// funzione di successo per il recaptcha di Google var actual_form = null; function onSuccessRecaptcha(token) { actual_form.submit(); } var clmrecaptchaID = []; var clmrecaptchaFunc = []; var onloadCallback = function() { $('.btn-submit').each(function( index ) { recaptcha_form = $(this).closest("form"); $(this).before('
') }); $('.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' : '6LdIcRgUAAAAAPqxP2-P1h1HaFM2hVJvcGWHO0hs', 'callback' : gcallback, 'size' : 'invisible' }); }); }; $(window).load(function() { }); $('.lazy').lazy({ delay:-1, afterLoad: function(element) { $.event.trigger({ type: "lazyAfterLoad", time: new Date(), element : element }); }, onFinishedAll: function() { $.event.trigger({ type: "lazyComplete", time: new Date() }); } }); // lunghezza calcolata al caricamento della pagina e ad ogni resize della schermata var actualWidth; $( document ).ready(function() { $('.ga_email').click(function() {ga('send', 'event', 'button', 'click', 'email');}); $('.ga_phone').click(function() {ga('send', 'event', 'button', 'click', 'numero telefono');}); $('.fade_effect').click(function(){ $(this).next('.fade_text').toggle(); }); $("#bottom-to-top").click(function() { $("html, body").animate({ scrollTop: 0 }, "slow"); return false; }); // pulsante di conferma del form // memorizza il form dell'elemento (utilizzato alla conferma del recaptcha) // effettua la validation HTML5 // se andato a buon fine $('.btn-submit').on('click', function (e) { var error = false; actual_form = $(this).closest("form"); // recupera la classe da applicare in caso di successo var func_check = actual_form.data('check'); if (func_check !== undefined) { var fn = window[func_check]; if (typeof fn === "function") error = fn.apply(null, [this]); } if ( error ) // esco da on click return false; // ricerca il recaptcha del form cmlrecaptcha = actual_form.find('.clm-recaptcha'); cmlrecaptcha_id = -1; for (var i = 0; i < clmrecaptchaID.length; i++) { if (clmrecaptchaID[i] == cmlrecaptcha[0].id) cmlrecaptcha_id = i; } if (typeof actual_form[0].checkValidity != 'undefined' && !actual_form[0].checkValidity()) { } else { e.preventDefault(); // esegue il recaptcha se esiste per il form altrimenti richiama la funzione di successo if (cmlrecaptcha_id != -1) { grecaptcha.reset(clmrecaptchaFunc[cmlrecaptcha_id]); grecaptcha.execute(clmrecaptchaFunc[cmlrecaptcha_id]); } else { if (actual_form.data('gcallback') === undefined) gcallback = onSuccessRecaptcha; else gcallback = window[actual_form.data('gcallback')]; gcallback(); } } }); $('[data-toggle="tooltip"]').tooltip(); $( ".table" ).wrap( "
" ); $('.carousel').carousel(); $('.modal').modal('hide'); $('.dropdown-submenu a').click(function(){ if ($(this).next().hasClass('dropdown-menu')) { $('.dropdown-submenu > .dropdown-menu').css('display','block'); return false; } }); //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').waypoint(function() { var myAnimated = $(this).data('animated'); var oneSomeAnimated = $(this).data('oneanimated'); // animazione da eseguire una singola volta if (oneSomeAnimated == true) { // animazione non e' stata gia' eseguita in tal caso la esegue if (!($(this).hasClass(myAnimated))) $(this).toggleClass($(this).data('animated')).css("opacity", "1"); // animazione da eseguire sempre } else $(this).toggleClass($(this).data('animated')); }, { offset: '80%' }); } // 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'); } }) } $( '.form_ajax' ).each(function( index ) { $( this ).before(''); init_form(this.id); }); $( '.form_ajax' ).on('submit', function (e) { e.preventDefault(); $('#alert-code-'+this.id).remove(); $('#upload_container_'+this.id).show(); // recupera le classi da nascondere var class_hide = $(this).find( 'input[name=class_hide]' ); var value_class_hide = class_hide.val(); // recupera la classe da applicare in caso di errore var func_error_code = $(this).data('error_code'); // recupera la classe da applicare in caso di successo var func_positive_response = $(this).data('positive_response'); // recupera la classe da applicare in caso di failure var func_fail = $(this).data('fail'); //grab all form data var formData1 = new FormData(); $(this).find( ':input' ).each( function( index, el ) { switch (el.name) { case "submit": case "code": case "type": case "lang": case "from": case "module": case "em": case "class_hide": case "g-recaptcha-response": formData1.append(el.name, el.value); break; default: field = $(el); tagName = field.prop("tagName").toLowerCase(); if (field.attr('type') != "file") { lbl_client = lbl_admin = order = required = type = 'undefined'; lbl_client = field.data('label'); if (typeof lbl_client === 'undefined') lbl_client = el.name; lbl_admin = field.data('admin'); if (typeof lbl_admin === 'undefined') lbl_admin = lbl_client; order = field.data('order'); if (typeof order === 'undefined') order = -1; required = field.attr('required'); if (typeof required === 'undefined') required = 0; else required = 1; type = field.attr('type'); if (typeof type === 'undefined') type = ""; if (tagName == "select") { option = field.find(":selected"); val_client = option.data('label'); if (typeof val_client === 'undefined') val_client = option.val(); val_admin = option.data('admin'); if (typeof val_admin === 'undefined') val_admin = val_client; } else { val_client = el.value; val_admin = val_client; } value = val_client+"|||"+val_admin+"|||"+lbl_client+"|||"+lbl_admin+"|||"+order+"|||"+required+"|||"+type; formData1.append(el.name, value); } else { formData1.append(el.name, field[0].files[0]); } } } ); $.ajax({ type: "POST", url: 'http://www.leardininews.com/newsletter/includes/ajax/ajax_frontend.php', content: this, data: formData1, // Data sent to server, a set of key/value pairs (i.e. form fields and values) contentType: false, // The content type used when sending data to the server. cache: false, // To unable request pages to be cached processData:false // To send DOMDocument or non processed data file it is set to false }) .done(function(data){ $('#upload_container_'+this.content.id).hide(); datiJSON = JSON.parse(data); // errore if (datiJSON.hasOwnProperty('error_code')) { if (func_error_code === undefined) { $( this.content ).before('

'+datiJSON.error_code+'

'); $( "#alert-code-"+this.content.id )[0].scrollIntoView(); } else { var fn = window[func_error_code]; if (typeof fn === "function") fn.apply(null, [this, datiJSON, value_class_hide]); } } // azione non legato a risposta positiva if (datiJSON.hasOwnProperty('action')) { switch (datiJSON.action) { case 'refresh': location.reload(); break; } } // risposta positiva if (datiJSON.hasOwnProperty('positive_response')) { if (func_positive_response === undefined) { // action legata a risposta positiva if (datiJSON.hasOwnProperty('action')) { switch (datiJSON.action) { case 'popup': $('#popup_result .response_positive').html(datiJSON.positive_response); $('#popup_result').modal('show'); $( this.content ).find('.star').removeClass('fa-star-chosen').removeClass('fa-star-current').removeClass('fa-star').addClass('fa-star-o'); $( this.content )[0].reset(); return; } } $( this.content ).after('
'+datiJSON.positive_response+'
'); $( this.content ).detach(); if (value_class_hide !== undefined) $('.'+value_class_hide).hide(); } else { var fn = window[func_positive_response]; if (typeof fn === "function") fn.apply(null, [this, datiJSON, value_class_hide]); } } }) .fail(function(data) { if (func_fail === undefined) { $('#upload_container_'+this.content.id).hide(); $( this.content ).before('

Errore nell\'invio. Riprovare più tardi

'); } else { var fn = window[func_fail]; if (typeof fn === "function") fn.apply(null, [this, data, value_class_hide]); } }); }); WebFontConfig = { custom: { families: [ 'FontAwesome' ], urls: [ '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'] } }; (function() { var wf = document.createElement('script'); wf.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js'; wf.type = 'text/javascript'; wf.async = 'true'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(wf, s); })(); /** ESEMPIO PER UTILIZZO SLIDE // ID della slide // | $( "#slide-example" ).slide_carousel({ element : '.example-item', // elemento contenuto nel carousel breakpoint : [ // numero di elementi e righe in base alla risoluzione // >risoluzione minima // | numero di items // | | numero di righe // | | | [ 1199, 4, 1], [ 768, 2, 1], [ 0, 1, 1] ] }); ***/ $( "#slide" ).slide_carousel({ element : '.slide-item', breakpoint : [ // >risoluzione minima // | numero di items // | | numero di righe // | | | [ 0, 1, 1] ] }); /** ESEMPIO PER L'UTILIZZO DELLE IMMAGINI ADATTATIVE // indicare la classe delle immagini $( ".img-adapter-4-3" ).imgadapter({ w_prop : 4, // proporzione per la lunghezza h_prop : 3, // proporzione per l'altezza outer_div : true, // true: non è richiusa all'interno del wrapper, false è rinchiusa all'interno del wrapper breakpoint : [ // risoluzioni in cui ricalcolare il rapporto // >min-width [ 1400], [ 1200], [ 768], [ 480], [ 0] ] }); ***/ // immagini adattative all'interno del riquadro $( ".img-adapter-in-4-3" ).imgadapter({ w_prop : 4, h_prop : 3, outer_div : false }); $( ".img-adapter-in-1-1" ).imgadapter({ w_prop : 4, h_prop : 3, outer_div : false }); // immagini adattative all'esterno del riquadro $( ".img-adapter-16-9" ).imgadapter({ w_prop : 16, h_prop : 9 }); $( ".img-adapter-4-3" ).imgadapter({ w_prop : 4, h_prop : 3 }); $( ".img-adapter-1-1" ).imgadapter(); /** ESEMPIO PER L'UTILIZZO DELLA GALLERY // indicare la gallery $( ".simple-gallery-no-slide" ).gallery({ w_prop : 4, // proporzione per la lunghezza h_prop : 3, // proporzione per l'altezza outer_div : true, // true: non è richiusa all'interno del wrapper, false è rinchiusa all'interno del wrapper breakpoint : [ // percentuali da applicare in base alla larghezza minima della pagina // >min-width // | width % // | | margin px // | | | [ 768, 33, 15], [ 480, 50, 15], [ 0, 100, 15] ] }); */ /** ESEMPIO PER L'UTILIZZO DELLA GALLERY CON SLIDE $( "#slide-gallery" ).slide_gallery({ element : '.gallery-item', w_prop : 4, // proporzione per la lunghezza h_prop : 3, // proporzione per l'altezza outer_div : true, // true: non è richiusa all'interno del wrapper, false è rinchiusa all'interno del wrapper breakpoint : [ // >risoluzione minima // | numero di items // | | numero di righe // | | | margin px // | | | | [ 1199, 3, 1, 10], [ 480, 2, 1, 10], [ 0, 1, 1, 10], ] }); **/ $( "#slide-gallery" ).slide_gallery({ element : '.gallery-item', w_prop : 4, // proporzione per la lunghezza h_prop : 3, // proporzione per l'altezza outer_div : true, // true: non è richiusa all'interno del wrapper, false è rinchiusa all'interno del wrapper breakpoint : [ // >risoluzione minima // | numero di items // | | numero di righe // | | | margin px // | | | | [ 1199, 3, 1, 10], [ 480, 2, 1, 10], [ 0, 1, 1, 10], ] }); // margine applicato 15px $( ".simple-gallery-no-slide" ).gallery({ w_prop : 4, // proporzione per la lunghezza h_prop : 3, // proporzione per l'altezza outer_div : true, // true: non è richiusa all'interno del wrapper, false è rinchiusa all'interno del wrapper breakpoint : [ // percentuali da applicare in base alla larghezza minima della pagina // >min-width // | width % // | | margin px // | | | [ 768, 33, 5], [ 480, 50, 15], [ 0, 100, 15] ] }); // lunghezza calcolata al caricamento della pagina e ad ogni resize della schermata $( document ).ready(function() { });