1jQuery(function($) { 2 3 4 5//Smooth scrolling 6 7// Select all links with hashes 8$('a[href*="#"]') 9 // Remove links that don't actually link to anything 10 .not('[href="#"]') 11 .not('[href="#0"]') 12 .click(function(event) { 13 // On-page links 14 if ( 15 location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') 16 && 17 location.hostname == this.hostname 18 ) { 19 // Figure out element to scroll to 20 var target = $(this.hash); 21 target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); 22 // Does a scroll target exist? 23 if (target.length) { 24 // Only prevent default if animation is actually gonna happen 25 event.preventDefault(); 26 $('html, body').animate({ 27 scrollTop: target.offset().top 28 }, 1000, function() { 29 // Callback after animation 30 // Must change focus! 31 var $target = $(target); 32 $target.focus(); 33 if ($target.is(":focus")) { // Checking if the target was focused 34 return false; 35 } else { 36 $target.attr('tabindex','-1'); // Adding tabindex for elements not focusable 37 $target.focus(); // Set focus again 38 }; 39 }); 40 } 41 } 42 }); 43 44 45 46 47 48 49 // Fixed nav 50 $.fn.checkHeaderPositioning = function(scrollEl, scrollClass) { 51 var $me = $(this); 52 53 if (!$me.length) { 54 return; 55 } 56 57 if($(scrollEl).scrollTop() > 50) { 58 $me.addClass(scrollClass); 59 } else if($(scrollEl).scrollTop() === 0) { 60 $me.removeClass(scrollClass); 61 } 62 }; 63 64 // Mobile sidebars 65 $.fn.expandableSidebar = function(expandedClass) { 66 var $me = this; 67 68 $me.on('click', function() { 69 if(!$me.hasClass(expandedClass)) { 70 $me.addClass(expandedClass); 71 } else { 72 $me.removeClass(expandedClass); 73 } 74 }); 75 } 76 77 // Interval loop 78 $.fn.intervalLoop = function(condition, action, duration, limit) { 79 var counter = 0; 80 var looper = setInterval(function(){ 81 if (counter >= limit || $.fn.checkIfElementExists(condition)) { 82 clearInterval(looper); 83 } else { 84 action(); 85 counter++; 86 } 87 }, duration); 88 } 89 90 // Check if element exists 91 $.fn.checkIfElementExists = function(selector) { 92 return $(selector).length; 93 } 94 95 var birdseyeController = { 96 init: function(opts) { 97 var base = this; 98 99 $('body').checkHeaderPositioning(window, 'affix'); 100 101 // Add classes to elements 102 base._addClasses(); 103 104 if(!$('body').hasClass('wsite-editor') && $('#wsite-nav-cart-a').length) { 105 $('#wsite-nav-cart-a').html($('#wsite-nav-cart-a').html().replace(/[()]/g, '')); 106 } 107 108 setTimeout(function(){ 109 base._checkCartItems(); 110 base._attachEvents(); 111 if($('#wsite-nav-cart-a').length) { 112 $('#wsite-nav-cart-a').html($('#wsite-nav-cart-a').html().replace(/[()]/g, '')); 113 } 114 $('.banner-wrap .container').css("padding-top", $('.birdseye-header').outerHeight() + "px"); 115 }, 1500); 116 }, 117 118 _addClasses: function() { 119 var base = this; 120 121 // Add fade in class to nav + logo + banner 122 $('body').addClass('fade-in'); 123
124 // Add class to nav items with subnav 125 $('.wsite-menu-default').find('li.wsite-menu-item-wrap').each(function(){ 126 var $me = $(this); 127 128 if($me.children('.wsite-menu-wrap').length > 0) { 129 $me.addClass('has-submenu'); 130 $('<span class="icon-caret"></span>').insertAfter($me.children('a.wsite-menu-item')); 131 } 132 }); 133 134 // Add class to subnav items with subnav 135 $('.wsite-menu').find('li.wsite-menu-subitem-wrap').each(function(){ 136 var $me = $(this); 137 138 if($me.children('.wsite-menu-wrap').length > 0) { 139 $me.addClass('has-submenu'); 140 $('<span class="icon-caret"></span>').insertAfter($me.children('a.wsite-menu-subitem')); 141 } 142 }); 143 144 // Keep subnav open if submenu item is active 145 if ($(window).width() < 1024) { 146 $('li.wsite-menu-subitem-wrap.wsite-nav-current').parents('.wsite-menu-wrap').addClass('open'); 147 } 148 149 // Add placeholder text to inputs 150 setTimeout(function(){ 151 $('.wsite-form-sublabel').each(function(){ 152 var sublabel = $(this).text(); 153 $(this).prev('.wsite-form-input').attr('placeholder', sublabel); 154 }); 155 }, 1000); 156 }, 157 158 _checkCartItems: function() { 159 var base = this; 160 if($('#wsite-mini-cart').find('li.wsite-product-item').length > 0) { 161 $('body').addClass('cart-full'); 162 } else { 163 $('body').removeClass('cart-full'); 164 } 165 }, 166 167 _moveLogin: function() { 168 var login = $('#member-login').clone(true); 169 $('.mobile-nav .wsite-menu-default > li:last-child').after(login); 170 }, 171 172 _moveFlyout: function() { 173 var maxheight = $(window).height() - $('.birdseye-header').outerHeight(); 174 var anchor = true; 175 176 $('#wsite-menus .wsite-menu-wrap').each(function() { 177 if ($(this).outerHeight() > maxheight) { 178 anchor = false; 179 } 180 }); 181 182 if (anchor) { 183 var move = $("#wsite-menus").detach(); 184 $(".birdseye-header").append(move); 185 } 186 }, 187 188 _moveCart: function() { 189 var move = $("#wsite-mini-cart").detach(); 190 $(".birdseye-header").append(move); 191 }, 192 193 _attachEvents: function() { 194 var base = this; 195 196 $('.hamburger').on('click', function(e) { 197 e.preventDefault(); 198 if (!$('body').hasClass('nav-open')) { 199 $('body').addClass('nav-open'); 200 } else { 201 $('body').removeClass('nav-open'); 202 } 203 }); 204 205 // Move cart + login 206 $.fn.intervalLoop('.mobile-nav #member-login', base._moveLogin, 800, 5); 207 208 // Move Flyout 209 $.fn.intervalLoop('.birdseye-header #wsite-menus', base._moveFlyout, 300, 8); 210 211 // Move Cart 212 $.fn.intervalLoop('.birdseye-header #wsite-mini-cart', base._moveCart, 300, 8); 213 214 // Check Cart 215 216 $.fn.intervalLoop('body.cart-full', base._checkCartItems, 300, 10); 217 218 // Window scroll 219 220 // Fixed header 221 $(window).on('scroll', function() { 222 $('body').checkHeaderPositioning(window, 'affix'); 223 }); 224 225 // Subnav toggle 226 $('li.has-submenu span.icon-caret').on('click', function() { 227 var $me = $(this); 228 229 if($me.siblings('.wsite-menu-wrap').hasClass('open')) { 230 $me.siblings('.wsite-menu-wrap').removeClass('open'); 231 } else { 232 $me.siblings('.wsite-menu-wrap').addClass('open'); 233 } 234 }); 235 236 // Store category dropdown 237 $('.wsite-com-sidebar').expandableSidebar('sidebar-expanded'); 238 239 // Search filters dropdown 240 $('#wsite-search-sidebar').expandableSidebar('sidebar-expanded'); 241 242 // Init fancybox swipe on mobile 243 if ('ontouchstart' in window) { 244 $('body').on('click', 'a.w-fancybox', function() { 245 base._initSwipeGallery(); 246 }); 247 } 248 }, 249 250 _initSwipeGallery: function() { 251 var base = this; 252 253 setTimeout(function(){ 254 var touchGallery = document.getElementsByClassName('fancybox-wrap')[0]; 255 var mc = new Hammer(touchGallery); 256 mc.on("panleft panright", function(ev) { 257 if (ev.type == "panleft") { 258 $("a.fancybox-next").trigger("click"); 259 } else if (ev.type == "panright") { 260 $("a.fancybox-prev").trigger("click"); 261 } 262 base._initSwipeGallery(); 263 }); 264 }, 500); 265 } 266 } 267 268 $(document).ready(function(){ 269 birdseyeController.init(); 270 }); 271});
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.