Roo/bootstrap/NavSidebarItem.js
authorAlan Knowles <alan@roojs.com>
Thu, 24 Nov 2016 07:03:18 +0000 (15:03 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 24 Nov 2016 07:03:18 +0000 (15:03 +0800)
roojs-bootstrap.js
roojs-bootstrap-debug.js

roojs-bootstrap-debug.js
roojs-bootstrap.js

index aa3e2f0..0d2c1d1 100644 (file)
@@ -1862,8 +1862,6 @@ Roo.bootstrap.MenuMgr = function(){
  * @extends Roo.bootstrap.Component
  * Bootstrap Menu class - container for MenuItems
  * @cfg {String} type (dropdown|treeview|submenu) type of menu
- * @cfg {boolean} open is the menu open?
-
  * 
  * @constructor
  * Create a new Menu
@@ -1951,6 +1949,7 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component,  {
     
     hidden:true,
     
+        
     parentMenu : false,
     
     getChildContainer : function() {
@@ -1988,9 +1987,6 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component,  {
         
         this.triggerEl.addClass('dropdown-toggle');
         
-        if (this.open) {
-            this.triggerEl.addClass('open');
-        }
         
         if (Roo.isTouch) {
             this.el.on('touchstart'  , this.onTouch, this);
@@ -4359,6 +4355,7 @@ Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component,  {
  * @extends Roo.bootstrap.NavItem
  * Bootstrap Navbar.NavSidebarItem class
  * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
+ * {bool} open is the menu open
  * @constructor
  * Create a new Navbar Button
  * @param {Object} config The config object
@@ -4389,6 +4386,8 @@ Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem,  {
     
     badgeWeight : 'default',
     
+    open: false,
+    
     getAutoCreate : function(){
         
         
@@ -4417,7 +4416,9 @@ Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem,  {
         if (this.disabled) {
             cfg.cls += ' disabled';
         }
-        
+        if (this.open) {
+            cfg.cls += ' open';
+        }
         // left icon..
         if (this.glyphicon || this.icon) {
             var c = this.glyphicon  ? ('glyphicon glyphicon-'+this.glyphicon)  : this.icon;
index eb3c571..822d9be 100644 (file)
@@ -78,15 +78,15 @@ if(g){C[g].remove(F);F.un("beforecheckchange",onBeforeCheck);}}};}();
 Roo.bootstrap.Menu=function(A){Roo.bootstrap.Menu.superclass.constructor.call(this,A);if(this.registerMenu&&this.type!='treeview'){Roo.bootstrap.MenuMgr.register(this);}this.addEvents({beforeshow:true,beforehide:true,show:true,hide:true,click:true,mouseover:true,mouseout:true,itemclick:true}
 );this.menuitems=new Roo.util.MixedCollection(false,function(o){return o.el.id;});};Roo.extend(Roo.bootstrap.Menu,Roo.bootstrap.Component,{triggerEl:false,type:false,registerMenu:true,menuItems:false,hidden:true,parentMenu:false,getChildContainer:function(){return this.el;
 },getAutoCreate:function(){var A={tag:'ul',cls:'dropdown-menu',style:'z-index:1000'};if(this.type==='submenu'){A.cls='submenu active';}if(this.type==='treeview'){A.cls='treeview-menu';}return A;},initEvents:function(){this.triggerEl.on(Roo.isTouch?'touchstart':'mouseup',this.onTriggerPress,this);
-this.triggerEl.addClass('dropdown-toggle');if(this.open){this.triggerEl.addClass('open');}if(Roo.isTouch){this.el.on('touchstart',this.onTouch,this);}this.el.on('click',this.onClick,this);this.el.on("mouseover",this.onMouseOver,this);this.el.on("mouseout",this.onMouseOut,this);
-},findTargetItem:function(e){var t=e.getTarget(".dropdown-menu-item",this.el,true);if(!t){return false;}if(t&&t.id){return this.menuitems.get(t.id);}return false;},onTouch:function(e){this.onClick(e);},onClick:function(e){Roo.log("menu.onClick");var t=this.findTargetItem(e);
-if(!t||t.isContainer){return;}Roo.log(e);Roo.log('pass click event');t.onClick(e);this.fireEvent("click",this,t,e);this.hide();},onMouseOver:function(e){var t=this.findTargetItem(e);this.fireEvent("mouseover",this,e,t);},isVisible:function(){return !this.hidden;
-},onMouseOut:function(e){var t=this.findTargetItem(e);this.fireEvent("mouseout",this,e,t);},show:function(el,A,B){this.parentMenu=B;if(!this.el){this.render();}this.fireEvent("beforeshow",this);this.showAt(this.el.getAlignToXY(el,A||this.defaultAlign),B,false);
-},showAt:function(xy,A,_e){this.parentMenu=A;if(!this.el){this.render();}if(_e!==false){this.fireEvent("beforeshow",this);}this.hideMenuItems();this.hidden=false;this.triggerEl.addClass('open');if(this.el.getWidth()+xy[0]>Roo.lib.Dom.getViewWidth()){xy[0]=xy[0]-this.el.getWidth()+this.triggerEl.getWidth();
-}this.el.setXY(xy);this.focus();this.fireEvent("show",this);},focus:function(){return;if(!this.hidden){this.doFocus.defer(50,this);}},doFocus:function(){if(!this.hidden){this.focusEl.focus();}},hide:function(A){this.hideMenuItems();if(this.el&&this.isVisible()){this.fireEvent("beforehide",this);
-if(this.activeItem){this.activeItem.deactivate();this.activeItem=null;}this.triggerEl.removeClass('open');;this.hidden=true;this.fireEvent("hide",this);}if(A===true&&this.parentMenu){this.parentMenu.hide(true);}},onTriggerPress:function(e){Roo.log('trigger press');
-var A=Roo.get(e.getTarget());if(A.findParent('.dropdown-menu')||A.findParent('.treeview-menu')){return;}if(this.isVisible()){Roo.log('hide');this.hide();}else{Roo.log('show');this.show(this.triggerEl,false,false);}e.stopEvent();},hideMenuItems:function(){Roo.select('.open',true).each(function(aa){aa.removeClass('open');
-})},addxtypeChild:function(A,B){var C=Roo.bootstrap.Menu.superclass.addxtypeChild.call(this,A,B);this.menuitems.add(C);return C;},getEl:function(){Roo.log(this.el);return this.el;}});
+this.triggerEl.addClass('dropdown-toggle');if(Roo.isTouch){this.el.on('touchstart',this.onTouch,this);}this.el.on('click',this.onClick,this);this.el.on("mouseover",this.onMouseOver,this);this.el.on("mouseout",this.onMouseOut,this);},findTargetItem:function(e){var t=e.getTarget(".dropdown-menu-item",this.el,true);
+if(!t){return false;}if(t&&t.id){return this.menuitems.get(t.id);}return false;},onTouch:function(e){this.onClick(e);},onClick:function(e){Roo.log("menu.onClick");var t=this.findTargetItem(e);if(!t||t.isContainer){return;}Roo.log(e);Roo.log('pass click event');
+t.onClick(e);this.fireEvent("click",this,t,e);this.hide();},onMouseOver:function(e){var t=this.findTargetItem(e);this.fireEvent("mouseover",this,e,t);},isVisible:function(){return !this.hidden;},onMouseOut:function(e){var t=this.findTargetItem(e);this.fireEvent("mouseout",this,e,t);
+},show:function(el,A,B){this.parentMenu=B;if(!this.el){this.render();}this.fireEvent("beforeshow",this);this.showAt(this.el.getAlignToXY(el,A||this.defaultAlign),B,false);},showAt:function(xy,A,_e){this.parentMenu=A;if(!this.el){this.render();}if(_e!==false){this.fireEvent("beforeshow",this);
+}this.hideMenuItems();this.hidden=false;this.triggerEl.addClass('open');if(this.el.getWidth()+xy[0]>Roo.lib.Dom.getViewWidth()){xy[0]=xy[0]-this.el.getWidth()+this.triggerEl.getWidth();}this.el.setXY(xy);this.focus();this.fireEvent("show",this);},focus:function(){return;
+if(!this.hidden){this.doFocus.defer(50,this);}},doFocus:function(){if(!this.hidden){this.focusEl.focus();}},hide:function(A){this.hideMenuItems();if(this.el&&this.isVisible()){this.fireEvent("beforehide",this);if(this.activeItem){this.activeItem.deactivate();
+this.activeItem=null;}this.triggerEl.removeClass('open');;this.hidden=true;this.fireEvent("hide",this);}if(A===true&&this.parentMenu){this.parentMenu.hide(true);}},onTriggerPress:function(e){Roo.log('trigger press');var A=Roo.get(e.getTarget());if(A.findParent('.dropdown-menu')||A.findParent('.treeview-menu')){return;
+}if(this.isVisible()){Roo.log('hide');this.hide();}else{Roo.log('show');this.show(this.triggerEl,false,false);}e.stopEvent();},hideMenuItems:function(){Roo.select('.open',true).each(function(aa){aa.removeClass('open');})},addxtypeChild:function(A,B){var C=Roo.bootstrap.Menu.superclass.addxtypeChild.call(this,A,B);
+this.menuitems.add(C);return C;},getEl:function(){Roo.log(this.el);return this.el;}});
 // Roo/bootstrap/MenuItem.js
 Roo.bootstrap.MenuItem=function(A){Roo.bootstrap.MenuItem.superclass.constructor.call(this,A);this.addEvents({"click":true});};Roo.extend(Roo.bootstrap.MenuItem,Roo.bootstrap.Component,{href:false,html:false,preventDefault:true,isContainer:false,getAutoCreate:function(){if(this.isContainer){return {tag:'li',cls:'dropdown-menu-item'}
 ;}var A={tag:'li',cls:'dropdown-menu-item',cn:[{tag:'a',href:'#',html:'Link'}]};if(this.parent().type=='treeview'){A.cls='treeview-menu';}A.cn[0].href=this.href||A.cn[0].href;A.cn[0].html=this.html||A.cn[0].html;return A;},initEvents:function(){if(this.parent().type=='treeview'){this.el.select('a').on('click',this.onClick,this);
@@ -170,13 +170,13 @@ if(nv){var E=nv.getWasActive();if(E){E.setActive(true,false,true);}}}},setDisabl
 },scrollToElement:function(e){var c=document.body;if(Roo.isFirefox||Roo.isIE||Roo.isIE11){c=document.documentElement;}var A=Roo.get(c).select('a[name='+this.href.split('#')[1]+']',true).first();if(!A){return;}var o=A.calcOffsetsTo(c);var B={target:A,value:o[1]}
 ;this.fireEvent('scrollto',this,B,e);Roo.get(c).scrollTo('top',B.value,true);return;}});
 // Roo/bootstrap/NavSidebarItem.js
-Roo.bootstrap.NavSidebarItem=function(A){Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this,A);this.addEvents({"click":true,'changed':true});};Roo.extend(Roo.bootstrap.NavSidebarItem,Roo.bootstrap.NavItem,{badgeWeight:'default',getAutoCreate:function(){var a={tag:'a',href:this.href||'#',cls:'',html:'',cn:[]}
-;var A={tag:'li',cls:'',cn:[a]};var B={tag:'span',html:this.html||''};if(this.active){A.cls+=' active';}if(this.disabled){A.cls+=' disabled';}if(this.glyphicon||this.icon){var c=this.glyphicon?('glyphicon glyphicon-'+this.glyphicon):this.icon;a.cn.push({tag:'i',cls:c}
-);}a.cn.push(B);if(this.badge!==''){a.cn.push({tag:'span',cls:'badge pull-right badge-'+this.badgeWeight,html:this.badge});}if(this.menu){a.cn.push({tag:'i',cls:'glyphicon glyphicon-chevron-down pull-right'});a.cls+='dropdown-toggle treeview';}return A;},initEvents:function(){if(typeof(this.menu)!='undefined'){this.menu.parentType=this.xtype;
-this.menu.triggerEl=this.el;this.menu=this.addxtype(Roo.apply({},this.menu));}this.el.on('click',this.onClick,this);if(this.badge!==''){this.badgeEl=this.el.select('.badge',true).first().setVisibilityMode(Roo.Element.DISPLAY);}},onClick:function(e){if(this.disabled){e.preventDefault();
-return;}if(this.preventDefault){e.preventDefault();}this.fireEvent('click',this);},disable:function(){this.setDisabled(true);},enable:function(){this.setDisabled(false);},setDisabled:function(A){if(this.disabled==A){return;}this.disabled=A;if(A){this.el.addClass('disabled');
-return;}this.el.removeClass('disabled');return;},setActive:function(A){if(this.active==A){return;}this.active=A;if(A){this.el.addClass('active');return;}this.el.removeClass('active');return;},isActive:function(){return this.active;},setBadge:function(A){if(!this.badgeEl){return;
-}this.badgeEl.dom.innerHTML=A;}});
+Roo.bootstrap.NavSidebarItem=function(A){Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this,A);this.addEvents({"click":true,'changed':true});};Roo.extend(Roo.bootstrap.NavSidebarItem,Roo.bootstrap.NavItem,{badgeWeight:'default',open:false,getAutoCreate:function(){var a={tag:'a',href:this.href||'#',cls:'',html:'',cn:[]}
+;var A={tag:'li',cls:'',cn:[a]};var B={tag:'span',html:this.html||''};if(this.active){A.cls+=' active';}if(this.disabled){A.cls+=' disabled';}if(this.open){A.cls+=' open';}if(this.glyphicon||this.icon){var c=this.glyphicon?('glyphicon glyphicon-'+this.glyphicon):this.icon;
+a.cn.push({tag:'i',cls:c});}a.cn.push(B);if(this.badge!==''){a.cn.push({tag:'span',cls:'badge pull-right badge-'+this.badgeWeight,html:this.badge});}if(this.menu){a.cn.push({tag:'i',cls:'glyphicon glyphicon-chevron-down pull-right'});a.cls+='dropdown-toggle treeview';
+}return A;},initEvents:function(){if(typeof(this.menu)!='undefined'){this.menu.parentType=this.xtype;this.menu.triggerEl=this.el;this.menu=this.addxtype(Roo.apply({},this.menu));}this.el.on('click',this.onClick,this);if(this.badge!==''){this.badgeEl=this.el.select('.badge',true).first().setVisibilityMode(Roo.Element.DISPLAY);
+}},onClick:function(e){if(this.disabled){e.preventDefault();return;}if(this.preventDefault){e.preventDefault();}this.fireEvent('click',this);},disable:function(){this.setDisabled(true);},enable:function(){this.setDisabled(false);},setDisabled:function(A){if(this.disabled==A){return;
+}this.disabled=A;if(A){this.el.addClass('disabled');return;}this.el.removeClass('disabled');return;},setActive:function(A){if(this.active==A){return;}this.active=A;if(A){this.el.addClass('active');return;}this.el.removeClass('active');return;},isActive:function(){return this.active;
+},setBadge:function(A){if(!this.badgeEl){return;}this.badgeEl.dom.innerHTML=A;}});
 // Roo/bootstrap/Row.js
 Roo.bootstrap.Row=function(A){Roo.bootstrap.Row.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Row,Roo.bootstrap.Component,{getAutoCreate:function(){return {cls:'row clearfix'};}});
 // Roo/bootstrap/Element.js