Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/webroot/rsrc/js/phuix/PHUIXExample.js
12241 views
1
/**
2
* @provides javelin-behavior-phuix-example
3
* @requires javelin-install
4
* javelin-dom
5
* phuix-button-view
6
*/
7
8
JX.behavior('phuix-example', function(config) {
9
var node;
10
var spec;
11
var defaults;
12
13
switch (config.type) {
14
case 'button':
15
var button = new JX.PHUIXButtonView();
16
defaults = {
17
text: null,
18
icon: null,
19
type: null,
20
color: null
21
};
22
23
spec = JX.copy(defaults, config.spec);
24
25
if (spec.text !== null) {
26
button.setText(spec.text);
27
}
28
29
if (spec.icon !== null) {
30
button.setIcon(spec.icon);
31
}
32
33
if (spec.type !== null) {
34
button.setButtonType(spec.type);
35
}
36
37
if (spec.color !== null) {
38
button.setColor(spec.color);
39
}
40
41
node = button.getNode();
42
break;
43
case 'icon':
44
var icon = new JX.PHUIXIconView();
45
defaults = {
46
icon: null,
47
color: null
48
};
49
50
spec = JX.copy(defaults, config.spec);
51
52
if (spec.icon !== null) {
53
icon.setIcon(spec.icon);
54
}
55
56
if (spec.color !== null) {
57
icon.setColor(spec.color);
58
}
59
60
node = icon.getNode();
61
break;
62
}
63
64
JX.DOM.setContent(JX.$(config.id), node);
65
});
66
67