(function($, ns) { $(document).on('ToggleNavigationSearch:present', function(event) { var $element = $(event.target); var $navigationMenu = $('.js-navigation-menu', $element); var $navigationSearch = $('.js-navigation-search', $element); var $toggleSearchTrigger = $('.js-toggle-search-trigger', $element); var $toggleMenuTrigger = $('.js-toggle-menu-trigger', $element); var toggleNavigationSearch = { init: function() { if (window.undercase.BreakpointTell.isMobile()) { toggleNavigationSearch.showMenu(); } this.bind(); }, bind: function() { $toggleSearchTrigger.on('click', function(event) { event.preventDefault(); toggleNavigationSearch.showSearch(); }); $toggleMenuTrigger.on('click', function(event) { event.preventDefault(); toggleNavigationSearch.showMenu(); }); $(window).on('resize', function() { if(window.undercase.BreakpointTell.isMobile()) { if ($navigationMenu.is(':visible')) { toggleNavigationSearch.showMenu(); } else { toggleNavigationSearch.showSearch(); } } else { toggleNavigationSearch.showSearchAndMenu(); } }); }, showSearch: function() { $navigationSearch.show(); $navigationMenu.hide(); }, showMenu: function() { $navigationMenu.show(); $navigationSearch.hide(); }, showSearchAndMenu: function() { $navigationMenu.show(); $navigationSearch.show(); } } toggleNavigationSearch.init(); }); })(jQuery);