Roo/bootstrap/ComboBox.js
[roojs1] / Roo / bootstrap / ComboBox.js
index 548b925..ee0c049 100644 (file)
@@ -106,8 +106,13 @@ Roo.bootstrap.ComboBox = function(config){
             * @param {Roo.bootstrap.ComboBox} combo This combo box
             * @param {Object} cfg set html .
             */
-        'touchviewdisplay' : true
-        
+        'touchviewdisplay' : true,
+        /**
+         * @event ontouchviewload
+         * Fires when touch view load (local store)
+         * @param {Roo.bootstrap.ComboBox} combo This combo box
+        */
+        'ontouchviewload' : true
     });
     
     this.item = [];
@@ -647,6 +652,8 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
             throw "can not find store for combo";
         }
         
+        this.indicator = this.indicatorEl();
+        
         this.store = Roo.factory(this.store, Roo.data);
         this.store.parent = this;
         
@@ -958,11 +965,16 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
         this.list.on('scroll', this.onViewScroll, this);
         
         if(!this.tpl){
-            this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}" type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
+            this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' + 
+                'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
         }
 
         this.view = new Roo.View(this.list, this.tpl, {
-            singleSelect:true, tickable:true, parent:this, store: this.store, selectedClass: this.selectedClass
+            singleSelect:true,
+            tickable:true,
+            parent:this,
+            store: this.store,
+            selectedClass: this.selectedClass
         });
         
         //this.view.wrapEl.setDisplayed(false);
@@ -1511,6 +1523,7 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
     onEmptyResults : function(){
         
         if(this.tickable && this.editable){
+            this.hasFocus = false;
             this.restrictHeight();
             return;
         }
@@ -2127,6 +2140,10 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
     
     validate : function()
     {
+        if(this.getVisibilityEl().hasClass('hidden')){
+            return true;
+        }
+        
         var v = this.getRawValue();
         
         if(this.multiple){
@@ -2349,23 +2366,29 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
                 cfg.cn = [
                     {
                         tag: 'label',
+                        'for' :  id,
                         cls : 'control-label',
-                        html : this.fieldLabel,
                         cn : [
                             {
-                               tag : 'i',
-                               cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
-                               tooltip : 'This field is required'
+                                tag : 'span',
+                                html : this.fieldLabel
+                            },
+                            {
+                                tag : 'i',
+                                cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
+                                tooltip : 'This field is required'
                             }
                         ]
                     },
                     {
-                        cls : '', 
+                        cls : "",
                         cn: [
                             combobox
                         ]
                     }
+
                 ];
+                
                 labelCfg = cfg.cn[0];
                 contentCfg = cfg.cn[1];
             }
@@ -2708,6 +2731,8 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
             (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
         }
         
+        this.fireEvent('ontouchviewload', this);
+        
     },
     
     onTouchViewLoadException : function()
@@ -2827,6 +2852,14 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
             
             var default_text = '-- SELECT --';
             
+            if(this.placeholder.length){
+                default_text = this.placeholder;
+            }
+            
+            if(this.emptyTitle.length){
+                default_text += ' - ' + this.emptyTitle + ' -';
+            }
+            
             var opt = this.inputEl().createChild({
                 tag: 'option',
                 value : 0,