PageSourceSearch

https://www.ids.ac.uk/wp-content/themes/ids/assets/js/script-fixed.js?ver=1790237449

js ids.ac.uk collected 2026-09-24 08:43:11 UTC 48,384 bytes, 1,093 lines download raw bytes

1;(function( $ ) {
2
3    'use strict';
4
5    class DisclosureNav {
6
7        constructor(domNode) {
8            this.rootNode = domNode;
9            this.controlledNodes = [];
10            this.openIndex = null;
11            this.useArrowKeys = true;
12            this.topLevelNodes = [
13                ...this.rootNode.querySelectorAll(
14                    '.c-main-menu__link, button.js-menu-item-expand, button[aria-expanded][aria-controls]'
15                ),
16            ];
17
18            this.topLevelNodes.forEach((node) => {
19                // handle button + menu
20                if (
21                    node.tagName.toLowerCase() === 'button' ) {
22                    const menu = node.parentNode.querySelector('.js-sub-menu');
23                    if (menu) {
24                        // save ref controlled menu
25                        this.controlledNodes.push(menu);
26
27                        // collapse menus
28                        node.setAttribute('aria-expanded', 'false');
29                        this.toggleMenu(menu, false);
30
31                        // attach event listeners
32                        menu.addEventListener('keydown', this.onMenuKeyDown.bind(this));
33                        node.addEventListener('click', this.onButtonClick.bind(this));
34                        node.addEventListener('keydown', this.onButtonKeyDown.bind(this));
35                    }
36                }
37                // handle links
38                else {
39                    this.controlledNodes.push(null);
40                    node.addEventListener('keydown', this.onLinkKeyDown.bind(this));
41                }
42            });
43
44            this.rootNode.addEventListener('focusout', this.onBlur.bind(this));
45        }
46
47        controlFocusByKey(keyboardEvent, nodeList, currentIndex) {
48            switch (keyboardEvent.key) {
49                case 'ArrowUp':
50                case 'ArrowLeft':
51                    keyboardEvent.preventDefault();
52                    if (currentIndex > -1) {
53                        var prevIndex = Math.max(0, currentIndex - 1);
54                        nodeList[prevIndex].focus();
55                    }
56                    break;
57                case 'ArrowDown':
58                case 'ArrowRight':
59                    keyboardEvent.preventDefault();
60                    if (currentIndex > -1) {
61                        var nextIndex = Math.min(nodeList.length - 1, currentIndex + 1);
62                        nodeList[nextIndex].focus();
63                    }
64                    break;
65                case 'Home':
66                    keyboardEvent.preventDefault();
67                    nodeList[0].focus();
68                    break;
69                case 'End':
70                    keyboardEvent.preventDefault();
71                    nodeList[nodeList.length - 1].focus();
72                    break;
73            }
74        }
75
76        // public function to close open menu
77        close() {
78            this.toggleExpand(this.openIndex, false);
79        }
80
81        onBlur(event) {
82            var menuContainsFocus = this.rootNode.contains(event.relatedTarget);
83            if (!menuContainsFocus && this.openIndex !== null) {
84                this.toggleExpand(this.openIndex, false);
85            }
86        }
87
88        onButtonClick(event) {
89            var button = event.target;
90            var buttonIndex = this.topLevelNodes.indexOf(button);
91            var buttonExpanded = button.getAttribute('aria-expanded') === 'true';
92            this.toggleExpand(buttonIndex, !buttonExpanded);
93        }
94
95        onButtonKeyDown(event) {
96            var targetButtonIndex = this.topLevelNodes.indexOf(document.activeElement);
97
98            // close on escape
99            if (event.key === 'Escape') {
100                this.toggleExpand(this.openIndex, false);
101            }
102
103            // move focus into the open menu if the current menu is open
104            else if (
105                this.useArrowKeys &&
106                this.openIndex === targetButtonIndex &&
107                event.key === 'ArrowDown'
108            ) {
109                event.preventDefault();
110                this.controlledNodes[this.openIndex].querySelector('a').focus();
111            }
112
113            // handle arrow key navigation between top-level buttons, if set
114            else if (this.useArrowKeys) {
115                this.controlFocusByKey(event, this.topLevelNodes, targetButtonIndex);
116            }
117        }
118
119        onLinkKeyDown(event) {
120            var targetLinkIndex = this.topLevelNodes.indexOf(document.activeElement);
121
122            // handle arrow key navigation between top-level buttons, if set
123            if (this.useArrowKeys) {
124                this.controlFocusByKey(event, this.topLevelNodes, targetLinkIndex);
125            }
126        }
127
128        onMenuKeyDown(event) {
129            if (this.openIndex === null) {
130                return;
131            }
132
133            var menuLinks = Array.prototype.slice.call(
134                this.controlledNodes[this.openIndex].querySelectorAll('a')
135            );
136            var currentIndex = menuLinks.indexOf(document.activeElement);
137
138            // close on escape
139            if (event.key === 'Escape') {
140                this.topLevelNodes[this.openIndex].focus();
141                this.toggleExpand(this.openIndex, false);
142            }
143
144            // handle arrow key navigation within menu links, if set
145            else if (this.useArrowKeys) {
146                this.controlFocusByKey(event, menuLinks, currentIndex);
147            }
148        }
149
150        toggleExpand(index, expanded) {
151            // close open menu, if applicable
152            if (this.openIndex !== index) {
153                this.toggleExpand(this.openIndex, false);
154            }
155
156            // handle menu at called index
157            if (this.topLevelNodes[index]) {
158                this.openIndex = expanded ? index : null;
159                this.topLevelNodes[index].setAttribute('aria-expanded', expanded);
160                this.toggleMenu(this.controlledNodes[index], expanded);
161            }
162        }
163
164        toggleMenu(domNode, show) {
165            if (domNode) {
166                domNode.style.display = show ? 'block' : 'none';
167            }
168        }
169
170        updateKeyControls(useArrowKeys) {
171            this.useArrowKeys = useArrowKeys;
172        }
173    }
174
175    $( document ).on( 'ready', function() {
176
177        $('body.postid-41428 .c-meta-block__heading.ts-heading-6').html('PODCAST SERIES');
178        $('body.postid-41428 .c-breadcrumbs li:last-child .c-breadcrumbs__link .c-breadcrumbs__link-text').html('News & opinion');
179        $('body.postid-41428 .c-breadcrumbs li:last-child .c-breadcrumbs__link').attr('href','https://www.ids.ac.uk/news-and-opinion');
180        $('body.postid-41428 .c-breadcrumbs li:first-child').remove();
181
182
183        // New design for Single Post by Short Courses ( 01.08.24 )
184        if( document.querySelector('body.short-courses .sp-tabs-container') ) {
185
186            document.querySelectorAll('.sp-tabs-container .tabs-panel .tab-item').forEach((el) => {
187                el.addEventListener('click', function (e) {
188                    e.preventDefault();
189
190                    let _self = $(e.target);
191                    let tabID = e.target.dataset.tab;
192                    let contents = document.querySelectorAll('.tabs-content .content-item');
193
194                    _self.addClass('active').siblings().removeClass('active');
195
196                    contents.forEach((elemContent) => {
197                        let contentID = elemContent.dataset.content;
198                        if( contentID === tabID ) {
199                            $(elemContent).addClass('open').removeClass('hide');
200                        }
201                        else {
202                            $(elemContent).removeClass('open').addClass('hide');
203                        }
204                    });
205                });
206            });
207        }
208
209        // Filters Specialist Short Course 02/04/2025
210        if( document.querySelector('.wla-filters__specialist-short-course') ) {
211
212            document.querySelectorAll('.wla-filters__specialist-short-course .c-filters__filter__list li input').forEach((el) => {
213
214                el.addEventListener('click', function (e) {
215
216                    let arrTags = [];
217                    let clearButton = document.querySelector('.wla-filters__specialist-short-course .js-clear-filters-button');
218
219                    $('.wla-filters__specialist-short-course .js-filters__free_paid_courses li').find('input[type="checkbox"]:checked').each(function() {
220                        arrTags.push({ "value" : this.value, "tax" : 'free_paid_courses' } );
221                    });
222
223                    $('.wla-filters__specialist-short-course .js-filters__application_courses li').find('input[type="checkbox"]:checked').each(function() {
224                        arrTags.push({ "value" : this.value, "tax" : 'application_status' } );
225                    });
226
227                    (arrTags.length > 0) ? clearButton.classList.remove('is-disabled') : clearButton.classList.add('is-disabled');
228
229                    let container = document.querySelector('.wla-upcoming-courses .c-listing__main .c-listing__items');
230                    let textInfo = document.querySelector('.wla-upcoming-courses .c-listing__main .c-listing__items-intro-text');
231                    let activeFilters = document.querySelector('.wla-upcoming-courses .c-listing__main .c-active-filters');
232                    $(activeFilters).remove();
233
234                    if( !container ) {
235                        container = document.querySelector('.wla-upcoming-courses .c-listing__main .c-listing__no-results');
236                        container.classList.add('c-listing__items');
237                    }
238
239                    const data = {
240                        'action': 'filter_specialist_short_course',
241                        'nonce_code' : _global_object.nonce,
242                        'params' : JSON.stringify(arrTags),
243                    };
244
245                    $.ajax({
246                        type: 'POST',
247                        dataType: 'json',
248                        url: _global_object.ajax_url,
249                        data: data,
250                        beforeSend: function () {
251                            $(container).css({'opacity':'0.5','transition':'0.3s'});
252                        },
253                        success: function (response) {
254                            if( response.html !== '') {
255                                $(textInfo).html(`Showing ${response.count} result(s)`);
256                                $(container).css({'opacity':'1','transition':'0s'}).html(response.html);
257                            }
258                            else {
259                                $(textInfo).html(`Showing 0 result(s)`);
260                                $(container).html(`<h3 class="ts-heading-4 no-results">No results found</h3>`);
261                            }
262                        },
263                        error: function (obj, err) {
264                            console.log( obj, err );
265                        }
266                    });
267
268                });
269            });
270        }
271
272        // Clear Filters Buttons Specialist Short Course 02/04/2025
273        if( document.querySelector('.wla-filters__specialist-short-course .js-clear-filters-button') ) {
274
275            document.querySelector('.wla-filters__specialist-short-course .js-clear-filters-button').addEventListener('click', function (e) {
276
277                let arrTags = [];
278                let els = document.querySelectorAll('.wla-filters__specialist-short-course input[type=checkbox]:checked');
279                let container = document.querySelector('.wla-upcoming-courses .c-listing__main .c-listing__items');
280                let textInfo = document.querySelector('.wla-upcoming-courses .c-listing__main .c-listing__items-intro-text');
281
282                Array.prototype.forEach.call(els, function(cb){
283                    cb.checked = e.target.checked;
284                });
285
286                this.classList.add('is-disabled');
287
288                const data = {
289                    'action': 'filter_specialist_short_course',
290                    'nonce_code' : _global_object.nonce,
291                    'params' : JSON.stringify(arrTags)
292                };
293
294                $.ajax({
295                    type: 'POST',
296                    dataType: 'json',
297                    url: _global_object.ajax_url,
298                    data: data,
299                    beforeSend: function () {
300                        $(container).css({'opacity':'0.5','transition':'0.3s'});
301                    },
302                    success: function (response) {
303                        if( response.html !== '') {
304                            $(textInfo).html(`Showing ${response.count} result(s)`);
305                            $(container).css({'opacity':'1','transition':'0s'}).html(response.html);
306                        }
307                        else {
308                            $(textInfo).html(`Showing 0 result(s)`);
309                            $(container).html(`<h3 class="ts-heading-4 no-results">No results found</h3>`);
310                        }
311                    },
312                    error: function (obj, err) {
313                        console.log( obj, err );
314                    }
315                });
316
317            });
318        }
319
320        // Sort Specialist Short Course 02/04/2025 (Hide now)
321        if( document.querySelectorAll('.sort-post-specialist-courses .sort-btn').length > 0 ) {
322
323            document.querySelectorAll('.sort-post-specialist-courses .sort-btn').forEach((el) => {
324                el.addEventListener('click', function (e) {
325
326                    let arrTags = [];
327                    let orderDate = '';
328                    let alphabetically = '';
329
330                    if( this.classList.contains('most-recent-first') ) {
331                        orderDate = 'DESC';
332                    }
333                    if( this.classList.contains('oldest-first') ) {
334                        orderDate = 'ASC';
335                    }
336                    if( this.classList.contains('alphabetically') ) {
337                        if( ! this.classList.contains('asc') ) {
338                            alphabetically = 'ASC';
339                            this.classList.add('asc');
340                        } else {
341                            alphabetically = 'DESC';
342                            this.classList.remove('asc');
343                        }
344                    }
345
346                    $(this).toggleClass('is-active').siblings().removeClass('is-active');
347
348                    $('.wla-filters__specialist-short-course .js-filters__free_paid_courses li').find('input[type="checkbox"]:checked').each(function() {
349                        arrTags.push({ "value" : this.value, "tax" : 'free_paid_courses' } );
350                    });
351
352                    $('.wla-filters__specialist-short-course .js-filters__application_courses li').find('input[type="checkbox"]:checked').each(function() {
353                        arrTags.push({ "value" : this.value, "tax" : 'application_status' } );
354                    });
355
356                    let container = document.querySelector('.wla-upcoming-courses .c-listing__main .c-listing__items');
357                    let textInfo = document.querySelector('.wla-upcoming-courses .c-listing__main .c-listing__items-intro-text');
358                    let activeFilters = document.querySelector('.wla-upcoming-courses .c-listing__main .c-active-filters');
359                    $(activeFilters).remove();
360
361                    if( !container ) {
362                        container = document.querySelector('.wla-upcoming-courses .c-listing__main .c-listing__no-results');
363                        container.classList.add('c-listing__items');
364                    }
365
366                    const data = {
367                        'action': 'filter_specialist_short_course',
368                        'nonce_code' : _global_object.nonce,
369                        'params' : JSON.stringify(arrTags),
370                        'order_date' : orderDate,
371                        'alphabetically' : alphabetically
372                    };
373
374                    $.ajax({
375                        type: 'POST',
376                        dataType: 'json',
377                        url: _global_object.ajax_url,
378                        data: data,
379                        beforeSend: function () {
380                            $(container).css({'opacity':'0.5','transition':'0.3s'});
381                        },
382                        success: function (response) {
383                            if( response.html !== '') {
384                                $(textInfo).html(`Showing ${response.count} result(s)`);
385                                $(container).css({'opacity':'1','transition':'0s'}).html(response.html);
386                            }
387                            else {
388                                $(textInfo).html(`Showing 0 result(s)`);
389                                $(container).html(`<h3 class="ts-heading-4">No results found</h3>`);
390                            }
391                        },
392                        error: function (obj, err) {
393                            console.log( obj, err );
394                        }
395                    });
396
397                });
398            });
399        }
400
401        // 20.10.2023
402        // YMC Filter & Grids - Filters Specialist Short Course
403        if( document.querySelector('.specialist-short-courses .section__courses') ) {
404
405            // Toggle Class
406            document.querySelectorAll('.section__courses .js-filters__filter button').forEach((el) => {
407
408                el.addEventListener('click', function (e) {
409                    let btn = $(e.target);
410                    btn.toggleClass('is-open').next().toggle();
411                });
412
413            });
414
415            // Add Filter
416            document.querySelectorAll('.section__courses .js-filters__filter label').forEach((el) => {
417
418                el.addEventListener('click', function (e) {
419
420                    let arrTags = [];
421
422                    setTimeout(() => {
423                        $('.section__courses .js-filters__filter').find('input
423:checked').each(function() {
424                            arrTags.push( this.value );
425                        });
426
427                        $('.section__courses .c-filters__button--clear').removeClass('is-disabled');
428
429                        YMCTools({
430                            target: '.data-target-ymc85372-1',
431                            terms: String(arrTags.join(','))
432                        }).apiTermUpdate();
433
434
435                    }, 1);
436
437                });
438
439            });
440
441            // Result Found Posts
442            wp.hooks.addAction('ymc_after_loaded_data_85372_1', 'smartfilter', function(class_name, response){
443                document.querySelector('.section__courses .found-posts .count').innerHTML = response.post_count;
444            });
445
446            // Clear Filter
447            document.querySelector('.section__courses .c-filters__button--clear').addEventListener('click', function (e) {
448
449                YMCTools({target: '.data-target-ymc85372-1'}).apiTermClear();
450                $('.section__courses .js-filters__filter').find('input:checked').each(function() {
451                    $(this).prop('checked', false);
452                });
453                $('.section__courses .c-filters__filter__list').hide();
454                $('.section__courses .js-filters__filter button').removeClass('is-open');
455                $('.section__courses .c-filters__button--clear').addClass('is-disabled');
456
457            });
458
459            // Sorted Posts
460            document.querySelectorAll('.section__courses .c-sorter a').forEach((el) => {
461
462                el.addEventListener('click', function (e) {
463                    e.preventDefault();
464
465                    let sortOrder = e.target.dataset.sorted;
466                    let sortOrderBy = e.target.dataset.sortorderby;
467
468                    $(e.target).toggleClass('selected').closest('.sorter-item').siblings().find('a').removeClass('selected');
469
470                    YMCTools({
471                        target: ".data-target-ymc85372-1",
472                        sortOrder: sortOrder,
473                        sortOrderBy: sortOrderBy
474                    }).apiSortPosts();
475
476                })
477
478            });
479
480        }
481
482        // 08.01.2024
483        // Filter & Grid Posts
484        if( document.querySelector('.content-hfo-students-new .section__posts') ) {
485
486            // Filters
487            document.querySelectorAll('.content-hfo-students-new .section__posts .filters-items .item').forEach((el) => {
488
489                el.addEventListener('click', function (e) {
490
491                    let item = e.target;
492                    let termID = item.dataset.termid;
493                    let slug = item.dataset.label;
494                    let featuredPosts = $('.section__posts .featured-posts .featured-posts__entry');
495                    let pageID = document.querySelector('.grid-posts__entry').dataset.pageid;
496
497                    $(item).addClass('active').siblings().removeClass('active');
498
499                    let data = {
500                        'action': 'filter_studying_ids',
501                        'nonce_code' : _global_object.nonce,
502                        'term_id' : termID,
503                        'page_id' : pageID,
504                        'slug' : slug
505                    };
506
507                    ( termID === '*' ) ? featuredPosts.show() : featuredPosts.hide();
508
509                    let container = $('.section__posts .grid-posts .grid-posts__entry');
510
511                    $.ajax({
512                        type: 'POST',
513                        dataType: 'json',
514                        url: _global_object.ajax_url,
515                        data: data,
516                        beforeSend: function () {
517                            container.addClass('processing');
518                        },
519                        success: function (response) {
520                            container.removeClass('processing');
521
522                            if( response.html !== '') {
523                                container.removeClass('no-data');
524                                container.html(response.html);
525                                $('.section__posts .grid-posts .pagination').html(response.pagination);
526
527                                if( response.featured_posts !== '') {
528                                    //featuredPosts.html(response.featured_posts);
529                                    container.prepend(response.featured_posts);
530                                }
531
532                            }
533                            else {
534                                container.addClass('no-data');
535                                container.html(`<header class="data-not-available">Data not available.<br/>
536                                    Please, change filtering criteria.</header>`);
537                                $('.section__posts .grid-posts .pagination').empty();
538                            }
539                        },
540                        error: function (obj, err) {
541                            console.log( obj, err );
542                        }
543                    });
544
545                });
546
547            });
548
549            // Pagination
550            $(document).on('click','.content-hfo-students-new .section__posts .grid-posts .pagination a.page-numbers', function (e) {
551
552                e.preventDefault();
553
554                let number_page = $(e.target).attr('href');
555
556                let loc_array = number_page.split('/');
557
558                let paged = loc_array[loc_array.length - 2];
559
560                let itemFilter = $('.content-hfo-students-new .section__posts .filters-items .item.active');
561
562                let termID = itemFilter.data('termid');
563
564                let slug = itemFilter.data('label');
565
566                let pageID = document.querySelector('.grid-posts__entry').dataset.pageid;
567
568                let data = {
569                    'action': 'filter_studying_ids',
570                    'nonce_code' : _global_object.nonce,
571                    'term_id' : termID,
572                    'paged' : paged,
573                    'page_id' : pageID,
574                    'slug' : slug
575                };
576
577                let container = $('.section__posts .grid-posts .grid-posts__entry');
578
579                $.ajax({
580                    type: 'POST',
581                    dataType: 'json',
582                    url: _global_object.ajax_url,
583                    data: data,
584                    beforeSend: function () {
585                        container.addClass('processing');
586                    },
587                    success: function (response) {
588                        if( response.html !== '') {
589                            container.removeClass('no-data processing');
590                            container.html(response.html);
591                            $('.section__posts .grid-posts .pagination').html(response.pagination);
592
593                            if( response.featured_posts !== '') {
594                                //featuredPosts.html(response.featured_posts);
595                                container.prepend(response.featured_posts);
596                            }
597
598
599                            let hash = document.querySelector('#section__posts').getAttribute('id');
600                            let top = $('#'+hash).offset().top - 30;
601                            $('html, body').animate({scrollTop: top}, 100);
602                        }
603                        else {
604                            container.addClass('no-data');
605                            container.html(`<header class="data-not-available">Data not available.<br/>
606                            Please, change filtering criteria.</header>`);
607                        }
608                    },
609                    error: function (obj, err) {
610                        console.log(obj, err);
611                    }
612                });
613
614            });
615        }
616
617        // 26.06.2024
618        if( document.querySelector('.pc-container .section__text') ) {
619
620            document.querySelector('.pc-container .section__text .read-more').addEventListener('click', function (e) {
621                e.preventDefault();
622                this.closest('.crop-content').classList.add('hide');
623                this.closest('.crop-content').nextElementSibling.classList.remove('hide');
624            });
625
626            document.querySelector('.pc-container .section__text .read-less').addEventListener('click', function (e) {
627                e.preventDefault();
628                this.closest('.full-content').previousElementSibling.classList.remove('hide');
629                this.closest('.full-content').classList.add('hide');
630
631                console.log(this.hash);
632
633                if (this.hash !== "") {
634
635                    let hash = this.hash;
636                    let vh = 50;
637                    var top = $(hash).offset().top - vh;
638
639                    $('html, body').animate({scrollTop: top}, 300, function () {
640                        location.hash = hash;
641                    });
642                }
643            });
644        }
645
646        // Scroll fixed navbar
647        if( document.querySelector('.pc-container .navbar') ) {
648            window.onscroll = function() {
649                stickyScroll();
650            };
651
652            let navbar = document.querySelector(".navbar");
653            let sticky = navbar.getBoundingClientRect().top + document.body.scrollTop;
654
655            /**
656             * Function to add or remove 'sticky' class to navbar based on scroll position
657             */
658            function stickyScroll() {
659                // Add 'sticky' class to navbar if scroll position is greater than or equal to 'sticky'
660                if (window.scrollY >= sticky) {
661                    navbar.classList.add("sticky");
662                } else { // Remove 'sticky' class from navbar
663                    navbar.classList.remove("sticky");
664                }
665            }
666        }
667
668        // Projects posts 19/05/25
669        if(document.querySelector('body.single-projects .js-projects-people')) {
670            const buttonLoadMore = document.querySelector('body.single-projects .projects-people__wrapper .js-button-load-more');
671            const listPosts = document.querySelector('body.single-projects .projects-people__wrapper .js-projects-people');
672            buttonLoadMore?.addEventListener('click', function (e) {
673                e.preventDefault();
674                //this.style.display = 'none';
675                this.querySelector('.ts-button').innerText = 'View less';
676                this.classList.toggle('is-view-less');
677
678                listPosts.querySelectorAll('li').forEach((el) => {
679                    //el.classList.contains('is-hidden') ? el.classList.remove('is-hidden') : '';
680                    if(el.classList.contains('is-hidden') && this.classList.contains('is-view-less')) {
681                        el.classList.remove('is-hidden');
682                        el.classList.add('is-visible');
683                    }
684                    if(!this.classList.contains('is-view-less') && el.classList.contains('is-visible')) {
685                        el.classList.remove('is-visible');
686                        el.classList.add('is-hidden');
687                        this.querySelector('.ts-button').innerText = 'View all';
688                    }
689                });
690            });
691        }
692
693        // Header Sticky
694        if(document.querySelector('.prHeader')) {
695            window.onscroll = function() {
696                stickyHeaderScroll();
697            };
698
699            let prHeader = document.querySelector(".prHeader");
700            function stickyHeaderScroll() {
701                if (window.scrollY >= 1) {
702                    prHeader.classList.add("sticky-header");
703                } else {
704                    prHeader.classList.remove("sticky-header");
705                }
706            }
707        }
708
709        // Profile Pages | Projects Grid Posts / 25.11.2025
710        if(document.querySelector('.people-works-modify')) {
711            // Projects
712            wp.hooks.addAction('ymc_after_loaded_data_115922', 'smartfilter', function(class_name, response){
713                if(response.post_count === 0) {
714                    const postsGrid = document.querySelector(`.${class_name}`);
715                    postsGrid.closest('.people-works-modify').style.display = 'none';
716                }
717            });
718            // Programme & Centres
719            wp.hooks.addAction('ymc_after_loaded_data_115991', 'smartfilter', function(class_name, response){
720                if(response.post_count === 0) {
721                    const postsGrid = document.querySelector(`.${class_name}`);
722                    postsGrid.closest('.people-works-modify').style.display = 'none';
723                }
724            });
725        }
726
727        // Menu scroll for Degree Page Template V2
728        const menu = document.querySelector('.js-top-menu-degree');
729        const header = document.querySelector('.prHeader');
730
731        if (menu && header) {
732            const stickyClass = 'is-sticky';
733            const menuStartY = menu.getBoundingClientRect().top + window.scrollY;
734
735            const onScroll = () => {
736                const headerRect = header.getBoundingClientRect();
737                const stickyTriggerY = menuStartY - headerRect.height;
738
739                if (window.scrollY >= stickyTriggerY) {
740                    if (!menu.classList.contains(stickyClass)) {
741                        menu.classList.add(stickyClass);
742                        header.style.visibility = 'hidden';
743                    }
744                } else {
745                    if (menu.classList.contains(stickyClass)) {
746                        menu.classList.remove(stickyClass);
747                        header.style.visibility = 'visible';
748                    }
749                }
750            };
751
752            window.addEventListener('scroll', onScroll, { passive: true });
753        }
754
755         // Single Post Campaigns
756         if(document.querySelector('body.single-campaigns')) {
757                    
758            const menuLocalNavigation = document.querySelector('.js-local-navigation');
759            const menuWrapper = menuLocalNavigation ? menuLocalNavigation.closest('.campaign-navigation__wrap') : null;
760            const navLinksCampaigns = document.querySelectorAll('.js-local-navigation a[href^="#"]'); 
761
762            // Sticky
763            /*if (menuLocalNavigation && menuWrapper && header) {
764
765               const stickyClass = 'is-sticky';
766               const menuStartY = menuLocalNavigation.getBoundingClientRect().top + window.scrollY;
767
768               const onScroll = () => {
769                  const headerRect = header.getBoundingClientRect();
770                  const stickyTriggerY = menuStartY - headerRect.height;
771
772                  if (window.scrollY >= stickyTriggerY) {
773                     if (!menuLocalNavigation.classList.contains(stickyClass)) {                           
774                        menuWrapper.style.height = `${menuLocalNavigation.offsetHeight}px`;
775                        
776                        menuLocalNavigation.classList.add(stickyClass);
777                        header.style.visibility = 'hidden';
778                     }
779                  } 
780                  else {
781                     if (menuLocalNavigation.classList.contains(stickyClass)) {
782                        menuLocalNavigation.classList.remove(stickyClass);
783                        header.style.visibility = 'visible'; 
784                        menuWrapper.style.height = 'auto';
785                     }
786                  }
787               };
788
789               window.addEventListener('scroll', onScroll, { passive: true });               
790            }  
791            */        
792            
793            // Local navigation
794            navLinksCampaigns.forEach(link => {
795               link.addEventListener('click', function (e) {
796                     e.preventDefault(); 
797
798                     const targetId = this.getAttribute('href');
799                     const targetSection = document.querySelector(targetId);
800
801                     if (targetSection) {
802                        
803                        const headerOffset = 140;
804                        const elementPosition = targetSection.getBoundingClientRect().top;
805                        const offsetPosition = elementPosition + window.pageYOffset - headerOffset;
806
807                        window.scrollTo({
808                           top: offsetPosition,
809                           behavior: 'smooth'
810                        });
811                        
812                        // targetSection.scrollIntoView({
813                        //    behavior: 'smooth',
814                        //    block: 'start'
815                        // });
816                        
817                        history.pushState(null, null, targetId);
818                     }
819               });
820            });
821         }       
822
823        
824    });
825
826    $( window ).on( 'load', function() {
827
828        // ADR_14138-6
829        let menus = document.querySelectorAll('#menu-main-menu');
830        for (let i = 0; i < menus.length; i++) {
831            new DisclosureNav(menus[i]);
832        }
833
834        // ADR_14138-8
835        function closeMobMenu(e) {
836            if(e.key === 'Escape') {
837                let btn_close = document.querySelector('.c-hamburger.js-hamburger.is-cross');
838                btn_close.focus();
839            }
840        }
841
842        if(document.querySelector('header .c-hamburger')) {
843            document.querySelector('header .c-hamburger').addEventListener('keydown', function (e) {
844
845                if( e.key === 'Enter' ) {
846                    e.preventDefault();
847
848                    // Open Menu
849                    if( !e.target.classList.contains('is-cross') ) {
850                        // Deativation all links
851                        document.querySelectorAll('section a, footer a').forEach((el)=>{
852                            el.setAttribute('tabindex','-1');
853                        });
854
855                        e.target.classList.add('is-cross');
856                        this.setAttribute('aria-expanded','true');
857                        this.setAttribute('aria-label','Close Menu');
858                        document.querySelector('.c-header__navigation').classList.add('is-visible');
859                        document.querySelector('#menu-main-menu li:first-child > a').focus();
860                    }
861                    // Close Menu
862                    else {
863                        // Activation all links
864                        document.querySelectorAll('section a, footer a').forEach((el)=>{
865                            el.removeAttribute('tabindex');
866                        });
867
868                        document.querySelector('.c-header__navigation').classList.remove('is-visible');
869                        document.querySelector('header .c-hamburger').classList.remove('is-cross');
870                        document.querySelector('header .c-hamburger').setAttribute('aria-expanded','false');
871                        document.querySelector('header .c-hamburger').setAttribute('aria-label','Open Menu');
872                        if(e.target.closest('.c-main-menu__list-item')) {
873                            e.target.closest('.c-main-menu__list-item').classList.remove('is-open');
874                        }
875                    }
876                }
877                if( e.key === 'Escape' ) {}
878            });
879        }
880
881        // add event on link
882        document.querySelectorAll('header #menu-main-menu > li > .c-main-menu__link').forEach((el) => {
883            el.addEventListener('keydown', closeMobMenu );
884        });
885        // add event on button
886        document.querySelectorAll('header #menu-main-menu > li > .js-menu-item-expand').forEach((el) => {
887            el.addEventListener('keydown', closeMobMenu );
888            el.addEventListener('keydown',  function (e) {
889                if(e.key === 'Enter') {
890                    e.target.setAttribute('aria-label','Click to collapse the sub menu');
891                }
892                if(e.key === 'Escape') {
893                    e.target.setAttribute('aria-label','Click to expand the sub menu');
894                    e.target.closest('li').classList.remove('is-open');
895                }
896            });
897        });
898        // add event on mobile extra menu
899        document.querySelectorAll('header #menu-extra-header-menu-1 .menu-item a').forEach((el) => {
900            el.addEventListener('keydown', closeMobMenu );
901        });
902        // add event on social menu
903        document.querySelectorAll('header .c-header__mobile-social li a').forEach((el) => {
904            el.addEventListener('keydown', closeMobMenu );
905        });
906        // add event on submenu
907        document.querySelectorAll('header #menu-main-menu .sub-menu li a').forEach((el) => {
908            el.addEventListener('keydown', function (e) {
909                if(e.key === 'Escape') {
910                    e.target.closest('.c-main-menu__list-item').classList.remove('is-open');
911                }
912            });
913            el.addEventListener('keydown',  function (e) {
914                if(e.key === 'Escape') {
915                    $(e.target).closest('.c-main-menu__list-item').find('.js-menu-item-expand').attr('aria-label','Click to expand the sub menu')
916                }
917            });
918        });
919
920
921        if(document.querySelector('header .c-hamburger')) {
922            document.querySelector('header .c-hamburger').addEventListener('click', function (e) {
923                this.setAttribute('aria-expanded','true');
924            });
925        }
926
927        // ADR_14138-62
928        let containerQuotesSlider = $('body.page-template-tmpl-degree .c-quotes-slider');
929        let quotesSlickList = containerQuotesSlider.find('.slick-list').detach();
930        quotesSlickList.appendTo('body.page-template-tmpl-degree .js-quotes-slider');
931
932        // ADR_14138-54
933        $(document).on('click', 'body.single-publications .js-citation-button', function (e) {
934            $(this).next('.js-cite-copied').html('Citation copied');
935            setTimeout(()=> {
936                $(this).next('.js-cite-copied').html('');
937            },2000);
938        });
939
940        // ADR_14138-10
941        if(document.querySelector('.c-header .js-header-search--mobile-button')) {
942            document.querySelector('.c-header .js-header-search--mobile-button').addEventListener('keydown', function (e) {
943                if( e.key === 'Enter' ) {
944                    e.preventDefault();
945
946                    if( !e.target.classList.contains('is-open') ) {
947                        e.target.classList.add('is-open');
948                        this.setAttribute('aria-expanded','true');
949                        e.target.setAttribute('aria-label','Click to close search');
950                        document.querySelector('.c-header').classList.add('has-search-open');
951                        document.querySelector('.c-header-search--mobile').classList.add('is-open');
952                        document.querySelector('.c-header-search--mobile .js-header-search--text-input').focus();
953                    }
954                    else {
955                        e.target.classList.remove('is-open');
956                        e.target.setAttribute('aria-label','Click to open search');
957                        e.target.setAttribute('aria-expanded','false');
958                        document.querySelector('.c-header-search--mobile').classList.remove('is-open');
959                        document.querySelector('.c-header').classList.remove('has-search-open');
960                    }
961                }
962            });
963        }
964        if(document.querySelector('.c-header .js-header-search--mobile-button')) {
965            document.querySelector('.c-header .js-header-search--mobile-button').addEventListener('click', function (e) {
966                e.preventDefault();
967
968                if( !this.classList.contains('is-open') ) {
969                    this.setAttribute('aria-expanded','false');
970                    this.setAttribute('aria-label','Click to open search');
971                }
972                else {
973                    this.setAttribute('aria-expanded','true');
974                    this.setAttribute('aria-label','Click to close search');
975                }
976            });
977        }
978        if(document.querySelector('.c-header-search--mobile .js-header-search--text-input')) {
979            document.querySelector('.c-header-search--mobile .js-header-search--text-input').addEventListener('keydown', function (e) {
980                if(e.key === 'Escape') {
981                    let el = document.querySelector('.js-header-search--mobile-button');
982                    el.classList.remove('is-open');
983                    el.setAttribute('aria-expanded','false');
984                    el.setAttribute('aria-label','Click to open search');
985                    this.value = '';
986                }
987            });
988        }
989        if(document.querySelector('.c-header-search--mobile .js-header-search--text-input')) {
990            document.querySelector('.c-header-search--mobile .js-header-search--text-input').addEventListener('click', function (e) {
991                setTimeout(() => {
992                    this.closest('.c-header-search--mobile').classList.add('is-open');
993                    this.closest('.c-header-search--mobile').previousElementSibling.querySelector('.js-header-search--mobile-button').classList.add('is-open');
994                },500);
995            });
996        }
997
998        // ADR_14138-40
999        const handlerBtnSearch = function(e) {
1000
1001            let btn = $(e.target).closest('.c-header-search__submit');
1002            if(btn.hasClass('is-clicked')) {
1003                btn.attr('aria-label','Search');
1004                btn.attr('aria-expanded','true');
1005            }
1006            else {
1007                btn.attr('aria-label','Click to open search');
1008            }
1009        }
1010
1011        if(document.querySelector('.c-header .js-header-search--form .c-header-search__submit')) {
1012            document.querySelector('.c-header .js-header-search--form .c-header-search__submit').addEventListener('click', handlerBtnSearch);
1013            document.querySelector('.c-header .js-header-search--form .c-header-search__submit').addEventListener('keydown', handlerBtnSearch);
1014        }
1015
1016        // ADR_14138-46
1017        if(document.querySelector('.wla-upcoming-courses .js-mobile-filters-button')) {
1018
1019            //document.querySelector('.wla-upcoming-courses .js-mobile-filters-button').addEventListener('keydown', function (e) {
1020                //if( e.key === 'Enter' ) {
1021                    //setTimeout(() => {
1022                        //jQuery(document.querySelector('.js-sorter .js-sorter__form fieldset label')).trigger('click');
1023                    //},100);
1024                //}
1025                //if(e.key === 'Escape') {}
1026            //});
1027
1028            document.querySelectorAll('.wla-upcoming-courses .js-sorter .js-sorter__form fieldset label').forEach((el) => {
1029                el.addEventListener('keydown', function (e){
1030                    if( e.key === 'Enter' ) {
1031                        el.click();
1032                    }
1033                });
1034            });
1035
1036        }
1037
1038        // ADR_14138-16
1039        if(document.querySelector('#menu-main-menu .current-menu-item a')) {
1040            document.querySelector('#menu-main-menu .current-menu-item a').setAttribute('aria-current','page');
1041        }
1042
1043        document.querySelectorAll('#menu-main-menu > li > a').forEach((el)=> {
1044            el.addEventListener('focus', function (e){
1045                $(e.target).closest('li').siblings('li').find('a').removeAttr('aria-current');
1046                e.target.setAttribute('aria-current','page');
1047            });
1048        });
1049
1050        // ADR_14138-22
1051        if(document.querySelector('.c-header .js-header-search--form .js-header-search--button')) {
1052            document.querySelector('.c-header .js-header-search--form .js-header-search--button').addEventListener('keydown', function (e) {
1053                if( e.key === 'Enter' ) {
1054                    this.setAttribute('aria-expanded','true');
1055                    this.setAttribute('aria-label','Search');
1056                }
1057            });
1058        }
1059        if(document.querySelector('.c-header .js-header-search--form .js-header-search--text-input')) {
1060            document.querySelector('.c-header .js-header-search--form .js-header-search--text-input').addEventListener('keydown', function (e) {
1061                if(e.key === 'Escape') {
1062                    let btn =  document.querySelector('.c-header .js-header-search--form .js-header-search--button');
1063                    btn.setAttribute('aria-expanded','false');
1064                    btn.setAttribute('aria-label','Click to open search');
1065                }
1066            });
1067        }
1068        if(document.querySelector('.c-header .js-header-search--form .js-header-search--close')) {
1069            document.querySelector('.c-header .js-header-search--form .js-header-search--close').addEventListener('keydown', function (e) {
1070                if( e.key === 'Enter' ) {
1071                    setTimeout(()=> {
1072                        $('.c-header .js-header-search--form .js-header-search--close').trigger("click");
1073                    },1);
1074
1075                    document.querySelector('.c-header .js-header-search--form .js-header-search--button').setAttribute('aria-expanded','false');
1076                    document.querySelector('.c-header .js-header-search--form .js-header-search--button').setAttribute('aria-label','Click to open search');
1077
1078                }
1079            });
1080        }
1081        if(document.querySelector('.c-header .js-header-search--form .js-header-search--close')) {
1082            document.querySelector('.c-header .js-header-search--form .js-header-search--close').addEventListener('click', function (e) {
1083                document.querySelector('.c-header .js-header-search--form .js-header-search--button').setAttribute('aria-expanded','false');
1084                document.querySelector('.c-header .js-header-search--form .js-header-search--button').setAttribute('aria-label','Click to open search');
1085            });
1086        }
1087
1088        // ADR_14138-3
1089        $('.js-sub-menu .ts-heading-4').wrap("<h2 class='heading-sub-menu'/>");
1090
1091    });
1092
1093}( 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.