[ Index ] |
|
Code source de FCKeditor 2.4 |
1 /* 2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net 3 * Copyright (C) 2003-2007 Frederico Caldeira Knabben 4 * 5 * == BEGIN LICENSE == 6 * 7 * Licensed under the terms of any of the following licenses at your 8 * choice: 9 * 10 * - GNU General Public License Version 2 or later (the "GPL") 11 * http://www.gnu.org/licenses/gpl.html 12 * 13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") 14 * http://www.gnu.org/licenses/lgpl.html 15 * 16 * - Mozilla Public License Version 1.1 or later (the "MPL") 17 * http://www.mozilla.org/MPL/MPL-1.1.html 18 * 19 * == END LICENSE == 20 * 21 * File Name: fckfitwindow.js 22 * Stretch the editor to full window size and back. 23 * 24 * File Authors: 25 * Paul Moers (mail@saulmade.nl) 26 * Thanks to Christian Fecteau (webmaster@christianfecteau.com) 27 * Frederico Caldeira Knabben (www.fckeditor.net) 28 */ 29 30 var FCKFitWindow = function() 31 { 32 this.Name = 'FitWindow' ; 33 } 34 35 FCKFitWindow.prototype.Execute = function() 36 { 37 var eEditorFrame = window.frameElement ; 38 var eEditorFrameStyle = eEditorFrame.style ; 39 40 var eMainWindow = parent ; 41 var eDocEl = eMainWindow.document.documentElement ; 42 var eBody = eMainWindow.document.body ; 43 var eBodyStyle = eBody.style ; 44 var eParent ; 45 46 // No original style properties known? Go fullscreen. 47 if ( !this.IsMaximized ) 48 { 49 // Registering an event handler when the window gets resized. 50 if( FCKBrowserInfo.IsIE ) 51 eMainWindow.attachEvent( 'onresize', FCKFitWindow_Resize ) ; 52 else 53 eMainWindow.addEventListener( 'resize', FCKFitWindow_Resize, true ) ; 54 55 // Save the scrollbars position. 56 this._ScrollPos = FCKTools.GetScrollPosition( eMainWindow ) ; 57 58 // Save and reset the styles for the entire node tree. They could interfere in the result. 59 eParent = eEditorFrame ; 60 // The extra () is to avoid a warning with strict error checking. This is ok. 61 while( (eParent = eParent.parentNode) ) 62 { 63 if ( eParent.nodeType == 1 ) 64 eParent._fckSavedStyles = FCKTools.SaveStyles( eParent ) ; 65 } 66 67 // Hide IE scrollbars (in strict mode). 68 if ( FCKBrowserInfo.IsIE ) 69 { 70 this.documentElementOverflow = eDocEl.style.overflow ; 71 eDocEl.style.overflow = 'hidden' ; 72 eBodyStyle.overflow = 'hidden' ; 73 } 74 else 75 { 76 // Hide the scroolbars in Firefox. 77 eBodyStyle.overflow = 'hidden' ; 78 eBodyStyle.width = '0px' ; 79 eBodyStyle.height = '0px' ; 80 } 81 82 // Save the IFRAME styles. 83 this._EditorFrameStyles = FCKTools.SaveStyles( eEditorFrame ) ; 84 85 // Resize. 86 var oViewPaneSize = FCKTools.GetViewPaneSize( eMainWindow ) ; 87 88 eEditorFrameStyle.position = "absolute"; 89 eEditorFrameStyle.zIndex = FCKConfig.FloatingPanelsZIndex - 1; 90 eEditorFrameStyle.left = "0px"; 91 eEditorFrameStyle.top = "0px"; 92 eEditorFrameStyle.width = oViewPaneSize.Width + "px"; 93 eEditorFrameStyle.height = oViewPaneSize.Height + "px"; 94 95 // Giving the frame some (huge) borders on his right and bottom 96 // side to hide the background that would otherwise show when the 97 // editor is in fullsize mode and the window is increased in size 98 // not for IE, because IE immediately adapts the editor on resize, 99 // without showing any of the background oddly in firefox, the 100 // editor seems not to fill the whole frame, so just setting the 101 // background of it to white to cover the page laying behind it anyway. 102 if ( !FCKBrowserInfo.IsIE ) 103 { 104 eEditorFrameStyle.borderRight = eEditorFrameStyle.borderBottom = "9999px solid white" ; 105 eEditorFrameStyle.backgroundColor = "white"; 106 } 107 108 // Scroll to top left. 109 eMainWindow.scrollTo(0, 0); 110 111 this.IsMaximized = true ; 112 } 113 else // Resize to original size. 114 { 115 // Remove the event handler of window resizing. 116 if( FCKBrowserInfo.IsIE ) 117 eMainWindow.detachEvent( "onresize", FCKFitWindow_Resize ) ; 118 else 119 eMainWindow.removeEventListener( "resize", FCKFitWindow_Resize, true ) ; 120 121 // Restore the CSS position for the entire node tree. 122 eParent = eEditorFrame ; 123 // The extra () is to avoid a warning with strict error checking. This is ok. 124 while( (eParent = eParent.parentNode) ) 125 { 126 if ( eParent._fckSavedStyles ) 127 { 128 FCKTools.RestoreStyles( eParent, eParent._fckSavedStyles ) ; 129 eParent._fckSavedStyles = null ; 130 } 131 } 132 133 // Restore IE scrollbars 134 if ( FCKBrowserInfo.IsIE ) 135 eDocEl.style.overflow = this.documentElementOverflow ; 136 137 // Restore original size 138 FCKTools.RestoreStyles( eEditorFrame, this._EditorFrameStyles ) ; 139 140 // Restore the window scroll position. 141 eMainWindow.scrollTo( this._ScrollPos.X, this._ScrollPos.Y ) ; 142 143 this.IsMaximized = false ; 144 } 145 146 FCKToolbarItems.GetItem('FitWindow').RefreshState() ; 147 148 // It seams that Firefox restarts the editing area when making this changes. 149 // On FF 1.0.x, the area is not anymore editable. On FF 1.5+, the special 150 //configuration, like DisableFFTableHandles and DisableObjectResizing get 151 //lost, so we must reset it. Also, the cursor position and selection are 152 //also lost, even if you comment the following line (MakeEditable). 153 // if ( FCKBrowserInfo.IsGecko10 ) // Initially I thought it was a FF 1.0 only problem. 154 FCK.EditingArea.MakeEditable() ; 155 156 FCK.Focus() ; 157 } 158 159 FCKFitWindow.prototype.GetState = function() 160 { 161 if ( FCKConfig.ToolbarLocation != 'In' ) 162 return FCK_TRISTATE_DISABLED ; 163 else 164 return ( this.IsMaximized ? FCK_TRISTATE_ON : FCK_TRISTATE_OFF ); 165 } 166 167 function FCKFitWindow_Resize() 168 { 169 var oViewPaneSize = FCKTools.GetViewPaneSize( parent ) ; 170 171 var eEditorFrameStyle = window.frameElement.style ; 172 173 eEditorFrameStyle.width = oViewPaneSize.Width + 'px' ; 174 eEditorFrameStyle.height = oViewPaneSize.Height + 'px' ; 175 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 15:28:05 2007 | par Balluche grâce à PHPXref 0.7 |