PageSourceSearch

https://www.premier-mfg.com/wp-content/plugins/woocommerce-products-filter/js/front.js?ver=2.2.4

js premier-mfg.com collected 2026-09-30 15:29:15 UTC 46,843 bytes, 1,544 lines download raw bytes

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

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.