function EXEC_OAS_AD_DEFERRED() { //console.log("EXEC_OAS_AD_DEFERRED"); // controllo che non sia stato bloccato qualcosa da adblock o simili if (typeof(OAS_RICH) != "function") return; // qui passo tutte le posizioni ed inietto $('.oas_placeholder').each(function() { var buffer = ''; // backup di document.write var doc_write_bak = document.write; // sovrascrivo document.write document.write = function(string) {buffer += string;} // ora eseguo la OAS normale OAS_AD($(this).attr('data-pos')); // ripristino document.write document.write = doc_write_bak; // in buffer ho l'html if (-1 == buffer.indexOf('')) { // banner pieno, non ho trovato empty.gif $(this).addClass('notempty'); } //$(this).replaceWith(buffer); postscribe('#'+$(this).attr('id'), buffer); }); // provo ad essere tempestivo e fixare subito eventuali skin window.setTimeout(repairSkin, 500); } /* function repairSkin() { //console.log("load - controllo skin"); if ($('body').css('background-attachment') == 'fixed' && $('body').not('.skinned')) { $('body').addClass('skinned'); var skin_offset = 0;//$('#header-wrapper').outerHeight(true); var body_bg_fixed = true; $(window).scroll(function() { if ($(window).scrollTop() > skin_offset) { if (!body_bg_fixed) { var body = $( 'body' ).get(0); body.style.setProperty( 'background-position-y', '0', 'important' ); body.style.setProperty( 'background-attachment', 'fixed', 'important' ); body_bg_fixed = true; } } else { if (body_bg_fixed) { var body = $( 'body' ).get(0); body.style.setProperty( 'background-position-y', skin_offset+'px', 'important' ); body.style.setProperty( 'background-attachment', 'initial', 'important' ); body_bg_fixed = false; } } }); // lancio un trigger per ricalcolare se deve essere fixed ed in che posizione (se la pagina si ricarica gi? scrollata) $(window).scroll(); } } */ /* se ho una skin che mette uno sfondo fixed lo devo sistemare (la barra superiore lo nasconde) */ function repairSkin() { //console.log("load - controllo skin"); if ($('body').css('background-attachment') == 'fixed' && $('body').not('.skinned')) { // segno subito come fatto $('body').addClass('skinned'); var skin_offset = 0;//$('#header-wrapper').outerHeight(true); var body_bg_fixed = true; // throttled scroll _waitFor('scroll', function (e, scrollPos) { // metto sile al body per eventuali eccezioni in grafica in presenza di skin if (scrollPos > skin_offset && !body_bg_fixed) { //$('body').css('background-position-y', '0'); //$('body').css('background-attachment', 'fixed'); var body = document.body; body.style.setProperty('background-position-y', '0', 'important'); body.style.setProperty('background-attachment', 'fixed', 'important'); body_bg_fixed = true; } else if (scrollPos <= skin_offset && body_bg_fixed) { //$('body').css('background-position-y', skin_offset+'px'); //$('body').css('background-attachment', 'initial'); var body = document.body; body.style.setProperty('background-position-y', skin_offset + 'px', 'important'); body.style.setProperty('background-attachment', 'initial', 'important'); body_bg_fixed = false; } }); // lancio un trigger per ricalcolare se deve essere fixed ed in che posizione (se la pagina si ricarica gi? scrollata) $(window).scroll(); } } // al load controllo la presenza della skin /* $(function() { repairSkin(); setTimeout(repairSkin, 1000); setTimeout(repairSkin, 2000); setTimeout(repairSkin, 3000); }); // un secondo dopo il load ricalcolo, la skin potrebbe essere lenta $(window).on('load',function () { repairSkin(); setTimeout(repairSkin, 1000); setTimeout(repairSkin, 2000); setTimeout(repairSkin, 3000); }); */ // captcha function captchaSubmit(data) { var id = $('.form_captcha').attr('id'); document.getElementById(id).submit(); } function initSocialbar() { $('#socialBarDiv').socialbar({ selectors: { logoutButton: '.logout' // classe dei pulsanti di login. Associo l'azione di logout } }); } // Shorthand for $( document ).ready() $(function() { var socialbarInitInterval = setInterval(function() { try { $('#socialBarDiv').socialbar({ selectors: { logoutButton: '.logout' // classe dei pulsanti di login. Associo l'azione di logout } }); // se arrivo qui ho inizializzato correttamente la socialbar clearInterval(socialbarInitInterval); } catch(e) { console.log("socialbar still not ready?", e); } }, 500); // evitiamo di tentare a vita, dopo venti secondi mi arrendo setTimeout(function() { clearInterval(socialbarInitInterval); }, 20000); $("#search_submit").click(function(e){ if( !$(".animated-search-form").val() ) { e.preventDefault(); $( ".animated-search-form" ).focus(); } }); }); $(function() { //console.log("ready - preparo menu fissante"); if ( $( "#header #logo" ).length ) { var elementToBeFixed = $('#header #logo'); }else{ var elementToBeFixed = $('#header .top-header-wrapper'); } if (elementToBeFixed.length <= 0) return; var wrapperTop = $('#header .top-header-wrapper'); var wrapperBottom = $('#header'); var header_start_position = elementToBeFixed.offset().top; var header_fixed = false; height_elementToBeFixed = (wrapperTop.height() + 11); style = "padding-top"; $(window).scroll(function() { if ($(window).scrollTop() > header_start_position) { // il menu diventa/resta fisso if (!header_fixed) { // $('#navbar-menu').after('
'); document.body.classList.add('header-bottom-fixed'); wrapperTop.addClass('fixed'); if(style != null){ wrapperBottom.css( style, height_elementToBeFixed+'px'); } header_fixed = true; } } else { // il menu diventa/resta al suo posto if (header_fixed) { document.body.classList.remove('header-bottom-fixed'); wrapperTop.removeClass('fixed'); if(style != null){ wrapperBottom.removeAttr("style"); } header_fixed = false; } } }); // ricalcolo la posizione del menu se la skin viene ricaricata _waitFor('adv_render_ended_adv_Skin', function () { // nota: uso l'offset del parent perché se la skin si carica mentre sono già in sticky // l'offset del "elementoToBeFixed" sarà uguale a window.scrollY e quindi sbagliato header_start_position = elementToBeFixed.parent().offset().top; // triggero uno scroll per aggiornare $(window).scroll(); }); // al load ricalcolo la posizione del menu. // tenere qui dentro per lo scope su header_start_position /* $(window).on('load',function() { //console.log("load - ricalcolo posizione menu"); // al ready resetto le posizioni di alcuni elementi (la skin li sposta) if (!header_fixed) header_start_position = elementToBeFixed.offset().top; // lo ricalcolo pure dopo setTimeout(function() { if (!header_fixed) header_start_position = elementToBeFixed.offset().top; }, 1000); }); */ }); $(window).on('load',function () { //riempitivo right home if ( $(".home #right-content").length) { if ($("#main-content").lenght == 0) return; if ($("#right-content").lenght == 0) return; var fine_main = $('#main-content').offset().top + $('#main-content').height(); var fine_right = $('#right-content').offset().top + $('#right-content').height(); var dislivello = fine_main - fine_right; if (dislivello > 0 && false) { // pareggio l'altezza per sisemare la righina $('#right-content').height($('#right-content').height() + dislivello); } //console.log(dislivello); /* if (dislivello > 100) { // metto roba nella colonna destra $.ajax({ url: '/?sez=AJAX&p=right_box_riempitivo&px=' + dislivello, dataType: 'html', success: function (data) { $(data).appendTo('#right-content'); } }); }*/ } //riempitivo right home_sezione /* if ( $(".home_sezione #right-content").length) { if ($("#main-content").lenght == 0) return; if ($("#right-content").lenght == 0) return; var fine_main = $('#main-content').offset().top + $('#main-content').height(); var fine_right = $('#right-content').offset().top + $('#right-content').height(); var dislivello = fine_main - fine_right; if (dislivello > 0) { // pareggio l'altezza per sisemare la righina $('#right-content').height($('#right-content').height() + dislivello); } //console.log(dislivello); if (dislivello > 100) { // metto roba nella colonna destra $.ajax({ url: '/?sez=AJAX&p=right_box_riempitivo&px=' + dislivello, dataType: 'html', success: function (data) { $(data).appendTo('#right-content'); } }); } } */ }); // pushNotifications avvio subito la burocrazia loadScript(impostazioni_testata.assets_domain + '/js/webPushNotifications.js', function(){ // dobbiamo essere sicuri che il DOM sia ready _waitOnceFor('ready', function(){ var wrap = document.querySelector('#socialBarDiv'); if (wrap) { document.body.classList.add("has-wpn"); var bellWrapHMTL = ''; wrap.insertAdjacentHTML("beforeend", bellWrapHMTL); var bellWrap = wrap.querySelector('#push-notifications-badge'); new WebPushNotification(bellWrap, { appId: impostazioni_testata.oneSignal_appId, superTags: document.querySelectorAll('body.articolo #main-content .contenuto h3.testatina > a') }); } }) }); $(document).ready(function () { if (document.body.classList.contains('articolo')) { // engageLeavingUsers loadScript(impostazioni_testata.assets_domain + '/js/engageLeavingUsers.js'); } }); /** * */ (function() { function ced_onerror(event) { var imgWidth = Number(event.target.getAttribute('width')); var imgHeight = Number(event.target.getAttribute('height')); //evito divisioni per 0, dopo useremo il placeholder di default if(imgWidth == 0 || imgHeight == 0) { var prop = 0; } else { var prop = (imgHeight / imgWidth).toFixed(2); } switch (prop) { case "1.00": //quadrata var placeholderImg = "/img/placeholders/THUMB.jpg"; break; case "0.55": //med high var placeholderImg = "/img/placeholders/MED.jpg"; break; case "0.35": //panorama var placeholderImg = "/img/placeholders/PANORAMA.jpg"; break; default: //img grigia senza logo var placeholderImg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mPcfBIAAjUBfhd+1wMAAAAASUVORK5CYII="; } event.target.src = placeholderImg; event.onerror = null } _waitFor('ready', function() { //prendo tutte le img, perchè quando sto cercando potrebbero ancora non avere src valorizzato, solo dopo controllo //che rientrino nelle img che voglio sostituire in caso di 404 var imgInpage = document.querySelectorAll('img'); if (imgInpage) { for (var i = 0; i < imgInpage.length; i++) { if (imgInpage[i].src.indexOf("/photos/") != -1) { //solo se l'img contiene /photos/ var tmp = imgInpage[i].onerror; imgInpage[i].onerror = function (tmp, evento) { try { //debugger; if (typeof tmp == 'function') { (tmp.bind(this))(); //eseguo la funzione originale dell'onerror this.onerror = ced_onerror } else ced_onerror(evento); } catch (e) { CED.log("ced_onerror", e); } }.bind(imgInpage[i], tmp); } } } }) })(); (function () { _waitOnceFor('cookielaw_5_accepted', function () { // ad Top LdbMastheadPush sticked x CLS //script in utils per stickare qualsiasi adv var targetIdSlot = 'adv_LdbMastheadPush'; var advSticky = document.getElementById(targetIdSlot); if (advSticky) { loadScript(impostazioni_testata.assets_domain + '/src/js/sticker.js', function () { _waitOnceFor('adv_render_ended_' + targetIdSlot, function () { var adv_Ldb = document.querySelector('#' + targetIdSlot); var stick = window.StiCa( adv_Ldb, { top: 45, time: 10, zIndex: 9999999 } ) function stopSticky() { setTimeout(stick.stopSticky, 800); } _waitOnceFor('adv_impression_viewable_' + targetIdSlot, stopSticky) }); }); } }); })(); _waitOnceFor(['socialbar_disabled','cookielaw.accepted'], () => { // login onetap da Google loadScript(impostazioni_testata.assets_domain + '/js/oneTapLogin.js'); });