| 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 ) ; |