Ticket #4070: RichEditBC.patch

File RichEditBC.patch, 5.6 kB (added by guest, 8 weeks ago)
  • Editor.js

    diff --git a/Editor.js b/Editor.js
    index 650a8fc..fde8fe9 100644
    a b  
    5656 
    5757                        if(!this.toolbar){ 
    5858                                // if we haven't been assigned a toolbar, create one 
    59                                 this.toolbar = new dijit.Toolbar({}); 
     59                                this.toolbar = new dijit.Toolbar({region:'top'}); // LALEE Added 'region:top' for BorderLayout  
    6060                                dojo.place(this.toolbar.domNode, this.editingArea, "before"); 
    6161                        } 
    6262 
    6363                        dojo.forEach(this.plugins, this.addPlugin, this); 
    6464                        this.onNormalizedDisplayChanged(); //update toolbar button status 
     65 
     66//LALEE:  ADD THE TOOLBAR TO OUR BORDERLAYOUT OBJECT 
     67                        if (this.borderContainer) { 
     68                                this.borderContainer.addChild(this.toolbar, 0); 
     69                                this.borderContainer.resize(); //  = new dijit.layout.BorderContainer({}, this.domNode); 
     70                        } else { 
     71                                console.debug('RichEdit Control has no usable borderContainer at this time.'); 
     72                        }                
     73                         
    6574//                      }catch(e){ console.debug(e); } 
    6675 
    6776                        this.toolbar.startup(); 
  • _editor/RichText.js

    diff --git a/_editor/RichText.js b/_editor/RichText.js
    index 384e250..6de056f 100644
    a b  
    66dojo.require("dojo.i18n"); 
    77dojo.requireLocalization("dijit.form", "Textarea"); 
    88 
     9dojo.require("dijit.layout.BorderContainer"); //LALEE:  Need BorderContainer for enhanced RichEditor 
     10 
    911// used to restore content when user leaves this page then comes back 
    1012// but do not try doing dojo.doc.write if we are using xd loading. 
    1113// dojo.doc.write will only work if RichText.js is included in the dojo.js 
     
    442444        //              By default, this is 300px. If you want to have the editor always 
    443445        //              resizes to accommodate the content, use AlwaysShowToolbar plugin 
    444446        //              and set height="" 
    445         height: "300px", 
     447        height: "100%", //LALEE:  Make our BorderContainer Stretch to fit the Container by default; Override if necessary. 
    446448 
    447449        // minHeight: String 
    448450        //              The minimum height that the editor should have 
     
    599601                        this.name=this.textarea.name; 
    600602                        html = this._preFilterContent(this.textarea.value); 
    601603                        this.domNode = dojo.doc.createElement("div"); 
     604 
     605//LALEE:  Make a BorderContainer out of a NEW DIV (assigned to this.domNode) if we're starting out from a TEXTAREA . . . 
     606                        // this.domNode.setAttribute('lalee', 'div_to_wrap_all_from_textarea'); 
     607                        this.borderContainer = new dijit.layout.BorderContainer({region:this.textarea.getAttribute('region')}, this.domNode); 
     608                        this.domNode.style.height = this.textarea.style.height; //  || this.height; 
     609                         
    602610                        this.domNode.setAttribute('widgetId',this.id); 
    603611                        this.textarea.removeAttribute('widgetId'); 
    604612                        this.domNode.cssText = this.textarea.cssText; 
     
    626634 
    627635                        // this.domNode.innerHTML = html; 
    628636 
    629                         if(this.textarea.form){ 
    630                                 dojo.connect(this.textarea.form, "onsubmit", this, function(){ 
     637//LALEE:  For some reason, this "out-of-box" code won't FORM-POST . . . 
     638//                      if(this.textarea.form){ 
     639//                              dojo.connect(this.textarea.form, "onsubmit", this, function(){ 
     640//                                      // FIXME: should we be calling close() here instead? 
     641//                                      this.textarea.value = this.getValue(); 
     642//                              }); 
     643//                      } 
     644  
     645                        // ------------------------------------------------------------ 
     646                        //LALEE:  I need this patch in order to get dijit.Editor to work for Form Submits!!  
     647                        // (From http://dojotoolkit.org/forum/support/dijit/dijit-editor-linked-textarea-submit-failes-textarea-content#comment-6023 ) 
     648                        // ------------------------------------------------------------ 
     649                        //this.domNode.innerHTML = html; 
     650                        if (this.textarea.form) { 
     651                                // FIXME: port: this used to be before advice!!! 
     652                                dojo.connect(this.textarea.form, "onsubmit", this, function(e){ 
    631653                                        // FIXME: should we be calling close() here instead? 
    632654                                        this.textarea.value = this.getValue(); 
    633                                 }); 
     655                                        if (this.textarea.form == null) { 
     656                                                this.textarea_form.appendChild(this.textarea); 
     657                                        } 
     658                                }, this); 
     659                                this.textarea_form = this.textarea.form; 
    634660                        } 
     661 
    635662                }else{ 
     663//LALEE:  Make a BorderContainer out of the EXISTING DIV (already assigned to this.domNode)  
     664//      since we're starting out from a NON-TEXTAREA (i.e. we're starting from a DIV) 
     665                        // this.domNode.setAttribute('lalee', 'div_to_wrap_all_from_div'); 
     666                        this.domNode.id += "_bc"; // LALEE:  Euwww DAMN!!  But I can't figure out any other way to get this "working" at the moment.  :-( 
     667                        this.borderContainer = new dijit.layout.BorderContainer({region:this.region}, this.domNode); 
     668                        // this.borderContainer.domNode.style.height = this.borderContainer.domNode.style.height || this.height; 
     669                         
    636670                        html = this._preFilterContent(dijit._editor.getChildrenHtml(this.domNode)); 
    637671                        this.domNode.innerHTML = ''; 
    638672                } 
     
    652686                        this.domNode.innerHTML = " <br>"; 
    653687                } 
    654688 
    655                 this.editingArea = this.domNode; // dojo.doc.createElement("div"); 
    656                 // this.domNode.appendChild(this.editingArea); 
     689                this.editingArea = dojo.doc.createElement("div"); // this.domNode; 
     690 
     691//LALEE:  If we did our BorderContainer correctly, we can now Convert this.editingArea into a ContentPane 
     692//      and then add it to our wrapping BorderContainer 
     693                if (this.borderContainer) { 
     694                        var editContentPane = new dijit.layout.ContentPane({region:'center'}, this.editingArea); 
     695                        this.borderContainer.addChild(editContentPane); 
     696                } 
    657697 
    658698                if(this.name != "" && (!dojo.config["useXDomain"] || dojo.config["allowXdRichTextSave"])){ 
    659699                        var saveTextarea = dojo.byId(dijit._scopeName + "._editor.RichText.savedContent");