// Blocs JS v4.4 document.addEventListener('DOMContentLoaded', function() { setUpNavExtras(); setUpSpecialNavs(); setUpLightBox(); setUpVisibilityToggle(); setUpClassToggle(); setUpImgProtection(); applyFormProtection(); initCarouselProgressBars(); // Initialise Tool tips $('[data-toggle="tooltip"]').tooltip(); // Auto Stop Videos When Modal Closes $('.modal').on('hidden.bs.modal', function (e){e.target.querySelectorAll(".embed-responsive-item").forEach(videoItem =>{if (videoItem.tagName=='VIDEO'){videoItem.pause();}else{videoItem.setAttribute('src',videoItem.getAttribute('data-src'));}});}); initBlocsInteractions('[data-custom-interaction-click],[data-custom-interaction-mouseover],[data-custom-interaction-mouseleave]'); document.querySelectorAll("a[onclick^=\"scrollToTarget\"]").forEach(function(targetObj){targetObj.addEventListener("click", function(e){e.preventDefault();});}); // Prevent page jump on scroll to links document.querySelectorAll(".nav-item [data-active-page]").forEach(function(targetObj){targetObj.classList.add(targetObj.getAttribute('data-active-page'));}); // Apply Active Link Classes // Internet Explorer Polyfill .closest() window.Element&&!Element.prototype.closest&&(Element.prototype.closest=function(e){var t,o=(this.document||this.ownerDocument).querySelectorAll(e),n=this;do{for(t=o.length;--t>=0&&o.item(t)!==n;);}while(t<0&&(n=n.parentElement));return n}); // Internet Explorer Polyfill .matches() if (!Element.prototype.matches) {Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;}; // Dark Mode if (window.matchMedia("(prefers-color-scheme: dark)").matches) {document.body.classList.add("dark-theme");} // Internet Explorer & Safari Polyfill .ScrollTo() - Animates scrollToPolyFill(); }); // Loading page complete window.addEventListener("load", function() { hideAll(); inViewCheck(); window.addEventListener("scroll", function() { inViewCheck(); scrollBtnVisible(); stickyBlocs(); }); var preloader = document.getElementById('page-loading-blocs-notifaction'); // Remove page loading UI if (preloader) { preloader.classList.add('preloader-complete'); } // Add Motion Ready Class requestAnimationFrame(() => {document.documentElement.classList.add('page-motion-ready');}); }); // Set Up Special NavBars function setUpSpecialNavs() { document.querySelectorAll(".navbar-toggler").forEach(function(targetObj) { targetObj.addEventListener("click", function(e) { var targetJSNav = e.target.closest('nav'); var targetMenu = targetJSNav.querySelector('ul.site-navigation'); var menuHTML = targetMenu.parentNode.innerHTML; if (targetMenu.parentNode.matches('.fullscreen-nav, .sidebar-nav')) // Special navigation menu { e.stopPropagation(); // Dont do this is normal menu in use targetMenu.parentNode.classList.add('nav-special'); if (!e.target.classList.contains('selected-nav')) // Open menu { e.target.classList.add('selected-nav'); var navClasses = targetJSNav.getAttribute('class').replace('navbar','').replace('row','').replace('hover-open-submenu',''); var menuClasses = targetMenu.parentNode.getAttribute('class').replace('navbar-collapse','').replace('collapse','').replace('collapsing',''); if (!document.querySelector('.content-tint')) { document.body.insertAdjacentHTML("beforeend","
"); } // Add menu HTML document.querySelector(".page-container").insertAdjacentHTML("beforebegin",""); initBlocsInteractions('.blocsapp-special-menu [data-custom-interaction-click], .blocsapp-special-menu [data-custom-interaction-mouseover], .blocsapp-special-menu [data-custom-interaction-mouseleave]'); // Add close button document.querySelector("blocsnav").insertAdjacentHTML("afterbegin",""); animateNavItems(); setTimeout(function() { document.querySelector(".blocsapp-special-menu blocsnav").classList.add("open"); document.querySelector(".content-tint").classList.add("on"); document.body.classList.add("lock-scroll"); document.body.classList.add("lock-scroll"); document.querySelector("blocsnav").focus(); }, 10); } else // Close menu { document.querySelector(".close-special-menu").remove(); document.querySelector(".blocsapp-special-menu blocsnav").classList.remove("open"); document.querySelector(".selected-nav").classList.remove("selected-nav"); setTimeout(function() { document.querySelector('.blocsapp-special-menu').remove(); document.body.classList.remove('lock-scroll'); document.querySelector('.nav-special').classList.remove('nav-special'); }, 300); } } }) }); // Handle special menu link click delegateSelector('body', "click", '.blocsapp-special-menu a', function(e) { if (!e.target.closest('.dropdown-toggle')) // Not Dropdown { if (e.target.hasAttribute('href') && e.target.closest('.fullscreen-nav')) { const href = e.target.getAttribute('href'); if (!href.startsWith('#')) // Anchor Link { return; } } hideNav(); } }); // Handle tint and close button touch events delegateSelector('body', "mousedown touchend", '.content-tint, .close-special-menu, .close-special-menu .close-icon', function(e) { hideNav(); }); // Animate Nav Items function animateNavItems() { var delay = 0; var increaseVal = 60; var animationStyle = "fadeInRight"; if (document.querySelector(".blocsapp-special-menu blocsnav").classList.contains("fullscreen-nav")) // Full Screen { animationStyle = "fadeIn"; increaseVal = 100; } else if (document.querySelector(".blocsapp-special-menu").classList.contains("nav-invert")) // Inverted { animationStyle = "fadeInLeft"; } document.querySelectorAll(".blocsapp-special-menu blocsnav li").forEach(navItem => { if (navItem.parentNode.classList.contains("dropdown-menu")) // Not dropdown menu { navItem.classList.add.apply(navItem.classList,["animated","fadeIn"]); } else { delay += increaseVal; navItem.classList.add.apply(navItem.classList,["animated",animationStyle]); navItem.setAttribute("style","animation-delay:"+delay+"ms") } }); } } // Hide special navigation menu function hideNav() { document.querySelector('.content-tint').classList.remove("on"); document.querySelector('.selected-nav').click(); setTimeout(function(){document.querySelector('.content-tint').remove();}, 10); } // Extra Nav Functions function setUpNavExtras() { // Programically added nav item clicks delegateSelector('body', "click", '.dropdown-menu a.dropdown-toggle', function(e) { menuPosition(e.target); }); document.querySelectorAll(".dropdown-menu a.dropdown-toggle").forEach(function(targetObj) { targetObj.addEventListener("click", function(e) { menuPosition(e.target); }); }); // Prevent multi level dropdown buttons resetting scroll position document.querySelectorAll("ul.dropdown-menu [data-toggle=dropdown]").forEach(function(targetObj) { targetObj.addEventListener("click", function(e) { e.stopPropagation(); }); }); // Set Sub Menu Position function menuPosition(target) { var parentMenu = target.closest(".dropdown-menu"); if (parentMenu) { var subMenu = target.parentNode.querySelector(".dropdown-menu"); if (!parentMenu.parentNode.classList.contains("navbar-nav")) { if (!target.closest(".nav-special")) // Vanilla navigation { var x = (parentMenu.offsetWidth - 2); var targetMenu = target.parentNode.querySelector(".dropdown-menu"); var targetMenuWidth = targetMenu.offsetWidth; subMenu.classList.remove('submenu-left'); if (targetMenuWidth == 0) { targetMenuWidth = 160; } if ((parentMenu.getBoundingClientRect().left+targetMenuWidth+x) > window.innerWidth) // Offscreen { subMenu.classList.add('submenu-left'); } } } } } } // Scroll to target function scrollToTarget(D,T) { var scrollY = window.scrollY || document.documentElement.scrollTop, currentTime = 0, speed = 1000, scrollTargetY = 0; // Top of page (default) if (D == 0) // Next Bloc { scrollTargetY = T.closest('.bloc').offsetHeight; } else if (D == 2) // Bottom of Page { scrollTargetY = document.documentElement.scrollHeight } else if (D != 1) // Specific Bloc { D = /^[.#]/.test(D) ? D : `#${D}`; scrollTargetY = document.querySelector(D).getBoundingClientRect().top + window.scrollY; var stickyNav = document.querySelector(".sticky-nav"); if (stickyNav) // Has sticky navigation { scrollTargetY -= stickyNav.offsetHeight; } } if (T) // Trigger Item Valid { if (T.matches("[data-scroll-speed]")) // Use assigned scroll speed { speed = parseInt(T.getAttribute("data-scroll-speed")); } } // Start Scroll Animation var time = Math.max(.1, Math.min(Math.abs(scrollY - scrollTargetY) / speed, .8)); // Animate Scroll Frames function animateFrame() { currentTime += 1 / 60; var pos = currentTime / time; var ease = Math.sin(pos * (Math.PI / 2)); var scrollPos = scrollTargetY; if (pos < 1) { requestAnimFrame(animateFrame); scrollPos = scrollY + ((scrollTargetY - scrollY) * ease); } window.scrollTo(0, scrollPos); } // Start Animation animateFrame(); } // Handle Sticky Blocs function stickyBlocs() { document.querySelectorAll('.sticky-bloc, .sticky-nav').forEach(stickyBloc => { if (stickyBloc) { var targetRect = stickyBloc.getBoundingClientRect(); var offsetVal = (targetRect.top + window.scrollY); // Offset Value var classes = ["sticky"]; // Classes var targetContainer = document.querySelector(".page-container"); var isFillScreenSticky = stickyBloc.classList.contains('fill-bloc-top-edge'); if (isFillScreenSticky) // Nav in Hero Bloc { classes = ["sticky","animated","fadeIn"]; targetContainer = document.querySelector(".fill-bloc-top-edge.sticky-nav").parentNode; } // Use stored Bloc offset if (stickyBloc.classList.contains('sticky')) { offsetVal = stickyBloc.getAttribute('data-original-offset') } // Get Current Padding Top var paddingTop = 0; // Get Sticky Blocs const stickyElements = document.querySelectorAll('.sticky'); if (stickyElements.length == 0) { // Current Bloc Height is Heigher Than Padding Top if (targetRect.height > paddingTop) { // Add Bloc Height paddingTop += targetRect.height; } } else { paddingTop = parseInt(window.getComputedStyle(targetContainer, null).getPropertyValue('padding-top')); } // Get Total Stiuck Bloc Height let totalStuckHeight = 0; // Loop All Stuck Blocs stickyElements.forEach(element => { totalStuckHeight += element.offsetHeight; }); // Get Sticky Offset var stickyOffset = 0; if (stickyElements.length > 0) { stickyOffset += totalStuckHeight; if (!stickyBloc.classList.contains('sticky')) { offsetVal -= stickyOffset; } } // Get Current Scroll Position var currentScrollTop = window.pageYOffset || document.documentElement.scrollTop; // Bloc is on Edge of Screen if (currentScrollTop > offsetVal) { if (!stickyBloc.classList.contains('sticky')) // Add Sticky { // Store Original Offset Scroll Position stickyBloc.setAttribute("data-original-offset",offsetVal); // Add Sticky Class To Bloc stickyBloc.classList.add.apply(stickyBloc.classList,classes); if (isFillScreenSticky) { stickyBloc.style.background = getBlocBgColor(targetContainer); } // Has Multiple Sticky Elements Adjust Top Padding if (stickyElements.length > 0) { paddingTop += targetRect.height; } // Set Page Container Top Padding Position targetContainer.style.paddingTop = paddingTop+'px'; // Set Sticky Bloc Top Position stickyBloc.style.top = stickyOffset+'px'; } } else if (stickyBloc.classList.contains('sticky')) // Remove Sticky { // Remove Sticky Attributes From Bloc stickyBloc.classList.remove.apply(stickyBloc.classList,classes); stickyBloc.removeAttribute("style"); // Reduce Top Padding paddingTop -= targetRect.height; if (paddingTop < 0) // Below 0 Reset to 0 { paddingTop = 0; } targetContainer.style.paddingTop = paddingTop+'px'; } } }); } // Get Bloc Background Color function getBlocBgColor(targetContainer) { var elementStyle = window.getComputedStyle(targetContainer ,null); var bgColor = elementStyle.getPropertyValue('background-color'); var bgImg = elementStyle.getPropertyValue('background-image'); if (targetContainer.classList.contains('b-parallax')) bgColor = window.getComputedStyle(targetContainer.querySelector('.parallax') ,null).getPropertyValue('background-color'); if (bgColor == "rgba(0, 0, 0, 0)" && bgImg.indexOf('gradient') ==-1) bgColor = '#FFFFFF'; // Prevent Transparent return bgColor; } // Hide all animation elements function hideAll() { document.querySelectorAll('.animated').forEach(targetObj => { if ((!document.body.classList.contains('mob-disable-anim')) || (document.body.classList.contains('mob-disable-anim') && window.innerWidth > 767)) { var targetRect = targetObj.getBoundingClientRect(); var targetObjX = targetRect.top + (targetObj.offsetHeight/3); if (targetObjX > window.innerHeight) // Animation item below fold { targetObj.classList.remove("animated"); targetObj.classList.add("hideMe"); } } }); } // Check if object is inView function inViewCheck() { const hiddenItems = [].slice.call(document.querySelectorAll('.hideMe'), 0).reverse(); hiddenItems.forEach(targetObj => { var targetRect = targetObj.getBoundingClientRect(); var offsetTop = (targetRect.top + window.scrollY); var a = offsetTop + targetObj.offsetHeight; var b = window.pageYOffset + window.innerHeight; if (targetObj.offsetHeight > window.innerHeight) // If object height is greater than window height { a = offsetTop } if (a < b) { var objectClass = targetObj.className.replace('hideMe','animated'); targetObj.style.visibility = "hidden"; targetObj.removeAttribute("class"); setTimeout(function(){ targetObj.style.visibility = "visible"; targetObj.setAttribute('class',objectClass); },0.01); // Listen for animation end events var animEvents = ["webkitAnimationEnd", "mozAnimationEnd", "oAnimationEnd", "animationEnd"]; animEvents.forEach(function(e) { window.addEventListener(e, function(event) { if (!targetObj.classList.contains('animLoopInfinite')) // Dont Remove Animation From Inifinite Loop { targetObj.classList.remove(targetObj.getAttribute("data-appear-anim-style")); } }); }); } }); }; // Handle Scroll To Top Button Visibility function scrollBtnVisible() { var scrollBtn = document.querySelector('.scrollToTop'); if (scrollBtn) { if (window.pageYOffset > (window.innerHeight/3)) { if (!scrollBtn.classList.contains('showScrollTop')) { scrollBtn.classList.add('showScrollTop'); } } else { scrollBtn.classList.remove('showScrollTop'); } } }; // Set Up Toggle Visibility function setUpVisibilityToggle() { document.querySelectorAll("[data-toggle-visibility]").forEach(function(targetObj) { targetObj.addEventListener("click", function(e) { e.preventDefault(); var targetID = e.currentTarget.getAttribute('data-toggle-visibility'); toggleElementVisibility(targetID); }); }); } // Toggle Visibility function toggleElementVisibility(targetID) { var targetArray = [targetID]; if (targetID.indexOf(',')!=-1) // Has multiple targets { targetArray = targetID.split(','); } targetArray.forEach(function(targetID) // Loop IDs { targetID = /^[.#]/.test(targetID) ? targetID : `#${targetID}`; var targetObj = document.querySelector(targetID); if (targetObj) // Item Exists { if (!targetObj.classList.contains('toggled-item')) // Add toggle class { targetObj.classList.add('toggled-item'); } if (window.getComputedStyle(targetObj, null).getPropertyValue("height") == '0px' || targetObj.classList.contains('object-hidden')) // Show { targetObj.classList.remove('object-hidden'); targetObj.style.removeProperty("display"); targetObj.style.height = 'auto'; var height = targetObj.clientHeight + 'px'; targetObj.style.height = '0px'; targetObj.offsetHeight; // Force Reflow targetObj.classList.remove("toggled-item-hidden"); setTimeout(function (){targetObj.style.height = height;}, 0); setTimeout(function (){targetObj.style.minHeight = height;targetObj.style.removeProperty("height");}, 360); } else // Hide { targetObj.style.height = targetObj.scrollHeight + 'px'; // Start height targetObj.offsetHeight; // Force Reflow targetObj.style.removeProperty("min-height"); // Remove min-height targetObj.classList.add('toggled-item-hidden'); window.setTimeout(function (){targetObj.style.height = "0"; if (targetObj.style.height == 0){targetObj.style.display = "none";}}, 0); // Set height to 0 } reCalculateParallax(); } }); } // Toggle Classes On Objects function setUpClassToggle() { document.querySelectorAll("[data-toggle-class-target]").forEach(function(targetObj) { targetObj.addEventListener("click", function(e) { e.preventDefault(); var targetID = e.currentTarget.getAttribute('data-toggle-class-target'); var targetClass = e.currentTarget.getAttribute('data-toggle-class'); if (targetClass.length) { if (targetID.indexOf(',')!=-1) // Multiple { var targeArray = targetID.split(','); targeArray.forEach(function(targetID) { document.getElementById(targetID).classList.toggle(targetClass); }); } else // Single { document.getElementById(targetID).classList.toggle(targetClass); } reCalculateParallax(); } }); }); } // Light box support function setUpLightBox() { window.targetJSLightbox; document.querySelectorAll("[data-lightbox]").forEach(function(lightboxObj) { lightboxObj.addEventListener("click", function(e) // Create lightbox Modal { e.preventDefault(); targetJSLightbox = lightboxObj; var lightBoxPath = targetJSLightbox.getAttribute('data-lightbox'); var caption = targetJSLightbox.getAttribute('data-caption'); var lightBoxFrame = targetJSLightbox.getAttribute('data-frame'); var protectionClass = ""; var autoplay = ""; if (targetJSLightbox.getAttribute('data-autoplay') == 1) // Has auto play { autoplay = "autoplay"; } // Check for image protection var lightboxImg = targetJSLightbox.querySelector('img'); if (lightboxImg) { if (lightboxImg.classList.contains('img-protected')) { protectionClass = "img-protected"; } } // Assign Modal var lbModal = document.querySelector('#lightbox-modal'); // Remove old Modal if (lbModal) { lbModal.remove(); } // Navigation icons var leftArrow = ''; var rightArrow = ''; var closeIcon = ''; // Image Tag var imageTag = '