Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
431 ddelon 1
/*
2
 * FCKeditor - The text editor for internet
3
 * Copyright (C) 2003-2005 Frederico Caldeira Knabben
4
 *
5
 * Licensed under the terms of the GNU Lesser General Public License:
6
 * 		http://www.opensource.org/licenses/lgpl-license.php
7
 *
8
 * For further information visit:
9
 * 		http://www.fckeditor.net/
10
 *
11
 * File Name: fckdialog_gecko.js
12
 * 	Dialog windows operations. (Gecko specific implementations)
13
 *
14
 * File Authors:
15
 * 		Frederico Caldeira Knabben (fredck@fckeditor.net)
16
 */
17
 
18
FCKDialog.Show = function( dialogInfo, dialogName, pageUrl, dialogWidth, dialogHeight, parentWindow, resizable )
19
{
20
	var iTop  = (screen.height - dialogHeight) / 2 ;
21
	var iLeft = (screen.width  - dialogWidth)  / 2 ;
22
 
23
	var sOption  = "location=no,menubar=no,toolbar=no,dependent=yes,dialog=yes,minimizable=no,modal=yes,alwaysRaised=yes" +
24
		",resizable="  + ( resizable ? 'yes' : 'no' ) +
25
		",width="  + dialogWidth +
26
		",height=" + dialogHeight +
27
		",top="  + iTop +
28
		",left=" + iLeft ;
29
 
30
	if ( !parentWindow )
31
		parentWindow = window ;
32
 
33
	var oWindow = parentWindow.open( '', 'FCKeditorDialog_' + dialogName, sOption, true ) ;
34
	oWindow.moveTo( iLeft, iTop ) ;
35
	oWindow.resizeTo( dialogWidth, dialogHeight ) ;
36
	oWindow.focus() ;
37
	oWindow.location.href = pageUrl ;
38
 
39
	oWindow.dialogArguments = dialogInfo ;
40
 
41
	// On some Gecko browsers (probably over slow connections) the
42
	// "dialogArguments" are not set to the target window so we must
43
	// put it in the opener window so it can be used by the target one.
44
	parentWindow.FCKLastDialogInfo = dialogInfo ;
45
 
46
	this.Window = oWindow ;
47
 
48
	// Try/Catch must be used to avoit an error when using a frameset
49
	// on a different domain:
50
	// "Permission denied to get property Window.releaseEvents".
51
	try
52
	{
53
		window.top.captureEvents( Event.CLICK | Event.MOUSEDOWN | Event.MOUSEUP | Event.FOCUS ) ;
54
		window.top.parent.addEventListener( 'mousedown', this.CheckFocus, true ) ;
55
		window.top.parent.addEventListener( 'mouseup', this.CheckFocus, true ) ;
56
		window.top.parent.addEventListener( 'click', this.CheckFocus, true ) ;
57
		window.top.parent.addEventListener( 'focus', this.CheckFocus, true ) ;
58
	}
59
	catch (e)
60
	{}
61
}
62
 
63
FCKDialog.CheckFocus = function()
64
{
65
	// It is strange, but we have to check the FCKDialog existence to avoid a
66
	// random error: "FCKDialog is not defined".
67
	if ( typeof( FCKDialog ) != "object" )
68
		return ;
69
 
70
	if ( FCKDialog.Window && !FCKDialog.Window.closed )
71
	{
72
		FCKDialog.Window.focus() ;
73
		return false ;
74
	}
75
	else
76
	{
77
		// Try/Catch must be used to avoit an error when using a frameset
78
		// on a different domain:
79
		// "Permission denied to get property Window.releaseEvents".
80
		try
81
		{
82
			window.top.releaseEvents(Event.CLICK | Event.MOUSEDOWN | Event.MOUSEUP | Event.FOCUS) ;
83
			window.top.parent.removeEventListener( 'onmousedown', FCKDialog.CheckFocus, true ) ;
84
			window.top.parent.removeEventListener( 'mouseup', FCKDialog.CheckFocus, true ) ;
85
			window.top.parent.removeEventListener( 'click', FCKDialog.CheckFocus, true ) ;
86
			window.top.parent.removeEventListener( 'onfocus', FCKDialog.CheckFocus, true ) ;
87
		}
88
		catch (e)
89
		{}
90
	}
91
}