here's how i do it (with a tweaked version of toastwindow):
PHP Code:
Ext.ux.NotificationMgr = {
positions: []
};
Ext.ux.Notification = Ext.extend(Ext.Window, {
initComponent: function(){
Ext.apply(this, {
iconCls: this.iconCls || 'x-icon-information',
width: 200,
autoHeight: true,
closable: false,
plain: false,
draggable: false,
bodyStyle: 'text-align:center;padding:1em;'
});
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);
},
afterShow: function(){
Ext.ux.Notification.superclass.afterShow.call(this);
this.on('move', function(){
Ext.ux.NotificationMgr.positions.remove(this.pos);
if(this.autoDestroy) {
this.task.cancel();
}
}, 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(200,100);
this.el.alignTo(document, "br-br", [ -1, -1-((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
});
}
});
and the example usage:
PHP Code:
new Ext.ux.Notification({
iconCls: (iconCls) ? iconCls : 'x-icon-exclamation',
title: (title) ? title : 'Notice',
html: message,
autoDestroy: false,
}).show((anchor) ? anchor : document);
or
PHP Code:
new Ext.ux.Notification({
iconCls: 'x-icon-error',
title: 'Ruh-row',
html: 'This is just a stub. This is only a stub. If this would have been a real functioning doo-dad, you never would have even seen this stub.',
autoDestroy: true,
hideDelay: 5000
}).show(document);