mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 09:12:41 +01:00
683647f1fb
Summary: Ref T12733. Ref M1476. This adds `PHUIXButtonView`, for client-side button rendering. It also adds a PHUIX example which renders the server and client versions of each component side-by-side so it's easier to see if they're messed up. Test Plan: {F4984128} Reviewers: chad Reviewed By: chad Maniphest Tasks: T12733 Differential Revision: https://secure.phabricator.com/D18051
65 lines
1.2 KiB
JavaScript
65 lines
1.2 KiB
JavaScript
/**
|
|
* @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);
|
|
});
|