Skip to content

Commit

Permalink
adobe-accessibility#41, Add RTL keyboard navigation support
Browse files Browse the repository at this point in the history
  • Loading branch information
reissr committed Aug 10, 2016
1 parent 726ea8e commit 3e77387
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions js/jquery-accessibleMegaMenu.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ limitations under the License.
(function ($, window, document) {
"use strict";
var pluginName = "accessibleMegaMenu",
isRtl = ($('html').attr('dir') === 'rtl'),
defaults = {
uuidPrefix: "accessible-megamenu", // unique ID's are required to indicate aria-owns, aria-controls and aria-labelledby
menuClass: "accessible-megamenu", // default css class used to define the megamenu styling
Expand Down Expand Up @@ -125,6 +126,10 @@ limitations under the License.
190: "."
}
};

defaults.prevKey = isRtl ? Keyboard.RIGHT : Keyboard.LEFT,
defaults.nextKey = isRtl ? Keyboard.LEFT : Keyboard.RIGHT;

/**
* @desc Creates a new accessible mega menu instance.
* @param {jquery} element
Expand Down Expand Up @@ -489,7 +494,7 @@ limitations under the License.
found = ($(':tabbable:lt(' + $(':tabbable').index(target) + '):first').focus().length === 1);
}
break;
case Keyboard.RIGHT:
case defaults.nextKey:
event.preventDefault();
if (isTopNavItem) {
found = (topnavitems.filter(':gt(' + topnavitems.index(topli) + '):first').find(':tabbable:first').focus().length === 1);
Expand All @@ -504,7 +509,7 @@ limitations under the License.
}
}
break;
case Keyboard.LEFT:
case defaults.prevKey:
event.preventDefault();
if (isTopNavItem) {
found = (topnavitems.filter(':lt(' + topnavitems.index(topli) + '):last').find(':tabbable:first').focus().length === 1);
Expand Down

0 comments on commit 3e77387

Please sign in to comment.