Ext自定义弹出窗口
Ext中用alert弹出提示窗口后,每次都要点确定,非常不友好,要是能够每次弹出窗口,不用点确定,窗口自动消失,就好了!实际上,用Ext也可以实现这样的功能,如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | Ext.namespace('Ext.ux');
Ext.ux.MessageBox = 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;width: 230px;z-index:10001'
}, true);
}
var s = String.format.apply(String, Array.prototype.slice.call(
arguments, 1));
var m = Ext.DomHelper.append(msgCt, {
html : createBox(title, s)
}, true);
msgCt.alignTo(document, 't-t');
m.slideIn('t').pause(1.5).ghost("t", {
remove : true
});
}
};
}(); |
Recent Comments