fix docs
[roojs1] / Roo / bootstrap / HtmlEditor.js
index f662cd1..244d4de 100644 (file)
@@ -7,7 +7,7 @@
 
 /**
  * @class Roo.bootstrap.HtmlEditor
- * @extends Roo.bootstrap.Component
+ * @extends Roo.bootstrap.TextArea
  * Bootstrap HtmlEditor class
 
  * @constructor
@@ -20,6 +20,7 @@ Roo.bootstrap.HtmlEditor = function(config){
     if (!this.toolbars) {
         this.toolbars = [];
     }
+    
     this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
     this.addEvents({
             /**
@@ -107,6 +108,11 @@ Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea,  {
      * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
      */
     toolbars : false,
+    
+     /**
+    * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
+    */
+    btns : [],
    
      /**
      * @cfg {String} resizable  's' or 'se' or 'e' - wrapps the element in a
@@ -120,7 +126,7 @@ Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea,  {
    /**
      * @cfg {Number} width (in pixels)
      */   
-    width: 500,
+    width: false,
     
     /**
      * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
@@ -141,9 +147,10 @@ Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea,  {
     iframePad:3,
     hideMode:'offsets',
     
-    
     tbContainer : false,
     
+    bodyCls : '',
+    
     toolbarContainer :function() {
         return this.wrap.select('.x-html-editor-tb',true).first();
     },
@@ -154,79 +161,26 @@ Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea,  {
      * add custom toolbar buttons.
      * @param {HtmlEditor} editor
      */
-    createToolbar : function(editor){
-        
-        
-        this.addxtypeChild({
-            
+    createToolbar : function(){
+        Roo.log('renewing');
+        Roo.log("create toolbars");
         
-            xtype: 'Navbar',
-            xns: Roo.bootstrap,
-            bar: true,
-            items : [
-                {
-                    xtype: 'NavGroup',
-                    xns: Roo.bootstrap,
-                    items : [
-                        {
-                            xtype: 'Item',
-                            xns: Roo.bootstrap.Navbar,
-                            html: "nav",
-                            href : 'http://roojs.com',
-                            
-                            menu:    {
-                                xtype: 'Menu',
-                                xns: Roo.bootstrap,
-                                items : [
-                                    {
-                                        xtype: 'MenuItem',
-                                        xns: Roo.bootstrap,
-                                        html: "hello",
-                                        href : 'http://roojs.com'
-                                    },
-                                    {
-                                        xtype: 'MenuSeparator',
-                                        xns: Roo.bootstrap,
-                                    },
-                                    {
-                                        xtype: 'MenuItem',
-                                        xns: Roo.bootstrap,
-                                        html: "hello",
-                                        href: 'http://roojs.com'
-                                    }   
-                                ]
-                            }
-                        }
-                    ]
-                },
-                 {
-                 
-                     xtype: 'Button',
-                     xns: Roo.bootstrap,
-                     weight: 'default',
-                     html : 'submit'
-                 }
-
-            ]
-            
-            
-        }, 'toolbarContainer')
+        this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
+        this.toolbars[0].render(this.toolbarContainer());
         
-        Roo.log("create toolbars");
         return;
-        if (!editor.toolbars || !editor.toolbars.length) {
-            editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
-        }
-        
-        for (var i =0 ; i < editor.toolbars.length;i++) {
-            editor.toolbars[i] = Roo.factory(
-                    typeof(editor.toolbars[i]) == 'string' ?
-                        { xtype: editor.toolbars[i]} : editor.toolbars[i],
-                Roo.bootstrap.HtmlEditor);
-            editor.toolbars[i].init(editor);
-        }
-         
         
+//        if (!editor.toolbars || !editor.toolbars.length) {
+//            editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
+//        }
+//        
+//        for (var i =0 ; i < editor.toolbars.length;i++) {
+//            editor.toolbars[i] = Roo.factory(
+//                    typeof(editor.toolbars[i]) == 'string' ?
+//                        { xtype: editor.toolbars[i]} : editor.toolbars[i],
+//                Roo.bootstrap.HtmlEditor);
+//            editor.toolbars[i].init(editor);
+//        }
     },
 
      
@@ -234,7 +188,7 @@ Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea,  {
     onRender : function(ct, position)
     {
        // Roo.log("Call onRender: " + this.xtype);
-        
+        var _t = this;
         Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
       
         this.wrap = this.inputEl().wrap({
@@ -263,7 +217,7 @@ Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea,  {
         this.createToolbar(this);
        
         
-        if(!this.width){
+        if(!this.width && this.resizable){
             this.setSize(this.wrap.getSize());
         }
         if (this.resizeEl) {
@@ -271,15 +225,12 @@ Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea,  {
             // should trigger onReize..
         }
         
-//        if(this.autosave && this.w){
-//            this.autoSaveFn = setInterval(this.autosave, 1000);
-//        }
     },
 
     // private
     onResize : function(w, h)
     {
-        //Roo.log('resize: ' +w + ',' + h );
+        Roo.log('resize: ' +w + ',' + h );
         Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
         var ew = false;
         var eh = false;
@@ -291,14 +242,15 @@ Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea,  {
                 ew = aw;
             }
             if(typeof h == 'number'){
-                var tbh = 0;
+                 var tbh = -11;  // fixme it needs to tool bar size!
                 for (var i =0; i < this.toolbars.length;i++) {
                     // fixme - ask toolbars for heights?
-                    tbh += this.toolbars[i].tb.el.getHeight();
-                    if (this.toolbars[i].footer) {
-                        tbh += this.toolbars[i].footer.el.getHeight();
-                    }
+                    tbh += this.toolbars[i].el.getHeight();
+                    //if (this.toolbars[i].footer) {
+                    //    tbh += this.toolbars[i].footer.el.getHeight();
+                    //}
                 }
+              
                 
                 
                 
@@ -327,22 +279,25 @@ Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea,  {
             
 //            Roo.log('in');
 //            Roo.log(this.syncValue());
-            this.editorcore.syncValue();
-            this.inputEl().removeClass('hide');
+            this.syncValue();
+            this.inputEl().removeClass(['hide', 'x-hidden']);
             this.inputEl().dom.removeAttribute('tabIndex');
             this.inputEl().focus();
         }else{
             Roo.log('editor - hiding textarea');
 //            Roo.log('out')
 //            Roo.log(this.pushValue()); 
-            this.editorcore.pushValue();
+            this.pushValue();
             
-            this.inputEl().addClass('hide');
+            this.inputEl().addClass(['hide', 'x-hidden']);
             this.inputEl().dom.setAttribute('tabIndex', -1);
             //this.deferFocus();
         }
          
-        this.setSize(this.wrap.getSize());
+        if(this.resizable){
+            this.setSize(this.wrap.getSize());
+        }
+        
         this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
     },
  
@@ -364,16 +319,16 @@ Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea,  {
         this.originalValue = this.getValue();
     },
 
-    /**
-     * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
-     * @method
-     */
-    markInvalid : Roo.emptyFn,
-    /**
-     * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
-     * @method
-     */
-    clearInvalid : Roo.emptyFn,
+//    /**
+//     * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
+//     * @method
+//     */
+//    markInvalid : Roo.emptyFn,
+//    /**
+//     * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
+//     * @method
+//     */
+//    clearInvalid : Roo.emptyFn,
 
     setValue : function(v){
         Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
@@ -422,8 +377,13 @@ Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea,  {
     
     // private
     syncValue : function()
-    {
+    {   
         this.editorcore.syncValue();
+    },
+    
+    pushValue : function()
+    {   
+        this.editorcore.pushValue();
     }
      
     
@@ -456,9 +416,7 @@ Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea,  {
     /**
      * @cfg {String} inputType @hide
      */
-    /**
-     * @cfg {String} invalidClass @hide
-     */
+     
     /**
      * @cfg {String} invalidText @hide
      */