From: Florian Date: Sat, 28 Nov 2015 15:10:33 +0000 (+0100) Subject: SpecialWatchlist: Add an option to automatically reload the page when a filter was... X-Git-Tag: 1.31.0-rc.0~8821 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=5327e3db561cd5efc67d71302ec961a33acab38e;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index edc54f2722..9d93797298 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4590,6 +4590,7 @@ $wgDefaultUserOptions = array( 'watchlisthideown' => 0, 'watchlisthidepatrolled' => 0, 'watchlisthidecategorization' => 1, + 'watchlistreloadautomatically' => 0, 'watchmoves' => 0, 'watchrollback' => 0, 'wllimit' => 250, diff --git a/includes/Preferences.php b/includes/Preferences.php index 096f8e3100..c7ab9cddc9 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -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( diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 32d4552762..34c44d49b8 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -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 ) ) ); diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 0092ada6f2..a7f0923bdb 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -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", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index dcf26b3dbc..2319663a45 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -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}}.", diff --git a/resources/Resources.php b/resources/Resources.php index 0eb5118670..aba5ce8304 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -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( diff --git a/resources/src/mediawiki.special/mediawiki.special.watchlist.js b/resources/src/mediawiki.special/mediawiki.special.watchlist.js new file mode 100644 index 0000000000..a35f4d1064 --- /dev/null +++ b/resources/src/mediawiki.special/mediawiki.special.watchlist.js @@ -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(); + } ); + +} );