-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask.jsx
More file actions
77 lines (62 loc) · 2.18 KB
/
Copy pathTask.jsx
File metadata and controls
77 lines (62 loc) · 2.18 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
// Task component - represents a single todo item
Task = React.createClass({
propTypes: {
task: React.PropTypes.object.isRequired,
showPrivateButton: React.PropTypes.bool.isRequired
},
toggleChecked() {
// Set the checked property to the opposite of its current value
Meteor.call("setChecked", this.props.task._id, ! this.props.task.checked);
},
deleteThisTask() {
Meteor.call("removeTask", this.props.task._id);
},
createMarkup() {
return {__html: '<strong>MMM</strong>'};
},
togglePrivate() {
Meteor.call("setPrivate", this.props.task._id, ! this.props.task.private);
},
createIntTag(tagStr) {
var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.setAttribute("data-key", "int-scr-loader");
script.setAttribute("src", tagStr);
this.refs.intContainer.appendChild(script);
// document.getElementsByTagName("int1")[0].appendChild(script);
},
render() {
// Give tasks a different className when they are checked off,
// so that we can style them nicely in CSS
// Add "checked" and/or "private" to the className when needed
const taskClassName = (this.props.task.checked ? "checked" : "") + " " +
(this.props.task.private ? "private" : "");
return (
<div>
{ this.props.showPrivateButton ? (
<button className="delete" onClick={this.deleteThisTask}>
×
</button>
) : ''}
<div className="author">
Task publisher: <strong>{this.props.task.username}</strong>
complete:
<input
type="checkbox"
readOnly={true}
checked={this.props.task.checked}
onClick={this.toggleChecked} />
{ this.props.showPrivateButton ? (
<button className="toggle-private" onClick={this.togglePrivate}>
{ this.props.task.private ? "Publish it" : "Make private" }
</button>
) : ''}
</div>
<div ref="intContainer" dangerouslySetInnerHTML={{__html: ''}}/>
</div>
);
},
componentDidMount:function(){
this.createIntTag(this.props.task.text);
}
});