TheDJ has submitted this change and it was merged.
Change subject: Code style improvements
......................................................................
Code style improvements
Change-Id: I273a14da7a02fe08f38f1660c24121660f20bb55
---
M resources/mw.UploadWizardDeed.js
M resources/mw.UploadWizardLicenseInput.js
M resources/mw.UploadWizardUpload.js
3 files changed, 41 insertions(+), 39 deletions(-)
Approvals:
TheDJ: Verified; Looks good to me, approved
jenkins-bot: Checked
diff --git a/resources/mw.UploadWizardDeed.js b/resources/mw.UploadWizardDeed.js
index 9460361..7090a4b 100644
--- a/resources/mw.UploadWizardDeed.js
+++ b/resources/mw.UploadWizardDeed.js
@@ -266,11 +266,13 @@
_this.authorInput = $j('<textarea class="mwe-author mwe-long-textarea"
name="author" rows="1" cols="40"></textarea>' )
.growTextArea();
licenseInputDiv = $j( '<div
class="mwe-upwiz-deed-license-groups"></div>' );
- _this.licenseInput = new mw.UploadWizardLicenseInput( licenseInputDiv,
- undefined,
-
mw.UploadWizard.config.licensesThirdParty,
- _this.uploadCount,
- api );
+ _this.licenseInput = new mw.UploadWizardLicenseInput(
+ licenseInputDiv,
+ undefined,
+ mw.UploadWizard.config.licensesThirdParty,
+ _this.uploadCount,
+ api
+ );
_this.licenseInput.setDefaultValues();
diff --git a/resources/mw.UploadWizardLicenseInput.js
b/resources/mw.UploadWizardLicenseInput.js
index a0672d7..caddcd4 100644
--- a/resources/mw.UploadWizardLicenseInput.js
+++ b/resources/mw.UploadWizardLicenseInput.js
@@ -3,21 +3,21 @@
* Note that this is very anti-MVC. The values are held only in the actual
form elements themselves.
*
* @param {String|jQuery} selector to place license input
- * @param {Array} license key name(s) to activate by default
- * @param {Array} configuration of licenseInput. Must have following
properties
+ * @param {Array|undefined} license key name(s) to activate by default
+ * @param {Object} configuration of licenseInput. Must have following
properties
* 'type' = ("and"|"or") -- whether inclusive or
exclusive license allowed
* 'defaults' => array of template string names
(can be empty array),
* 'licenses' => array of template string names
(matching keys in mw.UploadWizard.config.licenses)
* optional: 'licenseGroups' => groups of
licenses, with more explanation
* optional: 'special' => String -- indicates,
don't put licenses here, instead use a special widget
- * @param {Number} count of the things we are licensing (it matters to
some texts)
- * @param {mw.Api} api object; useful for previews
+ * @param {Number} count of the things we are licensing (it matters to some
texts)
+ * @param {mw.Api} api object; useful for previews
*/
( function( mw, $j, undefined ) {
-var catNsId = mw.config.get( 'wgNamespaceIds' ).category,
- templateNsId = mw.config.get( 'wgNamespaceIds' ).template;
+var catNsId = mw.config.get( 'wgNamespaceIds' ).category,
+ templateNsId = mw.config.get( 'wgNamespaceIds' ).template;
mw.UploadWizardLicenseInput = function( selector, values, config, count, api )
{
var _this = this;
@@ -26,8 +26,9 @@
_this.api = api;
if ( config.type === undefined
- || config.defaults === undefined
- || ( config.licenses === undefined && config.licenseGroups ===
undefined ) ) {
+ || config.defaults === undefined
+ || ( config.licenses === undefined && config.licenseGroups ===
undefined )
+ ) {
throw new Error( 'improper initialization' );
}
diff --git a/resources/mw.UploadWizardUpload.js
b/resources/mw.UploadWizardUpload.js
index 34cc779..c37d105 100644
--- a/resources/mw.UploadWizardUpload.js
+++ b/resources/mw.UploadWizardUpload.js
@@ -394,7 +394,7 @@
}
} );
- if( duplicate ) {
+ if ( duplicate ) {
fileErrors.dup = true;
fileNameErr( 'dup', basename, fileErrors );
}
@@ -412,7 +412,7 @@
fileErrors.noext = true;
fileNameErr( 'noext', null, fileErrors );
} else {
- if ( $j.inArray( extension.toLowerCase(),
mw.UploadWizard.config[ 'fileExtensions' ] ) === -1 ) {
+ if ( $j.inArray( extension.toLowerCase(),
mw.UploadWizard.config.fileExtensions ) === -1 ) {
fileErrors.ext = true;
fileNameErr( 'ext', extension, fileErrors );
}
@@ -451,7 +451,7 @@
// make sure the file isn't too large
// XXX need a way to find the size of
the Flickr image
- if( !_this.fromURL ){
+ if ( !_this.fromURL ){
this.transportWeight =
this.file.size;
if ( this.transportWeight >
actualMaxSize ) {
_this.showMaxSizeWarning( this.transportWeight, actualMaxSize );
@@ -471,11 +471,11 @@
//
// TODO: This should be refactored.
- if( this.file.type === 'image/jpeg' ) {
+ if ( this.file.type === 'image/jpeg' ) {
var binReader = new
FileReader();
binReader.onload = function() {
var binStr;
- if ( typeof
binReader.result == 'string' ) {
+ if ( typeof
binReader.result === 'string' ) {
binStr =
binReader.result;
} else {
// Array
buffer; convert to binary string for the library.
@@ -514,15 +514,14 @@
// Now that first file has been
prepared, process remaining files
// in case of a multi-file upload.
- var tooManyFiles = files.length +
_this.wizard.uploads.length > mw.UploadWizard.config[ 'maxUploads' ];
+ var tooManyFiles = files.length +
_this.wizard.uploads.length > mw.UploadWizard.config.maxUploads;
if ( tooManyFiles ) {
- var remainingFiles =
mw.UploadWizard.config[ 'maxUploads' ] - _this.wizard.uploads.length;
+ var remainingFiles =
mw.UploadWizard.config.maxUploads - _this.wizard.uploads.length;
_this.showTooManyFilesWarning(
files.length - remainingFiles );
- var files = remainingFiles > 1
? files.slice( 1, remainingFiles ) : [];
- }
- else {
- var files = files.slice( 1 );
+ files = remainingFiles > 1 ?
files.slice( 1, remainingFiles ) : [];
+ } else {
+ files = files.slice( 1 );
}
if ( files.length > 0 ) {
@@ -594,8 +593,8 @@
$j( '<div></div>' )
.msg(
'mwe-upwiz-too-many-files-text',
- mw.UploadWizard.config[ 'maxUploads' ],
- mw.UploadWizard.config[ 'maxUploads' ] +
filesIgnored,
+ mw.UploadWizard.config.maxUploads,
+ mw.UploadWizard.config.maxUploads +
filesIgnored,
filesIgnored
)
.dialog( {
@@ -732,10 +731,10 @@
props.push( 'url' );
}
if ( width !== undefined ) {
- params['siiurlwidth'] = width;
+ params.siiurlwidth = width;
}
if ( height !== undefined ) {
- params['siiurlheight'] = height;
+ params.siiurlheight = height;
}
}
@@ -782,10 +781,10 @@
props.push( 'url' );
}
if ( width !== undefined ) {
- params['iiurlwidth'] = width;
+ params.iiurlwidth = width;
}
if ( height !== undefined ) {
- params['iiurlheight'] = height;
+ params.iiurlheight = height;
}
}
@@ -820,11 +819,11 @@
* @return upload handler object
*/
getUploadHandler: function(){
- if( !this.uploadHandler ) {
+ if ( !this.uploadHandler ) {
var constructor; // must be the name of a function in
'mw' namespace
- if( mw.UploadWizard.config[ 'enableFirefogg' ] &&
mw.Firefogg.isInstalled() ) {
+ if ( mw.UploadWizard.config.enableFirefogg &&
mw.Firefogg.isInstalled() ) {
constructor = 'FirefoggHandler';
- } else if( mw.UploadWizard.config[ 'enableFormData' ]
&& mw.fileApi.isAvailable() && mw.fileApi.isFormDataAvailable()) {
+ } else if ( mw.UploadWizard.config.enableFormData &&
mw.fileApi.isAvailable() && mw.fileApi.isFormDataAvailable()) {
constructor = 'ApiUploadFormDataHandler';
} else {
constructor = 'ApiUploadHandler';
@@ -1066,8 +1065,8 @@
* @return {HTMLCanvasElement|HTMLImageElement}
*/
getScaledImageElement: function( image, width, height ) {
- if ( typeof width === 'undefined' || width === null || width <=
0 ) {
- width = mw.UploadWizard.config['thumbnailWidth'];
+ if ( width === undefined || width === null || width <= 0 ) {
+ width = mw.UploadWizard.config.thumbnailWidth;
}
var constraints = {
width: parseInt( width, 10 ),
@@ -1156,8 +1155,8 @@
$j( '<div class="mwe-upwiz-lightbox"></div>' )
.append( $imgDiv )
.dialog( {
- 'minWidth':
mw.UploadWizard.config[ 'largeThumbnailWidth' ],
- 'minHeight':
mw.UploadWizard.config[ 'largeThumbnailMaxHeight' ],
+ 'minWidth':
mw.UploadWizard.config.largeThumbnailWidth,
+ 'minHeight':
mw.UploadWizard.config.largeThumbnailMaxHeight,
'autoOpen': true,
'title': mw.msg(
'mwe-upwiz-image-preview' ),
'modal': true,
@@ -1165,8 +1164,8 @@
} );
_this.setThumbnail(
$imgDiv,
- mw.UploadWizard.config[
'largeThumbnailWidth' ],
- mw.UploadWizard.config[
'largeThumbnailMaxHeight' ],
+
mw.UploadWizard.config.largeThumbnailWidth,
+
mw.UploadWizard.config.largeThumbnailMaxHeight,
false /* obviously the largeThumbnail
doesn't have a lightbox itself! */
);
return false;
--
To view, visit https://gerrit.wikimedia.org/r/64513
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I273a14da7a02fe08f38f1660c24121660f20bb55
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Nischayn22 <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: TheDJ <[email protected]>
Gerrit-Reviewer: Yuvipanda <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits