fckdialog.html 22 KB

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