Roo/tree/TreeLoader.js
[roojs1] / roojs-debug.js
index ac2e0b8..52d28c2 100644 (file)
@@ -1007,6 +1007,7 @@ Format  Output      Description
   i      05         Minutes with leading zeros
   s      01         Seconds, with leading zeros
   O      -0600      Difference to Greenwich time (GMT) in hours
+  P      -06:00     Difference to Greenwich time (GMT) with colon between hours and minutes
   T      CST        Timezone setting of the machine running the code
   Z      -21600     Timezone offset in seconds (negative if west of UTC, positive if east)
 </pre>
@@ -1173,6 +1174,8 @@ Date.getFormatCode = function(character) {
         return "String.leftPad(this.getSeconds(), 2, '0') + ";
     case "O":
         return "this.getGMTOffset() + ";
+    case "P":
+       return "this.getGMTColonOffset() + ";
     case "T":
         return "this.getTimezone() + ";
     case "Z":
@@ -1385,6 +1388,17 @@ Date.formatCodeToRegex = function(character, currentGroup) {
                 "    (sn + String.leftPad(hr, 2, 0) + String.leftPad(mn, 2, 0)) : null;\n"
             ].join(""),
             s:"([+\-]\\d{4})"};
+    case "P":
+       return {g:1,
+               c:[
+                  "o = results[", currentGroup, "];\n",
+                  "var sn = o.substring(0,1);\n",
+                  "var hr = o.substring(1,3)*1 + Math.floor(o.substring(4,6) / 60);\n",
+                  "var mn = o.substring(4,6) % 60;\n",
+                  "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))?\n",
+                       "    (sn + String.leftPad(hr, 2, 0) + String.leftPad(mn, 2, 0)) : null;\n"
+            ].join(""),
+            s:"([+\-]\\d{4})"};
     case "T":
         return {g:0,
             c:null,
@@ -1419,6 +1433,18 @@ Date.prototype.getGMTOffset = function() {
         + String.leftPad(this.getTimezoneOffset() % 60, 2, "0");
 };
 
+/**
+ * Get the offset from GMT of the current date (equivalent to the format specifier 'P').
+ * @return {String} 2-characters representing hours and 2-characters representing minutes
+ * seperated by a colon and prefixed with + or - (e.g. '-06:00')
+ */
+Date.prototype.getGMTColonOffset = function() {
+       return (this.getTimezoneOffset() > 0 ? "-" : "+")
+               + String.leftPad(Math.abs(Math.floor(this.getTimezoneOffset() / 60)), 2, "0")
+               + ":"
+               + String.leftPad(this.getTimezoneOffset() %60, 2, "0");
+}
+
 /**
  * Get the numeric day number of the year, adjusted for leap year.
  * @return {Number} 0 through 364 (365 in leap years)
@@ -1734,7 +1760,8 @@ Date.prototype.add = function(interval, value){
       break;
   }
   return d;
-};/*
+};
+/*
  * Based on:
  * Ext JS Library 1.1.1
  * Copyright(c) 2006-2007, Ext JS, LLC.
@@ -23614,59 +23641,66 @@ Roo.View = function(config, depreciated_tpl, depreciated_config){
      
     /** @private */
     this.addEvents({
-    /**
-     * @event beforeclick
-     * Fires before a click is processed. Returns false to cancel the default action.
-     * @param {Roo.View} this
-     * @param {Number} index The index of the target node
-     * @param {HTMLElement} node The target node
-     * @param {Roo.EventObject} e The raw event object
-     */
-        "beforeclick" : true,
-    /**
-     * @event click
-     * Fires when a template node is clicked.
-     * @param {Roo.View} this
-     * @param {Number} index The index of the target node
-     * @param {HTMLElement} node The target node
-     * @param {Roo.EventObject} e The raw event object
-     */
-        "click" : true,
-    /**
-     * @event dblclick
-     * Fires when a template node is double clicked.
-     * @param {Roo.View} this
-     * @param {Number} index The index of the target node
-     * @param {HTMLElement} node The target node
-     * @param {Roo.EventObject} e The raw event object
-     */
-        "dblclick" : true,
-    /**
-     * @event contextmenu
-     * Fires when a template node is right clicked.
-     * @param {Roo.View} this
-     * @param {Number} index The index of the target node
-     * @param {HTMLElement} node The target node
-     * @param {Roo.EventObject} e The raw event object
-     */
-        "contextmenu" : true,
-    /**
-     * @event selectionchange
-     * Fires when the selected nodes change.
-     * @param {Roo.View} this
-     * @param {Array} selections Array of the selected nodes
-     */
-        "selectionchange" : true,
-
-    /**
-     * @event beforeselect
-     * Fires before a selection is made. If any handlers return false, the selection is cancelled.
-     * @param {Roo.View} this
-     * @param {HTMLElement} node The node to be selected
-     * @param {Array} selections Array of currently selected nodes
-     */
-        "beforeselect" : true
-    });
+        /**
+         * @event beforeclick
+         * Fires before a click is processed. Returns false to cancel the default action.
+         * @param {Roo.View} this
+         * @param {Number} index The index of the target node
+         * @param {HTMLElement} node The target node
+         * @param {Roo.EventObject} e The raw event object
+         */
+            "beforeclick" : true,
+        /**
+         * @event click
+         * Fires when a template node is clicked.
+         * @param {Roo.View} this
+         * @param {Number} index The index of the target node
+         * @param {HTMLElement} node The target node
+         * @param {Roo.EventObject} e The raw event object
+         */
+            "click" : true,
+        /**
+         * @event dblclick
+         * Fires when a template node is double clicked.
+         * @param {Roo.View} this
+         * @param {Number} index The index of the target node
+         * @param {HTMLElement} node The target node
+         * @param {Roo.EventObject} e The raw event object
+         */
+            "dblclick" : true,
+        /**
+         * @event contextmenu
+         * Fires when a template node is right clicked.
+         * @param {Roo.View} this
+         * @param {Number} index The index of the target node
+         * @param {HTMLElement} node The target node
+         * @param {Roo.EventObject} e The raw event object
+         */
+            "contextmenu" : true,
+        /**
+         * @event selectionchange
+         * Fires when the selected nodes change.
+         * @param {Roo.View} this
+         * @param {Array} selections Array of the selected nodes
+         */
+            "selectionchange" : true,
+    
+        /**
+         * @event beforeselect
+         * Fires before a selection is made. If any handlers return false, the selection is cancelled.
+         * @param {Roo.View} this
+         * @param {HTMLElement} node The node to be selected
+         * @param {Array} selections Array of currently selected nodes
+         */
+            "beforeselect" : true,
+        /**
+         * @event preparedata
+         * Fires on every row to render, to allow you to change the data.
+         * @param {Roo.View} this
+         * @param {Object} data to be rendered (change this)
+         */
+          "preparedata" : true
+        });
 
     this.el.on({
         "click": this.onClick,
@@ -23743,6 +23777,7 @@ Roo.extend(Roo.View, Roo.util.Observable, {
         }
         for(var i = 0, len = records.length; i < len; i++){
             var data = this.prepareData(records[i].data, i, records[i]);
+            this.fireEvent("preparedata", this, data, i, records[i]);
             html[html.length] = t.apply(data);
         }
         this.el.update(html.join(""));
@@ -38406,7 +38441,19 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
      */
     defaultLinkValue : 'http:/'+'/',
    
-    
+     /**
+     * @cfg {String} resizable  's' or 'se' or 'e' - wrapps the element in a
+     *                        Roo.resizable.
+     */
+    resizable : false,
+     /**
+     * @cfg {Number} height (in pixels)
+     */   
+    height: 300,
+   /**
+     * @cfg {Number} width (in pixels)
+     */   
+    width: 500,
     // id of frame..
     frameId: false,
     
@@ -38419,7 +38466,8 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
     onFocus : Roo.emptyFn,
     iframePad:3,
     hideMode:'offsets',
-    defaultAutoCreate : {
+    
+    defaultAutoCreate : { // modified by initCompnoent..
         tag: "textarea",
         style:"width:500px;height:300px;",
         autocomplete: "off"
@@ -38484,7 +38532,12 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
              * @param {HtmlEditor} this
              */
             editorevent: true
-        })
+        });
+        this.defaultAutoCreate =  {
+            tag: "textarea",
+            style:'width: ' + this.width + 'px;height: ' + this.height + 'px;',
+            autocomplete: "off"
+        };
     },
 
     /**
@@ -38516,7 +38569,9 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
     },
 
     // private
-    onRender : function(ct, position){
+    onRender : function(ct, position)
+    {
+        var _t = this;
         Roo.form.HtmlEditor.superclass.onRender.call(this, ct, position);
         this.el.dom.style.border = '0 none';
         this.el.dom.setAttribute('tabIndex', -1);
@@ -38527,6 +38582,24 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
         this.wrap = this.el.wrap({
             cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
         });
+        
+        if (this.resizable) {
+            this.resizeEl = new Roo.Resizable(this.wrap, {
+                pinned : true,
+                wrap: true,
+                dynamic : true,
+                minHeight : this.height,
+                height: this.height,
+                handles : this.resizable,
+                width: this.width,
+                listeners : {
+                    resize : function(r, w, h) {
+                        _t.onResize(w,h); // -something
+                    }
+                }
+            });
+            
+        }
 
         this.frameId = Roo.id();
         this.createToolbar(this);
@@ -38579,12 +38652,18 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
         Roo.TaskMgr.start(task);
 
         if(!this.width){
-            this.setSize(this.el.getSize());
+            this.setSize(this.wrap.getSize());
+        }
+        if (this.resizeEl) {
+            this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
+            // should trigger onReize..
         }
     },
 
     // private
-    onResize : function(w, h){
+    onResize : function(w, h)
+    {
+        //Roo.log('resize: ' +w + ',' + h );
         Roo.form.HtmlEditor.superclass.onResize.apply(this, arguments);
         if(this.el && this.iframe){
             if(typeof w == 'number'){
@@ -38603,6 +38682,7 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
                 
                 
                 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
+                ah -= 10; // knock a few pixes off for look..
                 this.el.setHeight(this.adjustWidth('textarea', ah));
                 this.iframe.style.height = ah + 'px';
                 if(this.doc){
@@ -39270,6 +39350,18 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
             return;
             
         }
+        if (Roo.form.HtmlEditor.remove.indexOf(node.tagName.toLowerCase()) > -1) {
+            this.cleanUpChildren(node);
+            // inserts everything just before this node...
+            while (node.childNodes.length) {
+                var cn = node.childNodes[0];
+                node.removeChild(cn);
+                node.parentNode.insertBefore(cn, node);
+            }
+            node.parentNode.removeChild(node);
+            return;
+        }
+        
         if (!node.attributes || !node.attributes.length) {
             this.cleanUpChildren(node);
             return;
@@ -39301,7 +39393,7 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
             Roo.each(parts, function(p) {
                 p = p.replace(/\s+/g,'');
                 if (!p.length) {
-                    return;
+                    return true;
                 }
                 var l = p.split(':').shift().replace(/\s+/g,'');
                 
@@ -39310,6 +39402,7 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
                     node.removeAttribute(n);
                     return false;
                 }
+                return true;
             });
             
             
@@ -39421,7 +39514,9 @@ Roo.form.HtmlEditor.black = [
 Roo.form.HtmlEditor.clean = [
     'script', 'style', 'title', 'xml'
 ];
-
+Roo.form.HtmlEditor.remove = [
+    'font'
+];
 // attributes..
 
 Roo.form.HtmlEditor.ablack = [
@@ -45727,7 +45822,17 @@ Roo.ContentPanel = function(el, config, content){
          * @param {Number} width The width after any component adjustments
          * @param {Number} height The height after any component adjustments
          */
-        "resize" : true
+        "resize" : true,
+        
+         /**
+         * @event render
+         * Fires when this tab is created
+         * @param {Roo.ContentPanel} this
+         */
+        "render" : true
+        
+        
+        
     });
     if(this.autoScroll){
         this.resizeEl.setStyle("overflow", "auto");
@@ -45749,6 +45854,8 @@ Roo.ContentPanel = function(el, config, content){
     
     
     Roo.ContentPanel.superclass.constructor.call(this);
+    
+    this.fireEvent('render', this);
 };
 
 Roo.extend(Roo.ContentPanel, Roo.util.Observable, {
@@ -46006,14 +46113,13 @@ layout.addxtype({
             // views..
             cfg.el = this.el.appendChild(document.createElement("div"));
             // factory?
-            var ret = new Roo[cfg.xtype](cfg);
+            
+            var ret = new Roo.factory(cfg);
             ret.render && ret.render(false, ''); // render blank..
             this.view = ret;
             return ret;
-            
         }
         return false;
-        
     }
 });
 
@@ -51441,7 +51547,7 @@ Roo.extend(Roo.XComponent, Roo.util.Observable, {
         el = el || false;
         var hp = this.parent ? 1 : 0;
         
-        if (!el && typeof(this.parent) == 'string' && this.parent[0] == '#') {
+        if (!el && typeof(this.parent) == 'string' && this.parent.substring(0,1) == '#') {
             // if parent is a '#.....' string, then let's use that..
             var ename = this.parent.substr(1)
             this.parent = false;
@@ -51558,7 +51664,7 @@ Roo.apply(Roo.XComponent, {
         if (!str || typeof(str) == 'object') {
             return str;
         }
-        if (str[0]=='#') {
+        if (str.substring(0,1) == '#') {
             return str;
         }
 
@@ -51566,7 +51672,12 @@ Roo.apply(Roo.XComponent, {
         var rt, o;
         rt = ar.shift();
             /** eval:var:o */
-        eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';');
+        try {
+            eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';');
+        } catch (e) {
+            throw "Module not found : " + str;
+        }
+        
         if (o === false) {
             throw "Module not found : " + str;
         }
@@ -51592,7 +51703,12 @@ Roo.apply(Roo.XComponent, {
         Roo.each(this.modules , function (obj)
         {
             var opar = obj.parent;
-            obj.parent = this.toObject(opar);
+            try { 
+                obj.parent = this.toObject(opar);
+            } catch(e) {
+                Roo.log(e.toString());
+                return;
+            }
             
             if (!obj.parent) {
                 this.topModule = obj;