Ver Mensaje Individual
  #2 (permalink)  
Antiguo 14/12/2010, 05:43
Avatar de stock
stock
 
Fecha de Ingreso: junio-2004
Ubicación: Monterrey NL
Mensajes: 2.390
Antigüedad: 19 años, 10 meses
Puntos: 53
Respuesta: Ventana emergente como en gmail

Hola, justo estos días estoy trabajando en un desktop y necesitaba usar un sistema de mensajería como el que propones, te he preparado un ejemplo para que veas en acción el siguiente plugin:

http://www.quizzpot.com/demos/extjs/...fications.html

Ahora, el código responsable es el siguiente:
Código Javascript:
Ver original
  1. /**
  2.  * Ext.ux.ToastWindow
  3.  *
  4.  * @author  Edouard Fattal
  5.  * @date    March 14, 2008
  6.  *
  7.  * Modified by Crysfel Villa
  8.  * @date December 09, 2010
  9.  *
  10.  * @class Ext.ux.ToastWindow
  11.  * @extends Ext.Window
  12.  */
  13.  
  14. Ext.namespace("Ext.ux");
  15.  
  16.  
  17. Ext.ux.NotificationMgr = {
  18.     positions: []
  19. };
  20.  
  21. Ext.ux.Notification = Ext.extend(Ext.Window, {
  22.     initComponent: function(){
  23.         Ext.apply(this, {
  24.             iconCls     : this.iconCls || 'x-icon-information',
  25.             cls         : 'x-notification',
  26.             width       : 200,
  27.             autoHeight  : true,
  28.             plain       : false,
  29.             draggable   : false,
  30.             bodyStyle   : 'text-align:center'
  31.         });
  32.         if(this.autoDestroy) {
  33.             this.task = new Ext.util.DelayedTask(this.hide, this);
  34.         } else {
  35.             this.closable = true;
  36.         }
  37.         Ext.ux.Notification.superclass.initComponent.call(this);
  38.     },
  39.     setMessage: function(msg){
  40.         this.body.update(msg);
  41.     },
  42.     setTitle: function(title, iconCls){
  43.         Ext.ux.Notification.superclass.setTitle.call(this, title, iconCls||this.iconCls);
  44.     },
  45.     onRender:function(ct, position) {
  46.         Ext.ux.Notification.superclass.onRender.call(this, ct, position);
  47.     },
  48.     onDestroy: function(){
  49.         Ext.ux.NotificationMgr.positions.remove(this.pos);
  50.         Ext.ux.Notification.superclass.onDestroy.call(this);
  51.     },
  52.     cancelHiding: function(){
  53.         this.addClass('fixed');
  54.         if(this.autoDestroy) {
  55.             this.task.cancel();
  56.         }
  57.     },
  58.     afterShow: function(){
  59.         Ext.ux.Notification.superclass.afterShow.call(this);
  60.         Ext.fly(this.body.dom).on('click', this.cancelHiding, this);
  61.         if(this.autoDestroy) {
  62.             this.task.delay(this.hideDelay || 5000);
  63.        }
  64.     },
  65.     animShow: function(){
  66.         this.pos = 0;
  67.         while(Ext.ux.NotificationMgr.positions.indexOf(this.pos)>-1)
  68.             this.pos++;
  69.         Ext.ux.NotificationMgr.positions.push(this.pos);
  70.         this.setSize(200,100);
  71.         this.el.alignTo(document, "br-br", [ -20, -42-((this.getSize().height+10)*this.pos) ]);
  72.         this.el.slideIn('b', {
  73.             duration: 1,
  74.             callback: this.afterShow,
  75.             scope: this
  76.         });
  77.     },
  78.     animHide: function(){
  79.         Ext.ux.NotificationMgr.positions.remove(this.pos);
  80.         this.el.ghost("b", {
  81.             duration    : 1,
  82.             scope       : this,
  83.             callback    : this.destroy
  84.         });
  85.     },
  86.    
  87.     focus: Ext.emptyFn
  88.  
  89. });

Este es un plugin para ExtJS, quizás una librería bastante pesada para lo que necesitas, dejo a tu consideración si quieres usar el ejemplo, yo como todo mi desktop esta basado en ExtJS no tengo problema en usar el plugin

Quizás en unos días prepare un tutorial sobre el plugin, te recomiendo visitar mi blog (Está en mi firma) donde tengo mucho material gratuito

Saludos

Última edición por stock; 14/12/2010 a las 05:49