/************************************************************************** * Common js **************************************************************************/ jQuery(document).ready(function() { "use strict"; /* Bestsell slider */ jQuery("#bestsell-slider .slider-items").owlCarousel({ items: 4, //10 items above 1000px browser width itemsDesktop: [1024, 3], //5 items between 1024px and 901px itemsDesktopSmall: [992, 2], // 3 items betweem 900px and 601px itemsTablet: [767, 2], //2 items between 600 and 0; itemsMobile: [479, 1], navigation: true, navigationText: ["", ""], slideSpeed: 500, pagination: false }); /* Featured slider */ jQuery("#featured-slider .slider-items").owlCarousel({ items: 4, //10 items above 1000px browser width itemsDesktop: [1024, 3], //5 items between 1024px and 901px itemsDesktopSmall: [992, 2], // 3 items betweem 900px and 601px itemsTablet: [767, 2], //2 items between 600 and 0; itemsMobile: [479, 1], navigation: true, navigationText: ["", ""], slideSpeed: 500, pagination: false }); /* New arrivals slider */ jQuery("#new-arrivals-slider .slider-items").owlCarousel({ items: 4, //10 items above 1000px browser width itemsDesktop: [1024, 3], //5 items between 1024px and 901px itemsDesktopSmall: [992, 2], // 3 items betweem 900px and 601px itemsTablet: [767, 2], //2 items between 600 and 0; itemsMobile: [479, 1], navigation: true, navigationText: ["", ""], slideSpeed: 500, pagination: false }); /* Brand logo slider */ jQuery("#brand-logo-slider .slider-items").owlCarousel({ autoPlay: true, items: 6, //10 items above 1000px browser width itemsDesktop: [1024, 4], //5 items between 1024px and 901px itemsDesktopSmall: [900, 3], // 3 items betweem 900px and 601px itemsTablet: [600, 2], //2 items between 600 and 0; itemsMobile: [320, 1], navigation: true, navigationText: ["", ""], slideSpeed: 500, pagination: false }); /* Category desc slider */ jQuery("#category-desc-slider .slider-items").owlCarousel({ autoPlay: true, items: 1, //10 items above 1000px browser width itemsDesktop: [1024, 1], //5 items between 1024px and 901px itemsDesktopSmall: [900, 1], // 3 items betweem 900px and 601px itemsTablet: [600, 1], //2 items between 600 and 0; itemsMobile: [320, 1], navigation: true, navigationText: ["", ""], slideSpeed: 500, pagination: false }); /* Related products slider */ jQuery("#related-products-slider .slider-items").owlCarousel({ items: 4, //10 items above 1000px browser width itemsDesktop: [1024, 3], //5 items between 1024px and 901px itemsDesktopSmall: [900, 3], // 3 items betweem 900px and 601px itemsTablet: [768, 2], //2 items between 600 and 0; itemsMobile: [360, 1], navigation: true, navigationText: ["", ""], slideSpeed: 500, pagination: false }); /* Upsell products slider */ jQuery("#upsell-products-slider .slider-items").owlCarousel({ items: 4, //10 items above 1000px browser width itemsDesktop: [1024, 3], //5 items between 1024px and 901px itemsDesktopSmall: [900, 3], // 3 items betweem 900px and 601px itemsTablet: [768, 2], //2 items between 600 and 0; itemsMobile: [360, 1], navigation: true, navigationText: ["", ""], slideSpeed: 500, pagination: false }); /* Mobile menu */ jQuery("#mobile-menu").mobileMenu({ MenuWidth: 250, SlideSpeed: 300, WindowsMaxWidth: 767, PagePush: true, FromLeft: true, Overlay: true, CollapseMenu: true, ClassName: "mobile-menu" }); /* side nav categories */ if (jQuery('.subDropdown')[0]) { jQuery('.subDropdown').on("click", function() { jQuery(this).toggleClass('plus'); jQuery(this).toggleClass('minus'); jQuery(this).parent().find('ul').slideToggle(); }); } jQuery.extend(jQuery.easing, { easeInCubic: function(x, t, b, c, d) { return c * (t /= d) * t * t + b; }, easeOutCubic: function(x, t, b, c, d) { return c * ((t = t / d - 1) * t * t + 1) + b; }, }); (function(jQuery) { jQuery.fn.extend({ accordion: function() { return this.each(function() { function activate(el, effect) { jQuery(el).siblings(panelSelector)[(effect || activationEffect)](((effect == "show") ? activationEffectSpeed : false), function() { jQuery(el).parents().show(); }); } }); } }); })(jQuery); jQuery(function(jQuery) { jQuery('.accordion').accordion(); jQuery('.accordion').each(function(index) { var activeItems = jQuery(this).find('li.active'); activeItems.each(function(i) { jQuery(this).children('ul').css('display', 'block'); if (i == activeItems.length - 1) { jQuery(this).addClass("current"); } }); }); }); /* Top Cart js */ function slideEffectAjax() { jQuery('.top-cart-contain').mouseenter(function() { jQuery(this).find(".top-cart-content").stop(true, true).slideDown(); }); jQuery('.top-cart-contain').mouseleave(function() { jQuery(this).find(".top-cart-content").stop(true, true).slideUp(); }); } jQuery(document).ready(function() { slideEffectAjax(); }); /* sticky header */ jQuery(window).scroll(function() { jQuery(this).scrollTop() > 1 ? jQuery("nav").addClass("sticky-header") : jQuery("nav").removeClass("sticky-header") /*jQuery(this).scrollTop() > 1 ? jQuery(".top-cart-contain").addClass("sticky-topcart") : jQuery(".top-cart-contain").removeClass("sticky-topcart")*/ }); jQuery("#mobile-menu").on('click', 'li.level2 span.expand', function(){ //Close all open third level menu jQuery("#mobile-menu li.level2 span.expand.open").removeClass('fa-minus open').addClass('fa-plus').parent().find("ul.level3").hide("slow"); if(jQuery(this).hasClass('open')){ jQuery(this).removeClass('fa-minus open').addClass("fa-plus"); jQuery(this).parent().find("ul.level3").hide("slow"); } else { jQuery(this).removeClass('fa-plus').addClass("fa-minus open"); jQuery(this).parent().find("ul.level3").show("slow"); } }); jQuery("#mobile-menu").on('click', '#my-mobile-menu ul li span.expand', function(){ if(jQuery(this).hasClass('open')){ jQuery(this).removeClass('fa-minus open').addClass("fa-plus"); } else { jQuery(this).removeClass('fa-plus').addClass("fa-minus open"); } }); }); /* UItoTop */ jQuery.fn.UItoTop = function(options) { var defaults = { text: '', min: 200, inDelay: 600, outDelay: 400, containerID: 'toTop', containerHoverID: 'toTopHover', scrollSpeed: 1200, easingType: 'linear' }; var settings = jQuery.extend(defaults, options); var containerIDhash = '#' + settings.containerID; var containerHoverIDHash = '#' + settings.containerHoverID; jQuery('body').append('' + settings.text + ''); jQuery(containerIDhash).hide().on("click", function() { jQuery('html, body').animate({ scrollTop: 0 }, settings.scrollSpeed, settings.easingType); jQuery('#' + settings.containerHoverID, this).stop().animate({ 'opacity': 0 }, settings.inDelay, settings.easingType); return false; }).prepend('').hover(function() { jQuery(containerHoverIDHash, this).stop().animate({ 'opacity': 1 }, 600, 'linear'); }, function() { jQuery(containerHoverIDHash, this).stop().animate({ 'opacity': 0 }, 700, 'linear'); }); jQuery(window).scroll(function() { var sd = jQuery(window).scrollTop(); if (typeof document.body.style.maxHeight === "undefined") { jQuery(containerIDhash).css({ 'position': 'absolute', 'top': jQuery(window).scrollTop() + jQuery(window).height() - 50 }); } if (sd > settings.min) jQuery(containerIDhash).fadeIn(settings.inDelay); else jQuery(containerIDhash).fadeOut(settings.Outdelay); }); }; /* mobileMenu */ var isTouchDevice = ('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0); jQuery(window).on("load", function() { if (isTouchDevice) { jQuery('#nav a.level-top').on("click", function(e) { jQueryt = jQuery(this); jQueryparent = jQueryt.parent(); if (jQueryparent.hasClass('parent')) { if (!jQueryt.hasClass('menu-ready')) { jQuery('#nav a.level-top').removeClass('menu-ready'); jQueryt.addClass('menu-ready'); return false; } else { jQueryt.removeClass('menu-ready'); } } }); } jQuery().UItoTop(); $typeAHeadSearchInput = $('.menu-autocomplete-search'); $typeAHeadSearchInput.typeahead({ autoSelect: false, minLength: 1, highlight: true, items: 20, source: function (query, process) { return $.get($(".menu-autocomplete-search").data("autocomplete-path"), { query: query }, function (data) { return process(data); }); } }) // Submit the form if the user hits "enter" .on('keydown', function (event) { //responsiveSearchField if (event.which === 13) { if($(this).hasClass("responsiveSearchField")){ $(".responsiveSearchButton").trigger('click'); } else{ $(".search-button").trigger('click'); } } }); $typeAHeadSearchInput.change(function() { var current = $(this).typeahead("getActive"); if (current) { // Some item from your model is active! window.location.href = current.route; } }); });