Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Ext.namespace('Zarafa.core.ui.notifier');
  2. /**
  3.  * @class Zarafa.core.ui.notifier.DialogNotifierPlugin
  4.  * @extends Zarafa.core.ui.notifier.NotifyPlugin
  5.  */
  6. Zarafa.core.ui.notifier.DialogNotifierPlugin = Ext.extend(Zarafa.core.ui.notifier.NotifyPlugin, {
  7.    
  8.     notifierElem : undefined,
  9.  
  10.     /**
  11.      * Send a notification to the user. This {@link #getPlugin requests} the plugin for the provided category.
  12.      * On the plugin the {@link Zarafa.core.ui.notifier.NotifyPlugin#notify notify} function is called to display
  13.      * the message to the user. If no plugin could be found for
  14.      * the given category, then no message will be shown to the user.
  15.      *
  16.      * @param {String} category The category which applies to the notification.
  17.      * @param {String} title The title which must be shown in the message.
  18.      * @param {Mixed} message The message which should be displayed. This could be either a String,
  19.      * @param {Ext.Container container} optional message container.
  20.      * a {@link Ext.data.Record record}, or a data object which contains the data which must be shown.
  21.      */
  22.     notify : function(category, title, message, container, animationEffect)
  23.     {
  24.         if(!Ext.isDefined(this.notifierElem)){
  25.             this.notifierElem = Ext.DomHelper.append(container, {tag : 'div', class:'zarafa-dialog-notifier-container', html:message}, true);
  26.             this.layoutMsgContainer(container);
  27.         }
  28.  
  29.         this.animMessage(this.notifierElem, animationEffect);
  30.     },
  31.    
  32.     /**
  33.      * set position for message container
  34.      * @private
  35.      */
  36.     layoutMsgContainer : function(container)
  37.     {
  38.         this.notifierElem.setLeft(container.getWidth()/2 - 50);
  39.         this.notifierElem.setTop(0);
  40.     },
  41.    
  42.     /**
  43.      * Event handler which is called when the {@link Ext.Fx#} animation has been
  44.      * completed. This will reset the {@link #animating} flag to start animating any pending messages.
  45.      *
  46.      * @private
  47.      */
  48.     removeElem : function(element){
  49.         Ext.destroy(element);
  50.         this.notifierElem = undefined;
  51.     },
  52.     /**
  53.      * Start the animation,
  54.      * we will slide the message into the screen from the given direction, and after the timeout,
  55.      * the message will be slided out to the given direction (during sliding it will disappear gradually).
  56.      * @param {@link Ext.Element element}
  57.      * @private
  58.      */
  59.     animMessage : function(element, animationEffect)
  60.     {
  61.        
  62.         switch (animationEffect)
  63.         {
  64.             case 'run':
  65.                 element.animate({
  66.                             opacity: {to: 0, from: 1},
  67.                         },
  68.                         4,      // animation duration
  69.                         this.removeElem.createDelegate(this),      // callback
  70.                         'easeOut', // easing method
  71.                         'run'      // animation type ('run','color','motion','scroll')
  72.                     );
  73.                 break;
  74.            
  75.             case 'fadeIn':
  76.                 element.fadeIn({
  77.                     endOpacity: .8, //can be any value between 0 and 1 (e.g. .5)
  78.                     easing: 'easeOut',
  79.                 });
  80.                 break;
  81.             case 'fadeOut' :
  82.                 element.fadeOut({
  83.                     endOpacity: 0, //can be any value between 0 and 1 (e.g. .5)
  84.                     easing: 'easeOut',
  85.                     duration: .2,
  86.                     remove: true
  87.                 });
  88.                 break;
  89.         }
  90.     }
  91. });
  92.  
  93. Zarafa.onReady(function() {
  94.     container.getNotifier().registerPlugin('dialogNotifier', new Zarafa.core.ui.notifier.DialogNotifierPlugin());
  95. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement