[Erp5-report] r20000 - in /erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style: SkinTemplat...

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Mar 18 17:48:10 CET 2008


Author: fabien
Date: Tue Mar 18 17:48:10 2008
New Revision: 20000

URL: http://svn.erp5.org?rev=20000&view=rev
Log:
use XPath expression in erp5.js to put the focus on the good field instead of DOM. This is more clear, and I think more performant.

Modified:
    erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5.js.xml
    erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/revision

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5.js.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5.js.xml?rev=20000&r1=19999&r2=20000&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5.js.xml (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5.js.xml Tue Mar 18 17:48:10 2008
@@ -77,24 +77,17 @@
 // else if no element have autofocus class, the first element wich is not the\n
 // search field will get the focus. This is generaly the title input text of\n
 // a view\n
+function autoFocus() {\n
+  var first_autofocus_expr = ".//input[@class=\'autofocus\']"\n
+  var FIRST_RESULT = XPathResult.FIRST_ORDERED_NODE_TYPE\n
 \n
-function autoFocus() {\n
-  var inputs = document.getElementsByTagName("input");\n
-  var input_to_focus = 0;\n
-  for (i=0;i<inputs.length;i++) {\n
-    if (inputs[i].className == "autofocus") {\n
-      input_to_focus = inputs[i];\n
-    }\n
-  }\n
-  if (input_to_focus != 0) {\n
-    input_to_focus.focus();\n
+  var input = document.evaluate(first_autofocus_expr, document, null, FIRST_RESULT, null).singleNodeValue;\n
+  if (input) {\n
+    input.focus();\n
   }else{\n
-    for ( var i=0; i<inputs.length; i++ ){\n
-      if (inputs[i].getAttribute("type") == "text" && inputs[i].getAttribute("name") != "field_your_search_text"){\n
-        inputs[i].focus();\n
-        break;\n
-      }\n
-    }\n
+    var first_text_input_expr = ".//input[@type=\'text\'][@name != \'field_your_search_text\']"\n
+    var first_text_input = document.evaluate(first_text_input_expr, document, null, FIRST_RESULT, null).singleNodeValue;\n
+    first_text_input.focus();\n
   }\n
 }\n
 \n

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/revision
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/revision?rev=20000&r1=19999&r2=20000&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/revision (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/bt/revision Tue Mar 18 17:48:10 2008
@@ -1,1 +1,1 @@
-515
+511




More information about the Erp5-report mailing list