SpecialWatchlist: Add an option to automatically reload the page when a filter was...
authorFlorian <florian.schmidt.stargatewissen@gmail.com>
Sat, 28 Nov 2015 15:10:33 +0000 (16:10 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Fri, 4 Dec 2015 15:48:22 +0000 (16:48 +0100)
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

includes/DefaultSettings.php
includes/Preferences.php
includes/specials/SpecialWatchlist.php
languages/i18n/en.json
languages/i18n/qqq.json
resources/Resources.php
resources/src/mediawiki.special/mediawiki.special.watchlist.js [new file with mode: 0644]

index edc54f2..9d93797 100644 (file)
@@ -4590,6 +4590,7 @@ $wgDefaultUserOptions = array(
        'watchlisthideown' => 0,
        'watchlisthidepatrolled' => 0,
        'watchlisthidecategorization' => 1,
+       'watchlistreloadautomatically' => 0,
        'watchmoves' => 0,
        'watchrollback' => 0,
        'wllimit' => 250,
index 096f8e3..c7ab9cd 100644 (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(
index 32d4552..34c44d4 100644 (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 ) )
                );
index 0092ada..a7f0923 100644 (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",
index dcf26b3..2319663 100644 (file)
        "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}}.",
index 0eb5118..aba5ce8 100644 (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(
diff --git a/resources/src/mediawiki.special/mediawiki.special.watchlist.js b/resources/src/mediawiki.special/mediawiki.special.watchlist.js
new file mode 100644 (file)
index 0000000..a35f4d1
--- /dev/null
@@ -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();
+       } );
+
+} );