css-bootstrap/combobox.css
[roojs1] / roojs-bootstrap-debug.js
index 7a3f9dd..db7c7bb 100644 (file)
@@ -770,10 +770,10 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component,  {
  * @class Roo.bootstrap.Column
  * @extends Roo.bootstrap.Component
  * Bootstrap Column class
- * @cfg {Number} xs colspan out of 12 for mobile-sized screens
- * @cfg {Number} sm colspan out of 12 for tablet-sized screens
- * @cfg {Number} md colspan out of 12 for computer-sized screens
- * @cfg {Number} lg colspan out of 12 for large computer-sized screens
+ * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
+ * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
+ * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
+ * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
  * @cfg {String} html content of column.
  * 
  * @constructor
@@ -787,10 +787,10 @@ Roo.bootstrap.Column = function(config){
 
 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component,  {
     
-    xs: null,
-    sm: null,
-    md: null,
-    lg: null,
+    xs: false,
+    sm: false,
+    md: false,
+    lg: false,
     html: '',
     offset: 0,
     
@@ -804,7 +804,11 @@ Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component,  {
         
         var settings=this;
         ['xs','sm','md','lg'].map(function(size){
-            if (settings[size]) {
+            if (settings[size] !== false) {
+                if (!settings[size]) { // 0 = hidden
+                    cfg.cls += ' hidden-' + size;
+                    return;
+                }
                 cfg.cls += ' col-' + size + '-' + settings[size];
             }
         });
@@ -3000,6 +3004,7 @@ Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar,  {
  * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
  * @cfg {String} brand_href href of the brand
  * @cfg {Boolean} srButton generate the sr-only button (true | false) default true
+ * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
  * 
  * @constructor
  * Create a new Sidebar
@@ -3017,7 +3022,7 @@ Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar,  {
     brand: '',
     brand_href: false,
     srButton : true,
-    
+    autohide : false,
     
     getAutoCreate : function(){
         
@@ -3097,8 +3102,35 @@ Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar,  {
         return cfg;
 
         
-    }
-    
+    },
+    initEvents : function()
+    {
+        Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
+        
+        if (this.autohide) {
+            
+            var prevScroll = 0;
+            var ft = this.el;
+            
+            Roo.get(document).on('scroll',function(e) {
+                var ns = Roo.get(document).getScroll().top;
+                var os = prevScroll;
+                prevScroll = ns;
+                
+                if(ns > os){
+                    ft.removeClass('slideDown');
+                    ft.addClass('slideUp');
+                    return;
+                }
+                ft.removeClass('slideUp');
+                ft.addClass('slideDown');
+                 
+              
+          },this);
+        }
+    }    
+          
+      
     
     
 });
@@ -3559,6 +3591,13 @@ Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component,  {
         if (this.disabled) {
             return;
         }
+        
+        var tg = Roo.bootstrap.TabGroup.get(this.navId);
+        if (tg && tg.transition) {
+            Roo.log("waiting for the transitionend");
+            return;
+        }
+        
         Roo.log("fire event clicked");
         if(this.fireEvent('click', this, e) === false){
             return;
@@ -5157,9 +5196,7 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
         });
         
         var tbody =  this.mainBody;
-        
-        var renders = [];
-                    
+              
         if(ds.getCount() > 0){
             ds.data.each(function(d,rowIndex){
                 var row =  this.renderRow(cm, ds, rowIndex);
@@ -5237,7 +5274,6 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
         var row = this.renderRow(this.cm, this.store, rowIndex);
         // insert before rowIndex..
         var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
-        Roo.log(e);
         
         var _this = this;
                 
@@ -7658,8 +7694,6 @@ Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input,  {
     
     getAutoCreate : function(){
        
-        var parent = this.parent();
-        
         var align = this.labelAlign || this.parentLabelAlign();
         
         var id = Roo.id();
@@ -7760,16 +7794,16 @@ Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input,  {
         var combobox = {
             cls: 'select2-container input-group',
             cn: [
-                box,
-                {
-                    tag: 'ul',
-                    cls: 'typeahead typeahead-long dropdown-menu',
-                    style: 'display:none'
-                }
+                box
+//                {
+//                    tag: 'ul',
+//                    cls: 'typeahead typeahead-long dropdown-menu',
+//                    style: 'display:none'
+//                }
             ]
         };
         
-        if(!this.multiple){
+        if(!this.multiple && this.showToggleBtn){
             combobox.cn.push({
                 tag :'span',
                 cls : 'input-group-addon btn dropdown-toggle',
@@ -7884,9 +7918,11 @@ Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input,  {
     // private
     initEvents : function(){
         
+        this.createList();
+        
         Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
         //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
-        if(!this.multiple){
+        if(!this.multiple && this.showToggleBtn){
             this.trigger = this.el.select('span.dropdown-toggle',true).first();
             if(this.hideTrigger){
                 this.trigger.setDisplayed(false);
@@ -7905,6 +7941,18 @@ Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input,  {
         //    this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
         //}
     },
+    
+    createList : function()
+    {
+        this.list = Roo.get(document.body).createChild({
+            tag: 'ul',
+            cls: 'typeahead typeahead-long dropdown-menu',
+            style: 'display:none'
+        });
+        
+        this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
+        
+    },
 
     // private
     initTrigger : function(){
@@ -10066,7 +10114,8 @@ Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
  * @cfg {Boolean} append (true|false) default false
  * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
  * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
- * @cfg {Boolean} editNotList allow text type,but not show pull down, default false
+ * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
+ * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
  * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
  * @constructor
  * Create a new ComboBox.
@@ -10327,7 +10376,8 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
     autoFocus : true,
     tickable : false,
     btnPosition : 'right',
-    editNotList : false,
+    triggerList : true,
+    showToggleBtn : true,
     // element that contains real text value.. (when hidden is used..)
     
     getAutoCreate : function()
@@ -10419,12 +10469,12 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
         var combobox = {
             cls: 'select2-container input-group select2-container-multi',
             cn: [
-                box,
-                {
-                    tag: 'ul',
-                    cls: 'typeahead typeahead-long dropdown-menu',
-                    style: 'display:none; max-height:' + this.maxHeight + 'px;'
-                }
+                box
+//                {
+//                    tag: 'ul',
+//                    cls: 'typeahead typeahead-long dropdown-menu',
+//                    style: 'display:none; max-height:' + this.maxHeight + 'px;'
+//                }
             ]
         };
         
@@ -10492,13 +10542,12 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
         this.store = Roo.factory(this.store, Roo.data);
         
         if(this.tickable){
-            this.initTickableEvnets();
+            this.initTickableEvents();
             return;
         }
         
         Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
         
-        
         if(this.hiddenName){
             
             this.hiddenField = this.el.select('input.form-hidden-field',true).first();
@@ -10516,10 +10565,9 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
         //if(Roo.isGecko){
         //    this.el.dom.setAttribute('autocomplete', 'off');
         //}
-
+        
         var cls = 'x-combo-list';
-        this.list = this.el.select('ul.dropdown-menu',true).first();
-
+        
         //this.list = new Roo.Layer({
         //    shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
         //});
@@ -10584,7 +10632,7 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
             this.tpl = '<li><a href="#">{' + this.displayField + '}</a></li>';
         }
 
-        this.view = new Roo.View(this.el.select('ul.dropdown-menu',true).first(), this.tpl, {
+        this.view = new Roo.View(this.list, this.tpl, {
             singleSelect:true, store: this.store, selectedClass: this.selectedClass
         });
         //this.view.wrapEl.setDisplayed(false);
@@ -10717,8 +10765,10 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
         }
     },
     
-    initTickableEvnets: function()
+    initTickableEvents: function()
     {   
+        this.createList();
+        
         if(this.hiddenName){
             
             this.hiddenField = this.el.select('input.form-hidden-field',true).first();
@@ -10734,11 +10784,11 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
              
         }
         
-        this.list = this.el.select('ul.dropdown-menu',true).first();
+//        this.list = this.el.select('ul.dropdown-menu',true).first();
         
         this.choices = this.el.select('ul.select2-choices', true).first();
         this.searchField = this.el.select('ul li.select2-search-field', true).first();
-        if(this.editNotList){
+        if(this.triggerList){
             this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
         }
          
@@ -10774,7 +10824,7 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
             this.tpl = '<li class="select2-result"><div class="checkbox"><input id="{roo-id}" type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></li>';
         }
 
-        this.view = new Roo.View(this.el.select('ul.dropdown-menu',true).first(), this.tpl, {
+        this.view = new Roo.View(this.list, this.tpl, {
             singleSelect:true, tickable:true, parent:this, store: this.store, selectedClass: this.selectedClass
         });
         
@@ -10935,7 +10985,7 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
          if (!opts.add) {
             this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
          }
-        this.restrictHeight();
+//        this.restrictHeight();
         this.selectedIndex = -1;
     },
 
@@ -10954,7 +11004,7 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
         
         if(this.store.getCount() > 0){
             this.expand();
-            this.restrictHeight();
+//            this.restrictHeight();
             if(this.lastQuery == this.allQuery){
                 if(this.editable && !this.tickable){
                     this.inputEl().dom.select();
@@ -11092,6 +11142,12 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
     setFromData : function(o){
         
         if(this.multiple){
+            if(typeof o.display_name !== 'string'){
+                for(var i=0;i<o.display_name.length;i++){
+                    this.addItem({'id':o.id[i],'display_name':o.display_name[i]});
+                }
+                return;
+            }
             this.addItem(o);
             return;
         }
@@ -11226,6 +11282,7 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
         //this.list.beginUpdate();
         //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
         this.list.alignTo(this.inputEl(), this.listAlign);
+        this.list.alignTo(this.inputEl(), this.listAlign);
         //this.list.endUpdate();
     },
 
@@ -11272,9 +11329,8 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
         this.view.select(index);
         if(scrollIntoView !== false){
             var el = this.view.getNode(index);
-            if(el){
-                //this.innerList.scrollChildIntoView(el, false);
-                
+            if(el && !this.multiple && !this.tickable){
+                this.list.scrollChildIntoView(el, false);
             }
         }
     },
@@ -11438,8 +11494,9 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
     collapseIf : function(e){
         var in_combo  = e.within(this.el);
         var in_list =  e.within(this.list);
+        var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
         
-        if (in_combo || in_list) {
+        if (in_combo || in_list || is_list) {
             //e.stopPropagation();
             return;
         }
@@ -11461,9 +11518,11 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
             return;
         }
          Roo.log('expand');
-        this.list.alignTo(this.inputEl(), this.listAlign);
+        
         this.list.show();
         
+        this.restrictHeight();
+        
         if(this.tickable){
             
             this.tickItems = Roo.apply([], this.item);
@@ -11489,7 +11548,7 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
     {
         Roo.log('trigger click');
         
-        if(this.disabled){
+        if(this.disabled || !this.triggerList){
             return;
         }
         
@@ -13808,6 +13867,7 @@ Roo.bootstrap.TabGroup = function(config){
 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column,  {
     
     carousel : false,
+    transition : false,
      
     getAutoCreate : function()
     {
@@ -13886,8 +13946,6 @@ Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column,  {
     showPanel : function (pan)
     {
         
-        
-        
         if (typeof(pan) == 'number') {
             pan = this.tabs[pan];
         }
@@ -13903,15 +13961,16 @@ Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column,  {
             return false;
         }
         
-        
-        
         if (this.carousel) {
+            this.transition = true;
             var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur)  ? 'next' : 'prev';
             var lr = dir == 'next' ? 'left' : 'right';
             pan.el.addClass(dir); // or prev
             pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
             cur.el.addClass(lr); // or right
             pan.el.addClass(lr);
+            
+            var _this = this;
             cur.el.on('transitionend', function() {
                 Roo.log("trans end?");
                 
@@ -13921,6 +13980,7 @@ Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column,  {
                 cur.el.removeClass([lr]);
                 cur.setActive(false);
                 
+                _this.transition = false;
                 
             }, this, { single:  true } );
             return true;
@@ -16472,11 +16532,18 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
             this.doc = iframe.contentWindow.document;
             this.win = iframe.contentWindow;
         } else {
-            if (!Roo.get(this.frameId)) {
+//            if (!Roo.get(this.frameId)) {
+//                return;
+//            }
+//            this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
+//            this.win = Roo.get(this.frameId).dom.contentWindow;
+            
+            if (!Roo.get(this.frameId) && !iframe.contentDocument) {
                 return;
             }
+            
             this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
-            this.win = Roo.get(this.frameId).dom.contentWindow;
+            this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
         }
     },
     
@@ -19534,6 +19601,7 @@ Roo.bootstrap.dash = Roo.bootstrap.dash || {};
  * Bootstrap TabBox class
  * @cfg {String} title Title of the TabBox
  * @cfg {String} icon Icon of the TabBox
+ * @cfg {Boolean} showtabs (true|false) show the tabs default true
  * 
  * @constructor
  * Create a new TabBox
@@ -19559,6 +19627,7 @@ Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component,  {
 
     title : '',
     icon : false,
+    showtabs : true,
     
     getChildContainer : function()
     {
@@ -19621,6 +19690,10 @@ Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component,  {
         //Roo.log('addpane');
         //Roo.log(pane);
         // tabs are rendere left to right..
+        if(!this.showtabs){
+            return;
+        }
+        
         var ctr = this.el.select('.nav-tabs', true).first();
          
          
@@ -19733,7 +19806,7 @@ Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component,  {
             return;
         }
         this.title = str;
-        this.tab.select('a'.true).first().dom.innerHTML = str;
+        this.tab.select('a'true).first().dom.innerHTML = str;
         
     }