1/* global woodmart_settings */ 2(function($) { 3 woodmartThemeModule.ajaxFilters = function() { 4 if (!woodmartThemeModule.$body.hasClass('woodmart-ajax-shop-on') || typeof ($.fn.pjax) === 'undefined' || woodmartThemeModule.$body.hasClass('single-product') || woodmartThemeModule.$body.hasClass('elementor-editor-active') || $('.products[data-source="main_loop"]').length === 0) { 5 return; 6 } 7 8 var that = this, 9 filtersState = false; 10 11 woodmartThemeModule.$body.on('click', '.post-type-archive-product .products-footer .woocommerce-pagination a', function() { 12 scrollToTop(true); 13 }); 14 15 woodmartThemeModule.$document.pjax(woodmart_settings.ajax_links, '.main-page-wrapper', { 16 timeout : woodmart_settings.pjax_timeout, 17 scrollTo : false, 18 renderCallback: function(context, html, afterRender) { 19 woodmartThemeModule.removeDuplicatedStylesFromHTML(html, function(html) { 20 context.html(html); 21 afterRender(); 22 woodmartThemeModule.$document.trigger('wdShopPageInit'); 23 woodmartThemeModule.$document.trigger('wood-images-loaded'); 24 }); 25 } 26 }); 27 28 if (woodmart_settings.price_filter_action === 'click') { 29 woodmartThemeModule.$document.on('click', '.widget_price_filter form .button', function() { 30 var form = $('.widget_price_filter form'); 31 $.pjax({ 32 container: '.main-page-wrapper', 33 timeout : woodmart_settings.pjax_timeout, 34 url : form.attr('action'), 35 data : form.serialize(), 36 scrollTo : false, 37 renderCallback: function(context, html, afterRender) { 38 woodmartThemeModule.removeDuplicatedStylesFromHTML(html, function(html) { 39 context.html(html); 40 afterRender(); 41 woodmartThemeModule.$document.trigger('wdShopPageInit'); 42 woodmartThemeModule.$document.trigger('wood-images-loaded'); 43 }); 44 } 45 }); 46 47 return false; 48 }); 49 } else if (woodmart_settings.price_filter_action === 'submit') { 50 woodmartThemeModule.$document.on('submit', '.widget_price_filter form', function(event) { 51 $.pjax.submit(event, '.main-page-wrapper'); 52 }); 53 } 54 55 woodmartThemeModule.$document.on('pjax:error', function(xhr, textStatus, error) { 56 console.log('pjax error ' + error); 57 }); 58 59 woodmartThemeModule.$document.on('pjax:start', function() { 60 var $siteContent = $('.site-content'); 61 62 $siteContent.removeClass('ajax-loaded'); 63 $siteContent.addClass('ajax-loading'); 64 65 woodmartThemeModule.$document.trigger('wdPjaxStart'); 66 woodmartThemeModule.$window.trigger('scroll.loaderVerticalPosition'); 67 }); 68 69 woodmartThemeModule.$document.on('pjax:complete', function() { 70 woodmartThemeModule.$window.off('scroll.loaderVerticalPosition'); 71 72 scrollToTop(false); 73 74 woodmartThemeModule.$document.trigger('wood-images-loaded'); 75 76 $('.wd-scroll-content').on('scroll', function() { 77 woodmartThemeModule.$document.trigger('wood-images-loaded'); 78 }); 79 80 if (typeof woodmart_wpml_js_data !== 'undefined' && woodmart_wpml_js_data.languages) { 81 $.each(woodmart_wpml_js_data.languages, function(index, language) { 82 $('.wpml-ls-item-' + language.code + ' .wpml-ls-link').attr('href', language.url); 83 }); 84 } 85 }); 86 87 woodmartThemeModule.$document.on('pjax:beforeReplace', function() { 88 if ($('.filters-area').hasClass('filters-opened') && woodmart_settings.shop_filters_close === 'yes') { 89 filtersState = true; 90 woodmartThemeModule.$body.addClass('body-filters-opened'); 91 } 92 }); 93 94 woodmartThemeModule.$document.on('wdShopPageInit', function() { 95 var $siteContent = $('.site-content'); 96 97 if (filtersState) { 98 $('.filters-area').css('display', 'block'); 99 woodmartThemeModule.openFilters(200); 100 filtersState = false; 101 } 102 103 $siteContent.removeClass('ajax-loading'); 104 $siteContent.addClass('ajax-loaded'); 105 }); 106 107 var scrollToTop = function(type) { 108 if (woodmart_settings.ajax_scroll === 'no' && type === false) { 109 return false; 110 } 111 112 var $scrollTo = $(woodmart_settings.ajax_scroll_class), 113 scrollTo = $scrollTo.offset().top - woodmart_settings.ajax_scroll_offset; 114 115 $('html, body').stop().animate({ 116 scrollTop: scrollTo 117 }, 400); 118 }; 119 }; 120 121 $(document).ready(function() { 122 woodmartThemeModule.ajaxFilters(); 123 }); 124 125 window.addEventListener('popstate', function() { 126 woodmartThemeModule.ajaxFilters(); 127 }); 128})(jQuery);
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.