allow string based values for comboboxarray
[roojs1] / Roo / form / DayPicker.js
index 5291a63..84e2a22 100644 (file)
@@ -31,7 +31,7 @@ Roo.extend(Roo.form.DayPicker, Roo.form.Field,  {
      * @cfg {String/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to
      * {tag: "input", type: "checkbox", autocomplete: "off"})
      */
-    defaultAutoCreate : { tag: "input", type: 'hidden', autocomplete: "off"},
+    defaultAutoCreate : { tag: "input", type: 'hidden', autocomplete: "new-password"},
     
    
     actionMode : 'viewEl', 
@@ -75,19 +75,19 @@ Roo.extend(Roo.form.DayPicker, Roo.form.Field,  {
        
         this.wrap = this.el.wrap({cls: 'x-form-daypick-item '});
         
-        var r1 = '<table><tr>'
+        var r1 = '<table><tr>';
         var r2 = '<tr class="x-form-daypick-icons">';
         for (var i=0; i < 7; i++) {
-            r1+= '<td>' + Date.dayNames[i].substring(0,3) + '</td>';
+            r1+= '<td><div>' + Date.dayNames[i].substring(0,3) + '</div></td>';
             r2+= '<td><img class="x-menu-item-icon" src="' + Roo.BLANK_IMAGE_URL  +'"></td>';
         }
         
         var viewEl = this.wrap.createChild( r1 + '</tr>' + r2 + '</tr></table>');
-        
+        viewEl.select('img').on('click', this.onClick, this);
         this.viewEl = viewEl;   
         
-        this.wrap.on('click', this.onClick,  this); 
         
+        // this will not work on Chrome!!!
         this.el.on('DOMAttrModified', this.setFromHidden,  this); //ff
         this.el.on('propertychange', this.setFromHidden,  this);  //ie
         
@@ -104,18 +104,29 @@ Roo.extend(Roo.form.DayPicker, Roo.form.Field,  {
      * @return {Boolean} True if checked, else false
      */
     getValue : function(){
-        return '';
+        return this.el.dom.value;
         
     },
 
        // private
-    onClick : function(){ 
+    onClick : function(e){ 
         //this.setChecked(!this.checked);
-
+        Roo.get(e.target).toggleClass('x-menu-item-checked');
+        this.refreshValue();
         //if(this.el.dom.checked != this.checked){
         //    this.setValue(this.el.dom.checked);
        // }
     },
+    
+    // private
+    refreshValue : function()
+    {
+        var val = '';
+        this.viewEl.select('img',true).each(function(e,i,n)  {
+            val += e.is(".x-menu-item-checked") ? String(n) : '';
+        });
+        this.setValue(val, true);
+    },
 
     /**
      * Sets the checked state of the checkbox.
@@ -124,8 +135,30 @@ Roo.extend(Roo.form.DayPicker, Roo.form.Field,  {
      * @param {Boolean/String} suppressEvent - whether to suppress the checkchange event.
      */
     setValue : function(v,suppressEvent){
+        if (!this.el.dom) {
+            return;
+        }
+        var old = this.el.dom.value ;
+        this.el.dom.value = v;
+        if (suppressEvent) {
+            return ;
+        }
+         
+        // update display..
+        this.viewEl.select('img',true).each(function(e,i,n)  {
+            
+            var on = e.is(".x-menu-item-checked");
+            var newv = v.indexOf(String(n)) > -1;
+            if (on != newv) {
+                e.toggleClass('x-menu-item-checked');
+            }
+            
+        });
+        
+        
+        this.fireEvent('change', this, v, old);
+        
         
-       
     },
    
     // handle setting of hidden value by some other method!!?!?