X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fmaximize%2Fplugin.js;h=a5a06fc1989f4b374e7904744036262758b7c429;hb=8665a7c6c60586526e32e8941fe2896739b6ebfb;hp=4c4054471b7b54452d3bbc6edad2b6f00e886036;hpb=8761695d9b70afe75905deaac88f78c1f8aeb32d;p=ckeditor.git diff --git a/_source/plugins/maximize/plugin.js b/_source/plugins/maximize/plugin.js index 4c40544..a5a06fc 100644 --- a/_source/plugins/maximize/plugin.js +++ b/_source/plugins/maximize/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -78,13 +78,35 @@ For licensing, see LICENSE.html or http://ckeditor.com/license restoreFormStyles( data ); } - function getResizeHandler( mainWindow, editor ) + function refreshCursor( editor ) { - return function() + if ( editor.focusManager.hasFocus ) { - var viewPaneSize = mainWindow.getViewPaneSize(); - editor.resize( viewPaneSize.width, viewPaneSize.height, null, true ); - }; + editor.toolbox.focus(); + editor.focus(); + } + } + + /** + * Adding an iframe shim to this element, OR removing the existing one if already applied. + * Note: This will only affect IE version below 7. + */ + function createIframeShim( element ) + { + if ( !CKEDITOR.env.ie || CKEDITOR.env.version > 6 ) + return null; + + var shim = CKEDITOR.dom.element.createFromHtml( '' ); + return element.append( shim, true ); } CKEDITOR.plugins.add( 'maximize', @@ -102,8 +124,15 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Saved scroll position for the outer window. var outerScroll; + var shim; + // Saved resize handler function. - var resizeHandler = getResizeHandler( mainWindow, editor ); + function resizeHandler() + { + var viewPaneSize = mainWindow.getViewPaneSize(); + shim && shim.setStyles( { width : viewPaneSize.width + 'px', height : viewPaneSize.height + 'px' } ); + editor.resize( viewPaneSize.width, viewPaneSize.height, null, true ); + } // Retain state after mode switches. var savedState = CKEDITOR.TRISTATE_OFF; @@ -114,7 +143,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license editorFocus : false, exec : function() { - var container = editor.container.getChild( [ 0, 0 ] ); + var container = editor.container.getChild( 1 ); var contents = editor.getThemeSpace( 'contents' ); // Save current selection and scroll position in editing area. @@ -165,8 +194,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } ); } - // Scroll to the top left. - mainWindow.$.scrollTo( 0, 0 ); + // Scroll to the top left (IE needs some time for it - #4923). + CKEDITOR.env.ie ? + setTimeout( function() { mainWindow.$.scrollTo( 0, 0 ); }, 0 ) : + mainWindow.$.scrollTo( 0, 0 ); // Resize and move to top left. var viewPaneSize = mainWindow.getViewPaneSize(); @@ -178,7 +209,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license left : '0px', top : '0px' } ); - editor.resize( viewPaneSize.width, viewPaneSize.height, null, true ); + + shim = createIframeShim( container ); // IE6 select element penetration when maximized. (#4459) + resizeHandler(); // Still not top left? Fix it. (Bug #174) var offset = container.getDocumentPosition(); @@ -188,6 +221,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license top : ( -1 * offset.y ) + 'px' } ); + // Fixing positioning editor chrome in Firefox break design mode. (#5149) + CKEDITOR.env.gecko && refreshCursor( editor ); + // Add cke_maximized class. container.addClass( 'cke_maximized' ); } @@ -212,11 +248,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } // Restore the window scroll position. - mainWindow.$.scrollTo( outerScroll.x, outerScroll.y ); + CKEDITOR.env.ie ? + setTimeout( function() { mainWindow.$.scrollTo( outerScroll.x, outerScroll.y ); }, 0 ) : + mainWindow.$.scrollTo( outerScroll.x, outerScroll.y ); // Remove cke_maximized class. container.removeClass( 'cke_maximized' ); + if ( shim ) + { + shim.remove(); + shim = null; + } + // Emit a resize event, because this time the size is modified in // restoreStyles. editor.fire( 'resize' ); @@ -238,6 +282,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { if ( savedSelection ) { + // Fixing positioning editor chrome in Firefox break design mode. (#5149) + CKEDITOR.env.gecko && refreshCursor( editor ); + editor.getSelection().selectRanges(savedSelection); var element = editor.getSelection().getStartElement(); element && element.scrollIntoView( true );