PageSourceSearch

https://artisian.ca/wp-content/plugins/woo-product-filter/modules/…/js/frontend.woofilters.js?ver=3.0.8

js artisian.ca collected 2026-10-09 21:33:47 UTC 151,002 bytes, 4,055 lines download raw bytes

1/**
2 * Product Filter by WBW - Frontend Woofilters JS
3 *
4 * @version 2.8.6
5 *
6 * @author  woobewoo
7 */
8
9/**
10 * Main function.
11 *
12 * @version 2.8.6
13 */
14(function ($, app) {
15	"use strict";
16
17	/**
18	 * WpfFrontendPage.
19	 *
20	 * @version 2.8.6
21	 */
22	function WpfFrontendPage() {
23		this.$obj = this;
24		this.noWoo = this.$obj.checkNoWooPage();
25		this.readyFuncs = ['.berocket_load_more_preload', 'woocommerce-product-bundle-hide', 'show_variation', 'woo_variation_swatches_pro_init', '.variations_form', 'yith_infs_start', 'flatsome_infinite_scroll','.dipl_woo_products_pagination_wrapper', 'divi_filter_loadmore_ajax_handler'];
26		this.isSafari = navigator.vendor && navigator.vendor.indexOf('Apple') > -1 && ((navigator.userAgent && navigator.userAgent.indexOf('CriOS') == -1 && navigator.userAgent.indexOf('FxiOS') == -1) || (navigator.platform && /iPhone|iPad|iPod/.test(navigator.platform)));
27		this.disableScrollJs = true;
28		this.lastFids = [];
29		return this.$obj;
30	}
31
32	WpfFrontendPage.prototype.init = (function () {
33		var _thisObj = this.$obj;
34		app.wpfNewUrl = '';
35		window.wpfDoNotLoadMore = false;
36		_thisObj.filterClick = true;
37		_thisObj.filteringId = 0;
38
39		_thisObj.setCurrentLocation();
40		_thisObj.filterLoadTypes = [];
41		_thisObj.defaultProductSelector = 'ul.products';
42		_thisObj.isAdminPreview = jQuery('#wpfFiltersEditForm').length > 0 || (typeof isElementorPreview != 'undefined' && isElementorPreview == 1);
43		_thisObj.moveFloatingElements();
44		_thisObj.checkForceFilters();
45		_thisObj.eventsPriceFilter();
46		_thisObj.disableLeerOptions();
47		_thisObj.eventsFrontend();
48		_thisObj.changeSlugByUrl();
49		_thisObj.runCustomJs();
50		_thisObj.addCustomCss();
51		_thisObj.chageRangeFieldWidth();
52		_thisObj.addSpecificPluginActions();
53		_thisObj.resizeWindow();
54		_thisObj.changeOrderBy();
55		_thisObj.copySelectsForSafari();
56
57		jQuery('.wpfMainWrapper').each(function() {
58			_thisObj.markCheckboxSelected(jQuery(this), true);
59		});
60
61		if (_thisObj.isAdminPreview) {
62			_thisObj.hideFiltersLoader();
63		} else {
64			setTimeout(function () {
65				_thisObj.hideFiltersLoader();
66			}, 100);
67        }
68	});
69	WpfFrontendPage.prototype.moveFloatingElements = (function () {
70		var _thisObj = this.$obj;
71		if (!_thisObj.isAdminPreview && jQuery('.wpfFloatingBlock').length == 0 && jQuery('.wpfFloatingWrapper').length == 1) {
72			jQuery('body').append('<div class="wpfFloatingBlock"></div>');
73			if (jQuery('.wpfFloatingSwitcher').length == 1) {
74				var button = $('.wpfFloatingSwitcher');
75				if (button.hasClass('wpfSwitcherRealFloat')) {
76					button.detach();
77					$('.wpfFloatingBlock').append(button);
78				}
79			}
80			if (jQuery('.wpfFloatingOverlay').length == 1) {
81				var overlay = $('.wpfFloatingOverlay').detach();
82				$('.wpfFloatingBlock').append(overlay);
83			}
84			if ($('.wpfFloatingWrapper').closest('.wpfFilterForWtbp').length) $('.wpfFloatingBlock').addClass('wpfFilterForWtbpFloating');
85			var block = $('.wpfFloatingWrapper').detach();
86			$('.wpfFloatingBlock').append(block);
87
88		}
89	});
90
91	WpfFrontendPage.prototype.changeOrderBy = (function () {
92		jQuery('.woocommerce-ordering select').on('change', function (e) {
93			e.preventDefault();
94			var orderBy = jQuery(this).val(),
95				curUrl = window.location.href;
96
97			if ((curUrl.indexOf('?') === -1)) {
98				curUrl += '?orderby=' + orderBy;
99				jQuery('.wpfMainWrapper').each(function () {
100					var filter = $(this).data('filter-settings');
101					if (typeof filter.settings.filters.defaults !== 'undefined') {
102						curUrl += '&' + filter.settings.filters.defaults.replace(';', '&').replace('|', '%7C');
103					}
104				});
105			} else {
106				if (curUrl.indexOf('orderby') === -1) {
107					curUrl += ((curUrl.indexOf('?') === -1) ? '?' : '&') + 'orderby=' + orderBy;
108				} else {
109					curUrl = curUrl.replace(/(orderby=)[^&]*/, '$1' + orderBy);
110				}
111			}
112			jQuery(location).attr('href', curUrl);
113			return false;
114		});
115	});
116
117	WpfFrontendPage.prototype.resizeWindow = (function() {
118		var _thisObj = this.$obj;
119		_thisObj.filterOptionsForDevices();
120		jQuery( window ).on('resize', function() {
121			_thisObj.filterOptionsForDevices();
122		});
123	});
124
125	WpfFrontendPage.prototype.copySelectsForSafari = (function() {
126		var _thisObj = this.$obj;
127		if (!_thisObj.isSafari) return;
128
129		jQuery('.wpfMainWrapper').each(function () {
130			var $wrapper = jQuery(this),
131				$selectsWrapper = $wrapper.find('.wpfSelectCopies');
132			if ($selectsWrapper.length == 0) {
133				jQuery('<div/>').addClass('wpfSelectCopies').appendTo($wrapper);
134				$selectsWrapper = $wrapper.find('.wpfSelectCopies');
135			}
136			if ($selectsWrapper.length == 0) return;
137
138			$wrapper.find('.wpfFilterWrapper[data-display-type="dropdown"] select').each(function() {
139				var $select = jQuery(this),
140					$filter = $select.closest('.wpfFilterWrapper'),
141					blockId = $filter.attr('id');
142				if ($selectsWrapper.find('select[data-block="' + blockId + '"]').length == 0) {
143					$select.clone().attr('data-block', blockId).appendTo($selectsWrapper);
144				}
145			});
146			_thisObj.removeHiddenOptionsForSafari($wrapper);
147		});
148	});
149
150	WpfFrontendPage.prototype.restoreSelectsForSafari = (function() {
151		var _thisObj = this.$obj;
152		if (!_thisObj.isSafari) return;
153
154		jQuery('.wpfMainWrapper').each(function () {
155			var $wrapper = jQuery(this),
156			$selectsWrapper = $wrapper.find('.wpfSelectCopies');
157			if ($selectsWrapper.length == 1) {
158
159				$selectsWrapper.find('select').each(function() {
160					var $select = jQuery(this),
161						blockId = $select.attr('data-block'),
162						$filterSelect = $wrapper.find('#' + blockId + ' select');
163					if ($filterSelect.length == 1) {
164						var value = $filterSelect.val();
165						$filterSelect.html($select.html());
166						$filterSelect.val(value);
167					}
168				});
169			}
170		});
171	});
172
173	/**
174	 * removeHiddenOptionsForSafari.
175	 *
176	 * @version 2.8.6
177	 */
178	WpfFrontendPage.prototype.removeHiddenOptionsForSafari = (function() {
179		var _thisObj = this.$obj;
180		if (!_thisObj.isSafari) return;
181
182		var $found = jQuery('.wpfFilterWrapper[data-display-type="dropdown"] select:visible option[style*="none"]');
183		if ($found.length) $found.remove();
184		else {
185			jQuery('.wpfFilterWrapper[data-display-type="dropdown"] select:visible option').each(function() {
186				if (jQuery(this).css('display') == 'none') jQuery(this).remove();
187			});
188		}
189	});
190
191	WpfFrontendPage.prototype.checkForceFilters = (function() {
192		var forceShowFilter = jQuery('.wpfMainWrapper[data-force="1"]');
193		if (!forceShowFilter.length) return;
194
195		jQuery('.wpfMainWrapper').each(function () {
196			var wrapper = jQuery(this),
197				forceShowCurrent = wrapper.attr('data-force');
198			if (!forceShowCurrent){
199				wrapper.remove();
200				if (wrapper.closest('.WpfWoofiltersWidget').length) {
201					wrapper.closest('.WpfWoofiltersWidget').remove();
202				}
203			}
204		});
205	});
206
207	WpfFrontendPage.prototype.showFiltersLoader = (function() {
208		jQuery('.wpfMainWrapper').each(function () {
209			var wrapper = jQuery(this);
210			wrapper.css('position','relative');
211			if (!wrapper.find('.wpfLoaderLayout').length){
212				jQuery('<div/>').addClass('wpfLoaderLayout').appendTo(wrapper);
213				wrapper.find('.wpfLoaderLayout').append('<i class="fa fa-spinner fa-pulse fa-3x fa-fw"/>');
214			}
215
216			wrapper.find('.wpfLoaderLayout').show();
217		});
218	});
219
220	WpfFrontendPage.prototype.hideFiltersLoader = (function() {
221		jQuery('.wpfMainWrapper').each(function () {
222			var wrapper = jQuery(this);
223
224			hideFilterLoader(wrapper);
225		});
226	});
227
228	WpfFrontendPage.prototype.runCustomJs = (function () {
229		var _thisObj = this.$obj;
230		jQuery('.wpfMainWrapper').each(function () {
231			var wrapper = jQuery(this),
232				jsCodeStr = '',
233				settings = _thisObj.getFilterMainSettings(wrapper);
234			if(settings){
235				settings = settings.settings;
236				jsCodeStr = settings.js_editor;
237			}
238			if(jsCodeStr.length > 0){
239				try {
240					eval(jsCodeStr);
241				}catch(e) {
242					console.log(e);
243				}
244
245			}
246		});
247	});
248
249	WpfFrontendPage.prototype.addCustomCss = (function () {
250		if (jQuery('style#wpfCustomCss').length === 0) {
251			var cssCodeStr = '';
252
253			jQuery('.wpfMainWrapper').each(function () {
254				var wrapper = jQuery(this),
255					customCss = jQuery('style#wpfCustomCss-' + wrapper.attr('data-viewid'));
256				if (customCss.length) {
257					cssCodeStr += customCss.html();
258					customCss.remove();
259				}
260			});
261			if (cssCodeStr.length > 0) {
262				jQuery('<style type="text/css" id="wpfCustomCss">' + cssCodeStr + '</style>').appendTo('head');
263			}
264		}
265	});
266
267	WpfFrontendPage.prototype.chageRangeFieldWidth = (function () {
268		var _thisObj = this.$obj;
269		jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"]').each(function () {
270			var filter = jQuery(this),
271				input1 = filter.find('#wpfMinPrice'),
272				input2 = filter.find('#wpfMaxPrice'),
273				fontSize1 = input1.css('font-size'),
274				fontSize2 = input2.css('font-size'),
275				visbleBuffer1 = filter.find('.wpfVisibleBufferMin'),
276				visbleBuffer2 = filter.find('.wpfVisibleBufferMax');
277			if(fontSize1) visbleBuffer1.css('font-size', fontSize1);
278			if(fontSize2) visbleBuffer2.css('font-size', fontSize2);
279
280			jQuery(visbleBuffer1).text(input1.val());
281			jQuery(visbleBuffer2).text(input2.val());
282
283			if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
284				jQuery(input1).width(visbleBuffer1.width()+20);
285				jQuery(input2).width(visbleBuffer2.width()+20);
286			} else {
287				jQuery(input1).width(visbleBuffer1.width()+10);
288				jQuery(input2).width(visbleBuffer2.width()+10);
289			}
290		});
291	});
292
293	WpfFrontendPage.prototype.eventsPriceFilter = (function () {
294		var _thisObj = this.$obj;
295
296		jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"]').each(function () {
297			_thisObj.initDefaultSlider(jQuery(this));
298		});
299
300		//change price filters
301		jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"]').on('wpfPriceChange', function(event){
302			var filter = jQuery(this),
303				mainWrapper = filter.closest('.wpfMainWrapper');
304
305			mainWrapper.find('.wpfFilterWrapper[data-filter-type="wpfPriceRange"] input').prop('checked', false);
306			mainWrapper.find('.wpfFilterWrapper[data-filter-type="wpfPriceRange"] select')
307				.val(mainWrapper.find('.wpfFilterWrapper[data-filter-type="wpfPriceRange"] select option:first').val());
308
309			filter.removeClass('wpfNotActive');
310			mainWrapper.find('.wpfFilterWrapper[data-filter-type="wpfPriceRange"]').addClass('wpfNotActive');
311		});
312
313		//change price range
314		jQuery('.wpfFilterWrapper[data-filter-type="wpfPriceRange"] input, .wpfFilterWrapper[data-filter-type="wpfPriceRange"] select').on('change', function(e){
315			e.preventDefault();
316
317			jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"]').addClass('wpfNotActive');
318		});
319
320	});
321
322	WpfFrontendPage.prototype.initDefaultSlider = (function (filter, type) {
323		var _thisObj = this.$obj,
324			wrapper = filter.closest('.wpfMainWrapper'),
325			filterType = typeof type !== 'undefined' ? type : 'price',
326			getAttr = filter.data('get-attribute'),
327			minInputId = '#wpfMinPrice',
328			maxInputId = '#wpfMaxPrice',
329			triggerName = 'wpfPriceChange';
330
331		if (filterType === 'attr') {
332			minInputId = '#wpfMinAttrNum';
333			maxInputId = '#wpfMaxAttrNum';
334			triggerName = 'wpfAttrSliderChange';
335		}
336
337		var minSelector = wrapper.find(minInputId),
338			maxSelector = wrapper.find(maxInputId),
339			wpfDataStep = wrapper.find('#wpfDataStep').val()
340		if (wpfDataStep == '0.001') {
341			wpfDataStep = '0.00000001';
342		}
343		wpfDataStep = Number(wpfDataStep);
344
345		var valMin = parseFloat(minSelector.attr('min')),
346			valMax = parseFloat(maxSelector.attr('max')),
347			curUrl = window.location.href,
348			urlParams = _thisObj.findGetParameter(curUrl),
349			rate = filter.data('rate');
350
351		urlParams = _thisObj.getConvertedPrices(urlParams, rate);
352
353		var	minPriceGetParams = urlParams.wpf_min_price ? parseFloat(urlParams.wpf_min_price) : valMin,
354			maxPriceGetParams = urlParams.wpf_max_price ? parseFloat(urlParams.wpf_max_price) : valMax;
355
356		if (filterType === 'attr') {
357			if (urlParams[getAttr]) {
358				var idsAnd = urlParams[getAttr].split(','),
359					idsOr = urlParams[getAttr].split('|'),
360					isAnd = idsAnd.length > idsOr.length;
361				var filterTypeValues = isAnd ? idsAnd : idsOr;
362			}
363			minPriceGetParams = urlParams[getAttr] ? parseFloat(filterTypeValues[0]) : valMin;
364			maxPriceGetParams = urlParams[getAttr] ? parseFloat(filterTypeValues.pop()) : valMax;
365		}
366
367		var sliderWrapper = filter.find("#wpfSliderRange"),
368			autoFilteringEnable = (wrapper.find('.wpfFilterButton').length == 0),
369			skin = filter.attr('data-price-skin');
370		if(skin === 'default'){
371			sliderWrapper.slider({
372				range: true,
373				orientation: "horizontal",
374				min: valMin,
375				max: valMax,
376				step: wpfDataStep,
377				values: [minPriceGetParams, maxPriceGetParams],
378				slide: function (event, ui) {
379					minSelector.val(ui.values[0]);
380					maxSelector.val(ui.values[1]);
381					filter.trigger(triggerName);
382				},
383				start: function () {
384					filter.trigger(triggerName);
385				},
386				stop: function () {
387					if(autoFilteringEnable){
388						_thisObj.setCurrentLocation();
389						_thisObj.filtering(wrapper);
390					}
391				},
392			});
393			minSelector.val(sliderWrapper.slider("values", 0));
394			maxSelector.val(sliderWrapper.slider("values", 1));
395		}
396	});
397
398	// add/remove get query param
399	WpfFrontendPage.prototype.QStringWork = (function ($attr, $value, $noWooPage, $filterWrapper, $type) {
400
401		$noWooPage = false;
402		if (window.wpfAdminPage) {
403			$noWooPage = true;
404		}
405		if($type === 'change'){
406			var curUrl = changeUrl($attr, $value, $noWooPage, $filterWrapper );
407			$filterWrapper.attr('data-hide-url', decodeURI(curUrl));
408		}else if($type === 'remove'){
409			var curUrl = removeQString($attr, $noWooPage, $filterWrapper);
410			$filterWrapper.attr('data-hide-url', decodeURI(curUrl));
411		}
412	});
413
414	WpfFrontendPage.prototype.eventChangeFilter = (function (e) {
415		var _thisObj = this.$obj,
416			_this = jQuery(e.target),
417			mainWrapper = _this.closest('.wpfMainWrapper'),
418			settings = _thisObj.getFilterMainSettings(mainWrapper);
419		_thisObj.setCurrentLocation();
420
421		_this.closest('.wpfFilterWrapper').removeClass('wpfNotActive');
422		if(typeof(_thisObj.eventChangeFilterPro) == 'function') {
423			_thisObj.eventChangeFilterPro(_this, settings);
424		}
425
426		var redirectOnlyClick = Number(settings.settings.redirect_only_click),
427		    autoUpdateFilter  = Number(settings.settings.auto_update_filter),
428			loaderEnable  = Number(settings.settings.filter_loader_icon_onload_enable),
429			isButton = ( mainWrapper.find('.wpfFilterButton').length > 0 ),
430			isCheckbox = _this.attr('type') == 'checkbox',
431			redirectLink = isCheckbox ? _this.closest('li' ).attr('data-link') : _this.find('option:selected').attr('data-link');
432
433		if (typeof redirectLink !== 'undefined' && isCheckbox) {
434			var filter = _this.closest('.wpfFilterWrapper');
435			if (filter.attr('data-display-type') != 'list' && _this.is(':checked')){
436				filter.find('input').prop('checked', false);
437				_this.prop('checked', true);
438			}
439		}
440
441		if (isButton) {
442			// if there is a button and autoUpdateFilter is selected, then we only change the filter.
443			// If redirectOnlyClick is selected, then we change the filter and products, but do not redirect until the button is clicked
444
445			if (autoUpdateFilter || redirectOnlyClick) {
446				if (loaderEnable) {
447					mainWrapper.find('.wpfLoaderLayout').show();
448				}
449				_thisObj.filterClick = false;
450				_thisObj.filtering(mainWrapper, false, redirectLink);
451			}
452
453		} else {
454			_thisObj.filterClick = true;
455			_thisObj.filtering(mainWrapper, false, redirectLink);
456		}
457	});
458
459
460	WpfFrontendPage.prototype.eventsFrontend = (function () {
461		var _thisObj = this.$obj,
462			searchParams = jQuery.toQueryParams(window.location.search);
463
464		//for Impreza LoadMore Pagination
465		if (searchParams['all_products_filtering'] && searchParams['all_products_filtering'] == '1') {
466			jQuery( document ).ajaxSend(function( event, jqxhr, settings ) {
467				if (settings.data) {
468					var response = _thisObj.unserializeStr(settings.data);
469					if (response['action'] && response['action'] == 'us_ajax_grid') {
470						if (response['template_vars'] && response['template_vars'].length) {
471							try {
472								var query = JSON.parse(response['template_vars']);
473							}catch(e){
474								var query = false;
475							}
476							if (query && query['query_args']) {
477								var args = query['query_args'];
478								if (args['product_cat']) delete args.product_cat;
479								if (args['product_tag']) delete args.product_tag;
480								response['template_vars'] = JSON.stringify(query);
481								var result = [];
482								jQuery.each(response, function(key, val) {
483									result.push(encodeURIComponent(key) + "=" + encodeURIComponent(val));
484								});
485								settings.data = result.join("&").replace(/%20/g, "+");
486							}
487						}
488					}
489				}
490			});
491		}
492		//for Divi Filter LoadMore / eael-pagination / premium-woo-products
493		if (jQuery('.divi-filter-archive-loop, .eael-woo-pagination, .premium-woo-products-pagination, .uael-woocommerce-pagination').length) {
494			var actions = ['divi_filter_loadmore_ajax_handler', 'woo_product_pagination_product', 'get_woo_products', 'uael_get_products'];
495			jQuery( document ).ajaxSend(function( event, jqxhr, settings ) {
496				if (settings.data) {
497					var response = _thisObj.unserializeStr(settings.data);
498					if (response['action'] && actions.indexOf(response['action']) != -1) {
499						var s = window.location.search;
500						if (s && s.length > 1) {
501							response['with_wpf_filter'] = s.replace('?','');
502							var result = [];
503							jQuery.each(response, function(key, val) {
504								result.push(encodeURIComponent(key) + "=" + encodeURIComponent(val));
505							});
506							settings.data = result.join("&").replace(/%20/g, "+");
507						}
508					}
509				}
510			});
511		}
512		//for woocommerce-blocks (All products and others)
513		if (typeof window.wpfFetchHookCreated == 'undefined' || window.wpfFetchHookCreated != 1) {
514			window.fetch = new Proxy(window.fetch, {
515				apply(fetch, that, args) {
516					var url = args.length ? args[0] : '';
517					if (typeof url === 'string' && url.length) {
518						if (url.indexOf('wp-json/wc/store/') != -1 && url.indexOf('/products?') != -1 && url.indexOf('per_page=') != -1) {
519							var s = window.location.search;
520							if (s.length) args[0] += s.replace('?','&');
521							else {
522								var urlPreselects = '';
523								jQuery('.wpfMainWrapper').each(function() {
524									var settings = _thisObj.getFilterMainSettings(jQuery(this)),
525										preselects = typeof settings.settings.filters.preselect !== 'undefined' ? settings.settings.filters.preselect : '';
526									if (preselects.length) {
527										urlPreselects += '&'+preselects.replace(/;/g,'&');
528										if (settings.settings.filtering_by_variations=='1') urlPreselects += '&wpf_fbv=1';
529										if (settings.settings.exclude_backorder_variations=='1') urlPreselects += '&wpf_ebv=1';
530										if (settings.settings.display_product_variations=='1') urlPreselects += '&wpf_dpv=1';
531									}
532								});
533								if (urlPreselects.length) {
534									args[0] += urlPreselects + '&wpf_preselects=1';
535
536								}
537							}
538						} else {
539							//Elementor Loop Load More
540							if ((jQuery('.e-load-more-anchor').length == 1) && jQuery('.e-load-more-spinner').length && url.indexOf('?') == -1) {
541								var $elementorLoadMoreAnchor = jQuery('.e-load-more-anchor'),
542									s = window.location.search;
543								if (s.length) {
544									var nextPage = $elementorLoadMoreAnchor.attr('data-next-page');
545									if (nextPage == url) args[0]+= s;
546								}
547
548							}
549						}
550					}
551					const result = fetch.apply(that, args);
552					return result;
553				}
554			});
555			window.wpfFetchHookCreated = 1;
556		}
557
558		//for themes with ajax-paginations, ajax-ordering
559		jQuery(document).ajaxComplete(function(event, xhr, options) {
560			setTimeout(function() {
561				if (jQuery('.wpfLoaderLayout:visible').length) {
562					window.wpfFrontendPage.init();
563					if (typeof(window.wpfFrontendPage.eventsFrontendPro) == 'function') {
564						window.wpfFrontendPage.eventsFrontendPro();
565					}
566				}
567			}, 500);
568			//if (jQuery('.wpfLoaderLayout:visible').length) window.wpfFrontendPage.init();
569		});
570
571		jQuery('.wpfMainWrapper').find('select[multiple]').each(function(){
572			var select = jQuery(this),
573				selectAll = select.attr('data-placeholder'),
574				search = JSON.parse(select.attr('data-search')),
575			    singleSelect = select.data('single-select'),
576				showCheckbox = (typeof select.data('hide-checkboxes') === 'undefined');
577
578			setTimeout(function () {
579				select.multiselect({
580					search: search.show,
581					columns: 1,
582					placeholder: selectAll ? selectAll : 'Select options',
583					optionAttributes: ['style', 'data-term-id'],
584					searchOptions: {'default': search.placeholder},
585					showCheckbox: showCheckbox,
586					onOptionClick: function (element, option) {
587						if (typeof singleSelect !== 'undefined') {
588							var value = jQuery(option).val();
589							jQuery(option).closest('ul').find('input[type="checkbox"][value!=' + value + ']').prop('checked', false);
590							jQuery(element).val(value);
591							jQuery(element).siblings('.ms-options-wrap').find('.ms-options:visible').hide();
592						}
593					},
594				});
595			}, 100);
596
597			if (search.show) {
598				jQuery('.ms-options-wrap').on('click', 'button', function () {
599					$(this).next('.ms-options').find('.ms-search input').focus();
600				});
601			}
602
603		});
604
605		if(jQuery('.wpfFilterWrapper[data-filter-type="wpfSortBy"]').length == 0) {
606			jQuery('.woocommerce-ordering').css('display', 'block');
607		}
608
609		jQuery('.wpfFilterWrapper[data-hide-single="1"]').each(function(){
610			var filter = jQuery(this),
611				selector = filter.find('.wpfColorsFilter').length ? 'li[data-term-slug]' : '[data-term-id]',
612				visible = 0;
613			if (filter.attr('data-display-type') == 'slider') {
614				var idsDef = filter.attr('data-ids-without-filtering').replaceAll(', ',',').split(',');
615				if (idsDef.length <= 1) filter.hide();
616			} else {
617				filter.find(selector).each(function(){
618					if (jQuery(this).css('display') != 'none') visible++;
619				});
620				if (visible <= 1) {
621					filter.hide();
622				}
623			}
624		});
625
626		//if no enabled filters hide all html
627		if(jQuery('.wpfFilterWrapper').length < 1){
628			jQuery('.wpfMainWrapper').addClass('wpfHidden');
629		}
630
631		//Start filtering
632		jQuery('body').on('mousedown', '.wpfFilterButton, .js-wpfFilterButtonSearch', function (e) {
633			e.preventDefault();
634			var $this = jQuery(this),
635				mainWrapper = $this.closest('.wpfMainWrapper'),
636				inputSearch = mainWrapper.find('.js-passiveFilterSearch');
637			if (inputSearch.length) {
638				inputSearch.each(function() {
639					var $sElem = jQuery(this);
640					if ($sElem.val() !== '') {
641						$sElem.closest('.wpfFilterWrapper').removeClass('wpfNotActive');
642					}
643					$sElem.trigger('blur');
644				});
645
646			}
647			applyFilter(_thisObj, $this);
648		});
649
650		jQuery('input.js-passiveFilterSearch').on('keydown', function (e) {
651			var char_code = e.which;
652			if (parseInt(char_code) == 13) {
653				e.preventDefault();
654				var $this = jQuery(this);
655				$this.closest('.wpfFilterWrapper').removeClass('wpfNotActive');
656				$this.trigger('blur');
657				applyFilter(_thisObj, $this);
658			}
659		});
660
661
662		//Clear filters
663		jQuery('body').on('click', '.wpfClearButton', function (e) {
664			e.preventDefault();
665			var $filterWrapper = jQuery(this).closest('.wpfMainWrapper'),
666				settings = _thisObj.getFilterMainSettings($filterWrapper),
667				resetAllFilters = typeof settings.settings.reset_all_filters !== 'undefined' ? settings.settings.reset_all_filters : 0;
668			_thisObj.setCurrentLocation();
669
670			if (resetAllFilters !== '0') {
671				jQuery('.wpfMainWrapper').each(function(){
672					_thisObj.clearFilters(jQuery(this).find('.wpfFilterWrapper'), true);
673				});
674			} else {
675				_thisObj.clearFilters($filterWrapper.find('.wpfFilterWrapper'), true);
676			}
677			if (Number(settings.settings.redirect_after_select) || Number(settings.settings.redirect_only_click)) {
678				_thisObj.filterClick = false;
679			}
680			_thisObj.filtering($filterWrapper, true);
681
682			if (typeof (_thisObj.initOneByOne) == 'function') {
683				_thisObj.initOneByOne($filterWrapper);
684			}
685
686		});
687
688		//price range choose only one checkbox
689		jQuery('.wpfFilterWrapper[data-filter-type="wpfPriceRange"] .wpfFilterContent input').on('change', function (e) {
690			e.preventDefault();
691			var input = jQuery(this),
692				inputs = input.closest('.wpfFilterWrapper').find('input');
693			if(input.is(":checked")){
694				inputs.prop('checked', false);
695				input.prop('checked', true);
696			}
697		});
698
699		//category/brand list choose only one checkbox
700		jQuery('.wpfFilterWrapper[data-filter-type="wpfCategory"], .wpfFilterWrapper[data-filter-type="wpfPerfectBrand"], .wpfFilterWrapper[data-filter-type="wpfAttribute"]').each(function() {
701			var categoryFilter = jQuery(this),
702				displayType = categoryFilter.data('display-type'),
703				categoryMulti = displayType == 'multi';
704			if (categoryFilter.data('filter-type') == 'wpfAttribute') {
705				if (displayType == 'list' || displayType == 'switch') categoryMulti = true;
706			}
707
708			categoryFilter.find('.wpfFilterContent input').on('change', function (e) {
709				e.preventDefault();
710				var input = jQuery(this);
711				if(categoryMulti) {
712					var mainWrapper = input.closest('.wpfMainWrapper'),
713						filterWrapper = input.closest('.wpfFilterWrapper'),
714						expandSelectedToChild = _thisObj.getFilterParam('f_multi_extend_parent_select', mainWrapper, filterWrapper);
715
716					if(expandSelectedToChild && input.is(':checked')) {
717						input.closest('li').find('ul input').prop('checked', true);
718					}
719
720					if (expandSelectedToChild && ! input.is(':checked') ) {
721						input.closest('li').find('ul input').prop('checked', false);
722					}
723				}
724			});
725		});
726
727		//rating choose only one checkbox
728		jQuery('.wpfFilterWrapper[data-filter-type="wpfRating"] .wpfFilterContent input').on('change', function (e) {
729			e.preventDefault();
730			var input = jQuery(this),
731				inputs = input.closest('.wpfFilterWrapper').find('input');
732			if(input.is(":checked")){
733				inputs.prop('checked', false);
734				input.prop('checked', true);
735			}
736		});
737
738		//after change input or dropdown make this filter active
739		//check if ajax mode enable and filtering on filter elements change
740		jQuery('body').off('change', '.wpfFilterWrapper select, .wpfFilterWrapper input:not(.passiveFilter)').on('change', '.wpfFilterWrapper select, .wpfFilterWrapper input:not(.passiveFilter)', function (e) {
741			e.preventDefault();
742			var isExeptionCase = _thisObj.checkExeptionCasesBeforeFiltering(this);
743			// exeption checkbox in multidropdown
744			if (!isExeptionCase) {
745				var $this = jQuery(this);
746				if ($this.is('input') && $this.closest('.wpfFilterWrapper').data('display-type') == 'mul_dropdown') {
747					isExeptionCase = true;
748				}
749			}
750
751			if (!isExeptionCase) {
752				setTimeout(function() {
753					_thisObj.eventChangeFilter(e);
754				}, 100);
755			}
756		});
757
758		//after change input or dropdown make this filter active
759		jQuery('.wpfFilterWrapper input:not(.passiveFilter)').on('change', function (e) {
760			e.preventDefault();
761			// check if input change move to top
762			_thisObj.moveCheckedToTop(jQuery(this));
763			// check multy or single input (radio or checkbox)
764			_thisObj.detectSingleCheckbox(jQuery(this))
765			// Mark selected
766			_thisObj.markCheckboxSelected(jQuery(this).closest('.wpfFilterWrapper'));
767		});
768
769		jQuery('.wpfMainWrapper').each(function() {
770			var mainWrapper = jQuery(this),
771				settings = _thisObj.getFilterMainSettings(mainWrapper);
772			if (settings && settings.settings && settings.settings.checked_items_top === '1') {
773				mainWrapper.find('.wpfFilterWrapper input').attr('autocomplete', 'off');
774				mainWrapper.find('.wpfFilterWrapper input:checked').each(function() {
775					_thisObj.moveCheckedToTop(jQuery(this), false);
776				});
777			}
778		});
779
780		/*jQuery('.wpfFilterWrapper input:checked').each(function() {
781			_thisObj.moveCheckedToTop(jQuery(this), false);
782		});*/
783
784		//search field work
785		jQuery('.wpfFilterWrapper .wpfSearchFieldsFilter').on('keyup', function (e) {
786			var _this = jQuery(this),
787				wrapper = _this.closest('.wpfFilterWrapper'),
788				searchVal = _this.val().toLowerCase(),
789				isIconFunc = typeof (_thisObj.getIcons) == 'function',
790				unfolding = (searchVal.length && _this.attr('data-unfolding') == '1' && isIconFunc),
791				collapse = (searchVal.length == 0 && _this.attr('data-collapse-search') == '1' && isIconFunc);
792			wrapper.find('.wpfFilterContent li:not(.wpfShowFewerWrapper)').filter(function() {
793				var $li = jQuery(this);
794				if ($li.find('.wpfValue').text().toLowerCase().indexOf(searchVal) > -1) {
795					$li.removeClass('wpfSearchHidden');
796					if (unfolding || collapse) {
797						var $parentLi = $li.closest('li');
798						while ($parentLi.length && $parentLi.closest('.wpfFilterWrapper')) {
799							var $label = $parentLi.children('label'),
800							    $icon = $label.length ? $label.find('i.fa, svg') : '';
801							if ($icon.length) {
802								var $icons = _thisObj.getIcons($icon.eq(0));
803								if ($icons.collapsed && unfolding || !$icons.collapsed && collapse) {
804									_thisObj.collapsibleToggle($icon.eq(0), $icons, $parentLi);
805								}
806							}
807							$parentLi = $parentLi.closest('ul').closest('li');
808						}
809					}
810				} else {
811					$li.addClass('wpfSearchHidden');
812				}
813			});
814			if(typeof(_thisObj.initShowMore) == 'function') {
815				_thisObj.initShowMore(wrapper.find('.wpfFilterVerScroll'));
816			}
817		});
818		/*jQuery('.wpfFilterWrapper .wpfSearchFieldsFilter').on('change', function (e) {
819			jQuery(this).closest('.wpfFilterWrapper').find('.wpfFilterContent li.wpfSearchHidden .wpfCheckbox input').prop('checked', false);
820		});*/
821
822		//uncheck one slug
823		jQuery('body').off('click', '.wpfSlugDelete').on('click', '.wpfSlugDelete', function(){
824			var _this = jQuery(this),
825				wrapper = _this.closest('.wpfSlug'),
826				filterType = wrapper.attr('data-filter-type'),
827				filterAttr = wrapper.attr('data-get-attribute'),
828				filterWrapper = false;
829			_thisObj.setCurrentLocation();
830
831			jQuery('.wpfFilterWrapper[data-filter-type="'+filterType+'"][data-get-attribute="'+filterAttr+'"]').each(function(){
832				var $this = jQuery(this),
833					filterType = $this.attr("data-filter-type");
834				if (filterType == 'wpfPrice' || filterType == 'wpfPriceRange') {
835					_thisObj.clearFilters($("[data-filter-type='wpfPrice']:not(.wpfSelectedParameter)"));
836					_thisObj.clearFilters($("[data-filter-type='wpfPriceRange']:not(.wpfSelectedParameter)"));
837				} else {
838					_thisObj.clearFilters($this);
839				}
840				if(filterWrapper == false) {
841					filterWrapper = $this.closest('.wpfMainWrapper');
842				}
843			});
844			if(filterWrapper != false) {
845				_thisObj.filtering(filterWrapper);
846			}
847		});
848
849		jQuery('body').off('click', '.wpfFilterWrapper .wpfFilterTitle').on('click', '.wpfFilterWrapper .wpfFilterTitle', function (e) {
850			e.preventDefault();
851			var _this = jQuery(this),
852				wrapper = _this.closest('.wpfMainWrapper'),
853				settings = _thisObj.getFilterMainSettings(wrapper),
854				content = _this.closest('.wpfFilterWrapper').find('.wpfFilterContent');
855
856			setTimeout(function () {
857				var toggle = _this.find('i.wpfTitleToggle, svg'),
858					icons  = {};
859				if (toggle.length) {
860					if (typeof (_thisObj.getIcons) == 'function') {
861						icons = _thisObj.getIcons(toggle);
862					} else {
863						icons = {collapsed: toggle.hasClass('fa-plus'), plusIcon: 'fa-plus', minusIcon: 'fa-minus'};
864					}
865
866					if (settings.settings.hide_filter_icon !== '0') {
867						if (icons.collapsed) {
868							_thisObj.openFilterToggle(toggle, content, true, icons);
869						} else {
870							_thisObj.closeFilterToggle(toggle, content, true, icons);
871						}
872					}
873				}
874			}, 100);
875		});
876
877		jQuery('body').off('click', '.wpfFilterWrapper .wpfBlockClear').on('click', '.wpfFilterWrapper .wpfBlockClear',  function(){
878			var parent = jQuery(this).closest(".wpfFilterWrapper"),
879				parentAttr = parent.attr("data-filter-type");
880			_thisObj.setCurrentLocation();
881			if (parentAttr == 'wpfPrice' || parentAttr == 'wpfPriceRange') {
882				_thisObj.clearFilters($("[data-filter-type='wpfPrice']:not(.wpfSelectedParameter)"));
883				_thisObj.clearFilters($("[data-filter-type='wpfPriceRange']:not(.wpfSelectedParameter)"));
884			} else {
885				_thisObj.clearFilters(parent);
886			}
887			_thisObj.filtering(parent.closest('.wpfMainWrapper'));
888			return false;
889		});
890
891		jQuery('body').off('wpffiltering').on('wpffiltering', function () {
892			_thisObj.setPagination(1);
893			_thisObj.setCurrentLocation();
894			_thisObj.filtering();
895			_thisObj.setPagination(0);
896		});
897
898		//click on new pagination link with page number
899		jQuery('body').off('click', '.wpfNoWooPage .woocommerce-pagination a.page-numbers').on('click', '.wpfNoWooPage .woocommerce-pagination a.page-numbers', function (e) {
900			e.preventDefault();
901			var _this = jQuery(this),
902				paginationWrapper = _this.closest('.woocommerce-pagination'),
903				currentNumber = paginationWrapper.find('.current').text();
904			if(!_this.hasClass('next') && !_this.hasClass('prev') ){
905				var number = _this.text();
906			}else if(_this.hasClass('next')){
907				var number = parseInt(currentNumber) + 1;
908			}else if(_this.hasClass('prev')){
909				var number = (parseInt(currentNumber) - 1) < 1 ? parseInt(currentNumber) - 1 : 1;
910			}
911			var wrapper = jQuery('.wpfMainWrapper').first(),
912				$queryVars = wrapper.attr('data-settings');
913			try{
914				var settings = JSON.parse($queryVars);
915			}catch(e){
916				var settings = false;
917			}
918			if(settings){
919				settings.paged = number;
920				settings.pagination = 1;
921				wrapper.attr('data-settings', JSON.stringify(settings) );
922			}
923			_thisObj.setCurrentLocation();
924
925			// todo: testing for two+ filters on page
926			_thisObj.filtering( jQuery('.wpfMainWrapper') );
927			_thisObj.setPagination(0);
928		});
929
930		var prevLocation = location.href.split('#').shift();
931		jQuery(window).on('popstate', function (e) {
932
933			var currentLocation = location.href.split('#').shift();
934			if (location.href.split('#').length > 1 && prevLocation === currentLocation) {
935				return;
936			}
937
938			if (typeof window.wpfAdminPage === 'undefined' && !_thisObj.isSafari) {
939				location.reload();
940			}
941		});
942		jQuery('.wpfPreselected:not([data-filter-type="wpfPriceRange"]) .wpfCheckbox input').prop('checked', true);
943
944		jQuery('#wpfOverlay:not([data-filter]').each(function() {
945			var $overlay = jQuery(this),
946				$wrapper = $overlay.closest('.wpfMainWrapper');
947			$overlay.attr('data-filter-for', $wrapper.attr('id')).attr('data-filter',$wrapper.attr('data-filter'));
948			$overlay.appendTo('body');
949		});
950
951	});
952
953	function applyFilter(_thisObj, $this) {
954		var mainWrapper = $this.closest('.wpfMainWrapper');
955		_thisObj.setCurrentLocation();
956
957		_thisObj.filterClick = true;
958		_thisObj.filtering(mainWrapper);
959	}
960
961	WpfFrontendPage.prototype.filterOptionsForDevices = (function () {
962		var _thisObj = this.$obj;
963		jQuery('.wpfMainWrapper .wpfFilterWrapper').each(function () {
964			var _this = jQuery(this),
965				wrapper = _this.closest('.wpfMainWrapper'),
966				settings = _thisObj.getFilterMainSettings(wrapper),
967				isMobile = false,
968				screenSize = jQuery(window).width();
969
970			if (settings.settings !== undefined) {
971				var isMobileBreakpoint = settings.settings.desctop_mobile_breakpoint_switcher,
972					mobileBreakpoinWidth = isMobileBreakpoint && isMobileBreakpoint == '1' ? settings.settings.desctop_mobile_breakpoint_width : '0',
973
974					displayFor = settings.settings.display_for,
975
976					filterWidthDesktop          = settings.settings.filter_width,
977					filterWidthDesktopUnit      = settings.settings.filter_width_in,
978					filterWidthMobile           = settings.settings.filter_width_mobile,
979					filterWidthMobileUnit       = settings.settings.filter_width_in_mobile,
980					filterBlockWidthDesktop     = settings.settings.filter_block_width,
981					filterBlockWidthDesktopUnit = settings.settings.filter_block_width_in,
982					filterBlockWidthMobile      = settings.settings.filter_block_width_mobile,
983					filterBlockWidthMobileUnit  = settings.settings.filter_block_width_in_mobile;
984
985				if (mobileBreakpoinWidth && '0' !== mobileBreakpoinWidth) {
986					if (screenSize <= mobileBreakpoinWidth) {
987						isMobile = true;
988					}
989
990					// "Filter Width" and "Filter Block Width" options
991					if (isMobile && filterBlockWidthMobile != '0') {
992						wrapper.css('width', filterWidthMobile+filterWidthMobileUnit);
993						_this.css('width', filterBlockWidthMobile+filterBlockWidthMobileUnit);
994						if (filterBlockWidthMobile+filterBlockWidthMobileUnit != '100%') {
995							_this.css('float', 'left');
996						}
997					} else if (!isMobile && filterBlockWidthDesktop != '0') {
998						wrapper.css('width', filterWidthDesktop+filterWidthDesktopUnit);
999						_this.css('width', filterBlockWidthDesktop+filterBlockWidthDesktopUnit);
1000						if (filterBlockWidthDesktop+filterBlockWidthDesktopUnit != '100%') {
1001							_this.css('float', 'left');
1002						}
1003					}
1004
1005					// "Display filter on"  option
1006					if (isMobile && displayFor == 'desktop') {
1007						wrapper.hide();
1008					} else if (!isMobile && displayFor == 'mobile') {
1009						wrapper.hide();
1010					}
1011
1012					// filters title
1013					_this.find('.wpfFilterTitle[data-show-on-mobile]').each(function() {
1014						jQuery(this).closest('.wpfFilterMainWrapper').find('wpfLoaderLayout').show();
1015							var showDesctop = jQuery(this).data('show-on-desctop'),
1016								showMobile = jQuery(this).data('show-on-mobile'),
1017								content = jQuery(this).closest('.wpfFilterWrapper').find('.wpfFilterContent'),
1018								title = jQuery(this).find('.wfpTitle'),
1019								icons = {};
1020						title.show();
1021
1022						var toggle = jQuery(this).closest('.wpfFilterWrapper').find('i.wpfTitleToggle, svg');
1023						setTimeout(function () {
1024							if (toggle.length) {
1025								toggle.show();
1026								if (typeof (_thisObj.getIcons) == 'function') {
1027									icons = _thisObj.getIcons(toggle);
1028								} else {
1029									icons = {collapsed: toggle.hasClass('fa-plus'), plusIcon: 'fa-plus', minusIcon: 'fa-minus'};
1030								}
1031
1032								if (isMobile) {
1033									if (showMobile == 'yes_open') {
1034										_thisObj.openFilterToggle(toggle, content, false, icons);
1035									} else if (showMobile == 'yes_close') {
1036										_thisObj.closeFilterToggle(toggle, content, false, icons);
1037									} else if (showMobile == 'no') {
1038										_thisObj.openFilterToggle(toggle, content, false, icons);
1039										toggle.hide();
1040										title.hide();
1041									}
1042								} else {
1043									if (showDesctop == 'yes_open') {
1044										_thisObj.openFilterToggle(toggle, content, false, icons);
1045									} else if (showDesctop == 'yes_close') {
1046										_thisObj.closeFilterToggle(toggle, content, false, icons);
1047									} else if (showDesctop == 'no') {
1048										_thisObj.openFilterToggle(toggle, content, false, icons);
1049										toggle.hide();
1050										title.hide();
1051									}
1052								}
1053							}
1054						}, 100);
1055					});
1056				}
1057			}
1058		});
1059	});
1060
1061	WpfFrontendPage.prototype.checkExeptionCasesBeforeFiltering = (function (filterInput) {
1062		var isExeption = false;
1063		// exeption when custom price do not set but input activated
1064		if ( jQuery(filterInput).parent().hasClass('wpfPriceCheckboxCustom')) {
1065			var customPriceWrapper = jQuery(filterInput).closest('li'),
1066				customMin = customPriceWrapper.find('input[name=wpf_custom_min]').val(),
1067				customMax = customPriceWrapper.find('input[name=wpf_custom_max]').val();
1068
1069			if (!customMin && !customMax) {
1070				isExeption = true;
1071			}
1072		}
1073		return isExeption;
1074	});
1075
1076	WpfFrontendPage.prototype.detectSingleCheckbox = (function (checkedInput) {
1077		var filterWrapper = checkedInput.closest('.wpfFilterWrapper'),
1078			displayType = filterWrapper.data('display-type'),
1079			filterType = filterWrapper.data('filter-type');
1080
1081		if (filterType == 'wpfCategory' || filterType == 'wpfPerfectBrand'|| filterType == 'wpfBrand') {
1082			var isOne = displayType == 'list';
1083		} else {
1084			var isOne = displayType == 'radio';
1085		}
1086
1087		if (isOne) {
1088			var inputs = filterWrapper.find('input');
1089
1090			if (checkedInput.is(':checked')) {
1091				inputs.prop('checked', false);
1092				checkedInput.prop('checked', true);
1093			}
1094		}
1095	});
1096
1097	WpfFrontendPage.prototype.moveCheckedToTop = (function (checkedInput, setPause) {
1098		var _thisObj = this.$obj,
1099			sPause = setPause === false ? 0 : 200;
1100		setTimeout(function() {
1101			var checkboxWrapper = checkedInput.closest('li'),
1102				mainWrapper = checkedInput.closest('.wpfMainWrapper'),
1103				filterWrapper = checkedInput.closest('.wpfFilterWrapper'),
1104				isHierarchical = filterWrapper.data('show-hierarchical'),
1105				settings = _thisObj.getFilterMainSettings(mainWrapper),
1106				checkboxesWrapper = checkedInput.closest(isHierarchical ? 'ul' : '.wpfFilterVerScroll');
1107			//if(settings && !isHierarchical) {
1108			if(settings && checkboxesWrapper.length) {
1109				settings = settings.settings;
1110				var checkedItemsTop = settings.checked_items_top === '1',
1111					isExeptionCase = _thisObj.checkExeptionCasesBeforeFiltering(checkedInput);
1112				if(checkedItemsTop && !isExeptionCase){
1113					if (checkedInput.is(":checked")) {
1114						checkboxesWrapper.prepend(checkboxWrapper);
1115					} else {
1116						checkboxesWrapper.append(checkboxWrapper);
1117						checkboxesWrapper.append(checkboxesWrapper.find('.wpfShowFewerWrapper,.wpfShowMoreWrapper'));
1118					}
1119					checkboxesWrapper.scrollTop(0);
1120				}
1121			}
1122		}, sPause);
1123	});
1124
1125	WpfFrontendPage.prototype.closeFilterToggle = (function (toggle, content, isTimeout, icons) {
1126		if (toggle.hasClass(icons.minusIcon)) {
1127			toggle.removeClass(icons.minusIcon);
1128			toggle.addClass(icons.plusIcon);
1129			content.addClass('wpfBlockAnimated');
1130			if (typeof isTimeout !== 'undefined' && isTimeout) {
1131				setTimeout(function () {
1132					if (content.hasClass('wpfBlockAnimated')) content.addClass('wpfHide');
1133				}, 10);
1134			} else {
1135				if (content.hasClass('wpfBlockAnimated')) content.addClass('wpfHide');
1136			}
1137		}
1138	});
1139
1140	WpfFrontendPage.prototype.openFilterToggle = (function (toggle, content, isTimeout, icons) {
1141		if (toggle.hasClass(icons.plusIcon)) {
1142			toggle.removeClass(icons.plusIcon);
1143			toggle.addClass(icons.minusIcon);
1144			content.removeClass('wpfHide');
1145			if (typeof isTimeout !== 'undefined' && isTimeout) {
1146				setTimeout(function () {
1147					if (!content.hasClass('wpfHide')) content.removeClass('wpfBlockAnimated');
1148				}, 400);
1149			} else {
1150				if (!content.hasClass('wpfHide')) content.removeClass('wpfBlockAnimated');
1151			}
1152		}
1153	});
1154
1155	WpfFrontendPage.prototype.setPagination = (function (pagination) {
1156		var wrapper = jQuery('.wpfMainWrapper').first(),
1157			$queryVars = wrapper.attr('data-settings');
1158		try{
1159			var settings = JSON.parse($queryVars);
1160		}catch(e){
1161			var settings = false;
1162		}
1163		if(settings){
1164			settings.pagination = pagination;
1165			wrapper.attr('data-settings', JSON.stringify(settings) );
1166		}
1167	});
1168	WpfFrontendPage.prototype.setCurrentLocation = (function() {
1169		app.wpfOldUrl = window.location.href;
1170		app.wpfNewUrl = app.wpfOldUrl;
1171	});
1172
1173	WpfFrontendPage.prototype.filtering = (function ($filterWrapper, clearAll, redirectLink, onlyRecalcFilter) {
1174		var _thisObj = this.$obj;
1175		_thisObj.chageRangeFieldWidth();
1176		if(_thisObj.isAdminPreview) return;
1177
1178		if(typeof $filterWrapper == 'undefined' || $filterWrapper.length == 0) {
1179			$filterWrapper = jQuery('.wpfMainWrapper').first();
1180		}
1181		if (_thisObj.filterClick && $filterWrapper.length) {
1182			_thisObj.createOverlay($filterWrapper.attr('id'));
1183		}
1184		if (typeof (_thisObj.beforeFilteringPro) === 'function') {
1185			_thisObj.beforeFilteringPro($filterWrapper);
1186		}
1187
1188		_thisObj.isSynchro = false;
1189		_thisObj.isStatistics = false;
1190
1191		if ($filterWrapper.length !== 0) {
1192			_thisObj.filteringId++;
1193			_thisObj.lastFids[$filterWrapper.data('viewid')] = _thisObj.filteringId;
1194
1195			var $filtersDataBackend = [],
1196				$filtersDataFrontend = [],
1197				noWooPage = _thisObj.noWoo,
1198				$generalSettings = _thisObj.getFilterMainSettings($filterWrapper);
1199			_thisObj.isSynchro = $generalSettings['settings']['use_filter_synchro'] && ($generalSettings['settings']['use_filter_synchro'] == '1') ? true : false;
1200			_thisObj.isStatistics = $filterWrapper.attr('data-is-stats') == 1;
1201
1202			if(_thisObj.isSynchro) {
1203				_thisObj.syncronizeFilters($filterWrapper);
1204			}
1205
1206			(_thisObj.isSynchro ? jQuery('.wpfMainWrapper') : $filterWrapper).find('.wpfFilterWrapper:not(.wpfNotActive), .wpfFilterWrapper.wpfPreselected').each(function () {
1207				var $filter = jQuery(this),
1208					filterType = $filter.attr('data-filter-type'),
1209					filterName = $filter.attr('data-get-attribute'),
1210					wrapper = $filter.closest('.wpfMainWrapper'),
1211					idFilter = wrapper.data('filter'),
1212					uniqId = $filter.attr('data-uniq-id'),
1213					allSettings = _thisObj.getFilterOptionsByType($filter, filterType),
1214					valueToPushBackend = {},
1215					valueToPushFrontend = {},
1216					logic = $filter.attr('data-query-logic'),
1217					isGroup = false,
1218					cgIndex = null;
1219				if(_thisObj.isStatistics && typeof (_thisObj.prepareStatisticsData) == 'function') {
1220					_thisObj.prepareStatisticsData($filter, allSettings);
1221				}
1222
1223				try {
1224					var order = JSON.parse(_thisObj.getFilterMainSettings(wrapper).settings.filters.order);
1225					jQuery.each(order, function (i, v) {
1226						if (v.uniqId === uniqId) {
1227							jQuery.each(v.settings, function (i, v) {
1228								cgIndex = i.match(/^f_cglist\[(\d+)\]/);
1229								if (cgIndex !== null && typeof cgIndex[1] !== 'undefined' && v !== '') {
1230									isGroup = true;
1231								}
1232							});
1233						}
1234					});
1235				} catch (e) {
1236				}
1237
1238				if (typeof logic === 'undefined') {
1239					logic = 'or';
1240				} else if (logic == 'not') {
1241					var notIds = $filter.attr('data-not-ids');
1242					if (notIds && notIds.length > 0) {
1243						allSettings = {backend: notIds.split(',')};
1244					}
1245				}
1246				var withChildren = $filter.attr('data-query-children');
1247				if (typeof withChildren === 'undefined') {
1248					withChildren = '1';
1249				}
1250
1251				if (allSettings['backend'].length && typeof allSettings['backend'] !== 'undefined' || filterType === 'wpfSearchText'  || filterType === 'wpfSearchNumber') {
1252					valueToPushBackend['id'] = filterType;
1253					valueToPushBackend['uniqId'] = uniqId;
1254					valueToPushBackend['logic'] = logic;
1255					valueToPushBackend['children'] = withChildren;
1256					valueToPushBackend['settings'] = allSettings['backend'];
1257					valueToPushBackend['name'] = filterName;
1258					$filtersDataBackend.push(valueToPushBackend);
1259				}
1260				if ('frontend' in allSettings) {
1261
1262					valueToPushFrontend['id'] = filterType;
1263
1264					var logicDelimetrList = {
1265						or: '|',
1266						and: ',',
1267						not_in: ';'
1268					}
1269
1270					valueToPushFrontend['delim'] = logicDelimetrList[logic];
1271					valueToPushFrontend['children'] = withChildren;
1272					valueToPushFrontend['settings'] = allSettings['frontend'];
1273					valueToPushFrontend['name'] = filterName;
1274					if (isGroup) {
1275						valueToPushFrontend['idFilter'] = idFilter;
1276						valueToPushFrontend['idBlock'] = uniqId.replace(/^wpf/, '');
1277					}
1278					$filtersDataFrontend.push(valueToPushFrontend);
1279				}
1280			});
1281
1282			var redirectTerm = typeof redirectLink !== 'undefined';
1283			if (redirectTerm || (typeof $filterWrapper.data('redirect-page-url') !== 'undefined' && _thisObj.filterClick)) {
1284				history.pushState({state: 1, rand: Math.random(), wpf: true}, '', location.protocol + '//' + location.host + location.pathname);
1285			}
1286
1287			var filterId = $filterWrapper.data('filter');
1288			if (typeof filterId !== 'undefined') {
1289				jQuery('span.wpfHidden').each(function () {
1290					var $span = jQuery(this),
1291						attribute = $span.data('shortcode-attribute'),
1292						fclass = 'wpf-filter-' + filterId;
1293					if ((attribute.class !== '' && fclass === attribute.class) || $span.closest('.'+fclass).length) {
1294						_thisObj.QStringWork('wpf_id', filterId, noWooPage, $filterWrapper, 'change');
1295					}
1296				});
1297			}
1298
1299			_thisObj.changeUrlByFilterParams($filtersDataFrontend);
1300			_thisObj.QStringWork('wpf_reload', '', noWooPage, $filterWrapper, 'remove');
1301
1302			//get paged params from html
1303			var $queryVars = $filterWrapper.attr('data-settings'),
1304				$defQuery = $filterWrapper.attr('data-default-query'),
1305				$queryVarsSettings = JSON.parse($queryVars);
1306
1307			var $filterSettings = $generalSettings === false ? {} : {
1308				'wpf_fid': _thisObj.filteringId,
1309				'filter_recount': $generalSettings['settings']['filter_recount'] && ($generalSettings['settings']['filter_recount'] == '1') ? true : false,
1310				'filter_recount_price': $generalSettings['settings']['filter_recount_price'] && ($generalSettings['settings']['filter_recount_price'] == '1') ? true : false,
1311				'text_no_products': $generalSettings['settings']['text_no_products'] ? $generalSettings['settings']['text_no_products'] : '',
1312				'count_product_shop': $generalSettings['settings']['count_product_shop'] ? parseInt($generalSettings['settings']['count_product_shop']) : 0,
1313				'f_multi_logic': $generalSettings['settings']['f_multi_logic'] ? $generalSettings['settings']['f_multi_logic'] : 'and',
1314				'remove_actions': $generalSettings['settings']['remove_actions'] && ($generalSettings['settings']['remove_actions'] == '1') ? true : false,
1315				'filtering_by_variations': $generalSettings['settings']['filtering_by_variations'] && ($generalSettings['settings']['filtering_by_variations'] == '1') ? true : false,
1316				'form_filter_by_variations': $generalSettings['settings']['form_filter_by_variations'] && ($generalSettings['settings']['form_filter_by_variations'] == '1') ? true : false,
1317				'exclude_backorder_variations': $generalSettings['settings']['exclude_backorder_variations'] && ($generalSettings['settings']['exclude_backorder_variations'] == '1') ? true : false,
1318				'display_product_variations': $generalSettings['settings']['display_product_variations'] && ($generalSettings['settings']['display_product_variations'] == '1') ? true : false,
1319				'all_products_filtering': $generalSettings['settings']['all_products_filtering'] && ($generalSettings['settings']['all_products_filtering'] == '1') ? true : false,
1320				'do_not_use_shortcut': $generalSettings['settings']['do_not_use_shortcut'] && ($generalSettings['settings']['do_not_use_shortcut'] == '1') ? true : false,
1321				'use_category_filtration': $generalSettings['settings']['use_category_filtration'] ? $generalSettings['settings']['use_category_filtration'] : 1,
1322				'product_list_selector': $generalSettings['settings']['product_list_selector'] ? $generalSettings['settings']['product_list_selector'] : '',
1323				'product_container_selector': $generalSettings['settings']['product_container_selector'] ? $generalSettings['settings']['product_container_selector'] : '',
1324				'auto_update_filter' : Number($generalSettings['settings']['auto_update_filter']),
1325				'redirect_only_click' : Number($generalSettings['settings']['redirect_only_click']),
1326				'display_status_private' : $generalSettings['settings']['display_status_private'] && ($generalSettings['settings']['display_status_private'] == '1') ? true : false,
1327				'open_one_by_one': $generalSettings['settings']['open_one_by_one'] ? $generalSettings['settings']['open_one_by_one'] : '',
1328				'obo_only_children': $generalSettings['settings']['obo_only_children'] ? $generalSettings['settings']['obo_only_children'] : '',
1329				'display_only_children_category': $generalSettings['settings']['display_only_children_category'] ? $generalSettings['settings']['display_only_children_category'] : '',
1330			};
1331			var $withPerPage = $filterWrapper.find('select.wpfPerPageDD'),
1332				perPageCount = $withPerPage.length ? $withPerPage.find('option:selected') : '';
1333			if (perPageCount.length) {
1334				$filterSettings['count_product_shop'] = perPageCount.val();
1335			}
1336
1337			$filterSettings['sort_by_title'] = ($generalSettings['settings']['sort_by_title'] != undefined && $generalSettings['settings']['sort_by_title'] == '1' ? true : false);
1338			if (typeof $defQuery !== 'undefined' && $defQuery.length) $filterSettings['default_query'] = JSON.parse($defQuery);
1339
1340			// find woocommerce product loop type ( shorcode, loop )
1341			var productContainerSelector = _thisObj.fixSelector($filterSettings['product_container_selector'], ''),
1342				productContainerElem = (productContainerSelector !== '')
1343					? jQuery(productContainerSelector)
1344					: jQuery(document);
1345
1346			$queryVars = JSON.parse($queryVars);
1347			var shortcode = jQuery('span[data-shortcode-attribute]', productContainerElem),
1348				$shortcodeAttr = {};
1349
1350			if (shortcode.length) {
1351				$shortcodeAttr = shortcode.data('shortcode-attribute');
1352
1353				if ($shortcodeAttr['limit'] > 0) {
1354					$queryVars['posts_per_page'] = $shortcodeAttr['limit'];
1355				}
1356
1357				$queryVars['wc_loop_type'] = 'shortcode';
1358				$queryVars['paginate_type'] = 'shortcode';
1359				$queryVars['paginate_base'] = 'product-page';
1360			} else {
1361				$queryVars['wc_loop_type'] = 'loop';
1362			}
1363
1364			// for plugin WooCommerce Products Per Page
1365			var $wppp = jQuery('.wppp-select').first();
1366			if ($wppp.length) {
1367				$queryVars['posts_per_page'] = $wppp.val();
1368			}
1369
1370			$queryVars = JSON.stringify($queryVars);
1371			$shortcodeAttr = JSON.stringify($shortcodeAttr);
1372
1373			if (clearAll) {
1374				var newUrl = getCurrentUrlPartsWpf();
1375				if (newUrl.search.length && newUrl.search.indexOf('wpf_')) clearAll = false;
1376			}
1377
1378			if ($filterSettings['count_product_shop'] > 0 && !clearAll) {
1379				_thisObj.QStringWork('wpf_count', $filterSettings['count_product_shop'], noWooPage, $filterWrapper, 'change');
1380			}
1381			if ($filterSettings['sort_by_title']) {
1382				_thisObj.QStringWork('wpf_order', 'title', noWooPage, $filterWrapper, 'change');
1383			}
1384			if ($filterSettings['filtering_by_variations'] && !clearAll) {
1385				_thisObj.QStringWork('wpf_fbv', 1, noWooPage, $filterWrapper, 'change');
1386			}
1387			if ($filterSettings['exclude_backorder_variations'] && !clearAll) {
1388				_thisObj.QStringWork('wpf_ebv', 1, noWooPage, $filterWrapper, 'change');
1389			}
1390			if ($filterSettings['display_product_variations'] && !clearAll) {
1391				_thisObj.QStringWork('wpf_dpv', 1, noWooPage, $filterWrapper, 'change');
1392			}
1393			if ($filterSettings['all_products_filtering'] && !clearAll) {
1394				_thisObj.QStringWork('all_products_filtering', '1', noWooPage, $filterWrapper, 'change');
1395			}
1396			if ($filtersDataBackend.length === 0) {
1397				_thisObj.QStringWork('all_products_filtering', '', noWooPage, $filterWrapper, 'remove');
1398			}
1399			if ($filterSettings['f_multi_logic'] !== 'and' && !clearAll) {
1400				_thisObj.QStringWork('wpf_filter_tax_block_logic', $filterSettings['f_multi_logic'], noWooPage, $filterWrapper, 'change');
1401			}
1402			if ($filtersDataBackend.length === 0) {
1403				_thisObj.QStringWork('wpf_filter_tax_block_logic', '', noWooPage, $filterWrapper, 'remove');
1404			}
1405			// we always start from first page after filtering
1406			//if ($queryVarsSettings['paginate_type'] == 'query' || $queryVarsSettings['paginate_type'] == 'shortcode') {
1407			_thisObj.QStringWork($queryVarsSettings['paginate_base'], '', noWooPage, $filterWrapper, 'remove');
1408			_thisObj.QStringWork('product-page', '', noWooPage, $filterWrapper, 'remove');
1409			_thisObj.QStringWork('shopPage', '', noWooPage, $filterWrapper, 'remove');
1410			_thisObj.QStringWork('avia-element-paging', '', noWooPage, $filterWrapper, 'remove');
1411
1412			var curUrl = getCurrentUrlPartsWpf();
1413            if (curUrl.search.length) {
1414                // Remove any URL parameters that start with 'e-page-'
1415                var ePageMatch = curUrl.search.match(/[?&](e-page-[^=&]+)=/);
1416                if (ePageMatch && ePageMatch[1]) {
1417                    _thisObj.QStringWork(ePageMatch[1], '', noWooPage, $filterWrapper, 'remove');
1418                }
1419
1420				var $pages = curUrl.search.match(/query-\d+-page/i);
1421				if ($pages != null && $pages.length) _thisObj.QStringWork($pages[0], '', noWooPage, $filterWrapper, 'remove');
1422			}
1423
1424			var $woocommerceSettings = {};
1425			if (jQuery('.wpfFilterWrapper[data-filter-type="wpfSortBy"]').length == 0) {
1426				var $wooCommerceSort = jQuery('.woocommerce-ordering select');
1427				if ($wooCommerceSort.length > 0) {
1428					$woocommerceSettings['woocommercefSortBy'] = $wooCommerceSort.eq(0).val();
1429				}
1430			}
1431			if (onlyRecalcFilter) {
1432				// this block for forced filter refresh without product filtering
1433				// you can call this with custom js: window.wpfFrontendPage.filtering(jQuery('.wpfMainWrapper[data-filter="1"]'),false,false,true);
1434				var requestData =_thisObj.getAjaxRequestData($filtersDataBackend, $queryVars, $filterSettings, $generalSettings, $shortcodeAttr, $woocommerceSettings);
1435				_thisObj.ajaxOnlyRecount(requestData, $filterWrapper.attr('id'));
1436				return;
1437			}
1438			var redirect = (typeof $filterWrapper.data('redirect-page-url') !== 'undefined'),
1439				$needUrl = $filterSettings['open_one_by_one'] == '1' && $filterSettings['obo_only_children'] == '1';
1440
1441			if (history.pushState && app.wpfNewUrl != window.wpfOldUrl && ((!redirect && !redirectTerm) || $needUrl))  {
1442				var newUrl = app.wpfNewUrl.indexOf('pr_search_') > 0 ? app.wpfNewUrl.replace('+', '%2b') : app.wpfNewUrl;
1443				history.pushState({state: 1, rand: Math.random(), wpf: true}, '', newUrl);
1444				app.wpfOldUrl = app.wpfNewUrl;
1445				_thisObj.changeSlugByUrl();
1446			}
1447
1448			if (redirectTerm || (redirect && _thisObj.filterClick)) {
1449				let queryString = app.wpfNewUrl.split('?')[1] || '';
1450				if (queryString !== '') {
1451					if (_thisObj.isStatistics) {
1452						var requestData =_thisObj.getAjaxRequestData($filtersDataBackend, $queryVars, $filterSettings, $generalSettings, $shortcodeAttr, $woocommerceSettings);
1453						wpfDoActionsAfterLoad(_thisObj.filteringId, -1, requestData);
1454					}
1455					var redLink = (redirectTerm ? redirectLink : $filterWrapper.data('redirect-page-url'));
1456					jQuery(location).attr('href', redLink + (redLink.indexOf('?') == -1 ? '?' : '&') + queryString + '&redirect');
1457				}
1458			} else {
1459				if ($generalSettings && $generalSettings.settings.enable_ajax !== '1') {
1460					if (_thisObj.isStatistics) {
1461						var requestData =_thisObj.getAjaxRequestData($filtersDataBackend, $queryVars, $filterSettings, $generalSettings, $shortcodeAttr, $woocommerceSettings);
1462						wpfDoActionsAfterLoad(_thisObj.filteringId, -1, requestData);
1463					}
1464					if (_thisObj.isSafari || navigator.userAgent.match(/firefox|fxios/i)) location.reload(true);
1465					else location.reload();
1466					return;
1467				}
1468
1469				_thisObj.currentFilterBackend = $filtersDataBackend;
1470				// event for custom javascript hook
1471				var customEvent = document.createEvent('Event');
1472				customEvent.initEvent('wpfAjaxStart', false, true);
1473				document.dispatchEvent(customEvent);
1474				//ajax call to server
1475				_thisObj.currentLoadId = $filterWrapper.attr('id');
1476
1477				var $wtbpFilterWrapper = $filterWrapper.closest('.wpfFilterForWtbp');
1478				if ($wtbpFilterWrapper.length == 0) {
1479					if ($filterWrapper.closest('.wpfFilterForWtbpFloating').length) {
1480						$wtbpFilterWrapper = $('.wpfFilterForWtbp[data-wpf-id="'+$filterWrapper.attr('data-filter')+'"]');
1481					}
1482				}
1483				if ($wtbpFilterWrapper.length == 1) {
1484					var wtbpTableId = $wtbpFilterWrapper.closest('.wtbpTableWrapper').attr('data-table-id'),
1485						wtbpTable = wtbpTableId ? window.woobewoo.WooTablepress.getTableInstanceById(wtbpTableId) : false;
1486					if (wtbpTable && wtbpTable.isSSP) {
1487						wtbpTable.ajax.reload();
1488						return;
1489					}
1490				}
1491				_thisObj.sendFiltersOptionsByAjax(_thisObj.currentFilterBackend, $queryVars, $filterSettings, $generalSettings, $woocommerceSettings, $shortcodeAttr);
1492				if (_thisObj.isSynchro) {
1493					jQuery('.wpfMainWrapper:not(#'+_thisObj.currentLoadId+')').each(function(){
1494						var $synchroWrapper = jQuery(this);
1495
1496						$generalSettings = _thisObj.getFilterMainSettings($synchroWrapper);
1497						var requestData =_thisObj.getAjaxRequestData($filtersDataBackend, $queryVars, $filterSettings, $generalSettings, $shortcodeAttr, $woocommerceSettings);
1498
1499						_thisObj.ajaxOnlyRecount(requestData, $synchroWrapper.attr('id'));
1500
1501					});
1502				}
1503			}
1504		}
1505	});
1506
1507	WpfFrontendPage.prototype.getAjaxRequestData = (function ($filtersDataBackend, $queryVars, $filterSettings, $generalSettings, $shortcodeAttr, $woocommerceSettings) {
1508		$generalSettings = $generalSettings ? $generalSettings['settings']['filters']['order'] : [];
1509		var typeSettings = typeof $generalSettings;
1510		if (typeSettings == 'undefined') $generalSettings = '[]';
1511		else if (typeSettings != 'string') $generalSettings = JSON.stringify($generalSettings);
1512
1513		return {
1514			mod: 'woofilters',
1515			action: 'filtersFrontend',
1516			filtersDataBackend: JSON.stringify($filtersDataBackend),
1517			queryvars: $queryVars,
1518			filterSettings: JSON.stringify($filterSettings),
1519			generalSettings: $generalSettings,
1520			shortcodeAttr: $shortcodeAttr,
1521			woocommerceSettings: JSON.stringify($woocommerceSettings),
1522			currenturl: window.location.href,
1523		};
1524	});
1525
1526	WpfFrontendPage.prototype.createOverlay = (function (filterId) {
1527		var selector = '#wpfOverlay';
1528		if (typeof filterId != 'undefined') selector += '[data-filter-for="'+filterId+'"]';
1529		jQuery(selector).css({'display':'block'});
1530	});
1531
1532	WpfFrontendPage.prototype.removeOverlay = (function () {
1533		jQuery('#wpfOverlay').css({'display':'none'});
1534		jQuery('#wpfOverlay[data-filter-for]').css({'display':'none'});
1535	});
1536
1537	WpfFrontendPage.prototype.syncronizeFilters = (function ($filterWrapper) {
1538		var _thisObj = this.$obj,
1539			filterId = $filterWrapper.attr('id');
1540
1541		$filterWrapper.find('.wpfFilterWrapper').each(function () {
1542			var $filter = jQuery(this),
1543				filterType = $filter.attr('data-filter-type'),
1544				filterDisplay = $filter.attr('data-display-type'),
1545				filterSlug = $filter.attr('data-slug'),
1546				filterTaxonomy = $filter.attr('data-taxonomy'),
1547				selector = '.wpfMainWrapper:not(#'+filterId+') .wpfFilterWrapper[data-filter-type="'+filterType+'"]';
1548			if (filterDisplay) selector += '[data-display-type="'+filterDisplay+'"]';
1549			if (filterSlug) selector += '[data-slug="'+filterSlug+'"]';
1550			if (filterTaxonomy) selector += '[data-taxonomy="'+filterTaxonomy+'"]';
1551			var $synchroFilters = jQuery(selector);
1552			if ($synchroFilters.length) {
1553				$synchroFilters.find('input').prop('checked', false).trigger('wpf-synchro');
1554				$filter.find('input:checked').each(function(){
1555					var $li = jQuery(this).closest('[data-term-id]');
1556					if ($li) {
1557						var $synchroInput = $synchroFilters.find('[data-term-id="'+$li.attr('data-term-id')+'"] input');
1558						if ($synchroInput.length == 0 && filterDisplay == 'colors') $synchroInput = $synchroFilters.find('input[data-term-id="'+$li.attr('data-term-id')+'"]');
1559						if ($synchroInput.length) $synchroInput.prop('checked', true).trigger('wpf-synchro');
1560					}
1561				});
1562				if (filterType === 'wpfPrice'){
1563					var min = $filter.find('#wpfMinPrice').val(),
1564						max = $filter.find('#wpfMaxPrice').val();
1565					$synchroFilters.each(function() {
1566						var $slider = jQuery(this);
1567						$slider.find('#wpfMinPrice').val(min);
1568						$slider.find('#wpfMaxPrice').val(max);
1569						//$slider.find('#wpfSliderRange').slider("option", "values", [ min, max ]);
1570					});
1571				} else if (filterDisplay == 'mul_dropdown') {
1572					$synchroFilters.find('select').val($filter.find('select').val());
1573					$synchroFilters.find('select.jqmsLoaded').multiselect('reload');
1574				} else if(filterDisplay == 'text') {
1575					$synchroFilters.find('input').val($filter.find('input').val());
1576				} else {
1577					var value = $filter.find('select').val();
1578					$synchroFilters.find('select').each(function() {
1579						if (jQuery(this).find('option[value="'+value+'"]').length) jQuery(this).val(value);
1580					});
1581				}
1582
1583				if(typeof(_thisObj.syncronizeFiltersPro) == 'function') {
1584					_thisObj.syncronizeFiltersPro($filter, $synchroFilters);
1585				}
1586
1587				if ($filter.hasClass('wpfNotActive')) $synchroFilters.addClass('wpfNotActive');
1588				else $synchroFilters.removeClass('wpfNotActive');
1589			}
1590
1591
1592
1593		});
1594
1595		//_thisObj.markCheckboxSelected(filter);
1596	});
1597
1598	WpfFrontendPage.prototype.clearFilters = (function (filter, clearAll) {
1599		var _thisObj = this.$obj,
1600			noWooPage = _thisObj.noWoo,
1601			clearAll = typeof clearAll == 'undefined' ? false : true;
1602
1603		(filter ? filter : jQuery('.wpfFilterWrapper')).each(function () {
1604			var $filter = jQuery(this),
1605				$filterWrapper = $filter.closest('.wpfMainWrapper'),
1606				filterAttribute = $filter.attr('data-get-attribute'),
1607				filterType = $filter.attr('data-display-type'),
1608				defValue = $filter.attr('data-filter-default');
1609			if (typeof defValue === 'undefined') {
1610				defValue = '';
1611			}
1612
1613			filterAttribute = filterAttribute.split(",");
1614			var count = filterAttribute.length;
1615			for(var i = 0; i < count; i++){
1616				_thisObj.QStringWork(filterAttribute[i], '', noWooPage, $filterWrapper, 'remove');
1617			}
1618
1619			if($filter.hasClass('wpfHidden')){
1620				$filter.removeClass('wpfNotActive');
1621			} else {
1622				$filter.find('input').prop('checked', false);
1623
1624				if(filterType == 'mul_dropdown') {
1625					$filter.find('select').val('');
1626					$filter.find('select.jqmsLoaded').multiselect('reload');
1627				} else if(filterType == 'text') {
1628					$filter.find('input').val('');
1629				} else {
1630					$filter.find("select").val($filter.find("select option:first").val());
1631				}
1632				if (defValue.length && clearAll) {
1633					if(filterType == 'dropdown') {
1634						$filter.find('select').val($filter.find('select option[data-term-slug="'+defValue+'"]').val());
1635					} else {
1636						$filter.find('li[data-term-slug="'+defValue+'"] input').prop('checked', true);
1637					}
1638					$filter.removeClass('wpfNotActive');
1639				} else {
1640					$filter.addClass('wpfNotActive');
1641				}
1642			}
1643
1644			if($filter.attr('data-filter-type') === 'wpfPrice'){
1645				var min = $filter.find('#wpfMinPrice').attr('min'),
1646					max = $filter.find('#wpfMaxPrice').attr('max');
1647				$filter.find('#wpfMinPrice').val(min);
1648				$filter.find('#wpfMaxPrice').val(max);
1649
1650				jQuery( "#wpfSliderRange" ).slider( "option", "values", [ min, max ] );
1651			}
1652
1653			if(typeof(_thisObj.clearFiltersPro) == 'function') {
1654				_thisObj.clearFiltersPro($filter);
1655			}
1656			if(typeof(_thisObj.eventChangeFilterPro) == 'function') {
1657				_thisObj.eventChangeFilterPro($filter);
1658			}
1659			if(clearAll) {
1660				_thisObj.QStringWork('wpf_order', '', noWooPage, $filterWrapper, 'remove');
1661				_thisObj.QStringWork('wpf_count', '', noWooPage, $filterWrapper, 'remove');
1662				_thisObj.QStringWork('all_products_filtering', '', noWooPage, $filterWrapper, 'remove');
1663				_thisObj.QStringWork('wpf_oistock', '', noWooPage, $filterWrapper, 'remove');
1664				_thisObj.QStringWork('wpf_fbv', '', noWooPage, $filterWrapper, 'remove');
1665				_thisObj.QStringWork('wpf_dpv', '', noWooPage, $filterWrapper, 'remove');
1666				_thisObj.QStringWork('wpf_ebv', '', noWooPage, $filterWrapper, 'remove');
1667			}
1668		});
1669
1670		_thisObj.markCheckboxSelected(filter);
1671	});
1672
1673	WpfFrontendPage.prototype.getFilterMainSettings = (function ($selector) {
1674		var settingsStr = $selector.attr('data-filter-settings');
1675		try{
1676			var settings = JSON.parse(settingsStr);
1677		}catch(e){
1678			var settings = false;
1679		}
1680		if (settings === false) {
1681			settingsStr = settingsStr.replace('}]"', '}]').replace('"[{', '[{');
1682			try{
1683				settings = JSON.parse(settingsStr);
1684			}catch(e){
1685				settings = false;
1686			}
1687		}
1688		return settings;
1689	});
1690
1691	WpfFrontendPage.prototype.getFilterParam = (function (paramSlug, mainWrapper, filterWrapper) {
1692		var paramValue = null,
1693			_thisObj = this.$obj,
1694			mainSettings = _thisObj.getFilterMainSettings(mainWrapper),
1695			orderKey = filterWrapper.attr('data-order-key');
1696		if (mainSettings.settings.filters.order && typeof orderKey !== undefined) {
1697			var filtersOderList = JSON.parse(mainSettings.settings.filters.order);
1698			if ( typeof filtersOderList[orderKey] !== undefined ) {
1699				var filterParamList = filtersOderList[orderKey].settings;
1700				if ( typeof filterParamList[paramSlug] !== undefined ) {
1701					paramValue = filterParamList[paramSlug];
1702				}
1703			}
1704		}
1705		return paramValue;
1706	});
1707
1708	WpfFrontendPage.prototype.checkNoWooPage = (function () {
1709		var noWooPage = false;
1710		if(jQuery('.wpfMainWrapper').first().attr('data-nowoo')){
1711			noWooPage = true;
1712		}
1713		return noWooPage;
1714	});
1715
1716	WpfFrontendPage.prototype.changeLmpButton = (function () {
1717		var lmpBtn = jQuery('.br_lmp_button_settings .lmp_button');
1718		if (lmpBtn.length) {
1719			var parentStyle = lmpBtn.parent().attr('style').replace(' ', '');
1720			if (parentStyle.indexOf('display:none') > -1) {
1721				return;
1722			}
1723			var url = lmpBtn.attr('href').split('?')[0];
1724			url += window.location.search;
1725			url = url.indexOf('/page/2') > -1 ? url : url.replace(/\/page\/[0-9]{1,}/ig, '/page/2');
1726			lmpBtn.attr('href', url);
1727			setTimeout(function(){
1728				jQuery('.woocommerce-pagination').addClass('wpfHidden');
1729			}, 1000);
1730		}
1731	});
1732
1733
1734	WpfFrontendPage.prototype.changeUrlByFilterParams = (function ($filtersDataFrontend) {
1735		var _thisObj = this.$obj,
1736			noWooPage = _thisObj.noWoo;
1737		if (typeof $filtersDataFrontend !== 'undefined' && $filtersDataFrontend.length > 0) {
1738			// the array is defined and has at least one element
1739			var count = $filtersDataFrontend.length,
1740				filterWrapper = jQuery('.wpfMainWrapper'),
1741				priceFlag = true;
1742			for(var i = 0; i < count; i++){
1743				switch ($filtersDataFrontend[i]['id']){
1744					case 'wpfPrice':
1745					case 'wpfPriceRange':
1746						if (priceFlag) {
1747							var minPrice = $filtersDataFrontend[i]['settings']['wpf_min_price'],
1748								maxPrice = $filtersDataFrontend[i]['settings']['wpf_max_price'],
1749								tax = $filtersDataFrontend[i]['settings']['tax'];
1750
1751							if (typeof minPrice !== 'undefined' && minPrice.length > 0) {
1752								_thisObj.QStringWork('wpf_min_price', minPrice, noWooPage, filterWrapper, 'change');
1753							} else {
1754								_thisObj.QStringWork('wpf_min_price', '', noWooPage, filterWrapper, 'remove');
1755							}
1756							if (typeof maxPrice !== 'undefined' && maxPrice.length > 0) {
1757								_thisObj.QStringWork('wpf_max_price', maxPrice, noWooPage, filterWrapper, 'change');
1758							} else {
1759								_thisObj.QStringWork('wpf_max_price', '', noWooPage, filterWrapper, 'remove');
1760							}
1761							if (typeof tax !== 'undefined') {
1762								_thisObj.QStringWork('tax', tax, noWooPage, filterWrapper, 'change');
1763							} else {
1764								_thisObj.QStringWork('tax', '', noWooPage, filterWrapper, 'remove');
1765							}
1766							priceFlag = false;
1767						}
1768						break;
1769					case 'wpfSortBy':
1770						var orderby = $filtersDataFrontend[i]['settings']['orderby'],
1771							oistock = $filtersDataFrontend[i]['settings']['oistock'];
1772						if (typeof orderby !== 'undefined' && orderby.length > 0 ) {
1773							_thisObj.QStringWork('orderby', orderby, noWooPage, filterWrapper, 'change');
1774						}else{
1775							_thisObj.QStringWork('orderby', '', noWooPage, filterWrapper, 'remove');
1776						}
1777						if (typeof oistock !== 'undefined' && oistock == 1 ) {
1778							_thisObj.QStringWork('wpf_oistock', 1, noWooPage, filterWrapper, 'change');
1779						}else{
1780							_thisObj.QStringWork('wpf_oistock', '', noWooPage, filterWrapper, 'remove');
1781						}
1782						break;
1783					case 'wpfCategory':
1784					case 'wpfPerfectBrand':
1785						var product_cat = $filtersDataFrontend[i]['settings']['settings'],
1786							name = $filtersDataFrontend[i]['name'],
1787							delim = $filtersDataFrontend[i]['delim'];
1788						product_cat = product_cat.join(delim ? delim : '|');
1789						if (typeof product_cat !== 'undefined' && product_cat.length > 0) {
1790							_thisObj.QStringWork(name, product_cat, noWooPage, filterWrapper, 'change');
1791						}else{
1792							_thisObj.QStringWork(name, '', noWooPage, filterWrapper, 'remove');
1793						}
1794						break;
1795					case 'wpfTags':
1796						var product_tag = $filtersDataFrontend[i]['settings']['settings'],
1797							name = $filtersDataFrontend[i]['name'],
1798							delim = $filtersDataFrontend[i]['delim'];
1799						product_tag = product_tag.join(delim ? delim : '|');
1800						if (typeof product_tag !== 'undefined' && product_tag.length > 0) {
1801							_thisObj.QStringWork(name, product_tag, noWooPage, filterWrapper, 'change');
1802						}else{
1803							_thisObj.QStringWork(name, '', noWooPage, filterWrapper, 'remove');
1804						}
1805						break;
1806					case 'wpfAttribute':
1807						var product_taxonomy = $filtersDataFrontend[i]['settings']['taxonomy'],
1808							product_attr = $filtersDataFrontend[i]['settings']['settings'],
1809							delim = $filtersDataFrontend[i]['delim'];
1810						product_attr = product_attr.join(delim ? delim : '|');
1811						if (typeof product_attr !== 'undefined' && product_attr.length > 0) {
1812							_thisObj.QStringWork(product_taxonomy, product_attr, noWooPage, filterWrapper, 'change');
1813						}else{
1814							_thisObj.QStringWork(product_taxonomy, '', noWooPage, filterWrapper, 'remove');
1815						}
1816
1817						if (typeof $filtersDataFrontend[i]['idBlock']!== 'undefined' && typeof $filtersDataFrontend[i]['idFilter']!== 'undefined' ) {
1818							_thisObj.QStringWork('group' + product_taxonomy.replace('filter', '') + $filtersDataFrontend[i]['idBlock'], $filtersDataFrontend[i]['idFilter'], noWooPage, filterWrapper, 'change');
1819						}
1820						break;
1821					case 'wpfAuthor':
1822						var authorVal = $filtersDataFrontend[i]['settings']['settings'],
1823							name = $filtersDataFrontend[i]['name'],
1824							delim = $filtersDataFrontend[i]['delim'];
1825							authorVal = authorVal.join(delim ? delim : '|');
1826						if (typeof authorVal !== 'undefined' && authorVal.length > 0) {
1827							_thisObj.QStringWork('pr_author', authorVal, noWooPage, filterWrapper, 'change');
1828						}else{
1829							_thisObj.QStringWork('pr_author', '', noWooPage, filterWrapper, 'remove');
1830						}
1831						break;
1832					case 'wpfFeatured':
1833						var featureVal = $filtersDataFrontend[i]['settings']['settings'];
1834						if (typeof featureVal !== 'undefined' && featureVal.length > 0) {
1835							_thisObj.QStringWork('pr_featured', featureVal, noWooPage, filterWrapper, 'change');
1836						}else{
1837							_thisObj.QStringWork('pr_featured', '', noWooPage, filterWrapper, 'remove');
1838						}
1839						break;
1840					case 'wpfOnSale':
1841						var onSaleVal = $filtersDataFrontend[i]['settings']['settings'];
1842						if (typeof onSaleVal !== 'undefined' && onSaleVal.length > 0) {
1843							_thisObj.QStringWork('pr_onsale', onSaleVal, noWooPage, filterWrapper, 'change');
1844						}else{
1845							_thisObj.QStringWork('pr_onsale', '', noWooPage, filterWrapper, 'remove');
1846						}
1847						break;
1848					case 'wpfInStock':
1849						var pr_stock = $filtersDataFrontend[i]['settings']['settings'];
1850						pr_stock = pr_stock.join(delim ? delim : '|');
1851						if (typeof pr_stock !== 'undefined' && pr_stock.length > 0 ) {
1852							_thisObj.QStringWork('pr_stock', pr_stock, noWooPage, filterWrapper, 'change');
1853						}else{
1854							_thisObj.QStringWork('pr_stock', '', noWooPage, filterWrapper, 'remove');
1855						}
1856						break;
1857					case 'wpfRating':
1858						var ratingVal = $filtersDataFrontend[i]['settings']['settings'];
1859						if (typeof ratingVal !== 'undefined' && checkArray(ratingVal) && ratingVal.length > 0 ) {
1860							_thisObj.QStringWork('pr_rating', ratingVal, noWooPage, filterWrapper, 'change');
1861						}else{
1862							_thisObj.QStringWork('pr_rating', '', noWooPage, filterWrapper, 'remove');
1863						}
1864						break;
1865					default:
1866						if(typeof(_thisObj.changeUrlByFilterParamsPro) == 'function') {
1867							_thisObj.changeUrlByFilterParamsPro($filtersDataFrontend[i], noWooPage, filterWrapper);
1868						}
1869						break;
1870				}
1871			}
1872		}else{
1873			return false;
1874		}
1875
1876	});
1877
1878	/**
1879	 * changeSlugByUrl.
1880	 *
1881	 * @version 2.8.6
1882	 */
1883	WpfFrontendPage.prototype.changeSlugByUrl = (function () {
1884		jQuery('.wpfSlugWrapper .wpfSlug').remove();
1885		var _thisObj = this.$obj,
1886			noWooPage = _thisObj.noWoo,
1887			searchParams = jQuery.toQueryParams(window.location.search);
1888		if (noWooPage) {
1889			if( jQuery('.wpfMainWrapper').first().attr('data-hide-url')) {
1890				searchParams =  jQuery.toQueryParams(jQuery('.wpfMainWrapper').first().attr('data-hide-url'));
1891			}
1892		}
1893
1894		var isRedirect = 'redirect' in searchParams && searchParams['redirect'] == 1;
1895
1896		for (var key in searchParams) {
1897			if(key === 'wpf_min_price'){
1898				key = 'wpf_min_price,wpf_max_price,tax';
1899			}
1900			var $elem = jQuery('.wpfFilterWrapper[data-get-attribute="'+key+'"]');
1901			if (!$elem.length && isRedirect) {
1902				var parts = key.split('_'),
1903					cnt = parts.length;
1904				if (cnt > 2 && isNumber(parts[cnt-1])) {
1905					parts.pop();
1906					$elem = jQuery('.wpfFilterWrapper[data-get-attribute^="'+parts.join('_')+'"]');
1907					_thisObj.QStringWork(key, '', false, $elem.closest('.wpfMainWrapper'), 'remove');
1908
1909				}
1910			}
1911			if($elem.length > 0) {
1912				var elem = $elem.first(),
1913					$slug = elem.attr('data-slug'),
1914					$label = elem.attr('data-label'),
1915					$title = elem.attr('data-title'),
1916					$getAttr = elem.attr('data-get-attribute'),
1917					$filterType = elem.attr('data-filter-type');
1918				if(typeof $title != 'undefined') $label = $title;
1919				else if(typeof $label == 'undefined') $label = $slug;
1920
1921				var html = '';
1922				if(jQuery('.wpfSlugWrapper').length > 0){
1923					if( !jQuery('.wpfSlugWrapper .wpfSlug[data-slug="'+$slug+'"]').length > 0 ) {
1924						html += '<div class="wpfSlug" data-slug="'+$slug+'" data-get-attribute="'+$getAttr+'" data-filter-type="'+$filterType+'"><div class="wpfSlugTitle">'+$label+'</div><div class="wpfSlugDelete">x</div></div>';
1925						jQuery('.wpfSlugWrapper').append(html);
1926					}
1927				}else{
1928					if( !jQuery('.wpfSlugWrapper .wpfSlug[data-slug="'+$slug+'"]').length > 0 ) {
1929						html += '<div class="wpfSlugWrapper">';
1930						html += '<div class="wpfSlug" data-slug="'+$slug+'" data-get-attribute="'+$getAttr+'" data-filter-type="'+$filterType+'"><div class="wpfSlugTitle">'+$label+'</div><div class="wpfSlugDelete">x</div></div>';
1931						html += '</div>';
1932						jQuery('.storefront-sorting').append(html);
1933					}
1934				}
1935			}
1936			if (isRedirect && history.pushState && app.wpfNewUrl != window.wpfOldUrl)  {
1937				history.pushState({state: 1, rand: Math.random(), wpf: true}, '', app.wpfNewUrl);
1938				app.wpfOldUrl = app.wpfNewUrl;
1939			}
1940		}
1941
1942	});
1943
1944	WpfFrontendPage.prototype.sendFiltersOptionsByAjax = (function ($filtersDataBackend, $queryVars, $filterSettings, $generalSettings, $woocommerceSettings, $shortcodeAttr) {
1945		var _thisObj = this.$obj,
1946			$wrapperSettings = [];
1947		if ( window.wpfAdminPage ) {
1948			return false;
1949		}
1950		_thisObj.currentAjaxJSLoaded = false;
1951		_thisObj.currentProductBlock = false;
1952
1953		if (_thisObj.filterLoadTypes[_thisObj.currentLoadId] && _thisObj.filterLoadTypes[_thisObj.currentLoadId] == 'reload') {
1954			location.reload();
1955			return;
1956		}
1957		var ajax_leave_products = $generalSettings && $generalSettings['settings'] && $generalSettings['settings']['ajax_leave_products'] == '1'
1958
1959		if (typeof $generalSettings !== 'undefined') {
1960			$wrapperSettings = $generalSettings['settings'];
1961		}
1962
1963		var customListSelector = $filterSettings['product_list_selector'],
1964			productListSelector = _thisObj.fixSelector(customListSelector, _thisObj.defaultProductSelector),
1965			productContainerSelector = _thisObj.fixSelector($filterSettings['product_container_selector'], ''),
1966			forceThemeTemplates = ($wrapperSettings['force_theme_templates'] == 1);
1967
1968		var productContainerElem = (productContainerSelector !== '')
1969			? jQuery(productContainerSelector)
1970			: jQuery(document);
1971
1972		if (productContainerElem.length === 0) {
1973			location.reload();
1974			return;
1975		}
1976
1977		var productListElem = jQuery(productListSelector, productContainerElem);
1978		if (productListElem.hasClass('wpfNoWooPage') || productListElem.closest('.wpfNoWooPage').length) {
1979			forceThemeTemplates = false;
1980		}
1981
1982		if (productListElem.length && (_thisObj.filterClick)) {
1983			if (_thisObj.enableFiltersLoaderPro && ajax_leave_products) {
1984				_thisObj.enableFiltersLoaderPro(_thisObj.currentLoadId, productListElem);
1985			} else {
1986				_thisObj.enableFiltersLoader(_thisObj.currentLoadId, productListElem);
1987			}
1988		}
1989
1990		var onlyRecount = false;
1991		if ($filterSettings === undefined) {
1992			$filterSettings = [];
1993		} else {
1994			if (!_thisObj.filterClick && $filterSettings.auto_update_filter && !$filterSettings.redirect_only_click) {
1995				onlyRecount = true;
1996			}
1997		}
1998
1999		var requestData =_thisObj.getAjaxRequestData($filtersDataBackend, $queryVars, $filterSettings, $generalSettings, $shortcodeAttr, $woocommerceSettings);
2000
2001		if (onlyRecount) {
2002			_thisObj.ajaxOnlyRecount(requestData, _thisObj.currentLoadId, $wrapperSettings);
2003			return;
2004		} else if (forceThemeTemplates || _thisObj.filterLoadTypes[_thisObj.currentLoadId] == 'force') {
2005			_thisObj.ajaxForceThemeTemplates(productContainerSelector, productListSelector, requestData, $wrapperSettings);
2006			return;
2007		}
2008
2009		/**
2010		 * There are some cases when we do not provide ajax functionlity
2011		 */
2012		if ( window.InfiniteScroll && window.InfiniteScroll.prototype ) {
2013			/**
2014			 * Flatsome theme compability
2015			 * We do not privide ajax functionlity with infinite scroll
2016			 *
2017			 * @link https://themeforest.net/item/flatsome-multipurpose-responsive-woocommerce-theme/5484319
2018			 */
2019			if (_thisObj.filterClick && jQuery('body').hasClass('theme-flatsome')) {
2020				location.reload();
2021				return;
2022			}
2023		}
2024		_thisObj.filterLoadTypes[_thisObj.currentLoadId] = 'ajax';
2025
2026		jQuery.sendFormWpf({
2027			data: requestData,
2028			onSuccess: function(res) {
2029                if (!res.error) {
2030					if ('fid' in res.data && toeInArray(res.data['fid'], _thisObj.lastFids) == -1) {
2031						return false;
2032					}
2033					if ('optionsHtml' in res.data) {
2034                        var optionsHtml = res.data['optionsHtml'];
2035
2036                        jQuery('.wpfMainWrapper .wpfFilterWrapper[data-order-key]').each(function() {
2037                            var $filter = jQuery(this),
2038                                orderKey = $filter.attr('data-order-key'),
2039                                $select = $filter.find('select');
2040
2041                            if (typeof optionsHtml[orderKey] !== 'undefined' && $select.length){
2042                                var selectedValues = [];
2043                                $select.find('option:selected').each(function() {
2044                                    selectedValues.push(jQuery(this).val());
2045                                });
2046
2047                                $select.html(optionsHtml[orderKey]);
2048
2049                                if (selectedValues.length) {
2050                                    $select.val(selectedValues);
2051                                }
2052
2053                            }
2054                        });
2055                    }
2056					if ('jscript' in res.data) {
2057						_thisObj.setAjaxJScript(res.data['jscript']);
2058					}
2059					if (_thisObj.filterClick) {
2060						if (customListSelector !== '' && productListElem.length) {
2061							var loopContainer = productListElem;
2062							loopContainer.html(res.data['productHtml']);
2063						} else {
2064							var catSelector = wpfGetSelector(res.data['categoryHtml'], true, _thisObj.defaultProductSelector, 1, false, productContainerElem),
2065								loopSelector = wpfGetSelector(res.data['loopStartHtml'], true, _thisObj.defaultProductSelector, 3, false, productContainerElem),
2066								loopContainer = jQuery(loopSelector, productContainerElem);
2067
2068							if (!loopContainer.length) {
2069								// trying to obtain loop container without dynamically change classes with numbers in it names
2070								loopSelector = wpfGetSelector(res.data['loopStartHtml'], true, _thisObj.defaultProductSelector, 3, true, productContainerElem);
2071								loopContainer = jQuery(loopSelector, productContainerElem);
2072							}
2073
2074							loopContainer.prev('.brand-description').remove();
2075							if (typeof res.data['beforeProductHtml'] !== 'undefined') {
2076								loopContainer.before('<div class="brand-description">' + res.data['beforeProductHtml'] + '</div>');
2077							}
2078							if (typeof jQuery('.product-categories-wrapper', productContainerElem) !== 'undefined' && jQuery('.product-categories-wrapper > ul.products', productContainerElem).length > 0) {
2079								//replace cats html
2080								if (res.data['categoryHtml'].length) {
2081									jQuery('.product-categories-wrapper > ul.products', productContainerElem).html(res.data['categoryHtml']);
2082								}
2083								//replace products html
2084								jQuery(_thisObj.defaultProductSelector, productContainerElem).eq(1).html(res.data['productHtml']);
2085							} else if (jQuery('.elementor-widget-container ul.products', productContainerElem).length > 0) {
2086								jQuery('.elementor-widget-container ul.products', productContainerElem).each(function () {
2087									if (!jQuery(this).find('.product-category').length) {
2088										jQuery(this).html(res.data['categoryHtml'] + res.data['productHtml']);
2089									}
2090								});
2091							} else if (jQuery('.woocommerce > .products[data-filterargs][data-innerargs]', productContainerElem).length > 0) {
2092								jQuery('.woocommerce > .products[data-filterargs][data-innerargs]', productContainerElem).html(res.data['categoryHtml'] + res.data['productHtml']);
2093							} else {
2094								if (!loopContainer.length) {
2095									if (!jQuery('.wpfMainWrapper', productContainerElem).attr('data-nowoo') !== typeof undefined
2096										&& !jQuery('.wpfMainWrapper', productContainerElem).attr('data-nowoo') !== false)
2097										_thisObj.ajaxForceThemeTemplates(productContainerSelector, productListSelector, requestData, $wrapperSettings);
2098									else {
2099										location.reload(true);
2100									}
2101									_thisObj.afterAjaxFiltering($wrapperSettings);
2102									return false;
2103								}
2104
2105								loopContainer.each(function () {
2106									//replace cats html
2107									jQuery(this).html(res.data['categoryHtml']);
2108									//replace products html
2109									jQuery(this).append(res.data['productHtml']);
2110								});
2111							}
2112						}
2113
2114						var countSelector = wpfGetSelector(res.data['resultCountHtml'], true, '.woocommerce-result-count', 1, false, productContainerElem),
2115							wooCount = jQuery(countSelector, productContainerElem);
2116						if (wooCount.length > 0) {
2117							wooCount.replaceWith(res.data['resultCountHtml']);
2118						}
2119
2120						var isLeerPagination = res.data['paginationHtml'] == '',
2121							paginationSelector = wpfGetSelector(res.data[isLeerPagination ? 'paginationLeerHtml' : 'paginationHtml'], false, '.woocommerce-pagination', 1, false, productContainerElem),
2122							wooPagination = jQuery(paginationSelector, productContainerElem),
2123							newPagination = res.data['paginationHtml'];
2124
2125						if (wooPagination.length > 0) {
2126							if (typeof _thisObj.paginationClasses == 'undefined') {
2127								_thisObj.paginationClasses = wooPagination.attr('class');
2128							}
2129							if (isLeerPagination) {
2130								wooPagination.css({'display': 'none'});
2131								wooPagination.empty();
2132							} else {
2133								wooPagination.replaceWith(newPagination);
2134							}
2135						} else if (!isLeerPagination) {
2136							var afterLoop = jQuery('.after-shop-loop', productContainerElem);
2137							if (afterLoop.length > 0) {
2138								afterLoop.prepend(newPagination);
2139							} else {
2140								wooCount = jQuery('.storefront-sorting ' + countSelector, productContainerElem);
2141								if (wooCount.length > 0) {
2142									wooCount.after(newPagination);
2143								} else {
2144									let shortcodeData = productContainerElem.find('span[data-shortcode-attribute]'),
2145										isPaginate = shortcodeData.length ? shortcodeData.data('shortcode-attribute').paginate : true;
2146									if (typeof isPaginate === 'undefined' || isPaginate) {
2147										loopContainer.eq(0).after(newPagination);
2148									}
2149								}
2150							}
2151						}
2152						if (typeof _thisObj.paginationClasses != 'undefined') {
2153							jQuery(paginationSelector, productContainerElem).attr('class', _thisObj.paginationClasses);
2154						}
2155						_thisObj.currentProductBlock = loopContainer.selector;
2156						if (!_thisObj.currentProductBlock) {
2157							loopContainer.addClass('wpfCurrentProductBlock');
2158							_thisObj.currentProductBlock = '.wpfCurrentProductBlock';
2159						}
2160                    }
2161
2162					_thisObj.afterAjaxFiltering($wrapperSettings);
2163					jQuery('.wpfLoaderLayout').hide();
2164				}
2165			}
2166		});
2167	});
2168
2169	WpfFrontendPage.prototype.ajaxForceThemeTemplates = (function (productContainerSelector, productListSelector, requestData, $wrapperSettings) {
2170		var _thisObj = this.$obj,
2171			curUrl = window.location.href,
2172			isContainer = (productContainerSelector != '');
2173
2174		_thisObj.filterLoadTypes[_thisObj.currentLoadId] = 'force';
2175
2176		jQuery.ajax({
2177			type: "GET",
2178			url: curUrl + (curUrl.indexOf('?') == -1 ? '?' : '&') + 'wpf_skip=1&wpf_fid=' + _thisObj.filteringId,
2179			cache: false,
2180			dataType: 'html',
2181			success: function(data){
2182				var block = '',
2183					foundContainer = false,
2184					noProducts = false,
2185					$loadedData = jQuery(data),
2186					$loadedJS = $loadedData.find('.wpfExistsTermsJS');
2187				if ($loadedJS.length) {
2188					if (toeInArray($loadedJS.eq(0).attr('data-fid'), _thisObj.lastFids) == -1) {
2189						return false;
2190					}
2191				}
2192
2193				if (isContainer) {
2194					block = jQuery(data).find(productContainerSelector);
2195				}
2196				if (block.length) {
2197					foundContainer = true;
2198				} else {
2199					block = jQuery(data).find(productListSelector);
2200				}
2201				var pageBlock = jQuery(isContainer && (foundContainer || block.length == 0) ? productContainerSelector : productListSelector);
2202                if (block.length == 0 || pageBlock.length == 0) {
2203                    if ($wrapperSettings.recalculate_filters === '1') {
2204                        var existsTermsJS = jQuery(data).find('.wpfExistsTermsJS').html();
2205                        _thisObj.setAjaxJScript(existsTermsJS);
2206                    }
2207                    if ($wrapperSettings.no_redirect_by_no_products === '1' && pageBlock.length > 0) {
2208                        block = jQuery('<div><div class="wpfNoProducts">' + $wrapperSettings.text_no_products + '</div></div>');
2209                        noProducts = true;
2210                    } else {
2211                        _thisObj.filterLoadTypes[_thisObj.currentLoadId] = 'reload';
2212						location.reload();
2213						return;
2214                    }
2215                }
2216                if ($wrapperSettings.recalculate_filters !== '1') {
2217                    _thisObj.ajaxOnlyRecount(requestData);
2218                }
2219
2220				_thisObj.currentProductBlock = (typeof pageBlock.selector !== 'undefined') ? pageBlock.selector : productListSelector ;
2221
2222				block.each(function (index, value) {
2223					var blockWhere = pageBlock.eq(index),
2224						blockWhat = jQuery(value);
2225
2226					if (!foundContainer && !noProducts) {
2227						blockWhere = blockWhere.parent();
2228						blockWhat = blockWhat.parent();
2229					}
2230					// some plugins save url parameters in input fields
2231					blockWhat.find('input[name="wpf_skip"]').remove();
2232
2233					blockWhere.html(blockWhat.html().replace(/wpf_skip=1/g, '').replace(/wpf_fid=[0-9]*/g, '').replace(/&amp;&amp;/g, '&amp;'));
2234
2235					// if pagination is not in the block to be replaced, we will try to find and replace it
2236					var paginationPageBlock = jQuery(blockWhere).find('.woocommerce-pagination');
2237					if (!paginationPageBlock.length) {
2238						var paginationPage = jQuery('.woocommerce-pagination');
2239						var paginationResponse = jQuery(data).find('.woocommerce-pagination');
2240						if (paginationResponse.length) {
2241							paginationResponse = paginationResponse.eq(0).html().replace(/wpf_skip=1/g, '').replace(/wpf_fid=[0-9]*/g, '').replace(/&amp;&amp;/g, '&amp;');
2242							if (paginationPage.length) {
2243								paginationPage.html(paginationResponse);
2244							} else {
2245								jQuery(blockWhere).parent().after('<nav class="woocommerce-pagination">' + paginationResponse + '</nav>');
2246							}
2247						} else if (paginationPage.length) {
2248							paginationPage.remove();
2249						}
2250					}
2251
2252					// if result count is not in the block to be replaced, we will try to find and replace it
2253					var resultCountBlock = jQuery(blockWhere).find('.woocommerce-result-count');
2254					var resultCountResponse = jQuery(data).find('.woocommerce-result-count');
2255					if (!resultCountBlock.length && resultCountResponse.length) {
2256						var resultCount = jQuery('.woocommerce-result-count');
2257						if (resultCount.length) {
2258							resultCount.replaceWith(resultCountResponse);
2259						}
2260					}
2261				});
2262				// for Divi archive loop
2263				var $styleObj = jQuery('style[id^="et-builder-module-design-"]');
2264				if ($styleObj.length == 1) {
2265					var $styleObjLoaded = $loadedData.find('style[id^="et-builder-module-design-"]');
2266					if ($styleObjLoaded.length == 0) $styleObjLoaded = $loadedData.filter('style[id^="et-builder-module-design-"]');
2267					if ($styleObjLoaded.length == 1) $styleObj.html($styleObjLoaded.html());
2268				}
2269
2270				_thisObj.afterAjaxFiltering($wrapperSettings);
2271				_thisObj.runReadyList();
2272				if ($wrapperSettings.recalculate_filters === '1') {
2273					var existsTermsJS = jQuery(data).find('.wpfExistsTermsJS').html();
2274					_thisObj.setAjaxJScript(existsTermsJS);
2275                }
2276
2277    		}
2278		});
2279
2280		return false;
2281	});
2282
2283	WpfFrontendPage.prototype.ajaxOnlyRecount = (function (requestData, filterId, $wrapperSettings) {
2284		var _thisObj = this.$obj;
2285
2286		if (!_thisObj.currentAjaxJSLoaded && requestData) {
2287			requestData['only_recound'] = 1;
2288
2289			if (typeof filterId !==  'undefined') {
2290				requestData['synchro_filter_id'] = filterId;
2291			}
2292
2293			jQuery.sendFormWpf({
2294				data: requestData,
2295				onSuccess: function (res) {
2296
2297					if (typeof $wrapperSettings !== 'undefined'
2298						&& typeof $wrapperSettings.filter_loader_icon_onload_enable !== 'undefined'
2299						&& Number($wrapperSettings.filter_loader_icon_onload_enable)) {
2300						hideFilterLoader(jQuery('#' + filterId));
2301					}
2302
2303					if (!res.error) {
2304
2305						if ('jscript' in res.data) {
2306							_thisObj.setAjaxJScript(res.data['jscript'], filterId);
2307						}
2308
2309					}
2310					_thisObj.removeOverlay();
2311				}
2312			});
2313		}
2314
2315	});
2316
2317	WpfFrontendPage.prototype.setAjaxJScript = (function(jscript, filterId){
2318		var _thisObj = this.$obj,
2319			filter = jQuery('#' + (typeof(filterId) == 'undefined' ? _thisObj.currentLoadId : filterId));
2320		if (filter.length && jscript != '') {
2321			var jsBlock = filter.find('.wpfAjaxJSBlock');
2322			if (jsBlock.length == 0) {
2323				jQuery('<div class="wpfAjaxJSBlock wpfHidden"></div>').appendTo(filter);
2324			}
2325			filter.find('.wpfAjaxJSBlock').html(jscript);
2326		}
2327		_thisObj.currentAjaxJSLoaded = true;
2328	});
2329	WpfFrontendPage.prototype.afterAjaxFiltering = (function($wrapperSettings){
2330		var _thisObj = this.$obj;
2331
2332		//if changed min/max price and we have wpfPrice filter
2333		//we need change slider
2334		_thisObj.getUrlParamsChangeFiltersValues();
2335
2336		_thisObj.disableFiltersLoader();
2337		_thisObj.removeOverlay();
2338		toggleClear();
2339
2340        // fix for OceanWP theme
2341		if ( jQuery('body').find('.products').hasClass('oceanwp-row') ) {
2342			var products = jQuery('body').find('.products'),
2343				aligns = ['center', 'left', 'right'];
2344			products.find('li:first').addClass('col');
2345			for (var i = 1; i <= 7; i++) {
2346				if (products.find('li').hasClass('span_1_of_' + i)) {
2347					products.find('li:first').addClass('span_1_of_' + i);
2348					break;
2349				}
2350			}
2351			for (var j = 0; j < aligns.length; j++) {
2352    			if (products.find('li').hasClass('owp-content-' + aligns[j])) {
2353					products.find('li:first').addClass('owp-content-' + aligns[j]);
2354					break;
2355				}
2356			}
2357		}
2358
2359		_thisObj.changeLmpButton();
2360
2361		// for yith quick view
2362		jQuery(document).trigger('yith_wcqv_wcajaxnav_update');
2363
2364		if (typeof (_thisObj.scrollToProductsPro) == 'function') {
2365			_thisObj.scrollToProductsPro($wrapperSettings);
2366		}
2367
2368		if (jQuery(_thisObj.defaultProductSelector).closest('.et_pb_shop').length && jQuery(_thisObj.defaultProductSelector).find('[loading="lazy"]').length == 0) {
2369			heightIdenticalInRow('.et_pb_shop li.product');
2370		}
2371
2372		// Improve compatibility with 'Woocommerce Products Per Page'
2373		jQuery('.form-wppp-select').each( function () {
2374			var $form = jQuery(this);
2375			$form.attr('action', jQuery('#'+_thisObj.currentLoadId).attr('data-hide-url'));
2376			$form.find('input[type="hidden"]').remove();
2377		});
2378		// Improve compatibility with Theme Bricks + Bricks Builder
2379		if (typeof(bricksLazyLoad) == 'function') {
2380			bricksLazyLoad();
2381		}
2382
2383		// event for custom javascript hook, example: document.addEventListener('wpfAjaxSuccess', function(event) {console.log('Custom js');});
2384		//document.dispatchEvent(new Event('wpfAjaxSuccess')); - not work in IE11
2385		var customEvent = document.createEvent('Event');
2386		customEvent.initEvent('wpfAjaxSuccess', false, true);
2387		document.dispatchEvent(customEvent);
2388	});
2389
2390	WpfFrontendPage.prototype.runReadyList = (function(){
2391		if (window.readyList && readyList.length) {
2392			var _thisObj = this.$obj;
2393			if (_thisObj.disableScrollJs) {
2394				jQuery(window).off("yith_infs_start").off("scroll touchstart");
2395				if (typeof(jQuery.fn) == 'object' && typeof(jQuery.fn.init_infinitescroll) == 'function') {
2396					jQuery.fn.init_infinitescroll();
2397				}
2398			}
2399			jQuery(window.readyList).each(function(i, el) {
2400				var strFunc = el['a'][0].toString();
2401				if (strFunc.indexOf('WpfFrontendPage') == -1) {
2402					for(var i = 0; i < _thisObj.readyFuncs.length; i++) {
2403						if (strFunc.indexOf(_thisObj.readyFuncs[i]) != -1 && (strFunc.indexOf('.ajaxComplete(') == -1 || i == 3 || i == 4)) {
2404							try {
2405								window.originalReadyMethod.apply(el['c'], el['a']);
2406							} catch(e) {
2407								console.log(e);
2408							}
2409							break;
2410						}
2411					}
2412				}
2413            });
2414		}
2415		jQuery(window).trigger("fusion-element-render-fusion_woo_product_grid");
2416		var fusionPrInfinite = jQuery(".fusion-products-container-infinite");
2417		if (fusionPrInfinite.length && typeof(fusionPrInfinite.infinitescroll) == 'function') {
2418			fusionPrInfinite.infinitescroll('unbind');
2419			fusionPrInfinite.infinitescroll('bind');
2420		}
2421
2422        if (typeof elementorFrontend !== 'undefined') {
2423            jQuery(window).trigger('resize');
2424
2425            var $eaPagination = jQuery('.elementor-widget-eicon-woocommerce');
2426            if ($eaPagination.length && window.elementorFrontend && window.elementorFrontend.hooks) {
2427                window.elementorFrontend.hooks.doAction('frontend/element_ready/eicon-woocommerce.default', $eaPagination, jQuery);
2428            }
2429        }
2430
2431		// AVADA infinitescroll
2432		if (jQuery('.fusion-grid-container-infinite').length == 1) {
2433			jQuery(document).trigger('fusion-element-render-fusion_post_cards');
2434			jQuery('.fusion-grid-container-infinite').infinitescroll('unbind');
2435			jQuery('.fusion-grid-container-infinite').infinitescroll('bind');
2436        }
2437	});
2438
2439	/*WpfFrontendPage.prototype.runReadyList = (function(){
2440		if (window.readyList && window.readyList.length) {
2441
2442			jQuery(window.readyList).each(function(i, el) {
2443				var strFunc = el['a'][0].toString();
2444				if (strFunc.indexOf('WpfFrontendPage') == -1 && strFunc.indexOf('.ajaxComplete(') == -1) {
2445					try {
2446						window.originalReadyMethod.apply(el['c'], el['a']);
2447					} catch(e) {
2448						console.log(e);
2449					}
2450				}
2451			});
2452		}
2453	});*/
2454
2455	WpfFrontendPage.prototype.enableFiltersLoader = (function(idWrapper, productListElem){
2456		var preview = jQuery('#' + idWrapper + ' .wpfPreviewLoader').first().clone().removeClass('wpfHidden');
2457		productListElem.html(preview);
2458	});
2459
2460	WpfFrontendPage.prototype.disableFiltersLoader =(function(){
2461		jQuery('.wpfPreviewLoader').first().clone().addClass('wpfHidden');
2462	});
2463
2464	//after load change price and price range filters params if find get params
2465	WpfFrontendPage.prototype.getUrlParamsChangeFiltersValues = (function(){
2466		var _thisObj = this.$obj,
2467			noWooPage = _thisObj.noWoo;
2468		if(noWooPage){
2469			var curUrl = jQuery('.wpfMainWrapper').first().attr('data-hide-url');
2470		}else{
2471			var curUrl = window.location.href;
2472		}
2473		if(!curUrl){
2474			return;
2475		}
2476		//get all get params
2477		var urlParams = _thisObj.findGetParameter(curUrl);
2478		jQuery('.wpfFilterWrapper').each(function () {
2479			var $filter = jQuery(this),
2480				filterType = $filter.attr('data-filter-type'),
2481				settings = _thisObj.getFilterMainSettings($filter.closest('.wpfMainWrapper'));
2482
2483			switch(filterType){
2484				case 'wpfAttribute':
2485					if(typeof(_thisObj.eventChangeFilterPro) == 'function') {
2486						_thisObj.eventChangeFilterPro($filter, settings);
2487					}
2488					break;
2489				case 'wpfPrice':
2490					var rate = $filter.data('rate');
2491					urlParams = _thisObj.getConvertedPrices(urlParams, rate);
2492					var minPrice = urlParams.wpf_min_price ? urlParams.wpf_min_price : $filter.attr('data-minvalue'),
2493						maxPrice = urlParams.wpf_max_price ? urlParams.wpf_max_price : $filter.attr('data-maxvalue'),
2494						skin = 'default';
2495
2496					if(minPrice){
2497						$filter.find('#wpfMinPrice').val(minPrice);
2498					}
2499					if(maxPrice){
2500						$filter.find('#wpfMaxPrice').val(maxPrice);
2501					}
2502					if(settings){
2503						skin = $filter.attr('data-price-skin');
2504					}
2505					if(skin === 'default'){
2506						var sliderWrapper = $filter.find("#wpfSliderRange");
2507					}else{
2508						var sliderCurBefore = ($filter.attr('data-slider-currency-before') != undefined) ? $filter.attr('data-slider-currency-before') : '';
2509						var sliderCurAfter = ($filter.attr('data-slider-currency-after') != undefined) ? $filter.attr('data-slider-currency-after') : '';
2510						var sliderWrapper = $filter.find('.ion-range-slider').data('ionRangeSlider');
2511						$filter.addClass('wpfNotActiveSlider');
2512
2513						if (sliderCurBefore || sliderCurAfter) {
2514							setTimeout(function()
2515							{
2516								$filter.find('span.irs-min:first').html(sliderCurBefore + sliderWrapper['result'].min_pretty + sliderCurAfter);
2517								$filter.find('span.irs-max:first').html(sliderCurBefore + sliderWrapper['result'].max_pretty + sliderCurAfter);
2518								$filter.find('span.irs-from:first').html(sliderCurBefore + sliderWrapper['result'].from_pretty + sliderCurAfter);
2519								$filter.find('span.irs-to:first').html(sliderCurBefore + sliderWrapper['result'].to_pretty + sliderCurAfter);
2520							}, 500);
2521						}
2522					}
2523					if(minPrice && maxPrice){
2524						if(skin === 'default'){
2525							sliderWrapper.slider({
2526								values: [minPrice, maxPrice]
2527							});
2528						}else if(typeof(sliderWrapper) != 'undefined') {
2529							sliderWrapper.update({from: minPrice, to: maxPrice});
2530							$filter.removeClass('wpfNotActiveSlider');
2531						}
2532					}
2533					_thisObj.chageRangeFieldWidth();
2534					if(typeof(_thisObj.eventChangeFilterPro) == 'function') {
2535						_thisObj.eventChangeFilterPro($filter, settings);
2536					}
2537					break;
2538				case 'wpfPriceRange':
2539					var rate = $filter.data('rate');
2540					urlParams = _thisObj.getConvertedPrices(urlParams, rate);
2541					var minPrice = urlParams.wpf_min_price ? parseFloat(urlParams.wpf_min_price) : false,
2542						maxPrice = urlParams.wpf_max_price ? parseFloat(urlParams.wpf_max_price) : false,
2543						$options = $filter.find('li');
2544					$options.find('input[type="checkbox"]').prop('checked', false);
2545					$options.each(function () {
2546						var _this = jQuery(this),
2547							range = _this.attr('data-range');
2548						if(typeof range != 'undefined') {
2549							range = range.split(',');
2550							var minRange = range[0] == '' ? false : parseFloat(range[0]),
2551								maxRange = range[1] == '' ? false : parseFloat(range[1]),
2552								minPrices = [minPrice - 1, minPrice, minPrice + 1], // rounding error correction
2553								maxPrices = [maxPrice - 1, maxPrice, maxPrice + 1]; // rounding error correction
2554
2555							if(minPrices.includes(minRange) && maxPrices.includes(maxRange)){
2556								_this.find('input[type="checkbox"]').prop('checked', true);
2557								return false;
2558							}
2559						}
2560					});
2561					if(typeof(_thisObj.eventChangeFilterPro) == 'function') {
2562						_thisObj.eventChangeFilterPro($filter, settings);
2563					}
2564					break;
2565			}
2566		});
2567
2568	});
2569
2570	WpfFrontendPage.prototype.findGetParameter =(function(url){
2571		// This function is anonymous, is executed immediately and
2572		// the return value is assigned to QueryString!
2573		var query_string = {},
2574			usefulParam = url.split("?")[1] || "",
2575			query = usefulParam || "",
2576			vars = query.split("&");
2577
2578		for (var i = 0; i < vars.length; i++) {
2579			var pair = vars[i].split("=");
2580
2581			// If first entry with this name
2582			if (typeof query_string[pair[0]] === "undefined") {
2583				query_string[pair[0]] = decodeURIComponent(pair[1]);
2584				// If second entry with this name
2585			} else if (typeof query_string[pair[0]] === "string") {
2586				var arr = [query_string[pair[0]], decodeURIComponent(pair[1])];
2587				query_string[pair[0]] = arr;
2588				// If third or later entry with this name
2589			} else {
2590				query_string[pair[0]].push(decodeURIComponent(pair[1]));
2591			}
2592		}
2593		return query_string;
2594	});
2595
2596	WpfFrontendPage.prototype.getClearLabel = (function (label, withCount) {
2597		if(withCount) {
2598			var cnt = label.lastIndexOf('(');
2599			if(cnt == -1) cnt = label.lastIndexOf('<span');
2600			if(cnt != -1) label = label.substring(0, cnt).trim();
2601		}
2602
2603		label = label.replace(/&nbsp;/g,'');
2604
2605		return label;
2606	});
2607
2608	WpfFrontendPage.prototype.getFilterOptionsByType = (function($filter, filterType){
2609		var _thisObj = this.$obj;
2610		return _thisObj['get' + filterType.replace('wpf', '') + 'FilterOptions']($filter);
2611	});
2612
2613	WpfFrontendPage.prototype.getPriceFilterOptions = (function ($filter) {
2614		var _thisObj = this.$obj,
2615			optionsArray = [],
2616			options = [],
2617			minPrice = $filter.find('#wpfMinPrice').val(),
2618			maxPrice = $filter.find('#wpfMaxPrice').val(),
2619			tax = $filter.data('tax'),
2620			rate = $filter.data('rate'),
2621			str = '';
2622
2623		[minPrice, maxPrice, tax] = _thisObj.getConvertedPrices([minPrice, maxPrice, tax], rate);
2624		str = minPrice + ',' + maxPrice;
2625		options.push(str);
2626
2627		//options for frontend(change url)
2628		var frontendOptions = [],
2629			getParams = $filter.attr('data-get-attribute');
2630		frontendOptions['rate'] = rate;
2631
2632		getParams = getParams.split(",");
2633		for (var i = 0; i < getParams.length; i++) {
2634			if (i === 0) {
2635				frontendOptions[getParams[i]] = minPrice;
2636			}
2637			if (i === 1) {
2638				frontendOptions[getParams[i]] = maxPrice;
2639			}
2640			if (i === 2 && tax !== '') {
2641				frontendOptions[getParams[i]] = tax;
2642			}
2643		}
2644		var symbol = $filter.find('.wpfCurrencySymbol'),
2645			symbolB = symbol.length && !symbol.is(':last-child') ? symbol.html() : '',
2646			symbolA = symbol.length && symbol.is(':last-child') ? symbol.html() : '',
2647			selectedOptions = {'is_one': true, 'list': [symbolB + minPrice + symbolA + ' - ' + symbolB + maxPrice + symbolA]};
2648
2649		optionsArray['backend'] = options;
2650		optionsArray['frontend'] = frontendOptions;
2651		optionsArray['selected'] = selectedOptions;
2652		optionsArray['stats'] = [[minPrice, maxPrice]];
2653
2654		return optionsArray;
2655	});
2656
2657	WpfFrontendPage.prototype.getPriceRangeFilterOptions = (function ($filter) {
2658		var _thisObj = this.$obj,
2659			optionsArray = [],
2660			options = [],
2661			frontendOptions = [],
2662			selectedOptions = {'is_one': true, 'list': []},
2663			statistics = [],
2664			i = 0,
2665			rate = $filter.data('rate');
2666
2667		if ($filter.attr('data-display-type') === 'list') {
2668			if ($filter.find("input:checked").length) {
2669				var li = $filter.find('input:checked').closest('li');
2670				options[i] = li.attr('data-range');
2671				selectedOptions['list'][i] = li.find('.wpfValue').html();
2672			}
2673		}else if($filter.attr('data-display-type') === 'dropdown'){
2674			if($filter.find(":selected").attr('data-range')){
2675				var option = $filter.find(":selected");
2676				options[i] = option.attr('data-range');
2677				selectedOptions['list'][i] = option.html();
2678			}
2679
2680		}
2681
2682		//options for frontend(change url)
2683		if (typeof options !== 'undefined' && options.length > 0) {
2684			var getParams = $filter.attr('data-get-attribute'),
2685				tax = $filter.data('tax');
2686			frontendOptions['rate'] = rate;
2687			getParams = getParams.split(",");
2688			if (typeof options[0] !== 'undefined' && options[0].length > 0) {
2689				var prices = options[0].split(',');
2690				[prices[0], prices[1], tax] = _thisObj.getConvertedPrices([prices[0], prices[1], tax], rate);
2691				frontendOptions[getParams[0]] = prices[0];
2692				frontendOptions[getParams[1]] = prices[1];
2693				if (typeof tax !== 'undefined') {
2694					frontendOptions[getParams[2]] = tax;
2695				}
2696			}
2697		}
2698		if (options.length == 0) {
2699			var defRange = $filter.attr('data-default');
2700			if (typeof defRange != 'undefined' && defRange.length) {
2701				options[i] = defRange;
2702			}
2703		}
2704
2705		if (typeof rate !== 'undefined') {
2706			var minPrice = '',
2707				maxPrice = '';
2708			options = options.map(function (elem) {
2709				[minPrice, maxPrice] = _thisObj.getConvertedPrices(elem.split(","), rate);
2710				return minPrice + ',' + maxPrice;
2711			});
2712		}
2713
2714		if (options.length) {
2715			statistics = options.map(function (elem) {
2716				return elem.split(",");
2717			});
2718		}
2719		optionsArray['backend'] = options;
2720		optionsArray['frontend'] = frontendOptions;
2721		optionsArray['selected'] = selectedOptions;
2722		optionsArray['stats'] = statistics;
2723
2724		return optionsArray;
2725	});
2726
2727	WpfFrontendPage.prototype.getSortByFilterOptions = (function ($filter) {
2728		var optionsArray = [],
2729			options = [],
2730			frontendOptions = [],
2731			selectedOptions = {'is_one': true, 'list': []},
2732			value = '';
2733		if ($filter.data('display-type') === 'radio') {
2734			var elem = $filter.find('input:checked').closest('li'),
2735				name = elem.find('.wpfFilterTaxNameWrapper').html();
2736		} else {
2737			var elem = $filter.find('select:not(.wpfPerPageDD)').find('option:selected'),
2738				name = elem.html();
2739		}
2740		if (elem.length) {
2741			value = elem.data('term-slug');
2742			//options for backend (filtering)
2743			options.push(value);
2744
2745			//options for frontend(change url)
2746			var getParams = $filter.attr('data-get-attribute');
2747			frontendOptions[getParams] = value;
2748			selectedOptions['list'][0] = name;
2749			optionsArray['stats'] = [name];
2750		}
2751		if ($filter.data('first-instock') == '1') {
2752			frontendOptions['oistock'] = 1;
2753			options.push('oistock');
2754		}
2755
2756		optionsArray['backend'] = options;
2757		optionsArray['frontend'] = frontendOptions;
2758		optionsArray['selected'] = selectedOptions;
2759		return optionsArray;
2760	});
2761
2762	WpfFrontendPage.prototype.getInStockFilterOptions = (function ($filter) {
2763		var optionsArray = [],
2764			frontendOptions = [],
2765			options = [],
2766			filterType = $filter.attr('data-display-type'),
2767			selectedOptions = {'is_one': (filterType === 'dropdown'), 'list': []},
2768			statistics = [],
2769			i = 0;
2770
2771		//options for backend (filtering)
2772		if(filterType === 'dropdown'){
2773			var option = $filter.find(":selected"),
2774				value = option.attr('data-slug');
2775			if(value != '') {
2776				options[i] = value;
2777				frontendOptions[i] = value;
2778				var name = option.html();
2779				selectedOptions['list'][i] = name;
2780				statistics.push(name);
2781			}
2782		} else {
2783			$filter.find('input:checked').each(function () {
2784				var li = jQuery(this).closest('li'),
2785					slug = li.attr('data-term-slug'),
2786					name = li.find('.wpfFilterTaxNameWrapper').length ? li.find('.wpfFilterTaxNameWrapper').html() : li.find('.wpfValue').html();
2787				options[i] = slug;
2788				frontendOptions[i] = slug;
2789				selectedOptions['list'][li.attr('data-term-id')] = name;
2790				statistics.push(name);
2791				i++;
2792			});
2793		}
2794		optionsArray['backend'] = options;
2795
2796		//options for frontend(change url)
2797		var getParams = $filter.attr('data-get-attribute');
2798
2799		optionsArray['frontend'] = [];
2800		optionsArray['frontend']['taxonomy'] = getParams;
2801		optionsArray['frontend']['settings'] = frontendOptions;
2802		optionsArray['selected'] = selectedOptions;
2803		optionsArray['stats'] = statistics;
2804
2805		return optionsArray;
2806	});
2807
2808	WpfFrontendPage.prototype.getCategoryFilterOptions = (function ($filter) {
2809		var _thisObj = this.$obj,
2810			optionsArray = [],
2811			frontendOptions = [],
2812			options = [],
2813			filterType = $filter.attr('data-display-type'),
2814			useSlugs = $filter.attr('data-use-slugs') == '1',
2815			selectedOptions = {'is_one': (filterType == 'list' || filterType == 'dropdown'), 'list': []},
2816			statistics = [],
2817			i = 0;
2818
2819		//options for backend (filtering)
2820		if(filterType === 'dropdown'){
2821			var option = $filter.find(":selected"),
2822				id = option.attr('data-term-id'),
2823				value = option.val();
2824			if(value != '') {
2825				options[i] = value;
2826				var name = _thisObj.getClearLabel(option.html(), $filter.hasClass('wpfShowCount'));
2827				selectedOptions['list'][id] = name;
2828				statistics.push(name);
2829			}
2830			frontendOptions[i] = (useSlugs ? option.attr('data-term-slug') : id);
2831		} else if(filterType === 'mul_dropdown'){
2832			$filter.find(':selected').each(function () {
2833				var option = jQuery(this),
2834					id = option.attr('data-term-id');
2835				options[i] = option.val();
2836				frontendOptions[i] = (useSlugs ? option.attr('data-term-slug') : id);
2837				var name = _thisObj.getClearLabel(option.html(), $filter.hasClass('wpfShowCount'));
2838				selectedOptions['list'][id] = name;
2839				statistics.push(name);
2840				i++;
2841			});
2842		} else {
2843			var removeSelectedList = [];
2844			$filter.find('input').each(function () {
2845				var inputCurent = jQuery(this),
2846					liCurent = inputCurent.closest('li'),
2847					id = liCurent.data('term-id'),
2848					isParent = liCurent.children('ul').length > 0,
2849					isChecked = inputCurent.is(':checked'),
2850					hierarchicalLogic = $filter.attr('data-logic-hierarchical'),
2851					type = $filter.attr('data-display-type'),
2852					isHierarchical = $filter.attr('data-show-hierarchical'),
2853					isHierarchicalLogic = isHierarchical === 'true' && type === 'multi' || type === 'text';
2854
2855				if ( isParent ) {
2856					var isAllChildChecked = true,
2857						childList = [];
2858
2859					liCurent.find('ul li').each(function() {
2860						var childId = jQuery(this).data('term-id'),
2861							childLi = jQuery(this),
2862							childInput = childLi.find('input'),
2863							isChildChecked = childInput.prop('checked');
2864
2865						childList.push(childId);
2866
2867						if (!isChildChecked) {
2868							isAllChildChecked = false;
2869							return false;
2870						}
2871					});
2872
2873					if (isChecked && isAllChildChecked) {
2874						removeSelectedList = removeSelectedList.concat(childList);
2875
2876						var onlyUnique = function(value, index, self) {
2877							return self.indexOf(value) === index;
2878						}
2879
2880						removeSelectedList = removeSelectedList.filter( onlyUnique );
2881						selectedOptions.removeSelected = removeSelectedList;
2882					}
2883				}
2884
2885				if (jQuery(this).is(':checked')) {
2886					if ( isHierarchicalLogic && hierarchicalLogic == 'child' ) {
2887						var liElements = liCurent.find('li'),
2888							isChildChicked = false;
2889
2890						for (var j = 0; j < liElements.length; ++j) {
2891							 var li = liElements[j];
2892							if (jQuery(li).find('input').prop('checked')) {
2893								isChildChicked = true;
2894							}
2895						}
2896						if (!isChildChicked) {
2897							options[i] = id;
2898							frontendOptions[i] = (useSlugs ? liCurent.attr('data-term-slug') : id);
2899						}
2900					} else if(isHierarchicalLogic && hierarchicalLogic == 'parent') {
2901						var parents = liCurent.parents('li'),
2902							isChildChicked = false;
2903
2904						for (var j = 0; j < parents.length; ++j) {
2905							 var li = parents[j];
2906							if (jQuery(li).find('input').prop('checked')) {
2907								isChildChicked = true;
2908							}
2909						}
2910						if (!isChildChicked) {
2911							options[i] = id;
2912							frontendOptions[i] = (useSlugs ? liCurent.attr('data-term-slug') : id);
2913						}
2914					} else {
2915						options[i] = id;
2916						frontendOptions[i] = (useSlugs ? liCurent.attr('data-term-slug') : id);
2917					}
2918					var name = liCurent.find('.wpfValue').html();
2919					selectedOptions['list'][id] = name;
2920					statistics.push(liCurent.find('.wpfFilterTaxNameWrapper:first').length ? liCurent.find('.wpfFilterTaxNameWrapper:first').html() : name);
2921					i++;
2922				}
2923			});
2924		}
2925
2926		var options = options.filter(function (el) {
2927			return el != null;
2928		});
2929		var frontendOptions = frontendOptions.filter(function (el) {
2930			return el != null;
2931		});
2932
2933
2934		optionsArray['backend'] = options;
2935
2936		//options for frontend(change url)
2937		var getParams = $filter.attr('data-get-attribute');
2938
2939		optionsArray['frontend'] = [];
2940		optionsArray['frontend']['taxonomy'] = getParams;
2941		optionsArray['frontend']['settings'] = frontendOptions;
2942		optionsArray['selected'] = selectedOptions;
2943		optionsArray['stats'] = statistics;
2944
2945		return optionsArray;
2946	});
2947
2948	WpfFrontendPage.prototype.getPerfectBrandFilterOptions = (function ($filter) {
2949		return this.$obj.getCategoryFilterOptions($filter);
2950	});
2951
2952	WpfFrontendPage.prototype.getTagsFilterOptions = (function ($filter) {
2953		var _thisObj = this.$obj,
2954			optionsArray = [],
2955			options = [],
2956			frontendOptions = [],
2957			filterType = $filter.attr('data-display-type'),
2958			selectedOptions = {'is_one': (filterType == 'dropdown'), 'list': []},
2959			statistics = [],
2960			withCount = $filter.hasClass('wpfShowCount'),
2961			i = 0,
2962			proFilterType = [
2963				'colors'
2964			];
2965
2966		//options for backend (filtering)
2967		if(filterType === 'dropdown'){
2968			var option = $filter.find(":selected"),
2969				value = option.val();
2970			if(value != '') {
2971				options[i] = value;
2972				frontendOptions[i] = option.attr('data-slug');
2973				var name = _thisObj.getClearLabel(option.html(), withCount);
2974				selectedOptions['list'][option.attr('data-term-id')] = name;
2975				statistics.push(name);
2976			}
2977		} else if (filterType === 'mul_dropdown'){
2978			$filter.find(':selected').each(function () {
2979				var option = jQuery(this);
2980				options[i] = option.val();
2981				frontendOptions[i] = option.attr('data-slug');
2982				var name = _thisObj.getClearLabel(option.html(), withCount);
2983				selectedOptions['list'][option.attr('data-term-id')] = name;
2984				statistics.push(name);
2985				i++;
2986			});
2987		} else if (jQuery.inArray(filterType, proFilterType) == -1 ) {
2988			$filter.find('input:checked').each(function () {
2989				var li = jQuery(this).closest('li'),
2990					id = li.attr('data-term-id');
2991				options[i] = id;
2992				frontendOptions[i] = li.attr('data-term-slug');
2993				var name = li.find('.wpfValue').html();
2994				selectedOptions['list'][id] = name;
2995				statistics.push(li.find('.wpfFilterTaxNameWrapper').length ? li.find('.wpfFilterTaxNameWrapper').html() : name);
2996				i++;
2997			});
2998		}
2999
3000		var data = {
3001			options : options,
3002			frontendOptions : frontendOptions,
3003			selectedOptions : selectedOptions,
3004			statistics : statistics,
3005			i : i,
3006		}
3007
3008		if (typeof window.wpfFrontendPage.getTagsFilterOptionsPro == 'function') {
3009			data = window.wpfFrontendPage.getTagsFilterOptionsPro($filter, data);
3010		}
3011
3012		optionsArray['backend'] = data.options;
3013
3014		//options for frontend(change url)
3015		var getParams = $filter.attr('data-get-attribute');
3016
3017		optionsArray['frontend'] = [];
3018		optionsArray['frontend']['taxonomy'] = getParams;
3019		optionsArray['frontend']['settings'] = data.frontendOptions;
3020		optionsArray['selected'] = data.selectedOptions;
3021		optionsArray['stats'] = data.statistics;
3022
3023		return optionsArray;
3024	});
3025
3026	WpfFrontendPage.prototype.getAttributeFilterOptions = (function ($filter) {
3027		var _thisObj = this.$obj,
3028			optionsArray = [],
3029			options = [],
3030			frontendOptions = [],
3031			filterType = $filter.attr('data-display-type'),
3032			selectedOptions = {'is_one': (filterType == 'dropdown'), 'list': []},
3033			statistics = [],
3034			withCount = $filter.hasClass('wpfShowCount'),
3035			i = 0,
3036			proFilterType = [
3037				'slider',
3038				'colors'
3039			];
3040
3041		//options for backend (filtering)
3042		if (filterType === 'dropdown'){
3043			var option = $filter.find(":selected"),
3044				value = option.val();
3045			if (value != '') {
3046				options[i] = value;
3047				frontendOptions[i] = option.attr('data-slug');
3048				var name = _thisObj.getClearLabel(option.html(), withCount);
3049				selectedOptions['list'][option.attr('data-term-id')] = name;
3050				statistics.push(name);
3051			}
3052		} else if (filterType === 'mul_dropdown'){
3053			$filter.find(':selected').each(function () {
3054				var option = jQuery(this);
3055				options[i] = option.val();
3056				frontendOptions[i] = option.attr('data-slug');
3057				var name = _thisObj.getClearLabel(option.html(), withCount);
3058				selectedOptions['list'][option.attr('data-term-id')] = name;
3059				statistics.push(name);
3060				i++;
3061			});
3062		} else if (jQuery.inArray(filterType, proFilterType) == -1 ) {
3063			$filter.find('input:checked').each(function () {
3064				var li = jQuery(this).closest('li'),
3065					id = li.attr('data-term-id');
3066				options[i] = id;
3067				frontendOptions[i] = li.attr('data-term-slug');
3068				var name = li.find('.wpfValue').html();
3069				selectedOptions['list'][id] = name;
3070				statistics.push(li.find('.wpfFilterTaxNameWrapper').length ? li.find('.wpfFilterTaxNameWrapper').html() : name);
3071				i++;
3072			});
3073		}
3074
3075		var data = {
3076			options : options,
3077			frontendOptions : frontendOptions,
3078			selectedOptions : selectedOptions,
3079			statistics : statistics,
3080			i : i,
3081		}
3082
3083		if (typeof window.wpfFrontendPage.getAttributeFilterOptionsPro == 'function') {
3084			data = window.wpfFrontendPage.getAttributeFilterOptionsPro($filter, data);
3085		}
3086
3087		optionsArray['backend'] = data.options;
3088
3089		//options for frontend(change url)
3090		var getParams = $filter.attr('data-get-attribute');
3091
3092		optionsArray['frontend'] = [];
3093		optionsArray['frontend']['taxonomy'] = getParams;
3094		optionsArray['frontend']['settings'] = data.frontendOptions;
3095		optionsArray['selected'] = data.selectedOptions;
3096		optionsArray['stats'] = data.statistics;
3097
3098		return optionsArray;
3099	});
3100
3101	WpfFrontendPage.prototype.getAuthorFilterOptions = (function ($filter) {
3102		var _thisObj = this.$obj,
3103			optionsArray = [],
3104			options = [],
3105			frontendOptions = [],
3106			filterType = $filter.attr('data-display-type'),
3107			selectedOptions = {'is_one': (filterType == 'dropdown'), 'list': []},
3108			statistics = [],
3109			i = 0;
3110
3111		//options for backend (filtering)
3112		if(filterType === 'list'){
3113			$filter.find('input:checked').each(function () {
3114				var li = jQuery(this).closest('li'),
3115					id = li.attr('data-term-id');
3116				options[i] = id;
3117				frontendOptions[i] = li.attr('data-term-slug');
3118				var name = li.find('.wpfValue').html();
3119				selectedOptions['list'][id] = name;
3120				statistics.push(li.find('.wpfFilterTaxNameWrapper').length ? li.find('.wpfFilterTaxNameWrapper').html() : name);
3121				i++;
3122			});
3123		} else if (filterType === 'mul_dropdown'){
3124			$filter.find(':selected').each(function () {
3125				var option = jQuery(this);
3126				options[i] = option.val();
3127				frontendOptions[i] = option.attr('data-slug');
3128				var name = _thisObj.getClearLabel(option.html());
3129				selectedOptions['list'][option.attr('data-term-id')] = name;
3130				statistics.push(name);
3131				i++;
3132			});
3133		} else if (filterType === 'dropdown'){
3134			var option = $filter.find(":selected"),
3135				value = option.val();
3136			options[i] = value;
3137			if(value != '') {
3138				frontendOptions[i] = option.attr('data-slug');
3139				var name = option.html();
3140				selectedOptions['list'][option.attr('data-term-id')] = name;
3141				statistics.push(name);
3142			}
3143		}
3144		optionsArray['backend'] = options;
3145
3146		//options for frontend(change url)
3147		var getParams = $filter.attr('data-get-attribute');
3148
3149		optionsArray['frontend'] = [];
3150		optionsArray['frontend']['taxonomy'] = getParams;
3151		optionsArray['frontend']['settings'] = frontendOptions;
3152		optionsArray['selected'] = selectedOptions;
3153		optionsArray['stats'] = statistics;
3154
3155		return optionsArray;
3156	});
3157
3158	WpfFrontendPage.prototype.getFeaturedFilterOptions = (function ($filter) {
3159		var optionsArray = [],
3160			options = [],
3161			frontendOptions = [],
3162			filterType = $filter.attr('data-display-type'),
3163			selectedOptions = {'is_one': (filterType == 'dropdown'), 'list': []},
3164			statistics = [],
3165			i = 0;
3166
3167		$filter.find('input:checked').each(function () {
3168			var li = jQuery(this).closest('li'),
3169				id = li.attr('data-term-id');
3170			options[i] = id;
3171			frontendOptions[i] = li.attr('data-term-slug');
3172			var name = li.find('.wpfValue').html();
3173			selectedOptions['list'][id] = name;
3174			statistics.push(li.find('.wpfFilterTaxNameWrapper').length ? li.find('.wpfFilterTaxNameWrapper').html() : name);
3175			i++;
3176		});
3177		optionsArray['backend'] = options;
3178
3179		//options for frontend(change url)
3180		var getParams = $filter.attr('data-get-attribute');
3181
3182		optionsArray['frontend'] = [];
3183		optionsArray['frontend']['taxonomy'] = getParams;
3184		optionsArray['frontend']['settings'] = frontendOptions;
3185		optionsArray['selected'] = selectedOptions;
3186		optionsArray['stats'] = statistics;
3187
3188		return optionsArray;
3189	});
3190
3191	WpfFrontendPage.prototype.getOnSaleFilterOptions = (function ($filter) {
3192		var optionsArray = [],
3193			options = [],
3194			frontendOptions = [],
3195			filterType = $filter.attr('data-display-type'),
3196			selectedOptions = {'is_one': (filterType == 'dropdown'), 'list': []},
3197			statistics = [],
3198			i = 0;
3199
3200		$filter.find('input:checked').each(function () {
3201			var li = jQuery(this).closest('li'),
3202				id = li.attr('data-term-id');
3203			options[i] = id;
3204			frontendOptions[i] = li.attr('data-term-slug');
3205			var name = li.find('.wpfValue').html();
3206			selectedOptions['list'][id] = name;
3207			statistics.push(li.find('.wpfFilterTaxNameWrapper').length ? li.find('.wpfFilterTaxNameWrapper').html() : name);
3208			i++;
3209		});
3210		optionsArray['backend'] = options;
3211
3212		//options for frontend(change url)
3213		var getParams = $filter.attr('data-get-attribute');
3214
3215		optionsArray['frontend'] = [];
3216		optionsArray['frontend']['taxonomy'] = getParams;
3217		optionsArray['frontend']['settings'] = frontendOptions;
3218		optionsArray['selected'] = selectedOptions;
3219		optionsArray['stats'] = statistics;
3220
3221		return optionsArray;
3222	});
3223
3224	WpfFrontendPage.prototype.getRatingFilterOptions = (function ($filter) {
3225		var optionsArray = [],
3226			frontendOptions = [],
3227			options = [],
3228			filterType = $filter.attr('data-display-type'),
3229			selectedOptions = {'is_one': true, 'list': []},
3230			statistics = [],
3231			i = 0;
3232
3233		//options for backend (filtering)
3234		if(filterType == 'linestars' || filterType == 'liststars'){
3235			var input = $filter.find('input.wpfStarInput:checked'),
3236				rating = input.val();
3237			options[i] = rating;
3238			frontendOptions[i] = rating;
3239			var name = input.attr('data-label');
3240			selectedOptions['list'][i] = name;
3241			statistics.push(name);
3242		}else if(filterType == 'list'){
3243			$filter.find('input:checked').each(function () {
3244				var li = jQuery(this).closest('li'),
3245					id = li.attr('data-term-id');
3246				options[i] = id;
3247				frontendOptions[i] = li.attr('data-term-slug');
3248				var name = li.find('.wpfValue').html();
3249				selectedOptions['list'][id] = name;
3250				statistics.push(li.find('.wpfFilterTaxNameWrapper').length ? li.find('.wpfFilterTaxNameWrapper').html() : name);
3251				i++;
3252			});
3253		}else if(filterType == 'dropdown'){
3254			var option = $filter.find(":selected"),
3255				value = option.val();
3256			options[i] = value;
3257			if(value != '') {
3258				frontendOptions[i] = option.attr('data-slug');
3259				var name = option.html();
3260				selectedOptions['list'][option.attr('data-term-id')] = name;
3261				statistics.push(name);
3262			}
3263		}
3264		optionsArray['backend'] = options;
3265
3266		//options for frontend(change url)
3267		var getParams = $filter.attr('data-get-attribute');
3268
3269		optionsArray['frontend'] = [];
3270		optionsArray['frontend']['taxonomy'] = getParams;
3271		optionsArray['frontend']['settings'] = frontendOptions;
3272		optionsArray['selected'] = selectedOptions;
3273		optionsArray['stats'] = statistics;
3274
3275		return optionsArray;
3276	});
3277
3278	WpfFrontendPage.prototype.disableLeerOptions = (function () {
3279		var _thisObj = this.$obj;
3280		jQuery('.wpfMainWrapper').each(function () {
3281			var mainWrapper = jQuery(this),
3282				settings = _thisObj.getFilterMainSettings(mainWrapper);
3283			if(settings && settings.settings.filter_null_disabled === '1') {
3284				var filters = mainWrapper.find('.wpfFilterWrapper.wpfShowCount');
3285				if(filters.length) {
3286					filters.find('option[data-term-id]').prop('disabled', false);
3287					filters.find('option[data-term-id][data-count="0"]').prop('disabled', true);
3288					filters.find('.wpfCount').each(function(){
3289						var cntObj = jQuery(this),
3290							leer = cntObj.html() == '(0)',
3291							el = cntObj.closest('[data-term-id]'),
3292							input = false;
3293						if(el.length == 0) {
3294							el = cntObj.closest('[data-term-slug]');
3295						}
3296						if(el.length) {
3297							if(el.is('input')) {
3298								input = el;
3299								el = input.parent();
3300							} else {
3301								input = el.find('input');
3302							}
3303							input.prop('disabled', leer);
3304							if(leer) el.addClass('wpfOptionDisabled');
3305							else el.removeClass('wpfOptionDisabled');
3306						}
3307					});
3308				}
3309			}
3310		});
3311	});
3312
3313	WpfFrontendPage.prototype.addSpecificPluginActions = (function() {
3314		// elementor plugin, action when widgets in admin panek are ready
3315		jQuery(window).on('load', function() {
3316			if ( window.elementorFrontend ) {
3317				if ( window.elementorFrontend.hooks ) {
3318					elementorFrontend.hooks.addAction( 'frontend/element_ready/widget', function( $scope ) {
3319						var wrapper = $scope.find('.wpfMainWrapper');
3320
3321						hideFilterLoader(wrapper);
3322					});
3323				}
3324			} else if ( jQuery('.elementor .wpfMainWrapper').length ) {
3325				setTimeout(function() {
3326					jQuery('.elementor .wpfMainWrapper').each(function() {
3327						var wrapper = jQuery(this);
3328						hideFilterLoader(wrapper);
3329					});
3330				}, 2000);
3331			}
3332		});
3333	});
3334
3335	WpfFrontendPage.prototype.fixSelector = (function(selector, defaultSelector) {
3336		if (typeof selector == 'undefined' || selector === '') {
3337			return typeof defaultSelector == 'undefined' ? '' : defaultSelector;
3338		}
3339		return (selector.search(/\.|#/) === -1) ? '.' + selector.replace(/(\s+)(\w+)/g, ' .$2')	: selector ;
3340	});
3341
3342	WpfFrontendPage.prototype.markCheckboxSelected = (function ($filter, first) {
3343		if ($filter.length) {
3344			var settings = this.getFilterMainSettings($filter.closest('.wpfMainWrapper'));
3345			if(settings) {
3346				if (settings.settings.checked_items_bold == '1') {
3347					var wpfMainWrapper = $filter.closest('.wpfMainWrapper');
3348					wpfMainWrapper.find('.wpfDisplay').css('font-weight', '');
3349					wpfMainWrapper.find('.wpfAttrLabel').css('font-weight', '');
3350					// console.log(wpfMainWrapper.find('input:checked'))
3351					wpfMainWrapper.find('input:checked').each(function () {
3352						var wpfDisplay = jQuery(this).closest('.wpfLiLabel').find('.wpfDisplay'),
3353							wpfAttrLabel = jQuery(this).closest('.wpfColorsColBlock').find('.wpfAttrLabel');
3354
3355						wpfDisplay.css('font-weight', 'bold');
3356						wpfAttrLabel.css('font-weight', 'bold');
3357					});
3358				}
3359			}
3360			if (first) {
3361				//need to delete automatic checked inputs by goback in browser Chrome/FF
3362				setTimeout(function () {
3363					$filter.find('input').each(function() {
3364						var input = this;
3365						if (input.type == "checkbox") {
3366							if (input.defaultChecked == true) {
3367								if (input.checked != true) input.checked = true;
3368							} else {
3369								if (input.checked == true) {
3370									input.checked = false;
3371									jQuery(input).closest('.wpfLiLabel').find('.wpfDisplay').removeClass('selected').css('font-weight', '');
3372								}
3373							}
3374
3375						}
3376					});
3377				}, 100);
3378			}
3379		}
3380	});
3381
3382	window.wpIinitialiseImmediately = typeof wpIinitialiseImmediately !== 'undefined' ? wpIinitialiseImmediately : 0;
3383	jQuery(document).ready(function () {
3384		if (!window.wpfFrontendPage) window.wpfFrontendPage = new WpfFrontendPage();
3385		if (typeof isElementorEditMode == 'undefined') {
3386			window.wpfFrontendPage.init();
3387		}
3388	});
3389	WpfFrontendPage.prototype.unserializeStr = function(serializedString){
3390		var str = decodeURI(serializedString);
3391        var pairs = str.split('&');
3392        var obj = {}, p, idx;
3393        for (var i=0, n=pairs.length; i < n; i++) {
3394            p = pairs[i].split('=');
3395            idx = p[0];
3396            if (obj[idx] === undefined) {
3397                obj[idx] = unescape(p[1]).replace ( /\+/g, ' ' );
3398            }else{
3399                if (typeof obj[idx] == "string") {
3400                    obj[idx]=[obj[idx]];
3401                }
3402                obj[idx].push(unescape(p[1]).replace ( /\+/g, ' ' ));
3403            }
3404        }
3405        return obj;
3406	};
3407
3408	WpfFrontendPage.prototype.getConvertedPrices = function (data, rate) {
3409		if (typeof rate !== 'undefined' && rate !== 1 ) {
3410			if (typeof data[0] !== 'undefined') {
3411				data[0] = String(Math.round(data[0] / rate));
3412				if (typeof data[1] !== 'undefined') {
3413					data[1] = String(Math.round(data[1] / rate));
3414				}
3415				if (typeof data[2] !== 'undefined') {
3416					data[2] = String(Math.round(data[2] / rate));
3417				}
3418			} else {
3419				if (data.wpf_min_price) {
3420					data.wpf_min_price = String(Math.round(data.wpf_min_price * rate));
3421				}
3422				if (data.wpf_max_price) {
3423					data.wpf_max_price = String(Math.round(data.wpf_max_price * rate));
3424				}
3425				if (data.tax) {
3426					data.tax = String(Math.round(data.tax * rate));
3427				}
3428			}
3429		}
3430		return data;
3431	};
3432
3433	if (jQuery('.variations_form').length > 0 && typeof $(this).wc_variation_form == 'function') {
3434		document.addEventListener('wpfAjaxSuccess', function (event) {
3435			$('.variations_form').each(function () {
3436				$(this).wc_variation_form();
3437			});
3438		});
3439	}
3440
3441	if (jQuery('.jetpack-lazy-image').length > 0) {
3442		document.addEventListener('wpfAjaxSuccess', function (event) {
3443			jQuery('.jetpack-lazy-image').each(function () {
3444				jQuery(this).removeAttr('srcset');
3445			});
3446		});
3447	}
3448	if (jQuery('.jetpack-lazy-image').length > 0) {
3449		document.addEventListener('wpfAjaxSuccess', function (event) {
3450			jQuery('.jetpack-lazy-image').each(function () {
3451				jQuery(this).removeAttr('srcset');
3452			});
3453		});
3454	}
3455
3456	// added for ElementorPro Loop Load More
3457	if (jQuery('div.elementor-widget[data-widget_type="loop-grid.product"]').length > 0) {
3458		document.addEventListener('wpfAjaxSuccess', function (event) {
3459			if (window.elementorFrontend && window.elementorFrontend.elementsHandler) {
3460				var $products = jQuery('div.elementor-widget[data-widget_type="loop-grid.product"]');
3461				if ($products.length == 1 && $products.find('.e-load-more-anchor').length == 1) {
3462					$products.removeClass('e-load-more-pagination-end');
3463					window.elementorFrontend.elementsHandler.runReadyTrigger($products);
3464				}
3465			}
3466		});
3467	}
3468
3469	// added for plugin: WooCommerce Load More Products
3470	jQuery(document).ready(function () {
3471		if (jQuery('a.lmp_button').length > 0) {
3472			document.addEventListener('wpfAjaxSuccess', function (event) {
3473				if (!window.wpfDoNotLoadMore && typeof load_next_page == 'function') {
3474					load_next_page(true, decodeURIComponent(location.href));
3475				}
3476			});
3477		}
3478	});
3479
3480	// plugin event woocommerce-product-search
3481	// https://docs.woocommerce.com/documentation/plugins/woocommerce/woocommerce-extensions/woocommerce-product-search/
3482	jQuery(document).on('ixProductFilterRequestProcessed', function (event) {
3483		window.wpfFrontendPage.filtering();
3484	});
3485	if (window.wpIinitialiseImmediately) {
3486		window.wpfFrontendPage = new WpfFrontendPage();
3487	}
3488}(window.jQuery, window));
3489
3490var objQueryString={};
3491
3492toggleClear();
3493
3494// try to get jquery selector from random html string
3495function wpfGetSelector(html, controlExist, defSelector, countChilds, removeDynamicClasse
3495s, context) {
3496	if(html.length == 0) return defSelector;
3497
3498	var elem     = (typeof context !== 'undefined') ? jQuery(html, context) : jQuery(html),
3499		selector = '',
3500		i = 0;
3501
3502	if (typeof countChilds == 'undefined') {
3503		countChilds = 1;
3504	}
3505
3506	while (i < countChilds && elem && elem.length) {
3507		if (i > 0) {
3508			selector += ' ';
3509		}
3510
3511		i++;
3512
3513		if (elem.length > 1) {
3514			elem = elem.last();
3515		}
3516
3517		var elemId = elem.attr('id');
3518		if (typeof elemId != 'undefined') {
3519			selector += '#' + elemId;
3520		} else {
3521			var elemClass = elem.attr('class');
3522
3523			// try to remove some dinamically changed classes that contains a number in it name
3524			if (removeDynamicClasses) {
3525				classList = elemClass.split(' ');
3526				classList.forEach( function( className, key ) {
3527					var hasNumber = /\d/.test(className);
3528					if ( hasNumber ) {
3529						classList.splice(key, 1);
3530					}
3531				});
3532				elemClass = classList.join(' ');
3533			}
3534
3535			if ( typeof elemClass != 'undefined' && elemClass != '' ) {
3536				if (elemClass == 'container' && countChilds == 1) countChilds = 2;
3537				selector += elem.get(0).tagName + '.' + elemClass.trim().replace(/ +/g, '.');
3538			}
3539		}
3540
3541		if (controlExist && selector != '' && jQuery(selector).length == 0) {
3542			selector = '';
3543			break;
3544		}
3545
3546		var elem = elem.children();
3547	}
3548
3549	return selector.length == 0 ? defSelector : selector;
3550}
3551
3552
3553function getUrlParams () {
3554	var params={};
3555	window.location.search
3556	  .replace(/[?&]+([^=&]+)=([^&]*)/gi, function(str,key,value) {
3557		params[key] = value;
3558	  }
3559	);
3560	return params;
3561}
3562
3563function toggleClear() {
3564	var params = getUrlParams();
3565	jQuery(".wpfBlockClear").hide();
3566	jQuery(".wpfFilterWrapper").each(function(){
3567		var attr = jQuery(this).attr('data-get-attribute');
3568		if (attr in params) {
3569			jQuery(this).find(".wpfBlockClear").show();
3570		}
3571	});
3572	if ('wpf_min_price' in params || 'wpf_max_price' in params) {
3573		jQuery("[data-filter-type='wpfPrice']").find(".wpfBlockClear").show();
3574		jQuery("[data-filter-type='wpfPriceRange']").find(".wpfBlockClear").show();
3575	}
3576}
3577
3578//Get querystring value
3579function getParameterByName(name, searchUrl) {
3580	name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
3581	var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
3582		results = regex.exec(searchUrl);
3583	return results === null ? "" : decodeURIComponent(results[1]);//decodeURIComponent(results[1].replace(/\+/g, " "));
3584}
3585function getCurrentUrlPartsWpf() {
3586	var parts = window.wpfNewUrl.split('?'),
3587		s = (parts[1] || '');
3588	return {href: window.wpfNewUrl, path: parts[0].replace(/#.*$/, ''), search: (s.length ? '?' + s : '')};
3589}
3590
3591//Add or modify querystring
3592function changeUrl(filterSlug, filterValue, $wooPage, $filterWrapper) {
3593	removePageQString();
3594	//Get query string filterValue
3595	$wooPage = (typeof $wooPage != 'undefined' ? $wooPage: false);
3596	var curUrl = getCurrentUrlPartsWpf();
3597	if(!$wooPage){
3598		var searchUrl = decodeURIComponent(curUrl.search);
3599	}else{
3600		if($filterWrapper.attr('data-hide-url')){
3601			var searchUrl=$filterWrapper.attr('data-hide-url');
3602		} else {
3603			var searchUrl = '';
3604		}
3605	}
3606
3607	if (searchUrl.indexOf("redirect")!==-1) {
3608		searchUrl = '';
3609	}
3610
3611	if(searchUrl.indexOf("?")== "-1") {
3612		var urlValue = curUrl.path + '?'+filterSlug+'='+filterValue;
3613	} else {
3614		//Check for filterSlug in query string, if not present
3615		if(searchUrl.indexOf('&'+filterSlug+'=')== "-1" && searchUrl.indexOf('?'+filterSlug+'=')== "-1") {
3616			var urlValue=searchUrl+'&'+filterSlug+'='+filterValue;
3617		//If filterSlug present in query string
3618		} else {
3619			var oldValue = getParameterByName(filterSlug, searchUrl);
3620			if(searchUrl.indexOf("?"+filterSlug+"=")!= "-1") {
3621				var urlValue = searchUrl.replace('?'+filterSlug+'='+oldValue,'?'+filterSlug+'='+filterValue);
3622			// add existing in url filter with another option
3623			} else {
3624				var urlValue = searchUrl.replace('&'+filterSlug+'='+oldValue,'&'+filterSlug+'='+filterValue);
3625			}
3626		}
3627		urlValue = curUrl.path + urlValue;
3628		//history.pushState function is used to add history state.
3629		//It takes three parameters: a state object, a title (which is currently ignored), and (optionally) a URL.
3630	}
3631	if(!$wooPage){
3632		window.wpfNewUrl = encodeURI(urlValue).indexOf('%25') === -1 ? encodeURI(urlValue) : urlValue;
3633	}
3634	objQueryString.key=filterValue;
3635	return urlValue;
3636}
3637
3638function removePageQString() {
3639	var curUrl = getCurrentUrlPartsWpf(),
3640		path = curUrl.path,
3641		page = path.indexOf('/page/');
3642	if(page != -1 && history.pushState) {
3643		window.wpfNewUrl = path.substr(0, page + 1) + curUrl.search;
3644	} else {
3645        window.wpfNewUrl = curUrl.path + removePagenum(curUrl.search);
3646    }
3647}
3648
3649function removePagenum(url) {
3650    return url.replace(/([&?])pagenum=\d+(&|$)/g, function(match, prefix, suffix) {
3651        return prefix === '?' && suffix === '&' ? '?' :
3652               prefix === '&' && suffix === '' ? '' :
3653               prefix;
3654    });
3655}
3656
3657//Function used to remove querystring
3658function removeQString(key, $wooPage, $filterWrapper) {
3659	removePageQString();
3660	//Get query string value
3661	var curUrl = getCurrentUrlPartsWpf(),
3662		urlValue=decodeURI(curUrl.href);
3663	$wooPage = (typeof $wooPage != 'undefined' ? $wooPage: false);
3664	if(!$wooPage){
3665		var searchUrl=decodeURIComponent(curUrl.search);
3666	}else{
3667		if($filterWrapper.attr('data-hide-url')){
3668			var searchUrl=decodeURI($filterWrapper.attr('data-hide-url'));
3669		}else {
3670			var searchUrl = '';
3671		}
3672		var urlValue=curUrl.href + searchUrl;
3673	}
3674	if(key!="") {
3675		var oldValue = getParameterByName(key, searchUrl),
3676			removeVal=key+"="+oldValue;
3677
3678		if(searchUrl.indexOf('?'+removeVal+'&')!= "-1") {
3679			urlValue=urlValue.replace('?'+removeVal+'&','?');
3680		}
3681		else if(searchUrl.indexOf('&'+removeVal+'&')!= "-1") {
3682			urlValue=urlValue.replace('&'+removeVal+'&','&');
3683		}
3684		else if(searchUrl.indexOf('?'+removeVal)!= "-1") {
3685			urlValue=urlValue.replace('?'+removeVal,'');
3686		}
3687		else if(searchUrl.indexOf('&'+removeVal)!= "-1") {
3688			urlValue=urlValue.replace('&'+removeVal,'');
3689		}
3690		if($wooPage){
3691			urlValue = urlValue.replace(curUrl.href,'');
3692		}
3693	} else {
3694		if(!$wooPage){
3695			var searchUrl=decodeURIComponent(curUrl.search);
3696			urlValue=urlValue.replace(searchUrl,'');
3697		}else{
3698			var searchUrl=$filterWrapper.attr('data-hide-url');
3699			urlValue=urlValue.replace(searchUrl,'');
3700			urlValue = urlValue.replace(curUrl.href,'');
3701		}
3702	}
3703	if(!$wooPage){
3704		window.wpfNewUrl = encodeURI(urlValue).indexOf('%25') === -1 ? encodeURI(urlValue) : urlValue;
3705	}
3706	return urlValue.indexOf('%25') !== -1 ? decodeURI(urlValue) : urlValue;
3707}
3708function checkArray(my_arr){
3709	for(var i=0;i<my_arr.length;i++){
3710		if(my_arr[i] === "")
3711			return false;
3712	}
3713	return true;
3714}
3715jQuery.toQueryParams = function(str, separator) {
3716	separator = separator || '&';
3717	var obj = {};
3718	if (str.length == 0)
3719		return obj
3720	var c = str.substr(0,1),
3721		s = c=='?' || c=='#'  ? str.substr(1) : str,
3722		a = s.split(separator);
3723	for (var i=0; i<a.length; i++) {
3724		var p = a[i].indexOf('=');
3725		if (p < 0) {
3726			obj[a[i]] = '';
3727			continue
3728		}
3729		var k = decodeURIComponent(a[i].substr(0,p)),
3730			v = decodeURIComponent(a[i].substr(p+1)),
3731			bps = k.indexOf('[');
3732		if (bps < 0) {
3733			obj[k] = v
3734			continue;
3735		}
3736
3737		var bpe = k.substr(bps+1).indexOf(']');
3738		if (bpe < 0) {
3739			obj[k] = v
3740			continue;
3741		}
3742
3743		var bpv = k.substr(bps+1, bps+bpe-1),
3744			k = k.substr(0,bps);
3745		if (bpv.length <= 0) {
3746			if (typeof(obj[k]) != 'object') obj[k] = [];
3747			obj[k].push(v);
3748		} else {
3749			if (typeof(obj[k]) != 'object') obj[k] = {};
3750			obj[k][bpv] = v;
3751		}
3752	}
3753	return obj;
3754}
3755function wpfChangeFiltersCount (wpfExistTerms, synchroFilterId) {
3756
3757	var wpfPage = window.wpfFrontendPage,
3758		curFilter = wpfPage.isSynchro ? (typeof(synchroFilterId) != 'undefined' && synchroFilterId.length ? '#'+synchroFilterId : '#'+wpfPage.currentLoadId) : 'body';
3759
3760	jQuery(curFilter).find(".wpfShowCount").find(".wpfCount").html("(0)");
3761	jQuery(curFilter).find(".wpfShowCount select:not([multiple]) option[data-count]").each(function(){
3762		var attr = jQuery(this).attr("data-term-name");
3763		jQuery(this).attr('data-count', 0).html(attr+" (0)");
3764	});
3765	jQuery(curFilter).find(".wpfShowCount select[multiple]").find("option").each(function(){
3766		attr = jQuery(this).attr("data-term-name");
3767		jQuery(this).attr('data-count', 0).html(attr+" (0)");
3768	});
3769
3770	jQuery(curFilter).find(".wpfShowCount").each(function(filterCounter){
3771
3772		var filter = jQuery(this);
3773		if (filter.attr("data-filter-type").length > 0) {
3774			var taxonomy = filter.data('taxonomy');
3775			if(typeof taxonomy == 'undefined' || taxonomy.length == 0) taxonomy = filter.data('slug');
3776
3777			if (taxonomy in wpfExistTerms) {
3778
3779				if (typeof (wpfExistTerms[taxonomy].relation) !== 'undefined') {
3780					var htmlArray = {};
3781					jQuery(curFilter).find('div.wpfShowCount[data-taxonomy="' + taxonomy + '"] li').each(function () {
3782						htmlArray[jQuery(this).data('term-id')] = jQuery('.wpfFilterTaxNameWrapper', this).html();
3783					});
3784
3785					jQuery.each(wpfExistTerms[taxonomy].relation, function (index, value) {
3786						jQuery.each(htmlArray, function (i, v) {
3787							if (v === value && i !== index) {
3788								wpfExistTerms[taxonomy][i] = wpfExistTerms[taxonomy][index];
3789								delete wpfExistTerms[taxonomy][index];
3790							}
3791						});
3792					});
3793				}
3794
3795				jQuery.each(wpfExistTerms[taxonomy], function (index, value) {
3796					changeCount(taxonomy, index, value, curFilter);
3797				});
3798
3799				delete wpfExistTerms[taxonomy];
3800			}
3801
3802		}
3803	});
3804
3805	window.wpfFrontendPage.disableLeerOptions();
3806	var multi = jQuery('.wpfShowCount').find('select[multiple]');
3807	if (multi.length) multi.multiselect('reload');
3808};
3809
3810function changeCount(taxonomy, index, value, curFilter) {
3811
3812	var oIndex = index;
3813	index = index.toLowerCase();
3814	var els = jQuery(curFilter).find('div.wpfShowCount[data-taxonomy="' + taxonomy + '"] [data-term-id="' + oIndex + '"]');
3815	if (els.length === 0) {
3816		els = jQuery(curFilter).find('div.wpfShowCount[data-slug="' + taxonomy + '"] [data-term-id="' + oIndex + '"]');
3817	}
3818	if (els.length === 0) {
3819		els = jQuery(curFilter).find('div.wpfShowCount[data-taxonomy="' + taxonomy + '"] [data-term-id="' + index + '"]');
3820	}
3821	if (els.length === 0) {
3822		els = jQuery(curFilter).find('div.wpfShowCount[data-slug="' + taxonomy + '"] [data-term-id="' + index + '"]');
3823	}
3824	if (els.length > 0) {
3825		els.each(function () {
3826			var el = jQuery(this);
3827			if (el.find('.wpfCount').length > 0) {
3828				el.find('.wpfCount:first').html('(' + value + ')');
3829			} else if (el.parent().attr('class') == 'wpfColorsColBlock') {
3830				el.parent().find('.wpfCount').html('(' + value + ')');
3831			} else {
3832				var attrname = el.attr('data-term-name');
3833				var tooltipstered = el.siblings('.tooltipstered');
3834				if (tooltipstered.length) {
3835					attrname = tooltipstered.attr('data-term-name');
3836					tooltipstered.tooltipster('content', '' + attrname + ' (' + value + ')');
3837					if (tooltipstered.attr('data-show-count')) tooltipstered.text(value);
3838				} else if (attrname !== undefined) {
3839					el.html('' + attrname + ' (' + value + ')');
3840				} else {
3841					el.html('' + index + ' (' + value + ')');
3842				}
3843			}
3844			if (el.is('option')) {
3845				el.attr('data-count', value);
3846			}
3847		});
3848	}
3849}
3850
3851// show/hide individual filter items
3852function wpfShowHideFiltersAtts(wpfExistTerms, wpfExistUsers, synchroFilterId) {
3853
3854	var wpfPage = window.wpfFrontendPage,
3855		curFilter = typeof(synchroFilterId) != 'undefined' && synchroFilterId.length ? synchroFilterId : wpfPage.currentLoadId;
3856
3857	wpfPage.restoreSelectsForSafari();
3858
3859	jQuery((curFilter ? '#' + curFilter + ' ' : '') + '.wpfFilterWrapper').each(function(){
3860		var filter = jQuery(this),
3861			filterType = filter.data('filter-type'),
3862			isTextFilter = filter.attr('data-display-type') == 'text',
3863			filterContentType = isTextFilter && filter.attr('data-control-products') == '1' ? 'taxonomy' : filter.data('content-type'),
3864			taxonomy = filter.data('taxonomy'),
3865			getAttr = filter.data('get-attribute'),
3866			isFilterCurentlyActivated = getParameterByName(getAttr, location.search),
3867			isHideActive = filter.data('hide-active'),
3868			isShowAll = Boolean(filter.data('show-all')),
3869			isNotInLogic = getAttr.indexOf('pr_filter') == -1 ? false : true,
3870			userExistIds = [];
3871
3872		switch (filterContentType) {
3873			case 'user':
3874				jQuery.each(wpfExistUsers, function (index, value) {
3875					userExistIds.push(parseInt(value.ID));
3876				});
3877				if (!isFilterCurentlyActivated && userExistIds.length > 0) {
3878					filter.find('[data-term-id]').each(function () {
3879						var el = jQuery(this),
3880							userId = el.data('term-id');
3881						if (userExistIds.indexOf(userId) >= 0) {
3882							el.show();
3883						} else {
3884							el.hide();
3885						}
3886					});
3887				}
3888				break;
3889			case 'taxonomy':
3890				if (typeof taxonomy == 'undefined' || taxonomy.length == 0) {
3891					taxonomy = filter.data('slug');
3892				}
3893
3894				if ((!isFilterCurentlyActivated || isHideActive) && !isNotInLogic && !isShowAll ) {
3895					if (taxonomy in wpfExistTerms || isFilterCurentlyActivated) {
3896						var termIds = wpfExistTerms[taxonomy] || {};
3897						filter.find('[data-term-id]').each(function () {
3898							var elem = jQuery(this),
3899								id = elem.data('term-id'),
3900								selected = isFilterCurentlyActivated && (elem.is('input:checked') || elem.find('input:checked').length || elem.is('option:selected'));
3901							if (id in termIds || selected) {
3902								if(elem.closest('.wpfButtonsFilter').length) elem.css('display', 'inline-block');
3903								else elem.show();
3904								if (elem.parent().hasClass('wpfColorsColBlock')) {
3905									elem.parent().parent().show();
3906								}
3907								if (elem.closest('.wpfColorsRow').length) {
3908									elem.parent().css('display', 'inline-block');
3909								}
3910							} else {
3911								elem.hide();
3912								elem.find('input').prop('checked', false);
3913								if (elem.parent().hasClass('wpfColorsColBlock')) {
3914									elem.parent().parent().hide();
3915								}
3916								if (elem.closest('.wpfColorsRow').length) {
3917									elem.parent().hide();
3918								}
3919							}
3920						});
3921
3922						if (filter.attr('data-display-type') == 'slider' ) {
3923							if (typeof(wpfPage.updateAttrSlider) == 'function') {
3924								wpfPage.updateAttrSlider(filter, termIds);
3925							}
3926						} else {
3927							// all terms display block already has css display none
3928							var hideSingle = filter.attr('data-hide-single') == '1',
3929								preSelector = hideSingle && filter.find('select[multiple]').length ? 'option' : '',
3930								selector = hideSingle && filter.find('.wpfColorsFilter').length ? 'li[data-term-slug]' : '[data-term-id]',
3931								cntAll = isTextFilter ? 1 : filter.find(preSelector+selector).length,
3932								cntHidden = filter.find(preSelector+selector+'[style*="none"]').length,
3933								limit = hideSingle ? 1 : 0;
3934							if (cntAll-cntHidden <= limit) {
3935								filter.hide();
3936							} else {
3937								filter.show();
3938							}
3939						}
3940					} else {
3941						filter.find('input').prop('checked', false);
3942						filter.find('select').val('');
3943						filter.hide();
3944					}
3945				}
3946				var multi = filter.find('select[multiple]');
3947				if (multi.length) multi.multiselect('reload');
3948
3949				if(typeof(window.wpfFrontendPage.wpfShowHideFiltersAttsPro) == 'function') {
3950					window.wpfFrontendPage.wpfShowHideFiltersAttsPro(filter);
3951				}
3952				break;
3953			default:
3954				// console.log(`Sorry, we are out of ${expr}.`);
3955		}
3956	});
3957	wpfPage.removeHiddenOptionsForSafari();
3958}
3959
3960function wpfChangePriceFiltersCount(prices) {
3961	var _thisObj = window.wpfFrontendPage,
3962		noWooPage = _thisObj.noWoo,
3963		filterWrapper = jQuery('.wpfMainWrapper'),
3964		priceFilters = jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"].wpfNotActive');
3965
3966	jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"]').each(function () {
3967		var wpfPrice = jQuery(this);
3968		wpfPrice.attr('data-minvalue', prices.wpf_min_price).attr('data-maxvalue', prices.wpf_max_price);
3969
3970		wpfPrice.find('#wpfMinPrice').attr('min', prices.wpf_min_price).val(prices.wpf_min_price);
3971		wpfPrice.find('#wpfMaxPrice').attr('max', prices.wpf_max_price).val(prices.wpf_max_price);
3972
3973		if (wpfPrice.find(".ion-range-slider").length) {
3974			wpfPrice.find(".ion-range-slider").each(function () {
3975				jQuery(this).attr('data-min', prices.wpf_min_price).attr('data-max', prices.wpf_max_price);
3976				var ionSlider = jQuery(this).data("ionRangeSlider");
3977				ionSlider.update({
3978					min: prices.wpf_min_price,
3979					max: prices.wpf_max_price,
3980				});
3981			});
3982		}
3983	});
3984	window.wpfFrontendPage.eventsPriceFilter();
3985	_thisObj.getUrlParamsChangeFiltersValues();
3986	/*if (typeof(window.wpfFrontendPage.eventsFrontendPro) == 'function') {
3987		window.wpfFrontendPage.eventsFrontendPro();
3988	}*/
3989}
3990
3991function hideFilterLoader( wrapper ) {
3992	wrapper.find('.wpfLoaderLayout').hide();
3993	wrapper.css({
3994		position: ''
3995	});
3996	wrapper.find('.wpfFilterWrapper').css({
3997		visibility: 'inherit'
3998	});
3999}
4000
4001function heightIdenticalInRow(selector) {
4002	var setMaxHeight = function (elements) {
4003		if (elements.length > 1) {
4004			var elementHeightMax = elements[0].height;
4005			for (var j = 1; j < elements.length; j++) {
4006				if (elements[j].height > elementHeightMax) {
4007					elementHeightMax = elements[j].height;
4008				}
4009			}
4010			for (var j = 0; j < elements.length; j++) {
4011				jQuery(elements[j].selector).height(elementHeightMax);
4012			}
4013		}
4014	};
4015	var elementsHeight = [];
4016	var rowIndex = 0;
4017	var elementIndex = 0;
4018
4019	jQuery(selector).each(function (index, element) {
4020		if (!elementsHeight[rowIndex]) {
4021			elementsHeight[rowIndex] = [];
4022		}
4023		if (
4024			elementsHeight[rowIndex][elementsHeight[rowIndex].length - 1]
4025			&&
4026			elementsHeight[rowIndex][elementsHeight[rowIndex].length - 1].top
4027			&&
4028			elementsHeight[rowIndex][elementsHeight[rowIndex].length - 1].top !== jQuery(element).offset().top
4029		) {
4030
4031			setMaxHeight(elementsHeight[rowIndex]);
4032			rowIndex++;
4033		}
4034		if (!elementsHeight[rowIndex]) {
4035			elementsHeight[rowIndex] = [];
4036		}
4037		elementsHeight[rowIndex].push({
4038			selector: selector + ':eq(' + elementIndex + ')',
4039			height: jQuery(element).height(),
4040			top: jQuery(element).offset().top
4041		});
4042		elementIndex++;
4043	});
4044	if (elementsHeight[rowIndex]) {
4045		setMaxHeight(elementsHeight[rowIndex]);
4046	}
4047}
4048function wpfDoActionsAfterLoad (fid, isFound, requestData) {
4049	if (typeof (window.wpfFrontendPage.saveStatistics) == 'function') {
4050		window.wpfFrontendPage.saveStatistics(fid, isFound, requestData);
4051	}
4052}
4053if (window.wpIinitialiseImmediately && window.wpfFrontendPage) {
4054	if (typeof isElementorEditMode == 'undefined') window.wpfFrontendPage.init();
4055}

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.