// lunghezza calcolata al caricamento della pagina e ad ogni resize della schermata var actualWidth; var figure_width = 100000000; $( ".table" ).wrap( "
" ); $( document ).ready(function() { if (navigator.userAgent.match(/(iPod)/)) { $('.parallax-container').height( $(window).height() * 0.5 | 0 ); } else { $(window).resize(function(){ var parallaxHeight = Math.max($(window).height() * 0.7, 200) | 0; $('.parallax-container').height(parallaxHeight); }).trigger('resize'); } $('[data-toggle="tooltip"]').tooltip() actualWidth = $(window).width(); $('.carousel').carousel(); $('.modal').modal('hide'); // adatta le immagini alla proporzione indicata (defaut quadrata) $( 'figure' ).each(function() { if ($( this ).width() < figure_width) figure_width = $( this ).width(); console.log(figure_width+' - '+$( this ).width()); }); // adatta le immagini alla proporzione indicata (defaut quadrata) $( 'figure img' ).each(function() { // recupero delle dimensioni reali dell'immagine $img_width = $( this ).get(0).naturalWidth; $img_height = $( this ).get(0).naturalHeight; console.log('img_width: '+$img_width); console.log('img_height: '+$img_height); // recupero delle proporzioni da utilizzare $w_prop = $(this).data('w-prop'); // larghezza $h_prop = $(this).data('h-prop'); // altezza // una delle due proporzioni non e' definita imposta il quadrato if (($w_prop === undefined) || ($h_prop === undefined)) { $w_prop = 1; $h_prop = 1; } // ricerca il div wrapper dell'immagine // calcola il padding-bottom in base alla proporzione da adottare $wrapper = $(this).closest('figure'); $wrapper_width = (100*figure_width)/$wrapper.parent().width(); $wrapper_padding_bottom = ($wrapper_width * $h_prop) / $w_prop; $wrapper.css('padding-bottom', $wrapper_padding_bottom+"%"); console.log($wrapper); console.log('wrapper.parent.width: '+$wrapper.parent().width()); console.log('wrapper.width: '+figure_width); console.log('wrapper_width (100*figure_width)/$wrapper.parent().width() : '+$wrapper_width); console.log('wrapper_padding_bottom ($wrapper_width * $h_prop) / $w_prop : '+$wrapper_padding_bottom); // imposta il margin-top negativo in base alla proporzione per le immagini verticali if ($img_height > $img_width) { $vert = ($img_width * $h_prop) / $w_prop; $margin = ($vert - $img_height) / 2; $perc = ($margin * 100) / $img_height; $( this ).css('margin-top', $perc+"%"); console.log('img_height > img_width'); console.log('vert ($img_width * $h_prop) / $w_prop : '+$vert); console.log('margin ($vert - $img_height) / 2 : '+$margin); console.log('perc ('+$margin+' * 100) / '+$img_height+' : '+$perc); // imposta il margin-left negativo in base alla proporzione per le immagini orizzontali } else { $vert = ($img_height * $w_prop) / $h_prop; $margin = ($vert - $img_width) / 2; $perc = ($margin * 100) / $img_width; $( this ).css('margin-left', $perc+"%"); console.log('img_height <= img_width'); console.log('vert ($img_height * $w_prop) / $h_prop : '+$vert); console.log('margin ($vert - $img_width) / 2 : '+$margin); console.log('perc ('+$margin+' * 100) / '+$img_width+' : '+$perc); } }); // adatta le immagini alla proporzione indicata (defaut quadrata) $( '.img-adapter' ).each(function() { // recupero delle dimensioni reali dell'immagine $img_width = $( this ).get(0).naturalWidth; $img_height = $( this ).get(0).naturalHeight; // recupero delle proporzioni da utilizzare $w_prop = $(this).data('w-prop'); // larghezza $h_prop = $(this).data('h-prop'); // altezza // una delle due proporzioni non e' definita imposta il quadrato if (($w_prop === undefined) || ($h_prop === undefined)) { $w_prop = 1; $h_prop = 1; } // ricerca il div wrapper dell'immagine // calcola il padding-bottom in base alla proporzione da adottare $wrapper = $(this).closest('.wrapper-img-adapter'); $wrapper_width = (100*$wrapper.width())/$wrapper.parent().width(); $wrapper_padding_bottom = ($wrapper_width * $h_prop) / $w_prop; $wrapper.css('padding-bottom', $wrapper_padding_bottom+"%"); // imposta il margin-top negativo in base alla proporzione per le immagini verticali if ($img_height > $img_width) { $vert = ($img_width * $h_prop) / $w_prop; $margin = ($vert - $img_height) / 2; $perc = ($margin * 100) / $img_height; $( this ).css('margin-top', $perc+"%"); // imposta il margin-left negativo in base alla proporzione per le immagini orizzontali } else { $vert = ($img_height * $w_prop) / $h_prop; $margin = ($vert - $img_width) / 2; $perc = ($margin * 100) / $img_width; $( this ).css('margin-left', $perc+"%"); } }); //One Animated $('.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', function(){ if($(this).val().length !== 0) { $(this).addClass('filled'); } else { $(this).removeClass('filled'); } }); // 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'); } }) }