-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathend-result-basics.html
127 lines (106 loc) · 3.24 KB
/
end-result-basics.html
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><Ember></Ember> Ember Mail</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<script src="js/libs/jquery-1.9.1.js"></script>
<script src="js/libs/handlebars-1.0.0-rc.3.js"></script>
<script src="js/libs/ember-1.0.0-rc.3.js"></script>
<script type="text/javascript">
App = Ember.Application.create({
selectEmail: function (email) {
this.set('previewedEmail', email);
email.set('isRead', true);
}
});
var User = Ember.Object.extend({
name: function () {
return this.get('lastName') + ', ' + this.get('firstName');
}.property('firstName', 'lastName'),
emails: [],
noEmails: function () {
return this.get('emails.length') === 0;
}.property('emails.@each'),
unreadCount: function () {
return this.get('emails').filterProperty('isRead', false).length;
}.property('[email protected]')
});
var newUser = User.create({
firstName: 'Moran',
lastName: 'Fine'
});
App.set('user', newUser);
newUser.set('emails', [
Ember.Object.create({
from: '[email protected]',
title: 'free viagra',
description: 'well, it is not really free',
isRead: false,
sentAt: new Date()
}),
Ember.Object.create({
from: '[email protected]',
title: 'title 2',
description: 'description 2',
isRead: true,
sentAt: new Date()
}),
Ember.Object.create({
from: '[email protected]',
title: 'title 3',
description: 'description 3',
isRead: true,
sentAt: new Date()
})
]);
</script>
<script type="text/x-handlebars" data-template-name="application">
<header>
<span class="app-name">
Ember Mail
</span>
<span class="emails-count">
{{App.user.emails.length}} emails ({{App.user.unreadCount}} unread)
</span>
<span class="user">
{{App.user.name}}
</span>
</header>
<div class="inbox">
{{#if App.user.noEmails}}
sorry, no emails
{{else}}
<ul class="emails">
{{#each App.user.emails}}
<li {{bindAttr class=":email-summary this.isRead::highlight"}} {{action selectEmail this target="App"}}>
<span class="title">
{{this.title}}
</span>
<div class="from">
{{this.from}}
</div>
</li>
{{/each}}
</ul>
{{/if}}
</div>
{{#if App.previewedEmail}}
<div class="previewed-email">
<div class="preview-caption">
Preview
</div>
<div class="preview-title">
{{App.previewedEmail.title}}:
</div>
<div class="preview-description">
{{App.previewedEmail.description}}
</div>
</div>
{{/if}}
</script>
</body>
</html>