最近项目需要,封装了一个Ext消息提示框,提示信息显示几秒后就自动消失。
css代码:
-
.msg .x-box-mc {
-
font-size:14px;
-
}
-
#msg-div {
-
position:absolute;
-
left:650px;
-
top:410px;
-
width:600px;
-
z-index:20000;
-
}
-
.msg-close{
-
width:10px; height:10px; position:absolute; top:1px; right:10px;cursor:hand;
-
}
-
.msg-h3 {
-
font-size:13px;
-
color:#2870b2;
-
font-weight:bold;
-
margin:10px 0;
-
}
.msg .x-box-mc {
font-size:14px;
}
#msg-div {
position:absolute;
left:650px;
top:410px;
width:600px;
z-index:20000;
}
.msg-close{
width:10px; height:10px; position:absolute; top:1px; right:10px;cursor:hand;
}
.msg-h3 {
font-size:13px;
color:#2870b2;
font-weight:bold;
margin:10px 0;
}
js代码:
-
-
-
-
Ext.QuickMsg = function(){
-
var msgCt;
-
-
function createBox(t, s,isClose){
-
var html = new Array();
-
-
html.push('
'
);
-
html.push('');
-
html.push('
'
);
-
if(t){
-
html.push('
'
);
-
html.push(t);
-
html.push('');
-
}
-
if(isClose){
-
html.push('+closeImageUrl+'" mce_src="'+closeImageUrl+'"/>');
-
}
-
html.push(s);
-
html.push('
');
-
html.push('');
-
html.push('
');
-
return html.join('');
-
}
-
return {
-
-
-
-
-
-
-
-
-
-
-
-
show : function(title, msg, width, time, alignEl, offsets, position,animate,isClose){
-
width = width?width:'250px';
-
time = time?time:2;
-
alignEl = alignEl?alignEl:document;
-
-
position = position?position:'t-t';
-
animate = animate?animate:false;
-
this.close();
-
if(!msgCt){
-
msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
-
msgCt.setWidth(width);
-
}
-
-
msgCt.alignTo(alignEl, position,offsets,animate);
-
var m = Ext.DomHelper.append(msgCt, {html:createBox(title, msg,isClose)}, true);
-
m.slideIn('t').pause(time).ghost("t", {remove:true});
-
},
-
-
-
alert : function(msg,field,alignEl,width){
-
width = width?width:'150px';
-
var html = ''+msg+'';
-
this.show('',html,'150px',2,field,[120,0],'t-t',true,false);
-
},
-
-
close: function(){
-
var div = document.getElementById('msg-div');
-
if(div){
-
div.style.display = 'none';
-
}
-
msgCt = '';
-
}
-
};
-
}();