Changed lazyload

This commit is contained in:
zeldaroot 2021-01-04 01:53:57 +02:00
parent 326ea276e2
commit f755e9021b
11 changed files with 17 additions and 66 deletions

View File

@ -151,7 +151,7 @@
class="poster_tr"></a>
<% } %>
</div>
<a href="<%- movie.url %>" rel="nofollow"><img src="<%- movie.poster_min %>" data-cinemapress-src="<%- movie.poster %>"
<a href="<%- movie.url %>" rel="nofollow"><img src="<%- movie.poster_min %>" class="lazy" data-src="<%- movie.poster %>"
alt="<%= movie.title %>"
title="<%= movie.title %>"> </a>
</div>

View File

@ -58,7 +58,7 @@
<div class="poster_m">
<div class="poster_main">
<div class="poster_main_2"><img src="<%- movie.poster_min %>" data-cinemapress-src="<%- movie.poster %>" alt="<%= page.title %>"
<div class="poster_main_2"><img src="<%- movie.poster_min %>" class="lazy" data-src="<%- movie.poster %>" alt="<%= page.title %>"
title="<%= page.title %>"
data-cinemapress-poster="<%- movie.poster %>"></div>
</div>
@ -238,7 +238,7 @@
<% if (typeof category === 'object' && category.movies && category.movies.length) {
category.movies.forEach(function (movie) { %>
<div class="item">
<a href="<%- movie.url %>"><img src="<%- movie.poster_min %>" data-cinemapress-src="<%- movie.poster %>" alt="<%= movie.title %>"
<a href="<%- movie.url %>"><img src="<%- movie.poster_min %>" class="lazy" data-src="<%- movie.poster %>" alt="<%= movie.title %>"
title="<%= movie.title %>"/></a>
<div class="link"><a href="<%- movie.url %>"><%= movie.title %> <%- movie.year %></a></div>
</div>

View File

@ -58,7 +58,7 @@
<div class="poster_m">
<div class="poster_main">
<div class="poster_main_2"><img src="<%- movie.poster_min %>" data-cinemapress-src="<%- movie.poster %>" alt="<%= page.title %>"
<div class="poster_main_2"><img src="<%- movie.poster_min %>" class="lazy" data-src="<%- movie.poster %>" alt="<%= page.title %>"
title="<%= page.title %>"
data-cinemapress-poster="<%- movie.poster %>"></div>
</div>
@ -247,7 +247,7 @@
<% if (typeof category === 'object' && category.movies && category.movies.length) {
category.movies.forEach(function (movie) { %>
<div class="item">
<a href="<%- movie.url %>"><img src="<%- movie.poster_min %>" data-cinemapress-src="<%- movie.poster %>" alt="<%= movie.title %>"
<a href="<%- movie.url %>"><img src="<%- movie.poster_min %>" class="lazy" data-src="<%- movie.poster %>" alt="<%= movie.title %>"
title="<%= movie.title %>"/></a>
<div class="link"><a href="<%- movie.url %>"><%= movie.title %> <%- movie.year %></a></div>
</div>

View File

@ -14,55 +14,6 @@
<div id="top"></div>
<script>
(function() {
var dataAllSrc = document.querySelectorAll('[data-cinemapress-src],[data-cinemapress-bg-src]');
var dataAllSrcCount = (dataAllSrc && dataAllSrc.length) || 0;
if (!dataAllSrcCount) return;
var dataAllSrcCountComp = 0;
var fSrc = {
'dataCountImage': function() {
dataAllSrcCountComp = dataAllSrcCountComp+1;
if (dataAllSrcCount && dataAllSrcCountComp >= dataAllSrcCount) {
dataAllSrcCount = 0;
var st;
window.addEventListener('load', function() {
clearTimeout(st);
fSrc['checkLoad']('dataSetImage');
});
st = setTimeout(function() {
fSrc['checkLoad']('dataSetImage');
}, 5000);
}
},
'dataSetImage': function(el) {
var src = el.dataset.cinemapressSrc;
var bgSrc = el.dataset.cinemapressBgSrc;
if (!src && !bgSrc) return;
var img = new Image();
img.src = src ? src : bgSrc;
img.onload = function() {
if (src) { el.src = src; }
else { el.style.backgroundImage = 'url("' + bgSrc + '")';}
}
},
'checkLoad': function(fn) {
if (!dataAllSrc) return;
dataAllSrc.forEach(function(src) {
if (typeof src.complete === 'undefined' || src.complete) {
fSrc[fn](src);
} else {
src.addEventListener('load', function() {
fSrc[fn](this);
}, { once: true });
}
});
}
}
fSrc['checkLoad']('dataCountImage');
})();
</script>
<script src="/themes/<%- page.theme %>/public/js/all.min.js"></script>
<script>

View File

@ -41,7 +41,7 @@
<div class="hs_item inner">
<a href="<%- movie.url %>">
<div class="hs_item_play"></div>
<img src="<%- movie.poster_min %>" data-cinemapress-src="<%- movie.poster %>" alt="<%= movie.title %>" title="<%= movie.title %>">
<img src="<%- movie.poster_min %>" class="lazy" data-src="<%- movie.poster %>" alt="<%= movie.title %>" title="<%= movie.title %>">
</a>
</div>
</li>

View File

@ -88,7 +88,7 @@ index[type].forEach(function (category) { %>
<br><%- movie.translate %><% } %>
<% } %>
</div>
<a href="<%- movie.url %>"><img src="<%- movie.poster_min %>" data-cinemapress-src="<%- movie.poster %>" alt="<%= movie.title %>"
<a href="<%- movie.url %>"><img src="<%- movie.poster_min %>" class="lazy" data-src="<%- movie.poster %>" alt="<%= movie.title %>"
title="<%= movie.title %>"></a>
</div>
<div class="link"><a href="<%- movie.url %>"><%= movie.title %></a></div>
@ -118,7 +118,7 @@ index[type].forEach(function (category) { %>
<div class="item">
<div class="poster">
<div class="sc_info"><%- page.l.premiere %><br> <%- movie.premiere %></div>
<a href="<%- movie.url %>"><img src="<%- movie.poster_min %>" data-cinemapress-src="<%- movie.poster %>" alt="<%= movie.title %>"
<a href="<%- movie.url %>"><img src="<%- movie.poster_min %>" class="lazy" data-src="<%- movie.poster %>" alt="<%= movie.title %>"
title="<%= movie.title %>"></a>
</div>
<div class="link"><a href="<%- movie.url %>"><%= movie.title %></a></div>

View File

@ -83,7 +83,7 @@
class="poster_tr"></a>
<% } %>
</div>
<a href="<%- movie.url %>" rel="nofollow"><img src="<%- movie.poster_min %>" data-cinemapress-src="<%- movie.poster %>"
<a href="<%- movie.url %>" rel="nofollow"><img src="<%- movie.poster_min %>" class="lazy" data-src="<%- movie.poster %>"
alt="<%= movie.title %>"
title="<%= movie.title %>"></a>
</div>

View File

@ -58,7 +58,7 @@
<div class="poster_m">
<div class="poster_main">
<div class="poster_main_2"><img src="<%- movie.poster_min %>" data-cinemapress-src="<%- movie.poster %>" alt="<%= page.title %>"
<div class="poster_main_2"><img src="<%- movie.poster_min %>" class="lazy" data-src="<%- movie.poster %>" alt="<%= page.title %>"
title="<%= page.title %>"
data-cinemapress-poster="<%- movie.poster %>"></div>
</div>
@ -261,7 +261,7 @@
<% if (typeof category === 'object' && category.movies && category.movies.length) {
category.movies.forEach(function (movie) { %>
<div class="item">
<a href="<%- movie.url %>"><img src="<%- movie.poster_min %>" data-cinemapress-src="<%- movie.poster %>" alt="<%= movie.title %>"
<a href="<%- movie.url %>"><img src="<%- movie.poster_min %>" class="lazy" data-src="<%- movie.poster %>" alt="<%= movie.title %>"
title="<%= movie.title %>"/></a>
<div class="link"><a href="<%- movie.url %>"><%= movie.title %> <%- movie.year %></a></div>
</div>

View File

@ -58,7 +58,7 @@
<div class="poster_m">
<div class="poster_main">
<div class="poster_main_2"><img src="<%- movie.poster_min %>" data-cinemapress-src="<%- movie.poster %>" alt="<%= page.title %>"
<div class="poster_main_2"><img src="<%- movie.poster_min %>" class="lazy" data-src="<%- movie.poster %>" alt="<%= page.title %>"
title="<%= page.title %>"
data-cinemapress-poster="<%- movie.poster %>"></div>
</div>
@ -243,7 +243,7 @@
<% if (typeof category === 'object' && category.movies && category.movies.length) {
category.movies.forEach(function (movie) { %>
<div class="item">
<a href="<%- movie.url %>"><img src="<%- movie.poster_min %>" data-cinemapress-src="<%- movie.poster %>" alt="<%= movie.title %>"
<a href="<%- movie.url %>"><img src="<%- movie.poster_min %>" class="lazy" data-src="<%- movie.poster %>" alt="<%= movie.title %>"
title="<%= movie.title %>"/></a>
<div class="link"><a href="<%- movie.url %>"><%= movie.title %> <%- movie.year %></a></div>
</div>

View File

@ -58,7 +58,7 @@
<div class="poster_m">
<div class="poster_main">
<div class="poster_main_2"><img src="<%- movie.poster_min %>" data-cinemapress-src="<%- movie.poster %>" alt="<%= page.title %>"
<div class="poster_main_2"><img src="<%- movie.poster_min %>" class="lazy" data-src="<%- movie.poster %>" alt="<%= page.title %>"
title="<%= page.title %>"
data-cinemapress-poster="<%- movie.poster %>"></div>
</div>
@ -206,7 +206,7 @@
<% if (typeof category === 'object' && category.movies && category.movies.length) {
category.movies.forEach(function (movie) { %>
<div class="item">
<a href="<%- movie.url %>"><img src="<%- movie.poster_min %>" data-cinemapress-src="<%- movie.poster %>" alt="<%= movie.title %>"
<a href="<%- movie.url %>"><img src="<%- movie.poster_min %>" class="lazy" data-src="<%- movie.poster %>" alt="<%= movie.title %>"
title="<%= movie.title %>"/></a>
<div class="link"><a href="<%- movie.url %>"><%= movie.title %> <%- movie.year %></a></div>
</div>

View File

@ -58,7 +58,7 @@
<div class="poster_m">
<div class="poster_main">
<div class="poster_main_2"><img src="<%- movie.poster_min %>" data-cinemapress-src="<%- movie.poster %>" alt="<%= page.title %>"
<div class="poster_main_2"><img src="<%- movie.poster_min %>" class="lazy" data-src="<%- movie.poster %>" alt="<%= page.title %>"
title="<%= page.title %>"
data-cinemapress-poster="<%- movie.poster %>"></div>
</div>
@ -242,7 +242,7 @@
<% if (typeof category === 'object' && category.movies && category.movies.length) {
category.movies.forEach(function (movie) { %>
<div class="item">
<a href="<%- movie.url %>"><img src="<%- movie.poster_min %>" data-cinemapress-src="<%- movie.poster %>" alt="<%= movie.title %>"
<a href="<%- movie.url %>"><img src="<%- movie.poster_min %>" class="lazy" data-src="<%- movie.poster %>" alt="<%= movie.title %>"
title="<%= movie.title %>"/></a>
<div class="link"><a href="<%- movie.url %>"><%= movie.title %> <%- movie.year %></a></div>
</div>