PageSourceSearch

https://migri.fi/o/yja-site-template-theme/js/app.js?browserId=chrome&languageId=sv_SE&t=1790001322000

js migri.fi collected 2026-09-24 17:39:53 UTC 34,837 bytes, 936 lines download raw bytes

1var waitForFinalEvent = (function() {
2    var timers = {};
3    return function(callback, ms, uniqueId) {
4        if (!uniqueId) {
5            uniqueId = "Don't call this twice without a uniqueId";
6        }
7        if (timers[uniqueId]) {
8            clearTimeout(timers[uniqueId]);
9        }
10        timers[uniqueId] = setTimeout(callback, ms);
11    };
12})();
13
14/* a11y init **/
15
16(function () {
17
18    jQuery('div[data-a11y-dialog]').each(function(){
19        var dialogEl = this;
20        var mainEl = document.getElementById('main-content');
21        var dialog = new window.A11yDialog(dialogEl, mainEl);
22    });
23
24    // A11Y Add landmark for MMenu close button
25
26    setTimeout(function (){
27        var mmCloseSection = jQuery('.mm-wrapper__blocker');
28        mmCloseSection.attr("role","navigation")
29        mmCloseSection.attr("aria-label", 'Stäng\x20undermenyn');
30    }, 500)
31
32}());
33
34
35
36var mobile = window.matchMedia("(max-width: 768px)");
37
38if (!Cookies.get('termsAccepted')) {
39    jQuery('#cookie-notice').slideDown();
40}
41
42jQuery('.acceptCookies').on('click', function() {
43    jQuery('#cookie-notice').slideUp();
44    Cookies.set('termsAccepted', 'true');
45});
46
47function onDemandScript(url, callback) {
48    callback = (typeof callback != 'undefined') ? callback : {};
49
50    jQuery.ajax({
51        type: "GET",
52        url: url,
53        success: callback,
54        dataType: "script",
55        cache: true
56    });
57}
58
59jQuery(function($) {
60    $('.block-grid-item .restriction-box').matchHeight();
61    $(document).on('lazybeforeunveil', function(e) {
62        $(e.target).closest('.defer-image').removeClass('is-loading');
63        $(e.target).closest('.defer-image').addClass('is-loaded');
64    });
65
66    $(document).on('lazyImageLoaded', function(e) {
67        var img = $(e.target);
68        img.closest('.defer-image').height(img.height());
69    });
70});
71
72var scrollable_items = jQuery('.carousel-wrapper ul').children(),
73    num_of_items_per_page = jQuery('.carousel').data('slides-per-page'),
74    extraWidth = jQuery('.carousel').data('extra-width');
75
76if (typeof extraWidth === 'undefined') {
77    extraWidth = 0;
78}
79var page_width = Math.ceil(jQuery('.carousel-wrapper').outerWidth(true) + extraWidth);
80
81// Check if slider has configuration
82if (typeof num_of_items_per_page === 'undefined') {
83    num_of_items_per_page = 5;
84}
85
86
87if (page_width < 800 && !mobile.matches) {
88    num_of_items_per_page = 4;
89    if (page_width < 620) {
90        num_of_items_per_page = 3;
91    }
92    if (page_width < 340) {
93        num_of_items_per_page = 1;
94    }
95}
96
97var total_items = scrollable_items.length,
98    total_pages = Math.ceil(total_items / num_of_items_per_page),
99    current_page = 0,
100    listItem = jQuery('.carousel-wrapper ul li'),
101    listItemMargin = parseInt(listItem.css('margin-right')),
102    listItemPadding = parseInt(listItem.css('padding-right')),
103    listItemBorder = parseInt(listItem.css('border-right-width')),
104    element_width = page_width / num_of_items_per_page,
105    paginationWrapper = jQuery('.carousel .position-nav');
106
107if (jQuery(window).width() < 769) {
108    element_width = listItem.first().outerWidth();
109}
110
111
112
113listItem.css('width', element_width);
114
115jQuery('.carousel-wrapper ul li:nth-child(' + num_of_items_per_page + 'n)').find('h3').css('border-right','none');
116jQuery('.carousel-wrapper ul').css('width', element_width * (total_items + 1) + listItemMargin + 'px');
117
118for (i = 0; i < total_pages; ++i) {
119    var paginationElement = '<li class="control"><button data-page="'+ i+ '"></button></li>';
120    paginationWrapper.append(paginationElement);
121}
122paginationWrapper.find('li:first-child').addClass('selected');
123paginationWrapper.find('li:first-child button').attr('aria-selected','true');
124
125
126
127paginationWrapper.find('button').click(function() {
128    paginationWrapper.find('li').removeClass('selected');
129    paginationWrapper.find('li button').removeAttr('aria-selected');
130    jQuery(this).parent().addClass('selected');
131    jQuery(this).attr('aria-selected','selected');
132
133    moveToPage(jQuery(this).data('page'));
134});
135
136function moveToPage(page_num) {
137    jQuery('.carousel-wrapper ul').animate({
138        left: -1 * page_num * page_width
139    }, 600, function() {});
140}
141
142
143jQuery(document).ready(function(){
144	// Set role to presentation for asset publisher RSS icon
145	if ($(".portlet-asset-publisher .subscribe-action svg.lexicon-icon.lexicon-icon-s
145hortcut").length) {
146		$(".portlet-asset-publisher .subscribe-action svg.lexicon-icon.lexicon-icon-shortcut").attr('role','presentation');
147	}
148});
149
150document.addEventListener('DOMContentLoaded', function(){
151    var d = document;
152
153    // -----------------------------
154    // YJA ACCORDION
155    // -----------------------------
156
157    var accordions = d.querySelectorAll('.yja-accordion');
158    if (accordions.length > 0) {
159        for(var i=0;i<accordions.length;i++) {
160            var accordion = accordions[i];
161
162            var wrappers = accordion.querySelectorAll('.yja-accordion-wrapper');
163
164            for(var j=0;j<wrappers.length;j++) {
165                var wrapper = wrappers[j];
166                var heading = wrapper.querySelector('.yja-accordion-toggle');
167
168                if (heading.classList.contains("yja-accordion-toggle--button")) {
169					heading.addEventListener('click',function(evt) {
170						if (evt.target.tagName === 'BUTTON' || evt.target.tagName === 'I') {
171							accordionTogglerHeading(evt.target.parentElement)
172						}
173					},false);
174					heading.addEventListener('keyup',function(evt) {
175
176						var key = evt.key || evt.keyCode;
177						if (evt.key === 13 || evt.key === 'Enter') {
178							accordionTogglerHeading(evt.target)
179						}
180					},false);
181				} else {
182					// For mouse click
183					heading.addEventListener('click',function(evt) {
184						if (evt.target.tagName === 'BUTTON' || evt.target.tagName === 'I') {
185							accordionToggler(evt.target.parentElement)
186						}
187
188					},false);
189
190					// for key enter
191					heading.addEventListener('keyup',function(evt) {
192						if (evt.key === 'Enter' && evt.target.tagName === 'BUTTON' || evt.key === 'Enter' && evt.target.tagName === 'DIV') {
193							accordionToggler(evt.target)
194						}
195					},false);
196				}
197
198            }
199        }
200    }
201
202
203    // -----------------------------
204    // Add link behaviour to cards
205    // -----------------------------
206    var cards = document.querySelectorAll('.yja-card');
207    if (cards.length > 0) {
208        linkifyElement(cards);
209    }
210
211
212}, false);
213
214function accordionToggler(el) {
215    var parent = el.parentElement;
216    var button = el.querySelector('button');
217    var icon = el.querySelector('i');
218    var content = parent.querySelector('.yja-accordion-content');
219
220    if (icon !== null) {
221        icon.classList.toggle('icon-chevron-down');
222        icon.classList.toggle('icon-chevron-right');
223    }
224    if (button !== null) {
225        button.setAttribute('aria-expanded', button.getAttribute('aria-expanded') === 'false' ? 'true' : 'false' );
226    }
227
228    if (content !== null) {
229        content.setAttribute('aria-hidden', content.getAttribute('aria-hidden') === 'true' ? 'false' : 'true'  );
230    }
231}
232
233function accordionTogglerHeading(el) {
234    var parent = el.parentElement;
235    var button = el;
236    var icon = el.querySelector('i');
237    var content = parent.querySelector('.yja-accordion-content');
238
239    if (icon !== null) {
240        icon.classList.toggle('icon-chevron-down');
241        icon.classList.toggle('icon-chevron-right');
242    }
243    if (button !== null) {
244        button.setAttribute('aria-expanded', button.getAttribute('aria-expanded') === 'false' ? 'true' : 'false' );
245    }
246
247    if (content !== null) {
248        content.setAttribute('aria-hidden', content.getAttribute('aria-hidden') === 'true' ? 'false' : 'true'  );
249    }
250}
251
252/* Add image caption to images with class caption*/
253jQuery('img.caption, img.caption-right, img.caption-left').each(function() {
254
255    var item = jQuery(this),
256        marginbottom = item.css('marginBottom'),
257        margintop = item.css('marginTop'),
258        marginleft = item.css('marginLeft'),
259        marginright = item.css('marginRight'),
260        float = item.css('float'),
261        itemClass = ' ' + item.attr("class"),
262        caption = item.prop('title'),
263        imageWidth = item.width(),
264        figcaption = "";
265
266
267    if (caption != "") {
268        if (float == "left" && marginright == "0px") {
269            marginright = "10px";
270        }
271        figcaption = '<figcaption>' + caption + '</figcaption>';
272        item.css({
273            'margin': '0',
274            'float': 'none'
275        });
276
277        if (imageWidth === 0) {
278            imageWidth = '100%';
279        } else {
280            imageWidth = imageWidth + 'px';
281        }
282
283        item.wrap('<figure class="image-caption' + itemClass + '" style="float:' + float + '; margin:' + margintop + ' ' + marginright + ' ' + marginbottom + ' ' + marginleft + '; width:' + imageWidth +';"></figure>');
284        item.closest('.image-caption').append(figcaption);
285    }
286});
287/*
288 **
289 ** Sidenavigation accordion
290 **
291 */
292var toggleButtonOpenSrElem = '';
293var toggleButtonCloseSrElem = '';
294var pageName = '';
295
296jQuery(".portlet-navigation .list-menu .layouts > li").has("ul").addClass("hasChild top") // Top level elements
297    .find("li").has("ul").addClass("hasChild sub"); // Sub level elements
298jQuery('.portlet-navigation .list-menu .layouts .selected').parents('li').addClass('active-li selected');
299jQuery('.hasChild > a').each(function() {
300
301    pageName = jQuery(this).text();
302    toggleButtonOpenSrElem = '<span class="sr-only">' + 'Öppna\x20undermenyn' + ', ' + pageName + '</span>';
303    toggleButtonCloseSrElem = '<span class="sr-only">' + 'Stäng\x20undermenyn' + ', ' + pageName + '</span>';
304    if (jQuery(this).hasClass('selected')) {
305        jQuery(this).parent().addClass('active-li selected');
306        jQuery(this).after('<button aria-expanded="true" class="toggleVisibility icon-chevron-down">'+toggleButtonCloseSrElem+'</button>');
307
308    }
309    else{
310        if (jQuery(this).parent().hasClass("selected")){
311            jQuery(this).after('<button aria-expanded="true" class="toggleVisibility icon-chevron-down">'+toggleButtonCloseSrElem+'</button>');
312        }
313        else{
314            jQuery(this).after('<button aria-expanded="false" class="toggleVisibility icon-chevron-right">'+toggleButtonOpenSrElem+'</button>');
315
316        }
317    }
318});
319
320jQuery('li.active-li a.selected.active').attr("aria-current", "page");
321
322
323
324jQuery('button.toggleVisibility').click(function() {
325    var elem = jQuery(this);
326
327    pageName = jQuery(this).prev('a').text();
328    toggleButtonOpenSrElem = '<span class="sr-only">' + 'Öppna\x20undermenyn' + ', ' + pageName + '</span>';
329    toggleButtonCloseSrElem = '<span class="sr-only">' + 'Stäng\x20undermenyn' + ', ' + pageName + '</span>';
330
331    jQuery(elem.next('ul')).slideToggle('fast');
332
333    if (elem.hasClass('icon-chevron-right')) {
334        elem.removeClass('icon-chevron-right');
335        elem.addClass('icon-chevron-down');
336        elem.attr('aria-expanded', 'true');
337        elem.html(toggleButtonCloseSrElem);
338    } else {
339        elem.removeClass('icon-chevron-down');
340        elem.addClass('icon-chevron-right');
341        elem.attr('aria-expanded', 'false');
342        elem.html(toggleButtonOpenSrElem);
343    }
344
345});
346
347//if (jQuery('.obfuscated-email').length > 0) {
348//
349//    var unobfuscateEmailAtRndStr = '6GWP7iLvhA';
350//    var unobfuscateEmailPeriodRndStr = 'Mw1kbytG99';
351//
352//    function unobfuscateEmail(s) {
353//        s = s.split("").reverse().join("");
354//        s = rot13(s);
355//        s = s.replace(new RegExp(unobfuscateEmailAtRndStr, 'g'), '@');
356//        s = s.replace(new RegExp(unobfuscateEmailPeriodRndStr, 'g'), '.');
357//        return s;
358//    }
359//
360//    jQuery('.obfuscated-email').each(function() {
361//        var unobfuscated = unobfuscateEmail(jQuery(this).html());
362//        jQuery(this).html(unobfuscated);
363//        jQuery(this).removeClass("obfuscated-email");
364//    });
365//
366//}
367
368jQuery(document).ready(function () {
369    jQuery('.portlet-nested-portlets div[role="main"]').removeAttr('role');
370
371});
372
373//
374// OWL Carousel
375//
376
377jQuery(document).ready(function(){
378    // default values
379    // Syntax to define values with CSS
380    // :root { --owl-carousel-items: 5; --owl-carousel-nav: false; }
381    const owlOptions = {
382        center:  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-center').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-center') === 'true' : false,
383        loop:  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-loop').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-loop') === 'true' : false,
384        margin:  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-margin').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-margin') : 10,
385        nav:  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-nav').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-nav') === 'true' : false,
386        dots:  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-dots').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-dots') === 'true' : true,
387        items:  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-items').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-items') : 5,
388        responsiveClass: true,
389        navText: ['<span aria-label="' + 'Föregående'+'"></span>', '<span aria-label="' + 'Nästa'+'"></span>'],
390        responsive:{
391            0:{
392                stagePadding: window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-xs-padding').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-xs-padding') : 0,
393                margin: window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-xs-margin').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-xs-margin') : 0,
394                items:  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-xs-items').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-xs-items') : 1
395            },
396            600:{
397                stagePadding: window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-sm-padding').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-sm-padding') : 0,
398                margin: window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-sm-margin').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-sm-margin') : 10,
399                items:  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-sm-items').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-sm-items') : 2
400            },
401            1000:{
402                stagePadding: window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-padding').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-padding') : 0,
403                margin: window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-margin').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-margin') : 10,
404                items:  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-md-items').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-md-items') : 5
405            }
406        },
407        itemElement:   window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-element-item').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-element-item') : 'LI',
408        stageElement:  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-stage-item').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-stage-item') : 'UL',
409    }
410
411
412
413    // Check that is carousel set as responsive
414    if ( window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-is-responsive') === 'false')  {
415        owlOptions.responsive = false
416        owlOptions.responsiveClass = false
417        owlOptions.items =  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-items').length > 0 ?  window.getComputedStyle(document.documentElement).getPropertyValue('--owl-carousel-items') : 5
418    }
419
420    // Check that OWL carousel content is added to current page
421    if (jQuery('.yja-owl-carousel').length) {
422        // Check that page contains OWL required olw script and style files
423        // if not add them to page
424        const owlScript = document.querySelectorAll('script[src^="/o/common-ui-resources/standalone/owl/js/"]');
425        if (owlScript.length === 0) {
426            addOWLLibraries();
427            setTimeout(function() {
428                // Create carousel
429                initializeOwlCarousel(owlOptions);
430            },500);
431        } else {
432            initializeOwlCarousel(owlOptions);
433        }
434
435    }
436
437
438});
439
440function initializeOwlCarousel(owlOptions) {
441    jQuery('.yja-owl-carousel').owlCarousel(owlOptions);
442
443    // A11Y Additions
444    const dotLabels = {
445        "fi-FI": "Näytä esitys",
446        "sv-SE": "Visa presentation"
447    }
448    let curLabel = "Go to slide";
449    const curLang = document.documentElement.lang;
450
451    if (['fi-FI', 'sv-SE'].includes(curLang)) curLabel = dotLabels[curLang];
452
453    // Remove border right from last visible element
454    jQuery('.owl-item.active').last().addClass('no-border');
455
456    // in resize
457    jQuery('.owl-carousel').on('resize.owl.carousel', function (event) {
458        setTimeout(function () {
459            jQuery('.owl-item').each(function () {
460                jQuery(this).removeClass('no-border');
461            })
462            jQuery('.owl-item.active').last().addClass('no-border');
463        }, 100);
464    });
465
466    // in change
467    jQuery('.owl-carousel').on('translate.owl.carousel', function (event) {
468
469        setTimeout(function () {
470            jQuery('.owl-item').each(function () {
471                jQuery(this).removeClass('no-border');
472            })
473            jQuery('.owl-item.active').last().addClass('no-border');
474        }, 100);
475    });
476
477    setTimeout(function () {
478        // Create a11y dots pagination
479        let curIndex = 1;
480        jQuery('.owl-dots > .owl-dot').each(function (index) {
481
482            jQuery(this).attr('aria-label', curLabel + ' ' + curIndex);
483            jQuery(this).attr('aria-current', 'false');
484            if (jQuery(this).hasClass('active')) jQuery(this).attr('aria-current', 'true');
485
486            curIndex++
487        });
488
489
490        // Listen to pagination clicks
491        jQuery('.owl-dots > .owl-dot').click(function () {
492            setTimeout(() => {
493                jQuery('.owl-dots > button').each(function () {
494                    if (jQuery(this).hasClass('active')) {
495                        jQuery(this).attr('aria-current', 'true');
496                    } else {
497                        jQuery(this).attr('aria-current', 'false');
498                    }
499                });
500            }, 100);
501        })
502    }, 500);
503
504}
505
506
507function addOWLLibraries() {
508    const jsFiles = ['owl.carousel', 'owl.carousel.a11y'];
509    const cssFiles = ['owl.carousel','owl.theme.default'];
510    let scripts = document.body.querySelectorAll('body > script[src]');
511    let styles = document.head.querySelectorAll('head > link[type="text/css"]')
512    let timestamp = '1686119742145';
513
514    jsFiles.forEach(file => {
515        const scriptUrl = `/o/common-ui-resources/standalone/owl/js/${file}.min.js?t=${timestamp}`;
516        $.getScript(scriptUrl,function() {});
517    });
518
519    cssFiles.forEach(file => {
520        const style = document.createElement('link');
521        style.setAttribute('rel', 'stylesheet');
522        style.setAttribute('type', 'text/css');
523        style.href = `/o/common-ui-resources/standalone/owl/css/${file}.min.css?t=${timestamp}`;
524        if (styles.length > 0) {
525            const first = styles[0];
526            first.parentElement.insertBefore(style, first);
527        } else {
528            document.body.appendChild(style);
529        }
530    });
531}
532
533
534
535
536jQuery(document).ready(function() {
537
538    /* ********************************* */
539    /* Youtube Channel / Playlist player */
540    /* ********************************* */
541
542    if(allCookiesAccepted()){
543        jQuery('.ytVideos__container').each(function () {
544            YTPlayer(jQuery(this));
545        });
546    }
547
548    function YTPlayer(id) {
549
550        var playlistID = id.data('ytid');
551        var YTKey = id.data('key');
552        var method = id.data('displayMethod');
553        var maxVideos = id.data('showMaxVideos');
554        var options = [];
555
556        options.push({
557            showDescription: id.data('showDescription'),
558            showViews: id.data('showViews'),
559            duration: id.data('showDuration')
560        });
561
562        if (maxVideos === 0) {
563            maxVideos = 50;
564        }
565
566
567        function showYTChannel(data) {
568
569            var videos = [];
570            $(data.items).each(function (index, item) {
571                if (index < maxVideos) {
572                    var videoStats = [],
573                        details = [],
574                        videoId = item.snippet.resourceId.videoId,
575                        preview = 'https://img.youtube.com/vi/' + videoId + '/hqdefault.jpg',
576                        link = 'https://www.youtube.com/watch?v=' + videoId + '&list=' + playlistID;
577
578                    details.push({title: item.snippet.title, description: item.snippet.description});
579
580
581                    if (method === 'embed') {
582                        createVideoEmbeds(id, videos, preview, link, details, options, videoId, YTKey)
583                    } else {
584                        createVideoLinks(id, videos, preview, link, details, options, videoId, YTKey)
585                    }
586
587                }
588            });
589        }
590
591        var url =
592            'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet%2CcontentDetails&maxResults=' + maxVideos + '&playlistId=' + playlistID + '&key=' + YTKey;
593
594        $.ajax({
595            url: url,
596            dataType: "jsonp",
597            success: function (data) {
598                showYTChannel(data);
599            }
600        });
601    }
602
603    function createVideoLinks(id, videos, preview, link, details, options, videoId, key) {
604        var result = null;
605        $.ajax({
606            url: 'https://www.googleapis.com/youtube/v3/videos?part=contentDetails,statistics&id=' + videoId + '&key=' + key,
607            type: 'get',
608            dataType: 'jsonp',
609            success: function (data) {
610                result = data;
611                linkVideos(videos, preview, link, details, options, result);
612                jQuery(id).html(videos.join(''));
613            }
614        })
615    }
616
617    function createVideoEmbeds(id, videos, preview, link, details, options, videoId, key) {
618        var result = null;
619        $.ajax({
620            url: 'https://www.googleapis.com/youtube/v3/videos?part=contentDetails,statistics&id=' + videoId + '&key=' + key,
621            type: 'get',
622            dataType: 'jsonp',
623            success: function (data) {
624                result = data;
625                embedVideos(videoId, videos, link, details, options, result);
626                jQuery(id).html(videos.join(''));
627            }
628        })
629    }
630
631    // Embed videos to page
632    function embedVideos(videoId, data, link, details, options, stats) {
633        var videoDecription = '';
634        var videoMeta = '';
635
636        if (options[0].showDescription === true) {
637            videoDecription = '<div class="video__description"><p>' + details[0].description + '</p></div>';
638        }
639        if (options[0].showViews === true) {
640            videoMeta = videoMeta + '<span class="video__meta--views"><i aria-hidden="true" class="icon-eye-open"></i><span class="sr-only">' + translate("views") + '</span> ' + stats.items[0].statistics.viewCount + '</span>';
641        }
642
643        if (options[0].duration === true) {
644            videoMeta = videoMeta + '<span class="video__meta--duration"><i aria-hidden="true" class="icon-time"></i><span class="sr-only">' + translate("duration") + '</span>' + YTDurationToSeconds(stats.items[0].contentDetails.duration) + '</span>';
645        }
646
647
648        data.push('<div class="video__item">' +
649            '<div class="u-ar_16-9"><iframe src="https://www.youtube.com/embed/' + videoId + '?modestbranding=1&amp;autoplay=0"></iframe></div>' +
650            '<div class="video__meta">' + videoMeta + '</div>' +
651            '<div class="video__content">' +
652            '<h4>' + details[0].title + '</h4>' +
653            videoDecription +
654            '</div>' +
655            '</div>');
656        return data;
657    }
658
659    // Show only preview & link to youtube
660    function linkVideos(data, preview, link, details, options, stats) {
661        var videoDecription = '';
662        var videoMeta = '';
663
664        if (options[0].showDescription === true) {
665            videoDecription = '<div class="video__description"><p>' + details[0].description + '</p></div>';
666        }
667        if (options[0].showViews === true) {
668            videoMeta = videoMeta + '<span class="video__meta--views"><i aria-hidden="true" class="icon-eye-open"></i><span class="sr-only">' + translate("views") + '</span> ' + stats.items[0].statistics.viewCount + '</span>';
669        }
670
671        if (options[0].duration === true) {
672            videoMeta = videoMeta + '<span class="video__meta--duration"><i aria-hidden="true" class="icon-time"></i><span class="sr-only">' + translate("duration") + '</span>' + YTDurationToSeconds(stats.items[0].contentDetails.duration) + '</span>';
673        }
674
675        data.push('<div class="video__item">' +
676            '<a target="_blank" href="' + link + '">' +
677            '<div class="video__placeholder" >' +
678            '<img src="' + preview + '" alt="' + details[0].title + '" />' +
679            '</div>' +
680            '<div class="video__meta">' + videoMeta + '</div>' +
681            '<div class="video__content">' +
682            '<h4>' + details[0].title + '</h4>' +
683            videoDecription +
684            '</div>' +
685            '</a>' +
686            '</div>');
687        return data;
688    }
689
690    function YTDurationToSeconds(duration) {
691        var match = duration.match(/PT(\d+H)?(\d+M)?(\d+S)?/);
692
693        match = match.slice(1).map(function (x) {
694            if (x != null) {
695                return x.replace(/\D/, '');
696            }
697        });
698
699        var hours = (parseInt(match[0]) || 0);
700        var minutes = (parseInt(match[1]) || 0);
701        var seconds = (parseInt(match[2]) || 0);
702
703        var time = '';
704        if (hours !== 0) {
705            time = hours + ':';
706        }
707        if (minutes !== 0) {
708            time = time + minutes + ':';
709        } else {
710            time = time + '0:';
711        }
712        if (parseInt(seconds) < 10) {
713            seconds = '0' + seconds;
714        }
715
716        time = time + seconds;
717
718        return time;
719    }
720
721    function translate(key) {
722
723        var content = {
724            "fi-FI": {
725                "views": "Katsottu",
726                "duration": "Kesto"
727            },
728            "sv-SE": {
729                "views": "Visningar",
730                "duration": "Längd"
731            },
732            "en-US": {
733                "views": "Views",
734                "duration": "Duration"
735            }
736        };
737
738        var lang = document.documentElement.lang;
739        var text = '';
740
741        switch (lang) {
742            case lang === "fi-FI": {
743                text = getTranslantions(content, lang, key);
744                break;
745            }
746            case lang === "sv-SE": {
747                text = getTranslantions(content, lang, key);
748                break;
749            }
750            case lang === "en-US": {
751                text = getTranslantions(content, lang, key);
752                break;
753            }
754            default:
755                text = getTranslantions(content, lang, key);
756                break;
757        }
758        return text;
759    }
760
761    function getTranslantions(obj, lang, key) {
762        return obj[lang][key];
763    }
764
765});
766
767
768/* Close dropdownd when clicked outside */
769window.addEventListener('click', function(e){
770    const a11yNav = document.querySelector('.a11y-navigation');
771    if (!a11yNav) return
772    if (!document.querySelector('.a11y-navigation')?.contains(e.target)){
773
774
775        jQuery(a11yNav).find('.special-nav-open').each(function() {
776
777            // Find and reset open element into unopened state
778            let targetElement = jQuery(this).find('.a11y-nav__sub');
779            jQuery(targetElement).addClass('d-none').attr('aria-hidden', 'true');
780            jQuery(targetElement).prev('button').attr('aria-expanded', 'false');
781            jQuery(this).find('.a11y-nav__toggle_text').text('Öppna\x20undermenyn');
782            jQuery(this).find('> button > span[role]').removeClass('icon-minus').addClass('icon-plus');
783            
784            // Note: removes class added during dropdown toggle in /yja-shared 'a11y-navigation.js'
785            jQuery(this).removeClass('special-nav-open');
786        });
787
788        // Remove set height
789        jQuery(a11yNav).removeAttr('style');
790    }
791});
792
793/* nav dropdown */
794var dropdownToggleButton = jQuery('.a11y-nav__item > button');
795dropdownToggleButton.click(function(){
796    var ddID = jQuery(this).next('.a11y-nav__sub').attr('data-layout-id');
797    var parentSubmenu = jQuery(this).closest('.a11y-nav__sub');
798    var parentSubmenuID = parentSubmenu.attr('data-layout-id');
799
800    if( parentSubmenu.attr('aria-hidden') == 'false' ){
801        var subMenu = jQuery('.a11y-nav__sub[data-layout-id="' + parentSubmenuID + '"]').find('.a11y-nav__sub');
802        subMenu.addClass('d-none').attr('aria-hidden', 'true').prev('button').attr('aria-expanded', 'false');
803        return false;
804    }
805    else{
806        jQuery('.a11y-nav__sub').each(function(){
807            if( jQuery(this).attr('data-layout-id') != ddID ){
808                jQuery(this).addClass('d-none').attr('aria-hidden', 'true').prev('button').attr('aria-expanded', 'false');
809            }
810        });
811    }
812});
813
814function linkifyElement(items) {
815
816    if (items.length > 0) {
817        for (var i=0; i < items.length; i++) {
818            var item = items[i];
819
820            var link = item.querySelector('a.link--main');
821            if (link) {
822                item.classList.add("linkify");
823
824                item.addEventListener("click", function (evt) {
825                    var parent = evt.target.closest('.linkify');
826                    if (parent) {
827                        var curLink = parent.querySelector('a.link--main');
828                        var url = curLink.getAttribute('href');
829                        location.href = url;
830                        curLink.preventDefault;
831                    }
832                });
833            }
834        }
835    }
836}
837
838function addExternalLinkSrOnlySpans(elem) {
839
840    var extLinkTranslation = 'Länk\x20till\x20en\x20annan\x20webbplats';
841    var opensInNewTabTranslation = 'Öppnas\x20i\x20en\x20ny\x20flik';
842    var srOnlySpanElements = elem.find("span.sr-only");
843    var extLinkSpanAdded = false;
844    var opensInNewTabAdded = false;
845    var isTargetBlank = elem.attr('target') === '_blank';
846
847    srOnlySpanElements.each(function(e) {
848        var span = jQuery(this);
849        if (span.text() === extLinkTranslation) {
850            extLinkSpanAdded = true;
851        } else if (span.text() === opensInNewTabTranslation) {
852            opensInNewTabAdded = true;
853        }
854    })
855    if (!extLinkSpanAdded) {
856        elem.append('<span class="sr-only">'+extLinkTranslation+'</span>')
857    }
858    if (!opensInNewTabAdded && isTargetBlank) {
859        elem.append('<span class="sr-only">, '+opensInNewTabTranslation+'</span>')
860    }
861
862}
863
864function addDocumentOpensInNewTabSrOnlySpan(elem) {
865
866    var opensInNewTabTranslation = 'Filen\x20öppnas\x20i\x20en\x20ny\x20flik';
867    var srOnlySpanElements = elem.find("span.sr-only");
868    var opensInNewTabAdded = false;
869    var isTargetBlank = elem.attr('target') === '_blank';
870
871    if (!isTargetBlank) {
872        elem.attr('target', '_blank');
873    }
874
875    srOnlySpanElements.each(function(e) {
876        var span = jQuery(this);
877        if (span.text() === opensInNewTabTranslation) {
878            opensInNewTabAdded = true;
879        }
880    })
881    if (!opensInNewTabAdded) {
882        elem.append('<span class="sr-only">'+opensInNewTabTranslation+'</span>')
883    }
884
885}
886
887// YJAY-2609 Skripti ylimääräisten linkkitunnisteiden karsimiseksi
888// YJAY-2297 - Set screen reader info for external links
889// YJAVNK-1090 Ulkoisen linkin kuvake: saavutettavuus
890
891jQuery("#content a").each(function(){
892    var aElement = jQuery(this);
893    if (aElement.hasClass("yja-external-link") || aElement.hasClass("external-link")){
894        if (aElement.find('img').length) {
895            if(jQuery.parseHTML(aElement.text().trim())[0]){
896                if (jQuery.parseHTML(aElement.text().trim())[0].nodeName === "IMG") {
897                    aElement.addClass("image-external-icon");
898                    addExternalLinkSrOnlySpans(aElement);
899                }
900                else{
901                    addExternalLinkSrOnlySpans(aElement);
902                }
903            } else{
904                if (aElement.find('img')[0].nodeName === "IMG") {
905                    aElement.addClass("image-external-icon");
906                    addExternalLinkSrOnlySpans(aElement);
907                }
908                else{
909                    addExternalLinkSrOnlySpans(aElement);
910                }
911            }
912        }
913        else if (aElement.find('i').length) {
914            if (!aElement.text().trim().length) {
915                aElement.addClass("no-external-icon");
916                addExternalLinkSrOnlySpans(aElement);
917            }
918            else{
919                addExternalLinkSrOnlySpans(aElement);
920            }
921        }
922        else{
923            addExternalLinkSrOnlySpans(aElement);
924        }
925    }
926
927    if (aElement.hasClass("pdf") && aElement.prop('target') !== '_self') {
928        addDocumentOpensInNewTabSrOnlySpan(aElement);
929    }
930});
931
932// YJAY-4447
933function allCookiesAccepted(){
934	const cookieValue = (document.cookie.match(/^(?:.*;)?\s*yja_cookie_acceptance\s*=\s*([^;]+)(?:.*)?$/)||[,null])[1];
935	return cookieValue == 'all' ? true : false;
936}

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.