0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-13 22:41:32 -05:00
ghost/core/client/docs/js/nav.js
2014-07-29 18:48:31 +01:00

30 lines
No EOL
922 B
JavaScript

(function(){
if (matchMedia) {
var mq_max_1025 = window.matchMedia("(max-width: 1025px)");
mq_max_1025.addListener(show_hide_nav);
show_hide_nav(mq_max_1025);
}
function show_hide_nav(mq) {
var viewport = document.querySelector(".viewport"),
global_nav = document.querySelector(".global-nav"),
menu_button = document.querySelector(".menu-button");
menu_button.addEventListener("click", function(e) {
e.preventDefault();
viewport.classList.toggle("global-nav-expanded");
global_nav.classList.toggle("global-nav-expanded");
});
if (mq.matches) {
// Window is 1025px or less
} else {
// Window is 1026px or more
viewport.classList.remove("global-nav-expanded");
global_nav.classList.remove("global-nav-expanded");
}
}
})();