SpecialWatchlist: Add an option to automatically reload the page when a filter was changed

The biggest negative point (as far as I can tell) with the change mentioned in the follow-up
is, that a user needs at least 3 clicks to change an option, which before it required only
one click. This option adds a new preference for the watchlist (which can be enabled/disabled
using Special:Preferences) which, if enabled, loads a new, tiny module with a script, that
listens on all input and select fields in the header form of Special:Watchlist. Whenever one
of these elements get changed, the watchlist form will be submitted automatically.

The default for this option is false (disabled).

Follow up: I3bcd27596c21aa4

Bug: T50615
Bug: T119322
Change-Id: Icab1a5143df24a06f468165421d40db8fa57e73c
This commit is contained in:
Florian 2015-11-28 16:10:33 +01:00 committed by Bartosz Dziewoński
parent 10703fae49
commit 5327e3db56
7 changed files with 34 additions and 1 deletions

View file

@ -4590,6 +4590,7 @@ $wgDefaultUserOptions = array(
'watchlisthideown' => 0,
'watchlisthidepatrolled' => 0,
'watchlisthidecategorization' => 1,
'watchlistreloadautomatically' => 0,
'watchmoves' => 0,
'watchrollback' => 0,
'wllimit' => 250,

View file

@ -1006,6 +1006,11 @@ class Preferences {
'section' => 'watchlist/advancedwatchlist',
'label-message' => 'tog-watchlisthideliu',
);
$defaultPreferences['watchlistreloadautomatically'] = array(
'type' => 'toggle',
'section' => 'watchlist/advancedwatchlist',
'label-message' => 'tog-watchlistreloadautomatically',
);
if ( $config->get( 'RCWatchCategoryMembership' ) ) {
$defaultPreferences['watchlisthidecategorization'] = array(

View file

@ -403,8 +403,15 @@ class SpecialWatchlist extends ChangesListSpecialPage {
*/
public function doHeader( $opts, $numRows ) {
$user = $this->getUser();
$out = $this->getOutput();
$this->getOutput()->addSubtitle(
// if the user wishes, that the watchlist is reloaded, whenever a filter changes,
// add the module for that
if ( $user->getBoolOption( 'watchlistreloadautomatically' ) ) {
$out->addModules( array( 'mediawiki.special.watchlist' ) );
}
$out->addSubtitle(
$this->msg( 'watchlistfor2', $user->getName() )
->rawParams( SpecialEditWatchlist::buildTools( null ) )
);

View file

@ -35,6 +35,7 @@
"tog-watchlisthidebots": "Hide bot edits from the watchlist",
"tog-watchlisthideminor": "Hide minor edits from the watchlist",
"tog-watchlisthideliu": "Hide edits by logged in users from the watchlist",
"tog-watchlistreloadautomatically": "Reload the watchlist automatically whenever a filter is changed (JavaScript required)",
"tog-watchlisthideanons": "Hide edits by anonymous users from the watchlist",
"tog-watchlisthidepatrolled": "Hide patrolled edits from the watchlist",
"tog-watchlisthidecategorization": "Hide categorization of pages",

View file

@ -209,6 +209,7 @@
"tog-watchlisthidebots": "[[Special:Preferences]], tab 'Watchlist'. Offers user to hide bot edits from watchlist. {{Gender}}\n\n{{Related|Preferences-watchlistrc-toggle}}",
"tog-watchlisthideminor": "[[Special:Preferences]], tab 'Watchlist'. Offers user to hide minor edits from watchlist. {{Gender}}\n\n{{Related|Preferences-watchlistrc-toggle}}",
"tog-watchlisthideliu": "Option in tab 'Watchlist' of [[Special:Preferences]]. {{Gender}}\n\n{{Related|Preferences-watchlistrc-toggle}}",
"tog-watchlistreloadautomatically": "[[Special:Preferences]], tab 'Watchlist'. Offers user to to automatically refresh the watchlist page, when a filter is changed.",
"tog-watchlisthideanons": "Option in tab 'Watchlist' of [[Special:Preferences]]. {{Gender}}\n\n{{Related|Preferences-watchlistrc-toggle}}",
"tog-watchlisthidepatrolled": "Option in Watchlist tab of [[Special:Preferences]]. {{Gender}}\n\n{{Related|Preferences-watchlistrc-toggle}}",
"tog-watchlisthidecategorization": "Option in Watchlist tab of [[Special:Preferences]]. Offers user to hide/show categorization of pages. Appears next to checkboxes with labels such as {{msg-mw|tog-watchlisthideminor}}.",

View file

@ -1834,6 +1834,9 @@ return array(
'mediawiki.util',
),
),
'mediawiki.special.watchlist' => array(
'scripts' => 'resources/src/mediawiki.special/mediawiki.special.watchlist.js',
),
'mediawiki.special.javaScriptTest' => array(
'scripts' => 'resources/src/mediawiki.special/mediawiki.special.javaScriptTest.js',
'messages' => array_merge( Skin::getSkinNameMessages(), array(

View file

@ -0,0 +1,15 @@
/*!
* JavaScript for Special:Watchlist
*
* This script is only loaded, if the user opt-in a setting in Special:Preferences,
* that the watchlist should be automatically reloaded, when a filter option is
* changed in the header form.
*/
jQuery( function ( $ ) {
// add a listener on all form elements in the header form
$( '#mw-watchlist-form input, #mw-watchlist-form select' ).on( 'change', function () {
// submit the form, when one of the input fields was changed
$( '#mw-watchlist-form' ).submit();
} );
} );