2017-07-21 22:40:01 +02:00
|
|
|
<script src="/vendors/masonry/masonry.pkgd.min.js"></script>
|
|
|
|
|
2017-07-12 01:55:03 +02:00
|
|
|
<div class="full">
|
|
|
|
<h2>Trending</h2>
|
2017-07-21 22:40:01 +02:00
|
|
|
<div class="grid" data-masonry='{ "itemSelector": ".grid-item" }'>
|
|
|
|
{{#each trendingAssets}}
|
|
|
|
{{#unless this.nsfw}}
|
|
|
|
|
2017-07-20 19:15:20 +02:00
|
|
|
<a href="/show/{{this.name}}/{{this.claimId}}">
|
|
|
|
{{#ifConditional this.fileType '===' 'video/mp4'}}
|
2017-07-21 22:40:01 +02:00
|
|
|
<video class="grid-item trending-video" controls>
|
2017-07-20 19:15:20 +02:00
|
|
|
<source src="/api/streamFile/{{this.fileName}}">
|
|
|
|
{{!--fallback--}}
|
|
|
|
Your browser does not support the <code>video</code> element.
|
|
|
|
</video>
|
|
|
|
{{else}}
|
2017-07-21 22:40:01 +02:00
|
|
|
<img class="grid-item trending-image" src="/api/streamFile/{{this.fileName}}" />
|
2017-07-20 19:15:20 +02:00
|
|
|
{{/ifConditional}}
|
|
|
|
</a>
|
2017-07-21 22:40:01 +02:00
|
|
|
|
|
|
|
{{/unless}}
|
2017-07-20 19:15:20 +02:00
|
|
|
{{/each}}
|
2017-07-21 22:40:01 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
var elem = document.querySelector('.grid');
|
|
|
|
var trendingImages = document.querySelectorAll('.trending-image');
|
|
|
|
console.log(trendingImages)
|
|
|
|
var trendingVideos = document.querySelectorAll('.trending-video');
|
|
|
|
var msnry = new Masonry( elem, {
|
|
|
|
itemSelector: '.grid-item'
|
|
|
|
});
|
|
|
|
// after images are loaded, reset layout
|
|
|
|
for (var i = 0; i < trendingVideos.length; i++) {
|
|
|
|
trendingImages[i].addEventListener('load', function(){
|
|
|
|
console.log('image loaded');
|
|
|
|
msnry.layout();
|
|
|
|
})
|
|
|
|
}
|
|
|
|
// after videos are loaded, reset layout
|
|
|
|
for (var i = 0; i < trendingVideos.length; i++) {
|
|
|
|
trendingVideos[i].addEventListener('loadeddata', function(){
|
|
|
|
console.log('video loaded');
|
|
|
|
msnry.layout();
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</script>
|