-
14 Apr 2008 2:07 AM #1
Ext.ux.Notification
Ext.ux.Notification
UPDATE 09.16.2008 : TOASTWINDOW IS DEAD. NOTIFICATION IS ALIVE.
I took in account your different contributions, especially that of jmcneese. I adopted the new name Ext.ux.Notification that seems more compliant to Ext spirit. I brought some corrections.
Enhancement: when you click on the notification window, it sticks and the close button shows up.
It seems to be OK in my different browsers.
Thanks a lot.
The attached source code (and the online demo) includes a sound effect when the window ejects.
Old post:
Here is a small extension that displays unobstrusive message sliding windows like those in Outlook.
Demo: http://www.efattal.fr/extjs-dev/examples/toastwindow/
CSS:
Code:.error{background-image:url(../images/icons/gif/exclamation.gif);} .information{background-image:url(../images/icons/gif/information.gif) ! important;}Usage:PHP Code:Ext.ux.ToastWindowMgr = {
positions: []
};
Ext.ux.ToastWindow = Ext.extend(Ext.Window, {
initComponent: function(){
Ext.apply(this, {
iconCls: this.iconCls || 'information',
width: 200,
height: 100,
autoScroll: true,
autoDestroy: true,
plain: false
});
this.task = new Ext.util.DelayedTask(this.hide, this);
Ext.ux.ToastWindow.superclass.initComponent.call(this);
},
setMessage: function(msg){
this.body.update(msg);
},
setTitle: function(title, iconCls){
Ext.ux.ToastWindow.superclass.setTitle.call(this, title, iconCls||this.iconCls);
},
onRender:function(ct, position) {
Ext.ux.ToastWindow.superclass.onRender.call(this, ct, position);
},
onDestroy: function(){
Ext.ux.ToastWindowMgr.positions.remove(this.pos);
Ext.ux.ToastWindow.superclass.onDestroy.call(this);
},
afterShow: function(){
Ext.ux.ToastWindow.superclass.afterShow.call(this);
this.on('move', function(){
Ext.ux.ToastWindowMgr.positions.remove(this.pos);
this.task.cancel();}
, this);
this.task.delay(2000);
},
animShow: function(){
this.pos = 0;
while(Ext.ux.ToastWindowMgr.positions.indexOf(this.pos)>-1)
this.pos++;
Ext.ux.ToastWindowMgr.positions.push(this.pos);
this.setSize(200,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.ToastWindowMgr.positions.remove(this.pos);
this.el.ghost("b", {
duration: 1,
remove: true,
scope: this,
callback: this.destroy
});
}
});
May this code be useful to someone.PHP Code:new Ext.ux.ToastWindow({
title: 'My title',
html: 'My Message',
iconCls: 'error'
}).show(document);
Last edited by efattal; 17 Nov 2008 at 9:35 AM. Reason: Bug corrected
-
14 Apr 2008 5:45 AM #2
Really cool!
Here is a code to be put into examples/toastwindow to test it:
Is there a way to prevent the scrollbar to show when the window is hiding?Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>ToastWindow</title> <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" /> <!-- GC --> <!-- LIBS --> <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script> <!-- ENDLIBS --> <script type="text/javascript" src="../../ext-all.js"></script> <script> Ext.ux.ToastWindowMgr = { positions: [] }; Ext.ux.ToastWindow = Ext.extend(Ext.Window, { initComponent: function(){ Ext.apply(this, { iconCls: this.iconCls || 'information', width: 200, height: 100, autoScroll: true, autoDestroy: true, plain: false }); this.task = new Ext.util.DelayedTask(this.hide, this); Ext.ux.ToastWindow.superclass.initComponent.call(this); }, setMessage: function(msg){ this.body.update(msg); }, setTitle: function(title, iconCls){ Ext.ux.ToastWindow.superclass.setTitle.call(this, title, iconCls||this.iconCls); }, onRender:function(ct, position) { Ext.ux.ToastWindow.superclass.onRender.call(this, ct, position); }, afterShow: function(){ Ext.ux.ToastWindow.superclass.afterShow.call(this); this.on('move', function(){ Ext.ux.ToastWindowMgr.positions.remove(this.pos); this.task.cancel();} , this); this.task.delay(2000); }, animShow: function(){ this.pos = 0; while(Ext.ux.ToastWindowMgr.positions.indexOf(this.pos)>-1) this.pos++; Ext.ux.ToastWindowMgr.positions.push(this.pos); this.setSize(200,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.ToastWindowMgr.positions.remove(this.pos); this.el.ghost("b", { duration: 1, remove: true }); } }); Ext.onReady(function() { new Ext.ux.ToastWindow({ title: 'My title', html: 'My Message', iconCls: 'error' }).show(document); }); </script> </head> <body> </body> </html>
-
14 Apr 2008 7:32 AM #3
-
14 Apr 2008 7:43 AM #4
Neat!
There's smoething funny about the stop pos if you close a wnidow though. When a window has appeared, press ESC to close it. The next window starts its popup from the top of the last wnidow. if you ESC that one, the next one starts higher up too until they go off the top of the screen!Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
14 Apr 2008 7:50 AM #5
Thanks Animal. Code has been corrected.
BTW, thanks for all the good job you do for the community.
-
14 Apr 2008 7:57 AM #6
That works, that's what the onXXX functions are for; to allow each subclass to contribute their own functionality at each stage of the lifecycle.
With that in mind, it's important to remember to call the superclass's onXXX function, to allow it to perform its own necessary contribution at that stage. As you have it, the Window will not actually be destroyed.Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
14 Apr 2008 8:00 AM #7
-
14 Apr 2008 8:23 AM #8
That doesn't actually get called if you let the windows fade out. You need to callback to the destroy function at the end of the fade out animation.
Test with Firebug open to the HTML tab. You can see the document filling up with every popup you ask for!Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
14 Apr 2008 9:30 AM #9Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,170
- Vote Rating
- 31
mmm... toast.
great work

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
14 Apr 2008 10:30 AM #10
Very nice, thanks for sharing.
On Firefox the toasts do a little stuttering and the bottom line looks somehow...uhm...messy while fading in...Extensions:
Ext.ux.DatePickerPlus (Multimonth,Multiselect,...)
Ext.ux.menu.StoreMenu - Ajax Store as menu-item config
Extended Window - Aero Shadows, nested grayscaled modal windows
Ext.MessageBox.promptCombo/promptRadio/promptCheckbox
Ext.ux.plugin.triggerfieldTooltip (for Comboboxes, Datefields...)
Ext.util.MD5
Ext.util.Utf8 (encode/decode)
Ext.util.base64 (encode/decode)
Using:
ExtJS 3.4.1.1/4.2
XPsp3/W7sp1
IE8/9/10
FF 20
Chrome 26


Reply With Quote