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