Changeset 1269

Show
Ignore:
Timestamp:
2008-01-04 08:13:17 (8 months ago)
Author:
martinkou
Message:

Fixed the issue where the Find and Replace dialog no longer works in IE after the floating dialog changes.

Location:
FCKeditor/branches/features/floating_dialog
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/branches/features/floating_dialog/editor/dialog/fck_replace.html

    r1256 r1269  
    5252} 
    5353 
     54// Place a range at the start of document. 
     55// This will be the starting point of our search. 
     56var GlobalRange = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ; 
     57GlobalRange.SetStart( oEditor.FCK.EditorDocument.body, 1 ) ; 
     58GlobalRange.SetEnd( oEditor.FCK.EditorDocument.body, 1 ) ; 
     59GlobalRange.Collapse( true ) ; 
     60 
     61var HighlightRange = null ; 
     62function 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 
     72function 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 
    5483function OnLoad() 
    5584{ 
     
    5786        oEditor.FCKLanguageManager.TranslatePage( document ) ; 
    5887 
    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  
    6788        // Show the appropriate tab at startup. 
    6889        if ( dialogArguments.CustomValue == 'Find' ) 
     
    7394        else 
    7495                dialog.SetSelectedTab( 'Replace' ) ; 
     96 
     97        SelectField( 'txtFind' + dialogArguments.CustomValue ) ; 
    7598} 
    7699 
     
    81104                        document.getElementById('btnFind').disabled = 
    82105                                ( 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() ; 
    92106} 
    93107 
     
    266280        // Start from the end of the current selection. 
    267281        var matcher = new KmpMatch( GetSearchString(), ! GetCheckCase() ) ; 
    268         var cursor = GetSelection().End ; 
     282        var cursor = GlobalRange.CreateBookmark2().End ; 
    269283        var matchState = KMP_NOMATCH ; 
    270284        var matchBookmark = null ; 
     
    346360        } 
    347361 
    348         // If we've found a match, select the match. 
     362        // If we've found a match, highlight the match. 
    349363        if ( matchState == KMP_MATCHED ) 
    350364        { 
    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 ; 
    355368                while ( focus && focus.nodeType != 1 ) 
    356369                        focus = focus.parentNode ; 
     
    372385function Find() 
    373386{ 
    374         var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ; 
    375         dialog.EnsureSelection() ; 
    376         range.MoveToSelection() ; 
    377         range.Collapse( false ) ; 
    378         range.Select() ; 
    379  
    380387        if ( ! _Find() ) 
     388        { 
     389                ClearHighlight() ; 
    381390                alert( FCKLang.DlgFindNotFoundMsg ) ; 
     391        } 
    382392} 
    383393 
    384394function Replace() 
    385395{ 
    386         var selection = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ; 
    387         dialog.EnsureSelection() ; 
    388         selection.MoveToSelection() ; 
    389  
    390         if ( selection.CheckIsCollapsed() ) 
     396        if ( GlobalRange.CheckIsCollapsed() ) 
    391397        { 
    392398                if (! _Find() ) 
     399                { 
     400                        ClearHighlight() ; 
    393401                        alert( FCKLang.DlgFindNotFoundMsg ) ; 
     402                } 
    394403        } 
    395404        else 
    396405        { 
    397406                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 ) ; 
    402410        } 
    403411} 
     
    406414{ 
    407415        oEditor.FCKUndo.SaveUndoStep() ; 
    408         var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ; 
    409  
    410416        var replaceCount = 0 ; 
    411417 
     
    413419        { 
    414420                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 ) ; 
    420424                replaceCount++ ; 
    421425        } 
    422426        if ( replaceCount == 0 ) 
     427        { 
     428                ClearHighlight() ; 
    423429                alert( FCKLang.DlgFindNotFoundMsg ) ; 
     430        } 
    424431        dialog.Cancel() ; 
    425432} 
     433 
     434window.onunload = function(){ ClearHighlight() ; } 
    426435        </script> 
    427436</head> 
  • FCKeditor/branches/features/floating_dialog/editor/_source/classes/fckstyle.js

    r1184 r1269  
    112112                } 
    113113 
    114                 this.ApplyToRange( range, selectIt ) ; 
     114                return this.ApplyToRange( range, selectIt ) ; 
    115115        }, 
    116116 
     
    276276                                range.SelectBookmark( bookmark ) ; 
    277277 
    278                         return ; 
     278                        return bookmark ; 
    279279                } 
    280280 
     
    401401                if ( selectIt ) 
    402402                        range.SelectBookmark( bookmark ) ; 
     403 
     404                return bookmark ; 
    403405        }, 
    404406 
     
    968970                if ( selectIt ) 
    969971                        range.SelectBookmark( bookmark ) ; 
     972 
     973                return bookmark ; 
    970974        }, 
    971975 
  • FCKeditor/branches/features/floating_dialog/fckconfig.js

    r1229 r1269  
    240240        }, 
    241241         
    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' } } 
    243245}; 
    244246