2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
6 CKEDITOR.plugins.add( 'resize',
\r
8 init : function( editor )
\r
10 var config = editor.config;
\r
12 if ( config.resize_enabled )
\r
14 var container = null,
\r
17 resizeHorizontal = ( config.resize_dir == 'both' || config.resize_dir == 'horizontal' ) &&
\r
18 ( config.resize_minWidth != config.resize_maxWidth ),
\r
19 resizeVertical = ( config.resize_dir == 'both' || config.resize_dir == 'vertical' ) &&
\r
20 ( config.resize_minHeight != config.resize_maxHeight );
\r
22 function dragHandler( evt )
\r
24 var dx = evt.data.$.screenX - origin.x,
\r
25 dy = evt.data.$.screenY - origin.y,
\r
26 width = startSize.width,
\r
27 height = startSize.height,
\r
28 internalWidth = width + dx * ( editor.lang.dir == 'rtl' ? -1 : 1 ),
\r
29 internalHeight = height + dy;
\r
31 if ( resizeHorizontal )
\r
32 width = Math.max( config.resize_minWidth, Math.min( internalWidth, config.resize_maxWidth ) );
\r
34 if ( resizeVertical )
\r
35 height = Math.max( config.resize_minHeight, Math.min( internalHeight, config.resize_maxHeight ) );
\r
37 editor.resize( width, height );
\r
40 function dragEndHandler ( evt )
\r
42 CKEDITOR.document.removeListener( 'mousemove', dragHandler );
\r
43 CKEDITOR.document.removeListener( 'mouseup', dragEndHandler );
\r
45 if ( editor.document )
\r
47 editor.document.removeListener( 'mousemove', dragHandler );
\r
48 editor.document.removeListener( 'mouseup', dragEndHandler );
\r
52 var mouseDownFn = CKEDITOR.tools.addFunction( function( $event )
\r
55 container = editor.getResizable();
\r
57 startSize = { width : container.$.offsetWidth || 0, height : container.$.offsetHeight || 0 };
\r
58 origin = { x : $event.screenX, y : $event.screenY };
\r
60 CKEDITOR.document.on( 'mousemove', dragHandler );
\r
61 CKEDITOR.document.on( 'mouseup', dragEndHandler );
\r
63 if ( editor.document )
\r
65 editor.document.on( 'mousemove', dragHandler );
\r
66 editor.document.on( 'mouseup', dragEndHandler );
\r
70 editor.on( 'destroy', function() { CKEDITOR.tools.removeFunction( mouseDownFn ); } );
\r
72 editor.on( 'themeSpace', function( event )
\r
74 if ( event.data.space == 'bottom' )
\r
77 if ( resizeHorizontal && !resizeVertical)
\r
78 direction = ' cke_resizer_horizontal';
\r
79 if ( !resizeHorizontal && resizeVertical)
\r
80 direction = ' cke_resizer_vertical';
\r
82 event.data.html += '<div class="cke_resizer' + direction + '"' +
\r
83 ' title="' + CKEDITOR.tools.htmlEncode( editor.lang.resize ) + '"' +
\r
84 ' onmousedown="CKEDITOR.tools.callFunction(' + mouseDownFn + ', event)"' +
\r
87 }, editor, null, 100 );
\r
93 * The minimum editor width, in pixels, when resizing it with the resize handle.
\r
97 * config.resize_minWidth = 500;
\r
99 CKEDITOR.config.resize_minWidth = 750;
\r
102 * The minimum editor height, in pixels, when resizing it with the resize handle.
\r
106 * config.resize_minHeight = 600;
\r
108 CKEDITOR.config.resize_minHeight = 250;
\r
111 * The maximum editor width, in pixels, when resizing it with the resize handle.
\r
115 * config.resize_maxWidth = 750;
\r
117 CKEDITOR.config.resize_maxWidth = 3000;
\r
120 * The maximum editor height, in pixels, when resizing it with the resize handle.
\r
124 * config.resize_maxHeight = 600;
\r
126 CKEDITOR.config.resize_maxHeight = 3000;
\r
129 * Whether to enable the resizing feature. If disabled the resize handler will not be visible.
\r
133 * config.resize_enabled = false;
\r
135 CKEDITOR.config.resize_enabled = true;
\r
138 * The directions to which the editor resizing is enabled. Possible values
\r
139 * are "both", "vertical" and "horizontal".
\r
144 * config.resize_dir = 'vertical';
\r
146 CKEDITOR.config.resize_dir = 'both';
\r