2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
6 CKEDITOR
.plugins
.add( 'resize',
8 init : function( editor
)
10 var config
= editor
.config
;
12 if ( config
.resize_enabled
)
15 var origin
, startSize
;
17 function dragHandler( evt
)
19 var dx
= evt
.data
.$.screenX
- origin
.x
;
20 var dy
= evt
.data
.$.screenY
- origin
.y
;
21 var internalWidth
= startSize
.width
+ dx
* ( editor
.lang
.dir
== 'rtl' ? -1 : 1 );
22 var internalHeight
= startSize
.height
+ dy
;
24 editor
.resize( Math
.max( config
.resize_minWidth
, Math
.min( internalWidth
, config
.resize_maxWidth
) ),
25 Math
.max( config
.resize_minHeight
, Math
.min( internalHeight
, config
.resize_maxHeight
) ) );
28 function dragEndHandler ( evt
)
30 CKEDITOR
.document
.removeListener( 'mousemove', dragHandler
);
31 CKEDITOR
.document
.removeListener( 'mouseup', dragEndHandler
);
33 if ( editor
.document
)
35 editor
.document
.removeListener( 'mousemove', dragHandler
);
36 editor
.document
.removeListener( 'mouseup', dragEndHandler
);
40 var mouseDownFn
= CKEDITOR
.tools
.addFunction( function( $event
)
43 container
= editor
.getResizable();
45 startSize
= { width
: container
.$.offsetWidth
|| 0, height
: container
.$.offsetHeight
|| 0 };
46 origin
= { x
: $event
.screenX
, y
: $event
.screenY
};
48 CKEDITOR
.document
.on( 'mousemove', dragHandler
);
49 CKEDITOR
.document
.on( 'mouseup', dragEndHandler
);
51 if ( editor
.document
)
53 editor
.document
.on( 'mousemove', dragHandler
);
54 editor
.document
.on( 'mouseup', dragEndHandler
);
58 editor
.on( 'destroy', function() { CKEDITOR
.tools
.removeFunction( mouseDownFn
); } );
60 editor
.on( 'themeSpace', function( event
)
62 if ( event
.data
.space
== 'bottom' )
64 event
.data
.html
+= '<div class="cke_resizer"' +
65 ' title="' + CKEDITOR
.tools
.htmlEncode( editor
.lang
.resize
) + '"' +
66 ' onmousedown="CKEDITOR.tools.callFunction(' + mouseDownFn
+ ', event)"' +
69 }, editor
, null, 100 );
75 * The minimum editor width, in pixels, when resizing it with the resize handle.
79 * config.resize_minWidth = 500;
81 CKEDITOR
.config
.resize_minWidth
= 750;
84 * The minimum editor height, in pixels, when resizing it with the resize handle.
88 * config.resize_minHeight = 600;
90 CKEDITOR
.config
.resize_minHeight
= 250;
93 * The maximum editor width, in pixels, when resizing it with the resize handle.
97 * config.resize_maxWidth = 750;
99 CKEDITOR
.config
.resize_maxWidth
= 3000;
102 * The maximum editor height, in pixels, when resizing it with the resize handle.
106 * config.resize_maxHeight = 600;
108 CKEDITOR
.config
.resize_maxHeight
= 3000;
111 * Whether to enable the resizing feature. If disabed the resize handler will not be visible.
115 * config.resize_enabled = false;
117 CKEDITOR
.config
.resize_enabled
= true;