-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUserControlViews.js
168 lines (156 loc) · 4.3 KB
/
UserControlViews.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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// Expects to be bound to the state model
var TotalTermsView = Backbone.View.extend({
el : 'div.TotalTermsView',
render : function()
{
d3.select(this.el).text( this.model.get("totalTerms") );
}
});
// Affinity Number Terms
// Need to bound to the state model
var AffinityNumTermsView = Backbone.View.extend({
el : 'div.AffinityNumTermsView',
render : function()
{
d3.select(this.el).text( this.model.get("numAffinityTerms") );
}
});
// Expects to be bound to the state model
var AffinityNumTermsSlider = Backbone.View.extend({
el : 'input.AffinityNumTermsSlider',
events : {
'change' : function(e) {
this.model.set("numAffinityTerms", parseInt(e.target.value));
}
},
initialize : function() {
this.model.on( "change:numAffinityTerms", function(value) {
d3.select(this.el)[0][0].value = this.model.get("numAffinityTerms");
}, this);
}
});
// Salient Number Terms
// Expects to be bound to the state model
var SalientNumTermsView = Backbone.View.extend({
el : 'div.SalientNumTermsView',
render : function()
{
d3.select(this.el).text( this.model.get("numSalientTerms") );
}
});
// Expects to be bound to the state model
var SalientNumTermsSlider = Backbone.View.extend({
el: 'input.SalientNumTermsSlider',
events : {
'change' : function(e) {
this.model.set("numSalientTerms", parseInt(e.target.value));
}
},
initialize : function() {
this.model.on( "change:numSalientTerms", function(value) {
d3.select(this.el)[0][0].value = this.model.get("numSalientTerms");
}, this);
}
});
// User Defined Terms
// Expects to be bound to the state model
var FoundTermsView = Backbone.View.extend({
el : 'div.FoundTermsView',
render : function()
{
d3.select(this.el).text( this.model.get("foundTerms"));
}
});
// Expects to be bound to the state model
var UnfoundTermsView = Backbone.View.extend({
el: 'div.UnfoundTermsView',
prefix: 'div.UnfoundTermsPrefix',
render : function()
{
if( this.model.get("unfoundTerms") !== ""){
d3.select( this.prefix ).style("visibility", "visible");
d3.select( this.el ).style("visibility", "visible").text( this.model.get("unfoundTerms"));
} else {
d3.select( this.prefix ).style("visibility", "hidden");
d3.select( this.el ).style("visibility", "hidden");
}
}
});
// Expects to be bound to the state model
var UserDefinedTermsBox = Backbone.View.extend({
el: 'input.UserDefinedTermsBox',
events : {
'keyup' : function(e) {
this.model.setVisibleTerms(e.target.value);
}
},
initialize : function() {
this.model.on( "change:visibleTerms", function(value) {
d3.select(this.el)[0][0].value = this.model.get("visibleTerms").join(", ");
}, this);
}
});
// Expects to be bound to the state model
var AddTopTwenty = Backbone.View.extend({
el: 'input.TopTwentyAddition',
events : {
'change' : function(e) {
this.model.set("addTopTwenty", e.target.checked);
}
},
initialize : function() {
this.model.on( "change:addTopTwenty", function(value) {
d3.select(this.el)[0][0].checked = this.model.get("addTopTwenty");
}, this);
}
});
// Expects to be bound to the state model
var SortDescription = Backbone.View.extend({
el: 'div.SortDescription',
render : function()
{
var sort = this.model.get("sortType");
var topic = this.model.get("doubleClickTopic");
var output = "";
if( sort === "" )
output = "default";
else if (sort === "asc")
output = "ascending on topic #" + topic;
else
output = "descending on topic #" + topic;
d3.select(this.el).text( output );
},
initialize : function() {
// TODO: call render's function?
this.model.on( "change:sortType change:doubleClickTopic", function(value) {
var sort = this.model.get("sortType");
var topic = this.model.get("doubleClickTopic");
var output = "";
if( sort === "" )
output = "default";
else if (sort === "asc")
output = "ascending on topic #" + topic;
else
output = "descending on topic #" + topic;
d3.select(this.el).text( output );
}, this);
}
});
// Expects to be bound to the state model
var ClearAllButton = Backbone.View.extend({
el: 'button.clearAll',
events : {
'click' : function(e) {
this.model.clearAllSelectedTopics();
}
}
});
// Expects to be bound to the state model
var ClearSortButton = Backbone.View.extend({
el: 'button.clearSort',
events : {
'click' : function(e) {
this.model.clearSorting();
}
}
});