1( () => { 2 3 if (document.getElementById('fixed-banner')) { 4 if (document.querySelector('#fixed-banner .inner-image')) { 5 if (document.querySelector('#fixed-banner .inner-image').getAttribute('src').includes('index-only')) { 6 document.getElementById('fixed-banner').classList.add('index-only'); 7 } 8 } 9 10 11 let hasTwoLinks = document.querySelector('#fixed-banner .inner-image') ? true : false; 12 let languageIsEngish = document.querySelector('html').getAttribute('lang') == 'en' ? true : false; 13 14 if (hasTwoLinks) { 15 document.querySelector('#fixed-banner .inner-image').style.display = 'none'; 16 if (languageIsEngish) { 17 let imgLink = document.querySelector('#fixed-banner .inner-image').getAttribute('src').split('*')[0]; 18 let pdfLink = document.querySelector('#fixed-banner .inner-image').getAttribute('src').split('*')[1]; 19 20 document.getElementById('fixed-banner').dataset.goto = pdfLink; 21 document.querySelector('#fixed-banner .full-image').setAttribute('src', imgLink); 22 23 } 24 } 25 26 } 27 28} 29 30)(); 31/*jshint multistr: true */ 32 33// Globals 34var googleAPIKey = "AIzaSyBQTPTxan4kS3PNmaHXqwBQ0XvDDMhfdsA"; 35var iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform); 36 37function groupFixedBanners() { 38 let secondBanner = document.getElementById('second-banner'); 39 if (!secondBanner) {return;} 40 let group = document.createElement('div'); 41 group.id = 'banners'; 42 document.querySelectorAll('[id*="-banner"]').forEach(banner => { 43 group.append(banner); 44 }); 45 document.querySelector('body').append(group); 46} 47 48function renderCapctha() { 49 if (!document.getElementById('g-recaptcha')) {return;} 50 if(typeof grecaptcha.render === 'function') { 51 grecaptcha.render( 'g-recaptcha', { 52 'sitekey' : document.getElementById('g-recaptcha').dataset.sitekey 53 }); 54 } 55} 56 57 58// Main nav ========================================================================== 59var initMainNav = function() { 60 // Initializes functionality for the main-nav element 61 var mainNav = $('#main-nav'); 62 // Prevent dropdowns from closing if the user clicks on a dropdown (submenu) 63 // inside that dropdown. 64 mainNav.find('.dropdown a.dropdown-toggle').on("click", function(e){ 65 setTimeout(function() { 66 var currentMenuItem = $(e.target).closest('li'); 67 if ($(e.target).is('li')) { 68 currentMenuItem = $(e.target); 69 } 70 currentMenuItem.siblings('.open').removeClass('open'); 71 currentMenuItem.toggleClass('open'); 72 e.stopPropagation(); 73 e.preventDefault(); 74 }, 100); 75 }); 76 77 $('body').on('click', function(e) { 78 if ($(e.target).closest('.dropdown').length <= 0) { 79 $('.dropdown.open').removeClass('open'); 80 } 81 }); 82 83 // Toggle the main-nav to sticky when the user scrolls. 84 $(window).scroll(function() { 85 if (iOS != true) { 86 if ( $(window).scrollTop() > 10 ) { 87 $('#main-nav').addClass('compact-sticky'); 88 } else { 89 $('#main-nav').removeClass('compact-sticky'); 90 } 91 } 92 }); 93}; 94 95 96// Maps ============================================================================= 97var initMaps = function(mapEl) { 98 99 if (mapEl.length > 0) { 100 $.each(mapEl, function() { 101 var mapContainer = $(this); 102 103 if (mapContainer.hasClass('osm')) { 104 105 // Loads the OS map and attaches it in the mapEl 106 var coords = [mapContainer.data('x'), mapContainer.data('y')]; 107 var mymap = L.map(mapContainer.attr('id'), { scrollWheelZoom:false }).setView(coords, 15); 108 L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', { 109 maxZoom: 19, 110 attribution: 'Tiles © Esri — Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012' 111 }).addTo(mymap); 112 L.marker(coords).addTo(mymap); 113 114 } else { 115 116 // Loads and attaches a map from google maps on any mapEl 117 var mapOptions = { 118 "APIkey": googleAPIKey, 119 "mode": "place", 120 "place": mapContainer.data('address').replace(/[,\/&]/g, '').split(' ').join('+'), 121 "coords": mapContainer.data('coords'), 122 "zoom": mapContainer.data('zoom'), 123 "maptype": "roadmap", 124 "language": lang 125 }; 126 if (mapOptions.coords == '0,0' || mapOptions.coords == '') { 127 mapContainer.html('\ 128 <iframe\ 129 width="100%" height="100%" frameborder="0" style="border:0"\ 130 src="https://www.google.com/maps/embed/v1/place?key='+mapOptions.APIkey+'&q='+mapOptions.place+'&zoom='+mapOptions.zoom+'" allowfullscreen>\ 131 '); 132 } else { 133 mapContainer.html('\ 134 <iframe\ 135 width="100%" height="100%" frameborder="0" style="border:0"\ 136 src="https://www.google.com/maps/embed/v1/place?key='+mapOptions.APIkey+'&q='+mapOptions.place+'¢er='+mapOptions.coords+'&zoom='+mapOptions.zoom+'" allowfullscreen>\ 137 '); 138 } 139 140 } 141 142 143 }); 144 } 145}; 146// ================================================================================= 147 148// Accessibility bar =========================================================== 149var initAccessibilityBar = function() { 150 if ($('#accessibility-bar').length > 0) { 151 $('#accessibility-bar>.access-icon, #accessibility-bar>.access-arrow').on('click', function(event) { 152 event.preventDefault(); 153 $('#accessibility-bar>.buttons').slideToggle('fast'); 154 $('#accessibility-bar>.access-arrow').toggleClass('open'); 155 }); 156 157 $('#text-small-btn').on('click', function() { 158 $('body').removeClass('medium-text'); 159 $('body').removeClass('large-text'); 160 st.setItem('fontSize', ''); 161 }); 162 $('#text-medium-btn').on('click', function() { 163 $('body').addClass('medium-text'); 164 $('body').removeClass('large-text'); 165 st.setItem('fontSize', 'medium-text'); 166 }); 167 $('#text-large-btn').on('click', function() { 168 $('body').addClass('large-text'); 169 $('body').removeClass('medium-text'); 170 st.setItem('fontSize', 'large-text'); 171 }); 172 173 $('#text-black-bg').on('click', function() { 174 $('body').toggleClass('bw-text'); 175 $('body').removeClass('by-text'); 176 if ($('body').hasClass('bw-text')) { 177 st.setItem('colors', 'bw-text'); 178 } else { 179 st.setItem('colors', ''); 180 } 181 }); 182 $('#text-blue-bg').on('click', function() { 183 $('body').toggleClass('by-text'); 184 $('body').removeClass('bw-text'); 185 if ($('body').hasClass('by-text')) { 186 st.setItem('colors', 'by-text'); 187 } else { 188 st.setItem('colors', ''); 189 } 190 }); 191 } 192}; 193 194 195var initHeaderText = function() { 196 $('#contact-info-container').insertAfter('#header-logo'); 197}; 198 199 200function initExpo() { 201 if ($('.expoUrl').length > 0) { 202 $('.expoUrl').wrapAll('<div id="expo-container"><div id="expo"></div></div>'); 203 204 function styleExpo() { 205 var maxUrls = 1; 206 if (window.innerWidth <= 768) { 207 maxUrls = 1; 208 } 209 210 $('.expoUrl').first().css('margin-left', '0px'); 211 212 // Create controls 213 if ($('.expoUrl').length > maxUrls) { 214 $('.expoUrl').slice(0, maxUrls).addClass('shown'); 215 if ($('#expo-container .next').length <= 0) { 216 $('#expo-container').append('<a href="#" class="next"><span class="fa fa-chevron-right"></span></a><a href="#" class="prev"><span class="fa fa-chevron-left"></span></a>'); 217 } 218 } else { 219 $('.expoUrl').addClass('shown'); 220 } 221 } 222 223 styleExpo(); 224 225 window.onresize = function() { 226 styleExpo(); 227 } 228 229 // Hide the description in expoURLs if it's empty 230 $('.expoUrl').each(function() { 231 if ($(this).find('p.url-contents').text().trim().length <= 0) { 232 $(this).find('p.url-contents').addClass('hidden'); 233 } 234 }); 235 236 // Controls 237 $('#expo-container .next').on('click', function(e) { 238 e.preventDefault(); 239 var marginLeft = parseFloat($('.expoUrl').first().css('margin-left')); 240 if ($('.expoUrl.shown').last().next('.expoUrl').length > 0) { 241 $('.expoUrl.shown').last().next('.expoUrl').addClass('shown'); 242 $('.expoUrl.shown').first().removeClass('shown'); 243 marginLeft -= $('.expoUrl').first().outerWidth(); 244 $('.expoUrl').first().css('margin-left', marginLeft + 'px'); 245 } 246 247 }); 248 249 $('#expo-container .prev').on('click', function(e) { 250 e.preventDefault(); 251 var marginLeft = parseFloat($('.expoUrl').first().css('margin-left')); 252 if ($('.expoUrl.shown').first().prev('.expoUrl').length > 0) { 253 $('.expoUrl.shown').first().prev('.expoUrl').addClass('shown'); 254 $('.expoUrl.shown').last().removeClass('shown'); 255 marginLeft += $('.expoUrl').first().outerWidth(); 256 $('.expoUrl').first().css('margin-left', marginLeft + 'px'); 257 } 258 }); 259 260 } 261} 262 263 264function lazyloadInit() { 265 document.addEventListener('lazybeforeunveil', function(e){ 266 267 if ($(e.target).hasClass('map-holder')) { 268 initMaps($(e.target)); 269 } 270 271 }); 272} 273 274 275function initSearch() { 276 $('#searchform-container .open-icon > a, #searchform-container .close-icon > a').on('click', function(e) { 277 e.preventDefault(); 278 $('#searchform-container').toggleClass('closed'); 279 $('#searchform-container .open-icon, #searchform-container .close-icon').toggleClass('hide'); 280 if ($('.social-container').length > 0) { 281 $('.social-container').toggle('fast'); 282 } 283 284 setTimeout(() => { 285 $('.search-social').toggleClass("open"); 286 }, 200); 287 288 }); 289} 290 291 // ===================== BAKERY SPECIFIC ================================ 292 293function moveLogo() { 294 document.getElementById('header-middle').append(document.querySelector('#header-bottom #logo')); 295} 296 297function addLangFlag() { 298 299 document.querySelectorAll('.langsDropdown>a').forEach(lang => { 300 let langCode = Array.from(lang.classList).slice(-1)[0]; 301 let flag = document.createElement('span'); 302 flag.id = `flag-${langCode}`; 303 flag.style.backgroundImage = `url(../images/langseldropdown/${langCode}.png)`; 304 lang.append(flag); 305 }); 306 307} 308 309function markNoUrlBigs() { 310 document.querySelectorAll('.bigUrl').forEach(big => { 311 if (!big.querySelector('a.url')) { 312 big.className = 'figure exclusive-url col-md bigNoUrl'; 313 } 314 }); 315} 316 317function calcTotalItems(type) { 318 let items = []; 319 document.querySelectorAll(`#exclusiveURLs>.${type}`).forEach(item => { 320 if (item.previousElementSibling) { 321 if (!item.previousElementSibling.className.includes('bigNoUrl')) { 322 items.push(item); 323 } 324 } else { 325 items.push(item); 326 } 327 }); 328 329 return items; 330} 331 332function collectGroup(type, total) { 333 let group = []; 334 let items = calcTotalItems(type); 335 336 for (let i = 0; i < total; i++) { 337 if (items[i]) { 338 group.push(items[i]); 339 } 340 } 341 342 return [group, group.length ? group.slice(-1)[0].nextElementSibling : false]; 343 344} 345 346function wrapElements(type, total) { 347 let urls = document.querySelectorAll(`#exclusiveURLs>.${type}`); 348 if (!urls.length) {return;} 349 350 let style = parseInt(type.slice(-1)) ? type.slice(-1) : ''; 351 let items = calcTotalItems(type); 352 353 for (let i = 0; i < items.length / total; i++) { 354 355 let wrapper = document.createElement('div'); 356 wrapper.className = `${type.replace(`Url${style}`, '')}-wrapper st${style}`; 357 358 let [group , reference] = collectGroup(type, total); 359 group.forEach(url => { 360 wrapper.append(url); 361 }); 362 363 if (reference) { 364 document.getElementById('exclusiveURLs').insertBefore(wrapper, reference); 365 } else { 366 document.getElementById('exclusiveURLs').append(wrapper); 367 } 368 369 } 370 371} 372 373function groupMediumCaptions() { 374 let captions = document.createElement('div'); 375 captions.className = 'medium-captions'; 376 377 document.querySelectorAll('.medium-wrapper').forEach(wrapper => { 378 wrapper.querySelectorAll('.mediumUrl > .figure-caption').forEach(caption => { 379 captions.append(caption); 380 }); 381 wrapper.append(captions); 382 }); 383} 384 385function mergeMediumTexts() { 386 document.querySelectorAll('.medium-captions').forEach(wrapper => { 387 let text = '';
388 let captions = wrapper.querySelectorAll('.url-contents'); 389 Array.from(captions).slice(1,).forEach(txt => { 390 text += txt.innerText + ' '; 391 }); 392 captions[0].innerText = captions[0].innerText + ' ' + text; 393 }); 394} 395 396function markOddBig() { 397 document.querySelectorAll('#exclusiveURLs > .bigUrl').forEach((big, i) => { 398 if (i % 2 != 0) { 399 big.classList.add('odd'); 400 } 401 }); 402} 403 404function moveBigBtn() { 405 document.querySelectorAll('#exclusiveURLs > .bigUrl:not(.odd)').forEach(big => { 406 if (!big.querySelector('a.url')) {return;} 407 let txtContent = document.createElement('div'); 408 txtContent.className = 'big-text col-md-9'; 409 big.querySelectorAll('.url-title, .url-contents').forEach(el => { 410 txtContent.append(el); 411 }); 412 big.querySelector('.contents-wrapper').append(txtContent); 413 }); 414} 415 416function addPlaceholders() { 417 418 document.querySelectorAll('#contact-form input, #contact-form textarea').forEach(el => { 419 el.placeholder = el.previousElementSibling.innerText; 420 }); 421 422} 423 424function addExpoBg() { 425 document.getElementById('expo-container').append(document.querySelector('.bigNoUrl')); 426 document.getElementById('expo-container').classList.add('img-bg'); 427} 428 429function moveSearch() { 430 if (!document.getElementById('search-input')) {return;} 431 document.querySelector('footer .left').append(document.getElementById('searchform-container')); 432} 433 434function moveOpenIcon() { 435 if (!document.getElementById('search-input')) {return;} 436 document.getElementById('search-form').append(document.querySelector('#searchform-container > .open-icon')); 437} 438 439function wrapSingleForm() { 440 document.querySelector('.contactform').append(document.querySelector('.singlecontact > .contact-details')); 441} 442 443function checkSpacer() { 444 if (document.getElementById('spacer')) { 445 document.body.classList.add('spacer'); 446 } 447} 448 449function checkMultiContact() { 450 if (document.querySelector('.multicontact')) { 451 document.body.classList.add('multicontact'); 452 } 453} 454 455function checkEmptyVideo() { 456 if (!document.querySelector('body.videos')) {return;} 457 let captions = document.querySelectorAll('.video-caption'); 458 if (!captions.length) {return;} 459 captions.forEach(caption => { 460 if (!caption.childElementCount) { 461 caption.classList.add('empty'); 462 } 463 }); 464} 465 466function moveFooterLogo() { 467 if (!document.querySelector('body.home')) {return;} 468 document.querySelector('#footer > .container-fluid > .row').append(document.querySelector('#footer .logo')) 469} 470 471function addTogglerName() { 472 let name = document.createElement('div'); 473 let trans = {'el':'ÎενοÏ', 'en':'Menu'}; 474 name.innerText = trans[document.querySelector('html').lang]; 475 name.className = 'name'; 476 document.querySelector('.navbar-toggler').append(name); 477} 478 479function hideLangMenu() { 480 const langs = document.querySelector('.nav-item.dropdown.langs'); 481 const domains = ['nafpigikihellasts']; 482 domains.forEach(domain =>{ 483 if (window.location.href.includes(domain)) { 484 langs.style.display = 'none'; 485 } 486 }); 487} 488 489function moveSmall1() { 490 const premium = document.getElementById('premium-text'); 491 const main = document.querySelector('main'); 492 if (!premium) {return;} 493 if (!main.querySelector('.small-wrapper.st1')) {return;} 494 main.prepend(document.querySelector('#exclusiveURLs > .small-wrapper.st1')); 495} 496 497function clickSmall1() { 498 const wrappers = document.querySelectorAll('.small-wrapper.st1'); 499 if(!wrappers.length) {return;} 500 501 wrappers.forEach(wrapper => { 502 wrapper.addEventListener('click',(e) => { 503 e.stopPropagation(); 504 e.target.closest('.smallUrl1').querySelector('.url-title').click(); 505 }); 506 }); 507 508} 509 510function hideExpoControls() { 511 const expo = document.getElementById('expo-container'); 512 if(!expo) {return;} 513 expo.classList.add('first'); 514 expo.addEventListener('click', (e) => { 515 e.stopPropagation(); 516 517 switch(true) { 518 519 case expo.querySelector('#expo > :first-child').classList.contains('shown'): 520 expo.classList.add('first'); 521 break; 522 523 case expo.querySelector('#expo > :last-child').classList.contains('shown'): 524 expo.classList.add('last'); 525 break; 526 527 case expo.classList.contains('last'): 528 expo.classList.remove('last'); 529 break; 530 531 default: 532 expo.classList.remove('first'); 533 534 } 535 536 }); 537} 538 539// ========================================================================= 540 541 542 checkEmptyVideo(); 543 groupFixedBanners(); 544 lazyloadInit(); 545 if ($('body').hasClass('home')) { 546 initExpo();
547 hideExpoControls(); 548 } 549 initMainNav(); 550 initHeaderText(); 551 552 if ($('body').hasClass('view-article')) { 553 $('.back-to-catalog').addClass('button'); 554 } 555 556 initAccessibilityBar(); 557 558 // Events 559 $('#move-top').on('click', () => $('html, body').animate({scrollTop: 0}, 300)); 560 $('#fb-messaging').on('click', () => $('#fb-messaging').toggleClass('show')); 561 562 // Contact message 563 if ($('#contact-form-msg').length > 0) { 564 $('#contact-form-msg').modal('show'); 565 } 566 567 // FixedBanner 568 $('#fixed-banner.goTo').on('click', function() { 569 if ($(this).hasClass('newTab')) { 570 window.open($(this).data('goto'), '_blank').focus(); 571 } else { 572 window.open($(this).data('goto'), '_self'); 573 } 574 }); 575 $('#fixed-banner > .close').on('click', function(e) { 576 e.preventDefault(); 577 $('#fixed-banner').fadeOut('fast'); 578 }); 579 580 if ($('body.contact').length > 0) { 581 setTimeout(() => { 582 initMaps($('.map-holder')); 583 }, 500); 584 } 585 586 initSearch(); 587 hideLangMenu(); 588 589 // ===================== BAKERY SPECIFIC ================================ 590$(document).ready(function() { 591 // stop carousel sliding. ENABLE ONLY FOR TESTING!!! 592 // $('#main-slideshow'). carousel({ interval: false, }); 593 594 checkSpacer(); 595 checkMultiContact(); 596 moveLogo(); 597 if (document.querySelector('.langsDropdown>.active')) {addLangFlag();} 598 599 if (document.querySelector('.bigUrl')) { 600 markNoUrlBigs(); 601 markOddBig(); 602 }; 603 604 if (document.querySelector('.bigNoUrl') && document.getElementById('expo')) { 605 addExpoBg(); 606 } 607 608 if (document.querySelector('#exclusiveURLs > .bigUrl:not(.odd)')) {moveBigBtn();} 609 610 if (document.querySelector('.smallUrl')) { 611 wrapElements('smallUrl', 3); 612 } 613 614 if (document.querySelector('.mediumUrl')) { 615 wrapElements('mediumUrl', 3); 616 groupMediumCaptions(); 617 mergeMediumTexts(); 618 } 619 620 if (document.querySelector('body.home')) { 621 moveSearch(); 622 moveOpenIcon(); 623 } 624 625 if (document.querySelector('.singlecontact')) { 626 wrapSingleForm(); 627 } 628 629 if (document.getElementById('contact-form')) { 630 addPlaceholders(); 631 } 632 633 if (document.querySelector('body.home')) { 634 if (!document.querySelector('footer #search-input')) { 635 document.querySelector('footer').className = 'no-search'; 636 } 637 } 638 639 wrapElements('smallUrl1', 5); 640 moveSmall1(); 641 clickSmall1(); 642 643 moveFooterLogo(); 644 addTogglerName(); 645 646 document.body.classList.add('loaded'); 647 setTimeout(() => {renderCapctha();}, 1000); 648 649});
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.