Changeset 703 for trunk/modules/Gecko


Ignore:
Timestamp:
01/28/07 03:43:05 (13 years ago)
Author:
ray
Message:

Ticket #900 retain editing position position between modes

File:
1 edited

Legend:

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

    r696 r703  
    655655}; 
    656656 
     657Xinha.prototype.setCC = function ( target ) 
     658{ 
     659  if ( target == "textarea" ) 
     660  { 
     661    var ta = this._textArea; 
     662    var index = ta.selectionStart; 
     663    var before = ta.value.substring( 0, index ) 
     664    var after = ta.value.substring( index, ta.value.length ); 
     665 
     666    if ( after.match(/^[^<]*>/) ) 
     667    { 
     668      var tagEnd = after.indexOf(">") + 1; 
     669      ta.value = before + after.substring( 0, tagEnd ) + this.cc + after.substring( tagEnd, after.length ); 
     670    } 
     671    else ta.value = before + this.cc + after; 
     672  } 
     673  else 
     674  { 
     675    var sel = this._getSelection(); 
     676    sel.getRangeAt(0).insertNode( document.createTextNode( this.cc ) ); 
     677  } 
     678}; 
     679 
     680Xinha.prototype.findCC = function ( target ) 
     681{ 
     682 
     683  var findIn = ( target == 'textarea' ) ? window : this._iframe.contentWindow; 
     684  if( findIn.find( this.cc ) ) 
     685  { 
     686    if (target == "textarea") 
     687    { 
     688      var ta = this._textArea; 
     689      var start = pos = ta.selectionStart; 
     690      var end = ta.selectionEnd; 
     691      var scrollTop = ta.scrollTop; 
     692      ta.value = ta.value.substring( 0, start ) + ta.value.substring( end, ta.value.length ); 
     693      ta.selectionStart = pos; 
     694      ta.selectionEnd = pos; 
     695      ta.scrollTop = scrollTop 
     696      ta.focus(); 
     697    } 
     698    else 
     699    { 
     700      var sel = this.getSelection(); 
     701      sel.getRangeAt(0).deleteContents(); 
     702    } 
     703  }   
     704}; 
    657705/*--------------------------------------------------------------------------*/ 
    658706/*------------ EXTEND SOME STANDARD "Xinha.prototype" METHODS --------------*/ 
Note: See TracChangeset for help on using the changeset viewer.