Moved progress-related functions to promises
This commit is contained in:
parent
64743499b6
commit
8b217118af
2 changed files with 9 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
||||||
var App = App || {};
|
var App = App || {};
|
||||||
|
|
||||||
App.PresenterManager = function(jQuery, promise, topNavigationPresenter, keyboard, progress) {
|
App.PresenterManager = function(jQuery, promise, topNavigationPresenter, keyboard) {
|
||||||
|
|
||||||
var lastContentPresenter = null;
|
var lastContentPresenter = null;
|
||||||
|
|
||||||
|
@ -15,8 +15,6 @@ App.PresenterManager = function(jQuery, promise, topNavigationPresenter, keyboar
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchContentPresenter(presenter, args) {
|
function switchContentPresenter(presenter, args) {
|
||||||
progress.start();
|
|
||||||
|
|
||||||
if (lastContentPresenter === null || lastContentPresenter.name !== presenter.name) {
|
if (lastContentPresenter === null || lastContentPresenter.name !== presenter.name) {
|
||||||
if (lastContentPresenter !== null && lastContentPresenter.deinit) {
|
if (lastContentPresenter !== null && lastContentPresenter.deinit) {
|
||||||
lastContentPresenter.deinit();
|
lastContentPresenter.deinit();
|
||||||
|
@ -24,10 +22,10 @@ App.PresenterManager = function(jQuery, promise, topNavigationPresenter, keyboar
|
||||||
keyboard.reset();
|
keyboard.reset();
|
||||||
topNavigationPresenter.changeTitle(null);
|
topNavigationPresenter.changeTitle(null);
|
||||||
topNavigationPresenter.focus();
|
topNavigationPresenter.focus();
|
||||||
presenter.init.call(presenter, args, progress.done);
|
presenter.init.call(presenter, args, function() {});
|
||||||
lastContentPresenter = presenter;
|
lastContentPresenter = presenter;
|
||||||
} else if (lastContentPresenter.reinit) {
|
} else if (lastContentPresenter.reinit) {
|
||||||
lastContentPresenter.reinit.call(lastContentPresenter, args, progress.done);
|
lastContentPresenter.reinit.call(lastContentPresenter, args, function() {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,4 +52,4 @@ App.PresenterManager = function(jQuery, promise, topNavigationPresenter, keyboar
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
App.DI.registerSingleton('presenterManager', ['jQuery', 'promise', 'topNavigationPresenter', 'keyboard', 'progress'], App.PresenterManager);
|
App.DI.registerSingleton('presenterManager', ['jQuery', 'promise', 'topNavigationPresenter', 'keyboard'], App.PresenterManager);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
var App = App || {};
|
var App = App || {};
|
||||||
|
|
||||||
App.Promise = function(_, jQuery) {
|
App.Promise = function(_, jQuery, progress) {
|
||||||
|
|
||||||
var active = [];
|
var active = [];
|
||||||
var promiseId = 0;
|
var promiseId = 0;
|
||||||
|
@ -30,6 +30,7 @@ App.Promise = function(_, jQuery) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function wait() {
|
function wait() {
|
||||||
|
progress.start();
|
||||||
var promises = arguments;
|
var promises = arguments;
|
||||||
var deferred = jQuery.Deferred();
|
var deferred = jQuery.Deferred();
|
||||||
return jQuery.when.apply(jQuery, promises)
|
return jQuery.when.apply(jQuery, promises)
|
||||||
|
@ -37,6 +38,8 @@ App.Promise = function(_, jQuery) {
|
||||||
return deferred.resolve.apply(deferred, arguments);
|
return deferred.resolve.apply(deferred, arguments);
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
return deferred.reject.apply(deferred, arguments);
|
return deferred.reject.apply(deferred, arguments);
|
||||||
|
}).always(function() {
|
||||||
|
progress.done();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,4 +60,4 @@ App.Promise = function(_, jQuery) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
App.DI.registerSingleton('promise', ['_', 'jQuery'], App.Promise);
|
App.DI.registerSingleton('promise', ['_', 'jQuery', 'progress'], App.Promise);
|
||||||
|
|
Loading…
Reference in a new issue