FCKeditor 2.6.6
[freeside.git] / httemplate / elements / fckeditor / editor / fckdialog.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
2 <!--\r
3  * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
4  * Copyright (C) 2003-2010 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                 <title></title>\r
27                 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\r
28                 <meta name="robots" content="noindex, nofollow" />\r
29                 <script type="text/javascript">\r
30 // <![CDATA[\r
31 \r
32 // Domain relaxation logic.\r
33 (function()\r
34 {\r
35         var d = document.domain ;\r
36 \r
37         while ( true )\r
38         {\r
39                 // Test if we can access a parent property.\r
40                 try\r
41                 {\r
42                         var parentDomain = ( Args().TopWindow || E ).document.domain ;\r
43 \r
44                         if ( document.domain != parentDomain )\r
45                                 document.domain = parentDomain ;\r
46 \r
47                         break ;\r
48                 }\r
49                 catch( e ) {}\r
50 \r
51                 // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...\r
52                 d = d.replace( /.*?(?:\.|$)/, '' ) ;\r
53 \r
54                 if ( d.length == 0 )\r
55                         break ;         // It was not able to detect the domain.\r
56 \r
57                 document.domain = d ;\r
58         }\r
59 })() ;\r
60 \r
61 var E = frameElement._DialogArguments.Editor ;\r
62 \r
63 // It seems referencing to frameElement._DialogArguments directly would lead to memory leaks in IE.\r
64 // So let's use functions to access its members instead.\r
65 function Args()\r
66 {\r
67         return frameElement._DialogArguments ;\r
68 }\r
69 \r
70 function ParentDialog( dialog )\r
71 {\r
72         return dialog ? dialog._ParentDialog : frameElement._ParentDialog ;\r
73 }\r
74 \r
75 var FCK                         = E.FCK ;\r
76 var FCKTools            = E.FCKTools ;\r
77 var FCKDomTools         = E.FCKDomTools ;\r
78 var FCKDialog           = E.FCKDialog ;\r
79 var FCKBrowserInfo      = E.FCKBrowserInfo ;\r
80 var FCKConfig           = E.FCKConfig ;\r
81 \r
82 // Steal the focus so that the caret would no longer stay in the editor iframe.\r
83 window.focus() ;\r
84 \r
85 // Sets the Skin CSS\r
86 document.write( FCKTools.GetStyleHtml( FCKConfig.SkinDialogCSS ) ) ;\r
87 \r
88 // Sets the language direction.\r
89 var langDir = E.FCKLang.Dir ;\r
90 \r
91 // For IE6-, the fck_dialog_ie6.js is loaded, used to fix limitations in the browser.\r
92 if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )\r
93         document.write( '<' + 'script type="text/javascript" src="' + FCKConfig.SkinPath + 'fck_dialog_ie6.js"><' + '\/script>' ) ;\r
94 \r
95 FCKTools.RegisterDollarFunction( window ) ;\r
96 \r
97 // Resize related functions.\r
98 var Sizer = function()\r
99 {\r
100         var bAutoSize = false ;\r
101 \r
102         var retval = {\r
103                 // Sets whether the dialog should auto-resize according to its content's height.\r
104                 SetAutoSize : function( autoSize )\r
105                 {\r
106                         bAutoSize = autoSize ;\r
107                         this.RefreshSize() ;\r
108                 },\r
109 \r
110                 // Fit the dialog container's layout to the inner iframe's external size.\r
111                 RefreshContainerSize : function()\r
112                 {\r
113                         var frmMain = $( 'frmMain' ) ;\r
114 \r
115                         if ( frmMain )\r
116                         {\r
117                                 // Get the container size.\r
118                                 var height = $( 'contents' ).offsetHeight ;\r
119 \r
120                                 // Subtract the size of other elements.\r
121                                 height -= $( 'TitleArea' ).offsetHeight ;\r
122                                 height -= $( 'TabsRow' ).offsetHeight ;\r
123                                 height -= $( 'PopupButtons' ).offsetHeight ;\r
124 \r
125                                 frmMain.style.height = Math.max( height, 0 ) + 'px' ;\r
126                         }\r
127                 },\r
128 \r
129                 // Resize and re-layout the dialog.\r
130                 // Triggers the onresize event for the layout logic.\r
131                 ResizeDialog : function( width, height )\r
132                 {\r
133                         FCKDomTools.SetElementStyles( window.frameElement,\r
134                                         {\r
135                                                 'width' : width + 'px',\r
136                                                 'height' : height + 'px'\r
137                                         } ) ;\r
138 \r
139                         // If the skin have defined a function for resize fixes, call it now.\r
140                         if ( typeof window.DoResizeFixes == 'function' )\r
141                                 window.DoResizeFixes() ;\r
142                 },\r
143 \r
144                 // if bAutoSize is true, automatically fit the dialog size and layout to\r
145                 // accomodate the inner iframe's internal height.\r
146                 // if bAutoSize is false, then only the layout logic for the dialog decorations\r
147                 // is run to accomodate the inner iframe's external height.\r
148                 RefreshSize : function()\r
149                 {\r
150                         if ( bAutoSize )\r
151                         {\r
152                                 var frmMain             = $( 'frmMain' ) ;\r
153                                 var innerDoc    = frmMain.contentWindow.document ;\r
154                                 var isStrict    = FCKTools.IsStrictMode( innerDoc ) ;\r
155 \r
156                                 // Get the size of the frame contents.\r
157                                 var innerWidth  = isStrict ? innerDoc.documentElement.scrollWidth : innerDoc.body.scrollWidth ;\r
158                                 var innerHeight = isStrict ? innerDoc.documentElement.scrollHeight : innerDoc.body.scrollHeight ;\r
159 \r
160                                 // Get the current frame size.\r
161                                 var frameSize = FCKTools.GetViewPaneSize( frmMain.contentWindow ) ;\r
162 \r
163                                 var deltaWidth  = innerWidth - frameSize.Width ;\r
164                                 var deltaHeight = innerHeight - frameSize.Height ;\r
165 \r
166                                 // If the contents fits the current size.\r
167                                 if ( deltaWidth <= 0 && deltaHeight <= 0 )\r
168                                         return ;\r
169 \r
170                                 var dialogWidth         = frameElement.offsetWidth + Math.max( deltaWidth, 0 ) ;\r
171                                 var dialogHeight        = frameElement.offsetHeight + Math.max( deltaHeight, 0 ) ;\r
172 \r
173                                 this.ResizeDialog( dialogWidth, dialogHeight ) ;\r
174                         }\r
175                         this.RefreshContainerSize() ;\r
176                 }\r
177         }\r
178 \r
179         /**\r
180          * Safari seems to have a bug with the time when RefreshSize() is executed - it\r
181          * thinks frmMain's innerHeight is 0 if we query the value too soon after the\r
182          * page is loaded in some circumstances. (#1316)\r
183          * TODO : Maybe this is not needed anymore after #35.\r
184          */\r
185         if ( FCKBrowserInfo.IsSafari )\r
186         {\r
187                 var originalRefreshSize = retval.RefreshSize ;\r
188 \r
189                 retval.RefreshSize = function()\r
190                 {\r
191                         FCKTools.SetTimeout( originalRefreshSize, 1, retval ) ;\r
192                 }\r
193         }\r
194 \r
195         /**\r
196          * IE6 has a similar bug where it sometimes thinks $('contents') has an\r
197          * offsetHeight of 0 (#2114).\r
198          */\r
199         if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )\r
200         {\r
201                 var originalRefreshContainerSize = retval.RefreshContainerSize ;\r
202                 retval.RefreshContainerSize = function()\r
203                 {\r
204                         FCKTools.SetTimeout( originalRefreshContainerSize, 1, retval ) ;\r
205                 }\r
206         }\r
207 \r
208         window.onresize = function()\r
209         {\r
210                 retval.RefreshContainerSize() ;\r
211         }\r
212 \r
213         window.SetAutoSize = FCKTools.Bind( retval, retval.SetAutoSize ) ;\r
214 \r
215         return retval ;\r
216 }() ;\r
217 \r
218 // Manages the throbber image that appears if the inner part of dialog is taking too long to load.\r
219 var Throbber = function()\r
220 {\r
221         var timer ;\r
222 \r
223         var updateThrobber = function()\r
224         {\r
225                 var throbberParent = $( 'throbberBlock' ) ;\r
226                 var throbberBlocks = throbberParent.childNodes ;\r
227                 var lastClass = throbberParent.lastChild.className ;\r
228 \r
229                 // From the last to the second one, copy the class from the previous one.\r
230                 for ( var i = throbberBlocks.length - 1 ; i > 0 ; i-- )\r
231                         throbberBlocks[i].className = throbberBlocks[i-1].className ;\r
232 \r
233                 // For the first one, copy the last class (rotation).\r
234                 throbberBlocks[0].className = lastClass ;\r
235         }\r
236 \r
237         return {\r
238                 Show : function( waitMilliseconds )\r
239                 {\r
240                         // Auto-setup the Show function to be called again after the\r
241                         // requested amount of time.\r
242                         if ( waitMilliseconds && waitMilliseconds > 0 )\r
243                         {\r
244                                 timer = FCKTools.SetTimeout( this.Show, waitMilliseconds, this, null, window ) ;\r
245                                 return ;\r
246                         }\r
247 \r
248                         var throbberParent = $( 'throbberBlock' ) ;\r
249 \r
250                         if (throbberParent.childNodes.length == 0)\r
251                         {\r
252                                 // Create the throbber blocks.\r
253                                 var classIds = [ 1,2,3,4,5,4,3,2 ] ;\r
254                                 while ( classIds.length > 0 )\r
255                                         throbberParent.appendChild( document.createElement( 'div' ) ).className = ' throbber_' + classIds.shift() ;\r
256                         }\r
257 \r
258                         // Center the throbber.\r
259                         var frm = $( 'contents' ) ;\r
260                         var frmCoords = FCKTools.GetDocumentPosition( window, frm ) ;\r
261                         var x = frmCoords.x + ( frm.offsetWidth - throbberParent.offsetWidth ) / 2 ;\r
262                         var y = frmCoords.y + ( frm.offsetHeight - throbberParent.offsetHeight ) / 2 ;\r
263                         throbberParent.style.left = parseInt( x, 10 ) + 'px' ;\r
264                         throbberParent.style.top = parseInt( y, 10 ) + 'px' ;\r
265 \r
266                         // Show it.\r
267                         throbberParent.style.visibility = ''  ;\r
268 \r
269                         // Hide tabs and buttons:\r
270                         $( 'Tabs' ).style.visibility = 'hidden' ;\r
271                         $( 'PopupButtons' ).style.visibility = 'hidden' ;\r
272 \r
273                         // Setup the animation interval.\r
274                         timer = setInterval( updateThrobber, 100 ) ;\r
275                 },\r
276 \r
277                 Hide : function()\r
278                 {\r
279                         if ( timer )\r
280                         {\r
281                                 clearInterval( timer ) ;\r
282                                 timer = null ;\r
283                         }\r
284 \r
285                         $( 'throbberBlock' ).style.visibility = 'hidden' ;\r
286 \r
287                         // Show tabs and buttons:\r
288                         $( 'Tabs' ).style.visibility = '' ;\r
289                         $( 'PopupButtons' ).style.visibility = '' ;\r
290                 }\r
291         } ;\r
292 }() ;\r
293 \r
294 // Drag and drop handlers.\r
295 var DragAndDrop = function()\r
296 {\r
297         var registeredWindows = [] ;\r
298         var lastCoords ;\r
299         var currentPos ;\r
300 \r
301         var cleanUpHandlers = function()\r
302         {\r
303                 for ( var i = 0 ; i < registeredWindows.length ; i++ )\r
304                 {\r
305                         FCKTools.RemoveEventListener( registeredWindows[i].document, 'mousemove', dragMouseMoveHandler ) ;\r
306                         FCKTools.RemoveEventListener( registeredWindows[i].document, 'mouseup', dragMouseUpHandler ) ;\r
307                 }\r
308         }\r
309 \r
310         var dragMouseMoveHandler = function( evt )\r
311         {\r
312                 if ( !lastCoords )\r
313                         return ;\r
314 \r
315                 if ( !evt )\r
316                         evt = FCKTools.GetElementDocument( this ).parentWindow.event ;\r
317 \r
318                 // Updated the last coordinates.\r
319                 var currentCoords =\r
320                 {\r
321                         x : evt.screenX,\r
322                         y : evt.screenY\r
323                 } ;\r
324 \r
325                 currentPos =\r
326                 {\r
327                         x : currentPos.x + ( currentCoords.x - lastCoords.x ),\r
328                         y : currentPos.y + ( currentCoords.y - lastCoords.y )\r
329                 } ;\r
330 \r
331                 lastCoords = currentCoords ;\r
332 \r
333                 frameElement.style.left = currentPos.x + 'px' ;\r
334                 frameElement.style.top  = currentPos.y + 'px' ;\r
335 \r
336                 if ( evt.preventDefault )\r
337                         evt.preventDefault() ;\r
338                 else\r
339                         evt.returnValue = false ;\r
340         }\r
341 \r
342         var dragMouseUpHandler = function( evt )\r
343         {\r
344                 if ( !lastCoords )\r
345                         return ;\r
346                 if ( !evt )\r
347                         evt = FCKTools.GetElementDocument( this ).parentWindow.event ;\r
348                 cleanUpHandlers() ;\r
349                 lastCoords = null ;\r
350         }\r
351 \r
352         return {\r
353 \r
354                 MouseDownHandler : function( evt )\r
355                 {\r
356                         var view = null ;\r
357                         if ( !evt )\r
358                         {\r
359                                 view = FCKTools.GetElementDocument( this ).parentWindow ;\r
360                                 evt = view.event ;\r
361                         }\r
362                         else\r
363                                 view = evt.view ;\r
364 \r
365                         var target = evt.srcElement || evt.target ;\r
366                         if ( target.id == 'closeButton' || target.className == 'PopupTab' || target.className == 'PopupTabSelected' )\r
367                                 return ;\r
368 \r
369                         lastCoords =\r
370                         {\r
371                                 x : evt.screenX,\r
372                                 y : evt.screenY\r
373                         } ;\r
374 \r
375                         // Save the current IFRAME position.\r
376                         currentPos =\r
377                         {\r
378                                 x : parseInt( FCKDomTools.GetCurrentElementStyle( frameElement, 'left' ), 10 ),\r
379                                 y : parseInt( FCKDomTools.GetCurrentElementStyle( frameElement, 'top' ), 10 )\r
380                         } ;\r
381 \r
382                         for ( var i = 0 ; i < registeredWindows.length ; i++ )\r
383                         {\r
384                                 FCKTools.AddEventListener( registeredWindows[i].document, 'mousemove', dragMouseMoveHandler ) ;\r
385                                 FCKTools.AddEventListener( registeredWindows[i].document, 'mouseup', dragMouseUpHandler ) ;\r
386                         }\r
387 \r
388                         if ( evt.preventDefault )\r
389                                 evt.preventDefault() ;\r
390                         else\r
391                                 evt.returnValue = false ;\r
392                 },\r
393 \r
394                 RegisterHandlers : function( w )\r
395                 {\r
396                         registeredWindows.push( w ) ;\r
397                 }\r
398         }\r
399 }() ;\r
400 \r
401 // Selection related functions.\r
402 //(Became simple shortcuts after the fix for #1990)\r
403 var Selection =\r
404 {\r
405         /**\r
406          * Ensures that the editing area contains an active selection. This is a\r
407          * requirement for IE, as it looses the selection when the focus moves to other\r
408          * frames.\r
409          */\r
410         EnsureSelection : function()\r
411         {\r
412                 // Move the focus to the Cancel button so even if the dialog contains a\r
413                 // contentEditable element the selection is properly restored in the editor #2496\r
414                 window.focus() ;\r
415                 $( 'btnCancel' ).focus() ;\r
416 \r
417                 FCK.Selection.Restore() ;\r
418         },\r
419 \r
420         /**\r
421          * Get the FCKSelection object for the editor instance.\r
422          */\r
423         GetSelection : function()\r
424         {\r
425                 return FCK.Selection ;\r
426         },\r
427 \r
428         /**\r
429          * Get the selected element in the editing area (for object selections).\r
430          */\r
431         GetSelectedElement : function()\r
432         {\r
433                 return FCK.Selection.GetSelectedElement() ;\r
434         }\r
435 }\r
436 \r
437 // Tab related functions.\r
438 var Tabs = function()\r
439 {\r
440         // Only element ids should be stored here instead of element references since setSelectedTab and TabDiv_OnClick\r
441         // would build circular references with the element references inside and cause memory leaks in IE6.\r
442         var oTabs = new Object() ;\r
443 \r
444         var setSelectedTab = function( tabCode )\r
445         {\r
446                 for ( var sCode in oTabs )\r
447                 {\r
448                         if ( sCode == tabCode )\r
449                                 $( oTabs[sCode] ).className = 'PopupTabSelected' ;\r
450                         else\r
451                                 $( oTabs[sCode] ).className = 'PopupTab' ;\r
452                 }\r
453 \r
454                 if ( typeof( window.frames["frmMain"].OnDialogTabChange ) == 'function' )\r
455                         window.frames["frmMain"].OnDialogTabChange( tabCode ) ;\r
456         }\r
457 \r
458         function TabDiv_OnClick()\r
459         {\r
460                 setSelectedTab( this.TabCode ) ;\r
461         }\r
462 \r
463         window.AddTab = function( tabCode, tabText, startHidden )\r
464         {\r
465                 if ( typeof( oTabs[ tabCode ] ) != 'undefined' )\r
466                         return ;\r
467 \r
468                 var eTabsRow = $( 'Tabs' ) ;\r
469 \r
470                 var oCell = eTabsRow.insertCell(  eTabsRow.cells.length - 1 ) ;\r
471                 oCell.noWrap = true ;\r
472 \r
473                 var oDiv = document.createElement( 'DIV' ) ;\r
474                 oDiv.className = 'PopupTab' ;\r
475                 oDiv.innerHTML = tabText ;\r
476                 oDiv.TabCode = tabCode ;\r
477                 oDiv.onclick = TabDiv_OnClick ;\r
478                 oDiv.id = Math.random() ;\r
479 \r
480                 if ( startHidden )\r
481                         oDiv.style.display = 'none' ;\r
482 \r
483                 eTabsRow = $( 'TabsRow' ) ;\r
484 \r
485                 oCell.appendChild( oDiv ) ;\r
486 \r
487                 if ( eTabsRow.style.display == 'none' )\r
488                 {\r
489                         var eTitleArea = $( 'TitleArea' ) ;\r
490                         eTitleArea.className = 'PopupTitle' ;\r
491 \r
492                         oDiv.className = 'PopupTabSelected' ;\r
493                         eTabsRow.style.display = '' ;\r
494 \r
495                         if ( window.onresize )\r
496                                 window.onresize() ;\r
497                 }\r
498 \r
499                 oTabs[ tabCode ] = oDiv.id ;\r
500 \r
501                 FCKTools.DisableSelection( oDiv ) ;\r
502         } ;\r
503 \r
504         window.SetSelectedTab = setSelectedTab ;\r
505 \r
506         window.SetTabVisibility = function( tabCode, isVisible )\r
507         {\r
508                 var oTab = $( oTabs[ tabCode ] ) ;\r
509                 oTab.style.display = isVisible ? '' : 'none' ;\r
510 \r
511                 if ( ! isVisible && oTab.className == 'PopupTabSelected' )\r
512                 {\r
513                         for ( var sCode in oTabs )\r
514                         {\r
515                                 if ( $( oTabs[sCode] ).style.display != 'none' )\r
516                                 {\r
517                                         setSelectedTab( sCode ) ;\r
518                                         break ;\r
519                                 }\r
520                         }\r
521                 }\r
522         } ;\r
523 }() ;\r
524 \r
525 // readystatechange handler for registering drag and drop handlers in cover\r
526 // iframes, defined out here to avoid memory leak.\r
527 // Do NOT put this function as a private function as it will induce memory leak\r
528 // in IE and it's not detectable with Drip or sIEve and undetectable leaks are\r
529 // really nasty (sigh).\r
530 var onReadyRegister = function()\r
531 {\r
532         if ( this.readyState != 'complete' )\r
533                 return ;\r
534         DragAndDrop.RegisterHandlers( this.contentWindow ) ;\r
535 } ;\r
536 \r
537 // The business logic of the dialog, dealing with operational things like\r
538 // dialog open/dialog close/enable/disable/etc.\r
539 (function()\r
540 {\r
541         var setOnKeyDown = function( targetDocument )\r
542         {\r
543                 targetDocument.onkeydown = function ( e )\r
544                 {\r
545                         e = e || event || this.parentWindow.event ;\r
546                         switch ( e.keyCode )\r
547                         {\r
548                                 case 13 :               // ENTER\r
549                                         var oTarget = e.srcElement || e.target ;\r
550                                         if ( oTarget.tagName == 'TEXTAREA' )\r
551                                                 return true ;\r
552                                         Ok() ;\r
553                                         return false ;\r
554 \r
555                                 case 27 :               // ESC\r
556                                         Cancel() ;\r
557                                         return false ;\r
558                         }\r
559                         return true ;\r
560                 }\r
561         } ;\r
562 \r
563         var contextMenuBlocker = function( e )\r
564         {\r
565                 var sTagName = e.target.tagName ;\r
566                 if ( ! ( ( sTagName == "INPUT" && e.target.type == "text" ) || sTagName == "TEXTAREA" ) )\r
567                         e.preventDefault() ;\r
568         } ;\r
569 \r
570         var disableContextMenu = function( targetDocument )\r
571         {\r
572                 if ( FCKBrowserInfo.IsIE )\r
573                         return ;\r
574 \r
575                 targetDocument.addEventListener( 'contextmenu', contextMenuBlocker, true ) ;\r
576         } ;\r
577 \r
578         // Program entry point.\r
579         window.Init = function()\r
580         {\r
581                 $( 'contents' ).dir = langDir;\r
582 \r
583                 // Start the throbber timer.\r
584                 Throbber.Show( 1000 ) ;\r
585 \r
586                 Sizer.RefreshContainerSize() ;\r
587                 LoadInnerDialog() ;\r
588 \r
589                 FCKTools.DisableSelection( document.body ) ;\r
590 \r
591                 // Make the title area draggable.\r
592                 var titleElement = $( 'header' ) ;\r
593                 titleElement.onmousedown = DragAndDrop.MouseDownHandler ;\r
594 \r
595                 // Connect mousemove and mouseup events from dialog frame and outer window to dialog dragging logic.\r
596                 DragAndDrop.RegisterHandlers( window ) ;\r
597                 DragAndDrop.RegisterHandlers( Args().TopWindow ) ;\r
598 \r
599                 // Disable the previous dialog if it exists.\r
600                 if ( ParentDialog() )\r
601                 {\r
602                         ParentDialog().contentWindow.SetEnabled( false ) ;\r
603                         if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )\r
604                         {\r
605                                 var currentParent = ParentDialog() ;\r
606                                 while ( currentParent )\r
607                                 {\r
608                                         var blockerFrame = currentParent.contentWindow.$( 'blocker' ) ;\r
609                                         if ( blockerFrame.readyState == 'complete' )\r
610                                                 DragAndDrop.RegisterHandlers( blockerFrame.contentWindow ) ;\r
611                                         else\r
612                                                 blockerFrame.onreadystatechange = onReadyRegister ;\r
613                                         currentParent = ParentDialog( currentParent ) ;\r
614                                 }\r
615                         }\r
616                         else\r
617                         {\r
618                                 var currentParent = ParentDialog() ;\r
619                                 while ( currentParent )\r
620                                 {\r
621                                         DragAndDrop.RegisterHandlers( currentParent.contentWindow ) ;\r
622                                         currentParent = ParentDialog( currentParent ) ;\r
623                                 }\r
624                         }\r
625                 }\r
626 \r
627                 // If this is the only dialog on screen, enable the background cover.\r
628                 if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )\r
629                 {\r
630                         var blockerFrame = FCKDialog.GetCover().firstChild ;\r
631                         if ( blockerFrame.readyState == 'complete' )\r
632                                 DragAndDrop.RegisterHandlers( blockerFrame.contentWindow ) ;\r
633                         else\r
634                                 blockerFrame.onreadystatechange = onReadyRegister;\r
635                 }\r
636 \r
637                 // Add Enter/Esc hotkeys and disable context menu for the dialog.\r
638                 setOnKeyDown( document ) ;\r
639                 disableContextMenu( document ) ;\r
640         } ;\r
641 \r
642         window.LoadInnerDialog = function()\r
643         {\r
644                 if ( window.onresize )\r
645                         window.onresize() ;\r
646 \r
647                 // First of all, translate the dialog box contents.\r
648                 E.FCKLanguageManager.TranslatePage( document ) ;\r
649 \r
650                 // Create the IFRAME that holds the dialog contents.\r
651                 $( 'innerContents' ).innerHTML = '<iframe id="frmMain" src="' + Args().Page + '" name="frmMain" frameborder="0" width="100%" height="100%" scrolling="auto" style="visibility: hidden;" allowtransparency="true"><\/iframe>' ;\r
652         } ;\r
653 \r
654         window.InnerDialogLoaded = function()\r
655         {\r
656                 // If the dialog has been closed before the iframe is loaded, do nothing.\r
657                 if ( !frameElement.parentNode )\r
658                         return null ;\r
659 \r
660                 Throbber.Hide() ;\r
661 \r
662                 var frmMain = $('frmMain') ;\r
663                 var innerWindow = frmMain.contentWindow ;\r
664                 var innerDoc = innerWindow.document ;\r
665 \r
666                 // Show the loaded iframe.\r
667                 frmMain.style.visibility = '' ;\r
668 \r
669                 // Set the language direction.\r
670                 innerDoc.documentElement.dir = langDir ;\r
671 \r
672                 // Sets the Skin CSS.\r
673                 innerDoc.write( FCKTools.GetStyleHtml( FCKConfig.SkinDialogCSS ) ) ;\r
674 \r
675                 setOnKeyDown( innerDoc ) ;\r
676                 disableContextMenu( innerDoc ) ;\r
677 \r
678                 Sizer.RefreshContainerSize();\r
679 \r
680                 DragAndDrop.RegisterHandlers( innerWindow ) ;\r
681 \r
682                 innerWindow.focus() ;\r
683 \r
684                 return E ;\r
685         } ;\r
686 \r
687         window.SetOkButton = function( showIt )\r
688         {\r
689                 $('btnOk').style.visibility = ( showIt ? '' : 'hidden' ) ;\r
690         } ;\r
691 \r
692         window.Ok = function()\r
693         {\r
694                 Selection.EnsureSelection() ;\r
695 \r
696                 var frmMain = window.frames["frmMain"] ;\r
697 \r
698                 if ( frmMain.Ok && frmMain.Ok() )\r
699                         CloseDialog() ;\r
700                 else\r
701                         frmMain.focus() ;\r
702         } ;\r
703 \r
704         window.Cancel = function( dontFireChange )\r
705         {\r
706                 Selection.EnsureSelection() ;\r
707                 return CloseDialog( dontFireChange ) ;\r
708         } ;\r
709 \r
710         window.CloseDialog = function( dontFireChange )\r
711         {\r
712                 Throbber.Hide() ;\r
713 \r
714                 // Points the src to a non-existent location to avoid loading errors later, in case the dialog\r
715                 // haven't been completed loaded at this point.\r
716                 if ( $( 'frmMain' ) )\r
717                         $( 'frmMain' ).src = FCKTools.GetVoidUrl() ;\r
718 \r
719                 if ( !dontFireChange && !FCK.EditMode )\r
720                 {\r
721                         // All dialog windows, by default, will fire the "OnSelectionChange"\r
722                         // event, no matter the Ok or Cancel button has been pressed.\r
723                         // It seems that OnSelectionChange may enter on a concurrency state\r
724                         // on some situations (#1965), so we should put the event firing in\r
725                         // the execution queue instead of executing it immediately.\r
726                         setTimeout( function()\r
727                                 {\r
728                                         FCK.Events.FireEvent( 'OnSelectionChange' ) ;\r
729                                 }, 0 ) ;\r
730                 }\r
731 \r
732                 FCKDialog.OnDialogClose( window ) ;\r
733         } ;\r
734 \r
735         window.SetEnabled = function( isEnabled )\r
736         {\r
737                 var cover = $( 'cover' ) ;\r
738                 cover.style.display = isEnabled ? 'none' : '' ;\r
739 \r
740                 if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )\r
741                 {\r
742                         if ( !isEnabled )\r
743                         {\r
744                                 // Inser the blocker IFRAME before the cover.\r
745                                 var blocker = document.createElement( 'iframe' ) ;\r
746                                 blocker.src = FCKTools.GetVoidUrl() ;\r
747                                 blocker.hideFocus = true ;\r
748                                 blocker.frameBorder = 0 ;\r
749                                 blocker.id = blocker.className = 'blocker' ;\r
750                                 cover.appendChild( blocker ) ;\r
751                         }\r
752                         else\r
753                         {\r
754                                 var blocker = $( 'blocker' ) ;\r
755                                 if ( blocker && blocker.parentNode )\r
756                                         blocker.parentNode.removeChild( blocker ) ;\r
757                         }\r
758                 }\r
759         } ;\r
760 })() ;\r
761 // ]]>\r
762                 </script>\r
763         </head>\r
764         <body onload="Init();" class="PopupBody">\r
765                 <div class="contents" id="contents">\r
766                         <div id="header">\r
767                                 <div id="TitleArea" class="PopupTitle PopupTitleBorder">\r
768                                         <script type="text/javascript">\r
769 // <![CDATA[\r
770 document.write( Args().Title ) ;\r
771 // ]]>\r
772                                         </script>\r
773                                         <div id="closeButton" onclick="Cancel();"></div>\r
774                                 </div>\r
775                                 <div id="TabsRow" class="PopupTabArea" style="display: none">\r
776                                         <table border="0" cellpadding="0" cellspacing="0" width="100%">\r
777                                                 <tr id="Tabs">\r
778                                                         <td class="PopupTabEmptyArea">&nbsp;</td>\r
779                                                         <td class="PopupTabEmptyArea" width="100%">&nbsp;</td>\r
780                                                 </tr>\r
781                                         </table>\r
782                                 </div>\r
783                         </div>\r
784                         <div id="innerContents"></div>\r
785                         <div id="PopupButtons" class="PopupButtons">\r
786                                 <table border="0" cellpadding="0" cellspacing="0">\r
787                                         <tr>\r
788                                                 <td width="100%">&nbsp;</td>\r
789                                                 <td nowrap="nowrap">\r
790                                                         <input id="btnOk" style="visibility: hidden;" type="button" value="Ok" class="Button" onclick="Ok();" fckLang="DlgBtnOK" />\r
791                                                         &nbsp;\r
792                                                         <input id="btnCancel" type="button" value="Cancel" class="Button" onclick="Cancel();" fckLang="DlgBtnCancel" />\r
793                                                 </td>\r
794                                         </tr>\r
795                                 </table>\r
796                         </div>\r
797                 </div>\r
798                 <div class="tl"></div>\r
799                 <div class="tc"></div>\r
800                 <div class="tr"></div>\r
801                 <div class="ml"></div>\r
802                 <div class="mr"></div>\r
803                 <div class="bl"></div>\r
804                 <div class="bc"></div>\r
805                 <div class="br"></div>\r
806                 <div class="cover" id="cover" style="display:none"></div>\r
807                 <div id="throbberBlock" style="position: absolute; visibility: hidden"></div>\r
808                 <script type="text/javascript">\r
809 // <![CDATA[\r
810                         // Set the class name for language direction.\r
811                         document.body.className += ' ' + langDir ;\r
812 \r
813                         var cover = $( 'cover' ) ;\r
814                         cover.style.backgroundColor = FCKConfig.BackgroundBlockerColor ;\r
815                         FCKDomTools.SetOpacity( cover, FCKConfig.BackgroundBlockerOpacity ) ;\r
816 // ]]>\r
817                 </script>\r
818         </body>\r
819 </html>\r