Update ckeditor to version 3.2.1
[gopost.git] / ckeditor / _source / plugins / resize / plugin.js
blob780f319388b09d898b7c323c02c80d5bf2d7d58c
1 /*
2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
4 */
6 CKEDITOR.plugins.add( 'resize',
8 init : function( editor )
10 var config = editor.config;
12 if ( config.resize_enabled )
14 var container = null;
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 )
42 if ( !container )
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 );
56 });
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)"' +
67 '></div>';
69 }, editor, null, 100 );
72 } );
74 /**
75 * The minimum editor width, in pixels, when resizing it with the resize handle.
76 * @type Number
77 * @default 750
78 * @example
79 * config.resize_minWidth = 500;
81 CKEDITOR.config.resize_minWidth = 750;
83 /**
84 * The minimum editor height, in pixels, when resizing it with the resize handle.
85 * @type Number
86 * @default 250
87 * @example
88 * config.resize_minHeight = 600;
90 CKEDITOR.config.resize_minHeight = 250;
92 /**
93 * The maximum editor width, in pixels, when resizing it with the resize handle.
94 * @type Number
95 * @default 3000
96 * @example
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.
103 * @type Number
104 * @default 3000
105 * @example
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.
112 * @type Boolean
113 * @default true
114 * @example
115 * config.resize_enabled = false;
117 CKEDITOR.config.resize_enabled = true;