jenkins-bot has submitted this change and it was merged.

Change subject: Consistently use NS_CATEGORY / NS_FILE for namespace numbers
......................................................................


Consistently use NS_CATEGORY / NS_FILE for namespace numbers

This is what we use in PHP, this is what we use in mediawiki.Title,
and this is what I'm used to seeing. Replaced different variable names
and hardcoded numbers.

Change-Id: Ie6fa28f162d01ecbd0eefe0ef061d9340af12d4d
---
M resources/jquery/jquery.mwCoolCats.js
M resources/mw.UploadWizardDetails.js
M resources/mw.UploadWizardUpload.js
3 files changed, 17 insertions(+), 13 deletions(-)

Approvals:
  MarkTraceur: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/resources/jquery/jquery.mwCoolCats.js 
b/resources/jquery/jquery.mwCoolCats.js
index e549c66..f99e34e 100644
--- a/resources/jquery/jquery.mwCoolCats.js
+++ b/resources/jquery/jquery.mwCoolCats.js
@@ -14,7 +14,7 @@
 $.fn.mwCoolCats = function ( options ) {
 
        var defaults, settings, cx, seenCat, $container, $template,
-               catNsId = mw.config.get( 'wgNamespaceIds' ).category;
+               NS_CATEGORY = mw.config.get( 'wgNamespaceIds' ).category;
 
        /**
         * Get content from our text field, and attempt to insert it as a 
category.
@@ -33,7 +33,7 @@
                }
 
                text = $input.val();
-               title = mw.Title.newFromUserInput( text, catNsId );
+               title = mw.Title.newFromUserInput( text, NS_CATEGORY );
                if ( !title ) {
                        // This also checks for empty $input
                        $input.removeData( 'title' );
@@ -164,7 +164,7 @@
                        input = this;
 
                // Stripping out bad characters as necessary.
-               title = mw.Title.newFromUserInput( $( this ).val(), catNsId );
+               title = mw.Title.newFromUserInput( $( this ).val(), NS_CATEGORY 
);
                if ( !title ) {
                        return;
                }
@@ -172,13 +172,13 @@
 
                $( input ).data( 'request', settings.api.get( {
                        action: 'opensearch',
-                       namespace: catNsId,
+                       namespace: NS_CATEGORY,
                        limit: 10,
                        search: prefix
                } ).done( function ( res ) {
                        var c,
                                catList = res[1].map( function ( name ) {
-                                       return mw.Title.newFromText( name, 
catNsId ).getMainText();
+                                       return mw.Title.newFromText( name, 
NS_CATEGORY ).getMainText();
                                } );
 
                        for ( c in catList ) {
@@ -270,8 +270,12 @@
                this.getWikiText = getWikiText;
 
                // initialize with some categories, if so configured
-               $.each( settings.cats, function ( i, cat ) { insertCat( 
mw.Title.newFromText( cat, catNsId ) ); } );
-               $.each( settings.hiddenCats, function ( i, cat ) { insertCat( 
mw.Title.newFromText( cat, catNsId ), true ); } );
+               $.each( settings.cats, function ( i, cat ) {
+                       insertCat( mw.Title.newFromText( cat, NS_CATEGORY ) );
+               } );
+               $.each( settings.hiddenCats, function ( i, cat ) {
+                       insertCat( mw.Title.newFromText( cat, NS_CATEGORY ), 
true );
+               } );
 
                processInput();
 
diff --git a/resources/mw.UploadWizardDetails.js 
b/resources/mw.UploadWizardDetails.js
index 21116fd..6ff01ed 100644
--- a/resources/mw.UploadWizardDetails.js
+++ b/resources/mw.UploadWizardDetails.js
@@ -13,7 +13,7 @@
  */
 ( function ( mw, uw, $, OO ) {
 
-       var fileNsId = mw.config.get( 'wgNamespaceIds' ).file;
+       var NS_FILE = mw.config.get( 'wgNamespaceIds' ).file;
 
        mw.UploadWizardDetails = function ( upload, containerDiv ) {
                var descriptionAdderDiv, titleContainerDiv, $categoriesDiv,
@@ -452,8 +452,8 @@
         * @return {mw.Title|null}
         */
        mw.UploadWizardDetails.makeTitleInFileNS = function ( filename ) {
-               var mwTitle = mw.Title.newFromText( filename, fileNsId );
-               if ( mwTitle && mwTitle.getNamespaceId() !== fileNsId ) {
+               var mwTitle = mw.Title.newFromText( filename, NS_FILE );
+               if ( mwTitle && mwTitle.getNamespaceId() !== NS_FILE ) {
                        // Force file namespace
                        mwTitle = mw.Title.newFromText( 'File:' + filename );
                }
@@ -1664,7 +1664,7 @@
                                } else if ( warnings['bad-prefix'] ) {
                                        this.recoverFromError( this.titleId, 
mw.message( 'mwe-upwiz-error-title-senselessimagename' ).text(), 
'title-senselessimagename' );
                                } else if ( existingFile ) {
-                                       existingFileUrl = mw.config.get( 
'wgServer' ) + new mw.Title( existingFile, 6 ).getUrl();
+                                       existingFileUrl = mw.config.get( 
'wgServer' ) + new mw.Title( existingFile, NS_FILE ).getUrl();
                                        this.recoverFromError( this.titleId, 
mw.message( 'mwe-upwiz-api-warning-exists', existingFileUrl ).parse(), 
'api-warning-exists' );
                                } else if ( warnings.duplicate ) {
                                        this.recoverFromError( this.titleId, 
mw.message( 'mwe-upwiz-upload-error-duplicate' ).text(), 
'upload-error-duplicate' );
diff --git a/resources/mw.UploadWizardUpload.js 
b/resources/mw.UploadWizardUpload.js
index 602c5fc..3d1bbe6 100644
--- a/resources/mw.UploadWizardUpload.js
+++ b/resources/mw.UploadWizardUpload.js
@@ -7,7 +7,7 @@
  */
 ( function ( mw, $, OO ) {
 
-       var fileNsId = mw.config.get( 'wgNamespaceIds' ).file;
+       var NS_FILE = mw.config.get( 'wgNamespaceIds' ).file;
 
        /**
         * @class mw.UploadWizardUpload
@@ -290,7 +290,7 @@
                                        $a.addClass( 'new' );
                                        params = { action: 'edit', redlink: '1' 
};
                                }
-                               href = new mw.Title( filename, fileNsId 
).getUrl( params );
+                               href = new mw.Title( filename, NS_FILE 
).getUrl( params );
                                $a.attr( { href: href, target: '_blank' } );
                        } catch ( e ) {
                                // For example, if the file was revdeleted

-- 
To view, visit https://gerrit.wikimedia.org/r/239893
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie6fa28f162d01ecbd0eefe0ef061d9340af12d4d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Bartosz DziewoƄski <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to