Nation Notes module contributed by Z&H Healthcare.
[openemr.git] / library / custom_template / ckeditor / _source / plugins / autogrow / plugin.js
blob492a8ef3cf9bf0ae468d98090e5127320e019ee3
1 /*
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
4 */
6 /**
7  * @file AutoGrow plugin
8  */
9 (function(){
10         var resizeEditor = function( editor )
11         {
12                 var doc = editor.document,
13                         currentHeight = editor.window.getViewPaneSize().height,
14                         newHeight;
16                 // We can not use documentElement to calculate the height for IE (#6061).
17                 // It is not good for IE Quirks, yet using offsetHeight would also not work as expected (#6408).
18                 // We do the same for FF because of the html height workaround (#6341).
19                 if ( CKEDITOR.env.ie || CKEDITOR.env.gecko )
20                         newHeight = doc.getBody().$.scrollHeight + ( CKEDITOR.env.ie && CKEDITOR.env.quirks ? 0 : 24 );
21                 else
22                         newHeight = doc.getDocumentElement().$.offsetHeight;
24                 var min = editor.config.autoGrow_minHeight,
25                         max = editor.config.autoGrow_maxHeight;
26                 ( min == undefined ) && ( editor.config.autoGrow_minHeight = min = 200 );
27                 if ( min )
28                         newHeight = Math.max( newHeight, min );
29                 if ( max )
30                         newHeight = Math.min( newHeight, max );
32                 if ( newHeight != currentHeight )
33                 {
34                         newHeight = editor.fire( 'autoGrow', { currentHeight : currentHeight, newHeight : newHeight } ).newHeight;
35                         editor.resize( editor.container.getStyle( 'width' ), newHeight, true );
36                 }
37         };
38         CKEDITOR.plugins.add( 'autogrow',
39         {
40                 init : function( editor )
41                 {
42                         for ( var eventName in { contentDom:1, key:1, selectionChange:1, insertElement:1 } )
43                         {
44                                 editor.on( eventName, function( evt )
45                                 {
46                                         var maximize = editor.getCommand( 'maximize' );
47                                         // Some time is required for insertHtml, and it gives other events better performance as well.
48                                         if ( evt.editor.mode == 'wysiwyg' &&
49                                                 // Disable autogrow when the editor is maximized .(#6339)
50                                                 ( !maximize || maximize.state != CKEDITOR.TRISTATE_ON ) )
51                                         {
52                                                 setTimeout( function(){ resizeEditor( evt.editor ); }, 100 );
53                                         }
54                                 });
55                         }
56                 }
57         });
58 })();
59 /**
60  * The minimum height to which the editor can reach using AutoGrow.
61  * @name CKEDITOR.config.autoGrow_minHeight
62  * @type Number
63  * @default 200
64  * @since 3.4
65  * @example
66  * config.autoGrow_minHeight = 300;
67  */
69 /**
70  * The maximum height to which the editor can reach using AutoGrow. Zero means unlimited.
71  * @name CKEDITOR.config.autoGrow_maxHeight
72  * @type Number
73  * @default 0
74  * @since 3.4
75  * @example
76  * config.autoGrow_maxHeight = 400;
77  */
79 /**
80  * Fired when the AutoGrow plugin is about to change the size of the editor.
81  * @name CKEDITOR.editor#autogrow
82  * @event
83  * @param {Number} data.currentHeight The current height of the editor (before the resizing).
84  * @param {Number} data.newHeight The new height of the editor (after the resizing). It can be changed
85  *                              to determine another height to be used instead.
86  */