Changeset 930 for trunk/modules/Gecko


Ignore:
Timestamp:
01/10/08 00:08:56 (12 years ago)
Author:
ray
Message:

#1112 retain editing position between modes generates char 173 in source code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/Gecko/Gecko.js

    r929 r930  
    722722    { 
    723723      var sel = this.getSelection(); 
    724       sel.getRangeAt(0).insertNode( document.createTextNode( cc ) ); 
     724      sel.getRangeAt(0).insertNode( this._doc.createTextNode( cc ) ); 
    725725    } 
    726726  } catch (e) {} 
     
    729729Xinha.prototype.findCC = function ( target ) 
    730730{ 
     731  if ( target == 'textarea' ) 
     732  { 
     733  var ta = this._textArea; 
     734  var pos = ta.value.indexOf( this.cc ); 
     735  if ( !pos ) return; 
     736  var end = pos + this.cc.length; 
     737  var before =  ta.value.substring( 0, pos ); 
     738  var after = ta.value.substring( end, ta.value.length ); 
     739  ta.value = before ; 
     740 
     741  ta.scrollTop = ta.scrollHeight; 
     742  var scrollPos = ta.scrollTop; 
     743   
     744  ta.value += after; 
     745  ta.setSelectionRange(pos,pos); 
     746 
     747  ta.focus(); 
     748   
     749  ta.scrollTop = scrollPos; 
     750 
     751  } 
     752  else 
     753  { 
    731754  try  
    732755  { 
    733     var findIn = ( target == 'textarea' ) ? window : this._iframe.contentWindow; 
    734     if( findIn.find( this.cc ) ) 
    735     { 
    736       if (target == "textarea") 
    737       { 
    738         var ta = this._textArea; 
    739         var start = pos = ta.selectionStart; 
    740         var end = ta.selectionEnd; 
    741         var scrollTop = ta.scrollTop; 
    742         ta.value = ta.value.substring( 0, start ) + ta.value.substring( end, ta.value.length ); 
    743         ta.selectionStart = pos; 
    744         ta.selectionEnd = pos; 
    745         ta.scrollTop = scrollTop 
    746         ta.focus(); 
    747       } 
    748       else 
    749       { 
    750         var sel = this.getSelection(); 
    751         sel.getRangeAt(0).deleteContents(); 
    752         this._iframe.contentWindow.focus(); 
    753       } 
    754     } 
     756    var self = this; 
     757    var t = setTimeout(function(){ // Why do so many thing work only with a timeout?? 
     758      self._iframe.contentWindow.find( self.cc ); 
     759      var sel = self.getSelection(); 
     760      sel.getRangeAt(0).deleteContents(); 
     761      self._iframe.contentWindow.focus(); 
     762    },50); 
     763     
    755764  } catch (e) {} 
     765  } 
    756766}; 
    757767/*--------------------------------------------------------------------------*/ 
Note: See TracChangeset for help on using the changeset viewer.