Rebuild the mobile menu to depend less on javascript.
This commit is contained in:
parent
3c444048f3
commit
d3761ce353
1 changed files with 166 additions and 132 deletions
|
|
@ -11,32 +11,20 @@
|
|||
$('html').removeClass('nojs').addClass('js');
|
||||
|
||||
// Activate the mobil menu for small screens.
|
||||
if (window.matchMedia && $('.mobile-nav-wrapper').length) {
|
||||
var mq = window.matchMedia('(max-width: 666px)');
|
||||
if (window.matchMedia && $('.mobile-nav').length) {
|
||||
var mq = window.matchMedia('(max-width: 999px)');
|
||||
if (mq.matches) {
|
||||
// Show mobile menu.
|
||||
$('.mobile-nav-wrapper').removeClass('hidden');
|
||||
|
||||
// Populate the mobile nav sheet.
|
||||
$('.header__region').filter(':not(:empty)').removeClass('header__region region hidden').addClass('js-region').appendTo('.mobile-nav-sheet');
|
||||
$('.main-menu').addClass('hidden').clone().removeClass('main-menu layout__navigation hidden').addClass('js-main-menu').appendTo('.mobile-nav-sheet').find('.navbar').removeClass('navbar').addClass('js-navbar');
|
||||
|
||||
// Toggle the mobile nav sheet.
|
||||
$('.mobile-nav-cover, .mobile-nav-toggle').click(function (e) {
|
||||
$('.mobile-nav__cover, .mobile-nav__toggle').click(function (e) {
|
||||
e.preventDefault();
|
||||
$('body').scrollTop(0).toggleClass('js-nav-open');
|
||||
});
|
||||
|
||||
// Close the nav sheet after click (needed for anchor links).
|
||||
$('.mobile-nav-sheet').find('a').click(function () {
|
||||
$('.mobile-nav__sheet').find('a').click(function () {
|
||||
$('body').removeClass('js-nav-open');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Display CSS grid layout warning to old browsers.
|
||||
// if (!window.CSS || !window.CSS.supports || !window.CSS.supports('display', 'grid')) {
|
||||
// $('.header').after('<div class="layout__grid-notice" role="complementary">Your browsers does not support modern grid layout so this page will not look or behave as it should. Resent versions of Chrome, Firefox and Safari all works so please update. Support is coming in Microsoft Edge as well, until then use another browser. <a href="https://www.whatbrowser.org/">What Browser?</a></div>');
|
||||
// }
|
||||
|
||||
})(jQuery);
|
||||
|
|
|
|||
Loading…
Reference in a new issue