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.
86 lines
2.7 KiB
86 lines
2.7 KiB
/** |
|
* 可以改变图标的button |
|
* |
|
* Created by GUY on 2016/2/2. |
|
* |
|
* @class BI.IconChangeButton |
|
* @extends BI.Single |
|
*/ |
|
BI.IconChangeButton = BI.inherit(BI.Single, { |
|
_defaultConfig: function () { |
|
var conf = BI.IconChangeButton.superclass._defaultConfig.apply(this, arguments); |
|
return BI.extend(conf, { |
|
baseCls: "bi-icon-change-button", |
|
iconCls: "", |
|
iconWidth: null, |
|
iconHeight: null, |
|
|
|
stopEvent: false, |
|
stopPropagation: false, |
|
selected: false, |
|
once: false, // 点击一次选中有效,再点无效 |
|
forceSelected: false, // 点击即选中, 选中了就不会被取消 |
|
forceNotSelected: false, // 无论怎么点击都不会被选中 |
|
disableSelected: false, // 使能选中 |
|
|
|
shadow: false, |
|
isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 |
|
trigger: null, |
|
handler: BI.emptyFn |
|
}); |
|
}, |
|
|
|
_init: function () { |
|
var self = this, o = this.options; |
|
o.iconCls = BI.isFunction(o.iconCls) ? this.__watch(o.iconCls, function (context, newValue) { |
|
self.setIcon(newValue); |
|
}) : o.iconCls; |
|
BI.IconChangeButton.superclass._init.apply(this, arguments); |
|
this.button = BI.createWidget({ |
|
type: "bi.icon_button", |
|
element: this, |
|
cls: o.iconCls, |
|
height: o.height, |
|
iconWidth: o.iconWidth, |
|
iconHeight: o.iconHeight, |
|
|
|
stopEvent: o.stopEvent, |
|
stopPropagation: o.stopPropagation, |
|
selected: o.selected, |
|
once: o.once, |
|
forceSelected: o.forceSelected, |
|
forceNotSelected: o.forceNotSelected, |
|
disableSelected: o.disableSelected, |
|
|
|
shadow: o.shadow, |
|
isShadowShowingOnSelected: o.isShadowShowingOnSelected, |
|
trigger: o.trigger, |
|
handler: o.handler |
|
}); |
|
|
|
this.button.on(BI.Controller.EVENT_CHANGE, function () { |
|
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
|
}); |
|
this.button.on(BI.IconButton.EVENT_CHANGE, function () { |
|
self.fireEvent(BI.IconChangeButton.EVENT_CHANGE, arguments); |
|
}); |
|
}, |
|
|
|
isSelected: function () { |
|
return this.button.isSelected(); |
|
}, |
|
|
|
setSelected: function (b) { |
|
this.button.setSelected(b); |
|
}, |
|
|
|
setIcon: function (cls) { |
|
var o = this.options; |
|
if (o.iconCls !== cls) { |
|
this.element.removeClass(o.iconCls).addClass(cls); |
|
o.iconCls = cls; |
|
} |
|
} |
|
}); |
|
BI.IconChangeButton.EVENT_CHANGE = "EVENT_CHANGE"; |
|
BI.shortcut("bi.icon_change_button", BI.IconChangeButton);
|
|
|