PageSourceSearch

https://www.joppen.nl/wp-content/themes/motors-child/assets/js/app.js?ver=4.0

js joppen.nl collected 2026-09-24 13:01:47 UTC 58,891 bytes, 1,580 lines download raw bytes

1"use strict";
2
3(function ($) {
4    $.fn.parallax = function () {
5        var window_width = $(window).width();
6        // Parallax Scripts
7        return this.each(function (i) {
8            var $this = $(this);
9            $this.addClass('parallax');
10
11            function updateParallax(initial) {
12                var container_height;
13                if (window_width < 601) {
14                    container_height = ($this.height() > 0) ? $this.height() : $this.children("img").height();
15                } else {
16                    container_height = ($this.height() > 0) ? $this.height() : 500;
17                }
18                var $img = $this.children("img").first();
19                var img_height = $img.height();
20                var parallax_dist = img_height - container_height + 100;
21                var bottom = $this.offset().top + container_height;
22                var top = $this.offset().top;
23                var scrollTop = $(window).scrollTop();
24                var windowHeight = window.innerHeight;
25                var windowBottom = scrollTop + windowHeight;
26                var percentScrolled = (windowBottom - top) / (container_height + windowHeight);
27                var parallax = Math.round((parallax_dist * percentScrolled));
28
29                if (initial) {
30                    $img.css('display', 'block');
31                }
32                if ((bottom > scrollTop) && (top < (scrollTop + windowHeight))) {
33                    $img.css('transform', "translate3D(-50%," + parallax + "px, 0)");
34                }
35
36            }
37
38            // Wait for image load
39            $this.children("img").one("load", function () {
40                updateParallax(true);
41            }).each(function () {
42                if (this.complete) $(this).load();
43            });
44
45            $(document).ready(function () {
46                updateParallax(false);
47            });
48
49            $(window).on('scroll', function () {
50                window_width = $(window).width();
51                updateParallax(false);
52            });
53
54            $(window).on('resize', function () {
55                window_width = $(window).width();
56                updateParallax(false);
57            });
58
59        });
60
61    };
62
63    // swipe events using vanilla js
64    var SwipeEvent = (function () {
65        function SwipeEvent(element) {
66            this.xDown = null;
67            this.yDown = null;
68            this.element = typeof (element) === 'string' ? document.querySelector(element) : element;
69            this.element.addEventListener('touchstart', function (evt) {
70                this.xDown = evt.touches[0].clientX;
71                this.yDown = evt.touches[0].clientY;
72            }.bind(this), false);
73        }
74
75        SwipeEvent.prototype.onLeft = function (callback) {
76            this.onLeft = callback;
77            return this;
78        };
79        SwipeEvent.prototype.onRight = function (callback) {
80            this.onRight = callback;
81            return this;
82        };
83        SwipeEvent.prototype.onUp = function (callback) {
84            this.onUp = callback;
85            return this;
86        };
87        SwipeEvent.prototype.onDown = function (callback) {
88            this.onDown = callback;
89            return this;
90        };
91
92        SwipeEvent.prototype.handleTouchMove = function (evt) {
93            if (!this.xDown || !this.yDown) {
94                return;
95            }
96            var xUp = evt.touches[0].clientX;
97            var yUp = evt.touches[0].clientY;
98            this.xDiff = this.xDown - xUp;
99            this.yDiff = this.yDown - yUp;
100
101            if (Math.abs(this.xDiff) !== 0) {
102                if (this.xDiff > 2) {
103                    typeof (this.onLeft) === "function" && this.onLeft();
104                } else if (this.xDiff < -2) {
105                    typeof (this.onRight) === "function" && this.onRight();
106                }
107            }
108
109            if (Math.abs(this.yDiff) !== 0) {
110                if (this.yDiff > 2) {
111                    typeof (this.onUp) === "function" && this.onUp();
112                } else if (this.yDiff < -2) {
113                    typeof (this.onDown) === "function" && this.onDown();
114                }
115            }
116            // Reset values.
117            this.xDown = null;
118            this.yDown = null;
119        };
120
121        SwipeEvent.prototype.run = function () {
122            this.element.addEventListener('touchmove', function (evt) {
123                this.handleTouchMove(evt);
124            }.bind(this), false);
125        };
126
127        return SwipeEvent;
128    }());
129
130    // all in one price block - smoothly scroll to div
131    $(".stm_all_in_one_price_block .contact-btn").on('click', function (e) {
132        e.preventDefault();
133        var id = $(this).attr("href")
134        $('html, body').animate({
135            scrollTop: $(id).offset().top
136        }, 2000);
137    });
138
139    // EV dealer demo home footer contact scripts
140    function ev_home_footer_contact() {
141        // collapse the input
142        if ($(window).width() > 991) {
143            $('.stm-template-ev_dealer .ev_footer_contact_block .wpcf7-form input:not(.wpcf7-submit), .stm-template-ev_dealer .ev_footer_contact_block .wpcf7-form textarea').css('height', '10px');
144        } else {
145            $('.stm-template-ev_dealer .ev_footer_contact_block .wpcf7-form input:not(.wpcf7-submit)').css('height', '43px');
146            $('.stm-template-ev_dealer .ev_footer_contact_block .wpcf7-form textarea').css('height', '100px');
147        }
148
149        // release on focus
150        $('.stm-template-ev_dealer .ev_footer_contact_block .wpcf7-form input:not(.wpcf7-submit)').on('focus', function () {
151            $(this).css({'height': '43px'});
152        });
153        $('.stm-template-ev_dealer .ev_footer_contact_block .wpcf7-form textarea').on('focus', function () {
154            $(this).css({'height': '100px'});
155        });
156
157        // return collapsed state if input is empty
158        $('.stm-template-ev_dealer .ev_footer_contact_block .wpcf7-form input:not(.wpcf7-submit), .stm-template-ev_dealer .ev_footer_contact_block .wpcf7-form textarea').on('focusout', function () {
159            let input_val = $(this).val();
160            if (input_val.length === 0 && $(window).width() > 991) {
161                $(this).css({'height': '10px'});
162            }
163        });
164    }
165
166    $(document).ready(function () {
167
168        var shareTimer;
169        var currentSelect;
170
171        $(document).on('click', '.language-switcher-unit', function () {
172            $(this).toggleClass('open');
173        });
174
175        $('[data-toggle="tooltip"]').tooltip();
176
177        $('body').on('click', '.c-l-test-drive', function () {
178            var carName = $('.carName').text();
179            $('.test-drive-car-name').text(carName);
180            $('input[name="vehicle_name"]').val(carName);
181            $('input[name="vehicle_id"]').val(0);
182        });
183
184        $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
185            $('img').trigger('appear');
186        });
187
188        if ($('body').hasClass('stm-boxed') && $('body').hasClass('stm-inventory-map-body')) {
189
190            var width = parseInt($('#main').width()) + 30;
191
192        }
193
194        $('.stm-more').on('click', function (e) {
195            e.preventDefault();
196            $(this).toggleClass('active');
197
198            $(this).closest('.stm_single_class_car, .stm_rental_option').find('.more').slideToggle();
199        });
200
201        stm_stretch_image();
202
203        if ($('.stm-simple-parallax').length) {
204            $('.stm-simple-parallax').append('<div class="stm-simple-parallax-gradient"><div class="stm-simple-parallax-vertical"></div></div>');
205            jQuery(window).on('scroll', function () {
206                var currentScrollPos = $(window).scrollTop();
207                var scrollOn = 400 - parseFloat(currentScrollPos / 1.2);
208                if (scrollOn < -200) {
209                    scrollOn = -200;
210                }
211                $('.stm-simple-parallax').css('background-position', '0 ' + scrollOn + 'px');
212            });
213        }
214
215        if ($('.stm-single-car-page').length && !$('body').hasClass('stm-template-car_dealer_two')) {
216            jQuery(window).on('scroll', function () {
217                var currentScrollPos = $(window).scrollTop();
218                var scrollOn = 200 - parseFloat(currentScrollPos / 1.2);
219                if (scrollOn < -200) {
220                    scrollOn = -200;
221                }
222
223                $('.stm-single-car-page').css('background-position', '0 ' + scrollOn + 'px');
224            });
225        }
226
227        stm_footer_selection();
228        stm_listing_mobile_functions();
229        if ($('.listing-nontransparent-header').length > 0) {
230            //$('#wrapper').css('padding-top', $('.listing-nontransparent-header').outerHeight() + 'px');
231        }
232
233        if ($('.stm-banner-image-filter').length > 0) {
234            var top = $('.stm-banner-image-filter').closest('.wpb_wrapper').offset().top;
235
236            if ($('body').hasClass('has_envato_iframe')) {
237                top = top - 54;
238                $('.stm-banner-image-filter').css('top', top + 'px');
239            }
240        }
241
242        $(document).on('click', '.stm_motorcycle_pp', function () {
243            $(this).toggleClass('active');
244            $(this).find('ul').toggleClass('activated');
245        });
246
247        $('.stm-material-parallax').parallax();
248
249        //Custom functions
250        stm_widget_color_first_word();
251        stm_widget_instagram();
252        footerToBottom();
253        stmFullwidthWithParallax();
254        stmMobileMenu();
255
256        stmShowListingIconFilter();
257
258        $('body').on('click', '.stm-after-video', function (e) {
259            var $this = $(this).closest('.stm-video-link-unit-wrap');
260            stm_listing_add_video_input($this, 2);
261        })
262
263        var $current_video_count = 1;
264
265        function stm_listing_add_video_input($video_unit, stm_restrict) {
266            var hasEmptyCount = 0;
267            var hasInputs = 0;
268            $('.stm-video-units .stm-video-link-unit-wrap').each(function () {
269                hasInputs++;
270                var stmVal = $(this).find('input').val();
271                if (stmVal.length !== 0) {
272                    hasEmptyCount++;
273                }
274            });
275
276            var $enable = (hasInputs - hasEmptyCount);
277
278            if ($enable < stm_restrict || hasInputs == 1) {
279                $current_video_count++;
280                var $video_label = $video_unit.find('.video-label').text();
281
282                var $new_item_string =
283                    '<div class="stm-video-link-unit-wrap">' +
284                    '<div class="heading-font">' +
285                    '<span class="video-label">' + $video_label + '</span>' +
286                    ' <span class="count">' + $current_video_count + '</span>' +
287                    '</div> ' +
288                    '<div class="stm-video-link-unit"> ' +
289                    '<input type="text" name="stm_video[]"> ' +
290                    '<div class="stm-after-video"></div> ' +
291                    '</div> ' +
292                    '</div>'
293
294                var new_item = $($new_item_string).hide();
295                $('.stm-video-units').append(new_item);
296                new_item.slideDown('fast');
297            }
298        }
299
300        function stmIsValidURL(str) {
301            var a = document.createElement('a');
302            a.href = str;
303            return (a.host && a.host != window.location.host) ? true : false;
304        }
305
306        $('body').on('input', '.stm-video-link-unit input[type="text"]', function (e) {
307            if ($(this).val().length > 0) {
308                if (stmIsValidURL($(this).val())) {
309                    $(this).closest('.stm-video-link-unit').find('.stm-after-video').addClass('active');
310                    var $this = $(this).closest('.stm-video-link-unit-wrap');
311                    stm_listing_add_video_input($this, 1);
312                }
313            } else {
314                $(this).closest('.stm-video-link-unit').find('.stm-after-video').removeClass('active');
315            }
316        });
317
318
319        if ($('.stm_automanager_features_list').length > 0) {
320            $('.wpb_tabs_nav li').on('click', function () {
321                var data_tab = $(this).attr('aria-controls');
322
323                if ($('#' + data_tab).find('.stm_automanager_features_list').length > 0) {
324                    $('.stm_automanager_features_list').isotope({
325                        // main isotope options
326                        itemSelector: '.stm_automanager_single'
327                    })
328                }
329            });
330        }
331
332        disableFancyHandy();
333
334        // Is on screen
335        $.fn.is_on_screen = function () {
336            var win = $(window);
337            var viewport = {
338                top: win.scrollTop(),
339                left: win.scrollLeft()
340            };
341            viewport.right = viewport.left + win.width();
342            viewport.bottom = viewport.top + win.height();
343
344            var bounds = this.offset();
345            bounds.right = bounds.left + this.outerWidth();
346            bounds.bottom = bounds.top + this.outerHeight();
347
348            return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
349        };
350
351        $('.stm-customize-page .wpb_tabs').remove();
352
353        //Default plugins
354
355
356        $('img.lazy').lazyload({
357            effect: "fadeIn",
358            failure_limit: Math.max('img'.length - 1, 0)
359        });
360
361        $('.owl-stage, .stm-single-image, .boat-gallery, .equip-gallery').lightGallery({
362            selector: '.stm_fancybox',
363            mode: 'lg-fade',
364            download: false
365        });
366
367        $('.owl-stage').lightGallery({
368            selector: '.fancy-iframe',
369            mode: 'lg-fade',
370            download: false
371        })
372
373        $('.fancy-iframe').lightGallery({
374            selector: 'this',
375            iframeMaxWidth: '80%',
376            mode: 'lg-fade',
377            download: false
378        })
379
380        $('#stm-google-map').lightGallery({
381            selector: 'this',
382            iframeMaxWidth: '80%',
383            mode: 'lg-fade',
384            download: false
385        })
386
387        $('#top-bar-address').lightGallery({
388            selector: 'this',
389            iframeMaxWidth: '80%',
390            mode: 'lg-fade',
391            download: false
392        })
393
394        $('.stm-carousel').lightGallery({
395            selector: '.stm_fancybox',
396            mode: 'lg-fade',
397            download: false
398        });
399
400        $('a.stm_fancybox').lightGallery({
401            selector: 'this',
402            mode: 'lg-fade',
403            download: false
404        });
405
406        $('#searchModal').on('shown.bs.modal', function (e) {
407            $('#searchform .search-input').trigger('focus');
408        });
409
410
411        $('p').each(function () {
412            if ($(this).html() == '') {
413                $(this).addClass('stm-hidden');
414            }
415        });
416
417        $('.calculated_shipping').on('DOMSubtreeModified', function (e) {
418        });
419
420        var pixelRatio = window.devicePixelRatio || 1;
421
422        if (typeof pixelRatio != 'undefined' && pixelRatio > 1) {
423            $('img').each(function () {
424                var stm_retina_image = $(this).data('retina');
425
426                if (typeof stm_retina_image != 'undefined') {
427                    $(this).attr('src', stm_retina_image);
428                }
429            })
430        }
431
432        $('body').on('click', '.car-action-unit.add-to-compare.disabled, a.stm_fancybox', function (e) {
433            e.preventDefault();
434            e.stopPropagation();
435        })
436
437        // Quantity actions
438        $('body').on('click', '.quantity_actions span', function () {
439            var quantityContainer = $(this).closest('.quantity'),
440                quantityInput = quantityContainer.find('.qty'),
441                quantityVal = quantityInput.attr('value');
442
443            $('.button.update-cart').removeAttr('disabled');
444
445            if ($(this).hasClass('plus')) {
446                quantityInput.attr('value', parseInt(quantityVal) + 1);
447            } else if ($(this).hasClass('minus')) {
448                if (quantityVal > 1) {
449                    quantityInput.attr('value', parseInt(quantityVal) - 1);
450                }
451            }
452        });
453
454        $('body').on('click', '.stm-modern-filter-unit-images .stm-single-unit-image', function () {
455
456            var stmHasChecked = false;
457            $('.stm-modern-filter-unit-images .stm-single-unit-image .image').addClass('non-active');
458            $('.stm-modern-filter-unit-images .stm-single-unit-image').each(function () {
459                var checked = $(this).find('input[type=checkbox]').prop('checked');
460                if (checked) {
461                    $(this).find('.image').removeClass('non-active');
462                    stmHasChecked = true;
463                }
464            });
465
466            if (!stmHasChecked) {
467                $('.stm-modern-filter-unit-images .stm-single-unit-image .image').removeClass('non-active');
468            }
469
470        })
471
472        $('.stm-modern-view-others').on('click', function (e) {
473            e.preventDefault();
474            $(this).closest('.stm-single-unit-wrapper').find('.stm-modern-filter-others').slideToggle('fast');
475        })
476
477        $('.header-help-bar-trigger').on('click', function () {
478            $(this).toggleClass('active');
479            $('.header-help-bar ul').slideToggle();
480        })
481
482        $('.header-menu').on('click', function (e) {
483            var link = $(this).attr('href');
484            if (link == '#') {
485                e.preventDefault();
486            }
487        })
488
489        $('#main .widget_search form.search-form input[type=search]').on('focus', function () {
490            $(this).closest('form').addClass('focus');
491        });
492
493        $('#main .widget_search form.search-form input[type=search]').on('focusout', function () {
494            $(this).closest('form').removeClass('focus');
495        });
496
497        $('body').on('change', '.stm-file-realfield', function () {
498            var length = $(this)[0].files.length;
499
500            if (length == 1) {
501                var uploadVal = $(this).val();
502                $(this).closest('.stm-pseudo-file-input').find(".stm-filename").text(uploadVal);
503            } else if (length == 0) {
504                $(this).closest('.stm-pseudo-file-input').find(".stm-filename").text('Choose file...');
505            } else if (length > 1) {
506                $(this).closest('.stm-pseudo-file-input').find(".stm-filename").text(length + ' files chosen');
507            }
508        });
509
510        $(".rev_slider_wrapper").each(function () {
511            var $this = $(this);
512            $this.on('revolution.slide.onloaded', function () {
513                setTimeout(function () {
514                    $('.stm-template-boats .wpb_revslider_element .button').addClass('loaded');
515                }, 1000);
516            });
517        });
518
519        $('.stm-share').on('click', function (e) {
520            e.preventDefault();
521        });
522
523        $('.stm-shareble').on({
524            mouseenter: function () {
525                $(this).parent().find('.stm-a2a-popup').addClass('stm-a2a-popup-active');
526            },
527            mouseleave: function () {
528                $(this).parent().find('.stm-a2a-popup').removeClass('stm-a2a-popup-active');
529            }
530        });
531
532        $('.unit-stm-moto-icon-share').on({
533            mouseenter: function () {
534                $(this).find('.stm-a2a-popup').addClass('stm-a2a-popup-active');
535            },
536            mouseleave: function () {
537                $(this).find('.stm-a2a-popup').removeClass('stm-a2a-popup-active');
538            }
539        });
540
541        $('.stm-gallery-action-unit').on({
542            mouseenter: function () {
543                if (shareTimer) {
544                    clearTimeout(shareTimer);
545                }
546                $(this).find('.stm-a2a-popup').addClass('stm-a2a-popup-active');
547            },
548            mouseleave: function () {
549                shareTimer = setTimeout(function () {
550                    if ($('.stm-a2a-popup-active:hover').length == 0) {
551                        $('.stm-a2a-popup').removeClass('stm-a2a-popup-active');
552                    }
553                }, 500);
554
555                $('.stm-a2a-popup-active').mouseleave(function () {
556                    $('.stm-a2a-popup').removeClass('stm-a2a-popup-active');
557                });
558            }
559        });
560
561        $('body').on('click', '.archive_request_price', function () {
562            var title = $(this).data('title');
563            var id = $(this).data('id');
564
565            $('#get-car-price form').find('.test-drive-car-name').text(title);
566            $('#get-car-price form').find('input[name="vehicle_id"]').val(id);
567        });
568
569        $('body').on(
570            'click',
571            '.listing-car-item-meta .price[data-target="#get-car-price"], .stm_moto_hover_unit .price [data-target="#get-car-price"], #listings-result .image .price [data-target="#get-car-price"]',
572            function (e) {
573                if ($(e.target).closest('a').length) {
574                    e.preventDefault()
575                }
576            }
577        )
578
579        if ($('.stm-hoverable-interactive-galleries .interactive-hoverable .hoverable-wrap').length > 0) {
580            // on desktop, hover
581            $(document).on('mousemove', '.interactive-hoverable .hoverable-wrap .hoverable-unit', function () {
582                var index = $(this).index();
583                if ($(this).parent().siblings('.hoverable-indicators').find('.indicator.active').index() !== index) {
584                    $(this).parent().siblings('.hoverable-indicators').find('.indicator.active').removeClass('active');
585                    $(this).parent().siblings('.hoverable-indicators').find('.indicator').eq(index).addClass('active');
586                }
587
588                $(this).siblings().removeClass('active');
589                $(this).addClass('active');
590            });
591
592            $(document).on('mouseleave', '.interactive-hoverable', function () {
593                $(this).find('.hoverable-indicators .indicator.active').removeClass('active');
594                $(this).find('.hoverable-indicators .indicator:first-child').addClass('active');
595
596                $(this).find('.hoverable-wrap .hoverable-unit.active').removeClass('active');
597                $(this).find('.hoverable-wrap .hoverable-unit:first-child').addClass('active');
598            });
599
600            // on mobile, swipe
601            stm_init_hoverable_swipe();
602        }
603
604        $('.mobile-contacts-trigger').on('click', function () {
605            $(this).toggleClass('open');
606            $('.header-top-info').toggleClass('open');
607
608            if ($('.mobile-menu-trigger').hasClass('opened')) {
609                $('html').trigger('removeNoScroll')
610                $('.mobile-menu-trigger').removeClass('opened');
611                $('.mobile-menu-holder').slideToggle();
612            }
613
614            if ($('.header-top-info').hasClass('open')) {
615                $('#stm-overlay').show();
616            } else {
617                $('#stm-overlay').hide();
618            }
619        });
620
621        // hoverable gallery preview using Brazzers Carousel library
622        var brazzers_carousel = $('.brazzers-carousel');
623        if (brazzers_carousel.length > 0) {
624            brazzers_carousel.brazzersCarousel();
625
626            brazzers_carousel.each(function () {
627                // remaining number of photos
628                if (typeof $(this).data('remaining') !== undefined && $(this).data('remaining') > 0) {
629                    let remaining_number = parseInt($(this).data('remaining'));
630                    var remaining_label = remaining_number + ' ' + photo_remaining_singular;
631                    if (remaining_number > 1) {
632                        var remaining_label = remaining_number + ' ' + photo_remaining_plural;
633                    }
634
635                    $(this).find('.tmb-wrap').append('<div class="remaining"><i class="stm-icon-album"></i><p>' + remaining_label + '</p></div>');
636                }
637            });
638
639            $('.brazzers-carousel .tmb-wrap-table >
639 div:nth-child(5)').on('mouseenter', function () {
640                $(this).parent().siblings('.remaining').addClass('active');
641            });
642
643            $('.brazzers-carousel .tmb-wrap-table > div:nth-child(5)').on('mouseleave', function () {
644                $(this).parent().siblings('.remaining').removeClass('active');
645            });
646
647            $('.brazzers-carousel .tmb-wrap').on('mouseleave', function () {
648                $(this).find('.tmb-wrap-table > div').removeClass('active');
649                $(this).find('.tmb-wrap-table > div:first-child').trigger('mouseenter');
650            });
651        }
652
653        $(document).on('mouseenter', '.select2-selection__rendered', function () {
654            $(this).attr('title', $.trim($(this).attr('title')));
655        });
656
657    }); // end of "document ready"
658
659    function stm_init_hoverable_swipe() {
660        if ($('.stm-hoverable-interactive-galleries .interactive-hoverable .hoverable-wrap').length > 0) {
661            $('.stm-hoverable-interactive-galleries .interactive-hoverable .hoverable-wrap').each((index, el) => {
662                let galleryPreviewSwiper = new SwipeEvent(el);
663
664                galleryPreviewSwiper.onRight(function () {
665                    let active_index = $(this.element).find('.hoverable-unit.active').index();
666                    $(this.element).find('.hoverable-unit').removeClass('active');
667                    $(this.element).siblings('.hoverable-indicators').find('.indicator.active').removeClass('active');
668                    if (active_index === 0) {
669                        $(this.element).find('.hoverable-unit:last-child').addClass('active');
670                        $(this.element).siblings('.hoverable-indicators').find('.indicator:last-child').addClass('active');
671                    } else {
672                        $(this.element).find('.hoverable-unit').eq(active_index - 1).addClass('active');
673                        $(this.element).siblings('.hoverable-indicators').find('.indicator').eq(active_index - 1).addClass('active');
674                    }
675                });
676
677                galleryPreviewSwiper.onLeft(function () {
678                    let active_index = $(this.element).find('.hoverable-unit.active').index();
679                    let total_items = $(this.element).find('.hoverable-unit');
680                    $(this.element).find('.hoverable-unit').removeClass('active');
681                    $(this.element).siblings('.hoverable-indicators').find('.indicator.active').removeClass('active');
682                    if (active_index === parseInt(total_items.length - 1)) {
683                        $(this.element).find('.hoverable-unit:first-child').addClass('active');
684                        $(this.element).siblings('.hoverable-indicators').find('.indicator:first-child').addClass('active');
685                    } else {
686                        $(this.element).find('.hoverable-unit').eq(active_index + 1).addClass('active');
687                        $(this.element).siblings('.hoverable-indicators').find('.indicator').eq(active_index + 1).addClass('active');
688                    }
689                });
690
691                galleryPreviewSwiper.run();
692            });
693        }
694    }
695
696    $(window).on('load', function () {
697        footerToBottom();
698        stmFullwidthWithParallax();
699
700        stm_stretch_image();
701        $('.stm-blackout-overlay').addClass('stm-blackout-loaded');
702
703        // if preloader_timer empty
704        if (preloader_timer === undefined || preloader_timer === null || preloader_timer === '') {
705            stmPreloader();
706        }
707
708        if ($('.stm-banner-image-filter').length > 0) {
709            var top = $('.stm-banner-image-filter').closest('.wpb_wrapper').offset().top;
710
711            if ($('body').hasClass('has_envato_iframe')) {
712                top = top - 54;
713                $('.stm-banner-image-filter').css('top', top + 'px');
714            }
715        }
716
717        // ev dealer demo home footer contact
718        if ($('.stm-template-ev_dealer .ev_footer_contact_block .wpcf7-form').length > 0) {
719            ev_home_footer_contact();
720        }
721
722    }); // end of "window on load"
723
724    $(window).on('resize', function () {
725        footerToBottom();
726        stmFullwidthWithParallax();
727
728        stm_stretch_image();
729
730        disableFancyHandy();
731        if ($('.stm-banner-image-filter').length > 0) {
732            var top = $('.stm-banner-image-filter').closest('.wpb_wrapper').offset().top;
733
734            if ($('body').hasClass('has_envato_iframe')) {
735                top = top - 54;
736                $('.stm-banner-image-filter').css('top', top + 'px');
737            }
738        }
739
740        // ev dealer demo home footer contact
741        ev_home_footer_contact();
742
743    });
744
745    //if preloader timer not empty
746    if (preloader_timer !== undefined || preloader_timer !== null || preloader_timer !== '') {
747        setTimeout(function () {
748            stmPreloader();
749        }, preloader_timer);
750    }
751
752    function loadVisible($els, trigger) {
753        $els.filter(function () {
754            var rect = this.getBoundingClientRect();
755            return rect.top >= 0 && rect.top <= window.innerHeight;
756        }).trigger(trigger);
757    }
758
759    function footerToBottom() {
760        var windowH = $(window).height();
761        var footerH = $('#footer').outerHeight();
762        $('#wrapper').css('min-height', (windowH - footerH) + 'px');
763    };
764
765    function stm_widget_color_first_word() {
766        // don't apply for electric vehicle layout
767        if ($('body').hasClass('stm-template-ev_dealer')) {
768            return false;
769        }
770
771        // go ahead for other layouts
772        $('.stm_wp_widget_text .widget-title h6').each(function () {
773            var html = $(this).html()
774            var spaceIndex = html.indexOf(' ')
775
776            if (spaceIndex === -1) {
777                $(this).html($('<span/>').html(html).addClass('colored'))
778            } else {
779                var word = html.substr(0, spaceIndex)
780                var rest = html.substr(spaceIndex)
781                $(this)
782                    .html(rest)
783                    .prepend($('<span/>').html(word).addClass('colored'))
784            }
785        })
786    }
787
788    function stm_widget_instagram() {
789        $('#sb_instagram').closest('.widget-wrapper').addClass('stm-instagram-unit');
790    }
791
792    function stmFullwidthWithParallax() {
793        var screenWidth = $(window).width();
794        if (screenWidth < 1140) {
795            var defaultWidth = screenWidth - 30;
796        } else {
797            var defaultWidth = 1140 - 30;
798        }
799        var marginLeft = (screenWidth - defaultWidth) / 2;
800
801        if ($('body').hasClass('rtl')) {
802            $('.stm-fullwidth-with-parallax').css({
803                'position': 'relative',
804                'left': (marginLeft - 15) + 'px'
805            })
806        }
807
808        $('.stm-fullwidth-with-parallax').css({
809            'width': screenWidth + 'px',
810            'margin-left': '-' + marginLeft + 'px',
811            'padding-left': (marginLeft - 15) + 'px',
812            'padding-right': (marginLeft - 15) + 'px'
813        })
814    }
815
816    function stmMobileMenu() {
817
818        let mobile_menu_holder = $('.mobile-menu-trigger')
819
820        mobile_menu_holder.on('click', function () {
821
822            let $this = $(this)
823            if ($this.hasClass('opened')) {
824                $('html').trigger('removeNoScroll')
825            } else {
826                $('html').trigger('addNoScroll')
827            }
828
829            $this.toggleClass('opened');
830            $('.mobile-menu-holder').slideToggle();
831
832
833            // close the contacts dropdown
834            if ($('.mobile-contacts-trigger').length > 0) {
835                $('.mobile-contacts-trigger').removeClass('open');
836                $('.header-top-info').removeClass('open');
837            }
838
839            if ($('.header-top-info').hasClass('open')) {
840                $('#stm-overlay').show();
841            } else {
842                $('#stm-overlay').hide();
843            }
844        });
845
846
847        $(".mobile-menu-holder .header-menu li.menu-item-has-children > a")
848            .after('<span class="arrow"><i class="fas fa-angle-right"></i></span>');
849
850        $(".magazine-menu-mobile > li.menu-item-has-children > a")
851            .after('<span class="arrow"><i class="fas fa-angle-right"></i></span>');
852
853        let arrow = $('.mobile-menu-holder .header-menu .arrow')
854        arrow.parents('.stm_motorcycle-header').find('> ul.sub-menu').hide();
855        arrow.on('click', function () {
856            $(this).toggleClass('active');
857
858            $(this).closest('li').toggleClass('opened');
859
860            // if (!$(this).parent().hasClass('stm_motorcycle-header')) {
861            //
862            //     // $(this).closest('li').find('> ul.sub-menu').slideToggle(300);
863            //
864            //     // hide any existing subs
865            //     if ($(this).closest('li').find('> ul.sub-menu').has('.sub-menu').length > 0) {
866            //         $(this).closest('li').find('> ul.sub-menu').find('ul.sub-menu').hide();
867            //         $(this).closest('li').find('> ul.sub-menu').find('.arrow').removeClass('active');
868            //     }
869            // } else {
870            // if contains megamenu
871            $(this).closest('li').find('> ul.sub-menu').slideToggle(300);
872            // }
873        });
874
875        // if menu item with "#" link is clicked
876        $(".mobile-menu-holder .header-menu > li.menu-item-has-children > a").on('click', function (e) {
877
878            if ($(this).attr('href') == '#') {
879
880                e.preventDefault();
881
882                $(this).closest('li').find(' > ul.sub-menu').slideToggle(300);
883
884                $(this).closest('li').toggleClass('opened');
885
886                $(this).closest('li').find(' > .arrow').toggleClass('active');
887
888                // hide any existing subs
889                if ($(this).closest('li').find('> ul.sub-menu').has('.sub-menu').length > 0) {
890                    $(this).closest('li').find('> ul.sub-menu').find('ul.sub-menu').hide();
891                    $(this).closest('li').find('> ul.sub-menu').find('.arrow').removeClass('active');
892                }
893            }
894        });
895
896        $('body').on('click', '.magazine-menu-mobile > li.menu-item-has-children >.arrow', function (e) {
897            $(this).parent().toggleClass('active');
898        });
899
900        let html = $('html');
901        html.on('addNoScroll', addNoScroll)
902        html.on('removeNoScroll', removeNoScroll);
903
904    }
905
906    function addNoScroll(el) {
907        if (!el) {
908            el = $('html')
909        }
910
911        if (typeof el === 'object' && el.hasOwnProperty('currentTarget')) {
912            el = $(el.currentTarget)
913        }
914
915        el.addClass('no-scroll');
916    }
917
918    function removeNoScroll(el) {
919        if (!el) {
920            el = $('html')
921        }
922
923        if (typeof el === 'object' && el.hasOwnProperty('currentTarget')) {
924            el = $(el.currentTarget)
925        }
926
927        el.removeClass('no-scroll');
928    }
929
930    let is_header = {
931            car_magazine: false,
932            dealer: false,
933        },
934        body = $('body')
935
936    if (body.hasClass('stm-layout-header-car_magazine')) {
937        is_header.car_magazine = true
938    }
939
940    if (body.hasClass('stm-layout-header-car_dealer')) {
941        is_header.dealer = true
942    }
943
944    $(window).ready(setMobileMenuHeight);
945    $(window).resize(setMobileMenuHeight);
946    $(window).scroll(setMobileMenuHeight);
947
948    function setMobileMenuHeight() {
949        let header_main = $('#header > div.header-main, #header > div.header-listing'),
950            mobile_menu_holder = $('.mobile-menu-holder')
951
952        if (is_header.car_magazine) {
953            header_main = $('#header > div.header-magazine')
954            mobile_menu_holder = $('.stm-opened-menu-magazine')
955        }
956
957        if (window.innerWidth > 1025 || !header_main.length || !mobile_menu_holder.length) {
958            return
959        }
960
961        let top_bar = $('#top-bar'),
962            top_bar_height = top_bar.outerHeight(),
963            header_main_height = header_main.outerHeight(),
964            _top_bar_offset = 0, _header_main_offset = 0;
965
966        //don't calculate top-bar if menu is fixed
967        if (header_main.hasClass('stm-fixed')) {
968            top_bar_height = 0
969        }
970
971        if (!top_bar_height) {
972            top_bar_height = 0
973        }
974
975        if (!header_main_height) {
976            header_main_height = 0
977        }
978
979        if (top_bar.length) {
980            _top_bar_offset = top_bar.offset().top
981        }
982
983        _header_main_offset = header_main.offset().top
984
985        let top_bar_offset = _top_bar_offset,
986            top_bar_visible_height = calculateVisibleHeight(top_bar_height, top_bar_offset),
987            header_main_offset = _header_main_offset,
988            header_main_visible_height = calculateVisibleHeight(header_main_height, header_main_offset)
989
990        let calculated_height = window.innerHeight - top_bar_visible_height - header_main_visible_height
991        mobile_menu_holder.css('height', calculated_height)
992
993        if (is_header.dealer) {
994            mobile_menu_holder.css('top', header_main_height)
995        }
996    }
997
998    function calculateVisibleHeight(elHeight, elOffset) {
999        if (!elHeight) {
1000            elHeight = 0
1001        }
1002
1003        if (!elOffset) {
1004            elOffset = 0
1005        }
1006
1007        let scrollY = window.scrollY,
1008            visible_height = elHeight
1009
1010        if (scrollY > elOffset) {
1011            visible_height = (elOffset + elHeight) - scrollY
1012        }
1013
1014        if ((elOffset + scrollY) < elHeight) {
1015            visible_height = elHeight - (elOffset + scrollY)
1016        }
1017
1018        if ((elOffset + scrollY) < elHeight && elOffset > scrollY) {
1019            visible_height = elHeight
1020        }
1021
1022        if ((elOffset + elHeight) < scrollY) {
1023            visible_height = 0
1024        }
1025
1026        return visible_height
1027    }
1028
1029    function disableFancyHandy() {
1030        var winWidth = $(window).width();
1031        if (winWidth < 1025) {
1032            $('.media-carousel-item .stm_fancybox').on('click', function (e) {
1033                e.preventDefault();
1034                e.stopPropagation();
1035            })
1036        }
1037    }
1038
1039    function stmPreloader() {
1040        if ($('html').hasClass('stm-site-preloader')) {
1041            $('html').addClass('stm-site-loaded');
1042
1043            if (preloader_timer === undefined || preloader_timer === null || preloader_timer === '') { // if preloader timer is not set
1044                setTimeout(function () {
1045                    $('html').removeClass('stm-site-preloader stm-site-loaded');
1046                }, 250);
1047                var prevent = false;
1048                $('a[href^=mailto], a[href^=skype], a[href^=tel]').on('click', function (e) {
1049                    prevent = true;
1050                    $('html').removeClass('stm-site-preloader stm-after-hidden');
1051                });
1052
1053                $(window).on('beforeunload', function (e, k) {
1054                    if (!prevent) {
1055                        $('html').addClass('stm-site-preloader stm-after-hidden');
1056                    } else {
1057                        prevent = false;
1058                    }
1059                });
1060            } else { // if preloader timer is set
1061                $('html').removeClass('stm-site-preloader stm-site-loaded');
1062            }
1063        }
1064    }
1065
1066    function stmShowListingIconFilter() {
1067        $('.stm_icon_filter_label').on('click', function () {
1068
1069            if (!$(this).hasClass('active')) {
1070                $(this).closest('.stm_icon_filter_unit').find('.stm_listing_icon_filter').toggleClass('active');
1071                $(this).closest('.stm_icon_filter_unit').find('.stm_listing_icon_filter .image').hide();
1072
1073                $(this).addClass('active');
1074            } else {
1075                $(this).closest('.stm_icon_filter_unit').find('.stm_listing_icon_filter').toggleClass('active');
1076                $(this).closest('.stm_icon_filter_unit').find('.stm_listing_icon_filter .image').show();
1077
1078                $(this).removeClass('active');
1079            }
1080
1081        });
1082    }
1083
1084    function stm_footer_selection() {
1085        if (typeof stm_footer_terms !== 'undefined') {
1086            var substringMatcher = function (strs) {
1087                return function findMatches(q, cb) {
1088                    var matches, substringRegex;
1089
1090                    // an array that will be populated with substring matches
1091                    matches = [];
1092
1093                    // regex used to determine if a string contains the substring `q`
1094                    var substrRegex = new RegExp(q, 'i');
1095
1096                    // iterate through the pool of strings and for any string that
1097                    // contains the substring `q`, add it to the `matches` array
1098                    $.each(strs, function (i, str) {
1099                        if (substrRegex.test(str)) {
1100                            matches.push(str);
1101                        }
1102                    });
1103
1104                    cb(matches);
1105                };
1106            };
1107
1108            var $input = $('.stm-listing-layout-footer .stm-footer-search-inventory input');
1109
1110            var selectedValue = '';
1111
1112            $input.typeahead({
1113                hint: true,
1114                highlight: true,
1115                minLength: 1
1116            }, {
1117                name: 'stm_footer_terms',
1118                source: substringMatcher(stm_footer_terms)
1119            });
1120
1121            $input.typeahead('val', stm_default_search_value).trigger('keyup');
1122            $input.typeahead('close');
1123
1124            $input.on('keydown', function () {
1125                selectedValue = $(this).val();
1126            })
1127
1128            $input.on('typeahead:select', function (ev, suggestion) {
1129                selectedValue = suggestion;
1130            });
1131
1132            var enableSubmission = false;
1133            $('.stm-footer-search-inventory form').on('submit', function (e) {
1134                if (!enableSubmission) {
1135                    e.preventDefault();
1136                }
1137                var keyChosen = $.inArray(selectedValue, stm_footer_terms);
1138                if (keyChosen != -1) {
1139                    var slug = stm_footer_terms_slugs[keyChosen];
1140                    var taxonomy = stm_footer_taxes[keyChosen];
1141                    if (typeof (taxonomy) != 'undefined' && typeof (slug) != 'undefined' && !enableSubmission) {
1142                        $input.attr('name', taxonomy);
1143                        $input.val(slug);
1144                        enableSubmission = true;
1145                        $(this).trigger('submit');
1146                    }
1147                } else {
1148                    if (!enableSubmission) {
1149                        enableSubmission = true;
1150                        $(this).trigger('submit');
1151                    }
1152                }
1153
1154            });
1155        }
1156    }
1157
1158    $('.stm-form-1-end-unit input[type="text"]').on('blur', function () {
1159        if ($(this).val() == '') {
1160            $(this).removeClass('stm_has_value');
1161        } else {
1162            $(this).addClass('stm_has_value');
1163        }
1164    });
1165
1166    function stm_listing_mobile_functions() {
1167        $('.listing-menu-mobile > li.menu-item-has-children > a').append('<span class="stm_frst_lvl_trigger"></span>');
1168        $('body').on('click', '.stm_frst_lvl_trigger', function (e) {
1169            e.preventDefault();
1170            $(this).closest('li').find('ul.sub-menu').slideToggle();
1171            $(this).closest('li').toggleClass('show_submenu');
1172            $(this).closest('li').toggleClass('active');
1173            $(this).toggleClass('active');
1174        });
1175
1176        $('.boats-menu-ipad > li.menu-item-has-children > a').addClass('has-child');
1177        $('body').on('click', 'a.has-child', function (e) {
1178
1179            if ($(this).hasClass('active')) {
1180                $(this).parent().trigger('blur');
1181                $(this).toggleClass('active');
1182            } else {
1183                e.preventDefault();
1184                $(this).toggleClass('active');
1185            }
1186        });
1187
1188        $('.boats-menu-ipad > li.menu-item-has-children > a.has-child').each(function () {
1189            $(this).parent().on('focusout', function () {
1190                $('.boats-menu-ipad > li.menu-item-has-children > a.has-child').removeClass('active');
1191            });
1192        });
1193
1194        $('.lOffer-account-dropdown.stm-login-form-unregistered form input').on('focus', function () {
1195
1196            $('.lOffer-account-unit').find('.lOffer-account').addClass('active');
1197            $('.lOffer-account-unit').find('.lOffer-account-dropdown.stm-login-form-unregistered').addClass('active');
1198
1199        })
1200
1201        $('.lOffer-account-dropdown.stm-login-form-unregistered form input').on('blur', function () {
1202            $('.lOffer-account-unit').find('.lOffer-account').removeClass('active');
1203            $('.lOffer-account-unit').find('.lOffer-account-dropdown.stm-login-form-unregistered').removeClass('active');
1204        })
1205
1206        $('.stm-menu-trigger').on('click', function () {
1207
1208            $('.lOffer-account').removeClass('active');
1209            $('.stm-user-mobile-info-wrapper').removeClass('active');
1210
1211            $('.stm-opened-menu-listing').toggleClass('opened');
1212            $('.stm-opened-menu-magazine').toggleClass('opened');
1213
1214            let $this = $(this);
1215            if ($this.hasClass('opened')) {
1216                $('html').trigger('removeNoScroll');
1217            } else {
1218                $('html').trigger('addNoScroll');
1219            }
1220
1221            $this.toggleClass('opened');
1222
1223        });
1224
1225        $('.lOffer-account').on('click', function (e) {
1226            e.preventDefault();
1227
1228            let $this = $(this),
1229                html = $('html');
1230
1231            $('.stm-opened-menu-listing').removeClass('opened');
1232            $('.stm-opened-menu-magazine').removeClass('opened');
1233            html.trigger('removeNoScroll');
1234            $('.stm-menu-trigger').removeClass('opened');
1235
1236            if (window.matchMedia("(max-width: 990px)").matches) {
1237                if ($this.hasClass('active')) {
1238                    html.trigger('removeNoScroll');
1239                } else {
1240                    html.trigger('addNoScroll');
1241                }
1242            }
1243
1244            $(this).toggleClass('active');
1245
1246            $(this).closest('.lOffer-account-unit').find('.stm-user-mobile-info-wrapper').toggleClass('active');
1247        });
1248
1249
1250        $('.stm-rent-lOffer-account').on('click', function (e) {
1251            e.preventDefault();
1252
1253            $('.stm-opened-menu-listing').removeClass('opened');
1254            $('.stm-opened-menu-magazine').removeClass('opened');
1255            $('html').trigger('removeNoScroll');
1256            $('.stm-menu-trigger').removeClass('opened');
1257
1258            $(this).toggleClass('active');
1259
1260            $(this).closest('.stm-rent-lOffer-account-unit').find('.stm-user-mobile-info-wrapper').toggleClass('active');
1261        });
1262
1263        $('body').on('click', function (e) {
1264            if ($(e.target).closest('#header').length === 0) {
1265                $('.lOffer-account').removeClass('active');
1266                $('.stm-user-mobile-info-wrapper').removeClass('active');
1267                $('.stm-login-form-unregistered').removeClass('active');
1268                $('.stm-opened-menu-listing').removeClass('opened');
1269                $('.stm-opened-menu-magazine').removeClass('opened');
1270                $('html').trigger('removeNoScroll');
1271                $('.stm-menu-trigger').removeClass('opened');
1272            }
1273        });
1274
1275
1276        /*Boats*/
1277        $('.stm-menu-boats-trigger').on('click', function () {
1278            let $this = $(this);
1279            if ($this.hasClass('opened')) {
1280                setTimeout(removeNoScroll)
1281            } else {
1282                setTimeout(addNoScroll)
1283            }
1284            $this.toggleClass('opened');
1285            $('.stm-boats-mobile-menu').toggleClass('opened');
1286        });
1287
1288        $('.stm-boats-mobile-menu .listing-menu > li.menu-item-has-children > a').append('<span class="stm-boats-menu-first-lvl"></span>');
1289
1290        $('body').on('click', '.stm-boats-menu-first-lvl', function (e) {
1291            e.preventDefault();
1292            $(this).closest('li').find('ul.sub-menu').toggle();
1293            $(this).parent().parent().toggleClass('active');
1294            $(this).toggleClass('active');
1295        });
1296    }
1297
1298    function shortenText(element, maxLength) {
1299        element.each(function() {
1300            var text = $(this).text();
1301
1302            if (text.length > maxLength) {
1303                $(this).text(text.slice(0, maxLength) + "...");
1304            }
1305        });
1306    }
1307
1308    shortenText($('.lOffer-account-dropdown .name a'), 15);
1309    shortenText($('.stm-dealer-mail .mail a'), 27);
1310
1311    var lazyTimeout;
1312
1313    $('#stm-dealer-view-type').on('change', function () {
1314        var tabId = $(this).val();
1315        $('a[href=#' + tabId + ']').tab('show');
1316        $('.select-listing-type select').trigger('change');
1317
1318        if (lazyTimeout) clearTimeout(lazyTimeout);
1319        setTimeout(function () {
1320            $("img.lazy").show().lazyload();
1321        }, 200);
1322    });
1323
1324    $('.service-mobile-menu-trigger').on('click', function () {
1325        $('.header-service .header-menu').slideToggle();
1326        let $this = $(this);
1327        if ($this.hasClass('active')) {
1328            $('html').trigger('removeNoScroll');
1329        } else {
1330            $('html').trigger('addNoScroll');
1331        }
1332        $(this).toggleClass('active');
1333    });
1334
1335    updateGridItemTitles();
1336
1337})(jQuery);
1338
1339function updateGridItemTitles() {
1340    var $ = jQuery;
1341
1342    $('.car-title').each(function () {
1343        var $title = $(this);
1344        var maxChar = parseInt($title.attr('data-max-char'));
1345        var $labels = $title.find('.labels');
1346
1347        if ($labels.length > 0 && ($(this).text().length > maxChar)) {
1348            var originalLabels = $labels.clone();
1349            $labels.remove();
1350            var originalText = $title.contents().filter(function () {
1351                return this.nodeType === 3;
1352            }).text().trim();
1353
1354            if (originalText.length > maxChar) {
1355                var truncatedText = originalText.substr(0, maxChar) + '...';
1356
1357                $title.html('').append(originalLabels).append(truncatedText);
1358            } else {
1359                $title.html(originalText).prepend($labels)
1360            }
1361        } else {
1362            if ($(this).attr('data-max-char') != 'undefined' && $(this).text().length > $(this).attr('data-max-char')) {
1363                $(this).text($(this).text().trim().substr(0, $(this).attr('data-max-char')) + '...');
1364            }
1365        }
1366    });
1367}
1368
1369function stm_stretch_image() {
1370    var $ = jQuery;
1371    var position = '.stm-stretch-image-right';
1372
1373    if ($(position).length) {
1374        var windowW = $(document).width();
1375        var containerW = $('.header-main .container').width();
1376
1377        var marginW = (windowW - containerW) / 2;
1378
1379        $(position + ' .vc_column-inner').css({
1380            'margin-right': '-' + marginW + 'px'
1381        });
1382    }
1383
1384    position = '.stm-stretch-image-left';
1385
1386    if ($(position).length) {
1387        var windowW = $(document).width();
1388        var containerW = $('.header-main .container').width();
1389
1390        var marginW = (windowW - containerW) / 2;
1391
1392        $(position + ' .vc_column-inner').css({
1393            'margin-left': '-' + marginW + 'px'
1394        });
1395    }
1396}
1397
1398function stm_isotope_sort_function(currentChoice) {
1399
1400    var $ = jQuery;
1401    var stm_choice = currentChoice;
1402    var $container = $('.stm-isotope-sorting');
1403    switch (stm_choice) {
1404        case 'price_low':
1405            $container.isotope({
1406                getSortData: {
1407                    price: function (itemElem) {
1408                        var price = $(itemElem).data('price');
1409                        return parseFloat(price);
1410                    }
1411                },
1412                sortBy: 'price',
1413                sortAscending: true
1414            });
1415            break;
1416        case 'price_high':
1417            $container.isotope({
1418                getSortData: {
1419                    price: function (itemElem) {
1420                        var price = $(itemElem).data('price');
1421                        return parseFloat(price);
1422                    }
1423                },
1424                sortBy: 'price',
1425                sortAscending: false
1426            });
1427            break;
1428        case 'date_low':
1429            $container.isotope({
1430                getSortData: {
1431                    date: function (itemElem) {
1432                        var date = $(itemElem).data('date');
1433                        return parseFloat(date);
1434                    },
1435                },
1436                sortBy: 'date',
1437                sortAscending: true
1438            });
1439            break;
1440        case 'date_high':
1441            $container.isotope({
1442                getSortData: {
1443                    date: function (itemElem) {
1444                        var date = $(itemElem).data('date');
1445                        return parseFloat(date);
1446                    },
1447                },
1448                sortBy: 'date',
1449                sortAscending: false
1450            });
1451            break;
1452        case 'mileage_low':
1453            $container.isotope({
1454                getSortData: {
1455                    mileage: function (itemElem) {
1456                        var mileage = $(itemElem).data('mileage');
1457                        return parseFloat(mileage);
1458                    }
1459                },
1460                sortBy: 'mileage',
1461                sortAscending: true
1462            });
1463            break;
1464        case 'mileage_high':
1465            $container.isotope({
1466                getSortData: {
1467                    mileage: function (itemElem) {
1468                        var mileage = $(itemElem).data('mileage');
1469                        return parseFloat(mileage);
1470                    }
1471                },
1472                sortBy: 'mileage',
1473                sortAscending: false
1474            });
1475            break;
1476        case 'distance':
1477            $container.isotope({
1478                getSortData: {
1479                    distance: function (itemElem) {
1480                        var distance = $(itemElem).data('distance');
1481                        return parseFloat(distance);
1482                    }
1483                },
1484                sortBy: 'distance',
1485                sortAscending: true
1486            });
1487            break;
1488        default:
1489    }
1490
1491    $container.isotope('updateSortData').isotope();
1492}
1493
1494
1495var stmMotorsCaptcha = function () {
1496    jQuery('.g-recaptcha').each(function (index, el) {
1497        var $ = jQuery;
1498        grecaptcha.render(el, {'sitekey': $(el).data('sitekey')});
1499    });
1500};
1501
1502function stm_check_mobile() {
1503    var isMobile = false; //initiate as false
1504    if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
1505        || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|
1505sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0, 4))) isMobile = true;
1506    return isMobile;
1507}
1508
1509(function ($) {
1510    window.STMCascadingSelect = function STMCascadingSelect(container, relations) {
1511        let self = this;
1512
1513        self.relations = relations;
1514        self.ctx = container;
1515        self.options = {
1516            selectBoxes: []
1517        };
1518
1519        if (self.relations && Object.keys(self.relations).length) {
1520            let selectBoxes = [];
1521
1522            $.each(self.relations, function (slug, options) {
1523                let selectBox = self.selectbox(slug, options);
1524
1525                if (selectBox && typeof selectBox === 'object') {
1526                    selectBoxes.push(selectBox);
1527                }
1528            });
1529
1530            if (selectBoxes.length) {
1531                self.options.selectBoxes = self.options.selectBoxes.concat(selectBoxes);
1532            }
1533        }
1534
1535        $(container).cascadingDropdown(self.options);
1536    };
1537
1538    STMCascadingSelect.prototype.selectbox = function (slug, config) {
1539        var parent = config.dependency;
1540
1541        if (!$(this.selector(slug), this.ctx).length || (parent && !$(this.selector(parent), this.ctx).length)) {
1542            return null;
1543        }
1544
1545        var $select = $(this.selector(slug), this.ctx);
1546        var selected = $select.data('selected');
1547
1548        if ($select.prop('multiple')) {
1549            selected = selected ? selected.split(',') : [];
1550        }
1551
1552        return {
1553            selector: this.selector(slug),
1554            paramName: slug,
1555            requires: parent ? [this.selector(parent)] : null,
1556            allowAll: config.allowAll,
1557            selected: selected,
1558            source: function (request, response) {
1559                var selected = request[parent];
1560                var options = [];
1561                $.each(config.options, function (i, option) {
1562                    if ((config.allowAll && !selected) || (option.deps && option.deps.indexOf(selected) >= 0)) {
1563                        options.push(option);
1564                    }
1565                });
1566
1567                response(options);
1568            }
1569        };
1570    };
1571
1572    STMCascadingSelect.prototype.selector = function (slug) {
1573        if (this.relations[slug].selector) {
1574            return this.relations[slug].selector;
1575        }
1576
1577        return '[name="' + slug + '"]';
1578    }
1579
1580})(jQuery);

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.