Created
November 8, 2012 16:20
-
-
Save tiff/4039835 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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