var news_scroll = 0; function newsSummaryOnClick(externLink) { var msgToShow = null; $.blockUI({ message: msgToShow, //onOverlayClick: abandon, overlayCSS: { backgroundColor: '#000', opacity: 0.6, cursor: 'wait' } }); $('.blockOverlay').attr('title','').click($.unblockUI); var id = $(this).data('news'); // If undefined it means called by esternal link if (typeof id == 'undefined') { id = externLink; } getjsonp('https://sbf.timeitaly.it/api/SBFWebApi/GetNews/it/' + id, loadNewsSuccess, null, loadNewsComplete) } function loadNewsSuccess(data) { prepareNews(data); news_scroll = $("body").scrollTop() + $("html").scrollTop(); $("html, body").animate( { scrollTop: 0 }, '500'); $('#news-list').stop().fadeTo(300, 0); $('#news-details').stop().fadeTo(1000, 1); } function loadNewsComplete(data) { $.unblockUI(); // calculate the new height of wrapper div for a correct positioning $('#wrapper').css('height', 0); $('#wrapper').css('height', $( document ).height() + $('#footer-strip').height() + $('#footer-margin').height() * 2); } function prepareNews(data) { if (!data.template) { data.template = 'news-template-default'; } var template = $('#' + data.template).html(); var html = Mustache.render(template, data); $('#news-details').append(html); $('.news-details-close').click(newsDetailsCloseOnClick); $('#banner-fade').show(); $('#banner-fade').bjqs({ /* Gallery Image */ height: 420, width: '100%', responsive: true }); magnificPopupInitialize(); } function newsDetailsCloseOnClick() { $("html, body").animate( { scrollTop: news_scroll }, '500'); $('#news-details').stop().fadeTo(300, 0); $('#news-list').stop().fadeTo(1000, 1); setTimeout(function () { $('#news-details').empty(); $('#wrapper').css('height', 0); $('#wrapper').css('height', $( document ).height() + $('#footer-strip').height() + $('#footer-margin').height() * 2); }, 1000); }