Changeset 1269
- Timestamp:
- 2008-01-04 08:13:17 (8 months ago)
- Location:
- FCKeditor/branches/features/floating_dialog
- Files:
-
- 3 modified
-
editor/dialog/fck_replace.html (modified) (9 diffs)
-
editor/_source/classes/fckstyle.js (modified) (4 diffs)
-
fckconfig.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor/branches/features/floating_dialog/editor/dialog/fck_replace.html
r1256 r1269 52 52 } 53 53 54 // Place a range at the start of document. 55 // This will be the starting point of our search. 56 var GlobalRange = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ; 57 GlobalRange.SetStart( oEditor.FCK.EditorDocument.body, 1 ) ; 58 GlobalRange.SetEnd( oEditor.FCK.EditorDocument.body, 1 ) ; 59 GlobalRange.Collapse( true ) ; 60 61 var HighlightRange = null ; 62 function Highlight() 63 { 64 if ( HighlightRange ) 65 ClearHighlight() ; 66 var bookmark = oEditor.FCKStyles.GetStyle( '_FCK_FindAndReplaceHighlight' ).ApplyToRange( GlobalRange.Clone() ) ; 67 HighlightRange = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ; 68 HighlightRange.MoveToBookmark( bookmark ) ; 69 GlobalRange = HighlightRange.Clone() ; 70 } 71 72 function ClearHighlight() 73 { 74 if ( HighlightRange ) 75 { 76 var bookmark = oEditor.FCKStyles.GetStyle( '_FCK_FindAndReplaceHighlight' ).RemoveFromRange( HighlightRange ) ; 77 var dummyRange = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ; 78 dummyRange.MoveToBookmark( bookmark ) ; 79 HighlightRange = null ; 80 } 81 } 82 54 83 function OnLoad() 55 84 { … … 57 86 oEditor.FCKLanguageManager.TranslatePage( document ) ; 58 87 59 // Place the cursor at the start of document.60 // This will be the starting point of our search.61 var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;62 range.SetStart( oEditor.FCK.EditorDocument.body, 1 ) ;63 range.SetEnd( oEditor.FCK.EditorDocument.body, 1 ) ;64 range.Collapse( true ) ;65 range.Select() ;66 67 88 // Show the appropriate tab at startup. 68 89 if ( dialogArguments.CustomValue == 'Find' ) … … 73 94 else 74 95 dialog.SetSelectedTab( 'Replace' ) ; 96 97 SelectField( 'txtFind' + dialogArguments.CustomValue ) ; 75 98 } 76 99 … … 81 104 document.getElementById('btnFind').disabled = 82 105 ( document.getElementById(idMap["FindText"]).value.length == 0 ) ; 83 }84 85 function GetSelection()86 {87 var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;88 89 dialog.EnsureSelection() ;90 range.MoveToSelection() ;91 return range.CreateBookmark2() ;92 106 } 93 107 … … 266 280 // Start from the end of the current selection. 267 281 var matcher = new KmpMatch( GetSearchString(), ! GetCheckCase() ) ; 268 var cursor = G etSelection().End ;282 var cursor = GlobalRange.CreateBookmark2().End ; 269 283 var matchState = KMP_NOMATCH ; 270 284 var matchBookmark = null ; … … 346 360 } 347 361 348 // If we've found a match, select the match.362 // If we've found a match, highlight the match. 349 363 if ( matchState == KMP_MATCHED ) 350 364 { 351 var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ; 352 range.MoveToBookmark2( matchBookmark ) ; 353 range.Select() ; 354 var focus = range._Range.endContainer ; 365 GlobalRange.MoveToBookmark2( matchBookmark ) ; 366 Highlight() ; 367 var focus = GlobalRange._Range.endContainer ; 355 368 while ( focus && focus.nodeType != 1 ) 356 369 focus = focus.parentNode ; … … 372 385 function Find() 373 386 { 374 var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;375 dialog.EnsureSelection() ;376 range.MoveToSelection() ;377 range.Collapse( false ) ;378 range.Select() ;379 380 387 if ( ! _Find() ) 388 { 389 ClearHighlight() ; 381 390 alert( FCKLang.DlgFindNotFoundMsg ) ; 391 } 382 392 } 383 393 384 394 function Replace() 385 395 { 386 var selection = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ; 387 dialog.EnsureSelection() ; 388 selection.MoveToSelection() ; 389 390 if ( selection.CheckIsCollapsed() ) 396 if ( GlobalRange.CheckIsCollapsed() ) 391 397 { 392 398 if (! _Find() ) 399 { 400 ClearHighlight() ; 393 401 alert( FCKLang.DlgFindNotFoundMsg ) ; 402 } 394 403 } 395 404 else 396 405 { 397 406 oEditor.FCKUndo.SaveUndoStep() ; 398 selection.DeleteContents() ; 399 selection.InsertNode( oEditor.FCK.EditorDocument.createTextNode( GetReplaceString() ) ) ; 400 selection.Collapse( false ) ; 401 selection.Select() ; 407 GlobalRange.DeleteContents() ; 408 GlobalRange.InsertNode( oEditor.FCK.EditorDocument.createTextNode( GetReplaceString() ) ) ; 409 GlobalRange.Collapse( false ) ; 402 410 } 403 411 } … … 406 414 { 407 415 oEditor.FCKUndo.SaveUndoStep() ; 408 var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;409 410 416 var replaceCount = 0 ; 411 417 … … 413 419 { 414 420 dialog.EnsureSelection() ; 415 range.MoveToSelection() ; 416 range.DeleteContents() ; 417 range.InsertNode( oEditor.FCK.EditorDocument.createTextNode( GetReplaceString() ) ) ; 418 range.Collapse( false ) ; 419 range.Select() ; 421 GlobalRange.DeleteContents() ; 422 GlobalRange.InsertNode( oEditor.FCK.EditorDocument.createTextNode( GetReplaceString() ) ) ; 423 GlobalRange.Collapse( false ) ; 420 424 replaceCount++ ; 421 425 } 422 426 if ( replaceCount == 0 ) 427 { 428 ClearHighlight() ; 423 429 alert( FCKLang.DlgFindNotFoundMsg ) ; 430 } 424 431 dialog.Cancel() ; 425 432 } 433 434 window.onunload = function(){ ClearHighlight() ; } 426 435 </script> 427 436 </head> -
FCKeditor/branches/features/floating_dialog/editor/_source/classes/fckstyle.js
r1184 r1269 112 112 } 113 113 114 this.ApplyToRange( range, selectIt ) ;114 return this.ApplyToRange( range, selectIt ) ; 115 115 }, 116 116 … … 276 276 range.SelectBookmark( bookmark ) ; 277 277 278 return ;278 return bookmark ; 279 279 } 280 280 … … 401 401 if ( selectIt ) 402 402 range.SelectBookmark( bookmark ) ; 403 404 return bookmark ; 403 405 }, 404 406 … … 968 970 if ( selectIt ) 969 971 range.SelectBookmark( bookmark ) ; 972 973 return bookmark ; 970 974 }, 971 975 -
FCKeditor/branches/features/floating_dialog/fckconfig.js
r1229 r1269 240 240 }, 241 241 242 'BackColor' : { Element : 'span', Styles : { 'background-color' : '#("Color","color")' } } 242 'BackColor' : { Element : 'span', Styles : { 'background-color' : '#("Color","color")' } }, 243 244 'FindAndReplaceHighlight' : { Element : 'span', Styles : { 'background-color' : 'navy', 'color' : 'white' } } 243 245 }; 244 246