fckfitwindow.js
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:5k
源码类别:

OA系统

开发平台:

C#

  1. /*
  2.  * FCKeditor - The text editor for internet
  3.  * Copyright (C) 2003-2006 Frederico Caldeira Knabben
  4.  * 
  5.  * Licensed under the terms of the GNU Lesser General Public License:
  6.  *  http://www.opensource.org/licenses/lgpl-license.php
  7.  * 
  8.  * For further information visit:
  9.  *  http://www.fckeditor.net/
  10.  * 
  11.  * "Support Open Source software. What about a donation today?"
  12.  * 
  13.  * File Name: fckfitwindow.js
  14.  *  Stretch the editor to full window size and back.
  15.  * 
  16.  * File Authors:
  17.  *  Paul Moers (mail@saulmade.nl)
  18.  *  Thanks to Christian Fecteau (webmaster@christianfecteau.com)
  19.  *  Frederico Caldeira Knabben (fredck@fckeditor.net)
  20.  */
  21. var FCKFitWindow = function()
  22. {
  23. this.Name = 'FitWindow' ;
  24. }
  25. FCKFitWindow.prototype.Execute = function()
  26. {
  27. var eEditorFrame = window.frameElement ;
  28. var eEditorFrameStyle = eEditorFrame.style ;
  29. var eMainWindow = parent ;
  30. var eDocEl = eMainWindow.document.documentElement ;
  31. var eBody = eMainWindow.document.body ;
  32. var eBodyStyle = eBody.style ;
  33. // No original style properties known? Go fullscreen.
  34. if ( !this.IsMaximized )
  35. {
  36. // Registering an event handler when the window gets resized.
  37. if( FCKBrowserInfo.IsIE )
  38. eMainWindow.attachEvent( 'onresize', FCKFitWindow_Resize ) ;
  39. else
  40. eMainWindow.addEventListener( 'resize', FCKFitWindow_Resize, true ) ;
  41. // Save the scrollbars position.
  42. this._ScrollPos = FCKTools.GetScrollPosition( eMainWindow ) ;
  43. // Save and reset the styles for the entire node tree. They could interfere in the result.
  44. var eParent = eEditorFrame ;
  45. while( eParent = eParent.parentNode )
  46. {
  47. if ( eParent.nodeType == 1 )
  48. eParent._fckSavedStyles = FCKTools.SaveStyles( eParent ) ;
  49. }
  50. // Hide IE scrollbars (in strict mode).
  51. if ( FCKBrowserInfo.IsIE )
  52. {
  53. this.documentElementOverflow = eDocEl.style.overflow ;
  54. eDocEl.style.overflow = 'hidden' ;
  55. eBodyStyle.overflow = 'hidden' ;
  56. }
  57. else
  58. {
  59. // Hide the scroolbars in Firefox.
  60. eBodyStyle.overflow = 'hidden' ;
  61. eBodyStyle.width = '0px' ;
  62. eBodyStyle.height = '0px' ;
  63. }
  64. // Save the IFRAME styles.
  65. this._EditorFrameStyles = FCKTools.SaveStyles( eEditorFrame ) ;
  66. // Resize.
  67. var oViewPaneSize = FCKTools.GetViewPaneSize( eMainWindow ) ;
  68. eEditorFrameStyle.position = "absolute";
  69. eEditorFrameStyle.zIndex = FCKConfig.FloatingPanelsZIndex - 1;
  70. eEditorFrameStyle.left = "0px";
  71. eEditorFrameStyle.top = "0px";
  72. eEditorFrameStyle.width = oViewPaneSize.Width + "px";
  73. eEditorFrameStyle.height = oViewPaneSize.Height + "px";
  74. // Giving the frame some (huge) borders on his right and bottom
  75. // side to hide the background that would otherwise show when the
  76. // editor is in fullsize mode and the window is increased in size
  77. // not for IE, because IE immediately adapts the editor on resize, 
  78. // without showing any of the background oddly in firefox, the
  79. // editor seems not to fill the whole frame, so just setting the
  80. // background of it to white to cover the page laying behind it anyway.
  81. if ( !FCKBrowserInfo.IsIE )
  82. {
  83. eEditorFrameStyle.borderRight = eEditorFrameStyle.borderBottom = "9999px solid white" ;
  84. eEditorFrameStyle.backgroundColor = "white";
  85. }
  86. // Scroll to top left.
  87. eMainWindow.scrollTo(0, 0);
  88. this.IsMaximized = true ;
  89. }
  90. else // Resize to original size.
  91. {
  92. // Remove the event handler of window resizing.
  93. if( FCKBrowserInfo.IsIE )
  94. eMainWindow.detachEvent( "onresize", FCKFitWindow_Resize ) ;
  95. else
  96. eMainWindow.removeEventListener( "resize", FCKFitWindow_Resize, true ) ;
  97. // Restore the CSS position for the entire node tree.
  98. var eParent = eEditorFrame ;
  99. while( eParent = eParent.parentNode )
  100. {
  101. if ( eParent._fckSavedStyles )
  102. {
  103. FCKTools.RestoreStyles( eParent, eParent._fckSavedStyles ) ;
  104. eParent._fckSavedStyles = null ;
  105. }
  106. }
  107. // Restore IE scrollbars
  108. if ( FCKBrowserInfo.IsIE )
  109. eDocEl.style.overflow = this.documentElementOverflow ;
  110. // Restore original size
  111. FCKTools.RestoreStyles( eEditorFrame, this._EditorFrameStyles ) ;
  112. // Restore the window scroll position.
  113. eMainWindow.scrollTo( this._ScrollPos.X, this._ScrollPos.Y ) ;
  114. this.IsMaximized = false ;
  115. }
  116. FCKToolbarItems.GetItem('FitWindow').RefreshState() ;
  117. // It seams that Firefox restarts the editing area when making this changes.
  118. // On FF 1.0.x, the area is not anymore editable. On FF 1.5+, the special 
  119. //configuration, like DisableFFTableHandles and DisableObjectResizing get 
  120. //lost, so we must reset it. Also, the cursor position and selection are 
  121. //also lost, even if you comment the following line (MakeEditable).
  122. // if ( FCKBrowserInfo.IsGecko10 ) // Initially I thought it was a FF 1.0 only problem.
  123. FCK.EditingArea.MakeEditable() ;
  124. FCK.Focus() ;
  125. }
  126. FCKFitWindow.prototype.GetState = function()
  127. {
  128. if ( FCKConfig.ToolbarLocation != 'In' )
  129. return FCK_TRISTATE_DISABLED ;
  130. else
  131. return ( this.IsMaximized ? FCK_TRISTATE_ON : FCK_TRISTATE_OFF );
  132. }
  133. function FCKFitWindow_Resize()
  134. {
  135. var oViewPaneSize = FCKTools.GetViewPaneSize( parent ) ;
  136. var eEditorFrameStyle = window.frameElement.style ;
  137. eEditorFrameStyle.width = oViewPaneSize.Width + 'px' ;
  138. eEditorFrameStyle.height = oViewPaneSize.Height + 'px' ;
  139. }