X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fresize%2Fplugin.js;h=db4651e8504612254697dd2aa366633d703c055f;hb=3fe9cac293e090ea459a3ee10d78cbe9e1dd0e03;hp=780f319388b09d898b7c323c02c80d5bf2d7d58c;hpb=e7789c1ad838194d45eeee6ac2eb6e55f5cf35a1;p=ckeditor.git diff --git a/_source/plugins/resize/plugin.js b/_source/plugins/resize/plugin.js index 780f319..db4651e 100644 --- a/_source/plugins/resize/plugin.js +++ b/_source/plugins/resize/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -9,20 +9,43 @@ CKEDITOR.plugins.add( 'resize', { var config = editor.config; - if ( config.resize_enabled ) + // Resize in the same direction of chrome, + // which is identical to dir of editor element. (#6614) + var resizeDir = editor.element.getDirection( 1 ); + + !config.resize_dir && ( config.resize_dir = 'both' ); + ( config.resize_maxWidth == undefined ) && ( config.resize_maxWidth = 3000 ); + ( config.resize_maxHeight == undefined ) && ( config.resize_maxHeight = 3000 ); + ( config.resize_minWidth == undefined ) && ( config.resize_minWidth = 750 ); + ( config.resize_minHeight == undefined ) && ( config.resize_minHeight = 250 ); + + if ( config.resize_enabled !== false ) { - var container = null; - var origin, startSize; + var container = null, + origin, + startSize, + resizeHorizontal = ( config.resize_dir == 'both' || config.resize_dir == 'horizontal' ) && + ( config.resize_minWidth != config.resize_maxWidth ), + resizeVertical = ( config.resize_dir == 'both' || config.resize_dir == 'vertical' ) && + ( config.resize_minHeight != config.resize_maxHeight ); function dragHandler( evt ) { - var dx = evt.data.$.screenX - origin.x; - var dy = evt.data.$.screenY - origin.y; - var internalWidth = startSize.width + dx * ( editor.lang.dir == 'rtl' ? -1 : 1 ); - var internalHeight = startSize.height + dy; + var dx = evt.data.$.screenX - origin.x, + dy = evt.data.$.screenY - origin.y, + width = startSize.width, + height = startSize.height, + internalWidth = width + dx * ( resizeDir == 'rtl' ? -1 : 1 ), + internalHeight = height + dy; + + if ( resizeHorizontal ) + width = Math.max( config.resize_minWidth, Math.min( internalWidth, config.resize_maxWidth ) ); - editor.resize( Math.max( config.resize_minWidth, Math.min( internalWidth, config.resize_maxWidth ) ), - Math.max( config.resize_minHeight, Math.min( internalHeight, config.resize_maxHeight ) ) ); + if ( resizeVertical ) + height = Math.max( config.resize_minHeight, Math.min( internalHeight, config.resize_maxHeight ) ); + + // DO NOT impose fixed size with single direction resize. (#6308) + editor.resize( resizeHorizontal ? width : null, height ); } function dragEndHandler ( evt ) @@ -45,6 +68,9 @@ CKEDITOR.plugins.add( 'resize', startSize = { width : container.$.offsetWidth || 0, height : container.$.offsetHeight || 0 }; origin = { x : $event.screenX, y : $event.screenY }; + config.resize_minWidth > startSize.width && ( config.resize_minWidth = startSize.width ); + config.resize_minHeight > startSize.height && ( config.resize_minHeight = startSize.height ); + CKEDITOR.document.on( 'mousemove', dragHandler ); CKEDITOR.document.on( 'mouseup', dragEndHandler ); @@ -61,10 +87,23 @@ CKEDITOR.plugins.add( 'resize', { if ( event.data.space == 'bottom' ) { - event.data.html += '
'; + + // Always sticks the corner of botttom space. + resizeDir == 'ltr' && direction == 'ltr' ? + event.data.html += resizerHtml : + event.data.html = resizerHtml + event.data.html; } }, editor, null, 100 ); } @@ -72,46 +111,59 @@ CKEDITOR.plugins.add( 'resize', } ); /** - * The minimum editor width, in pixels, when resizing it with the resize handle. + * The minimum editor width, in pixels, when resizing the editor interface by using the resize handle. + * Note: It falls back to editor's actual width if it is smaller than the default value. + * @name CKEDITOR.config.resize_minWidth * @type Number * @default 750 * @example * config.resize_minWidth = 500; */ -CKEDITOR.config.resize_minWidth = 750; /** - * The minimum editor height, in pixels, when resizing it with the resize handle. + * The minimum editor height, in pixels, when resizing the editor interface by using the resize handle. + * Note: It falls back to editor's actual height if it is smaller than the default value. + * @name CKEDITOR.config.resize_minHeight * @type Number * @default 250 * @example * config.resize_minHeight = 600; */ -CKEDITOR.config.resize_minHeight = 250; /** - * The maximum editor width, in pixels, when resizing it with the resize handle. + * The maximum editor width, in pixels, when resizing the editor interface by using the resize handle. + * @name CKEDITOR.config.resize_maxWidth * @type Number * @default 3000 * @example * config.resize_maxWidth = 750; */ -CKEDITOR.config.resize_maxWidth = 3000; /** - * The maximum editor height, in pixels, when resizing it with the resize handle. + * The maximum editor height, in pixels, when resizing the editor interface by using the resize handle. + * @name CKEDITOR.config.resize_maxHeight * @type Number * @default 3000 * @example * config.resize_maxHeight = 600; */ -CKEDITOR.config.resize_maxHeight = 3000; /** - * Whether to enable the resizing feature. If disabed the resize handler will not be visible. + * Whether to enable the resizing feature. If this feature is disabled, the resize handle will not be visible. + * @name CKEDITOR.config.resize_enabled * @type Boolean * @default true * @example * config.resize_enabled = false; */ -CKEDITOR.config.resize_enabled = true; + +/** + * The dimensions for which the editor resizing is enabled. Possible values + * are both, vertical, and horizontal. + * @name CKEDITOR.config.resize_dir + * @type String + * @default 'both' + * @since 3.3 + * @example + * config.resize_dir = 'vertical'; + */