/*
 * Camping JIDO
 * Copyright(c) 2010, softhall(softhall@naver.com),subi (ihan94@gmail.com).
 * 
 * This code is licensed under BSD license. Use it as you wish, 
 * but keep this copyright intact.
 */


Ext.namespace("Ext.ux");Ext.ux.NotificationMgr={positions:[]};Ext.ux.Notification=Ext.extend(Ext.Window,{initComponent:function(){Ext.apply(this,{iconCls:this.iconCls||'x-icon-information',cls:'x-notification',width:250,autoHeight:true,plain:false,draggable:false,bodyStyle:'text-align:center'});if(this.autoDestroy){this.task=new Ext.util.DelayedTask(this.hide,this);}else{this.closable=true;}
Ext.ux.Notification.superclass.initComponent.call(this);},setMessage:function(msg){this.body.update(msg);},setTitle:function(title,iconCls){Ext.ux.Notification.superclass.setTitle.call(this,title,iconCls||this.iconCls);},onRender:function(ct,position){Ext.ux.Notification.superclass.onRender.call(this,ct,position);},onDestroy:function(){Ext.ux.NotificationMgr.positions.remove(this.pos);Ext.ux.Notification.superclass.onDestroy.call(this);},cancelHiding:function(){this.addClass('fixed');if(this.autoDestroy){this.task.cancel();}},afterShow:function(){Ext.ux.Notification.superclass.afterShow.call(this);Ext.fly(this.body.dom).on('click',this.cancelHiding,this);if(this.autoDestroy){this.task.delay(this.hideDelay||5000);}},animShow:function(){this.pos=0;while(Ext.ux.NotificationMgr.positions.indexOf(this.pos)>-1)
this.pos++;Ext.ux.NotificationMgr.positions.push(this.pos);this.setSize(250,100);this.el.alignTo(document,"br-br",[-20,-20-((this.getSize().height+10)*this.pos)]);this.el.slideIn('b',{duration:1,callback:this.afterShow,scope:this});},animHide:function(){Ext.ux.NotificationMgr.positions.remove(this.pos);this.el.ghost("b",{duration:1,remove:true});},focus:Ext.emptyFn});
