forked from fanruan/fineui
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.5 KiB
54 lines
1.5 KiB
/** |
|
* 单选按钮组 |
|
* |
|
* 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: 30 |
|
}); |
|
}, |
|
_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", |
|
items: BI.createItems(o.items, { |
|
type: "bi.segment_button", |
|
height: 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) |
|
}) |
|
}, |
|
|
|
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); |