Browse Source

KERNEL-13901 refactor: input文件夹ES6化补充

es6
impact 2 years ago
parent
commit
4efd86dc35
  1. 25
      src/base/single/input/checkbox/checkbox.image.js
  2. 54
      src/base/single/input/checkbox/checkbox.js
  3. 4
      src/base/single/input/index.js
  4. 33
      src/base/single/input/radio/radio.image.js
  5. 53
      src/base/single/input/radio/radio.js

25
src/base/single/input/checkbox/checkbox.image.js

@ -1,13 +1,21 @@
/** /**
* guy * guy
* @extends BI.Single * @extends Single
* @type {*|void|Object} * @type {*|void|Object}
*/ */
BI.ImageCheckbox = BI.inherit(BI.IconButton, { import { shortcut, extend } from "../../../../core";
_defaultConfig: function () { import { IconButton } from "../../button";
var conf = BI.ImageCheckbox.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { @shortcut()
export class ImageCheckbox extends IconButton {
static xtype = "bi.image_checkbox";
static EVENT_CHANGE = IconButton.EVENT_CHANGE;
_defaultConfig() {
const conf = super._defaultConfig(arguments);
return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-image-checkbox check-box-icon", baseCls: (conf.baseCls || "") + " bi-image-checkbox check-box-icon",
selected: false, selected: false,
handler: BI.emptyFn, handler: BI.emptyFn,
@ -16,8 +24,5 @@ BI.ImageCheckbox = BI.inherit(BI.IconButton, {
iconWidth: 16, iconWidth: 16,
iconHeight: 16, iconHeight: 16,
}); });
}, }
}); }
BI.ImageCheckbox.EVENT_CHANGE = BI.IconButton.EVENT_CHANGE;
BI.shortcut("bi.image_checkbox", BI.ImageCheckbox);

54
src/base/single/input/checkbox/checkbox.js

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

4
src/base/single/input/index.js

@ -1,2 +1,6 @@
export { Input } from "./input"; export { Input } from "./input";
export { File } from "./file"; export { File } from "./file";
export { Checkbox } from "./checkbox/checkbox";
export { ImageCheckbox } from "./checkbox/checkbox.image";
export { Radio } from "./radio/radio";
export { ImageRadio } from "./radio/radio.image";

33
src/base/single/input/radio/radio.image.js

@ -1,13 +1,21 @@
/** /**
* guy * guy
* @extends BI.Single * @extends Single
* @type {*|void|Object} * @type {*|void|Object}
*/ */
BI.ImageRadio = BI.inherit(BI.IconButton, { import { shortcut, extend } from "../../../../core";
_defaultConfig: function () { import { IconButton } from "../../button";
var conf = BI.ImageRadio.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { @shortcut()
export class ImageRadio extends IconButton {
static xtype = "bi.image_radio";
static EVENT_CHANGE = IconButton.EVENT_CHANGE;
_defaultConfig() {
const conf = super._defaultConfig(arguments);
return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-radio radio-icon", baseCls: (conf.baseCls || "") + " bi-radio radio-icon",
selected: false, selected: false,
handler: BI.emptyFn, handler: BI.emptyFn,
@ -16,15 +24,12 @@ BI.ImageRadio = BI.inherit(BI.IconButton, {
iconWidth: 16, iconWidth: 16,
iconHeight: 16, iconHeight: 16,
}); });
}, }
doClick: function () { doClick() {
BI.ImageRadio.superclass.doClick.apply(this, arguments); super.doClick(arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.ImageRadio.EVENT_CHANGE); this.fireEvent(ImageRadio.EVENT_CHANGE);
}
}
} }
},
});
BI.ImageRadio.EVENT_CHANGE = BI.IconButton.EVENT_CHANGE;
BI.shortcut("bi.image_radio", BI.ImageRadio);

53
src/base/single/input/radio/radio.js

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

Loading…
Cancel
Save