/* global-animation.js =================== This file is included in inc-htmlbottom.php if animations are enabled. Please only place animations that are to be site wide in this file, otherwise please place Remember that animations are theme specific, meaning this file only effects the current theme that you are animating, and not every theme across the TemplateOTS platform. See detailed documentation here:- https://docs.google.com/document/d/1n5sWQ8SIr-zjOpTv8YnOTHJapO8WdedjDfbeo-lkqMM/edit#heading=h.lmxb59mpcpe2 */ /* FUNCTIONS ========= fRedirectAndFadeWebsiteOut() - Redirects and fades website out fFadeWebsiteIn() - Fades the website in */ /* fRedirectAndFadeWebsiteOut() ============================ Redirects to a new page and fades the website out, this is only done if the animation is enabled, otherwise the links work as they would by standard */ function fRedirectAndFadeWebsiteOut( sURL ) { // Fade the header container out TweenMax.to("body", 0.4, { opacity : 0, ease : Power2.easeOut } ); // After the animation has ended setTimeout(function () { // Redirect window.location = sURL; }, 400); } /* LOCAL COTNAINED WRAPPER ======================= Put all code here that you don't need to be accessed from the global scope of the website */ (function () { /* On Document Loaded ================== Called by Jquery event handler when the document is ready (When content has been loaded) */ $( document ).ready( function() { // Fade the website in fFadeWebsiteIn(); // If we are not on the homepage if( !$("#homepage-div").length ) { // Fade the navigation in TweenMax.to(".navigation", 0.8, { opacity : 1, ease : Power2.easeIn, delay : 0.25 } ); } // When any link is clicked $("a").click( function( oEvent) { // We need to check if we actually need to fade the website out, we do this by checking if the link conains javascript, or if the link has a hash tag. If it does have a hashtag we check to see if the anchor is going on another page // as if the anchor is going on another page we will need to redirect. If the anchor is going to the same page we are on now then we don't want to do a fade out as we aren't swapping pages. if( this.href != "" && this.href.toLowerCase().indexOf("javascript") === -1 && ( this.href.indexOf("#") === -1 || (this.anchor != "" && this.pathname != window.location.pathname ) ) ) { // If we are trying to click on a telephone or mailto link, then we also don't want to do the fading so handle that if( this.href.toLowerCase().indexOf("tel:") == -1 && this.href.toLowerCase().indexOf("mailto:") == -1) { // If we haven't clicked on a product since this is dealt with in index.js if( !$(this).hasClass("index-product") && !$(this).hasClass("social-icon") ) { // Finally, are we opening this in a new tab? if so no animation needed if( this.target != "_blank" ) { // Prevent the page from re-dir ecting oEvent.preventDefault(); // Redirect and fade the website fRedirectAndFadeWebsiteOut( this.href ); } } } } }); }); /* fFadeWebsiteIn() ================ This function is called when the website first loads, it simply fades the header container in */ function fFadeWebsiteIn() { // Fade the body in TweenMax.to("body", 0.8, { opacity : 1, ease : Power2.easeIn } ); } }());