mirror of
https://github.com/moparisthebest/mail
synced 2024-11-22 08:52:15 -05:00
tested mobile.html... works
This commit is contained in:
parent
1368672c1d
commit
2007fbcc0f
@ -2,7 +2,7 @@ require(['require-config'], function() {
|
||||
'use strict';
|
||||
|
||||
// Start the main app logic.
|
||||
require(['jquery', 'js/app-controller', 'js/app-config'], function($, controller) {
|
||||
require(['jquery', 'js/app-controller', 'js/app-config'], function($, controller, app) {
|
||||
|
||||
/**
|
||||
* Load templates and start the application
|
||||
|
@ -1,4 +1,4 @@
|
||||
(function() {
|
||||
define([], function() {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
@ -6,9 +6,6 @@
|
||||
*/
|
||||
var app = {
|
||||
model: {},
|
||||
view: {},
|
||||
dao: {},
|
||||
crypto: {},
|
||||
util: {}
|
||||
};
|
||||
|
||||
@ -31,28 +28,8 @@
|
||||
|
||||
get: function(name) {
|
||||
return this.templates[name];
|
||||
},
|
||||
|
||||
loadTemplates: function(names, callback) {
|
||||
var that = this;
|
||||
|
||||
var loadTemplate = function(index) {
|
||||
var name = names[index];
|
||||
console.log('Loading template: ' + name);
|
||||
$.get('tpl/' + name + '.html', function(data) {
|
||||
that.templates[name] = data;
|
||||
index++;
|
||||
if (index < names.length) {
|
||||
loadTemplate(index);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
};
|
||||
loadTemplate(0);
|
||||
}
|
||||
};
|
||||
|
||||
window.app = app;
|
||||
|
||||
}());
|
||||
return app;
|
||||
});
|
@ -1,21 +1,21 @@
|
||||
/**
|
||||
* The main application controller
|
||||
*/
|
||||
define(['js/dao/email-dao'], function(emailDao) {
|
||||
define(['jquery', 'js/dao/email-dao', 'js/dao/keychain-dao', 'js/dao/cloudstorage-dao',
|
||||
'js/app-config', 'cordova'
|
||||
], function($, EmailDAO, KeychainDAO, cloudstorage, app) {
|
||||
'use strict';
|
||||
|
||||
var self = {};
|
||||
|
||||
var emailDao;
|
||||
|
||||
/**
|
||||
* Initializes modules through dependecy injection
|
||||
*/
|
||||
self.init = function(callback) {
|
||||
// var crypto = new app.crypto.Crypto(window, util);
|
||||
// var cloudstorage = new app.dao.CloudStorage(window, $);
|
||||
// var jsonDao = new app.dao.LawnchairDAO(Lawnchair);
|
||||
// var devicestorage = new app.dao.DeviceStorage(util, crypto, jsonDao, null);
|
||||
// var keychain = new app.dao.KeychainDAO(jsonDao, cloudstorage);
|
||||
// emailDao = new app.dao.EmailDAO(jsonDao, crypto, devicestorage, cloudstorage, util, keychain);
|
||||
var keychain = new KeychainDAO(cloudstorage);
|
||||
emailDao = new EmailDAO(cloudstorage, keychain);
|
||||
callback();
|
||||
};
|
||||
|
||||
@ -39,7 +39,7 @@ define(['js/dao/email-dao'], function(emailDao) {
|
||||
|
||||
function onDeviceReady() {
|
||||
console.log('Starting app.');
|
||||
app.util.tpl.loadTemplates(views, callback);
|
||||
loadTemplates(views, callback);
|
||||
}
|
||||
};
|
||||
|
||||
@ -112,5 +112,22 @@ define(['js/dao/email-dao'], function(emailDao) {
|
||||
emailDao.init(account, password, callback);
|
||||
}
|
||||
|
||||
function loadTemplates(names, callback) {
|
||||
var loadTemplate = function(index) {
|
||||
var name = names[index];
|
||||
console.log('Loading template: ' + name);
|
||||
$.get('tpl/' + name + '.html', function(data) {
|
||||
app.util.tpl.templates[name] = data;
|
||||
index++;
|
||||
if (index < names.length) {
|
||||
loadTemplate(index);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
};
|
||||
loadTemplate(0);
|
||||
}
|
||||
|
||||
return self;
|
||||
});
|
@ -1,7 +1,10 @@
|
||||
(function() {
|
||||
define(['jquery', 'backbone', 'js/view/login-view', 'js/view/compose-view',
|
||||
'js/view/folderlist-view', 'js/view/messagelist-view', 'js/view/read-view',
|
||||
'jquerymobile'
|
||||
], function($, Backbone, LoginView, ComposeView, FolderListView, MessageListView, ReadView) {
|
||||
'use strict';
|
||||
|
||||
app.Router = Backbone.Router.extend({
|
||||
var Router = Backbone.Router.extend({
|
||||
|
||||
routes: {
|
||||
'': 'login',
|
||||
@ -16,7 +19,7 @@
|
||||
initialize: function() {},
|
||||
|
||||
login: function() {
|
||||
var loginView = new app.view.LoginView();
|
||||
var loginView = new LoginView();
|
||||
this.changePage(loginView);
|
||||
},
|
||||
|
||||
@ -24,7 +27,7 @@
|
||||
var self = this,
|
||||
composeView;
|
||||
|
||||
composeView = new app.view.ComposeView({
|
||||
composeView = new ComposeView({
|
||||
account: userId,
|
||||
folder: folder,
|
||||
messageId: (messageId) ? decodeURIComponent(messageId) : null,
|
||||
@ -35,7 +38,7 @@
|
||||
},
|
||||
|
||||
folders: function(userId) {
|
||||
var folderListView = new app.view.FolderListView({
|
||||
var folderListView = new FolderListView({
|
||||
account: userId
|
||||
});
|
||||
this.changePage(folderListView);
|
||||
@ -43,7 +46,7 @@
|
||||
|
||||
messagelist: function(userId, folder) {
|
||||
var self = this;
|
||||
var messageListView = new app.view.MessageListView({
|
||||
var messageListView = new MessageListView({
|
||||
account: userId,
|
||||
folder: folder
|
||||
});
|
||||
@ -55,7 +58,7 @@
|
||||
var self = this,
|
||||
readView;
|
||||
|
||||
readView = new app.view.ReadView({
|
||||
readView = new ReadView({
|
||||
account: userId,
|
||||
folder: folder,
|
||||
messageId: decodeURIComponent(messageId),
|
||||
@ -88,4 +91,5 @@
|
||||
|
||||
});
|
||||
|
||||
}());
|
||||
return Router;
|
||||
});
|
@ -3,8 +3,8 @@
|
||||
* gracefully degrades to JS crypto (if unavailable)
|
||||
*/
|
||||
define(['cryptoLib/util', 'cryptoLib/aes-cbc', 'cryptoLib/rsa', 'cryptoLib/crypto-batch',
|
||||
'js/crypto/pbkdf2'
|
||||
], function(util, aes, rsa, cryptoBatch, pbkdf2) {
|
||||
'js/crypto/pbkdf2', 'js/app-config'
|
||||
], function(util, aes, rsa, cryptoBatch, pbkdf2, app) {
|
||||
'use strict';
|
||||
|
||||
var self = {};
|
||||
|
@ -4,7 +4,7 @@
|
||||
/**
|
||||
* A Wrapper for Forge's RSA encryption
|
||||
*/
|
||||
var RSA = function(forge, util) {
|
||||
var RSA = function(forge, util, app) {
|
||||
|
||||
var utl = forge.util;
|
||||
|
||||
@ -129,8 +129,8 @@
|
||||
|
||||
if (typeof define !== 'undefined' && define.amd) {
|
||||
// AMD
|
||||
define(['forge', 'cryptoLib/util'], function(forge, util) {
|
||||
return new RSA(forge, util);
|
||||
define(['forge', 'cryptoLib/util', 'js/app-config'], function(forge, util, app) {
|
||||
return new RSA(forge, util, app);
|
||||
});
|
||||
} else if (typeof module !== 'undefined' && module.exports) {
|
||||
// node.js
|
||||
|
@ -2,7 +2,7 @@
|
||||
* High level storage api for handling syncing of data to
|
||||
* and from the cloud.
|
||||
*/
|
||||
define(['jquery'], function($) {
|
||||
define(['jquery', 'js/app-config'], function($, app) {
|
||||
'use strict';
|
||||
|
||||
var self = {};
|
||||
|
@ -3,8 +3,8 @@
|
||||
* between the cloud service and the device's local storage
|
||||
*/
|
||||
define(['underscore', 'cryptoLib/util', 'js/crypto/crypto', 'js/dao/lawnchair-dao',
|
||||
'js/dao/devicestorage-dao', 'js/model/account-model'
|
||||
], function(_, util, crypto, jsonDB, devicestorage) {
|
||||
'js/dao/devicestorage-dao', 'js/app-config', 'js/model/account-model'
|
||||
], function(_, util, crypto, jsonDB, devicestorage, app) {
|
||||
'use strict';
|
||||
|
||||
var EmailDAO = function(cloudstorage, keychain) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
(function() {
|
||||
define(['jquery'], function($) {
|
||||
'use strict';
|
||||
|
||||
$(document).on('mobileinit', function() {
|
||||
@ -10,9 +10,9 @@
|
||||
$.mobile.defaultPageTransition = 'none';
|
||||
|
||||
// Remove page from DOM when it's being replaced
|
||||
$(document).on('pagehide', 'div[data-role="page"]', function(event, ui) {
|
||||
$(document).on('pagehide', 'div[data-role="page"]', function(event) {
|
||||
$(event.currentTarget).remove();
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
});
|
@ -1,4 +1,4 @@
|
||||
define(['backbone', 'js/model/folder-model'], function(Backbone) {
|
||||
define(['backbone', 'js/app-config', 'js/model/folder-model'], function(Backbone, app) {
|
||||
'use strict';
|
||||
|
||||
app.model.Account = Backbone.Model.extend({
|
||||
|
@ -1,4 +1,4 @@
|
||||
define(['backbone'], function(Backbone) {
|
||||
define(['backbone', 'js/app-config'], function(Backbone, app) {
|
||||
'use strict';
|
||||
|
||||
app.model.Email = Backbone.Model.extend({
|
||||
|
@ -1,4 +1,4 @@
|
||||
define(['backbone'], function(Backbone) {
|
||||
define(['backbone', 'js/app-config'], function(Backbone, app) {
|
||||
'use strict';
|
||||
|
||||
app.model.Folder = Backbone.Model.extend({
|
||||
|
@ -1,16 +1,17 @@
|
||||
(function() {
|
||||
define(['jquery', 'underscore', 'backbone', 'js/app-config'], function($, _, Backbone, app) {
|
||||
'use strict';
|
||||
|
||||
app.view.AccountsView = Backbone.View.extend({
|
||||
var AccountsView = Backbone.View.extend({
|
||||
|
||||
initialize: function() {
|
||||
this.template = _.template(app.util.tpl.get('accounts'));
|
||||
},
|
||||
|
||||
render: function(eventName) {
|
||||
render: function() {
|
||||
$(this.el).html(this.template());
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
}());
|
||||
return AccountsView;
|
||||
});
|
@ -1,7 +1,7 @@
|
||||
(function() {
|
||||
define(['jquery', 'underscore', 'backbone', 'js/app-config'], function($, _, Backbone, app) {
|
||||
'use strict';
|
||||
|
||||
app.view.ComposeView = Backbone.View.extend({
|
||||
var ComposeView = Backbone.View.extend({
|
||||
|
||||
initialize: function(args) {
|
||||
var self = this;
|
||||
@ -140,4 +140,5 @@
|
||||
}
|
||||
});
|
||||
|
||||
}());
|
||||
return ComposeView;
|
||||
});
|
@ -1,13 +1,13 @@
|
||||
(function() {
|
||||
define(['jquery', 'underscore', 'backbone', 'js/app-config'], function($, _, Backbone, app) {
|
||||
'use strict';
|
||||
|
||||
app.view.FolderListView = Backbone.View.extend({
|
||||
var FolderListView = Backbone.View.extend({
|
||||
|
||||
initialize: function() {
|
||||
this.template = _.template(app.util.tpl.get('folderlist'));
|
||||
},
|
||||
|
||||
render: function(eventName) {
|
||||
render: function() {
|
||||
var page = $(this.el);
|
||||
|
||||
page.html(this.template(this.options));
|
||||
@ -23,4 +23,5 @@
|
||||
}
|
||||
});
|
||||
|
||||
}());
|
||||
return FolderListView;
|
||||
});
|
@ -1,7 +1,7 @@
|
||||
(function() {
|
||||
define(['jquery', 'underscore', 'backbone', 'js/app-config'], function($, _, Backbone, app) {
|
||||
'use strict';
|
||||
|
||||
app.view.LoginView = Backbone.View.extend({
|
||||
var LoginView = Backbone.View.extend({
|
||||
|
||||
initialize: function() {
|
||||
this.template = _.template(app.util.tpl.get('login'));
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
login: function() {
|
||||
var page = $(this.el),
|
||||
userId = page.find('#userId').val(),
|
||||
userId = page.find('#userId').val() + '@mail.whiteout.io',
|
||||
password = page.find('#password').val();
|
||||
|
||||
// show loading msg during init
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
// post message to main window
|
||||
app.util.postMessage('login', {
|
||||
userId: userId + '@mail.whiteout.io',
|
||||
userId: userId,
|
||||
password: password
|
||||
}, function(resArgs) {
|
||||
var err = resArgs.err;
|
||||
@ -51,4 +51,5 @@
|
||||
}
|
||||
});
|
||||
|
||||
}());
|
||||
return LoginView;
|
||||
});
|
@ -1,7 +1,9 @@
|
||||
(function() {
|
||||
define(['jquery', 'underscore', 'backbone', 'js/app-config',
|
||||
'js/view/messagelistitem-view'
|
||||
], function($, _, Backbone, app, MessageListItemView) {
|
||||
'use strict';
|
||||
|
||||
app.view.MessageListView = Backbone.View.extend({
|
||||
var MessageListView = Backbone.View.extend({
|
||||
|
||||
initialize: function(args) {
|
||||
this.template = _.template(app.util.tpl.get('messagelist'));
|
||||
@ -92,7 +94,7 @@
|
||||
folder: self.folder,
|
||||
model: email
|
||||
};
|
||||
list.append(new app.view.MessageListItemView(listItemArgs).render().el);
|
||||
list.append(new MessageListItemView(listItemArgs).render().el);
|
||||
}
|
||||
|
||||
// refresh list view
|
||||
@ -103,4 +105,5 @@
|
||||
|
||||
});
|
||||
|
||||
}());
|
||||
return MessageListView;
|
||||
});
|
@ -1,7 +1,7 @@
|
||||
(function() {
|
||||
define(['jquery', 'underscore', 'backbone', 'js/app-config'], function($, _, Backbone, app) {
|
||||
'use strict';
|
||||
|
||||
app.view.MessageListItemView = Backbone.View.extend({
|
||||
var MessageListItemView = Backbone.View.extend({
|
||||
|
||||
tagName: "li",
|
||||
|
||||
@ -25,4 +25,5 @@
|
||||
}
|
||||
});
|
||||
|
||||
}());
|
||||
return MessageListItemView;
|
||||
});
|
@ -1,7 +1,7 @@
|
||||
(function() {
|
||||
define(['jquery', 'underscore', 'backbone', 'js/app-config'], function($, _, Backbone, app) {
|
||||
'use strict';
|
||||
|
||||
app.view.ReadView = Backbone.View.extend({
|
||||
var ReadView = Backbone.View.extend({
|
||||
|
||||
initialize: function(args) {
|
||||
var self = this;
|
||||
@ -67,4 +67,5 @@
|
||||
|
||||
});
|
||||
|
||||
}());
|
||||
return ReadView;
|
||||
});
|
@ -8,47 +8,7 @@
|
||||
<link rel="stylesheet" href="css/styles.css"/>
|
||||
|
||||
<!-- The Scripts -->
|
||||
<script src="lib/cordova-2.5.0.js"></script>
|
||||
<script src="lib/jquery-1.8.2.min.js"></script>
|
||||
<script src="lib/underscore-1.4.4.min.js"></script>
|
||||
<script src="lib/backbone-1.0.0.min.js"></script>
|
||||
<script src="js/jqm-config.js"></script>
|
||||
<script src="lib/jquery.mobile-1.2.0.min.js"></script>
|
||||
<script src="lib/lawnchair/lawnchair-git.js"></script>
|
||||
<script src="lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js"></script>
|
||||
<script src="lib/lawnchair/lawnchair-adapter-indexed-db-git.js"></script>
|
||||
|
||||
<script src="lib/forge/forge.rsa.bundle.js"></script>
|
||||
<script src="lib/uuid.js"></script>
|
||||
|
||||
<script src="js/app-config.js"></script>
|
||||
|
||||
<script src="js/model/folder-model.js"></script>
|
||||
<script src="js/model/account-model.js"></script>
|
||||
|
||||
<script src="js/crypto/util.js"></script>
|
||||
<script src="js/crypto/pbkdf2.js"></script>
|
||||
<script src="js/crypto/aes-cbc.js"></script>
|
||||
<script src="js/crypto/rsa.js"></script>
|
||||
<script src="js/crypto/crypto-batch.js"></script>
|
||||
<script src="js/crypto/crypto.js"></script>
|
||||
|
||||
<script src="js/dao/lawnchair-dao.js"></script>
|
||||
<script src="js/dao/devicestorage.js"></script>
|
||||
<script src="js/dao/cloudstorage-dao.js"></script>
|
||||
<script src="js/dao/keychain-dao.js"></script>
|
||||
<script src="js/dao/email-dao.js"></script>
|
||||
|
||||
<script src="js/view/login-view.js"></script>
|
||||
<script src="js/view/compose-view.js"></script>
|
||||
<script src="js/view/messagelist-view.js"></script>
|
||||
<script src="js/view/messagelistitem-view.js"></script>
|
||||
<script src="js/view/folderlist-view.js"></script>
|
||||
<script src="js/view/read-view.js"></script>
|
||||
|
||||
<script src="js/app-router.js"></script>
|
||||
<script src="js/app-controller.js"></script>
|
||||
<script src="mobile.js"></script>
|
||||
<script data-main="mobile.js" src="lib/require.js"></script>
|
||||
</head>
|
||||
|
||||
<body></body>
|
||||
|
@ -1,31 +1,35 @@
|
||||
(function() {
|
||||
require(['require-config'], function() {
|
||||
'use strict';
|
||||
|
||||
var controller,
|
||||
router;
|
||||
// Start the main app logic.
|
||||
require(['jquery', 'backbone', 'js/app-controller', 'js/app-router',
|
||||
'js/app-config'
|
||||
], function($, Backbone, controller, Router, app) {
|
||||
|
||||
/**
|
||||
* Load templates and start the application
|
||||
*/
|
||||
$(document).ready(function() {
|
||||
controller = new app.Controller();
|
||||
controller.init(function() {
|
||||
controller.start(startApp);
|
||||
var router;
|
||||
|
||||
/**
|
||||
* Load templates and start the application
|
||||
*/
|
||||
$(document).ready(function() {
|
||||
controller.init(function() {
|
||||
controller.start(startApp);
|
||||
});
|
||||
});
|
||||
|
||||
function startApp() {
|
||||
// start backone.js router
|
||||
router = new Router();
|
||||
Backbone.history.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method shim to ease message posting between sandbox and main window
|
||||
*/
|
||||
app.util.postMessage = function(cmd, args, callback) {
|
||||
// handle the workload in the main window
|
||||
controller.execute(cmd, args, callback);
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
function startApp() {
|
||||
// start backone.js router
|
||||
router = new app.Router();
|
||||
Backbone.history.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method shim to ease message posting between sandbox and main window
|
||||
*/
|
||||
app.util.postMessage = function(cmd, args, callback) {
|
||||
// handle the workload in the main window
|
||||
controller.execute(cmd, args, callback);
|
||||
};
|
||||
|
||||
}());
|
||||
});
|
@ -8,6 +8,7 @@
|
||||
test: '../../test',
|
||||
cryptoLib: '../js/crypto',
|
||||
jquery: 'jquery-1.8.2.min',
|
||||
jquerymobile: 'jquery.mobile-1.2.0.min',
|
||||
underscore: 'underscore-1.4.4.min',
|
||||
backbone: 'backbone-1.0.0.min',
|
||||
lawnchair: 'lawnchair/lawnchair-git',
|
||||
@ -31,6 +32,9 @@
|
||||
},
|
||||
underscore: {
|
||||
exports: '_'
|
||||
},
|
||||
jquerymobile: {
|
||||
deps: ['jquery', 'js/jqm-config']
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
define(['js/dao/email-dao', 'js/dao/keychain-dao', 'js/dao/lawnchair-dao',
|
||||
'js/dao/cloudstorage-dao'
|
||||
], function(EmailDAO, KeychainDAO, jsonDao, cloudstorage) {
|
||||
'js/dao/cloudstorage-dao', 'js/app-config'
|
||||
], function(EmailDAO, KeychainDAO, jsonDao, cloudstorage, app) {
|
||||
'use strict';
|
||||
|
||||
module("CloudStorage DAO");
|
||||
|
@ -7,7 +7,7 @@ require(['../../src/require-config'], function() {
|
||||
});
|
||||
|
||||
// Start the main app logic.
|
||||
require(['cordova', 'js/app-config'], function() {
|
||||
require(['js/app-config', 'cordova'], function(app) {
|
||||
// clear session storage of failed tests, so async order is correct after fail & refresh
|
||||
window.sessionStorage.clear();
|
||||
window.Worker = undefined;
|
||||
|
@ -1,4 +1,4 @@
|
||||
define(['cryptoLib/util', 'js/model/email-model'], function(util) {
|
||||
define(['cryptoLib/util', 'js/app-config', 'js/model/email-model'], function(util, app) {
|
||||
'use strict';
|
||||
|
||||
var self = {};
|
||||
|
@ -1,6 +1,6 @@
|
||||
define(['js/dao/email-dao', 'js/dao/keychain-dao', 'js/dao/lawnchair-dao',
|
||||
'js/crypto/crypto', 'js/dao/devicestorage-dao', 'test/test-data'
|
||||
], function(EmailDAO, KeychainDAO, jsonDao, crypto, storage, testData) {
|
||||
'js/crypto/crypto', 'js/dao/devicestorage-dao', 'test/test-data', 'js/app-config'
|
||||
], function(EmailDAO, KeychainDAO, jsonDao, crypto, storage, testData, app) {
|
||||
'use strict';
|
||||
|
||||
module("Email DAO");
|
||||
|
@ -7,7 +7,7 @@ require(['../../src/require-config'], function() {
|
||||
});
|
||||
|
||||
// Start the main app logic.
|
||||
require(['cordova', 'js/app-config'], function() {
|
||||
require(['js/app-config', 'cordova'], function(app) {
|
||||
// clear session storage of failed tests, so async order is correct after fail & refresh
|
||||
window.sessionStorage.clear();
|
||||
window.Worker = undefined;
|
||||
|
Loading…
Reference in New Issue
Block a user