jQuery(function() { var $ = jQuery; $('body').addClass('postload'); var Theme = { // Swiping mobile galleries wwith Hammer.js swipeGallery: function() { setTimeout(function() { var touchGallery = document.getElementsByClassName("fancybox-wrap")[0]; var mc = new Hammer(touchGallery); mc.on("panleft panright", function(ev) { if (ev.type == "panleft") { $("a.fancybox-next").trigger("click"); } else if (ev.type == "panright") { $("a.fancybox-prev").trigger("click"); } Theme.swipeGallery(); }); }, 500); }, swipeInit: function() { if ('ontouchstart' in window) { $("body").on("click", "a.w-fancybox", function() { Theme.swipeGallery(); }); } }, // Hide minicart better on mobile hideCart: function(){ if ('ontouchstart' in window) { $('#banner, #main-content, #footer-wrap').on('click touchend mouseenter', function () { $('#wsite-mini-cart').fadeOut("fast"); }); } }, interval: function(condition, action, duration, limit) { var counter = 0; var looper = setInterval(function(){ if (counter >= limit || Theme.checkElement(condition)) { clearInterval(looper); } else { action(); counter++; } }, duration); }, checkElement: function(selector) { return $(selector).length; }, moveMinicart: function() { var move = $("#wsite-mini-cart").detach(); $("#header").append(move); }, moveFlyout: function() { var move = $("#wsite-menus").detach(); $("#header").append(move); } } $(document).ready(function() { // Add current class to store gallery thumb var galleryLink = $("#wsite-com-product-images-strip a"); var currentClass = "current"; galleryLink.first().addClass(currentClass); galleryLink.click(function(){ $("."+currentClass).removeClass(currentClass); $(this).addClass(currentClass); }); // Add halfwidth class to gallery thumbs if less than 6 $('.imageGallery').each(function(){ if ($(this).children('div').length <= 6) { $(this).children('div').addClass('halfwidth-mobile'); } }); // Add search to mobile menu if present var headerSearch = $("#header .wsite-search"); var navMobile = $("#navmobile"); if (headerSearch.length) { navMobile.prepend('