2
* FCKeditor - The text editor for internet
3
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
5
* Licensed under the terms of the GNU Lesser General Public License:
6
* http://www.opensource.org/licenses/lgpl-license.php
8
* For further information visit:
9
* http://www.fckeditor.net/
11
* "Support Open Source software. What about a donation today?"
13
* File Name: fckpanel_gecko.js
14
* FCKPanel Class: Creates and manages floating panels in Gecko Browsers.
17
* Frederico Caldeira Knabben (fredck@fckeditor.net)
20
var FCKPanel = function( parentWindow )
23
this.IsContextMenu = false ;
24
this._IsOpened = false ;
27
this._Window = parentWindow ;
30
this._Window = window ;
32
while ( this._Window != window.top )
34
// Try/Catch must be used to avoit an error when using a frameset
35
// on a different domain:
36
// "Permission denied to get property HTMLDocument.Body".
39
if ( this._Window.parent.document.body.tagName == 'FRAMESET' )
41
} catch (e) { break ; }
43
this._Window = this._Window.parent ;
47
var oIFrame = this._IFrame = this._Window.document.createElement('iframe') ;
48
oIFrame.frameBorder = '0';
49
oIFrame.scrolling = 'no' ;
50
oIFrame.style.position = 'absolute';
51
oIFrame.width = oIFrame.height = 0 ;
52
oIFrame.style.zIndex = FCKConfig.FloatingPanelsZIndex ;
54
this._Window.document.body.appendChild( oIFrame ) ;
56
this.Document = oIFrame.contentWindow.document ;
58
// Initialize the IFRAME document body.
59
this.Document.open() ;
60
this.Document.write( '<html><head></head><body><\/body><\/html>' ) ;
61
this.Document.close() ;
63
// Remove the default margins.
64
this.Document.body.style.margin = this.Document.body.style.padding = '0px' ;
66
this._IFrame.contentWindow.onblur = this.Hide ;
68
oIFrame.contentWindow.Panel = this ;
71
// Create the main DIV that is used as the panel base.
72
this.PanelDiv = this.Document.body.appendChild( this.Document.createElement('DIV') ) ;
73
this.PanelDiv.className = 'FCK_Panel' ;
75
this.EnableContextMenu( false ) ;
76
this.SetDirection( FCKLang.Dir ) ;
79
FCKPanel.prototype.EnableContextMenu = function( enabled )
81
this.Document.oncontextmenu = enabled ? null : FCKTools.CancelEvent ;
84
FCKPanel.prototype.AppendStyleSheet = function( styleSheet )
86
FCKTools.AppendStyleSheet( this.Document, styleSheet ) ;
89
FCKPanel.prototype.SetDirection = function( dir )
91
this.IsRTL = ( dir == 'rtl' ) ;
92
this.Document.dir = dir ;
94
// The "float" property must be set so Firefox calculates the size correcly.
95
this.PanelDiv.style.cssFloat = ( dir == 'rtl' ? 'right' : 'left' ) ;
98
FCKPanel.prototype.Load = function()
100
// This is a IE only need.
103
FCKPanel.prototype.Show = function( x, y, relElement, width, height )
105
this.PanelDiv.style.width = width ? width + 'px' : '' ;
106
this.PanelDiv.style.height = height ? height + 'px' : '' ;
108
if ( !width ) this._IFrame.width = 1 ;
109
if ( !height ) this._IFrame.height = 1 ;
111
var oPos = FCKTools.GetElementPosition( relElement, this._Window ) ;
118
if ( this.IsContextMenu )
119
x = x - this.PanelDiv.offsetWidth + 1 ;
120
else if ( relElement )
121
x = x + ( relElement.offsetWidth - this.PanelDiv.offsetWidth ) ;
125
if ( ( x + this.PanelDiv.offsetWidth ) > this._Window.document.body.clientWidth )
126
x -= x + this.PanelDiv.offsetWidth - this._Window.document.body.clientWidth ;
132
// Set the context menu DIV in the specified location.
133
this._IFrame.style.left = x + 'px' ;
134
this._IFrame.style.top = y + 'px' ;
136
var iWidth = this.PanelDiv.offsetWidth ;
137
var iHeight = this.PanelDiv.offsetHeight ;
139
this._IFrame.width = iWidth ;
140
this._IFrame.height = iHeight ;
142
// Move the focus to the IFRAME so we catch the "onblur".
143
this._IFrame.contentWindow.focus() ;
145
this._IsOpened = true ;
148
FCKPanel.prototype.Hide = function()
150
var oPanel = this.Panel ? this.Panel : this ;
152
if ( !oPanel._IsOpened )
155
// It is better to set the sizes to 0, otherwise Firefox would have
156
// rendering problems.
157
oPanel._IFrame.width = oPanel._IFrame.height = 0 ;
159
if ( oPanel._OnHide )
160
oPanel._OnHide( oPanel ) ;
162
oPanel._IsOpened = false ;
165
FCKPanel.prototype.CheckIsOpened = function()
167
return this._IsOpened ;
170
FCKPanel.prototype.AttachToOnHideEvent = function( targetFunction )
172
this._OnHide = targetFunction ;
b'\\ No newline at end of file'