From 481cbef81ad89415a2d2a16d114ed3933e40f552 Mon Sep 17 00:00:00 2001 From: grandeljay Date: Fri, 17 Jun 2022 10:39:12 +0200 Subject: [PATCH] Improve progress visibility --- src/assets/js/wishlists.js | 55 ++++++++++++++------------------------ 1 file changed, 20 insertions(+), 35 deletions(-) diff --git a/src/assets/js/wishlists.js b/src/assets/js/wishlists.js index 3db781ad..c84348ed 100644 --- a/src/assets/js/wishlists.js +++ b/src/assets/js/wishlists.js @@ -7,6 +7,12 @@ $(function () { * Get Wishlists */ var wishlists = []; + var progress = $('.ui.progress'); + progress.progress({ + onSuccess : function() { + $(this).slideUp(); + } + }); function wishlistsRefresh() { $('.ui.dropdown.wishlists').api({ @@ -39,30 +45,10 @@ $(function () { wishlistsRefresh(); - /** - * Selection - */ - var progress = $('.ui.progress'); - progress.progress({ - /** - * Only fires once - * - * @see https://github.com/fomantic/Fomantic-UI/issues/2177 - */ - onSuccess : function() { - wishlistsRefresh(); - - progress.slideUp(); - } - }); - $(document).on('change', '.ui.dropdown.wishlists', function () { var wishlistValue = $('.ui.dropdown.wishlists').dropdown('get value'); var wishlistIndex = $('.ui.dropdown.wishlists select').prop('selectedIndex') - 1; - progress.progress('reset'); - progress.addClass('indeterminate'); - if (wishlistValue) { wishlist.id = wishlistValue; @@ -111,10 +97,8 @@ $(function () { if (cards.length > 0) { progress.slideDown(); - progress.removeClass('indeterminate'); + progress.progress('reset'); progress.progress('set total', cards.length); - } else { - progress.slideUp(); } var timerInterval = 1200; @@ -122,15 +106,15 @@ $(function () { function generateCacheCards() { var cards = $('.ui.card[data-cache="true"]'); - cards.each(function (index, card) { - generateCacheCard($(card)); - - if (index >= 0) { - return false; - } - }); - if (cards.length > 0) { + cards.each(function (index, card) { + generateCacheCard($(card)); + + if (index >= 0) { + return false; + } + }); + setTimeout(generateCacheCards, timerInterval); } }, @@ -155,9 +139,6 @@ $(function () { return; } - card.addClass('loading'); - card.attr('data-cache', false); - var wishlistIndex = $('.ui.dropdown.wishlists select').prop('selectedIndex') - 1; var wishlist_user = wishlists[wishlistIndex].user; @@ -173,7 +154,11 @@ $(function () { .finally(function() { card.removeClass('loading'); - progress.progress('increment'); + progress.progress('increment', 1); + + if (progress.progress('get percent') >= 100) { + progress.slideUp(); + } $('.ui.dropdown.options').dropdown(); });