//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: "We use cookies to enhance your experience. By continuing to visit this site you agree to our use of cookies. If you want to learn more, please refer to the cookie policy.
",
acceptText: "Ok, close this banner",
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 lang=$(this).data('lang');
var url=$(this).data('url');
$.ajax({
url: $('#base_url').val() + "ajax/set_lang",
type: 'POST',
data: 'lang=' + lang,
success: function (data) {
$('#lang').val(data);
if(url) {
document.location.href=url;
} else {
document.location.href=document.location.href;
}
}
});
});
var genericForm = 1;
$('#js_no_lang_content').bind('click',function(e) {
e.preventDefault();
//setLang($(this).data('lang'),1);
var lang=$(this).data('lang');
var url=$(this).data('url');
$.ajax({
url: $('#base_url').val() + "ajax/set_lang",
type: 'POST',
data: 'lang=' + lang,
success: function (data) {
$('#lang').val(data);
if(url) {
document.location.href=url;
} else {
document.location.href=document.location.href;
}
}
});
});
/***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("option", $.datepicker.regional["de"])
$('#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",
regional: "de",
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 e table****/
const tinyImgsTable = document.querySelectorAll('table img');
observertinyimgtable = 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);
}
observertinyimgtable.unobserve(element);
}
});
},config);
tinyImgsTable.forEach(image => {
observertinyimgtable.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);
});
//////prova per carosello
$('.js_carousel_embed').each(function() {
//$(this).addClass('observer_hide');
});
const myElementsCarousel = document.querySelectorAll('.js_carousel_embed');
observerplugincarosello = new IntersectionObserver(entries => {
entries.forEach(entry => {
//console.log(entry);
const element = entry.target;
if (entry.intersectionRatio > 0) {
//console.log('in the view carosello');
const carousel_element = entry.target;
const carousel_element_id = carousel_element.getAttribute('data-id');
var element_div_id="js_carousel_embed_"+carousel_element_id;
//console.log("id carosello entrante "+carousel_element_id);
$.ajax({
type: "POST",
url: $('#base_url').val() +"ajax/carosello_embed",
data: 'carosello_slide_id=' + carousel_element_id,
success: function(data) {
if(data!=""){
document.getElementById(element_div_id).innerHTML = data;
observerplugincarosello.unobserve(element);
window.instgrm.Embeds.process();
} else {
}
},
error: function(xhr, status, error) {
},
});
//carousel_element.classList.remove("absolute");
} else {
//console.log('out of view carosello');
//entry.target.classList.remove('observer_in_view');
//observer.unobserve(element);
}
});
},config);
myElementsCarousel.forEach(image => {
observerplugincarosello.observe(image);
});
////prova per carosello
}
if($('#paginazione_eventi_input').length>0) {
/*const config = {
//root: document.querySelector("#js_hd_cont"),
rootMargin: '-10%',
threshold: [0]
};
const bottomEventiDiv = document.querySelectorAll('.js_paginazione_eventi_div');
observerBottomEventi = new IntersectionObserver(entries => {
entries.forEach(entry => {
const element = entry.target;
console.log(entry.intersectionRatio);
if (entry.isIntersecting) {
alert("bottom");
//observerBottomEventi.unobserve(element);
}
});
},config);
bottomEventiDiv.forEach(image => {
observerBottomEventi.observe(image);
}); */
var chiamata_in_corso=0;
var ricevuto_uno_zero=0;
const el = document.querySelector('#paginazione_eventi_div')
const observer = new window.IntersectionObserver(([entry]) => {
//console.log(entry.boundingClientRect.top)
if (entry.isIntersecting) {
//console.log('Enter')
//console.log("VISIBLE") // do things if visible
var filtro_data=$("#filtro_data_paginazione").val();
var filtro_tag=$("#filtro_tag_paginazione").val();
var filtro_comune=$("#filtro_comune_paginazione").val();
var attuale=$("#paginazione_eventi_input").val();
var nuovo=parseInt(attuale)+1;
var eventi_ids_estratti = $('input[name^=eventi_ids]').map(function(idx, elem) {
return $(elem).val();
}).get();
console.log(eventi_ids_estratti);
if(chiamata_in_corso==0 && ricevuto_uno_zero==0 && eventi_ids_estratti.length>=10){
chiamata_in_corso=1;
$("#loader_paginazione").fadeIn(300);
$.ajax({
type: "POST",
url: $('#base_url').val() +"ajax/eventi_paginazione",
data: 'pagina=' + nuovo+"&filtro_data="+filtro_data+"&filtro_comune="+filtro_comune+"&filtro_tag="+filtro_tag+"&eventi_ids_estratti="+eventi_ids_estratti,
success: function(data) {
$("#loader_paginazione").fadeOut(100);
if(data!=""){
$('#paginazione_eventi_input').val(nuovo);
//$('#paginazione_elements').append(data);
$(data).hide().appendTo("#paginazione_elements").fadeIn(1000);
} else {
ricevuto_uno_zero=1;
}
chiamata_in_corso=0;
},
error: function(xhr, status, error) {
$("#loader_paginazione").fadeOut(100);
chiamata_in_corso=0;
},
});
}
return
}
//console.log('Leave')
if (entry.boundingClientRect.top > 0) {
//console.log("BELOW") // do things if below
} else {
//console.log("ABOVE") // do things if above
}
}, {
root: null,
threshold: 0,
})
observer.observe(el);
}
if($('#paginazione_instagram_input').length>0) {
var chiamata_in_corso=0;
var ricevuto_uno_zero=0;
const el = document.querySelector('#paginazione_instagram_div')
const observer = new window.IntersectionObserver(([entry]) => {
//console.log(entry.boundingClientRect.top)
if (entry.isIntersecting) {
//console.log('Enter')
//console.log("VISIBLE") // do things if visible
var attuale=$("#paginazione_instagram_input").val();
var nuovo=parseInt(attuale)+1;
var instagram_ids_estratti = $('input[name^=instagram_ids]').map(function(idx, elem) {
return $(elem).val();
}).get();
//console.log(instagram_ids_estratti);
if(chiamata_in_corso==0 && ricevuto_uno_zero==0 && instagram_ids_estratti.length>=30){
chiamata_in_corso=1;
$("#loader_paginazione").fadeIn(300);
$.ajax({
type: "POST",
url: $('#base_url').val() +"ajax/instagram_paginazione",
data: 'pagina=' + nuovo+"&instagram_ids_estratti="+instagram_ids_estratti,
success: function(data) {
$("#loader_paginazione").fadeOut(100);
if(data!=""){
$('#paginazione_instagram_input').val(nuovo);
//$('#paginazione_elements').append(data);
$(data).hide().appendTo("#paginazione_elements").fadeIn(1000);
} else {
ricevuto_uno_zero=1;
}
chiamata_in_corso=0;
},
error: function(xhr, status, error) {
$("#loader_paginazione").fadeOut(100);
chiamata_in_corso=0;
},
});
}
return
}
//console.log('Leave'+entry.boundingClientRect.top);
if (entry.boundingClientRect.top > 0) {
//console.log("BELOW") // do things if below
} else {
//console.log("ABOVE") // do things if above
}
}, {
root: null,
threshold: 0,
})
observer.observe(el);
}
if($('#paginazione_carosello_input').length>0) {
var chiamata_in_corso=0;
var ricevuto_uno_zero=0;
const el = document.querySelector('#paginazione_carosello_div')
const observer = new window.IntersectionObserver(([entry]) => {
//console.log(entry.boundingClientRect.top)
if (entry.isIntersecting) {
//console.log('Enter')
//console.log("VISIBLE") // do things if visible
var attuale=$("#paginazione_carosello_input").val();
var nuovo=parseInt(attuale)+1;
var carosello_ids_estratti = $('input[name^=carosello_ids]').map(function(idx, elem) {
return $(elem).val();
}).get();
//console.log(carosello_ids_estratti);
if(chiamata_in_corso==0 && ricevuto_uno_zero==0 && carosello_ids_estratti.length>=20){
chiamata_in_corso=1;
$("#loader_paginazione").fadeIn(300);
$.ajax({
type: "POST",
url: $('#base_url').val() +"ajax/carosello_paginazione",
data: 'pagina=' + nuovo+"&carosello_ids_estratti="+carosello_ids_estratti,
success: function(data) {
$("#loader_paginazione").fadeOut(100);
if(data!=""){
$('#paginazione_carosello_input').val(nuovo);
//$('#paginazione_elements').append(data);
$(data).hide().appendTo("#paginazione_elements").fadeIn(1000);
window.instgrm.Embeds.process(); //senza questo i post in ritorno non si vedono
} else {
ricevuto_uno_zero=1;
}
chiamata_in_corso=0;
},
error: function(xhr, status, error) {
$("#loader_paginazione").fadeOut(100);
chiamata_in_corso=0;
},
});
}
return
}
//console.log('Leave'+entry.boundingClientRect.top);
if (entry.boundingClientRect.top > 0) {
//console.log("BELOW") // do things if below
} else {
//console.log("ABOVE") // do things if above
}
}, {
root: null,
threshold: 0,
})
observer.observe(el);
}
/******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('');
},
});
}
});
/****ARCHIVIO INSTAGRAM****/
function hideModalInstagram() {
$('#sfondo').remove();
$('#modal_instagram_front').fadeOut();
$('#modal_instagram_front').html("");
}
$('.js_popup_insta_element').each(function() {
$(this).bind('click',function(e) {
e.preventDefault();
var item_id = $(this).data('slide_id');
$.ajax({
url: $('#base_url').val() + "ajax/get_instagram_pop_up",
type: 'POST',
data: 'item_id=' + item_id,
success: function (data) {
//alert("titolo "+popup_title+" item id"+item_id);
$('body').prepend('');
$('#modal_instagram_front').html(data);
$('#modal_instagram_front').fadeIn();
$('#sfondo').bind('click',function(e) {
hideModalInstagram();
});
$('.instacrs_modal_close_btn').bind('click',function(e) {
hideModalInstagram();
});
}
});
});
});
/****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********************/
//controlla se è presente un'ancora nell'url. Se c'è porta all'ancora
var hash = window.location.hash.substr(1);
if(hash!="" && hash!=null){
setTimeout( function(){
// Do something after 1 second
var aTag = $("a[id='"+ hash +"']");
$('html,body').animate({scrollTop: aTag.offset().top},'fast');
} , 250 );
}
//controlla se è presente un'ancora nell'url. Se c'è porta all'ancora
});
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;
}
}
});
}