Changeset 12842

Show
Ignore:
Timestamp:
03/03/08 13:29:43 (9 months ago)
Author:
doughays
Message:

Fixes #4996, #5835 !strict. IE wanted badly to focus the iframe's BODY tag on the way in and out. I added an onfocus handler for IE that just moved the focus either up or down another level to avoid stopping on the BODY tag. Also fixed a few code-style issues. becka11y verified correct behavior.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/_editor/RichText.js

    r12767 r12842  
    2828        }else{ 
    2929                //dojo.body() is not available before onLoad is fired 
    30                 try { 
     30                try{ 
    3131                        dojo.doc.write('<textarea id="' + dijit._scopeName + '._editor.RichText.savedContent" ' + 
    3232                                'style="display:none;position:absolute;top:-100px;left:-100px;height:3px;width:3px;overflow:hidden;"></textarea>'); 
     
    329329                // Safari's selections go all out of whack if we do it inline, 
    330330                // so for now IE is our only hero 
    331                 //if (typeof dojo.doc.body.contentEditable != "undefined") { 
     331                //if(typeof dojo.doc.body.contentEditable != "undefined"){ 
    332332                if(dojo.isIE || dojo.isSafari || dojo.isOpera){ // contentEditable, easy 
    333333                        var ifr = this.iframe = dojo.doc.createElement('iframe'); 
     
    378378        _getIframeDocTxt: function(/* String */ html){ 
    379379                var _cs = dojo.getComputedStyle(this.domNode); 
    380                 if(!this.height && !dojo.isMoz){ 
     380                if(dojo.isIE || (!this.height && !dojo.isMoz)){ 
    381381                        html="<div>"+html+"</div>"; 
    382382                } 
     
    648648                        dijit.registerWin(this.window); 
    649649                } 
    650                 if(this.height || dojo.isMoz){ 
     650                if(!dojo.isIE && (this.height || dojo.isMoz)){ 
    651651                        this.editNode=this.document.body; 
    652652                }else{ 
    653653                        this.editNode=this.document.body.firstChild; 
     654                        var _this = this; 
     655                        if(dojo.isIE){ // #4996 IE wants to focus the BODY tag 
     656                                this.editNode.parentNode.onfocus = 
     657                                        function(){ 
     658                                                if(!_this.editNode.blurring){ 
     659                                                        _this.editNode.focus(); 
     660                                                } 
     661                                                _this.editNode.blurring = false; 
     662                                        } 
     663                        } 
    654664                } 
    655665 
     
    681691                }else{ // IE contentEditable 
    682692                        // give the node Layout on IE 
     693                        this.connect(this.document, "onmousedown", "_onMouseDown"); // #4996 fix focus 
    683694                        this.editNode.style.zoom = 1.0; 
    684695                } 
     
    696707        onKeyDown: function(/* Event */ e){ 
    697708                // summary: Fired on keydown 
    698  
    699 //               console.info("onkeydown:", e.keyCode); 
    700709 
    701710                // we need this event at the moment to get the events from control keys 
     
    703712                // keyPress events can be emulated by the keyDown and keyUp detection. 
    704713                if(dojo.isIE){ 
    705                         if(e.keyCode === dojo.keys.BACKSPACE && this.document.selection.type === "Control"){ 
     714                        if(e.keyCode == dojo.keys.TAB && e.shiftKey && !e.ctrlKey && !e.altKey){ 
     715                                // focus the BODY so the browser will tab away from it instead 
     716                                this.editNode.blurring = true; 
     717                                this.editNode.parentNode.focus(); 
     718                        }else if(e.keyCode === dojo.keys.BACKSPACE && this.document.selection.type === "Control"){ 
    706719                                // IE has a bug where if a non-text object is selected in the editor, 
    707720                  // hitting backspace would act as if the browser's back button was 
     
    715728                                this.onKeyPress(e); 
    716729                        } 
    717                 } 
    718                 else if(dojo.isMoz){ 
     730                }else if(dojo.isMoz){ 
    719731                        if(e.keyCode == dojo.keys.TAB && !e.shiftKey && !e.ctrlKey && !e.altKey && this.iframe){ 
    720732                                // update iframe document title for screen reader 
     
    725737                                this.iframe.focus();  // this.focus(); won't work 
    726738                                dojo.stopEvent(e); 
    727                         }else if (e.keyCode == dojo.keys.TAB && e.shiftKey){ 
     739                        }else if(e.keyCode == dojo.keys.TAB && e.shiftKey){ 
    728740                                // if there is a toolbar, set focus to it, otherwise ignore 
    729                                 if (this.toolbar){ 
     741                                if(this.toolbar){ 
    730742                                        this.toolbar.focus(); 
    731743                                } 
     
    745757        onKeyPress: function(e){ 
    746758                // summary: Fired on keypress 
    747  
    748 //               console.info("onkeypress:", e.keyCode); 
    749759 
    750760                // handle the various key events 
     
    788798                this.onDisplayChanged(e); 
    789799        }, 
     800 
     801        _onMouseDown: function(/*Event*/e){ // IE only to prevent 2 clicks to focus 
     802                if(!this._focused && !this.disabled){ 
     803                        this.focus(); 
     804                } 
     805        }, 
     806 
    790807        _onBlur: function(e){ 
    791808                this.inherited(arguments); 
     
    798815                        this.iframe.contentDocument.title = this._localizedIframeTitles.iframeEditTitle; 
    799816                }  
    800 //                      console.info('_onBlur') 
    801817        }, 
    802818        _initialFocus: true, 
    803819        _onFocus: function(/*Event*/e){ 
    804 //                      console.info('_onFocus') 
    805820                // summary: Fired on focus 
    806821                this.inherited(arguments); 
     
    13141329 
    13151330                // line height is squashed for iframes 
    1316                 // FIXME: why was this here? if (this.iframe){ this.domNode.style.lineHeight = null; } 
     1331                // FIXME: why was this here? if(this.iframe){ this.domNode.style.lineHeight = null; } 
    13171332 
    13181333                if(this.interval){ clearInterval(this.interval); }