Skip to content
Snippets Groups Projects
Commit f9afb810 authored by ale's avatar ale
Browse files

allow nesting calls to djr.loading()

parent 454bfd16
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,8 @@ djr = {}; ...@@ -9,7 +9,8 @@ djr = {};
// Global state (with Player instance). // Global state (with Player instance).
djr.state = { djr.state = {
backend: null, backend: null,
player: null player: null,
loadingCount: 0
}; };
// Initialize the Player and add all our onclick handlers. // Initialize the Player and add all our onclick handlers.
...@@ -158,9 +159,15 @@ djr.player = function() { ...@@ -158,9 +159,15 @@ djr.player = function() {
}; };
// Show/hide the 'loader' animated GIF. // Show/hide the 'loader' animated GIF.
// Keep a counter so we can nest calls.
djr.loading = function(active) { djr.loading = function(active) {
var loader = $('#loaderImg'); var loader = $('#loaderImg');
if (active) { if (active) {
djr.state.loaderCount += 1;
} else {
djr.state.loaderCount -= 1;
}
if (djr.state.loaderCount > 0) {
loader.show(); loader.show();
} else { } else {
loader.hide(); loader.hide();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment