Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open on click #45

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions js/jquery-accessibleMegaMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ limitations under the License.
panelGroupClass: "accessible-megamenu-panel-group", // default css class for a group of items within a megamenu panel
hoverClass: "hover", // default css class for the hover state
focusClass: "focus", // default css class for the focus state
openClass: "open" // default css class for the open state
openClass: "open", // default css class for the open state
openDelay: 0 // default open delay when opening menu via mouseover
},
Keyboard = {
BACKSPACE: 8,
Expand Down Expand Up @@ -633,6 +634,7 @@ limitations under the License.
if ($(event.target).is(this.settings.panelClass) || $(event.target).closest(":focusable").length) {
this.mouseFocused = true;
}
clearTimeout(this.mouseTimeoutID);
this.mouseTimeoutID = setTimeout(function () {
clearTimeout(this.focusTimeoutID);
}, 1);
Expand All @@ -647,13 +649,16 @@ limitations under the License.
* @private
*/
_mouseOverHandler = function (event) {
if (this.settings.openOnClick) { return; }
clearTimeout(this.mouseTimeoutID);
$(event.target)
.addClass(this.settings.hoverClass);
_togglePanel.call(this, event);
if ($(event.target).is(':tabbable')) {
$('html').on('keydown.accessible-megamenu', $.proxy(_keyDownHandler, event.target));
}
var that = this;
this.mouseTimeoutID = setTimeout(function () {
$(event.target).addClass(that.settings.hoverClass);
_togglePanel.call(that, event);
if ($(event.target).is(':tabbable')) {
$('html').on('keydown.accessible-megamenu', $.proxy(_keyDownHandler, event.target));
}
}, this.settings.openDelay);
};

/**
Expand All @@ -665,6 +670,7 @@ limitations under the License.
* @private
*/
_mouseOutHandler = function (event) {
clearTimeout(this.mouseTimeoutID);
var that = this;
$(event.target)
.removeClass(that.settings.hoverClass);
Expand Down Expand Up @@ -706,7 +712,10 @@ limitations under the License.
var settings = this.settings,
nav = $(this.element),
menu = nav.children().first(),
topnavitems = menu.children();
// Only filter to those items with the selector class
topnavitems = this.settings.selectors.topNavItems ?
menu.children(this.settings.selectors.topNavItems) :
menu.children();
this.start(settings, nav, menu, topnavitems);
},

Expand Down Expand Up @@ -752,7 +761,6 @@ limitations under the License.
.on("mouseover.accessible-megamenu", $.proxy(_mouseOverHandler, this))
.on("mouseout.accessible-megamenu", $.proxy(_mouseOutHandler, this))
.on("mousedown.accessible-megamenu", $.proxy(_mouseDownHandler, this));

if (isTouch) {
menu.on("touchstart.accessible-megamenu", $.proxy(_clickHandler, this));
}
Expand Down Expand Up @@ -993,6 +1001,8 @@ limitations under the License.
* @param {string} [options.hoverClass=hover] - CSS class for the hover state
* @param {string} [options.focusClass=focus] - CSS class for the focus state
* @param {string} [options.openClass=open] - CSS class for the open state
* @param {boolean} [options.openOnClick=false] - Whether to open the menu on click (rather than hover)
* @param {string} [options.openDelay=0] - Open delay when opening menu via mouseover
*/
$.fn[pluginName] = function (options) {
return this.each(function () {
Expand Down
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "accessible-mega-menu",
"version": "1.0.0",
"description": "Fork of Adobe's Accessible Mega Menu ",
"main": "js/jquery-accessibleMegaMenu.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/noahmanger/Accessible-Mega-Menu.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/noahmanger/Accessible-Mega-Menu/issues"
},
"homepage": "https://github.com/noahmanger/Accessible-Mega-Menu#readme"
}