myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject svn commit: r1480906 - 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...
Date Fri, 10 May 2013 07:54:20 GMT
Author: weber
Date: Fri May 10 07:54:20 2013
New Revision: 1480906

URL: http://svn.apache.org/r1480906
Log:
TOBAGO-1261 - Keyboard navigation in Menubar

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

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=1480906&r1=1480905&r2=1480906&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
Fri May 10 07:54:20 2013
@@ -74,6 +74,10 @@ public class MenuRenderer extends Layout
     writer.startElement(HtmlElements.A, menu);
     writer.writeAttribute(HtmlAttributes.HREF, "#", false);
 
+    if (component != null && !component.isTransient()) {
+      writer.writeIdAttribute(component.getClientId(facesContext));
+    }
+
     LabelWithAccessKey label = new LabelWithAccessKey(menu);
     if (label.getText() != null) {
       if (label.getAccessKey() != 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=1480906&r1=1480905&r2=1480906&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
Fri May 10 07:54:20 2013
@@ -73,9 +73,17 @@ Tobago.Menu.handelKey = function(event) 
       break;
     case 37: // cursor left
       if (jQuery(this).parent().hasClass('tobago-menu-markup-top')) {
-        jQuery(this).parent().prev('li').children('a').focus();
-      } else if (jQuery(this).parent().parent().tobagoMenu_findParentMenu().parent().hasClass('tobago-menu-markup-top'))
{
-        jQuery(this).parent().parent().tobagoMenu_findParentMenu().parent().prev('li').children('a').focus();
+        // on top: if on first goto last else goto prev
+        var prevMenu = jQuery(this).parent().prev('li');
+        if (prevMenu.length == 0) {
+          // goto last
+          jQuery(this).parent().nextAll('li:last').children('a').eq(0).focus();
+        } else {
+          // goto prev
+          prevMenu.children('a').focus();
+        }
+      } else if (jQuery(this).parent().parent().tobagoMenu_findParentMenu().hasClass('tobago-menu-markup-top'))
{
+        jQuery(this).parent().parent().tobagoMenu_findParentMenu().prev('li').children('a').focus();
       } else {
         jQuery(this).closest('ol').prev('a').focus();
       }
@@ -83,27 +91,53 @@ Tobago.Menu.handelKey = function(event) 
       break;
     case 38: // cursor up
       if (jQuery(this).parent().hasClass('tobago-menu-markup-top')) {
-        // nothing
+        // on top: goto last child
+        jQuery(this).parent().tobagoMenu_findSubMenu().children(":last-child").children('a').focus();
       } else {
-        jQuery(this).parent().prevAll('li').children('a').eq(0).focus();
+        // if on first goto last else goto prev
+        var prevAll = jQuery(this).parent().prevAll('li');
+        if (prevAll.length == 0) {
+          // goto last
+          jQuery(this).parent().nextAll('li:last').children('a').eq(0).focus();
+        } else {
+          // goto prev
+          prevAll.children('a').eq(0).focus();
+        }
       }
       handled = true;
       break;
     case 39: // cursor right
       if (jQuery(this).parent().hasClass('tobago-menu-markup-top')) {
-        jQuery(this).parent().next('li').children('a').focus();
+        // on top: if on last goto first else goto next
+        var nextMenu = jQuery(this).parent().next('li');
+        if (nextMenu.length == 0) {
+          // goto first
+          jQuery(this).parent().prevAll('li:last').children('a').eq(0).focus();
+        } else {
+          // goto next
+          nextMenu.children('a').eq(0).focus();
+        }
       } else if (jQuery(this).next('ol').size() > 0) {
         jQuery(this).next('ol').children(":nth-child(1)").children('a').focus();
       } else {
-        jQuery(this).parents('ol:last').tobagoMenu_findParentMenu().parent().next('li').children('a').focus();
+        jQuery(this).parents('ol:last').tobagoMenu_findParentMenu().next('li').children('a').focus();
       }
       handled = true;
       break;
     case 40: // cursor down
       if (jQuery(this).parent().hasClass('tobago-menu-markup-top')) {
-        jQuery(this).parent().tobagoMenu_findSubMenu().children(":nth-child(1)").children('a').focus();
+        // on top: goto first child
+        jQuery(this).parent().tobagoMenu_findSubMenu().children(":first-child").children('a').focus();
       } else {
-        jQuery(this).parent().nextAll('li').children('a').eq(0).focus();
+        // if on last goto first else goto next
+        var nextAll2 = jQuery(this).parent().nextAll('li');
+        if (nextAll2.length == 0) {
+          // goto first
+          jQuery(this).parent().prevAll('li:last').children('a').eq(0).focus();
+        } else {
+          // goto next
+          nextAll2.children('a').eq(0).focus();
+        }
       }
       handled = true;
       break;



Mime
View raw message