PageSourceSearch

https://www.premier-mfg.com/wp-content/plugins/woo-vehicle-parts-finder/assets/js/scripts.js?ver=7.1.2

js premier-mfg.com collected 2026-09-30 15:29:07 UTC 14,475 bytes, 393 lines download raw bytes

1jQuery( document ).ready(function($) {
2
3	// Reset Form on Page Load
4	$('.widget-woo-vpf-filter form').each(function() {
5		$(this)[0].reset();
6	});
7	
8	// Disable Dependent Fields
9	if( woo_vpf_params.disable_dependent_fields == 'yes' ) {
10		
11		$('.widget-woo-vpf-filter select').attr( 'disabled', 'disabled' );
12		$('.widget-woo-vpf-filter select[name="make"]').removeAttr( 'disabled' );
13		$('.widget-woo-vpf-filter select[name="category"]').removeAttr( 'disabled' );
14		
15		if( $('.widget-woo-vpf-filter select[name="make"]').val() > 0 ) {
16			$('.widget-woo-vpf-filter select[name="model"]').removeAttr( 'disabled' );
17		}
18		
19		if( $('.widget-woo-vpf-filter select[name="model"]').val() > 0 ) {
20			$('.widget-woo-vpf-filter select[name="year_id"]').removeAttr( 'disabled' );
21		}
22		
23		if( $('.widget-woo-vpf-filter select[name="year_id"]').val() > 0 ) {
24			$('.widget-woo-vpf-filter select[name="engine"]').removeAttr( 'disabled' );
25		}
26		
27		$( document.body ).on('woo_vpf_models_updated', function(event, elem_container, elem_select) {
28			if( elem_container.find('select[name="make"]').val() == '' ) {
29				elem_container.find('select[name="model"]').attr( 'disabled', 'disabled' );
30			} else {
31				elem_container.find('select[name="model"]').removeAttr( 'disabled' );
32			}
33
34			elem_container.find('select[name="year_id"]').attr( 'disabled', 'disabled' );
35			elem_container.find('select[name="engine"]').attr( 'disabled', 'disabled' );
36		});
37		
38		$( document.body ).on('woo_vpf_years_updated', function(event, elem_container, elem_select) {
39			if( elem_container.find('select[name="model"]').val() == '' ) {
40				elem_container.find('select[name="year_id"]').attr( 'disabled', 'disabled' );
41			} else {
42				elem_container.find('select[name="year_id"]').removeAttr( 'disabled' );
43			}
44			
45			elem_container.find('select[name="engine"]').attr( 'disabled', 'disabled' );
46		});
47		
48		$( document.body ).on('woo_vpf_engines_updated', function(event, elem_container, elem_select) {
49			if( elem_container.find('select[name="year_id"]').val() == '' ) {
50				elem_container.find('select[name="engine"]').attr( 'disabled', 'disabled' );
51			} else {
52				elem_container.find('select[name="engine"]').removeAttr( 'disabled' );
53			}
54		});
55	}
56	
57	// Chosen
58	if( woo_vpf_params.is_chosen == 'yes' ) {
59		$('.widget-woo-vpf-filter select').chosen();
60		
61		$( document.body ).on('woo_vpf_models_updated', function(event, elem_container, elem_select) {
62			elem_container.find('select[name="model"]').trigger('chosen:updated');
63			elem_container.find('select[name="year_id"]').trigger('chosen:updated');
64			elem_container.find('select[name="engine"]').trigger('chosen:updated');
65		});
66		
67		$( document.body ).on('woo_vpf_years_updated', function(event, elem_container, elem_select) {
68			elem_container.find('select[name="year_id"]').trigger('chosen:updated');
69			elem_container.find('select[name="engine"]').trigger('chosen:updated');
70		});
71		
72		$( document.body ).on('woo_vpf_engines_updated', function(event, elem_container, elem_select) {
73			elem_container.find('select[name="engine"]').trigger('chosen:updated');
74		});
75	}
76	
77	// Dynamic DropDowns
78	if( $('.widget-woo-vpf-filter select[name="model"]').length ) {
79		$( document.body ).on('change', '.widget-woo-vpf-filter select[name="make"]', function() {
80			var $elem = $(this).closest('form');
81			$elem.addClass('woo-vpf-processing');
82		
83			$term_id = $(this).val();
84			$.post( woo_vpf_params.ajax_url, {'parent':$term_id, 'action':'woo_vpf_get_terms'}, function( response ) {
85				$elem.removeClass('woo-vpf-processing');
86				
87				if( $elem.find('select[name="model"]').length ) {
88					$elem.find('select[name="model"] option:not(:first)').remove();
89					$elem.find('select[name="model"]').append( response );
90				}
91				
92				if( $elem.find('select[name="year_id"]').length ) {
93					$elem.find('select[name="year_id"] option:not(:first)').remove();
94				}
95			
96				if( $elem.find('select[name="engine"]').length ) {
97					$elem.find('select[name="engine"] option:not(:first)').remove();
98				}
99			
100				$( document.body ).trigger( 'woo_vpf_models_updated', [ $elem, $elem.find('select[name="model"]') ] );
101			});
102		});
103	}
104	
105	if( $('.widget-woo-vpf-filter select[name="year_id"]').length ) {
106		$( document.body ).on('change', '.widget-woo-vpf-filter select[name="model"]', function() {
107			var $elem = $(this).closest('form');
108			$elem.addClass('woo-vpf-processing');
109		
110			$term_id = $(this).val();
111			$.post( woo_vpf_params.ajax_url, {'parent':$term_id, 'action':'woo_vpf_get_terms'}, function( response ) {
112				$elem.removeClass('woo-vpf-processing');
113				
114				if( $elem.find('select[name="year_id"]').length ) {
115					$elem.find('select[name="year_id"] option:not(:first)').remove();
116					$elem.find('select[name="year_id"]').append( response );
117				}
118			
119				if( $elem.find('select[name="engine"]').length ) {
120					$elem.find('select[name="engine"] option:not(:first)').remove();
121				}
122			
123				$( document.body ).trigger( 'woo_vpf_years_updated', [ $elem, $elem.find('select[name="year_id"]') ] );
124			});
125		});
126	}
127	
128	if( $('.widget-woo-vpf-filter select[name="engine"]').length ) {
129		$( document.body ).on('change', '.widget-woo-vpf-filter select[name="year_id"]', function() {
130			var $elem = $(this).closest('form');
131			$elem.addClass('woo-vpf-processing');
132			
133			$term_id = $(this).val();
134			$.post( woo_vpf_params.ajax_url, {'parent':$term_id, 'action':'woo_vpf_get_terms'}, function( response ) {
135				$elem.removeClass('woo-vpf-processing');
136				
137				if( $elem.find('select[name="engine"]').length ) {
138					$elem.find('select[name="engine"] option:not(:first)').remove();
139					$elem.find('select[name="engine"]').append( response );
140				}
141				
142				$( document.body ).trigger( 'woo_vpf_engines_updated', [ $elem, $elem.find('select[name="engine"]') ] );
143			});
144		});
145	}
146	
147	// Validation Rules
148	if( woo_vpf_params.activate_validation == 'yes' ) {
149		
150		$( document.body ).on('submit', '.widget-woo-vpf-filter form', function() {
151			var $elem = $(this);
152			
153			var $error_text = ''; var $error_elem = '';
154			
155			// Validation: Make
156			if( $error_elem == '' ) {
157				if( woo_vpf_params.validate_make == 'yes' && $elem.find('select[name="make"]').length ) {
158					if( $elem.find('select[name="make"]').val() == '' ) {
159						$error_elem = $elem.find('select[name="make"]');
160						$error_text = woo_vpf_params.validate_make_text;
161					}
162				}
163			}
164			
165			// Validation: Model
166			if( $error_elem == '' ) {
167				if( woo_vpf_params.validate_model == 'yes' && $elem.find('select[name="model"]').length ) {
168					if( $elem.find('select[name="model"]').val() == '' ) {
169						$error_elem = $elem.find('select[name="model"]');
170						$error_text = woo_vpf_params.validate_model_text;
171					}
172				}
173			}
174			
175			// Validation: Year
176			if( $error_elem == '' ) {
177				if( woo_vpf_params.validate_year == 'yes' && $elem.find('select[name="year_id"]').length ) {
178					if( $elem.find('select[name="year_id"]').val() == '' ) {
179						$error_elem = $elem.find('select[name="year_id"]');
180						$error_text = woo_vpf_params.validate_year_text;
181					}
182				}
183			}
184			
185			// Validation: Engine
186			if( $error_elem == '' ) {
187				if( woo_vpf_params.validate_engine == 'yes' && $elem.find('select[name="engine"]').length ) {
188					if( $elem.find('select[name="engine"]').val() == '' ) {
189						$error_elem = $elem.find('select[name="engine"]');
190						$error_text = woo_vpf_params.validate_engine_text;
191					}
192				}
193			}
194			
195			// Validation: Category
196			if( $error_elem == '' ) {
197				if( woo_vpf_params.validate_category == 'yes' && $elem.find('select[name="category"]').length ) {
198					if( $elem.find('select[name="category"]').val() == '' ) {
199						$error_elem = $elem.find('select[name="category"]');
200						$error_text = woo_vpf_params.validate_category_text;
201					}
202				}
203			}
204			
205			// Validation: Keyword
206			if( $error_elem == '' ) {
207				if( woo_vpf_params.validate_keyword == 'yes' && $elem.find('input[name="s"]').length ) {
208					if( $elem.find('input[name="s"]').val() == '' ) {
209						$error_elem = $elem.find('input[name="s"]');
210						$error_text = woo_vpf_params.validate_keyword_text;
211					}
212				}
213			}
214			
215			// Validation: Alerts / Styles
216			$elem.find('.woo-vpf-error').removeClass('woo-vpf-error');
217			if( $error_elem != '' ) {
218			
219				if( woo_vpf_params.validation_alert == 'yes' ) {
220					if( $error_text != '' ) {
221						alert( $error_text );
222					}
223				}
224				
225				if( woo_vpf_params.validation_style == 'yes' ) {
226					$error_elem.closest('.woo-vpf-field').addClass('woo-vpf-error');
227				}
228				
229				return false;
230			} else {
231				return true;
232			}
233			
234		});
235		
236	}
237	
238	
239	
240	/* My Vehicles */
241	
242	// Radio Button Link
243	$('.woo-vpf-mv-container').on('click', '.mv-item-radio', function(event) {
244		$(this).closest('.mv-item').find('.mv-lnk-browse').get(0).click();
245	});
246	
247	// Expand/Collapse Widget
248	$( document.body ).on('click', '.woo-vpf-mv-container.mv-has-expandable-wrapper > .mv-header, .woo-vpf-mv-container.mv-has-flyout-wrapper > .mv-header', function(event) {
249		var $elem = $(this).closest('.woo-vpf-mv-container');
250		if( $elem.hasClass('mv-expanded') ) {
251			$elem.addClass('mv-collapse').removeClass('mv-expanded').find('.mv-inner').slideUp();
252		} else {
253			$elem.addClass('mv-expanded').removeClass('mv-collapse').find('.mv-inner').slideDown();
254		}
255	});
256	
257	// Close Current Widget when Opens Another Widget
258	$(document).click(function(e) {
259		$('.woo-vpf-mv-container.mv-has-flyout-wrapper').each(function() {
260			var $elem = $(this).closest('.woo-vpf-mv-container');
261			
262			if ( ! $elem.is(e.target) && $elem.has(e.target).length === 0 ) {
263				if( $elem.hasClass('mv-expanded') ) {
264					$elem.addClass('mv-collapse').removeClass('mv-expanded').find('.mv-inner').slideUp();
265				}
266			}
267		});
268	});
269	
270	// Reset Search
271	$('.woo-vpf-reset-search').click(function(event) {
272		event.preventDefault();
273		
274		var $href = $(this).attr('href');		
275		var $elem = $(this).closest('form');
276		$elem.addClass('woo-vpf-processing');
277			
278		$.post( woo_vpf_params.ajax_url, {'action':'woo_vpf_reset_search'}, function( response ) {
279			if( $href != '#' ) {
280				window.location.href = $href;
281			} else {
282				window.location.href = window.location.href;
283			}
284		});
285	});
286	
287	// Save User Search from History to Permanent Save
288	$('.woo-vpf-mv-container').on('click', '.mv-lnk-save', function(event) {
289		event.preventDefault();
290		
291		if( $(this).hasClass('mv-lnk-disable') ) {
292			return;
293		}
294		
295		var $elem = $(this).closest('.woo-vpf-mv-container');
296		$elem.find('.woo-vpf-loader').show();
297		
298		var $search_id = $(this).attr('data-search-id');
299		var $search_type = $(this).attr('data-search-type');
300		$.post( woo_vpf_params.ajax_url, {'search_id':$search_id, 'search_type':$search_type, 'action':'woo_vpf_save_search'}, function( response ) {
301			woo_vpf_set_my_vehicles_html(response);			
302			$elem.find('.woo-vpf-loader').hide();
303		});
304	});
305	
306	// Delete User Search
307	$('.woo-vpf-mv-container').on('click', '.mv-lnk-delete', function(event) {
308		event.preventDefault();
309		
310		if( $(this).hasClass('mv-lnk-disable') ) {
311			return;
312		}
313		
314		var $elem = $(this).closest('.woo-vpf-mv-container');
315		$elem.find('.woo-vpf-loader').show();
316		
317		var $search_id = $(this).attr('data-search-id');
318		var $search_type = $(this).attr('data-search-type');
319		$.post( woo_vpf_params.ajax_url, {'search_id':$search_id, 'search_type':$search_type, 'action':'woo_vpf_delete_search'}, function( response ) {
320			woo_vpf_set_my_vehicles_html(response);			
321			$elem.find('.woo-vpf-loader').hide();
322		});
323	});
324	
325	// Clear History
326	$('.woo-vpf-mv-container').on('click', '.mv-clear-history', function(event) {
327		event.preventDefault();
328		
329		var $elem = $(this).closest('.woo-vpf-mv-container');
330		$elem.find('.woo-vpf-loader').show();
331		
332		var $search_type = $(this).attr('data-search-type');
333		$.post( woo_vpf_params.ajax_url, {'search_type':$search_type, 'action':'woo_vpf_clear_history'}, function( response ) {
334			woo_vpf_set_my_vehicles_html(response);
335			$elem.find('.woo-vpf-loader').hide();
336		});
337	});
338	
339	// Modal
340	if( $('.woo-vpf-modal').length ) {
341		// Add a Vehicle Popup
342		$('.woo-vpf-mv-container').on('click', '.mv-add-vehicle', function(event) {
343			event.preventDefault();
344			
345			var $title = $(this).attr('data-title');
346			
347			$.colorbox({
348				inline:true,
349				width:'500',
350				maxWidth:'95%',
351				maxHeight:'95%',
352				href:'#woo-vpf-modal-filter',
353				title:$title,
354				className:'woo-vpf-popup',
355				onComplete:function(){
356					$('#cboxWrapper').find('select, input[name="s"]').val('');
357				
358					//$('#cboxWrapper').find('select[name="make"]').trigger('change');
359					$('#cboxWrapper').find('select[name="model"], select[name="year_id"], select[name="engine"]').find('option:not(:first)').remove();
360					
361					if( woo_vpf_params.disable_dependent_fields == 'yes' ) {
362						$('#cboxWrapper').find('select[name="model"], select[name="year_id"], select[name="engine"]').attr( 'disabled', 'disabled' );
363					}
364					
365					$('#cboxWrapper .widget-woo-vpf-filter select').trigger("chosen:updated");
366				}
367			});
368		});
369	}
370	
371	// Common Functions
372	function woo_vpf_set_my_vehicles_html(response) {
373		if( response != '' ) {
374			$response_container = $(response).filter('.woo-vpf-mv-container');
375			
376			if( $('.woo-vpf-mv-container > .mv-header').length ) {
377				$('.woo-vpf-mv-container > .mv-header').html( $response_container.find('.mv-header').html() );
378			}
379			
380			if( $('.woo-vpf-mv-container .mv-section-vehicles-saved').length ) {
381				$('.woo-vpf-mv-container .mv-section-vehicles-saved').html( $response_container.find('.mv-section-vehicles-saved').html() );
382			}
383			
384			if( $('.woo-vpf-mv-container .mv-section-vehicles-history .mv-items').length ) {
385				$('.woo-vpf-mv-container .mv-section-vehicles-history .mv-items').html( $response_container.find('.mv-section-vehicles-history .mv-items').html() );
386			}
387			
388			if( $('.woo-vpf-mv-container .mv-section-vehicles-history .mv-actions .mv-clear-history').length ) {
389				$('.woo-vpf-mv-container .mv-section-vehicles-history .mv-actions .mv-clear-history').html( $response_container.find('.mv-section-vehicles-history .mv-actions .mv-clear-history').html() );
390			}
391		}
392	}
393});

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.