(function($){ $(document).ready(function(){ if ( $('.preloader').length > 0 ) $('.preloader').delay(1000).fadeOut(); $('.top--bar .close').click(function(){ // $(this).slideUp(); $(this).parent().hide(); return false; }); $('.hamburger').click(function(){ // $(this).toggleClass('is-active'); $('.hamburger--menu-container').addClass('active'); $('.hamburger--menu').addClass('active'); $('.top').addClass('active'); return false; }); $('.hamburger--menu .close, .hamburger--menu-container').click(function(){ // $('.hamburger').removeClass('is-active'); $('.hamburger--menu-container').removeClass('active'); $('.hamburger--menu').removeClass('active'); $('.top').removeClass('active'); return false; }); $('.scroll--up').click(function(){ $('html').animate({ scrollTop: 0 }, 'slow'); return false; }); $('.top--shopping-cart').click(function(){ $('.shopping--bag-list--bg').toggleClass('active'); $('.shopping--bag-list').toggleClass('active'); $('.top').toggleClass('active'); return false; }); $('.shopping--bag-list--bg, .shopping--bag-close').click(function(){ $('.shopping--bag-list--bg, .shopping--bag-list').removeClass('active'); $('.top').removeClass('active'); return false; }); var position = $(window).scrollTop(); var timer; $(window).scroll(function() { // console.log(scroll + ' ' + position); // console.log(top_logo); // if(timer) { // window.clearTimeout(timer); // } // timer = window.setTimeout(function() { // actual callback console.log( "Firing!" ); var scroll = $(window).scrollTop(); //var top_logo = $('.top--logo').offset().top + $('.top--logo').outerHeight(); //var top_logo = $('header.top').offset().top + $('header.top').outerHeight(); //var top_logo = '143'; //var top_logo = $('header.top').offset().top - 143; var top_logo = $('header.top').outerHeight() - $('header.top').offset().top; // Down if ( scroll > position && scroll > top_logo) { $('header.top').addClass('fixed'); $('header.top').removeClass('down'); } else if ( scroll > position && scroll < top_logo ) { $('header.top').removeClass('fixed'); $('header.top').removeClass('down'); // Up } else if ( scroll < position && scroll > top_logo ) { $('header.top').addClass('fixed'); $('header.top').addClass('down'); } else if ( scroll < position && scroll < top_logo ) { $('header.top').removeClass('fixed'); $('header.top').removeClass('down'); } /*if($(window).scrollTop() + $(window).height() > $(document).height()-143){ $('.account--bar').removeClass('fixed_'); }else{ $('.account--bar').addClass('fixed_'); }*/ position = scroll; //console.log(top_logo); // }, 50); }); function throttle(fn, threshhold, scope) { threshhold || (threshhold = 250); var last, deferTimer; return function () { var context = scope || this; var now = +new Date, args = arguments; if (last && now < last + threshhold) { // hold on to it clearTimeout(deferTimer); deferTimer = setTimeout(function () { last = now; fn.apply(context, args); }, threshhold); } else { last = now; fn.apply(context, args); } }; } //Custom dropdown // Iterate over each select element $('.product--category-list .form-group.select select').each(function () { // Cache the number of options var $this = $(this), numberOfOptions = $(this).children('option').length; // Hides the select element $this.addClass('s-hidden'); // Wrap the select element in a div $this.wrap('
'); // Insert a styled div to sit over the top of the hidden select element $this.after(''); // Cache the styled div var $styledSelect = $this.next('div.styledSelect'); // Show the first select option in the styled div $styledSelect.text($this.children('option').eq(0).text()); // Insert an unordered list after the styled div and also cache the list var $list = $('