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 @@ |
2 | 2 | /** |
3 | 3 | * Sort of an abstract class for deeds |
4 | 4 | */ |
5 | | -( function( $j ) { |
| 5 | +( function( $j, undefined ) { |
6 | 6 | |
7 | 7 | mw.UploadWizardDeed = function() { |
8 | 8 | var _this = this; |
— | — | @@ -354,7 +354,7 @@ |
355 | 355 | mw.UploadWizardDeedChooser = function( selector, deeds, uploads, api ) { |
356 | 356 | var _this = this; |
357 | 357 | _this.$selector = $j( selector ); |
358 | | - _this.uploads = mw.isDefined( uploads ) ? uploads : []; |
| 358 | + _this.uploads = uploads === undefined ? [] : uploads; |
359 | 359 | |
360 | 360 | |
361 | 361 | _this.$errorEl = $j( '<div class="mwe-error"></div>' ); |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardLicenseInput.js |
— | — | @@ -22,9 +22,9 @@ |
23 | 23 | |
24 | 24 | _this.api = api; |
25 | 25 | |
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 ) ) { |
29 | 29 | throw new Error( 'improper initialization' ); |
30 | 30 | } |
31 | 31 | |
— | — | @@ -42,10 +42,10 @@ |
43 | 43 | _this.inputs = []; |
44 | 44 | |
45 | 45 | // 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 { |
47 | 49 | _this.createGroupedInputs( _this.$selector, config['licenseGroups'] ); |
48 | | - } else { |
49 | | - _this.createInputs( _this.$selector, config ); |
50 | 50 | } |
51 | 51 | |
52 | 52 | // set values of the whole license input |
— | — | @@ -83,7 +83,10 @@ |
84 | 84 | $j.each( configGroups, function( i, group ) { |
85 | 85 | var $body, $toggler; |
86 | 86 | 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 { |
88 | 91 | // if there is a header, make a toggle-to-expand div and append inputs there. |
89 | 92 | var $head = $j( '<div></div>' ).append( |
90 | 93 | $j( '<a>' ) |
— | — | @@ -92,11 +95,9 @@ |
93 | 96 | ); |
94 | 97 | $body = $j( '<div></div>' ).addClass( 'mwe-upwiz-toggler-content' ).css( { 'marginBottom': '1em' } ); |
95 | 98 | $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 | + |
99 | 100 | } |
100 | | - if ( mw.isDefined( group['subhead'] ) ) { |
| 101 | + if ( group['subhead'] !== undefined ) { |
101 | 102 | $body.append( $j( '<div></div>' ).addClass( 'mwe-upwiz-deed-license-group-subhead' ).msg( group.subhead, _this.count ) ); |
102 | 103 | } |
103 | 104 | var $licensesDiv = $j( '<div></div>' ).addClass( 'mwe-upwiz-deed-license' ); |
— | — | @@ -124,14 +125,14 @@ |
125 | 126 | */ |
126 | 127 | createInputs: function( $el, config, $groupToggler ) { |
127 | 128 | var _this = this; |
128 | | - if ( !mw.isDefined( config['licenses'] && typeof config['licenses'] === 'object' ) ) { |
| 129 | + if ( config['licenses'] === undefined || typeof config['licenses'] !== 'object' ) { |
129 | 130 | throw new Error( "improper license config" ); |
130 | 131 | } |
131 | 132 | $j.each( config['licenses'], function( i, licenseName ) { |
132 | | - if ( mw.isDefined( mw.UploadWizard.config.licenses[licenseName] ) ) { |
| 133 | + if ( mw.UploadWizard.config.licenses[licenseName] !== undefined ) { |
133 | 134 | var license = { name: licenseName, props: mw.UploadWizard.config.licenses[licenseName] }; |
134 | 135 | |
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); |
136 | 137 | |
137 | 138 | var $input = _this.createInputElement( templates, config ); |
138 | 139 | _this.inputs.push( $input ); |
— | — | @@ -165,12 +166,12 @@ |
166 | 167 | * @return {String} of wikitext |
167 | 168 | */ |
168 | 169 | createInputValueFromTemplateConfig: function( templates, config ) { |
169 | | - if ( mw.isDefined( config['prependTemplates'] ) ) { |
| 170 | + if ( config['prependTemplates'] !== undefined ) { |
170 | 171 | $j.each( config['prependTemplates'], function( i, template ) { |
171 | 172 | templates.unshift( template ); |
172 | 173 | } ); |
173 | 174 | } |
174 | | - if ( mw.isDefined( config['filterTemplate'] ) ) { |
| 175 | + if ( config['filterTemplate'] !== undefined ) { |
175 | 176 | templates.unshift( config['filterTemplate'] ); |
176 | 177 | templates = [ templates.join( '|' ) ]; |
177 | 178 | } |
— | — | @@ -214,14 +215,14 @@ |
215 | 216 | * @return {jQuery} wrapped label referring to that input, with appropriate HTML, decorations, etc. |
216 | 217 | */ |
217 | 218 | 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; |
219 | 220 | |
220 | 221 | // The URL is optional, but if the message includes it as $2, we surface the fact |
221 | 222 | // 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; |
223 | 224 | var licenseLink = $j( '<a>' ).attr( { 'target': '_blank', 'href': licenseURL } ); |
224 | 225 | var $icons = $j( '<span></span>' ); |
225 | | - if ( mw.isDefined( license.props['icons'] ) ) { |
| 226 | + if ( license.props['icons'] !== undefined ) { |
226 | 227 | $j.each( license.props.icons, function( i, icon ) { |
227 | 228 | $icons.append( $j( '<span></span>' ).addClass( 'mwe-upwiz-license-icon mwe-upwiz-' + icon + '-icon' ) ); |
228 | 229 | } ); |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js |
— | — | @@ -4,6 +4,8 @@ |
5 | 5 | * @param div to insert file interface |
6 | 6 | * @param providedFile a File object that this ui component should use (optional) |
7 | 7 | */ |
| 8 | +( function( mw, $j, undefined ) { |
| 9 | + |
8 | 10 | mw.UploadWizardUploadInterface = function( upload, filesDiv, providedFile ) { |
9 | 11 | var _this = this; |
10 | 12 | |
— | — | @@ -175,7 +177,7 @@ |
176 | 178 | * @param Array args: array of values, in case any need to be fed to the image. |
177 | 179 | */ |
178 | 180 | setStatus: function( msgKey, args ) { |
179 | | - if ( !mw.isDefined( args ) ) { |
| 181 | + if ( args === undefined ) { |
180 | 182 | args = []; |
181 | 183 | } |
182 | 184 | // get the status line for our upload |
— | — | @@ -569,3 +571,5 @@ |
570 | 572 | } |
571 | 573 | |
572 | 574 | }; |
| 575 | + |
| 576 | +}) ( window.mediaWiki, jQuery ); |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardUtil.js |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | /** |
3 | 3 | * Miscellaneous utilities |
4 | 4 | */ |
| 5 | +( function ( mw, $j, undefined ) { |
5 | 6 | mw.UploadWizardUtil = { |
6 | 7 | |
7 | 8 | /** |
— | — | @@ -62,7 +63,7 @@ |
63 | 64 | * @return {String} basename |
64 | 65 | */ |
65 | 66 | getBasename: function( path ) { |
66 | | - if ( !mw.isDefined( path ) || path === null ) { |
| 67 | + if ( path === undefined || path === null ) { |
67 | 68 | return ''; |
68 | 69 | } |
69 | 70 | |
— | — | @@ -84,5 +85,4 @@ |
85 | 86 | |
86 | 87 | |
87 | 88 | }; |
88 | | - |
89 | | - |
| 89 | +}) ( window.mediaWiki, jQuery ); |
Index: trunk/extensions/UploadWizard/resources/mw.Api.js |
— | — | @@ -1,8 +1,6 @@ |
2 | 2 | /* mw.Api objects represent the API of a particular MediaWiki server. */ |
3 | 3 | |
4 | | -// dependencies: [ mw ] |
5 | | - |
6 | | -( function( mw, $j ) { |
| 4 | +( function( mw, $j, undefined ) { |
7 | 5 | |
8 | 6 | /** |
9 | 7 | * Represents the API of a particular MediaWiki server. |
— | — | @@ -21,7 +19,7 @@ |
22 | 20 | mw.Api = function( options ) { |
23 | 21 | |
24 | 22 | // make sure we at least have a URL endpoint for the API |
25 | | - if ( ! mw.isDefined( options.url ) ) { |
| 23 | + if ( options.url === undefined ) { |
26 | 24 | throw new Error( 'Configuration error - needs url property' ); |
27 | 25 | } |
28 | 26 | |
— | — | @@ -133,10 +131,10 @@ |
134 | 132 | |
135 | 133 | /* success just means 200 OK; also check for output and API errors */ |
136 | 134 | ajaxOptions.success = function( result ) { |
137 | | - if ( mw.isEmpty( result ) ) { |
| 135 | + if ( result === undefined || result === null || result === '' ) { |
138 | 136 | ajaxOptions.err( "ok-but-empty", "OK response but empty result (check HTTP headers?)" ); |
139 | 137 | } 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; |
141 | 139 | ajaxOptions.err( code, result ); |
142 | 140 | } else { |
143 | 141 | ajaxOptions.ok( result ); |
Index: trunk/extensions/UploadWizard/resources/mw.Title.js |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | /** |
36 | 36 | * Constructor |
37 | 37 | */ |
38 | | -( function( $j, mw ) { |
| 38 | +( function( $j, mw, undefined ) { |
39 | 39 | mw.Title = function( title, namespace ) { |
40 | 40 | // integer namespace id |
41 | 41 | var ns = 0; |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | * @return {String} |
56 | 56 | */ |
57 | 57 | function clean( s ) { |
58 | | - if ( mw.isDefined( s ) ) { |
| 58 | + if ( s !== undefined ) { |
59 | 59 | return s.replace( /[\x00-\x1f\x23\x3a\x3c\x3e\x5b\x5d\x7b\x7c\x7d\x7f\s]+/g, '_' ); |
60 | 60 | } |
61 | 61 | } |
— | — | @@ -153,7 +153,7 @@ |
154 | 154 | * @return {mw.Title} this |
155 | 155 | */ |
156 | 156 | this.setNamespace = function( s ) { |
157 | | - if ( !mw.isDefined( mw.Title.ns[s] ) ) { |
| 157 | + if ( mw.Title.ns[s] === undefined ) { |
158 | 158 | throw new Error( 'unrecognized namespace: ' + s ); |
159 | 159 | } |
160 | 160 | return this.setNamespaceById( mw.Title.ns[s] ); |
— | — | @@ -220,7 +220,7 @@ |
221 | 221 | throw new Error( "couldn't parse title '" + title + "'" ); |
222 | 222 | } |
223 | 223 | |
224 | | - if ( mw.isDefined( namespace ) ) { |
| 224 | + if ( namespace !== undefined ) { |
225 | 225 | this.setNamespace( namespace ); |
226 | 226 | } |
227 | 227 | |
— | — | @@ -245,5 +245,15 @@ |
246 | 246 | 'category': 14, |
247 | 247 | 'category_talk': 15 |
248 | 248 | }; |
| 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 | + |
249 | 259 | } )( jQuery, mediaWiki ); |
250 | 260 | |
Index: trunk/extensions/UploadWizard/resources/mw.Api.titleblacklist.js |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | * @param {Function} optional callback to run if api error |
14 | 14 | * @return ajax call object |
15 | 15 | */ |
16 | | - isBlacklisted: function( title, callback, error ) { |
| 16 | + isBlacklisted: function( title, callback, err ) { |
17 | 17 | var params = { |
18 | 18 | 'action': 'titleblacklist', |
19 | 19 | 'tbaction': 'create', |
— | — | @@ -40,8 +40,6 @@ |
41 | 41 | } |
42 | 42 | }; |
43 | 43 | |
44 | | - var err = mw.isDefined( error ) ? error : undefined; |
45 | | - |
46 | 44 | return this.get( params, ok, err ); |
47 | 45 | |
48 | 46 | } |
Index: trunk/extensions/UploadWizard/resources/mw.Feedback.js |
— | — | @@ -1,4 +1,4 @@ |
2 | | -( function( mw, $ ) { |
| 2 | +( function( mw, $, undefined ) { |
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Thingy for collecting user feedback on a wiki page |
— | — | @@ -106,7 +106,7 @@ |
107 | 107 | this.displaySubmitting(); |
108 | 108 | |
109 | 109 | var ok = function( result ) { |
110 | | - if ( mw.isDefined( result.edit ) ) { |
| 110 | + if ( result.edit !== undefined ) { |
111 | 111 | if ( result.edit.result === 'Success' ) { |
112 | 112 | _this.$dialog.dialog( 'close' ); // edit complete, close dialog box |
113 | 113 | } else { |
Index: trunk/extensions/UploadWizard/resources/mw.Api.edit.js |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | // library to assist with edits |
3 | 3 | |
4 | | -( function( mw, $ ) { |
| 4 | +( function( mw, $, undefined ) { |
5 | 5 | |
6 | 6 | // cached token so we don't have to keep fetching new ones for every single post |
7 | 7 | var cachedToken = null; |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | return false; |
74 | 74 | } |
75 | 75 | } ); |
76 | | - if ( mw.isDefined( token ) ) { |
| 76 | + if ( token !== undefined ) { |
77 | 77 | cachedToken = token; |
78 | 78 | tokenCallback( token ); |
79 | 79 | } else { |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | * Object that reperesents the entire multi-step Upload Wizard |
4 | 4 | */ |
5 | 5 | |
6 | | -( function( $j ) { |
| 6 | +( function( mw, $j, undefined ) { |
7 | 7 | |
8 | 8 | mw.UploadWizard = function( config ) { |
9 | 9 | |
— | — | @@ -30,38 +30,6 @@ |
31 | 31 | stepNames: [ 'tutorial', 'file', 'deeds', 'details', 'thanks' ], |
32 | 32 | currentStepName: undefined, |
33 | 33 | |
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 | | - |
66 | 34 | /** |
67 | 35 | * Reset the entire interface so we can upload more stuff |
68 | 36 | * (depends on updateFileCounts to reset the interface when uploads go down to 0) |
— | — | @@ -92,9 +60,8 @@ |
93 | 61 | // construct the message for the subheader |
94 | 62 | $j( '#contentSub' ).append( $j( '<span style="margin-right: 0.5em;"></span>' ).msg( 'mwe-upwiz-subhead-message' ) ); |
95 | 63 | // 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'] ) ); |
99 | 66 | var feedbackLink = $j( '<span class="contentSubLink"></span>' ).msg( 'mwe-upwiz-feedback-prompt', |
100 | 67 | function() { |
101 | 68 | feedback.launch(); |
— | — | @@ -104,13 +71,13 @@ |
105 | 72 | $j( '#contentSub' ).append( feedbackLink ); |
106 | 73 | } |
107 | 74 | |
108 | | - if ( mw.isDefined( mw.UploadWizard.config['bugList'] ) && mw.UploadWizard.config['bugList'] !== '' ) { |
| 75 | + if ( mw.UploadWizard.config['bugList'] !== undefined && mw.UploadWizard.config['bugList'] !== '' ) { |
109 | 76 | $j( '#contentSub' ).append( $j( '<span class="contentSubLink"></span>' ).msg( 'mwe-upwiz-subhead-bugs', $j( '<a></a>' ).attr( { href: mw.UploadWizard.config['bugList'], target: '_blank' } ) ) ); |
110 | 77 | } |
111 | | - if ( mw.isDefined( mw.UploadWizard.config['translateHelp'] ) && mw.UploadWizard.config['translateHelp'] !== '' ) { |
| 78 | + if ( mw.UploadWizard.config['translateHelp'] !== undefined && mw.UploadWizard.config['translateHelp'] !== '' ) { |
112 | 79 | $j( '#contentSub' ).append( $j( '<span class="contentSubLink"></span>' ).msg( 'mwe-upwiz-subhead-translate', $j( '<a></a>' ).attr( { href: mw.UploadWizard.config['translateHelp'], target: '_blank' } ) ) ); |
113 | 80 | } |
114 | | - if ( mw.isDefined( mw.UploadWizard.config['altUploadForm'] ) && mw.UploadWizard.config['altUploadForm'] !== '' ) { |
| 81 | + if ( mw.UploadWizard.config['altUploadForm'] !== undefined && mw.UploadWizard.config['altUploadForm'] !== '' ) { |
115 | 82 | // altUploadForm is expected to be a page title like 'Commons:Upload', so convert to URL |
116 | 83 | var title; |
117 | 84 | try { |
— | — | @@ -217,7 +184,7 @@ |
218 | 185 | |
219 | 186 | // DETAILS div |
220 | 187 | var finalizeDetails = function() { |
221 | | - if ( mw.isDefined( _this.allowCloseWindow ) ) { |
| 188 | + if ( _this.allowCloseWindow !== undefined ) { |
222 | 189 | _this.allowCloseWindow(); |
223 | 190 | } |
224 | 191 | _this.prefillThanksPage(); |
— | — | @@ -672,7 +639,7 @@ |
673 | 640 | selector = '.mwe-upwiz-file-next-some-failed'; |
674 | 641 | } |
675 | 642 | |
676 | | - if ( allOk && mw.isDefined( allOkCallback ) ) { |
| 643 | + if ( allOk && ( allOkCallback !== undefined ) ) { |
677 | 644 | allOkCallback(); |
678 | 645 | } else { |
679 | 646 | $j( '#mwe-upwiz-stepdiv-' + step + ' .mwe-upwiz-buttons' ).show().find( selector ).show(); |
— | — | @@ -739,12 +706,12 @@ |
740 | 707 | // fix various other pages that may have state |
741 | 708 | $j( '#mwe-upwiz-thanks' ).html( '' ); |
742 | 709 | |
743 | | - if ( mw.isDefined( _this.deedChooser ) ) { |
| 710 | + if ( _this.deedChooser !== undefined ) { |
744 | 711 | _this.deedChooser.remove(); |
745 | 712 | } |
746 | 713 | |
747 | 714 | // remove any blocks on closing the window |
748 | | - if ( mw.isDefined( _this.allowCloseWindow ) ) { |
| 715 | + if ( _this.allowCloseWindow !== undefined ) { |
749 | 716 | _this.allowCloseWindow(); |
750 | 717 | } |
751 | 718 | |
— | — | @@ -1007,8 +974,18 @@ |
1008 | 975 | } |
1009 | 976 | }; |
1010 | 977 | |
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 | +}; |
1012 | 987 | |
| 988 | +} )( window.mediaWiki, jQuery ); |
| 989 | + |
1013 | 990 | ( function ( $j ) { |
1014 | 991 | |
1015 | 992 | $j.fn.notify = function ( message ) { |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardUpload.js |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * 'new' 'transporting' 'transported' 'metadata' 'stashed' 'details' 'submitting-details' 'complete' 'error' |
7 | 7 | * should fork this into two -- local and remote, e.g. filename |
8 | 8 | */ |
9 | | -( function( $j ) { |
| 9 | +( function( $j, undefined ) { |
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Constructor for objects representing uploads. The workhorse of this entire extension. |
— | — | @@ -118,7 +118,7 @@ |
119 | 119 | * Queue some warnings for possible later consumption |
120 | 120 | */ |
121 | 121 | addWarning: function( code, info ) { |
122 | | - if ( !mw.isDefined( this.warnings ) ) { |
| 122 | + if ( this.warnings === undefined ) { |
123 | 123 | this.warnings = []; |
124 | 124 | } |
125 | 125 | this.warnings.push( [ code, info ] ); |
— | — | @@ -354,7 +354,7 @@ |
355 | 355 | |
356 | 356 | // TODO check max upload size, alert user if too big |
357 | 357 | this.transportWeight = this.file.size; |
358 | | - if ( !mw.isDefined( this.imageinfo ) ) { |
| 358 | + if ( this.imageinfo === undefined ) { |
359 | 359 | this.imageinfo = {}; |
360 | 360 | } |
361 | 361 | |
— | — | @@ -420,11 +420,11 @@ |
421 | 421 | * @param {Object} (as returned by jpegmeta) |
422 | 422 | */ |
423 | 423 | 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 ) { |
426 | 426 | this.imageinfo = {}; |
427 | 427 | } |
428 | | - if ( !mw.isDefined( this.imageinfo.metadata ) ) { |
| 428 | + if ( this.imageinfo.metadata === undefined ) { |
429 | 429 | this.imageinfo.metadata = {}; |
430 | 430 | } |
431 | 431 | if ( meta.tiff && meta.tiff.Orientation ) { |
— | — | @@ -480,7 +480,7 @@ |
481 | 481 | for ( var key in imageinfo ) { |
482 | 482 | // we get metadata as list of key-val pairs; convert to object for easier lookup. Assuming that EXIF fields are unique. |
483 | 483 | if ( key == 'metadata' ) { |
484 | | - if ( !mw.isDefined( _this.imageinfo.metadata ) ) { |
| 484 | + if ( _this.imageinfo.metadata === undefined ) { |
485 | 485 | _this.imageinfo.metadata = {}; |
486 | 486 | } |
487 | 487 | if ( imageinfo.metadata && imageinfo.metadata.length ) { |
— | — | @@ -527,7 +527,7 @@ |
528 | 528 | getStashImageInfo: function( callback, props, width, height ) { |
529 | 529 | var _this = this; |
530 | 530 | |
531 | | - if (!mw.isDefined( props ) ) { |
| 531 | + if ( props === undefined ) { |
532 | 532 | props = []; |
533 | 533 | } |
534 | 534 | |
— | — | @@ -537,14 +537,14 @@ |
538 | 538 | 'siiprop': props.join( '|' ) |
539 | 539 | }; |
540 | 540 | |
541 | | - if ( mw.isDefined( width ) || mw.isDefined( height ) ) { |
| 541 | + if ( width !== undefined || height !== undefined ) { |
542 | 542 | if ( ! $j.inArray( 'url', props ) ) { |
543 | 543 | props.push( 'url' ); |
544 | 544 | } |
545 | | - if ( mw.isDefined( width ) ) { |
| 545 | + if ( width !== undefined ) { |
546 | 546 | params['siiurlwidth'] = width; |
547 | 547 | } |
548 | | - if ( mw.isDefined( height ) ) { |
| 548 | + if ( height !== undefined ) { |
549 | 549 | params['siiurlheight'] = height; |
550 | 550 | } |
551 | 551 | } |
— | — | @@ -578,7 +578,7 @@ |
579 | 579 | */ |
580 | 580 | getImageInfo: function( callback, props, width, height ) { |
581 | 581 | var _this = this; |
582 | | - if (!mw.isDefined( props ) ) { |
| 582 | + if ( props === undefined ) { |
583 | 583 | props = []; |
584 | 584 | } |
585 | 585 | var requestedTitle = _this.title.getPrefixedText(); |
— | — | @@ -588,14 +588,14 @@ |
589 | 589 | 'iiprop': props.join( '|' ) |
590 | 590 | }; |
591 | 591 | |
592 | | - if ( mw.isDefined( width ) || mw.isDefined( height ) ) { |
| 592 | + if ( width !== undefined || height !== undefined ) { |
593 | 593 | if ( ! $j.inArray( 'url', props ) ) { |
594 | 594 | props.push( 'url' ); |
595 | 595 | } |
596 | | - if ( mw.isDefined( width ) ) { |
| 596 | + if ( width !== undefined ) { |
597 | 597 | params['iiurlwidth'] = width; |
598 | 598 | } |
599 | | - if ( mw.isDefined( height ) ) { |
| 599 | + if ( height !== undefined ) { |
600 | 600 | params['iiurlheight'] = height; |
601 | 601 | } |
602 | 602 | } |
— | — | @@ -663,7 +663,7 @@ |
664 | 664 | height = -1; |
665 | 665 | } |
666 | 666 | |
667 | | - if ( !mw.isDefined( _this.thumbnailPublishers[key] ) ) { |
| 667 | + if ( _this.thumbnailPublishers[key] === undefined ) { |
668 | 668 | var thumbnailPublisher = function( thumbnails ) { |
669 | 669 | if ( thumbnails === null ) { |
670 | 670 | // the api call failed somehow, no thumbnail data. |
— | — | @@ -879,7 +879,7 @@ |
880 | 880 | } |
881 | 881 | var constraints = { |
882 | 882 | width: parseInt( width, 10 ), |
883 | | - height: ( mw.isDefined( height ) ? parseInt( height, 10 ) : null ) |
| 883 | + height: ( height === undefined ? null : parseInt( height, 10 ) ) |
884 | 884 | }; |
885 | 885 | |
886 | 886 | 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 ) { |
3 | 3 | /** |
4 | 4 | * Prevent the closing of a window with a confirm message (the onbeforeunload event seems to |
5 | 5 | * work in most browsers.) |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | * @return closure execute this when you want to allow the user to close the window |
20 | 20 | */ |
21 | 21 | mw.confirmCloseWindow = function( options ) { |
22 | | - if ( ! mw.isDefined( options ) ) { |
| 22 | + if ( options === undefined ) { |
23 | 23 | options = {}; |
24 | 24 | } |
25 | 25 | |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js |
— | — | @@ -11,6 +11,8 @@ |
12 | 12 | * @param API |
13 | 13 | * @param containerDiv The div to put the interface into |
14 | 14 | */ |
| 15 | +( function( mw, $j, undefined ) { |
| 16 | + |
15 | 17 | mw.UploadWizardDetails = function( upload, api, containerDiv ) { |
16 | 18 | |
17 | 19 | var _this = this; |
— | — | @@ -356,13 +358,13 @@ |
357 | 359 | } ); |
358 | 360 | } |
359 | 361 | // 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 !== '' ) { |
362 | 364 | hiddenCats.push( mw.UploadWizard.config.autoCategory ); |
363 | 365 | } |
364 | 366 | |
365 | 367 | var missingCatsWikiText = null; |
366 | | - if ( typeof mw.UploadWizard.config.missingCategoriesWikiText !== 'undefined' |
| 368 | + if ( mw.UploadWizard.config.missingCategoriesWikiText !== undefined |
367 | 369 | && mw.UploadWizard.config.missingCategoriesWikiText !== '' ) { |
368 | 370 | missingCatsWikiText = mw.UploadWizard.config.missingCategoriesWikiText; |
369 | 371 | } |
— | — | @@ -373,7 +375,7 @@ |
374 | 376 | api: _this.upload.api, |
375 | 377 | hiddenCats: hiddenCats, |
376 | 378 | 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, |
378 | 380 | missingCatsWikiText: missingCatsWikiText |
379 | 381 | } ); |
380 | 382 | |
— | — | @@ -397,7 +399,7 @@ |
398 | 400 | |
399 | 401 | // make sure title is valid |
400 | 402 | var titleInputValid = $j( _this.titleInput ).data( 'valid' ); |
401 | | - if ( typeof titleInputValid == 'undefined' ) { |
| 403 | + if ( titleInputValid === undefined ) { |
402 | 404 | alert( "please wait, still checking the title for uniqueness..." ); |
403 | 405 | return false; |
404 | 406 | } |
— | — | @@ -500,7 +502,7 @@ |
501 | 503 | $errorEl.append( ' · ' ).append( completeErrorLink ); |
502 | 504 | |
503 | 505 | // 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'] !== '' ) { |
505 | 507 | var feedback = new mw.Feedback( |
506 | 508 | _this.api, |
507 | 509 | new mw.Title( mw.UploadWizard.config['blacklistIssuesPage'] ) |
— | — | @@ -539,15 +541,15 @@ |
540 | 542 | */ |
541 | 543 | addDescription: function( required, languageCode, allowRemove ) { |
542 | 544 | var _this = this; |
543 | | - if ( typeof required === 'undefined' ) { |
| 545 | + if ( required === undefined ) { |
544 | 546 | required = false; |
545 | 547 | } |
546 | 548 | |
547 | | - if ( typeof languageCode === 'undefined' ) { |
| 549 | + if ( languageCode === undefined ) { |
548 | 550 | languageCode = mw.LanguageUpWiz.UNKNOWN; |
549 | 551 | } |
550 | 552 | |
551 | | - if ( typeof allowRemove === 'undefined' ) { |
| 553 | + if ( allowRemove === undefined ) { |
552 | 554 | allowRemove = true; |
553 | 555 | } |
554 | 556 | |
— | — | @@ -648,7 +650,7 @@ |
649 | 651 | // if we don't have EXIF or other metadata, let's use "now" |
650 | 652 | // XXX if we have FileAPI, it might be clever to look at file attrs, saved |
651 | 653 | // in the upload object for use here later, perhaps |
652 | | - if ( !mw.isDefined( dateObj ) ) { |
| 654 | + if ( dateObj === undefined ) { |
653 | 655 | dateObj = new Date(); |
654 | 656 | } |
655 | 657 | dateStr = dateObj.getFullYear() + '-' + pad( dateObj.getMonth() + 1 ) + '-' + pad( dateObj.getDate() ); |
— | — | @@ -678,13 +680,13 @@ |
679 | 681 | if ( _this.upload.imageinfo.metadata ) { |
680 | 682 | var m = _this.upload.imageinfo.metadata; |
681 | 683 | |
682 | | - if ( mw.isDefined( m['gpslatitude'] ) ) { |
| 684 | + if ( m['gpslatitude'] !== undefined ) { |
683 | 685 | $j( _this.latInput ).val( m['gpslatitude'] ); |
684 | 686 | } |
685 | | - if ( mw.isDefined( m['gpslongitude'] ) ) { |
| 687 | + if ( m['gpslongitude'] !== undefined ) { |
686 | 688 | $j( _this.lonInput ).val( m['gpslongitude'] ); |
687 | 689 | } |
688 | | - if ( mw.isDefined( m['gpsaltitude'] ) ) { |
| 690 | + if ( m['gpsaltitude'] !== undefined ) { |
689 | 691 | $j( _this.altInput ).val( m['gpsaltitude'] ); |
690 | 692 | } |
691 | 693 | } |
— | — | @@ -848,7 +850,7 @@ |
849 | 851 | wikiText += "=={{int:license-header}}==\n"; |
850 | 852 | wikiText += deed.getLicenseWikiText() + "\n\n"; |
851 | 853 | |
852 | | - if ( mw.isDefined( mw.UploadWizard.config.autoWikiText ) ) { |
| 854 | + if ( mw.UploadWizard.config.autoWikiText !== undefined ) { |
853 | 855 | wikiText += mw.UploadWizard.config.autoWikiText; |
854 | 856 | } |
855 | 857 | |
— | — | @@ -856,7 +858,7 @@ |
857 | 859 | wikiText += _this.div.find( '.categoryInput' ).get(0).getWikiText() + "\n\n"; |
858 | 860 | |
859 | 861 | // 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' ) { |
861 | 863 | wikiText = TextCleaner.sanitizeWikiText( wikiText, true ); |
862 | 864 | } |
863 | 865 | |
— | — | @@ -1009,3 +1011,5 @@ |
1010 | 1012 | } |
1011 | 1013 | |
1012 | 1014 | }; |
| 1015 | + |
| 1016 | +}) ( window.mediaWiki, jQuery ); |
Index: trunk/extensions/UploadWizard/resources/mw.ApiQueryImageInfo.js |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | 'prop': 'imageinfo', |
23 | 23 | 'titles': title.toString() |
24 | 24 | }; |
25 | | - if ( mw.isDefined( extraParams.width ) ) { |
| 25 | + if ( extraParams.width !== undefined ) { |
26 | 26 | params['iiurlwidth'] = extraParams.width; |
27 | 27 | } |
28 | 28 | params.iiprop = properties.join( '|' ); |