1
0
mirror of https://github.com/moparisthebest/mail synced 2024-12-25 00:38:54 -05:00

Set back button event in navigation.js

This commit is contained in:
Tankred Hase 2014-08-04 15:53:55 +02:00
parent 3a713180f1
commit 9e1a402b94
3 changed files with 15 additions and 9 deletions

View File

@ -24,7 +24,6 @@ define(function(require) {
InvitationDAO = require('js/dao/invitation-dao'), InvitationDAO = require('js/dao/invitation-dao'),
DeviceStorageDAO = require('js/dao/devicestorage-dao'), DeviceStorageDAO = require('js/dao/devicestorage-dao'),
UpdateHandler = require('js/util/update/update-handler'), UpdateHandler = require('js/util/update/update-handler'),
backBtnHandler = require('js/util/backbutton-handler'),
config = appConfig.config, config = appConfig.config,
str = appConfig.string; str = appConfig.string;
@ -55,7 +54,6 @@ define(function(require) {
function onDeviceReady() { function onDeviceReady() {
axe.debug('Starting app.'); axe.debug('Starting app.');
backBtnHandler.start();
self.buildModules(); self.buildModules();
// Handle offline and online gracefully // Handle offline and online gracefully

View File

@ -5,6 +5,7 @@ define(function(require) {
appController = require('js/app-controller'), appController = require('js/app-controller'),
config = require('js/app-config').config, config = require('js/app-config').config,
notification = require('js/util/notification'), notification = require('js/util/notification'),
backBtnHandler = require('js/util/backbutton-handler'),
_ = require('underscore'), _ = require('underscore'),
emailDao, outboxBo; emailDao, outboxBo;
@ -54,6 +55,8 @@ define(function(require) {
// Start // Start
// //
// handle back button
backBtnHandler.start();
// init folders // init folders
initializeFolders(); initializeFolders();

View File

@ -34,25 +34,30 @@ define(function(require) {
if (backBtnHandler.scope.state.lightbox) { if (backBtnHandler.scope.state.lightbox) {
// closes the lightbox (error msgs, writer, ...) // closes the lightbox (error msgs, writer, ...)
backBtnHandler.scope.$apply(function() {
backBtnHandler.scope.state.lightbox = undefined; backBtnHandler.scope.state.lightbox = undefined;
});
axe.debug(DEBUG_TAG, 'lightbox closed'); axe.debug(DEBUG_TAG, 'lightbox closed');
backBtnHandler.scope.$apply();
} else if (backBtnHandler.scope.state.read && backBtnHandler.scope.state.read.open) { } else if (backBtnHandler.scope.state.read && backBtnHandler.scope.state.read.open) {
// closes the reader // closes the reader
backBtnHandler.scope.$apply(function() {
backBtnHandler.scope.state.read.toggle(false); backBtnHandler.scope.state.read.toggle(false);
});
axe.debug(DEBUG_TAG, 'reader closed'); axe.debug(DEBUG_TAG, 'reader closed');
backBtnHandler.scope.$apply();
} else if (backBtnHandler.scope.state.nav && backBtnHandler.scope.state.nav.open) { } else if (backBtnHandler.scope.state.nav && backBtnHandler.scope.state.nav.open) {
// closes the navigation // closes the navigation
backBtnHandler.scope.$apply(function() {
backBtnHandler.scope.state.nav.toggle(false); backBtnHandler.scope.state.nav.toggle(false);
});
axe.debug(DEBUG_TAG, 'navigation closed'); axe.debug(DEBUG_TAG, 'navigation closed');
backBtnHandler.scope.$apply();
} else { } else {
// exits the app // exits the app
navigator.app.exitApp(); navigator.app.exitApp();
} }
} }
return backBtnHandler; return backBtnHandler;
}); });