| 128 | | // Steal the focus from the editor. |
| 129 | | var knapsack = topDocument.createElement( 'textarea' ) ; |
| 130 | | knapsack.value = knapsack.name = '_FCK_Dummy' ; |
| 131 | | FCKDomTools.SetElementStyles( knapsack, |
| 132 | | { |
| 133 | | 'position' : 'absolute', |
| 134 | | 'top' : '-1000px', |
| 135 | | 'left' : '-1000px', |
| 136 | | 'zIndex' : 100000 |
| 137 | | } ) ; |
| 138 | | topDocument.body.appendChild( knapsack ) ; |
| 139 | | |
| 140 | | var createDialog = function() |
| 141 | | { |
| 142 | | // Destroy the text area used for stealing focus. |
| 143 | | knapsack.parentNode.removeChild( knapsack ) ; |
| 144 | | |
| 145 | | // Calculate the dialog position, centering it on the screen. |
| 146 | | var viewSize = FCKTools.GetViewPaneSize( topWindow ) ; |
| 147 | | var scrollPosition = FCKTools.GetScrollPosition( topWindow ) ; |
| 148 | | var iTop = Math.max( scrollPosition.Y + ( viewSize.Height - height - 20 ) / 2, 0 ) ; |
| 149 | | var iLeft = Math.max( scrollPosition.X + ( viewSize.Width - width - 20 ) / 2, 0 ) ; |
| 150 | | |
| 151 | | // Setup the IFRAME that will hold the dialog. |
| 152 | | var dialog = topDocument.createElement( 'iframe' ) ; |
| 153 | | dialog.src = FCKConfig.BasePath + 'fckdialog.html' ; |
| 154 | | dialog.frameBorder = 0 ; |
| 155 | | dialog.allowTransparency = true ; |
| 156 | | FCKDomTools.SetElementStyles( dialog, |
| 157 | | { |
| 158 | | 'position' : 'absolute', |
| 159 | | 'top' : iTop + 'px', |
| 160 | | 'left' : iLeft + 'px', |
| 161 | | 'width' : width + 'px', |
| 162 | | 'height' : height + 'px', |
| 163 | | 'zIndex' : getZIndex() |
| 164 | | } ) ; |
| 165 | | |
| 166 | | // Save the dialog info to be used by the dialog page once loaded. |
| 167 | | dialog._DialogArguments = dialogInfo ; |
| 168 | | |
| 169 | | // Append the IFRAME to the target document. |
| 170 | | topDocument.body.appendChild( dialog ) ; |
| 171 | | |
| 172 | | // Keep record of the dialog's parent/child relationships. |
| 173 | | dialog._ParentDialog = topDialog ; |
| 174 | | topDialog = dialog ; |
| 175 | | } |
| 176 | | |
| 177 | | var stealFocus = function() |
| 178 | | { |
| 179 | | knapsack.focus() ; |
| 180 | | if ( knapsack.setSelectionRange ) |
| 181 | | knapsack.setSelectionRange( 0, 0 ) ; |
| 182 | | else |
| 183 | | knapsack.createTextRange().select() ; |
| 184 | | setTimeout( createDialog, 1 ) ; |
| 185 | | } |
| 186 | | |
| 187 | | setTimeout( stealFocus, 1 ) ; |
| | 128 | // Calculate the dialog position, centering it on the screen. |
| | 129 | var viewSize = FCKTools.GetViewPaneSize( topWindow ) ; |
| | 130 | var scrollPosition = FCKTools.GetScrollPosition( topWindow ) ; |
| | 131 | var iTop = Math.max( scrollPosition.Y + ( viewSize.Height - height - 20 ) / 2, 0 ) ; |
| | 132 | var iLeft = Math.max( scrollPosition.X + ( viewSize.Width - width - 20 ) / 2, 0 ) ; |
| | 133 | |
| | 134 | // Setup the IFRAME that will hold the dialog. |
| | 135 | var dialog = topDocument.createElement( 'iframe' ) ; |
| | 136 | dialog.src = FCKConfig.BasePath + 'fckdialog.html' ; |
| | 137 | dialog.frameBorder = 0 ; |
| | 138 | dialog.allowTransparency = true ; |
| | 139 | FCKDomTools.SetElementStyles( dialog, |
| | 140 | { |
| | 141 | 'position' : 'absolute', |
| | 142 | 'top' : iTop + 'px', |
| | 143 | 'left' : iLeft + 'px', |
| | 144 | 'width' : width + 'px', |
| | 145 | 'height' : height + 'px', |
| | 146 | 'zIndex' : getZIndex() |
| | 147 | } ) ; |
| | 148 | |
| | 149 | // Save the dialog info to be used by the dialog page once loaded. |
| | 150 | dialog._DialogArguments = dialogInfo ; |
| | 151 | |
| | 152 | // Append the IFRAME to the target document. |
| | 153 | topDocument.body.appendChild( dialog ) ; |
| | 154 | |
| | 155 | // Keep record of the dialog's parent/child relationships. |
| | 156 | dialog._ParentDialog = topDialog ; |
| | 157 | topDialog = dialog ; |