JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.4.2
[ckeditor.git] / _source / plugins / maximize / plugin.js
index 9f18043..5f2715e 100644 (file)
@@ -10,8 +10,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                if ( !formElement || formElement.type != CKEDITOR.NODE_ELEMENT || formElement.getName() != 'form' )\r
                        return [];\r
 \r
-               var hijackRecord = [];\r
-               var hijackNames = [ 'style', 'className' ];\r
+               var hijackRecord = [],\r
+                       hijackNames = [ 'style', 'className' ];\r
                for ( var i = 0 ; i < hijackNames.length ; i++ )\r
                {\r
                        var name = hijackNames[i];\r
@@ -129,12 +129,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                init : function( editor )\r
                {\r
                        var lang = editor.lang;\r
-                       var mainDocument = CKEDITOR.document;\r
-                       var mainWindow = mainDocument.getWindow();\r
+                       var mainDocument = CKEDITOR.document,\r
+                               mainWindow = mainDocument.getWindow();\r
 \r
                        // Saved selection and scroll position for the editing area.\r
-                       var savedSelection;\r
-                       var savedScroll;\r
+                       var savedSelection,\r
+                               savedScroll;\r
 \r
                        // Saved scroll position for the outer window.\r
                        var outerScroll;\r
@@ -194,6 +194,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                        container.setCustomData( 'maximize_saved_styles', saveStyles( container, true ) );\r
 \r
                                                        // Hide scroll bars.\r
+                                                       var viewPaneSize = mainWindow.getViewPaneSize();\r
+                                                       var styles =\r
+                                                               {\r
+                                                                       overflow : 'hidden',\r
+                                                                       width : ( CKEDITOR.env.opera ? viewPaneSize.width : 0 ) + 'px',\r
+                                                                       height : ( CKEDITOR.env.opera ? viewPaneSize.height - 16 : 0 ) + 'px'\r
+                                                               };\r
+\r
                                                        if ( CKEDITOR.env.ie )\r
                                                        {\r
                                                                mainDocument.$.documentElement.style.overflow =\r
@@ -201,21 +209,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                        }\r
                                                        else\r
                                                        {\r
-                                                               mainDocument.getBody().setStyles(\r
-                                                                       {\r
-                                                                               overflow : 'hidden',\r
-                                                                               width : '0px',\r
-                                                                               height : '0px'\r
-                                                                       } );\r
+                                                               mainDocument.getBody().setStyles( styles );\r
                                                        }\r
 \r
+                                                       // #4023: [Opera] Maximize plugin\r
+                                                       if ( CKEDITOR.env.opera )\r
+                                                               mainDocument.getBody().getParent().setStyles( styles );\r
+\r
                                                        // Scroll to the top left (IE needs some time for it - #4923).\r
                                                        CKEDITOR.env.ie ?\r
                                                                setTimeout( function() { mainWindow.$.scrollTo( 0, 0 ); }, 0 ) :\r
                                                                mainWindow.$.scrollTo( 0, 0 );\r
 \r
                                                        // Resize and move to top left.\r
-                                                       var viewPaneSize = mainWindow.getViewPaneSize();\r
                                                        container.setStyle( 'position', 'absolute' );\r
                                                        container.$.offsetLeft;                 // SAFARI BUG: See #2066.\r
                                                        container.setStyles(\r
@@ -333,10 +339,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        command : 'maximize'\r
                                } );\r
 \r
-                       // Restore the command state after mode change.\r
+                       // Restore the command state after mode change, unless it has been changed to disabled (#6467)\r
                        editor.on( 'mode', function()\r
                                {\r
-                                       editor.getCommand( 'maximize' ).setState( savedState );\r
+                                       var command = editor.getCommand( 'maximize' );\r
+                                       command.setState( command.state == CKEDITOR.TRISTATE_DISABLED ? CKEDITOR.TRISTATE_DISABLED : savedState );\r
                                }, null, null, 100 );\r
                }\r
        } );\r