event refactor, landing on HEAD!
[freeside.git] / httemplate / elements / fckeditor / editor / fckdialog.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\r
2 <!--\r
3  * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
4  * Copyright (C) 2003-2007 Frederico Caldeira Knabben\r
5  *\r
6  * == BEGIN LICENSE ==\r
7  *\r
8  * Licensed under the terms of any of the following licenses at your\r
9  * choice:\r
10  *\r
11  *  - GNU General Public License Version 2 or later (the "GPL")\r
12  *    http://www.gnu.org/licenses/gpl.html\r
13  *\r
14  *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
15  *    http://www.gnu.org/licenses/lgpl.html\r
16  *\r
17  *  - Mozilla Public License Version 1.1 or later (the "MPL")\r
18  *    http://www.mozilla.org/MPL/MPL-1.1.html\r
19  *\r
20  * == END LICENSE ==\r
21  *\r
22  * This page is used by all dialog box as the container.\r
23 -->\r
24 <html xmlns="http://www.w3.org/1999/xhtml">\r
25         <head>\r
26                 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\r
27                 <meta name="robots" content="noindex, nofollow" />\r
28                 <script type="text/javascript">\r
29 \r
30 // On some Gecko browsers (probably over slow connections) the\r
31 // "dialogArguments" are not set so we must get it from the opener window.\r
32 if ( !window.dialogArguments )\r
33         window.dialogArguments = window.opener.FCKLastDialogInfo ;\r
34 \r
35 // Sets the Skin CSS\r
36 document.write( '<link href="' + window.dialogArguments.Editor.FCKConfig.SkinPath + 'fck_dialog.css" type="text/css" rel="stylesheet">' ) ;\r
37 \r
38 // Sets the language direction.\r
39 window.document.dir = window.dialogArguments.Editor.FCKLang.Dir ;\r
40 \r
41 var sTitle = window.dialogArguments.Title ;\r
42 document.write( '<title>' + sTitle + '<\/title>' ) ;\r
43 \r
44 function LoadInnerDialog()\r
45 {\r
46         if ( window.onresize )\r
47                 window.onresize() ;\r
48 \r
49         // First of all, translate the dialog box contents.\r
50         window.dialogArguments.Editor.FCKLanguageManager.TranslatePage( document ) ;\r
51 \r
52         window.frames["frmMain"].document.location.href = window.dialogArguments.Page ;\r
53 }\r
54 \r
55 function InnerDialogLoaded()\r
56 {\r
57         var oInnerDoc = document.getElementById('frmMain').contentWindow.document ;\r
58 \r
59         // Set the language direction.\r
60         oInnerDoc.dir = window.dialogArguments.Editor.FCKLang.Dir ;\r
61 \r
62         // Sets the Skin CSS.\r
63         oInnerDoc.write( '<link href="' + window.dialogArguments.Editor.FCKConfig.SkinPath + 'fck_dialog.css" type="text/css" rel="stylesheet">' ) ;\r
64 \r
65         SetOnKeyDown( oInnerDoc ) ;\r
66         DisableContextMenu( oInnerDoc ) ;\r
67 \r
68         return window.dialogArguments.Editor ;\r
69 }\r
70 \r
71 function SetOkButton( showIt )\r
72 {\r
73         document.getElementById('btnOk').style.visibility = ( showIt ? '' : 'hidden' ) ;\r
74 }\r
75 \r
76 var bAutoSize = false ;\r
77 \r
78 function SetAutoSize( autoSize )\r
79 {\r
80         bAutoSize = autoSize ;\r
81         RefreshSize() ;\r
82 }\r
83 \r
84 function RefreshSize()\r
85 {\r
86         if ( bAutoSize )\r
87         {\r
88                 var oInnerDoc = document.getElementById('frmMain').contentWindow.document ;\r
89 \r
90                 var iFrameHeight ;\r
91                 if ( document.all )\r
92                         iFrameHeight = oInnerDoc.body.offsetHeight ;\r
93                 else\r
94                         iFrameHeight = document.getElementById('frmMain').contentWindow.innerHeight ;\r
95 \r
96                 var iInnerHeight = oInnerDoc.body.scrollHeight ;\r
97 \r
98                 var iDiff = iInnerHeight - iFrameHeight ;\r
99 \r
100                 if ( iDiff > 0 )\r
101                 {\r
102                         if ( document.all )\r
103                                 window.dialogHeight = ( parseInt( window.dialogHeight, 10 ) + iDiff ) + 'px' ;\r
104                         else\r
105                                 window.resizeBy( 0, iDiff ) ;\r
106                 }\r
107         }\r
108 }\r
109 \r
110 function Ok()\r
111 {\r
112         if ( window.frames["frmMain"].Ok && window.frames["frmMain"].Ok() )\r
113                 Cancel() ;\r
114 }\r
115 \r
116 function Cancel( dontFireChange )\r
117 {\r
118         if ( !dontFireChange )\r
119         {\r
120                 // All dialog windows, by default, will fire the "OnSelectionChange"\r
121                 // event, no matter the Ok or Cancel button has been pressed.\r
122                 window.dialogArguments.Editor.FCK.Events.FireEvent( 'OnSelectionChange' ) ;\r
123         }\r
124         window.close() ;\r
125 }\r
126 \r
127 // Object that holds all available tabs.\r
128 var oTabs = new Object() ;\r
129 \r
130 function TabDiv_OnClick()\r
131 {\r
132         SetSelectedTab( this.TabCode ) ;\r
133 }\r
134 \r
135 function AddTab( tabCode, tabText, startHidden )\r
136 {\r
137         if ( typeof( oTabs[ tabCode ] ) != 'undefined' )\r
138                 return ;\r
139 \r
140         var eTabsRow = document.getElementById( 'Tabs' ) ;\r
141 \r
142         var oCell = eTabsRow.insertCell(  eTabsRow.cells.length - 1 ) ;\r
143         oCell.noWrap = true ;\r
144 \r
145         var oDiv = document.createElement( 'DIV' ) ;\r
146         oDiv.className = 'PopupTab' ;\r
147         oDiv.innerHTML = tabText ;\r
148         oDiv.TabCode = tabCode ;\r
149         oDiv.onclick = TabDiv_OnClick ;\r
150 \r
151         if ( startHidden )\r
152                 oDiv.style.display = 'none' ;\r
153 \r
154         eTabsRow = document.getElementById( 'TabsRow' ) ;\r
155 \r
156         oCell.appendChild( oDiv ) ;\r
157 \r
158         if ( eTabsRow.style.display == 'none' )\r
159         {\r
160                 var eTitleArea = document.getElementById( 'TitleArea' ) ;\r
161                 eTitleArea.className = 'PopupTitle' ;\r
162 \r
163                 oDiv.className = 'PopupTabSelected' ;\r
164                 eTabsRow.style.display = '' ;\r
165 \r
166                 if ( ! window.dialogArguments.Editor.FCKBrowserInfo.IsIE )\r
167                         window.onresize() ;\r
168         }\r
169 \r
170         oTabs[ tabCode ] = oDiv ;\r
171 }\r
172 \r
173 function SetSelectedTab( tabCode )\r
174 {\r
175         for ( var sCode in oTabs )\r
176         {\r
177                 if ( sCode == tabCode )\r
178                         oTabs[sCode].className = 'PopupTabSelected' ;\r
179                 else\r
180                         oTabs[sCode].className = 'PopupTab' ;\r
181         }\r
182 \r
183         if ( typeof( window.frames["frmMain"].OnDialogTabChange ) == 'function' )\r
184                 window.frames["frmMain"].OnDialogTabChange( tabCode ) ;\r
185 }\r
186 \r
187 function SetTabVisibility( tabCode, isVisible )\r
188 {\r
189         var oTab = oTabs[ tabCode ] ;\r
190         oTab.style.display = isVisible ? '' : 'none' ;\r
191 \r
192         if ( ! isVisible && oTab.className == 'PopupTabSelected' )\r
193         {\r
194                 for ( var sCode in oTabs )\r
195                 {\r
196                         if ( oTabs[sCode].style.display != 'none' )\r
197                         {\r
198                                 SetSelectedTab( sCode ) ;\r
199                                 break ;\r
200                         }\r
201                 }\r
202         }\r
203 }\r
204 \r
205 function SetOnKeyDown( targetDocument )\r
206 {\r
207         targetDocument.onkeydown = function ( e )\r
208         {\r
209                 e = e || event || this.parentWindow.event ;\r
210                 switch ( e.keyCode )\r
211                 {\r
212                         case 13 :               // ENTER\r
213                                 var oTarget = e.srcElement || e.target ;\r
214                                 if ( oTarget.tagName == 'TEXTAREA' )\r
215                                         return true ;\r
216                                 Ok() ;\r
217                                 return false ;\r
218                         case 27 :               // ESC\r
219                                 Cancel() ;\r
220                                 return false ;\r
221                                 break ;\r
222                 }\r
223                 return true ;\r
224         }\r
225 }\r
226 SetOnKeyDown( document ) ;\r
227 \r
228 function DisableContextMenu( targetDocument )\r
229 {\r
230         if ( window.dialogArguments.Editor.FCKBrowserInfo.IsIE ) return ;\r
231 \r
232         // Disable Right-Click\r
233         var oOnContextMenu = function( e )\r
234         {\r
235                 var sTagName = e.target.tagName ;\r
236                 if ( ! ( ( sTagName == "INPUT" && e.target.type == "text" ) || sTagName == "TEXTAREA" ) )\r
237                         e.preventDefault() ;\r
238         }\r
239         targetDocument.addEventListener( 'contextmenu', oOnContextMenu, true ) ;\r
240 }\r
241 DisableContextMenu( document ) ;\r
242 \r
243 if ( ! window.dialogArguments.Editor.FCKBrowserInfo.IsIE )\r
244 {\r
245         window.onresize = function()\r
246         {\r
247                 var oFrame = document.getElementById("frmMain") ;\r
248 \r
249                 if ( ! oFrame )\r
250                 return ;\r
251 \r
252                 oFrame.height = 0 ;\r
253 \r
254                 var oCell = document.getElementById("FrameCell") ;\r
255                 var iHeight = oCell.offsetHeight ;\r
256 \r
257                 oFrame.height = iHeight - 2 ;\r
258         }\r
259 }\r
260 \r
261 if ( window.dialogArguments.Editor.FCKBrowserInfo.IsIE )\r
262 {\r
263         function Window_OnBeforeUnload()\r
264         {\r
265                 for ( var t in oTabs )\r
266                         oTabs[t] = null ;\r
267 \r
268                 window.dialogArguments.Editor = null ;\r
269         }\r
270         window.attachEvent( "onbeforeunload", Window_OnBeforeUnload ) ;\r
271 }\r
272 \r
273 function Window_OnClose()\r
274 {\r
275         window.dialogArguments.Editor.FCKFocusManager.Unlock() ;\r
276 }\r
277 \r
278 if ( window.addEventListener )\r
279         window.addEventListener( 'unload', Window_OnClose, false ) ;\r
280 \r
281                 </script>\r
282         </head>\r
283         <body onload="LoadInnerDialog();" class="PopupBody">\r
284                 <table height="100%" cellspacing="0" cellpadding="0" width="100%" border="0">\r
285                         <tr>\r
286                                 <td id="TitleArea" class="PopupTitle PopupTitleBorder">\r
287                                         <script type="text/javascript">\r
288 document.write( sTitle ) ;\r
289                                         </script>\r
290                                 </td>\r
291                         </tr>\r
292                         <tr id="TabsRow" style="DISPLAY: none">\r
293                                 <td class="PopupTabArea">\r
294                                         <table border="0" cellpadding="0" cellspacing="0" width="100%">\r
295                                                 <tr id="Tabs" onselectstart="return false;">\r
296                                                         <td class="PopupTabEmptyArea">&nbsp;</td>\r
297                                                         <td class="PopupTabEmptyArea" width="100%">&nbsp;</td>\r
298                                                 </tr>\r
299                                         </table>\r
300                                 </td>\r
301                         </tr>\r
302                         <tr>\r
303                                 <td id="FrameCell" height="100%" valign="top">\r
304                                         <iframe id="frmMain" src="javascript:void(0)" name="frmMain" frameborder="0" height="100%" width="100%" scrolling="auto">\r
305                                         </iframe>\r
306                                 </td>\r
307                         </tr>\r
308                         <tr>\r
309                                 <td class="PopupButtons">\r
310                                         <table border="0" cellpadding="0" cellspacing="0">\r
311                                                 <tr>\r
312                                                         <td width="100%">&nbsp;</td>\r
313                                                         <td nowrap="nowrap">\r
314                                                                 <input id="btnOk" style="VISIBILITY: hidden;" type="button" value="Ok" class="Button" onclick="Ok();" fckLang="DlgBtnOK" />\r
315                                                                 &nbsp; \r
316                                                                 <input id="btnCancel" type="button" value="Cancel" class="Button" onclick="Cancel();" fckLang="DlgBtnCancel" />\r
317                                                         </td>\r
318                                                 </tr>\r
319                                         </table>\r
320                                 </td>\r
321                         </tr>\r
322                 </table>\r
323         </body>\r
324 </html>