Roo/bootstrap/ComboBox.js
[roojs1] / Roo / bootstrap / ComboBox.js
index 53f182f..053e05a 100644 (file)
@@ -647,6 +647,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 +960,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 +1518,7 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
     onEmptyResults : function(){
         
         if(this.tickable && this.editable){
+            this.hasFocus = false;
             this.restrictHeight();
             return;
         }
@@ -2127,6 +2135,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){
@@ -2343,31 +2355,35 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
             
             var labelCfg = cfg.cn[1];
             var contentCfg = cfg.cn[2];
+            
 
             if(this.indicatorpos == 'right'){
-                
-                Roo.log('-------------------right-------------------');
-                
                 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];
             }
@@ -2520,6 +2536,8 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
             document.activeElement.blur();
         }, this);
         
+        this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
+        
         return;
         
         
@@ -2580,6 +2598,13 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
         }else{
             this.touchViewEl.addClass('in');
         }
+        
+        if(this._touchViewMask){
+            this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true),   Roo.lib.Dom.getViewHeight(true));
+            this._touchViewMask.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
+            this._touchViewMask.addClass('show');
+        }
+        
 
         this.doTouchViewQuery();
         
@@ -2829,6 +2854,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,