Changeset 13382

Show
Ignore:
Timestamp:
04/22/08 08:28:57 (7 months ago)
Author:
liucougar
Message:

refs #6582: detect useIframe correctly when styleSheets or useIframe is explicitly specified
refs #6584: fix broken auto-expand when iframe is used
refs #6583: enable alwaysshowtoolbar plugin for editor when iframe is used (which is needed to support auto-expand)

Location:
dijit/trunk/_editor
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/_editor/plugins/AlwaysShowToolbar.js

    r13380 r13382  
    55        _handleScroll: true, 
    66        setEditor: function(e){ 
    7                 console.log('Port AlwaysShowToolbar plugin to work with Editor without iframe'); 
    8                 return; 
     7                if(!e.iframe){ 
     8                        console.log('Port AlwaysShowToolbar plugin to work with Editor without iframe'); 
     9                        return; 
     10                } 
     11 
    912                this.editor = e; 
    10 //              setTimeout(dojo.hitch(this,this.enable), 10000); 
     13 
    1114                e.onLoadDeferred.addCallback(dojo.hitch(this, this.enable)); 
    12 //              this.scrollInterval = setInterval(dojo.hitch(this, "globalOnScrollHandler"), 100); 
    1315        }, 
    1416        enable: function(d){ 
     
    4648                        // this.editorObject.style.height = this._lastHeight + "px"; 
    4749                        dojo.marginBox(e.iframe, { h: this._lastHeight }); 
    48 //                      this.iframe.height=this._lastHeight+10+'px'; 
    49 //                      this.iframe.style.height=this._lastHeight+'px'; 
    5050                } 
    5151        }, 
  • dijit/trunk/_editor/RichText.js

    r13381 r13382  
    151151                if(!this.iframe){ 
    152152                        var ifr = this.iframe = dojo.doc.createElement("iframe"); 
    153                         ifr.id=this.id; 
     153                        ifr.id=this.id+'_iframe'; 
    154154                        // this.iframe.src = "about:blank"; 
    155155                        // document.body.appendChild(this.iframe); 
     
    332332 
    333333        setDisabled: function(/*Boolean*/ disabled){ 
    334                 if(disabled){ 
    335                         //AP: 
    336                         //              why isn't this set in the constructor, or put in 
    337                         //              mozSettingProps as a hash? 
    338                         this._mozSettings = [ false, this.blockNodeForEnter==='BR' ]; 
     334                if(!dojo.isMoz){ 
     335                        dijit._editor.RichText.prototype.setDisabled.call(this, disabled); 
     336                        return; 
    339337                } 
    340338                this.document.designMode = disabled ? 'off' : 'on'; 
    341                 if(!disabled && this._mozSettings){ 
    342                         dojo.forEach(this._mozSettingProps, function(s,i){ 
    343                                 this.document.execCommand(s,false,this._mozSettings[i]); 
    344                         },this); 
     339                if(!disabled && this._mozSettingProps){ 
     340                        var ps=this._mozSettingProps; 
     341                        for(var n in ps){ 
     342                                if(ps.hasOwnProperty(n)){ 
     343                                        try{ 
     344                                                this.document.execCommand(n,false,ps[n]); 
     345                                        }catch(e){} 
     346                                } 
     347                        } 
    345348                } 
    346349                this.disabled = disabled; 
     
    355358 
    356359dojo.declare("dijit._editor.RichText", dijit._Widget, { 
    357         constructor: function(){ 
     360        constructor: function(paras){ 
    358361                // summary: 
    359362                //              dijit._editor.RichText is the core of the WYSIWYG editor in dojo, which 
     
    403406                this.onLoadDeferred = new dojo.Deferred(); 
    404407 
    405                 this.useIframe = (dojo.isFF && (dojo.isFF < 3)) || this.useIframe || this.styleSheets.length; 
     408                //in this constructor, mixin properties are not yet merged, so we have to check for paras here 
     409                this.useIframe = (dojo.isFF && (dojo.isFF < 3)) || paras['useIframe'] || paras['styleSheets']; 
    406410 
    407411                if(this.useIframe){ 
     
    713717 
    714718        disabled: true, 
    715         _mozSettingProps: ['styleWithCSS','insertBrOnReturn'], 
     719        _mozSettingProps: {'styleWithCSS':false}, 
    716720 
    717721        setDisabled: function(/*Boolean*/ disabled){ 
     
    750754 
    751755                var events = this.events.concat(this.captureEvents); 
    752                 var ap = (this.iframe) ? this.window : this.editNode; 
     756                var ap = (this.iframe) ? this.document : this.editNode; 
    753757                dojo.forEach(events, function(item){ 
    754758                        // dojo.connect(ap, item.toLowerCase(), console, "debug"); 
    755759                        this.connect(ap, item.toLowerCase(), item); 
    756760                }, this); 
    757                 if(!dojo.isIE){ 
    758                         try{ // sanity check for Mozilla 
    759                                 // this.document.execCommand("useCSS", false, true); // old moz call 
    760                                 this.document.execCommand("styleWithCSS", false, false); // new moz call 
    761                                 //this.document.execCommand("insertBrOnReturn", false, false); // new moz call 
    762                         }catch(e2){ } 
    763                         // FIXME: when scrollbars appear/disappear this needs to be fired 
    764                 }else{ // IE contentEditable 
     761                if(dojo.isIE){ // IE contentEditable 
    765762                        // give the node Layout on IE 
    766763                        this.editNode.style.zoom = 1.0; 
     
    832829 
    833830                // function call after the character has been inserted 
    834                 setTimeout(dojo.hitch(this, "onKeyPressed", e), 1); 
     831                if(!this._onKeyHitch){ 
     832                        this._onKeyHitch=dojo.hitch(this, "onKeyPressed"); 
     833                } 
     834                setTimeout(this._onKeyHitch, 1); 
    835835                return true; 
    836836        }, 
     
    848848        }, 
    849849 
    850         onKeyPressed: function(/*Event*/e){ 
    851                 return; 
     850        onKeyPressed: function(){ 
    852851                this.onDisplayChanged(/*e*/); // can't pass in e 
    853852        }, 
     
    928927                        clearTimeout(this._updateTimer); 
    929928                } 
    930                 this._updateTimer = setTimeout( // really? we hitch every time? 
    931                         dojo.hitch(this,"onNormalizedDisplayChanged"),  
    932                         this.updateInterval 
    933                 ); 
     929                if(!this._updateHandler){ 
     930                        this._updateHandler = dojo.hitch(this,"onNormalizedDisplayChanged"); 
     931                } 
     932                this._updateTimer = setTimeout(this._updateHandler, this.updateInterval); 
    934933        }, 
    935934        onNormalizedDisplayChanged: function(){ 
     
    939938                //              If something needs to happen immidiately after a 
    940939                //              user change, please use onDisplayChanged instead 
    941                 this._updateTimer = null; 
     940                delete this._updateTimer; 
    942941        }, 
    943942        onChange: function(newContent){