45 lines
1.5 KiB
JavaScript
45 lines
1.5 KiB
JavaScript
|
(function($) {
|
||
|
"use strict"; // Start of use strict
|
||
|
|
||
|
// If the feed is loaded immediadely on page load (i.e. we're not using ajax), reset the layout on each image load
|
||
|
$('.masonry img').each(function() {
|
||
|
$(this).one('load', () => {
|
||
|
$('.masonry').masonry()
|
||
|
})
|
||
|
})
|
||
|
|
||
|
// Apply masonry layout to feed cards after content (including images) has been loaded
|
||
|
$(window).on('feedLoaded', function() {
|
||
|
if (!feedItemClass) feedItemClass = 'col-sm-12 col-md-6 col-xl-4'
|
||
|
|
||
|
$('.masonry-item').addClass(feedItemClass)
|
||
|
$('.show-onfeedloaded').removeClass('d-none')
|
||
|
|
||
|
$('.masonry').masonry('reloadItems')
|
||
|
$('.masonry').masonry()
|
||
|
|
||
|
// Every time an image loads, reset the layout
|
||
|
$('.masonry img').each(function() {
|
||
|
$(this).one('load', () => {
|
||
|
$('.masonry').masonry()
|
||
|
})
|
||
|
})
|
||
|
})
|
||
|
|
||
|
// If there's tag data set once the page is loaded, create a tag cloud
|
||
|
$(function() {
|
||
|
if(typeof tagData !== 'undefined') {
|
||
|
var cloudWords = []
|
||
|
|
||
|
tagData.forEach((tag) => {
|
||
|
cloudWords.push({text: tag.tag, weight: tag.count, link: '/feed/all/' + tag.tag})
|
||
|
})
|
||
|
|
||
|
$('#tagcloud').jQCloud(cloudWords, {
|
||
|
autoResize: true,
|
||
|
removeOverflowing: true,
|
||
|
delay: 2
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
})(jQuery); // End of use strict
|