1/*eslint-env jquery*/ 2//Make Ready text load faster 3// jQuery(document).ready(function ($) { 4// setTimeout(function () { 5// jQuery('.hero .big-text').css('opacity', '1'); 6// }, 500); 7// }); 8window.onload = function productLanding() { 9 //Delay hero display 10 $('body').addClass('loaded'); 11 12 var url = window.location.href; 13 14 var urlCheck = url.includes('/fr/services/'); 15 16 if (urlCheck) { 17 var linkArray = url.split('/'); 18 console.log(linkArray.length); 19 20 if (linkArray.length == 3) { 21 var sectionId = linkArray[linkArray.length - 2]; 22 console.log(sectionId); 23 24 $([document.documentElement, document.body]).animate( 25 { 26 scrollTop: $(sectionId).offset().top, 27 }, 28 500 29 ); 30 } 31 } 32}; 33 34function resourcesTitleChange() { 35 if ( 36 $('.inner-pg-block').length > 0 || 37 $('.dc-res-wrapper').length > 0 || 38 $('#res-listing').length > 0 39 ) { 40 var screenWidth = screen.width; 41 42 var vidCount = $('#vidCount').val(); 43 var datasheetscount = $('#datasheetsCount').val(); 44 var whitepaperscount = $('#whitepapersCount').val(); 45 var reportsscount = $('#reportsCount').val(); 46 var blogsscount = $('#blogsCount').val(); 47 48 if (screenWidth <= 415) { 49 $titleBreak = 45; 50 $contentBreak = 120; 51 } else if (screenWidth <= 451) { 52 $titleBreak = 45; 53 $contentBreak = 130; 54 } else if (screenWidth <= 528) { 55 $titleBreak = 45; 56 $contentBreak = 150; 57 } else if (screenWidth <= 767) { 58 $titleBreak = 45; 59 $contentBreak = 180; 60 } else if (screenWidth < 991 && screenWidth > 767) { 61 $titleBreak = 30; 62 $contentBreak = 80; 63 } else if (screenWidth <= 1024) { 64 $titleBreak = 30; 65 $contentBreak = 135; 66 } else if (screenWidth <= 1261) { 67 $titleBreak = 30; 68 $contentBreak = 160; 69 } else { 70 $titleBreak = 47; 71 $contentBreak = 190; 72 } 73 74 for (i = 1; i <= vidCount; i++) { 75 var title = $('#originalTitle-' + i).val(); 76 var content = $('#originalVidCont-' + i).val(); 77 var titleLength = title.length; 78 var contentLength = content.length; 79 80 if (contentLength >= $contentBreak) { 81 var newContent = content.substring(0, $contentBreak); 82 newContent = 83 newContent.substr( 84 0, 85 Math.min(newContent.length, newContent.lastIndexOf(' ')) 86 ) + '...'; 87 } 88 if (contentLength < $contentBreak) { 89 var newContent = content; 90 } 91 if (titleLength >= $titleBreak) { 92 var newTitle = title.substring(0, $titleBreak); 93 newTitle = 94 newTitle.substr( 95 0, 96 Math.min(newTitle.length, newTitle.lastIndexOf(' ')) 97 ) + '...'; 98 } 99 if (titleLength < $titleBreak) { 100 var newTitle = title; 101 } 102 103 $('#vid-title-' + i).text(newTitle); 104 $('#vid-cont-' + i).text(newContent); 105 } 106 for (i = 1; i <= datasheetscount; i++) { 107 var title = $('#datasheetOriTitle-' + i).val(); 108 var titleLength = title.length; 109 var content = $('#datasheetOriContent-' + i).val(); 110 var contentLength = content.length; 111 112 if (contentLength >= $contentBreak) { 113 var newContent = content.substring(0, $contentBreak); 114 newContent = 115 newContent.substr( 116 0, 117 Math.min(newContent.length, newContent.lastIndexOf(' ')) 118 ) + '...'; 119 } 120 if (contentLength < $contentBreak) { 121 var newContent = content; 122 } 123 124 if (titleLength >= $titleBreak) { 125 var newTitle = title.substring(0, $titleBreak); 126 newTitle = 127 newTitle.substr( 128 0, 129 Math.min(newTitle.length, newTitle.lastIndexOf(' ')) 130 ) + '...'; 131 } 132 if (titleLength < $titleBreak) { 133 var newTitle = title; 134 } 135 $('#datasts-title-' + i).text(newTitle); 136 $('#datasts-content-' + i).text(newContent); 137 } 138 139 for (i = 1; i <= whitepaperscount; i++) { 140 var title = $('#whitepaperOriTitle-' + i).val(); 141 var titleLength = title.length; 142 var content = $('#whitepaperOriContent-' + i).val(); 143 var contentLength = content.length; 144 145 if (contentLength >= $contentBreak) { 146 var newContent = content.substring(0, $contentBreak); 147 newContent = 148 newContent.substr( 149 0, 150 Math.min(newContent.length, newContent.lastIndexOf(' ')) 151 ) + '...'; 152 } 153 if (contentLength < $contentBreak) { 154 var newContent = content; 155 } 156 157 if (titleLength >= $titleBreak) { 158 var newTitle = title.substring(0, $titleBreak); 159 newTitle = 160 newTitle.substr( 161 0, 162 Math.min(newTitle.length, newTitle.lastIndexOf(' ')) 163 ) + '...'; 164 } 165 if (titleLength < $titleBreak) { 166 var newTitle = title; 167 } 168 $('#whiprs-title-' + i).text(newTitle); 169 $('#whiprs-content-' + i).text(newContent); 170 } 171 172 for (i = 1; i <= reportsscount; i++) { 173 var title = $('#reportOriTitle-' + i).val(); 174 var titleLength = title.length; 175 var content = $('#reportOriContent-' + i).val(); 176 var contentLength = content.length; 177 178 if (contentLength >= $contentBreak) { 179 var newContent = content.substring(0, $contentBreak); 180 newContent = 181 newContent.substr( 182 0, 183 Math.min(newContent.length, newContent.lastIndexOf(' ')) 184 ) + '...'; 185 } 186 if (contentLength < $contentBreak) { 187 var newContent = content; 188 } 189 190 if (titleLength >= $titleBreak) { 191 var newTitle = title.substring(0, $titleBreak); 192 newTitle = 193 newTitle.substr( 194 0, 195 Math.min(newTitle.length, newTitle.lastIndexOf(' ')) 196 ) + '...'; 197 } 198 if (titleLength < $titleBreak) { 199 var newTitle = title; 200 } 201 $('#report-title-' + i).text(newTitle); 202 $('#report-content-' + i).text(newContent); 203 } 204 205 if (blogsscount > 0) { 206 for (i = 1; i <= blogsscount; i++) { 207 var title = $('#blogOriTitle-' + i).val(); 208 var titleLength = title.length; 209 var content = $('#blogOriContent-' + i).val(); 210 var contentLength = content.length; 211 212 if (contentLength >= $contentBreak) { 213 var newContent = content.substring(0, $contentBreak); 214 newContent = 215 newContent.substr( 216 0, 217 Math.min(newContent.length, newContent.lastIndexOf(' ')) 218 ) + '...'; 219 } 220 if (contentLength < $contentBreak) { 221 var newContent = content; 222 } 223 224 if (titleLength >= $titleBreak) { 225 var newTitle = title.substring(0, $titleBreak); 226 newTitle = 227 newTitle.substr( 228 0, 229 Math.min(newTitle.length, newTitle.lastIndexOf(' ')) 230 ) + '...'; 231 } 232 if (titleLength < $titleBreak) { 233 var newTitle = title; 234 } 235 $('#blog-title-' + i).text(newTitle); 236 $('#blog-content-' + i).text(newContent); 237 } 238 } 239 } 240} 241 242$(window).resize(function () { 243 resourcesTitleChange(); 244}); 245 246$(document).ready(function () { 247 if ($('.announcement-hero').length > 0 || $('.hero').length > 0) { 248 var mainLinksColor = $('#main-menu-links-color').val(); 249 var mainLinksColorOpacity = $('#main-menu-links-opacity').val(); 250
251 var subLinksColor = $('#sub-menu-links-color').val(); 252 var subBackgroundColor = $('#sub-menu-background-color').val(); 253 var subMenuOpacity = $('#sub-menu-opacity').val(); 254 255 var buttonTextColor = $('#button-text-color').val(); 256 var buttonBackgroundColor = $('#button-background-color').val(); 257 var buttonBorderColor = $('#button-border-color').val(); 258 var buttonOpacity = $('#button-opacity').val(); 259 260 $('#primary-menu > .menu-item > a').css('color', mainLinksColor); 261 $('#primary-menu > .menu-item > a').css('opacity', mainLinksColorOpacity); 262 263 $('#primary-menu .sub-menu > li > a').css('color', subLinksColor); 264 $('#primary-menu .sub-menu > li').css('opacity', subMenuOpacity); 265 $('#primary-menu .sub-menu > li').css('background', subBackgroundColor); 266 267 $('.btn-primary-solid').css('color', buttonTextColor); 268 $('.btn-primary-solid').css('background-color', buttonBackgroundColor); 269 $('.btn-primary-solid').css('border-color', buttonBorderColor); 270 $('.btn-primary-solid').css('opacity', buttonOpacity); 271 } 272 273 var url = window.location.href; 274 275 var status = url.includes('?trp-edit-translation'); 276 277 if (status) { 278 $('#footer-menu').css('padding-left', '30px'); 279 } 280 281 resourcesTitleChange(); 282 283 $('.menu-item-type-custom').click(function () { 284 if ($('.toggled').length > 0) { 285 $('.main-navigation').removeClass('toggled'); 286 } 287 }); 288 289 $('.menu-item-object-custom').click(function () { 290 var href = $('a', this).attr('href'); 291 292 var languageCheck = href.includes('/fr/'); 293 294 if (languageCheck) { 295 var linkArray = href.split('/'); 296 var sectionId = linkArray[linkArray.length - 2]; 297 // var sectionId = '#'+linkArray[linkArray.length-2]; 298 299 $([document.documentElement, document.body]).animate( 300 { 301 scrollTop: $(sectionId).offset().top, 302 }, 303 500 304 ); 305 } 306 // var url = window.location.href; 307 // var languageCheck = url.includes("/fr/"); 308 // var checkservicePage = url.includes("/services"); 309 310 // if(!checkservicePage){ 311 312 // var href = $("a",this).attr('href'); 313 // var linkArray = href.split("/"); 314 // var sectionId = linkArray[linkArray.length-1]; 315 316 // if(languageCheck){ 317 // window.location.href = '/fr/services/'+sectionId; 318 // }else{ 319 // window.location.href = '/services/'+sectionId; 320 // } 321 322 // } 323 }); 324 325 // Data Center Datasheet French Button Links Format 326 var oldLink = $('.overview-button') 327 .children('.btn-secondary-solid') 328 .attr('href'); 329 330 if (oldLink) { 331 var status = oldLink.includes('/fr/'); 332 333 if (status) { 334 var newLink = oldLink.replace('/fr/', '/'); 335 } else { 336 var newLink = oldLink; 337 } 338 339 var linkLength = newLink.length; 340 var endChar = newLink.charAt(linkLength - 1); 341 342 if (endChar == '/') { 343 newLink = newLink.slice(0, -1); 344 } 345 346 $('.overview-button') 347 .children('.btn-secondary-solid') 348 .attr('href', newLink); 349 } 350 351 //Home Page Blog article open in a new tab 352 $('a.rsswidget').attr('target', '_blank'); 353 354 //Sticky Header 355 $(window).scroll(function () { 356 if ($(window).scrollTop() >= 76) { 357 $('#masthead').addClass('sticky'); 358 } else { 359 $('#masthead').removeClass('sticky'); 360 } 361 }); 362 363 //MOBILE NAV 364 $('.menu-item-has-children').click(function () { 365 $('.menu-item-has-children').not(this).removeClass('open'); 366 $(this).toggleClass('open'); 367 }); 368 369 $('#pr-menu-close').click(function () { 370 $('#pr-menu-toggle').trigger('click'); 371 }); 372 373 // Search 374 $('.open-search-screen').on('focus, click', function (event) { 375 event.preventDefault(); 376 $('.full-screen-search').addClass('open-panel'); 377 $('.full-screen-search input').focus(); 378 }); 379 380 // Hide search 381 $('.full-screen-search a.close').on('click', function (event) { 382 event.preventDefault(); 383 $('.full-screen-search').removeClass('open-panel'); 384 }); 385 386 // Gellery Slider 387 $('#dc-gal-slider').slick({ 388 autoplay: true, 389 autoplaySpeed: 5000, 390 pauseOnHover: false, 391 arrows: false, 392 dots: true, 393 slidesToShow: 1, 394 adaptiveHeight: true, 395 }); 396 397 // VAN TOGGLE SECTION 398 $('.vant-toggle-section .btn-toggle').click(function () { 399 $(this) 400 .parents('.vant-toggle-section') 401 .find('.vant-collapsible') 402 .slideDown(); 403 $(this).hide(); 404 }); 405 406 // View BIO 407 $('.bio-detail-view').hide(); 408 $('body').removeClass('fixed-modal'); 409 410 //$(".read-bio").click(function(){ 411 $(document).on('click', '.read-bio', function () { 412 if ($(this).next().hasClass('bio-detail-view')) { 413 $(this).next('.bio-detail-view').fadeToggle(600); 414 $('body').toggleClass('fixed-modal'); 415 } 416 }); 417
418 //$('.clickable-name').click(function () { 419 $(document).on('click', '.clickable-name', function () { 420 $(this).parent('.member-info').find('.read-bio').trigger('click'); 421 }); 422 423 //$('.close-btn').click(function () { 424 $(document).on('click', '.close-btn', function () { 425 $('.bio-detail-view').fadeOut(500); 426 $('body').removeClass('fixed-modal'); 427 }); 428 429 //close with Esc key 430 $(document).keydown(function (e) { 431 if (e.keyCode == 27) { 432 $('.bio-detail-view').fadeOut(500); 433 $('body').removeClass('fixed-modal'); 434 $('.filter-list').removeClass('open'); 435 faqClose(); 436 } 437 }); 438 439 var winWidth = $(window).width(); 440 441 if (winWidth > 992) { 442 //CURSOR FOLLOWING 443 //$('.bio-detail-view').mousemove(function (e) { 444 // $(document).on('mousemove', '.bio-detail-view', function (e) { 445 // $('.close-btn').offset({ 446 // left: e.pageX - 24, 447 // top: e.pageY - 24, 448 // }); 449 // }); 450 } 451 452 // CONTACT PAGE ACCORDION 453 if (winWidth < 768) { 454 $('.office-and-dc h3').next('.listing').slideUp(); 455 $(this).removeClass('open'); 456 457 $('.office-and-dc h3').click(function () { 458 $(this).toggleClass('open'); 459 $(this).next('.listing').slideToggle(); 460 }); 461 } 462 463 $('.top-link-item.lang-switcher').removeClass('open'); 464 if (winWidth < 1024) { 465 //Language switcher styles 466 $('.js-wpml-ls-item-toggle.wpml-ls-item-toggle').click(function () { 467 $(this).parents('.lang-switcher').toggleClass('open'); 468 }); 469 $('#pr-menu-close, #primary-menu li').click(function () { 470 $('.top-link-item.lang-switcher').removeClass('open'); 471 }); 472 } 473 474 //TEXT SIZE ADJUST TO WIDTH 475 $('.fittext').inputfit(); 476 477 //FAQ 478 var faqs = []; 479 var faq_ids = []; 480 var currentQuestionID = ''; 481 var faq_page = 0; 482 var totFAQPages = 1; 483 var faq_cat_id = ''; 484 var faq_cat_name = ''; 485 486 // FAQ CATEGORY DROPDOWN 487 $('.filter-list').removeClass('open'); 488 489 $(document).on('click', '.toggle-dropdown, .current', function (e) { 490 $(e.target).parent('.filter-list').toggleClass('open'); 491 }); 492 493 $(document).on('click', '.filter-list li a', function () { 494 $('.filter-list').removeClass('open'); 495 }); 496 497 // FAQ MODAL 498 faqClose(); 499 500 // FILTER DROPDOWN 501 502 // CLOSE FAQ MODAL 503 $(document).on('click', '.closePopup', function () { 504 faqClose(); 505 }); 506 507 // OPEN FAQ MODAL 508 $(document).on('click', '.openModal', function () { 509 currentQuestionID = $(this).data('id'); 510 showQuestion(); 511 faqOpen(); 512 }); 513 514 // CLICK NEXT QUESTION 515 $('.next-question a').click(function () { 516 nxtQIndex = faq_ids[faq_ids.indexOf(currentQuestionID) + 1]; 517 if ( 518 typeof nxtQIndex != undefined && 519 faqs[faq_ids.indexOf(currentQuestionID) + 1] 520 ) { 521 loadNextQ(); 522 } else if (faq_page <= totFAQPages) { 523 loadFaq(true); 524 } 525 }); 526 527 // CLICK PREV QUESTION 528 $('.prev-question a').click(function () { 529 prvQIndex = faq_ids[faq_ids.indexOf(currentQuestionID) - 1]; 530 if ( 531 typeof prvQIndex != undefined && 532 faqs[faq_ids.indexOf(currentQuestionID) - 1] 533 ) { 534 loadPrevQ(); 535 } 536 }); 537 538 // SELECT CATEGORY 539 $(document).on('click', '.faqCategory li', function (e) { 540 faq_cat_id = $(e.target).data('id'); 541 faq_cat_name = $(e.target).html(); 542 $('.faq-filter .current').html(faq_cat_name); 543 $('.title-category').html(faq_cat_name); 544 faqs = []; 545 faq_ids = []; 546 currentQuestionID = ''; 547 faq_page = 0; 548 totFAQPages = 1; 549 $('.faqs-list').html(''); 550 $('.loadMore').fadeIn(150); 551 loadFaq(); 552 }); 553 554 // LOAD MORE FAQ 555 $('.faq-page .loadMore').click(function () { 556 loadFaq(); 557 }); 558 559 // SELECT NEXT QUESTION 560 function loadNextQ() { 561 currentQuestionID = faqs[faq_ids.indexOf(currentQuestionID) + 1].id; 562 showQuestion(); 563 } 564 565 // SELECT PREV QUESTION 566 function loadPrevQ() { 567 currentQuestionID = faqs[faq_ids.indexOf(currentQuestionID) - 1].id; 568 showQuestion(); 569 } 570 571 // FAQ MODAL CLOSE 572 function faqClose() { 573 $('.faq-preview-popup').fadeOut(); 574 $('.vant-overlay').fadeOut(); 575 } 576 577 // FAQ MODAL OPEN 578 function faqOpen() { 579 $('.vant-overlay').fadeIn(); 580 $('.faq-preview-popup').fadeIn(); 581 } 582 583 // LOAD FAQ CATEGORIES 584 function loadFaqCategories() { 585 var url = `${siteUrl}/wp-json/wp/v2/faq_category`; 586 if (url != '') { 587 $.ajax({ 588 url: url, 589 type: 'GET', 590 success: function (res, status, request) { 591 catListHtml = $('.faqCategory').html();
592 res.forEach(function (c) { 593 catListHtml += `<li><a href="javascript:;" data-id="${c.id}">${c.name}</a></li>`; 594 }); 595 $('.faqCategory').html(catListHtml); 596 loadFaq(); 597 }, 598 error: function () { 599 // console.error('Something went wrong'); 600 }, 601 }); 602 } 603 } 604 605 // LOAD & DISPLAY FAQ 606 function loadFaq(showNext = false) { 607 var url = `${siteUrl}/wp-json/wp/v2/faq?`; 608 609 if (faq_cat_id != '') { 610 url += `faq_category=${faq_cat_id}&`; 611 } 612 url += `per_page=9&`; 613 url += `page=${faq_page + 1}&`; 614 faq_page++; 615 616 if (url != '' && faq_page <= totFAQPages) { 617 $('.loadMore .text').hide(); 618 $('.loadMore .spinner').fadeIn(80); 619 $.ajax({ 620 url: url, 621 type: 'GET', 622 success: function (res, status, request) { 623 res.forEach(function (i) { 624 faqs.push(i); 625 }); 626 displayFAQs(res); 627 totFAQPages = request.getResponseHeader('X-WP-TotalPages'); 628 $('.loadMore .spinner').hide(); 629 $('.loadMore .text').fadeIn(80); 630 if (faq_page >= totFAQPages) { 631 $('.loadMore').fadeOut(250); 632 } 633 if (showNext) { 634 loadNextQ(); 635 setNextNav(); 636 } 637 }, 638 error: function () { 639 // console.error('Something went wrong'); 640 }, 641 }); 642 } else { 643 $('.loadMore').fadeOut(250); 644 } 645 } 646 647 // DISPLAY QUESTIONS 648 function displayFAQs(faq_data = []) { 649 faqHtml = $('.faqs-list').html(); 650 faq_data.forEach(function (el) { 651 faq_ids.push(el.id); 652 faqHtml += `<div class="col-lg-4"> 653 <div class="faq-block"> 654 <div class="faq-inner"> 655 <h3><a class="openModal" data-id="${el.id}" href="javascript:;">${ 656 el.title.rendered 657 }</a></h3> 658 <div class="faq-excerpt"> 659 ${el.excerpt ? el.excerpt.rendered : el.content.rendered} 660 </div> 661 </div> 662 <a class="seeMore openModal" data-id="${el.id}" href="javascript:;">See More</a> 663 </div> 664 </div>`; 665 }); 666 $('.faqs-list').html(faqHtml); 667 } 668 669 // SHOW SELECTED QUESTION 670 function showQuestion() { 671 if (currentQuestionID != '') { 672 question = faqs[faq_ids.indexOf(currentQuestionID)]; 673 $('.faq-title').html(question.title.rendered); 674 $('.faq-detail').html(question.content.rendered); 675 } 676 setPrevNav(); 677 setNextNav(); 678 } 679 680 // SET PREV NAVIGATION 681 function setPrevNav() { 682 if (faq_ids.indexOf(currentQuestionID) == 0) { 683 $('.prev-question').addClass('disabled'); 684 } else { 685 $('.prev-question').removeClass('disabled'); 686 } 687 } 688 689 // SET NEXT NAVIGATION 690 function setNextNav() { 691 nxtQIndex = faq_ids[faq_ids.indexOf(currentQuestionID) + 1]; 692 if ( 693 (typeof nxtQIndex != undefined && 694 faqs[faq_ids.indexOf(currentQuestionID) + 1]) || 695 faq_page <= totFAQPages 696 ) { 697 $('.next-question').removeClass('disabled'); 698 } else { 699 $('.next-question').addClass('disabled'); 700 } 701 } 702 703 // INIT FAQ CATEGORIES 704 if ($('.faq-page').length > 0) { 705 loadFaqCategories(); 706 } 707 708 // NEWS AND EVENTS 709 710 var news_events = []; 711 var ne_category = ''; 712 var ne_page = 0; 713 var totNEPages = 1; 714 var ne_page_type = ''; 715 var ne_filter_year = ''; 716 717 // LOAD & DISPLAY NEWS 718 function loadNewsEvents() { 719 ne_category = $('.year-filter').data('category'); 720 ne_page_type = $('.year-filter').data('page-type'); 721 // siteUrl is the English root (WPML doesn't language-adjust get_site_url()). 722 // Use the /fr/ REST root on French pages so titles come back in French. 723 var langBase = 724 window.location.pathname.indexOf('/fr/') === 0 ? siteUrl + '/fr' : siteUrl; 725 var url = `${langBase}/wp-json/wp/v2/news?`; 726 727 if (ne_category != '') { 728 url += `news_type=${ne_category}&`; 729 } 730 731 if (ne_filter_year != '') { 732 url += `after=${ne_filter_year}-01-01T00:00:00Z&before=${ne_filter_year}-12-31T23:59:59Z&`; 733 } 734 735 url += `per_page=4&`; 736 url += `page=${ne_page + 1}&`; 737 url += `_embed=1&`; 738 ne_page++; 739 740 if (url != '' && ne_page <= totNEPages) { 741 $('.loadMore .text').hide(); 742 $('.loadMore .spinner').fadeIn(80); 743 $.ajax({ 744 url: url, 745 type: 'GET', 746 success: function (res, status, request) {
747 res.forEach(function (i) { 748 news_events.push(i); 749 }); 750 if (ne_page_type == 'Press Releases') { 751 displayNewsAndPress(); 752 } else if (ne_page_type == 'Media Coverages') { 753 displayMediaCoverage(); 754 } else if (ne_page_type == 'Statements') { 755 displayStatements(); 756 } 757 displayFAQs(res); 758 totNEPages = request.getResponseHeader('X-WP-TotalPages'); 759 $('.loadMore .spinner').hide(); 760 $('.loadMore .text').fadeIn(80); 761 if (ne_page >= totNEPages) { 762 $('.loadMore').fadeOut(250); 763 } 764 }, 765 error: function () { 766 // console.error('Something went wrong'); 767 }, 768 }); 769 } else { 770 $('.loadMore').fadeOut(250); 771 } 772 } 773 774 // INIT NEWS AND EVENTS 775 ne_filter_year = $('.news-events-year-filter .current').data('current-year'); 776 if ($('.news-events-sub').length > 0) { 777 loadNewsEvents(); 778 } 779 780 // DISPLAY PRESS RELEASE 781 function displayNewsAndPress() { 782 html = ''; 783 $('.press').html(''); 784 news_events.forEach(function (el) { 785 var cat_tag = getTermNameById( 786 el._embedded['wp:term'], 787 el.news_type[0] ? el.news_type[0] : '' 788 ); 789 var n_title = el.title.rendered; 790 791 /*if(n_title.length > 12){ 792 var res = n_title.split(" ", 5); 793 var mobttlfive = res.join(' '); 794 n_title_mo = mobttlfive+'...'; 795 }*/ 796 console.log(n_title.length); 797 if (n_title.length > 32) { 798 var res1 = n_title.split(' ', 5); 799 console.log(res1); 800 var mobttlfive1 = res1.join(' '); 801 console.log(mobttlfive1); 802 var n_title_mo = mobttlfive1 + '...'; 803 console.log(n_title_mo); 804 } else { 805 n_title_mo = n_title; 806 } 807 808 var n_desc = el.content.rendered; 809 if (n_title.length > 150) n_title = n_title.substring(0, 150) + '...'; 810 //if(n_title.length > 50) n_title_mo = n_title.substring(0,50)+"..."; 811 if (n_desc.length > 180) n_desc = n_desc.substring(0, 180) + '...'; 812 html += `<li> 813 <div class="post-container"> 814 <div class="meta"><span>${localizeNewsType(cat_tag).toUpperCase()}</span>|<span>${formatNEDate( 815 el.date 816 )}</span></div> 817 <a target="_blank" href="${ 818 el.link 819 }"><h4 class="van-desk-vie">${n_title}</h4><h4 class="van-mob-vie test">${n_title_mo}</h4></a> 820 <!--<div class="post-description">${n_desc}</div>--> 821 </div> 822 </li>`; 823 }); 824 825 $('.press').html(html); 826 } 827 828 // DISPLAY MEADIA COVERAGE 829 function displayMediaCoverage() { 830 html = ''; 831 $('.media').html(''); 832 news_events.forEach(function (el) { 833 var cat_tag = getTermNameById( 834 el._embedded['wp:term'], 835 el.news_type[0] ? el.news_type[0] : '' 836 ); 837 var mediaCovBrk = el.title.rendered; 838 if (mediaCovBrk.length > 32) { 839 var res = mediaCovBrk.split(' ', 5); 840 var mobttlfive = res.join(' '); 841 var medi_title_mo = mobttlfive + '...'; 842 } else { 843 medi_title_mo = mediaCovBrk; 844 } 845 //if(mediaCovBrk.length > 50) medi_title_mo = mediaCovBrk.substring(0,50)+"..."; 846 html += `<li> 847 <div class="post-container"> 848 <div class="row"> 849 <div class="col-sm-4"> 850 <div class="img-wrapper vant-img"> 851 <img src="${el.fimg_url ? el.fimg_url : ''}" alt="media logo"> 852 </div> 853 </div> 854 855 <div class="col-sm-8"> 856 <div class="meta"><span>${localizeNewsType(cat_tag).toUpperCase()}</span>|<span>${formatNEDate( 857 el.date 858 )}</span></div> 859 <a${el.media_page_url != '' ? ' target="_blank"' : ''} href="${ 860 el.media_page_url != '' ? el.media_page_url : 'javascript:;' 861 }"><h4 class="van-desk-vie">${mediaCovBrk}</h4><h4 class="van-mob-vie">${medi_title_mo}</h4></a> 862 </div> 863 </div> 864 </div> 865 </li>`; 866 }); 867 868 $('.media').html(html); 869 imgResize(); 870 } 871 872 // DISPLAY STATEMENTS 873 function displayStatements() { 874 html = ''; 875 $('.statements').html(''); 876 news_events.forEach(function (el) { 877 var cat_tag = getTermNameById( 878 el._embedded['wp:term'], 879 el.news_type[0] ? el.news_type[0] : '' 880 ); 881 var n_title = el.title.rendered; 882 883 if (n_title.length > 32) { 884 var res1 = n_title.split(' ', 5); 885 var mobttlfive1 = res1.join(' '); 886 var n_title_mo = mobttlfive1 + '...'; 887 } else { 888 n_title_mo = n_title; 889 } 890 891 var n_desc = el.content.rendered; 892 if (n_title.length > 150) n_title = n_title.substring(0, 150) + '...'; 893 if (n_desc.length > 180) n_desc = n_desc.substring(0, 180) + '...'; 894 html += `<li> 895 <div class="post-container"> 896 <div class="meta"><span>${localizeNewsType(cat_tag).toUpperCase()}</span> | <span>${formatNEDate( 897 el.date 898 )}</span></div> 899 <a target="_blank" href="${ 900 el.link 901 }"><h4 class="van-desk-vie">${n_title}</h4><h4 class="van-mob-vie">${n_title_mo}</h4></a> 902 <!--<div class="post-description">${n_desc}</div>--> 903 </div> 904 </li>`; 905 }); 906 907 $('.statements').html(html); 908 } 909 910 // FORMAT DATE 911 function formatNEDate(str) { 912 var date = new Date(str); 913 const options = { year: 'numeric', month: 'long', day: 'numeric' }; 914 var LangStr = jQuery('html').attr('lang'); 915 return date.toLocaleDateString(LangStr, options); 916 } 917 918 // LOCALIZE news_type TERM NAME 919 // News posts aren't translated in WPML, so the REST embed always returns the 920 // default-language (English) term (e.g. "Press Release") even on /fr/. Map it 921 // to French for display, mirroring the breadcrumb label map in functions.php. 922 function localizeNewsType(name) { 923 var isFrench = (jQuery('html').attr('lang') || '').toLowerCase().indexOf('fr') === 0; 924 // The REST embed can return EITHER language's term (posts may be tagged with 925 // the EN or FR news_type term), so normalize the label to the current page 926 // language in BOTH directions. 927 var enToFr = { 928 'Press Release': 'Communiqués de Presse', 929 'Media Coverage': 'Couverture Médiatique', 930 'Statements': 'Déclarations', 931 'Statement': 'Déclarations', 932 }; 933 var frToEn = { 934 'Communiqués de Presse': 'Press Release', 935 'Couverture Médiatique': 'Media Coverage', 936 'Déclarations': 'Statements', 937 }; 938 if (isFrench) { 939 return enToFr[name] || name; 940 } 941 return frToEn[name] || name; 942 } 943 944 // SELECT CATEGORY 945 $(document).on( 946 'click', 947 '.news-events-year-filter .year-filter li a', 948 function (e) { 949 ne_filter_year = $(e.target).html(); 950 $('.news-events-year-filter .current').html(ne_filter_year); 951 952 news_events = []; 953 ne_page = 0; 954 totNEPages = 1; 955 956 if (ne_page_type == 'Press Releases') { 957 $('.press').html(''); 958 } else if (ne_page_type == 'Media Coverages') { 959 $('.media').html(''); 960 } else if (ne_page_type == 'Statements') { 961 $('.statements').html(''); 962 } 963 964 $('.loadMore').fadeIn(150); 965 loadNewsEvents(); 966 } 967 ); 968 969 // LOAD MORE NEWS & EVENTS 970 $('.news-events .loadMore').click(function () { 971 loadNewsEvents(); 972 }); 973 974 // GET TERM NAME BY ID 975 function getTermNameById(terms, id) { 976 if (terms[0] && id != '') { 977 name = '';
978 terms.forEach(function (set) { 979 set.forEach(function (el) { 980 if (id == el.id) { 981 name = el.name; 982 } 983 }); 984 }); 985 return name; 986 } else { 987 return ''; 988 } 989 } 990 991 // image frame to list 992 $('.frame-to-list .frmImg:first-child') 993 .find('.img-wrapper') 994 .addClass('frame-tl'); 995 $('.frame-to-list .frmImg:last-child') 996 .find('.img-wrapper') 997 .addClass('frame-br'); 998 999 // Get url params by name 1000 function getParameterByName(name, url) { 1001 if (!url) url = window.location.href; 1002 name = name.replace(/[\[\]]/g, '\\$&'); 1003 var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), 1004 results = regex.exec(url); 1005 if (!results) return null; 1006 if (!results[2]) return ''; 1007 return decodeURIComponent(results[2].replace(/\+/g, ' ')); 1008 } 1009 1010 // Expand the area in globe 1011 function selectGlobeArea() { 1012 var area = getParameterByName('area'); 1013 setTimeout(function () { 1014 if (area == 'NorthAmerica') { 1015 $('.tab-view-title-button-america').click(); 1016 } else if (area == 'Europe') { 1017 $('.tab-view-title-button-europe').click(); 1018 } 1019 }, 1800); 1020 } 1021 selectGlobeArea(); 1022 1023 function imgResize() { 1024 $('.vant-img img').each(function () { 1025 // Calculate aspect ratio and store it in HTML data- attribute 1026 var aspectRatio = $(this).width() / $(this).height(); 1027 $(this).data('aspect-ratio', aspectRatio); 1028 1029 // Conditional statement 1030 if (aspectRatio > 1) { 1031 // Image is landscape 1032 $(this).css({ 1033 width: '100%', 1034 height: 'auto', 1035 }); 1036 } else if (aspectRatio < 1) { 1037 // Image is portrait 1038 $(this).css({ 1039 height: '100%', 1040 width: 'auto', 1041 }); 1042 } else { 1043 // Image is square 1044 $(this).css({ 1045 maxWidth: '100%', 1046 height: 'auto', 1047 }); 1048 } 1049 }); 1050 } 1051 1052 imgResize(); 1053 1054 $('.toggle-btn-mobile').click(function () { 1055 $(this).next('ul').slideToggle(); 1056 }); 1057 1058 if (winWidth < 768) { 1059 $('.inner-page-nav-list li a').click(function () { 1060 var txtVal = $(this).html(); 1061 var drpIcn = "<i class='fa fa-angle-down'></i>"; 1062 $(this) 1063 .parents('.inner-page-nav') 1064 .find('.toggle-btn-mobile') 1065 .html(txtVal + drpIcn); 1066 $('.inner-page-nav-list').slideUp(); 1067 }); 1068 } 1069}); 1070 1071// $(window).on('load', function() { 1072// //Image size 1073// var vntImg = $('.vant-img img'); 1074// if (vntImg.width() > vntImg.height()){ 1075// $(this).css('width' , '100%'); 1076// } else if (vntImg.width() < vntImg.height()){ 1077// $(this).css('height' , '100%'); 1078// } else { 1079// $(this).css('height' , '100%'); 1080// } 1081// }); 1082 1083// SELECT CATEGORY 1084/*$(document).on('click', '.leadership-filter .year-filter li a', function(e) { 1085 ne_filter_year = $(e.target).html(); 1086 $('.leadership-filter .current').html(ne_filter_year); 1087 1088 news_events = []; 1089 ne_page = 0; 1090 totNEPages = 1; 1091 1092 $('.leadership-posts-list').html(''); 1093 1094 $('.loadMore').fadeIn(150); 1095 loadLeadership(); 1096 });*/ 1097 1098// LOAD & DISPLAY NEWS 1099/*function loadLeadership() { 1100 1101 ne_category = $('.year-filter').data('category'); 1102 ne_page_type = $('.year-filter').data('page-type'); 1103 var url = `${siteUrl}/wp-json/wp/v2/news?`; 1104 1105 if(ne_category != '') { 1106 url += `news_type=${ne_category}&` 1107 } 1108 1109 if(ne_filter_year != '') { 1110 url += `after=${ne_filter_year}-01-01T00:00:00Z&before=${ne_filter_year}-12-31T23:59:59Z&` 1111 } 1112 1113 url += `per_page=4&`; 1114 url += `page=${ne_page + 1}&`; 1115 url += `_embed=1&` 1116 ne_page++; 1117 1118 if(url != '' && ne_page <= totNEPages) { 1119 $('.loadMore .text').hide(); 1120 $('.loadMore .spinner').fadeIn(80); 1121 $.ajax({ 1122 url: url, 1123 type: 'GET', 1124 success: function(res, status, request){ 1125 res.forEach(function (i) { 1126 news_events.push(i); 1127 }); 1128 if(ne_page_type == 'Press Releases'){ 1129 displayNewsAndPress(); 1130 } else if(ne_page_type == 'Media Coverages') { 1131 displayMediaCoverage(); 1132 } 1133 displayFAQs(res); 1134 totNEPages = request.getResponseHeader('X-WP-TotalPages'); 1135 $('.loadMore .spinner').hide(); 1136 $('.loadMore .text').fadeIn(80); 1137 if(ne_page >= totNEPages) { 1138 $('.loadMore').fadeOut(250); 1139 } 1140 }, 1141 error: function (){ 1142 // console.error('Something went wrong'); 1143 } 1144 }); 1145 } else { 1146 $('.loadMore').fadeOut(250); 1147 } 1148 }*/ 1149 1150 1151 // Scroll to top button 1152$(function () { 1153 1154 if ($(this).scrollTop() > 300) { 1155 $('#scroll-to-top-btn').addClass('show'); 1156 } 1157 1158 $(window).on('scroll', function () { 1159 if ($(this).scrollTop() > 300) { 1160 $('#scroll-to-top-btn').addClass('show'); 1161 } else { 1162 $('#scroll-to-top-btn').removeClass('show'); 1163 } 1164 }); 1165 $('#scroll-to-top-btn').on('click', function () { 1166 $('html').scrollTop(0); 1167 }); 1168}); 1169 1170// Single-news breadcrumb category fix. 1171// A footer snippet (in WPCode/Code Snippets, not the theme) hardcodes the 1172// "Press Releases" crumb for EVERY single news post. Correct the last crumb to 1173// match the post's real news_type â read from the `news-type-*` body class the 1174// theme adds (see functions.php) â and watch for the snippet's late rewrite so 1175// there is no flicker. No-op on press releases (already correct). 1176jQuery(function () { 1177 var $body = jQuery('body'); 1178 if (!$body.hasClass('single-news')) return; 1179 1180 var isFr = window.location.pathname.indexOf('/fr/') === 0; 1181 var neBase = isFr ? '/fr/company/news-events/' : '/company/news-events/'; 1182 var cat = null; 1183 if ($body.hasClass('news-type-statement') || $body.hasClass('news-type-declaration')) { 1184 cat = { url: neBase + 'statements/', label: isFr ? 'Déclarations' : 'Statements' }; 1185 } else if ($body.hasClass('news-type-media-coverage') || $body.hasClass('news-type-media-coverage-fr')) { 1186 cat = { url: neBase + 'media-coverage/', label: isFr ? 'Couverture Médiatique' : 'Media Coverage' }; 1187 } 1188 if (!cat) return; // press-release posts already show the correct crumb 1189 1190 function fixCrumb() { 1191 var $links = jQuery('.single-news .rank-math-breadcrumb p a'); 1192 if (!$links.length) return false;
1193 var $last = $links.last(); 1194 var t = jQuery.trim($last.text()); 1195 if (t === 'Press Releases' || t === 'Communiqués de Presse') { 1196 $last.text(cat.label).attr('href', cat.url); 1197 return true; 1198 } 1199 return false; 1200 } 1201 1202 if (fixCrumb()) return; 1203 var el = document.querySelector('.single-news .rank-math-breadcrumb'); 1204 if (el && window.MutationObserver) { 1205 var obs = new MutationObserver(function () { if (fixCrumb()) obs.disconnect(); }); 1206 obs.observe(el, { childList: true, subtree: true }); 1207 setTimeout(function () { obs.disconnect(); }, 4000); 1208 } 1209});
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.