myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r1344169 - in /myfaces/tobago/trunk: tobago-example/tobago-example-demo/src/main/webapp/ tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/
Date Wed, 30 May 2012 09:32:23 GMT
Author: lofwyr
Date: Wed May 30 09:32:23 2012
New Revision: 1344169

URL: http://svn.apache.org/viewvc?rev=1344169&view=rev
Log:
TOBAGO-616: DefaultCommand on subforms

Modified:
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/footer.xhtml
    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-example/tobago-example-demo/src/main/webapp/footer.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/footer.xhtml?rev=1344169&r1=1344168&r2=1344169&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/footer.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/footer.xhtml Wed
May 30 09:32:23 2012
@@ -56,77 +56,5 @@
 
     <tc:out value="#{overviewBundle.notTranslated}"/>
 
-    <tc:style>
-      .tobago-button-markup-default {
-        border-width: 2px;
-      }
-    </tc:style>
-
-    <tc:script onload="init()">
-
-      function init() {
-
-        jQuery("body").keypress(function (event) {
-          var code = event.which;
-          if (code == 0) {
-            code = event.keyCode;
-          }
-          if (code == 13) {
-            var target = event.target;
-            if (target.tagName == "A" || target.tagName == "BUTTON") {
-              return;
-            }
-            if (target.tagName == "TEXTAREA") {
-              if (!event.metaKey &amp;&amp; !event.ctrlKey) {
-                return;
-              }
-            }
-            var id = target.id;
-            while (id != "") {
-              var command = jQuery("[data-tobago-default='" + id + "']");
-              if (command.size() > 0) {
-                LOG.error(code + " on " + id + " command=" + command.attr('id'));
-                command.click();
-                break;
-              }
-              id = Tobago.Utils.getNamingContainerId(id);
-            }
-            return false;
-          }
-        });
-
-        jQuery("input, select, textarea, a, button").focus(function (event) {
-          var target = event.target;
-          var id = target.id;
-          var command;
-          if (target.tagName == "A" || target.tagName == "BUTTON") {
-            command = jQuery(target);
-          } else {
-            while (id != "") {
-              command = jQuery("[data-tobago-default='" + id + "']");
-              if (command.size() > 0) {
-                break;
-              }
-              id = Tobago.Utils.getNamingContainerId(id);
-            }
-          }
-
-          if (command.size() > 0) {
-            // remove old
-            jQuery(".tobago-link-markup-default").removeClass("tobago-link-markup-default");
-            jQuery(".tobago-button-markup-default").removeClass("tobago-button-markup-default");
-
-            command.filter("a").addClass("tobago-link-markup-default");
-            command.filter("button").addClass("tobago-button-markup-default");
-          }
-        });
-      }
-
-      Tobago.Utils.getNamingContainerId = function (id) {
-        return id.substring(0, id.lastIndexOf(":"));
-      };
-
-    </tc:script>
-
   </tc:panel>
 </f:subview>

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=1344169&r1=1344168&r2=1344169&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
Wed May 30 09:32:23 2012
@@ -59,6 +59,38 @@ Tobago.Utils.getSuperComponentId = funct
 };
 
 /**
+ * "a:b" -> "a"
+ * "a:b:c" -> "a:b"
+ * "a" -> null
+ * null -> null
+ * "a:b::sub-component" -> "a"
+ * "a::sub-component:b" -> "a::sub-component" // should currently not happen in Tobago
+ *
+ * @param id The clientId of a component.
+ * @return The clientId of the naming container.
+ */
+Tobago.Utils.getNamingContainerId = function (id) {
+  if (id == null) {
+    return null;
+  }
+  if (id.lastIndexOf(":") == -1) {
+    return null;
+  }
+  while (true) {
+    var sub = id.lastIndexOf("::");
+    if (sub == -1) {
+      break;
+    }
+    if (sub + 1 == id.lastIndexOf(":")) {
+      id = id.substring(0, sub);
+    } else {
+      break;
+    }
+  }
+  return id.substring(0, id.lastIndexOf(":"));
+};
+
+/**
  * fix position, when the element it is outside of the current page
  * @param elements is an jQuery Array of elements to be fixed.
  */

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=1344169&r1=1344168&r2=1344169&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
Wed May 30 09:32:23 2012
@@ -2520,6 +2520,94 @@ Tobago.registerListener(Tobago.TabGroup.
 Tobago.registerListener(Tobago.TabGroup.init, Tobago.Phase.AFTER_UPDATE);
 
 // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Commands
+
+Tobago.Command = {};
+
+Tobago.Command.initEnter = function(elements) {
+  var body = Tobago.Utils.selectWidthJQuery(elements, "body");
+  body.keypress(function (event) {
+    var code = event.which;
+    if (code == 0) {
+      code = event.keyCode;
+    }
+    if (code == 13) {
+      var target = event.target;
+      if (target.tagName == "A" || target.tagName == "BUTTON") {
+        return;
+      }
+      if (target.tagName == "TEXTAREA") {
+        if (!event.metaKey && !event.ctrlKey) {
+          return;
+        }
+      }
+      var id = target.id;
+      while (id != null) {
+        var command = jQuery("[data-tobago-default='" + id + "']");
+        if (command.size() > 0) {
+          command.click();
+          break;
+        }
+        id = Tobago.Utils.getNamingContainerId(id);
+      }
+      return false;
+    }
+  })};
+
+Tobago.Command.initInputElements = function(elements) {
+  var inputElements = Tobago.Utils.selectWidthJQuery(elements, "input, select, textarea,
a, button");
+  inputElements.focus(function (event) {
+    var target = event.target;
+    var id = target.id;
+    var command;
+    if (target.tagName == "A" || target.tagName == "BUTTON") {
+      command = jQuery(target);
+    } else {
+      while (id != null) {
+        command = jQuery("[data-tobago-default='" + id + "']");
+        if (command.size() > 0) {
+          break;
+        }
+        id = Tobago.Utils.getNamingContainerId(id);
+      }
+    }
+
+    if (command.size() > 0) {
+      // add new classes
+      command.filter("a").addClass("tobago-link-markup-default");
+      command.filter("button").addClass("tobago-button-markup-default");
+    }
+  });
+  inputElements.blur(function (event) {
+    var target = event.target;
+    var id = target.id;
+    var command;
+    if (target.tagName == "A" || target.tagName == "BUTTON") {
+      command = jQuery(target);
+    } else {
+      while (id != null) {
+        command = jQuery("[data-tobago-default='" + id + "']");
+        if (command.size() > 0) {
+          break;
+        }
+        id = Tobago.Utils.getNamingContainerId(id);
+      }
+    }
+
+    if (command.size() > 0) {
+      // remove old
+      command.filter("a").removeClass("tobago-link-markup-default");
+      command.filter("button").removeClass("tobago-button-markup-default");
+    }
+  });
+};
+
+Tobago.registerListener(Tobago.Command.initEnter, Tobago.Phase.DOCUMENT_READY);
+
+Tobago.registerListener(Tobago.Command.initInputElements, Tobago.Phase.DOCUMENT_READY);
+Tobago.registerListener(Tobago.Command.initInputElements, Tobago.Phase.AFTER_UPDATE);
+
+// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 Tobago.SelectManyShuttle = {};
 



Mime
View raw message