szurubooru/public_html/js/Presenters/ProgressPresenter.js

40 lines
550 B
JavaScript
Raw Normal View History

2014-10-20 20:01:37 +02:00
var App = App || {};
App.Controls = App.Controls || {};
App.Presenters.ProgressPresenter = function(nprogress) {
var nesting = 0;
function start() {
nesting ++;
if (nesting === 1) {
nprogress.start();
}
}
function reset() {
nesting = 0;
}
2014-10-20 20:01:37 +02:00
function done() {
if (nesting) {
nesting --;
}
2014-10-20 20:01:37 +02:00
if (nesting <= 0) {
2014-10-20 20:01:37 +02:00
nprogress.done();
} else {
nprogress.inc();
}
}
return {
start: start,
done: done,
reset: reset,
2014-10-20 20:01:37 +02:00
};
2014-10-22 09:53:51 +02:00
};
2014-10-20 20:01:37 +02:00
App.DI.registerSingleton('progress', ['nprogress'], App.Presenters.ProgressPresenter);