-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoolbar.js
More file actions
115 lines (91 loc) · 3.25 KB
/
toolbar.js
File metadata and controls
115 lines (91 loc) · 3.25 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
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
var oojs = (function (oojs) {
var createToolbarItems = function (itemElements) {
var items = [];
[].forEach.call(itemElements, function (el, index, array) {
var item = {
toggleActiveState: function () {
this.activated = !this.activated;
}
};
Object.defineProperties(item, {
el: {
value: el
},
enabled: {
get: function () {
return !this.el.classList.contains("disabled");
},
set: function (value) {
if (value) {
this.el.classList.remove("disabled");
} else {
this.el.classList.add("disabled");
}
}
},
activated: {
get: function () {
return this.el.classList.contains("active");
},
set: function (value) {
if (value) {
this.el.classList.add("active");
} else {
this.el.classList.remove("active");
}
}
}
});
//var item = {
// el: el,
// disable: function () {
// this.el.classList.add("disabled");
// },
// enable: function () {
// this.el.classList.remove("disabled");
// },
// isDisabled: function () {
// return this.el.classList.contains("disabled");
// },
// activate: function () {
// if (this.isDisabled()) {
// return;
// }
// this.el.classList.add("active");
// },
// deactivate: function () {
// if (this.isDisabled()) {
// return;
// }
// this.el.classList.remove("active");
// },
// isActive: function () {
// return this.el.classList.contains("active");
// },
// toggleActiveState: function () {
// if (this.isActive()) {
// this.deactivate();
// } else {
// this.activate();
// }
// }
//};
items.push(item);
});
return items;
};
oojs.createToolbar = function (elementId) {
var element = document.getElementById(elementId);
var items = element.querySelectorAll(".toolbar-item");
return {
items: createToolbarItems(items)
};
};
return oojs;
}(oojs || {}));
//var toolbar = oojs.createToolbar("myToolbar");
//var toolbarItem = toolbar.items[0];
//toolbarItem.setEnabled(true); //or false
//toolbarItem.getEnabled();
//toolbarItem.enabled = true; // or false
//var enabled = toolbarItem.enabled;