2014-09-19 15:51:37 -04:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// Check if a new ApaCache is available on page load.
|
|
|
|
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-10-02 16:05:44 -04:00
|
|
|
var DialogCtrl = require('./controller/dialog'),
|
|
|
|
AddAccountCtrl = require('./controller/add-account'),
|
|
|
|
AccountCtrl = require('./controller/account'),
|
|
|
|
SetPassphraseCtrl = require('./controller/set-passphrase'),
|
|
|
|
PrivateKeyUploadCtrl = require('./controller/privatekey-upload'),
|
|
|
|
ContactsCtrl = require('./controller/contacts'),
|
|
|
|
AboutCtrl = require('./controller/about'),
|
|
|
|
LoginCtrl = require('./controller/login'),
|
|
|
|
LoginInitialCtrl = require('./controller/login-initial'),
|
|
|
|
LoginNewDeviceCtrl = require('./controller/login-new-device'),
|
|
|
|
LoginExistingCtrl = require('./controller/login-existing'),
|
|
|
|
LoginPrivateKeyDownloadCtrl = require('./controller/login-privatekey-download'),
|
|
|
|
LoginSetCredentialsCtrl = require('./controller/login-set-credentials'),
|
|
|
|
MailListCtrl = require('./controller/mail-list'),
|
|
|
|
ReadCtrl = require('./controller/read'),
|
|
|
|
WriteCtrl = require('./controller/write'),
|
|
|
|
NavigationCtrl = require('./controller/navigation'),
|
|
|
|
errorUtil = require('./util/error'),
|
|
|
|
backButtonUtil = require('./util/backbutton-handler');
|
2014-09-23 09:41:37 -04:00
|
|
|
require('./directives/common');
|
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',
|
|
|
|
'navigation',
|
|
|
|
'mail-list',
|
|
|
|
'write',
|
|
|
|
'read',
|
|
|
|
'contacts',
|
|
|
|
'login-new-device',
|
|
|
|
'privatekey-upload',
|
|
|
|
'infinite-scroll',
|
2014-09-23 09:41:37 -04:00
|
|
|
'ngTagsInput',
|
|
|
|
'woDirectives'
|
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) {
|
|
|
|
$routeProvider.when('/add-account', {
|
|
|
|
templateUrl: 'tpl/add-account.html',
|
|
|
|
controller: AddAccountCtrl
|
2013-09-04 12:39:26 -04:00
|
|
|
});
|
2014-10-02 16:05:44 -04:00
|
|
|
$routeProvider.when('/login', {
|
|
|
|
templateUrl: 'tpl/login.html',
|
|
|
|
controller: LoginCtrl
|
|
|
|
});
|
|
|
|
$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
|
|
|
|
});
|
|
|
|
$routeProvider.when('/desktop', {
|
|
|
|
templateUrl: 'tpl/desktop.html',
|
|
|
|
controller: NavigationCtrl
|
|
|
|
});
|
|
|
|
$routeProvider.otherwise({
|
|
|
|
redirectTo: '/login'
|
|
|
|
});
|
|
|
|
});
|
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 = {};
|
2014-07-29 13:17:03 -04:00
|
|
|
|
2014-10-02 16:05:44 -04:00
|
|
|
// attach global error handler
|
|
|
|
errorUtil.attachHandler($rootScope);
|
2014-07-29 13:17:03 -04:00
|
|
|
|
2014-10-02 16:05:44 -04:00
|
|
|
// attach the back button handler to the root scope
|
|
|
|
backButtonUtil.attachHandler($rootScope);
|
2014-04-23 06:20:46 -04:00
|
|
|
|
2014-10-02 16:05:44 -04:00
|
|
|
// 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-09-23 09:41:37 -04:00
|
|
|
app.controller('DialogCtrl', DialogCtrl);
|