1jQuery(document).on('lazyImageLoaded', function(e) { 2 var img = jQuery(e.target); 3 img.closest('.defer-image').height(img.height()); 4}); 5 6var timeout = false, // holder for timeout id 7delay = 250; // delay after event is "complete" to run callback 8 9//window.resize callback function 10function setImageDimensions() { 11 jQuery('.defer-image').each(function(){ 12 var that = jQuery(this); 13 that.height(that.find('img').height()); 14 }); 15 16} 17 18//window.resize event listener 19window.addEventListener('resize', function() { 20// clear the timeout 21clearTimeout(timeout); 22// start timing for event "completion" 23timeout = setTimeout(setImageDimensions, delay); 24}); 25 26 27 28if (jQuery('#flexcarousel').length != 0 ) { 29 30 if(jQuery('#flexcarousel').hasClass('wide')) { 31 var slider = document.getElementById("flexcarousel").outerHTML; 32 jQuery('#flexcarousel').remove(); 33 jQuery('#header').after(slider); 34 jQuery('body .mm-page >.container').addClass('wide-flex'); 35 } 36 jQuery.getScript( "/o/minisite-theme/js/flexslider.min.js"). 37 done(function( script, textStatus ) { 38 jQuery('.flexslider').flexslider({ 39 animation: "fade" 40 }); 41 42 if (typeof(Liferay.Language.get) === 'function') { 43 // Find translated prev/next texts and set them to flex slider elements 44 prevText = 'Tidigare'; 45 nextText = 'Nästa'; 46 if (prevText && nextText) { 47 jQuery('#flexcarousel .flex-direction-nav .flex-prev').text(prevText); 48 jQuery('#flexcarousel .flex-direction-nav .flex-next').text(nextText); 49 } 50 } 51 }); 52 53} 54 55// Navigation dropdowns 56jQuery('.lfr-nav-child-toggle').on('click tap', function() { 57 var dropdown = jQuery(this).parent().find('.dropdown-menu') 58 var currentButton = jQuery(this) 59 60 61 // Close all open dropdowns expect current one 62 jQuery('.dropdown-menu').each(function() { 63 if( !jQuery(this).is(dropdown)) { 64 var elem = jQuery(this) 65 var parentButton = elem.parent().find('.lfr-nav-child-toggle') 66 if (elem.attr('aria-hidden') === 'false') { 67 elem.attr('aria-hidden', 'true') 68 elem.stop(true, true).delay(200).fadeOut() 69 parentButton.attr('aria-expanded', 'false') 70 jQuery(this).parent().removeClass('dropdown--expanded'); 71 } 72 } 73 }) 74 75 if (currentButton.attr('aria-expanded') === 'false') { 76 currentButton.attr('aria-expanded', 'true') 77 dropdown.attr('aria-hidden', 'false') 78 dropdown.stop(true, true).delay(200).fadeIn() 79 currentButton.parent().addClass('dropdown--expanded') 80 } else { 81 currentButton.attr('aria-expanded', 'false') 82 dropdown.attr('aria-hidden', 'true') 83 dropdown.stop(true, true).delay(200).fadeOut() 84 currentButton.parent().removeClass('dropdown--expanded') 85 } 86 87}); 88 89// Close dropdown if clicked elsewhere 90jQuery(document).click(function(event) { 91 var target = jQuery(event.target); 92 if(target.closest('.navbar').length === 0) { 93 jQuery('.dropdown-menu').each(function() { 94 var elem = jQuery(this) 95 var parentButton = elem.parent().find('.lfr-nav-child-toggle') 96 if (elem.attr('aria-hidden') === 'false') { 97 elem.attr('aria-hidden', 'true') 98 elem.stop(true, true).delay(200).fadeOut() 99 parentButton.attr('aria-expanded', 'false') 100 jQuery(this).parent().removeClass('dropdown--expanded'); 101 } 102 }) 103 } 104}); 105 106 107// A11Y Navigation 108var navigation = document.querySelector("#navigation"); 109if (navigation != undefined) { 110 var menu = navigation.querySelectorAll('.nav')[0] 111 if (menu != undefined) { 112 menu.addEventListener('keydown',function(event) { 113 EVENT_KEY = event.key; 114 115 switch (EVENT_KEY) { 116 case 'ArrowLeft': 117 moveLeft() 118 break; 119 case 'ArrowRight': 120 moveRight() 121 break; 122 case 'ArrowDown': 123 event.preventDefault(); 124 moveDown(); 125 break; 126 case 'ArrowUp': 127 event.preventDefault(); 128 moveUp() 129 break; 130 case 'Escape': 131 if( jQuery('.nav').find('.dropdown[aria-hidden="false"]').length > 0 ){ 132 var target = document.querySelector(".dropdown[aria-hidden='false'] > li a"); 133 closeDropdown(target, false); 134 } 135 break; 136 case 'Tab': 137 setTimeout(function(){ 138 // If focus outside close all dropdowns 139 if (navigation.contains(document.activeElement) === false) { 140 // Close all open dropdowns expect current one 141 jQuery('.dropdown-menu').each(function() { 142 var elem = jQuery(this) 143 var parentButton = elem.parent().find('.lfr-nav-child-toggle') 144 if (elem.attr('aria-hidden') === 'false') { 145 elem.attr('aria-hidden', 'true') 146 elem.stop(true, true).delay(200).fadeOut() 147 parentButton.attr('aria-expanded', 'false') 148 jQuery(this).parent().removeClass('dropdown--expanded'); 149 } 150 }) 151 } 152 },100) 153 } 154 155 156 },false) 157 } 158} 159 160jQuery(document).ready(function(){ 161 // Set role to presentation for asset publisher RSS icon 162 if ($(".portlet-asset-publisher .subscribe-action svg.lexicon-icon.lexicon-icon-s
162hortcut").length) { 163 $(".portlet-asset-publisher .subscribe-action svg.lexicon-icon.lexicon-icon-shortcut").attr('role','presentation'); 164 } 165}); 166 167jQuery("#header").find(".btn-navbar").on("click tap", function(){ 168 var nav =jQuery("#header").find(".container").find(".nav-collapse"); 169 nav.toggle(); 170 nav.css({height: "auto"}); 171}); 172 173function flexHeight() { 174 var textHeight = jQuery('.slide-content .text-content').getMaxHeight(); 175 jQuery('.flexslider .slides > li, .flexslider').height(textHeight+100); 176} 177 178jQuery.fn.getMaxHeight = function(){ 179 return Math.max.apply(this, jQuery.map( this , function(e){ return jQuery(e).height() }) ); 180} 181jQuery('#load-more-news').click(function(){ 182 jQuery('.news-list').find('.hidden').each(function(index){ 183 if(index < 2){ 184 jQuery(this).removeClass('hidden'); 185 } 186 }); 187/* Hide load more button */ 188 if(jQuery('.news-list').find('div.hidden').length == 0){ 189 jQuery('#load-more-news').fadeOut(); 190 } 191}); 192 193jQuery(window).on('load', function(){ 194 if(jQuery(window).width() < 480) { 195 flexHeight(); 196 } 197 jQuery(window).resize(function() { 198 if(jQuery(window).width() < 480) { 199 flexHeight(); 200 } else { 201 jQuery('.flexslider .slides > li, .flexslider').height(400); 202 } 203 }); 204}); 205 206var scrollable_items = jQuery('.carousel-wrapper ul').children(), 207 num_of_items_per_page = jQuery('.carousel').data('slides-per-page'), 208 extraWidth = jQuery('.carousel').data('extra-width'); 209 210// Check if slider has configuration 211 if (typeof num_of_items_per_page === 'undefined') { 212 num_of_items_per_page = 5; 213 } 214 215 if (typeof extraWidth === 'undefined') { 216 extraWidth = 0; 217} 218 219 220var total_items = scrollable_items.length, 221 total_pages = Math.ceil(total_items / num_of_items_per_page), 222 current_page = 0, 223 page_width = jQuery('.carousel-wrapper').outerWidth(true) + extraWidth, 224 element_width = page_width / num_of_items_per_page, 225 listItem = jQuery('.carousel-wrapper ul li'), 226 listItemMargin = parseInt(listItem.css('margin-right')), 227 listItemPadding = parseInt(listItem.css('padding-right')), 228 listItemBorder = parseInt(listItem.css('border-right-width')), 229 paginationWrapper = jQuery('.carousel .position-nav'); 230 231 if(jQuery(window).width() < 769) { 232 element_width = listItem.first().outerWidth(); 233 } 234 235 listItem.width(element_width - listItemMargin - 10); 236 jQuery('.carousel-wrapper ul').css('width', element_width * (total_items + 1) + listItemMargin + 'px'); 237 238 paginationWrapper.find('li:first-child').addClass('selected'); 239 240 paginationWrapper.find('li').click(function() { 241 paginationWrapper.find('li').removeClass('selected'); 242 jQuery(this).addClass('selected'); 243 moveToPage(jQuery(this).data('page')); 244 }); 245 function moveToPage(page_num) { 246 jQuery('.carousel-wrapper ul').animate({ 247 left: -1 * page_num * (page_width + listItemMargin + listItemPadding + listItemBorder) 248 }, 600, function() { 249 }); 250 } 251 252 253 254 /* Add image caption to images with class caption*/ 255 jQuery('img.caption, img.caption-right, img.caption-left').each(function() { 256 257 var item = jQuery(this), 258 marginbottom = item.css('marginBottom'), 259 margintop = item.css('marginTop'), 260 marginleft = item.css('marginLeft'), 261 marginright = item.css('marginRight'), 262 float = item.css('float'), 263 itemClass=' '+item.attr("class"), 264 caption = item.prop('title'), 265 figcaption = ""; 266 if (caption!="") { 267 if(float =="left" && marginright=="0px") { 268 marginright="10px"; 269 } 270 figcaption = '<figcaption>'+caption+'</figcaption>'; 271 item.css({'margin': '0', 'float':'none'}); 272 item.wrap('<figure class="image-caption'+itemClass+'" style="float:'+float+'; margin:'+margintop+' '+marginright+' '+marginbottom+' '+marginleft+'; width:'+item.width()+'px;"></figure>'); 273 item.closest('.image-caption').append(figcaption); 274 } 275 }); 276 277 jQuery('#load-more-news').click(function(){ 278 jQuery('.news-list').find('.hidden').each(function(index){ 279 if(index < 2){ 280 jQuery(this).removeClass('hidden'); 281 } 282 }); 283 /* Hide load more button */ 284 if(jQuery('.news-list').find('div.hidden').length == 0){ 285 jQuery('#load-more-news').fadeOut(); 286 } 287 }); 288 289 290jQuery( document ).ready(function() { 291 jQuery('#yja-notification button').on('click', function() { 292 document.cookie = "yjaNotification=read;path=/"; 293 jQuery('#yja-notification').toggleClass("active"); 294 setTimeout(function() { jQuery('#yja-notification').hide(); }, 1000); 295 }); 296}); 297 298jQuery(document).ready(function() { 299 jQuery('.portlet-nested-portlets div').removeAttr('role', 'main'); 300}); 301 302/* --- Accordions --- */ 303jQuery( document ).ready( function() { 304 var container = jQuery('.yja-accordion'); 305 if (container !== null) { 306 container.each(function(index, value){ 307 wrappers = jQuery(this).find('.yja-accordion-wrapper'); 308 wrappers.each(function(index,value) { 309 wrapper = jQuery(this); 310 311 var heading = wrapper.find('.yja-accordion-toggle'); 312 var content = wrapper.find('.yja-accordion-content'); 313 314 heading.attr('aria-expanded','false'); 315 heading.attr('tabIndex','0'); 316 content.attr('aria-hidden','true'); 317 content.attr('tabIndex','-1'); 318 319 heading.on('tap click', function() { 320 321 var parent = jQuery(this).parent(); 322 parent.toggleClass('open'); 323 jQuery(this).attr('aria-expanded','false'); 324 jQuery(this).find(".icon").toggleClass('icon-chevron-right'); 325 jQuery(this).find(".icon").toggleClass('icon-chevron-down'); 326 327 if ( parent.hasClass('open') ) { 328 content.attr('aria-hidden','false'); 329 jQuery(this).attr('aria-expanded','true'); 330 content.attr('tabIndex','0'); 331 } else { 332 jQuery(this).attr('aria-expanded','false'); 333 content.attr('aria-hidden','true'); 334 content.attr('tabIndex','-1'); 335 } 336 337 }); 338 339 heading.on('keydown',function(event){ 340 if (event.which == 13) { 341 var parent = jQuery(this).parent(); 342 parent.toggleClass('open'); 343 jQuery(this).attr('aria-expanded','false'); 344 jQuery(this).find(".icon").toggleClass('icon-chevron-right'); 345 jQuery(this).find(".icon").toggleClass('icon-chevron-down'); 346 347 if ( parent.hasClass('open') ) { 348 349 jQuery(this).attr('aria-expanded','true'); 350 content.attr('aria-hidden','true'); 351 content.attr('tabIndex','0'); 352 } else { 353 jQuery(this).attr('aria-expanded','false'); 354 content.attr('aria-hidden','true'); 355 content.attr('tabIndex','-1'); 356 } 357 } 358 }); 359 }); 360 }); 361 } 362}); 363 364 365// ---------------------------------- 366// A11Y NAVIGATE WITH KEYBOARD 367// ---------------------------------- 368 369function moveLeft() { 370 var target = document.activeElement 371 var parent = target.parentElement; 372 var parentUL = parent.parentElement; 373 var id = parentUL.id 374 var focusable = parentUL.querySelectorAll('#'+id+' > li > a[href], #'+id+' > li > button') 375 var firstFocusable = focusable[0]
376 var lastFocusbale = focusable[focusable.length - 1] 377 378 var focusIndex = [].indexOf.call(focusable, document.activeElement); 379 // If focus is inside child menu jump to previous main level element 380 if (parentUL.classList.contains('dropdown-menu')) { 381 var grandParent = parentUL.parentElement; 382 var grandParentUl = grandParent.parentElement; 383 var parentFocusable = grandParentUl.querySelectorAll('#'+grandParentUl.id+' > li > a[href], #'+grandParentUl.id+' > li > button') 384 var parentButton = grandParent.querySelectorAll('button')[0] 385 var parentFocusIndex = [].indexOf.call(parentFocusable, parentButton); 386 387 if (parentFocusIndex > 1) { 388 parentFocusable[parentFocusIndex - 2].focus() 389 } else { 390 parentFocusable[parentFocusable.length - 1].focus() 391 } 392 closeDropdown(target,false) 393 394 } else { 395 if (target != firstFocusable) { 396 focusable[focusIndex - 1].focus(); 397 } else { 398 lastFocusbale.focus() 399 } 400 } 401} 402 403function moveRight() { 404 var target = document.activeElement 405 var parent = target.parentElement; 406 var parentUL = parent.parentElement; 407 var id = parentUL.id 408 var focusable = parentUL.querySelectorAll('#'+id+' > li > a[href], #'+id+' > li > button') 409 var firstFocusable = focusable[0] 410 var lastFocusbale = focusable[focusable.length - 1] 411 412 var focusIndex = [].indexOf.call(focusable, target); 413 414 if (parentUL.classList.contains('dropdown-menu')) { 415 var grandParent = parentUL.parentElement; 416 var grandParentUl = grandParent.parentElement; 417 var parentFocusable = grandParentUl.querySelectorAll('#'+grandParentUl.id+' > li > a[href], #'+grandParentUl.id+' > li > button') 418 var parentButton = grandParent.querySelectorAll('button')[0] 419 var parentFocusIndex = [].indexOf.call(parentFocusable, parentButton); 420 421 if (parentFocusIndex < parentFocusable.length) { 422 parentFocusable[parentFocusIndex + 1].focus() 423 } else { 424 parentFocusable[0].focus() 425 } 426 closeDropdown(target,false) 427 428 } else { 429 if (target != lastFocusbale) { 430 focusable[focusIndex + 1].focus(); 431 } else { 432 firstFocusable.focus() 433 } 434 } 435 436} 437 438function moveUp() { 439 var target = document.activeElement 440 var parent = target.parentElement; 441 var parentUL = parent.parentElement; 442 var id = parentUL.id; 443 444 // Check that we are inside in sub-menu 445 if (parentUL.classList.contains('dropdown-menu')) { 446 var focusable = parentUL.querySelectorAll('#'+id+' > li > a[href]') 447 var firstFocusable = focusable[0] 448 var focusIndex = [].indexOf.call(focusable, target); 449 450 if (target != firstFocusable) { 451 focusable[focusIndex - 1].focus(); 452 } else { 453 var grandParent = parentUL.parentElement; 454 var button = grandParent.querySelectorAll('button')[0] 455 var jSubNav = jQuery(parentUL); 456 button.focus(); 457 button.setAttribute('aria-expanded','false') 458 grandParent.classList.remove('dropdown--expanded') 459 parentUL.setAttribute('aria-hidden','true') 460 jSubNav.stop(true, true).delay(200).fadeOut() 461 } 462 } 463} 464 465function moveDown() { 466 var target = document.activeElement 467 var parent = target.parentElement; 468 var parentUL = parent.parentElement; 469 var id = parentUL.id; 470 // Check if element has children && clicked on first level element 471 472 if (parent.classList.contains('dropdown--children')) { 473 var elem = document.activeElement; 474 var subNav = elem.parentElement.querySelectorAll('ul')[0] 475 var jSubNav = jQuery(target).parent().find('ul') 476 var button = elem.parentElement.querySelectorAll('button')[0] 477 button.setAttribute('aria-expanded','true') 478 parent.classList.add('dropdown--expanded') 479 subNav.setAttribute('aria-hidden','false') 480 jSubNav.stop(true, true).delay(200).fadeIn() 481 482 setTimeout(function() { 483 var firstElement = subNav.querySelectorAll('a')[0] 484 console.log(subNav.id, firstElement) 485 firstElement.focus(); 486 }, 500) 487 488 } else { 489 var focusable = parentUL.querySelectorAll('#'+id+' > li > a[href], #'+id+' > li > button') 490 var firstFocusable = focusable[0] 491 var lastFocusbale = focusable[focusable.length - 1] 492 493 var focusIndex = [].indexOf.call(focusable, document.activeElement); 494 495 if (document.activeElement != lastFocusbale) { 496 focusable[focusIndex + 1].focus(); 497 } else { 498 firstFocusable.focus() 499 } 500 } 501 502} 503 504function closeDropdown(elem, focus) { 505 focus = (typeof focus !== 'undefined') ? focus : true 506 var parentUL = elem.parentElement.parentElement; 507 var grandParent = parentUL.parentElement; 508 var button = grandParent.querySelectorAll('button')[0] 509 var jSubNav = jQuery(parentUL); 510 if (focus) { 511 button.focus(); 512 } 513 button.setAttribute('aria-expanded','false') 514 grandParent.classList.remove('dropdown--expanded') 515 parentUL.setAttribute('aria-hidden','true') 516 jSubNav.stop(true, true).delay(200).fadeOut() 517}
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.