You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2011/11/10 19:30:52 UTC

svn commit: r1200469 - in /myfaces/tobago/trunk/tobago-theme: tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/st...

Author: lofwyr
Date: Thu Nov 10 18:30:52 2011
New Revision: 1200469

URL: http://svn.apache.org/viewvc?rev=1200469&view=rev
Log:
TOBAGO-1048: Access keys doesn't work with webkit browsers

Modified:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-menu.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-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuRenderer.java?rev=1200469&r1=1200468&r2=1200469&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuRenderer.java Thu Nov 10 18:30:52 2011
@@ -69,6 +69,7 @@ public class MenuRenderer extends Layout
 
     writer.startElement(HtmlElements.LI, menu);
     writer.writeClassAttribute(Classes.create(menu, firstLevel ? Markup.TOP : null));
+    writer.writeIdAttribute(clientId);
     if (menu.getImage() != null) {
       Style style = new Style();
       style.setBackgroundImage("url(" + menu.getImage() + ")");
@@ -76,7 +77,6 @@ public class MenuRenderer extends Layout
     }
     writer.startElement(HtmlElements.A, menu);
     writer.writeAttribute(HtmlAttributes.HREF, "#", false);
-    writer.writeIdAttribute(clientId);
 
     LabelWithAccessKey label = new LabelWithAccessKey(menu);
     if (label.getText() != null) {

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-menu.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-menu.js?rev=1200469&r1=1200468&r2=1200469&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-menu.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-menu.js Thu Nov 10 18:30:52 2011
@@ -22,11 +22,11 @@
    <body>
      <form>
        <ol class="tobago-menuBar">
-         <li class="tobago-menu-markup-top">
-           <a id="m1">Menu 1</a>
+         <li id="m1" class="tobago-menu-markup-top">
+           <a>Menu 1</a>
          </li>
-         <li class="tobago-menu-markup-top">
-           <a id="m2">Menu 2</a>
+         <li id="m2" class="tobago-menu-markup-top">
+           <a>Menu 2</a>
          </li>
          ...
        </ol>
@@ -101,7 +101,7 @@ Tobago.Menu.handelKey = function(event) 
       break;
     case 40: // cursor down
       if (jQuery(this).parent().hasClass('tobago-menu-markup-top')) {
-        jQuery(this).tobagoMenu_findSubMenu().children(":nth-child(1)").children('a').focus();
+        jQuery(this).parent().tobagoMenu_findSubMenu().children(":nth-child(1)").children('a').focus();
       } else {
         jQuery(this).parent().nextAll('li').children('a').eq(0).focus();
       }
@@ -119,10 +119,10 @@ Tobago.Menu.handelKey = function(event) 
 Tobago.Menu.open = function(event) {
 
   var li = jQuery(this).parent();
-  var sub = jQuery(this).tobagoMenu_findSubMenu();
-  
+  var sub = li.tobagoMenu_findSubMenu();
+
   // close menus in other branches
-  li.siblings().children('a').tobagoMenu_findSubMenu().find('ol').andSelf().css('visibility', 'hidden');
+  li.siblings().tobagoMenu_findSubMenu().find('ol').andSelf().css('visibility', 'hidden');
 
   // close sub sub menu 
   sub.children().find("ol").css('visibility', 'hidden');
@@ -196,7 +196,7 @@ Tobago.Menu.mouseOver = function(event) 
 
 Tobago.Menu.switchOn = function(menuBar, menu) {
   menuBar.find('li') // direct menus
-      .add(menuBar.find('li').children('a').tobagoMenu_findSubMenu().find('li')) // add sub menus
+      .add(menuBar.find('li').tobagoMenu_findSubMenu().find('li')) // add sub menus
       .bind('mouseover', Tobago.Menu.mouseOver)
       .children('a')
       .bind('focus', Tobago.Menu.open)
@@ -208,9 +208,9 @@ Tobago.Menu.switchOn = function(menuBar,
 
 Tobago.Menu.switchOff = function(menuBar) {
   menuBar.find("ol")
-      .add(menuBar.find('li').children('a').tobagoMenu_findSubMenu().find('ol').andSelf())
+      .add(menuBar.find('li').tobagoMenu_findSubMenu().find('ol').andSelf())
       .css('visibility', 'hidden');
-  menuBar.find('li').add(menuBar.find('li').children('a').tobagoMenu_findSubMenu().find('li'))
+  menuBar.find('li').add(menuBar.find('li').tobagoMenu_findSubMenu().find('li'))
       .unbind('mouseover', Tobago.Menu.mouseOver)
       .children('a')
       .unbind('focus', Tobago.Menu.open)
@@ -284,13 +284,13 @@ jQuery.tobagoMenuParent = function(eleme
 };
 
 /*
-  jQuery(this) is a list of "a" element of a menu item as jQuery object.
+  jQuery(this) is a list of "li" element of a menu item as jQuery object.
   Returns a list of "ol" objects. All sub menus as jQuery object.
 */
 (function(jQuery) {
   jQuery.fn.extend({
     tobagoMenu_findSubMenu: function() {
-      var menu = jQuery(this).next("ol");
+      var menu = jQuery(this).children("ol");
       jQuery(this).each(function() {
         menu = menu.add(Tobago.Utils.findSubComponent(jQuery(this), "menu"));
       });

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=1200469&r1=1200468&r2=1200469&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 Thu Nov 10 18:30:52 2011
@@ -75,3 +75,7 @@ Tobago.Utils.keepElementInVisibleArea = 
     element.css('top', top);
   });
 };
+
+Tobago.Utils.acceleratorKeyEvent = function() {
+  return jQuery.browser.webkit || jQuery.browser.mozilla ? 'keydown' : 'keypress';
+};

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=1200469&r1=1200468&r2=1200469&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 Thu Nov 10 18:30:52 2011
@@ -150,7 +150,7 @@ var Tobago = {
     },
 
     get: function(event) {
-      if (!event.type == 'keypress') {
+      if (!event.type == Tobago.Utils.acceleratorKeyEvent()) {
         return;
       }
       var keyCode = event.which ? event.which : event.keyCode;
@@ -275,7 +275,7 @@ var Tobago = {
       TbgTimer.endAppOnload = new Date(); // @DEV_ONLY
     } // @DEV_ONLY
 
-    this.addBindEventListener(document, 'keypress', this.acceleratorKeys, 'observe');
+    this.addBindEventListener(document, Tobago.Utils.acceleratorKeyEvent(), this.acceleratorKeys, 'observe');
 
     if (Tobago.resizeAction) {
       // firefox submits an onresize event