(function($, Drupal){ Drupal.behaviors.navBehaviours = { attach: function (context, settings) { // $(window).once('accountWindowBehaviour').on('load', function() { var urlParams = new URLSearchParams(window.location.search); //get all parameters var customer = urlParams.get('customer'); //extract the foo parameter - this will return NULL if customer isn't a parameter var cart = urlParams.get('cart'); //extract the foo parameter - this will return NULL if customer isn't a parameter if ( customer && !$('.nav-window.account').hasClass('loaded') ) { $('body').addClass('account-open noscroll'); $('.nav-window.account').addClass('open loaded'); $('body > div, #block-815eatsnavigation').css('left','unset'); } if ( cart && !$('.nav-window.cart').hasClass('loaded') ) { $('body').addClass('cart-open noscroll'); $('.nav-window.cart').addClass('open loaded'); $('body > div, #block-815eatsnavigation').css('left','unset'); } // }); $('.eightonefive-nav > div:not(.eightonefive-logo), a.add-to-cart').once('navWindowBehaviour').click( function() { if ($(this).hasClass('open')) { if (!$(this).hasClass('.add-to-cart')) { $(this).removeClass('open'); } $('body').removeClass('menu-open account-open cart-open noscroll'); $('.nav-window.open').removeClass('open'); } else { $('.eightonefive-nav > div.open').removeClass('open'); $(this).addClass('open'); // if (!$(this).hasClass('.add-to-cart')) { // $('.eightonefive-cart').addClass('open'); // } $('#quick-view').fadeOut(); $('body').removeClass('menu-open account-open cart-open'); $('.nav-window.open').removeClass('open'); var windowAction = $(this).data('nav-action'); $('body').addClass(windowAction + '-open noscroll'); $('.nav-window.' + windowAction).addClass('open'); if (windowAction !== 'menu') { $('body > div, #block-815eatsnavigation').css('left','unset'); } } }); $('.nav-overlay, .nav-close').once('navCloseBehaviour').click( function() { $('.eightonefive-nav > div.open, a.add-to-cart.open').removeClass('open'); $('body').removeClass('menu-open account-open cart-open noscroll'); $('.nav-window.open').removeClass('open'); $('.nav-window').animate({ opacity: 0, },400, function() { $('.nav-window, body > div, #block-815eatsnavigation').removeAttr('style'); }); }); $('.dropdown-toggle').once('dropdownMenuBehaviour').click(function(e) { if (!$(this).hasClass('open')) { // $('.dropdown-toggle.open').removeClass('open').parent().children('.dropdown-menu').slideUp(); $(this).addClass('open'); $(this).parent().children('.dropdown-menu').slideDown(); } else { $(this).removeClass('open'); $(this).parent().children('.dropdown-menu').slideUp(); } e.preventDefault(); }); $('a.quick-view').once('viewFactsBehaviour').click(function() { $('#quick-view').fadeIn(); $('body').addClass('noscroll'); }); $('#quick-view').once('closeFactsBehaviour').click(function (e) { if (!$(e.target).closest('#quick-view > div > div').length) { $('#quick-view').fadeOut().html(''); $('body').removeClass('noscroll'); } }); } } })(jQuery, Drupal);