1// EXTERNAL LINK FUNCTION 2function addExternalLink(e) { 3 if (!e.hasAttribute("target") || e.getAttribute("target") === "") { 4 e.setAttribute("target", "_blank"); 5 } 6 var newTabSpan = document.createElement("SPAN"); 7 var spanText = document.createTextNode('Avautuu\x20uudessa\x20välilehdessä'); 8 newTabSpan.appendChild(spanText); 9 newTabSpan.classList.add("sr-only"); 10 e.appendChild(newTabSpan); 11 e.classList.add("external-link"); 12} 13 14// DOCUMENT LINK FUNCTION 15function addDocumentLink(e) { 16 if (!e.hasAttribute("target") || e.getAttribute("target") === "") { 17 e.setAttribute("target", "_blank"); 18 } 19 var newTabSpan = document.createElement("SPAN"); 20 var spanText = document.createTextNode('Tiedosto\x20avautuu\x20uudessa\x20välilehdessä'); 21 newTabSpan.appendChild(spanText); 22 newTabSpan.classList.add("sr-only"); 23 e.appendChild(newTabSpan); 24 e.classList.add("external-link"); 25} 26 27// EXTERNAL LINK ADDER 28document.addEventListener("DOMContentLoaded", function () { 29 var d = document; 30 var b = location.origin; 31 // Add class to external links 32 var queriedSelectors = [".journal-content-article", ".yja-document-display", ".footer-main-content"]; 33 Array.prototype.slice.call(queriedSelectors).forEach(function (current) { 34 var c = d.querySelectorAll(current); 35 for (var i = 0; i < c.length; i++) { 36 var a = c[i].querySelectorAll("a"); 37 for (var j = 0; j < a.length; j++) { 38 var u = a[j].href; 39 if (u !== "" && !u.startsWith(b) && !u.startsWith("/") && !u.startsWith("#")) { 40 addExternalLink(a[j]); 41 } 42 if (u !== "" && u.startsWith(b) && u.indexOf("/documents/") > -1) { 43 addDocumentLink(a[j]); 44 } 45 } 46 } 47 }); 48 49 // YJALVV-192 50 const adoptio = document.getElementsByClassName('adoptio'); 51 52 if (adoptio.length > 0) { 53 jQuery('.yja-dropdown__list ul li').each(function (index) { 54 if (jQuery(this).hasClass('se')) { 55 jQuery(this).remove(); 56 } 57 }) 58 } 59}); 60 61// YJALVV-179 62document.addEventListener("DOMContentLoaded", function () { 63 $('div.columns-1-3-1').addClass('lvv-layout-wrapper'); 64}); 65 66// MENU TOGGLE PAGE USE AND BACKGROUND 67var contentArea = document.querySelector("#content"); 68var footerArea = document.querySelector("#footer"); 69 70function menuOpenBodyToggleAdd() { 71 document.body.classList.add("nav-menu-opened"); 72 contentArea.addEventListener("click", menuOpenBodyContentToggle); 73 footerArea.addEventListener("click", menuOpenBodyContentToggle); 74} 75 76function menuOpenBodyToggleRemove() { 77 document.body.classList.remove("nav-menu-opened"); 78 contentArea.removeEventListener("click", menuOpenBodyContentToggle); 79 footerArea.removeEventListener("click", menuOpenBodyContentToggle); 80} 81 82function menuOnToggleClick(event) { 83 const button = event.currentTarget; 84 const isExpanded = button.getAttribute("aria-expanded") === "true"; 85 86 if (isExpanded) { 87 menuOpenBodyToggleRemove(); 88 } else { 89 menuOpenBodyToggleAdd(); 90 } 91} 92 93function menuOpenBodyContentToggle() { 94 if (document.body.classList.contains("nav-menu-opened")) { 95 menuOpenBodyToggleRemove(); 96 } 97 else { 98 menuOpenBodyToggleAdd(); 99 } 100} 101 102document.querySelectorAll("#navigation button.dropdown-toggle").forEach((button) => { 103 button.addEventListener("click", menuOnToggleClick); 104}); 105 106 107/* 108 ** Sidenavigation accordion 109 */ 110var toggleButtonOpenSrElem = ""; 111var toggleButtonCloseSrElem = ""; 112var pageName = ""; 113 114jQuery(".portlet-navigation .list-menu .layouts > li") 115 .has("ul") 116 .addClass("hasChild top") // Top level elements 117 .find("li") 118 .has("ul") 119 .addClass("hasChild sub"); // Sub level elements 120jQuery(".portlet-navigation .list-menu .layouts ul.submenu").css("flex", "1 1 auto"); 121jQuery(".portlet-navigation .list-menu .layouts .selected").parents("li").addClass("active-li selected"); 122 123jQuery(".portlet-navigation .list-menu .layouts li").each(function () { 124 pageName = jQuery(this).text(); 125 toggleButtonOpenSrElem = '<span class="sr-only">' + 'Avaa\x20alavalikko' + ", " + pageName + "</span>"; 126 toggleButtonCloseSrElem = '<span class="sr-only">' + 'Sulje\x20alavalikko' + ", " + pageName + "</span>"; 127 128 if (jQuery(this).hasClass("selected")) { 129 jQuery(this).find("div").css("display", "flex"); 130 jQuery(this).find("div").css("width", "100%"); 131 jQuery(this).find("button svg").remove(); 132 jQuery(this).find("button").addClass("toggleVisibility icon-chevron-down"); 133 } else if (jQuery(this).closest("li").hasClass("hasChild")) { 134 jQuery(this).find("button").addClass("toggleVisibility icon-chevron-right"); 135 jQuery(this).find("button svg").remove(); 136 jQuery(this).find("div").css("display", "flex"); 137 jQuery(this).find("div").css("width", "100%"); 138 } 139 140 jQuery(this) 141 .find(".hasChild a") 142 .each(function () { 143 pageName = jQuery(this).text(); 144 toggleButtonOpenSrElem = '<span class="sr-only">' + 'Avaa\x20alavalikko' + ", " + pageName + "</span>"; 145 toggleButtonCloseSrElem = '<span class="sr-only">' + 'Sulje\x20alavalikko' + ", " + pageName + "</span>"; 146 147 if (jQuery(this).closest("li").hasClass("selected")) { 148 jQuery(this).parent().addClass("active-li selected"); 149 jQuery(this).parent().css("display", "flex"); 150 jQuery(this).parent().css("width", "100%"); 151 jQuery(this).find("button svg").remove(); 152 jQuery(this).next("button").addClass("toggleVisibility icon-chevron-down"); 153 } else if (jQuery(this).closest("li").hasClass("hasChild")) { 154 jQuery(this).next("button").addClass("toggleVisibility icon-chevron-right"); 155 jQuery(this).find("button svg").remove(); 156 jQuery(this).parent().css("display", "flex"); 157 jQuery(this).parent().css("width", "100%"); 158 } 159 }); 160}); 161 162jQuery("li.active-li a.selected.active").attr("aria-current", "page"); 163 164jQuery("button.toggleVisibility").click(function () { 165 var elem = jQuery(this); 166 pageName = jQuery(this).prev("a").text(); 167
168 setTimeout(function () { 169 toggleButtonOpenSrElem = '<span class="sr-only">' + 'Avaa\x20alavalikko' + ", " + pageName + "</span>"; 170 toggleButtonCloseSrElem = '<span class="sr-only">' + 'Sulje\x20alavalikko' + ", " + pageName + "</span>"; 171 172 jQuery(elem.next("ul")).slideToggle("fast"); 173 174 if (elem.hasClass("icon-chevron-right")) { 175 elem.removeClass("icon-chevron-right"); 176 elem.addClass("icon-chevron-down"); 177 elem.attr("aria-expanded", "true"); 178 elem.html(toggleButtonCloseSrElem); 179 } else { 180 elem.removeClass("icon-chevron-down"); 181 elem.addClass("icon-chevron-right"); 182 elem.attr("aria-expanded", "false"); 183 elem.html(toggleButtonOpenSrElem); 184 } 185 }, 50); 186}); 187 188// ADOPTIOLAUTAKUNTA 189(function () { 190 const BREAKPOINT = 992; 191 const sourceSelector = ".adoptio-nav ul.layouts.level-1"; 192 const targetSelector = ".adoptio .yja-mobile-navigation__tree"; 193 194 const sourceEl = document.querySelector(sourceSelector); 195 const targetEl = document.querySelector(targetSelector); 196 197 if (!sourceEl || !targetEl) return; 198 199 const placeholder = document.createElement("div"); 200 placeholder.style.display = "none"; 201 202 const originalParent = sourceEl.parentNode; 203 const originalNextSibling = sourceEl.nextSibling; 204 205 originalParent.insertBefore(placeholder, sourceEl); 206 207 function moveToMobile() { 208 if (sourceEl.parentNode !== targetEl) { 209 targetEl.appendChild(sourceEl); 210 } 211 } 212 213 function restoreToOriginal() { 214 if (sourceEl.parentNode !== originalParent) { 215 if (originalNextSibling && originalNextSibling.parentNode === originalParent) { 216 originalParent.insertBefore(sourceEl, originalNextSibling); 217 } else { 218 originalParent.insertBefore(sourceEl, placeholder.nextSibling); 219 } 220 } 221 } 222 223 function evaluate() { 224 if (window.matchMedia(`(max-width: ${BREAKPOINT - 1}px)`).matches) { 225 moveToMobile(); 226 } else { 227 restoreToOriginal(); 228 } 229 } 230 231 function debounce(fn, wait) { 232 let t; 233 return function () { 234 clearTimeout(t); 235 t = setTimeout(fn, wait); 236 }; 237 } 238 239 evaluate(); 240 241 window.addEventListener("resize", debounce(evaluate, 100)); 242 window.addEventListener("orientationchange", debounce(evaluate, 100)); 243})();
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.