1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-25 10:22:18 -05:00

add ngtouch to angular app, remove all backbone deps and models code

This commit is contained in:
Tankred Hase 2013-09-04 19:18:28 +02:00
parent 0e3340c586
commit 1259d0c160
12 changed files with 23 additions and 157 deletions

View File

@ -5,7 +5,6 @@ define([], function() {
* Create the application namespace * Create the application namespace
*/ */
var app = { var app = {
model: {},
util: {} util: {}
}; };

View File

@ -1,10 +1,10 @@
// hey Angular, we're bootstrapping manually! // hey Angular, we're bootstrapping manually!
window.name = 'NG_DEFER_BOOTSTRAP!'; window.name = 'NG_DEFER_BOOTSTRAP!';
require(['angular', 'js/controller/message-list', 'angularRoute', 'js/app-config'], function(angular, MessageListCtrl) { require(['angular', 'js/controller/message-list', 'angularRoute', 'angularTouch', 'js/app-config'], function(angular, MessageListCtrl) {
'use strict'; 'use strict';
var app = angular.module('mail', ['ngRoute']); var app = angular.module('mail', ['ngRoute', 'ngTouch']);
app.config(function($routeProvider) { app.config(function($routeProvider) {
$routeProvider.when('/', { $routeProvider.when('/', {
templateUrl: 'tpl/message-list.html', templateUrl: 'tpl/message-list.html',

View File

@ -1,27 +0,0 @@
define(['backbone', 'js/app-config', 'js/model/folder-model'], function(Backbone, app) {
'use strict';
app.model.Account = Backbone.Model.extend({
defaults: {
emailAddress: null,
symKeySize: null,
symIvSize: null,
ssymKeySize: null,
folders: null
},
initialize: function() {
this.set('folders', new app.model.FolderCollection());
}
});
app.model.AccountCollection = Backbone.Collection.extend({
model: app.model.Account
});
return app.model.Account;
});

View File

@ -1,27 +0,0 @@
define(['backbone', 'js/app-config'], function(Backbone, app) {
'use strict';
app.model.Email = Backbone.Model.extend({
defaults: {
id: null,
from: null,
to: [],
cc: [],
bcc: [],
subject: null,
body: null,
sentDate: null
},
initialize: function() {}
});
app.model.EmailCollection = Backbone.Collection.extend({
model: app.model.Email
});
});

View File

@ -1,21 +0,0 @@
define(['backbone', 'js/app-config'], function(Backbone, app) {
'use strict';
app.model.Folder = Backbone.Model.extend({
defaults: {
name: null,
items: null
},
initialize: function() {}
});
app.model.FolderCollection = Backbone.Collection.extend({
model: app.model.Folder
});
});

View File

@ -1,23 +0,0 @@
define(['backbone', 'js/app-config'], function(Backbone, app) {
'use strict';
app.model.PrivateKey = Backbone.Model.extend({
defaults: {
_id: null,
userId: null,
encryptedKey: null,
iv: null
},
initialize: function() {}
});
app.model.PrivateKeyCollection = Backbone.Collection.extend({
model: app.model.PrivateKey
});
});

View File

@ -1,22 +0,0 @@
define(['backbone', 'js/app-config'], function(Backbone, app) {
'use strict';
app.model.PublicKey = Backbone.Model.extend({
defaults: {
_id: null,
userId: null,
publicKey: null
},
initialize: function() {}
});
app.model.PublicKeyCollection = Backbone.Collection.extend({
model: app.model.PublicKey
});
});

View File

@ -8,9 +8,7 @@
test: '../../test', test: '../../test',
cryptoLib: '../js/crypto', cryptoLib: '../js/crypto',
jquery: 'jquery-1.8.2.min', jquery: 'jquery-1.8.2.min',
jquerymobile: 'jquery.mobile-1.2.0.min',
underscore: 'underscore-1.4.4.min', underscore: 'underscore-1.4.4.min',
backbone: 'backbone-1.0.0.min',
lawnchair: 'lawnchair/lawnchair-git', lawnchair: 'lawnchair/lawnchair-git',
lawnchairSQL: 'lawnchair/lawnchair-adapter-webkit-sqlite-git', lawnchairSQL: 'lawnchair/lawnchair-adapter-webkit-sqlite-git',
lawnchairIDB: 'lawnchair/lawnchair-adapter-indexed-db-git', lawnchairIDB: 'lawnchair/lawnchair-adapter-indexed-db-git',
@ -18,7 +16,8 @@
ImapClient: 'imap-client-browserified', ImapClient: 'imap-client-browserified',
SmtpClient: 'smtp-client-browserified', SmtpClient: 'smtp-client-browserified',
angular: 'angular/angular.min', angular: 'angular/angular.min',
angularRoute: 'angular/angular-route.min' angularRoute: 'angular/angular-route.min',
angularTouch: 'angular/angular-touch.min'
}, },
shim: { shim: {
angular: { angular: {
@ -28,6 +27,10 @@
exports: 'angular', exports: 'angular',
deps: ['angular'] deps: ['angular']
}, },
angularTouch: {
exports: 'angular',
deps: ['angular']
},
lawnchair: { lawnchair: {
exports: 'Lawnchair' exports: 'Lawnchair'
}, },
@ -37,20 +40,10 @@
lawnchairIDB: { lawnchairIDB: {
deps: ['lawnchair', 'lawnchairSQL'] deps: ['lawnchair', 'lawnchairSQL']
}, },
backbone: {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
underscore: { underscore: {
exports: '_' exports: '_'
},
jquerymobile: {
deps: ['jquery', 'js/jqm-config']
} }
}, }
priority: [
"angular"
]
}); });
}()); }());

View File

@ -1,24 +1,24 @@
define(['cryptoLib/util', 'js/app-config', 'js/model/email-model'], function(util, app) { define(['cryptoLib/util', 'js/app-config'], function(util) {
'use strict'; 'use strict';
var self = {}; var self = {};
self.getEmailCollection = function(size) { self.getEmailCollection = function(size) {
// create test data // create test data
var i, mail, collection = new app.model.EmailCollection(), var i, mail, collection = [],
bigAssString = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet,'; bigAssString = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet,';
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
mail = new app.model.Email({ mail = {
id: i + '', id: i + '',
from: 'john@from.com', from: 'john@from.com',
to: ['jack@to.com'], to: ['jack@to.com'],
subject: 'Important stuff ' + i, subject: 'Important stuff ' + i,
sentDate: (1971 + i) + '-03-13 18:17:53', sentDate: (1971 + i) + '-03-13 18:17:53',
body: bigAssString body: bigAssString
}); };
collection.add(mail); collection.push(mail);
} }
return collection; return collection;

View File

@ -58,10 +58,7 @@ define(['js/crypto/crypto', 'cryptoLib/util', 'test/test-data'], function(crypto
asyncTest("AES/HMAC encrypt batch (Async/Worker)", 2, function() { asyncTest("AES/HMAC encrypt batch (Async/Worker)", 2, function() {
// generate test data // generate test data
var collection; cryptoTest.symlist = testData.getEmailCollection(10);
collection = testData.getEmailCollection(10);
cryptoTest.symlist = collection.toJSON();
crypto.symEncryptList(cryptoTest.symlist, function(err, result) { crypto.symEncryptList(cryptoTest.symlist, function(err, result) {
ok(!err && result.key && result.list && result.list[0].hmac, 'Encrypt list for user'); ok(!err && result.key && result.list && result.list[0].hmac, 'Encrypt list for user');
@ -89,10 +86,7 @@ define(['js/crypto/crypto', 'cryptoLib/util', 'test/test-data'], function(crypto
asyncTest("AES/RSA encrypt batch for User (Async/Worker)", 2, function() { asyncTest("AES/RSA encrypt batch for User (Async/Worker)", 2, function() {
// generate test data // generate test data
var collection; cryptoTest.list = testData.getEmailCollection(10);
collection = testData.getEmailCollection(10);
cryptoTest.list = collection.toJSON();
var receiverPubkeys = [cryptoTest.generatedKeypair.publicKey]; var receiverPubkeys = [cryptoTest.generatedKeypair.publicKey];

View File

@ -1,5 +1,5 @@
define(['underscore', 'cryptoLib/util', 'js/crypto/crypto', 'js/dao/lawnchair-dao', define(['underscore', 'cryptoLib/util', 'js/crypto/crypto', 'js/dao/lawnchair-dao',
'js/dao/devicestorage-dao', 'test/test-data' 'js/dao/devicestorage-dao', 'test/test-data'
], function(_, util, crypto, jsonDao, storage, testData) { ], function(_, util, crypto, jsonDao, storage, testData) {
'use strict'; 'use strict';
@ -19,7 +19,7 @@ define(['underscore', 'cryptoLib/util', 'js/crypto/crypto', 'js/dao/lawnchair-da
ok(storage, 'DeviceStorageDAO'); ok(storage, 'DeviceStorageDAO');
// generate test data // generate test data
devicestorageTest.list = testData.getEmailCollection(100).toJSON(); devicestorageTest.list = testData.getEmailCollection(100);
// init crypto // init crypto
crypto.init({ crypto.init({

View File

@ -1,5 +1,5 @@
define(['js/dao/email-dao', 'js/dao/keychain-dao', 'js/dao/lawnchair-dao', define(['js/dao/email-dao', 'js/dao/keychain-dao', 'js/dao/lawnchair-dao',
'js/crypto/crypto', 'js/dao/devicestorage-dao', 'test/test-data', 'js/app-config' 'js/crypto/crypto', 'js/dao/devicestorage-dao', 'test/test-data', 'js/app-config'
], function(EmailDAO, KeychainDAO, jsonDao, crypto, storage, testData, app) { ], function(EmailDAO, KeychainDAO, jsonDao, crypto, storage, testData, app) {
'use strict'; 'use strict';
@ -60,13 +60,13 @@ define(['js/dao/email-dao', 'js/dao/keychain-dao', 'js/dao/lawnchair-dao',
var receiverPubkeys = [keypair.publicKey]; var receiverPubkeys = [keypair.publicKey];
crypto.encryptListForUser(emaildaoTest.list.toJSON(), receiverPubkeys, function(err, encryptedList) { crypto.encryptListForUser(emaildaoTest.list, receiverPubkeys, function(err, encryptedList) {
ok(!err); ok(!err);
equal(encryptedList.length, emaildaoTest.list.length, 'Encrypt list'); equal(encryptedList.length, emaildaoTest.list.length, 'Encrypt list');
// add sent date to encrypted items // add sent date to encrypted items
for (var i = 0; i < encryptedList.length; i++) { for (var i = 0; i < encryptedList.length; i++) {
encryptedList[i].sentDate = emaildaoTest.list.at(i).get('sentDate'); encryptedList[i].sentDate = emaildaoTest.list[i].sentDate;
} }
// set encrypted test list as return value for cloud storage stub // set encrypted test list as return value for cloud storage stub
@ -87,7 +87,7 @@ define(['js/dao/email-dao', 'js/dao/keychain-dao', 'js/dao/lawnchair-dao',
emaildaoTest.emailDao.listItems('inbox', 0, emaildaoTest.list.length, function(err, gotten) { emaildaoTest.emailDao.listItems('inbox', 0, emaildaoTest.list.length, function(err, gotten) {
ok(!err); ok(!err);
var reference = emaildaoTest.list.toJSON(); var reference = emaildaoTest.list;
deepEqual(gotten, reference, 'Compare collection'); deepEqual(gotten, reference, 'Compare collection');
@ -96,7 +96,7 @@ define(['js/dao/email-dao', 'js/dao/keychain-dao', 'js/dao/lawnchair-dao',
}); });
asyncTest("Get item", 1, function() { asyncTest("Get item", 1, function() {
var item = emaildaoTest.list.toJSON()[0]; var item = emaildaoTest.list[0];
var mail = emaildaoTest.emailDao.getItem('inbox', item.id); var mail = emaildaoTest.emailDao.getItem('inbox', item.id);
deepEqual(mail, item, 'Item correct'); deepEqual(mail, item, 'Item correct');
start(); start();