jQuery(document).ready(function($){
document.addEventListener('wpcf7mailsent', function(event){
switch(window.location.pathname){
case '/download-trial/':
window.location.href='/cortesia/?redirect=home';
break;
case '/videocorsi/iscrizioni/':
if($('input[name="listaattesa"]').length > 0&&1===parseInt($('input[name="listaattesa"]').val().trim()) ){
window.location.href='/videocorsi/lista-attesa-confermata/';
}else{
window.location.href='/videocorsi/iscrizione-confermata/';
}
break;
case '/suggerimenti/':
window.location.href='/suggerimenti/conferma-invio/';
break;
default:
}}, false);
if('/cortesia/'==window.location.pathname){
var mc4Redirect='';
if(-1!==window.location.search.indexOf('?redirect=home') ){
mc4Redirect='/';
}
setTimeout(function(){
window.location.href=mc4Redirect;
}, 5000);
}else if('/download-trial/'==window.location.pathname){
if('1'==mc4_custom_data.mc4_is_logged){
$('input[name="form_fields[email]"]').val(mc4_custom_data.mc4_user_email);
$('input[name="form_fields[name]"]').val(mc4_custom_data.mc4_user_name);
$('input[name="form_fields[surname]"]').val(mc4_custom_data.mc4_user_surname);
$('input[name="form_fields[telephone]"]').val(mc4_custom_data.mc4_user_telephone);
$('input[name="form_fields[email]"]').attr('readonly', 'readonly');
$('input[name="form_fields[telephone]"]').attr('readonly', 'readonly');
}}else if('/videocorsi/iscrizioni/'==window.location.pathname){
if('1'==mc4_custom_data.mc4_is_logged){
$('input[name="ragione"]').attr('readonly', 'readonly');
$('input[name="nome"]').attr('readonly', 'readonly');
$('input[name="cognome"]').attr('readonly', 'readonly');
$('input[name="indirizzo"]').attr('readonly', 'readonly');
$('input[name="telefono"]').attr('readonly', 'readonly');
$('input[name="email"]').attr('readonly', 'readonly');
}}
$('button[name="go-home"], input[name="go-home"]').on('click', function(){
window.location.href='/';
});
$('button[name="go-login"], input[name="go-login"]').on('click', function(){
window.location.href='/accedi/';
});
$('[type="button"][data-location]').each(function(index){
var mc4_data_location=$(this).attr('data-location');
$(this).on('click', function(){
if($(this).attr('data-blank')&&'yes'==$(this).attr('data-blank') ){
window.open(mc4_data_location, '_blank');
}else{
window.location.href=mc4_data_location;
}});
});
$('div.mc4-elementor-tab-title').on('click', function(){
if($(this).hasClass('elementor-active') ){
$(this).removeClass('elementor-active');
$(this).attr('aria-expanded', 'false');
$(this).attr('aria-selected', 'false');
$(this).attr('tabindex', '-1');
$(this).next('div.elementor-tab-content').removeClass('elementor-active');
$(this).next('div.elementor-tab-content').animate({height: "hide", marginBottom: "hide", marginTop: "hide", paddingBottom: "hide", paddingTop: "hide"}, 400);
}else{
$(this).addClass('elementor-active');
$(this).attr('aria-expanded', 'true');
$(this).attr('aria-selected', 'true');
$(this).attr('tabindex', '0');
$(this).next('div.elementor-tab-content').addClass('elementor-active');
$(this).next('div.elementor-tab-content').animate({height: "show", marginBottom: "show", marginTop: "show", paddingBottom: "show", paddingTop: "show"}, 400);
}});
$('a[data-come-from]').click(function(event){
var comeFrom=$(this).attr('data-come-from');
$('input[name="come_from"]').each(function(index){
$(this).val(comeFrom);
});
});
$('.wpcf7 button.wpcf7-submit').click(function(event){
var comeFromIsEmpty=true;
if($('input[name="come_from"]').length > 0){
$('input[name="come_from"]').each(function(index){
if(''!=$(this).val().trim()){
comeFromIsEmpty=false;
return false;
}});
if(comeFromIsEmpty){
var comeFrom=$('title').html();
$('input[name="come_from"]').each(function(index){
$(this).val(comeFrom);
});
}}
});
$('div[data-mc4-slideshow="zoom"] div.elementor-widget-container img').click(function(event){
if($(this).hasClass('mc4-zoom') ){
$(this).removeClass('mc4-zoom');
$(this).css('-webkit-transform', '');
$(this).css('-moz-transform', '');
$(this).css('-o-transform', '');
$(this).css('transform', '');
$(this).css('translate', '');
}else{
$(this).addClass('mc4-zoom');
var screenWidth=parseInt($(window).width());
var imageWidth=parseInt($(this).width());
var imgOffsetLeft=parseInt($(this).offset().left);
if(screenWidth > imageWidth&&screenWidth > 767){
var translWidth=(screenWidth / 2) -(imgOffsetLeft +(imageWidth / 2) );
var scalePercent=(screenWidth / imageWidth) - 0.01;
scalePercent=(scalePercent > 2) ? 2:scalePercent;
if(translWidth > 0){
$(this).css('-webkit-transform', 'scale(' + scalePercent + ')');
$(this).css('-moz-transform', 'scale(' + scalePercent + ')');
$(this).css('-o-transform', 'scale(' + scalePercent + ')');
$(this).css('transform', 'scale(' + scalePercent + ')');
$(this).css('translate', translWidth + 'px');
}}
}});
$('input[name="disclaimer_start"]').click(function(event){
if($(this).is(':checked') ){
$('button[name="start_assistance"]').prop('disabled', false);
$('button[name="start_assistance"]').removeClass('mc4-action-1-disabled');
$('button[name="start_assistance"]').addClass('mc4-action-1');
$('button[name="start_assistance"]').attr('title', mc4_custom_data.mc4_support_start);
}else{
$('button[name="start_assistance"]').prop('disabled', true);
$('button[name="start_assistance"]').removeClass('mc4-action-1');
$('button[name="start_assistance"]').addClass('mc4-action-1-disabled');
$('button[name="start_assistance"]').attr('title', mc4_custom_data.mc4_support_warning);
}});
$('input[name="disclaimer_online"]').click(function(event){
if($(this).is(':checked') ){
$('button[name="online_assistance"]').prop('disabled', false);
$('button[name="online_assistance"]').removeClass('mc4-action-1-disabled');
$('button[name="online_assistance"]').addClass('mc4-action-1');
$('button[name="online_assistance"]').attr('title', mc4_custom_data.mc4_support_online);
}else{
$('button[name="online_assistance"]').prop('disabled', true);
$('button[name="online_assistance"]').removeClass('mc4-action-1');
$('button[name="online_assistance"]').addClass('mc4-action-1-disabled');
$('button[name="online_assistance"]').attr('title', mc4_custom_data.mc4_support_warning);
}});
$('input[name="disclaimer_phone"]').click(function(event){
if($(this).is(':checked') ){
$('button[name="phone_assistance"]').prop('disabled', false);
$('button[name="phone_assistance"]').removeClass('mc4-action-1-disabled');
$('button[name="phone_assistance"]').addClass('mc4-action-1');
$('button[name="phone_assistance"]').attr('title', mc4_custom_data.mc4_support_phone);
}else{
$('button[name="phone_assistance"]').prop('disabled', true);
$('button[name="phone_assistance"]').removeClass('mc4-action-1');
$('button[name="phone_assistance"]').addClass('mc4-action-1-disabled');
$('button[name="phone_assistance"]').attr('title', mc4_custom_data.mc4_support_warning);
}});
$('input[name="disclaimer_chat"]').click(function(event){
if($(this).is(':checked') ){
$('button[name="chat_assistance"]').prop('disabled', false);
$('button[name="chat_assistance"]').removeClass('mc4-action-1-disabled');
$('button[name="chat_assistance"]').addClass('mc4-action-1');
$('button[name="chat_assistance"]').attr('title', mc4_custom_data.mc4_chat_assistance);
}else{
$('button[name="chat_assistance"]').prop('disabled', true);
$('button[name="chat_assistance"]').removeClass('mc4-action-1');
$('button[name="chat_assistance"]').addClass('mc4-action-1-disabled');
$('button[name="chat_assistance"]').attr('title', mc4_custom_data.mc4_support_warning);
}});
/*
setTimeout(function(){
if($('div.widget_shopping_cart_content div.woocommerce-mini-cart__empty-message').length > 0){
var mc4HtmlButton='<p>&nbsp;</p><div class="elementor-button-wrapper"><a href="' + mc4_custom_data.link_go_to_shop_button + '" class="elementor-button-link elementor-button elementor-size-sm mc4-action-1" role="button"><span class="elementor-button-content-wrapper"><span class="elementor-button-icon elementor-align-icon-right"><i aria-hidden="true" class="fas fa-angle-right"></i></span><span class="elementor-button-text">' + mc4_custom_data.title_go_to_shop_button + '</span></span></a></div>';
$(mc4HtmlButton).insertAfter('div.widget_shopping_cart_content div.woocommerce-mini-cart__empty-message');
}}, 1500);
*/
$('.elementor-37 .elementor-element.elementor-element-44065fa').hide();
if($('input#form-field-mc4_id_email_field_saas').length > 0){
$('input#form-field-mc4_id_email_field_saas').prop('readonly', true);
}
if($('div#mc4_active_service').length > 0){
$.ajax({
url: mc4_custom_data.ajax_url,
method: 'POST',
dataType: 'json',
data: {
action:  'active_services',
security: mc4_custom_data.mc4_ajax_nonce
}}).done(function(returnData){
if(returnData.success){
$('div#mc4_active_service').fadeOut(0, function(){
$(this).html(returnData.data);
}).fadeIn(1000);
}});
}});