PageSourceSearch

https://cerclearistote.fr/wp-content/plugins/woo-product-filter/js/core.js?ver=3.4.5

js cerclearistote.fr collected 2026-10-02 11:45:50 UTC 13,894 bytes, 428 lines download raw bytes

1/**
2 * Product Filter by WBW - Core JS
3 *
4 * @version 3.3.0
5 *
6 * @author woobewoo
7 */
8
9"use strict";
10if(typeof(WPF_DATA) == 'undefined')
11	var WPF_DATA = {};
12if(isNumber(WPF_DATA.animationSpeed))
13    WPF_DATA.animationSpeed = parseInt(WPF_DATA.animationSpeed);
14else if(jQuery.inArray(WPF_DATA.animationSpeed, ['fast', 'slow']) == -1)
15    WPF_DATA.animationSpeed = 'fast';
16WPF_DATA.showSubscreenOnCenter = parseInt(WPF_DATA.showSubscreenOnCenter);
17var sdLoaderImgWpf = '<img src="'+ WPF_DATA.loader+ '" />';
18var g_wpfAnimationSpeed = 300;
19
20jQuery.fn.showLoaderWpf = function() {
21    return jQuery(this).html( sdLoaderImgWpf );
22};
23jQuery.fn.appendLoaderWpf = function() {
24    jQuery(this).append( sdLoaderImgWpf );
25};
26jQuery.sendFormWpf = function(params) {
27	// Any html element can be used here
28	return jQuery('<br />').sendFormWpf(params);
29};
30/**
31 * Send form or just data to server by ajax and route response
32 * @param string params.fid form element ID, if empty - current element will be used
33 * @param string params.msgElID element ID to store result messages, if empty - element with ID "msg" will be used. Can be "noMessages" to not use this feature
34 * @param function params.onSuccess funstion to do after success receive response. Be advised - "success" means that ajax response will be success
35 * @param array params.data data to send if You don't want to send Your form data, will be set instead of all form data
36 * @param array params.appendData data to append to sending request. In contrast to params.data will not erase form data
37 * @param string params.inputsWraper element ID for inputs wraper, will be used if it is not a form
38 * @param string params.clearMsg clear msg element after receive data, if is number - will use it to set time for clearing, else - if true - will clear msg element after 5 seconds
39 */
40jQuery.fn.sendFormWpf = function(params) {
41    var form = null;
42    if(!params)
43        params = {fid: false, msgElID: false, onSuccess: false};
44    if(params.fid)
45        form = jQuery('#'+ fid);
46    else
47        form = jQuery(this);
48
49    /* This method can be used not only from form data sending, it can be used just to send some data and fill in response msg or errors*/
50    var sentFromForm = (jQuery(form).tagName() == 'FORM');
51    var data = new Array();
52    if(params.data)
53        data = params.data;
54    else if(sentFromForm)
55        data = jQuery(form).serialize();
56
57    if(params.appendData) {
58		var dataIsString = typeof(data) == 'string';
59		var addStrData = [];
60        for(var i in params.appendData) {
61			if(dataIsString) {
62				addStrData.push(i+ '='+ params.appendData[i]);
63			} else
64            data[i] = params.appendData[i];
65        }
66		if(dataIsString)
67			data += '&'+ addStrData.join('&');
68    }
69    var msgEl = null;
70    if(params.msgElID) {
71        if(params.msgElID == 'noMessages')
72            msgEl = false;
73        else if(typeof(params.msgElID) == 'object')
74           msgEl = params.msgElID;
75       else
76            msgEl = jQuery('#'+ params.msgElID);
77    }
78	if(typeof(params.inputsWraper) == 'string') {
79		form = jQuery('#'+ params.inputsWraper);
80		sentFromForm = true;
81	}
82	if(sentFromForm && form) {
83        jQuery(form).find('.wpfInputError').removeClass('wpfInputError');
84    }
85	if(msgEl && !params.btn) {
86		jQuery(msgEl)
87			.removeClass('wpfSuccessMsg')
88			.removeClass('wpfErrorMsg');
89		if(!params.btn) {
90			jQuery(msgEl).showLoaderWpf();
91		}
92	}
93	if(params.btn) {
94		jQuery(params.btn).attr('disabled', 'disabled');
95		// Font awesome usage
96		params.btnIconElement = jQuery(params.btn).find('.fa').length ? jQuery(params.btn).find('.fa') : jQuery(params.btn);
97		if(jQuery(params.btn).find('.fa').length) {
98			params.btnIconElement
99				.data('prev-class', params.btnIconElement.attr('class'))
100				.attr('class', 'fa fa-spinner fa-spin');
101		} else {
102			params.btnIconElement.attr('data-prev-text', params.btnIconElement.html());
103			params.btnIconElement.html('<i class="fa fa-spinner fa-spin"></i>');
104		}
105	}
106    var url = '';
107	if(typeof(params.url) != 'undefined')
108		url = params.url;
109    else if(typeof(ajaxurl) == 'undefined' || typeof(ajaxurl) !== 'string')
110        url = WPF_DATA.ajaxurl;
111    else
112        url = ajaxurl;
113
114    jQuery('.wpfErrorForField').hide(WPF_DATA.animationSpeed);
115	var dataType = params.dataType ? params.dataType : 'json';
116	// Set plugin orientation
117	if(typeof(data) == 'string') {
118		data += '&pl='+ WPF_DATA.WPF_CODE;
119		data += '&reqType=ajax';
120	} else {
121		data['pl'] = WPF_DATA.WPF_CODE;
122		data['reqType'] = 'ajax';
123	}
124
125    jQuery.ajax({
126        url: url,
127        data: data,
128        type: 'POST',
129        dataType: dataType,
130        success: function(res) {
131            toeProcessAjaxResponseWpf(res, msgEl, form, sentFromForm, params);
132			if(params.clearMsg) {
133				setTimeout(function(){
134					if(msgEl)
135						jQuery(msgEl).animateClear();
136				}, typeof(params.clearMsg) == 'boolean' ? 5000 : params.clearMsg);
137			}
138        }
139    });
140};
141/**
142 * Hide content in element and then clear it
143 */
144jQuery.fn.animateClear = function() {
145	var newContent = jQuery('<span>'+ jQuery(this).html()+ '</span>');
146	jQuery(this).html( newContent );
147	jQuery(newContent).hide(WPF_DATA.animationSpeed, function(){
148		jQuery(newContent).remove();
149	});
150};
151/**
152 * Hide content in element and then remove it
153 */
154jQuery.fn.animateRemoveWpf = function(animationSpeed, onSuccess) {
155	animationSpeed = animationSpeed == undefined ? WPF_DATA.animationSpeed : animationSpeed;
156	jQuery(this).hide(animationSpeed, function(){
157		jQuery(this).remove();
158		if(typeof(onSuccess) === 'function')
159			onSuccess();
160	});
161};
162function toeProcessAjaxResponseWpf(res, msgEl, form, sentFromForm, params) {
163    if(typeof(params) == 'undefined')
164        params = {};
165    if(typeof(msgEl) == 'string')
166        msgEl = jQuery('#'+ msgEl);
167    if(msgEl)
168        jQuery(msgEl).html('');
169	if(params.btn) {
170		jQuery(params.btn).removeAttr('disabled');
171		if(params.btnIconElement) {
172			params.btnIconElement.attr('class', params.btnIconElement.data('prev-class'));
173			var prevText = params.btnIconElement.attr('data-prev-text');
174			if (prevText && prevText.length) params.btnIconElement.html(prevText);
175		}
176	}
177    /*if(sentFromForm) {
178        jQuery(form).find('*').removeClass('wpfInputError');
179    }*/
180    if(typeof(res) == 'object') {
181        if(res.error) {
182            if(msgEl) {
183                jQuery(msgEl)
184					.removeClass('wpfSuccessMsg')
185					.addClass('wpfErrorMsg');
186            }
187			var errorsArr = [];
188            for(var name in res.errors) {
189                if(sentFromForm) {
190					var inputError = jQuery(form).find('[name*="'+ name+ '"]');
191                    inputError.addClass('wpfInputError');
192					if(!inputError.data('keyup-error-remove-binded')) {
193						inputError.keydown(function(){
194							jQuery(this).removeClass('wpfInputError');
195						}).data('keyup-error-remove-binded', 1);
196					}
197                }
198                if(jQuery('.wpfErrorForField.toe_'+ nameToClassId(name)+ '').exists())
199                    jQuery('.wpfErrorForField.toe_'+ nameToClassId(name)+ '').show().html(res.errors[name]);
200                else if(msgEl)
201                    jQuery(msgEl).append(res.errors[name]).append('<br />');
202				else
203					errorsArr.push( res.errors[name] );
204            }
205			if(errorsArr.length && params.btn && jQuery.fn.dialog && !msgEl && !params.noError) {
206				jQuery('<div title="'+ toeLangWpf("Really small warning :)")+ '" />').html( errorsArr.join('<br />') ).appendTo('body').dialog({
207					modal: true
208				,	width: '500px'
209				});
210			}
211        } else if(res.messages.length) {
212            if(msgEl) {
213                jQuery(msgEl)
214					.removeClass('wpfErrorMsg')
215					.addClass('wpfSuccessMsg');
216                for(var i = 0; i < res.messages.length; i++) {
217                    jQuery(msgEl).append(res.messages[i]).append('<br />');
218                }
219            }
220        }
221    }
222    if(params.onSuccess && typeof(params.onSuccess) == 'function') {
223        params.onSuccess(res);
224    }
225}
226
227function getDialogElementWpf() {
228	return jQuery('<div/>').appendTo(jQuery('body'));
229}
230
231function toeOptionWpf(key) {
232	if(WPF_DATA.options && WPF_DATA.options[ key ])
233		return WPF_DATA.options[ key ];
234	return false;
235}
236function toeLangWpf(key) {
237	if(WPF_DATA.siteLang && WPF_DATA.siteLang[key])
238		return WPF_DATA.siteLang[key];
239	return key;
240}
241function toePagesWpf(key) {
242	if(typeof(WPF_DATA) != 'undefined' && WPF_DATA[key])
243		return WPF_DATA[key];
244	return false;;
245}
246/**
247 * This function will help us not to hide desc right now, but wait - maybe user will want to select some text or click on some link in it.
248 */
249function toeOptTimeoutHideDescriptionWpf() {
250	jQuery('#wpfOptDescription').removeAttr('toeFixTip');
251	setTimeout(function(){
252		if(!jQuery('#wpfOptDescription').attr('toeFixTip'))
253			toeOptHideDescriptionWpf();
254	}, 500);
255}
256/**
257 * Show description for options
258 */
259function toeOptShowDescriptionWpf(description, x, y, moveToLeft) {
260    if(typeof(description) != 'undefined' && description != '') {
261        if(!jQuery('#wpfOptDescription').length) {
262            jQuery('body').append('<div id="wpfOptDescription"></div>');
263        }
264		if(moveToLeft)
265			jQuery('#wpfOptDescription').css('right', jQuery(window).width() - (x - 10));	// Show it on left side of target
266		else
267			jQuery('#wpfOptDescription').css('left', x + 10);
268        jQuery('#wpfOptDescription').css('top', y);
269        jQuery('#wpfOptDescription').show(200);
270        jQuery('#wpfOptDescription').html(description);
271    }
272}
273/**
274 * Hide description for options
275 */
276function toeOptHideDescriptionWpf() {
277	jQuery('#wpfOptDescription').removeAttr('toeFixTip');
278    jQuery('#wpfOptDescription').hide(200);
279}
280function toeInArrayWpf(needle, haystack) {
281	if(haystack) {
282		for(var i in haystack) {
283			if(haystack[i] == needle)
284				return true;
285		}
286	}
287	return false;
288}
289function toeShowDialogCustomized(element, options) {
290	options = jQuery.extend({
291		resizable: false
292	,	width: 500
293	,	height: 300
294	,	closeOnEscape: true
295	,	open: function(event, ui) {
296			jQuery('.ui-dialog-titlebar').css({
297				'background-color': '#222222'
298			,	'background-image': 'none'
299			,	'border': 'none'
300			,	'margin': '0'
301			,	'padding': '0'
302			,	'border-radius': '0'
303			,	'color': '#CFCFCF'
304			,	'height': '27px'
305			});
306			jQuery('.ui-dialog-titlebar-close').css({
307				'background': 'url("'+ WPF_DATA.cssPath+ 'img/tb-close.png") no-repeat scroll 0 0 transparent'
308			,	'border': '0'
309			,	'width': '15px'
310			,	'height': '15px'
311			,	'padding': '0'
312			,	'border-radius': '0'
313			,	'margin': '7px 7px 0'
314			}).html('');
315			jQuery('.ui-dialog').css({
316				'border-radius': '3px'
317			,	'background-color': '#FFFFFF'
318			,	'background-image': 'none'
319			,	'padding': '1px'
320			,	'z-index': '300000'
321			,	'position': 'fixed'
322			,	'top': '60px'
323			});
324			jQuery('.ui-dialog-buttonpane').css({
325				'background-color': '#FFFFFF'
326			});
327			jQuery('.ui-dialog-title').css({
328				'color': '#CFCFCF'
329			,	'font': '12px sans-serif'
330			,	'padding': '6px 10px 0'
331			});
332			if(options.openCallback && typeof(options.openCallback) == 'function') {
333				options.openCallback(event, ui);
334			}
335			jQuery('.ui-widget-overlay').css({
336				'z-index': jQuery( event.target ).parents('.ui-dialog:first').css('z-index') - 1
337			,	'background-image': 'none'
338			});
339			if(options.modal && options.closeOnBg) {
340				jQuery('.ui-widget-overlay').unbind('click').bind('click', function() {
341					jQuery( element ).dialog('close');
342				});
343			}
344		}
345	}, options);
346	return jQuery(element).dialog(options);
347}
348/**
349 * @see html::slider();
350 **/
351function toeSliderMove(event, ui) {
352    var id = jQuery(event.target).attr('id');
353    jQuery('#toeSliderDisplay_'+ id).html( ui.value );
354    jQuery('#toeSliderInput_'+ id).val( ui.value ).change();
355}
356function wpfCorrectJqueryUsed() {
357	return (typeof(jQuery.fn.sendFormWpf) === 'function');
358}
359function _wpfRunClbAfterCoreReload(clb, params) {
360	if(wpfCorrectJqueryUsed()) {
361		callUserFuncArray(clb, params);
362		return;
363	}
364	setTimeout(function(){
365		wpfCorrectJqueryUsed(clb, params);
366	}, 500);
367}
368function wpfGetStyleSheetRule(sheetId, rule, isLike) {
369	var obj = document.getElementById(sheetId),
370		sheet = obj.sheet || obj.styleSheet,
371		rules = sheet.cssRules || sheet.rules,
372		isLike = typeof isLike == 'undefined' ? false : isLike;
373	for (var r = 0; r < rules.length; r++) {
374		if(isLike) {
375			if(rules[r].selectorText.indexOf(rule) === 0) return rules[r];
376		} else if(rules[r].selectorText == rule) return rules[r];
377	}
378	return false;
379}
380function wpfGetColorText(bg) {
381	if(typeof bg !== 'undefined' && bg.length >= 7) {
382		var rgb = (/^#[0-9A-F]{6}$/i.test(bg))
383			? [0, parseInt(bg.substring(1,3),16), parseInt(bg.substring(3,5),16), parseInt(bg.substring(5,7),16)]
384			: bg.replace(/\s/g,'').match(/^rgba?\((\d+),(\d+),(\d+)/i);
385		if(rgb.length >= 4 && (1 - (0.299 * rgb[1] + 0.587 * rgb[2] + 0.114 * rgb[3]) / 255) > 0.5) return '#dddddd';
386	}
387	return '#444444';
388}
389function wpfLightenDarkenColor(col, amt) {
390	var usePound = false,
391		r = 255,
392		g = 255,
393		b = 255;
394	if(typeof col !== 'undefined' && col.length >= 7) {
395		if(col.indexOf('rgb') == -1) {
396			if(col[0] == "#") {
397				col = col.slice(1);
398				usePound = true;
399			}
400 			var num = parseInt(col, 16);
401			r = (num >> 16);
402			b = ((num >> 8) & 0x00FF);
403			g = (num & 0x0000FF);
404		} else {
405			var withA = col.indexOf('rgba') != -1,
406				rgb = withA ? col.replace(/\s/g,'').match(/^rgba?\((\d+),(\d+),(\d+),(\d+)/i) : col.replace(/\s/g,'').match(/^rgba?\((\d+),(\d+),(\d+)/i);
407			if(rgb.length >= 4) {
408				var a = withA ? rgb[3] : 1,
409					bg = (1 - a) * 255;
410				r = rgb[1] * a + bg;
411				g = rgb[2] * a + bg;
412				b = rgb[3] * a + bg;
413			}
414			usePound = true;
415		}
416	}
417	r = r + amt;
418	b = b + amt;
419	g = g + amt;
420	if(r > 255) r = 255;
421	else if(r < 0) r = 0;
422	if(b > 255) b = 255;
423	else if(b < 0) b = 0;
424	if(g > 255) g = 255;
425	else if(g < 0) g = 0;
426	var res = (g | (b << 8) | (r << 16)).toString(16);
427	return (usePound?"#":"") + '0'.repeat(6 - res.length) + res;
428}

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.