setTimeout(function(){ $(document).ready(function () { let dataFiles = $('html').data('files'); let storeId = $('html').data('store'); $.ajax({ url : `/loja/busca_noticias.php?loja=${storeId}&${dataFiles}`, method : 'get', success : function(response){ let target; let news; $('.contaier-blog .content-blog').append('') target = $('.contaier-blog .content-blog .blog'); news = $($(response).find('.noticias')); news.find('li:nth-child(n+7)').remove(); news.find('li').wrapInner('
'); news = news.contents(); news.each(function (index, news) { let link = $(this).find('#noticia_imagem a').attr('href'); let title = $(this).find('#noticia_dados h3 a').text(); $(this).find('p').after('Leia mais'); $(this).find('#noticia_imagem img').attr('alt', title).removeAttr('title'); let image = $(news).find('img'); let source = image.prop('src'); image.attr('data-original', source); image.attr('data-src', source); image.attr('data-srcset', source); image.attr('src', source); }); target.append(news); } }); document.addEventListener("DOMContentLoaded", function() { let lazyImages = [].slice.call(document.querySelectorAll("img.lazy")); let active = false; const lazyLoad = function() { if (active === false) { active = true; setTimeout(function() { lazyImages.forEach(function(lazyImage) { if ((lazyImage.getBoundingClientRect().top <= window.innerHeight && lazyImage.getBoundingClientRect().bottom >= 0) && getComputedStyle(lazyImage).display !== "none") { lazyImage.src = lazyImage.dataset.src; lazyImage.srcset = lazyImage.dataset.srcset; lazyImage.classList.remove("lazy"); lazyImages = lazyImages.filter(function(image) { return image !== lazyImage; }); if (lazyImages.length === 0) { document.removeEventListener("scroll", lazyLoad); window.removeEventListener("resize", lazyLoad); window.removeEventListener("orientationchange", lazyLoad); } } }); active = false; }, 200); } }; document.addEventListener("scroll", lazyLoad); window.addEventListener("resize", lazyLoad); window.addEventListener("orientationchange", lazyLoad); }); }); });