// load scripts for replaced elements var isExecuteLoad = false; document.addEventListener('swup:pageView', function(e) { $( document ).trigger('inizialize'); if (isExecuteLoad) { $( document ).trigger('executeReady'); $( window ).trigger('load'); } else { $('.transition-fade').addClass('finished'); } isExecuteLoad = true; }); document.addEventListener('swup:transitionStart', function(e) { $('.transition-fade').removeClass('finished'); $(document).trigger('removeEvent'); }); document.addEventListener("swup:transitionEnd", function(e){ $('.transition-fade').addClass('finished'); }); $.fn.isInViewport = function(offset) { var $el = $(this); if (offset === undefined) offset = 50; var elementTop = $el.offset().top; var elementBottom = elementTop + ($el.outerHeight() * offset / 100); var viewportHeight = $(window).height(); var viewportToll = 15; var viewportTop = $(window).scrollTop() - viewportToll; var viewportBottom = viewportTop + viewportHeight + (viewportToll * 2.0); if (offset < 0) return elementTop < viewportBottom && elementBottom < viewportBottom; else { return elementBottom >= viewportTop && elementTop < viewportBottom && elementBottom < viewportBottom; } }; var loadScript = function (path) { var result = $.Deferred(); var script = document.createElement("script"); script.async = "async"; script.type = "text/javascript"; script.src = path; script.onload = script.onreadystatechange = function(_, isAbort) { if (!script.readyState || /loaded|complete/.test(script.readyState)) { if (isAbort) result.reject(); else result.resolve(); } }; script.onerror = function () { result.reject(); }; $("head")[0].appendChild(script); return result.promise(); } function getCookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie.replace(/\+/g, ' ')); var ca = decodedCookie.split(';'); for(var i = 0; i ') }); $('.clm-recaptcha').each(function( index ) { recaptcha_form = $(this).closest("form"); // recupera la callback success per il recaptcha di google del form, // se non esiste mette quella di default if (recaptcha_form.data('gcallback') === undefined) gcallback = onSuccessRecaptcha; else gcallback = window[recaptcha_form.data('gcallback')]; // render il recaptcha clmrecaptchaID[index] = this.id; clmrecaptchaFunc[index] = grecaptcha.render(this.id, { 'sitekey' : '6Lcgo40oAAAAAKmq7ho-uG-fj3-SY3gYthMchoQe', 'callback' : gcallback, 'error-callback' : onErrorRecaptcha, 'size' : 'invisible' }); }); }; $(window).on("load resize scroll", function() { if ($(".googlemaps").length > 0) { if ($(".googlemaps").isInViewport(0) && !isMapsLoaded) { isMapsLoaded = true; var lang = getCookie('lang'); loadScript("https://www.hotelmaryrose.it/js/gmap.js.php").then(function() { var googleMap = document.createElement("script"); googleMap.src = "//maps.googleapis.com/maps/api/js?key=AIzaSyB7QNGNqzCne7q66JsCINlDWWcx9OzPyFw&callback=mapsCallback&language="+lang; googleMap.async = true; googleMap.defer = true; document.body.appendChild(googleMap); }); } } }); function adsBlocked(callback){ var testURL = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js' var myInit = { method: 'HEAD', mode: 'no-cors' }; try { var myRequest = new Request(testURL, myInit); fetch(myRequest).then(function(response) { return response; }).then(function(response) { callback(false) }).catch(function(e){ callback(true) }); } catch (e) { callback(false) }; } function showStatusCookie() { var policyCookieConsent = getCookie('policyCookieConsent'); var policyCookiePreferences = getCookie('policyCookiePreferences'); var policyCookieStatistics = getCookie('policyCookieStatistics'); var policyCookieMarketing = getCookie('policyCookieMarketing'); var policyCookieUnique = getCookie('policyCookieUnique'); var policyCookieLanguage = 0; if (getCookie('lang_id') != 1) policyCookieLanguage = 1; var txtPolicyCookieStatusDeclineDef = ['Rifiuta', 'Reject']; var txtPolicyCookieStatusConfirmDef = ['Accetta selezionati', 'Allow selection']; var txtPolicyCookieStatusNecessaryDef = ['Tecnici', 'Technical']; var txtPolicyCookieStatusPreferencesDef = ['Preferenze', 'Preference']; var txtPolicyCookieStatusStatisticsDef = ['Statistici', 'Statistical']; var txtPolicyCookieStatusMarketingDef = ['Marketing', 'Marketing']; var txtPolicyCookieStatus = "---"; var txtPolicyCookieStatusSelect = ""; var txtPolicyCookieDate = '---'; var txtPolicyCookieUnique = '---'; if (policyCookieConsent == "") { $('.cookie-btn-erase').hide(); } else if (policyCookieConsent == "0") { txtPolicyCookieStatus = txtPolicyCookieStatusDeclineDef[policyCookieLanguage]; txtPolicyCookieStatusSelect = '('+txtPolicyCookieStatusNecessaryDef[policyCookieLanguage]+')'; txtPolicyCookieDate = getCookie('policyCookieDate'); } else if (policyCookieConsent == "1") { txtPolicyCookieStatus = txtPolicyCookieStatusConfirmDef[policyCookieLanguage]; txtPolicyCookieStatusSelect = '('+txtPolicyCookieStatusNecessaryDef[policyCookieLanguage]; if (policyCookiePreferences == "1") txtPolicyCookieStatusSelect += ', '+txtPolicyCookieStatusPreferencesDef[policyCookieLanguage]; if (policyCookieStatistics == "1") txtPolicyCookieStatusSelect += ', '+txtPolicyCookieStatusStatisticsDef[policyCookieLanguage]; if (policyCookieMarketing == "1") txtPolicyCookieStatusSelect += ', '+txtPolicyCookieStatusMarketingDef[policyCookieLanguage]; txtPolicyCookieStatusSelect += ')'; txtPolicyCookieDate = getCookie('policyCookieDate'); } if (policyCookieUnique != "") txtPolicyCookieUnique = policyCookieUnique; $('.statusConsent').html(txtPolicyCookieStatus + ' ' +txtPolicyCookieStatusSelect); $('.dateConsent').html(txtPolicyCookieDate); $('.dateUniqueId').html(txtPolicyCookieUnique); } $(window).on("load", function() { showStatusCookie(); $(window).off('eventCookieUpdate'); $(window).on('eventCookieUpdate', function() { var policyCookieUnique = getCookie('policyCookieUnique'); var sendInfo = { 'p': !window.policyCookiePreferences, 's': !window.policyCookieStatistics, 'm': !window.policyCookieMarketing, 'i': '80.88.84.54', 'u': 'www.hotelmaryrose.it', 't': 0, }; if (policyCookieUnique != "") sendInfo['uq'] = policyCookieUnique; if (policyCookieRequired1 == '0') sendInfo['d'] = true; $.ajax({ type: "PUT", url: 'https://registro-cookie.colombo3000.com/api/update', beforeSend: function (xhr) { xhr.setRequestHeader('Authorization', 'Bearer t-7614f875-8423-4f20-a674-d7cf3096290e'); }, data: JSON.stringify(sendInfo), contentType: "application/json; charset=utf-8", }) .done(function(datiJSON){ SetCookie('policyCookieUnique', datiJSON.uq, 365); $('.dateUniqueId').html(datiJSON.uq); }) .fail(function(data, textStatus, errorThrown) { }); }); var lang = getCookie('lang'); $('form input, form select, form textarea, form button').bind('focus.recaptcha', function() { loadScript("https://www.hotelmaryrose.it/js/recaptcha.js.php").then(function() { var googleRecaptcha = document.createElement("script"); googleRecaptcha.src = "https://www.google.com/recaptcha/api.js?hl="+lang+"&onload=onloadCallback&render=explicit"; googleRecaptcha.async = true; googleRecaptcha.defer = true; document.body.appendChild(googleRecaptcha); adsBlocked(function(blocked){ var exdate = new Date() var n = document.location.hostname.split("."); var e = n.slice(1).join("."); exdate.setDate(exdate.getDate() + 1) var value = 0; if (blocked) value = 1; document.cookie = "adblock=" + escape(value) + ";path=/;expires="+exdate.toGMTString(); }) }); $('form input, form select, form textarea, form button').unbind('focus.recaptcha'); }); }); lazyExecute = function(el) { $(el).lazy({ delay:-1, afterLoad: function(element) { $.event.trigger({ type: "lazyAfterLoad", time: new Date(), element : element }); $(window).trigger('resize'); }, onFinishedAll: function() { $.event.trigger({ type: "lazyComplete", time: new Date() }); $(window).trigger('resize'); } }); } $(window).on('load', function() { $('.lazy').each(function() { if ($(this).closest('.waitLazyLoad').length == 0) { lazyExecute(this); } }); }); // lunghezza calcolata al caricamento della pagina e ad ogni resize della schermata var actualWidth; $( document ).ready(function() { $(document).trigger('executeReady'); }); $( document ).on('executeReady', function() { $(document).on('change', '[type="radio"]', function() { var name = $(this).attr('name'); $('[name="'+name+'"]').removeAttr('required'); }); $("#bottom-to-top").click(function() { $("html, body").animate({ scrollTop: 0 }, "slow"); return false; }); $('[data-toggle="tooltip"]').tooltip(); $( ".table" ).each(function( index ) { if (!$(this).parent().hasClass("table-responsive")) { $(this).wrap( "
" ); } }); $('.carousel').carousel(); $('.modal').modal('hide'); $('.dropdown-submenu > a').on("click", function(e) { e.preventDefault(); var submenu = $(this); var isShow = submenu.next('.dropdown-menu').hasClass('show'); $('.dropdown-submenu .dropdown-menu').removeClass('show'); if (!isShow) { submenu.next('.dropdown-menu').addClass('show'); } e.stopPropagation(); }); $('.dropdown').on("hidden.bs.dropdown", function() { // hide any open menus when parent closes $('.dropdown-menu.show').removeClass('show'); }); //One Animated /* var is_iOS = ( /iPhone|iPad|iPod/i.test(navigator.userAgent) ); // le animazioni waypoint laterali estendono la pagina causando problemi di visualizzazione nei sistemi operativi IOS // le animazioni waypoint disabilitate if(is_iOS) { $('.animated').css("opacity", "1"); } else { */ $('.animated:not([data-delay],[data-order])').each(function() { var element = this.element; if (element === undefined) $element = $(this); else $element = $(element); var offset = $element.data('offset'); if (typeof offset === 'undefined') offset = 80; var context = window; var horizontal = false; var data_context = $element.data('context'); if (data_context !== undefined) { context = document.getElementById(data_context) horizontal = true; } $(this).waypoint(function() { var element = this.element; if (element === undefined) $element = $(this); else $element = $(element); var myAnimated = $element.data('animated'); var oneSomeAnimated = $element.data('oneanimated'); // animazione da eseguire una singola volta if (oneSomeAnimated == true) { // animazione non e' stata gia' eseguita in tal caso la esegue if (!($element.hasClass(myAnimated))) $element.toggleClass($element.data('animated')).css("opacity", "1"); // animazione da eseguire sempre } else $element.toggleClass($element.data('animated')); }, { offset: offset+'%', context: context, horizontal: horizontal, }); }); $('.animated[data-order="0"]').each(function() { var element = this.element; if (element === undefined) $element = $(this); else $element = $(element); var offset = $element.data('offset'); if (typeof offset === 'undefined') offset = 80; var context = window; var horizontal = false; var data_context = $element.data('context'); if (data_context !== undefined) { context = document.getElementById(data_context) horizontal = true; } $(this).waypoint(function() { var element = this.element; if (element === undefined) $element = $(this); else $element = $(element); if ($element.hasClass('execute')) return; var myAnimated = $element.data('animated'); var group = $element.data('group'); $element.addClass("execute").addClass($element.data('animated')).css("opacity", "1"); $('[data-group="'+group+'"]').each(function( index ) { var el = $(this); var delay = el.data('delay') * el.data('order'); setTimeout( function() { el.addClass("execute").addClass(el.data('animated')).css("opacity", "1"); }, delay, el); }); }, { offset: offset+'%', context: context, horizontal: horizontal, }); }); $('.animated[data-delay="0"]').each(function() { var element = this.element; if (element === undefined) $element = $(this); else $element = $(element); var offset = $element.data('offset'); if (typeof offset === 'undefined') offset = 80; var context = window; var horizontal = false; var data_context = $element.data('context'); if (data_context !== undefined) { context = document.getElementById(data_context) horizontal = true; } $(this).waypoint(function() { var element = this.element; if (element === undefined) $element = $(this); else $element = $(element); if ($element.hasClass('execute')) return; var myAnimated = $element.data('animated'); var group = $element.data('group'); $element.addClass("execute").addClass($element.data('animated')).css("opacity", "1"); $('[data-group="'+group+'"]').each(function( index ) { var el = $(this); var delay = el.data('delay'); setTimeout( function() { el.addClass("execute").addClass(el.data('animated')).css("opacity", "1"); }, delay, el); }); }, { offset: offset+'%', context: context, horizontal: horizontal, }); }); /* } */ // Effect input $(document).on("blur", 'form input, form textarea, form select', function(){ if($(this).val().length !== 0) { $(this).addClass('filled'); } else { $(this).removeClass('filled'); } }); }); // Inizializza l'effetto input function init_form(form_id) { $.each($('input, textarea, select', '#'+form_id),function(e){ if($(this).val().length !== 0) { $(this).addClass('filled'); } else { $(this).removeClass('filled'); } }) } var isIE = /*@cc_on!@*/false || !!document.documentMode; if (!isIE) { var options = { LINK_SELECTOR: 'a[href^="https://www.hotelmaryrose.it/"]:not([data-no-swup]):not([class^="thumb"]), a[href^="#"]:not([data-no-swup]):not([class^="thumb"])', cache:false, skipPopStateHandling: function(event){ if (event.state === null) return false; if (event.state && event.state.source == "swup" && !window.photoswipe_open) { return false; } window.photoswipe_open = false; return true; } }; var swup = new Swup(options); swup.use(new SwupHeadPlugin()); swup.use(new SwupScrollPlugin({functionOffset: "functionOffset"})); swup.use(new SwupPreloadPlugin()); swup.use(new SwupBodyClassPlugin()); const bodyClassPlugin = new SwupBodyClassPlugin({ prefix: 'page-' }); } var sendVirtualEvent = function(eventForce, eventItem) { if (eventForce === undefined) eventForce = ""; if (eventItem === undefined) eventItem = null; $.post({ url: "https://www.hotelmaryrose.it/admin/includes/ajax/ajax_frontend.php", data: { "type": "sendVirtualEvent", "url" : window.location.href, "lang" : getCookie('lang'), "eventForce" : eventForce, "eventItem" : eventItem, } }) .done(function(data ) { datiJSON = JSON.parse(data); if (datiJSON.event != "") { window.dataLayer.push({ event: datiJSON.event, event_name: datiJSON.event_name, item: datiJSON.item, }); } }); } /*var pageParams; var dateCheckIn; var dateCheckOut;*/ var tme_popup = null; swup.on('transitionStart', function() { if (tme_popup != null) { clearTimeout(tme_popup); } tme_popup = null; if ($(".modal-backdrop").length > 0) { var $modalBackdrop = $('.modal-backdrop').detach(); $('#swup').append($modalBackdrop); } }); $(window).on('load', function() { $('.modal').on('shown.bs.modal', function (e) { var $modalBackdrop = $('.modal-backdrop').detach(); $('#swup').append($modalBackdrop); }); if ($('.pswp').length > 0) { loadScript("https://www.hotelmaryrose.it/js/jquery.photoswipe.min.js").then(function() { loadScript("https://www.hotelmaryrose.it/js/simple-gallery.min.js").then(function() {}); }); } if ($('.gallery-mas').length > 0) { loadScript("https://www.hotelmaryrose.it/js/imagesloaded.pkgd.min.js").then(function() { loadScript("https://www.hotelmaryrose.it/js/masonry.pkgd.min.js").then(function() { loadScript("https://www.hotelmaryrose.it/js/masonry.clm.min.js.php").then(function() {}); }); }); } if ($('.cmsdate').length > 0) { var lang = getCookie('lang'); $('', { rel: 'stylesheet', type: 'text/css', href: 'https://www.hotelmaryrose.it/css/bootstrap-datepicker.min.css' }).appendTo('head'); var dt = new Date().toISOString().split('.')[0].replace(/[^\d]/gi,''); loadScript("https://www.hotelmaryrose.it/js/bootstrap-datepicker.min.js").then(function() { loadScript("https://www.hotelmaryrose.it/js/bootstrap-datepicker."+lang+".min.js").then(function() { loadScript("https://www.hotelmaryrose.it/js/cmsdate.min.js.php?"+dt).then(function() {}); }); }); } /*NAVBAR COLLAPSED CLICK BUTTON*/ isMenuOpen = false; $(document).off("click", ".navbar-toggler"); $(document).on("click", ".navbar-toggler", function() { var nav = $(this).parents("#top_content").first(); if (!isMenuOpen) { isMenuOpen = true; nav.addClass("collapsed-open"); } else { isMenuOpen = false; nav.removeClass("collapsed-open"); } }); /*NAVBAR SCROLLING EFFECT*/ if($(window).scrollTop() > 50) { $("#top_content").addClass("scrolling"); } else { $("#top_content").removeClass("scrolling"); } /*if($("#availability").length > 0) { pageParams = new URLSearchParams(window.location.search); if(pageParams != '') { dateCheckIn = pageParams.get('field_date'); dateCheckOut = pageParams.get('field_date_end'); $("#field_date_in").val(dateCheckIn); $("#field_date_Out").val(dateCheckOut); $("#field_date_in").trigger("change"); setTimeout(function() { $("#field_date_out").trigger("change"); }, 200); } }*/ $(".cmsdate").change(function() { var lang = getCookie('lang'); if($(this).val() != '') { var bookDate = new Date($(this).datepicker('getDate')); var bookDateString = bookDate.toString(); var bookDayNumMonth = bookDateString.split(" ")[2]; var bookNumMonth = bookDate.getMonth(); var bookingFieldWrapper = $(this).parents(".input-wrapper").first(); bookingFieldWrapper.find(".lbl-date-day").first().html(bookDayNumMonth); bookingFieldWrapper.find(".lbl-date-month").first().html($.fn.datepicker.dates[lang].months[bookNumMonth]); } }); $("#field_date_in").change(function() { var endDateDay = $(".end-date-wrapper .lbl-date-day"); var endDateMonth = $(".end-date-wrapper .lbl-date-month"); var nightsDate = $(".nights-date-wrapper .form-control"); endDateDay.html("--"); endDateMonth.html(""); nightsDate.val(""); }); $("#field_date_out").change(function() { if($(this).val() != '') { var startDate = $("#field_date_in").datepicker('getDate'); var endDate = $("#field_date_out").datepicker('getDate'); var difference_In_Time = Math.abs(endDate - startDate); var difference_In_Days = Math.ceil(difference_In_Time / (1000 * 60 * 60 * 24)); if($(".nights-date-wrapper").length > 0) { var nightsDate = $(".nights-date-wrapper .form-control"); nightsDate.val(difference_In_Days); } } }); $(".input-operating-field .form-control").each(function() { $(this).val(0); }); // PULSANTE + $(document).off("click", ".input-plus"); $(document).on("click", ".input-plus", function() { var btnElem = $(this); var operatingBox = btnElem.parents(".input-operating-field").first(); var targetInput = operatingBox.find(".form-control"); var inputCurrentVal = parseInt(targetInput.val()); // AUMENTO IL VALORE DEL CAMPO inputCurrentVal++; targetInput.val(inputCurrentVal); targetInput.trigger("change"); }); // PULSANTE - $(document).off("click", ".input-minus"); $(document).on("click", ".input-minus", function() { var btnElem = $(this); var operatingBox = btnElem.parents(".input-operating-field").first(); var targetInput = operatingBox.find(".form-control"); var inputCurrentVal = parseInt(targetInput.val()); if(inputCurrentVal > 0) { // DIMINUISCO IL VALORE DEL CAMPO inputCurrentVal--; targetInput.val(inputCurrentVal); } targetInput.trigger("change"); }); $(".input-operating-field #bambini").change(function() { var childrenInput = $(this); var childrenNum = childrenInput.val(); if(childrenNum > 0) { // MOSTRO IL CAMPO ETÀ BAMBINO E NUMERO CULLE $(".input-clone").addClass("show"); $(".input-cots").addClass("show"); } else { // NASCONDO I CAMPI ETÀ BAMBINO E NUMERO CULLE $(".input-clone").removeClass("show"); $(".input-cots").removeClass("show"); // AZZERO I CAMPI ETÀ BAMBINO E NUMERO CULLE $(".input-clone .form-control").val(0); $(".input-cots .form-control").val(0); } if(childrenNum >= 2) { // COPIO IL CAMPO ETÀ BAMBINO var inputClone = $(".input-clone").clone(); inputClone.removeClass("input-clone"); inputClone.addClass("input-clone-num-"); inputClone.find(".form-control").val(0); // INCOLLO IL CAMPO ETÀ BAMBINO inputClone.insertAfter($(".input-clone")); } }); }); $(window).on('scroll', function() { /*NAVBAR SCROLLING EFFECT*/ if($(window).scrollTop() > 50) { $("#top_content").addClass("scrolling"); } else { $("#top_content").removeClass("scrolling"); } }); $(window).on('resize', function() { if(window.innerWidth > 767 && isMenuOpen) { $(".navbar-toggler").trigger("click"); } }); var isGliderLoaded = false; $( document ).on('inizialize', function() { isGliderLoaded = false; }); $(window).on("load resize scroll", function() { if ($(".glider").length > 0) { if ($(".glider").isInViewport(-10) && !isGliderLoaded) { $('', { rel: 'stylesheet', type: 'text/css', href: 'https://www.hotelmaryrose.it/css/glider.min.css' }).appendTo('head'); isGliderLoaded = true; loadScript("https://www.hotelmaryrose.it/js/glider.min.js").then(function() { loadScript("https://www.hotelmaryrose.it/js/glider.clm.min.js.php").then(function() {}); }); } } });$(window).on('load', function(){ }); $(window).on('load', function(){ $(document).off("click", ".attraction-preview-container .show-attraction-btn"); $(document).on("click", ".attraction-preview-container .show-attraction-btn", function() { var showBtn = $(this); showBtn.parents(".attraction-preview-container").first().addClass("reveal"); showBtn.parents(".attraction-preview-container").find(".attraction-hidden-part").slideDown(); }); $(document).off("click", ".attraction-preview-container .hide-attraction-btn"); $(document).on("click", ".attraction-preview-container .hide-attraction-btn", function() { var hideBtn = $(this); hideBtn.parents(".attraction-preview-container").find(".attraction-hidden-part").slideUp(); setTimeout(function() { hideBtn.parents(".attraction-preview-container").first().removeClass("reveal"); }, 500); }); });