PageSourceSearch

https://planthire.morrisleslie.com/wp-content/plugins/woocommerce-products-filter/js/front.js

js morrisleslie.com collected 2026-10-02 20:59:52 UTC 39,898 bytes, 1,353 lines download raw bytes

1var woof_redirect = '';//if we use redirect attribute in shortcode [woof]
2//***
3
4jQuery(function ($) {
5    jQuery('body').append('<div id="woof_html_buffer" class="woof_info_popup" style="display: none;"></div>');
6    jQuery.fn.life = function (types, data, fn) {
7	jQuery(this.context).on(types, this.selector, data, fn);
8	return this;
9    };
10//http://stackoverflow.com/questions/2389540/jquery-hasparent
11    jQuery.extend(jQuery.fn, {
12	within: function (pSelector) {
13	    // Returns a subset of items using jQuery.filter
14	    return this.filter(function () {
15		// Return truthy/falsey based on presence in parent
16		return jQuery(this).closest(pSelector).length;
17	    });
18	}
19    });
20
21    //+++
22
23    if (jQuery('#woof_results_by_ajax').length > 0) {
24	woof_is_ajax = 1;
25    }
26
27    //listening attributes in shortcode [woof]
28    woof_autosubmit = parseInt(jQuery('.woof').eq(0).data('autosubmit'), 10);
29    woof_ajax_redraw = parseInt(jQuery('.woof').eq(0).data('ajax-redraw'), 10);
30
31
32
33    //+++
34
35    woof_ext_init_functions = jQuery.parseJSON(woof_ext_init_functions);
36
37    //fix for native woo price range
38    woof_init_native_woo_price_filter();
39
40
41    jQuery('body').bind('price_slider_change', function (event, min, max) {
42	if (woof_autosubmit && !woof_show_price_search_button && jQuery('.price_slider_wrapper').length < 2) {
43
44	    jQuery('.woof .widget_price_filter form').trigger('submit');
45
46	} else {
47	    var min_price = jQuery(this).find('.price_slider_amount #min_price').val();
48	    var max_price = jQuery(this).find('.price_slider_amount #max_price').val();
49	    woof_current_values.min_price = min_price;
50	    woof_current_values.max_price = max_price;
51	}
52    });
53
54    jQuery('.woof_price_filter_dropdown').life('change', function () {
55	var val = jQuery(this).val();
56	if (parseInt(val, 10) == -1) {
57	    delete woof_current_values.min_price;
58	    delete woof_current_values.max_price;
59	} else {
60	    var val = val.split("-");
61	    woof_current_values.min_price = val[0];
62	    woof_current_values.max_price = val[1];
63	}
64
65	if (woof_autosubmit || jQuery(this).within('.woof').length == 0) {
66	    woof_submit_link(woof_get_submit_link());
67	}
68    });
69
70
71
72
73
74    //change value in textinput price filter if WOOCS is installed
75    woof_recount_text_price_filter();
76    //+++
77    jQuery('.woof_price_filter_txt').life('change', function () {
78
79	var from = parseInt(jQuery(this).parent().find('.woof_price_filter_txt_from').val(), 10);
80	var to = parseInt(jQuery(this).parent().find('.woof_price_filter_txt_to').val(), 10);
81
82	if (to < from || from < 0) {
83	    delete woof_current_values.min_price;
84	    delete woof_current_values.max_price;
85	} else {
86	    if (typeof woocs_current_currency !== 'undefined') {
87		from = Math.ceil(from / parseFloat(woocs_current_currency.rate));
88		to = Math.ceil(to / parseFloat(woocs_current_currency.rate));
89	    }
90
91	    woof_current_values.min_price = from;
92	    woof_current_values.max_price = to;
93	}
94
95	if (woof_autosubmit || jQuery(this).within('.woof').length == 0) {
96	    woof_submit_link(woof_get_submit_link());
97	}
98    });
99
100
101    //***
102
103    jQuery('.woof_open_hidden_li_btn').life('click', function () {
104	var state = jQuery(this).data('state');
105	var type = jQuery(this).data('type');
106
107	if (state == 'closed') {
108	    jQuery(this).parents('.woof_list').find('.woof_hidden_term').addClass('woof_hidden_term2');
109	    jQuery(this).parents('.woof_list').find('.woof_hidden_term').removeClass('woof_hidden_term');
110	    if (type == 'image') {
111		jQuery(this).find('img').attr('src', jQuery(this).data('opened'));
112	    } else {
113		jQuery(this).html(jQuery(this).data('opened'));
114	    }
115
116	    jQuery(this).data('state', 'opened');
117	} else {
118	    jQuery(this).parents('.woof_list').find('.woof_hidden_term2').addClass('woof_hidden_term');
119	    jQuery(this).parents('.woof_list').find('.woof_hidden_term2').removeClass('woof_hidden_term2');
120
121	    if (type == 'image') {
122		jQuery(this).find('img').attr('src', jQuery(this).data('closed'));
123	    } else {
124		jQuery(this).text(jQuery(this).data('closed'));
125	    }
126
127	    jQuery(this).data('state', 'closed');
128	}
129
130
131	return false;
132    });
133    //open hidden block
134    woof_open_hidden_li();
135
136    //*** woocommerce native "AVERAGE RATING" widget synchronizing
137    jQuery('.widget_rating_filter li.wc-layered-nav-rating a').click(function () {
138	var is_chosen = jQuery(this).parent().hasClass('chosen');
139	var parsed_url = woof_parse_url(jQuery(this).attr('href'));
140	var rate = 0;
141	if (parsed_url.query !== undefined) {
142	    if (parsed_url.query.indexOf('min_rating') !== -1) {
143		var arrayOfStrings = parsed_url.query.split('min_rating=');
144		rate = parseInt(arrayOfStrings[1], 10);
145	    }
146	}
147	jQuery(this).parents('ul').find('li').removeClass('chosen');
148	if (is_chosen) {
149	    delete woof_current_values.min_rating;
150	} else {
151	    woof_current_values.min_rating = rate;
152	    jQuery(this).parent().addClass('chosen');
153	}
154
155	woof_submit_link(woof_get_submit_link());
156
157	return false;
158    });
159
160    //WOOF start filtering button action
161    jQuery('.woof_start_filtering_btn').life('click', function () {
162
163	var shortcode = jQuery(this).parents('.woof').data('shortcode');
164	jQuery(this).html(woof_lang_loading);
165	jQuery(this).addClass('woof_start_filtering_btn2');
166	jQuery(this).removeClass('woof_start_filtering_btn');
167	//redrawing [woof ajax_redraw=1] only
168	var data = {
169	    action: "woof_draw_products",
170	    page: 1,
171	    shortcode: 'woof_nothing', //we do not need get any products, seacrh form data only
172	    woof_shortcode: shortcode
173	};
174	jQuery.post(woof_ajaxurl, data, function (content) {
175	    content = jQuery.parseJSON(content);
176	    jQuery('div.woof_redraw_zone').replaceWith(jQuery(content.form).find('.woof_redraw_zone'));
177	    woof_mass_reinit();
178	});
179
180
181	return false;
182    });
183
184    //***
185    var str = window.location.href;
186    window.onpopstate = function (event) {
187	try {
188	    if (Object.keys(woof_current_values).length) {
189		var temp = str.split('?');
190		var get1 = temp[1].split('#');
191		var str2 = window.location.href;
192		var temp2 = str2.split('?');
193		var get2 = temp2[1].split('#');
194		//console.log(get1[0]);
195		//console.log(get2[0]);
196		if (get2[0] != get1[0]) {
197		    woof_show_info_popup(woof_lang_loading);
198		    window.location.reload();
199		}
200		return false;
201	    }
202	} catch (e) {
203	    console.log(e);
204	}
205    };
206    //***
207
208    //ion-slider price range slider
209    woof_init_ion_sliders();
210
211    //***
212
213    woof_init_show_auto_form();
214    woof_init_hide_auto_form();
215
216    //***
217    woof_remove_empty_elements();
218
219    woof_init_search_form();
220    woof_init_pagination();
221    woof_init_orderby();
222    woof_init_reset_button();
223    woof_init_beauty_scroll();
224    //+++
225    woof_draw_products_top_panel();
226    woof_shortcode_observer();
227
228
229//+++
230    //if we use redirect attribute in shortcode [woof is_ajax=0]
231    //not for ajax, for redirect mode only
232    if (!woof_is_ajax) {
233	woof_redirect_init();
234    }
235
236    woof_init_toggles();
237
238});
239
240//if we use redirect attribute in shortcode [woof is_ajax=0]
241//not for ajax, for redirect mode only
242function woof_redirect_init() {
243
244    try {
245	if (jQuery('.woof').length) {
246	    //https://wordpress.org/support/topic/javascript-error-in-frontjs?replies=1
247	    if (undefined !== jQuery('.woof').val()) {
248		woof_redirect = jQuery('.woof').eq(0).data('redirect');//default value
249		if (woof_redirect.length > 0) {
250		    woof_shop_page = woof_current_page_link = woof_redirect;
251		}
252
253
254		//***
255		/*
256		 var events = ['click', 'change', 'ifChecked', 'ifUnchecked'];
257		 
258		 for (var i = 0; i < events.length; i++) {
259		 
260		 jQuery('div.woof input, div.woof option, div.woof div, div.woof label').live(events[i], function (e) {
261		 try {
262		 if (jQuery(this).parents('.woof').data('redirect').length > 0) {
263		 woof_redirect = jQuery(this).parents('.woof').data('redirect');
264		 }
265		 } catch (e) {
266		 console.log('Error: attribute redirection doesn works!');
267		 }
268		 e.stopPropagation();
269		 });
270		 
271		 }
272		 */
273		//***
274
275
276		return woof_redirect;
277	    }
278	}
279    } catch (e) {
280	console.log(e);
281    }
282
283}
284
285function woof_init_orderby() {
286    jQuery('form.woocommerce-ordering').life('submit', function () {
287	return false;
288    });
289    jQuery('form.woocommerce-ordering select.orderby').life('change', function () {
290	woof_current_values.orderby = jQuery(this).val();
291	woof_ajax_page_num = 1;
292	woof_submit_link(woof_get_submit_link());
293	return false;
294    });
295}
296
297function woof_init_reset_button() {
298    jQuery('.woof_reset_search_form').life('click', function () {
299	//var link = jQuery(this).data('link');
300	woof_ajax_page_num = 1;
301	if (woof_is_permalink) {
302	    woof_current_values = {};
303	    woof_submit_link(woof_get_submit_link().split("page/")[0]);
304	    //woof_submit_link(woof_get_submit_link());
305	} else {
306	    var link = woof_shop_page;
307	    if (woof_current_values.hasOwnProperty('page_id')) {
308		link = location.protocol + '//' + location.host + "/?page_id=" + woof_current_values.page_id;
309		woof_current_values = {'page_id': woof_current_values.page_id};
310		woof_get_submit_link();
311	    }
312	    //***
313	    woof_submit_link(link);
314	    if (woof_is_ajax) {
315		history.pushState({}, "", link);
316		if (woof_current_values.hasOwnProperty('page_id')) {
317		    woof_current_values = {'page_id': woof_current_values.page_id};
318		} else {
319		    woof_current_values = {};
320		}
321	    }
322	}
323	return false;
324    });
325}
326
327function woof_init_pagination() {
328
329    if (woof_is_ajax === 1) {
330	//jQuery('.woocommerce-pagination ul.page-numbers a.page-numbers').life('click', function () {
331	jQuery('a.page-numbers').life('click', function () {
332	    var l = jQuery(this).attr('href');
333
334	    if (woof_ajax_first_done) {
335		//http://woocommerce-filter.pluginus.net/wp-admin/admin-ajax.php?paged=2
336		var res = l.split("paged=");
337		if (typeof res[1] !== 'undefined') {
338		    woof_ajax_page_num = parseInt(res[1]);
339		} else {
340		    woof_ajax_page_num = 1;
341		}
342	    } else {
343		//http://woocommerce-filter.pluginus.net/tester/page/2/
344		var res = l.split("page/");
345		if (typeof res[1] !== 'undefined') {
346		    woof_ajax_page_num = parseInt(res[1]);
347		} else {
348		    woof_ajax_page_num = 1;
349		}
350	    }
351
352	    //+++
353
354	    //if (woof_autosubmit) - pagination doesn need pressing any submit button!!
355	    {
356		woof_submit_link(woof_get_submit_link());
357	    }
358
359	    return false;
360	});
361    }
362}
363
364function woof_init_search_form() {
365    woof_init_checkboxes();
366    woof_init_mselects();
367    woof_init_radios();
368    woof_price_filter_radio_init();
369    woof_init_selects();
370
371
372    //for extensions
373    if (woof_ext_init_functions !== null) {
374	jQuery.each(woof_ext_init_functions, function (type, func) {
375	    eval(func + '()');
376	});
377    }
378    //+++
379    //var containers = jQuery('.woof_container');
380
381    //+++
382    jQuery('.woof_submit_search_form').click(function () {
383	if (woof_ajax_redraw) {
384	    //[woof redirect="http://www.dev.woocommerce-filter.com/test-all/" autosubmit=1 ajax_redraw=1 is_ajax=1 tax_only="locations" by_only="none"]
385	    woof_ajax_redraw = 0;
386	    woof_is_ajax = 0;
387	}
388	//***
389	woof_submit_link(woof_get_submit_link());
390	return false;
391    });
392
393
394
395    //***
396    jQuery('ul.woof_childs_list').parent('li').addClass('woof_childs_list_li');
397
398    //***
399
400    woof_remove_class_widget();
401    woof_checkboxes_slide();
402}
403
404var woof_submit_link_locked = false;
405function woof_submit_link(link) {
406
407    if (woof_submit_link_locked) {
408	return;
409    }
410
411    woof_submit_link_locked = true;
412    woof_show_info_popup(woof_lang_loading);
413
414    if (woof_is_ajax === 1 && !woof_ajax_redraw) {
415	woof_ajax_first_done = true;
416	var data = {
417	    action: "woof_draw_products",
418	    link: link,
419	    page: woof_ajax_page_num,
420	    shortcode: jQuery('#woof_results_by_ajax').data('shortcode'),
421	    woof_shortcode: jQuery('div.woof').data('shortcode')
422	};
423	jQuery.post(woof_ajaxurl, data, function (content) {
424	    content = jQuery.parseJSON(content);
425	    if (jQuery('.woof_results_by_ajax_shortcode').length) {
426		jQuery('#woof_results_by_ajax').replaceWith(content.products);
427	    } else {
428		jQuery('.woof_shortcode_output').replaceWith(content.products);
429	    }
430
431	    jQuery('div.woof_redraw_zone').replaceWith(jQuery(content.form).find('.woof_redraw_zone'));
432	    woof_draw_products_top_panel();
433	    woof_mass_reinit();
434	    woof_submit_link_locked = false;
435	    //removing id woof_results_by_ajax - multi in ajax mode sometimes
436	    //when uses shorcode woof_products in ajax and in settings try ajaxify shop is Yes
437	    jQuery.each(jQuery('#woof_results_by_ajax'), function (index, item) {
438		if (index == 0) {
439		    return;
440		}
441
442		jQuery(item).removeAttr('id');
443	    });
444	    //infinite scroll
445	    woof_infinite();
446	    //*** script after ajax loading here
447	    woof_js_after_ajax_done();
448	});
449
450    } else {
451
452	if (woof_ajax_redraw) {
453	    //redrawing [woof ajax_redraw=1] only
454	    var data = {
455		action: "woof_draw_products",
456		link: link,
457		page: 1,
458		shortcode: 'woof_nothing', //we do not need get any products, seacrh form data only
459		woof_shortcode: jQuery('div.woof').eq(0).data('shortcode')
460	    };
461	    jQuery.post(woof_ajaxurl, data, function (content) {
462		content = jQuery.parseJSON(content);
463		jQuery('div.woof_redraw_zone').replaceWith(jQuery(content.form).find('.woof_redraw_zone'));
464		woof_mass_reinit();
465		woof_submit_link_locked = false;
466	    });
467	} else {
468
469	    window.location = link;
470	    woof_show_info_popup(woof_lang_loading);
471	}
472    }
473}
474
475function woof_remove_empty_elements() {
476    // lets check for empty drop-downs
477    jQuery.each(jQuery('.woof_container select'), function (index, select) {
478	var size = jQuery(select).find('option').size();
479	if (size === 0) {
480	    jQuery(select).parents('.woof_container').remove();
481	}
482    });
483    //+++
484    // lets check for empty checkboxes, radio, color conatiners
485    jQuery.each(jQuery('ul.woof_list'), function (index, ch) {
486	var size = jQuery(ch).find('li').size();
487	if (size === 0) {
488	    jQuery(ch).parents('.woof_container').remove();
489	}
490    });
491}
492
493function woof_get_submit_link() {
494//filter woof_current_values values
495    if (woof_is_ajax) {
496	woof_current_values.page = woof_ajax_page_num;
497    }
498//+++
499    if (Object.keys(woof_current_values).length > 0) {
500	jQuery.each(woof_current_values, function (index, value) {
501	    if (index == swoof_search_slug) {
502		delete woof_current_values[index];
503	    }
504	    if (index == 's') {
505		delete woof_current_values[index];
506	    }
507	    if (index == 'product') {
508//for single product page (when no permalinks)
509		delete woof_current_values[index];
510	    }
511	    if (index == 'really_curr_tax') {
512		delete woof_current_values[index];
513	    }
514	});
515    }
516
517
518    //***
519    if (Object.keys(woof_current_values).length === 2) {
520	if (('min_price' in woof_current_values) && ('max_price' in woof_current_values)) {
521	    var l = woof_current_page_link + '?min_price=' + woof_current_values.min_price + '&max_price=' + woof_current_values.max_price;
522	    if (woof_is_ajax) {
523		history.pushState({}, "", l);
524	    }
525	    return l;
526	}
527    }
528
529
530
531    //***
532
533    if (Object.keys(woof_current_values).length === 0) {
534	if (woof_is_ajax) {
535	    history.pushState({}, "", woof_current_page_link);
536	}
537	return woof_current_page_link;
538    }
539    //+++
540    if (Object.keys(woof_really_curr_tax).length > 0) {
541	woof_current_values['really_curr_tax'] = woof_really_curr_tax.term_id + '-' + woof_really_curr_tax.taxonomy;
542    }
543    //+++
544    var link = woof_current_page_link + "?" + swoof_search_slug + "=1";
545    //console.log(woof_current_page_link);
546    //just for the case when no permalinks enabled
547    if (!woof_is_permalink) {
548
549	if (woof_redirect.length > 0) {
550	    link = woof_redirect + "?" + swoof_search_slug + "=1";
551	    if (woof_current_values.hasOwnProperty('page_id')) {
552		delete woof_current_values.page_id;
553	    }
554	} else {
555	    link = location.protocol + '//' + location.host + "?" + swoof_search_slug + "=1";
556	    /*
557	     if (!woof_is_ajax) {
558	     link = location.protocol + '//' + location.host + "?" + swoof_search_slug + "=1";
559	     }
560	     
561	     if (woof_current_values.hasOwnProperty('page_id')) {
562	     link = location.protocol + '//' + location.host + "?" + swoof_search_slug + "=1";
563	     }
564	     */
565	}
566    }
567    //console.log(link);
568    //throw('STOP!');
569
570    //any trash for different sites, useful for quick support
571    var woof_exclude_accept_array = ['path'];
572
573    if (Object.keys(woof_current_values).length > 0) {
574	jQuery.each(woof_current_values, function (index, value) {
575	    if (index == 'page' && woof_is_ajax) {
576		index = 'paged';//for right pagination if copy/paste this link and send somebody another by email for example
577	    }
578
579	    //http://www.dev.woocommerce-filter.com/?swoof=1&woof_author=3&woof_sku&woof_text=single
580	    //avoid links where values is empty
581	    if (typeof value !== 'undefined') {
582		if ((typeof value && value.length > 0) || typeof value == 'number')
583		{
584		    if (jQuery.inArray(index, woof_exclude_accept_array) == -1) {
585			link = link + "&" + index + "=" + value;
586		    }
587		}
588	    }
589
590	});
591    }
592
593    //+++
594    //remove wp pagination like 'page/2'
595    link = link.replace(new RegExp(/page\/(\d+)\//), "");
596    if (woof_is_ajax) {
597	history.pushState({}, "", link);
598
599    }
600
601    //throw ("STOP!");
602    return link;
603}
604
605
606
607function woof_show_info_popup(text) {
608    if (woof_overlay_skin == 'default') {
609	jQuery("#woof_html_buffer").text(text);
610	jQuery("#woof_html_buffer").fadeTo(200, 0.9);
611    } else {
612	//http://jxnblk.com/loading/
613	switch (woof_overlay_skin) {
614	    case 'loading-balls':
615	    case 'loading-bars':
616	    case 'loading-bubbles':
617	    case 'loading-cubes':
618	    case 'loading-cylon':
619	    case 'loading-spin':
620	    case 'loading-spinning-bubbles':
621	    case 'loading-spokes':
622		jQuery('body').plainOverlay('show', {progress: function () {
623			return jQuery('<div id="woof_svg_load_container"><img style="height: 100%;width: 100%" src="' + woof_link + 'img/loading-master/' + woof_overlay_skin + '.svg" alt=""></div>');
624		    }});
625		break;
626	    default:
627		jQuery('body').plainOverlay('show', {duration: -1});
628		break;
629	}
630    }
631}
632
633
634function woof_hide_info_popup() {
635    if (woof_overlay_skin == 'default') {
636	window.setTimeout(function () {
637	    jQuery("#woof_html_buffer").fadeOut(400);
638	}, 200);
639    } else {
640	jQuery('body').plainOverlay('hide');
641    }
642}
643
644function woof_draw_products_top_panel() {
645
646    if (woof_is_ajax) {
647	jQuery('#woof_results_by_ajax').prev('.woof_products_top_panel').remove();
648    }
649
650    var panel = jQuery('.woof_products_top_panel');
651
652    panel.html('');
653    if (Object.keys(woof_current_values).length > 0) {
654	panel.show();
655	panel.html('<ul></ul>');
656	var is_price_in = false;
657	//lets show this on the panel
658	jQuery.each(woof_current_values, function (index, value) {
659
660	    //lets filter data for the panel
661	    if (jQuery.inArray(index, woof_accept_array) == -1) {
662		return;
663	    }
664
665
666	    //***
667
668
669	    if ((index == 'min_price' || index == 'max_price') && is_price_in) {
670		return;
671	    }
672
673	    if ((index == 'min_price' || index == 'max_price') && !is_price_in) {
674		is_price_in = true;
675		index = 'price';
676		value = woof_lang_pricerange;
677	    }
678	    //+++
679	    value = value.toString().trim();
680	    if (value.search(',')) {
681		value = value.split(',');
682	    }
683	    //+++
684	    jQuery.each(value, function (i, v) {
685		if (index == 'page') {
686		    return;
687		}
688
689		if (index == 'post_type') {
690		    return;
691		}
692
693		var txt = v;
694		if (index == 'orderby') {
695		    if (woof_lang[v] !== undefined) {
696			txt = woof_lang.orderby + ': ' + woof_lang[v];
697		    } else {
698			txt = woof_lang.orderby + ': ' + v;
699		    }
700		} else if (index == 'perpage') {
701		    txt = woof_lang.perpage;
702		} else if (index == 'price') {
703		    txt = woof_lang.pricerange;
704		} else {
705
706		    var is_in_custom = false;
707		    if (Object.keys(woof_lang_custom).length > 0) {
708			jQuery.each(woof_lang_custom, function (i, tt) {
709			    if (i == index) {
710				is_in_custom = true;
711				txt = tt;
712				if (index == 'woof_sku') {
713				    txt += " " + v;//because search by SKU can by more than 1 value
714				}
715			    }
716			});
717		    }
718
719		    if (!is_in_custom) {
720			try {
721			    //txt = jQuery('.woof_n_' + index + '_' + v).val();
722			    txt = jQuery("input[data-anchor='woof_n_" + index + '_' + v + "']").val();
723			} catch (e) {
724			    console.log(e);
725			}
726
727			if (typeof txt === 'undefined')
728			{
729			    txt = v;
730			}
731		    }
732
733
734		    /* hidden feature
735		     if (jQuery('input[name=woof_t_' + index + ']').length > 0) {
736		     txt = jQuery('input[name=woof_t_' + index + ']').val() + ': ' + txt;
737		     }
738		     */
739
740
741		}
742
743		panel.find('ul').append(
744			jQuery('<li>').append(
745			jQuery('<a>').attr('href', v).attr('data-tax', index).append(
746			jQuery('<span>').attr('class', 'woof_remove_ppi').append(txt)
747			)));
748
749	    });
750
751
752	});
753    }
754
755
756    if (jQuery(panel).find('li').size() == 0 || !jQuery('.woof_products_top_panel').length) {
757	panel.hide();
758    }
759
760    //+++
761    jQuery('.woof_remove_ppi').parent().click(function () {
762	var tax = jQuery(this).data('tax');
763	var name = jQuery(this).attr('href');
764
765	//***
766
767	if (tax != 'price') {
768	    values = woof_current_values[tax];
769	    values = values.split(',');
770	    var tmp = [];
771	    jQuery.each(values, function (index, value) {
772		if (value != name) {
773		    tmp.push(value);
774		}
775	    });
776	    values = tmp;
777	    if (values.length) {
778		woof_current_values[tax] = values.join(',');
779	    } else {
780		delete woof_current_values[tax];
781	    }
782	} else {
783	    delete woof_current_values['min_price'];
784	    delete woof_current_values['max_price'];
785	}
786
787	woof_ajax_page_num = 1;
788	//if (woof_autosubmit)
789	{
790	    woof_submit_link(woof_get_submit_link());
791	}
792	jQuery('.woof_products_top_panel').find("[data-tax='" + tax + "'][href='" + name + "']").hide(333);
793	return false;
794    });
795
796}
797
798//control conditions if proucts shortcode uses on the page
799function woof_shortcode_observer() {
800    if (jQuery('.woof_shortcode_output').length) {
801	woof_current_page_link = location.protocol + '//' + location.host + location.pathname;
802    }
803
804    if (jQuery('#woof_results_by_ajax').length) {
805	woof_is_ajax = 1;
806    }
807}
808
809
810
811function woof_init_beauty_scroll() {
812    if (woof_use_beauty_scroll) {
813	try {
814	    var anchor = ".woof_section_scrolled, .woof_sid_auto_shortcode .woof_container_radio .woof_block_html_items, .woof_sid_auto_shortcode .woof_container_checkbox .woof_block_html_items, .woof_sid_auto_shortcode .woof_container_label .woof_block_html_items";
815	    jQuery("" + anchor).mCustomScrollbar('destroy');
816	    jQuery("" + anchor).mCustomScrollbar({
817		scrollButtons: {
818		    enable: true
819		},
820		advanced: {
821		    updateOnContentResize: true,
822		    updateOnBrowserResize: true
823		},
824		theme: "dark-2",
825		horizontalScroll: false,
826		mouseWheel: true,
827		scrollType: 'pixels',
828		contentTouchScroll: true
829	    });
830	} catch (e) {
831	    console.log(e);
832	}
833    }
834}
835
836//just for inbuilt price range widget
837function woof_remove_class_widget() {
838    jQuery('.woof_container_inner').find('.widget').removeClass('widget');
839}
840
841function woof_init_show_auto_form() {
842    jQuery('.woof_show_auto_form').unbind('click');
843    jQuery('.woof_show_auto_form').click(function () {
844	var _this = this;
845	jQuery(_this).addClass('woof_hide_auto_form').removeClass('woof_show_auto_form');
846	jQuery(".woof_auto_show").show().animate(
847		{
848		    height: (jQuery(".woof_auto_show_indent").height() + 20) + "px",
849		    opacity: 1
850		}, 377, function () {
851	    //jQuery(_this).text(woof_lang_hide_products_filter);
852	    woof_init_hide_auto_form();
853	    jQuery('.woof_auto_show').removeClass('woof_overflow_hidden');
854	    jQuery('.woof_auto_show_indent').removeClass('woof_overflow_hidden');
855	    jQuery(".woof_auto_show").height('auto');
856	});
857
858
859	return false;
860    });
861
862
863}
864
865function woof_init_hide_auto_form() {
866    jQuery('.woof_hide_auto_form').unbind('click');
867    jQuery('.woof_hide_auto_form').click(function () {
868	var _this = this;
869	jQuery(_this).addClass('woof_show_auto_form').removeClass('woof_hide_auto_form');
870	jQuery(".woof_auto_show").show().animate(
871		{
872		    height: "1px",
873		    opacity: 0
874		}, 377, function () {
875	    //jQuery(_this).text(woof_lang_show_products_filter);
876	    jQuery('.woof_auto_show').addClass('woof_overflow_hidden');
877	    jQuery('.woof_auto_show_indent').addClass('woof_overflow_hidden');
878	    woof_init_show_auto_form();
879	});
880
881	return false;
882    });
883
884
885}
886
887//if we have mode - child checkboxes closed - append openers buttons by js
888function woof_checkboxes_slide() {
889    if (woof_checkboxes_slide_flag == true) {
890	var childs = jQuery('ul.woof_childs_list');
891	if (childs.size()) {
892	    jQuery.each(childs, function (index, ul) {
893
894		if (jQuery(ul).parents('.woof_no_close_childs').length) {
895		    return;
896		}
897
898		var span_class = 'woof_is_closed';
899		if (jQuery(ul).find('input[type=checkbox],input[type=radio]').is(':checked')) {
900		    jQuery(ul).show();
901		    span_class = 'woof_is_opened';
902		}
903
904		jQuery(ul).before('<a href="javascript:void(0);" class="woof_childs_list_opener"><span class="' + span_class + '"></span></a>');
905	    });
906
907	    jQuery.each(jQuery('a.woof_childs_list_opener'), function (index, a) {
908		jQuery(a).click(function () {
909		    var span = jQuery(this).find('span');
910		    if (span.hasClass('woof_is_closed')) {
911			//lets open
912			jQuery(this).parent().find('ul.woof_childs_list').first().show(333);
913			span.removeClass('woof_is_closed');
914			span.addClass('woof_is_opened');
915		    } else {
916			//lets close
917			jQuery(this).parent().find('ul.woof_childs_list').first().hide(333);
918			span.removeClass('woof_is_opened');
919			span.addClass('woof_is_closed');
920		    }
921
922		    return false;
923		});
924	    });
925	}
926    }
927}
928
929function woof_init_ion_sliders() {
930    jQuery.each(jQuery('.woof_range_slider'), function (index, input) {
931	try {
932	    jQuery(input).ionRangeSlider({
933		min: jQuery(input).data('min'),
934		max: jQuery(input).data('max'),
935		from: jQuery(input).data('min-now'),
936		to: jQuery(input).data('max-now'),
937		type: 'double',
938		prefix: jQuery(input).data('slider-prefix'),
939		postfix: jQuery(input).data('slider-postfix'),
940		prettify: true,
941		hideMinMax: false,
942		hideFromTo: false,
943		grid: true,
944		step: jQuery(input).data('step'),
945		onFinish: function (ui) {
946		    woof_current_values.min_price = parseInt(ui.from, 10);
947		    woof_current_values.max_price = parseInt(ui.to, 10);
948		    //woocs adaptation
949		    if (typeof woocs_current_currency !== 'undefined') {
950			woof_current_values.min_price = Math.ceil(woof_current_values.min_price / parseFloat(woocs_current_currency.rate));
951			woof_current_values.max_price = Math.ceil(woof_current_values.max_price / parseFloat(woocs_current_currency.rate));
952		    }
953		    //***
954		    woof_ajax_page_num = 1;
955		    //jQuery(input).within('.woof').length -> if slider is as shortcode
956		    if (woof_autosubmit || jQuery(input).within('.woof').length == 0) {
957			woof_submit_link(woof_get_submit_link());
958		    }
959		    return false;
960		}
961	    });
962	} catch (e) {
963
964	}
965    });
966}
967
968function woof_init_native_woo_price_filter() {
969    jQuery('.widget_price_filter form').unbind('submit');
970    jQuery('.widget_price_filter form').submit(function () {
971	var min_price = jQuery(this).find('.price_slider_amount #min_price').val();
972	var max_price = jQuery(this).find('.price_slider_amount #max_price').val();
973	woof_current_values.min_price = min_price;
974	woof_current_values.max_price = max_price;
975	woof_ajax_page_num = 1;
976	if (woof_autosubmit || jQuery(input).within('.woof').length == 0) {
977	    //comment next code row to avoid endless ajax requests
978	    woof_submit_link(woof_get_submit_link());
979	}
980	return false;
981    });
982
983}
984
985//we need after ajax redrawing of the search form
986function woof_reinit_native_woo_price_filter() {
987
988    // woocommerce_price_slider_params is required to continue, ensure the object exists
989    if (typeof woocommerce_price_slider_params === 'undefined') {
990	return false;
991    }
992
993    // Get markup ready for slider
994    jQuery('input#min_price, input#max_price').hide();
995    jQuery('.price_slider, .price_label').show();
996
997    // Price slider uses jquery ui
998    var min_price = jQuery('.price_slider_amount #min_price').data('min'),
999	    max_price = jQuery('.price_slider_amount #max_price').data('max'),
1000	    current_min_price = parseInt(min_price, 10),
1001	    current_max_price = parseInt(max_price, 10);
1002
1003    if (woof_current_values.hasOwnProperty('min_price')) {
1004	current_min_price = parseInt(woof_current_values.min_price, 10);
1005	current_max_price = parseInt(woof_current_values.max_price, 10);
1006    } else {
1007	if (woocommerce_price_slider_params.min_price) {
1008	    current_min_price = parseInt(woocommerce_price_slider_params.min_price, 10);
1009	}
1010	if (woocommerce_price_slider_params.max_price) {
1011	    current_max_price = parseInt(woocommerce_price_slider_params.max_price, 10);
1012	}
1013    }
1014
1015    //***
1016
1017    var currency_symbol = woocommerce_price_slider_params.currency_symbol;
1018    if (typeof currency_symbol == undefined) {
1019	currency_symbol = woocommerce_price_slider_params.currency_format_symbol;
1020    }
1021    jQuery(document.body).bind('price_slider_create price_slider_slide', function (event, min, max) {
1022
1023	if (typeof woocs_current_currency !== 'undefined') {
1024	    var label_min = min;
1025	    var label_max = max;
1026
1027
1028	    if (woocs_current_currency.rate !== 1) {
1029		label_min = Math.ceil(label_min * parseFloat(woocs_current_currency.rate));
1030		label_max = Math.ceil(label_max * parseFloat(woocs_current_currency.rate));
1031	    }
1032
1033	    //+++
1034	    label_min = number_format(label_min, 2, '.', ',');
1035	    label_max = number_format(label_max, 2, '.', ',');
1036	    if (jQuery.inArray(woocs_current_currency.name, woocs_array_no_cents) || woocs_current_currency.hide_cents == 1) {
1037		label_min = label_min.replace('.00', '');
1038		label_max = label_max.replace('.00', '');
1039	    }
1040	    //+++
1041
1042
1043	    if (woocs_current_currency.position === 'left') {
1044
1045		jQuery('.price_slider_amount span.from').html(currency_symbol + label_min);
1046		jQuery('.price_slider_amount span.to').html(currency_symbol + label_max);
1047
1048	    } else if (woocs_current_currency.position === 'left_space') {
1049
1050		jQuery('.price_slider_amount span.from').html(currency_symbol + " " + label_min);
1051		jQuery('.price_slider_amount span.to').html(currency_symbol + " " + label_max);
1052
1053	    } else if (woocs_current_currency.position === 'right') {
1054
1055		jQuery('.price_slider_amount span.from').html(label_min + currency_symbol);
1056		jQuery('.price_slider_amount span.to').html(label_max + currency_symbol);
1057
1058	    } else if (woocs_current_currency.position === 'right_space') {
1059
1060		jQuery('.price_slider_amount span.from').html(label_min + " " + currency_symbol);
1061		jQuery('.price_slider_amount span.to').html(label_max + " " + currency_symbol);
1062
1063	    }
1064
1065	} else {
1066
1067	    if (woocommerce_price_slider_params.currency_pos === 'left') {
1068
1069		jQuery('.price_slider_amount span.from').html(currency_symbol + min);
1070		jQuery('.price_slider_amount span.to').html(currency_symbol + max);
1071
1072	    } else if (woocommerce_price_slider_params.currency_pos === 'left_space') {
1073
1074		jQuery('.price_slider_amount span.from').html(currency_symbol + ' ' + min);
1075		jQuery('.price_slider_amount span.to').html(currency_symbol + ' ' + max);
1076
1077	    } else if (woocommerce_price_slider_params.currency_pos === 'right') {
1078
1079		jQuery('.price_slider_amount span.from').html(min + currency_symbol);
1080		jQuery('.price_slider_amount span.to').html(max + currency_symbol);
1081
1082	    } else if (woocommerce_price_slider_params.currency_pos === 'right_space') {
1083
1084		jQuery('.price_slider_amount span.from').html(min + ' ' + currency_symbol);
1085		jQuery('.price_slider_amount span.to').html(max + ' ' + currency_symbol);
1086
1087	    }
1088	}
1089
1090	jQuery(document.body).trigger('price_slider_updated', [min, max]);
1091    });
1092
1093    jQuery('.price_slider').slider({
1094	range: true,
1095	animate: true,
1096	min: min_price,
1097	max: max_price,
1098	values: [current_min_price, current_max_price],
1099	create: function () {
1100
1101	    jQuery('.price_slider_amount #min_price').val(current_min_price);
1102	    jQuery('.price_slider_amount #max_price').val(current_max_price);
1103
1104	    jQuery(document.body).trigger('price_slider_create', [current_min_price, current_max_price]);
1105	},
1106	slide: function (event, ui) {
1107
1108	    jQuery('input#min_price').val(ui.values[0]);
1109	    jQuery('input#max_price').val(ui.values[1]);
1110
1111	    jQuery(document.body).trigger('price_slider_slide', [ui.values[0], ui.values[1]]);
1112	},
1113	change: function (event, ui) {
1114	    jQuery(document.body).trigger('price_slider_change', [ui.values[0], ui.values[1]]);
1115	}
1116    });
1117
1118
1119    //***
1120    woof_init_native_woo_price_filter();
1121}
1122
1123function woof_mass_reinit() {
1124    woof_remove_empty_elements();
1125    woof_open_hidden_li();
1126    woof_init_search_form();
1127    woof_hide_info_popup();
1128    woof_init_beauty_scroll();
1129    woof_init_ion_sliders();
1130    woof_reinit_native_woo_price_filter();//native woo price range slider reinit
1131    woof_recount_text_price_filter();
1132    woof_draw_products_top_panel();
1133}
1134
1135function woof_recount_text_price_filter() {
1136    //change value in textinput price filter if WOOCS is installed
1137    if (typeof woocs_current_currency !== 'undefined') {
1138	jQuery.each(jQuery('.woof_price_filter_txt_from, .woof_price_filter_txt_to'), function (i, item) {
1139	    jQuery(this).val(Math.ceil(jQuery(this).data('value')));
1140	});
1141    }
1142}
1143
1144function woof_init_toggles() {
1145    jQuery('.woof_front_toggle').life('click', function () {
1146	if (jQuery(this).data('condition') == 'opened') {
1147	    jQuery(this).removeClass('woof_front_toggle_opened');
1148	    jQuery(this).addClass('woof_front_toggle_closed');
1149	    jQuery(this).data('condition', 'closed');
1150	    if (woof_toggle_type == 'text') {
1151		jQuery(this).text(woof_toggle_closed_text);
1152	    } else {
1153		jQuery(this).find('img').prop('src', woof_toggle_closed_image);
1154	    }
1155	} else {
1156	    jQuery(this).addClass('woof_front_toggle_opened');
1157	    jQuery(this).removeClass('woof_front_toggle_closed');
1158	    jQuery(this).data('condition', 'opened');
1159	    if (woof_toggle_type == 'text') {
1160		jQuery(this).text(woof_toggle_opened_text);
1161	    } else {
1162		jQuery(this).find('img').prop('src', woof_toggle_opened_image);
1163	    }
1164	}
1165
1166
1167	jQuery(this).parents('.woof_container_inner').find('.woof_block_html_items').toggle(500);
1168	return false;
1169    });
1170}
1171
1172//for "Show more" blocks
1173function woof_open_hidden_li() {
1174    if (jQuery('.woof_open_hidden_li_btn').length > 0) {
1175	jQuery.each(jQuery('.woof_open_hidden_li_btn'), function (i, b) {
1176	    if (jQuery(b).parents('ul').find('li.woof_hidden_term input[type=checkbox],li.woof_hidden_term input[type=radio]').is(':checked')) {
1177		jQuery(b).trigger('click');
1178	    }
1179	});
1180    }
1181}
1182
1183//http://stackoverflow.com/questions/814613/how-to-read-get-data-from-a-url-using-javascript
1184function $_woof_GET(q, s) {
1185    s = (s) ? s : window.location.search;
1186    var re = new RegExp('&' + q + '=([^&]*)', 'i');
1187    return (s = s.replace(/^\?/, '&').match(re)) ? s = s[1] : s = '';
1188}
1189
1190function woof_parse_url(url) {
1191    var pattern = RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?");
1192    var matches = url.match(pattern);
1193    return {
1194	scheme: matches[2],
1195	authority: matches[4],
1196	path: matches[5],
1197	query: matches[7],
1198	fragment: matches[9]
1199    };
1200}
1201
1202
1203//      woof price radio;
1204function woof_price_filter_radio_init() {
1205    if (icheck_skin != 'none') {
1206	jQuery('.woof_price_filter_radio').iCheck('destroy');
1207
1208	jQuery('.woof_price_filter_radio').iCheck({
1209	    radioClass: 'iradio_' + icheck_skin.skin + '-' + icheck_skin.color,
1210	    //radioClass: 'iradio_square-green'        
1211	});
1212
1213	jQuery('.woof_price_filter_radio').siblings('div').removeClass('checked');
1214
1215	jQuery('.woof_price_filter_radio').unbind('ifChecked');
1216	jQuery('.woof_price_filter_radio').on('ifChecked', function (event) {
1217	    jQuery(this).attr("checked", true);
1218	    jQuery('.woof_radio_price_reset').removeClass('woof_radio_term_reset_visible');
1219	    jQuery(this).parents('.woof_list').find('.woof_radio_price_reset').removeClass('woof_radio_term_reset_visible');
1220	    jQuery(this).parents('.woof_list').find('.woof_radio_price_reset').hide();
1221	    jQuery(this).parents('li').eq(0).find('.woof_radio_price_reset').eq(0).addClass('woof_radio_term_reset_visible');
1222	    var val = jQuery(this).val();
1223	    if (parseInt(val, 10) == -1) {
1224		delete woof_current_values.min_price;
1225		delete woof_current_values.max_price;
1226		jQuery(this).removeAttr('checked');
1227		jQuery(this).siblings('.woof_radio_price_reset').removeClass('woof_radio_term_reset_visible');
1228	    } else {
1229		var val = val.split("-");
1230		woof_current_values.min_price = val[0];
1231		woof_current_values.max_price = val[1];
1232		jQuery(this).siblings('.woof_radio_price_reset').addClass('woof_radio_term_reset_visible');
1233		jQuery(this).attr("checked", true);
1234	    }
1235	    if (woof_autosubmit || jQuery(this).within('.woof').length == 0) {
1236		woof_submit_link(woof_get_submit_link());
1237	    }
1238	});
1239
1240    } else {
1241	jQuery('.woof_price_filter_radio').life('change', function () {
1242	    var val = jQuery(this).val();
1243	    jQuery('.woof_radio_price_reset').removeClass('woof_radio_term_reset_visible');
1244	    if (parseInt(val, 10) == -1) {
1245		delete woof_current_values.min_price;
1246		delete woof_current_values.max_price;
1247		jQuery(this).removeAttr('checked');
1248		jQuery(this).siblings('.woof_radio_price_reset').removeClass('woof_radio_term_reset_visible');
1249	    } else {
1250		var val = val.split("-");
1251		woof_current_values.min_price = val[0];
1252		woof_current_values.max_price = val[1];
1253		jQuery(this).siblings('.woof_radio_price_reset').addClass('woof_radio_term_reset_visible');
1254		jQuery(this).attr("checked", true);
1255	    }
1256	    if (woof_autosubmit || jQuery(this).within('.woof').length == 0) {
1257		woof_submit_link(woof_get_submit_link());
1258	    }
1259	});
1260    }
1261    //***
1262    jQuery('.woof_radio_price_reset').click(function () {
1263	delete woof_current_values.min_price;
1264	delete woof_current_values.max_price;
1265	jQuery(this).siblings('div').removeClass('checked');
1266	jQuery(this).parents('.woof_list').find('input[type=radio]').removeAttr('checked');
1267	//jQuery(this).remove();
1268	jQuery(this).removeClass('woof_radio_term_reset_visible');
1269	if (woof_autosubmit) {
1270	    woof_submit_link(woof_get_submit_link());
1271	}
1272	return false;
1273    });
1274}
1275//    END  woof price radio;
1276
1277
1278
1279//compatibility with YITH Infinite Scrolling
1280function woof_serialize(serializedString) {
1281    var str = decodeURI(serializedString);
1282    var pairs = str.split('&');
1283    var obj = {}, p, idx, val;
1284    for (var i = 0, n = pairs.length; i < n; i++) {
1285	p = pairs[i].split('=');
1286	idx = p[0];
1287
1288	if (idx.indexOf("[]") == (idx.length - 2)) {
1289	    // Eh um vetor
1290	    var ind = idx.substring(0, idx.length - 2)
1291	    if (obj[ind] === undefined) {
1292		obj[ind] = [];
1293	    }
1294	    obj[ind].push(p[1]);
1295	} else {
1296	    obj[idx] = p[1];
1297	}
1298    }
1299    return obj;
1300}
1301
1302
1303//compatibility with YITH Infinite Scrolling
1304function woof_infinite() {
1305
1306    if (typeof yith_infs === 'undefined') {
1307	return;
1308    }
1309    
1310  
1311    //***
1312    var infinite_scroll1 = {
1313	//'nextSelector': ".woof_infinity .nav-links .next",
1314        'nextSelector': '.woocommerce-pagination li .next',
1315	'navSelector': yith_infs.navSelector,
1316	'itemSelector': yith_infs.itemSelector,
1317	'contentSelector': yith_infs.contentSelector,
1318	'loader': '<img src="' + yith_infs.loader + '">',
1319	'is_shop': yith_infs.shop
1320    };
1321var curr_l = window.location.href;
1322var curr_link = curr_l.split('?');
1323var get="";
1324    if (curr_link[1] != undefined) {
1325	var temp = woof_serialize(curr_link[1]);
1326	delete temp['paged'];
1327	get = decodeURIComponent(jQuery.param(temp))
1328    }
1329    
1330  var page_link = jQuery('.woocommerce-pagination li .next').attr("href");
1331    //console.log(page_link);
1332    if(page_link==undefined){
1333       page_link=curr_link+"page/1/"
1334    }
1335console.log(page_link );
1336var ajax_link=page_link.split('?');
1337var page="";
1338    if (ajax_link[1] != undefined) {
1339	var temp1 = woof_serialize(ajax_link[1]);
1340        if(temp1['paged']!=undefined){
1341          page= "page/"+ temp1['paged']+"/"; 
1342        }
1343    }
1344
1345    page_link = curr_link[0] +page+ '?' + get;
1346    //console.log(page_link);
1347    jQuery('.woocommerce-pagination li .next').attr('href', page_link);
1348    
1349    jQuery(window).unbind("yith_infs_start"), jQuery(yith_infs.contentSelector).yit_infinitescroll(infinite_scroll1)
1350}
1351//End infinity scroll
1352
1353

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.