Ticket #6112: 6112_focus.patch

File 6112_focus.patch, 3.0 kB (added by liucougar, 10 months ago)

fix #6112 while keep #4996 and #5835 working

  • _editor/RichText.js

     
    324324                } 
    325325 
    326326                this.isClosed = false; 
    327                 // Safari's selections go all out of whack if we do it inline, 
    328                 // so for now IE is our only hero 
    329                 //if(typeof dojo.doc.body.contentEditable != "undefined"){ 
     327 
    330328                if(dojo.isIE || dojo.isSafari || dojo.isOpera){ // contentEditable, easy 
    331329                        var ifr = this.iframe = dojo.doc.createElement('iframe'); 
    332330                        ifr.id=this.id; 
     
    377375 
    378376        _getIframeDocTxt: function(/* String */ html){ 
    379377                var _cs = dojo.getComputedStyle(this.domNode); 
    380                 if(dojo.isIE || (!this.height && !dojo.isMoz)){ 
     378                if(!this.height && !dojo.isMoz){ 
    381379                        html="<div style='height:100%;'>"+html+"</div>"; 
    382380                } 
    383381                var font = [ _cs.fontWeight, _cs.fontSize, _cs.fontFamily ].join(" "); 
     
    648646                        this.window.__registeredWindow=true; 
    649647                        dijit.registerWin(this.window); 
    650648                } 
    651                 if(!dojo.isIE && (this.height || dojo.isMoz)){ 
     649                if(this.height || dojo.isMoz){ 
    652650                        this.editNode=this.document.body; 
    653651                }else{ 
    654652                        this.editNode=this.document.body.firstChild; 
    655                         var _this = this; 
    656                         if(dojo.isIE){ // #4996 IE wants to focus the BODY tag 
    657                                 this.editNode.parentNode.onfocus = 
    658                                         function(){ 
    659                                                 if(!_this.editNode.blurring){ 
    660                                                         _this.editNode.focus(); 
    661                                                 } 
    662                                                 _this.editNode.blurring = false; 
    663                                         } 
     653                        if(dojo.isIE && !this.height){ // #4996 IE wants to focus the BODY tag when it should focus 
     654                            var _this = this;  
     655                            this.editNode.parentNode.onfocus = function(){  
     656                                if(!_this.editNode.blurring){  
     657                                    _this.editNode.focus();  
     658                                } 
     659                                _this.editNode.blurring = false;  
     660                            } 
    664661                        } 
    665662                } 
    666663 
     
    713710                // keyPress events can be emulated by the keyDown and keyUp detection. 
    714711                if(dojo.isIE){ 
    715712                        if(e.keyCode == dojo.keys.TAB && e.shiftKey && !e.ctrlKey && !e.altKey){ 
    716                                 // focus the BODY so the browser will tab away from it instead 
     713                                // focus the documentElement so the browser will tab away from it instead 
    717714                                this.editNode.blurring = true; 
    718                                 this.editNode.parentNode.focus(); 
     715                                this.editNode.blur(); 
     716                                this.document.documentElement.focus(); 
    719717                        }else if(e.keyCode === dojo.keys.BACKSPACE && this.document.selection.type === "Control"){ 
    720718                                // IE has a bug where if a non-text object is selected in the editor, 
    721719                  // hitting backspace would act as if the browser's back button was 
     
    833831        // TODO: why is this needed - should we deprecate this ? 
    834832        blur: function(){ 
    835833                // summary: remove focus from this instance 
    836                 if(!dojo.isIE && this.window.document.documentElement && this.window.document.documentElement.focus){ 
    837                         this.window.document.documentElement.focus(); 
     834                if(!dojo.isIE && this.document.documentElement && this.document.documentElement.focus){ 
     835                        this.document.documentElement.focus(); 
    838836                }else if(dojo.doc.body.focus){ 
    839837                        dojo.doc.body.focus(); 
    840838                }