diff --git a/pages/home.php b/pages/home.php index 5ff7409..02f102a 100644 --- a/pages/home.php +++ b/pages/home.php @@ -128,32 +128,9 @@ foreach ($newsitems as $item) { break; } $count++; - ?> -
-
- getImage())) { ?> - - getImage(), "preview.redd.it") !== false) { - $imgurl = $item->getImage(); - } else { - $imgurl = Thumbnail::getThumbnailCacheURL($item->getImage(), 500); - } - ?> - - - -
- -

- getHeadline()); ?> -

-
-

getSource(); ?>

-
-
-
- + echo $item->generateGridCard(false); + } + ?>
diff --git a/pages/news.php b/pages/news.php index 759c10e..c02a42d 100644 --- a/pages/news.php +++ b/pages/news.php @@ -30,31 +30,11 @@ $newsitems = News::getItems();
- -
- -
- + generateGridCard(true); + } + ?>
diff --git a/static/js/home.js b/static/js/home.js index dedfb35..9ae1f87 100644 --- a/static/js/home.js +++ b/static/js/home.js @@ -2,4 +2,4 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ \ No newline at end of file + */ diff --git a/static/js/news.js b/static/js/news.js index 4f8c9ed..4e357d3 100644 --- a/static/js/news.js +++ b/static/js/news.js @@ -4,9 +4,19 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +function fetchVisibleGridImages() { + $(".grid__brick").each(function () { + if ($(this).css("opacity") == "1") { + $("img.newscard-img", this).attr("src", $("img.newscard-img", this).data("src")); + } + }); +} + $("input[name=newscategory]").on("change", function () { window.shuffleInstance.filter($(this).val()); $(this).button('toggle'); + setTimeout(fetchVisibleGridImages, 500); }); -window.shuffleInstance.filter("general"); \ No newline at end of file +window.shuffleInstance.filter("general"); +setTimeout(fetchVisibleGridImages, 500); \ No newline at end of file diff --git a/static/js/newsgrid.js b/static/js/newsgrid.js index 9010605..408826e 100644 --- a/static/js/newsgrid.js +++ b/static/js/newsgrid.js @@ -13,13 +13,6 @@ setInterval(function () { window.shuffleInstance.layout(); }, 500); -$("img.newscard-img").on("error", function () { - if ($(this).data("reloaded")) { - return; - } - var img = $(this); - setTimeout(function () { - img.attr("src", $(this).attr("src")); - img.data("reloaded", true); - }, 500); -}); \ No newline at end of file +// Show the images using JavaScript, to make sure we don't see double +// when JS is disabled +$("img.newscard-img.d-none").removeClass("d-none"); \ No newline at end of file