-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtodo.tag
55 lines (40 loc) · 1.02 KB
/
todo.tag
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
<todo>
<h3>{ opts.title }</h3>
<ul>
<li each={ items }>
<label class={ completed: done }>
<input type="checkbox" checked={ done } onclick={ parent.toggle }> { title }
</label>
</li>
</ul>
<form onsubmit={ add }>
<input name="input" onkeyup={ edit }>
<button disabled={ !text }>Add #{ items.length + 1 }</button>
</form>
<button disabled={ !items.length } onclick={ action('todo_remove') }>Remove</button>
this.mixin('tsore');
var self = this
self.disabled = true
self.items = []
this.attach('todos_changed', 'TodoStore', function(store,items) {
self.items = items;
});
self.on('mount', function() {
tsore.action('todo_init')
});
// Register a listener for store change events.
edit(e) {
self.text = e.target.value
}
add(e) {
if (self.text) {
tsore.action('todo_add', { title: self.text });
self.text = self.input.value = '';
}
};
toggle(e) {
var item = e.item;
item.done = !item.done;
return true;
};
</todo>