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,
92 cls : 'dropdown-toggle btn btn-' + this.weight,
102 cls : 'dropdown-menu'
108 if(this.isSubMenu()){
111 cls : 'dropdown-menu'
118 isSubMenu : function()
120 if(this.parent() instanceof Roo.bootstrap.menu.Item){
128 initEvents : function()
131 if(this.isSubMenu()){
137 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
138 this.triggerEl.on('click', this.onTriggerPress, this);
140 this.buttonEl = this.el.select('button.dropdown-button', true).first();
141 this.buttonEl.on('click', this.onClick, this);
145 onClick : function(e)
147 this.fireEvent("click", this, e);
150 onTriggerPress : function(e)
152 if (this.isVisible()) {
159 isVisible : function(){
165 this.fireEvent("beforeshow", this);
168 this.el.addClass('open');
170 Roo.get(document).on("mouseup", this.onMouseUp, this);
172 this.fireEvent("show", this);
178 this.fireEvent("beforehide", this);
181 this.el.removeClass('open');
183 Roo.get(document).un("mouseup", this.onMouseUp);
185 this.fireEvent("hide", this);
188 onMouseUp : function()