Ext 组件继承

/**
* This class is used for all image background buttons.
*
* @class My.button.ImageButton
* @extends Ext.Button
*/

Ext.namespace(’My.button’);

My.button.ImageButton = function(cfg) {
My.button.ImageButton.superclass.constructor.call(this, cfg);
};

Ext.extend(My.button.ImageButton, Ext.Button, {
imageClass: ’image-btn’,
tpl: new Ext.Template(’<div><a href="" class="{imageClass}"><span>{imgText:htmlEncode}</span></a></div>’),

onRender: function(ct, position) {
this.disabledImgPath = this.disabledImgPath || this.imgPath;

var btn, targs = {
imgText: this.text || "",
imageClass: this.imageClass
};

btn = this.tpl.append(ct, targs, true);
btn.on("click", this.onClick, this);
this.el = btn;

if (this.hidden) {
this.hide();
}
},

disable: function(newImgPath) {
var replaceImgPath = newImgPath || this.disabledImgPath;
if (replaceImgPath)
this.el.dom.firstChild.src = replaceImgPath;
this.disabled = true;
},

enable: function(newImgPath) {
var replaceImgPath = newImgPath || this.imgPath;
if (replaceImgPath)
this.el.dom.firstChild.src = replaceImgPath;
this.disabled = false;
},

reload: function(newImageClass) {
this.imageClass = newImageClass;

var targs = {
imgText: this.text || "",
imageClass: this.imageClass
};

this.tpl.overwrite(this.el, targs);
}
});

Ext.reg(’imagebutton’, My.button.ImageButton);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值