Bartosz Dziewoński has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/277937

Change subject: Remove mw.isEmpty
......................................................................

Remove mw.isEmpty

It checked for most falsy values except '0' and 'false'. If 'false'
and '0' are not valid values, it's idiomatic in JavaScript to just
cast to boolean in this case. I verified that they're not valid in
every place where this was used.

Change-Id: If53cf6cba4623d39d5d7c4acfabfaab46a5e9b6c
---
M resources/controller/uw.controller.Step.js
M resources/mw.GroupProgressBar.js
M resources/mw.UploadWizard.js
M resources/mw.UploadWizardDetails.js
M resources/mw.UploadWizardUpload.js
5 files changed, 10 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/37/277937/1

diff --git a/resources/controller/uw.controller.Step.js 
b/resources/controller/uw.controller.Step.js
index 2b9de33..66e7ae4 100644
--- a/resources/controller/uw.controller.Step.js
+++ b/resources/controller/uw.controller.Step.js
@@ -124,7 +124,7 @@
                var count = 0;
 
                $.each( this.uploads, function ( i, upload ) {
-                       if ( mw.isEmpty( upload ) ) {
+                       if ( !upload ) {
                                count += 1;
                        }
                } );
diff --git a/resources/mw.GroupProgressBar.js b/resources/mw.GroupProgressBar.js
index 0c9bafc..38ac989 100644
--- a/resources/mw.GroupProgressBar.js
+++ b/resources/mw.GroupProgressBar.js
@@ -182,7 +182,7 @@
                countEmpties: function () {
                        var count = 0;
                        $.each( this.uploads, function ( i, upload ) {
-                               if ( mw.isEmpty( upload ) || upload.state === 
'aborted' ) {
+                               if ( !upload || upload.state === 'aborted' ) {
                                        count += 1;
                                }
                        } );
diff --git a/resources/mw.UploadWizard.js b/resources/mw.UploadWizard.js
index f0a2982..fc0a1d4 100644
--- a/resources/mw.UploadWizard.js
+++ b/resources/mw.UploadWizard.js
@@ -553,16 +553,6 @@
        };
 
        /**
-        * Check if a value is null, undefined, or the empty string.
-        *
-        * @param {mixed} v Variable to be checked
-        * @return {boolean}
-        */
-       mw.isEmpty = function ( v ) {
-               return v === undefined || v === null || v === '';
-       };
-
-       /**
         * jQuery plugin - collapse toggle
         * Given an element, makes contained elements of class 
mw-collapsible-toggle clickable to show/reveal
         * contained element(s) of class mw-collapsible-content.
diff --git a/resources/mw.UploadWizardDetails.js 
b/resources/mw.UploadWizardDetails.js
index 3b30cc7..578e0f5 100644
--- a/resources/mw.UploadWizardDetails.js
+++ b/resources/mw.UploadWizardDetails.js
@@ -556,11 +556,11 @@
                                $.each( [ 'datetimeoriginal', 
'datetimedigitized', 'datetime', 'date' ], function ( i, propName ) {
                                        var matches, timeMatches,
                                                dateInfo = metadata[ propName ];
-                                       if ( !mw.isEmpty( dateInfo ) ) {
+                                       if ( dateInfo ) {
                                                matches = 
dateInfo.trim().match( yyyyMmDdRegex );
-                                               if ( !mw.isEmpty( matches ) ) {
+                                               if ( matches ) {
                                                        timeMatches = 
dateInfo.trim().match( timeRegex );
-                                                       if ( !mw.isEmpty( 
timeMatches ) ) {
+                                                       if ( timeMatches ) {
                                                                dateObj = new 
Date( parseInt( matches[ 1 ], 10 ),
                                                                                
        parseInt( matches[ 2 ], 10 ) - 1,
                                                                                
        parseInt( matches[ 3 ], 10 ),
@@ -582,7 +582,7 @@
                        if ( dateObj === undefined && this.upload.file !== 
undefined && this.upload.file.date !== undefined ) {
                                dateTimeRegex = /^\d\d\d\d-\d\d-\d\d 
\d\d:\d\d:\d\d/;
                                matches = this.upload.file.date.match( 
dateTimeRegex );
-                               if ( !mw.isEmpty( matches ) ) {
+                               if ( matches ) {
                                        this.dateDetails.setSerialized( {
                                                mode: dateMode,
                                                value: this.upload.file.date
diff --git a/resources/mw.UploadWizardUpload.js 
b/resources/mw.UploadWizardUpload.js
index 3b74e52..efc4f11 100644
--- a/resources/mw.UploadWizardUpload.js
+++ b/resources/mw.UploadWizardUpload.js
@@ -422,7 +422,7 @@
 
                // Check if extension is acceptable
                extension = this.title.getExtension();
-               if ( mw.isEmpty( extension ) ) {
+               if ( !extension ) {
                        this.fileNameErr( 'noext', null );
                } else {
                        if (
@@ -855,7 +855,9 @@
                        }
                }
 
-               if ( mw.isEmpty( height ) ) {
+               if ( !height ) {
+                       // For action=query&prop=stashimageinfo / 
action=query&prop=imageinfo,
+                       // height of '-1' is the same as not given, while '0' 
gives a one-pixel-wide thumbnail
                        height = -1;
                }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If53cf6cba4623d39d5d7c4acfabfaab46a5e9b6c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>

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

Reply via email to