var sendVirtualFBApi = function() { rand_event_id = randomInt(1000000); window.dataLayer.push({ event: 'VirtualFBApi', event_random_id: rand_event_id }); } document.addEventListener('swup:willReplaceContent', function(e) { sendVirtualFBApi(); }); // 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' : '6LeQ3Q0fAAAAAJ85IBHH3NWb1HjIZl5ghOncqNdE', '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.palazzodellascala.com/js/gmap.js.php").then(function() { var googleMap = document.createElement("script"); googleMap.src = "//maps.googleapis.com/maps/api/js?key=AIzaSyCzkvYwNKOCbKtm9X866wtOHUfV9JOaLjM&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', 'Rifiuta']; var txtPolicyCookieStatusConfirmDef = ['Accetta selezionati', 'Accetta selezionati']; var txtPolicyCookieStatusNecessaryDef = ['Tecnici', 'Tecnici']; var txtPolicyCookieStatusPreferencesDef = ['Preferenze', 'Preferenze']; var txtPolicyCookieStatusStatisticsDef = ['Statistici', 'Statistici']; 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.87.20', 'u': 'www.palazzodellascala.com', '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.palazzodellascala.com/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, force) { if (force === undefined) force = true; var instance = $(el).lazy({ chainable: !force, delay:-1, afterLoad: function(element) { $(element).addClass('lazy-loaded'); $.event.trigger({ type: "lazyAfterLoad", time: new Date(), element : element }); }, onFinishedAll: function() { $.event.trigger({ type: "lazyComplete", time: new Date() }); } }); if (force) instance.force($(el)); } var scroll = null; var previousScroll = 0; var changeScroll = 0; var isGliderLoadedScroll = false; var isMasonryLoadedScroll = false; var scroll = null; var scrollWindowWidth = 0; var idxLazyImg = 0; var idxLazyVideo = 0; var idxLazyFrame = 0; var $aLazyPicture = null; var $aLazyVideo = null; var $aLazyFrame = null; var $aLazyStarted = false; var scroolUpdateAfterLazy = true; $( document ).on('inizialize', function() { previousScroll = 0; isGliderLoadedScroll = false; isMasonryLoadedScroll = false; if (scroll !== null) { scroll.destroy(); scroll = null; } idxLazyImg = 0; idxLazyVideo = 0; idxLazyFrame = 0; $aLazyPicture = null; $aLazyVideo = null; $aLazyFrame = null; $aLazyStarted = false; scroolUpdateAfterLazy = true; }); $(window).on('lazyComplete', function() { if ($aLazyStarted) lazy_load(); }); var lazy_load = function() { if ($($aLazyPicture[idxLazyImg]).hasClass('lazy-loaded')) { idxLazyImg++; lazy_load(); return; } if (idxLazyImg < $aLazyPicture.length) { lazyExecute($aLazyPicture[idxLazyImg]); idxLazyImg++; } else { if ((idxLazyImg == $aLazyPicture.length) && (scroll !== null)) { idxLazyImg++; if (scroolUpdateAfterLazy) { setTimeout(function() { if (scroll !== null) { scroll.update(); $(document).trigger('scrollUpdateImage'); } }, 2000); } else { $(document).trigger('scrollUpdateImage'); } } if ($($aLazyVideo[idxLazyVideo]).hasClass('lazy-loaded')) { idxLazyVideo++; lazy_load(); return; } if (idxLazyVideo < $aLazyVideo.length) { lazyExecute($aLazyVideo[idxLazyVideo]); idxLazyVideo++; } else { if ((idxLazyVideo == $aLazyVideo.length) && (scroll !== null)) { idxLazyVideo++; if (scroolUpdateAfterLazy) { setTimeout(function() { if (scroll !== null) { scroll.update(); $(document).trigger('scrollUpdateVideo'); } }, 2000); } else { $(document).trigger('scrollUpdateVideo'); } } if ($($aLazyFrame[idxLazyFrame]).hasClass('lazy-loaded')) { idxLazyFrame++; lazy_load(); return; } if (idxLazyFrame < $aLazyFrame.length) { lazyExecute($aLazyFrame[idxLazyFrame]); idxLazyFrame++; } else { if ((idxLazyFrame == $aLazyFrame.length) && (scroll !== null)) { idxLazyFrame++; if (scroolUpdateAfterLazy) { setTimeout(function() { if (scroll !== null) { scroll.update(); $(document).trigger('scrollUpdateFrame'); } }, 2000); } else { $(document).trigger('scrollUpdateFrame'); } } } } } } var scroll_call_load = function(obj) { $('[data-scroll-call="load"]').removeAttr('data-scroll-call'); $aLazyStarted = true; lazy_load(); setTimeout(function() { if ($('.glider').length > 0) { if (!isGliderLoadedScroll) { $('', { rel: 'stylesheet', type: 'text/css', href: 'https://www.palazzodellascala.com/css/glider.min.css' }).appendTo('head'); isGliderLoadedScroll = true; loadScript("https://www.palazzodellascala.com/js/glider.min.js").then(function() { loadScript("https://www.palazzodellascala.com/js/glider.clm.min.js.php").then(function() {}); }); } } if ($('.gallery-mas').length > 0) { if (!isMasonryLoadedScroll) { isMasonryLoadedScroll = true; loadScript("https://www.palazzodellascala.com/js/imagesloaded.pkgd.min.js").then(function() { loadScript("https://www.palazzodellascala.com/js/masonry.pkgd.min.js").then(function() { loadScript("https://www.palazzodellascala.com/js/masonry.clm.min.js.php").then(function() {}); }); }); } } $(document).trigger('scrollCallLoad'); }, 1000); }; $(window).on('load', function() { $aLazyPicture = $('picture.lazy, img.lazy'); $aLazyVideo = $('video.lazy'); $aLazyFrame = $('iframe.lazy'); scrollWindowWidth = $(window).width(); var locomotive_arg = { el: document.querySelector('[data-scroll-container]'), smooth: true, lerp: scrollWindowWidth < 960 ? .1 : .06, touchMultiplier: 2.5, }; if ($('[data-scroll-scrollbar]').length > 0) { locomotive_arg['scrollbarClass'] = 'c-myscrollbar'; } scroll = new LocomotiveScroll(locomotive_arg); $(document).trigger('scrollLoaded'); if ($('[data-scroll-call="load_delay"]').length > 0) { $('[data-scroll-call="load_delay"]').removeAttr('data-scroll-call'); setTimeout(function() { if ($('[data-scroll-call="load"]').length > 0) scroll_call_load(); }, 1000); } scroll.on("call", (fun, dir, obj) => { if (fun === "load") { scroll_call_load(obj); } }); $(document).on('click', 'a[href^="#"]', function(e) { e.preventDefault(); var elTo = $(this).attr('href'); if (elTo == "#") return false; scroll.scrollTo($(elTo)[0], { 'offset': -functionOffset(), 'duration': 1000 } ); return false; }); }); // 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).off('change', '[type="radio"]'); $(document).on('change', '[type="radio"]', function() { var name = $(this).attr('name'); $('[name="'+name+'"]').removeAttr('required'); }); $(document).off('change', 'select'); $(document).on('change', 'select', function() { if ($(this).val() !== "") { $(this).addClass('selected'); } else { $(this).removeClass('selected'); } }); $("#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'); if (typeof myAnimated === 'undefined') myAnimated = 'in-view'; // 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(myAnimated).css("opacity", "1"); // animazione da eseguire sempre } else $element.toggleClass(myAnimated); }, { 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'); if (typeof myAnimated === 'undefined') myAnimated = 'in-view'; $element.addClass("execute").addClass(myAnimated).css("opacity", "1"); $('[data-group="'+group+'"]').each(function( index ) { var el = $(this); var delay = el.data('delay') * el.data('order'); setTimeout( function() { var elAnimated = el.data('animated'); if (typeof elAnimated === 'undefined') elAnimated = 'in-view'; el.addClass("execute").addClass(elAnimated).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'); if (typeof myAnimated === 'undefined') myAnimated = 'in-view'; $element.addClass("execute").addClass(myAnimated).css("opacity", "1"); $('[data-group="'+group+'"]').each(function( index ) { var el = $(this); var delay = el.data('delay'); setTimeout( function() { var elAnimated = el.data('animated'); if (typeof elAnimated === 'undefined') elAnimated = 'in-view'; el.addClass("execute").addClass(elAnimated).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 sendVirtualEvent = function(eventForce, eventItem) { if (eventForce === undefined) eventForce = ""; if (eventItem === undefined) eventItem = null; $.post({ url: "https://www.palazzodellascala.com/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 fbCapi = function(eventForce = "") { if (eventForce === undefined) eventForce = ""; if (eventForce != "") { sendVirtualFBApi(); } if (rand_event_id !== undefined) { var page = window.location.href; $.post({ url: "https://www.palazzodellascala.com/admin/includes/ajax/ajax_frontend.php", data: { "type": "fbCapi", "url" : page, "eventForce" : eventForce, "event_random_id" : rand_event_id, } }) .done(function(data ) { datiJSON = JSON.parse(data); if (datiJSON.event_send != "") { window.dataLayer.push({ event: datiJSON.event_send, fb_event_name: datiJSON.fb_event_name, }); } }) } } $( window ).on('load', function() { fbCapi(); $("[class*='gtag_phone']").on('click', function(e) { fbCapi('LeadPhone'); }); $("[class*='gtag_mail']").on('click', function(e) { fbCapi('LeadMail'); }); $("[class*='gtag_whatsapp']").on('click', function(e) { fbCapi('LeadWhatsapp'); }); $("[class*='gtag_map']").on('click', function(e) { fbCapi('ClickMap'); }); }); var supportsCssVariables = (window.CSS && window.CSS.supports && window.CSS.supports('--fake-var', 0)); function functionOffset() { var offsetH = $('#top_content').outerHeight(true); return offsetH; }; $(window).on('load', function() { /*BANNER POPUP*/ if ($('#banner_popup').length > 0) $('#banner_popup').modal('show'); }); var myInterval = null; var $logo = undefined; var hasCollideLogoLast = false; var hasCollideLogoActual = false; var $top_content = undefined; var $main = undefined; var hasCollideTopLast = false; var hasCollideTopActual = false; var menuTriggered = false; $( document ).on('inizialize', function() { hasCollideLogoLast = false; hasCollideLogoActual = false; menuTriggered = false; hasTopLast = false; hasTopActual = false; if (myInterval != null) clearInterval(myInterval); $('.sb__svg-sprite').parent().detach(); }); function isCollide(a, b) { if ((a === undefined) || (b === undefined)) return false; var aRect = a.getBoundingClientRect(); var bRect = b.getBoundingClientRect(); return !( ((aRect.top + aRect.height) < (bRect.top)) || (aRect.top > (bRect.top + bRect.height)) || ((aRect.left + aRect.width) < bRect.left) || (aRect.left > (bRect.left + bRect.width)) ); }; var detectCollide = function() { hasCollideLogoActual = false; $( "img:not(.nocollide), .collide.is-inview" ).each(function( index ) { if (hasCollideLogoActual == false) hasCollideLogoActual = isCollide(this, $logo[0]); }); if (hasCollideLogoActual != hasCollideLogoLast) { if (hasCollideLogoActual) $logo.addClass('inverse'); else $logo.removeClass('inverse'); hasCollideLogoLast = hasCollideLogoActual; } if ($main.length) { if ($main.find('.is-inview').length) hasCollideTopActual = true; else hasCollideTopActual = false; if (hasCollideTopActual != hasCollideTopLast) { if (!hasCollideTopActual) $top_content.addClass('sftop'); else $top_content.removeClass('sftop'); hasCollideTopLast = hasCollideTopActual; } } requestAnimationFrame(detectCollide); }; $(document).on('removeEvent.slickevent', function(e) { setTimeout(function() { $( ".glider_relais" ).each(function() { this.glider.destroy(); delete this.glider; }); }, 200); $(document).off('removeEvent.slickevent'); }); $(document).on('scrollLoaded', function() { $('#slide .lazy').each(function() { lazyExecute(this, false); }); }); /*WHATSAPP FAKE CHAT FUNCTIONS*/ function setChatTime() { var currentdate = new Date(); /*Metto lo zero davanti ai numeri a cifra singola*/ var hours = (currentdate.getHours()<10?'0':'') + currentdate.getHours(); var minutes = (currentdate.getMinutes()<10?'0':'') + currentdate.getMinutes(); var datetime = hours + ":" + minutes; $(".wa-fake-chat-time").append(datetime); } $(window).on('load', function() { $logo = $('#logo'); $top_content = $("#top_content"); $main = $("#slide"); $("#slide.carousel-fade .carousel-item").addClass("zoomInOutSlide"); $('#slide.carousel-fade').each(function() { $(this).on('slid.bs.carousel', function() { $(this).find(".carousel-item").toggleClass("zoomInOutSlide"); }) }); /*WHATSAPP FAKE CHAT*/ if($(".wa-fake-chat-container").length > 0) { setChatTime(); $(".wa-fake-chat-open-button").click(function() { var dataContainer = $(this).attr('data-container'); $("#"+dataContainer).addClass("chat-visible"); }); $(".wa-fake-chat-close-button").click(function() { $(".wa-fake-chat-container").removeClass("chat-visible"); }); } /*scroll = new LocomotiveScroll({ el: document.querySelector('[data-scroll-container]'), smooth: true, getSpeed: true, getDirection: true, useKeyboard: true, lerp: 0.9, inertia: .9, multiplier: 2, scrollbarClass: 'c-myscrollbar', });*/ scroll.on("call", (fun, dir, obj) => { /*if (fun === "toggleLazy") { $(obj.el).removeAttr('data-scroll-call'); if ($(window).width() > 767) { $listLazy = $(obj.el).find('.lazy'); lazyExecute($listLazy); } }*/ /*if ((fun === "gliderShow") && !isGliderLoaded) { $('', { rel: 'stylesheet', type: 'text/css', href: 'https://www.palazzodellascala.com/css/glider.min.css' }).appendTo('head'); isGliderLoaded = true; loadScript("https://www.palazzodellascala.com/js/glider.min.js").then(function() { loadScript("https://www.palazzodellascala.com/js/glider.clm.min.js.php").then(function() {}); }); }*/ /* if (fun === "activeRipples") { var $el = $(obj.el); $(obj.el).removeAttr('data-scroll-call'); loadScript("https://www.palazzodellascala.com/js/jquery.ripples-min.js").then(function() { loadScript("https://www.palazzodellascala.com/js/ripples.clm.min.js").then(function() {}); }); } */ }); if ($('.pswp').length > 0) { loadScript("https://www.palazzodellascala.com/js/jquery.photoswipe.min.js").then(function() { loadScript("https://www.palazzodellascala.com/js/simple-gallery.min.js").then(function() {}); }); } $('.btn-toggle').click(function() { var el = $(this); var toggle = $('#toggle'); var top_content = $('#top_content'); var overlayName = el.data('overlay'); if (!menuTriggered) { scroll_call_load(); menuTriggered = true; } var toggleActive = toggle.hasClass('active'); if (toggleActive) { toggle.removeClass('active') $('.overlay').removeClass('open'); top_content.removeClass (function (index, css) { return (css.match (/(^|\s)overlay\S+/g) || []).join(' '); }); if (el.hasClass("btn-forceopen")) toggleActive = false; } if (!toggleActive) { top_content.addClass(overlayName); var top_contentH = 0; if ((overlayName != "overlay-booking") && ($(window).width() > 767)) top_contentH = top_content.outerHeight(); $('#toggle').addClass('active'); var overlay = $('#'+overlayName); overlay.css({'top':top_contentH+'px','height':'calc(100% - '+top_contentH+'px)'}).addClass('open'); lazyExecute(overlay.find('.lazy')); } }); $(document).on('mouseenter', '.nav-img', function(){ var $el = $(this); var img = $el.data('img'); $('.menu-img .singol-img').removeClass('hovertop'); $('.menu-img .singol-img#img'+img).addClass('hovertop'); }); $(document).on('mouseleave', '.nav-img', function(){ $('.menu-img .singol-img').removeClass('hovertop'); }); $(document).on('mouseover', '#container_camere_glider .box-left', function(){ $('#pointer-cursor').addClass('arrow-left'); $('#pointer1').addClass('arrow-left'); }); $(document).on('mouseout', '#container_camere_glider .box-left', function(){ $('#pointer-cursor').removeClass('arrow-left'); $('#pointer1').removeClass('arrow-left'); }); $(document).on('mouseover', '#container_camere_glider .box-right', function(){ $('#pointer-cursor').addClass('arrow-right'); $('#pointer1').addClass('arrow-right'); }); $(document).on('mouseout', '#container_camere_glider .box-right', function(){ $('#pointer-cursor').removeClass('arrow-right'); $('#pointer1').removeClass('arrow-right'); }); $(".overlay").each(function(){ var id = this.id; $("#"+id+" > .overlay-menu > ul > li").each(function(index){ var delay = 150*(index); if (supportsCssVariables) { this.style.setProperty('--delay', delay + 'ms'); } else { $(this).css({'-webkit-animation-delay' : delay+'ms', 'animation-delay' : delay+'ms'}); } }); $("#"+id+" .dropdown-menu").each(function(){ $(this).find('li').each(function(index) { var delay = 150*(index); if (supportsCssVariables) { this.style.setProperty('--delay', delay + 'ms'); } else { $(this).css({'-webkit-animation-delay' : delay+'ms', 'animation-delay' : delay+'ms'}); } }); }); }); setTimeout( function() { loadScript("https://www.palazzodellascala.com/js/simplebooking.js?20250512144441").then(function() {}); }, 1000 ); requestAnimationFrame(detectCollide); /* if ($(window).width() > 767) { $(window).pointercursor({ numTrail: 1, cursorMarginHide: 0, opacity: .3 }); } else { $('#pointer-cursor').detach(); $('#pointer1').detach(); } */ });var isGliderLoadedrelais = false; var lastWidth = 10000; var limitWidth = 991; $( document ).on('inizialize', function() { isGliderLoadedrelais = false; lastWidth = 10000; limitWidth = 991; }); var gliderLoadedrelais = function() { $('', { rel: 'stylesheet', type: 'text/css', href: 'https://www.palazzodellascala.com/modules/relais/css/glider.min.css' }).appendTo('head'); isGliderLoadedrelais = true; loadScript("https://www.palazzodellascala.com/modules/relais/js/glider.min.js").then(function() { loadScript("https://www.palazzodellascala.com/modules/relais/js/glider.clm.min.js.php").then(function() { $('#container_relais_glider').addClass('is-completed'); }); }); } // di lato in modalità desktop var box_shift_position = function() { if ($(window).width() < (limitWidth + 1)) actualWidth = limitWidth; else actualWidth = (limitWidth + 1); if (lastWidth != actualWidth) { lastWidth = actualWidth; if ($('#h1-mobile').length) { if (lastWidth == limitWidth) { var h1_box = $('#h1-box').detach(); $('#h1-mobile').append(h1_box).show(); } else { var h1_box = $('#h1-box').detach(); $('#h1-desktop').append(h1_box); $('#h1-mobile').hide(); } } } } $(window).on('load', function() { if (!isGliderLoadedrelais) { gliderLoadedrelais(); } if ($('.gallery-relais-mas').length > 0) { loadScript("https://www.palazzodellascala.com/modules/relais/js/imagesloaded.pkgd.min.js").then(function() { loadScript("https://www.palazzodellascala.com/modules/relais/js/masonry.pkgd.min.js").then(function() { loadScript("https://www.palazzodellascala.com/modules/relais/js/masonry.clm.min.js.php").then(function() {}); }); }); } //if (scroll != null) { scroll.on("call", (fun, dir, obj) => { if (fun === "shiftPosition") { $(obj.el).removeAttr('data-scroll-call'); box_shift_position(); } }); /* } else { if ($('[data-scroll-call="shiftPosition"]').length()) { if ($('[data-scroll-call="shiftPosition"]').isInViewport(-10)) { $(this).removeAttr('data-scroll-call'); box_shift_position(); } } } */ }); $(window).on('resize',function() { box_shift_position(); }); $(window).on('load', function() { if ($('.slide-video').length) { var $el; if ($(window).width() > 767) { $el = $('.slide-video .desktop'); } else { $el = $('.slide-video .mobile'); } $el.attr('src', $el.attr('data-src')); } });$(window).on('load', function(){ if ($('.gallery-pageinternal-mas').length > 0) { loadScript("https://www.palazzodellascala.com/modules/pageinternal/js/imagesloaded.pkgd.min.js").then(function() { loadScript("https://www.palazzodellascala.com/modules/pageinternal/js/masonry.pkgd.min.js").then(function() { loadScript("https://www.palazzodellascala.com/modules/pageinternal/js/masonry.clm.min.js.php").then(function() {}); }); }); } });$(window).on('load', function() { if ($('.gallery-gallery-mas').length > 0) { loadScript("https://www.palazzodellascala.com/modules/gallery/js/imagesloaded.pkgd.min.js").then(function() { loadScript("https://www.palazzodellascala.com/modules/gallery/js/masonry.pkgd.min.js").then(function() { loadScript("https://www.palazzodellascala.com/modules/gallery/js/masonry.clm.min.js.php").then(function() {}); }); }); } });function packet_contact_positive_response(element, datiJSON, value_class_hide) { $('#form_packet_contact_popup_ajax')[0].reset(); $('#packet_contact_popup').modal('hide'); // sistema la sidebar $('#modal_result_packet_contact .modal-body').html(datiJSON.positive_response); $('#modal_result_packet_contact').modal('show'); setTimeout(function() {$('#modal_result_packet_contact').modal('hide');}, 6000); }