Jatin has uploaded a new change for review.

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

Change subject: making js files pass jshint
......................................................................

making js files pass jshint

Bug: 61631
Change-Id: I0c25ff5363aa68f1a6484dad6054d026015fafca
---
M libs/datecheck.js
M libs/datepicker.js
M libs/datetimepicker.js
M libs/jquery.form-validator.js
M libs/jquery.multi-select.js
M libs/jquery.quicksearch.js
M libs/menuselect.js
M libs/regexp.js
M libs/timepicker.js
M libs/twolistboxes.js
10 files changed, 86 insertions(+), 76 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticFormsInputs 
refs/changes/79/121679/1

diff --git a/libs/datecheck.js b/libs/datecheck.js
index 2440c2c..83f1984 100644
--- a/libs/datecheck.js
+++ b/libs/datecheck.js
@@ -5,6 +5,8 @@
  *
  */
 
+var mw;
+
 window.SFI_DateCheck_init = function(input_id, params) {
     $.validate({
                borderColorOnError : '', // Border color of elements with 
invalid value; empty string to not change border color as it messes up the 
style of the input box
diff --git a/libs/datepicker.js b/libs/datepicker.js
index 06cc483..e0b9494 100644
--- a/libs/datepicker.js
+++ b/libs/datepicker.js
@@ -30,7 +30,7 @@
        
        var tabindex = inputShow.attr('tabindex');
        
-       var re = /\d{4}\/\d{2}\/\d{2}/
+       var re = /\d{4}\/\d{2}\/\d{2}/;
 
        if ( params.disabled ) {
 
@@ -97,35 +97,37 @@
                        inputShow.datepicker( 'widget' ).addClass( 
params.userClasses );
                        jQuery( '#' + input_id + ' + button' ).addClass( 
params.userClasses );
                }
-
+               var i;
                if ( params.disabledDates ) {
                        
-                       var disabledDates = new Array();
-
+                       var disabledDates = [];
+                       
                        for (i in params.disabledDates)
-                               disabledDates.push([
+                               if ( params.disabledDates[i] )
+                                       disabledDates.push([
                                        new Date(params.disabledDates[i][0], 
params.disabledDates[i][1], params.disabledDates[i][2]),
                                        new Date(params.disabledDates[i][3], 
params.disabledDates[i][4], params.disabledDates[i][5])
-                               ]);
+                                       ]);
 
                        inputShow.datepicker( 'option', 'disabledDates', 
disabledDates );
 
-                       delete disabledDates;
+                       disabledDates = null;
                }
 
                if ( params.highlightedDates ) {
 
-                       var highlightedDates = new Array();
+                       var highlightedDates = [];
 
                        for (i in params.highlightedDates)
-                               highlightedDates.push([
-                                       new Date(params.highlightedDates[i][0], 
params.highlightedDates[i][1], params.highlightedDates[i][2]),
-                                       new Date(params.highlightedDates[i][3], 
params.highlightedDates[i][4], params.highlightedDates[i][5])
-                               ]);
+                               if ( params.highlightedDates[i])
+                  highlightedDates.push([
+                    new Date(params.highlightedDates[i][0], 
params.highlightedDates[i][1], params.highlightedDates[i][2]),
+                    new Date(params.highlightedDates[i][3], 
params.highlightedDates[i][4], params.highlightedDates[i][5])
+                  ]);
 
                        inputShow.datepicker( 'option', 'highlightedDates', 
highlightedDates );
 
-                       delete highlightedDates;
+                       highlightedDates = null;
                }
 
                if (params.disabledDays) {
@@ -163,7 +165,7 @@
 
                inputShow.datepicker( 'widget' ).hide();
        }
-}
+};
 
 /**
  * Checks a date if it is to be enabled or highlighted
@@ -179,7 +181,7 @@
 
        var jInput = jQuery( input );
 
-       var enable = true
+       var enable = true;
 
        var disabledDays = jInput.datepicker( 'option', 'disabledDays' );
 
diff --git a/libs/datetimepicker.js b/libs/datetimepicker.js
index 255c85b..52acce7 100644
--- a/libs/datetimepicker.js
+++ b/libs/datetimepicker.js
@@ -4,7 +4,7 @@
  * @author Stephan Gambke
  *
  */
-
+/*jshint sub:true*/
 
 window.SFI_DTP_init = function( inputId, params ) {
 
@@ -29,14 +29,16 @@
        
        // call initialisation functions for subinputs
        for (var subinputId in params.subinputsInitData) {
-               
-               for ( var index in params.subinputsInitData[subinputId] ) {
+               if ( params.subinputsInitDat[subinputId] ) {
+      for ( var index in params.subinputsInitData[subinputId] ) {
+        if( params.subinputsInitData[subinputId][index] ) {
+                                       var fn = window[ 
params.subinputsInitData[subinputId][index]['name'] ];
+                                       var param = JSON.parse( 
params.subinputsInitData[subinputId][index]['param'] );
                        
-                       var fn = window[ 
params.subinputsInitData[subinputId][index]['name'] ];
-                       var param = JSON.parse( 
params.subinputsInitData[subinputId][index]['param'] );
-               
-                       if ( typeof fn === 'function' ) {
-                               fn( subinputId, param );
+                                       if ( typeof fn === 'function' ) {
+                                               fn( subinputId, param );
+                                       }
+        }
                        }
                }
        }
@@ -87,4 +89,4 @@
                }
        }
 
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/libs/jquery.form-validator.js b/libs/jquery.form-validator.js
index 53ec02a..dee0fc2 100644
--- a/libs/jquery.form-validator.js
+++ b/libs/jquery.form-validator.js
@@ -7,6 +7,8 @@
  * @license Dual licensed under the MIT or GPL Version 2 licenses
  * @version 2.1.38
  */
+/*jshint sub:true*/
+
 (function($) {
 
        'use strict';
@@ -43,7 +45,7 @@
                                custom.innerHTML = mess;
                        } else {
                                var $mess = 
$input.parent().find('.'+conf.errorMessageClass+'.help-block');
-                               if( $mess.length == 0 ) {
+                               if( $mess.length === 0 ) {
                                        $mess = 
$('<span></span>').addClass('help-block').addClass(conf.errorMessageClass);
                                        $mess.appendTo($input.parent());
                                }
@@ -122,7 +124,7 @@
                                        .unbind('focus.help')
                                        .bind('focus.help', function() {
                                                var $help = 
$elem.parent().find('.'+className);
-                                               if($help.length == 0) {
+                                               if($help.length === 0) {
                                                        $help = $('<span />')
                                                                
.addClass(className)
                                                                
.addClass('help')
@@ -355,7 +357,7 @@
         * Plugin for displaying input length restriction
         */
        $.fn.restrictLength = function(maxLengthElement) {
-               new $.formUtils.lengthRestriction(this, maxLengthElement);
+               $.formUtils.lengthRestriction(this, maxLengthElement);
                return this;
        };
 
@@ -449,7 +451,7 @@
                                .unbind('submit.validation')
                                .unbind('reset.validation')
                                
.find('input[data-validation],textarea[data-validation]')
-                               .unbind('blur.validation')
+                               .unbind('blur.validation');
 
                        // Validate when submitted
                        $form.bind('submit.validation', function() {
@@ -494,7 +496,7 @@
 
                });
 
-               if( conf.modules != '' ) {
+               if( conf.modules !== '' ) {
                        if( typeof conf.onModulesLoaded == 'function' ) {
                                $.formUtils.on('load', function() {
                                        conf.onModulesLoaded();
@@ -536,7 +538,7 @@
                                dateFormat : 'yyyy-mm-dd',
                                addValidClassOnAll : false, // whether or not 
to apply class="valid" even if the input wasn't validated
                                decimalSeparator : '.'
-                       }
+                       };
                },
 
                /**
@@ -637,7 +639,7 @@
                                                numModules = moduleList.length,
                                                moduleLoadedCallback = 
function() {
                                                        numModules--;
-                                                       if( numModules == 0 ) {
+                                                       if( numModules === 0 ) {
                                                                
$.formUtils.isLoadingModules = false;
                                                                if( fireEvent 
&& hasLoadedAnyModule ) {
                                                                        
$.formUtils.trigger('load', path);
@@ -654,7 +656,7 @@
 
                                        $.each(moduleList, function(i, modName) 
{
                                                modName = $.trim(modName);
-                                               if( modName.length == 0 ) {
+                                               if( modName.length === 0 ) {
                                                        moduleLoadedCallback();
                                                }
                                                else {
@@ -745,7 +747,7 @@
                                validateIfCheckedElementName = 
$elem.valAttr("if-checked");
 
                        // make sure we can proceed
-                       if (validateIfCheckedElementName != null) {
+                       if (validateIfCheckedElementName !== null) {
 
                                // Set the boolean telling us that the 
validation depends
                                // on another input being checked
@@ -857,9 +859,7 @@
                        day = findDateUnit('d', formatParts, matches);
                        year = findDateUnit('y', formatParts, matches);
 
-                       if ((month === 2 && day > 28 && (year % 4 !== 0  || 
year % 100 === 0 && year % 400 !== 0))
-                               || (month === 2 && day > 29 && (year % 4 === 0 
|| year % 100 !== 0 && year % 400 === 0))
-                               || month > 12 || month === 0) {
+                       if ((month === 2 && day > 28 && (year % 4 !== 0  || 
year % 100 === 0 && year % 400 !== 0)) || (month === 2 && day > 29 && (year % 4 
=== 0 || year % 100 !== 0 && year % 400 === 0)) || month > 12 || month === 0) {
                                return false;
                        }
                        if ((this.isShortMonth(month) && day > 30) || 
(!this.isShortMonth(month) && day > 31) || day === 0) {
@@ -943,7 +943,7 @@
                        // split by dash
                        var range = $.split(rangeAllowed, '-');
                        // min or max
-                       var minmax = parseInt(rangeAllowed.substr(3),10)
+                       var minmax = parseInt(rangeAllowed.substr(3),10);
                        // range ?
                        if (range.length == 2 && (value < parseInt(range[0],10) 
|| value > parseInt(range[1],10) ) )
                        {   return [ "out", range[0], range[1] ] ; } // value 
is out of range
@@ -1048,7 +1048,7 @@
                                        $suggestionContainer.scrollTop(0);
 
                                        // Find the right suggestions
-                                       if(val != '') {
+                                       if(val !== '') {
                                                var findPartial = val.length > 
2;
                                                
$.each($input.data('suggestions'), function(i, suggestion) {
                                                        var lowerCaseVal = 
suggestion.toLocaleLowerCase();
@@ -1063,12 +1063,12 @@
                                        }
 
                                        // Hide suggestion container
-                                       if(hasTypedSuggestion || 
(foundSuggestions.length == 0 && $suggestionContainer.length > 0)) {
+                                       if(hasTypedSuggestion || 
(foundSuggestions.length === 0 && $suggestionContainer.length > 0)) {
                                                $suggestionContainer.hide();
                                        }
 
                                        // Create suggestion container if not 
already exists
-                                       else if(foundSuggestions.length > 0 && 
$suggestionContainer.length == 0) {
+                                       else if(foundSuggestions.length > 0 && 
$suggestionContainer.length === 0) {
                                                $suggestionContainer = 
$('<div></div>').css(conf.css).appendTo('body');
                                                
$elem.addClass('suggestions-'+suggestionId);
                                                $suggestionContainer
@@ -1218,8 +1218,8 @@
        };
 
 
-       /* * * * * * * * * * * * * * * * * * * * * *
-        CORE VALIDATORS
+  /* * * * * * * * * * * * * * * * * * * * * *
+       CORE VALIDATORS
         * * * * * * * * * * * * * * * * * * * * */
 
 
@@ -1365,7 +1365,7 @@
                        var lengthAllowed = $el.valAttr('length'),
                                type = $el.attr('type');
 
-                       if(lengthAllowed == undefined) {
+                       if(lengthAllowed === undefined) {
                                var elementType = $el.get(0).nodeName;
                                alert('Please add attribute 
"data-validation-length" to '+elementType+' named '+$el.attr('name'));
                                return true;
@@ -1549,7 +1549,7 @@
                        var checkedCount = 
$("input[type=checkbox][name^='"+elname+"']:checked", $form).length;
                        // get el attr that specs qty required / allowed
                        var qtyAllowed = $el.valAttr('qty');
-                       if (qtyAllowed == undefined) {
+                       if (qtyAllowed === undefined) {
                                var elementType = $el.get(0).nodeName;
                                alert('Attribute "data-validation-qty" is 
missing from '+elementType+' named '+$el.attr('name'));
                        }
diff --git a/libs/jquery.multi-select.js b/libs/jquery.multi-select.js
index 1edf752..7b4871a 100644
--- a/libs/jquery.multi-select.js
+++ b/libs/jquery.multi-select.js
@@ -26,7 +26,7 @@
       multiSelects.each(function(){
         var ms = $(this);
 
-        if (ms.next('.ms-container').length == 0){
+        if (ms.next('.ms-container').length === 0){
           ms.attr('id', ms.attr('id') ? ms.attr('id') : 
'ms-'+Math.ceil(Math.random()*1000));
           var container = $('<div id="ms-'+ms.attr('id')+'" 
class="ms-container"></div>'),
               selectableContainer = $('<div class="ms-selectable"></div>'),
@@ -35,7 +35,7 @@
               selectedUl = $('<ul class="ms-list"></ul>');
 
           if (multiSelects.settings.emptyArray){
-            if (ms.find("option[value='']").length == 0){
+            if (ms.find("option[value='']").length === 0){
               ms.prepend("<option value='' selected='selected'></option>");
             } else {
               ms.find("option[value='']").attr('selected', 'selected');
@@ -106,9 +106,9 @@
           selectableLi = selectableUl.children('li[ms-value="'+value+'"]'),
           haveToSelect =  
((!selectableLi.hasClass(ms.data('settings').disabledClass)) ||
                           
(selectableLi.hasClass(ms.data('settings').disabledClass) && method == 'init')) 
&&
-                          value != '' &&
+                          value !== '' &&
                           ((method == 'init' && 
selectedOption.attr('selected')) ||
-                            (method != 'init' && 
!selectedOption.attr('selected')))
+                            (method != 'init' && 
!selectedOption.attr('selected')));
 
       if (haveToSelect ){
         var parentOptgroup = selectableLi.parent('.ms-optgroup');
@@ -119,7 +119,7 @@
         selectableLi.hide();
         selectedOption.attr('selected', 'selected');
         if(titleAttr){
-          selectedLi.attr('title', titleAttr)
+          selectedLi.attr('title', titleAttr);
         }
         if (selectableLi.hasClass(ms.data('settings').disabledClass)){
           selectedLi.addClass(ms.data('settings').disabledClass);
@@ -133,19 +133,19 @@
         if (method != 'init' && ms.data('settings').keepOrder && 
selectedUlLis.length > 0) {
 
           var getIndexOf = function(value) {
-            elems = selectableUl.children('.ms-elem-selectable');
+            var elems = selectableUl.children('.ms-elem-selectable');
             return(elems.index(elems.closest('[ms-value="'+value+'"]')));
-          }
+          };
 
           var index = getIndexOf(selectedLi.attr('ms-value'));
-          if (index == 0)
+          if (index === 0)
             selectedUl.prepend(selectedLi);
           else {
-            for (i = index - 1; i >= 0; i--){
+            for (var i = index - 1; i >= 0; i--){
               if (selectedUlLis[i] && 
getIndexOf($(selectedUlLis[i]).attr('ms-value')) < index) {
                 $(selectedUlLis[i]).after(selectedLi);
                 break;
-              } else if (i == 0) {
+              } else if (i === 0) {
                 $(selectedUlLis[i]).before(selectedLi);
               }
             }
@@ -177,7 +177,7 @@
           selectedLi = selectedUl.children('li[ms-value="'+value+'"]');
 
       if(selectedLi){
-        var selectableUl = $('#ms-'+ms.attr('id')+' .ms-selectable ul'),
+            selectableUl = $('#ms-'+ms.attr('id')+' .ms-selectable ul'),
             selectedUl = $('#ms-'+ms.attr('id')+' .ms-selection ul'),
             selectableLi = selectableUl.children('li[ms-value="'+value+'"]'),
             selectedLi = selectedUl.children('li[ms-value="'+value+'"]');
@@ -191,7 +191,7 @@
         selectableLi.show();
         selectableLi.removeClass('ms-selected');
         selectedLi.remove();
-        if (ms.data('settings').emptyArray && selectedUl.children('li').length 
== 0){
+        if (ms.data('settings').emptyArray && selectedUl.children('li').length 
=== 0){
           if (ms.find("option[value='']")){
             ms.find("option[value='']").attr('selected', 'selected');
           }
diff --git a/libs/jquery.quicksearch.js b/libs/jquery.quicksearch.js
index edb6a22..ebca997 100644
--- a/libs/jquery.quicksearch.js
+++ b/libs/jquery.quicksearch.js
@@ -1,4 +1,4 @@
-(function($, window, document, undefined) {
+ (function($, window, document, undefined) {
   $.fn.quicksearch = function (target, opt) {
     
     var timeout, cache, rowcache, jq_results, val = '', e = this, options = 
$.extend({ 
@@ -39,8 +39,8 @@
       noresults = true, 
       query = options.prepareQuery(val),
       val_empty = (val.replace(' ', '').length === 0);
-      
-      for (var i = 0, len = rowcache.length; i < len; i++) {
+      var len;
+      for ( i = 0, len = rowcache.length; i < len; i++) {
         if (val_empty || options.testQuery(query, cache[i], rowcache[i])) {
           options.show.apply(rowcache[i]);
           noresults = false;
diff --git a/libs/menuselect.js b/libs/menuselect.js
index 32f0458..45f7901 100644
--- a/libs/menuselect.js
+++ b/libs/menuselect.js
@@ -10,13 +10,14 @@
  *
  * @param inputID ( String ) the id of the input to initialize
  */
+
 window.SFI_MS_init = function( inputID, params ) {
 
        var inputShow = jQuery('#' + inputID + "_show");
 
        inputShow.one('focus', function(){
 
-               var treeid = "#" + inputID.replace(/input/,"span") + "_tree"
+               var treeid = "#" + inputID.replace(/input/,"span") + "_tree";
                var tree = jQuery( treeid );
                var treeRoot = tree.children( "ul" );
                var treeAllLists = tree.find( "ul" );
@@ -38,7 +39,7 @@
                                var item = jQuery( this );
                                var contents = item.contents()//.not( "ul" );
                                        .filter(function() {
-                                         return ! jQuery( this ).is('ul');
+                                               return ! jQuery( this 
).is('ul');
                                        });
 
                                contents
@@ -46,15 +47,16 @@
 
                                // insert the arrows indicating submenus
                                if ( item.children( "ul" ).length > 0 ) {
+          var sfigScriptPath;
                                        contents.parent()
-                                       .after( '<td class="arrow" ><img src="' 
+ sfigScriptPath + '/images/MenuSelectArrow.gif" /></td>' )
+                                       .after( '<td class="arrow" ><img src="' 
+ sfigScriptPath + '/images/MenuSelectArrow.gif" /></td>' );
                                }
 
                                maxwidth = Math.max( item.outerWidth(false) + 
10, maxwidth );
 
                                item.css('position', 'static');
 
-                       } )
+                       } );
 
                        if ( jQuery.browser.msie && document.documentMode <= 
"7" ) {
                                maxwidth = 100;
@@ -63,7 +65,7 @@
                                .height( window.screen.height );
                        } else if ( jQuery.browser.webkit || 
jQuery.browser.safari ) {
                                maxwidth = 100;
-                       };
+                       }
 
 
                        listitems
@@ -83,10 +85,10 @@
                                // find title of target page
                                if ( link.hasClass( 'new' ) ) { // for red 
links get it from the href
 
-                                       regexp = /.*title=([^&]*).*/;
-                                       res = regexp.exec( link.attr( 'href' ) 
);
-
-                                       title = unescape( res[1] );
+                                       var regexp = /.*title=([^&]*).*/;
+                                       var res = regexp.exec( link.attr( 
'href' ) );
+                                       var unescape;
+                                       var title = unescape( res[1] );
                                        title = title.replace('_', ' ', 'g');
 
                                        link.data( 'title', title ); // save 
title in data
@@ -121,7 +123,7 @@
                        if ( target.children( "ul" ).length > 0 ) {
 
                                // if we reentered (i.e. moved mouse from item 
to sub-item)
-                               if ( target.data( "timeout" ) != null) {
+                               if ( target.data( "timeout" ) !== null) {
 
                                        // clear any timeout that may still run 
on the list item
                                        // (i.e. do not fade out submenu)
@@ -170,13 +172,13 @@
                        // switch classes to change display style
                        target
                        .removeClass( "ui-state-hover" )
-                       .addClass( "ui-state-default" )
+                       .addClass( "ui-state-default" );
 
                        // if list item has sub-items...
                        if ( target.children( "ul" ).length > 0 ) {
 
                                // if we just moved in and out of the item 
(without really hovering)
-                               if ( target.data( "timeout" ) != null ) {
+                               if ( target.data( "timeout" ) !== null ) {
 
                                        // clear any timeout that may still run 
on the list item
                                        // (i.e. do not fade in submenu)
@@ -278,4 +280,4 @@
                .fadeTo( 400, 1 );
 
        });
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/libs/regexp.js b/libs/regexp.js
index 105273d..c42d031 100644
--- a/libs/regexp.js
+++ b/libs/regexp.js
@@ -16,6 +16,7 @@
  * @return (Boolean) true, if the input's value matches the regular expression 
in
  *         retext, false otherwise; the value is inverted if inverse is true
  */
+ 
 window.SFI_RE_validate = function( input_id, params ) { //input_number, 
retext, inverse, message, multiple
 
        var match;
@@ -35,4 +36,4 @@
                jQuery( '#' + input_id ).parent().addErrorMessage( message );
                return false;
        }
-}
+};
diff --git a/libs/timepicker.js b/libs/timepicker.js
index ede4a0e..ed05d9f 100644
--- a/libs/timepicker.js
+++ b/libs/timepicker.js
@@ -16,6 +16,7 @@
  *             format: (String) a format string (unused) (do we even need it?)
  *
  */
+
 window.SFI_TP_init = function( inputID, params ) { // minTime, maxTime, 
interval, format
 
        var inputIDshow = inputID + '_show';
@@ -261,4 +262,4 @@
        .click( function() {
                inputShow.val('');
        });
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/libs/twolistboxes.js b/libs/twolistboxes.js
index 8667e62..06fcda3 100644
--- a/libs/twolistboxes.js
+++ b/libs/twolistboxes.js
@@ -4,7 +4,7 @@
  * @author Yury Katkov
  *
  */
-
+ 
 window.SFI_TwoListboxes_init = function(input_id, params){
        var $input = jQuery( "#" + input_id );
 
@@ -17,4 +17,4 @@
        }
 
        );
-};
+};
\ No newline at end of file

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0c25ff5363aa68f1a6484dad6054d026015fafca
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticFormsInputs
Gerrit-Branch: master
Gerrit-Owner: Jatin <mehtajati...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to