|
|
|
@ -1,8 +1,9 @@
|
|
|
|
|
function isVertical(position) { |
|
|
|
|
(function () { |
|
|
|
|
function isVertical(position) { |
|
|
|
|
return position === "top" || position === "bottom"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
/** |
|
|
|
|
* 文字类型的按钮 |
|
|
|
|
* @class BI.Button |
|
|
|
|
* @extends BI.BasicButton |
|
|
|
@ -10,7 +11,7 @@ function isVertical(position) {
|
|
|
|
|
* @cfg {JSON} options 配置属性 |
|
|
|
|
* @cfg {'common'/'success'/'warning'/'ignore'} [options.level='common'] 按钮类型,用不同颜色强调不同的场景 |
|
|
|
|
*/ |
|
|
|
|
BI.Button = BI.inherit(BI.BasicButton, { |
|
|
|
|
BI.Button = BI.inherit(BI.BasicButton, { |
|
|
|
|
|
|
|
|
|
_const: { |
|
|
|
|
iconWidth: 16 |
|
|
|
@ -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,17 +48,17 @@ 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; |
|
|
|
|
if (BI.isNumber(o.height)) { |
|
|
|
|
if(!isVertical(o.iconPosition)) { |
|
|
|
|
if (!isVertical(o.iconPosition)) { |
|
|
|
|
if (o.clear || o.block) { |
|
|
|
|
lineHeight = o.height; |
|
|
|
|
} else { |
|
|
|
@ -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", |
|
|
|
@ -196,6 +198,7 @@ BI.Button = BI.inherit(BI.BasicButton, {
|
|
|
|
|
unHighLight: function () { |
|
|
|
|
this.text.unHighLight.apply(this.text, arguments); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
BI.shortcut("bi.button", BI.Button); |
|
|
|
|
BI.Button.EVENT_CHANGE = "EVENT_CHANGE"; |
|
|
|
|
}); |
|
|
|
|
BI.shortcut("bi.button", BI.Button); |
|
|
|
|
BI.Button.EVENT_CHANGE = "EVENT_CHANGE"; |
|
|
|
|
}()); |
|
|
|
|