PageSourceSearch

https://sandybrown-seahorse-487194.hostingersite.com/wp-content/pl…/assets/js/scripts.js?ver=20120206

js sandybrown-seahorse-487194.hostingersite.com collected 2026-10-03 04:53:23 UTC 15,406 bytes, 552 lines download raw bytes

1jQuery(document).ready(function($) {
2	var listing_class 		= ".products";
3	var item_class 			= ".products > .product";
4	var pagination_class 	= "body.woocommerce-shop .woocommerce-pagination";
5	var next_page_class 	= ".woocommerce-pagination a.next";
6	var ajax_button_class 	= ".products_ajax_button";
7	var ajax_loader_class 	= ".products_ajax_loader";
8	var loadmore_text = nova_js_var.load_more_btn;
9
10	var ajax_load_items = {
11
12			init: function() {
13
14					if (nova_js_var.shop_pagination_type == 'load_more_button' || nova_js_var.shop_pagination_type == 'infinite_scroll') {
15
16						$(document).ready(function() {
17
18								if ($(pagination_class).length) {
19
20										$(pagination_class).before('<div class="'+ajax_button_class.replace('.', '')+'" data-processing="0"><span>'+loadmore_text+'</span></div>');
21
22								}
23
24						});
25
26					}
27
28					if (nova_js_var.shop_pagination_type == 'infinite_scroll') {
29
30						var buffer_pixels = Math.abs(100);
31
32						$(window).scroll(function() {
33
34								if ($(listing_class).length) {
35
36										var a = $(listing_class).offset().top + $(listing_class).outerHeight();
37										var b = a - $(window).scrollTop();
38
39										if ((b - buffer_pixels) < $(window).height()) {
40												if ($(ajax_button_class).attr('data-processing') == 0) {
41														$(ajax_button_class).trigger('click');
42												}
43										}
44
45								}
46
47						});
48
49					}
50
51			},
52
53			onstart: function() {
54			},
55
56			onfinish: function() {
57
58			},
59
60			msieversion: function() {
61					var ua = window.navigator.userAgent;
62					var msie = ua.indexOf("MSIE ");
63
64					if (msie > 0)
65							return parseInt(ua.substring(msie + 5, ua.indexOf(".", msie)));
66
67					return false;
68			},
69
70	};
71	// return false if novaapf_params variable is not found
72	if (typeof novaapf_params === 'undefined') {
73		return false;
74	}
75
76	// store widget ids those will be replaced with new data
77	var widgets = {};
78
79	$('.novaapf-ajax-term-filter').each(function(index) {
80		var widget_id = $(this).attr('id');
81		widgets[index] = widget_id;
82	});
83
84	// scripts to run before updating shop loop
85	novaapfBeforeUpdate = function() {
86		var overlay_color;
87
88		if (novaapf_params.overlay_bg_color.length) {
89			overlay_color = novaapf_params.overlay_bg_color;
90		} else {
91			overlay_color = '#fff';
92		}
93
94		var markup = '<div class="novaapf-before-update" style="background-color: ' + overlay_color + '"></div>',
95			holder,
96			top_scroll_offset = 0;
97
98		if ($(novaapf_params.shop_loop_container.length)) {
99			holder = novaapf_params.shop_loop_container;
100		} else if ($(novaapf_params.not_found_container).length) {
101			holder = novaapf_params.not_found_container;
102		}
103
104		if (holder.length) {
105			// show loading image
106			$(markup).prependTo(holder);
107
108			// scroll to top
109			if (typeof novaapf_params.scroll_to_top !== 'undefined' && novaapf_params.scroll_to_top == true) {
110				var scroll_to_top_offset,
111					top_scroll_offset;
112
113				if (typeof novaapf_params.scroll_to_top_offset !== 'undefined' && novaapf_params.scroll_to_top_offset.length) {
114					scroll_to_top_offset = parseInt(novaapf_params.scroll_to_top_offset);
115				} else {
116					scroll_to_top_offset = 100;
117				}
118
119				top_scroll_offset = $(holder).offset().top - scroll_to_top_offset;
120
121				if (top_scroll_offset < 0) {
122					top_scroll_offset = 0;
123				}
124
125				$('html, body').animate({scrollTop: top_scroll_offset}, 'slow');
126			}
127		}
128
129	}
130
131	// scripts to run after updating shop loop
132	novaapfAfterUpdate = function() {
133		// Compatibility with YITH Wishlist Pro
134		setTimeout( function(){
135			$(document).trigger( 'yith_infs_added_elem' );
136		}, 1000 );
137		ajax_load_items.init();
138		if ( typeof $.fn.select2 === 'function' ) {
139
140			$('.woocommerce-ordering .orderby').select2({
141				minimumResultsForSearch: -1,
142				placeholder: nova_js_var.select_placeholder,
143				dropdownParent: $('.woocommerce-archive-header-inside'),
144				allowClear: false,
145				dropdownAutoWidth: true,
146			})
147		}
148		Novaworks.module.SwitchProductsAppearance();
149	}
150
151	// load filtered products
152	novaapfFilterProducts = function() {
153		// run before update function: show a loading image and scroll to top
154		novaapfBeforeUpdate();
155
156		$.get(window.location.href, function(data) {
157			var $data = jQuery(data),
158				shop_loop = $data.find(novaapf_params.shop_loop_container),
159				not_found = $data.find(novaapf_params.not_found_container);
160
161			// replace widgets data with new data
162			$.each(widgets, function(index, id) {
163				var single_widget = $data.find('#' + id),
164					single_widget_class = $(single_widget).attr('class');
165
166				// update class
167				$('#' + id).attr('class', single_widget_class);
168				// update widget
169				$('#' + id).html(single_widget.html());
170			});
171
172			// replace old shop loop with new one
173			if (novaapf_params.shop_loop_container == novaapf_params.not_found_container) {
174				$(novaapf_params.shop_loop_container).html(shop_loop.html());
175			} else {
176				if ($(novaapf_params.not_found_container).length) {
177					if (shop_loop.length) {
178						$(novaapf_params.not_found_container).html(shop_loop.html());
179					} else if (not_found.length) {
180						$(novaapf_params.not_found_container).html(not_found.html());
181					}
182				} else if ($(novaapf_params.shop_loop_container).length) {
183					if (shop_loop.length) {
184						$(novaapf_params.shop_loop_container).html(shop_loop.html());
185					} else if (not_found.length) {
186						$(novaapf_params.shop_loop_container).html(not_found.html());
187					}
188				}
189			}
190
191			// reinitialize ordering
192			novaapfInitOrder();
193
194			// reinitialize dropdown filter
195			novaapfDropDownFilter();
196
197			// after update
198			novaapfAfterUpdate();
199
200			// run scripts after shop loop undated
201			if (typeof novaapf_params.custom_scripts !== 'undefined' && novaapf_params.custom_scripts.length > 0) {
202				eval(novaapf_params.custom_scripts);
203			}
204		});
205	}
206
207	// URL Parser
208	novaapfGetUrlVars = function(url) {
209	    var vars = {}, hash;
210
211	    if (typeof url == 'undefined') {
212	    	url = window.location.href;
213	    } else {
214	    	url = url;
215	    }
216
217	    var hashes = url.slice(url.indexOf('?') + 1).split('&');
218	    for (var i = 0; i < hashes.length; i++) {
219	        hash = hashes[i].split('=');
220	        vars[hash[0]] = hash[1];
221	    }
222	    return vars;
223	}
224
225	// if current page is greater than 1 then we should set it to 1
226	// everytime we add new query to url to prevent page not found error.
227	novaapfFixPagination = function() {
228		var url = window.location.href,
229			params = novaapfGetUrlVars(url);
230
231		if (current_page = parseInt(url.replace(/.+\/page\/([0-9]+)+/, "$1"))) {
232			if (current_page > 1) {
233				url = url.replace(/page\/([0-9]+)/, 'page/1');
234			}
235		}
236		else if(typeof params['paged'] != 'undefined') {
237			current_page = parseInt(params['paged']);
238			if (current_page > 1) {
239				url = url.replace('paged=' + current_page, 'paged=1');
240			}
241		}
242
243		return url;
244	}
245
246	// update query string for categories, meta etc..
247	novaapfUpdateQueryStringParameter = function(key, value, push_history, url) {
248		if (typeof push_history === 'undefined') {
249			push_history = true;
250		}
251
252		if (typeof url === 'undefined') {
253			url = novaapfFixPagination();
254		}
255
256		var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i"),
257			separator = url.indexOf('?') !== -1 ? "&" : "?",
258			url_with_query;
259
260		if (url.match(re)) {
261			url_with_query = url.replace(re, '$1' + key + "=" + value + '$2');
262		}
263		else {
264			url_with_query = url + separator + key + "=" + value;
265		}
266
267		if (push_history === true) {
268			return history.pushState({}, '', url_with_query);
269		} else {
270			return url_with_query;
271		}
272	}
273
274	// remove parameter from url
275	novaapfRemoveQueryStringParameter = function(filter_key, url) {
276		if (typeof url === 'undefined') {
277			url = novaapfFixPagination();
278		}
279
280		var params = novaapfGetUrlVars(url),
281			count_params = Object.keys(params).length,
282			start_position = url.indexOf('?'),
283			param_position = url.indexOf(filter_key),
284			clean_url,
285			clean_query;
286
287		if (count_params > 1) {
288			if ((param_position - start_position) > 1) {
289				clean_url = url.replace('&' + filter_key + '=' + params[filter_key], '');
290			} else {
291				clean_url = url.replace(filter_key + '=' + params[filter_key] + '&', '');
292			}
293
294			var params = clean_url.split('?');
295			clean_query = '?' + params[1];
296		} else {
297			clean_query = url.replace('?' + filter_key + '=' + params[filter_key], '');
298		}
299
300		return clean_query;
301	}
302
303	// add filter if not exists else remove filter
304	novaapfSingleFilter = function(filter_key, filter_val) {
305		var params = novaapfGetUrlVars(),
306			query;
307
308		if (typeof params[filter_key] !== 'undefined' && params[filter_key] == filter_val) {
309			query = novaapfRemoveQueryStringParameter(filter_key);
310		} else {
311			query = novaapfUpdateQueryStringParameter(filter_key, filter_val, false);
312		}
313		// update url
314		history.pushState({}, '', query);
315
316		// filter products
317		novaapfFilterProducts();
318	}
319
320	// take the key and value and make query
321	novaapfMakeParameters = function(filter_key, filter_val, url) {
322		var params,
323			next_vals,
324			empty_val = false;
325
326		if (typeof url !== 'undefined') {
327			params = novaapfGetUrlVars(url);
328		} else {
329			params = novaapfGetUrlVars();
330		}
331
332		if (typeof params[filter_key] != 'undefined') {
333			var prev_vals = params[filter_key],
334				prev_vals_array = prev_vals.split(',');
335
336			if (prev_vals.length > 0) {
337				var found = jQuery.inArray(filter_val, prev_vals_array);
338
339				if (found >= 0) {
340				    // Element was found, remove it.
341				    prev_vals_array.splice(found, 1);
342
343				    if (prev_vals_array.length == 0) {
344				    	empty_val = true;
345				    }
346				} else {
347				    // Element was not found, add it.
348				    prev_vals_array.push(filter_val);
349				}
350
351				if (prev_vals_array.length > 1) {
352					next_vals = prev_vals_array.join(',');
353				} else {
354					next_vals = prev_vals_array;
355				}
356			} else {
357				next_vals = filter_val;
358			}
359		} else {
360			next_vals = filter_val;
361		}
362
363		// update url and query string
364		if (empty_val == false) {
365			novaapfUpdateQueryStringParameter(filter_key, next_vals);
366		} else {
367			var query = novaapfRemoveQueryStringParameter(filter_key);
368			history.pushState({}, '', query);
369		}
370
371		// filter products
372		novaapfFilterProducts();
373	}
374
375	// handle the filter request
376	$('.novaapf-ajax-term-filter').not('.novaapf-price-filter-widget').on('click', 'li a', function(event) {
377		event.preventDefault();
378		var element = $(this),
379			filter_key = element.attr('data-key'),
380			filter_val = element.attr('data-value'),
381			enable_multiple_filter = element.attr('data-multiple-filter');
382		if (enable_multiple_filter == true) {
383			novaapfMakeParameters(filter_key, filter_val);
384		} else {
385			novaapfSingleFilter(filter_key, filter_val);
386		}
387
388	});
389
390	// handle the filter request for price filter display type list
391	$('.novaapf-price-filter-widget.novaapf-ajax-term-filter').on('click', 'li a', function(event) {
392		event.preventDefault();
393		var element = $(this),
394			filter_key_min = element.attr('data-key-min'),
395			filter_val_min = element.attr('data-value-min'),
396			filter_key_max = element.attr('data-key-max'),
397			filter_val_max = element.attr('data-value-max'),
398			query;
399
400		if (element.parent().hasClass('chosen')) {
401			query = novaapfRemoveQueryStringParameter(filter_key_min);
402			query = novaapfRemoveQueryStringParameter(filter_key_max, query);
403
404			if (query == '') {
405				query = window.location.href.split('?')[0];
406			}
407
408			history.pushState({}, '', query);
409		} else {
410			query = novaapfUpdateQueryStringParameter(filter_key_min, filter_val_min, false);
411			query = novaapfUpdateQueryStringParameter(filter_key_max, filter_val_max, true, query);
412		}
413
414		// filter products
415		novaapfFilterProducts();
416	});
417
418	// handle the pagination request
419	if (novaapf_params.pagination_container.length > 0) {
420		var holder = novaapf_params.pagination_container + ' a';
421
422		$(document).on('click', holder, function(event) {
423			event.preventDefault();
424			var location = $(this).attr('href');
425			history.pushState({}, '', location);
426
427			// filter products
428			novaapfFilterProducts();
429		});
430	}
431
432	// history back and forward request handling
433	$(window).bind('popstate', function(event) {
434		// filter products
435		novaapfFilterProducts();
436    });
437
438    // ordering
439    novaapfInitOrder = function() {
440    	if (typeof novaapf_params.sorting_control !== 'undefined' && novaapf_params.sorting_control.length && novaapf_params.sorting_control == true) {
441	    	$('.novaapf-before-products').find('.woocommerce-ordering').each(function(index) {
442	    		$(this).on('submit', function(event) {
443	    			event.preventDefault();
444	    		});
445
446	    		$(this).on('change', 'select.orderby', function(event) {
447	    			event.preventDefault();
448
449	    			var order = $(this).val(),
450	    				filter_key = 'orderby';
451
452	    			// change url
453	    			novaapfUpdateQueryStringParameter(filter_key, order);
454
455	    			// filter products
456	    			novaapfFilterProducts();
457	    		});
458	    	});
459    	}
460    }
461
462    // init ordering
463    novaapfInitOrder();
464
465    // remove active filters
466    $(document).on('click', '.novaapf-active-filters a:not(.reset)', function(event) {
467    	event.preventDefault();
468    	var element = $(this),
469    		filter_key = element.attr('data-key'),
470    		filter_val = element.attr('data-value');
471    	if (typeof filter_val === 'undefined') {
472	    	var query = novaapfRemoveQueryStringParameter(filter_key);
473	    	history.pushState({}, '', query);
474
475	    	// price slider
476	    	if ($('#novaapf-noui-slider').length && jQuery().noUiSlider) {
477	    		var priceSlider = document.getElementById('novaapf-noui-slider'),
478	    			min_val = parseInt($(priceSlider).attr('data-min')),
479	    			max_val = parseInt($(priceSlider).attr('data-max'));
480
481	    		if (min_val && max_val) {
482			    	if (filter_key === 'min-price') {
483			    		priceSlider.noUiSlider.set([min_val, null]);
484			    	} else if (filter_key === 'max-price') {
485			    		priceSlider.noUiSlider.set([null, max_val]);
486			    	}
487	    		}
488	    	}
489
490	    	// filter products
491	    	novaapfFilterProducts();
492    	} else {
493    		novaapfMakeParameters(filter_key, filter_val);
494    	}
495    });
496
497    // clear all filters
498    $(document).on('click', '.novaapf-active-filters a.reset', function(event) {
499    	event.preventDefault();
500    	var location = $(this).attr('data-location');
501    	history.pushState({}, '', location);
502
503    	// filter products
504    	novaapfFilterProducts();
505    });
506
507	// dispaly type dropdown
508	function formatState(state) {
509	    var depth = $(state.element).attr('data-depth'),
510	    	$state = $('<span class="depth depth-' + depth + '">' + state.text + '</span>');
511
512		return $state;
513	}
514
515	novaapfDropDownFilter = function() {
516		if ($('.novaapf-select2-single').length) {
517			$('.novaapf-select2-single').select2({
518			    templateResult: formatState,
519			    minimumResultsForSearch: Infinity,
520			    allowClear: true
521			});
522		}
523
524		if ($('.novaapf-select2-multiple').length) {
525			$('.novaapf-select2-multiple').select2({
526			    templateResult: formatState,
527			});
528		}
529
530		$('.select2-dropdown').css('display', 'none');
531	}
532
533	// initialize dropdown filter
534	novaapfDropDownFilter();
535
536	$(document).on('change', '.novaapf-select2', function(event) {
537		event.preventDefault();
538		var filter_key = $(this).attr('name'),
539			filter_val = $(this).val();
540
541		if (!filter_val) {
542			var query = novaapfRemoveQueryStringParameter(filter_key);
543			history.pushState({}, '', query);
544		} else {
545			filter_val = filter_val.toString();
546			novaapfUpdateQueryStringParameter(filter_key, filter_val);
547		}
548
549		// filter products
550		novaapfFilterProducts();
551	});
552});

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.