Roo/form/ComboBoxArray.js
[roojs1] / roojs-ui-debug.js
index 3d6af0b..627c0e8 100644 (file)
@@ -10336,9 +10336,14 @@ Roo.extend(Roo.DatePicker, Roo.Component, {
      */
     setValue : function(value){
         var old = this.value;
+        
         if (typeof(value) == 'string') {
+         
             value = Date.parseDate(value, this.format);
         }
+        if (!value) {
+            value = new Date();
+        }
         
         this.value = value.clearTime(true);
         if(this.el){
@@ -10361,7 +10366,7 @@ Roo.extend(Roo.DatePicker, Roo.Component, {
         }
     },
 
-    // private
+    // privateval
     onRender : function(container, position){
         
         var m = [
@@ -22723,6 +22728,7 @@ Roo.extend(Roo.form.DateField, Roo.form.TriggerField,  {
     {
         value = this.formatDate(value);
         if(!Roo.form.DateField.superclass.validateValue.call(this, value)){
+            Roo.log('super failed');
             return false;
         }
         if(value.length < 1){ // if it's blank and textfield didn't flag it then it's valid
@@ -22731,6 +22737,7 @@ Roo.extend(Roo.form.DateField, Roo.form.TriggerField,  {
         var svalue = value;
         value = this.parseDate(value);
         if(!value){
+            Roo.log('parse date failed' + svalue);
             this.markInvalid(String.format(this.invalidText, svalue, this.format));
             return false;
         }
@@ -22815,7 +22822,7 @@ dateField.setValue('2006-5-4');
             return value;
         }
         var v = Date.parseDate(value, this.format);
-         if (this.useIso) {
+         if (!v && this.useIso) {
             v = Date.parseDate(value, 'Y-m-d');
         }
         if(!v && this.altFormats){
@@ -22838,6 +22845,7 @@ dateField.setValue('2006-5-4');
     // private
     menuListeners : {
         select: function(m, d){
+            
             this.setValue(d);
             this.fireEvent('select', this, d);
         },
@@ -23147,6 +23155,10 @@ monthField.setValue('2006-5-4');
      */
     setValue : function(date){
         Roo.log('month setValue' + date);
+        // can only be first of month..
+        
+        var val = this.parseDate(date);
+        
         if (this.hiddenField) {
             this.hiddenField.value = this.formatDate(this.parseDate(date), 'Y-m-d');
         }
@@ -23157,12 +23169,17 @@ monthField.setValue('2006-5-4');
     // private
     parseDate : function(value){
         if(!value || value instanceof Date){
+            value = value ? Date.parseDate(value.format('Y-m') + '-01', 'Y-m-d') : null;
             return value;
         }
         var v = Date.parseDate(value, this.format);
-        if (this.useIso) {
+        if (!v && this.useIso) {
             v = Date.parseDate(value, 'Y-m-d');
         }
+        if (v) {
+            // 
+            v = Date.parseDate(v.format('Y-m') +'-01', 'Y-m-d');
+        }
         
         
         if(!v && this.altFormats){
@@ -23207,9 +23224,7 @@ monthField.setValue('2006-5-4');
         }
         if(this.menu == null){
             this.menu = new Roo.menu.DateMenu();
-            this.menu.on(Roo.apply({}, this.menuListeners, {
-                scope:this
-            }));
+           
         }
         
         Roo.apply(this.menu.picker,  {
@@ -23220,42 +23235,56 @@ monthField.setValue('2006-5-4');
             disabledDatesRE : this.ddMatch,
             disabledDatesText : this.disabledDatesText,
             
-            format : this.format,
+            format : this.useIso ? 'Y-m-d' : this.format,
             minText : String.format(this.minText, this.formatDate(this.minValue)),
             maxText : String.format(this.maxText, this.formatDate(this.maxValue))
             
         });
-        
+         this.menu.on(Roo.apply({}, this.menuListeners, {
+            scope:this
+        }));
        
         
         var m = this.menu;
         var p = m.picker;
-        p.format = this.useIso ? 'Y-m-d' : this.format;  // make sure they are the same..?
-        Roo.log('picker set value');
-        Roo.log(this.getValue());
-        p.setValue(this.getValue() || new Date());
-        m.show(this.el, "tl-bl?");
-        
-        // hidden the day picker
-        Roo.select('.x-date-picker table', true).first().dom.style.visibility = "hidden";
         
+        // hide month picker get's called when we called by 'before hide';
         
+        var ignorehide = true;
         p.hideMonthPicker  = function(disableAnim){
-            if(this.monthPicker){
+            if (ignorehide) {
+                return;
+            }
+             if(this.monthPicker){
+                Roo.log("hideMonthPicker called");
                 if(disableAnim === true){
                     this.monthPicker.hide();
                 }else{
                     this.monthPicker.slideOut('t', {duration:.2});
-                    p.setValue(new Date(m.picker.mpSelYear, m.picker.mpSelMonth));
+                    p.setValue(new Date(m.picker.mpSelYear, m.picker.mpSelMonth, 1));
                     p.fireEvent("select", this, this.value);
                     m.hide();
                 }
             }
         }
         
-        (function() {
-            p.showMonthPicker();
-        }).defer(100);
+        Roo.log('picker set value');
+        Roo.log(this.getValue());
+        p.setValue(this.getValue() ? this.parseDate(this.getValue()) : new Date());
+        m.show(this.el, 'tl-bl?');
+        ignorehide  = false;
+        // this will trigger hideMonthPicker..
+        
+        
+        // hidden the day picker
+        Roo.select('.x-date-picker table', true).first().dom.style.visibility = "hidden";
+        
+        
+        
+      
+        
+        p.showMonthPicker.defer(100, p);
+    
         
        
     },
@@ -24006,6 +24035,9 @@ Roo.extend(Roo.form.ComboBox, Roo.form.TriggerField, {
         this.setValue(this.originalValue);
         this.clearInvalid();
         this.lastData = false;
+        if (this.view) {
+            this.view.clearSelections();
+        }
     },
     // private
     findRecord : function(prop, value){
@@ -24459,6 +24491,7 @@ Roo.extend(Roo.form.ComboBoxArray, Roo.form.TextField,
         
         this.combo = Roo.factory(this.combo, Roo.form);
         this.combo.onRender(ct, position);
+        this.combo.initEvents();
         
         // assigned so form know we need to do this..
         this.store          = this.combo.store;
@@ -26122,11 +26155,12 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
         
         var remove_keep_children= Roo.form.HtmlEditor.remove.indexOf(node.tagName.toLowerCase()) > -1;
         
-        // remove <a name=....> as rendering on yahoo mailer is bored with this.
+        // remove <a name=....> as rendering on yahoo mailer is borked with this.
+        // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
         
-        if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
-            remove_keep_children = true;
-        }
+        //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
+        //    remove_keep_children = true;
+        //}
         
         if (remove_keep_children) {
             this.cleanUpChildren(node);
@@ -26315,7 +26349,7 @@ Roo.form.HtmlEditor.ablack = [
 ];
     
 Roo.form.HtmlEditor.aclean = [ 
-    'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
+    'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc' 
 ];
 
 // protocols..
@@ -27357,6 +27391,7 @@ Roo.apply(Roo.form.HtmlEditor.ToolbarContext.prototype,  {
         }
         
         if (!updateFooter) {
+            //this.footDisp.dom.innerHTML = ''; 
             return;
         }
         // update the footer
@@ -27383,6 +27418,8 @@ Roo.apply(Roo.form.HtmlEditor.ToolbarContext.prototype,  {
             
         //this.editorsyncValue();
     },
+     
+    
    
        
     // private
@@ -27519,6 +27556,56 @@ Roo.apply(Roo.form.HtmlEditor.ToolbarContext.prototype,  {
             }));
              
         }
+        tb.addFill();
+        var _this = this;
+        tb.addButton( {
+            text: 'Remove Tag',
+    
+            listeners : {
+                click : function ()
+                {
+                    // remove
+                    // undo does not work.
+                     
+                    var sn = tb.selectedNode;
+                    Roo.log(sn);
+                    var pn = sn.parentNode;
+                    
+                    var stn =  sn.childNodes[0];
+                    var en = sn.childNodes[sn.childNodes.length - 1 ];
+                    while (sn.childNodes.length) {
+                        var node = sn.childNodes[0];
+                        sn.removeChild(node);
+                        Roo.log(node);
+                        pn.insertBefore(node, sn);
+                        
+                    }
+                    pn.removeChild(sn);
+                    var range = editor.createRange();
+        
+                    range.setStart(stn,0);
+                    range.setEnd(en,0); //????
+                    //range.selectNode(sel);
+                    
+                    
+                    var selection = editor.getSelection();
+                    selection.removeAllRanges();
+                    selection.addRange(range);
+                    
+                    
+                    
+                    //_this.updateToolbar(null, null, pn);
+                    _this.updateToolbar(null, null, null);
+                    this.footDisp.dom.innerHTML = ''; 
+                }
+            }
+            
+                    
+                
+            
+        });
+        
+        
         tb.el.on('click', function(e){
             e.preventDefault(); // what does this do?
         });
@@ -33179,6 +33266,16 @@ Roo.ContentPanel = function(el, config, content){
     }else{
         this.resizeEl = this.el;
     }
+    // handle view.xtype
+    
+    if (this.view && typeof(this.view.xtype) != 'undefined') {
+        this.view.el = this.el.appendChild(document.createElement("div"));
+        this.view = Roo.factory(this.view);
+        this.view.render && this.view.render(false, ''); // render blank..
+    }
+    
+    
+    
     this.addEvents({
         /**
          * @event activate
@@ -34373,7 +34470,7 @@ Roo.extend(Roo.grid.Grid, Roo.util.Observable, {
     */
     loadMask : false,
     /**
-    * @cfg {Roo.dd.DropTarget} dragTarget An {@link Roo.dd.DragTarget} config
+    * @cfg {Roo.dd.DropTarget} dropTarget An {@link Roo.dd.DropTarget} config
     */
     dropTarget: false,
     
@@ -34431,7 +34528,7 @@ Roo.extend(Roo.grid.Grid, Roo.util.Observable, {
         }
         if (this.dropTarget && this.dropTarget.xtype) {
             delete this.dropTarget.xtype;
-            this.dropTarget =  new Ext.dd.DropTarget(this.getView().mainBody, this.dropTarget);
+            this.dropTarget =  new Roo.dd.DropTarget(this.getView().mainBody, this.dropTarget);
         }
         
         
@@ -34985,6 +35082,9 @@ Roo.grid.GridView = function(config){
 
 Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, {
 
+    unselectable :  'unselectable="on"',
+    unselectableCls :  'x-unselectable',
+    
     
     rowClass : "x-grid-row",
 
@@ -35106,7 +35206,7 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, {
         if(!tpls.hcell){
             tpls.hcell = new Roo.Template(
                 '<td class="x-grid-hd x-grid-td-{id} {cellId}"><div title="{title}" class="x-grid-hd-inner x-grid-hd-{id}">',
-                '<div class="x-grid-hd-text" unselectable="on">{value}<img class="x-grid-sort-icon" src="', Roo.BLANK_IMAGE_URL, '" /></div>',
+                '<div class="x-grid-hd-text ' + this.unselectableCls +  '" ' + this.unselectable +'>{value}<img class="x-grid-sort-icon" src="', Roo.BLANK_IMAGE_URL, '" /></div>',
                 "</div></td>"
              );
              tpls.hcell.disableFormats = true;
@@ -35114,7 +35214,8 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, {
         tpls.hcell.compile();
 
         if(!tpls.hsplit){
-            tpls.hsplit = new Roo.Template('<div class="x-grid-split {splitId} x-grid-split-{id}" style="{style}" unselectable="on">&#160;</div>');
+            tpls.hsplit = new Roo.Template('<div class="x-grid-split {splitId} x-grid-split-{id}" style="{style} ' +
+                                            this.unselectableCls +  '" ' + this.unselectable +'>&#160;</div>');
             tpls.hsplit.disableFormats = true;
         }
         tpls.hsplit.compile();
@@ -35138,7 +35239,8 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, {
         if(!tpls.cell){
             tpls.cell = new Roo.Template(
                 '<td class="x-grid-col x-grid-td-{id} {cellId} {css}" tabIndex="0">',
-                '<div class="x-grid-col-{id} x-grid-cell-inner"><div class="x-grid-cell-text" unselectable="on" {attr}>{value}</div></div>',
+                '<div class="x-grid-col-{id} x-grid-cell-inner"><div class="x-grid-cell-text ' +
+                    this.unselectableCls +  '" ' + this.unselectable +'" {attr}>{value}</div></div>',
                 "</td>"
             );
             tpls.cell.disableFormats = true;
@@ -36441,6 +36543,7 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, {
             this.dd = new Roo.grid.GridDragZone(this.grid, {
                 ddGroup : this.grid.ddGroup || 'GridDD'
             });
+            
         }
 
         /*
@@ -36739,15 +36842,45 @@ Roo.extend(Roo.grid.GridDragZone, Roo.dd.DragZone, {
     getDragData : function(e){
         var t = Roo.lib.Event.getTarget(e);
         var rowIndex = this.view.findRowIndex(t);
+        var sm = this.grid.selModel;
+            
+        //Roo.log(rowIndex);
+        
+        if (sm.getSelectedCell) {
+            // cell selection..
+            if (!sm.getSelectedCell()) {
+                return false;
+            }
+            if (rowIndex != sm.getSelectedCell()[0]) {
+                return false;
+            }
+        
+        }
+        
         if(rowIndex !== false){
-            var sm = this.grid.selModel;
+            
+            // if editorgrid.. 
+            
+            
+            //Roo.log([ sm.getSelectedCell() ? sm.getSelectedCell()[0] : 'NO' , rowIndex ]);
+               
             //if(!sm.isSelected(rowIndex) || e.hasModifier()){
-              //  sm.mouseDown(e, t);
+              //  
             //}
             if (e.hasModifier()){
                 sm.handleMouseDown(e, t); // non modifier buttons are handled by row select.
             }
-            return {grid: this.grid, ddel: this.ddel, rowIndex: rowIndex, selections:sm.getSelections()};
+            
+            Roo.log("getDragData");
+            
+            return {
+                grid: this.grid,
+                ddel: this.ddel,
+                rowIndex: rowIndex,
+                selections:sm.getSelections ? sm.getSelections() : (
+                    sm.getSelectedCell() ? [ this.grid.ds.getAt(sm.getSelectedCell()[0]) ] : []
+                )
+            };
         }
         return false;
     },
@@ -38312,7 +38445,17 @@ Roo.extend(Roo.grid.EditorGrid, Roo.grid.Grid, {
             this.activeEditor.completeEdit();
         }
         this.activeEditor = null;
+    },
+       
+        /**
+     * Called to get grid's drag proxy text, by default returns this.ddText.
+     * @return {String}
+     */
+    getDragDropText : function(){
+        var count = this.selModel.getSelectedCell() ? 1 : 0;
+        return String.format(this.ddText, count, count == 1 ? '' : 's');
     }
+       
 });/*
  * Based on:
  * Ext JS Library 1.1.1