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 50document.addEventListener("DOMContentLoaded", function () { 51 $('.ka-logo') 52 .next('span') 53 .remove(); 54 55 document.querySelectorAll('nav a.yja-external-link, .sidebar-body a.yja-external-link').forEach(link => { 56 link.classList.remove('yja-external-link'); 57 }); 58}); 59 60 61function updateSubsectionMenuTop() { 62 const mainMenuItems = document.querySelectorAll('.ka-main-menu-item'); 63 const subsectionMenus = document.querySelectorAll('.ka-subsection-menu'); 64 const contentArea = document.getElementById('content'); 65 let menuActive = false; 66 67 if (!mainMenuItems.length || !subsectionMenus.length) { 68 return; 69 } 70 71 let maxHeight = 0; 72 73 mainMenuItems.forEach(item => { 74 const height = item.getBoundingClientRect().height; 75 if (height > maxHeight) { 76 maxHeight = height; 77 } 78 79 if (item.classList.contains('active')) { 80 menuActive = true; 81 } 82 }); 83 84 subsectionMenus.forEach(menu => { 85 menu.style.top = '${maxHeight}px'; 86 }); 87 88 if (menuActive == true) { 89 contentArea.style.marginTop = '${maxHeight}px'; 90 } 91} 92 93document.addEventListener('DOMContentLoaded', updateSubsectionMenuTop); 94window.addEventListener('resize', updateSubsectionMenuTop); 95 96 97 98 99/* 100 ** Sidenavigation accordion 101 */ 102var toggleButtonOpenSrElem = ""; 103var toggleButtonCloseSrElem = ""; 104var pageName = ""; 105 106jQuery(".portlet-navigation .list-menu .layouts > li") 107 .has("ul") 108 .addClass("hasChild top") // Top level elements 109 .find("li") 110 .has("ul") 111 .addClass("hasChild sub"); // Sub level elements 112jQuery(".portlet-navigation .list-menu .layouts ul.submenu").css("flex", "1 1 auto"); 113jQuery(".portlet-navigation .list-menu .layouts .selected").parents("li").addClass("active-li selected"); 114 115jQuery(".portlet-navigation .list-menu .layouts li").each(function () { 116 pageName = jQuery(this).text(); 117 toggleButtonOpenSrElem = '<span class="sr-only">' + 'Avaa\x20alavalikko' + ", " + pageName + "</span>"; 118 toggleButtonCloseSrElem = '<span class="sr-only">' + 'Sulje\x20alavalikko' + ", " + pageName + "</span>"; 119 120 if (jQuery(this).hasClass("selected")) { 121 jQuery(this).find("div").css("display", "flex"); 122 jQuery(this).find("div").css("width", "100%"); 123 jQuery(this).find("button svg").remove(); 124 jQuery(this).find("button").addClass("toggleVisibility icon-chevron-down"); 125 } else if (jQuery(this).closest("li").hasClass("hasChild")) { 126 jQuery(this).find("button").addClass("toggleVisibility icon-chevron-right"); 127 jQuery(this).find("button svg").remove(); 128 jQuery(this).find("div").css("display", "flex"); 129 jQuery(this).find("div").css("width", "100%"); 130 } 131 132 jQuery(this) 133 .find(".hasChild a") 134 .each(function () { 135 pageName = jQuery(this).text(); 136 toggleButtonOpenSrElem = '<span class="sr-only">' + 'Avaa\x20alavalikko' + ", " + pageName + "</span>"; 137 toggleButtonCloseSrElem = '<span class="sr-only">' + 'Sulje\x20alavalikko' + ", " + pageName + "</span>"; 138 139 if (jQuery(this).closest("li").hasClass("selected")) { 140 jQuery(this).parent().addClass("active-li selected"); 141 jQuery(this).parent().css("display", "flex"); 142 jQuery(this).parent().css("width", "100%"); 143 jQuery(this).find("button svg").remove(); 144 jQuery(this).next("button").addClass("toggleVisibility icon-chevron-down"); 145 } else if (jQuery(this).closest("li").hasClass("hasChild")) { 146 jQuery(this).next("button").addClass("toggleVisibility icon-chevron-right"); 147 jQuery(this).find("button svg").remove(); 148 jQuery(this).parent().css("display", "flex"); 149 jQuery(this).parent().css("width", "100%"); 150 } 151 }); 152}); 153 154jQuery("li.active-li a.selected.active").attr("aria-current", "page"); 155 156jQuery("button.toggleVisibility").click(function () { 157 var elem = jQuery(this); 158 pageName = jQuery(this).prev("a").text(); 159
160 setTimeout(function () { 161 toggleButtonOpenSrElem = '<span class="sr-only">' + 'Avaa\x20alavalikko' + ", " + pageName + "</span>"; 162 toggleButtonCloseSrElem = '<span class="sr-only">' + 'Sulje\x20alavalikko' + ", " + pageName + "</span>"; 163 164 jQuery(elem.next("ul")).slideToggle("fast"); 165 166 if (elem.hasClass("icon-chevron-right")) { 167 elem.removeClass("icon-chevron-right"); 168 elem.addClass("icon-chevron-down"); 169 elem.attr("aria-expanded", "true"); 170 elem.html(toggleButtonCloseSrElem); 171 } else { 172 elem.removeClass("icon-chevron-down"); 173 elem.addClass("icon-chevron-right"); 174 elem.attr("aria-expanded", "false"); 175 elem.html(toggleButtonOpenSrElem); 176 } 177 }, 50); 178}); 179/* 180document.querySelectorAll('.ka-main-dropdown-toggle').forEach(button => { 181 button.addEventListener('click', () => { 182 const menu = button.nextElementSibling; 183 184 if (!menu || !menu.classList.contains('ka-main-dropdown-menu')) { 185 return; 186 } 187 188 const isExpanded = button.getAttribute('aria-expanded') === 'true'; 189 190 menu.classList.toggle('show', !isExpanded); 191 192 button.setAttribute('aria-expanded', !isExpanded); 193 }); 194}); 195 196document.querySelectorAll('.ka-submenu-levels.ka-dropdown-toggle').forEach(button => { 197 button.addEventListener('click', () => { 198 const menu = button.nextElementSibling; 199 200 if (!menu || !menu.classList.contains('ka-submenu-levels-menu')) { 201 return; 202 } 203 204 const isExpanded = button.getAttribute('aria-expanded') === 'true'; 205 206 menu.classList.toggle('show', !isExpanded); 207 208 button.setAttribute('aria-expanded', !isExpanded); 209 }); 210}); 211*/ 212 213 214const kaMenuButtons = document.querySelectorAll('.ka-main-dropdown-toggle'); 215 216kaMenuButtons.forEach(button => { 217 button.addEventListener('click', () => { 218 const menu = button.nextElementSibling; 219 220 if (!menu?.classList.contains('ka-main-dropdown-menu')) { 221 return; 222 } 223 224 const isOpening = !menu.classList.contains('show'); 225 226 kaMenuButtons.forEach(otherButton => { 227 const otherMenu = otherButton.nextElementSibling; 228 229 if (otherMenu?.classList.contains('ka-main-dropdown-menu')) { 230 otherMenu.classList.remove('show'); 231 otherButton.setAttribute('aria-expanded', 'false'); 232 } 233 }); 234 235 if (isOpening) { 236 menu.classList.add('show'); 237 button.setAttribute('aria-expanded', 'true'); 238 } 239 }); 240}); 241 242const kaSubMenuButtons = document.querySelectorAll('.ka-submenu-levels.ka-dropdown-toggle'); 243 244kaSubMenuButtons.forEach(button => { 245 button.addEventListener('click', () => { 246 const menu = button.nextElementSibling; 247 248 if (!menu?.classList.contains('ka-submenu-levels-menu')) { 249 return; 250 } 251 252 const isOpening = !menu.classList.contains('show'); 253 254 kaSubMenuButtons.forEach(otherButton => { 255 const otherMenu = otherButton.nextElementSibling; 256 257 if (otherMenu?.classList.contains('ka-submenu-levels-menu')) { 258 otherMenu.classList.remove('show'); 259 otherButton.setAttribute('aria-expanded', 'false'); 260 } 261 }); 262 263 if (isOpening) { 264 menu.classList.add('show'); 265 button.setAttribute('aria-expanded', 'true'); 266 } 267 }); 268});
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.