myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r1644111 - in /myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script: tobago-sheet.js tobago-utils.js tobago.js
Date Tue, 09 Dec 2014 16:29:42 GMT
Author: lofwyr
Date: Tue Dec  9 16:29:41 2014
New Revision: 1644111

URL: http://svn.apache.org/r1644111
Log:
TOBAGO-1325: jQuery too slow in IE8: Tobago.Util.selectWithJQuery()

Modified:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-utils.js
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js?rev=1644111&r1=1644110&r2=1644111&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
Tue Dec  9 16:29:41 2014
@@ -52,9 +52,9 @@ Tobago.Sheet = function(
 
   this.firstRowRegExp = new RegExp("^" + this.id + "_data_tr_\\d+$");
 
-  this.setup();
-
   console.timeEnd("[tobago-sheet] constructor"); // @DEV_ONLY
+
+  this.setup();
 };
 
 Tobago.Sheet.init = function(elements) {

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-utils.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-utils.js?rev=1644111&r1=1644110&r2=1644111&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-utils.js
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-utils.js
Tue Dec  9 16:29:41 2014
@@ -27,15 +27,76 @@ Tobago.Utils.escapeClientId = function(i
 };
 
 /**
+ * @deprecated since Tobago 2.0.5 because of spelling
+ */
+Tobago.Utils.selectWidthJQuery = function(elements, selector) {
+  return Tobago.Utils.selectWithJQuery(elements, selector);
+};
+
+/**
  * Helps to select either elements from the whole DOM or only find in sub trees
  * (in the case of AJAX partial rendering)
  * @param elements a jQuery object to initialize (ajax) or null for initializing the whole
document (full load).
  * @param selector a jQuery selector.
  */
-Tobago.Utils.selectWidthJQuery = function(elements, selector) {
-  return elements == null
-      ? jQuery(selector)
-      : elements.find(selector).add(elements.filter(selector));
+Tobago.Utils.selectWithJQuery = function(elements, selector) {
+
+  if (elements == null) {
+    return jQuery(selector);
+  }
+
+  if (Tobago.browser.isMsie678) {
+    if (selector.match(/^\[[-_a-zA-Z0-9]+\]$/)) {
+      return Tobago.Utils.ieSelectWidthJQueryAttr(elements, selector);
+    }
+    if (selector == Tobago.Command.INPUTS_FOR_DEFAULT) {
+      return Tobago.Utils.ieSelectWidthJQueryInputs(elements);
+    }
+  }
+
+  return elements.find(selector).add(elements.filter(selector));
+};
+
+/** internal function for IE <= 8 performance */
+Tobago.Utils.ieSelectWidthJQueryAttr = function (elements, selector) {
+  var founds = [];
+  for (var i = 0; i < elements.length; i++) {
+    Tobago.Utils.ieFilterAttributes(elements.get(i), selector.substr(1, selector.length -
2), founds);
+  }
+  return jQuery(founds);
+};
+
+/** internal function for IE <= 8 performance */
+Tobago.Utils.ieSelectWidthJQueryInputs = function(elements) {
+  var founds = [];
+  for (var i = 0; i < elements.length; i++) {
+    var element = elements.get(i);
+    Tobago.Utils.ieFilterTags(element, ["INPUT", "SELECT", "TEXTAREA", "A", "BUTTON"], founds);
+  }
+  return jQuery(founds);
+};
+
+/** internal function for IE <= 8 performance */
+Tobago.Utils.ieFilterTags = function (element, tagNames, result) {
+  for (var i = 0; i < tagNames.length; i++) {
+    if (element.tagName == tagName[i]) {
+      result.push(element);
+      break;
+    }
+  }
+  for (i = 0; i < element.childNodes.length; i++) {
+    Tobago.Utils.ieFilterTags(element.childNodes[i], tagName, result);
+  }
+};
+
+/** internal function for IE <= 8 performance */
+Tobago.Utils.ieFilterAttributes = function (element, filter, result) {
+  if (element[filter] !== undefined) {
+    result.push(element);
+  }
+  for (var i = 0; i < element.childNodes.length; i++) {
+    Tobago.Utils.ieFilterAttributes(element.childNodes[i], filter, result);
+  }
 };
 
 Tobago.Utils.findSubComponent = function(element, subId) {

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=1644111&r1=1644110&r2=1644111&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
Tue Dec  9 16:29:41 2014
@@ -2505,8 +2505,10 @@ Tobago.Command.initEnter = function(elem
     }
   })};
 
+Tobago.Command.INPUTS_FOR_DEFAULT = "input, select, textarea, a, button";
+
 Tobago.Command.initInputElements = function(elements) {
-  var inputElements = Tobago.Utils.selectWidthJQuery(elements, "input, select, textarea,
a, button");
+  var inputElements = Tobago.Utils.selectWidthJQuery(elements, Tobago.Command.INPUTS_FOR_DEFAULT);
   inputElements.focus(function (event) {
     var target = event.target;
     var id = target.id;



Mime
View raw message