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
16 * @cfg {String} pos Menu align to (top | bottom) default bottom
21 * @param {Object} config The config object
25 Roo.bootstrap.menu.Menu = function(config){
26 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
31 * Fires before this menu is displayed
32 * @param {Roo.bootstrap.menu.Menu} this
37 * Fires before this menu is hidden
38 * @param {Roo.bootstrap.menu.Menu} this
43 * Fires after this menu is displayed
44 * @param {Roo.bootstrap.menu.Menu} this
49 * Fires after this menu is hidden
50 * @param {Roo.bootstrap.menu.Menu} this
55 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
56 * @param {Roo.bootstrap.menu.Menu} this
57 * @param {Roo.EventObject} e
64 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
73 getChildContainer : function() {
78 return this.el.select('ul.dropdown-menu', true).first();
81 getAutoCreate : function()
86 cls : 'roo-menu-text',
94 cls : 'fa ' + this.icon
105 cls : 'dropdown-button btn btn-' + this.weight,
110 cls : 'dropdown-toggle btn btn-' + this.weight,
120 cls : 'dropdown-menu'
126 if(this.pos == 'top'){
127 cfg.cls += ' dropup';
129 Roo.log('create menu');
130 Roo.log(this.parent());
131 Roo.log(this.isSubMenu());
132 if(this.isSubMenu()){
135 cls : 'dropdown-menu'
142 isSubMenu : function()
144 if(this.parent() instanceof Roo.bootstrap.menu.Item){
152 initEvents : function()
155 if(this.isSubMenu()){
161 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
162 this.triggerEl.on('click', this.onTriggerPress, this);
164 this.buttonEl = this.el.select('button.dropdown-button', true).first();
165 this.buttonEl.on('click', this.onClick, this);
169 onClick : function(e)
171 this.fireEvent("click", this, e);
174 onTriggerPress : function(e)
176 if (this.isVisible()) {
183 isVisible : function(){
189 this.fireEvent("beforeshow", this);
192 this.el.addClass('open');
194 Roo.get(document).on("mouseup", this.onMouseUp, this);
196 this.fireEvent("show", this);
202 this.fireEvent("beforehide", this);
205 this.el.removeClass('open');
207 Roo.get(document).un("mouseup", this.onMouseUp);
209 this.fireEvent("hide", this);
212 onMouseUp : function()