PageSourceSearch

https://www.screen.scot/webfiles/1790170705834/screenscot-assets/js/global.js

js screen.scot collected 2026-10-02 05:09:10 UTC 8,954 bytes, 361 lines download raw bytes

1/*global jQuery*/
2/**
3 * creative-scotland
4 * Global JS
5 *
6 * version: 0.0.1
7 * file:    global.js
8 * author:  Squiz Australia
9 * change log:
10 *     Thu Feb 20 2020 14:15:19 GMT+0100 (CET) - First revision
11 */
12
13/*
14 * Table of Contents
15 *
16 * - Global
17 * - Modules
18
19 */
20'use strict';
21/*
22--------------------
23Global
24--------------------
25*/
26//  Declare JS Enabled.
27
28$('body').removeClass('no-js').addClass('js-enabled');
29
30/*
31--------------------
32Modules
33--------------------
34*/
35
36// $(function() {
37//
38// });
39
40
41$(document).ready(function () {
42    var maxHeight = 0;
43
44    $(".team-list__row-list-item").each(function () {
45        var thisH = $(this).height();
46        if (thisH > maxHeight) {
47            maxHeight = thisH;
48        }
49    });
50
51    $(".team-list__row-list-item").height(maxHeight);
52});
53// $(function() {
54//
55// });
56
57// $(function() {
58//
59// });
60
61// $(function() {
62//
63// });
64
65// $(function() {
66//
67// });
68
69// $(function() {
70//
71// });
72
73// $(function() {
74//
75// });
76
77// $(function() {
78//
79// });
80
81// $(function() {
82//
83// });
84
85/* globals cookie */
86
87var cookie = { //eslint-disable-line
88    set: function set(name, value, expires, path, domain, secure) {
89        var curCookie = name + '=' + escape(value) + (expires ? '; expires=' + expires.toGMTString() : '') + (path ? '; path=' + path : '') + (domain ? '; domain=' + domain : '') + (secure ? '; secure' : '');
90        document.cookie = curCookie;
91    },
92    get: function get(name) {
93        var dc = document.cookie;
94        var prefix = name + '=';
95        var begin = dc.indexOf('; ' + prefix);
96        if (begin === -1) {
97            begin = dc.indexOf(prefix);
98            if (begin !== 0) {
99                return null;
100            }
101        } else {
102            begin += 2;
103        }
104        var end = document.cookie.indexOf(';', begin);
105        if (end === -1) {
106            end = dc.length;
107        }
108        return unescape(dc.substring(begin + prefix.length, end));
109    },
110    del: function del(name) {
111        document.cookie = name + '=; domain=/; path=/; expires=' + new Date(0).toUTCString();
112    },
113    getArray: function getArray(name) {
114        var re = new RegExp('[; ]*' + name + '=([^\\s;]*)');
115        var sMatch = document.cookie.match(re);
116        return JSON.parse(sMatch ? unescape(sMatch[1]) : '[]');
117    }
118};
119
120var cookieInfo = {
121    config: {
122        elSelector: '.js-cookie-info',
123        disabledClass: 'cookie-info--disabled',
124        ctaSelector: '.js-cookie-cta',
125        dataAttrs: {
126            cookieName: 'data-cookie-name',
127            acceptedVal: 'data-cookie-accepted-val'
128        }
129    },
130    init: function init() {
131        var el = document.querySelector(cookieInfo.config.elSelector);
132        // adjust basket position
133
134        // Check if the cookie info wrapper exists and the cookie is not yet set
135        if (el && !cookieInfo.isCookieSet(el)) {
136            var btnEl = el.querySelector(cookieInfo.config.ctaSelector);
137            // Add cta click listener that will set the cookie when clicked
138            btnEl && cookieInfo.handleClick(btnEl, el);
139        }
140        // Check if the cookie is already set on load. If so, lets hide the cookie info wrapper
141        el && cookieInfo.isCookieSet(el) && cookieInfo.hideEl(el);
142    },
143    handleClick: function handleClick(btn, wrapperEl) {
144        btn.addEventListener('click', function (e) {
145            e.preventDefault();
146            cookieInfo.setCookie(wrapperEl);
147            cookieInfo.hideEl(wrapperEl);
148        });
149    },
150    isCookieSet: function isCookieSet(wrapperEl) {
151        return cookie.get(wrapperEl.getAttribute(cookieInfo.config.dataAttrs.cookieName));
152    },
153    setCookie: function setCookie(el) {
154        var cookieName = el.getAttribute(cookieInfo.config.dataAttrs.cookieName),
155            cookieVal = el.getAttribute(cookieInfo.config.dataAttrs.acceptedVal);
156        cookie.set(cookieName, cookieVal, false, '/', window.location.hostname);
157    },
158    hideEl: function hideEl(el) {
159        // Hide the cookie info wrapper
160        el.style.top = '-' + el.clientHeight + 'px';
161        // adjust basket position
162        var basket = document.getElementsByClassName('basket');
163        if (el && basket && basket[1]) {
164            basket[1].style.top = '0px';
165        }
166    }
167};
168
169jQuery(window).on('load', function () {
170    cookieInfo.init();
171});
172
173// $(function() {
174//
175// });
176
177// $(function() {
178//
179// });
180
181// $(function() {
182//
183// });
184
185$(function () {
186
187    function toggleHoverClass() {
188        $(this).toggleClass('header-nav__top-level-list-item--hover');
189        // $(this).children('.header-nav__mega-menu').fadeToggle(200);
190    }
191
192    $('.header-nav__top-level-list-item').hoverIntent({
193        over: toggleHoverClass,
194        timeout: 100
195    });
196
197    // $(document).on('click', '.header-nav__top-level-list-link',  function(e){
198    // 	e.preventDefault();
199    // 	console.log('hovad');
200    //     $(this).next('.header-nav__mega-menu').addClass('active').find('.col-md-3:first .header-nav__mega-menu-link').focus();
201    // });
202    //
203    // $(document).on('click', '.mega-menu--toggle',  function(e){
204    // 	e.preventDefault();
205    // 	$('.header-nav__mega-menu').removeClass('active');
206    // });
207});
208
209// $(function() {
210//
211// });
212
213$(function () {
214    if ($('#mp-menu').length) {
215        new mlPushMenu(document.getElementById('mp-menu'), document.getElementById('mp-menu-button'));
216    }
217});
218
219$(document).on('click', '.header__nav-button', function (e) {
220    e.preventDefault();
221    // console.log('clicked');
222});
223
224// $(function() {
225//
226// });
227
228$(function () {
229    $('.film-carousel__list').slick({
230        infinite: true,
231        slidesToShow: 1,
232        mobileFirst: true,
233        responsive: [{
234            breakpoint: 767, // potentially 543
235            settings: {
236                slidesToShow: 2
237            }
238        }, {
239            breakpoint: 991,
240            settings: {
241                slidesToShow: 3
242            }
243        }, {
244            breakpoint: 1199,
245            settings: {
246                slidesToShow: 4
247            }
248        }]
249    });
250});
251
252$(function () {
253    $('.homepage-carousel__carousel').slick({
254        arrows: false,
255        autoplaySpeed: 8000,
256        autoplay: true,
257        dots: true,
258        infinite: true
259    });
260});
261
262// $(function() {
263//
264// });
265
266// $(function() {
267//
268// });
269
270$(function () {
271    $('.social-feeds__ajax-container').each(function () {
272        $(this).load($(this).data('url'));
273    });
274});
275
276// $(function() {
277//
278// });
279
280// $(function() {
281//
282// });
283
284// $(function() {
285//
286// });
287
288// $(function() {
289//
290// });
291//# sourceMappingURL=global.js.map
292
293//set video iframe title for accessibility
294
295function getVideoTitle(videoType, vidID) {
296    let vidURL;
297
298    switch(videoType) {
299        case "vimeo":
300            vidURL = `https://vimeo.com/${vidID}`;
301            break;
302        case "youtube":
303            vidURL = `https://www.youtube.com/watch?v=${vidID}`;
304            break;
305    }
306
307    fetch(`https://noembed.com/embed?dataType=json&url=${vidURL}`)
308      .then(res => res.json())
309      .then(data => $(`.${vidID}`).attr('title', data.title))
310      .catch((error) => {
311        console.log(error)
312      });
313    
314}
315
316
317//Animation for tabbed section
318function scrollToTabbedContent() {
319    // On mobile the "Choose section" toggle sits above the collapsible menu
320    // panel, so its offset stays put regardless of the panel's collapse state -
321    // scroll there instead of #tabbedcontent so the user lands back on the
322    // toggle and can pick another section without scrolling up again.
323    var $target = $(window).width() < 992 ? $(".tabbedSection__nav-toggle") : $("#tabbedcontent");
324    $([document.documentElement, document.body]).animate({
325        scrollTop: $target.offset().top
326    }, 1000);
327}
328
329function addTabbedSectionScroll() {
330    $(".tabbedSection .nav-btn, .tabbedSection .nav li").click(function () {
331        scrollToTabbedContent();
332    });
333}
334
335function setActiveMenuItem() {
336    let anchor = window.location.hash;
337    if (anchor) {
338        $("#tabbedmenu li").removeClass("active");
339        $("#tabbedcontent div").removeClass("active");
340        $("#tabbedmenu a[href='" + anchor + "']").parent().addClass("active");
341        $("#tabbedcontent " + anchor).addClass("active");
342    }
343}
344
345
346if ($(".tabbedSection")) {
347    addTabbedSectionScroll();
348    setActiveMenuItem();
349
350    $(window).on("hashchange", function () {
351        setActiveMenuItem();
352    });
353
354    $("#tabbedmenu a").on("click", function () {
355        setTimeout(setActiveMenuItem, 50);
356
357        if ($(window).width() < 992) {
358            $("#tabbedmenu-panel").collapse("hide");
359        }
360    });
361}

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.