From 8b217118af258484429ab0131e43d341a4959e7e Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Wed, 22 Oct 2014 18:43:09 +0200 Subject: [PATCH] Moved progress-related functions to promises --- public_html/js/PresenterManager.js | 10 ++++------ public_html/js/Promise.js | 7 +++++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/public_html/js/PresenterManager.js b/public_html/js/PresenterManager.js index a1e98f54..b4069c25 100644 --- a/public_html/js/PresenterManager.js +++ b/public_html/js/PresenterManager.js @@ -1,6 +1,6 @@ var App = App || {}; -App.PresenterManager = function(jQuery, promise, topNavigationPresenter, keyboard, progress) { +App.PresenterManager = function(jQuery, promise, topNavigationPresenter, keyboard) { var lastContentPresenter = null; @@ -15,8 +15,6 @@ App.PresenterManager = function(jQuery, promise, topNavigationPresenter, keyboar } function switchContentPresenter(presenter, args) { - progress.start(); - if (lastContentPresenter === null || lastContentPresenter.name !== presenter.name) { if (lastContentPresenter !== null && lastContentPresenter.deinit) { lastContentPresenter.deinit(); @@ -24,10 +22,10 @@ App.PresenterManager = function(jQuery, promise, topNavigationPresenter, keyboar keyboard.reset(); topNavigationPresenter.changeTitle(null); topNavigationPresenter.focus(); - presenter.init.call(presenter, args, progress.done); + presenter.init.call(presenter, args, function() {}); lastContentPresenter = presenter; } 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); diff --git a/public_html/js/Promise.js b/public_html/js/Promise.js index 32877fb9..e211d38f 100644 --- a/public_html/js/Promise.js +++ b/public_html/js/Promise.js @@ -1,6 +1,6 @@ var App = App || {}; -App.Promise = function(_, jQuery) { +App.Promise = function(_, jQuery, progress) { var active = []; var promiseId = 0; @@ -30,6 +30,7 @@ App.Promise = function(_, jQuery) { } function wait() { + progress.start(); var promises = arguments; var deferred = jQuery.Deferred(); return jQuery.when.apply(jQuery, promises) @@ -37,6 +38,8 @@ App.Promise = function(_, jQuery) { return deferred.resolve.apply(deferred, arguments); }).fail(function() { 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);