if (!String.prototype.startsWith) { String.prototype.startsWith = function(searchString, position){ position = position || 0; return this.substr(position, searchString.length) === searchString; }; } /* ASSET */ $('#logo').click(function() { $('body').attr('data-direction', 'link'); $('#frameblocks > .frameblock').addClass('hidden'); $('#front').removeClass('hidden'); window.location.hash = ''; $('#menu li').removeClass('active'); $('body').removeClass('menuActive'); setTimeout(function() { $('#nextbtn').addClass('on'); $('#prevbtn').removeClass('on'); }, 0); }); //Hvis det kun er et spreadsheetblock på siden rejustere vi højden på siden function fullPageSpreadsheets() { var spreadsheetVisbile = $('#frameblocks .frameblock[data-class="regnskab"]:visible'); if(spreadsheetVisbile.length <= 1) { $(spreadsheetVisbile[0]).addClass('viewHeight'); } } //Hvis det kun er caseblocks som er på siden fylder den til bund function fullPageCases() { var caseVisbile = $('#frameblocks .frameblock[data-class="case-theme"]:visible'); if(caseVisbile.length >= 1) { var caseVisbileLast = caseVisbile.toArray().reverse()[0]; caseVisbileLast.style["margin-bottom"] = "-5rem"; } } // Iframe Nøgletalsiden window.addEventListener('load', iframeVideoPlayerResize); window.addEventListener('resize', iframeVideoPlayerResize); function iframeVideoPlayerResize() { var windWidth = $(window).width(); /* gets window width in pixel after resize */ var iframe = $(".frameblock[data-class='topvideo'] iframe"); /* iframe dom element */ if(windWidth <= 450){ // XSMALL iframe.height("200px"); } if(windWidth <= 640){ // SMALL iframe.height("350px"); } if(windWidth >= 640){ // Medium checkInvisibleImages(); iframe.height("600px"); } if(windWidth >= 1024){ // Large checkInvisibleImages(); iframe.height("780px"); } if(windWidth >= 1200){ // xLarge checkInvisibleImages(); iframe.height("840px"); } if(windWidth >= 1440){ // xxLarge checkInvisibleImages(); iframe.height("840px"); } } //----------------------------------------------------------------------------// // MENU // Lægger chaptertitles i menu $('#menu li[data-ref="separator"]').addClass('separator'); // Separator var prevAll = $('.separator').prevAll(); var nextAll = $('.separator').nextAll(); prevAll.clone().appendTo($('#prevAll')); // Første kolonne nextAll.clone().appendTo($('#nextAll')); // Anden kolonne if ($('#menu #prevAll li, #menu #nextAll li').length > 0) {$('#menu #authMenu').hide();} ul = $('#prevAll'); // your parent ul element ul.children().each(function(i,li){ul.prepend(li)}) //----------------------------------------------------------------------------// $('#menu li:not(.separator)').click(function() { $('body').attr('data-direction', 'link'); if ( $(this).attr('data-ref') == 'pdf') { window.open('ekf-2019-annual-report.pdf'); } else { $('#menu li').removeClass('active'); var currentActive = $(this).attr('data-ref'); // Tjekker om det valgte menupunkt i #nexAll eller #prevAll findes i #authMenu, og opdatere active på authMenu if(!currentActive.startsWith('content')) { $('#authMenu li[data-ref="'+currentActive+'"]').addClass('active'); $('body').removeClass('menuActive'); window.location.hash = $(this).attr('data-ref'); window.scrollTo(0,0); } else { //var parentFrame = $('.contentblock').closest('.frameblock').prevAll('.frameblock.typetitle:first').data('frameblock'); /*var titleFrame = $('.frameblock[data-frameblock="'+currentActive.replace(/\D/g,'')+'"]').prevAll('.frameblock.typetitle:first').data('frameblock');*/ var titleFrame = $('.contentblock[data-contentblock="'+currentActive.replace(/\D/g,'')+'"]').closest('.frameblock').prevAll('.frameblock.typetitle:first').data('frameblock'); $('#authMenu li[data-ref="'+titleFrame+'"]').addClass('active'); $('body').removeClass('menuActive'); window.location.hash = titleFrame; setTimeout(function(){ $('html, body').animate({ scrollTop: ($('.contentblock[data-contentblock="'+currentActive.replace(/\D/g,'')+'"]').offset().top - 80) },500); }, 100); } } }); //----------------------------------------------------------------------------// // Åbn menu $('#menubtn').click(function() { $('body').toggleClass('menuActive'); }); if ($('body').attr('data-customheader') == '0') { $('#menu li').first().trigger('click'); } //----------------------------------------------------------------------------// $('.edit-reference[data-ref]').click(function() { $('body').removeClass('menuActive'); $('#menu li').removeClass('active'); $('#menu li[data-ref="'+$(this).attr('data-ref')+'"]').addClass('active'); window.location.hash = $(this).attr('data-ref'); window.scrollTo(0,0); }); //----------------------------------------------------------------------------// window.onhashchange = function() { var hash = window.location.hash.split('#')[1]; if (hash && hash.length > 0) { $('#front').addClass('hidden'); } else { var frontNext = $('#menu li').eq(0); while ( frontNext.hasClass('hideNav') || frontNext.hasClass('separator') || (typeof frontNext.attr('data-ref') != 'undefined' && frontNext.attr('data-ref').startsWith('content')) ) { frontNext = frontNext.next('li'); } var nextText = frontNext.find('a').text(); $('#nextbtn span').text(nextText); $('#front').removeClass('hidden'); if ($('body').attr('data-customheader') == '0') { $('#menu li').first().trigger('click'); //frontNext.trigger('click'); } } $('#frameblocks > .frameblock, #frameblocks > .frameblockparent').addClass('hidden'); $(".frameblock.typetitle[data-frameblock='"+hash+"']").removeClass('hidden').nextUntil(".frameblock.typetitle").removeClass('hidden'); var prev = getPrev($('#menu li.active').index()), next = getNext($('#menu li.active').index()); if ($.isNumeric(prev) || (prev == 'front' && $('body').attr('data-customheader') == '1')) { $('#prevbtn').addClass('on'); } else { $('#prevbtn').removeClass('on'); } if (next && $('#menu li.active').attr('data-ref') == hash && $('#menu li.active').next('li').attr('data-ref') != 'pdf' && $('#menu li.active').next('li').not('[data-ref="separator"]').attr('data-ref') != 'separator') { $('#nextbtn').addClass('on'); } else { $('#nextbtn').removeClass('on'); } if ($('#prevbtn').hasClass('on')) { var prevText = $('#menu li').eq(prev).find('a').text(); if (prevText == '') { $('#prevbtn span').addClass('prev-front'); //prevText = window.getComputedStyle(document.querySelector('.front-title'), ':before').getPropertyValue('content').replace(/"/, ''); } else { $('#prevbtn span').removeClass('prev-front'); } $('#prevbtn span').text(prevText); } if ($('#nextbtn').hasClass('on')) { var nextText = $('#menu li').eq(next).find('a').text(); $('#nextbtn span').text(nextText); } initVisibleGraphs(); checkInvisibleImages(); fullPageSpreadsheets(); fullPageCases(); setTimeout(function(){ if ("ga" in window) { tracker = ga.getAll()[0]; if (tracker) { tracker.send("pageview", window.location.pathname+'?id='+window.location.hash.replace('#', '')); } } $('iframe[data-webelementtype="youtube"]:visible').each(function(){ var parent = $(this).parent(); if (parent.children('.vid-cover').length === 0 && "ga" in window) { var coverElem = $('
').on('click', function(){ tracker = ga.getAll()[0]; if (tracker) { console.log("PLAY VID"); tracker.send("event", "Video", "play", window.location.pathname+'?id='+window.location.hash.replace('#', '')); } $(this).remove(); }); parent.append(coverElem); } }); }, 350); }; $('#menu-pdf-link a').on('click', function(){ if ("ga" in window) { tracker = ga.getAll()[0]; if (tracker) { console.log("GET PDF"); tracker.send("event", "PDF", "Download", document.title); } } }); function checkInvisibleImages() { $('.frameblock:visible img[data-src]').each(function() { $(this).attr('src', $(this).attr('data-src')); }); }; //----------------------------------------------------------------------------// $('.contentblock a').on('click', function(e) { var href = $(this).attr('href'); if ( (href.indexOf('http://') == -1 && href.indexOf('https://') == -1) || href.indexOf('#') !== -1) { e.preventDefault(); window.location.hash = href.split('#')[1]; window.scrollTo(0,0); $('#nextbtn').removeClass('on'); } }); // prev/next btns $('#prevbtn').click(function() { if ($('#menu li.active').attr('data-ref') != window.location.hash.split('#')[1]) { $('#menu li.active').trigger('click'); return; } var prev = getPrev( $('#menu li.active').index() ); if ($.isNumeric(prev) || prev == 'front') { if (prev == 'front') { $('#logo').trigger('click'); } else { $('#menu li').eq(prev).trigger('click'); } } }); function getPrev(index) { var hash = window.location.hash.split('#')[1], $prev = $('#menu li').eq(index).prev('li'); if($prev.hasClass('separator')) { $prev = $prev.prev('li'); } while($prev.hasClass('hideNav') || (typeof $prev.attr('data-ref') != 'undefined' && $prev.attr('data-ref').startsWith('content'))) { $prev = $prev.prev('li'); } if ($prev.attr('data-ref') != hash && $prev.attr('data-ref') != 'separator' && $prev.attr('data-ref') != 'pdf' && (typeof $prev.attr('data-ref') == 'undefined' || !$prev.attr('data-ref').startsWith('content'))) { if ($prev.index() >= 0) { return $prev.index(); //initVisibleGraphs(); } else { return 'front'; } } else { //return $prev.index(); return getPrev($prev.index()); } } $('#nextbtn').click(function() { if ($('#front').length && !$('#front').hasClass('hidden')) { //next = $('#menu li').eq(0).trigger('click'); var frontNext = $('#menu li').eq(0); while ( frontNext.hasClass('hideNav') || frontNext.hasClass('separator') || (typeof frontNext.attr('data-ref') != 'undefined' && frontNext.attr('data-ref').startsWith('content')) ) { frontNext = frontNext.next('li'); } frontNext.trigger('click'); console.log("FRONT NXT"); return false; } var next = getNext( $('#menu li.active').index() ); if (next) { $('#menu li').eq(next).trigger('click'); } }); function getNext(index) { var hash = window.location.hash.split('#')[1], $next = $('#menu li').eq(index).next('li'); if($next.hasClass('separator')) { $next = $next.next('li'); } while($next.hasClass('hideNav')) { $next = $next.next('li'); } while(typeof $next.attr('data-ref') != 'undefined' && $next.attr('data-ref').startsWith('content')) { $next = $next.next('li'); } if ($next.attr('data-ref') != hash && $next.attr('data-ref') != 'separator' && $next.attr('data-ref') != 'pdf') { if ($next.index() >= 0) { return $next.index(); } } else if ($next.index() >= 0) { return getNext($next.index()); } } //----------------------------------------------------------------------------// $("body").keydown(function(e) { if(e.keyCode == 37) { // left if ($('#prevbtn').hasClass('on')) { $('#prevbtn').trigger('click'); } } else if(e.keyCode == 39) { if ($('#nextbtn').hasClass('on')) { $('#nextbtn').trigger('click'); } } }); //----------------------------------------------------------------------------// // Nøgletal 2017 function scroll(dataAttr){ var target = $('*[data-class="'+dataAttr+'"]'); if( target.length ) { event.preventDefault(); $('html, body').stop().animate({ scrollTop: target.offset().top-180 }, 1000); } } var topVideo = $('*[data-class="topvideo"]'); var iconList = topVideo.find('ul'); iconList.children('li:nth-child(1)').on('click', function() { scroll('yearresult'); }); iconList.children('li:nth-child(2)').on('click', function() { scroll('basicincome'); }); iconList.children('li:nth-child(3)').on('click', function() { scroll('morale'); }); iconList.children('li:nth-child(4)').on('click', function() { scroll('news'); }); iconList.children('li:nth-child(5)').on('click', function() { scroll('customers'); }); //----------------------------------------------------------------------------// var currentPopup; $('.popupboxbtn').click(function(e) { // if ($(this).find(".edit-picker").data("picked") == "photo") { // e.preventDefault(); // } // else { alert("Video"); } var $contentblock = $(this).parent(), $popupbox = $contentblock.find('.popupbox'); $popupbox.removeClass('hidden'); $(document).find('.dimmer').removeClass('hidden'); updateWebElementPreview($contentblock.data('contentblock')); $popupbox[0].addEventListener('load', updateIframeSize); currentPopup = $contentblock.data('contentblock'); if($(this).hasClass("play-video")) { if (YT) { var thisId = $(this).find('.player').first().attr('id'); youtubeSettings['videoId'] = $(this).find('.ytv').first().attr('href'); console.log(thisId, youtubeSettings['videoId']); player = new YT.Player(thisId, youtubeSettings); if (player !== undefined && typeof player.playVideo == "function") { player.playVideo(); } } else { player.playVideo(); } } }); $('.dimmer').click(function() { $('.popupbox, .dimmer').addClass('hidden'); unsetWebElement(currentPopup); player.stopVideo(); }); //----------------------------------------------------------------------------// // INIT if (!window.location.hash.length > 0) { // no hash: goto front $('#logo').trigger('click'); } else { var hash = window.location.hash.split('#')[1]; $('#menu li[data-ref="'+hash+'"]').addClass('active'); } // Skjul alle frameblocks $('#frameblocks > .frameblock').addClass('hidden'); $('#frameblocks').children().not('.frameblock').addClass('frameblockparent hidden'); // Vis første side $('.frameblock.typetitle:first-child').removeClass('hidden').nextUntil('.frameblock.typetitle').removeClass('hidden'); $(window).trigger('hashchange'); var videoId = $("#ytv").attr("href"); var environment = "web"; var youtubeSettings = { "width": "16", "height": "9", "videoId": videoId, "playerVars": { "modestbranding": "0", "vq": "highres", "controls": "2", "autoplay": "0", "fs": "1", "rel": "0", "showinfo": "0", "hl": "-w861O_gaJ4", "disablekb": "1", "start": "", "end": "", "loop": "0", "playlist": "" } } var player, ratio, ratioW, YT; function loadVideoWhenReady() { ratio = youtubeSettings.height / youtubeSettings.width; ratioW = youtubeSettings.width / youtubeSettings.height; window.containerIframeWidth = window.containerIframeHeight = '0px'; youtubeSettings.height = (document.body.offsetWidth - $('#topbar').outerHeight()) * ratio * 0.6; youtubeSettings.width = youtubeSettings.height * ratioW; if (document.getElementById('player') && document.getElementById('player').getElementsByTagName('img').length > 0) { youtubeSettings.height = document.body.offsetWidth * ratio; youtubeSettings.width = youtubeSettings.height * ratioW; window.containerIframeWidth = document.body.offsetWidth + 'px'; window.containerIframeHeight = youtubeSettings.height + 'px'; document.getElementById('player').style.width = youtubeSettings.width + 'px'; document.getElementById('player').style.height = youtubeSettings.height + 'px'; document.getElementById('player').addEventListener('click', onYouTubeIframeAPIReady); } else { onYouTubeIframeAPIReady(); } } function onYouTubeIframeAPIReady() { var tag = document.createElement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); window.containerIframeWidth = youtubeSettings.width + 'px'; window.containerIframeHeight = youtubeSettings.height + 'px'; if (YT) { player = new YT.Player('player', youtubeSettings); if (player !== undefined && typeof player.playVideo == "function") { player.playVideo(); } } } function updateContainerIframeDimensions() { window.containerIframeWidth = document.body.offsetWidth + 'px'; window.containerIframeHeight = (document.body.offsetWidth * ratio) + 'px'; var elem = document.getElementById('player'); if (elem) {elem.style.height = window.containerIframeHeight;} } window.addEventListener('load', loadVideoWhenReady); window.addEventListener('resize', updateContainerIframeDimensions); $(function () { var picker = $("#front .play-video .edit-picker"); if (picker.data("picked") == "photo") { var popupboxbtn = picker.parents('.popupboxbtn'); popupboxbtn.unbind('click'); popupboxbtn.removeClass('play-video popupboxbtn'); popupboxbtn.find('.hidden.popupbox').remove(); $(".ekf_play_icon.ekf_icon").hide(); } else if (picker.data('picked') == 'video') { } });