+++ /dev/null
-/*\r
- * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
- * Copyright (C) 2003-2009 Frederico Caldeira Knabben\r
- *\r
- * == BEGIN LICENSE ==\r
- *\r
- * Licensed under the terms of any of the following licenses at your\r
- * choice:\r
- *\r
- * - GNU General Public License Version 2 or later (the "GPL")\r
- * http://www.gnu.org/licenses/gpl.html\r
- *\r
- * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
- * http://www.gnu.org/licenses/lgpl.html\r
- *\r
- * - Mozilla Public License Version 1.1 or later (the "MPL")\r
- * http://www.mozilla.org/MPL/MPL-1.1.html\r
- *\r
- * == END LICENSE ==\r
- *\r
- * Dialog windows operations.\r
- */\r
-\r
-var FCKDialog = ( function()\r
-{\r
- var topDialog ;\r
- var baseZIndex ;\r
- var cover ;\r
-\r
- // The document that holds the dialog.\r
- var topWindow = window.parent ;\r
-\r
- while ( topWindow.parent && topWindow.parent != topWindow )\r
- {\r
- try\r
- {\r
- if ( topWindow.parent.document.domain != document.domain )\r
- break ;\r
- if ( topWindow.parent.document.getElementsByTagName( 'frameset' ).length > 0 )\r
- break ;\r
- }\r
- catch ( e )\r
- {\r
- break ;\r
- }\r
- topWindow = topWindow.parent ;\r
- }\r
-\r
- var topDocument = topWindow.document ;\r
-\r
- var getZIndex = function()\r
- {\r
- if ( !baseZIndex )\r
- baseZIndex = FCKConfig.FloatingPanelsZIndex + 999 ;\r
- return ++baseZIndex ;\r
- }\r
-\r
- // TODO : This logic is not actually working when reducing the window, only\r
- // when enlarging it.\r
- var resizeHandler = function()\r
- {\r
- if ( !cover )\r
- return ;\r
-\r
- var relElement = FCKTools.IsStrictMode( topDocument ) ? topDocument.documentElement : topDocument.body ;\r
-\r
- FCKDomTools.SetElementStyles( cover,\r
- {\r
- 'width' : Math.max( relElement.scrollWidth,\r
- relElement.clientWidth,\r
- topDocument.scrollWidth || 0 ) - 1 + 'px',\r
- 'height' : Math.max( relElement.scrollHeight,\r
- relElement.clientHeight,\r
- topDocument.scrollHeight || 0 ) - 1 + 'px'\r
- } ) ;\r
- }\r
-\r
- return {\r
- /**\r
- * Opens a dialog window using the standard dialog template.\r
- */\r
- OpenDialog : function( dialogName, dialogTitle, dialogPage, width, height, customValue, parentWindow, resizable )\r
- {\r
- if ( !topDialog )\r
- this.DisplayMainCover() ;\r
-\r
- // Setup the dialog info to be passed to the dialog.\r
- var dialogInfo =\r
- {\r
- Title : dialogTitle,\r
- Page : dialogPage,\r
- Editor : window,\r
- CustomValue : customValue, // Optional\r
- TopWindow : topWindow\r
- }\r
-\r
- FCK.ToolbarSet.CurrentInstance.Selection.Save( true ) ;\r
-\r
- // Calculate the dialog position, centering it on the screen.\r
- var viewSize = FCKTools.GetViewPaneSize( topWindow ) ;\r
- var scrollPosition = { 'X' : 0, 'Y' : 0 } ;\r
- var useAbsolutePosition = FCKBrowserInfo.IsIE && ( !FCKBrowserInfo.IsIE7 || !FCKTools.IsStrictMode( topWindow.document ) ) ;\r
- if ( useAbsolutePosition )\r
- scrollPosition = FCKTools.GetScrollPosition( topWindow ) ;\r
- var iTop = Math.max( scrollPosition.Y + ( viewSize.Height - height - 20 ) / 2, 0 ) ;\r
- var iLeft = Math.max( scrollPosition.X + ( viewSize.Width - width - 20 ) / 2, 0 ) ;\r
-\r
- // Setup the IFRAME that will hold the dialog.\r
- var dialog = topDocument.createElement( 'iframe' ) ;\r
- FCKTools.ResetStyles( dialog ) ;\r
- dialog.src = FCKConfig.BasePath + 'fckdialog.html' ;\r
-\r
- // Dummy URL for testing whether the code in fckdialog.js alone leaks memory.\r
- // dialog.src = 'about:blank';\r
-\r
- dialog.frameBorder = 0 ;\r
- dialog.allowTransparency = true ;\r
- FCKDomTools.SetElementStyles( dialog,\r
- {\r
- 'position' : ( useAbsolutePosition ) ? 'absolute' : 'fixed',\r
- 'top' : iTop + 'px',\r
- 'left' : iLeft + 'px',\r
- 'width' : width + 'px',\r
- 'height' : height + 'px',\r
- 'zIndex' : getZIndex()\r
- } ) ;\r
-\r
- // Save the dialog info to be used by the dialog page once loaded.\r
- dialog._DialogArguments = dialogInfo ;\r
-\r
- // Append the IFRAME to the target document.\r
- topDocument.body.appendChild( dialog ) ;\r
-\r
- // Keep record of the dialog's parent/child relationships.\r
- dialog._ParentDialog = topDialog ;\r
- topDialog = dialog ;\r
- },\r
-\r
- /**\r
- * (For internal use)\r
- * Called when the top dialog is closed.\r
- */\r
- OnDialogClose : function( dialogWindow )\r
- {\r
- var dialog = dialogWindow.frameElement ;\r
- FCKDomTools.RemoveNode( dialog ) ;\r
-\r
- if ( dialog._ParentDialog ) // Nested Dialog.\r
- {\r
- topDialog = dialog._ParentDialog ;\r
- dialog._ParentDialog.contentWindow.SetEnabled( true ) ;\r
- }\r
- else // First Dialog.\r
- {\r
- // Set the Focus in the browser, so the "OnBlur" event is not\r
- // fired. In IE, there is no need to do that because the dialog\r
- // already moved the selection to the editing area before\r
- // closing (EnsureSelection). Also, the Focus() call here\r
- // causes memory leak on IE7 (weird).\r
- if ( !FCKBrowserInfo.IsIE )\r
- FCK.Focus() ;\r
-\r
- this.HideMainCover() ;\r
- // Bug #1918: Assigning topDialog = null directly causes IE6 to crash.\r
- setTimeout( function(){ topDialog = null ; }, 0 ) ;\r
-\r
- // Release the previously saved selection.\r
- FCK.ToolbarSet.CurrentInstance.Selection.Release() ;\r
- }\r
- },\r
-\r
- DisplayMainCover : function()\r
- {\r
- // Setup the DIV that will be used to cover.\r
- cover = topDocument.createElement( 'div' ) ;\r
- FCKTools.ResetStyles( cover ) ;\r
- FCKDomTools.SetElementStyles( cover,\r
- {\r
- 'position' : 'absolute',\r
- 'zIndex' : getZIndex(),\r
- 'top' : '0px',\r
- 'left' : '0px',\r
- 'backgroundColor' : FCKConfig.BackgroundBlockerColor\r
- } ) ;\r
- FCKDomTools.SetOpacity( cover, FCKConfig.BackgroundBlockerOpacity ) ;\r
-\r
- // For IE6-, we need to fill the cover with a transparent IFRAME,\r
- // to properly block <select> fields.\r
- if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )\r
- {\r
- var iframe = topDocument.createElement( 'iframe' ) ;\r
- FCKTools.ResetStyles( iframe ) ;\r
- iframe.hideFocus = true ;\r
- iframe.frameBorder = 0 ;\r
- iframe.src = FCKTools.GetVoidUrl() ;\r
- FCKDomTools.SetElementStyles( iframe,\r
- {\r
- 'width' : '100%',\r
- 'height' : '100%',\r
- 'position' : 'absolute',\r
- 'left' : '0px',\r
- 'top' : '0px',\r
- 'filter' : 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)'\r
- } ) ;\r
- cover.appendChild( iframe ) ;\r
- }\r
-\r
- // We need to manually adjust the cover size on resize.\r
- FCKTools.AddEventListener( topWindow, 'resize', resizeHandler ) ;\r
- resizeHandler() ;\r
-\r
- topDocument.body.appendChild( cover ) ;\r
-\r
- FCKFocusManager.Lock() ;\r
-\r
- // Prevent the user from refocusing the disabled\r
- // editing window by pressing Tab. (Bug #2065)\r
- var el = FCK.ToolbarSet.CurrentInstance.GetInstanceObject( 'frameElement' ) ;\r
- el._fck_originalTabIndex = el.tabIndex ;\r
- el.tabIndex = -1 ;\r
- },\r
-\r
- HideMainCover : function()\r
- {\r
- FCKDomTools.RemoveNode( cover ) ;\r
- FCKFocusManager.Unlock() ;\r
-\r
- // Revert the tab index hack. (Bug #2065)\r
- var el = FCK.ToolbarSet.CurrentInstance.GetInstanceObject( 'frameElement' ) ;\r
- el.tabIndex = el._fck_originalTabIndex ;\r
- FCKDomTools.ClearElementJSProperty( el, '_fck_originalTabIndex' ) ;\r
- },\r
-\r
- GetCover : function()\r
- {\r
- return cover ;\r
- }\r
- } ;\r
-} )() ;\r