--- /dev/null
+/*\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+For licensing, see LICENSE.html or http://ckeditor.com/license\r
+*/\r
+\r
+/**\r
+ * @file AutoGrow plugin\r
+ */\r
+(function(){\r
+ var resizeEditor = function( editor )\r
+ {\r
+ if ( !editor.window )\r
+ return;\r
+ var doc = editor.document,\r
+ currentHeight = editor.window.getViewPaneSize().height,\r
+ newHeight;\r
+\r
+ // We can not use documentElement to calculate the height for IE (#6061).\r
+ // It is not good for IE Quirks, yet using offsetHeight would also not work as expected (#6408).\r
+ // We do the same for FF because of the html height workaround (#6341).\r
+ if ( CKEDITOR.env.ie || CKEDITOR.env.gecko )\r
+ newHeight = doc.getBody().$.scrollHeight + ( CKEDITOR.env.ie && CKEDITOR.env.quirks ? 0 : 24 );\r
+ else\r
+ newHeight = doc.getDocumentElement().$.offsetHeight;\r
+\r
+ var min = editor.config.autoGrow_minHeight,\r
+ max = editor.config.autoGrow_maxHeight;\r
+ ( min == undefined ) && ( editor.config.autoGrow_minHeight = min = 200 );\r
+ if ( min )\r
+ newHeight = Math.max( newHeight, min );\r
+ if ( max )\r
+ newHeight = Math.min( newHeight, max );\r
+\r
+ if ( newHeight != currentHeight )\r
+ {\r
+ newHeight = editor.fire( 'autoGrow', { currentHeight : currentHeight, newHeight : newHeight } ).newHeight;\r
+ editor.resize( editor.container.getStyle( 'width' ), newHeight, true );\r
+ }\r
+ };\r
+ CKEDITOR.plugins.add( 'autogrow',\r
+ {\r
+ init : function( editor )\r
+ {\r
+ for ( var eventName in { contentDom:1, key:1, selectionChange:1, insertElement:1 } )\r
+ {\r
+ editor.on( eventName, function( evt )\r
+ {\r
+ var maximize = editor.getCommand( 'maximize' );\r
+ // Some time is required for insertHtml, and it gives other events better performance as well.\r
+ if ( evt.editor.mode == 'wysiwyg' &&\r
+ // Disable autogrow when the editor is maximized .(#6339)\r
+ ( !maximize || maximize.state != CKEDITOR.TRISTATE_ON ) )\r
+ {\r
+ setTimeout( function(){ resizeEditor( evt.editor ); }, 100 );\r
+ }\r
+ });\r
+ }\r
+ }\r
+ });\r
+})();\r
+/**\r
+ * The minimum height to which the editor can reach using AutoGrow.\r
+ * @name CKEDITOR.config.autoGrow_minHeight\r
+ * @type Number\r
+ * @default 200\r
+ * @since 3.4\r
+ * @example\r
+ * config.autoGrow_minHeight = 300;\r
+ */\r
+\r
+/**\r
+ * The maximum height to which the editor can reach using AutoGrow. Zero means unlimited.\r
+ * @name CKEDITOR.config.autoGrow_maxHeight\r
+ * @type Number\r
+ * @default 0\r
+ * @since 3.4\r
+ * @example\r
+ * config.autoGrow_maxHeight = 400;\r
+ */\r
+\r
+/**\r
+ * Fired when the AutoGrow plugin is about to change the size of the editor.\r
+ * @name CKEDITOR.editor#autogrow\r
+ * @event\r
+ * @param {Number} data.currentHeight The current height of the editor (before the resizing).\r
+ * @param {Number} data.newHeight The new height of the editor (after the resizing). It can be changed\r
+ * to determine another height to be used instead.\r
+ */\r