roojs-bootstrap.js
authorbenny <benny@roojs.com>
Fri, 20 Jul 2018 07:57:50 +0000 (15:57 +0800)
committerbenny <benny@roojs.com>
Fri, 20 Jul 2018 07:57:50 +0000 (15:57 +0800)
roojs-bootstrap-debug.js

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

index 0aad301..92a0df7 100644 (file)
@@ -562,7 +562,8 @@ Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component,  {
  * @cfg {String} badge text for badge
  * @cfg {String} theme default 
  * @cfg {Boolean} inverse 
- * @cfg {Boolean} toggle 
+ * @cfg {Boolean} toggle is it a slidy toggle button
+ * @cfg {Boolean} pressed (true|false) default null - if the button ahs active state
  * @cfg {String} ontext text for on toggle state
  * @cfg {String} offtext text for off toggle state
  * @cfg {Boolean} defaulton 
@@ -708,7 +709,7 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component,  {
         }
         
         
-        if (this.active) {
+        if (this.active || this.pressed === true) {
             cfg.cls += ' active';
         }
         
@@ -901,10 +902,16 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component,  {
     {
         return this.el.hasClass('active');
     },
+    /**
+     * set the text of the first selected button
+     */
     setText : function(str)
     {
         this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
     },
+    /**
+     * get the text of the first selected button
+     */
     getText : function()
     {
         return this.el.select('.roo-button-text',true).first().dom.innerHTML;
@@ -920,7 +927,7 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component,  {
     },
     setWeight : function(str)
     {
-         this.el.removeClass(this.weightClass);
+       this.el.removeClass(this.weightClass);
         this.el.addClass('btn-' + str);        
     }
     
index 83bd3fc..be0eb91 100644 (file)
@@ -25,16 +25,16 @@ Roo.bootstrap.Button=function(A){Roo.bootstrap.Button.superclass.constructor.cal
 ;if(['a','button','input','submit'].indexOf(this.tag)<0){throw "Invalid value for tag: "+this.tag+". must be a, button, input or submit.";this.tag='button';}else{A.tag=this.tag;}A.html='<span class="roo-button-text">'+(this.html||A.html)+'</span>';if(this.toggle==true){A={tag:'div',cls:'slider-frame roo-button',cn:[{tag:'span','data-on-text':'ON','data-off-text':'OFF',cls:'slider-button',html:this.offtext}
 ]};if(['default','primary','success','info','warning','danger','link'].indexOf(this.weight)>-1){A.cls+=' '+this.weight;}return A;}if(this.isClose){A.cls+=' close';A["aria-hidden"]=true;A.html="&times;";return A;}if(this.theme==='default'){A.cls='btn roo-button';
 this.weight=this.weight.length?this.weight:'default';if(['default','primary','success','info','warning','danger','link'].indexOf(this.weight)>-1){A.cls+=' btn-'+this.weight;}}else if(this.theme==='glow'){A.tag='a';A.cls='btn-glow roo-button';if(['default','primary','success','info','warning','danger','link'].indexOf(this.weight)>-1){A.cls+=' '+this.weight;
-}}if(this.inverse){this.cls+=' inverse';}if(this.active){A.cls+=' active';}if(this.disabled){A.disabled='disabled';}if(this.items){Roo.log('changing to ul');A.tag='ul';this.glyphicon='caret';}A.cls+=this.size.length?(' btn-'+this.size):'';if(this.parentType==='Navbar'&&!this.parent().bar){Roo.log('changing to li?');
-A.tag='li';A.cls='';A.cn=[{tag:'a',cls:'roo-button',html:this.html,href:this.href||'#'}];if(this.menu){A.cn[0].html=this.html+' <span class="caret"></span>';A.cls+=' dropdown';}delete A.html;}A.cls+=this.parentType==='Navbar'?' navbar-btn':'';if(this.glyphicon){A.html=' '+A.html;
-A.cn=[{tag:'span',cls:'glyphicon glyphicon-'+this.glyphicon}];}if(this.badge){A.html+=' ';A.tag='a';A.href=this.href;var B=A.html;if(this.glyphicon){B={tag:'span',cls:'glyphicon glyphicon-'+this.glyphicon,html:this.html};}A.cn=[B,{tag:'span',cls:'badge',html:this.badge}
-];A.html='';}if(this.menu){A.cls+=' dropdown';A.html=typeof(A.html)!='undefined'?A.html+' <span class="caret"></span>':'<span class="caret"></span>';}if(A.tag!=='a'&&this.href!==''){throw "Tag must be a to set href.";}else if(this.href.length>0){A.href=this.href;
-}if(this.removeClass){A.cls='';}if(this.target){A.target=this.target;}return A;},initEvents:function(){if(typeof(this.menu)!='undefined'){this.menu.parentType=this.xtype;this.menu.triggerEl=this.el;this.addxtype(Roo.apply({},this.menu));}if(this.el.hasClass('roo-button')){this.el.on('click',this.onClick,this);
-}else{this.el.select('.roo-button').on('click',this.onClick,this);}if(this.removeClass){this.el.on('click',this.onClick,this);}this.el.enableDisplayMode();},onClick:function(e){if(this.disabled){return;}Roo.log('button on click ');if(this.preventDefault){e.preventDefault();
-}if(this.pressed===true||this.pressed===false){this.pressed=!this.pressed;this.el[this.pressed?'addClass':'removeClass']('active');this.fireEvent('toggle',this,e,this.pressed);}this.fireEvent('click',this,e);},enable:function(){this.disabled=false;this.el.removeClass('disabled');
-},disable:function(){this.disabled=true;this.el.addClass('disabled');},setActive:function(v){this.el[v?'addClass':'removeClass']('active');},toggleActive:function(){var A=this.el.hasClass('active');this.setActive(!A);},isActive:function(){return this.el.hasClass('active');
-},setText:function(A){this.el.select('.roo-button-text',true).first().dom.innerHTML=A;},getText:function(){return this.el.select('.roo-button-text',true).first().dom.innerHTML;},hide:function(){this.el.hide();},show:function(){this.el.show();},setWeight:function(A){this.el.removeClass(this.weightClass);
-this.el.addClass('btn-'+A);}});
+}}if(this.inverse){this.cls+=' inverse';}if(this.active||this.pressed===true){A.cls+=' active';}if(this.disabled){A.disabled='disabled';}if(this.items){Roo.log('changing to ul');A.tag='ul';this.glyphicon='caret';}A.cls+=this.size.length?(' btn-'+this.size):'';
+if(this.parentType==='Navbar'&&!this.parent().bar){Roo.log('changing to li?');A.tag='li';A.cls='';A.cn=[{tag:'a',cls:'roo-button',html:this.html,href:this.href||'#'}];if(this.menu){A.cn[0].html=this.html+' <span class="caret"></span>';A.cls+=' dropdown';}
+delete A.html;}A.cls+=this.parentType==='Navbar'?' navbar-btn':'';if(this.glyphicon){A.html=' '+A.html;A.cn=[{tag:'span',cls:'glyphicon glyphicon-'+this.glyphicon}];}if(this.badge){A.html+=' ';A.tag='a';A.href=this.href;var B=A.html;if(this.glyphicon){B={tag:'span',cls:'glyphicon glyphicon-'+this.glyphicon,html:this.html}
+;}A.cn=[B,{tag:'span',cls:'badge',html:this.badge}];A.html='';}if(this.menu){A.cls+=' dropdown';A.html=typeof(A.html)!='undefined'?A.html+' <span class="caret"></span>':'<span class="caret"></span>';}if(A.tag!=='a'&&this.href!==''){throw "Tag must be a to set href.";
+}else if(this.href.length>0){A.href=this.href;}if(this.removeClass){A.cls='';}if(this.target){A.target=this.target;}return A;},initEvents:function(){if(typeof(this.menu)!='undefined'){this.menu.parentType=this.xtype;this.menu.triggerEl=this.el;this.addxtype(Roo.apply({}
+,this.menu));}if(this.el.hasClass('roo-button')){this.el.on('click',this.onClick,this);}else{this.el.select('.roo-button').on('click',this.onClick,this);}if(this.removeClass){this.el.on('click',this.onClick,this);}this.el.enableDisplayMode();},onClick:function(e){if(this.disabled){return;
+}Roo.log('button on click ');if(this.preventDefault){e.preventDefault();}if(this.pressed===true||this.pressed===false){this.pressed=!this.pressed;this.el[this.pressed?'addClass':'removeClass']('active');this.fireEvent('toggle',this,e,this.pressed);}this.fireEvent('click',this,e);
+},enable:function(){this.disabled=false;this.el.removeClass('disabled');},disable:function(){this.disabled=true;this.el.addClass('disabled');},setActive:function(v){this.el[v?'addClass':'removeClass']('active');},toggleActive:function(){var A=this.el.hasClass('active');
+this.setActive(!A);},isActive:function(){return this.el.hasClass('active');},setText:function(A){this.el.select('.roo-button-text',true).first().dom.innerHTML=A;},getText:function(){return this.el.select('.roo-button-text',true).first().dom.innerHTML;},hide:function(){this.el.hide();
+},show:function(){this.el.show();},setWeight:function(A){this.el.removeClass(this.weightClass);this.el.addClass('btn-'+A);}});
 // Roo/bootstrap/Column.js
 Roo.bootstrap.Column=function(A){Roo.bootstrap.Column.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Column,Roo.bootstrap.Component,{xs:false,sm:false,md:false,lg:false,xsoff:false,smoff:false,mdoff:false,lgoff:false,html:'',offset:0,alert:false,fa:false,icon:false,hidden:false,fasize:1,getAutoCreate:function(){var A=Roo.apply({}
 ,Roo.bootstrap.Column.superclass.getAutoCreate.call(this));A={tag:'div',cls:'column'};var B=this;['xs','sm','md','lg'].map(function(D){if(B[D+'off']!==false){A.cls+=' col-'+D+'-offset-'+B[D+'off'];}if(B[D]===false){return;}if(!B[D]){A.cls+=' hidden-'+D;return;