Browse Source

无JIRA任务 switch自适应高度展示

es6
windy 3 years ago
parent
commit
26c238ebd7
  1. 13
      src/case/button/switch.js

13
src/case/button/switch.js

@ -3,6 +3,10 @@
*/ */
BI.Switch = BI.inherit(BI.BasicButton, { BI.Switch = BI.inherit(BI.BasicButton, {
constants: {
CIRCLE_SIZE: 12
},
props: { props: {
extraCls: "bi-switch", extraCls: "bi-switch",
height: 20, height: 20,
@ -14,7 +18,8 @@ BI.Switch = BI.inherit(BI.BasicButton, {
}, },
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options, c = this.constants;
var tgap = (o.height - c.CIRCLE_SIZE) / 2;
return { return {
type: "bi.absolute", type: "bi.absolute",
ref: function () { ref: function () {
@ -27,14 +32,14 @@ BI.Switch = BI.inherit(BI.BasicButton, {
}, },
width: 12, width: 12,
height: 12, height: 12,
top: 4, top: tgap,
left: this.options.selected ? 28 : 4 left: this.options.selected ? 28 : 4
}, { }, {
type: "bi.label", type: "bi.label",
text: BI.i18nText("BI-Basic_Open"), text: BI.i18nText("BI-Basic_Open"),
cls: "content-tip", cls: "content-tip",
left: 8, left: 8,
top: 2, top: tgap - 2,
invisible: !o.showTip, invisible: !o.showTip,
ref: function (ref) { ref: function (ref) {
self.openTip = ref; self.openTip = ref;
@ -44,7 +49,7 @@ BI.Switch = BI.inherit(BI.BasicButton, {
text: BI.i18nText("BI-Basic_Close"), text: BI.i18nText("BI-Basic_Close"),
cls: "content-tip", cls: "content-tip",
right: 8, right: 8,
top: 2, top: tgap - 2,
invisible: !o.showTip, invisible: !o.showTip,
ref: function (ref) { ref: function (ref) {
self.closeTip = ref; self.closeTip = ref;

Loading…
Cancel
Save