2014-09-19 15:51:37 -04:00
|
|
|
'use strict';
|
|
|
|
|
2014-12-10 14:58:32 -05:00
|
|
|
// Check if a new AppCache is available on page load.
|
2014-09-19 15:51:37 -04:00
|
|
|
if (typeof window.applicationCache !== 'undefined') {
|
|
|
|
window.onload = function() {
|
|
|
|
window.applicationCache.onupdateready = function() {
|
|
|
|
if (window.applicationCache.status === window.applicationCache.UPDATEREADY) {
|
|
|
|
// Browser downloaded a new app cache
|
|
|
|
if (window.confirm('A new version of Whiteout Mail is available. Restart the app to update?')) {
|
|
|
|
window.location.reload();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-11-19 14:54:59 -05:00
|
|
|
var axe = require('axe-logger'),
|
2014-11-20 09:51:55 -05:00
|
|
|
AddAccountCtrl = require('./controller/login/add-account'),
|
|
|
|
CreateAccountCtrl = require('./controller/login/create-account'),
|
|
|
|
ValidatePhoneCtrl = require('./controller/login/validate-phone'),
|
|
|
|
LoginCtrl = require('./controller/login/login'),
|
|
|
|
LoginInitialCtrl = require('./controller/login/login-initial'),
|
|
|
|
LoginNewDeviceCtrl = require('./controller/login/login-new-device'),
|
|
|
|
LoginExistingCtrl = require('./controller/login/login-existing'),
|
|
|
|
LoginPrivateKeyDownloadCtrl = require('./controller/login/login-privatekey-download'),
|
|
|
|
LoginSetCredentialsCtrl = require('./controller/login/login-set-credentials'),
|
|
|
|
DialogCtrl = require('./controller/app/dialog'),
|
|
|
|
AccountCtrl = require('./controller/app/account'),
|
|
|
|
SetPassphraseCtrl = require('./controller/app/set-passphrase'),
|
|
|
|
PrivateKeyUploadCtrl = require('./controller/app/privatekey-upload'),
|
|
|
|
ContactsCtrl = require('./controller/app/contacts'),
|
|
|
|
AboutCtrl = require('./controller/app/about'),
|
|
|
|
MailListCtrl = require('./controller/app/mail-list'),
|
|
|
|
ReadCtrl = require('./controller/app/read'),
|
|
|
|
WriteCtrl = require('./controller/app/write'),
|
|
|
|
NavigationCtrl = require('./controller/app/navigation'),
|
|
|
|
ActionBarCtrl = require('./controller/app/action-bar'),
|
2014-12-04 06:46:55 -05:00
|
|
|
StatusDisplayCtrl = require('./controller/app/status-display');
|
2014-11-19 14:54:59 -05:00
|
|
|
|
|
|
|
// include angular modules
|
|
|
|
require('./app-config');
|
|
|
|
require('./directive/common');
|
|
|
|
require('./util');
|
|
|
|
require('./crypto');
|
2014-11-17 12:58:03 -05:00
|
|
|
require('./service');
|
2014-11-19 14:54:59 -05:00
|
|
|
require('./email');
|
2013-09-04 12:39:26 -04:00
|
|
|
|
2014-10-02 16:05:44 -04:00
|
|
|
// init main angular module including dependencies
|
|
|
|
var app = angular.module('mail', [
|
|
|
|
'ngRoute',
|
|
|
|
'ngAnimate',
|
2014-11-19 14:54:59 -05:00
|
|
|
'ngTagsInput',
|
|
|
|
'woAppConfig',
|
|
|
|
'woDirectives',
|
|
|
|
'woUtil',
|
2014-11-20 16:53:30 -05:00
|
|
|
'woCrypto',
|
2014-11-19 14:54:59 -05:00
|
|
|
'woServices',
|
|
|
|
'woEmail',
|
2014-10-02 16:05:44 -04:00
|
|
|
'navigation',
|
|
|
|
'mail-list',
|
|
|
|
'write',
|
|
|
|
'read',
|
|
|
|
'contacts',
|
|
|
|
'login-new-device',
|
2014-11-19 14:54:59 -05:00
|
|
|
'infinite-scroll'
|
2014-10-02 16:05:44 -04:00
|
|
|
]);
|
2013-11-27 04:40:55 -05:00
|
|
|
|
2014-10-02 16:05:44 -04:00
|
|
|
// set router paths
|
2014-11-10 07:03:32 -05:00
|
|
|
app.config(function($routeProvider, $animateProvider) {
|
2014-11-05 10:03:48 -05:00
|
|
|
$routeProvider.when('/login', {
|
|
|
|
templateUrl: 'tpl/login.html',
|
|
|
|
controller: LoginCtrl
|
|
|
|
});
|
2014-10-02 16:05:44 -04:00
|
|
|
$routeProvider.when('/add-account', {
|
|
|
|
templateUrl: 'tpl/add-account.html',
|
|
|
|
controller: AddAccountCtrl
|
2013-09-04 12:39:26 -04:00
|
|
|
});
|
2014-11-05 10:03:48 -05:00
|
|
|
$routeProvider.when('/create-account', {
|
2014-11-09 14:58:13 -05:00
|
|
|
templateUrl: 'tpl/create-account.html',
|
|
|
|
controller: CreateAccountCtrl
|
2014-11-05 10:03:48 -05:00
|
|
|
});
|
|
|
|
$routeProvider.when('/validate-phone', {
|
2014-11-09 14:58:13 -05:00
|
|
|
templateUrl: 'tpl/validate-phone.html',
|
|
|
|
controller: ValidatePhoneCtrl
|
2014-10-02 16:05:44 -04:00
|
|
|
});
|
|
|
|
$routeProvider.when('/login-set-credentials', {
|
|
|
|
templateUrl: 'tpl/login-set-credentials.html',
|
|
|
|
controller: LoginSetCredentialsCtrl
|
|
|
|
});
|
|
|
|
$routeProvider.when('/login-existing', {
|
|
|
|
templateUrl: 'tpl/login-existing.html',
|
|
|
|
controller: LoginExistingCtrl
|
|
|
|
});
|
|
|
|
$routeProvider.when('/login-initial', {
|
|
|
|
templateUrl: 'tpl/login-initial.html',
|
|
|
|
controller: LoginInitialCtrl
|
|
|
|
});
|
|
|
|
$routeProvider.when('/login-new-device', {
|
|
|
|
templateUrl: 'tpl/login-new-device.html',
|
|
|
|
controller: LoginNewDeviceCtrl
|
|
|
|
});
|
|
|
|
$routeProvider.when('/login-privatekey-download', {
|
|
|
|
templateUrl: 'tpl/login-privatekey-download.html',
|
|
|
|
controller: LoginPrivateKeyDownloadCtrl
|
|
|
|
});
|
2014-12-04 06:46:55 -05:00
|
|
|
$routeProvider.when('/account', {
|
2014-10-02 16:05:44 -04:00
|
|
|
templateUrl: 'tpl/desktop.html',
|
2014-12-04 06:46:55 -05:00
|
|
|
controller: NavigationCtrl,
|
|
|
|
reloadOnSearch: false // don't reload controllers in main app when query params change
|
|
|
|
});
|
2014-10-02 16:05:44 -04:00
|
|
|
$routeProvider.otherwise({
|
|
|
|
redirectTo: '/login'
|
|
|
|
});
|
2014-11-10 07:03:32 -05:00
|
|
|
|
|
|
|
// activate ngAnimate for whitelisted classes only
|
2014-11-20 08:12:08 -05:00
|
|
|
$animateProvider.classNameFilter(/lightbox/);
|
2014-10-02 16:05:44 -04:00
|
|
|
});
|
2013-09-04 12:39:26 -04:00
|
|
|
|
2014-10-02 16:05:44 -04:00
|
|
|
app.run(function($rootScope) {
|
|
|
|
// global state... inherited to all child scopes
|
|
|
|
$rootScope.state = {};
|
|
|
|
// attach fastclick
|
|
|
|
FastClick.attach(document.body);
|
|
|
|
});
|
2013-09-18 12:47:18 -04:00
|
|
|
|
2014-10-02 16:05:44 -04:00
|
|
|
// inject controllers from ng-included view templates
|
|
|
|
app.controller('ReadCtrl', ReadCtrl);
|
|
|
|
app.controller('WriteCtrl', WriteCtrl);
|
|
|
|
app.controller('MailListCtrl', MailListCtrl);
|
|
|
|
app.controller('AccountCtrl', AccountCtrl);
|
|
|
|
app.controller('SetPassphraseCtrl', SetPassphraseCtrl);
|
|
|
|
app.controller('PrivateKeyUploadCtrl', PrivateKeyUploadCtrl);
|
|
|
|
app.controller('ContactsCtrl', ContactsCtrl);
|
|
|
|
app.controller('AboutCtrl', AboutCtrl);
|
2014-11-05 08:26:09 -05:00
|
|
|
app.controller('DialogCtrl', DialogCtrl);
|
2014-11-19 14:54:59 -05:00
|
|
|
app.controller('ActionBarCtrl', ActionBarCtrl);
|
2014-11-20 09:14:39 -05:00
|
|
|
app.controller('StatusDisplayCtrl', StatusDisplayCtrl);
|
2014-11-19 14:54:59 -05:00
|
|
|
|
|
|
|
//
|
|
|
|
// Manual angular bootstraping
|
|
|
|
//
|
|
|
|
|
|
|
|
// are we running in a cordova app or in a browser environment?
|
|
|
|
if (window.cordova) {
|
|
|
|
// wait for 'deviceready' event to make sure plugins are loaded
|
|
|
|
axe.debug('Assuming Cordova environment...');
|
|
|
|
document.addEventListener('deviceready', bootstrap, false);
|
|
|
|
} else {
|
|
|
|
// No need to wait on events... just start the app
|
|
|
|
axe.debug('Assuming Browser environment...');
|
|
|
|
bootstrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
function bootstrap() {
|
|
|
|
angular.element(document).ready(function() {
|
|
|
|
angular.bootstrap(document, ['mail']);
|
|
|
|
});
|
2014-12-10 14:58:32 -05:00
|
|
|
}
|