1jQuery(function($) { 2 3 // Fixed nav 4 $.fn.checkHeaderPositioning = function(scrollEl, scrollClass) { 5 var $me = $(this); 6 7 if (!$me.length) { 8 return; 9 } 10 11 if($(scrollEl).scrollTop() > 50) { 12 $me.addClass(scrollClass); 13 } else if($(scrollEl).scrollTop() === 0) { 14 $me.removeClass(scrollClass); 15 } 16 }; 17 18 // Mobile sidebars 19 $.fn.expandableSidebar = function(expandedClass) { 20 var $me = this; 21 22 $me.on('click', function() { 23 if(!$me.hasClass(expandedClass)) { 24 $me.addClass(expandedClass); 25 } else { 26 $me.removeClass(expandedClass); 27 } 28 }); 29 } 30 31 // Interval loop 32 $.fn.intervalLoop = function(condition, action, duration, limit) { 33 var counter = 0; 34 var looper = setInterval(function(){ 35 if (counter >= limit || $.fn.checkIfElementExists(condition)) { 36 clearInterval(looper); 37 } else { 38 action(); 39 counter++; 40 } 41 }, duration); 42 } 43 44 // Check if element exists 45 $.fn.checkIfElementExists = function(selector) { 46 return $(selector).length; 47 } 48 49 var birdseyeController = { 50 init: function(opts) { 51 var base = this; 52 53 $('body').checkHeaderPositioning(window, 'affix'); 54 55 // Add classes to elements 56 base._addClasses(); 57 58 if(!$('body').hasClass('wsite-editor') && $('#wsite-nav-cart-a').length) { 59 $('#wsite-nav-cart-a').html($('#wsite-nav-cart-a').html().replace(/[()]/g, '')); 60 } 61 62 setTimeout(function(){ 63 base._checkCartItems(); 64 base._attachEvents(); 65 if($('#wsite-nav-cart-a').length) { 66 $('#wsite-nav-cart-a').html($('#wsite-nav-cart-a').html().replace(/[()]/g, '')); 67 } 68 $('.banner-wrap .container').css("padding-top", $('.birdseye-header').outerHeight() + "px"); 69 }, 1500); 70 }, 71 72 _addClasses: function() { 73 var base = this; 74 75 // Add fade in class to nav + logo + banner 76 $('body').addClass('fade-in'); 77
78 // Add class to nav items with subnav 79 $('.wsite-menu-default').find('li.wsite-menu-item-wrap').each(function(){ 80 var $me = $(this); 81 82 if($me.children('.wsite-menu-wrap').length > 0) { 83 $me.addClass('has-submenu'); 84 $('<span class="icon-caret"></span>').insertAfter($me.children('a.wsite-menu-item')); 85 } 86 }); 87 88 // Add class to subnav items with subnav 89 $('.wsite-menu').find('li.wsite-menu-subitem-wrap').each(function(){ 90 var $me = $(this); 91 92 if($me.children('.wsite-menu-wrap').length > 0) { 93 $me.addClass('has-submenu'); 94 $('<span class="icon-caret"></span>').insertAfter($me.children('a.wsite-menu-subitem')); 95 } 96 }); 97 98 // Keep subnav open if submenu item is active 99 if ($(window).width() < 1024) { 100 $('li.wsite-menu-subitem-wrap.wsite-nav-current').parents('.wsite-menu-wrap').addClass('open'); 101 } 102 103 // Add placeholder text to inputs 104 setTimeout(function(){ 105 $('.wsite-form-sublabel').each(function(){ 106 var sublabel = $(this).text(); 107 $(this).prev('.wsite-form-input').attr('placeholder', sublabel); 108 }); 109 }, 1000); 110 }, 111 112 _checkCartItems: function() { 113 var base = this; 114 if($('#wsite-mini-cart').find('li.wsite-product-item').length > 0) { 115 $('body').addClass('cart-full'); 116 } else { 117 $('body').removeClass('cart-full'); 118 } 119 }, 120 121 _moveLogin: function() { 122 var login = $('#member-login').clone(true); 123 $('.mobile-nav .wsite-menu-default > li:last-child').after(login); 124 }, 125 126 _moveFlyout: function() { 127 var maxheight = $(window).height() - $('.birdseye-header').outerHeight(); 128 var anchor = true; 129 130 $('#wsite-menus .wsite-menu-wrap').each(function() { 131 if ($(this).outerHeight() > maxheight) { 132 anchor = false; 133 } 134 }); 135 136 if (anchor) { 137 var move = $("#wsite-menus").detach(); 138 $(".birdseye-header").append(move); 139 } 140 }, 141 142 _moveCart: function() { 143 var move = $("#wsite-mini-cart").detach(); 144 $(".birdseye-header").append(move); 145 }, 146 147 _attachEvents: function() { 148 var base = this; 149 150 $('.hamburger').on('click', function(e) { 151 e.preventDefault(); 152 if (!$('body').hasClass('nav-open')) { 153 $('body').addClass('nav-open'); 154 } else { 155 $('body').removeClass('nav-open'); 156 } 157 }); 158 159 // Move cart + login 160 $.fn.intervalLoop('.mobile-nav #member-login', base._moveLogin, 800, 5); 161 162 // Move Flyout 163 $.fn.intervalLoop('.birdseye-header #wsite-menus', base._moveFlyout, 300, 8); 164 165 // Move Cart 166 $.fn.intervalLoop('.birdseye-header #wsite-mini-cart', base._moveCart, 300, 8); 167 168 // Check Cart 169 170 $.fn.intervalLoop('body.cart-full', base._checkCartItems, 300, 10); 171 172 // Window scroll 173 174 // Fixed header 175 $(window).on('scroll', function() { 176 $('body').checkHeaderPositioning(window, 'affix'); 177 }); 178 179 // Subnav toggle 180 $('li.has-submenu span.icon-caret').on('click', function() { 181 var $me = $(this); 182 183 if($me.siblings('.wsite-menu-wrap').hasClass('open')) { 184 $me.siblings('.wsite-menu-wrap').removeClass('open'); 185 } else { 186 $me.siblings('.wsite-menu-wrap').addClass('open'); 187 } 188 }); 189 190 // Store category dropdown 191 $('.wsite-com-sidebar').expandableSidebar('sidebar-expanded'); 192 193 // Search filters dropdown 194 $('#wsite-search-sidebar').expandableSidebar('sidebar-expanded'); 195 196 // Init fancybox swipe on mobile 197 if ('ontouchstart' in window) { 198 $('body').on('click', 'a.w-fancybox', function() { 199 base._initSwipeGallery(); 200 }); 201 } 202 }, 203 204 _initSwipeGallery: function() { 205 var base = this; 206 207 setTimeout(function(){ 208 var touchGallery = document.getElementsByClassName('fancybox-wrap')[0]; 209 var mc = new Hammer(touchGallery); 210 mc.on("panleft panright", function(ev) { 211 if (ev.type == "panleft") { 212 $("a.fancybox-next").trigger("click"); 213 } else if (ev.type == "panright") { 214 $("a.fancybox-prev").trigger("click"); 215 } 216 base._initSwipeGallery(); 217 }); 218 }, 500); 219 } 220 } 221 222 $(document).ready(function(){ 223 birdseyeController.init(); 224 }); 225});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.