PageSourceSearch

https://www.scottishlawreports.org.uk/scripts/application.js

js scottishlawreports.org.uk collected 2026-10-02 10:27:24 UTC 14,254 bytes, 423 lines download raw bytes

1	// DETECT DEVICE
2	$(window).bind('load resize', function() {
3
4	    // IOS BROWSER CLASS
5	    if (navigator.userAgent.match(/iP(hone|od|ad)/i)) {
6	        jQuery('body').addClass('browser-ios');
7	    }
8
9	});
10
11	// FIX PARALLAX 
12	// IE 11 background-attachment:fixed will jitter on scroll if this is missing
13	jQuery(function() {
14	    if (navigator.userAgent.match(/MSIE 10/i) || navigator.userAgent.match(/Trident\/7\./) || navigator.userAgent.match(/Edge\/12\./)) {
15	        $('body').on("mousewheel", function() {
16	            event.preventDefault();
17	            var wd = event.wheelDelta;
18	            var csp = window.pageYOffset;
19	            window.scrollTo(0, csp - wd);
20	        });
21	    }
22	});
23
24	// ADD CLASS TO HTML ELEMENT WHEN THE MOBILE/BURGER NAVIGATION IS PRESENT
25	(function($) {
26	    var $window = $(window),
27	        $html = $('html');
28
29	    function resize() {
30	        if ($window.width() < 768) {
31	            return $html.addClass('mobile-width');
32	        }
33	        $html.removeClass('mobile-width');
34	    }
35	    $window
36	        .resize(resize)
37	        .trigger('load resize');
38	})(jQuery);
39
40	// IMPROVE SCROLL PERFORMANCE FOR
41	// ANIMATION &
42	// HEADER HIDE/REVEAL
43	function debounce(func, wait, immediate) {
44	    var timeout;
45	    return function() {
46	        var context = this,
47	            args = arguments;
48	        var later = function() {
49	            timeout = null;
50	            if (!immediate) func.apply(context, args);
51	        };
52	        var callNow = immediate && !timeout;
53	        clearTimeout(timeout);
54	        timeout = setTimeout(later, wait);
55	        if (callNow) func.apply(context, args);
56	    };
57	};
58	var myEfficientScroll = debounce(function() {
59	    // TRIGGER ANIMATIONS
60	    // http://www.oxygenna.com/tutorials/scroll-animations-using-waypoints-js-animate-css
61	    function onScrollInit(items, trigger) {
62
63	        items.each(function() {
64	            var osElement = $(this),
65	                osAnimationClass = osElement.attr('data-os-animation'),
66	                osAnimationDelay = osElement.attr('data-os-animation-delay');
67
68	            osElement.css({
69	                '-webkit-animation-delay': osAnimationDelay,
70	                '-moz-animation-delay': osAnimationDelay,
71	                '-ms-animation-delay': osAnimationDelay,
72	                'animation-delay': osAnimationDelay
73	            });
74
75	            var osTrigger = (trigger) ? trigger : osElement;
76
77	            osTrigger.waypoint(function() {
78	                osElement.addClass('animated').addClass(osAnimationClass);
79	                $('.slick-slide .os-animation').removeClass('fadeInUp animated');
80	                $('.slick-active .os-animation').addClass('fadeInUp animated');
81	            }, {
82	                //triggerOnce: true,
83	                offset: '95%'
84	            });
85	        });
86
87	    }
88	    onScrollInit($('.os-animation'));
89
90	}, 250);
91	window.addEventListener('load', myEfficientScroll);
92
93	$(document).ready(function() {
94
95	    cookiePolicy();
96
97	    $(".heading, h1, h2, h3, h4, h5, h6").wrapInner("<span class='line'></span>");
98
99	    $(".umbraco-ajax-form form").preventDoubleSubmission();
100
101	    // LAZYSIZES PRELOAD
102	    $('img.lazyload').addClass('lazypreload');
103
104	    // DROP DOWN - CLICK & HOVER - MAIN NAV
105	    $(".navigation nav.main ul li.has-child").hover(function() {
106	        $(this).toggleClass("hover");
107	        $(this).toggleClass("hover");
108	    });
109	    $(".navigation nav.main ul li span i").click(function() {
110	        if ($(".navigation nav.main ul li span i").length) {
111	            $(this).parent().parent().toggleClass("open").toggleClass("open-mobile");
112	            $(this).parent().parent().siblings().removeClass("open").removeClass("open-mobile");
113	        } else {
114	            $(this).parent().parent().toggleClass("open").toggleClass("open-mobile");
115	        }
116	    });
117	    $(".navigation nav.main ul li span.active").parent("li").addClass("open-mobile");
118	    $("html").click(function() {
119	        $(".navigation nav.main ul li.open").removeClass("open");
120	    });
121	    $(".navigation nav.main ul li span i, header a.expand").click(function(e) {
122	        e.stopPropagation();
123	    });
124
125	    // EXPAND MOBILE NAVIVAGTION  
126	    $("header a.expand").click(function() {
127	        if ($(".navigation .reveal").length) {
128	            $("header a.expand").toggleClass('active');
129	            $("html").toggleClass('reveal-out');
130	        } else {
131	            $("header a.expand").toggleClass('active');
132	            $("html").toggleClass('reveal-out');
133	        }
134	    });
135
136	    // EXPAND HEADER SEARCH 
137	    $("header .site-search a.expand-search").click(function() {
138	        if ($("header .site-search").length) {
139	            $("header .site-search").toggleClass('open-search');
140	            $("header .site-search .form-control").focus();
141	        } else {
142	            $("header .site-search").toggleClass('open-search');
143	        }
144	    });
145	    $("html").click(function() {
146	        $("header .site-search").removeClass("open-search");
147	    });
148	    $("header .site-search").click(function(e) {
149	        e.stopPropagation();
150	    });
151
152	    // BANNER
153	    // PLAYS VIDEO IN BANNER
154	    $('.banner .slides').on('init', function(ev, el) {
155	        $('video').each(function() {
156	            this.play();
157	        });
158	    });
159	    // BANNER ITSELF
160	    $(".banner .slides").slick({
161	        infinite: true,
162	        speed: 600,
163	        fade: true,
164	        adaptiveHeight: true,
165	        prevArrow: '<div class="slick-prev"><i class="ion-chevron-left"></i>',
166	        nextArrow: '<div class="slick-next"><i class="ion-chevron-right"></i>'
167	    });
168	    // BANNER INFO IS ANIMATED FOR EACH SLIDE
169	    $('.banner .slides').on('afterChange', function(event, slick, currentSlide) {
170	        slick.$slider.find('.slick-active .os-animation').removeClass('fadeInUp animated');
171	        slick.$slider.find('.slick-active .os-animation').addClass('fadeInUp animated');
172	    });
173	    $('.banner .slides').on('beforeChange', function(event, slick, currentSlide) {
174	        slick.$slider.find('.slick-active .os-animation').removeClass('fadeInUp animated');
175	    });
176
177	    // GALLERY WITH CAROUSEL
178	    $(".spc.gallery .slides").slick({
179	        prevArrow: '<div class="slick-prev"><i class="ion-chevron-left"></i>',
180	        nextArrow: '<div class="slick-next"><i class="ion-chevron-right"></i>',
181	        infinite: true,
182	        speed: 600,
183	        easing: 'linear',
184	        adaptiveHeight: true,
185	        slidesToScroll: 1
186	    });
187
188	    // FEATURED WITH CAROUSEL
189	    $(".related-content .slides").slick({
190	        prevArrow: '<div class="slick-prev"><i class="ion-chevron-left"></i>',
191	        nextArrow: '<div class="slick-next"><i class="ion-chevron-right"></i>',
192	        infinite: true,
193	        speed: 600,
194	        easing: 'linear',
195	        adaptiveHeight: true,
196	        slidesToScroll: 1
197	    });
198
199	    // BOCKQUOTE WITH CAROUSEL
200	    $(".spc.blockquotes .slides").slick({
201	        prevArrow: '<div class="slick-prev"><i class="ion-chevron-left"></i>',
202	        nextArrow: '<div class="slick-next"><i class="ion-chevron-right"></i>',
203	        infinite: true,
204	        speed: 600,
205	        easing: 'linear',
206	        adaptiveHeight: true,
207	        slidesToScroll: 1
208	    });
209
210	    // TEXT WITH SLIDESHOW
211	    $(".apc.text-with-slideshow .slides").slick({
212	        prevArrow: '<div class="slick-prev"><i class="ion-chevron-left"></i>',
213	        nextArrow: '<div class="slick-next"><i class="ion-chevron-right"></i>',
214	        infinite: true,
215	        speed: 600,
216	        easing: 'linear',
217	        adaptiveHeight: true,
218	        slidesToScroll: 1
219	    });
220
221	    // SCROLL PROMPT
222	    // 3 DIFFERENT VERSIONS
223	    // ACCOUNTS FOR DIFFERENT OFFSETS DEPENDING:
224	    // SCREEN WIDTH &/OR HEADER SHOWN
225	    $('html:not(.mobile-width) body:not(.no-header) .scroll-prompt').click(function() {
226	        var target;
227	        $("section").next().each(function(i, element) {
228	            target = ($(element).offset().top - 80);
229	            if (target - 10 > $(document).scrollTop()) {
230	                return false; // break
231	            }
232	        });
233	        $("html, body").animate({
234	            scrollTop: target
235	        }, 600);
236	    });
237	    $('html.mobile-width body:not(.no-header) .scroll-prompt').click(function() {
238	        var target;
239	        $("section").next().each(function(i, element) {
240	            target = ($(element).offset().top - 80);
241	            if (target - 10 > $(document).scrollTop()) {
242	                return false; // break
243	            }
244	        });
245	        $("html, body").animate({
246	            scrollTop: target
247	        }, 600);
248	    });
249	    $('html body.no-header .scroll-prompt').click(function() {
250	        var target;
251	        $("section").next().each(function(i, element) {
252	            target = ($(element).offset().top - 0);
253	            if (target - 10 > $(document).scrollTop()) {
254	                return false; // break
255	            }
256	        });
257	        $("html, body").animate({
258	            scrollTop: target
259	        }, 600);
260	    });
261
262	    // BACK TO TOP
263	    if (($(window).height() + 100) < $(document).height()) {
264
265	        $('#top-link-block').addClass('show').affix({
266	            // how far to scroll down before link "slides" into view
267	            offset: { top: 160 }
268	        });
269
270	    }
271
272	    // MATCH HEIGHTS
273	    // TEXT WITH SLIDESHOW
274	    $(".apc.text-with-slideshow .slides .item, .apc.text-with-slideshow .text-side").matchHeight({
275	        byRow: true
276	    });
277
278	});
279
280	// LIGHTBOX
281	$(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) {
282	    event.preventDefault();
283	    $(this).ekkoLightbox();
284	});
285
286	// HEADER SCROLLING
287	var didScroll;
288	var lastScrollTop = 0;
289	var delta = 160;
290	var navbarHeight = $('header').outerHeight();
291
292	// FIXED HEADER
293	$(window).scroll(function(event) {
294	    didScroll = true;
295	    var scroll = $(window).scrollTop();
296	    if (scroll >= 100) {
297	        $("html").removeClass("reached-top");
298	    } else {
299	        $("html").addClass("reached-top").removeClass("nav-down").removeClass("nav-up");
300	    }
301	});
302	setInterval(function() {
303	    if (didScroll) {
304	        hasScrolled();
305	        didScroll = false;
306	    }
307	}, 5);
308
309	function hasScrolled() {
310	    var st = $(this).scrollTop();
311	    // Make sure they scroll more than delta
312	    if (Math.abs(lastScrollTop - st) <= delta)
313	        return;
314	    if (st > lastScrollTop && st > navbarHeight) {
315	        // Scroll Down
316	        $('html').removeClass('nav-down').addClass('nav-up');
317	    } else {
318	        // Scroll Up
319	        $('html').addClass('nav-down').removeClass('nav-up');
320	    }
321	    lastScrollTop = st;
322	}
323
324	// COOKIE NOTICE FUNCTION
325	function cookiePolicy() {
326	    var cookiePanel = $('.cookie-notice'),
327	        cookieName = "cookieNotice";
328
329	    checkCookie();
330
331	    $('.accept-cookies').on('click', function(e) {
332	        e.preventDefault();
333	        setCookie();
334	    });
335
336	    // Get cookie
337	    function getCookie(c_name) {
338
339	        var i, x, y, ARRcookies = document.cookie.split(";");
340	        for (i = 0; i < ARRcookies.length; i++) {
341	            x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
342	            y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
343	            x = x.replace(/^\s+|\s+$/g, "");
344	            if (x == c_name) {
345	                return unescape(y);
346	            }
347	        }
348
349	    }
350
351	    // Set cookie
352	    function setCookie() {
353
354	        var exdate = new Date();
355	        exdate.setDate(exdate.getDate() + exdays);
356	        var c_value = "accepted" + ((exdays == null) ? "" : "; path=/; expires=" + exdate.toUTCString());
357	        document.cookie = cookieName + " =" + c_value;
358	        cookiePanel.addClass("closed");
359	        cookiePanel.removeClass("open");
360	    }
361
362	    // Check cookie
363	    function checkCookie() {
364
365	        var username = getCookie(cookieName);
366	        if (username != null && username != "") {
367	            cookiePanel.addClass("closed");
368	            cookiePanel.removeClass("open");
369	        } else {
370	            cookiePanel.addClass("open");
371	            cookiePanel.removeClass("closed");
372	        }
373
374	    }
375
376	};
377
378	// jQuery plugin to prevent double submission of forms
379	jQuery.fn.preventDoubleSubmission = function() {
380
381	    $(this).on('submit', function(e) {
382
383	        e.preventDefault();
384
385	        var $form = $(this);
386
387	        if ($form.data('submitted') === true) {
388	            // Previously submitted - don't submit again
389	        } else {
390	            if ($form.valid()) {
391	                // Mark it so that the next submit can be ignored
392	                $form.data('submitted', true);
393
394	                /*show loader*/
395	                $form.find(".ajax-loading").show();
396
397	                // Make ajax call form submission
398	                $.ajax({
399	                    url: $form.attr('action'),
400	                    type: 'POST',
401	                    cache: false,
402	                    data: $form.serialize(),
403	                    success: function(result) {
404
405	                        var thankYouMessage = $form.find('input[name="umbraco_submit_message"]').val();
406
407	                        $form.find('.form-container').html("<div class='umbraco-forms-submitmessage alert alert-success' role='alert'>" + thankYouMessage + "</div>");
408	                        $form.find(".ajax-loading").hide();
409	                    },
410	                    error: function() {
411	                        /*hide loader*/
412	                        $form.find(".ajax-loading").hide();
413	                        $form.find('.UmbracoFormMessage').html("<div class='alert alert-danger alert-dismissible text-center'>An error occured. Please try again.</div>");
414	                    }
415	                });
416	            }
417	        }
418
419	    });
420
421	    // Keep chainability
422	    return this;
423	};

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.