//自定义工具,用户产生操作提示窗片
Ext.MsgAlert = function(){
var msgCt;
function createBox(t,s){
return ['<div class="msg">',
'<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>',
'<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"><h3>', t, '</h3>', s, '</div></div></div>',
'<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>',
'</div>'].join('');
}
return {
msg: function(title,format){
if(!msgCt){
msgCt = Ext.DomHelper.insertFirst(document.body,{
id: "msg-div",
style: 'position:absolute;top:10px;width:250px;margin:0 auto;z-index:20000;'
},true);
}
msgCt.alignTo(document,'c-c'); //具体参数可参考http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.Element
var s = String.format.apply(String,Array.prototype.slice.call(arguments,1));
var m = Ext.DomHelper.append(msgCt,{
html:createBox(title,s)
},true);
m.slideIn('t').pause(3).ghost("tr",{
remove:true
});
},
init: function(){
var lb = Ext.get('lib-bar');
if(lb){
lb.show();
}
}
};
}();
调用方法
Ext.MsgAlert.msg("提示框", "你点击了确认");