|
|
|
/**
|
|
|
|
* 单选按钮组
|
|
|
|
*
|
|
|
|
* Created by GUY on 2015/9/7.
|
|
|
|
* @class BI.Segment
|
|
|
|
* @extends BI.Widget
|
|
|
|
*/
|
|
|
|
BI.Segment = BI.inherit(BI.Widget, {
|
|
|
|
_defaultConfig: function () {
|
|
|
|
return BI.extend(BI.Segment.superclass._defaultConfig.apply(this, arguments), {
|
|
|
|
baseCls: "bi-segment",
|
|
|
|
items: [],
|
|
|
|
height: 24
|
|
|
|
});
|
|
|
|
},
|
|
|
|
_init: function () {
|
|
|
|
BI.Segment.superclass._init.apply(this, arguments);
|
|
|
|
var self = this, o = this.options;
|
|
|
|
this.buttonGroup = BI.createWidget({
|
|
|
|
element: this,
|
|
|
|
type: "bi.button_group",
|
|
|
|
value: o.value,
|
|
|
|
items: BI.createItems(o.items, {
|
|
|
|
type: "bi.segment_button",
|
|
|
|
height: BI.pixFormat(o.height, 2),
|
|
|
|
whiteSpace: o.whiteSpace
|
|
|
|
}),
|
|
|
|
layout: [
|
|
|
|
{
|
|
|
|
type: "bi.center"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
this.buttonGroup.on(BI.Controller.EVENT_CHANGE, function () {
|
|
|
|
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
|
|
|
|
});
|
|
|
|
this.buttonGroup.on(BI.ButtonGroup.EVENT_CHANGE, function (value, obj) {
|
|
|
|
self.fireEvent(BI.Segment.EVENT_CHANGE, value, obj);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
_setEnable: function (enable) {
|
|
|
|
BI.Segment.superclass._setEnable.apply(this, arguments);
|
|
|
|
if (enable === true) {
|
|
|
|
this.element.removeClass("base-disabled disabled");
|
|
|
|
} else if (enable === false) {
|
|
|
|
this.element.addClass("base-disabled disabled");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setValue: function (v) {
|
|
|
|
this.buttonGroup.setValue(v);
|
|
|
|
},
|
|
|
|
|
|
|
|
setEnabledValue: function (v) {
|
|
|
|
this.buttonGroup.setEnabledValue(v);
|
|
|
|
},
|
|
|
|
|
|
|
|
getValue: function () {
|
|
|
|
return this.buttonGroup.getValue();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
BI.Segment.EVENT_CHANGE = "EVENT_CHANGE";
|
|
|
|
BI.shortcut("bi.segment", BI.Segment);
|