JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.2.2
[ckeditor.git] / _source / plugins / resize / plugin.js
index 780f319..8c25035 100644 (file)
@@ -11,18 +11,30 @@ CKEDITOR.plugins.add( 'resize',
 \r
                if ( config.resize_enabled )\r
                {\r
-                       var container = null;\r
-                       var origin, startSize;\r
+                       var container = null,\r
+                               origin,\r
+                               startSize,\r
+                               resizeHorizontal = ( config.resize_dir == 'both' || config.resize_dir == 'horizontal' ) &&\r
+                                       ( config.resize_minWidth != config.resize_maxWidth ),\r
+                               resizeVertical = ( config.resize_dir == 'both' || config.resize_dir == 'vertical' ) &&\r
+                                       ( config.resize_minHeight != config.resize_maxHeight );\r
 \r
                        function dragHandler( evt )\r
                        {\r
-                               var dx = evt.data.$.screenX - origin.x;\r
-                               var dy = evt.data.$.screenY - origin.y;\r
-                               var internalWidth = startSize.width + dx * ( editor.lang.dir == 'rtl' ? -1 : 1 );\r
-                               var internalHeight = startSize.height + dy;\r
+                               var dx = evt.data.$.screenX - origin.x,\r
+                                       dy = evt.data.$.screenY - origin.y,\r
+                                       width = startSize.width,\r
+                                       height = startSize.height,\r
+                                       internalWidth = width + dx * ( editor.lang.dir == 'rtl' ? -1 : 1 ),\r
+                                       internalHeight = height + dy;\r
 \r
-                               editor.resize( Math.max( config.resize_minWidth, Math.min( internalWidth, config.resize_maxWidth ) ),\r
-                                               Math.max( config.resize_minHeight, Math.min( internalHeight, config.resize_maxHeight ) ) );\r
+                               if ( resizeHorizontal )\r
+                                       width =  Math.max( config.resize_minWidth, Math.min( internalWidth, config.resize_maxWidth ) );\r
+\r
+                               if ( resizeVertical )\r
+                                       height =  Math.max( config.resize_minHeight, Math.min( internalHeight, config.resize_maxHeight ) );\r
+\r
+                               editor.resize( width, height );\r
                        }\r
 \r
                        function dragEndHandler ( evt )\r
@@ -61,7 +73,13 @@ CKEDITOR.plugins.add( 'resize',
                                {\r
                                        if ( event.data.space == 'bottom' )\r
                                        {\r
-                                               event.data.html += '<div class="cke_resizer"' +\r
+                                               var direction = '';\r
+                                               if ( resizeHorizontal && !resizeVertical)\r
+                                                       direction = ' cke_resizer_horizontal';\r
+                                               if ( !resizeHorizontal && resizeVertical)\r
+                                                       direction = ' cke_resizer_vertical';\r
+\r
+                                               event.data.html += '<div class="cke_resizer' + direction + '"' +\r
                                                        ' title="' + CKEDITOR.tools.htmlEncode( editor.lang.resize ) + '"' +\r
                                                        ' onmousedown="CKEDITOR.tools.callFunction(' + mouseDownFn + ', event)"' +\r
                                                        '></div>';\r
@@ -108,10 +126,21 @@ CKEDITOR.config.resize_maxWidth = 3000;
 CKEDITOR.config.resize_maxHeight = 3000;\r
 \r
 /**\r
- * Whether to enable the resizing feature. If disabed the resize handler will not be visible.\r
+ * Whether to enable the resizing feature. If disabled the resize handler will not be visible.\r
  * @type Boolean\r
  * @default true\r
  * @example\r
  * config.resize_enabled = false;\r
  */\r
 CKEDITOR.config.resize_enabled = true;\r
+\r
+/**\r
+ * The directions to which the editor resizing is enabled. Possible values\r
+ * are "both", "vertical" and "horizontal".\r
+ * @type String\r
+ * @default 'both'\r
+ * @since 3.3\r
+ * @example\r
+ * config.resize_dir = 'vertical';\r
+ */\r
+CKEDITOR.config.resize_dir = 'both';\r