Changeset 3734
- Timestamp:
- 06/22/09 10:39:04 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CKEditor/trunk/_source/plugins/find/dialogs/find.js
r3712 r3734 215 215 { 216 216 this._.isMatched = true; 217 this.highlight();218 217 }, 219 218 … … 221 220 { 222 221 this._.isMatched = false; 223 this.removeHighlight();224 222 }, 225 223 … … 428 426 searchRange : null, 429 427 matchRange : null, 430 find : function( pattern, matchCase, matchWord, matchCyclic )428 find : function( pattern, matchCase, matchWord, matchCyclic, highlightMatched ) 431 429 { 432 430 if( !this.matchRange ) … … 472 470 continue; 473 471 } 474 475 472 this.matchRange.setMatched(); 473 if ( highlightMatched !== false ) 474 this.matchRange.highlight(); 476 475 return true; 477 476 } … … 497 496 498 497 replace : function( dialog, pattern, newString, matchCase, matchWord, 499 matchCyclic , matchReplaceAll )498 matchCyclic , isReplaceAll ) 500 499 { 501 500 // Successiveness of current replace/find. … … 511 510 var domRange = this.matchRange.toDomRange(); 512 511 var text = editor.document.createText( newString ); 513 514 // Save undo snaps before and after the replacement. 515 var selection = editor.getSelection(); 516 selection.selectRanges( [ domRange ] ); 517 editor.fire( 'saveSnapshot' ); 518 512 if ( !isReplaceAll ) 513 { 514 // Save undo snaps before and after the replacement. 515 var selection = editor.getSelection(); 516 selection.selectRanges( [ domRange ] ); 517 editor.fire( 'saveSnapshot' ); 518 } 519 519 domRange.deleteContents(); 520 520 domRange.insertNode( text ); 521 522 selection.selectRanges( [ domRange ] ); 523 editor.fire( 'saveSnapshot' ); 524 521 if ( !isReplaceAll ) 522 { 523 selection.selectRanges( [ domRange ] ); 524 editor.fire( 'saveSnapshot' ); 525 } 525 526 this.matchRange.updateFromDomRange( domRange ); 526 this.matchRange.highlight(); 527 if ( !isReplaceAll ) 528 this.matchRange.highlight(); 527 529 this.matchRange._.isReplaced = true; 528 530 this.replaceCounter++; … … 530 532 } 531 533 else 532 result = this.find( pattern, matchCase, matchWord, matchCyclic ); 533 534 // Recusively replace all matches. 535 if ( matchReplaceAll && result ) 536 this.replace.apply( this, Array.prototype.slice.call( arguments ) ); 537 538 return matchReplaceAll ? 539 this.replaceCounter : result; 534 result = this.find( pattern, matchCase, matchWord, matchCyclic, !isReplaceAll ); 535 536 return result; 540 537 } 541 538 }; … … 703 700 // Scope to full document. 704 701 finder.searchRange = getSearchRange( true ); 705 finder.matchRange = null; 706 if ( ( replaceNums = finder.replace( dialog, 702 if ( finder.matchRange ) 703 { 704 finder.matchRange.removeHighlight(); 705 finder.matchRange = null; 706 } 707 editor.fire( 'saveSnapshot' ); 708 while( finder.replace( dialog, 707 709 dialog.getValueOf( 'replace', 'txtFindReplace' ), 708 710 dialog.getValueOf( 'replace', 'txtReplace' ), 709 711 dialog.getValueOf( 'replace', 'txtReplaceCaseChk' ), 710 712 dialog.getValueOf( 'replace', 'txtReplaceWordChk' ), 711 false, true ) ) ) 712 alert( editor.lang.findAndReplace.replaceSuccessMsg.replace( /%1/, replaceNums ) ); 713 false, true ) ) 714 ; 715 716 if ( finder.replaceCounter ) 717 { 718 alert( editor.lang.findAndReplace.replaceSuccessMsg.replace( /%1/, finder.replaceCounter ) ); 719 editor.fire( 'saveSnapshot' ); 720 } 713 721 else 714 722 alert( editor.lang.findAndReplace.notFoundMsg );
Note: See TracChangeset
for help on using the changeset viewer.
