' // ).appendTo( // jQuery( // ".bmo-interactive-map .elementor-container.elementor-column-gap-default" // ) // ); // jQuery( // '
' // ).appendTo( // jQuery( // ".bmo-interactive-map-title-section .elementor-element-populated" // ) // ); // jQuery( // ".bmo-interactive-map-pin-box .bmo-interactive-map-listing" // ).each(function() { // var pinCategory = // jQuery(this).attr("data-category"), // pinIconColor = jQuery(this) // .find( // ".bmo-pin-category-colorpicker > div > div > div > div" // ) // .text(); // if ( // jQuery( // ".bmo-legend-item-category." + pinCategory // ).length === 0 // ) { // jQuery( // '
' // ).appendTo( // jQuery( // ".bmo-interactive-map .bmo-interactive-map-legend-box" // ) // ); // jQuery( // '
" // ).appendTo( // jQuery( // ".bmo-interactive-map-title-section .bmo-interactive-map-filter-box .bmo-interactive-map-filters-select" // ) // ); // } // }); // } // } // function generateMarkers() { // var countItems = 0, // arrayA = [], // bounds = new google.maps.LatLngBounds(), // infowindow = new google.maps.InfoWindow({ // maxWidth: 500, // closeBoxURL: window.location.origin + // "/wp-content/themes/bmo/assets/images/close.png", // }); // jQuery( // ".bmo-interactive-map-pin-box .bmo-interactive-map-listing" // ).each(function() { // var pinLocationY = jQuery(this) // .find( // ".bmo-pin-location-y .elementor-heading-title" // ) // .text(), // pinLocationX = jQuery(this) // .find( // ".bmo-pin-location-x .elementor-heading-title" // ) // .text(), // pinCategory = jQuery(this).attr("data-cateogory"), // pinBoxTitle = jQuery(this) // .find( // ".bmo-pin-box-title .elementor-heading-title" // ) // .text(), // pinBoxDescription = jQuery(this) // .find( // ".bmo-pin-box-description .elementor-text-editor" // ) // .text(), // pinButtonAttr = jQuery(this) // .find(".bmo-pin-box-button.pin-external-link") // .attr("data-switcher"), // pinBoxButtonLabel = jQuery(this) // .find(".pin-url-link .elementor-button-text") // .text(), // pinBoxButtonExternalLabel = jQuery(this) // .find( // ".pin-external-link .elementor-button-text" // ) // .text(), // pinBoxButtonPostUrl = jQuery(this) // .find(".bmo-pin-box-button.pin-url-link a") // .attr("href"), // pinBoxButtonExternal = jQuery(this) // .find(".bmo-pin-box-button.pin-external-link a") // .attr("href"), // pinBoxImage = jQuery(this) // .find( // ".elementor-widget-image .elementor-image img" // ) // .attr("src"), // pinIconColor = jQuery(this) // .find( // ".bmo-pin-category-colorpicker > div > div > div > div" // ) // .text(), // svg = pinTemplate.replace( // "{{ color }}", // pinIconColor // ), // icon = { // // Here was the function that blocked upload: encodeURIComponent // // url: "data:image/svg+xml;base64," + btoa(svg), // scaledSize: new google.maps.Size(30, 30), // }; // if (jQuery(this).attr("data-init") === "true") { // var markerData = { // position: new google.maps.LatLng( // pinLocationY, // pinLocationX // ), // map: map, // icon: icon, // }; // } // var marker = new google.maps.Marker(markerData); // jQuery(this).each(function() { // if ( // jQuery(this).attr("data-init") === "true" && // marker.getPosition() // ) { // var latLng = marker.getPosition(); // countItems++; // arrayA.push(latLng); // if (countItems === 1) { // map.setZoom(9); // map.setCenter(latLng); // } else if (countItems === 2) { // var lastEl = arrayA[arrayA.length - 1]; // bounds.extend(arrayA[0]); // bounds.extend(lastEl); // map.fitBounds(bounds); // } else if ( // countItems === 3 || // countItems === 4 // ) { // lastEl = arrayA[arrayA.length - 1]; // bounds.extend(arrayA[0]); // bounds.extend(lastEl); // map.fitBounds(bounds); // } else if (countItems > 5) { // lastEl = arrayA[arrayA.length - 1]; // bounds.extend(arrayA[0]); // bounds.extend(lastEl); // map.fitBounds(bounds); // } // } // }); // google.maps.event.addListener( // marker, // "click", // (function(e) { // return function() { // var customContent = []; // map.setZoom(6); // customContent.push( // '
' + // pinBoxTitle + // '
' + // pinBoxDescription + // "
" + // '' + // pinBoxButtonLabel + // "
" // ); // infowindow.setContent( // customContent.join("") // ); // infowindow.open(map, marker); // /* change button label/link if external on */ // if (pinButtonAttr === "true") { // jQuery("a.title").attr( // "href", // pinBoxButtonExternal // ); // jQuery("a.post-url-link").attr( // "href", // pinBoxButtonExternal // ); // jQuery("a.post-url-link").text( // pinBoxButtonExternalLabel // ); // } // }; // })(marker) // ); // }); // } // /* Legend filter box - sort item */ // var legendItems = jQuery( // ".bmo-interactive-map-legend-item .bmo-legend-item-category" // ); // legendItems // .sort(function(a, b) { // if (a.textContent < b.textContent) { // return -1; // } else { // return 1; // } // }) // .appendTo(".bmo-interactive-map-legend-box"); // /* Select filter box - sort item */ // var selectItems = jQuery( // ".bmo-interactive-map-filters-select .bmo-interactive-map-select-item:not(:first-child" // ); // selectItems // .sort(function(a, b) { // if (a.textContent < b.textContent) { // return -1; // } else { // return 1; // } // }) // .appendTo(".bmo-interactive-map-filters-select"); // /* Legend filter box - replace - with '' space */ // jQuery(".bmo-legend-item-category p").each(function() { // var itemText = jQuery(this).text().replace(/-/g, " "); // jQuery(this).text(itemText); // }); // /* Select filter box - replace - with '' space */ // jQuery(".bmo-interactive-map-select-item").each(function() { // var itemText = jQuery(this).text().replace(/-/g, " "); // jQuery(this).text(itemText); // }); // /* Select filter box - arrow rotate function */ // jQuery(".bmo-interactive-map-filters-select").on( // "click", // function() { // jQuery(".bmo-interactive-map-filter-box").toggleClass( // "bmo-active-select" // ); // } // ); // jQuery(".bmo-legend-item-category").on("click", function() { // var currentVal = jQuery(this).attr("data-value"); // jQuery(".bmo-interactive-map-select-item").each( // function() { // var selectValue = jQuery(this).attr("data-value"); // if (selectValue === currentVal) { // jQuery(this).attr("selected", "selected"); // } // } // ); // jQuery( // ".bmo-interactive-map-pin-box .bmo-interactive-map-listing" // ).each(function() { // if (jQuery(this).attr("data-category") === currentVal) { // jQuery(this).attr("data-init", "true"); // } else { // jQuery(this).attr("data-init", "false"); // } // }); // initMap(); // }); // /* Focus, focusout - legend box function */ // jQuery(".bmo-legend-item-category").each(function() { // jQuery(this).on("focus", function() { // jQuery(this).addClass("legend-item-focus"); // }); // jQuery(this).on("focusout", function() { // jQuery(this).removeClass("legend-item-focus"); // }); // }); // /* 'Enter' keypress fucntion */ // jQuery(document).on("keypress", function(e) { // if ( // e.key === "Enter" && // jQuery(".legend-item-focus").length === 1 // ) { // var currentVal = // jQuery(".legend-item-focus").attr("data-value"); // jQuery(".bmo-interactive-map-select-item").each( // function() { // var selectValue = // jQuery(this).attr("data-value"); // if (selectValue === currentVal) { // jQuery(this).attr("selected", "selected"); // } // } // ); // jQuery( // ".bmo-interactive-map-pin-box .bmo-interactive-map-listing" // ).each(function() { // if ( // jQuery(this).attr("data-category") === // currentVal // ) { // jQuery(this).attr("data-init", "true"); // } else { // jQuery(this).attr("data-init", "false"); // } // }); // initMap(); // } // }); // } /*========== End [135] Interactive map ==========*/ /*========== [201] Bio title ==========*/ if (jQuery(".bmo-bio-title-listing").length > 0) { function hiddenArrow() { jQuery(".bmo-bio-title-listing").each(function() { var name = jQuery(this) .find( ".bmo-bio-title-listing-description .elementor-text-editor" ) .height(), moreArrow = jQuery(this).find( ".bmo-bio-title-listing-description .button-wrapper" ), heightArrow = moreArrow.height(), heightDescription = jQuery(this) .find( ".bmo-bio-title-listing-description .expandable-text" ) .css("max-height"), heightBox = parseFloat(heightDescription) - parseFloat(heightArrow); if (name < heightBox) { moreArrow.css("display", "none"); } else { moreArrow.css("display", "block"); } }); } hiddenArrow(); jQuery(window).on("resize", debounce(hiddenArrow, 100)); jQuery( ".bmo-bio-title-listing .bmo-bio-title-listing-description .expand-button" ).on("click", function() { jQuery(this) .closest(".elementor-widget-container") .toggleClass("expanded"); }); } /*========== End [201] Bio title ==========*/ /*========== [202/203/222] Team members not focus slider element ==========*/ if (jQuery(".bmo-team-member-carousel ").length > 0) { jQuery( ".bmo-team-member-carousel .slick-track .kurtosys-listing-grid__item" ).attr("tabindex", "-1"); } /*========== End [202/203/222] Team members not focus slider element ==========*/ /*========== [306] Documents Module ==========*/ setTimeout(function() { jQuery( ".bmo-documents-module-term .kurtosys-listing-dynamic-terms" ).each(function() { if (jQuery(this).is(":empty")) { jQuery(this).text("-"); } }); }, 2000); /*========== End [306] Documents Module ==========*/ hideInsightTag(); jQuery(".load-more-button").on("click", function() { setTimeout(function() { hideInsightTag(); }, 2000); }); /*========== [BMO-577] Accessible Navigation ==========*/ const setNewOrderForTeamMember = document.querySelectorAll('.lp-order-by .kurtosys-listing-grid__item .bmo-team-member-listing-name .elementor-heading-title') const setNewOrder = () => { setNewOrderForTeamMember.forEach((el) => { switch (el.textContent) { case 'Kristi Mitchem': el.closest('.kurtosys-listing-grid__item').style.order = '-3' break; case 'Sadiq S. Adatia FSA, FCIA, CFA': el.closest('.kurtosys-listing-grid__item').style.order = '-1' break; case 'Bill Bamber CFA, MBA. MMA': el.closest('.kurtosys-listing-grid__item').style.order = '-2' break; } }) } if (setNewOrderForTeamMember.length) { setNewOrder(); } /*========== [BMO-724] Setting cookies for the banner ==========*/ function setCookiePopup(cookieName, cookieValue, expirationDays) { let date = new Date(); date.setTime(date.getTime() + (expirationDays * 24 * 60 * 60 * 1000)); const expires = "expires=" + date.toUTCString(); document.cookie = cookieName + "=" + cookieValue + "; " + expires + "; path=/"; } function getCookiePopup(cookieName) { const name = cookieName + "="; const cDecoded = decodeURIComponent(document.cookie); //to be careful const cArr = cDecoded.split('; '); let res; cArr.forEach(val => { if (val.indexOf(name) === 0) res = val.substring(name.length); }) return res; } jQuery( document ).on( 'elementor/popup/show', () => { const bmoCookieBarCloseButton = document.querySelector('.bmo-cookie-bar .bmo-cookie-close-btn a') if (!!bmoCookieBarCloseButton) { bmoCookieBarCloseButton.addEventListener('click', () => { if (isInvestorTypeSite()) { setCookiePopup('cookies_banner', true, 90); } else { setCookiePopup('cookies_banner_product_site', true, 90); } }) } const hideCookieBanner = () => { const cookiesBarPopup = document.querySelector('.bmo-cookies-bar-popup') if (!!cookiesBarPopup) { cookiesBarPopup.classList.add('bmo-hide-cookie-popup') } } if (isInvestorTypeSite() && getCookiePopup('cookies_banner')) { hideCookieBanner() } if (!isInvestorTypeSite() && getCookiePopup('cookies_banner_product_site')) { hideCookieBanner() } }); /*========== [BMO-488] Accessible Navigation ==========*/ const accessibleNavigation = () => { const menuItemLinks = document.querySelectorAll('.bmo-main-navigation.bmo-main-navigation-primary.bmo-navigation-right-position .menu-item a[role="menuitem"]') if (menuItemLinks) { let mql = window.matchMedia('(min-width: 1024px)'); if (mql.matches) { const removeHoverStateFromParents = (item) => { let parent = item.closest('.menu-item'); while (parent) { parent.classList.remove('hover-state') parent.setAttribute('aria-expanded', "false") parent = parent.parentNode.closest('.menu-item'); } } const addHoverStateToParents = (target) => { let parent = target.closest('.menu-item'); while (parent) { parent.classList.add('hover-state') parent.setAttribute('aria-expanded', "true") parent = parent.parentNode.closest('.menu-item'); } } menuItemLinks.forEach(el => { el.parentElement.setAttribute('aria-expanded', "false") el.addEventListener('focus', (event) => { menuItemLinks.forEach(item => { removeHoverStateFromParents(item) }) let { target } = event; addHoverStateToParents(target) }) }) } } } /** * Sets the aria-expanded attribute on the menu items when hovered over and removes it when mouseout. * */ const setAriaExpandedOnMenu = () => { const menuItems = document.querySelectorAll('.bmo-main-navigation .menu-item.menu-item-has-children'); menuItems.forEach(menuItem => { menuItem.addEventListener('mouseover', debounce(() => { menuItem.setAttribute('aria-expanded', "true") }, 400)) menuItem.addEventListener('mouseout', debounce(() => { menuItem.setAttribute('aria-expanded', "false") }, 400)) }) } setAriaExpandedOnMenu() const addAriaLabels = () => { const menuItemLinksText = document.querySelectorAll('.bmo-main-navigation.bmo-main-navigation-primary.bmo-navigation-right-position .menu-item a[role="menuitem"] .kurtosys-menu-link-text') if (menuItemLinksText) { menuItemLinksText.forEach(el => { const selector = 'kurtosys-custom-nav__item-link'; const labels = { investment: 'Investment Solutions Overview', insights: 'Insights Overview', tools: 'Tools and Resources Overview', solutions: 'Aper des solutions de placement', perspectives: 'Aper des perspectives', outils: 'Aperu des outils et des ressources' }; switch (el.textContent.toLowerCase()) { case 'investment solutions': el.closest(`.${selector}`).setAttribute('aria-label', labels.investment) break; case 'insights': el.closest(`.${selector}`).setAttribute('aria-label', labels.insights) break; case 'tools and resources': el.closest(`.${selector}`).setAttribute('aria-label', labels.tools) break; case 'solutions de placement': el.closest(`.${selector}`).setAttribute('aria-label', labels.solutions) break; case 'perspectives': el.closest(`.${selector}`).setAttribute('aria-label', labels.perspectives) break; case 'outils et ressources': el.closest(`.${selector}`).setAttribute('aria-label', labels.outils) break; } }) } } accessibleNavigation(); addAriaLabels(); /*========== [BMO-488] Accessible Navigation ==========*/ /** * Takes the insight excerpt and use it as the aria-label for screen readers */ const addAriaLabelToFlyoutReadMoreButton = () => { const flyoutInsightLinksSections = document.querySelectorAll('.bmo-quick-links-flyouts') flyoutInsightLinksSections.forEach(section => { const readMoreButton = section.querySelector('.elementor-widget-button .elementor-button-link') const insightExcerpt = section.querySelector('.bmo-quick-links-flyouts-desc .elementor-text-editor')?.textContent.replace(/^[\s]+|[\s]+$/g,'') const siteLang = document.documentElement.lang; const languages = ['en-CA', 'en-US']; const labelPrepend = languages.includes(siteLang) ? 'Read more about ' : 'En savoir plus sur'; if (!insightExcerpt || !readMoreButton) return readMoreButton.setAttribute('aria-label', labelPrepend + insightExcerpt) }) } addAriaLabelToFlyoutReadMoreButton(); /** * Takes the team member name and use it as the aria-label for screen readers */ const addAriaLabelToBioButton = () => { const bioButton = document.querySelectorAll('.bmo-team-members-carousel-button') bioButton.forEach(button => { const link = button.querySelector('.elementor-button-link') const section = button.closest('.bmo-team-member-listing') const teamMemberName = section.querySelector('.bmo-team-member-listing-name')?.textContent.replace(/^[\s]+|[\s]+$/g,'') const siteLang = document.documentElement.lang; const languages = ['en-CA', 'en-US']; const labelPrepend = languages.includes(siteLang) ? 'Read ' : 'Lire la '; const labelAppend = languages.includes(siteLang) ? ' bio' : ' biographie'; if (!link || !teamMemberName) return link.setAttribute('aria-label', labelPrepend + teamMemberName + labelAppend) }) } addAriaLabelToBioButton(); /** * Whenever the widget button has the aria-label set in 'Custom attributes', we move its value to the 'a' link */ const addAriaLabelToButtons = () => { const buttons = document.querySelectorAll('.elementor-widget-button[aria-label]') buttons.forEach(button => { const ariaLabel = button.getAttribute('aria-label') button.removeAttribute('aria-label') const link = button.querySelector('.elementor-widget-button .elementor-button-link') if (!ariaLabel || !link) return link.setAttribute('aria-label', ariaLabel) }) } addAriaLabelToButtons(); /** * Sets the aria for the menu item which represents the current site */ const setAriaUsingCurrentPage = () => { const pageParams = new URL(window.location.href); const menuItems = document.querySelectorAll('.bmo-nav-menu-top-left .elementor-nav-menu > .menu-item a') menuItems.forEach(item => { if(pageParams.href.includes(item.textContent.toLowerCase())) { item.setAttribute('aria-current', 'page') } }) } setAriaUsingCurrentPage() /*========== [BMO-581] Accessible Top Navbar ==========*/ const accessibleTopNavbar = () => { const investorDropdownButton = document.querySelectorAll('.bmo-navigation.bmo-top-navigation .bmo-column-button-right .kurtosys-dropbar__button'); const mql = window.matchMedia('(min-width: 1025px)'); if (mql.matches) { investorDropdownButton.forEach((button) => { const dropdown = button.closest('.kurtosys-dropbar'); const investors = dropdown.querySelectorAll('.kurtosys-dropbar__content a'); button.addEventListener('focus', () => { button.setAttribute('aria-expanded', 'true'); dropdown.classList.add('kurtosys-dropbar-open'); }); button.addEventListener('focusout', (event) => { if (!dropdown.contains(event.relatedTarget)) { button.setAttribute('aria-expanded', 'false'); dropdown.classList.remove('kurtosys-dropbar-open'); } }); investors.forEach((investor) => { investor.addEventListener('focus', () => { button.setAttribute('aria-expanded', 'true'); dropdown.classList.add('kurtosys-dropbar-open'); }); investor.addEventListener('focusout', (event) => { if (!dropdown.contains(event.relatedTarget)) { button.setAttribute('aria-expanded', 'false'); dropdown.classList.remove('kurtosys-dropbar-open'); } }); }); }); } }; accessibleTopNavbar(); /*========== [BMO-581] Accessible Top Navbar ==========*/ /*========== [BMO-567] Accessible Menu ==========*/ const accessibilityMenuIndex = () => { const accessibilityGroupOne = document.querySelectorAll('.bmo-nav-menu-top-left .elementor-nav-menu--main .menu-item.menu-item-type-custom a:not([href="#empty-link"])') const accessibilityGroupTwo = document.querySelectorAll('.bmo-top-navigation .bmo-column-button-right .bmo-nav-sign .kurtosys-custom-nav__item-link.menu-image-title-after,' + '.bmo-top-navigation .bmo-column-button-right .bmo-nav-sign .kurtosys-custom-nav__item-link.menu-image-title-after + .kurtosys-custom-nav__mega-sub a, ' + '.bmo-top-navigation .bmo-column-button-right .elementor-row .kurtosys-dropbar__button,' + '.bmo-top-navigation.elementor-hidden-tablet.elementor-hidden-phone .bmo-column-button-right .bmo-button-nav .elementor-button-wrapper a.elementor-button-link:not([href="#empty-link"]),' + '.bmo-top-navigation .bmo-column-button-right .elementor-row .elementor-column.bmo-navigation-desktop-only .bmo-button-nav a.elementor-button-link:not([href="#empty-link"]),' + '.bmo-top-navigation .bmo-column-button-right .bmo-navigation-search input, ' + '.bmo-navigation.bmo-top-navigation .bmo-column-button-right .kurtosys-dropbar__content a,' + '.bmo-navigation.bmo-top-navigation .menu-other-bmo-sites-container .menu-item .kurtosys-custom-nav__mega-sub .elementor-icon-list-item a,' + '.bmo-top-navigation .menu-item-has-children .kurtosys-custom-nav__item-link'); const accessibilityGroupThree = document.querySelectorAll('.bmo-top-navigation .elementor-element.bmo-main-logo .bmo-logo-desktop .elementor-image a:not([href="#empty-link"])'); const accessibilityGroupFour = document.querySelectorAll('.bmo-main-navigation-primary .elementor-hidden-tablet.elementor-hidden-mobile .menu-item.menu-item-type-custom a.kurtosys-custom-nav__item-link.menu-image-title-after:not([href="#empty-link"]),' + '.bmo-main-navigation-primary .elementor-hidden-tablet.elementor-hidden-mobile .menu-item.menu-item-type-custom a.kurtosys-custom-nav__item-link.menu-image-title-after:not([href="#empty-link"]) + .kurtosys-custom-nav__mega-sub a'); accessibilityGroupOne.forEach(el => { el.setAttribute('tabindex', '1'); }) accessibilityGroupTwo.forEach(el => { el.setAttribute('tabindex', '2'); }) accessibilityGroupThree.forEach(el => { el.setAttribute('tabindex', '3'); }) accessibilityGroupFour.forEach(el => { el.setAttribute('tabindex', '4'); }) } accessibilityMenuIndex(); /*========== [BMO-567] Accessible Menu ==========*/ /*========== [BMO-564] accessibility Carousel ==========*/ const accessibilityCarousel = () => { const teamMemberCarousel = document.querySelector('.bmo-team-member-carousel') if (teamMemberCarousel !== null) { const teamMemberCarouselDots = teamMemberCarousel.querySelectorAll('.kurtosys-slick-dots li'); teamMemberCarouselDots.forEach((el) => { el.setAttribute('tabindex', '0'); el.addEventListener('keydown', (event) => { if (event.key === 'Enter') { el.click(); } }) }) } } accessibilityCarousel(); /*========== [BMO-564] accessibility Carousel ==========*/ /*========== [BMO-555] accessibility Login dropdown ==========*/ const accessibleLoginDropDown = () => { const menuItemLinks = document.querySelectorAll('.bmo-top-navigation .bmo-column-button-right .bmo-nav-sign + .bmo-navigation-desktop-only .bmo-button-nav .elementor-button-wrapper a[role="button"], .bmo-navigation.bmo-top-navigation.bmo-ca-top-navigation .bmo-nav-sign .menu-item.menu-item-type-custom a[role="menuitem"], .bmo-top-navigation .bmo-column-button-right .bmo-navigation-search input') const loginButton = document.querySelector('.bmo-navigation.bmo-top-navigation.bmo-ca-top-navigation .bmo-nav-sign .menu-item.menu-item-type-custom a[role="menuitem"]') if (menuItemLinks.length) { let mql = window.matchMedia('(min-width: 1024px)'); if (mql.matches) { menuItemLinks.forEach((el, index) => { el.parentElement.setAttribute('aria-expanded', "false") el.addEventListener('focus', (event) => { let { target } = event; if (el.parentElement.classList.contains('menu-item-has-children')) { target.closest('.menu-item').classList.add('hover-state') el.parentElement.setAttribute('aria-expanded', "true"); } if (el.classList.contains('kurtosys-search__field') || el.classList.contains('elementor-button-link')) { loginButton.closest('.menu-item').classList.remove('hover-state'); loginButton.closest('.menu-item').setAttribute('aria-expanded', "false") } }) }) } } } accessibleLoginDropDown(); /*========== [BMO-555] accessibility Login dropdown ==========*/ /*========== [BMO-620] Disable nav links if are triggering flyout menu ==========*/ const disableNavLinksOnFlyout = () => { const blockLink = (ev) => { const menuItems = document.querySelectorAll('.bmo-main-navigation .menu-item.menu-item-has-children, .bmo-mega-menu .bmo-product-navigation-language-toggle--mobile .menu-item.menu-item-has-children'); menuItems.forEach((item) => { if (item.contains(ev.target)) return; item.classList.remove('hover-state'); }); ev.preventDefault(); ev.stopPropagation(); let parent = ev.target.closest('.menu-item.menu-item-has-children'); parent.classList.toggle('hover-state'); }; const links = document.querySelectorAll('.bmo-main-navigation .menu-item.menu-item-has-children > a, .bmo-mega-menu .bmo-product-navigation-language-toggle--mobile .menu-item.menu-item-has-children > a'); links.forEach((link) => { link.addEventListener('touchstart', blockLink); link.addEventListener('click', blockLink); }); }; disableNavLinksOnFlyout(); /*========== [BMO-620] Disable nav links if are triggering flyout menu ==========*/ /*========== [BMO-719] Changing the placeholder in the seach field on French sites. ==========*/ if (document.querySelectorAll('[lang="fr-CA"] .kurtosys-search__field').length) { const searchInputFr = [...document.querySelectorAll('[lang="fr-CA"] .kurtosys-search__field')]; searchInputFr.map((el) => { el.placeholder = 'Recherche'; }) } /*========== [BMO-720] Category hiding in the big insight module. ==========*/ const categoryInsights = [...document.querySelectorAll('.bmo-category-listing .kurtosys-listing-grid__item.kurtosys-equal-columns .kurtosys-listing-dynamic-terms')] if(categoryInsights !== null) { categoryInsights.map((el) => { let element = [...el.querySelectorAll('span')] element.map((el) => { if(el.textContent !== 'Responsible Investment' && el.textContent !== 'Investissem*nt responsable'){ el.classList.add('bmo-category-hidden') } }) }) } // Downloading from local storage anchor token const anchor = localStorage.getItem("anchor"); if (isSelectorValid(anchor)) { const targetElement = document.querySelector(anchor); if (targetElement) { let currentScrollTop = $(window).scrollTop(); let targetScrollTop = $(targetElement).offset().top - 75; window.location.href = window.location.href + anchor; $("html, body").animate({ scrollTop: targetScrollTop }, 1000, "swing", function () { localStorage.removeItem("anchor"); }); localStorage.removeItem("anchor"); } } // I download the token answered for displaying the popup with attestation const attestation = localStorage.getItem("ksys-attestation"); if (!attestation) { document.addEventListener('ksys-apps-loaded', (e) => { const currentUrl = window.location.href; const anchorIndex = currentUrl.indexOf("#"); if (anchorIndex !== -1) { // Adding anchor values to local storage const anchor = currentUrl.substring(anchorIndex); localStorage.setItem("anchor", anchor); } }); } /** * Scrolls the page to the corresponding element when a link with a valid hash selector is clicked. * Using this technique if the html element has scroll-[padding,margin]-top set, then that is taken into account too. For this reason we overwrite the default elementor scrolling behavior */ const scrollIntoViewIfAnchor = () => { const anchorList = document.querySelectorAll('a[href^="#"]'); anchorList.forEach(link => { link.addEventListener('click', (e) => { const displayValue = window.getComputedStyle(document.querySelector(".bmo-alerts-wrapper")) .getPropertyValue("display"); if (!isSelectorValid(link.hash) || '#empty-link' === link.hash) return; const destination = document.querySelector(link.hash); if (!destination) return; e.preventDefault(); e.stopImmediatePropagation(); if(displayValue !== "none") { setTimeout(function () { const destinationRect = destination.getBoundingClientRect(); const destinationTop = destinationRect.top + window.scrollY; window.scrollTo({ top: destinationTop - 200, behavior: 'smooth' }); }, 100); } else { destination.scrollIntoView({ behavior: 'smooth' }); } }); }); } scrollIntoViewIfAnchor(); /** * Mobile tab anchors - moved from Elementor */ const mobileTabAnchors = () => { const sectionAnchorLinks = document.querySelector('.dr-anchor-links'); if(!sectionAnchorLinks) { return; } const anchorLinks = document.querySelectorAll('.dr-anchor-links-list .elementor-icon-list-text'); const anchorLinkMobile = document.querySelector('.dr-anchor-links .dr-anchor-links-mobile-tab .elementor-heading-title'); const mqDrAnchorLinks = window.matchMedia('(max-width: 1024px)'); const dropdownTrigger = document.querySelector('.dr-anchor-links .dr-anchor-links-dropdown'); const setFirstAnchorLinkValue = () => { if (!anchorLinks.length) { return false; } anchorLinkMobile.textContent = anchorLinks[0].textContent; }; const setNewActiveLink = (anchorText) => { anchorLinkMobile.textContent = anchorText; }; const handleAnchorLinkClick = (event) => { const {target} = event; setNewActiveLink(target.textContent); dropdownTrigger.classList.remove('dr-anchor-links-dropdown-active'); }; const checkMediaQueryDrPage = () => { if(mqDrAnchorLinks.matches) { sectionAnchorLinks.classList.add('dr-anchor-links-mobile-active'); setFirstAnchorLinkValue(); anchorLinks.forEach((link) => { link.addEventListener("click", handleAnchorLinkClick) }); } else { sectionAnchorLinks.classList.remove('dr-anchor-links-mobile-active'); anchorLinks.forEach((link) => { link.removeEventListener("click", handleAnchorLinkClick) }); } } checkMediaQueryDrPage(); dropdownTrigger.addEventListener('click', () => { dropdownTrigger.classList.toggle('dr-anchor-links-dropdown-active'); }) window.addEventListener('resize', debounce(checkMediaQueryDrPage, 250)); } window.addEventListener('load', mobileTabAnchors); /** * Fix for alignment of sticky Menu when scrolling */ const stickyMenuScroll = () => { const anchList = document.querySelector(".dr-anchor-links-list"); if(!anchList) { return; } window.addEventListener("scroll", debounce(function() { if(document.querySelector(".bmo-navigation-right-position").classList.contains("bmo-smaller-nav")) { anchList.classList.add("dr-anchor-links-list--small"); } else { anchList.classList.remove("dr-anchor-links-list--small"); } },100)); }; stickyMenuScroll(); // [BMO-952] Accessibility for dialog const accessibilityForDialog = () => { const dialogList = document.querySelectorAll('.dialog-lightbox-widget .dialog-close-button.dialog-lightbox-close-button'); const siteLang = document.documentElement.lang; const languages = ['en-CA', 'en-US']; let ariaLabelEn = 'Modal close button'; let ariaLabelFr = "Bouton de fermeture modale"; let ariaLabel = languages.includes(siteLang) ? ariaLabelEn : ariaLabelFr; if(dialogList.length > 0) { for (const dialog of dialogList) { dialog.setAttribute('role','button'); dialog.setAttribute('aria-label', ariaLabel); } } }; accessibilityForDialog(); // [BMO-954] Button is not reachable by the keyboard const closingAlerts = () => { const alertList = document.querySelectorAll('.bmo-alerts-listing-close') if (alertList.length === 0) return; alertList.forEach((closeButton) => { closeButton.addEventListener('keydown', (event) => { event.preventDefault(); if (event.key === 'Enter' ||event.key === " ") { closeButton.click(); } }) }) } closingAlerts(); const iconBannerPlay = document.querySelectorAll('.bmo-banner-play'); iconBannerPlay.forEach(btn => { btn.addEventListener('click', () => { setTimeout(() => { accessibilityForDialog(); }, 0); }) }) // [BMO-975] Adding a label to bmo-bio-title-listing const setAriaLabelsBioListing = () => { const bioItems = document.querySelectorAll('.bmo-bio-title-listing .kurtosys-listing-grid__item'); const siteLang = document.documentElement.lang; const languages = ['en-CA', 'en-US']; if (bioItems.length === 0) return; bioItems.forEach(item => { let name = item.querySelector('.elementor-widget-kurtosys-listing-dynamic-image + .elementor-widget-heading .elementor-heading-title').textContent; let ariaLabelEn = `Read ${name} bio`; let ariaLabelFr = `"Lire la biographie de ${name}"`; let ariaLabel = languages.includes(siteLang) ? ariaLabelEn : ariaLabelFr; item.querySelector('.bmo-button-anchor-team-member .elementor-button-link').setAttribute('aria-label', ariaLabel); }); }; setAriaLabelsBioListing(); // [BMO-1025] Expanded change of state const skipMainMenuButton = document.querySelector('.bmo-skip-to-main-content a'); const bmoBackToTopButton = document.querySelector('.bmo-back-to-top a'); bmoBackToTopButton?.addEventListener('click', () => skipMainMenuButton.focus()); // [BMO-987] Button doesn't provide enough information const setAriaMobileAttestationLinks = () => { const mobileAttestationLinks = document.querySelectorAll('.bmo-ca-top-navigation .bmo-navigation-attestation-mobile a'); const siteLang = document.documentElement.lang; const languages = ['en-CA', 'en-US']; if (mobileAttestationLinks.length === 0) return; mobileAttestationLinks.forEach(item => { const ariaLabelEn = `Change language & location`; const ariaLabelFr = `Modifier la langue et la localisation`; let ariaLabel = languages.includes(siteLang) ? ariaLabelEn : ariaLabelFr; item.setAttribute('aria-label', ariaLabel); }); }; setAriaMobileAttestationLinks(); // [BMO-1015] Content announced incorrectly by screen reader const createSpanElement = () => { const existingSpan = document.querySelectorAll('.bmo-footer .bmo-bottom-footer-menu .menu-item a span.menu-image-title'); if(existingSpan.length === 0) return; existingSpan.forEach((span) => { const newSpan = document.createElement('span'); newSpan.className = 'menu-footer-pipeline'; newSpan.setAttribute('aria-hidden', 'true'); span.appendChild(newSpan); }); }; createSpanElement(); // START BMO-998 Add aria-label to video buttons. Move the aria-label value from the video widget into the button element const addAriaLabelsToVideoButtons = () => { const buttons = document.querySelectorAll('.bmo-text-and-video-v1 .elementor-custom-embed-play') buttons.forEach(button => { const section = button.closest('.elementor-widget-video') const ariaLabel = section.getAttribute('aria-label') section.removeAttribute('aria-label') button.setAttribute('aria-label', ariaLabel) button.setAttribute('tabindex', "0") }) } addAriaLabelsToVideoButtons(); // END BMO-998 Add aria-label to video buttons. Move the aria-label value from the video widget into the button element // [BMO-986] Change in aria-expanded status const setAriaExpanded = (element, value) => { if (element) { element.setAttribute("aria-expanded", value); } }; const toggleExpandedState = (icon) => { const isExpanded = icon.getAttribute("aria-expanded") === "true"; setAriaExpanded(icon, !isExpanded); }; const hamburgerIcon = document.querySelector(".bmo-nav-mobile-hamburger .elementor-icon-wrapper a"); const closeIcon = document.querySelector(".bmo-nav-mobile-hamburger .bmo-nav-close a"); setAriaExpanded(hamburgerIcon, "false"); if (hamburgerIcon && closeIcon) { hamburgerIcon.addEventListener("click", () => toggleExpandedState(hamburgerIcon)); closeIcon.addEventListener("click", () => toggleExpandedState(hamburgerIcon)); } // [BMO-1009] Add aria label to search results buttons const addAriaLabelToSearchResultButtons = () => { const buttons = document.querySelectorAll('.bmo-search-listing .elementor-button-link'); buttons.forEach(button => { if(button.getAttribute('aria-label')) { return; } const resultContainer = button.closest('.elementor-widget-wrap'); const resultHeading = resultContainer.querySelector('.elementor-heading-title').innerText.trim(); const resultButton = button.innerText.trim(); const descriptiveLinkName = `${resultButton} ${resultHeading}`; button.setAttribute('aria-label', descriptiveLinkName); }) } jQuery(document).on('ajaxComplete', () => { if(!window.location.href.includes('/?s=')) { return; } addAriaLabelToSearchResultButtons(); }) /** * Handle Disclaimer Popups */ jQuery(document).on('elementor/popup/show', () => { /*========== Start [1378] Disclaimer popup ==========*/ const disclaimerPopup = () => { const popup = document.querySelector('.bmo-disclaimer-alternative-pages-popup') if (!popup) return const activeAttestation = document.querySelector('.attestation-hide-module') const isDisclaimerAccepted = localStorage.getItem('disclaimer-popup') const cancelBtn = document.querySelector(".bmo-disclaimer-alternative-pages-popup__cancel-button"); const acceptBtn = document.querySelector(".bmo-disclaimer-alternative-pages-popup__accept-button"); const hideElement = (element) => { if (element) { element.style.display = 'none'; } }; hideElement(activeAttestation) if (isDisclaimerAccepted) { hideElement(popup) } cancelBtn.addEventListener("click", function () { hideElement(popup) redirectToProductsHomepage() }); acceptBtn.addEventListener("click", function () { hideElement(popup) localStorage.setItem('disclaimer-popup', 'accepted'); }); } disclaimerPopup() /*========== END [1378] Disclaimer popup ==========*/ /*========== Start [1585] CDR Disclaimer popup ==========*/ const cdrDisclaimerPopup = () => { const popup = document.querySelector('.bmo-disclaimer-cdr-pages-popup'); if (!popup) return; const closeButton = popup.querySelector('.bmo-disclaimer-cdr-pages-popup__cancel-button'); const acceptBtn = popup.querySelector('.bmo-disclaimer-cdr-pages-popup__accept-button'); const activeAttestation = document.querySelector('.attestation-hide-module'); const isPopupAccepted = localStorage.getItem('is-cdr-disclaimer-popup-accepted'); const hideElement = (element) => { element.style.display = 'none'; }; hideElement(activeAttestation); if (isPopupAccepted) { hideElement(popup); return; } const handlePressEscape = (e) => { if (e.key === 'Escape') { redirectToProductsHomepage(); } }; const registerPopupListeners = () => { closeButton.addEventListener('click', () => { hideElement(popup); redirectToProductsHomepage(); }); window.addEventListener('keyup', handlePressEscape) acceptBtn.addEventListener('click', () => { hideElement(popup); localStorage.setItem('is-cdr-disclaimer-popup-accepted', 'true'); window.removeEventListener('keyup', handlePressEscape); }); }; registerPopupListeners() }; cdrDisclaimerPopup(); /*========== END [1585] CDR Disclaimer popup ==========*/ }) }); // [BMO-1024] Block quotes not implemented function accessibilityBlockquoteElement() { const blockquoteElements = document.querySelectorAll('.bmo-people-spotlight-carousel-quote .kurtosys-listing-dynamic-field__content'); blockquoteElements.forEach(function(element) { const blockquoteElem = document.createElement('blockquote'); while (element.firstChild) { blockquoteElem.appendChild(element.firstChild); } element.appendChild(blockquoteElem); }); } accessibilityBlockquoteElement(); // [BMO-983] Change list ul/li to div const accessibilityUlLiElement = () => { const liListToChange = document.querySelectorAll('.bmo-contact-us-tiles-v2 ul, .bmo-contact-us-tiles-v2 ul li, .bmo-contact-us-tiles ul, .bmo-contact-us-tiles ul li'); liListToChange.forEach(elem => { const divElement = document.createElement('div'); Array.from(elem.attributes).forEach(attribute => { divElement.setAttribute(attribute.name, attribute.value); }); while (elem.firstChild) { divElement.appendChild(elem.firstChild); } elem.parentNode.replaceChild(divElement, elem); }); } accessibilityUlLiElement(); // [BMO-1199] Add screen reader only element for the links that open in a new window const addScreenReaderOnlyElement = () => { const links = document.querySelectorAll('a[target="_blank"]') const siteLang = document.documentElement.lang const languages = ['en-CA'] const EN = 'opens in new window' const FR = 's’ouvre dans une nouvelle fenêtre' const info = languages.includes(siteLang) ? EN : FR links.forEach(link => { const srOnlyElement = document.createElement('span') srOnlyElement.setAttribute('aria-hidden', 'true') srOnlyElement.classList.add('sr-only') srOnlyElement.textContent = info link.appendChild(srOnlyElement) }) } addScreenReaderOnlyElement() // [BMO-1020] Toggle Tip is not keyboard accessible const ToggleTip = () => { const bmoTooltip = document.querySelectorAll('.bmo-tooltip'); if (bmoTooltip.length === 0) return; let activeButton = null; const addTooltipAttributes = () => { bmoTooltip.forEach(tooltip => { tooltip.setAttribute('tabindex', '0'); tooltip.setAttribute('role', 'button'); tooltip.setAttribute('aria-expanded', 'false'); tooltip.setAttribute('aria-describedby', 'Click the spacebar to open or close the tootip'); }); }; const toggleTooltipClass = (button) => { if (activeButton !== button) { if (activeButton) { activeButton.classList.remove('bmo-tooltip-open'); activeButton.setAttribute('aria-expanded', 'false'); } button.classList.add('bmo-tooltip-open'); button.setAttribute('aria-expanded', 'true'); activeButton = button; } else { button.classList.remove('bmo-tooltip-open'); button.setAttribute('aria-expanded', 'false'); activeButton = null; } }; const attachEventListeners = () => { bmoTooltip.forEach(button => { button.addEventListener('click', () => toggleTooltipClass(button)); button.addEventListener('keydown', (event) => { if (event.key === 'Enter' || event.key === ' ' || event.key === 'Escape') { event.preventDefault(); toggleTooltipClass(button); } }); }); const bmoTooltipTextLinks = document.querySelectorAll('.bmo-tooltiptext a'); bmoTooltipTextLinks.forEach(link => { link.addEventListener('keydown', (event) => { if (event.key === 'Tab') { event.preventDefault(); bmoTooltip[0].focus(); } }); }); }; addTooltipAttributes(); attachEventListeners(); }; ToggleTip(); }); var heights = []; function heightBox() { jQuery( ".bmo-insight-banner-carousel .timeline-content-single .bmo-listing-article-banner-corusel" ).each(function() { heights.push(jQuery(this).outerHeight()); }); var maxHeight = Math.max.apply(null, heights); jQuery( ".bmo-insight-banner-carousel .timeline-content-single .bmo-listing-article-banner-corusel" ).css("min-height", maxHeight); } setTimeout(function() { heightBox(); }, 1); jQuery(window).on( "resize", debounce(function() { jQuery( ".bmo-insight-banner-carousel .timeline-content-single .bmo-listing-article-banner-corusel" ).css("min-height", "auto"); heights = []; heightBox(); }, 100) ); /*========== Linkedin functionality ==========*/ if (jQuery(".bmo-team-member-listing").length > 0) { jQuery(".bmo-team-member-listing").each(function() { var $name = jQuery(this).find( ".bmo-team-member-listing-name .elementor-heading-title" ), $shortPosition = jQuery(this).find( ".bmo-team-member-listing-short-position .elementor-heading-title" ), $linkedinButton = jQuery(this).find( ".bmo-team-member-listing-linkedin a .elementor-button-text" ); if ( jQuery(this) .find(".bmo-team-member-listing-linkedin a") .attr("href") === undefined ) { jQuery(this).find(".bmo-team-member-listing-linkedin").remove(); } $linkedinButton.text( $linkedinButton.text() + $name.text() + $shortPosition.text() ); }); } /*========== End Linkedin functionality ==========*/ /*========== Insights filters ==========*/ jQuery("
").prependTo( ".bmo-global-filters" ); jQuery(".bmo-button-show-hide a.elementor-button").on("click", function() { var filterList = jQuery( ".bmo-filters-styles .elementor-inner-section.bmo-show-checkbox-section" ), buttonList = jQuery( ".bmo-button-show-hide a.elementor-button > span > span:nth-child(2)" ), buttonShowList = jQuery(".bmo-show-button-display"), buttonHideList = jQuery(".bmo-hide-button-display"); buttonShowList.toggleClass("showButton"); buttonHideList.toggleClass("showButton"); jQuery(".button-reset-filters").toggleClass("filtersActive"); if (filterList.hasClass("filtersActive")) { filterList.removeClass("filtersActive"); } else { filterList.addClass("filtersActive"); } }); var $filterCheckboxButton = jQuery( ".bmo-filters-styles .kurtosys-checkboxes-list .kurtosys-checkboxes-list__row label .kurtosys-checkboxes-list__input" ), buttonReset = jQuery(".button-reset-filters"); buttonReset.on("click", function() { var filtersBox = jQuery(".filtersBox"); filtersBox.find(".filterItemAbove").remove(); filtersBox.removeClass("filtersBoxHeight"); }); $filterCheckboxButton.on("click", function() { var $filterLabel = jQuery(this) .siblings(".kurtosys-checkboxes-list__label") .text(), // Get filter label text filtersBox = jQuery(".filtersBox"), $dropdownFilterVal = jQuery(this).attr("value"), // Get checkbox dropdown value $filterAbove = jQuery( '
' + $filterLabel + '
' ); // Add checkbox value to the filter label el above dropdown /* If checkbox is checked */ if (jQuery(this).is(":checked")) { filtersBox.append($filterAbove); // Add clicked filter label above dropdown filtersBox.addClass("filtersBoxHeight"); } else { jQuery( '.filterItemAbove[value="' + $dropdownFilterVal + '"]' ).remove(); // If clicked again - remove //checking if item is lastchild in filter box above if (filtersBox.is(":empty")) { filtersBox.removeClass("filtersBoxHeight"); //closing filter box above } } /* On click event on filter above dropdown */ $filterAbove.find(".close-button").on("click", function() { $aboveCheckboxVal = jQuery(this) .closest(".filterItemAbove") .attr("value"); // Get value of above filter label el $dropdownCheckbox = jQuery( '.bmo-filters-styles .kurtosys-checkboxes-list__input[value="' + $aboveCheckboxVal + '"]' ); // Find dropdown el with same val as above el /* If both val equals */ if ($aboveCheckboxVal === $dropdownFilterVal) { $dropdownCheckbox.removeAttr("checked").trigger("change"); // Remove 'checked' value and trigger filter event } jQuery(this).closest(".filterItemAbove").remove(); // remove clicked filter above el //checking if filterbox above is empty - to remove class if (jQuery(".filtersBox").is(":empty")) { jQuery(".filtersBox").removeClass("filtersBoxHeight"); //closing filter box above } }); }); var $filterInput = jQuery(".bmo-filters-styles .bmo-filters-search input"), // filter input $flag = false, $typingTimer, //timer identifier $doneTypingInterval = 500, e = jQuery.Event("keypress"); e.which === "Enter"; // enter key e.key === "Enter"; //on keyup, start the countdown $filterInput.on("keyup", function() { clearTimeout($typingTimer); if ($filterInput.val()) { // if there's text inside input $typingTimer = setTimeout(doneTyping, $doneTypingInterval); } else if ($filterInput.val() === "") { // if user removes text from input $filterInput.trigger(e); jQuery(".filter-typed-value").remove(); $flag = false; } }); //function when user finishes typing function doneTyping() { $filterInput.trigger(e); var $filterInputText = $filterInput.val(), // get input string $filterTypedAbove = jQuery( '
' ); if ($flag === false) { jQuery(".filtersBox").append($filterTypedAbove); $flag = true; } jQuery(".filter-typed-value") .text($filterInputText) .append('
'); // add text on the box above jQuery(".filtersBox").addClass("filtersBoxHeight"); jQuery(".filter-typed-value .close-button").on("click", function() { jQuery(".filter-typed-value").remove(); $filterInput.val(""); $filterInput.trigger(e); $flag = false; }); } /* filter error message change */ jQuery(document).on("kurtosys-filter-loaded", function() { jQuery(".bmo-filters-styles .kurtosys-listing-not-found").addClass( "messageOpacity" ); /*========== Insights tag hide function - asset class / content category ==========*/ hideInsightTag(); /*========== End Insights hide tag function - asset class / content category ==========*/ }); /*========== End Insights filters ==========*/ /*========= START Aria for filters ==========*/ const addAriaSummaryForListingGrid = () => { const createElement = () => { const elementToInsert = document.createElement('div'); elementToInsert.classList.add('listing-grid-summary-for-sr', 'sr-only') elementToInsert.setAttribute('role', 'alert') elementToInsert.setAttribute('aria-live', 'polite') return elementToInsert; } const insertSummaryElement = () => { const listingGrids = document.querySelectorAll('.elementor-widget-kurtosys-listing-grid') listingGrids.forEach(listing => { listing.appendChild(createElement()) }) } const injectMessage = (listingId, message) => { const listingGrid = document.querySelector(`#${listingId}`) if (!listingGrid) return const summaryInfo = listingGrid.querySelector('.listing-grid-summary-for-sr') summaryInfo.textContent = message } let foundPosts = ""; const updateSummaryFoundPostsMessage = (event, provider, query, providerName, listingId) => { foundPosts = query.listingGridWpQueryArgs.found_posts const message = `${0 === foundPosts ? 'No' : foundPosts} results found`; injectMessage(listingId, message) } const updateSummaryResetFiltersMessage = (e) => { const listingId = e.target.getAttribute('data-query-id') injectMessage(listingId, `Filters remove`) } insertSummaryElement() jQuery(document).on("kurtosys-filter-content-rendered", updateSummaryFoundPostsMessage) jQuery(".kurtosys-remove-all-filters__button").on('click', updateSummaryResetFiltersMessage) } addAriaSummaryForListingGrid() const updateSearchCounterAria = () => { const tabs = document.querySelectorAll('.search-results-tabs .kurtosys-tabs__control') const tabsContent = document.querySelectorAll('.search-results-tabs .kurtosys-tabs__content') tabs.forEach((tab, index) => { tab.addEventListener('click', () => { const resultCounter = tabsContent[index].querySelector('.listing-grid-summary-for-sr') // Clear the content and inject value to updates/notifications explicitly for screen readers const value = resultCounter.innerHTML resultCounter.innerHTML = "" resultCounter.innerHTML = value }) }) } updateSearchCounterAria() /*========= END Aria for filters ==========*/ /*========= Contact form Global function ==========*/ var textInput = jQuery(".bmo-contact-form-styles .elementor-field-textual"), inputLabel = jQuery(".elementor-field-label"); jQuery(".bmo-contact-form-styles .elementor-form").attr("novalidate", ""); textInput.on("focus", function() { jQuery(this).siblings(inputLabel).addClass("inputActive"); }); textInput.on("focusout", function() { if (jQuery(this).val()) { jQuery(this).siblings(inputLabel).addClass("inputActive"); } else { jQuery(this).siblings(inputLabel).removeClass("inputActive"); } }); /*========= End Contact form Global function =========*/ /*========= Communique email validator =========*/ function removeLabelClass() { var thisContactForm = jQuery( ".elementor-message.elementor-message-success" ).parents(".bmo-contact-form-styles"); setTimeout(function() { if ( jQuery(".bmo-contact-form-styles").find( ".elementor-message.elementor-message-success" ).length === 1 ) { jQuery(".elementor-field-textual").each(function() { if (!jQuery(this).val()) { jQuery(this) .siblings(".elementor-field-label") .removeClass("inputActive"); } }); } }, 5000); } jQuery(this) .find( ".elementor-field-group.elementor-column.elementor-field-type-submit .elementor-button" ) .on("click", function() { var $singUpForm = jQuery(this) .closest(".bmo-contact-form-styles") .find(".elementor-form"), $singUpFormInput = jQuery(this) .closest(".bmo-contact-form-styles") .find(".elementor-field-textual"), $containerEmailInput = jQuery(this) .closest(".bmo-contact-form-styles") .find("form .elementor-field-type-email"), $singUpEmailInput = jQuery(this) .closest(".bmo-contact-form-styles") .find( ".elementor-field-type-email .elementor-field-textual" ), $thisSiblingsLabel = jQuery(this).siblings( ".elementor-field-label" ); $singUpForm.attr("novalidate", ""); $singUpFormInput.on("focus", function() { $thisSiblingsLabel.addClass("inputActive"); }); $singUpFormInput.on("focusout", function() { if (jQuery(this).val()) { $thisSiblingsLabel.addClass("inputActive"); } else { $thisSiblingsLabel.removeClass("inputActive"); } }); function isEmail() { var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/, emailValidationMessage = jQuery( ".elementor-element.elementor-widget.elementor-widget-form" ).attr("data-email-validation-message"), emailValidationDefaultError = jQuery( ".elementor-field-type-email .elementor-message.elementor-message-danger.elementor-help-inline.elementor-form-help-inline" ).text(); if (regex.test($singUpEmailInput.val())) { return; } else if ($singUpEmailInput.val() === "") { jQuery( ".elementor-field-type-email .elementor-message.elementor-message-danger.elementor-help-inline.elementor-form-help-inline" ).text(emailValidationDefaultError); } else { jQuery( ".elementor-field-type-email .elementor-message.elementor-message-danger.elementor-help-inline.elementor-form-help-inline" ).text(emailValidationMessage); } } function checkEmailAfterSend() { if ($singUpEmailInput.val()) { new MutationObserver(function(mutations) { isEmail(); }).observe($containerEmailInput[0], { childList: true, }); } } removeLabelClass(); checkEmailAfterSend(); }); /*========= End Communique email validator =========*/ /*========== Module [38] Change src in popup from attribute bmo-iframe-link ==========*/ jQuery(".bmo-popup-button").on("click", function() { var iframeSrc = jQuery(this).attr("bmo-iframe-link"); setTimeout(function() { jQuery(".bmo-popup-model iframe").attr("src", iframeSrc); }, 100); }); /*========== End Module [38] Change src in popup from attribute bmo-iframe-link ==========*/ // Add date to disclaimer var $disclaimerDate = jQuery(".bmo-disclaimer-date"), $currentTime = new Date(), $currentYear = $currentTime.getFullYear(); $disclaimerDate.text($currentYear); // Dropdown disclaimer - load more btn var $disclaimerBtn = jQuery(".bmo-footer-more-btn .elementor-button"), $disclaimerMaxHeight = jQuery( ".bmo-disclaimer-long .elementor-text-editor" ), $disclaimerArrow = $disclaimerBtn.find("i"); $disclaimerBtn.on("click", function() { $disclaimerArrow.toggleClass("bmo-rotate-arrow"); minimumHeight = 335; // get current height currentHeight = $disclaimerMaxHeight.innerHeight(); // get height with auto applied autoHeight = $disclaimerMaxHeight.css("height", "auto").innerHeight(); // reset height and revert to original if current and auto are equal $disclaimerMaxHeight.css("height", currentHeight).animate({ height: currentHeight == autoHeight ? minimumHeight : autoHeight, }); }); // back to top button var $backToTopBtn = jQuery( ".bmo-back-to-top-btn .elementor-widget-container" ), $backToTopText = jQuery(".bmo-back-to-top-text"), $scrollPxMeasure = jQuery(document).scrollTop(); $backToTopBtn .on("mouseenter ", function() { $backToTopText.addClass("back-to-top-text-display"); }) .on("mouseout", function() { $backToTopText.removeClass("back-to-top-text-display"); }) .on("click", function() { window.scrollTo({ top: 0, behavior: "smooth", }); }); if ($scrollPxMeasure > 800) { $backToTopBtn.fadeIn(); } jQuery(window).on( "scroll", debounce(function() { var $pxAfterScrolling = jQuery(this).scrollTop(); if ($pxAfterScrolling > 800) { $backToTopBtn.fadeIn(); } else { $backToTopBtn.fadeOut(); $backToTopText.removeClass("back-to-top-text-display"); } }, 100) ); /*========== [103] Text boxes v5 ==========*/ if (jQuery(window).width() > 1024) { function equalHeightSmallBoxv5() { var boxDescription = jQuery(".bmo-text-boxes-v5-box-equal"); var maxHeightDescription = Math.max.apply( null, boxDescription .map(function() { jQuery(this).css("height", ""); return jQuery(this).outerHeight(); }) .get() ); boxDescription.css("height", maxHeightDescription); } equalHeightSmallBoxv5(); jQuery(window).on("resize", debounce(equalHeightSmallBoxv5, 150)); } /*========== End [103] Text boxes v5 ==========*/ /*========== Insights tag hide function - asset class / content category ==========*/ function hideInsightTag() { var assetClassTag = jQuery( ".bmo-insight-tag-asset-class .kurtosys-listing-dynamic-terms" ), contentCategoryTag = jQuery(".bmo-insight-tag-content-category"); assetClassTag.each(function() { if (jQuery(this).is(":empty")) { jQuery(this).addClass("hideInsightTag"); } else { jQuery(this).removeClass("hideInsightTag"); jQuery(this) .parents(".bmo-insight-tag-asset-class") .siblings(contentCategoryTag) .addClass("hideInsightTag"); } }); } /*========== End Insights hide tag function - asset class / content category ==========*/ /*========== [124] Quick links with view more button ==========*/ /* hide 'view-more' button if less than 4 links*/ function setListHeight() { if (jQuery(".bmo-quick-links-view-more-button")) { jQuery( ".bmo-quick-links-view-more-button .elementor-icon-list-items" ).each(function() { var linksNumbers = jQuery(this).children().length, $quickLinksList = jQuery(this).closest( ".elementor-widget.elementor-widget-icon-list" ); if (linksNumbers < 5) { jQuery(this) .closest(".elementor-widget-icon-list") .siblings(".bmo-button-v6.bmo-quick-links-button") .addClass("linksHideButton"); } else if (!$quickLinksList.hasClass("listOpen")) { /* get height of first 4 elements, to set list max-height and hide other quick links */ var $outerHeight = 1; jQuery(this) .find(".elementor-icon-list-item") .slice(0, 4) .each(function() { $outerHeight += jQuery(this).outerHeight(); /* add height attribute to save list default height */ $quickLinksList.attr("listHeight", $outerHeight); $quickLinksList.css( "max-height", $outerHeight + 2 + "px" ); }); } }); } } setListHeight(); jQuery(window).on("resize", debounce(setListHeight, 250)); /* button click show/hide other quick links */ jQuery(".bmo-quick-links-button").on("click", function() { var $quickLinksContainer = jQuery(this).siblings( ".elementor-widget.elementor-widget-icon-list" ); if (jQuery(this).hasClass("activeQuickLinks")) { jQuery(this).removeClass("activeQuickLinks"); jQuery(this).toggleClass("bmo-hide-button"); jQuery(this) .siblings(".bmo-quick-links-button") .toggleClass("bmo-hide-button"); /*get initial height of list from attribute (hide other quicklinks)*/ var thisHeight = $quickLinksContainer.attr("listheight"); $quickLinksContainer.css("max-height", thisHeight + "px"); $quickLinksContainer.removeClass("listOpen"); setListHeight(); } else { jQuery(this) .siblings(".bmo-quick-links-button") .addClass("activeQuickLinks"); jQuery(this).toggleClass("bmo-hide-button"); jQuery(this) .siblings(".bmo-quick-links-button") .toggleClass("bmo-hide-button"); /*set list height to 100% (show other quicklinks)*/ $quickLinksContainer.css("max-height", "100%"); $quickLinksContainer.addClass("listOpen"); } }); /*========== End [124] Quick links with view more button ==========*/ /*========== [126] Fund links (view more) ==========*/ function setFundListHeight() { if (jQuery(".bmo-fund-list-column").length > 0) { var outerHeight = 180, column = jQuery( ".bmo-fund-list-column .bmo-fund-links-2-columns" ); column.slice(0, 4).each(function() { outerHeight += jQuery(this).outerHeight(); }); if (column.length < 4) { jQuery(this) .closest(".bmo-fund-links-button") .css("display", "none"); } else if ( !jQuery(".bmo-fund-links .elementor-widget-wrap").hasClass( "fundListOpen" ) ) { column.slice(4, 20).each(function() { jQuery(this).css("display", "none"); jQuery(".bmo-fund-links .elementor-widget-wrap").css( "max-height", outerHeight + "px" ); }); } } } setFundListHeight(); jQuery(window).on("resize", debounce(setFundListHeight, 250)); jQuery(".bmo-fund-links-button a").on("click", function() { var fundLinksList = jQuery(".bmo-fund-links .elementor-widget-wrap"); jQuery(".bmo-fund-links .bmo-fund-links-2-columns") .slice(4, 20) .each(function() { jQuery(this).css("display", "block"); }); if (jQuery(this).hasClass("activeFundLinks")) { jQuery(this).removeClass("activeFundLinks"); jQuery(this).parent().parent().parent().addClass("bmo-hide-button"); jQuery(".bmo-fund-links-button.bmo-view-more-button").removeClass( "bmo-hide-button" ); fundLinksList.removeClass("fundListOpen"); setFundListHeight(); } else { jQuery(this).parent().parent().parent().addClass("bmo-hide-button"); jQuery(".bmo-fund-links-button.bmo-view-less-button a").addClass( "activeFundLinks" ); jQuery( ".bmo-fund-links .bmo-view-less-button.bmo-hide-button" ).removeClass("bmo-hide-button"); fundLinksList.css("max-height", "100%"); fundLinksList.addClass("fundListOpen"); } }); /*========== End [126] Fund links (view more) ==========*/ /*===========[139] Timeline ==========*/ jQuery(".bmo-timeline-desktop").each(function() { var amountOfCards = jQuery(this).find( ".kurtosys-hor-timeline-item__card" ).length; jQuery(this) .find( ".kurtosys-hor-timeline-track .kurtosys-hor-timeline-list .kurtosys-hor-timeline-item" ) .css({ flex: "0 0 calc(100%/" + amountOfCards + ")", "max-width": "calc(100%/" + amountOfCards + ")", }); var $this = jQuery(this), startAnimation = function() { var hT = $this.offset().top, hH = $this.outerHeight() - 150, wH = jQuery(window).height(), wS = $this.scrollTop(); if (hT > wS) { $this.addClass("bmo-timeline-animation"); } }; startAnimation(); jQuery(window).on( "scroll", debounce(function() { startAnimation(); }, 100) ); var amountOfCardsAnimation = jQuery(this).find( ".kurtosys-hor-timeline-item" ).length; delay = 600; for (i = 0; i < amountOfCardsAnimation; i++) { jQuery(this) .find( ".kurtosys-hor-timeline-list--top .kurtosys-hor-timeline-item" ) .eq(i) .css("transition-delay", delay + "ms"); delay += 50; jQuery(this) .find( ".kurtosys-hor-timeline-list--bottom .kurtosys-hor-timeline-item" ) .eq(i) .css("transition-delay", delay + "ms"); delay += 50; } }); //custom dots var colorOfThePoint = jQuery( ".kurtosys-hor-timeline-item__point-content" ).css("background-color"); jQuery(".kurtosys-hor-timeline-item__card").append( "
" ); //hover on link jQuery(".kurtosys-hor-timeline-item__card-desc a").on( "hover", function() { jQuery(this) .closest(".kurtosys-hor-timeline-item__card-inner") .find("h3") .addClass("bmo-timeline-marked-title"); }, function() { jQuery(this) .closest(".kurtosys-hor-timeline-item__card-inner") .find("h3") .removeClass("bmo-timeline-marked-title"); } ); /*========== End Cominucat email validator ==========*/ /*========== [155] Glossary ==========*/ if (jQuery(".bmo-glossary").length > 0) { function removeEmptyImage() { jQuery(".bmo-glossary img").each(function() { if (!jQuery(this).attr("src").includes("http")) { jQuery(this).remove(); } }); } jQuery(document).on("ready", removeEmptyImage); } /*========== End Glossary ==========*/ /*========== [194] and [195] repair module after resize ===========*/ if (jQuery(".bmo-slider-with-content-from-template").length > 0) { var flag = true; jQuery(window).on( "resize", debounce(function() { if (jQuery(this).width() >= 1025) { flag = true; } if (flag) { if (jQuery(window).width() < 1025) { jQuery( ".bmo-slider-with-content-from-template .slick-track" ).css({ width: "1000px", }); setTimeout(function() { jQuery( ".bmo-slider-with-content-from-template .slick-active" ).trigger("click"); flag = false; }, 100); } } }, 250) ); } /*========== End [194] and [195] repair module after resize ===========*/ /*========== [195] Tabs with image and text v2 ==========*/ //mobile equal height with slider in tabs function equalHeightSmallBox() { var boxDescription = jQuery( ".bmo-equal-tabs-height-mobile .slick-slider .slick-list.draggable .slick-track .slick-slide section > .elementor-row" ); var maxHeightDescription = Math.max.apply( null, boxDescription .map(function() { jQuery(this).css("height", ""); return jQuery(this).outerHeight(); }) .get() ); boxDescription.css("height", maxHeightDescription); } equalHeightSmallBox(); jQuery(window).on( "resize", debounce(function() { equalHeightSmallBox(); }, 250) ); /*========== End [195] Tabs with image and text v2==========*/ /*========== Single bio template - empty element padding ==========*/ if ( jQuery( ".bmo-team-member-static .bmo-single-logo .kurtosys-listing-dynamic-image.kurtosys-listing" ).is(":empty") ) { jQuery( ".bmo-team-member-static .bmo-single-logo .elementor-widget-container" ).css("padding", "0"); } /*========== End Single bio template - empty element padding==========*/ /*========== [205] Investment Team ==========*/ if (jQuery(".bmo-portfolio-managers-listing").length > 0) { var elementEquealHeight = jQuery( ".bmo-portfolio-managers-listing .bmo-team-member-listing-description-column" ); var maxColumnHeight = 0; function equalColumn() { jQuery(elementEquealHeight).each(function() { if (jQuery(this).height() > maxColumnHeight) { maxColumnHeight = jQuery(this).height(); } }); elementEquealHeight.css("min-height", maxColumnHeight); } equalColumn(); jQuery(window).on( "resize", debounce(function() { equalColumn(); }, 250) ); } /*========== End [205] Investment Team ==========*/ /*========== [220] Team members in accordion ==========*/ if (jQuery(".bmo-team-members-in-accordion").length > 0) { var accordionTab = jQuery(".kurtosys-accordion__item.kurtosys-toggle"); function focusAccordionTab() { accordionTab.each(function() { if (jQuery(this).hasClass("active-toggle")) { jQuery(this).find("a").removeAttr("tabindex"); } else { jQuery(this).find("a").attr("tabindex", "-1"); } }); } focusAccordionTab(); accordionTab.each(function() { jQuery(this).on("click", function() { focusAccordionTab(); }); }); } /*========== End [220] Team members in accordion ==========*/ /*========== [237] Insights filter v1 ==========*/ var inputs = jQuery( ".bmo-237-filter .kurtosys-filter input.kurtosys-checkboxes-list__input" ), inputRange = jQuery( ".bmo-filters-insight-version-3 .elementor-widget-ksys-smart-filters-date-range .ksys-smart-filters-date-range .kurtosys-date-range input" ), inputRangeFrom = jQuery( ".bmo-filters-insight-version-3 .elementor-widget-ksys-smart-filters-date-range .ksys-smart-filters-date-range .kurtosys-date-range input.kurtosys-date-range__from" ), inputRangeTo = jQuery( ".bmo-filters-insight-version-3 .elementor-widget-ksys-smart-filters-date-range .ksys-smart-filters-date-range .kurtosys-date-range input.kurtosys-date-range__to" ), arrayToChecked = [], appButton = jQuery( ".bmo-filters-insight-version-3 button.apply-filters__button" ), searchInput = jQuery( ".bmo-filters-insight-version-3 .bmo-filters-search .kurtosys-search-filter .kurtosys-search-filter__input" ); function setChecboxes() { var isChecked = jQuery(this) .siblings( ".bmo-filters-insight-version-3 .kurtosys-checkboxes-list__label" ) .text(); if ( typeof jQuery(this).closest("[data-filter-value]") !== "undefine" && jQuery(this).closest("[data-filter-value]") !== null ) { var keyParameter = jQuery(this) .closest("[data-filter-value]") .attr("data-filter-value"); } if (!keyParameter) { keyParameter = "filter"; } var getParamNotEmpty = getParameter(keyParameter); if (jQuery(this).is(":checked")) { if (getParamNotEmpty) { getParamNotEmpty = getParamNotEmpty + "|" + isChecked; arrayToChecked.push({ key: keyParameter, value: getParamNotEmpty, }); } else { arrayToChecked.push({ key: keyParameter, value: isChecked }); } setParameters(arrayToChecked, true); } else { if (getParameter(keyParameter)) { const query = getParamNotEmpty .split("|") .filter((item) => item !== isChecked) .join("|"); setParameter(keyParameter, query, true); if (query.length === 0) { deleteParameter(keyParameter, true); } } } } function inputsRange(input, parametr) { if (input.val() !== "") { setParameter(parametr, input.val(), true); } else { deleteParameter(parametr, true); } } jQuery(window).on("elementor/frontend/init", function() { var getParametersValue = getParameters(); for (let item of getParametersValue) { var currentItem = jQuery( '.bmo-237-filter [data-filter-value="' + item.value + '"] input' ); var splitItem = item.value.split("|"); if (currentItem.length !== 0) { currentItem.each(function() { if ( splitItem.indexOf( jQuery(this) .siblings(".kurtosys-checkboxes-list__label") .text() ) != -1 ) { jQuery(this).attr("checked", true); } }); } else { jQuery(".bmo-237-filter .kurtosys-filter input").each( function() { if ( splitItem.indexOf( jQuery(this) .siblings( ".kurtosys-checkboxes-list__label" ) .text() ) != -1 ) { jQuery(this).attr("checked", true); } } ); } } setTimeout(function() { appButton.trigger("click"); }, 0); }); function searchParamSet() { setParameter("search filter", searchInput.val(), true); } function searchParamDelete() { if (!searchInput.val()) { deleteParameter("search filter", true); } } jQuery(window).on("elementor/frontend/init", function() { if (getParameter("search filter")) { searchInput.val(getParameter("search filter")); setTimeout(function() { appButton.trigger("click"); }, 0); } if (getParameter("sort date from")) { inputRangeFrom.val(getParameter("sort date from")); } if (getParameter("sort date to")) { inputRangeTo.val(getParameter("sort date to")); } }); function applyButtonFilter() { setTimeout(function() { appButton.trigger("click"); }, 0); } jQuery(".bmo-smart-remove-filters").on("click", function() { var getkeyToRemove = getParameters(); var arrayToRemove = []; for (let itemToRemove of getkeyToRemove) { arrayToRemove.push(itemToRemove.key); deleteParameters(arrayToRemove, true); } }); searchInput.on("keyup", searchParamSet); searchInput.on("keyup", searchParamDelete); searchInput.on("change", searchParamSet); inputs.on("change", setChecboxes); inputs.on("change", applyButtonFilter); inputRangeFrom.on("change", function() { inputsRange(inputRangeFrom, "sort date from"); }); inputRangeTo.on("change", function() { inputsRange(inputRangeTo, "sort date to"); }); /*========== End [237] Insights filter v1==========*/ /*========== [240] Small filters for Properties ==========*/ function bmoSmartFilter() { var select = jQuery(".filter-select-240 option:selected"); setParameter("postsfilter=category", select.text(), true); } jQuery(window).on("elementor/frontend/init", function() { var select = jQuery(".filter-select-240 select"); var applyButton = jQuery(".filter-select-240 button"); if (getParameter("postsfilter=category")) { jQuery(".filter-select-240 option").each(function() { if ( jQuery(this).text() === getParameter("postsfilter=category") ) { select.val(jQuery(this).attr("value")); } }); setTimeout(function() { applyButton.trigger("click"); }, 0); } applyButton .off(".bmoFilterEvent") .on("click.bmoFilterEvent", bmoSmartFilter); }); /*========== End [240] Small filters for Properties ==========*/ /*========== [248] Nested Chart ==========*/ function openAccordion() { jQuery("button.box-title").click(function(e) { e.preventDefault(); var $this = jQuery(this); $this.parent().next().children(".card-body").slideToggle(350); }); jQuery("a.box-title").click(function(e) { e.preventDefault(); var $this = jQuery(this); $this.parent().parent().children(".card-body").slideToggle(350); }); } openAccordion(); /*========== End [248] Nested Chart ==========*/ /*========== [250] Register form ==========*/ //add class inputActive to select list jQuery( ".bmo-register-form .elementor-widget-form .elementor-field-type-select select" ).on("click", function() { jQuery(this) .closest(".elementor-field-type-select") .find("label") .addClass("inputActive"); }); //select first element empty jQuery(".bmo-register-form .elementor-widget-form select").prop( "selectedIndex", -1 ); /*========== End [250] Register form==========*/ /*========== [278] 404 Page ==========*/ var button404Href = jQuery(".bmo-site-url a").attr("href"); jQuery(".bmo-404-home-page-button a").attr("href", button404Href); /*========== End [278] 404 Page==========*/ /*========== [287] Dynamic Author ==========*/ if (jQuery(".bmo-dynamic-author-listing")) { // Get text button from option page var buttonText = jQuery(".bmo-dynamic-author-button-hidden").text(); jQuery(".bmo-dynamic-author-listing .dynamic-author").each(function() { // Get href to Member page var hrefMemberPage = jQuery(this) .find(".kurtosys-dynamic-author-name a") .attr("href"); // Append button to all authors with link to member page jQuery(this) .find(".kurtosys-dynamic-author-info") .append( ` ${buttonText} ` ); }); } /*========== End [287] Dynamic Author ==========*/ /*========== [290] Audio player - version 2 ==========*/ if (jQuery(".bmo-audio-section")) { jQuery(function($) { var linkAudio = jQuery(".bmo-new-audio audio").attr("src"); jQuery(".bmo-audio-section .bmo-new-audio-icon a").attr( "href", linkAudio ); jQuery(".bmo-audio-share-main").on("click", function() { jQuery(".bmo-audio-share-child").toggleClass( "bmo-audio-change-width" ); }); }); } /*========== End [290] Audio player - version 2==========*/ /*========== [297] Investment graph ==========*/ jQuery(".bmo-investment-graph .elementor-inner-column").on( "mouseenter", function() { var elementNumber = jQuery(this).attr("data-element-number"); jQuery(this) .find(".bmo-shadow-hover") .find(".elementor-heading-title") .addClass("bmo-column-circle-shadow"); jQuery(".bmo-investment-graph .inner-title-below").each( function() { if ( jQuery(this).attr("data-element-number") === elementNumber ) { jQuery(this).find("p").css("opacity", "1"); } } ); } ); /*========== End [297] Investment graph==========*/ /*========== [300] Tabs container with icons ==========*/ function changeTab() { var iconTab = jQuery(".focusTab").attr("data-number"); jQuery(".kurtosys-tabs__control-wrapper .kurtosys-tabs__control").each( function() { if (jQuery(this).attr("data-tab") == iconTab) { jQuery(this).siblings().removeClass("active-tab"); jQuery(this).addClass("active-tab"); } } ); jQuery(".kurtosys-tabs__content-wrapper .kurtosys-tabs__content").each( function() { if (jQuery(this).attr("data-tab") == iconTab) { jQuery(this).siblings().removeClass("active-content"); jQuery(this).addClass("active-content"); } } ); } var circleButtonLink = jQuery(".bmo-circle-icon .bmo-button-link"); circleButtonLink.on("click", function() { changeTab(); }); function equalHeightTabBox() { var boxTab = jQuery( ".bmo-tabs-container-with-icons .kurtosys-tabs__control-wrapper .kurtosys-tabs__control" ); var maxHeightDescription = Math.max.apply( null, boxTab .map(function() { jQuery(this).css("height", ""); return jQuery(this).outerHeight(); }) .get() ); boxTab.css("height", maxHeightDescription); } equalHeightTabBox(); jQuery(window).on( "resize", debounce(function() { equalHeightTabBox(); }, 250) ); circleButtonLink.on("focus", function() { jQuery(this).siblings(".bmo-tablinks").addClass("focusTab"); }); circleButtonLink.on("focusout", function() { jQuery(this).siblings(".bmo-tablinks").removeClass("focusTab"); }); jQuery(document).on("keypress", function(e) { if (e.key === "Enter" && jQuery(".focusTab")) { changeTab(); } }); /*========== End [300] Tabs container with icons =========*/ /*========== [304] Flip Cards ==========*/ jQuery(".flip-card-inner").on("click", function() { jQuery(this).closest(".flip-card-inner").toggleClass("active"); }); /*========== End [304] Flip Cards ==========*/ /*========== Search Results Page ==========*/ //escape elemnts function HTMLescape(html) { return document .createElement("div") .appendChild(document.createTextNode(html)).parentNode.innerHTML; } if (document.body.classList.contains("search")) { //get query string from url const params = new URLSearchParams(window.location.search); let param = params.get("s"); param = HTMLescape(param); jQuery(window).on("elementor/frontend/init", function() { elementorFrontend.on("components:init", function() { //add query string to frontend if (param !== "undefined" && param != null) { document.querySelector(".bmo-search-title h1").innerHTML += "" + ' "' + param + '"' + ""; let filters = document.querySelectorAll( ".kurtosys-search-filter__input" ); filters.forEach((element) => { setTimeout(() => { element.value = param; element .closest(".kurtosys-search-filter") .querySelector(".kurtosys-search-filter__submit") .click(); }, 500) }); } }); }); jQuery(document).on("kurtosys-filter-loaded", function(queryID) { jQuery(".bmo-search-result-item-descr .elementor-text-editor").each( function() { let content = jQuery(this).text(); let searchExp = new RegExp(param, "ig"); let matches = content.match(searchExp); if (matches) { jQuery(this).html( content.replace(searchExp, function() { return "" + param + ""; }) ); } } ); }); } /*========== BMO-1157 Set focus on content when the tab is clicked - works on search results page START ==========*/ const setFocusInContentWhenTabIsClicked = () => { const tabs = document.querySelector('.bmo-search-page .bmo-only-tabs-with-image-and-text') if (!tabs) return const setFocus = (index) => { const button = tabs.querySelector(`.kurtosys-tabs__content[data-tab="${index}"] .elementor-button-link`) button.focus() } const tabControls = tabs.querySelectorAll('.kurtosys-tabs__control') tabControls.forEach(tabControl => { tabControl.addEventListener('keypress', (e) => { if (e.key === "Enter") { tabControl.click() const index = tabControl.getAttribute('data-tab') setFocus(index) } }) }) } setFocusInContentWhenTabIsClicked() /*========== BMO-1157 Set focus on content when the tab is clicked - works on search results page END ==========*/ /*========== End Search Results Page ==========*/ /*========== Insight video, insight video v2 ==========*/ if (document.querySelector(".bmo-insight-video") !== null) { (() => { const bmoModule = document.querySelector(".bmo-insight-video"); const modal = bmoModule.querySelector(".bmo-modal-content"); const modalOverlay = bmoModule.querySelector(".bmo-modal-head"); const hideModal = "bmo-modal-hidden"; const iframeBox = bmoModule.querySelector( ".bmo-iframe-content-insight-video" ); const selector = 'a[href], area[href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]'; let tabData = []; const preventTabOutside = (modal) => { const tabbableElements = document.querySelectorAll(selector); tabData = Array.from(tabbableElements) .filter((elem) => !modal.contains(elem)) .map((elem) => { const tabIndex = elem.hasAttribute("tabindex") ? elem.getAttribute("tabindex") : null; elem.setAttribute("tabindex", -1); return { elem, tabIndex, }; }); }; const enableTabOutside = () => { tabData.forEach(({ elem, tabIndex }) => { if (tabIndex === null) { elem.removeAttribute("tabindex"); } else { elem.setAttribute("tabindex", tabIndex); } }); tabData = []; }; const toggleFade = () => { modalOverlay.classList.add("bmo-insight-video-fadeout"); modalOverlay.classList.remove("bmo-insight-video-fadein"); }; bmoModule .querySelector(".bmo-close-modal-insight-video") .addEventListener("click", () => { iframeBox.setAttribute("src", ""); modalOverlay.classList.add(hideModal); toggleFade(); enableTabOutside(); }); document.addEventListener("mouseup", (e) => { if ( !modal.classList.contains(e.target) && e.target.parentNode != modal ) { modalOverlay.classList.add(hideModal); toggleFade(); iframeBox.setAttribute("src", ""); enableTabOutside(); } }); const openModal = (videoLink) => { iframeBox.setAttribute("src", videoLink); modalOverlay.classList.remove(hideModal); modalOverlay.classList.remove("bmo-insight-video-fadeout"); modalOverlay.classList.add("bmo-insight-video-fadein"); preventTabOutside(modal); }; const playVideos = bmoModule.querySelectorAll( ".bmo-custom-video-btn" ); playVideos.forEach((playVideo) => { playVideo.addEventListener("click", function(e) { if ( e.target.classList.contains( "kurtosys-listing-dynamic-field__icon" ) ) { const videoLink = e.target.nextSibling.innerText; openModal(videoLink); } else { const videoLink = e.target.innerText; openModal(videoLink); } }); }); const insightBoxes = bmoModule.querySelectorAll(".bmo-insight-box"); insightBoxes.forEach((insightBox) => { if ( insightBox.querySelector(".bmo-custom-video-btn") !== null ) { const insightBoxTitles = insightBox.querySelectorAll(".bmo-insight-title"); insightBoxTitles.forEach((insightBoxTitle) => { const aTagTitle = insightBoxTitle.querySelector("a"); if (aTagTitle) { const titleText = aTagTitle.innerText; insightBoxTitle.querySelector( ".elementor-heading-title" ).innerHTML = titleText; } }); const insightBoxImages = insightBox.querySelectorAll(".bmo-insight-image"); insightBoxImages.forEach((insightBoxImage) => { const aTagImage = insightBoxImage.querySelector("a"); if (aTagImage) { const image = aTagImage.innerHTML; insightBoxImage.querySelector( ".elementor-image" ).innerHTML = image; } }); const insightBoxHrefs = insightBox.querySelectorAll("[href]"); insightBoxHrefs.forEach((insightBoxHref) => { if ( insightBoxHref.parentNode.classList.contains( "kurtosys-listing-dynamic-field__content" ) ) { return; } else { insightBoxHref.removeAttribute("href"); } }); const readMoreButtons = insightBox.querySelectorAll( ".bmo-insight-button-external" ); readMoreButtons.forEach((readMoreButton) => { readMoreButton.remove(); }); const readMoreInternalButtons = insightBox.querySelectorAll( ".bmo-insight-button-internal" ); readMoreInternalButtons.forEach((readMoreButton) => { readMoreButton.remove(); }); const postBoxes = insightBox.querySelectorAll( ".bmo-posts-box-100-column-description" ); postBoxes.forEach((postBox) => { const externalLinkButton = postBox.querySelector( ".bmo-external-link-btn" ); externalLinkButton.remove(); }); const hrefVideo = insightBox.querySelector(".video-link"); hrefVideo.setAttribute("href", "empty-link"); } }); const playVideoBoxes = bmoModule.querySelectorAll(".bmo-box-cover-btn"); playVideoBoxes.forEach((playVideoBox) => { playVideoBox.addEventListener("click", (e) => { const elementorRow = e.target.closest(".elementor-row"); if ( elementorRow.querySelector(".bmo-custom-video-btn") !== null ) { const videoLink = elementorRow.querySelector( ".kurtosys-listing-dynamic-field__content" ).innerText; openModal(videoLink); } }); }); })(); } if (document.querySelector(".bmo-insight-video-v2") !== null) { (() => { const bmoModule = document.querySelector(".bmo-insight-video-v2"); const modal = bmoModule.querySelector(".bmo-modal-content"); const modalOverlay = bmoModule.querySelector(".bmo-modal-head"); const hideModal = "bmo-modal-hidden"; const iframeBox = bmoModule.querySelector( ".bmo-iframe-content-insight-video" ); const selector = 'a[href], area[href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]'; let tabData = []; const preventTabOutside = (modal) => { const tabbableElements = document.querySelectorAll(selector); tabData = Array.from(tabbableElements) .filter((elem) => !modal.contains(elem)) .map((elem) => { const tabIndex = elem.hasAttribute("tabindex") ? elem.getAttribute("tabindex") : null; elem.setAttribute("tabindex", -1); return { elem, tabIndex, }; }); }; const enableTabOutside = () => { tabData.forEach(({ elem, tabIndex }) => { if (tabIndex === null) { elem.removeAttribute("tabindex"); } else { elem.setAttribute("tabindex", tabIndex); } }); tabData = []; }; const toggleFade = () => { modalOverlay.classList.add("bmo-insight-video-fadeout"); modalOverlay.classList.remove("bmo-insight-video-fadein"); }; bmoModule .querySelector(".bmo-close-modal-insight-video") .addEventListener("click", () => { iframeBox.setAttribute("src", ""); modalOverlay.classList.add(hideModal); toggleFade(); enableTabOutside(); }); document.addEventListener("mouseup", (e) => { if ( !modal.classList.contains(e.target) && e.target.parentNode != modal ) { modalOverlay.classList.add(hideModal); toggleFade(); iframeBox.setAttribute("src", ""); enableTabOutside(); } }); const openModal = (videoLink) => { iframeBox.setAttribute("src", videoLink); modalOverlay.classList.remove(hideModal); modalOverlay.classList.remove("bmo-insight-video-fadeout"); modalOverlay.classList.add("bmo-insight-video-fadein"); preventTabOutside(modal); }; const playVideos = bmoModule.querySelectorAll( ".bmo-custom-video-btn" ); playVideos.forEach((playVideo) => { playVideo.addEventListener("click", function(e) { if ( e.target.classList.contains( "kurtosys-listing-dynamic-field__icon" ) ) { const videoLink = e.target.nextSibling.innerText; openModal(videoLink); } else { const videoLink = e.target.innerText; openModal(videoLink); } }); }); const insightBoxes = bmoModule.querySelectorAll(".bmo-insight-box"); insightBoxes.forEach((insightBox) => { if ( insightBox.querySelector(".bmo-custom-video-btn") !== null ) { const insightBoxTitles = insightBox.querySelectorAll(".bmo-insight-title"); insightBoxTitles.forEach((insightBoxTitle) => { const aTagTitle = insightBoxTitle.querySelector("a"); if (aTagTitle) { const titleText = aTagTitle.innerText; insightBoxTitle.querySelector( ".elementor-heading-title" ).innerHTML = titleText; } }); const insightBoxImages = insightBox.querySelectorAll(".bmo-insight-image"); insightBoxImages.forEach((insightBoxImage) => { const aTagImage = insightBoxImage.querySelector("a"); if (aTagImage) { const image = aTagImage.innerHTML; insightBoxImage.querySelector( ".elementor-image" ).innerHTML = image; } }); const insightBoxHrefs = insightBox.querySelectorAll("[href]"); insightBoxHrefs.forEach((insightBoxHref) => { if ( insightBoxHref.parentNode.classList.contains( "kurtosys-listing-dynamic-field__content" ) ) { return; } else { insightBoxHref.removeAttribute("href"); } }); const readMoreButtons = insightBox.querySelectorAll( ".bmo-insight-button-external" ); readMoreButtons.forEach((readMoreButton) => { readMoreButton.remove(); }); const readMoreInternalButtons = insightBox.querySelectorAll( ".bmo-insight-button-internal" ); readMoreInternalButtons.forEach((readMoreButton) => { readMoreButton.remove(); }); const postBoxes = insightBox.querySelectorAll( ".bmo-posts-box-100-column-description" ); postBoxes.forEach((postBox) => { const externalLinkButton = postBox.querySelector( ".bmo-external-link-btn" ); externalLinkButton.remove(); }); const hrefVideo = insightBox.querySelector(".video-link"); hrefVideo.setAttribute("href", "empty-link"); } }); const playVideoBoxes = bmoModule.querySelectorAll(".bmo-box-cover-btn"); playVideoBoxes.forEach((playVideoBox) => { const tagButton = playVideoBox.querySelector(".elementor-button"); if (tagButton) { tagButton.remove(); } playVideoBox.addEventListener("click", (e) => { const elementorRow = e.target.closest(".elementor-row"); if ( elementorRow.querySelector(".bmo-custom-video-btn") !== null ) { const videoLink = elementorRow.querySelector( ".kurtosys-listing-dynamic-field__content" ).innerText; openModal(videoLink); } }); }); const insightTags = bmoModule.querySelectorAll(".bmo-insight-tag"); insightTags.forEach((insightTag) => { insightTag.remove(); }); const insightTimes = bmoModule.querySelectorAll(".bmo-insight-time"); insightTimes.forEach((insightTime) => { insightTime.remove(); }); })(); } /*========== End Insight video, insight video v2 ==========*/ /*========== [294] Insight with big image ==========*/ if (jQuery(".bmo-insights-grid-with-big-image-v2").length > 0) { jQuery(".bmo-insights-grid-with-big-image-v2").each(function() { var featuredImage = jQuery(this).find( ".bmo-big-insight-first-column .bmo-insight-image" ), secondImage = jQuery(this).find( ".bmo-big-insight-first-column .bmo-big-insight-second-image" ), secondColumnImage = jQuery(this).find( ".bmo-big-insight-second-column .bmo-big-insight-second-image" ); secondColumnImage.addClass("hideBannerImage"); if ( secondImage .find(".kurtosys-listing-dynamic-field__content") .is(":empty") ) { featuredImage.removeClass("hideBannerImage"); secondImage.addClass("hideBannerImage"); } else { secondImage.siblings(featuredImage).addClass("hideBannerImage"); } }); } /*========== End [294] Insight with big image ==========*/ /*========== [308] US money market nav ==========*/ /* don't refactor, unless consulted */ if (jQuery(".bmo-us-money-market-nav").length > 0) { // Setting global vars if they don't exist already var daily_as_of_date = daily_as_of_date === undefined ? null : daily_as_of_date; var monthly_as_of_date = monthly_as_of_date === undefined ? null : monthly_as_of_date; var quarterly_as_of_date = quarterly_as_of_date === undefined ? null : quarterly_as_of_date; var funds = funds === undefined ? {} : funds; var benchmarks = benchmarks === undefined ? {} : benchmarks; var errorMsg = errorMsg === undefined ? "No data at this time." : errorMsg; var jsonCode = jsonCode === undefined ? jQuery( ".bmo-us-json .kurtosys-listing-dynamic-field__content" ) .first() .text() : jsonCode; if (typeof jsonCode !== "object") { jsonCode = JSON.parse(jsonCode); daily_as_of_date = jsonCode.json_updated_date; monthly_as_of_date = jsonCode.monthly_as_of_date; quarterly_as_of_date = jsonCode.quarterly_as_of_date; funds = jsonCode.funds; benchmarks = jsonCode.benchmarks; } // Module specific variables var $moneyDailyNav = jQuery("#wpx-money-market-nav"), moneyDailyNavTickers = $moneyDailyNav.data("tickers"), moneyDailyNavIndices = $moneyDailyNav.data("indices"); function mmDisclosures() { if (jQuery("#cusip").length > 0) { var cusipID = []; var cusipData = []; if ( typeof moneyDailyNavTickers !== "undefined" && typeof cusipID !== "undefined" ) { $.each(moneyDailyNavTickers, function(i, v) { if (funds.hasOwnProperty(v)) { cusipID.push("C_" + funds[v].fund.cusip); } else { console.log(v + " ticker missing from DDM feed."); } }); } else if (typeof moneyDailyNavTickers == "undefined") { console.log("Tickers not specified."); } else if (typeof cusipID == "undefined") { jQuery("#fund_assets").text(errorMsg).removeAttr("id"); console.log("Data feed failure: State Street Money Market"); } if (typeof cusipData !== "undefined") { jQuery("#cusip .cusip-table").each(function(i) { jQuery(this).append( '
" ); }); } else { console.log( "Data feed failure: State Street Money Market Disclosures" ); } if (typeof cusipID !== "undefined") { $.each(cusipID, function(i, v) { if (mmktFeed.hasOwnProperty(v)) { cusipData.push(mmktFeed[v]); } else { jQuery( "#cusip table#" + cusipID[i] + " .data" ).append( '
No data at this time.
' ); } }); $.each(mmktFeed.cols, function(i, v) { jQuery("#cusip .mmktData .headers").append( "
" + v + "
" ); jQuery("#cusip .mmktData .footers").append( "
" + v + "
" ); }); } else { console.log("CUSIP numbers not specified."); } if ( typeof cusipData[0] !== "undefined" && typeof cusipData[1] !== "undefined" ) { $.each(cusipData[0], function(i) { jQuery("#cusip #tab-class-y .data").append( "
" ); }); $.each(cusipData[1], function(i) { jQuery("#cusip #tab-premier-class .data").append( "
" ); }); } else { jQuery("#cusip .data").append( '
" ); console.log("One or both CUSIP numbers not found."); } jQuery("#cusip .cusip-table").removeClass("loader"); } } mmDisclosures(); (function($) { let $module = jQuery(".wpx-m31a7f983"); $module.each(function() { let $el = jQuery(this), $tabs = $el.find(".nav"), $navItem = $tabs.find("li"), $navLink = $navItem.find("a"), $tabContent = $el.find(".performance-table"); $navLink.each(function() { jQuery(this).on("click", function(e) { e.preventDefault(); let href = jQuery(this).attr("href"); $navLink.removeClass("active"); jQuery(this).addClass("active"); $tabContent.removeClass("show"); jQuery(href).addClass("show"); }); }); }); })(jQuery); } /*========== Emd [308] US money market nav ==========*/ /*========== [309] US fund performance ==========*/ /* don't refactor, unless consulted */ if (jQuery(".bmo-us-fund-performance").length > 0) { // Setting global vars if they don't exist already var daily_as_of_date = daily_as_of_date === undefined ? null : daily_as_of_date; var monthly_as_of_date = monthly_as_of_date === undefined ? null : monthly_as_of_date; var quarterly_as_of_date = quarterly_as_of_date === undefined ? null : quarterly_as_of_date; var funds = funds === undefined ? {} : funds; var benchmarks = benchmarks === undefined ? {} : benchmarks; var errorMsg = errorMsg === undefined ? "No data at this time." : errorMsg; var jsonCode = jsonCode === undefined ? jQuery( ".bmo-us-json .kurtosys-listing-dynamic-field__content" ) .first() .text() : jsonCode; if (typeof jsonCode !== "object") { jsonCode = JSON.parse(jsonCode); daily_as_of_date = jsonCode.json_updated_date; monthly_as_of_date = jsonCode.monthly_as_of_date; quarterly_as_of_date = jsonCode.quarterly_as_of_date; funds = jsonCode.funds; benchmarks = jsonCode.benchmarks; } // Module specific variables var $fundPerformanceContainer = jQuery("#wpx-fund-performance"), fundPerformanceTickers = $fundPerformanceContainer.data("tickers"), fundPerformanceIndices = $fundPerformanceContainer.data("indices"); if ($fundPerformanceContainer.data("offer").length !== 0) { var fundPerformanceOffer = $fundPerformanceContainer.data("offer"); } function DDMPrint(val) { if (val == "N/A") { return val; } else { return val.toFixed(2); } } var dailyDateStamp = daily_as_of_date.split("-"); var dailyDate = dailyDateStamp[1] + "/" + dailyDateStamp[2] + "/" + dailyDateStamp[0]; var monthlyDateStamp = monthly_as_of_date.split("-"); var monthlyDate = monthlyDateStamp[1] + "/" + monthlyDateStamp[2] + "/" + monthlyDateStamp[0]; var quarterlyDateStamp = quarterly_as_of_date.split("-"); var quarterlyDate = quarterlyDateStamp[1] + "/" + quarterlyDateStamp[2] + "/" + quarterlyDateStamp[0]; jQuery("#monthlyDate").text(monthlyDate); jQuery("#quarterlyDate").text(quarterlyDate); jQuery("#performance-table .performance-table").append( "
" + ' | Current 7-day yield¹ | ' + 'Effective 7-day yield¹ | ' + '' + ' | YTD | ' + '1 yr | ' + '3 yr | ' + '5 yr | ' + '10 yr | ' + 'Since inception | ' + 'Expenses (%) | ' + "
---|
" ); jQuery("#performance-table #monthlyTable .table-id").text("MTD"); jQuery("#performance-table #quarterlyTable .table-id").text("QTD"); if (typeof fundPerformanceTickers !== "undefined") { $.each(fundPerformanceTickers, function(i, v) { if (funds.hasOwnProperty(v)) { jQuery("#monthlyTable table tbody").append( '
Class " + funds[v].fund.class + "" + "
" + "
Inception: " + '' + funds[v].fund.inception_date + "
" + "
" + DDMPrint(funds[v].fund.exprationet) + " net" + "
" ); jQuery("#quarterlyTable table tbody").append( '
Class " + funds[v].fund.class + "" + "" + "
" + "
Inception: " + '' + funds[v].fund.inception_date + "
" + "
" + DDMPrint(funds[v].fund.exprationet) + " net" + "
" ); console.log("fund " + (i + 1) + ": " + v); } else { jQuery( "#monthlyTable table tbody, #quarterlyTable table tbody" ).append( '
' + v + " - " + errorMsg + "
" ); console.log(v + " ticker missing from DDM feed."); } }); if ( jQuery("#performance-table.money-market-funds").length > 0 && typeof UMBFEED !== "undefined" ) { $.each(fundPerformanceTickers, function(i, v) { if (UMBFEED.hasOwnProperty(v)) { jQuery( '#performance-table.money-market-funds tr[id*="-ticker-' + (i + 1) + '"] td.curr7dYld' ).text(Number(UMBFEED[v].DAILY.Curr7dyYtd)); jQuery( '#performance-table.money-market-funds tr[id*="-ticker-' + (i + 1) + '"] td.eff7dYld' ).text(Number(UMBFEED[v].DAILY.Eff7dyYtd)); } else { console.log( v + " ticker missing from State Street feed." ); } }); } } else { jQuery( "#monthlyTable table tbody, #quarterlyTable table tbody" ).append( '
' + errorMsg + "
" ); console.log("Tickers not specified."); } if (typeof fundPerformanceOffer !== "undefined") { if (funds.hasOwnProperty(fundPerformanceOffer)) { jQuery("tr#mt-ticker-1").after( '
" ); jQuery("tr#qt-ticker-1").after( '
" ); console.log("offer: " + fundPerformanceOffer); } else { jQuery( "#monthlyTable table tbody, #quarterlyTable table tbody" ).append( '
' + fundPerformanceOffer + " offer - " + errorMsg + "
" ); console.log( fundPerformanceOffer + " ticker or offer data missing from State Street performance feed." ); } } if (typeof fundPerformanceIndices !== "undefined") { $.each(fundPerformanceIndices, function(i, v) { if (benchmarks.hasOwnProperty(v)) { jQuery("#monthlyTable table tbody").append( '
" ); jQuery("#quarterlyTable table tbody").append( '
" ); console.log("benchmark " + (i + 1) + ": " + v); } else { console.log( v + " ticker or offer data missing from State Street performance feed." ); } }); } else {} jQuery("#performance-table .performance-table").removeClass("loader"); (function($) { let $module = jQuery(".wpx-me5bd4dce"); function cloneThead(table, thead) { thead.clone().appendTo(table).addClass("bottom-thead"); } function hideClonedThead(table) { if (jQuery(window).width() > 767) { if (table.height() > 500) { table.removeClass("hide-thead"); } else { table.addClass("hide-thead"); } } else { if (table.height() > 300) { table.removeClass("hide-thead"); } else { table.addClass("hide-thead"); } } } $module.each(function() { let $el = jQuery(this), $tabs = $el.find(".nav"), $navItem = $tabs.find("li"), $navLink = $navItem.find("a"), $tabContent = $el.find(".performance-table"); $tabContent.each(function() { let $table = jQuery(this).find("table"), $tableHead = $table.find("thead"); cloneThead($table, $tableHead); hideClonedThead($table); $navLink.each(function() { jQuery(this).on("click", function(e) { e.preventDefault(); let href = jQuery(this).attr("href"); $navLink.removeClass("active"); jQuery(this).addClass("active"); $tabContent.removeClass("show"); jQuery(href).addClass("show"); hideClonedThead($table); }); }); }); }); })(jQuery); } /*========== Emd [309] US fund performance ==========*/ /*========== [310] US fund overview and key documents ==========*/ /* don't refactor, unless consulted */ if (jQuery(".bmo-us-fund-overview-and-key-documents").length > 0) { // Setting global vars if they don't exist already var daily_as_of_date = daily_as_of_date === undefined ? null : daily_as_of_date; var monthly_as_of_date = monthly_as_of_date === undefined ? null : monthly_as_of_date; var quarterly_as_of_date = quarterly_as_of_date === undefined ? null : quarterly_as_of_date; var funds = funds === undefined ? {} : funds; var benchmarks = benchmarks === undefined ? {} : benchmarks; var errorMsg = errorMsg === undefined ? "No data at this time." : errorMsg; var jsonCode = jsonCode === undefined ? jQuery( ".bmo-us-json .kurtosys-listing-dynamic-field__content" ) .first() .text() : jsonCode; if (typeof jsonCode !== "object") { jsonCode = JSON.parse(jsonCode); daily_as_of_date = jsonCode.json_updated_date; monthly_as_of_date = jsonCode.monthly_as_of_date; quarterly_as_of_date = jsonCode.quarterly_as_of_date; funds = jsonCode.funds; benchmarks = jsonCode.benchmarks; } // Module specific variables var mstar = mstar === undefined ? jQuery( ".bmo-us-mstar-json .kurtosys-listing-dynamic-field__content" ) .first() .text() : mstar, $fundsOverviewContainer = jQuery("#funds-overview"), fundsOverviewTickers = $fundsOverviewContainer.data("tickers"), fundsOverviewIndices = $fundsOverviewContainer.data("indices"), fundsOverviewMStarsIDs = $fundsOverviewContainer.data("mstar-ids"), mstar = JSON.parse(mstar); if (typeof fundsOverviewIndices !== "undefined") { jQuery("#benchmarks .elementor-text-editor p").remove(); $.each(fundsOverviewIndices, function(i, v) { if (benchmarks.hasOwnProperty(v)) { jQuery("#benchmarks .elementor-text-editor").append( '
' + benchmarks[v].benchmark.name + "
" ); console.log("benchmark " + (i + 1) + ": " + v); } else { jQuery("#benchmarks .elementor-text-editor").append( "
" + errorMsg + "
" ); console.log( v + " ticker or offer data missing from State Street performance feed." ); } }); jQuery("#benchmarks .elementor-text-editor") .removeClass("loader") .find('.benchmark:contains("Lipper")') .remove(); } else { jQuery("#benchmarks .elementor-text-editor").append( "
" + errorMsg + "
" ); console.log("Benchmarks not specified."); } function fundAssets() { if (jQuery("#fund_assets").length > 0) { var fund_assets = 0; if ( typeof fundsOverviewTickers !== "undefined" && typeof UMBFEED !== "undefined" ) { $.each(fundsOverviewTickers, function(i, v) { if (UMBFEED.hasOwnProperty(v)) { fund_assets += Number(UMBFEED[v].FUND.totassets); } else { console.log( v + " ticker missing from State Street feed." ); } }); if (fund_assets < 1000) { var abbr = " Million"; fund_assets = fund_assets.toFixed(1); } else { var abbr = " Billion"; fund_assets = (fund_assets / 1000).toFixed(1); } fund_assets = "$" + fund_assets + abbr; jQuery("#fund_assets").text(fund_assets); console.log("assets: " + fund_assets); } else if (typeof fundsOverviewTickers == "undefined") { jQuery("#fund_assets").text().removeAttr("id"); console.log("Tickers not specified."); } else if (typeof UMBFEED == "undefined") { jQuery("#fund_assets").text(errorMsg).removeAttr("id"); console.log("Data feed failure: State Street Performance"); } jQuery(".net-assets .loader").removeClass("loader"); } } function totalDate() { if (jQuery("#total_date").length > 0) { if ( typeof fundsOverviewTickers !== "undefined" && typeof UMBFEED !== "undefined" && UMBFEED.hasOwnProperty(fundsOverviewTickers[0]) ) { var ticker1 = fundsOverviewTickers[0]; var total_date = UMBFEED[ticker1].FUND.totdate.split("-"); jQuery("#total_date").text( "as of " + total_date[1] + "/" + total_date[2] + "/" + total_date[0] ); console.log( "as of: " + total_date[1] + "/" + total_date[2] + "/" + total_date[0] ); } else if (typeof fundsOverviewTickers == "undefined") { jQuery("#total_date").text(); console.log("Tickers not specified."); } else if (typeof UMBFEED == "undefined") { jQuery("#total_date").remove(); console.log("Data feed failure: State Street Performance"); } } } (function($) { $.fn.morningstar = function(options) { var $container = jQuery(this); var opt = $.extend({ mstarIDs: [], format: 1, }, options ); if (opt.mstarIDs.length > 0) { $.each(opt.mstarIDs, function(i, v) { if (mstar.hasOwnProperty(v)) { var ticker = mstar[v].Ticker; var ratingDateStamp = mstar[v].RatingDate.split("-"); var ratingDate = ratingDateStamp[1] + "/" + ratingDateStamp[2] + "/" + ratingDateStamp[0]; var stars = []; for (var i = 0; i < mstar[v].RatingOverall; i++) { stars.push("★"); } if (mstar[v].RatingOverall >= 3) { $container.append( '
' + stars.join("") + "
" + '
' + "
Overall Morningstar Rating™ among " + mstar[v].NumberOfFundsOverall + " " + mstar[v].CategoryName + " funds as of " + ratingDate + " (Class " + funds[ticker].fund.class + ")
" + "
" ); } jQuery("#ms-dis-1").text( "Institutional shares received a " + mstar[v].RatingOverall + "-star rating for overall performance" ); if ( mstar[v].Rating3Year !== undefined && mstar[v].Rating5Year !== undefined && mstar[v].Rating10Year !== undefined ) { jQuery("#ms-dis-1").append( ", " + mstar[v].Rating3Year + " stars for 3-year performance among " + mstar[v].NumberOfFunds3Year + " " + mstar[v].CategoryName + " funds, " + mstar[v].Rating5Year + " stars for 5-year performance among " + mstar[v].NumberOfFunds5Year + " funds, and " + mstar[v].Rating10Year + " stars for 10-year performance among " + mstar[v].NumberOfFunds10Year + " funds." ); } else if ( mstar[v].Rating3Year !== undefined && mstar[v].Rating5Year !== undefined && mstar[v].Rating10Year == undefined ) { jQuery("#ms-dis-1").append( ", " + mstar[v].Rating3Year + " stars for 3-year performance among " + mstar[v].NumberOfFunds3Year + " " + mstar[v].CategoryName + " funds, and " + mstar[v].Rating5Year + " stars for 5-year performance among " + mstar[v].NumberOfFunds5Year + " funds. " + "For the 10-year performance ending " + ratingDate + ", the Morningstar Rating™ is not available." ); } else if ( mstar[v].Rating3Year !== undefined && mstar[v].Rating5Year == undefined && mstar[v].Rating10Year == undefined ) { jQuery("#ms-dis-1").append( " and " + mstar[v].Rating3Year + " stars for 3-year performance among " + mstar[v].NumberOfFunds3Year + " " + mstar[v].CategoryName + " funds. " + "For the 5-year and 10-year performance ending " + ratingDate + ", the Morningstar Rating™ is not available." ); } else { jQuery("#ms-dis-1").append("."); } jQuery("#ms-dis-2").html( "For each fund with at least a 3-year history, Morningstar calculates a Morningstar Rating™ based on a Morningstar Risk-Adjusted Return measure that accounts for variation in a fund's monthly performance (including the effects of sales charges, loads, and redemption fees), placing more emphasis on downward variations and rewarding consistent performance. The top 10% of funds in each category receive 5 stars, the next 22.5% receive 4 stars, the next 35% receive 3 stars, the next 22.5% receive 2 stars and the bottom 10% receive 1 star. (Each share class is counted as a fraction of one fund within this scale and is rated separately, which may cause slight variations in the distribution percentages.) The Overall Morningstar Rating™ for a fund is derived from a weighted average of the performance figures associated with its 3-, 5- and 10-year (if applicable) Morningstar Rating™ metrics. Morningstar Rating™ is for the I share class only; other classes may have different performance characteristics." ); } else { console.log(v + " not found in db"); } }); } else { $container.remove(); jQuery("#ms-dis-1, #ms-dis-2").remove(); } }; })(jQuery); fundAssets(); totalDate(); const msRating = jQuery("#ms-rating"); if (msRating) { msRating.morningstar({ mstarIDs: fundsOverviewMStarsIDs, }); if (msRating.text() !== "") { jQuery(".mstar-element").removeClass( "elementor-hidden-desktop elementor-hidden-tablet elementor-hidden-phone" ); } } } /*========== End [310] US fund overview and key documents ==========*/ /*========== [311] US daily fund data ==========*/ /* don't refactor, unless consulted */ if (jQuery(".bmo-us-daily-fund-data").length > 0) { // Setting global vars if they don't exist already var daily_as_of_date = daily_as_of_date === undefined ? null : daily_as_of_date; var monthly_as_of_date = monthly_as_of_date === undefined ? null : monthly_as_of_date; var quarterly_as_of_date = quarterly_as_of_date === undefined ? null : quarterly_as_of_date; var funds = funds === undefined ? {} : funds; var benchmarks = benchmarks === undefined ? {} : benchmarks; var errorMsg = errorMsg === undefined ? "No data at this time." : errorMsg; var jsonCode = jsonCode === undefined ? jQuery( ".bmo-us-json .kurtosys-listing-dynamic-field__content" ) .first() .text() : jsonCode; if (typeof jsonCode !== "object") { jsonCode = JSON.parse(jsonCode); daily_as_of_date = jsonCode.json_updated_date; monthly_as_of_date = jsonCode.monthly_as_of_date; quarterly_as_of_date = jsonCode.quarterly_as_of_date; funds = jsonCode.funds; benchmarks = jsonCode.benchmarks; } // Module specific variables var $dailyDataContainer = jQuery("#wpx-daily-data"), dailyDataTickers = $dailyDataContainer.data("tickers"), dailyDataIndices = $dailyDataContainer.data("indices"); if (typeof dailyDataTickers !== "undefined") { $.each(dailyDataTickers, function(i, v) { if (funds.hasOwnProperty(v)) { var inceptDate = funds[v].fund.inception_date; jQuery("#daily-nav .daily-nav-tabs").append( '
" ); jQuery("#daily-nav").append( '
' + '
' + '
' + funds[v].fund.inception_date + "
" + '
Inception date
' + "
" + '
' + '
' + funds[v].fund.expratiogross + "%
" + '
Gross expense ratio
' + "
" + '
' + '
' + funds[v].fund.exprationet + "%
" + '
Net expense ratio
' + "
" + '
' + '
' + '
NAV as of
' + "
" + '
' + '
' + '
Change as of
' + "
" + '
' + '
' + '
Change as of
' + "
" + '' + "
" ); } else { console.log("Daily NAV data not found."); } if (UMBFEED.hasOwnProperty(v)) { var daily_nav_date = UMBFEED[v].DAILY.Navdate.split("-"); jQuery("#daily-nav #" + v + " .daily-nav .data").text( UMBFEED[v].DAILY.NAV ); jQuery("#daily-nav #" + v + " .change-dollar .data").text( "$" + UMBFEED[v].DAILY.Chgamt ); jQuery("#daily-nav #" + v + " .change-percent .data").text( UMBFEED[v].DAILY.Chgpct + "%" ); jQuery("#daily-nav #" + v + " .daily-nav-date").text( daily_nav_date[1] + "/" + daily_nav_date[2] + "/" + daily_nav_date[0] ); } else { console.log(v + " ticker missing from State Street feed."); } }); } (function($) { let $module = jQuery(".wpx-m69c2e1f5"); $module.each(function() { let $el = jQuery(this), $tabs = $el.find(".daily-nav-tabs"), $navItem = $tabs.find("li"), $navLink = $navItem.find("a"), $tabContent = $el.find(".row"), $tabBox = $tabContent.find(".float-left"); //Set first tab as active $navLink.first().addClass("active"); $tabContent.addClass("hide"); //Show first tab content $tabContent.first().addClass("show"); $tabBox .addClass("column") .removeClass("float-left") .removeClass("col-2") .addClass("col-12 col-md"); $navLink.each(function() { jQuery(this).on("click", function(e) { e.preventDefault(); let href = jQuery(this).attr("href"); $navLink.removeClass("active"); jQuery(this).addClass("active"); $tabContent.removeClass("show"); jQuery(href).addClass("show"); }); }); }); })(jQuery); } /*========== End [311] US daily fund data ==========*/ /*========== Properties template ==========*/ if ( jQuery(".bmo-small-filters-for-team-memers").length > 0 || jQuery(".bmo-small-filters-properties").length > 0 ) { jQuery(".ksys-smart-filters-select").each(function() { jQuery(this).on("click", function() { jQuery(this) .find(".kurtosys-select") .toggleClass("bmo-active-select"); jQuery(".kurtosys-select__control").show(); }); }); } /*========== End Properties template ==========*/ /*=======READ MORE button in filter page =====*/ var filter = jQuery(".bmo-small-filters-properties"); if (filter) { var filterQueryId = filter .find(".kurtosys-select") .attr("data-query-id"), loadMoreButton = jQuery("#" + filterQueryId) .parents(".bmo-insights-load-more") .find( ".bmo-button-v6.elementor-widget-kurtosys-load-more .load-more-button" ); function removeReadMoreButton() { var numberOfItems = jQuery("#" + filterQueryId).find( ".kurtosys-listing-grid__item" ).length; if (numberOfItems < 12) { loadMoreButton.css("display", "none"); } else { loadMoreButton.css("display", "block"); } } jQuery(document).on( "kurtosys-filter-content-rendered", removeReadMoreButton ); } /*======= END READ MORE button in filter page =====*/ /*========== Fund template - button bookmark page ==========*/ if (jQuery(".bmo-button-bookmark-page").length > 0) { jQuery(".bmo-button-bookmark-page .elementor-button-icon").on( "click", function() { if (jQuery("body.bmo-ios").length > 0) { alert("Press Cmd+D to bookmark this fund."); } else { alert("Press Ctrl+D to bookmark this fund."); } } ); } /*========== End Fund template - button bookmark page ==========*/ /*----------- Insight with big image - add padding to right side boxes -----------*/ jQuery(".bmo-big-insight-second-column .bmo-insight-tag").each(function() { if ( jQuery(this) .find(".kurtosys-listing-dynamic-terms.kurtosys-listing") .is(":empty") ) { return true; } else { jQuery(this) .parents(".bmo-posts-box-100-column-image") .siblings(".bmo-posts-box-100-column-description") .find(".elementor-column-wrap") .addClass("boxPadding"); } }); /*----------- End Insight with big image - add padding to right side boxes -----------*/ }); /*========== [137] Sticky Sub Nav v2 ==========*/ jQuery(function($) { jQuery(window).on("elementor/frontend/init", function() { let navHeightSum; const sections = document.querySelectorAll( ".elementor-widget-menu-anchor .elementor-menu-anchor" ); const stickyNavigation = document.querySelectorAll( ".bmo-sticky-sub-nav-on-button" ); if (stickyNavigation.length > 0) { stickyNavigation.forEach((module) => { const stickyList = module.querySelector( "ul.elementor-icon-list-items" ); const stickyListItems = stickyList.querySelectorAll("li a"); const buttonMobile = module.querySelector( ".bmo-stickynav-button .elementor-widget-container" ); const buttonMobileText = stickyList.querySelector("li:first-of-type a").textContent; const headerHeightCheck = function() { const headerHeight = document.querySelector("header").offsetHeight; const navHeight = document.querySelector("header nav").offsetHeight; const moduleHeight = module.offsetHeight; if (window.innerWidth < 1024) { navHeightSum = headerHeight + moduleHeight - 20; } else { navHeightSum = headerHeight + navHeight + moduleHeight + 30; stickyList.style.height = ""; } }; const prependMobileButton = function(text) { buttonMobile.insertAdjacentHTML( "afterbegin", '
' + text + "
" ); }; const buttonMobileTextActive = function(activeText) { const thisActive = buttonMobile.querySelector( ".bmo-stickynav-button-mobile" ); thisActive.textContent = activeText; }; const stickyNavigation = function() { sections.forEach((current) => { const sectionId = current.getAttribute("id"); const sectionTop = current.getClientRects()[0].top - navHeightSum; if (sectionTop < 50) { stickyListItems.forEach((item) => { item.classList.remove("active"); }); const itemSame = stickyList.querySelectorAll( `li a[href="#${sectionId}"]` ); const lastItemSame = itemSame[itemSame.length - 1]; if (lastItemSame) { lastItemSame.classList.add("active"); } if ( stickyList.querySelector( `li a[href="#${sectionId}"]` ) ) { buttonMobileTextActive( stickyList.querySelector( `li a[href="#${sectionId}"]` ).textContent ); } } }); }; document.addEventListener("click", (e) => { if (e.target.className === "bmo-stickynav-button-mobile") { module.classList.toggle("bmo-arrow-mobile-tab"); if (window.innerWidth < 1024) { const stickyMobileHeight = stickyList.offsetHeight; stickyList.style.height = stickyMobileHeight + "px"; } } else { module.classList.remove("bmo-arrow-mobile-tab"); } }); prependMobileButton(buttonMobileText); stickyNavigation(); headerHeightCheck(); window.addEventListener( "scroll", debounce(stickyNavigation, 10) ); window.addEventListener( "scroll", debounce(headerHeightCheck, 10) ); window.addEventListener( "resize", debounce(headerHeightCheck, 10) ); }); elementorFrontend.hooks.addFilter( "frontend/handlers/menu_anchor/scroll_top_distance", function(scrollTop) { return scrollTop - navHeightSum; } ); } }); }); /*========== End [137] Sticky Sub Nav v2 ==========*/ /*========== Start [839] Insights filter ==========*/ /** * Translations for reset and apply buttons pulled from options page */ jQuery(function($) { jQuery(document).on("kurtosys-filter-loaded", function() { $('.bmo-filters-insight-version-4').each(function () { const resetButtonNode = jQuery(this).find(".elementor-widget-ksys-smart-filters-remove-filters"); const resetLabelTranslation = resetButtonNode.attr("data-translation"); resetButtonNode.find("button").text(resetLabelTranslation); const applyButtonNode = jQuery(this).find(".elementor-widget-ksys-smart-filters-apply-button"); const applyLabelTranslation = applyButtonNode.attr("data-translation"); applyButtonNode.find("button").text(applyLabelTranslation); }); }); }); /*========== End [839] Insights filter ==========*/ /*========== End [1378] Disclaimer popup ==========*/ /*------ JS MODULE END -------*/ /** * Top Navigation * Top Navigation for Ri Post * Top Navigation for UMAP */ jQuery( ".bmo-navigation .bmo-main-navigation .elementor-widget-kurtosys-custom-menu:not(.bmo-navigation-two-mobile) .menu-item a" ).on("click", function($) { window.dataLayer.push({ event: "navigation-interaction", Category: "Navigation Interaction", Action: "Header", Label: jQuery.trim(jQuery(this).text()), }); }); /** * Footer menu and sitemap */ jQuery( ".bmo-footer .bmo-top-footer-menu .elementor-nav-menu--main .menu-item a, .bmo-footer .bmo-bottom-footer-menu .elementor-nav-menu--main .menu-item a" ).on("click", function() { window.dataLayer.push({ event: "navigation-interaction", Category: "Navigation Interaction", Action: "Footer", Label: jQuery.trim(jQuery(this).text()), }); }); /** * Insights carousel banner * slider's arrows and dots */// Get title of the current slide before change let titleSliderContainer; jQuery(".bmo-insight-banner-carousel .slick-slider").on( "beforeChange", function() { titleSliderContainer = jQuery(this) .find(".slick-current .elementor-widget-heading") .text(); } ); jQuery(".bmo-insight-banner-carousel").on( "click", '.slick-arrow, .slick-dots [role="button"]', function() { window.dataLayer.push({ event: "carousel-interactions", Category: "Carousel Interactions", Action: "Impression Click", Label: jQuery.trim(titleSliderContainer), }); } ); /** * Accordion links */ jQuery( ".bmo-accordion .elementor-widget-kurtosys-accordion, .bmo-accordion-and-video .elementor-widget-kurtosys-accordion, .bmo-accordion-with-external-script .elementor-widget-kurtosys-accordion" ).on("click", "a", function() { const title = jQuery(this) .closest(".elementor-widget-kurtosys-accordion") .closest(".elementor-top-section") .find(".elementor-widget-heading") .first() .text(); const linkTitle = jQuery(this).text(); if (!title) { return; } window.dataLayer.push({ event: "accordion", Category: "Accordion Interaction", Action: jQuery.trim(title), Label: jQuery.trim(linkTitle), }); }); /** * Accordion - open/close * * .kurtosys-toggle__control - element responsible for open/close accordion. */ jQuery( ".bmo-accordion .elementor-widget-kurtosys-accordion .kurtosys-toggle__control, .bmo-accordion-and-video .elementor-widget-kurtosys-accordion .kurtosys-toggle__control, .bmo-accordion-with-external-script .elementor-widget-kurtosys-accordion .kurtosys-toggle__control" ).on("click", function() { const title = jQuery(this) .closest(".elementor-top-section") .find(".elementor-widget-heading") .first() .text(); const isOpen = jQuery(this).parent().hasClass("active-toggle"); if (!title) { return; } window.dataLayer.push({ event: "accordion", Category: "Accordion Interaction", Action: isOpen ? "open" : "close", Label: jQuery.trim(title), }); }); /** * Document library * exactly the same as on the old website */ var $kurtosysDocLibrary = jQuery("#kurtosysDocLibrary");// Download buttons $kurtosysDocLibrary.on("click", 'button[title="Download"]', function() { var $box = jQuery(this).closest("section"), boxTitle = $box.find("h1").clone().children().remove().end().text(), elementTitle = jQuery(this).closest("tr").find("td:eq(1)").text(), elementType = jQuery(this).closest("tr").find("td:eq(4)").text(); window.dataLayer.push({ event: "download-collateral", Category: "Download Collateral", Action: jQuery.trim(elementType), Label: jQuery.trim(boxTitle + " " + elementTitle), }); });// Filter checkboxes $kurtosysDocLibrary.on("click", "div ol li label img", function() { var $el = jQuery(this), isChecked = $el.siblings("input").attr("checked"), filterTitle; if ($el.is("label")) { filterTitle = $el.text(); } else { filterTitle = $el.closest("label").text(); } if (!isChecked) { isChecked = "select"; } else { isChecked = "deselect"; } window.dataLayer.push({ event: "filter-options", Category: "Filter options", Action: isChecked, Label: jQuery.trim(filterTitle), }); });// Filters category accordion (only for #kurtosysDocLibrary) $kurtosysDocLibrary.on("click", "aside.open h4", function() { var $el = jQuery(this), accordionID = $el.clone().children().remove().end().text(), isCollapsed = $el.parent().find("div").length; if (isCollapsed) { isCollapsed = "close"; } else { isCollapsed = "open"; } window.dataLayer.push({ event: "accordion", Category: "Accordion Interaction", Action: isCollapsed, Label: jQuery.trim(accordionID), }); }); /** * Download Collateral for table module. * */ jQuery( ".bmo-documents-module .bmo-documents-module-listing .elementor-widget-button a" ).on("click", function() { const $el = jQuery(this); const $singleInsight = $el.closest(".bmo-documents-module-listing"); const elementType = $singleInsight .find(".bmo-documents-module-term:not(.bmo-documents-capability-topic)") .text(); const postTitle = $singleInsight.find(".elementor-widget-heading").text(); if (!elementType || !postTitle) { return; } window.dataLayer.push({ event: "download-collateral", Category: "Download Collateral", Action: jQuery.trim(elementType), Label: jQuery.trim(postTitle), }); }); /** * Download Collateral for all .pdf quick links */ jQuery('.bmo-quick-links-styles.elementor-top-section a[href$=".pdf"]').on( "click", function() { const $el = jQuery(this); const documentType = $el .closest(".bmo-quick-links-styles.elementor-top-section") .find(".elementor-widget-heading") .first() .text(); if (!documentType) { return; } const documentTitle = $el.text(); window.dataLayer.push({ event: "download-collateral", Category: "Download Collateral", Action: jQuery.trim(documentType), Label: jQuery.trim(documentTitle), }); } ); /** * Internal links. * * a - all the links on the page. */ function pushInternalLinkToDataLayer(action, label) { window.dataLayer.push({ event: "internal-links", Category: "Internal Links", Action: action, Label: label, }); } jQuery("body").on("click", "a", function($) { const $link = jQuery(this); const href = $link.attr("href"); if ( $link.parents("footer").length || ["", "#", "empty-link", "#empty-link"].includes(href) ) { return; } // ContactUs if ((href !== '' && href !== 'undefined') === false) { if (href.startsWith("tel:") || href.startsWith("mailto:")) { pushInternalLinkToDataLayer("ContactUs", href); } } // DocumentLibrary & Funds const pathname = $link.get(0).pathname; if (pathname) { if (pathname.includes("documents")) { pushInternalLinkToDataLayer("DocumentLibrary", href); } else if (pathname.includes("funds")) { pushInternalLinkToDataLayer("Funds", href); } } const $section = $link.closest(".elementor-top-section"); if(!!!$section.length) return; const sectionClassList = $section.get(0).classList; const sectionClassListArray = [...sectionClassList]; // Megamenu1 if ($link.closest(".megamenu-1").length) { pushInternalLinkToDataLayer("Megamenu1", href); return; } // Megamenu2 if ($link.closest(".megamenu-2").length) { pushInternalLinkToDataLayer("Megamenu2", href); return; } // Megamenu3 if ($link.closest(".megamenu-3").length) { pushInternalLinkToDataLayer("Megamenu3", href); return; } // Megamenu4 if ($link.closest(".megamenu-4").length) { pushInternalLinkToDataLayer("Megamenu4", href); return; } // TopNav if ($link.closest("nav.bmo-main-navigation").length) { pushInternalLinkToDataLayer("TopNav", href); } // Teambio const teambioClasses = [ "bmo-bio-title-listing", "bmo-team-member-listing", "bmo-lisiting-members-ri", "bmo-dynamic-author-listing", ]; if ( teambioClasses.some((teambioClass) => sectionClassListArray.includes(teambioClass) ) ) { pushInternalLinkToDataLayer("Teambio", href); } // Heropanel if (sectionClassList.contains("bmo-icon-grid")) { pushInternalLinkToDataLayer("Heropanel", href); } // Carousel if (sectionClassList.contains("bmo-listing-article-banner-corusel")) { pushInternalLinkToDataLayer("Carousel", href); } // Insights if (sectionClassList.contains("bmo-insight-box")) { pushInternalLinkToDataLayer("Insights", href); } // PlatformLink const $linkImage = $link.find("img"); if (sectionClassList.contains("bmo-image-grid-v1") && $linkImage.length) { const linkImageAlt = $linkImage.attr("alt"); pushInternalLinkToDataLayer( "PlatformLink", linkImageAlt ? linkImageAlt : href ); } // StickyNav if (sectionClassList.contains("bmo-sticky-sub-nav-on-button")) { pushInternalLinkToDataLayer("StickyNav", jQuery.trim($link.text())); } }); /** * Internal links - Podcast */ jQuery(".bmo-audio-section, .bmo-audio-player").on( "click", ".mejs-playpause-button button", function() { const $button = jQuery(this); const $audio = $button .closest(".elementor-top-section") .find("audio.kurtosys-audio-player"); if ($button.closest(".mejs-button").hasClass("mejs-play")) { pushInternalLinkToDataLayer( "Podcast", jQuery.trim($audio.attr("src")) ); } } ); /** * Internal links - Video */ const videoClasses = [ "bmo-wistia-v1", "bmo-wistia-v2", "bmo-custom-video-wistia", "bmo-video-grid-wistia", "bmo-text-and-video-v1", "bmo-video-grid", "bmo-youtube-video", "bmo-custom-video-youtube-vimeo", "bmo-quick-links-and-video-v1", ]; const videoSelector = videoClasses.map((value) => `.${value}`).join(", "); jQuery(videoSelector).on( "click", '.elementor-widget-html [role="button"], .elementor-widget-html [data-handle="bigPlayButton"] button, .elementor-widget-video [role="button"]', function() { const $button = jQuery(this); const $widgetContainer = $button.closest(".elementor-widget"); if ($widgetContainer.hasClass("elementor-widget-video")) { // non-wistia const videoData = $widgetContainer .find("[data-elementor-lightbox]") .attr("data-elementor-lightbox"); if (!videoData) { return; } const videoDataJSON = JSON.parse(videoData); if (videoDataJSON || videoDataJSON.url) { pushInternalLinkToDataLayer( "Video", jQuery.trim(videoDataJSON.url) ); } } else if ($widgetContainer.hasClass("elementor-widget-html")) { // wistia const $wistiaEmbed = $widgetContainer.find(".wistia_embed"); const wistiaEmbedClasses = [...$wistiaEmbed.get(0).classList]; const wistiaVideoIdClass = wistiaEmbedClasses.filter((value) => value.includes("wistia_async_") )[0]; if (!wistiaVideoIdClass) { return; } const wistiaVideoId = wistiaVideoIdClass.split("wistia_async_")[1]; if (wistiaVideoId) { pushInternalLinkToDataLayer( "Video", `https://fast.wistia.com/embed/medias/${jQuery.trim( wistiaVideoId )}` ); } } } ); /*---- GTM END -----*/ /*========== Start bmo-our-commitment-box ==========*/ if (document.querySelectorAll('.bmo-our-commitment-box-trigger') !== null) { const boxTrigger = document.querySelectorAll(`.bmo-our-commitment-box-trigger`) boxTrigger.forEach((el) => { el.addEventListener('click', () => { el.querySelector('a').click(); }) }) } /*========== End bmo-our-commitment-box ==========*/ /*========== Start Adding a mobile image to Sadiq's inights ==========*/ const postCategory = [...document.querySelectorAll('.bmo-insight-box .kurtosys-listing-dynamic-terms__link')] const changeImage = () => { if (postCategory === null) return; postCategory.map(el => { let categoryToCheck = el.innerText switch (categoryToCheck) { case 'Weekly Commentary': el.closest('.bmo-insight-box').classList.add('has-mobile-image') break; case 'Commentaire hebdomadaire': el.closest('.bmo-insight-box').classList.add('has-mobile-image') break; } }) } changeImage(); /*========== End Adding a mobile image to Sadiq's insights ==========*/ /*========== Start functionality to sadiq template right sidebar ==========*/ document.querySelectorAll('.bmo-video-boxes-rpc').forEach(elem => { const openModals = document.querySelectorAll('.bmo-video-modals'); const closeModals = document.querySelectorAll('.bmo-close-button-rp'); function openModal(event) { const currentModalParent = event.target.closest('.bmo-modal-parent'); const currentModal = currentModalParent.querySelector('dialog.bmo-content-modal'); const closeOverlay = currentModalParent.querySelector('.bmo-bg-overlay-modal-rp'); const closeBtnOverlay = currentModalParent.querySelector('.bmo-close-button-rp'); const modalIframe = currentModal.querySelector('iframe'); currentModal.showModal(); closeOverlay.classList.add('open'); function closeModal(event) { closeOverlay.classList.remove('open'); closeBtnOverlay.click(); currentModal.close(); const modalUrl = modalIframe.getAttribute('src'); modalIframe.src = ''; modalIframe.src = modalUrl; } currentModal.addEventListener('click', closeModal); closeBtnOverlay.addEventListener('click', closeModal); } function closeModal(event) { const currentModalParent = event.target.closest('.bmo-modal-parent'); const currentModal = currentModalParent.querySelector('dialog.bmo-content-modal'); const closeOverlay = currentModalParent.querySelector('.bmo-bg-overlay-modal-rp'); currentModal.close(); closeOverlay.classList.remove('open'); } openModals.forEach((modal) => { modal.addEventListener('click', openModal); }); closeModals.forEach((modal) => { modal.addEventListener('click', closeModal); }); }); /*========== END functionality to sadiq template right sidebar ==========*/ /*========== START [1116] Events Cards and [1050] New Card module with variations - Open in new tab if link is external ==========*/ const addBlankAttribute = () => { const externalButton = document.querySelectorAll(".bmo-box-cover-btn"); externalButton.forEach((elem) => { if ( elem.hasAttribute("data-content-toggle-hide-icon-link") && elem.getAttribute("data-content-toggle-hide-icon-link") === "false" || elem.hasAttribute("data-switcher") && elem.getAttribute("data-switcher") === "true" ) { let linkButton = elem.querySelector(".elementor-button-link"); linkButton?.setAttribute("target", "_blank"); } }); }; addBlankAttribute(); /*========== END [1116] Events Cards and [1050] New Card module with variations - Open in new tab if link is external ==========*/// [BMO-1099] Add Profile ID To Iframe const PROFILE_PARAM = 'profileId'; const ENV_PARAM = 'env'; const IFRAME_SELECTOR = '#bmo-dr-iframe'; const INVESTORS = ['/investors/', '/advisors/', '/institutional/', '/conseillers/', '/institutions/', '/placements/']; const resizeIframe = () => { const iframe = document.querySelector(IFRAME_SELECTOR) // offset is needed to avoid a white space const offset = 5 if (!iframe) return window.addEventListener( "message", ({data}) => { const {type, height} = data if (type !== 'IFRAME_RESIZED') return iframe.height = height - offset }, false ); const iframeUrl = iframe.dataset.src iframe.setAttribute('src', iframeUrl) // In case of an issue with dynamically setting the iframe's height, we use a reasonable value 2050px setTimeout(() => { if (iframe.height !== "650") return iframe.height = 2050 }, 2000) } resizeIframe() const addProfileIdToIframe = (url, iframeUrl, iframe) => { const profileId = url.searchParams.get(PROFILE_PARAM); if (!profileId) return; iframeUrl.searchParams.set(PROFILE_PARAM, profileId) iframe.src = iframeUrl.toString(); }; const addEnvToIframe = (iframeUrl, iframe) => { const iframeEnv = iframe.dataset.env if (!iframeEnv) return; iframeUrl.searchParams.set(ENV_PARAM, iframeEnv) iframe.src = iframeUrl.toString(); } const addParamsToIframe = () => { const iframe = document.querySelector(IFRAME_SELECTOR); if (!iframe) return; const url = new URL(window.location.href); if (INVESTORS.some(investor => url.href.includes(investor))) return; const iframeUrl = new URL(iframe.src); addProfileIdToIframe(url, iframeUrl, iframe) addEnvToIframe(iframeUrl, iframe) } addParamsToIframe() const addTickerToIframe = () => { const iframe = document.querySelector('.iframe-ticker'); if (!iframe) return; const url = new URL(window.location.href); const param = 'ticker'; const iframeUrl = new URL(iframe.src); const tickerValue = url.searchParams.get(param); if (!tickerValue) return; iframeUrl.searchParams.set(param, tickerValue) iframe.src = iframeUrl.toString(); }; addEventListener("DOMContentLoaded", (event) => { addTickerToIframe(); }); /*========== START [1050] New Card module with variations ==========*/ const attributeList = [ { label: 'data-content-toggle-hide-category', className: 'bmo-card-hide-category' }, { label: 'data-content-toggle-hide-date', className: 'bmo-card-hide-date' }, { label: 'data-content-toggle-hide-description', className: 'bmo-card-hide-description' }, { label: 'data-content-toggle-hide-link-text', className: 'bmo-card-hide-link-text' }, { label: 'data-content-toggle-hide-icon-link', className: 'bmo-card-hide-icon-link' }, ]; const advancedListingElements = document.querySelectorAll('.bmo-card-module-advanced-listing .kurtosys-listing-grid__item'); const checkAndAddClass = () => { advancedListingElements.forEach(el => { attributeList.forEach(attr => { const attributeItem = el.querySelector(`[${attr.label}="true"]`); if (attributeItem) { el.classList.add(attr.className); } }); let termLink = el.querySelector('.kurtosys-listing-dynamic-terms__link'); if (termLink !== null ) { if(termLink.textContent === "Uncategorized") { el.querySelector('.kurtosys-listing-dynamic-terms__link').classList.add('bmo-card-hide-uncategorized'); } return; } }); }; if(advancedListingElements?.length > 0) { checkAndAddClass(); } /*========== END [1050] New Card module with variations ==========*/ /*========== START [BMO-1178] Sticky CTA button ==========*/ const hideStickyButton = () => { const stickyButton = document.querySelector('.bmo-sticky-cta-button'); const targetElement = document.querySelector('.bmo-text-and-icon-list-module'); if(!(stickyButton && targetElement)) { return; } function isElementAboveViewport(el) { const rect = el.getBoundingClientRect(); return rect.bottom <= 0; } function handleScroll() { if (isElementAboveViewport(targetElement)) { stickyButton.classList.add("bmo-sticky-cta-button--hide"); } else { stickyButton.classList.remove("bmo-sticky-cta-button--hide"); } } window.addEventListener('scroll', debounce(handleScroll,60)); handleScroll(); }; hideStickyButton(); /*========== END [BMO-1178] Sticky CTA button ==========*/ /*========== START [BMO - 1183] Video and list module ==========*/ const videoAndListModule = () => { const videoAndListModules = document.querySelectorAll(".bmo-video-and-list-module"); if(videoAndListModules) { videoAndListModules.forEach(module => { const buttonVideo = module.querySelector(".elementor-custom-embed-image-overlay"); buttonVideo.setAttribute("tabindex","0"); buttonVideo.setAttribute("aria-label","Open video modal"); buttonVideo.addEventListener("keydown", function(event) { if (event.keyCode === 13) { buttonVideo.click(); } }); }); } } videoAndListModule(); /*========== END [BMO - 1183] Video and list module ==========*/ /*========== START [BMO-1200] Option for accordion - link instead of toggle ==========*/ const accordionLinkInsteadOfToggle = () => { const accordions = document.querySelectorAll(".bmo-accordion-dr-box-radius"); const dashboardElementor = document.querySelector(".elementor-editor-active"); if(!accordions.length || dashboardElementor) { return; } accordions.forEach(module => { module.querySelectorAll(".kurtosys-accordion__item").forEach(item => { const content = item.querySelector(".kurtosys-toggle__content-inner p")?.textContent.trim(); if(content && content.substring(0, 4) === "http") { item.classList.add("bmo-accordion-dr-box-radius__link"); } }); }); document.addEventListener("click", e => { const eTarget = e.target; if(eTarget.closest(".bmo-accordion-dr-box-radius") && eTarget.closest(".kurtosys-accordion__item")) { const item = eTarget.closest(".kurtosys-accordion__item"); const content = item.querySelector(".kurtosys-toggle__content-inner p").textContent.trim(); if(content.substring(0, 4) === "http") { e.preventDefault(); window.open(content, "_blank"); } } }); }; accordionLinkInsteadOfToggle(); /*========== END [BMO-1200] Option for accordion - link instead of toggle ==========*/ /*========== START [BMO-1027] Video carousel ==========*/ jQuery(function ($) { jQuery(window).on("elementor/frontend/init", function () { elementorFrontend.on("components:init", function () { const videoCarousels = document.querySelectorAll('.bmo-pg-video-carousel'); videoCarousels.forEach(videoCarousel => { const videoWrappers = videoCarousel.querySelectorAll('.bmo-pg-video-wrapper'); videoWrappers.forEach((wrapper) => { const playButton = wrapper.querySelector('.bmo-pg-play-button'); const pauseButton = wrapper.querySelector('.bmo-pg-pause-button'); const video = wrapper.querySelector('video'); playButton.addEventListener('click', () => { if (video.paused) { video.setAttribute('controls', 'true'); video.play(); playButton.classList.add('bmo-pg-hidden'); pauseButton.classList.remove('bmo-pg-hidden'); } else { video.pause(); playButton.classList.remove('bmo-pg-hidden'); pauseButton.classList.add('bmo-pg-hidden'); } }); pauseButton.addEventListener('click', () => { video.pause(); playButton.classList.remove('bmo-pg-hidden'); pauseButton.classList.add('bmo-pg-hidden'); }); }); const videoCarouselDots = videoCarousel.querySelectorAll('.kurtosys-slick-dots li'); const countActiveVideo = videoCarousel.querySelectorAll('.count-active-video'); const countLengthVideo = videoCarousel.querySelectorAll('.count-length-video'); const counterContainer = videoCarousel.querySelectorAll('.bmo-pg-video-carousel .bmo-pg-video-carousel__hidden'); let videoCarouselDotsLength = videoCarouselDots.length; let carouselActiveCount; const handleIframeTabindex = () => { document.querySelectorAll('.bmo-pg-video-carousel iframe').forEach(iframe => { iframe.setAttribute('tabindex', "-1") }) let currentSlide = document.querySelector('.bmo-pg-video-carousel .slick-current iframe') if(currentSlide) { currentSlide.setAttribute('tabindex', '0'); } } const videoCarouselCounter = () => { carouselActiveCount = 1; countLengthVideo.forEach(count => { count.innerHTML = videoCarouselDotsLength.toString(); }); counterContainer.forEach(item => { item.style.visibility = 'visible'; }); }; const handlePrevClick = () => { carouselActiveCount = Math.max(--carouselActiveCount, 1); countActiveVideo.forEach(activeCount => { activeCount.innerHTML = carouselActiveCount; }); handleIframeTabindex(); }; const handleNextClick = () => { carouselActiveCount = Math.min(++carouselActiveCount, videoCarouselDotsLength); countActiveVideo.forEach(activeCount => { activeCount.innerHTML = carouselActiveCount; }); handleIframeTabindex(); }; const handleClickDots = (index, trigger) => { carouselActiveCount = index + 1; countActiveVideo.forEach(activeCount => { activeCount.innerHTML = carouselActiveCount; }); trigger.click(); } videoCarouselCounter(); videoCarousel.addEventListener('click', function (event) { if (event.target.classList.contains('prev-arrow')) { handlePrevClick(); } else if (event.target.classList.contains('next-arrow')) { handleNextClick(); } }); videoCarousel.addEventListener('keypress', function (event) { if (event.target.classList.contains('prev-arrow')) { handlePrevClick(); } else if (event.target.classList.contains('next-arrow')) { handleNextClick(); } }); videoCarouselDots.forEach((dot, index) => { dot.setAttribute('tabindex', '0'); dot.addEventListener('click', handleClick); dot.addEventListener('keypress', handleKeyPress); function handleClick(event) { event.stopPropagation(); if (isDotElement(event.target)) { handleClickDots(index, event.target); } } function handleKeyPress(event) { event.stopPropagation(); if (event.key === 'Enter' || event.key === ' ') { handleClickDots(index, event.target); } } function isDotElement(target) { return target.tagName.toLowerCase() === 'li'; } }); const stopVideos = () => { videoCarousel.querySelectorAll(':not(.slick-current) iframe').forEach(v => { v.src = v.src }); videoCarousel.querySelectorAll('video').forEach(v => { v.pause() }); }; const handleSlideChange = () => { stopVideos(); }; const $videoCarousel = $('.bmo-pg-video-carousel'); $videoCarousel.on('afterChange', handleSlideChange); const mqPgVideoCarousel = window.matchMedia('(max-width: 1024px)'); const carouselItems = document.querySelectorAll('.kurtosys-listing-grid__item'); if (mqPgVideoCarousel.matches) { const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { if (mutation.attributeName === 'aria-hidden') { const isHidden = mutation.target.getAttribute('aria-hidden'); if (isHidden === 'false') { let slideIndex = mutation.target.attributes[3].value; handleClickDots(Number(slideIndex)); } } }); }); const observerOptions = { attributes: true, attributeFilter: ['aria-hidden'] }; carouselItems.forEach((item) => { observer.observe(item, observerOptions); }); } }); }); }); }); /*========== END [BMO-1027] Video carousel ==========*/ /** * Mobile tab anchors - moved from Elementor */ const mobileTabAnchors = () => { const sectionAnchorLinks = document.querySelector('.dr-anchor-links'); if(!sectionAnchorLinks) { return; } const anchorLinks = document.querySelectorAll('.dr-anchor-links-list .elementor-icon-list-text'); const anchorLinkMobile = document.querySelector('.dr-anchor-links .dr-anchor-links-mobile-tab .elementor-heading-title'); const mqDrAnchorLinks = window.matchMedia('(max-width: 1024px)'); const dropdownTrigger = document.querySelector('.dr-anchor-links .dr-anchor-links-dropdown'); const setFirstAnchorLinkValue = () => { if (!anchorLinks.length) { return false; } anchorLinkMobile.textContent = anchorLinks[0].textContent; }; const setNewActiveLink = (anchorText) => { anchorLinkMobile.textContent = anchorText; }; const handleAnchorLinkClick = (event) => { const {target} = event; setNewActiveLink(target.textContent); dropdownTrigger.classList.remove('dr-anchor-links-dropdown-active'); }; const checkMediaQueryDrPage = () => { if(mqDrAnchorLinks.matches) { sectionAnchorLinks.classList.add('dr-anchor-links-mobile-active'); setFirstAnchorLinkValue(); anchorLinks.forEach((link) => { link.addEventListener("click", handleAnchorLinkClick) }); } else { sectionAnchorLinks.classList.remove('dr-anchor-links-mobile-active'); anchorLinks.forEach((link) => { link.removeEventListener("click", handleAnchorLinkClick) }); } } jQuery(window).on("elementor/frontend/init", () => { checkMediaQueryDrPage(); dropdownTrigger.addEventListener('click', () => { dropdownTrigger.classList.toggle('dr-anchor-links-dropdown-active'); }) window.addEventListener('resize', debounce(checkMediaQueryDrPage, 250)); }); } window.addEventListener('load', mobileTabAnchors); /*========== START [BMO-980 / BMO-1345] Events for new navigation widget - menu and WCAG options ==========*/// Replacing divs to ul / li const divDropDownMenu = document.querySelector('.bmo-navigation-wcag--top #bmo-dropdown-menu .kurtosys-custom-nav__sub'); if(divDropDownMenu) { const divElements = divDropDownMenu.querySelectorAll('.language_selector_item'); const ulElement = document.createElement('ul'); ulElement.className = 'kurtosys-custom-nav__sub'; divElements.forEach(divElement => { const liElement = document.createElement('li'); liElement.className = divElement.className; liElement.innerHTML = divElement.innerHTML; ulElement.appendChild(liElement); }); divDropDownMenu.parentNode.replaceChild(ulElement, divDropDownMenu); } const navigationWCAG = document.querySelector(".bmo-navigation-wcag"); const linksTopNavigation = document.querySelectorAll(".bmo-navigation a, .bmo-navigation input"); const linksMainNavigation = document.querySelectorAll(".bmo-main-navigation a"); const linksMainNavigationSub = document.querySelectorAll(".bmo-products-overview-secendary a"); const topMenuItemsWithChildren = document.querySelectorAll(".bmo-navigation-wcag--top .menu-item-has-children > a"); topMenuItemsWithChildren.forEach(item => { item.setAttribute("aria-expanded","false"); }); const MainMenuItemsWithChildren = document.querySelectorAll(".bmo-navigation-wcag--main .kurtosys-menu-item-has-children > a"); MainMenuItemsWithChildren.forEach(item => { item.setAttribute("aria-expanded","false"); }); const wcagTabClick = e => { const eTarget = e.target; linksTopNavigation.forEach(item => { item.setAttribute("tabindex","1"); }); document.querySelector(".bmo-main-logo a").setAttribute("tabindex","2"); linksMainNavigation.forEach(item => { item.setAttribute("tabindex","3"); }); linksMainNavigationSub.forEach(item => { item.setAttribute("tabindex","3"); }); const toggleClickFirstLevelMainMenu = eTarget.closest("a")?.parentNode.classList; if(toggleClickFirstLevelMainMenu?.contains("bmo-menu-click")) { toggleClickFirstLevelMainMenu.remove("bmo-menu-click"); eTarget.closest("a").setAttribute("aria-expanded","false"); return; } const toggleClickFirstLevelTopMenu = eTarget.closest("a")?.parentNode.classList; if(toggleClickFirstLevelTopMenu?.contains("click-state")) { toggleClickFirstLevelTopMenu.remove("click-state"); eTarget.closest("a").setAttribute("aria-expanded","false"); return; } const subMegaMenu = eTarget.closest(".kurtosys-sub-mega-menu"); const linkLevel2 = eTarget.closest(".kurtosys-custom-nav__item-link.menu-image-title-after"); if (linkLevel2 && !eTarget.closest(".bmo-column-button-right")) { const links = Array.from(eTarget.closest(".kurtosys-custom-nav").querySelectorAll(".kurtosys-custom-nav__item-link.menu-image-title-after")); const clickedIndex = links.indexOf(linkLevel2); if (clickedIndex !== -1) { const id = clickedIndex + 1; subMegaMenu?.querySelector(".active-content")?.classList.remove("active-content"); subMegaMenu?.querySelector('.kurtosys-tabs__content[data-tab="' + id + '"]')?.classList.add("active-content"); subMegaMenu?.querySelectorAll('.kurtosys-tabs__content.active-content a').forEach(item => { item.setAttribute("tabindex","3"); }); } document.querySelector(".bmo-sub-menu-click")?.classList.remove("bmo-sub-menu-click"); eTarget.closest("a").classList.add("bmo-sub-menu-click"); eTarget.closest(".kurtosys-custom-nav.kurtosys-custom-nav--dropdown-right-side").querySelectorAll("a").forEach(item => { item.setAttribute("tabindex","-1"); }); eTarget.closest("a").setAttribute("tabindex","3"); } const clickState = document.querySelector(".click-state"); clickState?.classList.remove("click-state"); clickState?.firstElementChild.setAttribute("aria-expanded","false"); const menuClickElement = document.querySelector(".bmo-menu-click"); if (menuClickElement && !subMegaMenu) { menuClickElement.classList.remove("bmo-menu-click"); menuClickElement.firstElementChild.setAttribute("aria-expanded","false"); } const hasChildren = eTarget.closest(".menu-item-has-children"); const subTopMenu = eTarget.closest(".kurtosys-custom-nav__mega-sub"); const subTopMenuWP = eTarget.closest(".kurtosys-custom-nav__sub"); if(hasChildren && !subTopMenu && !subTopMenuWP) { e.preventDefault(); hasChildren.classList.add("click-state"); hasChildren.firstElementChild.setAttribute("aria-expanded","true"); } const hasKurtoChildren = eTarget.closest(".kurtosys-menu-item-has-children"); const link = eTarget.closest("a"); if (hasKurtoChildren && (link?.classList.contains("kurtosys-custom-nav__item-link", "menu-image-title-after") || link?.classList.contains("top-level-link", "menu-image-title-after"))) { e.preventDefault(); hasKurtoChildren.classList.add("bmo-menu-click"); hasKurtoChildren.firstElementChild.setAttribute("aria-expanded","true"); } // Only level 1 if (hasKurtoChildren && link?.classList.contains("top-level-link", "menu-image-title-after")) { const subMenuClick = document.querySelector(".bmo-sub-menu-click"); subMenuClick?.classList.remove("bmo-sub-menu-click"); const customNavLink = hasKurtoChildren.querySelector(".kurtosys-sub-mega-menu .kurtosys-custom-nav__item-link.menu-image-title-after"); customNavLink?.click(); } }; const wcagTabKeyDown = e => { if (e.key === 'Tab') { const eTarget = e.target; const menuImageTitleAfter = eTarget.closest(".menu-image-title-after.elementor-item"); if(menuImageTitleAfter && !menuImageTitleAfter.parentNode.nextElementSibling) { document.querySelector(".bmo-sub-menu-click")?.parentNode?.querySelector("a")?.focus(); } } }; const wcagTabKeyUp = e => { const eTarget = e.target; if(e.key === "Enter") { const linkLevel2 = eTarget.closest(".kurtosys-custom-nav__item-link.menu-image-title-after"); if (linkLevel2 && eTarget.closest(".bmo-menu-level-2")) { linkLevel2.click(); } } const clickState = document.querySelector(".click-state"); const subMegaMenu = eTarget.closest(".kurtosys-sub-mega-menu"); const menuClick = document.querySelector(".bmo-menu-click"); const menuImageTitleAfter = eTarget.closest(".menu-image-title-after.elementor-item"); const seubMenuClick = document.querySelector(".bmo-sub-menu-click"); if(e.key === 'Escape') { clickState?.classList.remove("click-state"); clickState?.firstElementChild.setAttribute("aria-expanded","false"); menuClick?.classList.remove("bmo-menu-click"); menuClick?.firstElementChild.setAttribute("aria-expanded","false"); } else if (e.key === 'Tab') { if(eTarget.parentNode.classList.contains('kurtosys-menu-item')) { menuClick?.classList.remove("bmo-menu-click"); menuClick?.firstElementChild.setAttribute("aria-expanded","false"); } else if(!eTarget.closest('.kurtosys-custom-nav__mega-sub') && !eTarget.closest('.kurtosys-custom-nav__sub')) { clickState?.classList.remove("click-state"); clickState?.firstElementChild.setAttribute("aria-expanded","false"); } if(menuImageTitleAfter && !menuImageTitleAfter.parentNode.nextElementSibling) { seubMenuClick?.parentNode.parentNode.querySelectorAll("a").forEach(item => { item.setAttribute("tabindex","3"); }); subMegaMenu?.querySelectorAll('.kurtosys-tabs__content.active-content a').forEach(item => { item.setAttribute("tabindex","-1"); }); } } else if(e.key === 'ArrowLeft') { if(menuImageTitleAfter) { subMegaMenu?.querySelectorAll('.kurtosys-tabs__content.active-content a').forEach(item => { item.setAttribute("tabindex","-1"); }); if(seubMenuClick) { seubMenuClick.parentNode.parentNode.querySelectorAll("a").forEach(item => { item.setAttribute("tabindex","3"); }); if(seubMenuClick.parentNode?.nextElementSibling) { seubMenuClick.parentNode?.nextElementSibling?.querySelector("a")?.focus(); } else { seubMenuClick.parentNode?.querySelector("a")?.focus(); } } } } }; let isEventListenersForDesktopRegistered = false; const checkBrowserWidth = () => { if(!navigationWCAG) { return; } if (window.innerWidth > 1024 && !isEventListenersForDesktopRegistered) { document.addEventListener("click", wcagTabClick); document.addEventListener("touchstart", wcagTabClick); document.addEventListener("keydown", wcagTabKeyDown); document.addEventListener("keyup", wcagTabKeyUp); isEventListenersForDesktopRegistered = true; } else if (window.innerWidth <= 1024 && isEventListenersForDesktopRegistered) { document.removeEventListener("click", wcagTabClick); document.removeEventListener("touchstart", wcagTabClick); document.removeEventListener("keydown", wcagTabKeyDown); document.removeEventListener("keyup", wcagTabKeyUp); isEventListenersForDesktopRegistered = false; } const fixHoverAriaAxpanded = e => { const eTarget = e.target; const kurtosysMainMenu = eTarget.closest(".bmo-navigation-wcag--main .kurtosys-menu .kurtosys-menu-item-has-children"); if(kurtosysMainMenu && !kurtosysMainMenu.classList.contains("bmo-menu-click")) { kurtosysMainMenu.firstElementChild.setAttribute("aria-expanded","false"); } }; document.addEventListener("mouseover", fixHoverAriaAxpanded); document.addEventListener("mouseout", fixHoverAriaAxpanded); document.addEventListener("keyup", fixHoverAriaAxpanded); document.querySelector(".bmo-skip-to-main-content-btn a")?.setAttribute("tabindex", "1"); document.querySelector(".screen-reader-shortcut")?.setAttribute("tabindex", "-1"); document.querySelector('.bmo-navigation-wcag--top .bmo-nav-sign [role="menu"]')?.removeAttribute("tabindex"); document.querySelector('.bmo-navigation-wcag--top .kurtosys-search__field')?.setAttribute("aria-label","Search"); } checkBrowserWidth(); window.addEventListener("resize", debounce(checkBrowserWidth, 60)); /*========== END [BMO-980 / BMO-1345] Events for new navigation widget - menu and WCAG options ==========*/ /*========== START [BMO-1396] Data table caption ==========*/ const dataCaptions = document.querySelectorAll('.elementor-widget-kurtosys-table[data-caption]'); dataCaptions.forEach(item => { const textCaption = item.getAttribute("data-caption"); const newElement = document.createElement("caption"); newElement.innerText = textCaption.trim(); newElement.classList.add("elementor-hidden-desktop", "elementor-hidden-tablet", "elementor-hidden-mobile"); item.querySelector(".kurtosys-table")?.prepend(newElement); }); /*========== END [BMO-1396] Data table caption ==========*/ /*========== START [BMO-1422] Equal title in Tiles with icon x3 ==========*/ if (jQuery(document).innerWidth() > 1024) { function equalHeightTitle() { const boxTab = jQuery( ".bmo-tiles-with-icon-x3 .elementor-icon-box-title" ); let maxHeightDescription = Math.max.apply( null, boxTab .map(function () { jQuery(this).css("height", ""); return jQuery(this).outerHeight(); }) .get() ); boxTab.css("height", maxHeightDescription); } equalHeightTitle(); jQuery(window).on( "resize", debounce(function () { equalHeightTitle(); }, 250) ); } /*========== END [BMO-1422] Equal title in Tiles with icon x3 ==========*/ /*========== START [BMO-1519] Change place of toggle heading ==========*/ const changePlaceOfToggleHeading = () => { const mutualFundsModuleToggle = document.querySelectorAll('.bmo-mutial-funds-etfs-v2 .kurtosys-toggle'); mutualFundsModuleToggle.forEach(function (toggle) { let activeToggle = toggle.querySelectorAll('.bmo-mutial-funds-etfs-v2 .active-toggle'); let elementToMove = toggle.querySelector('.kurtosys-toggle__heading'); const changePlace = () => { let headingOfToggle = toggle.querySelector('.bmo-mutial-funds-etfs-v2 .kurtosys-toggle__content'); headingOfToggle.after(elementToMove); } if (activeToggle) { changePlace(); } else { toggle.addEventListener('click', function () { changePlace(); }); } }); } changePlaceOfToggleHeading(); /*========== END [BMO-1519] Change place of toggle heading ==========*/ /*========== START [BMO-1515] Remove attribute in chart ==========*/ removeTabIndexFromChart = () => { const chartImage = document.querySelectorAll('.bmo-portfolio-allocation .bmo-portfolio-allocation__column img'); chartImage.forEach(function (image) { image.removeAttribute("tabindex"); }); }; removeTabIndexFromChart(); /*========== END [BMO-1515] Remove attribute in chart ==========*/ /*========== START [BMO-1539] Remove attribute in dynamic share buttons to fix print ==========*/ const removeTargetBlank = () => { let dynamicPrint = document.querySelectorAll(".bmo-dynamic-share-buttons a.share-button[aria-label='Print']"); dynamicPrint.forEach(item => { item.removeAttribute("target"); }); }; removeTargetBlank(); /*========== END [BMO-1539] Remove attribute in dynamic share buttons to fix print ==========*/ /*========== START [BMO-1555] remove tab from link to Language toggle ==========*/ const removeFocus = () => { const toggleLink = document.querySelectorAll('.bmo-language-toggle-link .kurtosys-listing-dynamic-link__link'); toggleLink.forEach(link => { link.setAttribute("tabindex", "-1"); }); }; removeFocus(); /*========== END[BMO-1555] remove tab from link to Language toggle ==========*/ /*========== START [BMO-1560] Blog Posts for Direct Channel - skip to main content in single posts ==========*/ document.addEventListener('DOMContentLoaded', () => { const idMain = document.querySelector("#id"); if(!idMain) { const sectionSelector = '[data-elementor-type="single-post"] > .elementor-section-wrap > .elementor-section'; let targetElement = document.querySelector(`${sectionSelector}:nth-child(3)`); if(!targetElement) { targetElement = document.querySelector(`${sectionSelector}:nth-child(2)`); if(!targetElement) { targetElement = document.querySelector(`${sectionSelector}:nth-child(1)`); } } if(targetElement) { const newElementMain = document.createElement("div"); newElementMain.setAttribute("id", "main"); targetElement.prepend(newElementMain); } } }); /*========== END [BMO-1560] Blog Posts for Direct Channel - skip to main content in single posts ==========*/ /*========== START - WCAG fix for charts ==========*/ document.addEventListener('DOMContentLoaded', () => { const charts = document.querySelectorAll(".kurtosys-pie-chart"); charts.forEach(item => { const nextElement = item.nextElementSibling; if(nextElement && nextElement.hasAttribute("alt")) { const ariaLabel = nextElement.getAttribute("alt"); item.setAttribute("aria-label", ariaLabel); } else { item.setAttribute("aria-label", "Chart"); } }); }); /*========== END - WCAG fix for charts ==========*/ /*========== START - Lightbox option for list ==========*/ document.addEventListener("click", e => { const eTarget = e.target; const lightbox = eTarget.closest('[data-lightbox="true"]'); if(lightbox) { e.preventDefault(); const newElementIframe = document.createElement("iframe"); newElementIframe.src=lightbox.getAttribute("href"); const newElementLightBox = document.createElement("div"); newElementLightBox.classList.add("dialog-type-lightbox","bmo-lightbox-custom"); const newElementContent = document.createElement("div"); newElementContent.classList.add("bmo-lightbox-custom__content"); const newElementClose = document.createElement("button"); newElementClose.classList.add("bmo-lightbox-custom__close"); newElementClose.setAttribute("aria-label", "CLose lightbox"); document.querySelector("body").append(newElementLightBox); newElementLightBox.append(newElementContent); newElementContent.append(newElementClose); newElementContent.append(newElementIframe); } if(eTarget.closest(".bmo-lightbox-custom__close")) { document.querySelector(".bmo-lightbox-custom").remove(); } }); /*========== END - Lightbox option for list ==========*/ /*========== START - anchors and charts fix ==========*/ /*========== START - anchors and charts fix ==========*/ document.addEventListener("DOMContentLoaded", function () { const anchorLinks = document.querySelector(".dr-anchor-links"); if(anchorLinks && anchorLinks.hasAttribute("data-chart-aniamation-ids")) { const anchorLinksWithCharts = anchorLinks.getAttribute("data-chart-aniamation-ids"); const arrayIds = anchorLinksWithCharts.split(','); let linkOurPortfolio; if(arrayIds.length > 1) { linkOurPortfolio = arrayIds.find(item => document.querySelector(`[href="${item}"]`)); } else { linkOurPortfolio = document.querySelector(`[href="${anchorLinksWithCharts}"]`); } const portfolio = document.querySelectorAll(".bmo-portfolio-allocation"); const linksSubNav = document.querySelectorAll(".dr-anchor-links a"); if(portfolio.length && linksSubNav.length) { linksSubNav.forEach(item => { if(arrayIds.length > 1) { arrayIds.forEach(hash => { const element = document.querySelector(`[href="${hash}"]`); if (element) { element.parentElement.classList.add('bmo-portfolio-link'); } }); } else { if(item.getAttribute("href") === anchorLinksWithCharts) { item.parentElement.classList.add('bmo-portfolio-link'); } } item.addEventListener("click", (e) => { e.preventDefault(); const eTarget = e.target; let hasSpecialClass = false; const parentItem = eTarget.closest(".elementor-icon-list-item"); let nextSibling = parentItem.nextElementSibling; while (nextSibling !== null) { if (nextSibling.classList.contains("bmo-portfolio-link")) { hasSpecialClass = true; break; } nextSibling = nextSibling.nextElementSibling; } if(!hasSpecialClass) { portfolio.forEach(item => { const numberOfCharts = item.querySelectorAll(".kurtosys-pie-chart-container").length; const numberOfinitializedCharts = item.querySelectorAll(".kurtosys-pie-chart-container .chartjs-size-monitor").length; if(numberOfCharts !== numberOfinitializedCharts) { const heightModule = item.offsetHeight; item.style.height = `${heightModule}px`; item.querySelector(".elementor-container").style.display = "none"; setTimeout(() => { item.querySelector(".elementor-container").removeAttribute("style"); item.removeAttribute("style"); }, 600); } }); } }); }); } } }); /*========== END - anchors and charts fix ==========*/ /*========== START - [BMO-1655] new tabindexes for tools and resources ==========*/ document.addEventListener("DOMContentLoaded", function () { const toolsAndResources = document.querySelectorAll(".bmo-tools-and-resources"); toolsAndResources?.forEach(module => { module.querySelectorAll("a").forEach(item => { item.setAttribute("tabindex","-1"); }); const newButtons = module.querySelectorAll(".elementor-widget-icon-box"); newButtons.forEach(newButton => { newButton.setAttribute("tabindex","0"); }); }); }); document.addEventListener('keyup', e => { const eTarget = e.target; if(eTarget.closest(".bmo-tools-and-resources") && e.keyCode === 13 && eTarget.classList.contains("elementor-widget-icon-box")) { const link = eTarget.querySelector("a"); const href = link.getAttribute("href"); if(href) { window.open(link.getAttribute("href"), (link.getAttribute("target") === "_blank") ? "_blank" : "_self"); } } }); /*========== END - [BMO-1655] new tabindexes for tools and resources ==========*/}