// Add Zurb Foundation JavaScript to the DOM $(document).foundation(); //Get URL query string function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } return (false); } // Toggle visibility of content based on date $("[data-show-date], [data-hide-date]").each(function () { var showDateValue = $(this).data("show-date"); var hideDateValue = $(this).data("hide-date"); var showDate = new Date(showDateValue); var hideDate = new Date(hideDateValue); var today = new Date(); // Hide all elements with data-show-date and data-hide-date attributes $(this).hide(); // If element only has show-date attribute if ($(this).attr('data-show-date')) { if (today >= showDate) { $(this).show().css('display', 'block'); $(this).removeClass('hide'); } else { $(this).remove(); } } // If element only has hide-date attribute if ($(this).attr('data-hide-date')) { if (today <= hideDate) { $(this).removeClass('hide'); $(this).show().css('display', 'block'); } else { $(this).remove(); } } // If element has show-date and hide-date attribute if ($(this).attr('data-show-date') && $(this).attr('data-hide-date')) { if (today >= showDate && today <= hideDate) { $(this).removeClass('hide'); $(this).show().css('display', 'block'); } else { $(this).remove(); } } }); // Open Nav $('[data-open-nav]').on('click', function (e) { e.preventDefault(); $('[data-body-nav-container]').addClass('nav-is-active'); $('[data-nav-primary-item]').removeClass('is-active'); $(this).parent().addClass('is-active'); $('[data-nav-secondary]').addClass('is-active'); $('[data-nav-toggle-secondary]').addClass('is-active'); $('[data-nav-secondary]').addClass('hide'); $(this).parent().find('[data-nav-secondary]').removeClass('hide'); }); // Toggle Nav for Mobile $('[data-nav-toggle-primary]').on('click', function () { if ($('[data-nav-toggle-primary]').hasClass('is-active')) { $(this).removeClass('is-active'); $('[data-body-nav-container]').removeClass('nav-is-active'); $('[data-nav-secondary]').removeClass('is-active'); $('[data-nav-primary]').removeClass('is-active'); $('[data-nav-toggle-secondary]').removeClass('is-active'); } else { $(this).addClass('is-active'); $('[data-body-nav-container]').addClass('nav-is-active'); $('[data-nav-primary]').addClass('is-active'); } }); $('[data-nav-toggle-secondary]').on('click', function () { $('[data-nav-primary]').addClass('is-active'); $('[data-nav-secondary]').removeClass('is-active'); $('[data-nav-toggle-secondary]').removeClass('is-active'); }); // Close Nav $('[data-nav-primary-item].is-active').on('click', function () { $(this).removeClass('is-active'); $('[data-body-nav-container]').removeClass('nav-is-active'); }); $('[data-close-nav]').on('click', function () { $('[data-body-nav-container]').removeClass('nav-is-active'); $('[data-nav-secondary]').removeClass('is-active'); $('[data-nav-toggle-secondary]').removeClass('is-active'); $('[data-nav-primary-item]').removeClass('is-active'); }); $('[data-body-nav-container]').on('click', function (event) { if ($(event.target).closest('[data-nav-secondary].is-active, [data-nav-primary]').length === 0) { $('[data-body-nav-container]').removeClass('nav-is-active'); $('[data-nav-secondary]').removeClass('is-active'); $('[data-nav-toggle-secondary]').removeClass('is-active'); $('[data-nav-primary-item]').removeClass('is-active'); } }); /* Script to check whether to show the Closure Banner or not */ //var closureBannerStatus = localStorage.getItem("closureBanner"); //var closureBannerTime = localStorage.getItem("lastClosedTime"); //var currentDate = Date.now(); //if (closureBannerStatus === "hidden" && Math.abs(closureBannerTime - currentDate) < 86400000) { // $("#footer-notification").hide(); //} //$("#close-notification-button").click(function () { // currentDate = Date.now(); // $("#footer-notification").fadeOut(500); // localStorage.setItem("closureBanner", "hidden"); // localStorage.setItem("lastClosedTime", currentDate.toString()); // $("#footer-notification").slideUp(); //}); // Show account nav on click (if hidden) $('#accountNavToggle').on('click', function () { if ($('#accountNavPanel').children(':visible').length == 0) { $("#accountNavPanel").fadeIn(); } }); // Handle click events around account nav // If user clicks outside of #accountNavPanel, close the dropdown $(document).mouseup(function (e) { var accountNavPanel = $("#accountNavPanel"); // if the target of the click isn't the container nor a descendant of the container if (!accountNavPanel.is(e.target) && accountNavPanel.has(e.target).length === 0) { accountNavPanel.fadeOut(); } });