forked from willeeklund/JavaScriptForAnalysts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemailApp.js
More file actions
77 lines (70 loc) · 2.14 KB
/
Copy pathemailApp.js
File metadata and controls
77 lines (70 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* Common config part for all pages
*/
requirejs.config({
baseUrl: 'js/',
paths: {
jquery: 'lib/jquery',
underscore: 'lib/underscore',
backbone: 'lib/backbone',
jquery_serializeObject: 'lib/jquery.serializeObject'
},
shim: {
'backbone': {
//These script dependencies should be loaded before loading
//backbone.js
deps: ['underscore', 'jquery'],
//Once loaded, use the global 'Backbone' as the
//module value.
exports: 'Backbone'
},
'jquery_serializeObject': {
deps: ['jquery']
}
}
});
/**
* Start JS for this specific page
*/
requirejs(
['jquery',
'underscore',
'collections/emails',
'models/email',
'views/EmailList',
'views/EmailItem',
'views/ReadEmail',
// Unnamed
'backbone'],
function ($, _, EmailCollection, EmailModel, EmailListView, EmailItemView, ReadEmailView) {
// Run when ready
$(function () {
console.info("Starting EmailApp.js");
_.templateSettings = { interpolate : /\{\{(.+?)\}\}/g };
var emailCollection = new EmailCollection();
emailCollection.add(new EmailModel({
title: 'Köp mjölk!',
text: 'Donec id elit non mi porta gravida at eget metus. Maecenas faucibus mollis interdum.'+
'Maecenas sed diam eget risus varius blandit sit amet non magna.',
sender: 'Cissi',
receiver: 'Wille'
}));
emailCollection.add(new EmailModel({
title: 'Fanns ingen mjölk...',
text: 'Nullam id dolor id nibh ultricies vehicula ut id elit.'+
'Praesent commodo cursus magna, vel scelerisque nisl consectetur et.'+
'Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.'+
'Maecenas sed diam eget risus varius blandit sit amet non magna. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.',
sender: 'Cissi',
receiver: 'Wille'
}));
console.log("emailCollection", emailCollection.toJSON());
var emailListView = new EmailListView({
collection: emailCollection
});
// @todo skicka in en email model
var activeEmail = new ReadEmailView({
collection: emailCollection
});
});
});