fineui是帆软报表和BI产品线所使用的前端框架。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.6 KiB

8 years ago
/**
* @class BI.IconButton
* @extends BI.BasicButton
* 图标的button
*/
BI.IconButton = BI.inherit(BI.BasicButton, {
_defaultConfig: function () {
var conf = BI.IconButton.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
_baseCls: (conf._baseCls || "") + " bi-icon-button horizon-center",
8 years ago
iconWidth: null,
iconHeight: null
7 years ago
});
8 years ago
},
_init: function () {
BI.IconButton.superclass._init.apply(this, arguments);
var o = this.options;
this.element.css({
7 years ago
textAlign: "center"
8 years ago
});
this.icon = BI.createWidget({
7 years ago
type: "bi.icon",
8 years ago
width: o.iconWidth,
height: o.iconHeight
});
if (BI.isNumber(o.height) && o.height > 0 && BI.isNull(o.iconWidth) && BI.isNull(o.iconHeight)) {
this.element.css("lineHeight", o.height / BI.pixRatio + BI.pixUnit);
8 years ago
BI.createWidget({
type: "bi.default",
8 years ago
element: this,
8 years ago
items: [this.icon]
7 years ago
});
8 years ago
} else {
this.element.css("lineHeight", "1");
8 years ago
BI.createWidget({
8 years ago
element: this,
7 years ago
type: "bi.center_adapt",
8 years ago
items: [this.icon]
});
}
},
doClick: function () {
BI.IconButton.superclass.doClick.apply(this, arguments);
if (this.isValid()) {
this.fireEvent(BI.IconButton.EVENT_CHANGE, this);
}
}
});
BI.IconButton.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_button", BI.IconButton);