var componentVerifyCycle = 0;
var bottom_of_window = jQuery(window).scrollTop() + jQuery(window).height();
var siteApp = {
params: {
homepage: {
images: [],
images_mobile: [],
},
},
init: function () {
if (siteApp.allComponentIsLoaded()) {
siteApp.startApplication();
} else {
componentVerifyCycle++;
if (componentVerifyCycle < 200) {
setTimeout(function () {
siteApp.init();
}, 100);
} else {
console.warn(
"Init Application Error! waiting for: " +
siteApp.params.tmp,
);
return false;
}
}
},
allComponentIsLoaded: function () {
var loaded = true;
var msg = "";
if (typeof jQuery == "undefined") {
loaded = false;
msg += "-jQuery";
}
if (typeof hs == "undefined") {
loaded = false;
msg += "-hs";
}
if (typeof jQuery().slick == "undefined") {
loaded = false;
msg += "-slick";
}
if (typeof jQuery().imageLightbox == "undefined") {
loaded = false;
msg += "-imagelightbox";
}
if (typeof cms == "undefined") {
loaded = false;
msg += "cms";
}
if (!loaded) {
//console.info('waiting for: '+msg);
siteApp.params.tmp = msg;
return false;
} else {
return true;
}
},
startApplication: function () {
console.info("startApplication...");
siteApp.openMenuMobile();
siteApp.openLanguage();
//siteApp.openSubMenu();
//siteApp.countAnimation();
siteApp.scrollAnimation();
siteApp.fadeInHeader(jQuery(".barra-desktop"));
siteApp.accordionTab();
siteApp.openClickBooking();
siteApp.fadeInRoom(jQuery("#contenuto_512830"));
/* if(cmsPageParams.relation_code != 1570197566){
siteApp.triggerExitPopup();
}*/
switch(cmsPageParams.relation_code) {
case "1570197566"://thankyoupage
case "1674490834"://famiglie
case "1674560825"://coppie
case "1590568460"://video
break;
default:
siteApp.triggerExitPopup();
break;
}
jQuery(".comments_clear").remove();
cms.onEvent("FormSent", function (d) {
console.log("d = ",d.Tdata);
// console.log("d nome form = ",d.Tdata.form_data.nome_form);
// console.log("d nome form = ",d.Tdata.nome_form);
if(d.Tdata.form_data != undefined){
switch (d.Tdata.form_data.nome_form) {
case "form-divertimento":
console.log("form sent divertimento");
if(d.Tdata.form_data.newsletter_optin == 1){
setTimeout(function () {
console.log("form sent divertimento 5sec");
location.href = "/divertimento/grazie";
},2000);
}
break;
default:
break;
}
}
});
/*jQuery('.fumetto-box').wrapInner( "
" );*/
jQuery(".testo.table-box").wrapInner("");
setTimeout(function () {
jQuery(".border").removeClass("no_width , no_height");
jQuery(".border-2").removeClass("no_width , no_height");
}, 50);
//aggiungo una freccia a qualunque voce abbia un sottomenu
jQuery(".level1 > li:has('.level2')").addClass("submenu");
jQuery("li.submenu > a").removeAttr("href");
if (cmsPageParams.type == 3) {
//controllo di essere solo in homepage
//in homepage c'è il popup esterno, quindi bisgona dare spazio sopra
jQuery("body").addClass("space-popup");
siteApp.openClickForm();
/*
if(window.innerWidth < 992){
jQuery('#blk_80678').slick({
dots:true,
infinite: true,
speed: 900,
arrows: false,
slidesToShow: 1,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 5000,
accessibility:false,
pauseOnHover:false,
slide:'.cont-rist',
});
};
*/
}
/* switch per pagine */
switch (cmsPageParams.relation_code) {
case "1683802744":
//landing divertimento
/*
document.querySelector("#form-divertimento #newsletter_optin").value = 1;
document.querySelector("#form-divertimento #newsletter_optin").checked = true
*/
document.querySelector("#form-divertimento .send_form.bottone_alt").value="Si, voglio ricevere il coupon";
document.querySelector("#form-divertimento .wrp_newsletter_optin #testo_newsletter_optin").innerHTML="Iscrivimi alla newsletter
(Se non darai il consenso non potremo inviarti tutte le offerte relative al tuo coupon 2x1)";
break;
case "1570197566":
//thankyoupage
cms.facebook.event.track("track", "Lead");
break;
case "1590568460":
//video
cms.facebook.event.track("track", "ViewContent");
break;
//elenco offerte
case "1549612079":
jQuery(".boxOff").each(function () {
var link_booking = jQuery(this)
.find("#link-booking-value")
.val();
console.log("link-booking-value.val = ", link_booking);
if (link_booking == undefined) {
console.log("link-booking-value undefined");
} else {
console.log(
"link-booking-value.length = ",
link_booking.length,
);
if (link_booking.length == 0) {
console.log("link-booking-value lenght 0");
jQuery(this).find(".link-booking").remove();
} else {
console.log("link-booking-value lenght > 0");
jQuery(this).find(".dettaglio-offerta").remove();
}
}
});
break;
default:
break;
}
jQuery(".select-txt").on("change", function () {
siteApp.openClickBooking();
});
cms.onEvent("DatePickerSelected", function (data) {
//console.log(data.Tdata);
//alert(data.Tdata.monthNumber+' '+data.Tdata.monthText);
var id = data.Tdata.element[0].id;
switch (id) {
case "arrival":
// console.log(data.Tdata);
siteApp.openClickBooking();
break;
case "departure":
// console.log(data.Tdata);
siteApp.openClickBooking();
break;
}
});
cms.onEvent("DatePickerStarted", function (data) {
var id = data.Tdata.element[0].id;
//alert(data.Tdata.monthNumber+' '+data.Tdata.monthText);
switch (id) {
case "arrival":
// console.log(data.Tdata);
siteApp.openClickBooking();
break;
case "departure":
// console.log(data.Tdata);
siteApp.openClickBooking();
break;
}
});
cms.onEvent("DatePickerAutoSelectedDeparture", function (data) {
var id = data.Tdata.element[0].id;
// console.log(data.Tdata);
siteApp.openClickBooking();
});
if (cmsPageParams.relation_code == "1549617218") {
/*gestione imageLightBox*/
var galleries = [
".elenco-img-1 a.image_lightbox",
".elenco-img-2 a.image_lightbox",
".elenco-img-3 a.image_lightbox",
".elenco-img-4 a.image_lightbox",
".elenco-img-5 a.image_lightbox",
".elenco-img-6 a.image_lightbox",
".elenco-img-7 a.image_lightbox",
];
var instance = [];
jQuery.each(galleries, function (i) {
var selector = galleries[i];
instance[i] = jQuery(selector).imageLightbox({
onStart: function () {
overlayOn();
arrowsOn(instance[i], selector);
closeButtonOn(instance[i]);
},
onEnd: function () {
overlayOff();
closeButtonOff();
arrowsOff();
activityIndicatorOff();
},
onLoadStart: function () {
activityIndicatorOn();
},
onLoadEnd: function () {
jQuery(".imagelightbox-arrow").css("display", "block");
activityIndicatorOff();
},
});
});
} else {
startImageLightBox();
}
// apertura sottomenu mobile //
siteApp.openSecondLevel();
/* verifico lingua della pagina */
var lang_page = cmsPageParams.lang;
/* ************************ */
switch (lang_page) {
case "it":
break;
default:
}
setTimeout(function () {
// if (window.innerWidth > 767) {
jQuery("body").addClass("loaded");
//controllo se è visibile la barra del sondaggio nel top
if (
jQuery(".hb-bar-top").is(":hidden") ||
jQuery(".hb-bar-top").length == 0
) {
jQuery("body").removeClass("space-popup");
}
// }
}, 10);
/*VIDEO YOUTUBE*/
jQuery(".video_youtube_icoplay").each(function (index) {
var code_youtube = jQuery.trim(jQuery(this).find("span").text());
if (jQuery(this)[0]) {
jQuery(this).YTPlayer({
fitToBackground: true,
videoId: code_youtube,
mute: true,
playerVars: {
modestbranding: 0,
autoplay: 1,
controls: 0,
showinfo: 0,
branding: 0,
rel: 0,
autohide: 0,
start: 0,
mute: 1,
enablejsapi: 1,
},
callback: function () {
// var player = jQuery(this).data('ytPlayer').player;
// player.playVideo();
},
});
}
});
jQuery('.video_youtube_icoplay span[class="icon-youtube"]').click(
function (e) {
jQuery(this).hide();
var videohtml = jQuery(this).parent();
console.log("videohtml ", videohtml);
var code_youtube = jQuery.trim(videohtml.find("span").text());
if (videohtml[0]) {
videohtml.YTPlayer({
fitToBackground: true,
videoId: code_youtube,
mute: false,
playerVars: {
modestbranding: 0,
autoplay: 1,
controls: 0,
showinfo: 0,
branding: 0,
rel: 0,
autohide: 0,
start: 0,
mute: 0,
enablejsapi: 1,
},
callback: function () {
// var player = videohtml.data('ytPlayer').player;
// player.playVideo();
},
});
}
},
);
/* switch per pagine */
switch (cmsPageParams.relation_code) {
case "1652962635"://benvenuto
//setInterval(siteApp.startCountdown(), 1000);
siteApp.startCountdown();
break;
case "1548848726":
if (window.innerWidth > 767) {
siteApp.hresize(".cont-chi-siamo h3");
}
break;
case "1548692803":
//homepage
break;
case "1549632955":
if (window.innerWidth > 767) {
siteApp.hresize(".elenco-offerte .bordered");
siteApp.hresize(".elenco-offerte .pad-space-offer");
}
break;
default:
}
jQuery("#popupNewsletter .pulsante").click(function (e) {
jQuery("#popupNewsletter").modal("hide");
});
/* slider offerte */
jQuery(".offerte-scorrevoli").slick({
arrows: false,
dots: false,
speed: 600,
slidesToShow: 1,
autoplay: true,
autoplaySpeed: 6000,
accessibility: false,
infinite: true,
});
jQuery(".arrows .next").click(function () {
jQuery(".offerte-scorrevoli").slick("slickNext");
});
jQuery(".arrows .prev").click(function () {
jQuery(".offerte-scorrevoli").slick("slickPrev");
});
if (window.innerWidth > 991) {
if (jQuery(".offerte-scorrevoli .slick-slide").length <= 1) {
jQuery(".arrows").hide();
}
}
jQuery(".slider-bottom").slick({
dots: true,
infinite: true,
speed: 900,
arrows: false,
slidesToShow: 5,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 5000,
accessibility: false,
responsive: [
{
breakpoint: 992,
settings: {
dots: false,
arrows: true,
slidesToShow: 3,
},
},
{
breakpoint: 768,
settings: {
dots: false,
arrows: true,
slidesToShow: 1,
},
},
],
});
jQuery(".slider-commenti-so").slick({
dots: true,
infinite: true,
speed: 900,
arrows: false,
slidesToShow: 3,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 5000,
accessibility: false,
// slide:'.slide-commenti',
responsive: [
{
breakpoint: 992,
settings: {
dots: false,
arrows: true,
slidesToShow: 2,
},
},
{
breakpoint: 768,
settings: {
dots: false,
arrows: true,
slidesToShow: 1,
},
},
],
});
jQuery(".slider-commenti").slick({
dots: true,
infinite: true,
speed: 900,
arrows: false,
slidesToShow: 3,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 5000,
accessibility: false,
slide: ".slide-commenti",
responsive: [
{
breakpoint: 992,
settings: {
dots: false,
arrows: true,
slidesToShow: 2,
},
},
{
breakpoint: 768,
settings: {
dots: false,
arrows: true,
slidesToShow: 1,
},
},
],
});
jQuery(".arrows-commenti .next").click(function () {
jQuery(".slider-commenti").slick("slickNext");
});
jQuery(".arrows-commenti .prev").click(function () {
jQuery(".slider-commenti").slick("slickPrev");
});
if (window.innerWidth > 991) {
if (jQuery(".slider-commenti .slick-slide").length <= 1) {
jQuery(".arrows-commenti").hide();
}
}
// slider foto //
jQuery(".slider-plus").slick({
arrows: false,
dots: false,
speed: 900,
slidesToShow: 1,
autoplay: true,
autoplaySpeed: 5000,
infinite: true,
slide: ".cont-plus",
});
jQuery(".arrows-plus .next").click(function () {
jQuery(".slider-plus").slick("slickNext");
});
jQuery(".arrows-plus .prev").click(function () {
jQuery(".slider-plus").slick("slickPrev");
});
if (window.innerWidth > 991) {
if (jQuery(".slider-plus .slick-slide").length <= 1) {
jQuery(".arrows-plus").hide();
}
}
// slider foto //
jQuery(".slider-home").slick({
arrows: true,
dots: false,
speed: 600,
slidesToShow: 1,
autoplay: true,
autoplaySpeed: 2000,
infinite: true,
pauseOnHover: false,
fade: true,
cssEase: "linear",
});
// slider foto //
jQuery(".slider-img").slick({
arrows: false,
dots: false,
speed: 600,
slidesToShow: 1,
autoplay: true,
autoplaySpeed: 2000,
infinite: true,
pauseOnHover: false,
});
jQuery(".slider-room").slick({
arrows: true,
dots: false,
speed: 600,
slidesToShow: 1,
autoplay: false,
autoplaySpeed: 2000,
infinite: true,
pauseOnHover: false,
accessibility: false,
fade: true,
cssEase: "linear",
});
jQuery(".slider-foto-1").slick({
arrows: true,
dots: false,
speed: 600,
slidesToShow: 1,
autoplay: false,
autoplaySpeed: 2000,
infinite: true,
pauseOnHover: false,
accessibility: false,
fade: true,
cssEase: "linear",
});
jQuery(".slider-foto-so-1 > div").slick({
arrows: true,
dots: false,
speed: 600,
slidesToShow: 1,
autoplay: false,
autoplaySpeed: 2000,
infinite: true,
pauseOnHover: false,
accessibility: false,
fade: true,
cssEase: "linear",
});
if (window.innerWidth < 992) {
jQuery(".plus").slick({
arrows: true,
dots: false,
speed: 600,
slidesToShow: 1,
autoplay: false,
slide: ".cont-plus",
autoplaySpeed: 2000,
infinite: false,
accessibility: false,
});
}
jQuery(".slider-icone-eventi > div").slick({
dots: false,
infinite: true,
speed: 900,
arrows: true,
slidesToShow: 5,
slidesToScroll: 1,
autoplay: false,
autoplaySpeed: 5000,
accessibility: false,
pauseOnHover: false,
responsive: [
{
breakpoint: 992,
settings: {
slidesToShow: 4,
},
},
{
breakpoint: 768,
settings: {
slidesToShow: 3,
},
},
],
});
jQuery(".slider-parlano").slick({
dots: false,
infinite: true,
speed: 900,
arrows: true,
slidesToShow: 4,
slidesToScroll: 1,
autoplay: false,
autoplaySpeed: 5000,
accessibility: false,
pauseOnHover: false,
slide: ".space-img-parlano",
responsive: [
{
breakpoint: 992,
settings: {
slidesToShow: 3,
},
},
{
breakpoint: 768,
settings: {
slidesToShow: 1,
},
},
],
});
jQuery(".slider-4foto > div, .slider-4fotoListato").slick({
dots: false,
infinite: true,
speed: 900,
arrows: true,
slidesToShow: 4,
slidesToScroll: 1,
autoplay: false,
autoplaySpeed: 5000,
accessibility: false,
pauseOnHover: false,
responsive: [
{
breakpoint: 1300,
settings: {
slidesToShow: 4,
},
},
{
breakpoint: 992,
settings: {
slidesToShow: 3,
},
},
{
breakpoint: 768,
settings: {
slidesToShow: 1,
},
},
],
});
jQuery(".slider-terraferma").slick({
dots: false,
infinite: true,
speed: 900,
arrows: true,
slidesToShow: 4,
slidesToScroll: 1,
autoplay: false,
autoplaySpeed: 5000,
accessibility: false,
pauseOnHover: false,
slide: ".box-terraferma",
responsive: [
{
breakpoint: 1300,
settings: {
slidesToShow: 4,
},
},
{
breakpoint: 992,
settings: {
slidesToShow: 3,
},
},
{
breakpoint: 768,
settings: {
slidesToShow: 1,
},
},
],
});
jQuery(".slider-riquadri").slick({
dots: false,
infinite: true,
speed: 900,
arrows: true,
slidesToShow: 3,
slidesToScroll: 1,
autoplay: false,
autoplaySpeed: 5000,
accessibility: false,
pauseOnHover: false,
slide: ".box-riquadri",
responsive: [
{
breakpoint: 1300,
settings: {
slidesToShow: 3,
},
},
{
breakpoint: 992,
settings: {
slidesToShow: 3,
},
},
{
breakpoint: 768,
settings: {
slidesToShow: 1,
},
},
],
});
jQuery(".slider-personale").slick({
dots: false,
infinite: true,
speed: 900,
arrows: true,
slidesToShow: 6,
slidesToScroll: 1,
autoplay: false,
autoplaySpeed: 5000,
accessibility: false,
pauseOnHover: false,
slide: ".space-img-personale",
responsive: [
{
breakpoint: 1300,
settings: {
slidesToShow: 4,
},
},
{
breakpoint: 992,
settings: {
slidesToShow: 3,
},
},
{
breakpoint: 768,
settings: {
slidesToShow: 1,
},
},
],
});
siteApp.hresize(".servizio-index");
/*
if(window.innerWidth < 992){
jQuery('.slider-servizi-index').slick({
dots:false,
infinite: true,
speed: 900,
arrows: true,
slidesToShow: 3,
slidesToScroll: 1,
autoplay: false,
autoplaySpeed: 5000,
accessibility:false,
pauseOnHover:false,
slide:'.servizio-index',
responsive: [{
breakpoint: 768,
settings: {
slidesToShow: 2
}
}]
});
};
*/
//slider pagina covid
/* *************** */
jQuery(".slider-covid > div").slick({
arrows: true,
dots: false,
speed: 600,
slidesToShow: 5,
autoplay: false,
autoplaySpeed: 2000,
infinite: true,
responsive: [
{
breakpoint: 992,
settings: {
slidesToShow: 2,
},
},
{
breakpoint: 768,
settings: {
slidesToShow: 1,
},
},
],
});
siteApp.hresize(".bg-slider-covid .testo-covid");
/*fine slider covid*/
var pathname = window.location.href;
var pathname = pathname.split("?id=");
var parametro = pathname[1];
if (parametro) {
//console.log('passo')
goToByScroll("#" + parametro);
}
jQuery(".tooltip_commento .close").click(function (e) {
jQuery(".tooltip_commento").removeClass("vis");
});
/* gestione tab prodotti */
jQuery(".cont-tabs input").click(function () {
jQuery(".tab-content").hide();
var element = jQuery(this).attr("id");
console.log(element);
jQuery(this)
.parent(".cont-tabs")
.siblings(jQuery("." + element + "").show());
});
/* gestione stile prezzo se non presente */
jQuery(".cont-prezzo").each(function () {
var html = jQuery(this).html();
var prezzo = jQuery(html).find("[itemprop=price]").html();
if (typeof prezzo == "undefined") {
jQuery(this).remove();
}
});
jQuery(window).on("scroll", function () {
siteApp.viewCheck();
siteApp.scrollAnimation();
siteApp.countAnimation();
});
jQuery(".image-container").each(function () {
var h_image = jQuery(this).find("img.foto").height();
jQuery(this).height(h_image);
});
jQuery(window).on("resize", function () {
if (window.innerWidth > 991) {
jQuery(".image-container").each(function () {
var h_image = jQuery(this).find("img.foto").height();
jQuery(this).height(h_image);
});
}
});
if (cmsPageParams.relation_code == "1590573193") {
if (window.innerWidth > 767) {
siteApp.hresize(".box-covid");
}
}
siteApp.formCortoMobile();
console.info("startApplication started!");
},
// Create the element
openMenuMobile: function () {
/* variabili menu */
var $id_menu = "#menu_3031";
var $menu = jQuery($id_menu);
var $btn = jQuery(".op_block");
/**************************/
jQuery($btn).click(function () {
jQuery(".vedi-menu").toggleClass("slide-menu");
//if(window.innerWidth > 991){
// jQuery('.menu-fix').fadeToggle();
//}
$btn.find(".click").toggleClass("open");
$btn.toggleClass("open");
if (jQuery($id_menu + " .level2").hasClass("slide-menu")) {
jQuery($id_menu + " .level2").removeClass("slide-menu");
}
});
/* jquery per chiudere la tendina del menu al click esterno alla tendina
jQuery(document).bind("click touchstart", function(event){
if(jQuery(event.target).parents('.op_block').size()|(jQuery(event.target).hasClass('open'))|(jQuery(event.target).parents('ul#root_3031 li').size())|jQuery(event.target).is('.tendina-lingue')){
return;
}
jQuery(".op_block").removeClass('open');
$btn.find('.click').removeClass('open');
if(jQuery('.vedi-menu').hasClass('slide-menu')){
jQuery(".vedi-menu").removeClass('slide-menu');
}
if(jQuery(".level2").hasClass('slide-menu')){
jQuery(".level2").removeClass('slide-menu');
}
});*/
},
triggerExitPopup: function () {
var popupOpen = false;
cms.onEvent("so_buttom_popup_opened", function (e) {
//console.log("apro popup");
// popupOpen = true;
});
cms.onEvent("so_buttom_popup_closed", function (e) {
console.log("chiudo popup");
popupOpen = false;
createCookie("modal_close", "chiuso", 0.045);
});
jQuery(".modal-dialog .close").click(function (e) {
console.log("chiudo popup");
popupOpen = false;
createCookie("modal_close", "chiuso", 0.045);
});
// Exit intent trigger
//controllo per il desktop se il mouse esce dallo schermo
// addEvent(document, 'mouseout', function(evt) {
document.addEventListener("mouseout", function (evt) {
if (evt.toElement == null && evt.relatedTarget == null) {
//se ho già chiuso il popup una volta entro la giornata non lo apro
if (readCookie("modal_close") != null) {
// console.log("popup già chiuso");
} else {
//se il popup è attualmente aperto non lo apro di nuovo
if (!popupOpen) {
popupOpen = true;
setTimeout(function () {
//jQuery('#myModalExit').modal('show');
// document.querySelector('a.exitpopup').click();
//controllo se la voce offerte è visibile
if (
jQuery("#menu_3341 ul li.voce_menu_39321").is(
":visible",
)
) {
jQuery("#exitPopupOfferta").modal();
} else {
jQuery("#exitPopupAssistente").modal();
}
}, 2000);
}
}
}
});
//gestore mobile se cambio scheda tornando indietro
if (window.history && window.history.pushState) {
window.history.pushState("forward", null, "");
jQuery(window).on("popstate", function () {
//se ho già chiuso il popup una volta entro la giornata non lo apro
if (readCookie("modal_close") != null) {
// console.log("popup già chiuso");
} else {
//se il popup è attualmente aperto non lo apro di nuovo
if (!popupOpen) {
popupOpen = true;
setTimeout(function () {
//controllo se la voce offerte è visibile
if (jQuery("#menu_3341 ul li.voce_menu_39321").is(":visible")) {
jQuery("#exitPopupOfferta").modal();
} else {
jQuery("#exitPopupAssistente").modal();
}
}, 1000);
}
}
});
}
document.addEventListener("visibilitychange", function () {
if (document.hidden) {
//se ho già chiuso il popup una volta entro la giornata non lo apro
if (readCookie("modal_close") != null) {
//console.log("popup già chiuso");
} else {
//se il popup è attualmente aperto non lo apro di nuovo
if (!popupOpen) {
popupOpen = true;
// document.querySelector('a.exitpopup').click();
//controllo se la voce offerte è visibile
if (
jQuery("#menu_3341 ul li.voce_menu_39321").is(
":visible",
)
) {
jQuery("#exitPopupOfferta").modal();
} else {
jQuery("#exitPopupAssistente").modal();
}
}
}
}
});
},
openSecondLevel: function () {
jQuery(".submenu > a").click(function (e) {
e.preventDefault(); /* disaable click 'a' event */
jQuery(this)
.parents("li")
.children(".level2")
.addClass("slide-menu"); /* rendo visibile il level2 */
});
jQuery(".level2 li:first-child a").click(function (e) {
e.preventDefault();
jQuery(this)
.parents("li")
.parents(".level2")
.removeClass("slide-menu"); /* nascondo il level2 */
});
},
// Effetto Superfish //
openSubMenu: function () {
jQuery(".menu-fix #root_3031, #root_3031").superfish({
delay: 0, // the delay in milliseconds that the mouse can remain outside a submenu without it closing
speed: "normal", // fast, normal
});
},
// fine effetto //
/* ***************gestione tab a fisarmonica*********** */
accordionTab: function (param) {
jQuery(".slider-titolo").click(function () {
if (!jQuery(this).hasClass("opened")) {
jQuery(".slider-titolo.opened").removeClass("opened");
jQuery(this).addClass("opened");
jQuery(".slider-corpo.opened").slideUp("fast", function () {
jQuery(this).removeClass("opened");
});
jQuery(this)
.next()
.slideDown("fast", function () {
jQuery(this).addClass("opened");
});
} else {
jQuery(this).removeClass("opened");
jQuery(".slider-corpo.opened").slideUp("fast", function () {
jQuery(this).removeClass("opened");
});
}
});
},
enableMixItUp: function () {
jQuery(".cont-prodotti").mixItUp({
animation: {
enable: false,
},
callbacks: {
onMixLoad: function () {
//console.log('onMixLoad: ',arguments)
jQuery(this).mixItUp("setOptions", {
animation: {
enable: true,
},
});
},
onMixFail: function (state) {
console.log(
"No elements found matching " + state.activeFilter,
);
},
onMixStart: function (obj_provenienza, obj_current) {
//jQuery('div.element_mixitup').css('display','inline-block');
var array_titoli = new Array();
},
onMixEnd: function (obj_provenienza, obj_current) {},
},
});
},
hresize: function (param) {
/* FUNZIONE PER CALCOLARE L'ALTEZZA MAX TRA DIV AFFIANCATI */
var hm = "";
var maxh = "";
var arrH = [];
jQuery(param).each(function () {
hm = jQuery(this).height();
arrH.push(hm);
});
maxh = Math.max.apply(Math, arrH);
jQuery(param).height(maxh);
},
/**************** tendina lingue ********************/
openLanguage: function () {
//APRO MENU LINGUE
jQuery(".tendina-lingue").click(function () {
var lingua = jQuery(this).children("#select_lingue");
if (lingua.is(":hidden")) {
lingua.slideDown();
jQuery(this).addClass("open");
} else {
lingua.slideUp();
jQuery(this).removeClass("open");
}
});
jQuery("#select_lingue").click(function () {
jQuery(this).slideUp();
jQuery(".tendina-lingue").children(".click").removeClass("open");
});
/* jquery per chiudere la tendina delle lingue al click esterno alla tendina */
jQuery(document).click(function (event) {
if (
jQuery(event.target).parents(".tendina-lingue").size() |
jQuery(event.target).hasClass("tendina-lingue")
) {
return;
}
if (!jQuery("#select_lingue").is(":hidden")) {
jQuery("#select_lingue").slideUp();
jQuery(".tendina-lingue").removeClass("open");
}
});
},
viewCheck: function () {
if (window.innerWidth > 991) {
jQuery(
".moveUp,.moveRight,.moveDown, .moveLeft, .moveLine, .hideme, .image-container, .highlight",
).viewportChecker({
classToAdd: "visible", // Class to add to the elements when they are visible,
classToAddForFullView: "full-visible", // Class to add when an item is completely visible in the viewport
repeat: false, // Add the possibility to remove the class if the elements are not visible
});
} else {
jQuery(".highlight").viewportChecker({
classToAdd: "visible", // Class to add to the elements when they are visible,
classToAddForFullView: "full-visible", // Class to add when an item is completely visible in the viewport
repeat: false, // Add the possibility to remove the class if the elements are not visible
});
}
},
formCortoMobile: function () {
if (window.innerWidth < 768) {
jQuery(".mrprenoForm").addClass("accorcia_campi");
jQuery(".mrprenoForm .jquery-datepicker").click(function (e) {
jQuery(".mrprenoForm").removeClass("accorcia_campi");
});
}
},
loadGoogleFont: function (url) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var css = xhr.responseText;
css = css.replace(/}/g, "font-display: swap; }");
var head = document.getElementsByTagName("head")[0];
var style = document.createElement("style");
style.appendChild(document.createTextNode(css));
head.appendChild(style);
}
};
xhr.send();
},
showMe: function (elem) {
anim = jQuery(elem).attr("data-anim");
jQuery(elem).addClass("animated " + anim);
jQuery(elem).animate(
{
opacity: 1,
},
300,
function () {},
);
},
scrollAnimation: function () {
setTimeout(function () {
if (window.innerWidth > 991) {
jQuery(".hideme.visible").each(function (i) {
siteApp.showMe(this);
});
}
}, 150);
},
fadeInHeader: function (element) {
if (window.innerWidth > 991) {
jQuery(window).scroll(function () {
var scrollpos =
document.documentElement.scrollTop ||
document.body.scrollTop;
var h_w = jQuery(window).height();
if (scrollpos > 300) {
element.fadeIn();
jQuery(".vedi-menu").addClass("top");
// console.log("close_commento = ",readCookie("close_commento"));
if (readCookie("close_commento") == null) {
jQuery(".tooltip_commento").addClass("vis");
createCookie("close_commento", "chiuso", 1);
}
} else {
element.fadeOut();
jQuery(".vedi-menu").removeClass("top");
jQuery(".tooltip_commento").removeClass("vis");
}
if (scrollpos > 1000) {
jQuery(".arrow_scroll").addClass("vis");
} else {
jQuery(".arrow_scroll").removeClass("vis");
}
});
} else {
jQuery(window).scroll(function () {
var scrollpos =
document.documentElement.scrollTop ||
document.body.scrollTop;
var h_w = jQuery(window).height();
if (scrollpos > 300) {
jQuery(".barra-mobile").addClass("scrollingMobi");
// console.log("close_commento_mobi = ",readCookie("close_commento_mobi"),);
if (readCookie("close_commento_mobi") == null) {
jQuery(".tooltip_commento").addClass("vis");
createCookie("close_commento_mobi", "chiuso", 1);
}
} else {
jQuery(".barra-mobile").removeClass("scrollingMobi");
jQuery(".tooltip_commento").removeClass("vis");
}
});
}
},
fadeInRoom: function (element) {
if (window.innerWidth > 991) {
jQuery(window).scroll(function () {
var scrollpos =
document.documentElement.scrollTop ||
document.body.scrollTop;
var h_w = jQuery(window).height();
if (scrollpos > 800) {
element.addClass("fix-room");
} else {
element.removeClass("fix-room");
}
});
}
},
countAnimation: function () {
if (window.innerWidth > 991) {
jQuery(".count").each(function () {
if (jQuery(this).hasClass("visible")) {
if (!jQuery(this).hasClass("fatto")) {
jQuery(this).fadeIn();
jQuery(this)
.prop("Counter", 0)
.animate({
Counter: jQuery(this).text(),
},
{
duration: 4000,
easing: "swing",
step: function (now) {
jQuery(this).text(Math.ceil(now));
},
},
);
jQuery(this).addClass("fatto");
}
}
});
}
},
adatta: function (elem) {
var win_h = window.innerHeight;
jQuery(elem).css("height", win_h);
},
openClickForm: function () {
jQuery("#frm").submit(function (e) {
e.preventDefault();
});
jQuery("#btn_submit").click(function (e) {
e.preventDefault(); /* disaable click 'a' event */
//console.log('btn_preventivo click');
var data_arrivo = jQuery(".booking #data_arrivo").val();
createCookie("data_arrivo", data_arrivo, 1);
//console.log('data_arrivo '+ data_arrivo);
var data_partenza = jQuery(".booking #data_partenza").val();
createCookie("data_partenza", data_partenza, 1);
var adulti = jQuery('#frm select[name="persone"]')
.children("option:selected")
.val();
createCookie("adulti", adulti, 1);
var bambini = jQuery('#frm select[name="bambini"]')
.children("option:selected")
.val();
createCookie("bambini", bambini, 1);
jQuery("input[name='periodo[0][arrival_date]']").val(readCookie("data_arrivo"));
jQuery("input[name='periodo[0][departure_date]']").val(readCookie("data_partenza"));
jQuery("select[name='living_unit_occupants[0][occupant_adult]']").val(readCookie("adulti"));
jQuery("select[name='living_unit_occupants[0][occupant_children]']").val(readCookie("bambini"));
jQuery(".occupant_age_lu0").each(function (index) {
console.log(index);
if (index < bambini) {
jQuery(this).removeClass("hidden");
}
});
goToByScroll(".mrpreno");
});
},
openClickBooking: function () {
var partenza = jQuery("#departure").val();
var arrivo = jQuery("#arrival").val();
var adulti = jQuery("#adults").val();
var bambini = jQuery("#childs").val();
console.log("btn_preventivo click");
jQuery("#frm").attr(
"action",
"https://book.ermeshotels.com/#/hotel/2010/channel/324/language/1/rooms?arrival=" +
arrivo +
"&departure=" +
partenza +
"&adults=" +
adulti +
"&childs=" +
bambini,
);
},
startCountdown: function () {
var data = new Date();
var Hh, Mm, Ss, mm, YY, NextYear, Oggi, End, inizioAnno, EndCookie;
Hh = data.getHours() + ":";
Mm = data.getMinutes() + ":";
Ss = data.getSeconds() + ":";
mm = data.getMilliseconds() + ":";
YY = data.getFullYear();
NextYear = YY + 1;
Oggi = data.getTime() / 1000;
var cookieDate = readCookie("endCountDown");
// console.log("cookieDate = ",cookieDate);
if(cookieDate == null){
// console.log("cookieDate null, allora lo creo");
EndCookie = new Date(data);
EndCookie.setDate(data.getDate()+1);
EndCookie = Math.floor(EndCookie.getTime() / 1000);
// console.log("EndCookie = ",EndCookie);
createCookie("endCountDown", EndCookie, 1);
}else{
EndCookie = readCookie("endCountDown");
}
inizioAnno = new Date(YY, 0, 1, 0, 0, 0, 0).getTime() / 1000;
var End = Math.floor(
new Date(
dictionaryTranslate(
"[DIZIONARIO:mese_giorno_anno_gara]",
cmsPageParams.lang
)
).getTime() /
1000 +
60 * 60 * 24
);
// console.log("end = ",EndCookie);
/* 10 Settembre 2015 fineAnno = new Date(YY, 8, 10, 23, 59, 59, 59).getTime() / 1000; */
if (window.innerWidth > 767) {
jQuery(".countdown").final_countdown({
now: Oggi,
start: inizioAnno,
end: EndCookie,
selectors: {
value_seconds: '.clock-seconds .val',
canvas_seconds: 'canvas_seconds',
value_minutes: '.clock-minutes .val',
canvas_minutes: 'canvas_minutes',
value_hours: '.clock-hours .val',
canvas_hours: 'canvas_hours',
value_days: '.clock-days .val',
canvas_days: 'canvas_days'
},
seconds: {
borderColor: "#0074B2",
borderWidth: "10",
},
minutes: {
borderColor: "#0074B2",
borderWidth: "10",
},
hours: {
borderColor: "#0074B2",
borderWidth: "10",
},
days: {
borderColor: "#0074B2",
borderWidth: "10",
},
});
} else {
jQuery(".countdown").final_countdown({
now: Oggi,
start: inizioAnno,
end: EndCookie,
selectors: {
value_seconds: '.clock-seconds .val',
canvas_seconds: 'canvas_seconds',
value_minutes: '.clock-minutes .val',
canvas_minutes: 'canvas_minutes',
value_hours: '.clock-hours .val',
canvas_hours: 'canvas_hours',
value_days: '.clock-days .val',
canvas_days: 'canvas_days'
},
seconds: {
borderColor: "#0074B2",
borderWidth: "3",
},
minutes: {
borderColor: "#0074B2",
borderWidth: "3",
},
hours: {
borderColor: "#0074B2",
borderWidth: "3",
},
days: {
borderColor: "#0074B2",
borderWidth: "3",
},
});
}
},
};
siteApp.loadGoogleFont(
"https://fonts.googleapis.com/css?family=Lora:400,700,700i|Work+Sans:400,700|Antic:400",
);
window.addEventListener("load", function () {
siteApp.init();
siteApp.viewCheck();
siteApp.scrollAnimation();
var forms = document.querySelectorAll(".booking form");
for (var i = 0; i < forms.length; i++) {
titankaForm.enableCalendar(forms[i], ".modulo_data_soggiorno");
}
});
jQuery(window).on("load resize", function () {
if (window.innerWidth > 991) {
jQuery(".adattHeight").each(function () {
$height = jQuery(this).next().height();
// console.log($height)
if ($height) {
jQuery(this).height($height);
} else if (!$height) {
$height = jQuery(this).next().height();
jQuery(this).height($height);
}
});
}
});
/*gestione di funzioni es. onclick="gotobyscroll('.classe')"*/
function add_slide_menu(item) {
jQuery("li" + item + " .level2").toggleClass("slide-menu");
}
function back_menu(item) {
jQuery("li" + item + " .level2").toggleClass("slide-menu");
}
function show_menu(elem) {
if (window.innerWidth < 992) {
jQuery(elem).children(".sottomenu").toggleClass("slide-menu");
}
}
function hide_sottomenu(elem) {
if (window.innerWidth < 992) {
jQuery(elem).closest(".sottomenu").removeClass("slide-menu");
}
}
function goToByScroll(param) {
try {
jQuery("html, body").animate(
{ scrollTop: jQuery(param).offset().top - 200 },
2000,
"easeInOutQuad",
);
} catch (err) {}
}
function openModal() {
jQuery("#popupNewsletter").modal("show");
}
/* funzioni dei cookie */
function createCookie(name, value, days) {
if (days) {
var date = new Date();
// Now get the current Time (in milliseconds) and add the required number of days (in milliseconds). Set the Time of the date to this new value, so that it now contains the date in milliseconds that the cookie should expire.
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
// Set the variable expires to this date in the UTC/GMT format required by cookies.
var expires = "; expires=" + date.toGMTString();
console.log("expires = ",expires);
} else {
// If 0 is passed to the function, expires is not set and the cookie expires when the user closes his browser..
var expires = "";
}
// Finally write the new cookie into document.cookie in the correct syntax.
document.cookie = name + "=" + value + expires + "; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
// Then split document.cookie on semicolons. ca becomes an array containing all cookies that are set for this domain and path.
var ca = document.cookie.split(";");
// Then we go through the array (so through all cookies):
for (var i = 0; i < ca.length; i++) {
// Set c to the cookie to be checked.
var c = ca[i];
// If the first character is a space, remove it by using the substring() method. Continue doing this until the first character is not a space.
while (c.charAt(0) == " ") c = c.substring(1, c.length);
// Now string c begins with the name of the current cookie. If this is the name of the desired cookie
// we've found what we were looking for. We now only need to return the value of the cookie, which is the part of c that comes after nameEQ. By returning this value we also end the function: mission accomplished.
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
// If, after having gone through all cookies, we haven't found the name we're looking for, the cookie is not present. We return null.
return null;
}
function eraseCookie(name) {
createCookie(name, "", -1);
}
function apriPopupVipClub() {
jQuery("#popupVipClub").modal();
}
function compilaForm() {
var nome = jQuery('.form-preventivo input[name="firstName"]').val();
var cognome = jQuery('.form-preventivo input[name="lastName"]').val();
var email = jQuery('.form-preventivo input[name="email"]').val();
var cellulare = jQuery('.form-preventivo input[name="phone"]').val();
// console.log("preventivo nome " + nome);
// console.log("preventivo cognome " + cognome);
// console.log("preventivo email " + email);
// console.log("preventivo cell " + cellulare);
jQuery(".mrprenoForm input[name='name']").val(nome);
jQuery(".mrprenoForm input[name='lastname']").val(cognome);
jQuery(".mrprenoForm input[name='email']").val(email);
jQuery(".mrprenoForm input[name='phone']").val(cellulare);
goToByScroll(".mrprenoForm");
}
switch (cmsPageParams.relation_code) {
case "1549633936":
function callbackIscrizioneNewsletter(e) {
location.href = "/thankyoupage-newsletter/";
}
break;
default:
break;
}