2014-08-31 23:22:56 +02:00
|
|
|
var App = App || {};
|
|
|
|
App.Presenters = App.Presenters || {};
|
|
|
|
|
|
|
|
App.Presenters.LogoutPresenter = function(
|
|
|
|
jQuery,
|
|
|
|
topNavigationPresenter,
|
|
|
|
messagePresenter,
|
|
|
|
auth,
|
2014-09-04 18:06:25 +02:00
|
|
|
promise,
|
2014-08-31 23:22:56 +02:00
|
|
|
router) {
|
|
|
|
|
|
|
|
var $messages = jQuery('#content');
|
|
|
|
|
2014-09-02 23:07:50 +02:00
|
|
|
function init() {
|
2014-09-03 09:10:26 +02:00
|
|
|
topNavigationPresenter.select('logout');
|
2014-09-04 18:06:25 +02:00
|
|
|
promise.wait(auth.logout()).then(function() {
|
2014-09-03 20:05:45 +02:00
|
|
|
$messages.empty();
|
2014-09-02 23:07:50 +02:00
|
|
|
var $messageDiv = messagePresenter.showInfo($messages, 'Logged out. <a href="">Back to main page</a>');
|
|
|
|
$messageDiv.find('a').click(mainPageLinkClicked);
|
2014-09-04 18:06:25 +02:00
|
|
|
}).fail(function(response) {
|
2014-09-02 23:07:50 +02:00
|
|
|
messagePresenter.showError($messages, response.json && response.json.error || response);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
App.DI.register('logoutPresenter', App.Presenters.LogoutPresenter);
|