Browse Source

DESIGN-4069 fix: 按钮增加闭包

es6
treecat 2 years ago
parent
commit
ddd8fcf5d6
  1. 28
      demo/js/base/button/demo.button.js
  2. 19
      src/base/single/button/buttons/button.js

28
demo/js/base/button/demo.button.js

@ -213,6 +213,34 @@ Demo.Button = BI.inherit(BI.Widget, {
},
height: 30
}
}, {
el: {
type: "bi.button",
text: "图标在上面的按钮",
iconCls: "close-font",
iconPosition: "top"
}
}, {
el: {
type: "bi.button",
text: "图标在下面的按钮",
iconCls: "close-font",
iconPosition: "bottom"
}
}, {
el: {
type: "bi.button",
text: "图标在左边的按钮",
iconCls: "close-font",
iconPosition: "left"
}
}, {
el: {
type: "bi.button",
text: "图标在右边的按钮",
iconCls: "close-font",
iconPosition: "right"
}
}];
// BI.each(items, function (i, item) {
// item.el.handler = function () {

19
src/base/single/button/buttons/button.js

@ -1,3 +1,4 @@
(function () {
function isVertical(position) {
return position === "top" || position === "bottom";
}
@ -19,7 +20,6 @@ BI.Button = BI.inherit(BI.BasicButton, {
_defaultConfig: function (props) {
var conf = BI.Button.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-button" + ((BI.isIE() && BI.isIE9Below()) ? " hack" : ""),
attributes: {
@ -48,12 +48,12 @@ BI.Button = BI.inherit(BI.BasicButton, {
rgap: 0,
iconGap: 4,
iconPosition: "left",
iconSize: props.iconSize || 12
iconSize: props.iconSize
});
},
render: function () {
var o = this.options, self = this;
var o = this.options;
// 由于button默认情况下有个边框,所以要主动算行高
var lineHeight, textHeight = o.textHeight;
@ -74,17 +74,19 @@ BI.Button = BI.inherit(BI.BasicButton, {
}
}
if (BI.isKey(o.iconCls)) {
var iconCss = {};
if (o.iconSize) {
iconCss.fontSize = o.iconSize / BI.pixRatio + BI.pixUnit;
}
this.icon = BI.createWidget({
type: "bi.icon_label",
cls: o.iconCls,
width: o.iconWidth,
height: o.iconHeight,
lineHeight: o.iconHeight,
iconWidth: o.iconWidth,
iconHeight: o.iconHeight,
css: {
fontSize: o.iconSize + "px"
}
iconWidth: o.iconSize,
iconHeight: o.iconSize,
css: iconCss
});
this.text = BI.createWidget({
type: "bi.label",
@ -199,3 +201,4 @@ BI.Button = BI.inherit(BI.BasicButton, {
});
BI.shortcut("bi.button", BI.Button);
BI.Button.EVENT_CHANGE = "EVENT_CHANGE";
}());

Loading…
Cancel
Save