Merge "Use new isTalkPage/isTalkNamespace methods"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 19 Sep 2018 17:20:53 +0000 (17:20 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 19 Sep 2018 17:20:53 +0000 (17:20 +0000)
1  2 
resources/src/mediawiki.page.watch.ajax.js
resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
resources/src/mediawiki.special.watchlist/watchlist.js

@@@ -14,7 -14,7 +14,7 @@@
   * @class mw.plugin.page.watch.ajax
   * @singleton
   */
 -( function ( mw, $ ) {
 +( function () {
        var watch,
                // The name of the page to watch or unwatch
                title = mw.config.get( 'wgRelevantPageName' );
                                .done( function ( watchResponse ) {
                                        var message, otherAction = action === 'watch' ? 'unwatch' : 'watch';
  
-                                       if ( mwTitle.getNamespaceId() > 0 && mwTitle.getNamespaceId() % 2 === 1 ) {
+                                       if ( mwTitle.isTalkPage() ) {
                                                message = action === 'watch' ? 'addedwatchtext-talk' : 'removedwatchtext-talk';
                                        } else {
                                                message = action === 'watch' ? 'addedwatchtext' : 'removedwatchtext';
                } );
        } );
  
 -}( mediaWiki, jQuery ) );
 +}() );
@@@ -1,5 -1,5 +1,5 @@@
  /* eslint-disable no-restricted-properties */
 -( function ( mw, $ ) {
 +( function () {
  
        var byteLength = require( 'mediawiki.String' ).byteLength;
  
@@@ -75,8 -75,8 +75,8 @@@
                                        label: label || mw.msg( 'blanknamespace' ),
                                        description: '',
                                        identifiers: [
-                                               ( namespaceID < 0 || namespaceID % 2 === 0 ) ?
-                                                       'subject' : 'talk'
+                                               mw.Title.isTalkNamespace( namespaceID ) ?
+                                                       'talk' : 'subject'
                                        ],
                                        cssClass: 'mw-changeslist-ns-' + namespaceID
                                } );
                        this.filtersModel.getViewTrigger( view )
                );
        };
 -}( mediaWiki, jQuery ) );
 +}() );
@@@ -1,7 -1,7 +1,7 @@@
  /*!
   * JavaScript for Special:Watchlist
   */
 -( function ( mw, $, OO ) {
 +( function () {
        $( function () {
                var api = new mw.Api(), $progressBar, $resetForm = $( '#mw-watchlist-resetbutton' );
  
                                        $watchlistLine = $unwatchLink.closest( 'li, table' )
                                                .find( '[data-target-page]' ),
                                        pageTitle = $watchlistLine.data( 'targetPage' ),
-                                       isTalk = mw.Title.newFromText( pageTitle ).getNamespaceId() % 2 === 1;
+                                       isTalk = mw.Title.newFromText( pageTitle ).isTalkPage();
  
                                // Utility function for looping through each watchlist line that matches
                                // a certain page or its associated page (e.g. Talk)
                                function forEachMatchingTitle( title, callback ) {
  
                                        var titleObj = mw.Title.newFromText( title ),
-                                               pageNamespaceId = titleObj.getNamespaceId(),
-                                               isTalk = pageNamespaceId % 2 === 1,
-                                               associatedTitle = mw.Title.makeTitle( isTalk ? pageNamespaceId - 1 : pageNamespaceId + 1,
-                                                       titleObj.getMainText() ).getPrefixedText();
+                                               associatedTitleObj = titleObj.isTalkPage() ? titleObj.getSubjectPage() : titleObj.getTalkPage(),
+                                               associatedTitle = associatedTitleObj.getPrefixedText();
                                        $( '.mw-changeslist-line' ).each( function () {
                                                var $this = $( this ), $row, $unwatchLink;
  
                }
        } );
  
 -}( mediaWiki, jQuery, OO )
 -);
 +}() );