-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTask.js
50 lines (40 loc) · 1 KB
/
Task.js
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
function Task(title, id, done) {
this.title = title || "";
this.done = done || false;
this.id = id;
}
Task.prototype.setDone = function () {
this.done = true;
}
Task.prototype.setUndone = function () {
this.done = false;
}
Task.prototype.toJSON = function() {
return {title:this.title, done:this.done};
}
Task.prototype.render = function () {
var $markup;
var $open = $('<i>',
{
class: "fa fa-clone"
});
var $closed = $('<i>',
{
class: "fa fa-check"
});
var $done = $('<span>',
{
class: 'checkit',
}).html((this.done) ? $closed : $open);
var $title = $('<span>', {
contenteditable: true,
class: "tsk-tit"
}).text(this.title);
$markup = $('<li>', {
class: "alert",
id: "task-" + this.id
}).append([$done, $title]);
$markup.addClass((this.done) ? "alert-success" : "alert-danger");
$markup.data("checked", this.done);
return $markup;
}