2014-08-31 23:22:56 +02:00
|
|
|
var App = App || {};
|
|
|
|
App.Presenters = App.Presenters || {};
|
|
|
|
|
|
|
|
App.Presenters.LogoutPresenter = function(
|
|
|
|
jQuery,
|
2014-09-04 18:06:25 +02:00
|
|
|
promise,
|
2014-09-04 19:06:12 +02:00
|
|
|
router,
|
|
|
|
auth,
|
|
|
|
topNavigationPresenter,
|
|
|
|
messagePresenter) {
|
2014-08-31 23:22:56 +02:00
|
|
|
|
|
|
|
var $messages = jQuery('#content');
|
|
|
|
|
2014-10-09 21:41:46 +02:00
|
|
|
function init(params, loaded) {
|
2014-09-03 09:10:26 +02:00
|
|
|
topNavigationPresenter.select('logout');
|
2014-09-11 13:59:12 +02:00
|
|
|
topNavigationPresenter.changeTitle('Logout');
|
2014-09-17 22:37:49 +02:00
|
|
|
promise.wait(auth.logout())
|
|
|
|
.then(function() {
|
|
|
|
loaded();
|
|
|
|
$messages.empty();
|
|
|
|
var $messageDiv = messagePresenter.showInfo($messages, 'Logged out. <a href="">Back to main page</a>');
|
|
|
|
$messageDiv.find('a').click(mainPageLinkClicked);
|
|
|
|
}).fail(function(response) {
|
|
|
|
messagePresenter.showError(($messages, response.json && response.json.error || response) + '<br/>Reload the page to continue.');
|
2014-10-10 18:13:46 +02:00
|
|
|
loaded();
|
2014-09-17 22:37:49 +02:00
|
|
|
});
|
2014-09-02 23:07:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function mainPageLinkClicked(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
router.navigateToMainPage();
|
|
|
|
}
|
|
|
|
|
2014-09-03 09:10:26 +02:00
|
|
|
return {
|
|
|
|
init: init
|
|
|
|
};
|
2014-08-31 23:22:56 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2014-09-11 12:33:44 +02:00
|
|
|
App.DI.register('logoutPresenter', ['jQuery', 'promise', 'router', 'auth', 'topNavigationPresenter', 'messagePresenter'], App.Presenters.LogoutPresenter);
|