~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to wiki/htdocs/applets/FCKeditor/editor/_source/internals/fckdialog_gecko.js

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20080622211713-inlv5k4eifxckelr
Import upstream version 1.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 * "Support Open Source software. What about a donation today?"
 
12
 * 
 
13
 * File Name: fckdialog_gecko.js
 
14
 *      Dialog windows operations. (Gecko specific implementations)
 
15
 * 
 
16
 * File Authors:
 
17
 *              Frederico Caldeira Knabben (fredck@fckeditor.net)
 
18
 */
 
19
 
 
20
FCKDialog.Show = function( dialogInfo, dialogName, pageUrl, dialogWidth, dialogHeight, parentWindow, resizable )
 
21
{
 
22
        var iTop  = (FCKConfig.ScreenHeight - dialogHeight) / 2 ;
 
23
        var iLeft = (FCKConfig.ScreenWidth  - dialogWidth)  / 2 ;
 
24
 
 
25
        var sOption  = "location=no,menubar=no,toolbar=no,dependent=yes,dialog=yes,minimizable=no,modal=yes,alwaysRaised=yes" +
 
26
                ",resizable="  + ( resizable ? 'yes' : 'no' ) +
 
27
                ",width="  + dialogWidth +
 
28
                ",height=" + dialogHeight +
 
29
                ",top="  + iTop +
 
30
                ",left=" + iLeft ;
 
31
 
 
32
        if ( !parentWindow )
 
33
                parentWindow = window ;
 
34
        
 
35
        var oWindow = parentWindow.open( '', 'FCKeditorDialog_' + dialogName, sOption, true ) ;
 
36
        
 
37
        if ( !oWindow )
 
38
        {
 
39
                alert( FCKLang.DialogBlocked ) ;
 
40
                return ;
 
41
        }
 
42
                
 
43
        oWindow.moveTo( iLeft, iTop ) ;
 
44
        oWindow.resizeTo( dialogWidth, dialogHeight ) ;
 
45
        oWindow.focus() ;
 
46
        oWindow.location.href = pageUrl ;
 
47
        
 
48
        oWindow.dialogArguments = dialogInfo ;
 
49
        
 
50
        // On some Gecko browsers (probably over slow connections) the 
 
51
        // "dialogArguments" are not set to the target window so we must
 
52
        // put it in the opener window so it can be used by the target one.
 
53
        parentWindow.FCKLastDialogInfo = dialogInfo ;
 
54
        
 
55
        this.Window = oWindow ;
 
56
        
 
57
        // Try/Catch must be used to avoit an error when using a frameset 
 
58
        // on a different domain: 
 
59
        // "Permission denied to get property Window.releaseEvents".
 
60
        try
 
61
        {
 
62
                window.top.captureEvents( Event.CLICK | Event.MOUSEDOWN | Event.MOUSEUP | Event.FOCUS ) ;
 
63
                window.top.parent.addEventListener( 'mousedown', this.CheckFocus, true ) ;
 
64
                window.top.parent.addEventListener( 'mouseup', this.CheckFocus, true ) ;
 
65
                window.top.parent.addEventListener( 'click', this.CheckFocus, true ) ;
 
66
                window.top.parent.addEventListener( 'focus', this.CheckFocus, true ) ;
 
67
        }
 
68
        catch (e)
 
69
        {}
 
70
}
 
71
 
 
72
FCKDialog.CheckFocus = function()
 
73
{
 
74
        // It is strange, but we have to check the FCKDialog existence to avoid a 
 
75
        // random error: "FCKDialog is not defined".
 
76
        if ( typeof( FCKDialog ) != "object" )
 
77
                return false ;
 
78
        
 
79
        if ( FCKDialog.Window && !FCKDialog.Window.closed )
 
80
                FCKDialog.Window.focus() ;
 
81
        else
 
82
        {
 
83
                // Try/Catch must be used to avoit an error when using a frameset 
 
84
                // on a different domain: 
 
85
                // "Permission denied to get property Window.releaseEvents".
 
86
                try
 
87
                {
 
88
                        window.top.releaseEvents(Event.CLICK | Event.MOUSEDOWN | Event.MOUSEUP | Event.FOCUS) ;
 
89
                        window.top.parent.removeEventListener( 'onmousedown', FCKDialog.CheckFocus, true ) ;
 
90
                        window.top.parent.removeEventListener( 'mouseup', FCKDialog.CheckFocus, true ) ;
 
91
                        window.top.parent.removeEventListener( 'click', FCKDialog.CheckFocus, true ) ;
 
92
                        window.top.parent.removeEventListener( 'onfocus', FCKDialog.CheckFocus, true ) ;
 
93
                }
 
94
                catch (e)
 
95
                {}
 
96
        }
 
97
        return false ;
 
98
}