`

为Ext.Msg添加一个ghost提示的方法

    博客分类:
  • Ext
阅读更多
总觉得的老用alert的方式打断用户操作是非常不好的做法,调用方法时这个提示会出现两秒,之后自动消失,稍做修改
/**
 * 存放自定义的单例函数
 * @author chemzqm@gmail.com
 */
Ext.MyApp = 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 {
		ghost : function(title, format){
            if(!msgCt){
                msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
            }
            msgCt.center();
            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').highlight().pause(2).ghost("t", {remove:true});
        }
	};
}();
Ext.Msg.ghost=Ext.MyApp.ghost;

#msg-div {
    position: absolute;
    left: 35%;
    top: 10px;
    width: 250px;
    z-index: 20000;
}

.msg .x-box-mc {
    font-size: 14px;
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics