[js] fix inArray usage in reorderTabIndex() : inArray returns -1 if element is not found, not 'false' oldstable
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Thu, 28 Apr 2011 08:18:48 +0200
brancholdstable
changeset 7258 2e7f0d6fa2d6
parent 7254 c0278ad81823
child 7259 f846f4f017b1
child 7261 1d1446e9dfe2
[js] fix inArray usage in reorderTabIndex() : inArray returns -1 if element is not found, not 'false'
web/data/cubicweb.compat.js
web/data/cubicweb.edition.js
web/data/cubicweb.widgets.js
--- a/web/data/cubicweb.compat.js	Wed Apr 27 09:54:22 2011 +0200
+++ b/web/data/cubicweb.compat.js	Thu Apr 28 08:18:48 2011 +0200
@@ -15,7 +15,7 @@
 
 // ========== ARRAY EXTENSIONS ========== ///
 Array.prototype.contains = cw.utils.deprecatedFunction(
-    '[3.9] array.contains(elt) is deprecated, use $.inArray(elt, array) instead',
+    '[3.9] array.contains(elt) is deprecated, use $.inArray(elt, array)!=-1 instead',
     function(element) {
         return jQuery.inArray(element, this) != - 1;
     }
--- a/web/data/cubicweb.edition.js	Wed Apr 27 09:54:22 2011 +0200
+++ b/web/data/cubicweb.edition.js	Thu Apr 28 08:18:48 2011 +0200
@@ -45,7 +45,7 @@
     var tabindex = (start == null) ? 15: start;
     cw.utils.nodeWalkDepthFirst(form, function(elem) {
         var tagName = elem.tagName.toUpperCase();
-        if ($.inArray(tagName, inputTypes)) {
+        if (jQuery.inArray(tagName, inputTypes) != -1) {
             if (jQuery(elem).attr('tabindex') != null) {
                 tabindex += 1;
                 jQuery(elem).attr('tabindex', tabindex);
@@ -58,7 +58,7 @@
 
 function showMatchingSelect(selectedValue, eid) {
     if (selectedValue) {
-        divId = 'div' + selectedValue + '_' + eid;
+        var divId = 'div' + selectedValue + '_' + eid;
         var divNode = jQuery('#' + divId);
         if (!divNode.length) {
             var args = {
--- a/web/data/cubicweb.widgets.js	Wed Apr 27 09:54:22 2011 +0200
+++ b/web/data/cubicweb.widgets.js	Thu Apr 28 08:18:48 2011 +0200
@@ -491,8 +491,8 @@
         var group = null;
         var variableRegexp = /%\((\w+)\)s/g;
         // emulates rgx.findAll()
-        while (group = variableRegexp.exec(text)) {
-            if (!$.inArray(group[1], self.variables)) {
+        while ( (group = variableRegexp.exec(text)) ) {
+            if ($.inArray(group[1], self.variables) == -1) {
                 unknownVariables.push(group[1]);
             }
             it++;