-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmodifier.js
More file actions
85 lines (64 loc) · 1.8 KB
/
Copy pathmodifier.js
File metadata and controls
85 lines (64 loc) · 1.8 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
78
79
80
81
82
83
84
85
var Modifier = function(name) {
this.name = name;
this.active = new BoolProperty("Active", true);
this.params = [];
}
Modifier.prototype.begin = function() {
}
Modifier.prototype.update = function() {
}
Modifier.prototype.end = function() {
}
Modifier.prototype.gui = function() {
}
Modifier.prototype.editor = function() {
}
Modifier.prototype.addParam = function(param) {
this.params.push(param)
return param;
}
Modifier.prototype.createGui = function() {
var menu = document.getElementById('menu');
var modifier = createDiv('');
modifier.addClass("modifier");
modifier.parent(menu);
var title = createDiv('');
title.addClass('modifier_title')
title.parent(modifier);
var arrow = createDiv('');
arrow.addClass('arrow rotate');
arrow.attribute("onclick", "closeAndOpen(this)");
arrow.parent(title);
var checkbox = createCheckbox('', this.active.value);
checkbox.style("float", "left");
checkbox.parent(title);
this.active.setInput(checkbox);
var name = createDiv(this.name);
name.parent(title);
var content = createDiv('');
content.addClass('modifier_content')
content.parent(modifier);
for(var i = 0; i < this.params.length; i++) {
var param = this.params[i].getDiv();
param.parent(content);
}
}
Modifier.prototype.setActive = function(active) {
this.active.setValue(active);
}
Modifier.prototype.updateParams = function() {
this.active.update();
for(var i = 0; i < this.params.length; i++) {
this.params[i].update();
}
}
function closeAndOpen(d){
var content = d.parentElement.parentElement.getElementsByClassName("modifier_content")[0];
if(d.className === "arrow"){
d.setAttribute("class", "arrow rotate");
content.setAttribute("class", "modifier_content");
} else {
d.setAttribute("class", "arrow");
content.setAttribute("class", "modifier_content hidden");
}
}