-
Notifications
You must be signed in to change notification settings - Fork 1
/
UI-plugin.js
48 lines (36 loc) · 950 Bytes
/
UI-plugin.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
/**
* Olives http://flams.github.com/olives
* The MIT License (MIT)
* Copyright (c) 2012 Olivier Scherrer <pode.fr@gmail.com> - Olivier Wietrich <olivier.wietrich@gmail.com>
*/
define("Olives/UI-plugin",
["Olives/OObject", "Tools"],
function (OObject, Tools) {
return function TypePluginConstructor($uis) {
var _uis = {};
this.place = function place(node, name) {
if (_uis[name] instanceof OObject) {
_uis[name].place(node);
} else {
throw new Error(name + " is not an OObject UI in place:"+name);
}
};
this.set = function set(name, ui) {
if (typeof name == "string" && ui instanceof OObject) {
_uis[name] = ui;
return true;
} else {
return false;
}
};
this.setAll = function setAll(uis) {
Tools.loop(uis, function (ui, name) {
this.set(name, ui);
}, this);
};
this.get = function get(name) {
return _uis[name];
};
this.setAll($uis);
};
});