      1 (function($, rf) {
      2     rf.ui = rf.ui || {};
      3     var defaultOptions = {
      4         showEvent : 'mouseenter',
      5         direction : "AA",
      6         jointPoint : "AA",
      7         positionType : "DDMENUGROUP",
      8         showDelay : 300
      9     }
     10     // constructor definition
     11     rf.ui.MenuGroup = function(componentId, options) {
     12         this.id = componentId;
     13         this.options = {};
     14         $.extend(this.options, defaultOptions, options || {});
     15         $super.constructor.call(this, componentId, this.options);
     16         this.namespace = this.namespace || "."
     17             + rf.Event.createNamespace(this.name, this.id);
     18         this.attachToDom(componentId);
     19
     20         rf.Event.bindById(this.id, this.options.showEvent, $.proxy(
     21             this.__showHandler, this), this);
     22
     23         this.rootMenu = rf.component(this.options.rootMenuId);
     24
     25         this.shown = false;
     26         this.jqueryElement = $(this.element);
     27
     28     };
     29
     30     rf.ui.MenuBase.extend(rf.ui.MenuGroup);
     31
     32     // define super class link
     33     var $super = rf.ui.MenuGroup.$super;
     34
     35     $.extend(rf.ui.MenuGroup.prototype, rf.ui.MenuKeyNavigation);
     36
     37     $.extend(rf.ui.MenuGroup.prototype, (function() {
     38         return {
     39             name : "MenuGroup",
     40             show : function() {
     41                 var id = this.id;
     42                 if (this.rootMenu.groupList[id] && !this.shown) {
     43                     this.rootMenu.invokeEvent("groupshow", rf
     44                         .getDomElement(this.rootMenu.id),
     45                         null);
     46                     this.__showPopup();
     47                     this.shown = true;
     48                 }
     49             },
     50             hide : function() {
     51                 var menu = this.rootMenu;
     52                 if (menu.groupList[this.id] && this.shown) {
     53                     menu.invokeEvent("grouphide", rf
     54                         .getDomElement(menu.id), null);
     55                     this.__hidePopup();
     56                     this.shown = false;
     57                 }
     58             },
     59
     60             select : function() {
     61                 this.jqueryElement.removeClass(this.options.cssClasses.unselectItemCss);
     62                 this.jqueryElement.addClass(this.options.cssClasses.selectItemCss);
     63             },
     64             unselect : function() {
     65                 this.jqueryElement.removeClass(this.options.cssClasses.selectItemCss);
     66                 this.jqueryElement.addClass(this.options.cssClasses.unselectItemCss);
     67             },
     68
     69             __showHandler : function() {
     70                 this.select();
     71                 $super.__showHandler.call(this);
     72             },
     73             __leaveHandler : function() {
     74                 window.clearTimeout(this.showTimeoutId);
     75                 this.showTimeoutId = null;
     76                 this.hideTimeoutId = window.setTimeout($.proxy(
     77                     function() {
     78                         this.hide();
     79                     }, this), this.options.hideDelay);
     80                 this.unselect();
     81             },
     82
     83             destroy : function() {
     84                 // clean up code here
     85                 this.detach(this.id);
     86                 // call parent's destroy method
     87                 $super.destroy.call(this);
     88             }
     89         }
     90
     91     })());
     92 })(RichFaces.jQuery, RichFaces)