Skip to content

Pass the event object as parameter to callback options for future reference. #87

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
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 3 additions & 4 deletions example/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">

<!--
<!--
jQuery-menu-aim: the following styles are used to customize bootstrap's
dropdowns and popover to play a little nicer w/ this example. They are
personal choices and not necessary for your use of jQuery-menu-aim.
Expand Down Expand Up @@ -211,7 +211,7 @@ <h1>jQuery-menu-aim example</h1>
// contents. Again, this can be done in any number of ways. jQuery-menu-aim
// doesn't care how you do this, it just fires the activate and deactivate
// events at the right times so you know when to show and hide your submenus.
function activateSubmenu(row) {
function activateSubmenu(row, event) {
var $row = $(row),
submenuId = $row.data("submenuId"),
$submenu = $("#" + submenuId),
Expand All @@ -230,7 +230,7 @@ <h1>jQuery-menu-aim example</h1>
$row.find("a").addClass("maintainHover");
}

function deactivateSubmenu(row) {
function deactivateSubmenu(row, event) {
var $row = $(row),
submenuId = $row.data("submenuId"),
$submenu = $("#" + submenuId);
Expand Down Expand Up @@ -259,4 +259,3 @@ <h1>jQuery-menu-aim example</h1>

</body>
</html>

33 changes: 16 additions & 17 deletions jquery.menu-aim.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@
/**
* Cancel possible row activations when leaving the menu entirely
*/
var mouseleaveMenu = function() {
var mouseleaveMenu = function(event) {
if (timeoutId) {
clearTimeout(timeoutId);
}

// If exitMenu is supplied and returns true, deactivate the
// currently active row on menu exit.
if (options.exitMenu(this)) {
if (options.exitMenu(this, event)) {
if (activeRow) {
options.deactivate(activeRow);
options.deactivate(activeRow, event);
}

activeRow = null;
Expand All @@ -134,39 +134,39 @@
/**
* Trigger a possible row activation whenever entering a new row.
*/
var mouseenterRow = function() {
var mouseenterRow = function(event) {
if (timeoutId) {
// Cancel any previous activation delays
clearTimeout(timeoutId);
}

options.enter(this);
possiblyActivate(this);
options.enter(this, event);
possiblyActivate(this, event);
},
mouseleaveRow = function() {
options.exit(this);
mouseleaveRow = function(event) {
options.exit(this, event);
};

/*
* Immediately activate a row if the user clicks on it.
*/
var clickRow = function() {
activate(this);
var clickRow = function(event) {
activate(this, event);
};

/**
* Activate a menu row.
*/
var activate = function(row) {
var activate = function(row, event) {
if (row == activeRow) {
return;
}

if (activeRow) {
options.deactivate(activeRow);
options.deactivate(activeRow, event);
}

options.activate(row);
options.activate(row, event);
activeRow = row;
};

Expand All @@ -175,15 +175,15 @@
* shouldn't activate yet because user may be trying to enter
* a submenu's content, then delay and check again later.
*/
var possiblyActivate = function(row) {
var possiblyActivate = function(row, event) {
var delay = activationDelay();

if (delay) {
timeoutId = setTimeout(function() {
possiblyActivate(row);
possiblyActivate(row, event);
}, delay);
} else {
activate(row);
activate(row, event);
}
};

Expand Down Expand Up @@ -320,4 +320,3 @@

};
})(jQuery);