PageSourceSearch

https://drerowery.pl/wp-content/plugins/woocommerce-ajax-filters/assets/frontend/js/widget.min.js?ver=3.3

js drerowery.pl collected 2026-09-26 16:58:42 UTC 77,029 bytes, 1,569 lines download raw bytes

1//Filter functions
2var berocket_filters = {};
3function berocket_make_args_array(args) {
4    var args_array = [];
5    for(var i = 0; i < args.length; i++) {
6        args_array.push(args[i]);
7    }
8    return args_array;
9}
10function berocket_apply_filters(filter_name, filter_element) {
11    if( typeof(berocket_filters[filter_name]) !== 'undefined' ) {
12        var array_args = berocket_make_args_array(arguments);
13        array_args.splice(0, 1);
14        jQuery.each(berocket_filters[filter_name], function(i, callback_data) {
15            filter_element = callback_data.callback.apply(null, array_args);
16            array_args[0] = filter_element;
17        });
18    }
19    return filter_element;
20}
21function berocket_do_action(filter_name) {
22    if( typeof(berocket_filters[filter_name]) !== 'undefined' ) {
23        var array_args = berocket_make_args_array(arguments);
24        array_args.splice(0, 1);
25        jQuery.each(berocket_filters[filter_name], function(i, callback_data) {
26            callback_data.callback.apply(null, array_args);
27        });
28    }
29}
30function berocket_throw_error(error_name) {
31    var filter_name = 'berocket_throw_error';
32    error_exist = true;
33    if( typeof(berocket_filters[filter_name]) !== 'undefined' ) {
34        var array_args = [error_exist];
35        for(var i = 0; i < arguments.length; i++) {
36            array_args.push(arguments[i]);
37        }
38        jQuery.each(berocket_filters[filter_name], function(i, callback_data) {
39            error_exist = callback_data.callback.apply(null, array_args);
40            array_args[0] = error_exist;
41            if( ! error_exist ) {
42                return false;
43            }
44        });
45    }
46    return error_exist;
47}
48function berocket_add_filter(filter_name, callback, priority) {
49    if( typeof(priority) == 'undefined' ) {
50        priority = 10;
51    }
52    if( typeof(berocket_filters[filter_name]) === 'undefined' ) {
53        berocket_filters[filter_name] = [];
54    }
55    var isExist = false;
56    jQuery.each(berocket_filters[filter_name], function(i, callback_data) {
57        if( callback_data.priority === priority && callback_data.callback === callback ) {
58            isExist = true;
59        }
60    });
61    if( ! isExist ) {
62        berocket_filters[filter_name].push({callback:callback, priority:priority});
63        berocket_filters[filter_name] = berocket_sort_by_priority(berocket_filters[filter_name]);
64    }
65}
66function berocket_remove_filter(filter_name, callback, priority) {
67    if( typeof(priority) == 'undefined' ) {
68        priority = 10;
69    }
70    if( typeof(berocket_filters[filter_name]) != 'undefined' ) {
71        var new_array = [];
72        jQuery.each(berocket_filters[filter_name], function(i, callback_data) {
73            if( callback_data.priority !== priority || callback_data.callback !== callback ) {
74                new_array.push(callback_data);
75            }
76        });
77        berocket_filters[filter_name] = berocket_sort_by_priority(new_array);
78    }
79}
80function berocket_sort_by_priority(sorting_array) {
81    if( Array.isArray(sorting_array) ) {
82        sorting_array.sort(function(a, b) {
83            if( a.priority > b.priority ) {
84                return 1;
85            } else if( a.priority < b.priority ) {
86                return -1;
87            }
88            return 0;
89        });
90    }
91    return sorting_array;
92}
93berocket_add_filter('compat_filters_result_single', function(val) {
94    if( typeof( val ) == 'object' && typeof(val.taxonomy) == 'string' && val.taxonomy.substr(0, 3) == 'pa_' ) {
95        val.taxonomy = val.taxonomy.substr(3);
96    }
97    return val;
98});
99
100
101//NEW TEMPLATE 
102
103function berocket_format_number (number, number_style) {
104    if( typeof number_style == 'undefined' ) {
105        number_style = the_ajax_script.number_style;
106    }
107    number = parseFloat(number);
108    if( number === NaN ) {
109        return '0';
110    }
111    var num = number.toFixed(number_style[2]);
112    num = num.toString();
113    var decimal = num.split('.');
114    var new_number = decimal[0];
115    if(num.indexOf('.') != -1)
116    {
117        decimal = decimal[1];
118    }
119    new_number = new_number.replace(/\d(?=(?:\d{3})+(?:$))/g, function($0, i){
120        return $0+number_style[0];
121    });
122    if(num.indexOf('.') != -1)
123    {
124        new_number = new_number+number_style[1]+decimal;
125    }
126    return new_number;
127}
128jQuery(document).trigger('berocket_hooks_ready');
129var braapf_filter_blocked = false,
130//object{taxonomy:"", values:[value:"",html:"name/colorBlock/imgBlock/text"], glue:""}
131braapf_selected_filters = [],
132braapf_filtered_filters = [],
133braapf_filters_var,
134braapf_ajax_request;
135//FUNCTIONS
136var braapf_checkbox_same,
137braapf_update_products,
138braapf_grab_all,
139braapf_grab_single,
140braapf_compact_filters,
141braapf_compat_filters_to_string,
142braapf_build_url_from_urldata,
143braapf_apply_additional_filter_data,
144braapf_glue_by_operator,
145braapf_ajax_load_from_url,
146braapf_ajax_load_from_url_request,
147braapf_init_load,
148braapf_remove_pages_from_url_data,
149braapf_filter_products_by_url,
150braapf_get_current_url_data,
151braapf_reset_buttons_hide,
152bapf_universal_theme_compatibility,
153braapf_disable_ajax_loading,
154braapf_close_tippy,
155braapf_context_is_update,
156braapf_filter_mobile_desktop_filters;
157function braapf_grab_all_init() {braapf_grab_all();}
158function braapf_selected_filters_area_set_init() {braapf_selected_filters_area_set();}
159function braapf_filtered_filters_set() {
160    braapf_filtered_filters = braapf_selected_filters.slice();
161    berocket_do_action('braapf_init_filtered_set', braapf_filtered_filters);
162}
163(function ($){
164    //Main part
165    //Checkbox change script
166    $(document).on("change", ".bapf_sfilter.bapf_ckbox input[type=checkbox]", function(){
167        var value = $(this).val();
168        var taxonomy = $(this).parents('.bapf_sfilter').data('taxonomy');
169        var checked = $(this).prop('checked');
170        braapf_checkbox_same(taxonomy, value, checked);
171        berocket_do_action('input_ckbox_changed', this, taxonomy, value, checked);
172        var filter_changed_element = {
173            element:'#'+$(this).attr('id'),
174            parent: 1,
175            find: false
176        };
177        berocket_apply_filters('filter_changed_element', filter_changed_element, $(this));
178        berocket_do_action('update_products', 'filter', $(this));
179    });
180    braapf_checkbox_same = function (taxonomy, value, checked) {
181        $('.bapf_sfilter[data-taxonomy="'+taxonomy+'"] input[value="'+value+'"]').prop('checked', checked);
182        if( $('.bapf_sfilter[data-taxonomy="'+taxonomy+'"]').length > $('.bapf_sfilter.bapf_ckbox[data-taxonomy="'+taxonomy+'"]').length ) {
183            berocket_throw_error('multiple_filters_for_same_taxonomy', taxonomy);
184        }
185    }
186    $(document).on('braapf_unselect', '.bapf_ckbox', function(event, data) {
187        if( typeof(data) == 'undefined' ) {
188            data = false;
189        }
190        if( data == false ) {
191            var $this = $(this).find('input[type=checkbox]');
192        } else {
193            var $this = $(this).find('input[value="'+data.value+'"]');
194        }
195        if( $this.length > 0 ) {
196            var value = $this.val();
197            var taxonomy = $(this).data('taxonomy');
198            $this.prop('checked', false);
199            braapf_checkbox_same(taxonomy, value, false);
200        }
201    });
202    $(document).on('braapf_unselect_all', '.bapf_ckbox', function(event, data) {
203        $(this).trigger('braapf_unselect', false);
204    });
205    $(document).on('berocket_filters_document_ready', function() {
206        $('.bapf_ckbox input[type=checkbox]:checked').closest('li').parents('li').trigger('bapf_ochild');
207    });
208    //update/reset butons
209    $(document).on('click', '.berocket_aapf_widget_update_button, .bapf_update', function(event) {
210        event.preventDefault();
211        berocket_do_action('update_products', 'update', $(this));
212    });
213    $(document).on('click', '.berocket_aapf_reset_button, .bapf_reset', function(event) {
214        event.preventDefault();
215        braapf_unselect_all();
216        berocket_do_action('update_products', 'reset_all', $(this));
217    });
218    braapf_reset_buttons_hide = function() {
219        if( berocket_apply_filters('bapf_rst_nofltr_hide', (typeof(braapf_filtered_filters) == 'undefined' || braapf_filtered_filters.length <= 0)) ) {
220            $('.bapf_rst_nofltr').hide();
221        } else {
222            $('.bapf_rst_nofltr').show();
223        }
224        var selected = false;
225        if( typeof(braapf_filtered_filters) != 'undefined' && braapf_filtered_filters.length > 0 ) {
226            $.each(braapf_filtered_filters, function(i, taxonomy) {
227                if( taxonomy.values.length > 0 ) {
228                    selected = true;
229                    return false;
230                }
231            });
232        }
233        if( berocket_apply_filters('bapf_rst_sel_show', selected) ) {
234            $('.bapf_rst_sel').show();
235        } else {
236            $('.bapf_rst_sel').hide();
237        }
238    }
239    berocket_add_filter('braapf_init', braapf_reset_buttons_hide, 1500);
240    berocket_add_filter('braapf_init_filtered_set', braapf_reset_buttons_hide, 1500);
241    //Pagination page
242    jQuery(document).ready( function() {
243        var pagination_links = the_ajax_script.pagination_class;
244        pagination_links = pagination_links.replaceAll(',', ' a,');
245        pagination_links = berocket_apply_filters('pagination_links_a_tags', pagination_links+' a', the_ajax_script.pagination_class);
246        if( !the_ajax_script.disable_ajax_loading && the_ajax_script.pagination_ajax && $(the_ajax_script.products_holder_id).length ) {
247            $(document).on('click', pagination_links, function(event) {
248                event.preventDefault();
249                var href = $(this).attr('href');
250                href = berocket_apply_filters('pagination_href_from_clicked_a', decodeURI(href), $(this));
251                braapf_change_url_history_api(href, {replace:the_ajax_script.seo_friendly_urls});
252                berocket_add_filter('ajax_load_from_url_beforeSend', braapf_pagination_prevent_filters_load);
253                braapf_ajax_load_from_url(href, {}, berocket_apply_filters('ajax_load_from_pagination', {done:[braapf_replace_products, braapf_replace_pagination, braapf_replace_result_count, braapf_init_load, braapf_update_data_from_current, braapf_update_seo_elements]}, href));
254            });
255        }
256    });
257    function braapf_pagination_prevent_filters_load(xhr) {
258        berocket_remove_filter('ajax_load_from_url_beforeSend', braapf_pagination_prevent_filters_load);
259        xhr.setRequestHeader('X-Braapfdisable', '1');
260        return xhr;
261    }
262    //Order By override
263    jQuery(document).ready( function() {
264        if( !the_ajax_script.disable_ajax_loading && the_ajax_script.control_sorting ) {
265            $(document).on('submit', the_ajax_script.ordering_class, function(event) {
266                event.preventDefault();
267                var current_url_data = braapf_get_current_url_data();
268                current_url_data = braapf_remove_pages_from_url_data(current_url_data);
269                if( Array.isArray(current_url_data.queryargs) ) {
270                    var newqueryargs = [];
271                    $.each(current_url_data.queryargs, function(i, val) {
272                        if(val.name != 'orderby') {
273                            newqueryargs.push(val);
274                        }
275                    });
276                    current_url_data.queryargs = newqueryargs;
277                } else {
278                    current_url_data.queryargs = [];
279                }
280                var form_data = $(this).serializeArray();
281                if( Array.isArray(form_data) ) {
282                    $.each(form_data, function(i, val) {
283                        if(val.name == 'paged') {
284                            current_url_data.page = parseInt(val.value);
285                        } else if( val.name == 'orderby' ) {
286                            if( the_ajax_script.default_sorting != val.value ) {
287                                current_url_data.queryargs.push(val);
288                            }
289                        } else {
290                            current_url_data.queryargs.push(val);
291                        }
292                    });
293                }
294                var url_filtered = braapf_build_url_from_urldata(current_url_data);
295                braapf_filter_products_by_url(url_filtered);
296            });
297        }
298    });
299    
300    //default update products
301    braapf_get_filters_selected = function() {
302        braapf_grab_all();
303        var compat_filters = braapf_compact_filters();
304        var filter_mask = berocket_apply_filters('braapf_filters_mask', the_aja
304x_script.url_mask);
305        var filter_string = braapf_compat_filters_to_string(compat_filters, filter_mask, the_ajax_script.url_split);
306        return filter_string;
307    }
308    braapf_get_url_with_filters_selected = function() {
309        var filter_string = braapf_get_filters_selected();
310        var current_url_data = braapf_get_current_url_data();
311        current_url_data.filter = filter_string;
312        current_url_data = braapf_remove_pages_from_url_data(current_url_data);
313        current_url_data = braapf_apply_additional_filter_data(current_url_data);
314        var url_filtered = braapf_build_url_from_urldata(current_url_data);
315        return url_filtered;
316    }
317    braapf_update_products = function (context, element) {
318        if( typeof(context) == 'undefined' ) {
319            context = 'filter';
320        }
321        if( typeof(element) == 'undefined' ) {
322            element = false;
323        }
324        context = berocket_apply_filters('before_update_products_context', context, element);
325        var url_filtered = berocket_apply_filters('before_update_products_context_url_filtered', braapf_get_url_with_filters_selected(), context, element);
326        if( berocket_apply_filters('apply_filters_to_page', ($('.berocket_aapf_widget_update_button:visible, .bapf_update:visible').length == 0 || braapf_context_is_update(context)), context, element, url_filtered) ) {
327            braapf_selected_filters_area_set();
328            braapf_filter_products_by_url(url_filtered);
329        } else if( berocket_apply_filters('apply_filters_to_page_partial', false, context, element, url_filtered) ) {
330            braapf_ajax_load_from_url(berocket_apply_filters('before_update_products_context_url_filtered_partial', url_filtered, context, element), {}, berocket_apply_filters('ajax_load_from_filters_partial', {done:[braapf_replace_each_filter, braapf_init_load]}, url_filtered, 'partial'), 'partial');
331        }
332    }
333    
334    braapf_context_is_update = function(context) {
335        return berocket_apply_filters('context_is_update', (context == 'update' || context == 'reset_all' || context == 'reset_single'), context);
336    }
337    braapf_filter_products_by_url = function(url) {
338        if( berocket_apply_filters('page_has_products_holder', (! $(the_ajax_script.products_holder_id).length), url) ) {
339            location.href = url;
340        } else {
341            braapf_change_url_history_api(url, {replace:the_ajax_script.seo_friendly_urls});
342            braapf_ajax_load_from_url(url, {}, berocket_apply_filters('ajax_load_from_filters', {done:[braapf_replace_products, braapf_replace_pagination, braapf_replace_result_count, braapf_replace_orderby, braapf_replace_each_filter, braapf_init_load, braapf_filtered_filters_set, braapf_update_url_history_api_from_current, braapf_update_seo_elements]}, url, 'default'));
343        }
344    }
345    braapf_update_data_from_current = function() {
346        braapf_grab_all();
347        var compat_filters = braapf_compact_filters();
348    }
349    var braapf_update_url_history_api_from_current_action = false;
350    braapf_update_url_history_api_from_current = function(data, textStatus, jqXHR, url, type) {
351        if( the_ajax_script.seo_friendly_urls ) {
352            url_filtered = braapf_get_url_with_filters_selected();
353            braapf_set_manual_scroll_restoration();
354            history.replaceState(history.state, "BeRocket Rules", url_filtered);
355            if( url != url_filtered && the_ajax_script.reload_changed_filters ) {
356                setTimeout(function() {
357                    braapf_filter_products_by_url(url_filtered);
358                }, 5);
359            }
360        }
361    }
362    braapf_filter_mobile_desktop_filters = function(all_filters) {
363        var mobile_width = berocket_apply_filters('filter_mobile_width', 767); 
364        var tablet_width = berocket_apply_filters('filter_tablet_width', 1024);
365        //Hide elements depebnd on devices
366        if( $(window).width() <= mobile_width ) {
367            all_filters = all_filters.filter(function() {
368                return !$(this).is('.bapf_sngl_hd_mobile') && !$(this).parents('.bapf_sngl_hd_mobile').length;
369            });
370        } else if( $(window).width() > mobile_width && $(window).width() <= tablet_width ) {
371            all_filters = all_filters.filter(function() {
372                return !$(this).is('.bapf_sngl_hd_tablet') && !$(this).parents('.bapf_sngl_hd_tablet').length;
373            });
374        } else {
375            all_filters = all_filters.filter(function() {
376                return !$(this).is('.bapf_sngl_hd_desktop') && !$(this).parents('.bapf_sngl_hd_desktop').length;
377            });
378        } 
379        return all_filters;
380    }
381    //Grab filters from page
382    braapf_grab_all = function ($parent) {
383        if( typeof($parent) == 'undefined' ) { $parent = false; }
384        var selected_filters = berocket_apply_filters('before_grab_all_filters', [], $parent);
385        var mobile_width = berocket_apply_filters('filter_mobile_width', 767); 
386        var tablet_width = berocket_apply_filters('filter_tablet_width', 1024); 
387        if( $parent === false ) {
388            var all_filters = $('.bapf_sfilter');
389        } else {
390            var all_filters = $($parent).find('.bapf_sfilter');
391        }
392        all_filters = braapf_filter_mobile_desktop_filters(all_filters);
393        all_filters.each(function() {
394            var single_data = braapf_grab_single(this, selected_filters);
395            if( single_data !== false ) {
396                selected_filters.push(single_data);
397            }
398        });
399        selected_filters = berocket_apply_filters('grab_all_filters', selected_filters, $parent);
400        if( $parent === false ) {
401            braapf_selected_filters = selected_filters;
402        }
403        return selected_filters;
404    }
405    braapf_grab_single = function(element, selected_filters, grab_single) {
406        if( typeof(grab_single) == 'undefined' ) {
407            grab_single = false;
408        }
409        element = $(element);
410        var single_data = false;
411        var exist = false;
412        var taxonomy = element.data('taxonomy');
413        if( typeof(taxonomy) == 'undefined' || ! taxonomy ) {
414            return berocket_apply_filters('grab_single_filter_taxonomy_undefined', single_data, element, selected_filters);
415        }
416        $.each(selected_filters, function(i, val) {
417            if(val.taxonomy == taxonomy ) {
418                exist = true;
419            }
420        });
421        if( ! berocket_apply_filters('grab_single_filter_exist', exist, element, selected_filters) ) {
422            single_data = berocket_apply_filters('grab_single_filter', single_data, element, selected_filters);
423            if( single_data !== false ) return single_data;
424            var operator = element.data('op');
425            var tax_name = element.data('name');
426            if( typeof(tax_name) == 'undefined' ) {
427                tax_name = '';
428            }
429            var glue = braapf_glue_by_operator(operator);
430            var values = [];
431            var values_find = [];
432            if( grab_single ) {
433                var $elements = element;
434            } else {
435                var $elements = $('.bapf_sfilter[data-taxonomy="'+taxonomy+'"]');
436                $elements = braapf_filter_mobile_desktop_filters($elements);
437            }
438            $elements.find('input:checked:not(:disabled)').each(function(i, val) {
439                if( values_find.indexOf($(this).val()) == -1 ) {
440                    values.push({value:$(this).val(), html:$(this).data('name')});
441                    values_find.push($(this).val());
442                }
443            });
444            single_data = {name:tax_name, taxonomy:taxonomy, values:values, glue:glue, operator:operator};
445        }
446        return berocket_apply_filters('grab_single_filter_default', single_data, element, selected_filters, grab_single);
447    }
448    braapf_glue_by_operator = function(operator) {
449        if( typeof(operator) != 'string' ) {
450            operator = '';
451        }
452        var glue = the_ajax_script.operator_or;
453        if( operator.toLowerCase() == 'and' ) {
454            glue = the_ajax_script.operator_and;
455        }
456        return berocket_apply_filters('glue_by_operator', glue, operator);
457    }
458    //compact filters to {taxonomy,values} object
459    braapf_compact_filters = function(filters_start) {
460        if( typeof(filters_start) == 'undefined' ) {
461            filters_start = braapf_selected_filters;
462        }
463        var filters = [];
464        $.each(filters_start, function(i, val) {
465            var values_str = '';
466            if( typeof(val.customValuesLine) != 'undefined' ) {
467                values_str = val.customValuesLine;
468            } else {
469                $.each(val.values, function(i2, val2) {
470                    if( values_str.length ) {
471                        values_str += val.glue;
472                    }
473                    values_str += val2.value;
474                });
475            }
476            if( values_str.length ) {
477                filters.push(berocket_apply_filters('compat_filters_result_single', {taxonomy:val.taxonomy, values:values_str}, val));
478            }
479        });
480        return berocket_apply_filters('compat_filters_result', filters, filters_start);
481    }
482    //Compact all filters to single string
483    braapf_compat_filters_to_string = function (compat_filters, filter_mask, glue_between_taxonomy) {
484        var filters_string = '';
485        $.each(compat_filters, function(i, val) {
486            if( filters_string.length ) {
487                filters_string += glue_between_taxonomy;
488            }
489            var single_string = filter_mask;
490            single_string = single_string.replace('%t%', val.taxonomy);
491            single_string = single_string.replace('%v%', val.values);
492            filters_string += berocket_apply_filters('compat_filters_to_string_single', single_string, val, compat_filters, filter_mask, glue_between_taxonomy);
493        });
494        return berocket_apply_filters('compat_filters_to_string', filters_string, compat_filters, filter_mask, glue_between_taxonomy);
495    }
496    //get object with information about currentUrl/sendedUrl
497    braapf_get_current_url_data = function(url) {
498        if( typeof(url) == 'undefined' ) {
499            var link = location.href.split('#')[0].split('?')[0],
500                query = location.search.substring(1);
501        } else {
502            var link = url.split('#')[0].split('?')[0];
503            if( url.split('#')[0].split('?').length > 1 ) {
504                var query = url.split('#')[0].split('?')[1];
505            } else {
506                var query = '';
507            }
508        }
509        var query_arr = [],
510            page = 1,
511            string_regex = the_ajax_script.pagination_base+'\\/(\\d+)/?',
512            regex_var = new RegExp(string_regex),
513            search_page = link.match(regex_var);
514        if( search_page && typeof(search_page[1]) == 'string' ) {
515            page = parseInt(search_page[1]);
516            link = link.replace(regex_var, '');
517        }
518        query = query.split('&');
519        $.each(query, function(i, val) {
520            if( val.length ) {
521                query[i] = val.split('=');
522                if( query[i][0] == 'paged' ) {
523                    page = parseInt(query[i][1]);
524                } else {
525                    query_arr.push({name:query[i][0], value: query[i][1]});
526                }
527            }
528        });
529        return berocket_apply_filters('get_current_url_data', {baselink:link, queryargs:query_arr, filter:"", page:page}, url, query);
530    }
531    braapf_remove_pages_from_url_data = function(url_data) {
532        url_data.page = 1;
533        if( Array.isArray(url_data.queryargs) ) {
534            var newqueryargs = [];
535            $.each(url_data.queryargs, function(i, val) {
536                if(val.name != 'product-page') {
537                    newqueryargs.push(val);
538                }
539            });
540            url_data.queryargs = newqueryargs;
541        }
542        url_data = berocket_apply_filters('braapf_remove_pages_from_url_data', url_data);
543        return url_data;
544    }
545    braapf_apply_additional_filter_data = function (url_data, filters_start) {
546        if( typeof(filters_start) == 'undefined' ) {
547            filters_start = braapf_selected_filters;
548        }
549        $.each(filters_start, function(i, val) {
550            url_data = berocket_apply_filters('apply_additional_filter_data', url_data, val);
551        });
552        return url_data;
553    }
554    //Build url from url data object
555    braapf_build_url_from_urldata = function (url_data, parameters) {
556        if( typeof(parameters) == 'undefined' ) {
557            parameters = braapf_build_url_parameters_default();
558        }
559        var url = berocket_apply_filters('url_from_urldata_baselink', url_data.baselink, url_data, parameters);
560        var query_get = '';
561        if( url_data.queryargs.length ) {
562            $.each(url_data.queryargs, function(i, val) {
563                if( query_get.length ) {
564                    query_get += '&';
565                }
566                if( typeof(val.name) != 'undefined' && val.name.length && typeof(val.value) != 'undefined' ) {
567                    query_get += val.name + '=' + val.value;
568                }
569            });
570        }
571        if( url_data.page && url_data.page > 1 ) {
572            if( query_get.length ) {
573                query_get += '&';
574            }
575            query_get += 'paged=' + url_data.page;
576        }
577        if( query_get.length ) {
578            query_get = '?' + query_get;
579        }
580        url = berocket_apply_filters('url_from_urldata_linkget', (url+query_get), url_data, parameters, url, query_get);
581        return url;
582    }
583    braapf_build_url_parameters_default = function () {
584        return berocket_apply_filters('build_url_parameters_default', {});
585    }
586    //REPLACE ANY ELEMENT ON PAGE
587    braapf_replace_current_with_new = function(html, selector, argsin) {
588        if( typeof(argsin) == 'undefined' ) {
589            argsin = {};
590        }
591        args = {replace:false};
592        jQuery.extend(args, argsin);
593        args = berocket_apply_filters('replace_current_with_new_args', args, html, selector);
594        var $html = $('<div><div>'+html+'</div></div>');
595        var $new = $html.find(selector);
596        var $current = $(selector);
597        if( $current.length != 0 ) {
598            if( $new.length != $current.length && $new.length != 0 ) {
599                berocket_throw_error('error_notsame_block_qty', selector, $new.length, $current.length);
600            }
601            if( $new.length == 0 ) {
602                $current.html('').addClass('braapfNotReplaced');
603                $current.hide();
604            } else {
605                $current.each(function(i, el) {
606                    if( typeof($new[i]) != 'undefined' ) {
607                        if( args.replace ) {
608                            $(el).replaceWith($($new[i]));
609                        } else {
610                            $(el).html($($new[i]).html()).removeClass('braapfNotReplaced');
611                        }
612                    } else {
613                        $(el).html('').addClass('braapfNotReplaced');
614                    }
615                });
616                $current.show();
617            }
618        }
619    }
620    braapf_replace_products = function (data) {
621        var products_selector = the_ajax_script.products_holder_id;
622        var $html = $('<div><div>'+data+'</div></div>');
623        $('.bapf_no_products').remove();
624        braapf_replace_current_with_new(data, products_selector);
625        if( $('.braapfNotReplaced').filter(products_selector).length ) {
626            $('.braapfNotReplaced').filter(products_selector).before($(the_ajax_script.no_products));
627        }
628    }
629    braapf_replace_pagination = function (data) {
630        var pagination_selector = the_ajax_script.pagination_class;
631        if( $(pagination_selector).length == 0 ) {
632            var products_selector = the_ajax_script.products_holder_id;
633            var $html = $('<div><div>'+data+'</div></div>');
634            var pagination = $html.find(pagination_selector).last();
635            if( pagination.length ) {
636                $(products_selector).last().after(pagination);
637            }
638        } else {
639            braapf_replace_current_with_new(data, pagination_selector, {type:'pagination'});
640        }
641    }
642    braapf_replace_result_count = function (data) {
643        var result_count_selector = the_ajax_script.result_count_class;
644        if( $(result_count_selector).length == 0 ) {
645            var products_selector = the_ajax_script.products_holder_id;
646            var $html = $('<div><div>'+data+'</div></div>');
647            var count_selector = $html.find(result_count_selector).last();
648            if( count_selector.length ) {
649                $(products_selector).last().before(count_selector);
650            }
651        } else {
652            braapf_replace_current_with_new(data, result_count_selector);
653        }
654    }
655    braapf_replace_orderby = function (data) {
656        var orderby_selector = the_ajax_script.ordering_class;
657        if( $(orderby_selector).length == 0 ) {
658            var products_selector = the_ajax_script.products_holder_id;
659            var $html = $('<div><div>'+data+'</div></div>');
660            var orderby = $html.find(orderby_selector).last();
661            if( orderby.length ) {
662                $(products_selector).last().before(orderby);
663            }
664        } else {
665            braapf_replace_current_with_new(data, orderby_selector);
666        }
667    }
668    braapf_replace_each_filter = function(html) {
669        var $html = $('<div><div>'+html+'</div></div>');
670        $html = braapf_sngl_hd_loaded_filters($html);
671        $('.berocket_single_filter_widget').each(function() {
672            var data_id = $(this).data('id');
673            var data_wid = $(this).data('wid');
674            $('.berocket_single_filter_widget_'+data_id+'.bapf_wid_'+data_wid).html($html.find('.berocket_single_filter_widget_'+data_id+'.bapf_wid_'+data_wid).last().html());
675            if( $html.find('.berocket_single_filter_widget_'+data_id+'.bapf_wid_'+data_wid).last().is('.bapf_mt_none') ) {
676                $('.berocket_single_filter_widget_'+data_id+'.bapf_wid_'+data_wid).addClass('bapf_mt_none');
677            } else {
678                $('.berocket_single_filter_widget_'+data_id+'.bapf_wid_'+data_wid).removeClass('bapf_mt_none');
679            }
680        });
681    }
682    braapf_update_seo_elements = function(html) {
683        var $html = $('<div><div>'+html+'</div></div>');
684        $('title').text($html.find('title').text());
685        $('h1').first().html($html.find('h1').first().html());
686        if( $('.bapf_page_title').length > 0 ) {
687            $('.bapf_page_title').first().html($html.find('.bapf_page_title').first().html());
688        }
689    }
690    //Add url HTML5
691    braapf_set_manual_scroll_restoration = function() {
692        if( 'scrollRestoration' in history ) {
693            history.scrollRestoration = 'manual';
694        }
695    }
696    braapf_change_url_history_api = function(new_url, data) {
697        if( typeof(data) != 'undefined' && data.replace ) {
698            braapf_set_manual_scroll_restoration();
699            var stateParameters = { BeRocket: "Rules" };
700            history.replaceState(stateParameters, "");
701            history.pushState(stateParameters, "", new_url);
702            history.pathname = new_url;
703        }
704    }
705    window.addEventListener("popstate", function(event) {
706        if ( berocket_apply_filters('load_products_ajax_on_popstate', true) && event.state != null && event.state.BeRocket == 'Rules' ) {
707            var url = location.href;
708            if( berocket_apply_filters('page_has_products_holder', (! $(the_ajax_script.products_holder_id).length), url) ) {
709                location.href = url;
710            } else {
711                braapf_ajax_load_from_url(url, {}, berocket_apply_filters('ajax_load_from_filters', {done:[braapf_replace_products, braapf_replace_pagination, braapf_replace_result_count, braapf_replace_orderby, braapf_replace_each_filter, braapf_init_load, braapf_filtered_filters_set, braapf_update_data_from_current, braapf_update_seo_elements]}, url, 'default'));
712            }
713        }
714    });
715    //Load data from URL
716    braapf_ajax_load_from_url = function(url, send_data, callback_func, type) {
717        if( typeof(type) == 'undefined' ) {
718            type = 'default';
719        }
720        if( typeof(send_data) != 'object' ) {
721            send_data = {};
722        }
723        if( typeof(callback_func) != 'object' ) {
724            callback_func = {done:[], fail:[], always:[]};
725        }
726        if( typeof(callback_func.done) == 'undefined' || ! Array.isArray(callback_func.done) ) {
727            callback_func.done = [];
728        }
729        if( typeof(callback_func.fail) == 'undefined' || ! Array.isArray(callback_func.fail) ) {
730            callback_func.fail = [];
731        }
732        if( typeof(callback_func.always) == 'undefined' || ! Array.isArray(callback_func.always) ) {
733            callback_func.always = [];
734        }
735        url = berocket_apply_filters('ajax_load_from_url_url', url, send_data, callback_func, type);
736        send_data = berocket_apply_filters('ajax_load_from_url_data', send_data, url, callback_func, type);
737        callback_func = berocket_apply_filters('ajax_load_from_url_callback', callback_func, url, send_data, type);
738        braapf_ajax_load_from_url_request(url, send_data, callback_func, type);
739    }
740    braapf_ajax_load_from_url_request = function(url, send_data, callback_func, type) {
741        $(document).trigger('berocket_ajax_filtering_start');
742        if( typeof(braapf_ajax_request) == 'object' && typeof(braapf_ajax_request.abort) != 'undefined' ) {
743            braapf_ajax_request.abort();
744        }
745        braapf_ajax_request = $.ajax({method:"GET", url: url, data: send_data, beforeSend: function(xhr) {
746                xhr = berocket_apply_filters('ajax_load_from_url_beforeSend', xhr, url, send_data, callback_func, type);
747            }
748        })
749            .done(function(data, textStatus, jqXHR) {
750                $(document).trigger('berocket_ajax_filtering_on_update');
751                data = berocket_apply_filters('ajax_load_from_url_done', data, url, send_data, callback_func, type);
752                $.each(callback_func.done, function(i, val) {
753                    val(data, textStatus, jqXHR, url, type);
754                });
755                data = berocket_apply_filters('ajax_load_from_url_done_after', data, url, send_data, callback_func, type);
756                $(document).trigger('berocket_ajax_products_loaded');
757            })
758            .fail(function(jqXHR, textStatus, errorThrown) {
759                if( textStatus == 'abort' ) {
760                    return false;
761                }
762                $(document).trigger('berocket_ajax_products_not_loaded');
763                jqXHR = berocket_apply_filters('ajax_load_from_url_fail', jqXHR, url, send_data, callback_func, type);
764                $.each(callback_func.fail, function(i, val) {
765                    val(jqXHR, textStatus, errorThrown, url, type);
766                });
767                jqXHR = berocket_apply_filters('ajax_load_from_url_fail_after', jqXHR, url, send_data, callback_func, type);
768                if( type == 'default' ) {
769                    var query_send_data = jQuery.param(send_data);
770                    if( query_send_data ) {
771                        if( url.split('?').length > 1 ) {
772                            url = url + "&" + query_send_data;
773                        } else {
774                            url = url + "?" + query_send_data;
775                        }
776                    }
777                    location.href = url;
778                }
779            })
780            .always(function(data, textStatus, jqXHR) {
781                data = berocket_apply_filters('ajax_load_from_url_always', data, url, send_data, callback_func, type);
782                $.each(callback_func.always, function(i, val) {
783                    val(data, textStatus, jqXHR, url, type);
784                });
785                data = berocket_apply_filters('ajax_load_from_url_always_after', data, url, send_data, callback_func, type);
786                $(document).trigger('berocket_ajax_filtering_end');
787            });
788    }
789    function braapf_additional_header(xhr) {
790        xhr.setRequestHeader('X-Braapf', '1');
791        return xhr;
792    }
793    var braapf_select2_ordering_reinit_check = false;
794    function braapf_select2_ordering_reinit(xhr) {
795        var ordering_class = the_ajax_script.ordering_class;
796        ordering_class = ordering_class.replaceAll(',', ' select,');
797        ordering_class = ordering_class+' select';
798        if( jQuery(ordering_class).data('select2') ) {
799            braapf_select2_ordering_reinit_check = true
800        }
801        return xhr;
802    }
803    jQuery(document).on('berocket_ajax_products_loaded', function() {
804        if( braapf_select2_ordering_reinit_check ) {
805            var ordering_class = the_ajax_script.ordering_class;
806            ordering_class = ordering_class.replaceAll(',', ' select,');
807            ordering_class = ordering_class+' select';
808            jQuery(ordering_class).select2({minimumResultsForSearch: -1});
809        }
810    });
811    function braapf_sngl_hd_loaded_filters($elements) {
812        var mobile_width = berocket_apply_filters('filter_mobile_width', 767); 
813        var tablet_width = berocket_apply_filters('filter_tablet_width', 1024); 
814        $elements.find('.bapf_sngl_hd_mobile').show();
815        $elements.find('.bapf_sngl_hd_tablet').show();
816        $elements.find('.bapf_sngl_hd_desktop').show();
817        if( $(window).width() <= mobile_width ) {
818            $elements.find('.bapf_sngl_hd_mobile').hide();
819        } else if( $(window).width() > mobile_width && $(window).width() <= tablet_width ) {
820            $elements.find('.bapf_sngl_hd_tablet').hide();
821        } else if( $(window).width() > tablet_width ) {
822            $elements.find('.bapf_sngl_hd_desktop').hide();
823        }
824        return $elements;
825    }
826    //INIT filters
827    braapf_init_load = function() {
828        braapf_sngl_hd_loaded_filters($('html'));
829        $('.bapf_sfilter .bapf_body.bapf_mcs:not(.bapf_mcs_ready)').each(function() {
830            $(this).css('max-height', $(this).data('mcs-h')).mCustomScrollbar({scrollInertia: 300}).addClass('bapf_mcs_ready');
831        });
832        $('.berocket_single_filter_widget').each(function() {
833            var data_id = $(this).data('id');
834            if( berocket_apply_filters('remove_same_filters_to_prevent_errors', ($('.berocket_single_filter_widget_'+data_id).length > 1), $(this), data_id ) ) {
835                var $elements = $('.berocket_single_filter_widget_'+data_id).not('.bapf_sngl_hd_mobile').not('.bapf_sngl_hd_tablet');
836                $elements = $elements.not($elements.first());
837                if( $elements.length > 0 ) {
838                    $elements.remove();
839                    berocket_throw_error('same_filters_multiple_times', data_id);
840                }
841                $elements = $('.berocket_single_filter_widget_'+data_id).not('.bapf_sngl_hd_mobile').not('.bapf_sngl_hd_desktop');
842                $elements = $elements.not($elements.first());
843                if( $elements.length > 0 ) {
844                    $elements.remove();
845                    berocket_throw_error('same_filters_multiple_times', data_id);
846                }
847                $elements = $('.berocket_single_filter_widget_'+data_id).not('.bapf_sngl_hd_tablet').not('.bapf_sngl_hd_desktop');
848                $elements = $elements.not($elements.first());
849                if( $elements.length > 0 ) {
850                    $elements.remove();
851                    berocket_throw_error('same_filters_multiple_times', data_id);
852                }
853            }
854        });
855        $('body').on('click', '.bapf_desci', function(e) {
856            e.stopPropagation();
857        });
858        $('body').on('hover', '.bapf_desci', function(e) {
859            e.stopPropagation();
860        });
861        berocket_do_action('braapf_init', braapf_selected_filters);
862        $(document).trigger('berocket_filters_first_load');
863    }
864    braapf_update_page_on_error = function() {
865        if( berocket_apply_filters('update_page_on_error', true) ) {
866            location.reload();
867        }
868    }
869    //Selected filters area
870    braapf_selected_filters_area_set = function() {
871        var html = '';
872        if( typeof(braapf_filtered_filters) != 'undefined' && braapf_filtered_filters.length > 0 ) {
873            $.each(braapf_filtered_filters, function(i, taxonomy) {
874                if( taxonomy.values.length > 0 ) {
875                    taxonomy = berocket_apply_filters('default_selected_filters_area_single_taxonomy', taxonomy);
876                    var html2 = '<div class="bapf_sfa_taxonomy"><span>' + taxonomy.name + '</span>';
877                    html2 += '<ul>';
878                    var html2_elements = '';
879                    $.each(taxonomy.values, function(i2, val) {
880                        html2_elements += berocket_apply_filters('default_selected_filters_area_single', '<li><a href="#unselect_'+val.value+'" class="braapf_unselect" data-taxonomy="'+taxonomy.taxonomy+'" data-value="'+val.value+'"><i class="fa fa-times"></i> '+val.html+'</a></li>', val);
881                    });
882                    html2 += html2_elements;
883                    html2 += '</ul></div>';
884                    html += berocket_apply_filters('default_selected_filters_area_single_taxonomy', html2, taxonomy, html2_elements);
885                }
886            });
887        }
888        if( typeof(braapf_filtered_filters) != 'undefined' ) {
889            $('.berocket_aapf_widget_selected_area').parents('.berocket_single_filter_widget').removeClass('bapf_mt_none');
890            if( html ) {
891                $('.bapf_sfa_mt_hide').show().parent().removeClass('bapf_mt_none');
892                html = berocket_apply_filters('default_selected_filters_area_full_exist', '<div class="berocket_aapf_widget_selected_filter">
892' + html + '<ul class="bapf_sfa_unall"><li><a href="#Unselect_all" class="braapf_unselect_all"><i class="fa fa-times"></i> '+the_ajax_script.translate.unselect_all+'</a></li></ul>', html, braapf_filtered_filters);
893            } else {
894                html = berocket_apply_filters('default_selected_filters_area_full_notexist', the_ajax_script.translate.nothing_selected, html, braapf_filtered_filters);
895                $('.bapf_sfa_mt_hide').hide().parent().addClass('bapf_mt_none');
896            }
897            $('.berocket_aapf_widget_selected_area').html(html);
898        }
899    }
900    
901    $(document).on('click', '.berocket_aapf_widget_selected_area .braapf_unselect', function(event) {
902        event.preventDefault();
903        $('.bapf_sfilter[data-taxonomy="'+$(this).data('taxonomy')+'"]').trigger('braapf_unselect', $(this).data());
904        berocket_do_action('update_products', 'reset_single', $(this));
905    });
906    braapf_unselect_all = function() {
907        braapf_grab_all();
908        if( typeof(braapf_selected_filters) != 'undefined' && braapf_selected_filters.length > 0 ) {
909            $.each(braapf_selected_filters, function(i, taxonomy) {
910                if( taxonomy.values.length > 0 ) {
911                    $('.bapf_sfilter[data-taxonomy="'+taxonomy.taxonomy+'"]').trigger('braapf_unselect_all', taxonomy);
912                }
913            });
914        }
915    }
916    $(document).on('click', '.berocket_aapf_widget_selected_area .braapf_unselect_all', function(event) {
917        event.preventDefault();
918        braapf_unselect_all();
919        berocket_do_action('update_products', 'reset_all', $(this));
920    });
921    berocket_add_filter('braapf_init', braapf_grab_all_init, 1000);
922    berocket_add_filter('braapf_init', braapf_selected_filters_area_set_init, 1100);
923    berocket_add_filter('braapf_init_filtered_set', braapf_selected_filters_area_set_init, 1100);
924    //Error catch
925    braapf_reload_page_for_products_error = function(error_exist, selector) {
926        if( selector == the_ajax_script.products_holder_id) {
927            braapf_update_page_on_error();
928        }
929        return error_exist;
930    }
931    //Additional part
932    berocket_add_filter('ajax_load_from_url_beforeSend', braapf_additional_header);
933    berocket_add_filter('ajax_load_from_url_beforeSend', braapf_select2_ordering_reinit);
934    berocket_add_filter('update_products', braapf_update_products);
935    berocket_add_filter('error_notsame_block_qty', braapf_reload_page_for_products_error);
936    bapf_universal_theme_compatibility = function(data) {
937        if( berocket_apply_filters('universal_theme_compatibility', true) ) {
938            $(window).trigger('resize');
939            //UNCODE theme
940            try {if( berocket_apply_filters('uncode_theme_compatibility', (typeof(UNCODE) == 'object' && typeof(UNCODE.init) == 'function' ) ) ) {
941                UNCODE.init();
942            }} catch (e) {berocket_throw_error('uncode_theme_compatibility', e);}
943            //Flatsome theme
944            try {if( berocket_apply_filters('flatsome_theme_compatibility', (typeof(Flatsome) == 'object' && typeof(Flatsome.attach) == 'function' && jQuery(the_ajax_script.products_holder_id).length ) ) ) {
945                Flatsome.attach(jQuery(the_ajax_script.products_holder_id));
946            }} catch (e) {berocket_throw_error('flatsome_theme_compatibility', e);}
947            //Woodmart theme
948            try {if( berocket_apply_filters('woodmart_theme_compatibility', (typeof(woodmartThemeModule) == 'object' ) ) ) {
949                if( typeof(woodmartThemeModule.wooInit) == 'function' ) {
950                    woodmartThemeModule.wooInit();
951                }
952                if( typeof(woodmartThemeModule.lazyLoading) == 'function' ) {
953                    woodmartThemeModule.lazyLoading();
954                }
955                if( typeof(woodmartThemeModule.productsLoadMore) == 'function' ) {
956                    woodmartThemeModule.productsLoadMore();
957                }
958            }} catch (e) {berocket_throw_error('woodmart_theme_compatibility', e);}
959            //Divi theme
960            try {if( berocket_apply_filters('divi_theme_compatibility', (typeof(et_reinit_waypoint_modules) == 'function' ) ) ) {
961                et_reinit_waypoint_modules();
962            }} catch (e) {berocket_throw_error('divi_theme_compatibility', e);}
963            //reyTheme theme
964            try {if( berocket_apply_filters('rey_theme_compatibility', (typeof(jQuery.reyTheme) == 'object' && typeof(jQuery.reyTheme.init) == 'function' ) ) ) {
965                jQuery.reyTheme.init();
966            }} catch (e) {berocket_throw_error('rey_theme_compatibility', e);}
967            //layzyLoadImage script
968            try {if( berocket_apply_filters('layzyloadimage_script_compatibility', (typeof(layzyLoadImage) == 'function' ) ) ) {
969                layzyLoadImage();
970            }} catch (e) {berocket_throw_error('layzyloadimage_script_compatibility', e);}
971            //jetpackLazyImagesModule script
972            try {if( berocket_apply_filters('jetpacklazyimages_script_compatibility', (typeof(jetpackLazyImagesModule) == 'function' ) ) ) {
973                jetpackLazyImagesModule();
974            }} catch (e) {berocket_throw_error('jetpacklazyimages_script_compatibility', e);}
975            try {
976            jQuery('img.jetpack-lazy-image').each(function() {
977                jQuery(this).removeClass('jetpack-lazy-image').attr('src', jQuery(this).data('lazy-src'));
978                jQuery(this).removeClass('jetpack-lazy-image').attr('srcset', '');
979            });
980            } catch (e) {berocket_throw_error('jetpacklazyimages_script_compatibility', e);}
981            //SWIFT script
982            try {if( berocket_apply_filters('swift_script_compatibility', (typeof(SWIFT) == 'object' && typeof(SWIFT.woocommerce) == 'object' && typeof(SWIFT.woocommerce.init) == 'function' ) ) ) {
983                SWIFT.woocommerce.init();
984            }} catch (e) {berocket_throw_error('swift_script_compatibility', e);}
985            try {if( typeof(baapfGet_wprocketInstance) != 'undefined' ) {
986                baapfGet_wprocketInstance.update();
987            }} catch (e) {berocket_throw_error('wprocket_script_compatibility', e);}
988            try {
989                jQuery(document).trigger('facetwp-loaded');
990            } catch (e) {berocket_throw_error('facetwp_script_compatibility', e);}
991            try {if( berocket_apply_filters('etTheme_compatibility', (typeof(etTheme) == 'object' && typeof(etTheme.global_image_lazy) == 'function' ) ) ) {
992                etTheme.global_image_lazy();
993            }} catch (e) {berocket_throw_error('etTheme_compatibility', e);}
994            try {if( berocket_apply_filters('the7_compatibility', ($(the_ajax_script.products_holder_id+' .iso-lazy-load').length > 0) ) ) {
995                $(the_ajax_script.products_holder_id+' .iso-lazy-load').attr('src', function(){
996                    if(typeof($(this).data('src')) != 'undefined' && $(this).data('src')) {
997                        return $(this).data('src');
998                    }
999                    return $(this).attr('src');
1000                }).attr('srcset', function() {
1001                    if(typeof($(this).data('srcset')) != 'undefined' && $(this).data('srcset')) {
1002                        return $(this).data('srcset');
1003                    }
1004                    return $(this).attr('srcset');
1005                }).removeClass('iso-lazy-load');
1006            }} catch (e) {berocket_throw_error('etTheme_compatibility', e);}
1007            try { if( typeof(InfiniteScroll) == 'function' ) {
1008                var infScroll = InfiniteScroll.data( '.shop-container .products' );
1009                if( typeof(infScroll) == 'object' && infScroll.options ) {
1010                    var infOptionsStore = infScroll.options;
1011                    infScroll.destroy();
1012                    jQuery('.shop-container .products').data('infiniteScroll', '').infiniteScroll(infOptionsStore);
1013                }
1014            }} catch (e) {berocket_throw_error('flatsome_infinitescroll', e);}
1015            try { if( jQuery('.shop-container .products').length && typeof(jQuery('.shop-container .products').data('packery')) == 'object' ) {
1016                jQuery('.shop-container .products').packery('reloadItems').packery('layout');
1017            }} catch (e) {berocket_throw_error('flatsome_packery', e);}
1018            try {if( berocket_apply_filters('JetSmartFilters_compatibility', (typeof(window.JetSmartFilters) == 'object' && typeof(window.JetSmartFilters.initializeFilters) == 'function' ) ) ) {
1019                window.JetSmartFilters.initializeFilters()
1020            }} catch (e) {berocket_throw_error('JetSmartFilters_compatibility', e);}
1021            $(window).trigger('resize');
1022            $(window).trigger('scroll');
1023        }
1024        return data;
1025    }
1026    jQuery(document).on('preInit.dt', '.berocket_product_table_compat .wc-product-table', function (e, settings, data) {
1027        if( the_ajax_script.nice_urls && typeof(settings.ajax) == 'object' && settings.ajax ) {
1028            settings.ajax.data[the_ajax_script.nice_url_variable] = braapf_get_filters_selected();
1029        }
1030    });
1031    berocket_add_filter('ajax_load_from_url_always_after', bapf_universal_theme_compatibility, 2500);
1032    $(document).ready(function(){
1033        if( berocket_apply_filters('remove_shortcode_fix_filters', $('.berocket_wc_shortcode_fix').length) ) {
1034            braapf_replace_each_filter($('.berocket_wc_shortcode_fix').html());
1035            $('.berocket_wc_shortcode_fix').html('');
1036        }
1037        braapf_init_load();
1038        braapf_filtered_filters_set();
1039        braapf_sngl_hd_loaded_filters($('html'));
1040        $(window).on('resize', function() {braapf_sngl_hd_loaded_filters($('html'))});
1041        $(document).trigger('berocket_filters_document_ready');
1042    });
1043    braapf_disable_ajax_loading = function($has_product) {
1044        return true;
1045    }
1046    $(document).ready(function() {
1047        if( the_ajax_script.disable_ajax_loading) {
1048            berocket_add_filter('page_has_products_holder', braapf_disable_ajax_loading);
1049        }
1050    });
1051    braapf_close_tippy = function () {
1052        try{
1053            if( $('.tippy-box').length ) {
1054                $('.tippy-box').each(function() {
1055                    if( typeof($(this).parent()[0]._tippy) != 'undefined' ) {
1056                        $(this).parent()[0]._tippy.hide();
1057                    }
1058                });
1059            }
1060        } catch(e){}
1061    }
1062    berocket_add_filter('update_products', braapf_close_tippy);
1063})(jQuery);
1064var braapf_get_current_filters,
1065braapf_filters_url_decode,
1066braapf_scroll_shop_to_top,
1067braapf_set_filters_to_link,
1068braapf_convert_ckbox_to_radio,
1069braapf_hierarhical_save,
1070braapf_hierarhical_set,
1071braapf_collapse_status_save,
1072braapf_collapse_status_set,
1073braapf_show_hide_values_save,
1074braapf_show_hide_values_set;
1075(function ($){
1076    //default filters
1077    braapf_get_current_filters = function (url_data) {
1078        if( url_data.queryargs.length ) {
1079            var newqueryargs = [];
1080            $.each(url_data.queryargs, function (i, val) {
1081                if( val.name == the_ajax_script.url_variable || decodeURI(val.name) == the_ajax_script.url_variable ) {
1082                    url_data.filter = val.value;
1083                } else {
1084                    newqueryargs.push(val);
1085                }
1086            });
1087            url_data.queryargs = newqueryargs;
1088        }
1089        return url_data;
1090    }
1091    braapf_set_filters_to_link = function(url, url_data, parameters, url_without_query, query_get) {
1092        if( typeof(url_data.filter) == 'string' && url_data.filter.length ) {
1093            if( query_get.length ) {
1094                url += '&';
1095            } else {
1096                url += '?';
1097            }
1098            url += the_ajax_script.url_variable + '=' + url_data.filter;
1099        }
1100        return url;
1101    }
1102    //SINGLE ELEMENT / RADIOBUTTONS
1103    braapf_convert_ckbox_to_radio = function(thisel, taxonomy, value, checked){
1104        var $this = $(thisel);
1105        var parent = $(thisel).closest('.bapf_sfilter.bapf_ckbox');
1106        if( parent.is('.bapf_asradio') ) {
1107            parent.find('input[type=checkbox]:checked:not(:disabled)').each(function() {
1108                var val = $(this).val();
1109                if( val != value ) {
1110                    braapf_checkbox_same(taxonomy, val, false);
1111                }
1112            });
1113        }
1114    }
1115    berocket_add_filter('input_ckbox_changed', braapf_convert_ckbox_to_radio);
1116    //CHILD HIERARCHICAL
1117    $(document).on('click', '.bapf_ochild, .bapf_cchild', function(e) {
1118        e.preventDefault();
1119        e.stopPropagation();
1120        if( $(this).is('.bapf_ochild' ) ) {
1121            $(this).trigger('bapf_ochild');
1122        } else {
1123            $(this).trigger('bapf_cchild');
1124        }
1125    });
1126    $(document).on('bapf_ochild', '.bapf_sfilter.bapf_ckbox ul li', function(e) {
1127        e.stopPropagation();
1128        if( berocket_apply_filters('colaps_child_open_apply', true, $(this)) ) {
1129            var data = $(this).parents('.bapf_sfilter').first().data();
1130            if( typeof(data.ochild) == 'undefined' ) {
1131                data.ochild = 'fa-plus';
1132            }
1133            if( typeof(data.cchild) == 'undefined' ) {
1134                data.cchild = 'fa-minus';
1135            }
1136            $(this).find('.bapf_ochild, .bapf_cchild').first().removeClass('bapf_ochild').removeClass(data.ochild).addClass('bapf_cchild').addClass(data.cchild);
1137            $(this).find('ul').first().show();
1138        }
1139    });
1140    $(document).on('bapf_cchild', '.bapf_sfilter.bapf_ckbox ul li', function(e) {
1141        e.stopPropagation();
1142        if( berocket_apply_filters('colaps_child_close_apply', true, $(this)) ) {
1143            var data = $(this).parents('.bapf_sfilter').first().data();
1144            if( typeof(data.ochild) == 'undefined' ) {
1145                data.ochild = 'fa-plus';
1146            }
1147            if( typeof(data.cchild) == 'undefined' ) {
1148                data.cchild = 'fa-minus';
1149            }
1150            $(this).find('.bapf_ochild, .bapf_cchild').first().addClass('bapf_ochild').addClass(data.ochild).removeClass('bapf_cchild').removeClass(data.cchild);
1151            $(this).find('ul').first().hide();
1152        }
1153    });
1154    var braapf_hierarhical_values = [];
1155    braapf_hierarhical_save = function(data) {
1156        braapf_hierarhical_values = [];
1157        $('.bapf_cchild').each(function() {
1158            braapf_hierarhical_values.push($(this).parent().children('input[type=checkbox]').attr('id'));
1159        });
1160        return data;
1161    }
1162    braapf_hierarhical_set = function(data) {
1163        $.each(braapf_hierarhical_values, function(i, val) {
1164            $('#'+val).trigger('bapf_ochild');
1165        });
1166        return data;
1167    }
1168    berocket_add_filter('ajax_load_from_url_done', braapf_hierarhical_save, 1);
1169    berocket_add_filter('ajax_load_from_url_done_after', braapf_hierarhical_set, 1000);
1170    //SHOW/HIDE FILTERS
1171    $(document).on('click', '.bapf_ocolaps .bapf_colaps_togl, .bapf_ccolaps .bapf_colaps_togl', function(e) {
1172        e.preventDefault;
1173        if( $(this).closest('.bapf_ocolaps, .bapf_ccolaps').is('.bapf_ocolaps' ) ) {
1174            $(this).closest('.bapf_ocolaps, .bapf_ccolaps').trigger('bapf_ocolaps', ["slideDown"]);
1175        } else {
1176            $(this).closest('.bapf_ocolaps, .bapf_ccolaps').trigger('bapf_ccolaps', ["slideUp"]);
1177        }
1178    });
1179    $(document).on('keydown', '.bapf_ocolaps .bapf_colaps_togl, .bapf_ccolaps .bapf_colaps_togl', function(e) {
1180        if( e.key === 'Enter' ) {
1181            e.preventDefault;
1182            if( $(this).closest('.bapf_ocolaps, .bapf_ccolaps').is('.bapf_ocolaps' ) ) {
1183                $(this).closest('.bapf_ocolaps, .bapf_ccolaps').trigger('bapf_ocolaps', ["slideDown"]);
1184            } else {
1185                $(this).closest('.bapf_ocolaps, .bapf_ccolaps').trigger('bapf_ccolaps', ["slideUp"]);
1186            }
1187        }
1188    });
1189    $(document).on('bapf_ocolaps', '.bapf_sfilter.bapf_ocolaps, .bapf_sfilter.bapf_ccolaps', function(e, animation) {
1190        $(this).removeClass('bapf_ocolaps').addClass('bapf_ccolaps');
1191        if( berocket_apply_filters('colaps_smb_open_apply', true, $(this)) ) {
1192            if ( typeof animation == "undefined") animation = "show";
1193            if ( animation == "slideDown" ) {
1194                $(this).find('.bapf_body').first().slideDown();
1195            } else {
1196                $(this).find('.bapf_body').first().show();
1197            }
1198            if( $(this).find('.bapf_colaps_smb').length ) {
1199                var data = $(this).find('.bapf_colaps_smb').data();
1200                if( typeof(data.opened) == 'undefined' ) {
1201                    data.opened = 'fa-chevron-up';
1202                }
1203                if( typeof(data.closed) == 'undefined' ) {
1204                    data.closed = 'fa-chevron-down';
1205                }
1206                $(this).find('.bapf_colaps_smb').removeClass(data.closed).addClass(data.opened);
1207            }
1208        }
1209    });
1210    $(document).on('bapf_ccolaps', '.bapf_sfilter.bapf_ocolaps, .bapf_sfilter.bapf_ccolaps', function(e, animation) {
1211        $(this).addClass('bapf_ocolaps').removeClass('bapf_ccolaps');
1212        if( berocket_apply_filters('colaps_smb_close_apply', true, $(this)) ) {
1213            if ( typeof animation == "undefined") animation = "hide";
1214            if ( animation == "slideUp" ) {
1215                $(this).find('.bapf_body').first().slideUp();
1216            } else {
1217                $(this).find('.bapf_body').first().hide();
1218            }
1219            if( $(this).find('.bapf_colaps_smb').length ) {
1220                var data = $(this).find('.bapf_colaps_smb').data();
1221                if( typeof(data.opened) == 'undefined' ) {
1222                    data.opened = 'fa-chevron-up';
1223                }
1224                if( typeof(data.closed) == 'undefined' ) {
1225                    data.closed = 'fa-chevron-down';
1226                }
1227                $(this).find('.bapf_colaps_smb').addClass(data.closed).removeClass(data.opened);
1228            }
1229        }
1230    });
1231    $(document).on('mouseenter', '.bapf_colaps_smb', function() {
1232        var data = $(this).data();
1233        if( typeof(data) != 'undefined' && typeof(data.hover) != 'undefined' && data.hover ) {
1234            if( typeof(data.opened) == 'undefined' ) {
1235                data.opened = 'fa-chevron-up';
1236            }
1237            if( typeof(data.closed) == 'undefined' ) {
1238                data.closed = 'fa-chevron-down';
1239            }
1240            $(this).removeClass(data.closed).removeClass(data.opened).addClass(data.hover);
1241        }
1242    });
1243    $(document).on('mouseleave', '.bapf_colaps_smb', function() {
1244        var data = $(this).data();
1245        if( typeof(data) != 'undefined' && typeof(data.hover) != 'undefined' && data.hover ) {
1246            if( typeof(data.opened) == 'undefined' ) {
1247                data.opened = 'fa-chevron-up';
1248            }
1249            if( typeof(data.closed) == 'undefined' ) {
1250                data.closed = 'fa-chevron-down';
1251            }
1252            $(this).removeClass(data.hover);
1253            if ( $(this).parents('.bapf_sfilter').first().is('.bapf_ocolaps') ) {
1254                $(this).addClass(data.closed);
1255            } else {
1256                $(this).addClass(data.opened);
1257            }
1258        }
1259    });
1260    var braapf_collapse_status = {open:[], close:[]};
1261    braapf_collapse_status_save = function(data) {
1262        braapf_collapse_status = {open:[], close:[]};
1263        $('.bapf_ocolaps, .bapf_ccolaps').each(function() {
1264            if( $(this).is('.bapf_ocolaps') ) {
1265                braapf_collapse_status.open.push($(this).attr('id'));
1266            } else {
1267                braapf_collapse_status.close.push($(this).attr('id'));
1268            }
1269        });
1270        return data;
1271    }
1272    braapf_collapse_status_set = function(data) {
1273        $.each(braapf_collapse_status.open, function(i, val) {
1274            $('#'+val).trigger('bapf_ccolaps', ["show"]);
1275        });
1276        $.each(braapf_collapse_status.close, function(i, val) {
1277            $('#'+val).trigger('bapf_ocolaps', ["hide"]);
1278        });
1279        return data;
1280    }
1281    berocket_add_filter('ajax_load_from_url_done', braapf_collapse_status_save, 1);
1282    berocket_add_filter('ajax_load_from_url_done_after', braapf_collapse_status_set, 1000);
1283    //Show/Hide values button
1284    $(document).on('click', '.bapf_show_hide', function() {
1285        $(this).closest('.bapf_sfilter').toggleClass('bapf_fhide');
1286        if( $(this).closest('.bapf_sfilter').is('.bapf_fhide') ) {
1287            $(this).text($(this).data('show'));
1288        } else {
1289            $(this).text($(this).data('hide'));
1290        }
1291    });
1292    var braapf_show_hide_values_status = {open:[], close:[]};
1293    braapf_show_hide_values_save = function(data) {
1294        braapf_show_hide_values_status = {open:[], close:[]};
1295        $('.bapf_sfilter').has('.bapf_show_hide').each(function() {
1296            if( $(this).is('.bapf_fhide') ) {
1297                braapf_show_hide_values_status.close.push($(this).attr('id'));
1298            } else {
1299                braapf_show_hide_values_status.open.push($(this).attr('id'));
1300            }
1301        });
1302        return data;
1303    }
1304    braapf_show_hide_values_set = function(data) {
1305        $.each(braapf_show_hide_values_status.open, function(i, val) {
1306            var $filter = $('#'+val).has('.bapf_show_hide');
1307            $filter.removeClass('bapf_fhide');
1308            $filter.find('.bapf_show_hide').text($filter.find('.bapf_show_hide').data('hide'));
1309        });
1310        $.each(braapf_show_hide_values_status.close, function(i, val) {
1311            var $filter = $('#'+val).has('.bapf_show_hide');
1312            $filter.addClass('bapf_fhide');
1313            $filter.find('.bapf_show_hide').text($filter.find('.bapf_show_hide').data('show'));
1314        });
1315        return data;
1316    }
1317    berocket_add_filter('ajax_load_from_url_done', braapf_show_hide_values_save, 1);
1318    berocket_add_filter('ajax_load_from_url_done_after', braapf_show_hide_values_set, 1000);
1319    //Scroll page to the top
1320    braapf_scroll_shop_to_top = function(data, url, send_data, callback_func, type) {
1321        var mobile_width = berocket_apply_filters('filter_mobile_width', 767); 
1322        if( berocket_apply_filters('scroll_shop_to_top', (type == 'default' && ( the_ajax_script.scroll_shop_top == 1 
1323            || (the_ajax_script.scroll_shop_top == 2 && $(window).width() < mobile_width)
1324            || (the_ajax_script.scroll_shop_top == 3 && $(window).width() >= mobile_width) )
1325        ) ) ) {
1326            var top_scroll_offset = 0,
1327                scroll_top_px = parseInt(the_ajax_script.scroll_shop_top_px, 10) || 0,
1328                $scroll_target = false;
1329            if( $( the_ajax_script.products_holder_id ).length ) {
1330                $scroll_target = $( the_ajax_script.products_holder_id ).first();
1331            } else if( $( '.bapf_no_products' ).length ) {
1332                $scroll_target = $( '.bapf_no_products' ).first();
1333            }
1334            if( $scroll_target && $scroll_target.length ) {
1335                top_scroll_offset = $scroll_target.get(0).getBoundingClientRect().top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0) + scroll_top_px;
1336                if(top_scroll_offset < 0) top_scroll_offset = 0;
1337            }
1338            var scroll_element = document.scrollingElement || document.documentElement || document.body,
1339                is_ios = /iPad|iPhone|iPod/.test(navigator.userAgent) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
1340            //iOS fix
1341            if( is_ios && window.requestAnimationFrame ) {
1342                var start_scroll = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0,
1343                    scroll_change = top_scroll_offset - start_scroll,
1344                    scroll_duration = 600,
1345                    scroll_start_time = null;
1346                var animate_scroll = function(timestamp) {
1347                    if( scroll_start_time === null ) scroll_start_time = timestamp;
1348                    var progress = Math.min((timestamp - scroll_start_time) / scroll_duration, 1),
1349                        ease_progress = progress < 0.5 ? 2 * progress * progress : -1 + (4 - 2 * progress) * progress;
1350                    window.scrollTo(0, start_scroll + scroll_change * ease_progress);
1351                    if( progress < 1 ) {
1352                        window.requestAnimationFrame(animate_scroll);
1353                    }
1354                };
1355                window.requestAnimationFrame(animate_scroll);
1356            } else if( scroll_element ) {
1357                $(scroll_element).animate({ scrollTop: top_scroll_offset }, "slow");
1358            } else {
1359                window.scrollTo(0, top_scroll_offset);
1360            }
1361        }
1362        return data;
1363    }
1364    berocket_add_filter('ajax_load_from_url_beforeSend', braapf_scroll_shop_to_top);
1365    //Sidebar
1366    $(document).on('mousedown', '.wc-product-table-reset a', function() {
1367        $(this).remove();
1368        br_reset_all_filters();
1369    });
1370    $(document).on('click', '.berocket_element_above_products_is_hide_toggle', function (e){
1371        e.preventDefault();
1372        $(this).toggleClass( "active" ).next().slideToggle(200, 'linear');
1373        var is_active = 'inactive';
1374        if( $(this).is('.active') ) {
1375            is_active = 'active';
1376        }
1377        $(document).trigger('berocket_element_above_products_'+is_active);
1378    });
1379    //Compatibility scripts
1380
1381    function berocket_ajax_load_product_table_compat() {
1382        if( jQuery('.berocket_product_table_compat .dataTables_length select').length ) {
1383            jQuery('.berocket_product_table_compat .wc-product-table').dataTable()._fnSaveState();
1384        }
1385        var tableid = jQuery('.berocket_product_table_compat .wc-product-table').attr('id');
1386        if( typeof(window['config_'+tableid]) != 'undefined' && window['config_'+tableid].serverSide ) {
1387            jQuery('.berocket_product_table_compat .wc-product-table').DataTable().destroy();
1388            var table_html = jQuery('.berocket_product_table_compat').html();
1389            jQuery('.berocket_product_table_compat').html('');
1390            jQuery('.berocket_product_table_compat').html(table_html);
1391            jQuery('.berocket_product_table_compat .blockUI.blockOverlay').remove();
1392            jQuery('.berocket_product_table_compat .wc-product-table').productTable();
1393        }
1394    }
1395    $(document).on('berocket_ajax_filtering_start', function() {
1396        if( jQuery('.berocket_product_table_compat').length ) {
1397            berocket_ajax_load_product_table_compat();
1398        }
1399    });
1400    braapf_filters_url_decode = function(filter) {
1401        if( the_ajax_script.seo_uri_decode ) {
1402            filter = encodeURIComponent(filter);
1403            if( the_ajax_script.nice_urls ) {
1404                filter = filter.replace(/%2F/g, '/');
1405            }
1406        }
1407        return filter;
1408    }
1409	jQuery( document ).on( 'elementor/popup/show', function() {
1410        try{
1411            braapf_init_load();
1412        } catch (e) {berocket_throw_error('elementor_popup_show', e);}
1413	} );
1414	jQuery( document ).on( 'pjax:success', function() {
1415        try{
1416            braapf_init_load();
1417        } catch (e) {berocket_throw_error('woodmart_ajax', e);}
1418	} );
1419})(jQuery);
1420berocket_add_filter('get_current_url_data', braapf_get_current_filters);
1421berocket_add_filter('compat_filters_to_string', braapf_filters_url_decode, 900);
1422berocket_add_filter('url_from_urldata_linkget', braapf_set_filters_to_link);
1423var braapf_child_parent_grab_single,
1424braapf_child_parent_fix_selected,
1425braapf_child_parent_load_with_update_button,
1426braapf_check_partial_load_filters,
1427braapf_add_loader_element,
1428braapf_remove_loader_element,
1429braapf_elementor_sticky_fix,
1430baapfGet_wprocketInstance,
1431brapf_jet_smart_filters_add,
1432brapf_jet_smart_filters_remove_pages,
1433brapf_jet_smart_filters;
1434(function ($){
1435    //CHILD/PARENT FEATURE
1436    braapf_child_parent_grab_single = function(single_data, element, selected_filters) {
1437        var child_position = element.data('child');
1438        if( typeof(child_position) != 'undefined' && child_position > 0 
1439         && typeof(single_data) == 'object' && typeof(single_data.values) != 'undefined' && Array.isArray(single_data.values) && single_data.values.length > 0 ) {
1440            child_position++;
1441            var taxonomy = element.data('taxonomy');
1442            var next_child = $('.bapf_sfilter.bapf_child_'+child_position+'[data-taxonomy="'+taxonomy+'"]');
1443            if( next_child.length ) {
1444                var new_single_data = braapf_grab_single (next_child, [], true);
1445                if( typeof(new_single_data) == 'object' && typeof(new_single_data.values) != 'undefined' && Array.isArray(new_single_data.values) && new_single_data.values.length > 0 ) {
1446                    single_data = new_single_data;
1447                }
1448            }
1449        }
1450        return single_data;
1451    }
1452    braapf_child_parent_fix_selected = function(context, element) {
1453        if( element != false) {
1454            var $filter = element.closest('.bapf_sfilter');
1455            if( $filter.length ) {
1456                var child_position = $filter.data('child');
1457                var taxonomy = $filter.data('taxonomy');
1458                if( typeof(child_position) != 'undefined' && child_position > 0 ) {
1459                    for(i = child_position + 1; $('.bapf_sfilter.bapf_child_'+i+'[data-taxonomy="'+taxonomy+'"]').length; i++) {
1460                        $('.bapf_sfilter.bapf_child_'+i+'[data-taxonomy="'+taxonomy+'"]').trigger('braapf_unselect', false);
1461                    }
1462                }
1463            }
1464        }
1465        return context;
1466    }
1467    braapf_child_parent_load_with_update_button = function(issend, context, element) {
1468        if( element != false) {
1469            var $filter = element.closest('.bapf_sfilter');
1470            if( $filter.length ) {
1471                var child_position = $filter.data('child');
1472                var taxonomy = $filter.data('taxonomy');
1473                if( typeof(child_position) != 'undefined' && child_position > 0 ) {
1474                    issend = true;
1475                }
1476            }
1477        }
1478        return issend;
1479    }
1480    braapf_check_partial_load_filters = function(issend, context, element) {
1481        if( $('.berocket_single_filter_widget.bapf_partload').length > 0 ) {
1482            issend = true;
1483        }
1484        return issend;
1485    }
1486    berocket_add_filter( 'grab_single_filter_default', braapf_child_parent_grab_single, 9000000 );
1487    berocket_add_filter( 'before_update_products_context', braapf_child_parent_fix_selected );
1488    berocket_add_filter( 'apply_filters_to_page_partial', braapf_child_parent_load_with_update_button );
1489    berocket_add_filter( 'apply_filters_to_page_partial', braapf_check_partial_load_filters );
1490    
1491    //LOADER OVER PAGE
1492    var braapf_loader_element;
1493    braapf_add_loader_element = function (data, url, send_data, callback_func, type) {
1494        if( type == 'default' ) {
1495            if( typeof(braapf_loader_element) != 'undefined' && typeof(braapf_loader_element.remove) == 'function' ) {
1496                braapf_loader_element.remove();
1497            }
1498            braapf_loader_element = $(the_ajax_script.load_image);
1499            $('body').append(braapf_loader_element);
1500        }
1501        return data;
1502    }
1503    braapf_remove_loader_element = function (data) {
1504        if( typeof(braapf_loader_element) != 'undefined' && typeof(braapf_loader_element.remove) == 'function' ) {
1505            braapf_loader_element.remove();
1506        }
1507        return data;
1508    }
1509    berocket_add_filter( 'ajax_load_from_url_beforeSend', braapf_add_loader_element );
1510    berocket_add_filter( 'ajax_load_from_url_always_after', braapf_remove_loader_element );
1511    //FILTER LINKS
1512    $(document).on('click', '.bapf_sfilter.bapf_ckbox .bapf_body li label a', function(event){event.preventDefault();$(this).parent().trigger('click')});
1513    //ELEMENTOR PRO
1514    if( jQuery('.elementor-widget').length ) {
1515        jQuery(window).on('scroll', function() {
1516            jQuery('.elementor-sticky__spacer .bapf_sfilter').remove();
1517        });
1518    }
1519    //WP-Rocket
1520    try {
1521        window.addEventListener('LazyLoad::Initialized',function(e){
1522            baapfGet_wprocketInstance = e.detail.instance;
1523        });
1524    } catch (e) {berocket_throw_error('wprocketInstance_get', e);}
1525    //WooCommerce quantity fix
1526    $(document).on("change", "form.cart input.qty", function() {
1527        try {
1528            $(this.form).find("[data-quantity]").attr("data-quantity", this.value);
1529        } catch (e) {berocket_throw_error('wc_quantity_change', e);}
1530    });
1531    //JetWooBuilder
1532    brapf_jet_smart_filters = function(data) {
1533        var $html = $('<div><div>'+data+'</div></div>');
1534        if( jQuery('#jet-smart-filters-js-extra').length >
1534 0 && $html.find('#jet-smart-filters-js-extra').length > 0 ) {
1535            jQuery('#jet-smart-filters-js-extra').replaceWith($html.find('#jet-smart-filters-js-extra'));
1536        }
1537    }
1538    brapf_jet_smart_filters_remove_pages = function(url_data) {
1539        if( Array.isArray(url_data.queryargs) ) {
1540            var newqueryargs = [];
1541            $.each(url_data.queryargs, function(i, val) {
1542                if(val.name != 'pagenum') {
1543                    newqueryargs.push(val);
1544                }
1545            });
1546            url_data.queryargs = newqueryargs;
1547        }
1548        return url_data;
1549    }
1550    brapf_jet_smart_filters_add = function(elem) {
1551        elem.done.push(brapf_jet_smart_filters);
1552        return elem;
1553    }
1554    brapf_JetSmartFilter_extra_props = function() {
1555        var compat_filters = braapf_compact_filters();
1556        var filter_mask = berocket_apply_filters('braapf_filters_mask', the_ajax_script.url_mask);
1557        var filter_string = braapf_compat_filters_to_string(compat_filters, filter_mask, the_ajax_script.url_split);
1558        JetSmartFilterSettings.extra_props.brfilters = filter_string;
1559    }
1560    jQuery(document).ready(function() {
1561        if( berocket_apply_filters('JetSmartFilter_compatibility', (jQuery('#jet-smart-filters-js-extra').length > 0)) ) {
1562            jQuery(document).on('berocket_ajax_products_loaded', brapf_JetSmartFilter_extra_props);
1563            brapf_JetSmartFilter_extra_props();
1564            berocket_add_filter( 'ajax_load_from_filters', brapf_jet_smart_filters_add );
1565            berocket_add_filter( 'braapf_remove_pages_from_url_data', brapf_jet_smart_filters_remove_pages );
1566        }
1567    });
1568})(jQuery);
1569jQuery(document).trigger('bapf_js_loaded');

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.