Loading bar: Introduced two event listeners on window 'pillar:workStart' and 'pillar:workStop' that (de)activates the loading bar.
Reason: * To decouple code * Have the loading bar active until whole page stopped working * Have local loading info Usage: $.('.myClass') .on('pillar:workStart', function(){ ... do stuff locally while loading ... }) .on('pillar:workStop', function(){ ... stop do stuff locally while loading ... }) $.('.myClass .mySubClass').trigger('pillar:workStart') ... do stuff ... $.('.myClass .mySubClass').trigger('pillar:workStop')
This commit is contained in:
parent
ce7cf52d70
commit
c8e62e3610
@ -104,13 +104,31 @@ function statusBarSet(classes, html, icon_name, time){
|
||||
* loading an asset or performing actions.
|
||||
*/
|
||||
function loadingBarShow(){
|
||||
/* NEVER call this directly! Trigger pillar:workStart event instead */
|
||||
$('.loading-bar').addClass('active');
|
||||
}
|
||||
|
||||
function loadingBarHide(){
|
||||
/* NEVER call this directly! Trigger pillar:workStop event instead */
|
||||
$('.loading-bar').removeClass('active');
|
||||
}
|
||||
|
||||
(function loadingbar () {
|
||||
var busyCounter = 0;
|
||||
|
||||
$(window)
|
||||
.on('pillar:workStart', function(e) {
|
||||
busyCounter += 1;
|
||||
loadingBarShow();
|
||||
})
|
||||
.on('pillar:workStop', function() {
|
||||
busyCounter -= 1;
|
||||
if(busyCounter === 0) {
|
||||
loadingBarHide();
|
||||
}
|
||||
})
|
||||
})();
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user