PageSourceSearch

https://aston.co.uk/astonassets/new/js/newmain_search.js?t=

js aston.co.uk collected 2026-09-24 23:09:18 UTC 18,476 bytes, 526 lines download raw bytes

1
2let interval = null;
3
4function fontLoadListener() {
5  var hasLoaded = false
6      /* 
7       * If anything goes wrong with the font loading API, 
8       * just change styles to the web font without handling FOUT 
9       */
10      try {
11        hasLoaded = document.fonts.check('12px "BenchNine"')
12      } catch (error) {
13        console.info(`document.fonts API error: ${error}`)
14        fontLoadedSuccess();
15        return
16      }
17  
18  if(hasLoaded) {
19    fontLoadedSuccess();
20  }
21}
22
23function fontLoadedSuccess() {
24  if(interval) {
25    clearInterval(interval);
26  }
27  
28  document.getElementById("js-font-status").innerHTML = "finished loading";
29  document.getElementsByTagName("body")[0].classList.add("wf-merriweather--loaded");
30}
31
32 interval = setInterval(fontLoadListener, 500)
33 
34
35
36
37
38
39$(document).ready(function () {
40    $(window).resize(function(){
41       $(".grid").isotope().isotope("reloadItems");
42    });
43    var $grid = $('.grid').imagesLoaded( function() {
44        $('.grid').isotope({
45            itemSelector: '.grid-item',
46            horizontalOrder: true,
47            percentPosition: true,
48            masonry: {
49                columnWidth: '.grid-sizer'
50            },
51            transitionDuration: '1s',
52            gutterWidth:10
53        });
54        if (typeof selected_model_id !== 'undefined') {
55            if (selected_model_id) {
56                setTimeout(function(){
57                    console.log('run model');
58                    $(".search-models li[data-id='"+selected_model_id+"']").click();
59                },500);
60            }
61        }
62    });   
63    
64$('.search-filter').on( 'click', 'li', function() {
65    if (typeof page_content_layout !== 'undefined') {
66        if (page_content_layout == 1) {
67            var models = [];
68            if (!$(this).hasClass('active')) {
69                $(this).addClass('active');
70            } else {
71                $(this).removeClass('active');
72            }
73            $('.search-filter .search-models li.active').each(function(){
74                models.push($(this).attr('data-filter'));
75            });
76            if (models.length) {
77                $(".gallery-items .item").hide();
78                $.each(models, function(k, m){
79                    $(".gallery-items .item"+m).show();
80                });
81            } else {
82                $(".gallery-items .item").show();
83            }
84        }
85    } else {
86        var is_query = $(".search-title h2").text() != "Search Results";
87        if (is_query || $(this).parent().hasClass('search-models')) {
88            var groups = [];
89            var models = [];
90            var allfilters = [];
91            if (!$(this).hasClass('active')) {
92                $(this).addClass('active');
93            } else {
94                $(this).removeClass('active');
95            }
96            $('.search-filter .search-groups li.active').each(function(){
97                groups.push($(this).attr('data-filter'));
98            });
99            $('.search-filter .search-models li.active').each(function(){
100                models.push($(this).attr('data-filter'));
101            });
102            if (groups.length && models.length) {
103                $.each(groups, function(i, v){
104                    $.each(models, function(k, m){
105                        allfilters.push(v+m);
106                    });
107                });
108            } else {
109                if (groups.length) {
110                    allfilters = groups;
111                }
112                if (models.length) {
113                    allfilters = models;
114                }
115            }
116            var filterValue = allfilters.length ? allfilters.join(", ") : '*';
117            $grid.isotope({ filter: filterValue });
118        } else {
119            top.location.href="/searchnew.html?group="+$(this).data('id');
120        }
121    }
122});
123    
124   $(".main-nav a").delay(500).animate({opacity:1},100)
125    
126
127    $('.nav-opener').click(function(){
128        $("body").toggleClass("nav-active");
129        $("html").toggleClass("nav-active");
130        $(".main-nav").slideToggle(); 
131        $('.header').toggleClass('active');
132        $('.searchbox').removeClass('active');
133            $(".searchbox .sub-menu").hide();
134            $('.navbox').removeClass('active');
135     
136    });
137
138    
139    if($(window).width() <= 1345){ 
140
141$(".searchbox input").focusin(function() {
142    $(".searchbox .sub-menu").show();
143}).focusout(function () {
144    $(".searchbox .sub-menu").hide();
145});
146        
147    }
148    
149    $(".searchbox input").keypress(function() {
150    $(".search-message").hide();
151    $('.search-results').fadeIn();
152        
153    });
154
155     if($(window).width() <= 1345) {
156        $('.searchbox img').click(function() {
157         if($('.searchbox').hasClass('active')) {
158            $('.searchbox').removeClass('active');
159            $(".searchbox .sub-menu").hide();
160            $('.navbox').removeClass('active');
161         } else {
162            $('.searchbox').addClass('active');
163            $('.navbox').addClass('active');
164            $(".searchbox .sub-menu").slideDown();
165              $("body").removeClass("nav-active");  
166        $(".main-nav").hide(); 
167        $('.header').removeClass('active');
168         }
169        });
170     } else {
171         $('.searchbox img').click(function() {
172             document.forms.f1.submit();
173         });
174     }
175    
176    
177if($(window).width() <= 1345){    
178    
179    
180$(function() {
181	$( ".main-nav" ).accordion({
182		heightStyle: "content",
183        header: ".hold",
184		collapsible: true,
185		active: false,
186		activate: function( event, ui ) {
187			if(!$.isEmptyObject(ui.newHeader.offset())) {
188				$('html:not(:animated), body:not(:animated)').animate({ scrollTop: ui.newHeader.offset().top }, 'slow');
189			}
190		}
191	});
192});
193    
194    $(function() {
195	$( ".searchbox" ).accordion({
196		heightStyle: "content",
197        header: ".searchbox input",
198		collapsible: true,
199		active: false,
200		activate: function( event, ui ) {
201			if(!$.isEmptyObject(ui.newHeader.offset())) {
202				$('html:not(:animated), body:not(:animated)').animate({ scrollTop: ui.newHeader.offset().top }, 'slow');
203			}
204		}
205	});
206});
207
208
209
210}
211
212    
213
214	$(window).scroll(function() {    
215    var scroll = $(window).scrollTop();
216
217    if (scroll >= 500) {
218        $(".homepage .header").addClass("fill");
219    } else {
220        $(".homepage .header").removeClass("fill");
221    }
222});
223    
224    
225    
226});
227
228
229
230!(function ($) {
231    "use strict";
232    var Modal = function (element, options) {
233        this.options = options;
234        this.$element = $(element).delegate('[data-dismiss="modal"]', "click.dismiss.modal", $.proxy(this.hide, this));
235        this.options.remote && this.$element.find(".modal-body").load(this.options.remote);
236    };
237    Modal.prototype = {
238        constructor: Modal,
239        toggle: function () {
240            return this[!this.isShown ? "show" : "hide"]();
241        },
242        show: function () {
243            var that = this,
244                e = $.Event("show");
245            this.$element.trigger(e);
246            if (this.isShown || e.isDefaultPrevented()) return;
247            $("body").addClass("modal-open"), (this.isShown = true);
248            this.escape();
249            this.backdrop(function () {
250                var transition = $.support.transition && that.$element.hasClass("fade");
251                if (!that.$element.parent().length) {
252                    that.$element.appendTo(document.body);
253                }
254                that.$element.show();
255                if (transition) {
256                    that.$element[0].offsetWidth;
257                }
258                that.$element.addClass("in").attr("aria-hidden", false).focus();
259                that.enforceFocus();
260                transition
261                    ? that.$element.one($.support.transition.end, function () {
262                          that.$element.trigger("shown");
263                      })
264                    : that.$element.trigger("shown");
265            });
266        },
267        hide: function (e) {
268            e && e.preventDefault();
269            var that = this;
270            e = $.Event("hide");
271            this.$element.trigger(e);
272            if (!this.isShown || e.isDefaultPrevented()) return;
273            this.isShown = false;
274            $("body").removeClass("modal-open");
275            this.escape();
276            $(document).off("focusin.modal");
277            this.$element.removeClass("in").attr("aria-hidden", true);
278            $.support.transition && this.$element.hasClass("fade") ? this.hideWithTransition() : this.hideModal();
279        },
280        enforceFocus: function () {
281            var that = this;
282            $(document).on("focusin.modal", function (e) {
283                if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
284                    that.$element.focus();
285                }
286            });
287        },
288        escape: function () {
289            var that = this;
290            if (this.isShown && this.options.keyboard) {
291                this.$element.on("keyup.dismiss.modal", function (e) {
292                    e.which == 27 && that.hide();
293                });
294            } else if (!this.isShown) {
295                this.$element.off("keyup.dismiss.modal");
296            }
297        },
298        hideWithTransition: function () {
299            var that = this,
300                timeout = setTimeout(function () {
301                    that.$element.off($.support.transition.end);
302                    that.hideModal();
303                }, 500);
304            this.$element.one($.support.transition.end, function () {
305                clearTimeout(timeout);
306                that.hideModal();
307            });
308        },
309        hideModal: function (that) {
310            this.$element.hide().trigger("hidden");
311            this.backdrop();
312        },
313        removeBackdrop: function () {
314            this.$backdrop.remove();
315            this.$backdrop = null;
316        },
317        backdrop: function (callback) {
318            var that = this,
319                animate = this.$element.hasClass("fade") ? "fade" : "";
320            if (this.isShown && this.options.backdrop) {
321                var doAnimate = $.support.transition && animate;
322                this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />').appendTo(document.body);
323                if (this.options.backdrop != "static") {
324                    this.$backdrop.click($.proxy(this.hide, this));
325                }
326                if (doAnimate) this.$backdrop[0].offsetWidth;
327                this.$backdrop.addClass("in");
328                doAnimate ? this.$backdrop.one($.support.transition.end, callback) : callback();
329            } else if (!this.isShown && this.$backdrop) {
330                this.$backdrop.removeClass("in");
331                $.support.transition && this.$element.hasClass("fade") ? this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) : this.removeBackdrop();
332            } else if (callback) {
333                callback();
334            }
335        },
336    };
337    $.fn.modal = function (option) {
338        return this.each(function () {
339            var $this = $(this),
340                data = $this.data("modal"),
341                options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == "object" && option);
342            if (!data) $this.data("modal", (data = new Modal(this, options)));
343            if (typeof option == "string") data[option]();
344            else if (options.show) data.show();
345        });
346    };
347    $.fn.modal.defaults = { backdrop: true, keyboard: true, show: true };
348    $.fn.modal.Constructor = Modal;
349    $(function () {
350        $("body").on("click.modal.data-api", '[data-toggle="modal"]', function (e) {
351            var $this = $(this),
352                href = $this.attr("href"),
353                $target = $($this.attr("data-target") || (href && href.replace(/.*(?=#[^\s]+$)/, ""))),
354                option = $target.data("modal") ? "toggle" : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data());
355            e.preventDefault();
356            $target.modal(option).one("hide", function () {
357                $this.focus();
358            });
359        });
360    });
361})(window.jQuery);
362!(function ($) {
363    "use strict";
364    var Tab = function (element) {
365        this.element = $(element);
366    };
367    Tab.prototype = {
368        constructor: Tab,
369        show: function () {
370            var $this = this.element,
371                $ul = $this.closest("ul:not(.dropdown-menu)"),
372                selector = $this.attr("data-target"),
373                previous,
374                $target,
375                e;
376            if (!selector) {
377                selector = $this.attr("href");
378                selector = selector && selector.replace(/.*(?=#[^\s]*$)/, "");
379            }
380            if ($this.parent("li").hasClass("active")) return;
381            previous = $ul.find(".active a").last()[0];
382            e = $.Event("show", { relatedTarget: previous });
383            $this.trigger(e);
384            if (e.isDefaultPrevented()) return;
385            $target = $(selector);
386            this.activate($this.parent("li"), $ul);
387            this.activate($target, $target.parent(), function () {
388                $this.trigger({ type: "shown", relatedTarget: previous });
389            });
390        },
391        activate: function (element, container, callback) {
392            var $active = container.find("> .active"),
393                transition = callback && $.support.transition && $active.hasClass("fade");
394            function next() {
395                $active.removeClass("active").find("> .dropdown-menu > .active").removeClass("active");
396                element.addClass("active");
397                if (transition) {
398                    element[0].offsetWidth;
399                    element.addClass("in");
400                } else {
401                    element.removeClass("fade");
402                }
403                if (element.parent(".dropdown-menu")) {
404                    element.closest("li.dropdown").addClass("active");
405                }
406                callback && callback();
407            }
408            transition ? $active.one($.support.transition.end, next) : next();
409            $active.removeClass("in");
410        },
411    };
412    $.fn.tab = function (option) {
413        return this.each(function () {
414            var $this = $(this),
415                data = $this.data("tab");
416            if (!data) $this.data("tab", (data = new Tab(this)));
417            if (typeof option == "string") data[option]();
418        });
419    };
420    $.fn.tab.Constructor = Tab;
421    $(function () {
422        $("body").on("click.tab.data-api", '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
423            e.preventDefault();
424            $(this).tab("show");
425        });
426    });
427})(window.jQuery);
428!(function ($) {
429    "use strict";
430    var Collapse = function (element, options) {
431        this.$element = $(element);
432        this.options = $.extend({}, $.fn.collapse.defaults, options);
433        if (this.options.parent) {
434            this.$parent = $(this.options.parent);
435        }
436        this.options.toggle && this.toggle();
437    };
438    Collapse.prototype = {
439        constructor: Collapse,
440        dimension: function () {
441            var hasWidth = this.$element.hasClass("width");
442            return hasWidth ? "width" : "height";
443        },
444        show: function () {
445            var dimension, scroll, actives, hasData;
446            if (this.transitioning) return;
447            dimension = this.dimension();
448            scroll = $.camelCase(["scroll", dimension].join("-"));
449            actives = this.$parent && this.$parent.find("> .accordion-group > .in");
450            if (actives && actives.length) {
451                hasData = actives.data("collapse");
452                if (hasData && hasData.transitioning) return;
453                actives.collapse("hide");
454                hasData || actives.data("collapse", null);
455            }
456            this.$element[dimension](0);
457            this.transition("addClass", $.Event("show"), "shown");
458            $.support.transition && this.$element[dimension](this.$element[0][scroll]);
459        },
460        hide: function () {
461            var dimension;
462            if (this.transitioning) return;
463            dimension = this.dimension();
464            this.reset(this.$element[dimension]());
465            this.transition("removeClass", $.Event("hide"), "hidden");
466            this.$element[dimension](0);
467        },
468        reset: function (size) {
469            var dimension = this.dimension();
470            this.$element.removeClass("collapse")[dimension](size || "auto")[0].offsetWidth;
471            this.$element[size !== null ? "addClass" : "removeClass"]("collapse");
472            return this;
473        },
474        transition: function (method, startEvent, completeEvent) {
475            var that = this,
476                complete = function () {
477                    if (startEvent.type == "show") that.reset();
478                    that.transitioning = 0;
479                    that.$element.trigger(completeEvent);
480                };
481            this.$element.trigger(startEvent);
482            if (startEvent.isDefaultPrevented()) return;
483            this.transitioning = 1;
484            this.$element[method]("in");
485            $.support.transition && this.$element.hasClass("collapse") ? this.$element.one($.support.transition.end, complete) : complete();
486        },
487        toggle: function () {
488            this[this.$element.hasClass("in") ? "hide" : "show"]();
489        },
490    };
491    $.fn.collapse = function (option) {
492        return this.each(function () {
493            var $this = $(this),
494                data = $this.data("collapse"),
495                options = typeof option == "object" && option;
496            if (!data) $this.data("collapse", (data = new Collapse(this, options)));
497            if (typeof option == "string") data[option]();
498        });
499    };
500    $.fn.collapse.defaults = { toggle: true };
501    $.fn.collapse.Constructor = Collapse;
502    $(function () {
503        $("body").on("click.collapse.data-api", "[data-toggle=collapse]", function (e) {
504            var $this = $(this),
505                href,
506                target = $this.attr("data-target") || e.preventDefault() || ((href = $this.attr("href")) && href.replace(/.*(?=#[^\s]+$)/, "")),
507                option = $(target).data("collapse") ? "toggle" : $this.data();
508            $this[$(target).hasClass("in") ? "addClass" : "removeClass"]("collapsed");
509            $(target).collapse(option);
510        });
511    });
512})(window.jQuery);
513
514
515
516
517
518
519
520
521
522
523
524
525
526

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.