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
15 var origin, startSize;
\r
17 function dragHandler( evt )
\r
19 var dx = evt.data.$.screenX - origin.x;
\r
20 var dy = evt.data.$.screenY - origin.y;
\r
21 var internalWidth = startSize.width + dx * ( editor.lang.dir == 'rtl' ? -1 : 1 );
\r
22 var internalHeight = startSize.height + dy;
\r
24 editor.resize( Math.max( config.resize_minWidth, Math.min( internalWidth, config.resize_maxWidth ) ),
\r
25 Math.max( config.resize_minHeight, Math.min( internalHeight, config.resize_maxHeight ) ) );
\r
28 function dragEndHandler ( evt )
\r
30 CKEDITOR.document.removeListener( 'mousemove', dragHandler );
\r
31 CKEDITOR.document.removeListener( 'mouseup', dragEndHandler );
\r
33 if ( editor.document )
\r
35 editor.document.removeListener( 'mousemove', dragHandler );
\r
36 editor.document.removeListener( 'mouseup', dragEndHandler );
\r
40 var mouseDownFn = CKEDITOR.tools.addFunction( function( $event )
\r
43 container = editor.getResizable();
\r
45 startSize = { width : container.$.offsetWidth || 0, height : container.$.offsetHeight || 0 };
\r
46 origin = { x : $event.screenX, y : $event.screenY };
\r
48 CKEDITOR.document.on( 'mousemove', dragHandler );
\r
49 CKEDITOR.document.on( 'mouseup', dragEndHandler );
\r
51 if ( editor.document )
\r
53 editor.document.on( 'mousemove', dragHandler );
\r
54 editor.document.on( 'mouseup', dragEndHandler );
\r
58 editor.on( 'themeSpace', function( event )
\r
60 if ( event.data.space == 'bottom' )
\r
62 event.data.html += '<div class="cke_resizer"' +
\r
63 ' title="' + CKEDITOR.tools.htmlEncode( editor.lang.resize ) + '"' +
\r
64 ' onmousedown="CKEDITOR.tools.callFunction(' + mouseDownFn + ', event)"' +
\r
67 }, editor, null, 100 );
\r
73 * The minimum editor width, in pixels, when resizing it with the resize handle.
\r
77 * config.resize_minWidth = 500;
\r
79 CKEDITOR.config.resize_minWidth = 750;
\r
82 * The minimum editor height, in pixels, when resizing it with the resize handle.
\r
86 * config.resize_minHeight = 600;
\r
88 CKEDITOR.config.resize_minHeight = 250;
\r
91 * The maximum editor width, in pixels, when resizing it with the resize handle.
\r
95 * config.resize_maxWidth = 750;
\r
97 CKEDITOR.config.resize_maxWidth = 3000;
\r
100 * The maximum editor height, in pixels, when resizing it with the resize handle.
\r
104 * config.resize_maxHeight = 600;
\r
106 CKEDITOR.config.resize_maxHeight = 3000;
\r
109 * Whether to enable the resizing feature. If disabed the resize handler will not be visible.
\r
113 * config.resize_enabled = false;
\r
115 CKEDITOR.config.resize_enabled = true;
\r