Improve progress visibility
This commit is contained in:
parent
6d6bc3d487
commit
481cbef81a
1 changed files with 20 additions and 35 deletions
|
@ -7,6 +7,12 @@ $(function () {
|
||||||
* Get Wishlists
|
* Get Wishlists
|
||||||
*/
|
*/
|
||||||
var wishlists = [];
|
var wishlists = [];
|
||||||
|
var progress = $('.ui.progress');
|
||||||
|
progress.progress({
|
||||||
|
onSuccess : function() {
|
||||||
|
$(this).slideUp();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function wishlistsRefresh() {
|
function wishlistsRefresh() {
|
||||||
$('.ui.dropdown.wishlists').api({
|
$('.ui.dropdown.wishlists').api({
|
||||||
|
@ -39,30 +45,10 @@ $(function () {
|
||||||
|
|
||||||
wishlistsRefresh();
|
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 () {
|
$(document).on('change', '.ui.dropdown.wishlists', function () {
|
||||||
var wishlistValue = $('.ui.dropdown.wishlists').dropdown('get value');
|
var wishlistValue = $('.ui.dropdown.wishlists').dropdown('get value');
|
||||||
var wishlistIndex = $('.ui.dropdown.wishlists select').prop('selectedIndex') - 1;
|
var wishlistIndex = $('.ui.dropdown.wishlists select').prop('selectedIndex') - 1;
|
||||||
|
|
||||||
progress.progress('reset');
|
|
||||||
progress.addClass('indeterminate');
|
|
||||||
|
|
||||||
if (wishlistValue) {
|
if (wishlistValue) {
|
||||||
wishlist.id = wishlistValue;
|
wishlist.id = wishlistValue;
|
||||||
|
|
||||||
|
@ -111,10 +97,8 @@ $(function () {
|
||||||
|
|
||||||
if (cards.length > 0) {
|
if (cards.length > 0) {
|
||||||
progress.slideDown();
|
progress.slideDown();
|
||||||
progress.removeClass('indeterminate');
|
progress.progress('reset');
|
||||||
progress.progress('set total', cards.length);
|
progress.progress('set total', cards.length);
|
||||||
} else {
|
|
||||||
progress.slideUp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var timerInterval = 1200;
|
var timerInterval = 1200;
|
||||||
|
@ -122,15 +106,15 @@ $(function () {
|
||||||
function generateCacheCards() {
|
function generateCacheCards() {
|
||||||
var cards = $('.ui.card[data-cache="true"]');
|
var cards = $('.ui.card[data-cache="true"]');
|
||||||
|
|
||||||
cards.each(function (index, card) {
|
|
||||||
generateCacheCard($(card));
|
|
||||||
|
|
||||||
if (index >= 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (cards.length > 0) {
|
if (cards.length > 0) {
|
||||||
|
cards.each(function (index, card) {
|
||||||
|
generateCacheCard($(card));
|
||||||
|
|
||||||
|
if (index >= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
setTimeout(generateCacheCards, timerInterval);
|
setTimeout(generateCacheCards, timerInterval);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -155,9 +139,6 @@ $(function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
card.addClass('loading');
|
|
||||||
card.attr('data-cache', false);
|
|
||||||
|
|
||||||
var wishlistIndex = $('.ui.dropdown.wishlists select').prop('selectedIndex') - 1;
|
var wishlistIndex = $('.ui.dropdown.wishlists select').prop('selectedIndex') - 1;
|
||||||
var wishlist_user = wishlists[wishlistIndex].user;
|
var wishlist_user = wishlists[wishlistIndex].user;
|
||||||
|
|
||||||
|
@ -173,7 +154,11 @@ $(function () {
|
||||||
.finally(function() {
|
.finally(function() {
|
||||||
card.removeClass('loading');
|
card.removeClass('loading');
|
||||||
|
|
||||||
progress.progress('increment');
|
progress.progress('increment', 1);
|
||||||
|
|
||||||
|
if (progress.progress('get percent') >= 100) {
|
||||||
|
progress.slideUp();
|
||||||
|
}
|
||||||
|
|
||||||
$('.ui.dropdown.options').dropdown();
|
$('.ui.dropdown.options').dropdown();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue