PageSourceSearch

https://www.sunsetvans.com/wp-content/themes/motors/assets/js/filter.js?ver=2.5

js sunsetvans.com collected 2026-10-08 10:28:04 UTC 17,326 bytes, 441 lines download raw bytes

1"use strict";
2
3(function ($) {
4
5    $(document).on('click', '.archive-listing-page .stm-blog-pagination a', function(){
6        if($('.archive-listing-page').length) {
7            $('html, body').animate({
8                scrollTop: $(".archive-listing-page").offset().top
9            }, 500);
10        }
11    });
12
13    STMListings.Filter.prototype.ajaxBefore = function () {
14        /*Add filter preloader*/
15        $('.stm-ajax-row').addClass('stm-loading');
16
17        /*Add selects preloader*/
18        $('.classic-filter-row .filter-sidebar .select2-container--default .select2-selection--single .select2-selection__arrow b').addClass('stm-preloader');
19        $('.mobile-search-filter .filter-sidebar .select2-container--default .select2-selection--single .select2-selection__arrow b').addClass('stm-preloader');
20        $('.mobile-search-filter .filter-sidebar .select2-container--default .selection').addClass('stm-overlay');
21        $('.search-filter-form .active .mobile .filter-sidebar .select2-container--default .selection').addClass('stm-overlay');
22    };
23
24    STMListings.Filter.prototype.ajaxSuccess = function (res) {
25
26        
27        /*Disable useless selects*/
28        this.disableOptions(res);
29
30        /*Append new html*/
31        this.appendData(res);
32
33		if (res.url) {
34			this.pushState(res.url);
35		}
36
37        /*Reinit js functions*/
38        this.reInitJs();
39        /*Remove preloader*/
40        $('.stm-ajax-row').removeClass('stm-loading');
41    
42        /*Remove select preloaders*/
43        $('.classic-filter-row .filter-sidebar .select2-container--default .select2-selection--single .select2-selection__arrow b').removeClass('stm-preloader');
44        $('.classic-filter-row .filter-sidebar select').prop("disabled", false);
45    
46    };
47
48    STMListings.Filter.prototype.disableOptions = function (res) {
49        var form = this.form;
50        if (typeof res.options != 'undefined') {
51            $.each(res.options, function (key, options) {
52                var value = $('select[name=' + key + ']', form).val();
53                $('select[name=' + key + '] > option', form).each(function () {
54                    var slug = $(this).val();
55                    if (options.hasOwnProperty(slug) && value !== slug) {
56                        $(this).prop('disabled', options[slug].disabled);
57                    }
58                });
59            });
60        }
61
62        $('select', form).select2('destroy');
63        $('select', form).select2(
64            {
65                dropdownParent: $('body'),
66            }
67        );
68
69		$('.stm-select-sorting select').select2('destroy');
70		$('.stm-select-sorting select').html('');
71		$('.stm-select-sorting select').select2({
72			data: res.sorts,
73            dropdownParent: $('body'),
74        });
75
76		if($('body').hasClass('stm-template-aircrafts')) {
77            $.each(res.filter_links, function (key, link) {
78                $.each(res.options[link['slug']], function (key, linkOption) {
79                    if(key) $('label[data-taxonomy="stm-iwf-'+link['slug']+'"] span[data-slug="stm-iwf-'+key+'"]').text('('+linkOption['count']+')');
80                })
81            })
82        }
83
84		$.each(res.filter_links, function (key, link) {
85			$.each(res.options[link['slug']], function (key, linkOption) {
86                if(key)
87				    $('#stm-filter-link-'+link['slug']+' li[data-value="'+key+'"] span').text('('+linkOption['count']+')');
88            })
89        })
90
91    };
92
93    STMListings.Filter.prototype.appendData = function (data) {
94        this.getTarget().html(data.html);
95
96        /*Listing functions*/
97        if ($('.stm-listing-directory-title .title').length > 0) {
98            if (typeof(data.listing_title) !== 'undefined') {
99                $('.stm-listing-directory-title .title').text(data.listing_title);
100            }
101
102            if (typeof(data.total) !== 'undefined') {
103                $('.stm-listing-directory-title .total > span').text(data.total);
104            }
105        }
106
107        if($('body').hasClass('stm-template-motorcycle')) {
108            $('.stm-car-listing-sort-units .stm-listing-directory-title .stm-listing-directory-total-matches > span').text(data.total);
109        }
110    };
111
112    STMListings.Filter.prototype.reInitJs = function () {
113        //stButtons.locateElements();
114        $("img.lazy").lazyload();
115        $('.stm-tooltip-link, div[data-toggle="tooltip"]').tooltip();
116        STMListings.initVideoIFrame();
117
118        $('.stm-shareble').on({
119            mouseenter: function () {
120                $(this).parent().find('.stm-a2a-popup').addClass('stm-a2a-popup-active');
121            },
122            mouseleave: function () {
123                $(this).parent().find('.stm-a2a-popup').removeClass('stm-a2a-popup-active');
124            }
125        });
126
127        $(".a2a_dd").each(function() {
128            a2a.init('page');
129        });
130
131        if ($('body').hasClass('logged-in')) {
132            $.getJSON(ajaxurl, {action: 'stm_ajax_get_favourites', security: stm_security_nonce}, function (data) {
133                window.stm_favourites.ids = data;
134                window.stm_favourites.activateLinks();
135            });
136        }
137
138        window.stm_compare.activateLinks();
139
140		//Default plugins
141        $("select:not(.hide)").each(function () {
142			var selectElement = $(this);
143            selectElement.select2({
144                
145                
146                dropdownParent: $('body'),
147            });
148        });
149	};
150
151    $(document).on('click', '#stm-classic-filter-submit', function (e) {
152        if ($(this).hasClass('stm-classic-filter-submit-boats')) {
153            e.preventDefault();
154            stm_disable_rest_filters($(this), 'listings-items');
155        }
156    });
157    
158    $(document).on('click', '#show-car-btn-mobile', function (e) {
159        if ($(this).hasClass('show-car-btn')) {
160            e.preventDefault();
161        }
162    });
163
164    // Listing price
165    $(document).on('slidestop', '.stm-filter-listing-directory-price .stm-price-range', function (event, ui) {
166        $(this).closest('form').trigger('submit');
167    });
168
169
170    //Checkboxed area listing trigger
171    $(document).on('click', '.stm-ajax-checkbox-button .button, .stm-ajax-checkbox-instant .stm-option-label input', function (e) {
172
173        if ($(this)[0].className == 'button') {
174            e.preventDefault();
175        }
176
177        $(this).closest('form').trigger('submit');
178
179    });
180
181    $(document).on('click', '.stm-view-by a', function (e) {
182
183        if(!$(this).hasClass('stm-modern-view')) {
184            if(!$('body').hasClass('author')) e.preventDefault();
185
186            var viewType = $(this).data('view');
187
188            $('.stm-view-by a').removeClass('active');
189            $(this).addClass('active');
190
191            $('#stm_view_type').val(viewType).closest('form').trigger('submit');
192        }
193    });
194
195    /*Remove badge*/
196    $(document).on('click', 'ul.stm-filter-chosen-units-list li > i', function () {
197        var stmUrl = $(this).data('url');
198        var stmFilter = $('form[data-trigger=filter]').data('Filter');
199        stmFilter.performAjax(stmUrl);
200
201        /*Reset field*/
202        var stmType = $(this).data('type');
203        var stmSlug = $(this).data('slug');
204
205        $('input[name="' + stmSlug + '[]"]:checked').each( function() {
206            $('input[name="' + stmSlug + '[]"]:checked').parent().removeClass("checked");
207            $('input[name="' + stmSlug + '[]"]:checked').prop('checked', false);
208        } );
209
210        if(stmType == 'select') {
211            $('select[name="' + stmSlug +  '"]').val('');
212            $('select[name="' + stmSlug +  '"]').find('option').prop('disabled', false);
213            $('select[name="' + stmSlug +  '"]').select2('destroy').select2().select2('val', '');
214        }
215    });
216
217    $(document).on('click', '.stm_boats_view_by ul li a', function (e) {
218        e.preventDefault();
219        var stmUrl = $(this).attr('href');
220        var stmFilter = $('form[data-trigger=filter]').data('Filter');
221        stmFilter.performAjax(stmUrl);
222
223        $('.stm_boats_view_by ul li').removeClass('active');
224        $(this).closest('li').addClass('active');
225    });
226
227    /*Location*/
228    var delay = (function () {
229        var timer = 0;
230        return function (callback, ms) {
231            clearTimeout(timer);
232            timer = setTimeout(callback, ms);
233        };
234    })();
235
236    $(document).on('keyup', '#ca_location_listing_filter', function () {
237        delay(function () {
238            $('#ca_location_listing_filter').closest('form').trigger('submit');
239        }, 500);
240    });
241
242    $(document).on('change', '#ca_location_listing_filter', function () {
243        delay(function () {
244
245            var address_search = $('#ca_location_listing_filter').val();
246			var geocoder = new google.maps.Geocoder();
247
248			geocoder.geocode({'address': address_search}, function (results, status) {
249				if (status === google.maps.GeocoderStatus.OK) {
250					var lat = results[0].geometry.location.lat();
251					var lng = results[0].geometry.location.lng();
252
253					$('#ca_location_listing_filter').closest('.stm-location-search-unit').find('input[name="stm_lat"]').val(lat);
254					$('#ca_location_listing_filter').closest('.stm-location-search-unit').find('input[name="stm_lng"]').val(lng);
255
256				    $('input[name="sort_order"]').val('distance_nearby');
257					$('#ca_location_listing_filter').closest('form').trigger('submit');
258				} else if(status === google.maps.GeocoderStatus.REQUEST_DENIED) {
259                    $('#ca_location_listing_filter').val('');
260                    $('#ca_location_listing_filter').closest('.stm-location-search-unit').find('input[name="stm_lat"]').val(0);
261                    $('#ca_location_listing_filter').closest('.stm-location-search-unit').find('input[name="stm_lng"]').val(0);
262
263                    $('#ca_location_listing_filter').closest('form').trigger('submit');
264                }
265			});
266            
267        }, 500);
268    });
269
270    /*Boats Filter res*/
271    $(document).on('change', 'body.stm-template-boats .archive-listing-page form input, body.stm-template-boats .archive-listing-page form select', function () {
272        stm_disable_rest_filters($(this), 'listings-binding');
273    });
274    
275    
276    if ($('.stm-checkbox-submit').length) {
277        $(document).on('change', '.classic-filter-row form.search-filter-form.mobile input[type=text], .classic-filter-row form.search-filter-form.mobile select', function () {
278            stm_disable_rest_filters($(this), 'listings-binding');
279        });
280    } else {
281        $(document).on('change', '.classic-filter-row form.search-filter-form.mobile input, .classic-filter-row form.search-filter-form.mobile select', function () {
282            stm_disable_rest_filters($(this), 'listings-binding');
283        });
284    }
285    
286    $(document).on('click', '.search-filter-form.mobile .stm-checkbox-submit', function () {
287        stm_disable_rest_filters($(this), 'listings-binding');
288    });
289    
290    if ($('.stm-checkbox-submit').length) {
291        $(document).on('change', '.mobile-search-filter input[type=text], .mobile-search-filter select', function () {
292            stm_disable_rest_filters($(this), 'listings-binding');
293        });
294    } else {
295        $(document).on('change', '.mobile-search-filter input, .mobile-search-filter select', function () {
296            stm_disable_rest_filters($(this), 'listings-binding');
297        });
298    }
299    
300    $(document).on('click', '.mobile-search-filter .stm-checkbox-submit', function () {
301        stm_disable_rest_filters($(this), 'listings-binding');
302    });
303    
304    $(document).on('slidestop', '.stm-filter-sidebar-boats .stm-filter-type-slider', function (event, ui) {
305        stm_disable_rest_filters($(this), 'listings-binding');
306    });
307
308    $(document).on('click', '.stm_motorcycle_pp a', function(e){
309        e.preventDefault();
310        e.stopPropagation();
311    });
312
313    function stm_disable_rest_filters($_this, action) {
314        var $_form = $_this.closest('form');
315
316        var data = [],
317            url = $_form.attr('action'),
318            sign = url.indexOf('?') < 0 ? '?' : '&';
319
320        $.each($_form.serializeArray(), function (i, field) {
321            if (field.value != '') {
322                data.push(field.name + '=' + field.value)
323            }
324        });
325
326        url = url + sign + data.join('&');
327
328        $.ajax({
329            url: url,
330            dataType: 'json',
331            context: this,
332            data: '&ajax_action=' + action,
333            beforeSend: function () {
334                if (action == 'listings-items') {
335                    $('.stm-ajax-row').addClass('stm-loading');
336                } else {
337                    $('.classic-filter-row .filter-sidebar .select2-container--default .select2-selection--single .select2-selection__arrow b').addClass('stm-preloader');
338                    $('.mobile-search-filter .filter-sidebar .select2-container--default .select2-selection--single .select2-selection__arrow b').addClass('stm-preloader');
339                    $('.mobile-search-filter .filter-sidebar .select2-container--default .selection').addClass('stm-overlay');
340                    $('.search-filter-form .filter-sidebar .select2-container--default .selection').addClass('stm-overlay');
341                }
342            },
343            success: function (res) {
344                if (action == 'listings-items') {
345                    $('.stm-ajax-row').removeClass('stm-loading');
346                    $('#listings-result').html(res.html);
347                    $("img.lazy").lazyload();
348                    $('.stm-tooltip-link, div[data-toggle="tooltip"]').tooltip();
349
350                    window.history.pushState('', '', decodeURI(url));
351                } else {
352                    /*Remove select preloaders*/
353                    $('.classic-filter-row .filter-sidebar .select2-container--default .select2-selection--single .select2-selection__arrow b').removeClass('stm-preloader');
354                    $('.classic-filter-row .filter-sidebar select').prop("disabled", false);
355                    
356                    /*Disable options*/
357                    if (typeof res.options != 'undefined') {
358                        $.each(res.options, function (key, options) {
359                            $('select[name=' + key + '] > option', $_form).each(function () {
360                                var slug = $(this).val();
361                                if (options.hasOwnProperty(slug)) {
362                                    $(this).prop('disabled', options[slug].disabled);
363                                }
364                            });
365                        });
366                    }
367
368                    $('select', $_form).select2('destroy');
369                    $('select', $_form).select2(
370                        {
371                            dropdownParent: $('body'),
372                        }
373                    );
374
375                    /*Change total*/
376                    $('.stm-filter-sidebar-boats #stm-classic-filter-submit span').text(res.total);
377                    $('.search-filter-form #show-car-btn-mobile span').text(res.total);
378                    $('.mobile-search-filter #show-car-btn-mobile span').text(res.total);
379                }
380            }
381        });
382    }
383
384    // Reset fields
385    STMListings.resetFields = function() {
386        $(document).on('reset', 'select', function(e){
387            $(this).val('');
388            $(this).find('option').prop('disabled', false);
389            $(this).select2('destroy').select2().select2('val', '');
390        });
391    };
392    
393    //Mobile search filter
394    $(document).ready(function(){
395        $('.mobile-search-btn').click(function(){
396            $('.mobile-search-filter').addClass('active');
397            $('.mobile-overlay').addClass('active').insertBefore('#wrapper');
398            $('html').addClass('mobile-overflow-hidden');
399            $('body').addClass('mobile-search-filter-opened');
400        });
401        $('.close-btn').click(function(){
402            $('.mobile-search-filter').removeClass('active');
403            $('.mobile-overlay').removeClass('active');
404            $('html').removeClass('mobile-overflow-hidden');
405            $('body').removeClass('mobile-search-filter-opened');
406        });
407        $('.mobile-overlay').click(function(){
408            $('.mobile-overlay').removeClass('active');
409            $('.mobile-search-filter').removeClass('active');
410            $('html').removeClass('mobile-overflow-hidden');
411            $('body').removeClass('mobile-search-filter-opened');
412        });
413        $('.show-car-btn').click(function(){
414            $('.mobile-overlay').removeClass('active');
415            $('.mobile-search-filter').removeClass('active');
416            $('html').removeClass('mobile-overflow-hidden');
417            $('body').removeClass('mobile-search-filter-opened');
418        });
419    });
420    $(document).ready(function() {
421        const classicFilterRow = $('.mobile-search-filter');
422        const footer = $('footer');
423
424        function checkScreenSize() {
425            if ($(window).width() < 1025) {
426                classicFilterRow.detach().appendTo(footer);
427            } else {
428                classicFilterRow.detach().appendTo('.container');
429            }
430        }
431
432        checkScreenSize();
433
434        $(window).resize(checkScreenSize);
435    });
436
437})(jQuery);
438
439function stm_get_price_view(price, currency, currencyPos, priceDel) {
440    return price;
441}

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.