/* THIS IS GLOBALLY INCLUDED ON EVERY PAGE. SO PUT STUFF HERE YOU NEED TO BE ON *EVERY* PAGE OF THE WEBSITE Previously called inc-htmlheader.js */ $(document).ready(function(){ if($('.datePicker').length) { $('.datePicker').datepicker({ minDate: 0, dateFormat: 'dd/mm/yy' }); } if($('.LangClose').length) { $('.LangClose').click(function(){ document.cookie="LanguageWidgetClose=1;path=/"; $("#LangSelect").remove(); }); } if($("#CurrencySelector").length) { $("#CurrencySelector").on("change",function(){ var oDate = new Date(); oDate.setTime(oDate.getTime() + (30*24*60*60*1000)); var sExpires = "expires="+oDate.toUTCString(); document.cookie="nCurrency_ID="+$(this).val()+"; path=/"; location.reload(); }); } }); function fLangChange($sLangAbbr, $sSURL) { var $bChange = 0; var $sNewURL = window.location.href; aLanguages.forEach(function($sTempLangAbbr){ console.log($sTempLangAbbr); if(window.location.href.indexOf("/"+$sTempLangAbbr+"/")>=0) { $sNewURL = $sNewURL.replace("/"+$sTempLangAbbr+"/","/"+$sLangAbbr+"/"); $bChange = 1; } }); if(!$bChange) { $sNewURL=$sSURL+$sLangAbbr+"/"; } window.location = $sNewURL; } // FOOTER SUBSCRIBE FORM // ===================== jQuery(document).ready(function(){ $('form#footerNewsletter').submit(function(e) { // stop form submitting (page load) e.preventDefault(); // get the name (if is exists) var emailName = ""; if($('input[name="sNewsName"]').length) emailName = $('input[name="sNewsName"]').val(); // get email address var emailAddress = $('input[name="sNewsEmailAddress"]').val(); // Check email address length if(emailAddress.length < 10) { alert("Your email address isn't valid"); } else { // Check if they've ticked the privacy policy box if( !$("#bNewsletter_PrivacyPolicy").is(":checked") ) { alert("Please tick the Privacy Policy box to confirm you've read our Privacy Policy before continuing."); } else { // ajax it $.ajax({ data: {sEmailName:emailName, sEmailAddress: emailAddress}, type: 'post', url: 'ajax/newsletter_exec.php', success: function(data) { // Append goal information to head $('head').append(data); // Alert user of sign up success //alert("Thank you for siging up to our mailing list!"); //fShowPageMessage("Thank you for siging up to our mailing list!"); // Clear the form if($('input[name="sNewsName"]').length) $('input[name="sNewsName"]').val(""); $('input[name="sNewsEmailAddress"]').val(""); $('input[name="sNewsEmailAddress"]').css('background-color',''); } }); } } }); }); /* fShowPrivacyPolicyPopUpMenu() ============================= This was created for newer themes to show the privacy policy checkbox when signing up to the newsletter in the footer, as it is requried for GDPR, but we don't want to display it in the footer as it takes up too much room. Please note that this currently isn't called from any older themes (Themes made before 2020), to find the submission for older newsletter forms (Shared footer etc) search for $('form#footerNewsletter').submit(function(e) To info on how it works, see below -: https://docs.google.com/document/d/1687TqhYId1D2JdCXBBM2MHIalXpe7YNAbsjDftOh7pM/edit#heading=h.6qsyyg8h66yp */ function fFooterNewsletter_ShowPrivacyPolicyModal() { // Show the modal $("#privacy-policy-modal").modal('show'); } /* fFooterNewsletter_OnKeyDown =========================== Prevent form being submited by pressing enter, instead open the modal To info on how it works, see below -: https://docs.google.com/document/d/1687TqhYId1D2JdCXBBM2MHIalXpe7YNAbsjDftOh7pM/edit#heading=h.6qsyyg8h66yp */ function fFooterNewsletter_OnKeyDown( oEvent ) { // If we press enter if( oEvent.which == 13 ) { // Stop the form from being submitted oEvent.preventDefault(); // Show the privacy modal instead fFooterNewsletter_ShowPrivacyPolicyModal(); } } // EMAIL CHECK // ============== function fCheckEmail(email) { var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; if(!re.test(email)) return "invalid"; else return true; } window.addEventListener('message', fReceiveMessage, false); function fReceiveMessage(e) { // only pass the message on if it's a valid ID var oValidCSSPattern = /^[a-zA-Z0-9\-]*$/; if(oValidCSSPattern.test(e.data)) { fScrollToDiv(e.data); } } // SCROLL TO DIV // ============== var fScrollToDivOffset = (function(){return 100;}); function fScrollToDiv($sCSSID) { var $oCSSSelector = $("#"+$sCSSID); $(".highlighted-div").removeClass("highlighted-div"); if($oCSSSelector.length > 0) { $oCSSSelector.addClass("highlightable-div"); $oCSSSelector.addClass("highlighted-div"); setTimeout(function(){ $oCSSSelector.removeClass("highlighted-div"); }, 2000); $('html,body').animate({ scrollTop: $oCSSSelector.offset().top-fScrollToDivOffset() }, 500); setTimeout(function(){ $('html,body').animate({ scrollTop: $oCSSSelector.offset().top-fScrollToDivOffset() }, 1); }, 600); } } $(window).on("load", function(){ parent.postMessage("loaded","*"); }); var processHeightJsNodes = []; function processHeightAdjust() { var processHeightJsNodes = processHeightJsNodes || []; if(! processHeightJsNodes[0]){ for (i = 0; i < arguments.length; i++) { processHeightJsNodes.push(document.getElementsByClassName(arguments[i])); } } for (i = 0; i < processHeightJsNodes.length; i++) { var max = 0; var elements = []; elements = processHeightJsNodes[i]; for (x = 0; x < elements.length; x++) { elements[x].style.setProperty("height","auto"); //elements[x].removeAttribute("style"); if(elements[x].clientHeight > max) max=Math.ceil(elements[x].clientHeight); } for (y = 0; y < elements.length; y++) { elements[y].style.setProperty("height",max+"px"); } } } function fShowPageMessage(sPageMessage, bHideCloseButton = false){ // Make sure the 2nd button is hidden by default // If we have teh additional page message buttons if($("#additionalPageMessageButton").length ) { // Hide them by default document.getElementById('additionalPageMessageButton').style.display='none'; } $("#page-message").html(sPageMessage); $("#page-message-modal").modal('show'); $('body').addClass("no-padding"); $('#page-message-modal').addClass("no-padding"); if (bHideCloseButton==true) { document.getElementById('modalCloseButton').style.display='none'; } else { document.getElementById('modalCloseButton').style.display=''; } } /* Shows page message, but allows an additional button next to the close button */ function fShowPageMessage_WithAdditionalButton(sPageMessage, sButtonText, oOnClickCallback ) { // If we have teh additional page message buttons if( $("#additionalPageMessageButton").length ) { // Store the additional button $("#additionalPageMessageButton").html(sButtonText); // On additional page message button clicked $("#additionalPageMessageButton").on("click", function() { // Unbind this event $("#additionalPageMessageButton").unbind( "click" ); // Invoke the callback if correctly typed if( typeof oOnClickCallback === 'function' ) { oOnClickCallback(); } // Otherwise log an error else { console.log("unable to invoke callback of page message, as passed type is not a function"); } }); } // Show the page message fShowPageMessage(sPageMessage, false); // Show the additional button document.getElementById('additionalPageMessageButton').style.display=''; } function fShowPageMessages() { if(aMessages.length > 0) { var sMessage = aMessages.shift(); fShowPageMessage(sMessage); $('#page-message-modal').on('hidden', function () { fShowPageMessages(); }); } } function fShowPageMessage_HTMLFromURL(sURLToGrabHTMLFrom, bHideCloseButton = false){ $.get( sURLToGrabHTMLFrom, function( data ) { $("#page-message").html(data); $("#page-message-modal").modal('show'); $('body').addClass("no-padding"); $('#page-message-modal').addClass("no-padding"); if (bHideCloseButton==true) { document.getElementById('modalCloseButton').style.display='none'; } else { document.getElementById('modalCloseButton').style.display=''; } }); }