Skip to content

Instantly share code, notes, and snippets.

@codequistador
Created June 10, 2015 17:42
Show Gist options
  • Select an option

  • Save codequistador/da508771c5441c1a3776 to your computer and use it in GitHub Desktop.

Select an option

Save codequistador/da508771c5441c1a3776 to your computer and use it in GitHub Desktop.
Packsize Fancy Nav
/** SCRIPT FOR PRIMARY NAVIGATION **/
var primaryMenu = $("#pnav");
var primaryMenuItems = ["solutions", "resources", "company"];
$(window).on("load resize scroll", function () {
var head_row = $("#header_row").offset().left;
$.each(primaryMenuItems, function (k, v) {
if (primaryMenu.find("." + v).length) {
var hiddenMenu = primaryMenu.find("." + v).offset().left;
var leftWidth = hiddenMenu - head_row;
$("#sn-" + v).css("left", leftWidth);
var subnav = $("#sc-" + v).find('.subnav-message');
if (leftWidth < subnav.innerWidth() && subnav.innerWidth() > (leftWidth - 30)) {
subnav.css("width", leftWidth - 30 + "px");
} else {
subnav.css("width", "48%");
}
}
});
});
$(document).ready(function () {
$.each(primaryMenuItems, function (k, v) {
if ($("#sc-" + v).length) {
$("#pnav ." + v + ", #sc-" + v).each(function () {
$(this).hover(function () {
$("#sc-" + v).show();
primaryMenu.find("." + v + " a").addClass("active");
}, function () {
$("#sc-" + v).hide();
primaryMenu.find("." + v + " a").removeClass("active");
});
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment