/**
* A components a represents a simple On/Off buttons group.
*
* @example
* Ext.require('MFC.form.field.OnOff', function() {
* Ext.create('Ext.form.Panel', {
* renderTo: Ext.getBody(),
* items: [
* {
* xtype: 'mfc-onofffield',
* fieldLabel: 'Debug',
* value: 'off'
* }
* ]
* });
* });
*
* Exposed localization tokens:
*
* * MFC.form.field.OnOff.onText
* * MFC.form.field.OnOff.offText
*
* @author Sergei Lissovski <sergei.lissovski@modera.org>
*/
Ext.define('MFC.form.field.OnOff', {
extend: 'MFC.form.field.Switch',
alias: 'widget.mfc-onofffield',
// l10n
onText: 'ON',
offText: 'OFF',
/**
* Something that this field must be set to in order to have "On" button activated. Defaults to `on`.
*
* @cfg {String} onValue
*/
/**
* Something that this field must be set to in order to have "Off" button activated. Defaults to `off`.
*
* @cfg {String} offValue
*/
/**
* This configuration property can be ignored. If you still want to use it then look at MFC.form.field.Switch.
*
* @cfg {Object[]} buttons
*/
/**
* @param {Object} config
*/
constructor: function(config) {
config = config || {};
var on = config['onValue'] || 'on',
off = config['offValue'] || 'off';
var defaults = {
buttons: [
{
text: this.onText,
reactTo: on
},
{
text: this.offText,
reactTo: off
}
]
};
this.config = Ext.apply(defaults, config || {});
this.callParent([this.config]);
}
});