Changeset 1230

Show
Ignore:
Timestamp:
2007-12-20 05:44:45 (9 months ago)
Author:
martinkou
Message:

Fixed the issue where the caret stays in the editor window after a dialog is opened.
Updated the placeholder's selection retrival logic to use the floating dialog's code instead of using FCKSelection directly.

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

Legend:

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

    r1229 r1230  
    535535                        return ; 
    536536 
    537                 // Debouncing logic for Opera, for preventing the dialog from vibrating during mouse drags. 
    538                 if ( FCKBrowserInfo.IsOpera ) 
     537                // Debouncing logic for Opera and IE7, for preventing the dialog from vibrating during mouse drags. 
     538                if ( FCKBrowserInfo.IsOpera || FCKBrowserInfo.IsIE7 ) 
    539539                { 
    540540                        if ( window.LastMoveTimestamp > (new Date()).getTime() - 20 ) 
     
    640640 
    641641/** 
     642  * Steals selection from the editor window after running EnsureSelection(). 
     643  */ 
     644function StealSelection() 
     645{ 
     646        var dummy = document.createElement( 'textarea' ) ; 
     647        dummy.value = dummy.name = 'dummy' ; 
     648        FCKDomTools.SetElementStyles( dummy, 
     649                { 
     650                        'position' : 'absolute', 
     651                        'left' : '-10000px', 
     652                        'top' : '-10000px', 
     653                        'zIndex' : 10000 
     654                } ) ; 
     655        document.body.appendChild( dummy ) ; 
     656 
     657        var removeDummy = function() 
     658        { 
     659                dummy.parentNode.removeChild( dummy ) ; 
     660        } 
     661 
     662        var stealFocus = function() 
     663        { 
     664                dummy.focus() ; 
     665                if ( dummy.setSelectionRange ) 
     666                        dummy.setSelectionRange( 0, 0 ) ; 
     667                else 
     668                        dummy.createTextRange().select() ; 
     669                setTimeout( removeDummy, 1 ) ; 
     670        } 
     671        setTimeout( stealFocus, 1 ) ; 
     672} 
     673 
     674/** 
    642675 * Get the FCKSelection object for the editor instance. 
    643676 */ 
     
    645678{ 
    646679        EnsureSelection() ; 
    647         return FCK.Selection ; 
     680        var retval = FCK.Selection ; 
     681        StealSelection() ; 
     682        return retval ; 
    648683} 
    649684 
  • FCKeditor/branches/features/floating_dialog/editor/plugins/placeholder/fck_placeholder.html

    r132 r1230  
    2929                <script language="javascript"> 
    3030 
     31var dialog = window.parent ; 
    3132var oEditor = window.parent.InnerDialogLoaded() ; 
    3233var FCKLang = oEditor.FCKLang ; 
     
    4445} 
    4546 
    46 var eSelected = oEditor.FCKSelection.GetSelectedElement() ; 
     47var eSelected = dialog.GetSelection().GetSelectedElement() ; 
    4748 
    4849function LoadSelected() 
  • FCKeditor/branches/features/floating_dialog/editor/_source/internals/fckdialog.js

    r1223 r1230  
    108108                        } 
    109109 
    110                         // Calculate the dialog position, centering it on the screen. 
    111                         var viewSize = FCKTools.GetViewPaneSize( topWindow ) ; 
    112                         var scrollPosition = FCKTools.GetScrollPosition( topWindow ) ; 
    113                         var iTop  = Math.max( scrollPosition.Y + ( viewSize.Height - height - 20 ) / 2, 0 ) ; 
    114                         var iLeft = Math.max( scrollPosition.X + ( viewSize.Width - width - 20 )  / 2, 0 ) ; 
    115  
    116                         // Setup the IFRAME that will hold the dialog. 
    117                         var dialog = topDocument.createElement( 'iframe' ) ; 
    118                         dialog.src = FCKConfig.BasePath + 'fckdialog.html' ; 
    119                         dialog.frameBorder = 0 ; 
    120                         dialog.allowTransparency = true ; 
    121                         FCKDomTools.SetElementStyles( dialog, 
    122                                         { 
    123                                                 'position'      : 'absolute', 
    124                                                 'top'           : iTop + 'px', 
    125                                                 'left'          : iLeft + 'px', 
    126                                                 'width'         : width + 'px', 
    127                                                 'height'        : height + 'px', 
    128                                                 'zIndex'        : getZIndex() 
    129                                         } ) ; 
    130  
    131                         // Save the dialog info to be used by the dialog page once loaded. 
    132                         dialog._DialogArguments = dialogInfo ; 
    133  
    134                         // Append the IFRAME to the target document. 
    135                         topDocument.body.appendChild( dialog ) ; 
    136  
    137                         // Keep record of the dialog's parent/child relationships. 
    138                         dialog._ParentDialog = topDialog ; 
    139                         topDialog = dialog ; 
     110                        // Steal the focus from the editor. 
     111                        var knapsack = topDocument.createElement( 'textarea' ) ; 
     112                        knapsack.value = knapsack.name = '_FCK_Dummy' ; 
     113                        FCKDomTools.SetElementStyles( knapsack, 
     114                                { 
     115                                        'position' : 'absolute', 
     116                                        'top' : '-1000px', 
     117                                        'left' : '-1000px', 
     118                                        'zIndex' : 100000 
     119                                } ) ; 
     120                        topDocument.body.appendChild( knapsack ) ; 
     121 
     122                        var createDialog = function() 
     123                        { 
     124                                // Destroy the text area used for stealing focus. 
     125                                knapsack.parentNode.removeChild( knapsack ) ; 
     126 
     127                                // Calculate the dialog position, centering it on the screen. 
     128                                var viewSize = FCKTools.GetViewPaneSize( topWindow ) ; 
     129                                var scrollPosition = FCKTools.GetScrollPosition( topWindow ) ; 
     130                                var iTop  = Math.max( scrollPosition.Y + ( viewSize.Height - height - 20 ) / 2, 0 ) ; 
     131                                var iLeft = Math.max( scrollPosition.X + ( viewSize.Width - width - 20 )  / 2, 0 ) ; 
     132 
     133                                // Setup the IFRAME that will hold the dialog. 
     134                                var dialog = topDocument.createElement( 'iframe' ) ; 
     135                                dialog.src = FCKConfig.BasePath + 'fckdialog.html' ; 
     136                                dialog.frameBorder = 0 ; 
     137                                dialog.allowTransparency = true ; 
     138                                FCKDomTools.SetElementStyles( dialog, 
     139                                                { 
     140                                                        'position'      : 'absolute', 
     141                                                        'top'           : iTop + 'px', 
     142                                                        'left'          : iLeft + 'px', 
     143                                                        'width'         : width + 'px', 
     144                                                        'height'        : height + 'px', 
     145                                                        'zIndex'        : getZIndex() 
     146                                                } ) ; 
     147 
     148                                // Save the dialog info to be used by the dialog page once loaded. 
     149                                dialog._DialogArguments = dialogInfo ; 
     150 
     151                                // Append the IFRAME to the target document. 
     152                                topDocument.body.appendChild( dialog ) ; 
     153 
     154                                // Keep record of the dialog's parent/child relationships. 
     155                                dialog._ParentDialog = topDialog ; 
     156                                topDialog = dialog ; 
     157                        } 
     158                         
     159                        var stealFocus = function() 
     160                        { 
     161                                knapsack.focus() ; 
     162                                if ( knapsack.setSelectionRange ) 
     163                                        knapsack.setSelectionRange( 0, 0 ) ; 
     164                                else 
     165                                        knapsack.createTextRange().select() ; 
     166                                setTimeout( createDialog, 1 ) ; 
     167                        } 
     168 
     169                        setTimeout( stealFocus, 1 ) ; 
    140170                }, 
    141171