X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fresize%2Fplugin.js;h=8c250355ab0acbba875a71a29457903e1ba81f4e;hb=8665a7c6c60586526e32e8941fe2896739b6ebfb;hp=32faf6fdcc77bd82305bd096000b5500e4ded027;hpb=941b0a9ba4e673e292510d80a5a86806994b8ea6;p=ckeditor.git diff --git a/_source/plugins/resize/plugin.js b/_source/plugins/resize/plugin.js index 32faf6f..8c25035 100644 --- a/_source/plugins/resize/plugin.js +++ b/_source/plugins/resize/plugin.js @@ -11,18 +11,30 @@ CKEDITOR.plugins.add( 'resize', if ( config.resize_enabled ) { - 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 * ( editor.lang.dir == 'rtl' ? -1 : 1 ), + internalHeight = height + dy; - 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 ( resizeHorizontal ) + width = Math.max( config.resize_minWidth, Math.min( internalWidth, config.resize_maxWidth ) ); + + if ( resizeVertical ) + height = Math.max( config.resize_minHeight, Math.min( internalHeight, config.resize_maxHeight ) ); + + editor.resize( width, height ); } function dragEndHandler ( evt ) @@ -53,13 +65,21 @@ CKEDITOR.plugins.add( 'resize', editor.document.on( 'mousemove', dragHandler ); editor.document.on( 'mouseup', dragEndHandler ); } - } ); + }); + + editor.on( 'destroy', function() { CKEDITOR.tools.removeFunction( mouseDownFn ); } ); editor.on( 'themeSpace', function( event ) { if ( event.data.space == 'bottom' ) { - event.data.html += '
'; @@ -106,10 +126,21 @@ CKEDITOR.config.resize_maxWidth = 3000; 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 disabled the resize handler will not be visible. * @type Boolean * @default true * @example * config.resize_enabled = false; */ CKEDITOR.config.resize_enabled = true; + +/** + * The directions to which the editor resizing is enabled. Possible values + * are "both", "vertical" and "horizontal". + * @type String + * @default 'both' + * @since 3.3 + * @example + * config.resize_dir = 'vertical'; + */ +CKEDITOR.config.resize_dir = 'both';