1
|
/**
|
2
|
* @constructor
|
3
|
*/
|
4
|
function Sidebar() {
|
5
|
var rootElement;
|
6
|
var activeChangeElement;
|
7
|
|
8
|
/** @prop {SidebarPostponedChangeList} postponedChangeListComponent */
|
9
|
this.postponedChangeListComponent = null;
|
10
|
/** @prop {SidebarUnconnectedNodeList} unconnectedNodeListComponent */
|
11
|
this.unconnectedNodeListComponent = null;
|
12
|
/** @prop {SidebarMissingClassList} missingClassListComponent */
|
13
|
this.missingClassListComponent = null;
|
14
|
/** @prop {SidebarExcludedNodeList} excludedNodeListComponent */
|
15
|
this.excludedNodeListComponent = null;
|
16
|
/** @prop {StatusBar} statusBarComponent */
|
17
|
this.statusBarComponent = null;
|
18
|
|
19
|
var activeChange = new Change;
|
20
|
var floaterList = [];
|
21
|
|
22
|
this.getFloaters = function() {
|
23
|
return floaterList;
|
24
|
};
|
25
|
|
26
|
this.refreshFloaters = function() {
|
27
|
floaterList.forEach(function(floater) {
|
28
|
floater.setPosition();
|
29
|
});
|
30
|
};
|
31
|
|
32
|
this.addFloater = function(floater) {
|
33
|
floaterList.push(floater);
|
34
|
};
|
35
|
|
36
|
this.removeFloater = function(floater) {
|
37
|
floaterList.splice(floaterList.indexOf(floater), 1);
|
38
|
};
|
39
|
|
40
|
this.addToChange = function(node) {
|
41
|
node.removeFromSidebarList();
|
42
|
node.remove(true);
|
43
|
|
44
|
activeChange.addVertex(node);
|
45
|
};
|
46
|
|
47
|
this.setChangeActive = function(change) {
|
48
|
// postpone currently active change
|
49
|
if (activeChange.getOldVertexList().length > 0) {
|
50
|
activeChange.postpone();
|
51
|
this.postponedChangeListComponent.add(activeChange);
|
52
|
} else {
|
53
|
activeChange.remove();
|
54
|
}
|
55
|
|
56
|
change.activate();
|
57
|
activeChange = change;
|
58
|
activeChangeElement.appendChild(activeChange.render());
|
59
|
};
|
60
|
|
61
|
this.setChangePostponed = function(change) {
|
62
|
// postpone currently active change if there are some vertices in it
|
63
|
if (change.getOldVertexList().length > 0) {
|
64
|
this.postponedChangeListComponent.add(change);
|
65
|
}
|
66
|
|
67
|
// set a new active change
|
68
|
activeChange = new Change;
|
69
|
activeChangeElement.appendChild(activeChange.render());
|
70
|
};
|
71
|
|
72
|
this.render = function() {
|
73
|
rootElement = app.utils.createHtmlElement('div', {
|
74
|
'class': 'sidebar',
|
75
|
'id': 'sidebar',
|
76
|
});
|
77
|
|
78
|
|
79
|
var sidebarNav = app.utils.createHtmlElement('nav', {
|
80
|
'class': 'sidebar-navbar',
|
81
|
'id': 'uploadMenu',
|
82
|
});
|
83
|
rootElement.appendChild(sidebarNav);
|
84
|
|
85
|
// change
|
86
|
var changeButton = app.utils.createHtmlElement('button', {
|
87
|
'class': 'button',
|
88
|
'id': 'changeButton',
|
89
|
'title': 'Active change',
|
90
|
'data-tooltip': 'top',
|
91
|
});
|
92
|
changeButton.appendChild(app.dom.createHtmlElement('img', {
|
93
|
'src': 'images/tochange/crce-call-trans.gif',
|
94
|
'alt': 'Icon of "toggle active change" action',
|
95
|
}));
|
96
|
changeButton.appendChild(app.dom.createTextElement('List'));
|
97
|
changeButton.addEventListener('click', function() {
|
98
|
document.getElementById('activeChange').classList.toggle('hidden');
|
99
|
app.redrawEdges();
|
100
|
});
|
101
|
sidebarNav.appendChild(changeButton);
|
102
|
|
103
|
// postponed
|
104
|
var postponedButton = app.utils.createHtmlElement('button', {
|
105
|
'class': 'button',
|
106
|
'id': 'postponedButton',
|
107
|
'title': 'Postponed changes',
|
108
|
'data-tooltip': 'top',
|
109
|
});
|
110
|
postponedButton.appendChild(app.dom.createHtmlElement('img', {
|
111
|
'src': 'images/tochange/postpone-trans.gif',
|
112
|
'alt': 'Icon of "toggle postponed changes list" action',
|
113
|
}));
|
114
|
postponedButton.appendChild(app.dom.createTextElement('List'));
|
115
|
postponedButton.addEventListener('click', function() {
|
116
|
document.getElementById('postponedChangeListComponent').classList.toggle('hidden');
|
117
|
app.redrawEdges();
|
118
|
});
|
119
|
sidebarNav.appendChild(postponedButton);
|
120
|
|
121
|
// unconnected
|
122
|
var unconnectedButton = app.utils.createHtmlElement('button', {
|
123
|
'class': 'button',
|
124
|
'id': 'unconnectedButton',
|
125
|
'title': 'Unconnected components',
|
126
|
'data-tooltip': 'top',
|
127
|
});
|
128
|
unconnectedButton.appendChild(app.dom.createHtmlElement('img', {
|
129
|
'src': 'images/tochange/unconnected.gif',
|
130
|
'alt': 'Icon of "toggle unconnected components list" action',
|
131
|
}));
|
132
|
unconnectedButton.appendChild(app.dom.createTextElement('List'));
|
133
|
unconnectedButton.addEventListener('click', function() {
|
134
|
document.getElementById('unconnectedNodeListComponent').classList.toggle('hidden');
|
135
|
app.redrawEdges();
|
136
|
});
|
137
|
sidebarNav.appendChild(unconnectedButton);
|
138
|
|
139
|
// missing
|
140
|
var missingButton = app.utils.createHtmlElement('button', {
|
141
|
'class': 'button',
|
142
|
'id': 'missingButton',
|
143
|
'title': 'Missing classes',
|
144
|
'data-tooltip': 'top-left',
|
145
|
});
|
146
|
missingButton.appendChild(app.dom.createHtmlElement('img', {
|
147
|
'src': 'images/tochange/accept-trans.gif',
|
148
|
'alt': 'Icon of "toggle missing classes list" action',
|
149
|
}));
|
150
|
missingButton.appendChild(app.dom.createTextElement('List'));
|
151
|
missingButton.addEventListener('click', function() {
|
152
|
document.getElementById('missingClassListComponent').classList.toggle('hidden');
|
153
|
app.redrawEdges();
|
154
|
});
|
155
|
sidebarNav.appendChild(missingButton);
|
156
|
|
157
|
|
158
|
var sidebarContainer = app.utils.createHtmlElement('div', {
|
159
|
'class': 'sidebar-container',
|
160
|
});
|
161
|
rootElement.appendChild(sidebarContainer);
|
162
|
|
163
|
// active change
|
164
|
activeChangeElement = app.utils.createHtmlElement('div', {
|
165
|
'id': 'activeChange',
|
166
|
'class': 'node-container change-nodes',
|
167
|
});
|
168
|
activeChangeElement.appendChild(app.dom.htmlStringToElement('<h2 class="node-container-title">Active change</h2>'));
|
169
|
activeChangeElement.appendChild(activeChange.render());
|
170
|
|
171
|
sidebarContainer.appendChild(activeChangeElement);
|
172
|
|
173
|
// postponed changes
|
174
|
this.postponedChangeListComponent = new SidebarPostponedChangeList({
|
175
|
'id': 'postponedChangeListComponent',
|
176
|
'class': 'hidden',
|
177
|
});
|
178
|
sidebarContainer.appendChild(this.postponedChangeListComponent.render());
|
179
|
|
180
|
// unconnected components
|
181
|
this.unconnectedNodeListComponent = new SidebarUnconnectedNodeList({
|
182
|
'id': 'unconnectedNodeListComponent',
|
183
|
'class': 'hidden',
|
184
|
});
|
185
|
sidebarContainer.appendChild(this.unconnectedNodeListComponent.render());
|
186
|
|
187
|
// missing classes
|
188
|
this.missingClassListComponent = new SidebarMissingComponentList({
|
189
|
'id': 'missingClassListComponent',
|
190
|
'class': 'hidden',
|
191
|
});
|
192
|
sidebarContainer.appendChild(this.missingClassListComponent.render());
|
193
|
|
194
|
|
195
|
// excluded nodes
|
196
|
this.excludedNodeListComponent = new SidebarExcludedNodeList({
|
197
|
'id': 'excludedNodeListComponent',
|
198
|
});
|
199
|
rootElement.appendChild(this.excludedNodeListComponent.render());
|
200
|
|
201
|
|
202
|
// status bar
|
203
|
this.statusBarComponent = new StatusBar;
|
204
|
rootElement.appendChild(this.statusBarComponent.render());
|
205
|
|
206
|
|
207
|
return rootElement;
|
208
|
};
|
209
|
|
210
|
this.reset = function() {
|
211
|
// remove active change
|
212
|
activeChange.remove();
|
213
|
|
214
|
// set a new active change
|
215
|
activeChange = new Change;
|
216
|
activeChangeElement.appendChild(activeChange.render());
|
217
|
|
218
|
// reset lists
|
219
|
this.postponedChangeListComponent.reset();
|
220
|
this.unconnectedNodeListComponent.reset();
|
221
|
this.missingClassListComponent.reset();
|
222
|
this.excludedNodeListComponent.reset();
|
223
|
|
224
|
// reset status bar
|
225
|
this.statusBarComponent.reset();
|
226
|
};
|
227
|
}
|