|
|
|
@ -1,11 +1,18 @@
|
|
|
|
|
/** |
|
|
|
|
* guy |
|
|
|
|
* @extends BI.Single |
|
|
|
|
* @extends Single |
|
|
|
|
* @type {*|void|Object} |
|
|
|
|
*/ |
|
|
|
|
BI.Checkbox = BI.inherit(BI.BasicButton, { |
|
|
|
|
import { shortcut } from "../../../../core"; |
|
|
|
|
import { BasicButton } from "../../button"; |
|
|
|
|
|
|
|
|
|
props: { |
|
|
|
|
@shortcut() |
|
|
|
|
export class Checkbox extends BasicButton { |
|
|
|
|
static xtype = "bi.checkbox"; |
|
|
|
|
|
|
|
|
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
|
|
|
|
|
|
|
|
|
props = { |
|
|
|
|
baseCls: "bi-checkbox", |
|
|
|
|
selected: false, |
|
|
|
|
handler: BI.emptyFn, |
|
|
|
@ -13,50 +20,47 @@ BI.Checkbox = BI.inherit(BI.BasicButton, {
|
|
|
|
|
height: 14, |
|
|
|
|
iconWidth: 14, |
|
|
|
|
iconHeight: 14, |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
render: function () { |
|
|
|
|
var self = this, o = this.options; |
|
|
|
|
render() { |
|
|
|
|
const { iconWidth, iconHeight } = this.options; |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
type: "bi.center_adapt", |
|
|
|
|
items: [{ |
|
|
|
|
type: "bi.default", |
|
|
|
|
ref: function (_ref) { |
|
|
|
|
self.checkbox = _ref; |
|
|
|
|
ref: (_ref) => { |
|
|
|
|
this.checkbox = _ref; |
|
|
|
|
}, |
|
|
|
|
cls: "checkbox-content", |
|
|
|
|
width: o.iconWidth, |
|
|
|
|
height: o.iconHeight, |
|
|
|
|
width: iconWidth, |
|
|
|
|
height: iconHeight, |
|
|
|
|
}], |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_setEnable: function (enable) { |
|
|
|
|
BI.Checkbox.superclass._setEnable.apply(this, arguments); |
|
|
|
|
_setEnable(enable) { |
|
|
|
|
super._setEnable(enable); |
|
|
|
|
if (enable === true) { |
|
|
|
|
this.checkbox.element.removeClass("base-disabled disabled"); |
|
|
|
|
} else { |
|
|
|
|
this.checkbox.element.addClass("base-disabled disabled"); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
doClick: function () { |
|
|
|
|
BI.Checkbox.superclass.doClick.apply(this, arguments); |
|
|
|
|
doClick() { |
|
|
|
|
super.doClick(arguments); |
|
|
|
|
if (this.isValid()) { |
|
|
|
|
this.fireEvent(BI.Checkbox.EVENT_CHANGE); |
|
|
|
|
this.fireEvent(Checkbox.EVENT_CHANGE); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
setSelected: function (b) { |
|
|
|
|
BI.Checkbox.superclass.setSelected.apply(this, arguments); |
|
|
|
|
setSelected(b) { |
|
|
|
|
super.setSelected(b); |
|
|
|
|
if (b) { |
|
|
|
|
this.checkbox.element.addClass("bi-high-light-background"); |
|
|
|
|
} else { |
|
|
|
|
this.checkbox.element.removeClass("bi-high-light-background"); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
BI.Checkbox.EVENT_CHANGE = "EVENT_CHANGE"; |
|
|
|
|
|
|
|
|
|
BI.shortcut("bi.checkbox", BI.Checkbox); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|