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()
87 cls : 'dropdown-button btn btn-' + this.weight,
97 cls : 'dropdown-toggle btn btn-' + this.weight,
107 cls : 'dropdown-menu'
113 if(this.isSubMenu()){
116 cls : 'dropdown-menu'
123 isSubMenu : function()
125 if(this.parent() instanceof Roo.bootstrap.menu.Item){
133 initEvents : function()
136 if(this.isSubMenu()){
142 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
143 this.triggerEl.on('click', this.onTriggerPress, this);
145 this.buttonEl = this.el.select('button.dropdown-button', true).first();
146 this.buttonEl.on('click', this.onClick, this);
150 onClick : function(e)
152 this.fireEvent("click", this, e);
155 onTriggerPress : function(e)
157 if (this.isVisible()) {
164 isVisible : function(){
170 this.fireEvent("beforeshow", this);
173 this.el.addClass('open');
175 Roo.get(document).on("mouseup", this.onMouseUp, this);
177 this.fireEvent("show", this);
183 this.fireEvent("beforehide", this);
186 this.el.removeClass('open');
188 Roo.get(document).un("mouseup", this.onMouseUp);
190 this.fireEvent("hide", this);
193 onMouseUp : function()