r105616 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105615‎ | r105616 | r105617 >
Date:23:48, 8 December 2011
Author:neilk
Status:ok
Tags:
Comment:
break dependencies on mw.Utilities.js (will be moving some libs into core)
Modified paths:
  • /trunk/extensions/UploadWizard/resources/mw.Api.edit.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.Api.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.Api.titleblacklist.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.ApiQueryImageInfo.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.ConfirmCloseWindow.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.Feedback.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.Title.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizard.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardDeed.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardLicenseInput.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardUpload.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardUtil.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.Utilities.js (deleted) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/resources/mw.Utilities.js
@@ -1,33 +0,0 @@
2 -( function() {
3 -
4 - /**
5 - * Check if a value is null, undefined, or the empty string.
6 - *
7 - * @param {mixed} v Variable to be checked
8 - * @return {boolean}
9 - */
10 - mw.isEmpty = function( v ) {
11 - return ! mw.isDefined( v ) || v === null || v === '';
12 - };
13 -
14 - /**
15 - * Check if something is defined
16 - * @param {mixed} v
17 - * @return {boolean}
18 - */
19 - mw.isDefined = function( v ) {
20 - return typeof v !== 'undefined';
21 - };
22 -
23 -
24 - /**
25 - * Upper-case the first letter of a string.
26 - * @param {string}
27 - * @return {string} with first letter uppercased.
28 - */
29 - mw.ucfirst = function( s ) {
30 - return s.substring(0,1).toUpperCase() + s.substr(1);
31 - };
32 -
33 -
34 -} )();
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDeed.js
@@ -1,7 +1,7 @@
22 /**
33 * Sort of an abstract class for deeds
44 */
5 -( function( $j ) {
 5+( function( $j, undefined ) {
66
77 mw.UploadWizardDeed = function() {
88 var _this = this;
@@ -354,7 +354,7 @@
355355 mw.UploadWizardDeedChooser = function( selector, deeds, uploads, api ) {
356356 var _this = this;
357357 _this.$selector = $j( selector );
358 - _this.uploads = mw.isDefined( uploads ) ? uploads : [];
 358+ _this.uploads = uploads === undefined ? [] : uploads;
359359
360360
361361 _this.$errorEl = $j( '<div class="mwe-error"></div>' );
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardLicenseInput.js
@@ -22,9 +22,9 @@
2323
2424 _this.api = api;
2525
26 - if ( ! ( mw.isDefined(config.type)
27 - && mw.isDefined( config.defaults )
28 - && ( mw.isDefined( config.licenses ) || mw.isDefined( config.licenseGroups ) ) ) ) {
 26+ if ( config.type === undefined
 27+ || config.defaults === undefined
 28+ || ( config.licenses === undefined && config.licenseGroups === undefined ) ) {
2929 throw new Error( 'improper initialization' );
3030 }
3131
@@ -42,10 +42,10 @@
4343 _this.inputs = [];
4444
4545 // create inputs and licenses from config
46 - if ( mw.isDefined( config['licenseGroups'] ) ) {
 46+ if ( config['licenseGroups'] === undefined ) {
 47+ _this.createInputs( _this.$selector, config );
 48+ } else {
4749 _this.createGroupedInputs( _this.$selector, config['licenseGroups'] );
48 - } else {
49 - _this.createInputs( _this.$selector, config );
5050 }
5151
5252 // set values of the whole license input
@@ -83,7 +83,10 @@
8484 $j.each( configGroups, function( i, group ) {
8585 var $body, $toggler;
8686 var $group = $j( '<div></div>' ).addClass( 'mwe-upwiz-deed-license-group' );
87 - if ( mw.isDefined( group['head'] ) ) {
 87+ if ( group['head'] === undefined ) {
 88+ // if there is no header, just append licenses to the group div.
 89+ $body = $group;
 90+ } else {
8891 // if there is a header, make a toggle-to-expand div and append inputs there.
8992 var $head = $j( '<div></div>' ).append(
9093 $j( '<a>' )
@@ -92,11 +95,9 @@
9396 );
9497 $body = $j( '<div></div>' ).addClass( 'mwe-upwiz-toggler-content' ).css( { 'marginBottom': '1em' } );
9598 $toggler = $group.append( $head, $body ).collapseToggle();
96 - } else {
97 - // if there is no header, just append licenses to the group div.
98 - $body = $group;
 99+
99100 }
100 - if ( mw.isDefined( group['subhead'] ) ) {
 101+ if ( group['subhead'] !== undefined ) {
101102 $body.append( $j( '<div></div>' ).addClass( 'mwe-upwiz-deed-license-group-subhead' ).msg( group.subhead, _this.count ) );
102103 }
103104 var $licensesDiv = $j( '<div></div>' ).addClass( 'mwe-upwiz-deed-license' );
@@ -124,14 +125,14 @@
125126 */
126127 createInputs: function( $el, config, $groupToggler ) {
127128 var _this = this;
128 - if ( !mw.isDefined( config['licenses'] && typeof config['licenses'] === 'object' ) ) {
 129+ if ( config['licenses'] === undefined || typeof config['licenses'] !== 'object' ) {
129130 throw new Error( "improper license config" );
130131 }
131132 $j.each( config['licenses'], function( i, licenseName ) {
132 - if ( mw.isDefined( mw.UploadWizard.config.licenses[licenseName] ) ) {
 133+ if ( mw.UploadWizard.config.licenses[licenseName] !== undefined ) {
133134 var license = { name: licenseName, props: mw.UploadWizard.config.licenses[licenseName] };
134135
135 - var templates = mw.isDefined( license.props['templates'] ) ? license.props.templates.slice(0) : [ license.name ];
 136+ var templates = license.props['templates'] === undefined ? [ license.name ] : license.props.templates.slice(0);
136137
137138 var $input = _this.createInputElement( templates, config );
138139 _this.inputs.push( $input );
@@ -165,12 +166,12 @@
166167 * @return {String} of wikitext
167168 */
168169 createInputValueFromTemplateConfig: function( templates, config ) {
169 - if ( mw.isDefined( config['prependTemplates'] ) ) {
 170+ if ( config['prependTemplates'] !== undefined ) {
170171 $j.each( config['prependTemplates'], function( i, template ) {
171172 templates.unshift( template );
172173 } );
173174 }
174 - if ( mw.isDefined( config['filterTemplate'] ) ) {
 175+ if ( config['filterTemplate'] !== undefined ) {
175176 templates.unshift( config['filterTemplate'] );
176177 templates = [ templates.join( '|' ) ];
177178 }
@@ -214,14 +215,14 @@
215216 * @return {jQuery} wrapped label referring to that input, with appropriate HTML, decorations, etc.
216217 */
217218 createInputElementLabel: function( license, $input ) {
218 - var messageKey = mw.isDefined( license.props['msg'] ) ? license.props.msg : '[missing msg for ' + license.name + ']';
 219+ var messageKey = license.props['msg'] === undefined ? '[missing msg for ' + license.name + ']' : license.props.msg;
219220
220221 // The URL is optional, but if the message includes it as $2, we surface the fact
221222 // that it's misisng.
222 - var licenseURL = mw.isDefined( license.props['url'] ) ? license.props.url : '#missing license URL';
 223+ var licenseURL = license.props['url'] === undefined ? '#missing license URL' : license.props.url;
223224 var licenseLink = $j( '<a>' ).attr( { 'target': '_blank', 'href': licenseURL } );
224225 var $icons = $j( '<span></span>' );
225 - if ( mw.isDefined( license.props['icons'] ) ) {
 226+ if ( license.props['icons'] !== undefined ) {
226227 $j.each( license.props.icons, function( i, icon ) {
227228 $icons.append( $j( '<span></span>' ).addClass( 'mwe-upwiz-license-icon mwe-upwiz-' + icon + '-icon' ) );
228229 } );
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js
@@ -4,6 +4,8 @@
55 * @param div to insert file interface
66 * @param providedFile a File object that this ui component should use (optional)
77 */
 8+( function( mw, $j, undefined ) {
 9+
810 mw.UploadWizardUploadInterface = function( upload, filesDiv, providedFile ) {
911 var _this = this;
1012
@@ -175,7 +177,7 @@
176178 * @param Array args: array of values, in case any need to be fed to the image.
177179 */
178180 setStatus: function( msgKey, args ) {
179 - if ( !mw.isDefined( args ) ) {
 181+ if ( args === undefined ) {
180182 args = [];
181183 }
182184 // get the status line for our upload
@@ -569,3 +571,5 @@
570572 }
571573
572574 };
 575+
 576+}) ( window.mediaWiki, jQuery );
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardUtil.js
@@ -1,6 +1,7 @@
22 /**
33 * Miscellaneous utilities
44 */
 5+( function ( mw, $j, undefined ) {
56 mw.UploadWizardUtil = {
67
78 /**
@@ -62,7 +63,7 @@
6364 * @return {String} basename
6465 */
6566 getBasename: function( path ) {
66 - if ( !mw.isDefined( path ) || path === null ) {
 67+ if ( path === undefined || path === null ) {
6768 return '';
6869 }
6970
@@ -84,5 +85,4 @@
8586
8687
8788 };
88 -
89 -
 89+}) ( window.mediaWiki, jQuery );
Index: trunk/extensions/UploadWizard/resources/mw.Api.js
@@ -1,8 +1,6 @@
22 /* mw.Api objects represent the API of a particular MediaWiki server. */
33
4 -// dependencies: [ mw ]
5 -
6 -( function( mw, $j ) {
 4+( function( mw, $j, undefined ) {
75
86 /**
97 * Represents the API of a particular MediaWiki server.
@@ -21,7 +19,7 @@
2220 mw.Api = function( options ) {
2321
2422 // make sure we at least have a URL endpoint for the API
25 - if ( ! mw.isDefined( options.url ) ) {
 23+ if ( options.url === undefined ) {
2624 throw new Error( 'Configuration error - needs url property' );
2725 }
2826
@@ -133,10 +131,10 @@
134132
135133 /* success just means 200 OK; also check for output and API errors */
136134 ajaxOptions.success = function( result ) {
137 - if ( mw.isEmpty( result ) ) {
 135+ if ( result === undefined || result === null || result === '' ) {
138136 ajaxOptions.err( "ok-but-empty", "OK response but empty result (check HTTP headers?)" );
139137 } else if ( result.error ) {
140 - var code = mw.isDefined( result.error.code ) ? result.error.code : "unknown";
 138+ var code = result.error.code === undefined ? 'unknown' : result.error.code;
141139 ajaxOptions.err( code, result );
142140 } else {
143141 ajaxOptions.ok( result );
Index: trunk/extensions/UploadWizard/resources/mw.Title.js
@@ -34,7 +34,7 @@
3535 /**
3636 * Constructor
3737 */
38 -( function( $j, mw ) {
 38+( function( $j, mw, undefined ) {
3939 mw.Title = function( title, namespace ) {
4040 // integer namespace id
4141 var ns = 0;
@@ -54,7 +54,7 @@
5555 * @return {String}
5656 */
5757 function clean( s ) {
58 - if ( mw.isDefined( s ) ) {
 58+ if ( s !== undefined ) {
5959 return s.replace( /[\x00-\x1f\x23\x3a\x3c\x3e\x5b\x5d\x7b\x7c\x7d\x7f\s]+/g, '_' );
6060 }
6161 }
@@ -153,7 +153,7 @@
154154 * @return {mw.Title} this
155155 */
156156 this.setNamespace = function( s ) {
157 - if ( !mw.isDefined( mw.Title.ns[s] ) ) {
 157+ if ( mw.Title.ns[s] === undefined ) {
158158 throw new Error( 'unrecognized namespace: ' + s );
159159 }
160160 return this.setNamespaceById( mw.Title.ns[s] );
@@ -220,7 +220,7 @@
221221 throw new Error( "couldn't parse title '" + title + "'" );
222222 }
223223
224 - if ( mw.isDefined( namespace ) ) {
 224+ if ( namespace !== undefined ) {
225225 this.setNamespace( namespace );
226226 }
227227
@@ -245,5 +245,15 @@
246246 'category': 14,
247247 'category_talk': 15
248248 };
 249+
 250+ /**
 251+ * Upper-case the first letter of a string.
 252+ * @param {string}
 253+ * @return {string} with first letter uppercased.
 254+ */
 255+ mw.ucfirst = function( s ) {
 256+ return s.substring(0,1).toUpperCase() + s.substr(1);
 257+ };
 258+
249259 } )( jQuery, mediaWiki );
250260
Index: trunk/extensions/UploadWizard/resources/mw.Api.titleblacklist.js
@@ -12,7 +12,7 @@
1313 * @param {Function} optional callback to run if api error
1414 * @return ajax call object
1515 */
16 - isBlacklisted: function( title, callback, error ) {
 16+ isBlacklisted: function( title, callback, err ) {
1717 var params = {
1818 'action': 'titleblacklist',
1919 'tbaction': 'create',
@@ -40,8 +40,6 @@
4141 }
4242 };
4343
44 - var err = mw.isDefined( error ) ? error : undefined;
45 -
4644 return this.get( params, ok, err );
4745
4846 }
Index: trunk/extensions/UploadWizard/resources/mw.Feedback.js
@@ -1,4 +1,4 @@
2 -( function( mw, $ ) {
 2+( function( mw, $, undefined ) {
33
44 /**
55 * Thingy for collecting user feedback on a wiki page
@@ -106,7 +106,7 @@
107107 this.displaySubmitting();
108108
109109 var ok = function( result ) {
110 - if ( mw.isDefined( result.edit ) ) {
 110+ if ( result.edit !== undefined ) {
111111 if ( result.edit.result === 'Success' ) {
112112 _this.$dialog.dialog( 'close' ); // edit complete, close dialog box
113113 } else {
Index: trunk/extensions/UploadWizard/resources/mw.Api.edit.js
@@ -1,6 +1,6 @@
22 // library to assist with edits
33
4 -( function( mw, $ ) {
 4+( function( mw, $, undefined ) {
55
66 // cached token so we don't have to keep fetching new ones for every single post
77 var cachedToken = null;
@@ -72,7 +72,7 @@
7373 return false;
7474 }
7575 } );
76 - if ( mw.isDefined( token ) ) {
 76+ if ( token !== undefined ) {
7777 cachedToken = token;
7878 tokenCallback( token );
7979 } else {
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js
@@ -2,7 +2,7 @@
33 * Object that reperesents the entire multi-step Upload Wizard
44 */
55
6 -( function( $j ) {
 6+( function( mw, $j, undefined ) {
77
88 mw.UploadWizard = function( config ) {
99
@@ -30,38 +30,6 @@
3131 stepNames: [ 'tutorial', 'file', 'deeds', 'details', 'thanks' ],
3232 currentStepName: undefined,
3333
34 - /*
35 - // list possible upload handlers in order of preference
36 - // these should all be in the mw.* namespace
37 - // hardcoded for now. maybe some registry system might work later, like, all
38 - // things which subclass off of UploadHandler
39 - uploadHandlers: [
40 - 'FirefoggUploadHandler',
41 - 'XhrUploadHandler',
42 - 'ApiIframeUploadHandler',
43 - 'SimpleUploadHandler',
44 - 'NullUploadHandler'
45 - ],
46 -
47 - * We can use various UploadHandlers based on the browser's capabilities. Let's pick one.
48 - * For example, the ApiUploadHandler should work just about everywhere, but XhrUploadHandler
49 - * allows for more fine-grained upload progress
50 - * @return valid JS upload handler class constructor function
51 - getUploadHandlerClass: function() {
52 - // return mw.MockUploadHandler;
53 - return mw.ApiUploadHandler;
54 - var _this = this;
55 - for ( var i = 0; i < uploadHandlers.length; i++ ) {
56 - var klass = mw[uploadHandlers[i]];
57 - if ( klass != undefined && klass.canRun( this.config )) {
58 - return klass;
59 - }
60 - }
61 - // this should never happen; NullUploadHandler should always work
62 - return null;
63 - },
64 - */
65 -
6634 /**
6735 * Reset the entire interface so we can upload more stuff
6836 * (depends on updateFileCounts to reset the interface when uploads go down to 0)
@@ -92,9 +60,8 @@
9361 // construct the message for the subheader
9462 $j( '#contentSub' ).append( $j( '<span style="margin-right: 0.5em;"></span>' ).msg( 'mwe-upwiz-subhead-message' ) );
9563 // feedback request
96 - if ( mw.isDefined( mw.UploadWizard.config['feedbackPage'] ) && mw.UploadWizard.config['feedbackPage'] !== '' ) {
97 - var feedback = new mw.Feedback( _this.api,
98 - new mw.Title( mw.UploadWizard.config['feedbackPage'] ) );
 64+ if ( mw.UploadWizard.config['feedbackPage'] !== undefined && mw.UploadWizard.config['feedbackPage'] !== '' ) {
 65+ var feedback = new mw.Feedback( _this.api, new mw.Title( mw.UploadWizard.config['feedbackPage'] ) );
9966 var feedbackLink = $j( '<span class="contentSubLink"></span>' ).msg( 'mwe-upwiz-feedback-prompt',
10067 function() {
10168 feedback.launch();
@@ -104,13 +71,13 @@
10572 $j( '#contentSub' ).append( feedbackLink );
10673 }
10774
108 - if ( mw.isDefined( mw.UploadWizard.config['bugList'] ) && mw.UploadWizard.config['bugList'] !== '' ) {
 75+ if ( mw.UploadWizard.config['bugList'] !== undefined && mw.UploadWizard.config['bugList'] !== '' ) {
10976 $j( '#contentSub' ).append( $j( '<span class="contentSubLink"></span>' ).msg( 'mwe-upwiz-subhead-bugs', $j( '<a></a>' ).attr( { href: mw.UploadWizard.config['bugList'], target: '_blank' } ) ) );
11077 }
111 - if ( mw.isDefined( mw.UploadWizard.config['translateHelp'] ) && mw.UploadWizard.config['translateHelp'] !== '' ) {
 78+ if ( mw.UploadWizard.config['translateHelp'] !== undefined && mw.UploadWizard.config['translateHelp'] !== '' ) {
11279 $j( '#contentSub' ).append( $j( '<span class="contentSubLink"></span>' ).msg( 'mwe-upwiz-subhead-translate', $j( '<a></a>' ).attr( { href: mw.UploadWizard.config['translateHelp'], target: '_blank' } ) ) );
11380 }
114 - if ( mw.isDefined( mw.UploadWizard.config['altUploadForm'] ) && mw.UploadWizard.config['altUploadForm'] !== '' ) {
 81+ if ( mw.UploadWizard.config['altUploadForm'] !== undefined && mw.UploadWizard.config['altUploadForm'] !== '' ) {
11582 // altUploadForm is expected to be a page title like 'Commons:Upload', so convert to URL
11683 var title;
11784 try {
@@ -217,7 +184,7 @@
218185
219186 // DETAILS div
220187 var finalizeDetails = function() {
221 - if ( mw.isDefined( _this.allowCloseWindow ) ) {
 188+ if ( _this.allowCloseWindow !== undefined ) {
222189 _this.allowCloseWindow();
223190 }
224191 _this.prefillThanksPage();
@@ -672,7 +639,7 @@
673640 selector = '.mwe-upwiz-file-next-some-failed';
674641 }
675642
676 - if ( allOk && mw.isDefined( allOkCallback ) ) {
 643+ if ( allOk && ( allOkCallback !== undefined ) ) {
677644 allOkCallback();
678645 } else {
679646 $j( '#mwe-upwiz-stepdiv-' + step + ' .mwe-upwiz-buttons' ).show().find( selector ).show();
@@ -739,12 +706,12 @@
740707 // fix various other pages that may have state
741708 $j( '#mwe-upwiz-thanks' ).html( '' );
742709
743 - if ( mw.isDefined( _this.deedChooser ) ) {
 710+ if ( _this.deedChooser !== undefined ) {
744711 _this.deedChooser.remove();
745712 }
746713
747714 // remove any blocks on closing the window
748 - if ( mw.isDefined( _this.allowCloseWindow ) ) {
 715+ if ( _this.allowCloseWindow !== undefined ) {
749716 _this.allowCloseWindow();
750717 }
751718
@@ -1007,8 +974,18 @@
1008975 }
1009976 };
1010977
1011 -} )( jQuery );
 978+/**
 979+ * Check if a value is null, undefined, or the empty string.
 980+ *
 981+ * @param {mixed} v Variable to be checked
 982+ * @return {boolean}
 983+ */
 984+mw.isEmpty = function( v ) {
 985+ return v === undefined || v === null || v === '';
 986+};
1012987
 988+} )( window.mediaWiki, jQuery );
 989+
1013990 ( function ( $j ) {
1014991
1015992 $j.fn.notify = function ( message ) {
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardUpload.js
@@ -5,7 +5,7 @@
66 * 'new' 'transporting' 'transported' 'metadata' 'stashed' 'details' 'submitting-details' 'complete' 'error'
77 * should fork this into two -- local and remote, e.g. filename
88 */
9 -( function( $j ) {
 9+( function( $j, undefined ) {
1010
1111 /**
1212 * Constructor for objects representing uploads. The workhorse of this entire extension.
@@ -118,7 +118,7 @@
119119 * Queue some warnings for possible later consumption
120120 */
121121 addWarning: function( code, info ) {
122 - if ( !mw.isDefined( this.warnings ) ) {
 122+ if ( this.warnings === undefined ) {
123123 this.warnings = [];
124124 }
125125 this.warnings.push( [ code, info ] );
@@ -354,7 +354,7 @@
355355
356356 // TODO check max upload size, alert user if too big
357357 this.transportWeight = this.file.size;
358 - if ( !mw.isDefined( this.imageinfo ) ) {
 358+ if ( this.imageinfo === undefined ) {
359359 this.imageinfo = {};
360360 }
361361
@@ -420,11 +420,11 @@
421421 * @param {Object} (as returned by jpegmeta)
422422 */
423423 extractMetadataFromJpegMeta: function( meta ) {
424 - if ( mw.isDefined( meta ) && meta !== null && typeof meta === 'object' ) {
425 - if ( !mw.isDefined( this.imageinfo ) ) {
 424+ if ( meta !== undefined && meta !== null && typeof meta === 'object' ) {
 425+ if ( this.imageinfo === undefined ) {
426426 this.imageinfo = {};
427427 }
428 - if ( !mw.isDefined( this.imageinfo.metadata ) ) {
 428+ if ( this.imageinfo.metadata === undefined ) {
429429 this.imageinfo.metadata = {};
430430 }
431431 if ( meta.tiff && meta.tiff.Orientation ) {
@@ -480,7 +480,7 @@
481481 for ( var key in imageinfo ) {
482482 // we get metadata as list of key-val pairs; convert to object for easier lookup. Assuming that EXIF fields are unique.
483483 if ( key == 'metadata' ) {
484 - if ( !mw.isDefined( _this.imageinfo.metadata ) ) {
 484+ if ( _this.imageinfo.metadata === undefined ) {
485485 _this.imageinfo.metadata = {};
486486 }
487487 if ( imageinfo.metadata && imageinfo.metadata.length ) {
@@ -527,7 +527,7 @@
528528 getStashImageInfo: function( callback, props, width, height ) {
529529 var _this = this;
530530
531 - if (!mw.isDefined( props ) ) {
 531+ if ( props === undefined ) {
532532 props = [];
533533 }
534534
@@ -537,14 +537,14 @@
538538 'siiprop': props.join( '|' )
539539 };
540540
541 - if ( mw.isDefined( width ) || mw.isDefined( height ) ) {
 541+ if ( width !== undefined || height !== undefined ) {
542542 if ( ! $j.inArray( 'url', props ) ) {
543543 props.push( 'url' );
544544 }
545 - if ( mw.isDefined( width ) ) {
 545+ if ( width !== undefined ) {
546546 params['siiurlwidth'] = width;
547547 }
548 - if ( mw.isDefined( height ) ) {
 548+ if ( height !== undefined ) {
549549 params['siiurlheight'] = height;
550550 }
551551 }
@@ -578,7 +578,7 @@
579579 */
580580 getImageInfo: function( callback, props, width, height ) {
581581 var _this = this;
582 - if (!mw.isDefined( props ) ) {
 582+ if ( props === undefined ) {
583583 props = [];
584584 }
585585 var requestedTitle = _this.title.getPrefixedText();
@@ -588,14 +588,14 @@
589589 'iiprop': props.join( '|' )
590590 };
591591
592 - if ( mw.isDefined( width ) || mw.isDefined( height ) ) {
 592+ if ( width !== undefined || height !== undefined ) {
593593 if ( ! $j.inArray( 'url', props ) ) {
594594 props.push( 'url' );
595595 }
596 - if ( mw.isDefined( width ) ) {
 596+ if ( width !== undefined ) {
597597 params['iiurlwidth'] = width;
598598 }
599 - if ( mw.isDefined( height ) ) {
 599+ if ( height !== undefined ) {
600600 params['iiurlheight'] = height;
601601 }
602602 }
@@ -663,7 +663,7 @@
664664 height = -1;
665665 }
666666
667 - if ( !mw.isDefined( _this.thumbnailPublishers[key] ) ) {
 667+ if ( _this.thumbnailPublishers[key] === undefined ) {
668668 var thumbnailPublisher = function( thumbnails ) {
669669 if ( thumbnails === null ) {
670670 // the api call failed somehow, no thumbnail data.
@@ -879,7 +879,7 @@
880880 }
881881 var constraints = {
882882 width: parseInt( width, 10 ),
883 - height: ( mw.isDefined( height ) ? parseInt( height, 10 ) : null )
 883+ height: ( height === undefined ? null : parseInt( height, 10 ) )
884884 };
885885
886886 return mw.canvas.isAvailable() ? this.getTransformedCanvasElement( image, constraints )
Index: trunk/extensions/UploadWizard/resources/mw.ConfirmCloseWindow.js
@@ -1,4 +1,4 @@
2 -( function( mw, $ ) {
 2+( function( mw, $, undefined ) {
33 /**
44 * Prevent the closing of a window with a confirm message (the onbeforeunload event seems to
55 * work in most browsers.)
@@ -18,7 +18,7 @@
1919 * @return closure execute this when you want to allow the user to close the window
2020 */
2121 mw.confirmCloseWindow = function( options ) {
22 - if ( ! mw.isDefined( options ) ) {
 22+ if ( options === undefined ) {
2323 options = {};
2424 }
2525
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js
@@ -11,6 +11,8 @@
1212 * @param API
1313 * @param containerDiv The div to put the interface into
1414 */
 15+( function( mw, $j, undefined ) {
 16+
1517 mw.UploadWizardDetails = function( upload, api, containerDiv ) {
1618
1719 var _this = this;
@@ -356,13 +358,13 @@
357359 } );
358360 }
359361 // make this a category picker
360 - var hiddenCats = mw.isDefined( mw.UploadWizard.config.autoCategories ) ? mw.UploadWizard.config.autoCategories : [];
361 - if ( mw.isDefined( mw.UploadWizard.config.autoCategory ) && mw.UploadWizard.config.autoCategory !== '' ) {
 362+ var hiddenCats = mw.UploadWizard.config.autoCategories === undefined ? [] : mw.UploadWizard.config.autoCategories;
 363+ if ( mw.UploadWizard.config.autoCategory !== undefined && mw.UploadWizard.config.autoCategory !== '' ) {
362364 hiddenCats.push( mw.UploadWizard.config.autoCategory );
363365 }
364366
365367 var missingCatsWikiText = null;
366 - if ( typeof mw.UploadWizard.config.missingCategoriesWikiText !== 'undefined'
 368+ if ( mw.UploadWizard.config.missingCategoriesWikiText !== undefined
367369 && mw.UploadWizard.config.missingCategoriesWikiText !== '' ) {
368370 missingCatsWikiText = mw.UploadWizard.config.missingCategoriesWikiText;
369371 }
@@ -373,7 +375,7 @@
374376 api: _this.upload.api,
375377 hiddenCats: hiddenCats,
376378 buttontext: gM( 'mwe-upwiz-categories-add' ),
377 - cats: mw.isDefined( mw.UploadWizard.config.defaultCategories ) ? mw.UploadWizard.config.defaultCategories : [],
 379+ cats: mw.UploadWizard.config.defaultCategories === undefined ? [] : mw.UploadWizard.config.defaultCategories,
378380 missingCatsWikiText: missingCatsWikiText
379381 } );
380382
@@ -397,7 +399,7 @@
398400
399401 // make sure title is valid
400402 var titleInputValid = $j( _this.titleInput ).data( 'valid' );
401 - if ( typeof titleInputValid == 'undefined' ) {
 403+ if ( titleInputValid === undefined ) {
402404 alert( "please wait, still checking the title for uniqueness..." );
403405 return false;
404406 }
@@ -500,7 +502,7 @@
501503 $errorEl.append( '&nbsp;&middot;&nbsp;' ).append( completeErrorLink );
502504
503505 // feedback request for titleblacklist
504 - if ( mw.isDefined( mw.UploadWizard.config['blacklistIssuesPage'] ) && mw.UploadWizard.config['blacklistIssuesPage'] !== '' ) {
 506+ if ( mw.UploadWizard.config['blacklistIssuesPage'] !== undefined && mw.UploadWizard.config['blacklistIssuesPage'] !== '' ) {
505507 var feedback = new mw.Feedback(
506508 _this.api,
507509 new mw.Title( mw.UploadWizard.config['blacklistIssuesPage'] )
@@ -539,15 +541,15 @@
540542 */
541543 addDescription: function( required, languageCode, allowRemove ) {
542544 var _this = this;
543 - if ( typeof required === 'undefined' ) {
 545+ if ( required === undefined ) {
544546 required = false;
545547 }
546548
547 - if ( typeof languageCode === 'undefined' ) {
 549+ if ( languageCode === undefined ) {
548550 languageCode = mw.LanguageUpWiz.UNKNOWN;
549551 }
550552
551 - if ( typeof allowRemove === 'undefined' ) {
 553+ if ( allowRemove === undefined ) {
552554 allowRemove = true;
553555 }
554556
@@ -648,7 +650,7 @@
649651 // if we don't have EXIF or other metadata, let's use "now"
650652 // XXX if we have FileAPI, it might be clever to look at file attrs, saved
651653 // in the upload object for use here later, perhaps
652 - if ( !mw.isDefined( dateObj ) ) {
 654+ if ( dateObj === undefined ) {
653655 dateObj = new Date();
654656 }
655657 dateStr = dateObj.getFullYear() + '-' + pad( dateObj.getMonth() + 1 ) + '-' + pad( dateObj.getDate() );
@@ -678,13 +680,13 @@
679681 if ( _this.upload.imageinfo.metadata ) {
680682 var m = _this.upload.imageinfo.metadata;
681683
682 - if ( mw.isDefined( m['gpslatitude'] ) ) {
 684+ if ( m['gpslatitude'] !== undefined ) {
683685 $j( _this.latInput ).val( m['gpslatitude'] );
684686 }
685 - if ( mw.isDefined( m['gpslongitude'] ) ) {
 687+ if ( m['gpslongitude'] !== undefined ) {
686688 $j( _this.lonInput ).val( m['gpslongitude'] );
687689 }
688 - if ( mw.isDefined( m['gpsaltitude'] ) ) {
 690+ if ( m['gpsaltitude'] !== undefined ) {
689691 $j( _this.altInput ).val( m['gpsaltitude'] );
690692 }
691693 }
@@ -848,7 +850,7 @@
849851 wikiText += "=={{int:license-header}}==\n";
850852 wikiText += deed.getLicenseWikiText() + "\n\n";
851853
852 - if ( mw.isDefined( mw.UploadWizard.config.autoWikiText ) ) {
 854+ if ( mw.UploadWizard.config.autoWikiText !== undefined ) {
853855 wikiText += mw.UploadWizard.config.autoWikiText;
854856 }
855857
@@ -856,7 +858,7 @@
857859 wikiText += _this.div.find( '.categoryInput' ).get(0).getWikiText() + "\n\n";
858860
859861 // sanitize wikitext if TextCleaner is defined (MediaWiki:TextCleaner.js)
860 - if ( typeof TextCleaner != 'undefined' && typeof TextCleaner.sanitizeWikiText == 'function' ) {
 862+ if ( typeof TextCleaner !== 'undefined' && typeof TextCleaner.sanitizeWikiText === 'function' ) {
861863 wikiText = TextCleaner.sanitizeWikiText( wikiText, true );
862864 }
863865
@@ -1009,3 +1011,5 @@
10101012 }
10111013
10121014 };
 1015+
 1016+}) ( window.mediaWiki, jQuery );
Index: trunk/extensions/UploadWizard/resources/mw.ApiQueryImageInfo.js
@@ -21,7 +21,7 @@
2222 'prop': 'imageinfo',
2323 'titles': title.toString()
2424 };
25 - if ( mw.isDefined( extraParams.width ) ) {
 25+ if ( extraParams.width !== undefined ) {
2626 params['iiurlwidth'] = extraParams.width;
2727 }
2828 params.iiprop = properties.join( '|' );

Status & tagging log