2014-09-19 15:51:37 -04:00
|
|
|
'use strict';
|
|
|
|
|
2014-12-11 04:28:23 -05:00
|
|
|
//
|
|
|
|
// AppCache
|
|
|
|
//
|
|
|
|
|
2014-09-19 15:51:37 -04:00
|
|
|
if (typeof window.applicationCache !== 'undefined') {
|
|
|
|
window.onload = function() {
|
2014-12-11 04:28:23 -05:00
|
|
|
// Check if a new AppCache is available on page load.
|
2014-09-19 15:51:37 -04:00
|
|
|
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-12-11 04:28:23 -05:00
|
|
|
//
|
|
|
|
// Angular app config
|
|
|
|
//
|
|
|
|
|
2014-12-10 15:41:16 -05:00
|
|
|
var axe = require('axe-logger');
|
2014-11-19 14:54:59 -05:00
|
|
|
|
|
|
|
// include angular modules
|
|
|
|
require('./app-config');
|
2014-12-10 15:41:16 -05:00
|
|
|
require('./directive');
|
2014-11-19 14:54:59 -05:00
|
|
|
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',
|
|
|
|
'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',
|
2014-12-10 15:41:16 -05:00
|
|
|
controller: require('./controller/login/login')
|
2014-11-05 10:03:48 -05:00
|
|
|
});
|
2014-10-02 16:05:44 -04:00
|
|
|
$routeProvider.when('/add-account', {
|
|
|
|
templateUrl: 'tpl/add-account.html',
|
2014-12-10 15:41:16 -05:00
|
|
|
controller: require('./controller/login/add-account')
|
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',
|
2014-12-10 15:41:16 -05:00
|
|
|
controller: require('./controller/login/create-account')
|
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',
|
2014-12-10 15:41:16 -05:00
|
|
|
controller: require('./controller/login/validate-phone')
|
2014-10-02 16:05:44 -04:00
|
|
|
});
|
|
|
|
$routeProvider.when('/login-set-credentials', {
|
|
|
|
templateUrl: 'tpl/login-set-credentials.html',
|
2014-12-10 15:41:16 -05:00
|
|
|
controller: require('./controller/login/login-set-credentials')
|
2014-10-02 16:05:44 -04:00
|
|
|
});
|
2015-02-27 14:04:44 -05:00
|
|
|
$routeProvider.when('/login-privatekey-upload', {
|
|
|
|
templateUrl: 'tpl/login-privatekey-upload.html',
|
|
|
|
controller: require('./controller/login/login-privatekey-upload')
|
|
|
|
});
|
2015-02-20 11:55:11 -05:00
|
|
|
$routeProvider.when('/login-verify-public-key', {
|
|
|
|
templateUrl: 'tpl/login-verify-public-key.html',
|
|
|
|
controller: require('./controller/login/login-verify-public-key')
|
|
|
|
});
|
2014-10-02 16:05:44 -04:00
|
|
|
$routeProvider.when('/login-existing', {
|
|
|
|
templateUrl: 'tpl/login-existing.html',
|
2014-12-10 15:41:16 -05:00
|
|
|
controller: require('./controller/login/login-existing')
|
2014-10-02 16:05:44 -04:00
|
|
|
});
|
|
|
|
$routeProvider.when('/login-initial', {
|
|
|
|
templateUrl: 'tpl/login-initial.html',
|
2014-12-10 15:41:16 -05:00
|
|
|
controller: require('./controller/login/login-initial')
|
2014-10-02 16:05:44 -04:00
|
|
|
});
|
|
|
|
$routeProvider.when('/login-new-device', {
|
|
|
|
templateUrl: 'tpl/login-new-device.html',
|
2014-12-10 15:41:16 -05:00
|
|
|
controller: require('./controller/login/login-new-device')
|
2014-10-02 16:05:44 -04:00
|
|
|
});
|
|
|
|
$routeProvider.when('/login-privatekey-download', {
|
|
|
|
templateUrl: 'tpl/login-privatekey-download.html',
|
2014-12-10 15:41:16 -05:00
|
|
|
controller: require('./controller/login/login-privatekey-download')
|
2014-10-02 16:05:44 -04:00
|
|
|
});
|
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-10 15:41:16 -05:00
|
|
|
controller: require('./controller/app/navigation'),
|
2014-12-04 06:46:55 -05:00
|
|
|
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
|
2014-12-10 15:41:16 -05:00
|
|
|
app.controller('ReadCtrl', require('./controller/app/read'));
|
|
|
|
app.controller('WriteCtrl', require('./controller/app/write'));
|
|
|
|
app.controller('MailListCtrl', require('./controller/app/mail-list'));
|
|
|
|
app.controller('AccountCtrl', require('./controller/app/account'));
|
|
|
|
app.controller('SetPassphraseCtrl', require('./controller/app/set-passphrase'));
|
2015-01-28 09:01:18 -05:00
|
|
|
app.controller('PublicKeyImportCtrl', require('./controller/app/publickey-import'));
|
2014-12-10 15:41:16 -05:00
|
|
|
app.controller('ContactsCtrl', require('./controller/app/contacts'));
|
|
|
|
app.controller('AboutCtrl', require('./controller/app/about'));
|
|
|
|
app.controller('DialogCtrl', require('./controller/app/dialog'));
|
|
|
|
app.controller('ActionBarCtrl', require('./controller/app/action-bar'));
|
|
|
|
app.controller('StatusDisplayCtrl', require('./controller/app/status-display'));
|
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 15:41:16 -05:00
|
|
|
}
|