2008-04-15 14:15:22 +02:00
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2007-12-17 18:58:19 +01:00
|
|
|
<!--
|
|
|
|
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
|
2008-04-15 14:15:22 +02:00
|
|
|
* Copyright (C) 2003-2008 Frederico Caldeira Knabben
|
2007-12-17 18:58:19 +01:00
|
|
|
*
|
|
|
|
* == BEGIN LICENSE ==
|
|
|
|
*
|
|
|
|
* Licensed under the terms of any of the following licenses at your
|
|
|
|
* choice:
|
|
|
|
*
|
|
|
|
* - GNU General Public License Version 2 or later (the "GPL")
|
|
|
|
* http://www.gnu.org/licenses/gpl.html
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
|
|
|
|
* http://www.gnu.org/licenses/lgpl.html
|
|
|
|
*
|
|
|
|
* - Mozilla Public License Version 1.1 or later (the "MPL")
|
|
|
|
* http://www.mozilla.org/MPL/MPL-1.1.html
|
|
|
|
*
|
|
|
|
* == END LICENSE ==
|
|
|
|
*
|
|
|
|
* This page is used by all dialog box as the container.
|
|
|
|
-->
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<head>
|
2008-04-15 14:15:22 +02:00
|
|
|
<title></title>
|
2007-12-17 18:58:19 +01:00
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<meta name="robots" content="noindex, nofollow" />
|
|
|
|
<script type="text/javascript">
|
2008-10-08 12:16:30 +02:00
|
|
|
// <![CDATA[
|
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Domain relaxation logic.
|
|
|
|
(function()
|
|
|
|
{
|
|
|
|
var d = document.domain ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
while ( true )
|
|
|
|
{
|
|
|
|
// Test if we can access a parent property.
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var parentDomain = ( Args().TopWindow || E ).document.domain ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
if ( document.domain != parentDomain )
|
|
|
|
document.domain = parentDomain ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
break ;
|
|
|
|
}
|
|
|
|
catch( e ) {}
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
|
|
|
|
d = d.replace( /.*?(?:\.|$)/, '' ) ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
if ( d.length == 0 )
|
|
|
|
break ; // It was not able to detect the domain.
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
document.domain = d ;
|
|
|
|
}
|
|
|
|
})() ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
var E = frameElement._DialogArguments.Editor ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// It seems referencing to frameElement._DialogArguments directly would lead to memory leaks in IE.
|
|
|
|
// So let's use functions to access its members instead.
|
|
|
|
function Args()
|
|
|
|
{
|
|
|
|
return frameElement._DialogArguments ;
|
2007-12-17 18:58:19 +01:00
|
|
|
}
|
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
function ParentDialog( dialog )
|
2007-12-17 18:58:19 +01:00
|
|
|
{
|
2008-04-15 14:15:22 +02:00
|
|
|
return dialog ? dialog._ParentDialog : frameElement._ParentDialog ;
|
|
|
|
}
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
var FCK = E.FCK ;
|
|
|
|
var FCKTools = E.FCKTools ;
|
|
|
|
var FCKDomTools = E.FCKDomTools ;
|
|
|
|
var FCKDialog = E.FCKDialog ;
|
|
|
|
var FCKBrowserInfo = E.FCKBrowserInfo ;
|
|
|
|
var FCKConfig = E.FCKConfig ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Steal the focus so that the caret would no longer stay in the editor iframe.
|
|
|
|
window.focus() ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Sets the Skin CSS
|
|
|
|
document.write( FCKTools.GetStyleHtml( FCKConfig.SkinDialogCSS ) ) ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Sets the language direction.
|
|
|
|
var langDir = document.documentElement.dir = E.FCKLang.Dir ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// For IE6-, the fck_dialog_ie6.js is loaded, used to fix limitations in the browser.
|
|
|
|
if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )
|
|
|
|
document.write( '<' + 'script type="text/javascript" src="' + FCKConfig.SkinPath + 'fck_dialog_ie6.js"><' + '\/script>' ) ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
FCKTools.RegisterDollarFunction( window ) ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Resize related functions.
|
|
|
|
var Sizer = function()
|
2007-12-17 18:58:19 +01:00
|
|
|
{
|
2008-04-15 14:15:22 +02:00
|
|
|
var bAutoSize = false ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
var retval = {
|
|
|
|
// Sets whether the dialog should auto-resize according to its content's height.
|
|
|
|
SetAutoSize : function( autoSize )
|
|
|
|
{
|
|
|
|
bAutoSize = autoSize ;
|
|
|
|
this.RefreshSize() ;
|
|
|
|
},
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Fit the dialog container's layout to the inner iframe's external size.
|
|
|
|
RefreshContainerSize : function()
|
|
|
|
{
|
|
|
|
var frmMain = $( 'frmMain' ) ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
if ( frmMain )
|
|
|
|
{
|
|
|
|
// Get the container size.
|
|
|
|
var height = $( 'contents' ).offsetHeight ;
|
|
|
|
|
|
|
|
// Subtract the size of other elements.
|
|
|
|
height -= $( 'TitleArea' ).offsetHeight ;
|
|
|
|
height -= $( 'TabsRow' ).offsetHeight ;
|
|
|
|
height -= $( 'PopupButtons' ).offsetHeight ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
frmMain.style.height = Math.max( height, 0 ) + 'px' ;
|
|
|
|
}
|
|
|
|
},
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Resize and re-layout the dialog.
|
|
|
|
// Triggers the onresize event for the layout logic.
|
|
|
|
ResizeDialog : function( width, height )
|
2007-12-17 18:58:19 +01:00
|
|
|
{
|
2008-04-15 14:15:22 +02:00
|
|
|
FCKDomTools.SetElementStyles( window.frameElement,
|
|
|
|
{
|
|
|
|
'width' : width + 'px',
|
|
|
|
'height' : height + 'px'
|
|
|
|
} ) ;
|
|
|
|
|
|
|
|
// If the skin have defined a function for resize fixes, call it now.
|
|
|
|
if ( typeof window.DoResizeFixes == 'function' )
|
|
|
|
window.DoResizeFixes() ;
|
|
|
|
},
|
|
|
|
|
|
|
|
// if bAutoSize is true, automatically fit the dialog size and layout to
|
|
|
|
// accomodate the inner iframe's internal height.
|
|
|
|
// if bAutoSize is false, then only the layout logic for the dialog decorations
|
|
|
|
// is run to accomodate the inner iframe's external height.
|
|
|
|
RefreshSize : function()
|
|
|
|
{
|
|
|
|
if ( bAutoSize )
|
|
|
|
{
|
|
|
|
var frmMain = $( 'frmMain' ) ;
|
|
|
|
var innerDoc = frmMain.contentWindow.document ;
|
|
|
|
var isStrict = FCKTools.IsStrictMode( innerDoc ) ;
|
|
|
|
|
|
|
|
// Get the size of the frame contents.
|
|
|
|
var innerWidth = isStrict ? innerDoc.documentElement.scrollWidth : innerDoc.body.scrollWidth ;
|
|
|
|
var innerHeight = isStrict ? innerDoc.documentElement.scrollHeight : innerDoc.body.scrollHeight ;
|
|
|
|
|
|
|
|
// Get the current frame size.
|
|
|
|
var frameSize = FCKTools.GetViewPaneSize( frmMain.contentWindow ) ;
|
|
|
|
|
|
|
|
var deltaWidth = innerWidth - frameSize.Width ;
|
|
|
|
var deltaHeight = innerHeight - frameSize.Height ;
|
|
|
|
|
|
|
|
// If the contents fits the current size.
|
|
|
|
if ( deltaWidth <= 0 && deltaHeight <= 0 )
|
|
|
|
return ;
|
|
|
|
|
|
|
|
var dialogWidth = frameElement.offsetWidth + Math.max( deltaWidth, 0 ) ;
|
|
|
|
var dialogHeight = frameElement.offsetHeight + Math.max( deltaHeight, 0 ) ;
|
|
|
|
|
|
|
|
this.ResizeDialog( dialogWidth, dialogHeight ) ;
|
|
|
|
}
|
|
|
|
this.RefreshContainerSize() ;
|
2007-12-17 18:58:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
/**
|
|
|
|
* Safari seems to have a bug with the time when RefreshSize() is executed - it
|
|
|
|
* thinks frmMain's innerHeight is 0 if we query the value too soon after the
|
|
|
|
* page is loaded in some circumstances. (#1316)
|
|
|
|
* TODO : Maybe this is not needed anymore after #35.
|
|
|
|
*/
|
|
|
|
if ( FCKBrowserInfo.IsSafari )
|
|
|
|
{
|
|
|
|
var originalRefreshSize = retval.RefreshSize ;
|
|
|
|
|
|
|
|
retval.RefreshSize = function()
|
|
|
|
{
|
|
|
|
FCKTools.SetTimeout( originalRefreshSize, 1, retval ) ;
|
|
|
|
}
|
|
|
|
}
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-10-08 12:16:30 +02:00
|
|
|
/**
|
|
|
|
* IE6 has a similar bug where it sometimes thinks $('contents') has an
|
|
|
|
* offsetHeight of 0 (#2114).
|
|
|
|
*/
|
|
|
|
if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )
|
|
|
|
{
|
|
|
|
var originalRefreshContainerSize = retval.RefreshContainerSize ;
|
|
|
|
retval.RefreshContainerSize = function()
|
|
|
|
{
|
|
|
|
FCKTools.SetTimeout( originalRefreshContainerSize, 1, retval ) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
window.onresize = function()
|
2007-12-17 18:58:19 +01:00
|
|
|
{
|
2008-04-15 14:15:22 +02:00
|
|
|
retval.RefreshContainerSize() ;
|
2007-12-17 18:58:19 +01:00
|
|
|
}
|
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
window.SetAutoSize = FCKTools.Bind( retval, retval.SetAutoSize ) ;
|
|
|
|
|
|
|
|
return retval ;
|
|
|
|
}() ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Manages the throbber image that appears if the inner part of dialog is taking too long to load.
|
|
|
|
var Throbber = function()
|
2007-12-17 18:58:19 +01:00
|
|
|
{
|
2008-04-15 14:15:22 +02:00
|
|
|
var timer ;
|
|
|
|
|
|
|
|
var updateThrobber = function()
|
2007-12-17 18:58:19 +01:00
|
|
|
{
|
2008-04-15 14:15:22 +02:00
|
|
|
var throbberParent = $( 'throbberBlock' ) ;
|
|
|
|
var throbberBlocks = throbberParent.childNodes ;
|
|
|
|
var lastClass = throbberParent.lastChild.className ;
|
|
|
|
|
|
|
|
// From the last to the second one, copy the class from the previous one.
|
|
|
|
for ( var i = throbberBlocks.length - 1 ; i > 0 ; i-- )
|
|
|
|
throbberBlocks[i].className = throbberBlocks[i-1].className ;
|
|
|
|
|
|
|
|
// For the first one, copy the last class (rotation).
|
|
|
|
throbberBlocks[0].className = lastClass ;
|
2007-12-17 18:58:19 +01:00
|
|
|
}
|
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
return {
|
|
|
|
Show : function( waitMilliseconds )
|
|
|
|
{
|
|
|
|
// Auto-setup the Show function to be called again after the
|
|
|
|
// requested amount of time.
|
|
|
|
if ( waitMilliseconds && waitMilliseconds > 0 )
|
|
|
|
{
|
|
|
|
timer = FCKTools.SetTimeout( this.Show, waitMilliseconds, this, null, window ) ;
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
|
|
|
var throbberParent = $( 'throbberBlock' ) ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-10-08 12:16:30 +02:00
|
|
|
if (throbberParent.childNodes.length == 0)
|
|
|
|
{
|
|
|
|
// Create the throbber blocks.
|
|
|
|
var classIds = [ 1,2,3,4,5,4,3,2 ] ;
|
|
|
|
while ( classIds.length > 0 )
|
|
|
|
throbberParent.appendChild( document.createElement( 'div' ) ).className = ' throbber_' + classIds.shift() ;
|
|
|
|
}
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Center the throbber.
|
|
|
|
var frm = $( 'contents' ) ;
|
|
|
|
var frmCoords = FCKTools.GetDocumentPosition( window, frm ) ;
|
|
|
|
var x = frmCoords.x + ( frm.offsetWidth - throbberParent.offsetWidth ) / 2 ;
|
|
|
|
var y = frmCoords.y + ( frm.offsetHeight - throbberParent.offsetHeight ) / 2 ;
|
|
|
|
throbberParent.style.left = parseInt( x, 10 ) + 'px' ;
|
|
|
|
throbberParent.style.top = parseInt( y, 10 ) + 'px' ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Show it.
|
|
|
|
throbberParent.style.visibility = '' ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-10-08 12:16:30 +02:00
|
|
|
// Hide tabs and buttons:
|
|
|
|
$( 'Tabs' ).style.visibility = 'hidden' ;
|
|
|
|
$( 'PopupButtons' ).style.visibility = 'hidden' ;
|
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Setup the animation interval.
|
|
|
|
timer = setInterval( updateThrobber, 100 ) ;
|
|
|
|
},
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
Hide : function()
|
|
|
|
{
|
|
|
|
if ( timer )
|
|
|
|
{
|
|
|
|
clearInterval( timer ) ;
|
|
|
|
timer = null ;
|
|
|
|
}
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-10-08 12:16:30 +02:00
|
|
|
$( 'throbberBlock' ).style.visibility = 'hidden' ;
|
|
|
|
|
|
|
|
// Show tabs and buttons:
|
|
|
|
$( 'Tabs' ).style.visibility = '' ;
|
|
|
|
$( 'PopupButtons' ).style.visibility = '' ;
|
2008-04-15 14:15:22 +02:00
|
|
|
}
|
|
|
|
} ;
|
|
|
|
}() ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Drag and drop handlers.
|
|
|
|
var DragAndDrop = function()
|
|
|
|
{
|
|
|
|
var registeredWindows = [] ;
|
|
|
|
var lastCoords ;
|
|
|
|
var currentPos ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
var cleanUpHandlers = function()
|
|
|
|
{
|
|
|
|
for ( var i = 0 ; i < registeredWindows.length ; i++ )
|
|
|
|
{
|
|
|
|
FCKTools.RemoveEventListener( registeredWindows[i].document, 'mousemove', dragMouseMoveHandler ) ;
|
|
|
|
FCKTools.RemoveEventListener( registeredWindows[i].document, 'mouseup', dragMouseUpHandler ) ;
|
|
|
|
}
|
|
|
|
}
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
var dragMouseMoveHandler = function( evt )
|
2007-12-17 18:58:19 +01:00
|
|
|
{
|
2008-04-15 14:15:22 +02:00
|
|
|
if ( !lastCoords )
|
|
|
|
return ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
if ( !evt )
|
|
|
|
evt = FCKTools.GetElementDocument( this ).parentWindow.event ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Updated the last coordinates.
|
|
|
|
var currentCoords =
|
|
|
|
{
|
|
|
|
x : evt.screenX,
|
|
|
|
y : evt.screenY
|
|
|
|
} ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
currentPos =
|
|
|
|
{
|
|
|
|
x : currentPos.x + ( currentCoords.x - lastCoords.x ),
|
|
|
|
y : currentPos.y + ( currentCoords.y - lastCoords.y )
|
|
|
|
} ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
lastCoords = currentCoords ;
|
|
|
|
|
|
|
|
frameElement.style.left = currentPos.x + 'px' ;
|
|
|
|
frameElement.style.top = currentPos.y + 'px' ;
|
|
|
|
|
|
|
|
if ( evt.preventDefault )
|
|
|
|
evt.preventDefault() ;
|
2007-12-17 18:58:19 +01:00
|
|
|
else
|
2008-04-15 14:15:22 +02:00
|
|
|
evt.returnValue = false ;
|
2007-12-17 18:58:19 +01:00
|
|
|
}
|
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
var dragMouseUpHandler = function( evt )
|
|
|
|
{
|
|
|
|
if ( !lastCoords )
|
|
|
|
return ;
|
|
|
|
if ( !evt )
|
|
|
|
evt = FCKTools.GetElementDocument( this ).parentWindow.event ;
|
|
|
|
cleanUpHandlers() ;
|
|
|
|
lastCoords = null ;
|
|
|
|
}
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
return {
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
MouseDownHandler : function( evt )
|
2007-12-17 18:58:19 +01:00
|
|
|
{
|
2008-04-15 14:15:22 +02:00
|
|
|
var view = null ;
|
|
|
|
if ( !evt )
|
2007-12-17 18:58:19 +01:00
|
|
|
{
|
2008-04-15 14:15:22 +02:00
|
|
|
view = FCKTools.GetElementDocument( this ).parentWindow ;
|
|
|
|
evt = view.event ;
|
2007-12-17 18:58:19 +01:00
|
|
|
}
|
2008-04-15 14:15:22 +02:00
|
|
|
else
|
|
|
|
view = evt.view ;
|
|
|
|
|
|
|
|
var target = evt.srcElement || evt.target ;
|
|
|
|
if ( target.id == 'closeButton' || target.className == 'PopupTab' || target.className == 'PopupTabSelected' )
|
|
|
|
return ;
|
|
|
|
|
|
|
|
lastCoords =
|
|
|
|
{
|
|
|
|
x : evt.screenX,
|
|
|
|
y : evt.screenY
|
|
|
|
} ;
|
|
|
|
|
|
|
|
// Save the current IFRAME position.
|
|
|
|
currentPos =
|
|
|
|
{
|
|
|
|
x : parseInt( FCKDomTools.GetCurrentElementStyle( frameElement, 'left' ), 10 ),
|
|
|
|
y : parseInt( FCKDomTools.GetCurrentElementStyle( frameElement, 'top' ), 10 )
|
|
|
|
} ;
|
|
|
|
|
|
|
|
for ( var i = 0 ; i < registeredWindows.length ; i++ )
|
|
|
|
{
|
|
|
|
FCKTools.AddEventListener( registeredWindows[i].document, 'mousemove', dragMouseMoveHandler ) ;
|
|
|
|
FCKTools.AddEventListener( registeredWindows[i].document, 'mouseup', dragMouseUpHandler ) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( evt.preventDefault )
|
|
|
|
evt.preventDefault() ;
|
|
|
|
else
|
|
|
|
evt.returnValue = false ;
|
|
|
|
},
|
|
|
|
|
|
|
|
RegisterHandlers : function( w )
|
|
|
|
{
|
|
|
|
registeredWindows.push( w ) ;
|
2007-12-17 18:58:19 +01:00
|
|
|
}
|
|
|
|
}
|
2008-04-15 14:15:22 +02:00
|
|
|
}() ;
|
|
|
|
|
|
|
|
// Selection related functions.
|
|
|
|
//(Became simple shortcuts after the fix for #1990)
|
|
|
|
var Selection =
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Ensures that the editing area contains an active selection. This is a
|
|
|
|
* requirement for IE, as it looses the selection when the focus moves to other
|
|
|
|
* frames.
|
|
|
|
*/
|
|
|
|
EnsureSelection : function()
|
|
|
|
{
|
|
|
|
FCK.Selection.Restore() ;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the FCKSelection object for the editor instance.
|
|
|
|
*/
|
|
|
|
GetSelection : function()
|
|
|
|
{
|
|
|
|
return FCK.Selection ;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the selected element in the editing area (for object selections).
|
|
|
|
*/
|
|
|
|
GetSelectedElement : function()
|
|
|
|
{
|
|
|
|
return FCK.Selection.GetSelectedElement() ;
|
|
|
|
}
|
2007-12-17 18:58:19 +01:00
|
|
|
}
|
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Tab related functions.
|
|
|
|
var Tabs = function()
|
2007-12-17 18:58:19 +01:00
|
|
|
{
|
2008-04-15 14:15:22 +02:00
|
|
|
// Only element ids should be stored here instead of element references since setSelectedTab and TabDiv_OnClick
|
|
|
|
// would build circular references with the element references inside and cause memory leaks in IE6.
|
|
|
|
var oTabs = new Object() ;
|
|
|
|
|
|
|
|
var setSelectedTab = function( tabCode )
|
2007-12-17 18:58:19 +01:00
|
|
|
{
|
2008-04-15 14:15:22 +02:00
|
|
|
for ( var sCode in oTabs )
|
2007-12-17 18:58:19 +01:00
|
|
|
{
|
2008-04-15 14:15:22 +02:00
|
|
|
if ( sCode == tabCode )
|
|
|
|
$( oTabs[sCode] ).className = 'PopupTabSelected' ;
|
|
|
|
else
|
|
|
|
$( oTabs[sCode] ).className = 'PopupTab' ;
|
2007-12-17 18:58:19 +01:00
|
|
|
}
|
2008-04-15 14:15:22 +02:00
|
|
|
|
|
|
|
if ( typeof( window.frames["frmMain"].OnDialogTabChange ) == 'function' )
|
|
|
|
window.frames["frmMain"].OnDialogTabChange( tabCode ) ;
|
2007-12-17 18:58:19 +01:00
|
|
|
}
|
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
function TabDiv_OnClick()
|
|
|
|
{
|
|
|
|
setSelectedTab( this.TabCode ) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
window.AddTab = function( tabCode, tabText, startHidden )
|
|
|
|
{
|
|
|
|
if ( typeof( oTabs[ tabCode ] ) != 'undefined' )
|
|
|
|
return ;
|
|
|
|
|
|
|
|
var eTabsRow = $( 'Tabs' ) ;
|
|
|
|
|
|
|
|
var oCell = eTabsRow.insertCell( eTabsRow.cells.length - 1 ) ;
|
|
|
|
oCell.noWrap = true ;
|
|
|
|
|
|
|
|
var oDiv = document.createElement( 'DIV' ) ;
|
|
|
|
oDiv.className = 'PopupTab' ;
|
|
|
|
oDiv.innerHTML = tabText ;
|
|
|
|
oDiv.TabCode = tabCode ;
|
|
|
|
oDiv.onclick = TabDiv_OnClick ;
|
|
|
|
oDiv.id = Math.random() ;
|
|
|
|
|
|
|
|
if ( startHidden )
|
|
|
|
oDiv.style.display = 'none' ;
|
|
|
|
|
|
|
|
eTabsRow = $( 'TabsRow' ) ;
|
|
|
|
|
|
|
|
oCell.appendChild( oDiv ) ;
|
|
|
|
|
|
|
|
if ( eTabsRow.style.display == 'none' )
|
|
|
|
{
|
|
|
|
var eTitleArea = $( 'TitleArea' ) ;
|
|
|
|
eTitleArea.className = 'PopupTitle' ;
|
|
|
|
|
|
|
|
oDiv.className = 'PopupTabSelected' ;
|
|
|
|
eTabsRow.style.display = '' ;
|
|
|
|
|
|
|
|
if ( window.onresize )
|
|
|
|
window.onresize() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
oTabs[ tabCode ] = oDiv.id ;
|
|
|
|
|
|
|
|
FCKTools.DisableSelection( oDiv ) ;
|
|
|
|
} ;
|
|
|
|
|
|
|
|
window.SetSelectedTab = setSelectedTab ;
|
|
|
|
|
|
|
|
window.SetTabVisibility = function( tabCode, isVisible )
|
|
|
|
{
|
|
|
|
var oTab = $( oTabs[ tabCode ] ) ;
|
|
|
|
oTab.style.display = isVisible ? '' : 'none' ;
|
|
|
|
|
|
|
|
if ( ! isVisible && oTab.className == 'PopupTabSelected' )
|
|
|
|
{
|
|
|
|
for ( var sCode in oTabs )
|
|
|
|
{
|
|
|
|
if ( $( oTabs[sCode] ).style.display != 'none' )
|
|
|
|
{
|
|
|
|
setSelectedTab( sCode ) ;
|
|
|
|
break ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} ;
|
|
|
|
}() ;
|
|
|
|
|
|
|
|
// readystatechange handler for registering drag and drop handlers in cover
|
|
|
|
// iframes, defined out here to avoid memory leak.
|
|
|
|
// Do NOT put this function as a private function as it will induce memory leak
|
|
|
|
// in IE and it's not detectable with Drip or sIEve and undetectable leaks are
|
|
|
|
// really nasty (sigh).
|
|
|
|
var onReadyRegister = function()
|
2007-12-17 18:58:19 +01:00
|
|
|
{
|
2008-04-15 14:15:22 +02:00
|
|
|
if ( this.readyState != 'complete' )
|
|
|
|
return ;
|
|
|
|
DragAndDrop.RegisterHandlers( this.contentWindow ) ;
|
|
|
|
} ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// The business logic of the dialog, dealing with operational things like
|
|
|
|
// dialog open/dialog close/enable/disable/etc.
|
|
|
|
(function()
|
|
|
|
{
|
|
|
|
var setOnKeyDown = function( targetDocument )
|
|
|
|
{
|
|
|
|
targetDocument.onkeydown = function ( e )
|
|
|
|
{
|
|
|
|
e = e || event || this.parentWindow.event ;
|
|
|
|
switch ( e.keyCode )
|
|
|
|
{
|
|
|
|
case 13 : // ENTER
|
|
|
|
var oTarget = e.srcElement || e.target ;
|
|
|
|
if ( oTarget.tagName == 'TEXTAREA' )
|
|
|
|
return true ;
|
|
|
|
Ok() ;
|
|
|
|
return false ;
|
|
|
|
|
|
|
|
case 27 : // ESC
|
|
|
|
Cancel() ;
|
|
|
|
return false ;
|
|
|
|
}
|
|
|
|
return true ;
|
|
|
|
}
|
|
|
|
} ;
|
|
|
|
|
|
|
|
var contextMenuBlocker = function( e )
|
2007-12-17 18:58:19 +01:00
|
|
|
{
|
|
|
|
var sTagName = e.target.tagName ;
|
|
|
|
if ( ! ( ( sTagName == "INPUT" && e.target.type == "text" ) || sTagName == "TEXTAREA" ) )
|
|
|
|
e.preventDefault() ;
|
2008-04-15 14:15:22 +02:00
|
|
|
} ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
var disableContextMenu = function( targetDocument )
|
2007-12-17 18:58:19 +01:00
|
|
|
{
|
2008-04-15 14:15:22 +02:00
|
|
|
if ( FCKBrowserInfo.IsIE )
|
|
|
|
return ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
targetDocument.addEventListener( 'contextmenu', contextMenuBlocker, true ) ;
|
|
|
|
} ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Program entry point.
|
|
|
|
window.Init = function()
|
|
|
|
{
|
|
|
|
// Start the throbber timer.
|
|
|
|
Throbber.Show( 1000 ) ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
Sizer.RefreshContainerSize() ;
|
|
|
|
LoadInnerDialog() ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
FCKTools.DisableSelection( document.body ) ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Make the title area draggable.
|
|
|
|
var titleElement = $( 'header' ) ;
|
|
|
|
titleElement.onmousedown = DragAndDrop.MouseDownHandler ;
|
|
|
|
|
|
|
|
// Connect mousemove and mouseup events from dialog frame and outer window to dialog dragging logic.
|
|
|
|
DragAndDrop.RegisterHandlers( window ) ;
|
|
|
|
DragAndDrop.RegisterHandlers( Args().TopWindow ) ;
|
|
|
|
|
|
|
|
// Disable the previous dialog if it exists.
|
|
|
|
if ( ParentDialog() )
|
|
|
|
{
|
|
|
|
ParentDialog().contentWindow.SetEnabled( false ) ;
|
|
|
|
if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )
|
|
|
|
{
|
|
|
|
var currentParent = ParentDialog() ;
|
|
|
|
while ( currentParent )
|
|
|
|
{
|
|
|
|
var blockerFrame = currentParent.contentWindow.$( 'blocker' ) ;
|
|
|
|
if ( blockerFrame.readyState == 'complete' )
|
|
|
|
DragAndDrop.RegisterHandlers( blockerFrame.contentWindow ) ;
|
|
|
|
else
|
|
|
|
blockerFrame.onreadystatechange = onReadyRegister ;
|
|
|
|
currentParent = ParentDialog( currentParent ) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var currentParent = ParentDialog() ;
|
|
|
|
while ( currentParent )
|
|
|
|
{
|
|
|
|
DragAndDrop.RegisterHandlers( currentParent.contentWindow ) ;
|
|
|
|
currentParent = ParentDialog( currentParent ) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If this is the only dialog on screen, enable the background cover.
|
|
|
|
if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )
|
|
|
|
{
|
|
|
|
var blockerFrame = FCKDialog.GetCover().firstChild ;
|
|
|
|
if ( blockerFrame.readyState == 'complete' )
|
|
|
|
DragAndDrop.RegisterHandlers( blockerFrame.contentWindow ) ;
|
|
|
|
else
|
|
|
|
blockerFrame.onreadystatechange = onReadyRegister;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add Enter/Esc hotkeys and disable context menu for the dialog.
|
|
|
|
setOnKeyDown( document ) ;
|
|
|
|
disableContextMenu( document ) ;
|
|
|
|
} ;
|
|
|
|
|
|
|
|
window.LoadInnerDialog = function()
|
2007-12-17 18:58:19 +01:00
|
|
|
{
|
2008-04-15 14:15:22 +02:00
|
|
|
if ( window.onresize )
|
|
|
|
window.onresize() ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// First of all, translate the dialog box contents.
|
|
|
|
E.FCKLanguageManager.TranslatePage( document ) ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
// Create the IFRAME that holds the dialog contents.
|
2008-10-08 12:16:30 +02:00
|
|
|
$( 'innerContents' ).innerHTML = '<iframe id="frmMain" src="' + Args().Page + '" name="frmMain" frameborder="0" width="100%" height="100%" scrolling="auto" style="visibility: hidden;" allowtransparency="true"><\/iframe>' ;
|
2008-04-15 14:15:22 +02:00
|
|
|
} ;
|
|
|
|
|
|
|
|
window.InnerDialogLoaded = function()
|
|
|
|
{
|
|
|
|
// If the dialog has been closed before the iframe is loaded, do nothing.
|
|
|
|
if ( !frameElement.parentNode )
|
|
|
|
return null ;
|
|
|
|
|
|
|
|
Throbber.Hide() ;
|
|
|
|
|
|
|
|
var frmMain = $('frmMain') ;
|
|
|
|
var innerWindow = frmMain.contentWindow ;
|
|
|
|
var innerDoc = innerWindow.document ;
|
|
|
|
|
|
|
|
// Show the loaded iframe.
|
|
|
|
frmMain.style.visibility = '' ;
|
|
|
|
|
|
|
|
// Set the language direction.
|
|
|
|
innerDoc.documentElement.dir = langDir ;
|
|
|
|
|
|
|
|
// Sets the Skin CSS.
|
|
|
|
innerDoc.write( FCKTools.GetStyleHtml( FCKConfig.SkinDialogCSS ) ) ;
|
|
|
|
|
|
|
|
setOnKeyDown( innerDoc ) ;
|
|
|
|
disableContextMenu( innerDoc ) ;
|
|
|
|
|
|
|
|
Sizer.RefreshContainerSize();
|
|
|
|
|
|
|
|
DragAndDrop.RegisterHandlers( innerWindow ) ;
|
|
|
|
|
|
|
|
innerWindow.focus() ;
|
|
|
|
|
|
|
|
return E ;
|
|
|
|
} ;
|
|
|
|
|
|
|
|
window.SetOkButton = function( showIt )
|
|
|
|
{
|
|
|
|
$('btnOk').style.visibility = ( showIt ? '' : 'hidden' ) ;
|
|
|
|
} ;
|
|
|
|
|
|
|
|
window.Ok = function()
|
|
|
|
{
|
|
|
|
Selection.EnsureSelection() ;
|
|
|
|
|
|
|
|
var frmMain = window.frames["frmMain"] ;
|
|
|
|
|
|
|
|
if ( frmMain.Ok && frmMain.Ok() )
|
|
|
|
CloseDialog() ;
|
|
|
|
else
|
|
|
|
frmMain.focus() ;
|
|
|
|
} ;
|
|
|
|
|
|
|
|
window.Cancel = function( dontFireChange )
|
|
|
|
{
|
|
|
|
Selection.EnsureSelection() ;
|
|
|
|
return CloseDialog( dontFireChange ) ;
|
|
|
|
} ;
|
|
|
|
|
|
|
|
window.CloseDialog = function( dontFireChange )
|
|
|
|
{
|
|
|
|
Throbber.Hide() ;
|
|
|
|
|
|
|
|
// Points the src to a non-existent location to avoid loading errors later, in case the dialog
|
|
|
|
// haven't been completed loaded at this point.
|
|
|
|
if ( $( 'frmMain' ) )
|
|
|
|
$( 'frmMain' ).src = FCKTools.GetVoidUrl() ;
|
|
|
|
|
|
|
|
if ( !dontFireChange && !FCK.EditMode )
|
|
|
|
{
|
|
|
|
// All dialog windows, by default, will fire the "OnSelectionChange"
|
|
|
|
// event, no matter the Ok or Cancel button has been pressed.
|
|
|
|
// It seems that OnSelectionChange may enter on a concurrency state
|
|
|
|
// on some situations (#1965), so we should put the event firing in
|
|
|
|
// the execution queue instead of executing it immediately.
|
|
|
|
setTimeout( function()
|
|
|
|
{
|
|
|
|
FCK.Events.FireEvent( 'OnSelectionChange' ) ;
|
|
|
|
}, 0 ) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
FCKDialog.OnDialogClose( window ) ;
|
|
|
|
} ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
window.SetEnabled = function( isEnabled )
|
|
|
|
{
|
|
|
|
var cover = $( 'cover' ) ;
|
|
|
|
cover.style.display = isEnabled ? 'none' : '' ;
|
2007-12-17 18:58:19 +01:00
|
|
|
|
2008-04-15 14:15:22 +02:00
|
|
|
if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )
|
|
|
|
{
|
|
|
|
if ( !isEnabled )
|
|
|
|
{
|
|
|
|
// Inser the blocker IFRAME before the cover.
|
|
|
|
var blocker = document.createElement( 'iframe' ) ;
|
|
|
|
blocker.src = FCKTools.GetVoidUrl() ;
|
|
|
|
blocker.hideFocus = true ;
|
|
|
|
blocker.frameBorder = 0 ;
|
|
|
|
blocker.id = blocker.className = 'blocker' ;
|
|
|
|
cover.appendChild( blocker ) ;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var blocker = $( 'blocker' ) ;
|
|
|
|
if ( blocker && blocker.parentNode )
|
|
|
|
blocker.parentNode.removeChild( blocker ) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} ;
|
|
|
|
})() ;
|
2008-10-08 12:16:30 +02:00
|
|
|
// ]]>
|
2007-12-17 18:58:19 +01:00
|
|
|
</script>
|
|
|
|
</head>
|
2008-04-15 14:15:22 +02:00
|
|
|
<body onload="Init();" class="PopupBody">
|
|
|
|
<div class="contents" id="contents">
|
|
|
|
<div id="header">
|
|
|
|
<div id="TitleArea" class="PopupTitle PopupTitleBorder">
|
2007-12-17 18:58:19 +01:00
|
|
|
<script type="text/javascript">
|
2008-10-08 12:16:30 +02:00
|
|
|
// <![CDATA[
|
2008-04-15 14:15:22 +02:00
|
|
|
document.write( Args().Title ) ;
|
2008-10-08 12:16:30 +02:00
|
|
|
// ]]>
|
2007-12-17 18:58:19 +01:00
|
|
|
</script>
|
2008-04-15 14:15:22 +02:00
|
|
|
<div id="closeButton" onclick="Cancel();"></div>
|
|
|
|
</div>
|
|
|
|
<div id="TabsRow" class="PopupTabArea" style="display: none">
|
2007-12-17 18:58:19 +01:00
|
|
|
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
2008-04-15 14:15:22 +02:00
|
|
|
<tr id="Tabs">
|
2007-12-17 18:58:19 +01:00
|
|
|
<td class="PopupTabEmptyArea"> </td>
|
|
|
|
<td class="PopupTabEmptyArea" width="100%"> </td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
2008-04-15 14:15:22 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="innerContents"></div>
|
|
|
|
<div id="PopupButtons" class="PopupButtons">
|
|
|
|
<table border="0" cellpadding="0" cellspacing="0">
|
|
|
|
<tr>
|
|
|
|
<td width="100%"> </td>
|
|
|
|
<td nowrap="nowrap">
|
|
|
|
<input id="btnOk" style="visibility: hidden;" type="button" value="Ok" class="Button" onclick="Ok();" fckLang="DlgBtnOK" />
|
|
|
|
|
|
|
|
<input id="btnCancel" type="button" value="Cancel" class="Button" onclick="Cancel();" fckLang="DlgBtnCancel" />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="tl"></div>
|
|
|
|
<div class="tc"></div>
|
|
|
|
<div class="tr"></div>
|
|
|
|
<div class="ml"></div>
|
|
|
|
<div class="mr"></div>
|
|
|
|
<div class="bl"></div>
|
|
|
|
<div class="bc"></div>
|
|
|
|
<div class="br"></div>
|
|
|
|
<div class="cover" id="cover" style="display:none"></div>
|
|
|
|
<div id="throbberBlock" style="position: absolute; visibility: hidden"></div>
|
|
|
|
<script type="text/javascript">
|
2008-10-08 12:16:30 +02:00
|
|
|
// <![CDATA[
|
2008-04-15 14:15:22 +02:00
|
|
|
// Set the class name for language direction.
|
|
|
|
document.body.className += ' ' + langDir ;
|
|
|
|
|
|
|
|
var cover = $( 'cover' ) ;
|
|
|
|
cover.style.backgroundColor = FCKConfig.BackgroundBlockerColor ;
|
|
|
|
FCKDomTools.SetOpacity( cover, FCKConfig.BackgroundBlockerOpacity ) ;
|
2008-10-08 12:16:30 +02:00
|
|
|
// ]]>
|
2008-04-15 14:15:22 +02:00
|
|
|
</script>
|
2007-12-17 18:58:19 +01:00
|
|
|
</body>
|
|
|
|
</html>
|