7 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
10 * @class Roo.bootstrap.menu.Menu
11 * @extends Roo.bootstrap.Component
12 * Bootstrap Menu class - container for Menu
13 * @cfg {String} html Text of the menu
14 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
15 * @cfg {String} icon Font awesome icon
20 * @param {Object} config The config object
24 Roo.bootstrap.menu.Menu = function(config){
25 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
30 * Fires before this menu is displayed
31 * @param {Roo.bootstrap.menu.Menu} this
36 * Fires before this menu is hidden
37 * @param {Roo.bootstrap.menu.Menu} this
42 * Fires after this menu is displayed
43 * @param {Roo.bootstrap.menu.Menu} this
48 * Fires after this menu is hidden
49 * @param {Roo.bootstrap.menu.Menu} this
54 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
55 * @param {Roo.bootstrap.menu.Menu} this
56 * @param {Roo.EventObject} e
63 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
71 getChildContainer : function() {
76 return this.el.select('ul.dropdown-menu', true).first();
79 getAutoCreate : function()
84 cls : 'roo-menu-text',
92 cls : 'fa ' + this.icon
103 cls : 'dropdown-button btn btn-' + this.weight,
108 cls : 'dropdown-toggle btn btn-' + this.weight,
118 cls : 'dropdown-menu'
124 if(this.isSubMenu()){
127 cls : 'dropdown-menu'
134 isSubMenu : function()
136 if(this.parent() instanceof Roo.bootstrap.menu.Item){
144 initEvents : function()
147 if(this.isSubMenu()){
153 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
154 this.triggerEl.on('click', this.onTriggerPress, this);
156 this.buttonEl = this.el.select('button.dropdown-button', true).first();
157 this.buttonEl.on('click', this.onClick, this);
161 onClick : function(e)
163 this.fireEvent("click", this, e);
166 onTriggerPress : function(e)
168 if (this.isVisible()) {
175 isVisible : function(){
181 this.fireEvent("beforeshow", this);
184 this.el.addClass('open');
186 Roo.get(document).on("mouseup", this.onMouseUp, this);
188 this.fireEvent("show", this);
194 this.fireEvent("beforehide", this);
197 this.el.removeClass('open');
199 Roo.get(document).un("mouseup", this.onMouseUp);
201 this.fireEvent("hide", this);
204 onMouseUp : function()