fckdialog.html 23 KB

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