1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-10 11:15:01 -05:00
mail/src/js/app.js

139 lines
4.6 KiB
JavaScript
Raw Normal View History

'use strict';
2014-12-11 04:28:23 -05:00
//
// AppCache
//
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.
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
//
var axe = require('axe-logger');
// include angular modules
require('./app-config');
require('./directive');
require('./util');
require('./crypto');
2014-11-17 12:58:03 -05:00
require('./service');
require('./email');
2014-10-02 16:05:44 -04:00
// init main angular module including dependencies
var app = angular.module('mail', [
'ngRoute',
'ngAnimate',
'ngTagsInput',
'woAppConfig',
'woDirectives',
'woUtil',
2014-11-20 16:53:30 -05:00
'woCrypto',
'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
app.config(function($routeProvider, $animateProvider) {
$routeProvider.when('/login', {
templateUrl: 'tpl/login.html',
controller: require('./controller/login/login')
});
2014-10-02 16:05:44 -04:00
$routeProvider.when('/add-account', {
templateUrl: 'tpl/add-account.html',
controller: require('./controller/login/add-account')
});
$routeProvider.when('/create-account', {
templateUrl: 'tpl/create-account.html',
controller: require('./controller/login/create-account')
});
$routeProvider.when('/validate-phone', {
templateUrl: 'tpl/validate-phone.html',
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',
controller: require('./controller/login/login-set-credentials')
2014-10-02 16:05:44 -04:00
});
$routeProvider.when('/login-existing', {
templateUrl: 'tpl/login-existing.html',
controller: require('./controller/login/login-existing')
2014-10-02 16:05:44 -04:00
});
$routeProvider.when('/login-initial', {
templateUrl: 'tpl/login-initial.html',
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',
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',
controller: require('./controller/login/login-privatekey-download')
2014-10-02 16:05:44 -04:00
});
$routeProvider.when('/account', {
2014-10-02 16:05:44 -04:00
templateUrl: 'tpl/desktop.html',
controller: require('./controller/app/navigation'),
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'
});
// activate ngAnimate for whitelisted classes only
$animateProvider.classNameFilter(/lightbox/);
2014-10-02 16:05:44 -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);
});
2014-10-02 16:05:44 -04:00
// inject controllers from ng-included view templates
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'));
app.controller('PrivateKeyUploadCtrl', require('./controller/app/privatekey-upload'));
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'));
//
// 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']);
});
}