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.
80 lines
2.4 KiB
80 lines
2.4 KiB
/** |
|
* guy |
|
* 复选框item |
|
* @type {*|void|Object} |
|
*/ |
|
BI.MultiSelectItem = BI.inherit(BI.BasicButton, { |
|
_defaultConfig: function () { |
|
return BI.extend(BI.MultiSelectItem.superclass._defaultConfig.apply(this, arguments), { |
|
extraCls: "bi-multi-select-item", |
|
height: 24, |
|
logic: { |
|
dynamic: false |
|
}, |
|
iconWrapperWidth: 26, |
|
textHgap: 0, |
|
textLgap: 0, |
|
textRgap: 0 |
|
}); |
|
}, |
|
_init: function () { |
|
BI.MultiSelectItem.superclass._init.apply(this, arguments); |
|
var self = this, o = this.options; |
|
this.checkbox = BI.createWidget({ |
|
type: "bi.checkbox" |
|
}); |
|
this.text = BI.createWidget({ |
|
type: "bi.label", |
|
cls: "list-item-text", |
|
textAlign: "left", |
|
whiteSpace: "nowrap", |
|
textHeight: o.height, |
|
height: o.height, |
|
hgap: o.hgap, |
|
rgap: o.rgap, |
|
lgap: o.textLgap, |
|
text: o.text, |
|
keyword: o.keyword, |
|
value: o.value, |
|
py: o.py |
|
}); |
|
this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { |
|
if (type === BI.Events.CLICK) { |
|
self.setSelected(self.isSelected()); |
|
} |
|
}); |
|
|
|
BI.createWidget(BI.extend({ |
|
element: this |
|
}, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { |
|
items: BI.LogicFactory.createLogicItemsByDirection("left", { |
|
type: "bi.center_adapt", |
|
items: [this.checkbox], |
|
width: o.iconWrapperWidth |
|
}, this.text) |
|
})))); |
|
}, |
|
|
|
doRedMark: function () { |
|
this.text.doRedMark.apply(this.text, arguments); |
|
}, |
|
|
|
unRedMark: function () { |
|
this.text.unRedMark.apply(this.text, arguments); |
|
}, |
|
|
|
doClick: function () { |
|
BI.MultiSelectItem.superclass.doClick.apply(this, arguments); |
|
this.checkbox.setSelected(this.isSelected()); |
|
if (this.isValid()) { |
|
this.fireEvent(BI.MultiSelectItem.EVENT_CHANGE, this.getValue(), this); |
|
} |
|
}, |
|
|
|
setSelected: function (v) { |
|
BI.MultiSelectItem.superclass.setSelected.apply(this, arguments); |
|
this.checkbox.setSelected(v); |
|
} |
|
}); |
|
BI.MultiSelectItem.EVENT_CHANGE = "EVENT_CHANGE"; |
|
BI.shortcut("bi.multi_select_item", BI.MultiSelectItem);
|
|
|