Add refresh button

This commit is contained in:
Jay Trees 2022-02-23 15:53:37 +01:00
parent 716eb99254
commit 0216b09f30
3 changed files with 145 additions and 113 deletions

View file

@ -39,6 +39,20 @@
background-color: #fff; background-color: #fff;
} }
/** Refresh */
.ui.card > .image > button {
transition: 0.4s ease opacity;
position: absolute;
top: 1em;
right: 1em;
opacity: 0;
}
.ui.card:hover > .image > button {
opacity: 1;
}
/** Content */ /** Content */
.ui.card > .content > .header + .description, .ui.card > .content > .header + .description,
.ui.card > .content > .meta + .description, .ui.card > .content > .meta + .description,
@ -57,7 +71,6 @@
vertical-align: text-bottom; vertical-align: text-bottom;
} }
/** /**
* Label * Label
*/ */

View file

@ -58,10 +58,26 @@ $(function() {
*/ */
var timerInterval = 1200; var timerInterval = 1200;
var timerCache = setTimeout( var timerCache = setTimeout(
function generateCache() { function generateCacheCards() {
var cards = $('.ui.card[data-cache="false"]'); var cards = $('.ui.card[data-cache="false"]');
cards.each(function(index, card) { cards.each(function(index, card) {
generateCacheCard(card);
if (index >= 0) {
return false;
}
});
if (cards.length > 0) {
setTimeout(generateCacheCards, timerInterval);
}
},
0
);
});
function generateCacheCard(card) {
card = $(card); card = $(card);
var href = card.find('.content [href]').prop('href'); var href = card.find('.content [href]').prop('href');
@ -172,18 +188,17 @@ $(function() {
card.removeClass('loading'); card.removeClass('loading');
} }
}); });
if (index >= 0) {
return false;
} }
});
if (cards.length > 0) { /**
setTimeout(generateCache, timerInterval); * Refresh
} */
}, $(document).on('click', '.ui.button.refresh', function(event) {
0 var card = $(event.currentTarget).closest('.ui.card');
);
console.log(card);
generateCacheCard(card);
}); });
/** /**

View file

@ -90,6 +90,10 @@ class Wishlist
<?php if ($info->image) { ?> <?php if ($info->image) { ?>
<div class="image"> <div class="image">
<img src="<?= $info->image ?>" loading="lazy"/> <img src="<?= $info->image ?>" loading="lazy"/>
<button class="ui icon button refresh">
<i class="refresh icon"></i>
</button>
</div> </div>
<?php } ?> <?php } ?>