Ticket #4606: 4606.patch
File 4606.patch, 5.6 KB (added by , 14 years ago) |
---|
-
_samples/autogrow.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <!-- 3 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. 4 For licensing, see LICENSE.html or http://ckeditor.com/license 5 --> 6 <html xmlns="http://www.w3.org/1999/xhtml"> 7 <head> 8 <title>AutoGrow Plugin - CKEditor Sample</title> 9 <meta content="text/html; charset=utf-8" http-equiv="content-type" /> 10 <!-- CKReleaser %REMOVE_LINE% 11 <script type="text/javascript" src="../ckeditor.js"></script> 12 CKReleaser %REMOVE_START% --> 13 <script type="text/javascript" src="../ckeditor_source.js"></script> 14 <!-- CKReleaser %REMOVE_END% --> 15 <script src="sample.js" type="text/javascript"></script> 16 <link href="sample.css" rel="stylesheet" type="text/css" /> 17 </head> 18 <body> 19 <h1> 20 CKEditor Sample 21 </h1> 22 <!-- This <div> holds alert messages to be display in the sample page. --> 23 <div id="alerts"> 24 <noscript> 25 <p> 26 <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript 27 support, like yours, you should still see the contents (HTML data) and you should 28 be able to edit it normally, without a rich editor interface. 29 </p> 30 </noscript> 31 </div> 32 <form action="sample_posteddata.php" method="post"> 33 <p> 34 In this sample the AutoGrow plugin is available. It makes the editor grow to fit the size of the content.</p> 35 <p> 36 <label for="editor1"> 37 With default configuration:</label><br /> 38 <textarea cols="80" id="editor1" name="editor1" rows="10"><p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p></textarea> 39 <script type="text/javascript"> 40 //<![CDATA[ 41 42 CKEDITOR.replace( 'editor1', { 43 extraPlugins : 'autogrow' 44 }); 45 46 //]]> 47 </script> 48 </p> 49 <p> 50 <label for="editor2"> 51 With maximum height set to 400:</label><br /> 52 <textarea cols="80" id="editor2" name="editor2" rows="10"><p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p></textarea> 53 <script type="text/javascript"> 54 //<![CDATA[ 55 56 CKEDITOR.replace( 'editor2', { 57 extraPlugins : 'autogrow', 58 autoGrow_maxHeight : 400 59 }); 60 61 //]]> 62 </script> 63 </p> 64 <p> 65 <input type="submit" value="Submit" /> 66 </p> 67 </form> 68 <div id="footer"> 69 <hr /> 70 <p> 71 CKEditor - The text editor for Internet - <a href="http://ckeditor.com/">http://ckeditor.com</a> 72 </p> 73 <p id="copy"> 74 Copyright © 2003-2010, <a href="http://cksource.com/">CKSource</a> - Frederico 75 Knabben. All rights reserved. 76 </p> 77 </div> 78 </body> 79 </html> -
_source/plugins/autogrow/plugin.js
1 /* 2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 /** 7 * @file AutoGrow plugin 8 */ 9 (function(){ 10 var resizeEditor = function( editor ) 11 { 12 var doc = editor.document, 13 documentElement = doc.getDocumentElement().$, 14 currentHeight = editor.window.getViewPaneSize().height, 15 newHeight; 16 17 if ( CKEDITOR.env.ie ) 18 newHeight = documentElement.scrollHeight; 19 else 20 newHeight = documentElement.offsetHeight; 21 22 var min = editor.config.autoGrow_minHeight, 23 max = editor.config.autoGrow_maxHeight; 24 if ( min ) 25 newHeight = Math.max( newHeight, min ); 26 if ( max ) 27 newHeight = Math.min( newHeight, max ); 28 29 if ( newHeight != currentHeight ) 30 { 31 newHeight = editor.fire( 'autoGrow', { currentHeight : currentHeight, newHeight : newHeight } ).newHeight; 32 editor.resize( editor.container.getStyle( 'width' ), newHeight, true ); 33 } 34 }; 35 CKEDITOR.plugins.add( 'autogrow', 36 { 37 init : function( editor ) 38 { 39 for ( var eventName in { contentDom:1, key:1, selectionChange:1, insertElement:1 } ) 40 { 41 editor.on( eventName, function( evt ) 42 { 43 // Some time is required for insertHtml, and it gives other events better performance as well. 44 if ( evt.editor.mode == 'wysiwyg' ) 45 setTimeout( function(){ resizeEditor( evt.editor ); }, 100 ); 46 }); 47 } 48 } 49 }); 50 })(); 51 /** 52 * The minimum height to which the editor can reach using AutoGrow. 53 * @name autoGrow_minHeight 54 * @type Number 55 * @default 200 56 * @example 57 * config.autoGrow_minHeight = 300; 58 */ 59 CKEDITOR.config.autoGrow_minHeight = 200; 60 61 /** 62 * The maximum height to which the editor can reach using AutoGrow. Zero means unlimited. 63 * @name autoGrow_maxHeight 64 * @type Number 65 * @default 0 66 * @example 67 * config.autoGrow_maxHeight = 400; 68 */ 69 CKEDITOR.config.autoGrow_maxHeight = 0; 70 71 /** 72 * Fired when the AutoGrow plugin is about to change the size of the editor. 73 * @name CKEDITOR#autogrow 74 * @event 75 * @param {Number} data.currentHeight The current height of the editor (before the resizing). 76 * @param {Number} data.newHeight The new height of the editor (after the resizing). It can be changed 77 * to determine another height to be used instead. 78 */