//Main admin JS file $(function() { jQuery.validator.addMethod("noSpace", function(value, element) { return value.indexOf(" ") < 0 && value != ""; }, "Space are not allowed"); jQuery.validator.addMethod("invalidUsername", function(value, element) { return value != "" && value.toUpperCase() != "ROOT" && value.toUpperCase() != "ADMIN"; }, "Invalid username"); jQuery.validator.addMethod("numericField", function(value, element) { var myregExp = /^\d*[0-9](|.\d*[0-9]|,\d*[0-9])?$/; return value == "" || (value != "" && myregExp.test(value)); }, "Invalid number"); jQuery.validator.addMethod("requiredTinyMCE", function(value, element) { return tinyMCE.get($(element).attr('id')).getContent() != ''; //return Trim(tinyMCE.get(element.attr('id')).getContent()) == ''; //return value.indexOf(" ") < 0 && value != ""; }, "Required"); $.ajax({ url: $('#base_url').val() + "ajax/get_last_cookie_key", type: 'POST', data: 'lang=' + lang, success: function (data) { var actual_key=data; var cookie_url=$('#base_url').val()+"cookie"; $.cookieBar({ message: "I cookies servono a migliorare i servizi che offriamo e a ottimizzare l\'esperienza dell\'utente. Per saperne di piú accedi alla cookie policy.
Se chiudi il presente banner o prosegui la navigazione del sito, acconsenti all\'utilizzo dei cookie.

", acceptText: "Accetta tutti", declineText: "Rifiuta tutti", policyURL: cookie_url, cookieName: actual_key }); } }); $("img.lazy").lazyload({ effect : "fadeIn", skip_invisible : false }); $("div.lazy").lazyload({ effect : "fadeIn" }); //setLang('',0); $('.lang_switcher').bind('click',function(e) { e.preventDefault(); setLang($(this).data('lang'),1); }); var genericForm = 1; /***COOKIE PAGE***/ if($('.js_cookie_page').length) { $('.js_switch_cookies').attr('checked','checked'); $("#js_cookie_rifiuta_all").bind('click',function(e) { $('.js_switch_cookies_optional').removeAttr('checked'); }); $("#js_cookie_accetta_all").bind('click',function(e) { $('.js_switch_cookies_optional').attr('checked','checked'); }); } /***HOME***/ if($('#home_container').length) { $('#home_container').find('a').each(function() { var href = $(this).attr('href'); $(this).bind('click',function(e) { $.ajax({ url: $('#base_url').val() + "ajax/clear_filtri_eventi", type: 'POST', data: 'lang=' + lang, success: function (data) { document.location.href=href; } }); }); }); } /***CARRELLO***/ if($('#carrello_paypal').length>0) { function get_bundles() { $.ajax({ type: "POST", url: $('#base_url').val()+"ajax/get_bundles", data: "data_slot="+$('#data_slot').val()+"&evento_id="+$('#evento_id').val(), success: function(data) { $('#bundle_container').html(data); if($('#bundle_id').html().trim() != '' || $('#bundle_id').val().trim() != '') { //$('#bundle_container').fadeIn(); $('#bundle_id').bind('change',function() { get_quantity(); }); get_quantity(); } else { $('#carrello_paypal').fadeOut(0); } } }); } function get_quantity() { $.ajax({ type: "POST", url: $('#base_url').val()+"ajax/get_quantity", data: "bundle_id="+$('#bundle_id').val(), success: function(data) { var dataArr = data.split("|||"); $('#quantita').html(dataArr[0]); $('#quantita').fadeIn(); $('#quantita').bind('change',function() { $('#quantity_1').val($(this).val()); }); $('#amount_1').val(dataArr[1]); $('#loader_caricamento').fadeOut(0); $('#bundle_container').fadeIn(0); $('#quantita_container').fadeIn(0); } }); } $('#data_slot').bind('change',function() { get_bundles(); }); if($('#data_slot').val() != '') { get_bundles(); } $('#quantita').bind('change',function() { $('#quantity_1').val($(this).val()); }); $('#acquista_button').bind('click',function(e) { e.preventDefault(); $('body').prepend('
'); $('#loader_conferma').fadeIn(); $.ajax({ type: "POST", url: $('#base_url').val()+"ajax/set_ordine_data", data: "quantita="+$('#quantita').val()+"&bundle_id="+$('#bundle_id').val()+"&evento_id="+$('#evento_id').val()+"&data_slot="+$('#data_slot').val(), success: function(datas) { $.ajax({ type: "POST", url: $('#base_url').val()+"ajax/crea_ordine", success: function(data) { $('#custom').val(data+"-"+$('#quantita').val()+"-"+$('#bundle_id').val()); $.ajax({ type: "POST", url: $('#base_url').val()+"ajax/conferma_ordine", data:"ordine_id="+data+"&quantita="+$('#quantita').val()+"&bundle_id="+$('#bundle_id').val(), success: function(data) { document.location.href=$('#base_url').val()+'thank_you'; //$('#paypal_form').submit(); } }); } }); } }); }); } /****registrazione****/ if($('#registrazione_container').length>0) { $('.recupera_link').bind('click',function(e) { e.preventDefault(); $('#password_container').fadeIn(); }); $('.recupera_chiudi_btn').bind('click',function(e) { e.preventDefault(); $('#password_container').fadeOut(); }); $('#reg').validate({ ignore: [], errorPlacement: function(error, element) { error.appendTo('#' + element.attr('name')+'-error'); }, rules: { reg_email: { remote: { url: $('#base_url').val()+"ajax/check_email", type: "post", data: { email: function() { return $('#reg').find( "#reg_email" ).val(); }, id:function() { return 0; } } }, email:true, required:true }, privacy_policy_check: { required:true } }, messages: { reg_email: { remote: "Indirizzo email già in uso", email: "Inserisci un indirizzo email valido", required: "Inserisci un indirizzo email valido" }, privacy_policy_check: { required: "Attenzione, per poterti registrare devi aver letto l\'informativa privacy e acconsentire al trattamento dei tuoi dati." } } }); } if($('.evento_container').length>0) { $('#vai_reg').bind('click',function(e) { e.preventDefault(); $.ajax({ type: "POST", url: $('#base_url').val()+"ajax/set_ordine_data", data: "quantita="+$('#quantita').val()+"&bundle_id="+$('#bundle_id').val()+"&evento_id="+$('#evento_id').val()+"&data_slot="+$('#data_slot').val(), success: function(data) { document.location.href=$('#base_url').val()+"registrazione/1"; } }); }); } if($('.eventi_container').length>0) { $.datepicker.setDefaults( $.datepicker.regional[ "en-GB" ] ); $('#filtra_eventi').bind('click',function(e) { e.preventDefault(); $.ajax({ type: "POST", url: $('#base_url').val()+"ajax/filtra_eventi", data: "filtro_comune="+$('#filtro_comune').val()+"&filtro_data="+$('#from').val()+","+$('#to').val()+"&filtro_tag="+$('#filtro_tag').val(), success: function(data) { if($('#filtro_tag').val() == '0') { document.location.href=$('#base_url').val()+$('#config_slug').val(); } else { document.location.href=$('#base_url').val()+$('#config_slug').val()+"/"+$('#filtro_tag').find(":selected").data('slug'); } } }); }); $('#reset_filtro_eventi').bind('click',function(e) { e.preventDefault(); $.ajax({ type: "POST", url: $('#base_url').val()+"ajax/filtra_eventi", data: "filtro_comune=&filtro_data=&filtro_tag=,", success: function(data) { document.location.href=$('#base_url').val()+$('#config_slug').val(); } }); }); $('#filtro_data_from').datepicker({ altField: "#from", altFormat: "yy-mm-dd", onClose: function(selectedDate) { $( "#filtro_data_to" ).datepicker( "option", "minDate", selectedDate ); } }); $('#filtro_data_to').datepicker({ altField: "#to", altFormat: "yy-mm-dd", onClose: function(selectedDate) { $( "#filtro_data_from" ).datepicker( "option", "maxDate", selectedDate ); } }); } if($('#cambia_email').length>0) { $('#cambia_email').validate({ ignore: [], errorPlacement: function(error, element) { error.appendTo('#' + element.attr('name')+'-error'); }, rules: { email: { remote: { url: $('#base_url').val()+"ajax/check_email", type: "post", data: { email: function() { return $( "#email" ).val(); }, id: function() { return $( "#utente_id" ).val(); } } }, email:true, required:true } }, messages: { email: { remote: "Indirizzo email già in uso", email: "Inserisci un indirizzo email valido", required: "Inserisci un indirizzo email valido" } } }); } if($('#cambia_password').length>0) { $('#cambia_password').validate({ ignore: [], errorPlacement: function(error, element) { error.appendTo('#' + element.attr('name')+'-error'); }, rules: { password_corrente: { remote: { url: $('#base_url').val()+"ajax/check_old_password", type: "post", data: { password: function() { return $( "#password_corrente" ).val(); } } }, required:true } }, messages: { password_corrente: { remote: "Password errata", required: "Inserisci la tua password attuale" } } }); } /******PAGINE CON OBSERVER SCROLL*******/ if($('#js_scroll_template').length>0) { /****fade tiny mce****/ $("p").addClass('observer_hide'); const config = { //root: document.querySelector("#js_hd_cont"), rootMargin: '10%', threshold: [0] }; const myImgs = document.querySelectorAll('p'); observer = new IntersectionObserver(entries => { entries.forEach(entry => { //console.log(entry); const element = entry.target; if (entry.intersectionRatio > 0) { //console.log('in the view'); entry.target.classList.add('observer_show'); entry.target.classList.add('observer_in_view'); observer.unobserve(element); } else { //console.log('out of view'); //entry.target.classList.remove('observer_in_view'); //observer.unobserve(element); } }); },config); myImgs.forEach(image => { observer.observe(image); }); /****fade elementi plugin con classe js_plugin_scroll_element****/ $('.js_plugin_scroll_element').each(function() { $(this).addClass('observer_hide'); }); const myElements = document.querySelectorAll('.js_plugin_scroll_element'); observerplugin = new IntersectionObserver(entries => { entries.forEach(entry => { //console.log(entry); const element = entry.target; if (entry.intersectionRatio > 0) { //console.log('in the view'); entry.target.classList.add('observer_show'); entry.target.classList.add('observer_in_view'); } else { //console.log('out of view'); //entry.target.classList.remove('observer_in_view'); //observer.unobserve(element); } }); },config); myElements.forEach(image => { observerplugin.observe(image); }); /****lazy loading images in tiny****/ const tinyImgs = document.querySelectorAll('p img'); observertinyimg = new IntersectionObserver(entries => { entries.forEach(entry => { //console.log(entry); const element = entry.target; if (entry.intersectionRatio > 0) { //console.log('in the view'); const img = entry.target; const src = img.getAttribute('data-src'); if(src!=null){ //console.log('url trattato'+src); img.setAttribute('src', src); } observertinyimg.unobserve(element); } }); },config); tinyImgs.forEach(image => { observertinyimg.observe(image); }); /****lazy loading images in tiny****/ const pluginImgs = document.querySelectorAll('.plugin_image_lazy'); observerpluginimg = new IntersectionObserver(entries => { entries.forEach(entry => { const element = entry.target; if (entry.intersectionRatio >= 0) { const img = entry.target; const src = img.getAttribute('data-src'); img.setAttribute('src', src); observerpluginimg.unobserve(element); } }); },config); pluginImgs.forEach(image => { observerpluginimg.observe(image); }); /****lazy loading images in header_plugin****/ const pluginHeaderImgs = document.querySelectorAll('.plugin_header_image_lazy'); observerpluginheaderimg = new IntersectionObserver(entries => { entries.forEach(entry => { const element = entry.target; if (entry.intersectionRatio >= 0) { const img = entry.target; const src = img.getAttribute('data-src'); img.setAttribute('src', src); observerpluginheaderimg.unobserve(element); } }); },config); pluginHeaderImgs.forEach(image => { observerpluginheaderimg.observe(image); }); } /******GDPR*******/ if($('.privacy_policy').length>0) { } if($('#manage_privacy').length>0) { $('#edit_policy').validate({ ignore: [], errorPlacement: function(error, element) { error.appendTo('#' + element.attr('name')+'-error'); }, rules: { privacy_policy_check: { required:true } }, messages: { privacy_policy_check: { required: "Attenzione, per poterti registrare devi aver letto l\'informativa privacy e acconsentire al trattamento dei tuoi dati." } } }); $('#x_btn_marketing').bind('click',function(e) { e.preventDefault(); $("#container_marketing_checkbox").show(); $("#container_label_marketing").hide(); $('#marketing_check').attr('checked', false); }); $('#x_btn_newsletter').bind('click',function(e) { e.preventDefault(); $("#container_newsletter_checkbox").show(); $("#container_label_newsletter").hide(); $('#newsletter_check').attr('checked', false); }); } /*****NEWSLETTER BOX******/ $('#newsletter_form').validate({ ignore: [], errorPlacement: function(error, element) { error.appendTo('#' + element.attr('name')+'-error'); }, rules: { email: { email:true, required:true }, privacy_policy_check: { required:true } }, messages: { email: { email: "Inserisci un indirizzo email valido", required: "Inserisci un indirizzo email valido" }, privacy_policy_check: { required: "Attenzione, per poterti registrare devi aver letto l\'informativa privacy e acconsentire al trattamento dei tuoi dati." } }, submitHandler: function(form) { $.ajax({ type: "POST", url: $('#base_url').val() +"ajax/subscribe_mailchimp", data: $('#newsletter_form').serialize(), success: function(data) { alert(data); alert("Ok, a presto!"); $('#mailchimp_email').val(''); }, error: function(xhr, status, error) { alert("Ok, a presto!"); $('#mailchimp_email').val(''); }, }); } }); /****HEADER***/ //shadow animation header $(window).scroll(function() { var scroll = $(window).scrollTop(); if (scroll > 1.5) { $("#header").removeClass("header_container_main_shadow_off"); $("#header").addClass("header_container_main_shadow"); } else { $("#header").removeClass("header_container_main_shadow"); $("#header").addClass("header_container_main_shadow_off"); } }); if($('#menu_laterale').length>0) { $('#navigation_menu').find('a').each(function() { var href = $(this).attr('href'); $(this).bind('click',function(e) { $.ajax({ url: $('#base_url').val() + "ajax/clear_filtri_eventi", type: 'POST', data: 'lang=' + lang, success: function (data) { //document.location.href=href; } }); }); }); /***from right animation***/ /*$('.menu_btn').bind('click',function(e) { e.preventDefault(); if(!$('#menu_laterale').hasClass('open')) { $('#menu_laterale').animate({'right':'0'},500,function() { $('#menu_laterale').addClass('open'); }); $('body').prepend('
'); $('#sfondo').bind('click',function() { $('#sfondo').remove(); if($('#menu_laterale').hasClass('open')) { $('#menu_laterale').animate({'right': '-270px'}, 500, function () { $('#menu_laterale').removeClass('open'); }); } }); } else { $('#sfondo').remove(); if($('#menu_laterale').hasClass('open')) { $('#menu_laterale').animate({'right': '-270px'}, 500, function () { $('#menu_laterale').removeClass('open'); }); } } });*/ /***fade in/out animation***/ $('.menu_btn').bind('click',function(e) { e.preventDefault(); if(!$('#menu_laterale').hasClass('open')) { //alert("1"); $('.js_menu_btn_img').each(function() { $(this).attr("src",$('#base_url').val()+"assets/images/mobile_menu_btn.svg"); }); $('#header').prepend('
'); $('#sfondo').fadeOut(0); $('#sfondo').fadeIn(500, function() { $('#menu_laterale').animate({'right':'5%'},0,function() { $('#menu_laterale').addClass('open'); }); $('#menu_laterale').fadeIn(500); $('#sfondo').bind('click',function() { $("#sfondo").fadeOut(500, function() { $('#sfondo').remove(); }); if($('#menu_laterale').hasClass('open')) { $("#menu_laterale").fadeOut(500, function() { $('#menu_laterale').animate({'right': '-10%'}, 0, function () { $('#menu_laterale').removeClass('open'); }); }); } }); }); } else { $('.js_menu_btn_img').each(function() { $(this).attr("src",$('#base_url').val()+"assets/images/mobile_menu_btn.svg"); }); $("#sfondo").fadeOut(500, function() { $('#sfondo').remove(); }); if($('#menu_laterale').hasClass('open')) { $("#menu_laterale").fadeOut(500, function() { $('#menu_laterale').animate({'right': '-10%'}, 0, function () { $('#menu_laterale').removeClass('open'); }); }); } } }); } /****FORMS*****/ if(genericForm == 1) { $('form').each(function() { $(this).validate({ ignore: [], errorPlacement: function(error, element) { error.appendTo('#' + element.attr('name')+'-error'); } }); }); } /************SHOW BODY********************/ /************GRIGLIA CUSTOM TOLEMAICA********************/ function hideModal() { $('#sfondo').remove(); $('#modal_griglia_front').fadeOut(); $('#modal_griglia_front').html(""); } $('.griglia_pop_up_js').each(function() { $(this).bind('click',function(e) { e.preventDefault(); var item_id = $(this).data('item'); //alert("cliccato "+item_id); $.ajax({ type: "POST", url: $('#base_url').val()+"ajax/get_embed_griglia", data: "item_id="+item_id, success: function(data){ if(data!=""){ $('#modal_griglia_front').html(data); $('#modal_griglia_front').fadeIn(); $('body').prepend(''); $('#sfondo').bind('click',function(e) { hideModal(); }); } } }); }); }); /************GRIGLIA CUSTOM TOLEMAICA********************/ /************MODAL PLUGIN********************/ if ($("#modal_plugin_container").length){ showModalPlugin(); } function hideModalPlugin() { $('#sfondo').remove(); $('#modal_plugin_container').fadeOut(); $('#modal_plugin_container').html(""); } function showModalPlugin() { $('body').prepend(''); $('#modal_plugin_container').fadeIn(); $('#sfondo').bind('click',function(e) { hideModalPlugin(); }); } $('.open_modal_plugin_modal').each(function() { $(this).bind('click',function(e) { e.preventDefault(); showModalPlugin(); }); }); $('.close_modal_plugin_modal').each(function() { $(this).bind('click',function(e) { e.preventDefault(); hideModalPlugin(); }); }); $("#non_mostrare_piu_check").bind('change',function(e) { e.preventDefault(); var id_modal = $(this).data('item'); var status=0; if (this.checked) { status=1; } $.ajax({ type: "POST", url: $('#base_url').val()+"ajax/set_cookie", data: "id_modal="+id_modal+"&status="+status, success: function(data){ if(data!=""){ } } }); }); /************MODAL PLUGIN********************/ }); function setLang(lang,redirect) { $.ajax({ url: $('#base_url').val() + "ajax/set_lang", type: 'POST', data: 'lang=' + lang, success: function (data) { $('#lang').val(data); if(redirect == 1) { document.location.href=document.location.href; } } }); }