X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fmaximize%2Fplugin.js;h=9f1804371ec95c4d93e3aa6e53c48aeac6f0352f;hb=055b6b0792ce7dc53d47af606b367c04b927c2ab;hp=2b7ffe3cf152f9bc7281032bce80907233afdc22;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/_source/plugins/maximize/plugin.js b/_source/plugins/maximize/plugin.js index 2b7ffe3..9f18043 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,50 @@ For licensing, see LICENSE.html or http://ckeditor.com/license restoreFormStyles( data ); } - function getResizeHandler( mainWindow, editor ) + function refreshCursor( editor ) { - return function() + // Refresh all editor instances on the page (#5724). + var all = CKEDITOR.instances; + for ( var i in all ) { - var viewPaneSize = mainWindow.getViewPaneSize(); - editor.resize( viewPaneSize.width, viewPaneSize.height, null, true ); - }; + var one = all[ i ]; + if ( one.mode == 'wysiwyg' ) + { + var body = one.document.getBody(); + // Refresh 'contentEditable' otherwise + // DOM lifting breaks design mode. (#5560) + body.setAttribute( 'contentEditable', false ); + body.setAttribute( 'contentEditable', true ); + } + } + + if ( editor.focusManager.hasFocus ) + { + 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 +139,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; @@ -111,16 +155,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license editor.addCommand( 'maximize', { modes : { wysiwyg : 1, source : 1 }, - + 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. if ( editor.mode == 'wysiwyg' ) { - savedSelection = editor.getSelection().getRanges(); + var selection = editor.getSelection(); + savedSelection = selection && selection.getRanges(); savedScroll = mainWindow.getScrollPosition(); } else @@ -164,8 +209,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(); @@ -177,7 +224,13 @@ 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) + + // Add cke_maximized class before resize handle since that will change things sizes (#5580) + container.addClass( 'cke_maximized' ); + + resizeHandler(); // Still not top left? Fix it. (Bug #174) var offset = container.getDocumentPosition(); @@ -187,8 +240,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license top : ( -1 * offset.y ) + 'px' } ); - // Add cke_maximized class. - container.addClass( 'cke_maximized' ); + // Fixing positioning editor chrome in Firefox break design mode. (#5149) + CKEDITOR.env.gecko && refreshCursor( editor ); + } else if ( this.state == CKEDITOR.TRISTATE_ON ) // Restore from fullscreen if the state is on. { @@ -211,11 +265,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' ); @@ -223,14 +285,28 @@ For licensing, see LICENSE.html or http://ckeditor.com/license this.toggleState(); + // Toggle button label. + var button = this.uiItems[ 0 ]; + var label = ( this.state == CKEDITOR.TRISTATE_OFF ) + ? lang.maximize : lang.minimize; + var buttonNode = editor.element.getDocument().getById( button._.id ); + buttonNode.getChild( 1 ).setHtml( label ); + buttonNode.setAttribute( 'title', label ); + buttonNode.setAttribute( 'href', 'javascript:void("' + label + '");' ); + // Restore selection and scroll position in editing area. if ( editor.mode == 'wysiwyg' ) { - editor.getSelection().selectRanges( savedSelection ); + 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 ); + } - var element = editor.getSelection().getStartElement(); - if ( element ) - element.scrollIntoView( true ); else mainWindow.$.scrollTo( savedScroll.x, savedScroll.y ); }