1 (function($, rf) {
  2 
  3     rf.ui = rf.ui || {};
  4     
  5     var defaultOptions = {
  6         position: "tr",
  7         direction: "vertical",
  8         method: "last",
  9         notifications: [],
 10         addNotification: function(pnotify) {
 11             this.notifications.push(pnotify);
 12         }
 13     };
 14 
 15     rf.ui.NotifyStack = rf.BaseComponent.extendClass({
 16         
 17         name : "NotifyStack",
 18 
 19         init : function(componentId, options) {
 20             $super.constructor.call(this, componentId);
 21             this.attachToDom(this.id);
 22             this.__initializeStack(options);
 23         },
 24         
 25         __initializeStack : function(options) {
 26             var stack = $.extend({}, $.pnotify.defaults.pnotify_stack, defaultOptions, options);
 27             
 28             var isVertical = (stack.direction == 'vertical');
 29             var isFirst = (stack.method == 'first');
 30             
 31             stack.push = isFirst ? 'top' : 'bottom';
 32             
 33             switch (stack.position) {
 34                 case "tl": // topLeft
 35                     stack.dir1 = isVertical ? 'down' : 'right';
 36                     stack.dir2 = isVertical ? 'right' : 'down';
 37                     break;
 38                 case "tr": // topRight
 39                     stack.dir1 = isVertical ? 'down' : 'left';
 40                     stack.dir2 = isVertical ? 'left' : 'down';
 41                     break;
 42                 case "bl": // bottomLeft
 43                     stack.dir1 = isVertical ? 'up' : 'right';
 44                     stack.dir2 = isVertical ? 'right' : 'up';
 45                     break;
 46                 case "br": // bottomRight
 47                     stack.dir1 = isVertical ? 'up' : 'left';
 48                     stack.dir2 = isVertical ? 'left' : 'up';
 49                     break;
 50                 default:
 51                     throw "wrong stack position: " + stack.position;
 52             }
 53             
 54             this.stack = stack;
 55         },
 56     
 57         getStack : function() {
 58             return this.stack;
 59         },
 60         
 61         removeNotifications: function() {
 62             var pnotify;
 63             while (pnotify = this.stack.notifications.pop()) {
 64                 pnotify.pnotify_remove();
 65             }
 66         },
 67         
 68         destroy : function() {
 69             this.removeNotifications();
 70             this.stack = null;
 71             $super.destroy.call(this);
 72         }
 73     });
 74     
 75     var $super = rf.ui.NotifyStack.$super;
 76 
 77 })(RichFaces.jQuery, RichFaces);