Skip to content

Instantly share code, notes, and snippets.

@tiff
Created November 8, 2012 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiff/4039835 to your computer and use it in GitHub Desktop.
Save tiff/4039835 to your computer and use it in GitHub Desktop.
(function() {
// Reset OTTO Nav HTML for to remove existing event listeners
var $container = $(".homepage");
var html = $container.html();
$container.html(html);
// Get nav items
var $items = $container.find(".sort");
$items.each(function(i) {
var $item = $items.eq(i);
// Show corresponding sub-nav layer
$item.on("mouseenter", function() {
var $anchor = $item.children("a");
$container.attr("id", $item.attr("id") + "_over");
$anchor.addClass("over");
// Hide sub-nav layer if mouse leaves within a certain timeframe
$anchor.one("mouseleave", function() {
$item.trigger("mouseleave");
});
setTimeout(function() {
$anchor.off("mouseleave");
}, 350);
$item.children("ul").show();
});
// Hide corresponding sub-nav layer
$item.on("mouseleave", function() {
$container.removeAttr("id");
$item.children("a").removeClass("over");
$item.children("ul").hide();
});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment