[3019] | 1 | /*
|
---|
| 2 | Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
|
---|
| 3 | For licensing, see LICENSE.html or http://ckeditor.com/license
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | CKEDITOR.plugins.add( 'resize',
|
---|
| 7 | {
|
---|
| 8 | init : function( editor )
|
---|
| 9 | {
|
---|
| 10 | var config = editor.config;
|
---|
| 11 |
|
---|
| 12 | if ( config.resize_enabled )
|
---|
| 13 | {
|
---|
| 14 | var container = null;
|
---|
| 15 | var origin, startSize;
|
---|
| 16 |
|
---|
| 17 | function dragHandler( evt )
|
---|
| 18 | {
|
---|
| 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;
|
---|
| 23 |
|
---|
| 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 ) ) );
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | function dragEndHandler ( evt )
|
---|
| 29 | {
|
---|
| 30 | CKEDITOR.document.removeListener( 'mousemove', dragHandler );
|
---|
| 31 | CKEDITOR.document.removeListener( 'mouseup', dragEndHandler );
|
---|
| 32 |
|
---|
| 33 | if ( editor.document )
|
---|
| 34 | {
|
---|
| 35 | editor.document.removeListener( 'mousemove', dragHandler );
|
---|
| 36 | editor.document.removeListener( 'mouseup', dragEndHandler );
|
---|
| 37 | }
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | var mouseDownFn = CKEDITOR.tools.addFunction( function( $event )
|
---|
| 41 | {
|
---|
| 42 | if ( !container )
|
---|
| 43 | container = editor.getResizable();
|
---|
| 44 |
|
---|
| 45 | startSize = { width : container.$.offsetWidth || 0, height : container.$.offsetHeight || 0 };
|
---|
| 46 | origin = { x : $event.screenX, y : $event.screenY };
|
---|
| 47 |
|
---|
| 48 | CKEDITOR.document.on( 'mousemove', dragHandler );
|
---|
| 49 | CKEDITOR.document.on( 'mouseup', dragEndHandler );
|
---|
| 50 |
|
---|
| 51 | if ( editor.document )
|
---|
| 52 | {
|
---|
| 53 | editor.document.on( 'mousemove', dragHandler );
|
---|
| 54 | editor.document.on( 'mouseup', dragEndHandler );
|
---|
| 55 | }
|
---|
| 56 | } );
|
---|
| 57 |
|
---|
| 58 | editor.on( 'themeSpace', function( event )
|
---|
| 59 | {
|
---|
| 60 | if ( event.data.space == 'bottom' )
|
---|
| 61 | {
|
---|
| 62 | event.data.html += '<div class="cke_resizer"' +
|
---|
| 63 | ' title="' + CKEDITOR.tools.htmlEncode( editor.lang.resize ) + '"' +
|
---|
| 64 | ' onmousedown="CKEDITOR.tools.callFunction(' + mouseDownFn + ', event)"' +
|
---|
| 65 | '></div>';
|
---|
| 66 | }
|
---|
| 67 | }, editor, null, 100 );
|
---|
| 68 | }
|
---|
| 69 | }
|
---|
| 70 | } );
|
---|
| 71 |
|
---|
| 72 | /**
|
---|
| 73 | * The minimum editor width, in pixels, when resizing it with the resize handle.
|
---|
| 74 | * @type Number
|
---|
| 75 | * @default 750
|
---|
| 76 | * @example
|
---|
| 77 | * config.resize_minWidth = 500;
|
---|
| 78 | */
|
---|
| 79 | CKEDITOR.config.resize_minWidth = 750;
|
---|
| 80 |
|
---|
| 81 | /**
|
---|
| 82 | * The minimum editor height, in pixels, when resizing it with the resize handle.
|
---|
| 83 | * @type Number
|
---|
| 84 | * @default 250
|
---|
| 85 | * @example
|
---|
| 86 | * config.resize_minHeight = 600;
|
---|
| 87 | */
|
---|
| 88 | CKEDITOR.config.resize_minHeight = 250;
|
---|
| 89 |
|
---|
| 90 | /**
|
---|
| 91 | * The maximum editor width, in pixels, when resizing it with the resize handle.
|
---|
| 92 | * @type Number
|
---|
| 93 | * @default 3000
|
---|
| 94 | * @example
|
---|
| 95 | * config.resize_maxWidth = 750;
|
---|
| 96 | */
|
---|
| 97 | CKEDITOR.config.resize_maxWidth = 3000;
|
---|
| 98 |
|
---|
| 99 | /**
|
---|
| 100 | * The maximum editor height, in pixels, when resizing it with the resize handle.
|
---|
| 101 | * @type Number
|
---|
| 102 | * @default 3000
|
---|
| 103 | * @example
|
---|
| 104 | * config.resize_maxHeight = 600;
|
---|
| 105 | */
|
---|
| 106 | CKEDITOR.config.resize_maxHeight = 3000;
|
---|
| 107 |
|
---|
| 108 | /**
|
---|
| 109 | * Whether to enable the resizing feature. If disabed the resize handler will not be visible.
|
---|
| 110 | * @type Boolean
|
---|
| 111 | * @default true
|
---|
| 112 | * @example
|
---|
| 113 | * config.resize_enabled = false;
|
---|
| 114 | */
|
---|
| 115 | CKEDITOR.config.resize_enabled = true;
|
---|