1 | /* |
---|
2 | * FCKeditor - The text editor for Internet - http://www.fckeditor.net |
---|
3 | * Copyright (C) 2003-2007 Frederico Caldeira Knabben |
---|
4 | * |
---|
5 | * == BEGIN LICENSE == |
---|
6 | * |
---|
7 | * Licensed under the terms of any of the following licenses at your |
---|
8 | * choice: |
---|
9 | * |
---|
10 | * - GNU General Public License Version 2 or later (the "GPL") |
---|
11 | * http://www.gnu.org/licenses/gpl.html |
---|
12 | * |
---|
13 | * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") |
---|
14 | * http://www.gnu.org/licenses/lgpl.html |
---|
15 | * |
---|
16 | * - Mozilla Public License Version 1.1 or later (the "MPL") |
---|
17 | * http://www.mozilla.org/MPL/MPL-1.1.html |
---|
18 | * |
---|
19 | * == END LICENSE == |
---|
20 | * |
---|
21 | * Dialog windows operations. (Gecko specific implementations) |
---|
22 | */ |
---|
23 | |
---|
24 | FCKDialog.Show = function( dialogInfo, dialogName, pageUrl, dialogWidth, dialogHeight, parentWindow, resizable ) |
---|
25 | { |
---|
26 | var iTop = (FCKConfig.ScreenHeight - dialogHeight) / 2 ; |
---|
27 | var iLeft = (FCKConfig.ScreenWidth - dialogWidth) / 2 ; |
---|
28 | |
---|
29 | var sOption = "location=no,menubar=no,toolbar=no,dependent=yes,dialog=yes,minimizable=no,modal=yes,alwaysRaised=yes" + |
---|
30 | ",resizable=" + ( resizable ? 'yes' : 'no' ) + |
---|
31 | ",width=" + dialogWidth + |
---|
32 | ",height=" + dialogHeight + |
---|
33 | ",top=" + iTop + |
---|
34 | ",left=" + iLeft ; |
---|
35 | |
---|
36 | if ( !parentWindow ) |
---|
37 | parentWindow = window ; |
---|
38 | |
---|
39 | FCKFocusManager.Lock() ; |
---|
40 | |
---|
41 | var oWindow = parentWindow.open( '', 'FCKeditorDialog_' + dialogName, sOption, true ) ; |
---|
42 | |
---|
43 | if ( !oWindow ) |
---|
44 | { |
---|
45 | alert( FCKLang.DialogBlocked ) ; |
---|
46 | FCKFocusManager.Unlock() ; |
---|
47 | return ; |
---|
48 | } |
---|
49 | |
---|
50 | oWindow.moveTo( iLeft, iTop ) ; |
---|
51 | oWindow.resizeTo( dialogWidth, dialogHeight ) ; |
---|
52 | oWindow.focus() ; |
---|
53 | oWindow.location.href = pageUrl ; |
---|
54 | |
---|
55 | oWindow.dialogArguments = dialogInfo ; |
---|
56 | |
---|
57 | // On some Gecko browsers (probably over slow connections) the |
---|
58 | // "dialogArguments" are not set to the target window so we must |
---|
59 | // put it in the opener window so it can be used by the target one. |
---|
60 | parentWindow.FCKLastDialogInfo = dialogInfo ; |
---|
61 | |
---|
62 | this.Window = oWindow ; |
---|
63 | |
---|
64 | // Try/Catch must be used to avoit an error when using a frameset |
---|
65 | // on a different domain: |
---|
66 | // "Permission denied to get property Window.releaseEvents". |
---|
67 | try |
---|
68 | { |
---|
69 | window.top.parent.addEventListener( 'mousedown', this.CheckFocus, true ) ; |
---|
70 | window.top.parent.addEventListener( 'mouseup', this.CheckFocus, true ) ; |
---|
71 | window.top.parent.addEventListener( 'click', this.CheckFocus, true ) ; |
---|
72 | window.top.parent.addEventListener( 'focus', this.CheckFocus, true ) ; |
---|
73 | } |
---|
74 | catch (e) |
---|
75 | {} |
---|
76 | } |
---|
77 | |
---|
78 | FCKDialog.CheckFocus = function() |
---|
79 | { |
---|
80 | // It is strange, but we have to check the FCKDialog existence to avoid a |
---|
81 | // random error: "FCKDialog is not defined". |
---|
82 | if ( typeof( FCKDialog ) != "object" ) |
---|
83 | return false ; |
---|
84 | |
---|
85 | if ( FCKDialog.Window && !FCKDialog.Window.closed ) |
---|
86 | FCKDialog.Window.focus() ; |
---|
87 | else |
---|
88 | { |
---|
89 | // Try/Catch must be used to avoit an error when using a frameset |
---|
90 | // on a different domain: |
---|
91 | // "Permission denied to get property Window.releaseEvents". |
---|
92 | try |
---|
93 | { |
---|
94 | window.top.parent.removeEventListener( 'onmousedown', FCKDialog.CheckFocus, true ) ; |
---|
95 | window.top.parent.removeEventListener( 'mouseup', FCKDialog.CheckFocus, true ) ; |
---|
96 | window.top.parent.removeEventListener( 'click', FCKDialog.CheckFocus, true ) ; |
---|
97 | window.top.parent.removeEventListener( 'onfocus', FCKDialog.CheckFocus, true ) ; |
---|
98 | } |
---|
99 | catch (e) |
---|
100 | {} |
---|
101 | } |
---|
102 | return false ; |
---|
103 | } |
---|