PageSourceSearch

https://www.sklep-instalgrunt.pl/wp-content/plugins/woocommerce-products-filter/js/front.js?ver=1.4.6

js sklep-instalgrunt.pl collected 2026-10-10 02:09:29 UTC 83,123 bytes, 2,235 lines download raw bytes

1'use strict';
2var woof_redirect = ''; //if we use redirect attribute in shortcode [woof]
3var woof_reset_btn_action = false;
4var woof_additional_fields = {};
5
6jQuery(function () {
7    // PHP prints woof_current_values as a real object now. The string branch is
8    // kept only for third party code that may still assign a JSON string to it.
9    if (typeof woof_current_values === 'string') {
10        try {
11            woof_current_values = JSON.parse(woof_current_values);
12        } catch (e) {
13            woof_current_values = {};
14        }
15    }
16    if (woof_current_values == null || Array.isArray(woof_current_values)) {
17        woof_current_values = {};
18    }
19});
20
21//***
22if (typeof woof_lang_custom == 'undefined') {
23    var woof_lang_custom = {}; /*!!important*/
24}
25if (typeof woof_ext_filter_titles != 'undefined') {
26    woof_lang_custom = Object.assign(
27            {},
28            woof_lang_custom,
29            woof_ext_filter_titles
30            );
31}
32
33jQuery(function ($) {
34    jQuery('body').append(
35            '<div id="woof_html_buffer" class="woof_info_popup" style="display: none;"></div>'
36            );
37    //http://stackoverflow.com/questions/2389540/jquery-hasparent
38    jQuery.extend(jQuery.fn, {
39        within: function (pSelector) {
40            // Returns a subset of items using jQuery.filter
41            return this.filter(function () {
42                // Return truthy/falsey based on presence in parent
43                return jQuery(this).closest(pSelector).length;
44            });
45        },
46    });
47
48    //fix for swoof shortcode [woof_form_builder] (one form on one page)
49    let forms = document.querySelectorAll('.woof[data-slug]');
50    if (forms.length) {
51        forms.forEach((f) => {
52            if (f.dataset.slug.length > 0) {
53                swoof_search_slug = f.dataset.slug;
54            }
55        });
56    }
57
58    //+++
59
60    if (jQuery('#woof_results_by_ajax').length > 0) {
61        woof_is_ajax = 1;
62    }
63
64    //listening attributes in shortcode [woof]
65    woof_autosubmit = parseInt(jQuery('.woof').eq(0).data('autosubmit'), 10);
66    woof_ajax_redraw = parseInt(jQuery('.woof').eq(0).data('ajax-redraw'), 10);
67
68    //+++
69
70    woof_ext_init_functions = JSON.parse(woof_ext_init_functions);
71
72    //fix for native woo price range
73    woof_init_native_woo_price_filter();
74
75    jQuery('body').on('price_slider_change', function (event, min, max) {
76        if (
77                woof_autosubmit &&
78                !woof_show_price_search_button &&
79                jQuery('.price_slider_wrapper').length < 3
80                ) {
81            jQuery('.woof .widget_price_filter form').trigger('submit');
82        } else {
83            var min_price = jQuery(this)
84                    .find('.price_slider_amount #min_price')
85                    .val();
86            var max_price = jQuery(this)
87                    .find('.price_slider_amount #max_price')
88                    .val();
89            woof_current_values.min_price = min_price;
90            woof_current_values.max_price = max_price;
91        }
92    });
93
94    jQuery('body').on('change', '.woof_price_filter_dropdown', function () {
95        var val = jQuery(this).val();
96        if (parseInt(val, 10) == -1) {
97            delete woof_current_values.min_price;
98            delete woof_current_values.max_price;
99        } else {
100            var val = val.split('-');
101            woof_current_values.min_price = val[0];
102            woof_current_values.max_price = val[1];
103        }
104
105        if (woof_autosubmit || jQuery(this).within('.woof').length == 0) {
106            woof_submit_link(woof_get_submit_link());
107        }
108    });
109
110    //change value in textinput price filter if WOOCS is installed
111    woof_recount_text_price_filter();
112    //+++
113    jQuery('body').on('change', '.woof_price_filter_txt', function () {
114        var from = parseInt(
115                jQuery(this).parent().find('.woof_price_filter_txt_from').val(),
116                10
117                );
118        var to = parseInt(
119                jQuery(this).parent().find('.woof_price_filter_txt_to').val(),
120                10
121                );
122
123        if (to < from || from < 0) {
124            delete woof_current_values.min_price;
125            delete woof_current_values.max_price;
126        } else {
127            if (typeof woocs_current_currency !== 'undefined') {
128                from = Math.ceil(
129                        from / parseFloat(woocs_current_currency.rate)
130                        );
131                to = Math.ceil(to / parseFloat(woocs_current_currency.rate));
132            }
133
134            woof_current_values.min_price = from;
135            woof_current_values.max_price = to;
136        }
137
138        if (woof_autosubmit || jQuery(this).within('.woof').length == 0) {
139            woof_submit_link(woof_get_submit_link());
140        }
141    });
142
143    //***
144
145    jQuery('body').on('click', '.woof_open_hidden_li_btn', function () {
146        var state = jQuery(this).data('state');
147        var type = jQuery(this).data('type');
148
149        if (state == 'closed') {
150            jQuery(this)
151                    .parents('.woof_list')
152                    .find('.woof_hidden_term')
153                    .addClass('woof_hidden_term2');
154            jQuery(this)
155                    .parents('.woof_list')
156                    .find('.woof_hidden_term')
157                    .removeClass('woof_hidden_term');
158            if (type == 'image') {
159                jQuery(this)
160                        .find('img')
161                        .attr('src', jQuery(this).data('opened'));
162            } else {
163                jQuery(this).html(jQuery(this).data('opened'));
164            }
165
166            jQuery(this).data('state', 'opened');
167        } else {
168            jQuery(this)
169                    .parents('.woof_list')
170                    .find('.woof_hidden_term2')
171                    .addClass('woof_hidden_term');
172            jQuery(this)
173                    .parents('.woof_list')
174                    .find('.woof_hidden_term2')
175                    .removeClass('woof_hidden_term2');
176
177            if (type == 'image') {
178                jQuery(this)
179                        .find('img')
180                        .attr('src', jQuery(this).data('closed'));
181            } else {
182                jQuery(this).text(jQuery(this).data('closed'));
183            }
184
185            jQuery(this).data('state', 'closed');
186        }
187
188        return false;
189    });
190    //open hidden block
191    woof_open_hidden_li();
192
193    //*** woocommerce native "AVERAGE RATING" widget synchronizing
194    jQuery('.widget_rating_filter li.wc-layered-nav-rating a').on(
195            'click',
196            function () {
197                var is_chosen = jQuery(this).parent().hasClass('chosen');
198                var parsed_url = woof_parse_url(jQuery(this).attr('href'));
199                var rate = 0;
200                if (parsed_url.query !== undefined) {
201                    if (parsed_url.query.indexOf('min_rating') !== -1) {
202                        var arrayOfStrings = parsed_url.query.split('min_rating=');
203                        rate = parseInt(arrayOfStrings[1], 10);
204                    }
205                }
206                jQuery(this).parents('ul').find('li').removeClass('chosen');
207                if (is_chosen) {
208                    delete woof_current_values.min_rating;
209                } else {
210                    woof_current_values.min_rating = rate;
211                    jQuery(this).parent().addClass('chosen');
212                }
213
214                woof_submit_link(woof_get_submit_link());
215
216                return false;
217            }
218    );
219
220    //WOOF start filtering button action
221    jQuery('body').on('click', '.woof_start_filtering_btn', function () {
222        var shortcode = jQuery(this).parents('.woof').data('shortcode');
223        jQuery(this).html(woof_lang_loading);
224        jQuery(this).addClass('woof_start_filtering_btn2');
225        jQuery(this).removeClass('woof_start_filtering_btn');
226        //redrawing [woof ajax_redraw=1] only
227        var data = {
228            action: 'woof_draw_products',
229            page: 1,
230            shortcode: 'woof_nothing', //we do not need get any products, seacrh form data only
231            woof_shortcode: shortcode,
232            nonce_filter: woof_front_nonce,
233        };
234
235        jQuery.post(woof_ajaxurl, data, function (content) {
236            content = JSON.parse(content);
237            jQuery('div.woof_redraw_zone').replaceWith(
238                    jQuery(content.form).find('.woof_redraw_zone')
239                    );
240            woof_mass_reinit();
241            woof_init_tooltip();
242        });
243
244        return false;
245    });
246
247    //***
248
249    window.addEventListener('pageshow', function (event) {
250        var woof_check_history =
251                event.persisted ||
252                (typeof window.performance != 'undefined' &&
253                        window.performance.navigation.type === 2);
254        if (woof_check_history) {
255            woof_hide_info_popup();
256            woof_submit_link_locked = false;
257        }
258    });
259
260    var str = window.location.href;
261    window.onpopstate = function (event) {
262        try {
263            if (Object.keys(woof_current_values).length) {
264                var temp = str.split('?');
265                var get1 = '';
266                if (temp[1] != undefined) {
267                    get1 = temp[1].split('#');
268                }
269                var str2 = window.location.href;
270                var temp2 = str2.split('?');
271                if (temp2[1] == undefined) {
272                    //return false;
273                    var get2 = {0: '', 1: ''};
274                } else {
275                    var get2 = temp2[1].split('#');
276                }
277
278                if (get2[0] != get1[0]) {
279                    woof_show_info_popup(woof_lang_loading);
280                    window.location.reload();
281                }
282                return false;
283            }
284        } catch (e) {
285            console.log(e);
286        }
287    };
288    //***
289
290    //ion-slider price range slider
291    woof_init_ion_sliders();
292
293    //***
294
295    woof_init_show_auto_form();
296    woof_init_hide_auto_form();
297
298    //***
299    woof_remove_empty_elements();
300    woof_unblur_filter();
301
302    woof_init_search_form();
303    woof_init_pagination();
304    woof_init_orderby();
305    woof_init_reset_button();
306    woof_init_beauty_scroll();
307    //+++
308    woof_draw_products_top_panel();
309    woof_shortcode_observer();
310
311    //tooltip
312    woof_init_tooltip();
313
314    //mobile filter
315    woof_init_mobile_filter();
316
317    //+++
318    //if we use redirect attribute in shortcode [woof is_ajax=0]
319    //not for ajax, for redirect mode only
320    if (!woof_is_ajax) {
321        woof_redirect_init();
322    }
323
324    woof_init_toggles();
325});
326
327//if we use redirect attribute in shortcode [woof is_ajax=0]
328//not for ajax, for redirect mode only
329function woof_redirect_init() {
330    try {
331        if (jQuery('.woof').length) {
332            //https://wordpress.org/support/topic/javascript-error-in-frontjs?replies=1
333            if (undefined !== jQuery('.woof').val()) {
334                woof_redirect = jQuery('.woof').eq(0).data('redirect'); //default value
335                if (woof_redirect.length > 0) {
336                    woof_shop_page = woof_current_page_link = woof_redirect;
337                }
338                return woof_redirect;
339            }
340        }
341    } catch (e) {
342        console.log(e);
343    }
344}
345
346function woof_init_orderby() {
347    jQuery('body').on('submit', 'form.woocommerce-ordering', function () {
348        /* woo3.3 */
349        if (!jQuery('#is_woo_shortcode').length) {
350            return false;
351        }
352        /* +++ */
353    });
354    jQuery('body').on(
355            'change',
356            'form.woocommerce-ordering select.orderby',
357            function () {
358                /* woo3.3 */
359                if (!jQuery('#is_woo_shortcode').length) {
360                    woof_current_values.orderby = jQuery(this).val();
361                    woof_ajax_page_num = 1;
362                    woof_submit_link(woof_get_submit_link(), 0);
363                    return false;
364                }
365                /* +++ */
366            }
367    );
368}
369
370function woof_init_reset_button() {
371    jQuery('body').on('click', '.woof_reset_search_form', function () {
372        //var link = jQuery(this).data('link');
373        woof_ajax_page_num = 1;
374        woof_ajax_redraw = 0;
375        woof_reset_btn_action = true;
376        if (woof_is_permalink) {
377            woof_current_values = {};
378            woof_submit_link(woof_get_submit_link().split('page/')[0]);
379        } else {
380            var link = woof_shop_page;
381            if (woof_current_values.hasOwnProperty('page_id')) {
382                link =
383                        location.protocol +
384                        '//' +
385                        location.host +
386                        '/?page_id=' +
387                        woof_current_values.page_id;
388                woof_current_values = {page_id: woof_current_values.page_id};
389                woof_get_submit_link();
390            }
391            //***
392            woof_submit_link(link);
393            if (woof_is_ajax) {
394                history.pushState({}, '', link);
395                if (woof_current_values.hasOwnProperty('page_id')) {
396                    woof_current_values = {
397                        page_id: woof_current_values.page_id,
398                    };
399                } else {
400                    woof_current_values = {};
401                }
402            }
403        }
404        return false;
405    });
406}
407
408function woof_init_pagination() {
409    if (woof_is_ajax === 1) {
410        //jQuery('.woocommerce-pagination ul.page-numbers a.page-numbers').life('click', function () {
411        jQuery('body').on(
412                'click',
413                '.woocommerce-pagination a.page-numbers',
414                function () {
415                    var l = jQuery(this).attr('href');
416
417                    if (woof_ajax_first_done) {
418                        //wp-admin/admin-ajax.php?paged=2
419                        var res = l.split('paged=');
420                        if (typeof res[1] !== 'undefined') {
421                            woof_ajax_page_num = parseInt(res[1]);
422                        } else {
423                            woof_ajax_page_num = 1;
424                        }
425                        var res2 = l.split('product-page=');
426                        if (typeof res2[1] !== 'undefined') {
427                            woof_ajax_page_num = parseInt(res2[1]);
428                        }
429                    } else {
430                        var res = l.split('page/');
431                        if (typeof res[1] !== 'undefined') {
432                            woof_ajax_page_num = parseInt(res[1]);
433                        } else {
434                            woof_ajax_page_num = 1;
435                        }
436                        var res2 = l.split('product-page=');
437                        if (typeof res2[1] !== 'undefined') {
438                            woof_ajax_page_num = parseInt(res2[1]);
439                        }
440                    }
441
442                    //+++
443
444                    {
445                        woof_submit_link(woof_get_submit_link(), 0);
446                    }
447
448                    return false;
449                }
450        );
451    }
452}
453
454function woof_init_search_form() {
455    woof_init_checkboxes();
456    woof_init_mselects();
457    woof_init_radios();
458    woof_price_filter_radio_init();
459    woof_init_selects();
460
461    //for extensions
462    if (woof_ext_init_functions !== null) {
463        jQuery.each(woof_ext_init_functions, function (type, func) {
464            eval(func + '()');
465        });
466    }
467
468    //+++
469    jQuery('.woof_submit_search_form').on('click', function () {
470        if (woof_ajax_redraw) {
471            //[woof redirect="http://test-all/" autosubmit=1 ajax_redraw=1 is_ajax=1 tax_only="locations" by_only="none"]
472            woof_ajax_redraw = 0;
473            woof_is_ajax = 0;
474        }
475        //***
476        woof_submit_link(woof_get_submit_link());
477        return false;
478    });
479
480    //***
481    jQuery('ul.woof_childs_list').parent('li').addClass('woof_childs_list_li');
482
483    //***
484
485    woof_remove_class_widget();
486    woof_checkboxes_slide();
487
488    document.dispatchEvent(
489            new CustomEvent('woof_init_search_form', {detail: {}})
490            );
491}
492
493var woof_submit_link_locked = false;
494function woof_submit_link(link, ajax_redraw) {
495    if (woof_submit_link_locked) {
496        return;
497    }
498    if (typeof WoofTurboMode != 'undefined') {
499        WoofTurboMode.woof_submit_link(link);
500
501        return;
502    }
503    if (typeof ajax_redraw == 'undefined') {
504        ajax_redraw = woof_ajax_redraw;
505    }
506
507    woof_submit_link_locked = true;
508
509    woof_show_info_popup(woof_lang_loading);
510
511    if (woof_is_ajax === 1 && !ajax_redraw) {
512        woof_ajax_first_done = true;
513        var data = {
514            action: 'woof_draw_products',
515            link: link,
516            page: woof_ajax_page_num,
517            shortcode: jQuery('#woof_results_by_ajax').data('shortcode'),
518            woof_shortcode: jQuery('div.woof').data('shortcode'),
519            nonce_filter: woof_front_nonce,
520        };
521
522        jQuery.post(woof_ajaxurl, data, function (content) {
523            content = JSON.parse(content);
524
525            woof_before_ajax_form_redrawing();
526
527            if (jQuery('.woof_results_by_ajax_shortcode').length) {
528                if (typeof content.products != 'undefined') {
529                    jQuery('#woof_results_by_ajax').replaceWith(
530                            content.products
531                            );
532
533                    /* compatibility found products count*/
534                    var found_count = jQuery('.woof_found_count');
535                    jQuery(found_count).show();
536                    if (found_count.length > 0) {
537                        var count_prod = jQuery('#woof_results_by_ajax').data(
538                                'count'
539                                );
540                        if (typeof count_prod != 'undefined') {
541                            jQuery(found_count).text(count_prod);
542                        }
543                    }
544                }
545            } else {
546                if (typeof content.products != 'undefined') {
547                    jQuery('.woof_shortcode_output').replaceWith(
548                            content.products
549                            );
550                }
551            }
552            if (typeof content.additional_fields != 'undefined') {
553                jQuery.each(
554                        content.additional_fields,
555                        function (selector, html_data) {
556                            if (
557                                    typeof woof_additional_fields[selector] ==
558                                    'undefined'
559                                    ) {
560                                woof_additional_fields[selector] = jQuery(selector);
561                            }
562                            jQuery(selector).replaceWith(html_data);
563                        }
564                );
565                //draw old  values
566                jQuery.each(
567                        woof_additional_fields,
568                        function (selector, html_data_old) {
569                            if (
570                                    typeof content.additional_fields[selector] ==
571                                    'undefined'
572                                    ) {
573                                jQuery(selector).replaceWith(html_data_old);
574                            }
575                        }
576                );
577            }
578
579            jQuery('div.woof_redraw_zone').replaceWith(
580                    jQuery(content.form).find('.woof_redraw_zone')
581                    );
582            woof_draw_products_top_panel();
583            woof_mass_reinit();
584            woof_submit_link_locked = false;
585            //removing id woof_results_by_ajax - multi in ajax mode sometimes
586            //when uses shorcode woof_products in ajax and in settings try ajaxify shop is Yes
587            jQuery.each(
588                    jQuery('#woof_results_by_ajax'),
589                    function (index, item) {
590                        if (index == 0) {
591                            return;
592                        }
593
594                        jQuery(item).removeAttr('id');
595                    }
596            );
597            /*mobile  behavior*/
598            //jQuery('.woof_hide_mobile_filter').trigger('click');
599            jQuery('.woof').removeClass('woof_show_filter_for_mobile');
600
601            //infinite scroll
602            woof_infinite();
603            //*** script after ajax loading here
604            woof_js_after_ajax_done();
605            //***  change  link  in button "add to cart"
606            woof_change_link_addtocart();
607
608            /*tooltip*/
609            woof_init_tooltip();
610
611            document.dispatchEvent(
612                    new CustomEvent('woof-ajax-form-redrawing', {
613                        detail: {
614                            link: link,
615                        },
616                    })
617                    );
618        });
619    } else {
620        if (ajax_redraw) {
621            //redrawing [woof ajax_redraw=1] only
622            var data = {
623                action: 'woof_draw_products',
624                link: link,
625                page: 1,
626                shortcode: 'woof_nothing', //we do not need get any products, seacrh form data only
627                woof_shortcode: jQuery('div.woof').eq(0).data('shortcode'),
628                nonce_filter: woof_front_nonce,
629            };
630            jQuery.post(woof_ajaxurl, data, function (content) {
631                woof_before_ajax_form_redrawing();
632
633                content = JSON.parse(content);
634                jQuery('div.woof_redraw_zone').replaceWith(
635                        jQuery(content.form).find('.woof_redraw_zone')
636                        );
637                woof_mass_reinit();
638                woof_submit_link_locked = false;
639                /*tooltip*/
640                woof_init_tooltip();
641
642                document.dispatchEvent(
643                        new CustomEvent('woof-ajax-form-redrawing', {
644                            detail: {
645                                link: link,
646                            },
647                        })
648                        );
649            });
650        } else {
651            // Delay redirect to avoid conflicts with other scripts (Kadence, etc.)
652            //https://pluginus.net/support/topic/text-search-shortcode-enter-key-reloads-page-instead-of-redirecting-to-shop-page
653            setTimeout(() => {
654                window.location = link;
655            }, 100);
656            woof_show_info_popup(woof_lang_loading);
657        }
658    }
659}
660
661function woof_remove_empty_elements() {
662    // lets check for empty drop-downs
663    jQuery.each(jQuery('.woof_container select'), function (index, select) {
664        var size = jQuery(select).find('option').length;
665        if (size === 0) {
666            jQuery(select).parents('.woof_container').remove();
667        }
668    });
669    //+++
670    // lets check for empty checkboxes, radio, color conatiners
671    jQuery.each(jQuery('ul.woof_list'), function (index, ch) {
672        var size = jQuery(ch).find('li').length;
673        if (size === 0) {
674            jQuery(ch).parents('.woof_container').remove();
675        }
676    });
677    jQuery.each(jQuery('.woof_container .woof_list_sd'), function (index, ch) {
678        var size = jQuery(ch).find('.woof-sd-ie').length;
679        if (size === 0) {
680            jQuery(ch).parents('.woof_container').remove();
681        }
682    });
683}
684
685function woof_get_submit_link() {
686    //filter woof_current_values values
687
688    if (woof_is_ajax) {
689        woof_current_values.page = woof_ajax_page_num;
690    }
691    //+++
692    if (Object.keys(woof_current_values).length > 0) {
693        jQuery.each(woof_current_values, function (index, value) {
694            if (index == swoof_search_slug) {
695                delete woof_current_values[index];
696            }
697            if (index == 's') {
698                delete woof_current_values[index];
699            }
700            if (index == 'product') {
701                //for single product page (when no permalinks)
702                delete woof_current_values[index];
703            }
704            if (index == 'really_curr_tax') {
705                delete woof_current_values[index];
706            }
707        });
708    }
709
710    //***
711    if (Object.keys(woof_current_values).length === 2) {
712        if (
713                'min_price' in woof_current_values &&
714                'max_price' in woof_current_values
715                ) {
716            woof_current_page_link = woof_current_page_link.replace(
717                    new RegExp(/page\/(\d+)/),
718                    ''
719                    );
720            var l =
721                    woof_current_page_link +
722                    '?min_price=' +
723                    woof_current_values.min_price +
724                    '&max_price=' +
725                    woof_current_values.max_price;
726            if (woof_is_ajax) {
727                history.pushState({}, '', l);
728            }
729            return l;
730        }
731    }
732
733    //***
734
735    if (Object.keys(woof_current_values).length === 0) {
736        if (woof_is_ajax) {
737            history.pushState({}, '', woof_current_page_link);
738        }
739        return woof_current_page_link;
740    }
741    //+++
742    if (Object.keys(woof_really_curr_tax).length > 0) {
743        woof_current_values['really_curr_tax'] =
744                woof_really_curr_tax.term_id + '-' + woof_really_curr_tax.taxonomy;
745    }
746    //+++
747    var link = woof_current_page_link + '?' + swoof_search_slug + '
747=1';
748
749    //just for the case when no permalinks enabled
750    if (!woof_is_permalink) {
751        if (woof_redirect.length > 0) {
752            link = woof_redirect + '?' + swoof_search_slug + '=1';
753            if (woof_current_values.hasOwnProperty('page_id')) {
754                delete woof_current_values.page_id;
755            }
756        } else {
757            link =
758                    location.protocol +
759                    '//' +
760                    location.host +
761                    '?' +
762                    swoof_search_slug +
763                    '=1';
764        }
765    }
766
767    //any trash for different sites, useful for quick support
768    var woof_exclude_accept_array = ['path'];
769
770    if (Object.keys(woof_current_values).length > 0) {
771        jQuery.each(woof_current_values, function (index, value) {
772            if (index == 'page' && woof_is_ajax) {
773                index = 'paged'; //for right pagination if copy/paste this link and send somebody another by email for example
774            }
775            if (index == 'product-page') {
776                return;
777            }
778
779            //http://dev.products-filter.com/?swoof=1&woof_author=3&woof_sku&woof_text=single
780            //avoid links where values is empty
781            if (typeof value !== 'undefined') {
782                if (
783                        (typeof value && value.length > 0) ||
784                        typeof value == 'number'
785                        ) {
786                    if (
787                            jQuery.inArray(index, woof_exclude_accept_array) == -1
788                            ) {
789                        link = link + '&' + index + '=' + value;
790                    }
791                }
792            }
793        });
794    }
795
796    //+++
797    //remove wp pagination like 'page/2'
798    link = link.replace(new RegExp(/page\/(\d+)/), '');
799    if (woof_is_ajax) {
800        history.pushState({}, '', link);
801    }
802
803    return link;
804}
805
806function woof_show_info_popup(text) {
807    if (woof_overlay_skin == 'default') {
808        jQuery('#woof_html_buffer').text(text);
809        jQuery('#woof_html_buffer').fadeTo(200, 0.9);
810    } else {
811        //http://jxnblk.com/loading/
812        switch (woof_overlay_skin) {
813            case 'loading-balls':
814            case 'loading-bars':
815            case 'loading-bubbles':
816            case 'loading-cubes':
817            case 'loading-cylon':
818            case 'loading-spin':
819            case 'loading-spinning-bubbles':
820            case 'loading-spokes':
821                jQuery('body').plainOverlay('show', {
822                    progress: function () {
823                        //img style should be inlined
824                        return jQuery(
825                                '<div id="woof_svg_load_container"><img style="height: 100%; width: 100%" src="' +
826                                woof_link +
827                                'img/loading-master/' +
828                                woof_overlay_skin +
829                                '.svg" alt=""></div>'
830                                );
831                    },
832                });
833                break;
834            default:
835                jQuery('body').plainOverlay('show', {duration: -1});
836                break;
837        }
838    }
839}
840
841function woof_hide_info_popup() {
842    if (woof_overlay_skin == 'default') {
843        window.setTimeout(function () {
844            jQuery('#woof_html_buffer').fadeOut(400);
845        }, 200);
846    } else {
847        jQuery('body').plainOverlay('hide');
848    }
849}
850
851function woof_draw_products_top_panel() {
852    if (woof_is_ajax) {
853        jQuery('#woof_results_by_ajax')
854                .prev('.woof_products_top_panel')
855                .remove();
856    }
857
858    var panel = jQuery('.woof_products_top_panel');
859
860    panel.html('');
861    if (Object.keys(woof_current_values).length > 0) {
862        panel.show();
863        panel.html('<ul></ul>');
864        panel.find('ul').attr('class', 'woof_products_top_panel_ul');
865        var is_price_in = false;
866        //lets show this on the panel
867
868        jQuery.each(woof_current_values, function (index, value) {
869            //lets filter data for the panel
870
871            if (
872                    jQuery.inArray(index, woof_accept_array) == -1 &&
873                    jQuery.inArray(index.replace('rev_', ''), woof_accept_array) ==
874                    -1
875                    ) {
876                return;
877            }
878
879            //***
880
881            if ((index == 'min_price' || index == 'max_price') && is_price_in) {
882                return;
883            }
884
885            if (
886                    (index == 'min_price' || index == 'max_price') &&
887                    !is_price_in
888                    ) {
889                is_price_in = true;
890                index = 'price';
891                value = woof_lang_pricerange;
892            }
893
894            //tax slider  fix
895            var is_range = false;
896            var range_txt = jQuery(
897                    "input[data-anchor='woof_n_" + index + "_all_range']"
898                    ).val();
899
900            if (typeof range_txt != 'undefined') {
901                is_range = true;
902            }
903
904            //+++
905            value = value.toString().trim();
906            if (value.search(',')) {
907                value = value.split(',');
908            }
909            //+++
910            if (!is_range) {
911                jQuery.each(value, function (i, v) {
912                    if (index == 'page') {
913                        return;
914                    }
915
916                    if (index == 'post_type') {
917                        return;
918                    }
919
920                    var txt = v;
921                    if (index == 'orderby') {
922                        if (woof_lang[v] !== undefined) {
923                            txt = woof_lang.orderby + ': ' + woof_lang[v];
924                        } else {
925                            txt = woof_lang.orderby + ': ' + v;
926                        }
927                    } else if (index == 'perpage') {
928                        txt = woof_lang.perpage;
929                    } else if (index == 'price') {
930                        txt = woof_lang.pricerange;
931                    } else {
932                        var is_in_custom = false;
933                        if (Object.keys(woof_lang_custom).length > 0) {
934                            jQuery.each(woof_lang_custom, function (i, tt) {
935                                if (i == index) {
936                                    is_in_custom = true;
937                                    txt = tt;
938                                    if (index == 'woof_sku') {
939                                        txt += ' ' + v; //because search by SKU can by more than 1 value
940                                    }
941                                }
942                            });
943                        }
944                        if (!is_in_custom) {
945                            try {
946                                txt = jQuery(
947                                        "input[data-anchor='woof_n_" +
948                                        index +
949                                        '_' +
950                                        v +
951                                        "']"
952                                        ).val();
953                            } catch (e) {
954                                console.log(e);
955                            }
956
957                            if (typeof txt === 'undefined') {
958                                txt = v;
959                            }
960                        }
961                    }
962
963                    if (typeof woof_filter_titles[index] != 'undefined') {
964                        var cont_item = panel.find(
965                                'ul.woof_products_top_panel_ul li ul[data-container=' +
966                                index +
967                                ']'
968                                );
969
970                        if (cont_item.length) {
971                            cont_item.append(
972                                    jQuery('<li>').append(
973                                    jQuery('<a>')
974                                    .attr('href', '')
975                                    .attr('data-tax', index)
976                                    .attr('data-slug', v)
977                                    .attr('rel', 'nofollow')
978                                    .append(
979                                            jQuery('<span>')
980                                            .attr(
981                                                    'class',
982                                                    'woof_remove_ppi'
983                                                    )
984                                            .append(txt)
985                                            )
986                                    )
987                                    );
988                        } else {
989                            panel.find('ul.woof_products_top_panel_ul').append(
990                                    jQuery('<li>').append(
991                                    jQuery('<ul>')
992                                    .attr('data-container', index)
993                                    .append(
994                                            jQuery('<li>').text(
995                                            woof_filter_titles[index] + ':'
996                                            )
997                                            )
998                                    .append(
999                                            jQuery('<li>').append(
1000                                            jQuery('<a>')
1001                                            .attr('href', '')
1002                                            .attr('data-tax', index)
1003                                            .attr('data-slug', v)
1004                                            .attr('rel', 'nofollow')
1005                                            .append(
1006                                                    jQuery('<span>')
1007                                                    .attr(
1008                                                            'class',
1009                                                            'woof_remove_ppi'
1010                                                            )
1011                                                    .append(txt)
1012                                                    )
1013                                            )
1014                                            )
1015                                    )
1016                                    );
1017                        }
1018                    } else {
1019                        panel
1020                                .find('ul.woof_products_top_panel_ul')
1021                                .append(
1022                                        jQuery('<li>').append(
1023                                        jQuery('<a>')
1024                                        .attr('href', '')
1025                                        .attr('data-tax', index)
1026                                        .attr('data-slug', v)
1027                                        .attr('rel', 'nofollow')
1028                                        .append(
1029                                                jQuery('<span>')
1030                                                .attr(
1031                                                        'class',
1032                                                        'woof_remove_ppi'
1033                                                        )
1034                                                .append(txt)
1035                                                )
1036                                        )
1037                                        );
1038                    }
1039                });
1040            } else {
1041                if (typeof woof_filter_titles[index] != 'undefined') {
1042                    var cont_item = panel.find(
1043                            'ul.woof_products_top_panel_ul li ul[data-container=' +
1044                            index +
1045                            ']'
1046                            );
1047
1048                    if (cont_item.length) {
1049                        cont_item.append(
1050                                jQuery('<li>').append(
1051                                jQuery('<a>')
1052                                .attr('href', '')
1053                                .attr('data-tax', index)
1054                                .attr('data-slug', 'all_range')
1055                                .attr('rel', 'nofollow')
1056                                .append(
1057                                        jQuery('<span>')
1058                                        .attr('class', 'woof_remove_ppi')
1059                                        .append(range_txt)
1060                                        )
1061                                )
1062                                );
1063                    } else {
1064                        panel.find('ul.woof_products_top_panel_ul').append(
1065                                jQuery('<li>').append(
1066                                jQuery('<ul>')
1067                                .attr('data-container', index)
1068                                .append(
1069                                        jQuery('<li>').text(
1070                                        woof_filter_titles[index] + ':'
1071                                        )
1072                                        )
1073                                .append(
1074                                        jQuery('<li>').append(
1075                                        jQuery('<a>')
1076                                        .attr('href', '')
1077                                        .attr('data-tax', index)
1078                                        .attr('data-slug', 'all_range')
1079                                        .attr('rel', 'nofollow')
1080                                        .append(
1081                                                jQuery('<span>')
1082                                                .attr(
1083                                                        'class',
1084                                                        'woof_remove_ppi'
1085                                                        )
1086                                                .append(range_txt)
1087                                                )
1088                                        )
1089                                        )
1090                                )
1091                                );
1092                    }
1093                } else {
1094                    panel
1095                            .find('ul.woof_products_top_panel_ul')
1096                            .append(
1097                                    jQuery('<li>').append(
1098                                    jQuery('<a>')
1099                                    .attr('href', '')
1100                                    .attr('data-tax', index)
1101                                    .attr('data-slug', 'all_range')
1102                                    .attr('rel', 'nofollow')
1103                                    .append(
1104                                            jQuery('<span>')
1105                                            .attr('class', 'woof_remove_ppi')
1106                                            .append(range_txt)
1107                                            )
1108                                    )
1109                                    );
1110                }
1111            }
1112        });
1113    }
1114
1115    if (
1116            jQuery(panel).find('li').length == 0 ||
1117            !jQuery('.woof_products_top_panel').length
1118            ) {
1119        panel.hide();
1120    } else {
1121        panel
1122                .find('ul.woof_products_top_panel_ul')
1123                .prepend(
1124                        jQuery('<li>').append(
1125                        jQuery('<button>')
1126                        .attr('class', 'woof_reset_button_2')
1127                        .append(woof_lang.clear_all)
1128                        )
1129                        );
1130    }
1131
1132    jQuery('.woof_reset_button_2').on('click', function () {
1133        woof_ajax_page_num = 1;
1134        woof_ajax_redraw = 0;
1135        woof_reset_btn_action = true;
1136
1137        if (woof_is_permalink) {
1138            woof_current_values = {};
1139            woof_submit_link(woof_get_submit_link().split('page/')[0]);
1140        } else {
1141            var link = woof_shop_page;
1142            if (woof_current_values.hasOwnProperty('page_id')) {
1143                link =
1144                        location.protocol +
1145                        '//' +
1146                        location.host +
1147                        '/?page_id=' +
1148                        woof_current_values.page_id;
1149                woof_current_values = {page_id: woof_current_values.page_id};
1150                woof_get_submit_link();
1151            }
1152            //***
1153            woof_submit_link(link);
1154            if (woof_is_ajax) {
1155                history.pushState({}, '', link);
1156                if (woof_current_values.hasOwnProperty('page_id')) {
1157                    woof_current_values = {
1158                        page_id: woof_current_values.page_id,
1159                    };
1160                } else {
1161                    woof_current_values = {};
1162                }
1163            }
1164        }
1165        return false;
1166    });
1167    //+++
1168    jQuery('.woof_remove_ppi')
1169            .parent()
1170            .on('click', function (event) {
1171                event.preventDefault();
1172                var tax = jQuery(this).data('tax');
1173                var name = jQuery(this).data('slug');
1174
1175                //***
1176
1177                if (name == 'all_range') {
1178                    delete woof_current_values[tax];
1179                } else if (tax != 'price') {
1180                    var values = woof_current_values[tax];
1181                    values = values.split(',');
1182                    var tmp = [];
1183                    jQuery.each(values, function (index, value) {
1184                        if (value != name) {
1185                            tmp.push(value);
1186                        }
1187                    });
1188                    values = tmp;
1189
1190                    if (values.length) {
1191                        woof_current_values[tax] = values.join(',');
1192                    } else {
1193                        delete woof_current_values[tax];
1194                    }
1195                } else {
1196                    delete woof_current_values['min_price'];
1197                    delete woof_current_values['max_price'];
1198                }
1199                woof_ajax_page_num = 1;
1200                woof_reset_btn_action = true;
1201                {
1202                    woof_submit_link(woof_get_submit_link());
1203                }
1204                jQuery('.woof_products_top_panel')
1205                        .find("[data-tax='" + tax + "'][href='" + name + "']")
1206                        .hide(333);
1207                return false;
1208            });
1209}
1210
1211//control conditions if proucts shortcode uses on the page
1212function woof_shortcode_observer() {
1213    var redirect = true;
1214    if (
1215            jQuery('.woof_shortcode_output').length ||
1216            (jQuery('.woocommerce .products, .woocommerce .products-loop').length &&
1217                    !jQuery('.single-product').length)
1218            ) {
1219        redirect = false;
1220    }
1221    if (jQuery('.woocommerce .woocommerce-info').length) {
1222        redirect = false;
1223    }
1224    if (typeof woof_not_redirect !== 'undefined' && woof_not_redirect == 1) {
1225        redirect = false;
1226    }
1227
1228    if (jQuery('.woot-data-table').length) {
1229        redirect = false;
1230    }
1231
1232    if (!redirect) {
1233        woof_current_page_link =
1234                location.protocol + '//' + location.host + location.pathname;
1235    }
1236
1237    if (jQuery('#woof_results_by_ajax').length) {
1238        woof_is_ajax = 1;
1239    }
1240}
1241
1242function woof_init_beauty_scroll() {
1243    if (woof_use_beauty_scroll) {
1244        try {
1245            var anchor =
1246                    '.woof_section_scrolled, .woof_sid_auto_shortcode .woof_container';
1247            jQuery('' + anchor).addClass('woof_use_beauty_scroll');
1248        } catch (e) {
1249            console.log(e);
1250        }
1251    }
1252}
1253
1254//just for inbuilt price range widget
1255function woof_remove_class_widget() {
1256    jQuery('.woof_container_inner').find('.widget').removeClass('widget');
1257}
1258
1259function woof_init_show_auto_form() {
1260    jQuery('.woof_show_auto_form').off('click');
1261
1262    if (jQuery('.woof_show_auto_form.woof_btn').length) {
1263        jQuery('.woof_btn_default').remove();
1264    }
1265
1266    jQuery('.woof_show_auto_form').on('click', function () {
1267        var _this = this;
1268        jQuery(_this)
1269                .addClass('woof_hide_auto_form')
1270                .removeClass('woof_show_auto_form');
1271        jQuery(_this)
1272                .parent()
1273                .find('.woof_auto_show')
1274                .show()
1275                .animate(
1276                        {
1277                            height:
1278                                    jQuery(_this)
1279                                    .parent()
1280                                    .find('.woof_auto_show_indent')
1281                                    .height() +
1282                                    20 +
1283                                    'px',
1284                            opacity: 0.96,
1285                        },
1286                        377,
1287                        function () {
1288                            woof_init_hide_auto_form();
1289                            jQuery(_this)
1290                                    .parent()
1291                                    .find('.woof_auto_show')
1292                                    .removeClass('woof_overflow_hidden');
1293                            jQuery(_this)
1294                                    .parent()
1295                                    .find('.woof_auto_show_indent')
1296                                    .removeClass('woof_overflow_hidden');
1297                            jQuery(_this)
1298                                    .parent()
1299                                    .find('.woof_auto_show')
1300                                    .height('auto');
1301                        }
1302                );
1303
1304        return false;
1305    });
1306}
1307
1308//for woof_auto_show closing on blank place click
1309document.addEventListener('click', function (e) {
1310    let opened = document.querySelectorAll('.woof_auto_show');
1311    let target = e.target;
1312    let close = !target.classList.contains('woof_sid');
1313    if (close) {
1314        close = !target.closest('.woof_sid');
1315    }
1316
1317    //this close btn self
1318    if (target.classList.contains('woof_show_auto_form')) {
1319        return true;
1320    }
1321
1322    if (close && Array.from(opened).length > 0) {
1323        Array.from(opened).forEach(function (item) {
1324            if (item.parentNode.querySelector('.woof_hide_auto_form')) {
1325                item.parentNode.querySelector('.woof_hide_auto_form').click();
1326            }
1327        });
1328    }
1329
1330    return true;
1331});
1332
1333function woof_init_hide_auto_form() {
1334    jQuery('.woof_hide_auto_form').off('click');
1335    jQuery('.woof_hide_auto_form').on('click', function () {
1336        var _this = this;
1337        jQuery(_this)
1338                .addClass('woof_show_auto_form')
1339                .removeClass('woof_hide_auto_form');
1340        jQuery(_this)
1341                .parent()
1342                .find('.woof_auto_show')
1343                .show()
1344                .animate(
1345                        {
1346                            height: '1px',
1347                            opacity: 0,
1348                        },
1349                        377,
1350                        function () {
1351                            jQuery(_this)
1352                                    .parent()
1353                                    .find('.woof_auto_show')
1354                                    .addClass('woof_overflow_hidden');
1355                            jQuery(_this)
1356                                    .parent()
1357                                    .find('.woof_auto_show_indent')
1358                                    .addClass('woof_overflow_hidden');
1359                            woof_init_show_auto_form();
1360                        }
1361                );
1362
1363        return false;
1364    });
1365}
1366
1367//if we have mode - child checkboxes closed - append openers buttons by js
1368function woof_checkboxes_slide() {
1369    if (woof_checkboxes_slide_flag) {
1370        var childs = jQuery('ul.woof_childs_list');
1371        if (childs.length) {
1372            jQuery.each(childs, function (index, ul) {
1373                if (jQuery(ul).parents('.woof_no_close_childs').length) {
1374                    return;
1375                }
1376                if (jQuery(ul).find('input').length == 0) {
1377                    return;
1378                }
1379
1380                var span_class = 'woof_is_closed';
1381                if (woof_supports_html5_storage()) {
1382                    //test mode  from 06.11.2017
1383                    var preulstate = localStorage.getItem(
1384                            jQuery(ul).closest('li').attr('class')
1385                            );
1386                    if (preulstate && preulstate == 'woof_is_opened') {
1387                        var span_class = 'woof_is_opened';
1388                        jQuery(ul).show();
1389                    }
1390                    jQuery(ul)
1391                            .parent('li')
1392                            .children('label')
1393                            .after(
1394                                    '<a href="javascript:void(0);" rel="nofollow" class="woof_childs_list_opener" title="' +
1395                                    woof_lang.list_opener +
1396                                    '" ><span class="' +
1397                                    span_class +
1398                                    '"></span></a>'
1399                                    );
1400                    //++
1401                } else {
1402                    if (
1403                            jQuery(ul)
1404                            .find('input[type=checkbox],input[type=radio]')
1405                            .is(':checked')
1406                            ) {
1407                        jQuery(ul).show();
1408                        span_class = 'woof_is_opened';
1409                    }
1410                    jQuery(ul)
1411                            .parent('li')
1412                            .children('label')
1413                            .after(
1414                                    '<a href="javascript:void(0);" rel="nofollow" class="woof_childs_list_opener" title="' +
1415                                    woof_lang.list_opener +
1416                                    '" ><span class="' +
1417                                    span_class +
1418                                    '"></span></a>'
1419                                    );
1420                }
1421            });
1422
1423            jQuery.each(
1424                    jQuery('a.woof_childs_list_opener span'),
1425                    function (index, a) {
1426                        jQuery(a).on('click', function () {
1427                            var span = jQuery(this);
1428                            var this_ = jQuery(this).parent(
1429                                    '.woof_childs_list_opener'
1430                                    );
1431                            if (span.hasClass('woof_is_closed')) {
1432                                //lets open
1433                                jQuery(this_)
1434                                        .parent()
1435                                        .find('ul.woof_childs_list')
1436                                        .first()
1437                                        .show(333);
1438                                span.removeClass('woof_is_closed');
1439                                span.addClass('woof_is_opened');
1440                            } else {
1441                                //lets close
1442                                jQuery(this_)
1443                                        .parent()
1444                                        .find('ul.woof_childs_list')
1445                                        .first()
1446                                        .hide(333);
1447                                span.removeClass('woof_is_opened');
1448                                span.addClass('woof_is_closed');
1449                            }
1450
1451                            if (woof_supports_html5_storage()) {
1452                                //test mode  from 06.11.2017
1453                                var ullabel = jQuery(this_)
1454                                        .closest('li')
1455                                        .attr('class');
1456                                var ullstate = jQuery(this_)
1457                                        .children('span')
1458                                        .attr('class');
1459                                localStorage.setItem(ullabel, ullstate);
1460                            }
1461                            return false;
1462                        });
1463                    }
1464            );
1465        }
1466    }
1467}
1468
1469function woof_init_ion_sliders() {
1470    jQuery.each(jQuery('.woof_range_slider'), function (index, input) {
1471        try {
1472            jQuery(input).ionRangeSlider({
1473                min: jQuery(input).data('min'),
1474                max: jQuery(input).data('max'),
1475                from: jQuery(input).data('min-now'),
1476                to: jQuery(input).data('max-now'),
1477                type: 'double',
1478                prefix: jQuery(input).data('slider-prefix'),
1479                postfix: jQuery(input).data('slider-postfix'),
1480                prettify: true,
1481                prettify_separator: jQuery(input).data('thousand-separator'),
1482                prettify_enabled: true,
1483                hideMinMax: false,
1484                hideFromTo: false,
1485                grid: true,
1486                step: jQuery(input).data('step'),
1487                onFinish: function (ui) {
1488                    var tax = jQuery(input).data('taxes');
1489
1490                    woof_current_values.min_price =
1491                            parseFloat(ui.from, 10) / tax;
1492                    woof_current_values.max_price = parseFloat(ui.to, 10) / tax;
1493                    //woocs adaptation
1494                    if (typeof woocs_current_currency !== 'undefined') {
1495                        woof_current_values.min_price =
1496                                woof_current_values.min_price /
1497                                parseFloat(woocs_current_currency.rate);
1498                        woof_current_values.max_price =
1499                                woof_current_values.max_price /
1500                                parseFloat(woocs_current_currency.rate);
1501                    }
1502                    //***
1503                    woof_ajax_page_num = 1;
1504                    if (
1505                            woof_autosubmit ||
1506                            jQuery(input).within('.woof').length == 0
1507                            ) {
1508                        woof_submit_link(woof_get_submit_link());
1509                    }
1510                    return false;
1511                },
1512                onChange: function (data) {
1513                    if (jQuery('.woof_price_filter_txt')) {
1514                        var tax = jQuery(input).data('taxes');
1515
1516                        jQuery('.woof_price_filter_txt_from').val(
1517                                parseInt(data.from, 10) / tax
1518                                );
1519                        jQuery('.woof_price_filter_txt_to').val(
1520                                parseInt(data.to, 10) / tax
1521                                );
1522                        //woocs adaptation
1523                        if (typeof woocs_current_currency !== 'undefined') {
1524                            jQuery('.woof_price_filter_txt_from').val(
1525                                    Math.ceil(
1526                                            jQuery(
1527                                                    '.woof_price_filter_txt_from'
1528                                                    ).val() /
1529                                            parseFloat(woocs_current_currency.rate)
1530                                            )
1531                                    );
1532                            jQuery('.woof_price_filter_txt_to').val(
1533                                    Math.ceil(
1534                                            jQuery('.woof_price_filter_txt_to').val() /
1535                                            parseFloat(woocs_current_currency.rate)
1536                                            )
1537                                    );
1538                        }
1539                    }
1540                },
1541            });
1542        } catch (e) {
1543        }
1544    });
1545}
1546
1547function woof_init_native_woo_price_filter() {
1548    jQuery('.widget_price_filter form').off('submit');
1549    jQuery('.widget_price_filter form').on('submit', function () {
1550        var min_price = jQuery(this)
1551                .find('.price_slider_amount #min_price')
1552                .val();
1553        var max_price = jQuery(this)
1554                .find('.price_slider_amount #max_price')
1555                .val();
1556        woof_current_values.min_price = min_price;
1557        woof_current_values.max_price = max_price;
1558        woof_ajax_page_num = 1;
1559        // if (woof_autosubmit) {
1560        //comment next code row to avoid endless ajax requests
1561        woof_submit_link(woof_get_submit_link());
1562        // }
1563        return false;
1564    });
1565}
1566
1567//we need after ajax redrawing of the search form
1568function woof_reinit_native_woo_price_filter() {
1569    // woocommerce_price_slider_params is required to continue, ensure the object exists
1570    if (typeof woocommerce_price_slider_params === 'undefined') {
1571        return false;
1572    }
1573
1574    // Get markup ready for slider
1575    jQuery('input#min_price, input#max_price').hide();
1576    jQuery('.price_slider, .price_label').show();
1577
1578    // Price slider uses jquery ui
1579    var min_price = jQuery('.price_slider_amount #min_price').data('min'),
1580            max_price = jQuery('.price_slider_amount #max_price').data('max'),
1581            current_min_price = parseInt(min_price, 10),
1582            current_max_price = parseInt(max_price, 10);
1583
1584    if (woof_current_values.hasOwnProperty('min_price')) {
1585        current_min_price = parseInt(woof_current_values.min_price, 10);
1586        current_max_price = parseInt(woof_current_values.max_price, 10);
1587    } else {
1588        if (woocommerce_price_slider_params.min_price) {
1589            current_min_price = parseInt(
1590                    woocommerce_price_slider_params.min_price,
1591                    10
1592                    );
1593        }
1594        if (woocommerce_price_slider_params.max_price) {
1595            current_max_price = parseInt(
1596                    woocommerce_price_slider_params.max_price,
1597                    10
1598                    );
1599        }
1600    }
1601
1602    //***
1603
1604    var currency_symbol = woocommerce_price_slider_params.currency_symbol;
1605    if (typeof currency_symbol == 'undefined') {
1606        currency_symbol =
1607                woocommerce_price_slider_params.currency_format_symbol;
1608    }
1609
1610    jQuery(document.body).on(
1611            'price_slider_create price_slider_slide',
1612            function (event, min, max) {
1613                if (typeof woocs_current_currency !== 'undefined') {
1614                    var label_min = min;
1615                    var label_max = max;
1616                    if (typeof currency_symbol == 'undefined') {
1617                        currency_symbol = woocs_current_currency.symbol;
1618                    }
1619
1620                    if (woocs_current_currency.rate !== 1) {
1621                        label_min = Math.ceil(
1622                                label_min * parseFloat(woocs_current_currency.rate)
1623                                );
1624                        label_max = Math.ceil(
1625                                label_max * parseFloat(woocs_current_currency.rate)
1626                                );
1627                    }
1628
1629                    //+++
1630                    label_min = woof_front_number_format(label_min, 2, '.', ',');
1631                    label_max = woof_front_number_format(label_max, 2, '.', ',');
1632                    if (
1633                            jQuery.inArray(
1634                                    woocs_current_currency.name,
1635                                    woocs_array_no_cents
1636                                    ) ||
1637                            woocs_current_currency.hide_cents == 1
1638                            ) {
1639                        label_min = label_min.replace('.00', '');
1640                        label_max = label_max.replace('.00', '');
1641                    }
1642                    //+++
1643
1644                    if (woocs_current_currency.position === 'left') {
1645                        jQuery('.price_slider_amount span.from').html(
1646                                currency_symbol + label_min
1647                                );
1648                        jQuery('.price_slider_amount span.to').html(
1649                                currency_symbol + label_max
1650                                );
1651                    } else if (woocs_current_currency.position === 'left_space') {
1652                        jQuery('.price_slider_amount span.from').html(
1653                                currency_symbol + ' ' + label_min
1654                                );
1655                        jQuery('.price_slider_amount span.to').html(
1656                                currency_symbol + ' ' + label_max
1657                                );
1658                    } else if (woocs_current_currency.position === 'right') {
1659                        jQuery('.price_slider_amount span.from').html(
1660                                label_min + currency_symbol
1661                                );
1662                        jQuery('.price_slider_amount span.to').html(
1663                                label_max + currency_symbol
1664                                );
1665                    } else if (woocs_current_currency.position === 'right_space') {
1666                        jQuery('.price_slider_amount span.from').html(
1667                                label_min + ' ' + currency_symbol
1668                                );
1669                        jQuery('.price_slider_amount span.to').html(
1670                                label_max + ' ' + currency_symbol
1671                                );
1672                    }
1673                } else {
1674                    if (woocommerce_price_slider_params.currency_pos === 'left') {
1675                        jQuery('.price_slider_amount span.from').html(
1676                                currency_symbol + min
1677                                );
1678                        jQuery('.price_slider_amount span.to').html(
1679                                currency_symbol + max
1680                                );
1681                    } else if (
1682                            woocommerce_price_slider_params.currency_pos ===
1683                            'left_space'
1684                            ) {
1685                        jQuery('.price_slider_amount span.from').html(
1686                                currency_symbol + ' ' + min
1687                                );
1688                        jQuery('.price_slider_amount span.to').html(
1689                                currency_symbol + ' ' + max
1690                                );
1691                    } else if (
1692                            woocommerce_price_slider_params.currency_pos === 'right'
1693                            ) {
1694                        jQuery('.price_slider_amount span.from').html(
1695                                min + currency_symbol
1696                                );
1697                        jQuery('.price_slider_amount span.to').html(
1698                                max + currency_symbol
1699                                );
1700                    } else if (
1701                            woocommerce_price_slider_params.currency_pos ===
1702                            'right_space'
1703                            ) {
1704                        jQuery('.price_slider_amount span.from').html(
1705                                min + ' ' + currency_symbol
1706                                );
1707                        jQuery('.price_slider_amount span.to').html(
1708                                max + ' ' + currency_symbol
1709                                );
1710                    }
1711                }
1712
1713                jQuery(document.body).trigger('price_slider_updated', [min, max]);
1714            }
1715    );
1716
1717    jQuery('.price_slider').slider({
1718        range: true,
1719        animate: true,
1720        min: min_price,
1721        max: max_price,
1722        values: [current_min_price, current_max_price],
1723        create: function () {
1724            jQuery('.price_slider_amount #min_price').val(current_min_price);
1725            jQuery('.price_slider_amount #max_price').val(current_max_price);
1726
1727            jQuery(document.body).trigger('price_slider_create', [
1728                current_min_price,
1729                current_max_price,
1730            ]);
1731        },
1732        slide: function (event, ui) {
1733            jQuery('input#min_price').val(ui.values[0]);
1734            jQuery('input#max_price').val(ui.values[1]);
1735
1736            jQuery(document.body).trigger('price_slider_slide', [
1737                ui.values[0],
1738                ui.values[1],
1739            ]);
1740        },
1741        change: function (event, ui) {
1742            jQuery(document.body).trigger('price_slider_change', [
1743                ui.values[0],
1744                ui.values[1],
1745            ]);
1746        },
1747    });
1748
1749    //***
1750    woof_init_native_woo_price_filter();
1751}
1752
1753function woof_mass_reinit() {
1754    woof_remove_empty_elements();
1755    woof_open_hidden_li();
1756    woof_init_search_form();
1757    woof_hide_info_popup();
1758    woof_init_beauty_scroll();
1759    woof_init_ion_sliders();
1760    woof_reinit_native_woo_price_filter(); //native woo price range slider reinit
1761    woof_recount_text_price_filter();
1762    woof_draw_products_top_panel();
1763    woof_unblur_filter();
1764}
1765function woof_unblur_filter() {
1766    jQuery('.woof_redraw_zone.woof_blur_redraw_zone').removeClass(
1767            'woof_blur_redraw_zone'
1768            );
1769}
1770
1771function woof_recount_text_price_filter() {
1772    //change value in textinput price filter if WOOCS is installed
1773    if (typeof woocs_current_currency !== 'undefined') {
1774        jQuery.each(
1775                jQuery('.woof_price_filter_txt_from, .woof_price_filter_txt_to'),
1776                function (i, item) {
1777                    jQuery(this).val(Math.ceil(jQuery(this).data('value')));
1778                }
1779        );
1780    }
1781}
1782
1783function woof_init_toggles() {
1784    jQuery('body').off('click', '.woof_front_toggle');
1785    jQuery('body').on('click', '.woof_front_toggle', function () {
1786        if (jQuery(this).data('condition') == 'opened') {
1787            jQuery(this).removeClass('woof_front_toggle_opened');
1788            jQuery(this).addClass('woof_front_toggle_closed');
1789            jQuery(this).data('condition', 'closed');
1790
1791            if (woof_toggle_type == 'text') {
1792                jQuery(this).text(woof_toggle_closed_text);
1793            } else {
1794                jQuery(this).find('img').prop('src', woof_toggle_closed_image);
1795            }
1796        } else {
1797            jQuery(this).addClass('woof_front_toggle_opened');
1798            jQuery(this).removeClass('woof_front_toggle_closed');
1799            jQuery(this).data('condition', 'opened');
1800            if (woof_toggle_type == 'text') {
1801                jQuery(this).text(woof_toggle_opened_text);
1802            } else {
1803                jQuery(this).find('img').prop('src', woof_toggle_opened_image);
1804            }
1805        }
1806
1807        jQuery(this)
1808                .parents('.woof_container_inner')
1809                .find('.woof_block_html_items')
1810                .slideToggle(500);
1811
1812        /* fix  for chosen*/
1813        var is_chosen_here = jQuery(this)
1814                .parents('.woof_container_inner')
1815                .find('.chosen-container');
1816        if (
1817                is_chosen_here.length &&
1818                jQuery(this).hasClass('woof_front_toggle_opened')
1819                ) {
1820            jQuery(this)
1821                    .parents('.woof_container_inner')
1822                    .find('select')
1823                    .chosen('destroy')
1824                    .trigger('liszt:updated');
1825            jQuery(this)
1826                    .parents('.woof_container_inner')
1827                    .find('select')
1828                    .chosen(/*{disable_search_threshold: 10}*/);
1829        }
1830        if (jQuery(this).hasClass('woof_front_toggle_opened')) {
1831            woof_reinit_selects();
1832        }
1833
1834        return false;
1835    });
1836}
1837
1838//for "Show more" blocks
1839function woof_open_hidden_li() {
1840    if (jQuery('.woof_open_hidden_li_btn').length > 0) {
1841        jQuery.each(jQuery('.woof_open_hidden_li_btn'), function (i, b) {
1842            if (
1843                    jQuery(b)
1844                    .parents('ul')
1845                    .find(
1846                            'li.woof_hidden_term input[type=checkbox],li.woof_hidden_term input[type=radio]'
1847                            )
1848                    .is(':checked')
1849                    ) {
1850                jQuery(b).trigger('click');
1851            }
1852        });
1853    }
1854}
1855
1856//http://stackoverflow.com/questions/814613/how-to-read-get-data-from-a-url-using-javascript
1857function $_woof_GET(q, s) {
1858    s = s ? s : window.location.search;
1859    var re = new RegExp('&' + q + '=([^&]*)', 'i');
1860    return (s = s.replace(/^\?/, '&').match(re)) ? (s = s[1]) : (s = '');
1861}
1862
1863function woof_parse_url(url) {
1864    var pattern = RegExp(
1865            '^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?'
1866            );
1867    var matches = url.match(pattern);
1868    return {
1869        scheme: matches[2],
1870        authority: matches[4],
1871        path: matches[5],
1872        query: matches[7],
1873        fragment: matches[9],
1874    };
1875}
1876
1877//      woof price radio;
1878function woof_price_filter_radio_init() {
1879    if (icheck_skin != 'none') {
1880        jQuery('.woof_price_filter_radio').iCheck('destroy');
1881
1882        let icheck_selector = '.woof_price_filter_radio';
1883        let skin = jQuery(icheck_selector)
1884                .parents('.woof_redraw_zone')
1885                .eq(0)
1886                .data('icheck-skin');
1887        if (skin) {
1888            skin = skin.split('_');
1889            jQuery(icheck_selector).iCheck({
1890                radioClass: 'iradio_' + skin[0] + '-' + skin[1],
1891            });
1892        } else {
1893            jQuery(icheck_selector).iCheck({
1894                radioClass:
1895                        'iradio_' + icheck_skin.skin + '-' + icheck_skin.color,
1896            });
1897        }
1898
1899        //***
1900
1901        jQuery('.woof_price_filter_radio')
1902                .siblings('div')
1903                .removeClass('checked');
1904
1905        jQuery('.woof_price_filter_radio').off('ifChecked');
1906        jQuery('.woof_price_filter_radio').on('ifChecked', function (event) {
1907            jQuery(this).attr('checked', true);
1908            jQuery('.woof_radio_price_reset').removeClass(
1909                    'woof_radio_term_reset_visible'
1910                    );
1911            jQuery(this)
1912                    .parents('.woof_list')
1913                    .find('.woof_radio_price_reset')
1914                    .removeClass('woof_radio_term_reset_visible');
1915            jQuery(this)
1916                    .parents('.woof_list')
1917                    .find('.woof_radio_price_reset')
1918                    .hide();
1919            jQuery(this)
1920                    .parents('li')
1921                    .eq(0)
1922                    .find('.woof_radio_price_reset')
1923                    .eq(0)
1924                    .addClass('woof_radio_term_reset_visible');
1925            var val = jQuery(this).val();
1926            if (parseInt(val, 10) == -1) {
1927                delete woof_current_values.min_price;
1928                delete woof_current_values.max_price;
1929                jQuery(this).removeAttr('checked');
1930                jQuery(this)
1931                        .siblings('.woof_radio_price_reset')
1932                        .removeClass('woof_radio_term_reset_visible');
1933            } else {
1934                var val = val.split('-');
1935                woof_current_values.min_price = val[0];
1936                woof_current_values.max_price = val[1];
1937                jQuery(this)
1938                        .siblings('.woof_radio_price_reset')
1939                        .addClass('woof_radio_term_reset_visible');
1940                jQuery(this).attr('checked', true);
1941            }
1942            if (woof_autosubmit || jQuery(this).within('.woof').length == 0) {
1943                woof_submit_link(woof_get_submit_link());
1944            }
1945        });
1946    } else {
1947        jQuery('body').on('change', '.woof_price_filter_radio', function () {
1948            var val = jQuery(this).val();
1949            jQuery('.woof_radio_price_reset').removeClass(
1950                    'woof_radio_term_reset_visible'
1951                    );
1952            if (parseInt(val, 10) == -1) {
1953                delete woof_current_values.min_price;
1954                delete woof_current_values.max_price;
1955                jQuery(this).removeAttr('checked');
1956                jQuery(this)
1957                        .siblings('.woof_radio_price_reset')
1958                        .removeClass('woof_radio_term_reset_visible');
1959            } else {
1960                var val = val.split('-');
1961                woof_current_values.min_price = val[0];
1962                woof_current_values.max_price = val[1];
1963                jQuery(this)
1964                        .siblings('.woof_radio_price_reset')
1965                        .addClass('woof_radio_term_reset_visible');
1966                jQuery(this).attr('checked', true);
1967            }
1968            if (woof_autosubmit || jQuery(this).within('.woof').length == 0) {
1969                woof_submit_link(woof_get_submit_link());
1970            }
1971        });
1972    }
1973    //***
1974    jQuery('.woof_radio_price_reset').on('click', function () {
1975        delete woof_current_values.min_price;
1976        delete woof_current_values.max_price;
1977        jQuery(this).siblings('div').removeClass('checked');
1978        jQuery(this)
1979                .parents('.woof_list')
1980                .find('input[type=radio]')
1981                .removeAttr('checked');
1982
1983        jQuery(this).removeClass('woof_radio_term_reset_visible');
1984        if (woof_autosubmit) {
1985            woof_submit_link(woof_get_submit_link());
1986        }
1987        return false;
1988    });
1989}
1990//    END  woof price radio;
1991
1992function woof_serialize(serializedString) {
1993    var str = decodeURI(serializedString);
1994    var pairs = str.split('&');
1995    var obj = {},
1996            p,
1997            idx,
1998            val;
1999    for (var i = 0, n = pairs.length; i < n; i++) {
2000        p = pairs[i].split('=');
2001        idx = p[0];
2002
2003        if (idx.indexOf('[]') == idx.length - 2) {
2004            // Eh um vetor
2005            var ind = idx.substring(0, idx.length - 2);
2006            if (obj[ind] === undefined) {
2007                obj[ind] = [];
2008            }
2009            obj[ind].push(p[1]);
2010        } else {
2011            obj[idx] = p[1];
2012        }
2013    }
2014    return obj;
2015}
2016
2017//compatibility with YITH Infinite Scrolling
2018function woof_infinite() {
2019    if (typeof yith_infs_premium !== 'undefined' && yith_infs_premium.options) {
2020        woof_change_ajax_next_link();
2021        return false;
2022    }
2023
2024    if (typeof yith_infs === 'undefined') {
2025        return;
2026    }
2027
2028    //***
2029    var infinite_scroll1 = {
2030        //'nextSelector': ".woof_infinity .nav-links .next",
2031        nextSelector: '.woocommerce-pagination li .next',
2032        navSelector: yith_infs.navSelector,
2033        itemSelector: yith_infs.itemSelector,
2034        contentSelector: yith_infs.contentSelector,
2035        loader: '<img src="' + yith_infs.loader + '">',
2036        is_shop: yith_infs.shop,
2037    };
2038    woof_change_ajax_next_link();
2039    jQuery(window).off('yith_infs_start'),
2040            jQuery(yith_infs.contentSelector).yit_infinitescroll(infinite_scroll1);
2041}
2042
2043function woof_change_ajax_next_link() {
2044    if (!jQuery('.woocommerce-pagination li .next').length) {
2045        return false;
2046    }
2047    var curr_l = window.location.href;
2048    var curr_link = curr_l.split('?');
2049    var get = '';
2050    if (curr_link[1] != undefined) {
2051        var temp = woof_serialize(curr_link[1]);
2052        delete temp['paged'];
2053        get = decodeURIComponent(jQuery.param(temp));
2054    }
2055
2056    var page_link = jQuery('.woocommerce-pagination li .next').attr('href');
2057
2058    if (page_link == undefined) {
2059        page_link = curr_link + 'page/1/';
2060    }
2061
2062    var ajax_link = page_link.split('?');
2063    var page = '';
2064    if (ajax_link[1] != undefined) {
2065        var temp1 = woof_serialize(ajax_link[1]);
2066        if (temp1['paged'] != undefined) {
2067            page = '/page/' + temp1['paged'] + '/';
2068        }
2069    }
2070
2071    page_link = curr_link[0].replace(/\/$/, '') + page + '?' + get;
2072
2073    jQuery('.woocommerce-pagination li .next').attr('href', page_link);
2074}
2075//End infinity scroll
2076
2077//fix  if woof - is ajax  and  cart - is redirect
2078function woof_change_link_addtocart() {
2079    if (!woof_is_ajax) {
2080        return;
2081    }
2082    jQuery('.add_to_cart_button').each(function (i, elem) {
2083        var link = jQuery(elem).attr('href');
2084        if (link) {
2085            var link_items = link.split('?');
2086            var site_link_items = window.location.href.split('?');
2087            if (link_items[1] != undefined) {
2088                link = site_link_items[0] + '?' + link_items[1];
2089                jQuery(elem).attr('href', link);
2090            }
2091        }
2092    });
2093}
2094//https://github.com/kvz/phpjs/blob/master/functions/strings/number_format.js
2095function woof_front_number_format(number, decimals, dec_point, thousands_sep) {
2096    number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
2097    var n = !isFinite(+number) ? 0 : +number,
2098            prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
2099            sep = typeof thousands_sep === 'undefined' ? ',' : thousands_sep,
2100            dec = typeof dec_point === 'undefined' ? '.' : dec_point,
2101            s = '',
2102            toFixedFix = function (n, prec) {
2103                var k = Math.pow(10, prec);
2104                return '' + (Math.round(n * k) / k).toFixed(prec);
2105            };
2106    // Fix for IE parseFloat(0.55).toFixed(0) = 0;
2107    s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
2108    if (s[0].length > 3) {
2109        s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
2110    }
2111    if ((s[1] || '').length < prec) {
2112        s[1] = s[1] || '';
2113        s[1] += new Array(prec - s[1].length + 1).join('0');
2114    }
2115    return s.join(dec);
2116}
2117
2118//additional function to check local storage
2119function woof_supports_html5_storage() {
2120    if (typeof woof_save_state_checkbox !== 'undefined' && woof_save_state_checkbox === 0) {
2121        return false;
2122    }
2123    try {
2124        return 'localStorage' in window && window['localStorage'] !== null;
2125    } catch (e) {
2126        return false;
2127    }
2128}
2129
2130function woof_init_tooltip() {
2131    var tooltips = jQuery('.woof_tooltip_header');
2132
2133    if (tooltips.length) {
2134        jQuery(tooltips).tooltipster({
2135            theme: 'tooltipster-noir',
2136            side: 'right',
2137            trigger: 'click',
2138        });
2139    }
2140}
2141function woof_before_ajax_form_redrawing() {
2142    if (woof_select_type == 'selectwoo') {
2143        try {
2144            jQuery('select.woof_mselect').selectWoo('destroy');
2145            jQuery('select.woof_meta_mselect').selectWoo('destroy');
2146        } catch (e) {
2147            return false;
2148        }
2149    }
2150}
2151function woof_reinit_selects() {
2152    if (woof_select_type == 'chosen') {
2153        try {
2154            jQuery('select.woof_select, select.woof_mselect')
2155                    .chosen('destroy')
2156                    .trigger('liszt:updated');
2157            jQuery(
2158                    'select.woof_select, select.woof_mselect'
2159                    ).chosen(/*{disable_search_threshold: 10}*/);
2160            jQuery('select.woof_meta_select, select.woof_meta_mselect')
2161                    .chosen('destroy')
2162                    .trigger('liszt:updated');
2163            jQuery(
2164                    'select.woof_meta_select, select.woof_meta_mselect'
2165                    ).chosen(/*{disable_search_threshold: 10}*/);
2166        } catch (e) {
2167        }
2168    } else if (woof_select_type == 'selectwoo') {
2169        try {
2170            jQuery('select.woof_select, select.woof_mselect').selectWoo(
2171                    'destroy'
2172                    );
2173            jQuery('select.woof_select, select.woof_mselect').selectWoo();
2174            jQuery(
2175                    'select.woof_meta_select, select.woof_meta_mselect'
2176                    ).selectWoo('destroy');
2177            jQuery(
2178                    'select.woof_meta_select, select.woof_meta_mselect'
2179                    ).selectWoo();
2180        } catch (e) {
2181        }
2182    }
2183}
2184function woof_init_mobile_filter() {
2185    var show_btn = jQuery('.woof_show_mobile_filter');
2186    var show_btn_container = jQuery('.woof_show_mobile_filter_container');
2187    var def_container = jQuery(woof_m_b_container);
2188    if (!show_btn_container.length) {
2189        show_btn_container = def_container;
2190    }
2191    if (show_btn && show_btn_container) {
2192        jQuery(show_btn_container).append(show_btn);
2193    }
2194
2195    jQuery('.woof_show_mobile_filter').on('click', function (e) {
2196        var sid = jQuery(this).data('sid');
2197
2198        if (jQuery('.woof.woof_sid_front_builder').length > 0) {
2199            //front builder adaptation
2200            sid = 'front_builder';
2201            jQuery('.woof.woof_sid_' + sid).toggleClass(
2202                    'woof_show_filter_for_mobile'
2203                    );
2204        } else {
2205            jQuery('.woof.woof_sid_' + sid).toggleClass(
2206                    'woof_show_filter_for_mobile'
2207                    );
2208        }
2209
2210        setTimeout(function () {
2211            try {
2212                jQuery('.woof.woof_sid_' + sid)
2213                        .find('select.woof_mselect')
2214                        .chosen('destroy');
2215                jQuery('.woof.woof_sid_' + sid)
2216                        .find('select.woof_select')
2217                        .chosen('destroy');
2218                jQuery('.woof.woof_sid_' + sid)
2219                        .find('select.woof_mselect')
2220                        .chosen();
2221                jQuery('.woof.woof_sid_' + sid)
2222                        .find('select.woof_select')
2223                        .chosen();
2224            } catch (e) {
2225                //***
2226            }
2227        }, 300);
2228    });
2229
2230    jQuery('.woof_hide_mobile_filter').on('click', function (e) {
2231        jQuery(this)
2232                .parents('.woof')
2233                .toggleClass('woof_show_filter_for_mobile');
2234    });
2235}

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.