1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00
phorge-phorge/webroot/rsrc/js/phuix/PHUIXExample.js

66 lines
1.2 KiB
JavaScript
Raw Normal View History

/**
* @provides javelin-behavior-phuix-example
* @requires javelin-install
* javelin-dom
* phuix-button-view
*/
JX.behavior('phuix-example', function(config) {
var node;
var spec;
var defaults;
switch (config.type) {
case 'button':
var button = new JX.PHUIXButtonView();
defaults = {
text: null,
icon: null,
type: null,
color: null
};
spec = JX.copy(defaults, config.spec);
if (spec.text !== null) {
button.setText(spec.text);
}
if (spec.icon !== null) {
button.setIcon(spec.icon);
}
if (spec.type !== null) {
button.setButtonType(spec.type);
}
if (spec.color !== null) {
button.setColor(spec.color);
}
node = button.getNode();
break;
case 'icon':
var icon = new JX.PHUIXIconView();
defaults = {
icon: null,
color: null
};
spec = JX.copy(defaults, config.spec);
if (spec.icon !== null) {
icon.setIcon(spec.icon);
}
if (spec.color !== null) {
icon.setColor(spec.color);
}
node = icon.getNode();
break;
}
JX.DOM.setContent(JX.$(config.id), node);
});