Mimimum syndical pour en faire un produit zope / cmf.
[ckeditor.git] / skins / ckeditor / _source / plugins / resize / plugin.js
diff --git a/skins/ckeditor/_source/plugins/resize/plugin.js b/skins/ckeditor/_source/plugins/resize/plugin.js
new file mode 100644 (file)
index 0000000..24ba09c
--- /dev/null
@@ -0,0 +1,168 @@
+/*\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+For licensing, see LICENSE.html or http://ckeditor.com/license\r
+*/\r
+\r
+CKEDITOR.plugins.add( 'resize',\r
+{\r
+       init : function( editor )\r
+       {\r
+               var config = editor.config;\r
+\r
+               // Resize in the same direction of chrome,\r
+               // which is identical to dir of editor element. (#6614)\r
+               var resizeDir = editor.element.getDirection( 1 );\r
+\r
+               !config.resize_dir && ( config.resize_dir = 'both' );\r
+               ( config.resize_maxWidth == undefined ) && ( config.resize_maxWidth = 3000 );\r
+               ( config.resize_maxHeight == undefined ) && ( config.resize_maxHeight = 3000 );\r
+               ( config.resize_minWidth == undefined ) && ( config.resize_minWidth = 750 );\r
+               ( config.resize_minHeight == undefined ) && ( config.resize_minHeight = 250 );\r
+\r
+               if ( config.resize_enabled !== false )\r
+               {\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
+                                       dy = evt.data.$.screenY - origin.y,\r
+                                       width = startSize.width,\r
+                                       height = startSize.height,\r
+                                       internalWidth = width + dx * ( resizeDir == 'rtl' ? -1 : 1 ),\r
+                                       internalHeight = height + dy;\r
+\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
+                       {\r
+                               CKEDITOR.document.removeListener( 'mousemove', dragHandler );\r
+                               CKEDITOR.document.removeListener( 'mouseup', dragEndHandler );\r
+\r
+                               if ( editor.document )\r
+                               {\r
+                                       editor.document.removeListener( 'mousemove', dragHandler );\r
+                                       editor.document.removeListener( 'mouseup', dragEndHandler );\r
+                               }\r
+                       }\r
+\r
+                       var mouseDownFn = CKEDITOR.tools.addFunction( function( $event )\r
+                               {\r
+                                       if ( !container )\r
+                                               container = editor.getResizable();\r
+\r
+                                       startSize = { width : container.$.offsetWidth || 0, height : container.$.offsetHeight || 0 };\r
+                                       origin = { x : $event.screenX, y : $event.screenY };\r
+\r
+                                       config.resize_minWidth > startSize.width && ( config.resize_minWidth = startSize.width );\r
+                                       config.resize_minHeight > startSize.height && ( config.resize_minHeight = startSize.height );\r
+\r
+                                       CKEDITOR.document.on( 'mousemove', dragHandler );\r
+                                       CKEDITOR.document.on( 'mouseup', dragEndHandler );\r
+\r
+                                       if ( editor.document )\r
+                                       {\r
+                                               editor.document.on( 'mousemove', dragHandler );\r
+                                               editor.document.on( 'mouseup', dragEndHandler );\r
+                                       }\r
+                               });\r
+\r
+                       editor.on( 'destroy', function() { CKEDITOR.tools.removeFunction( mouseDownFn ); } );\r
+\r
+                       editor.on( 'themeSpace', function( event )\r
+                               {\r
+                                       if ( event.data.space == 'bottom' )\r
+                                       {\r
+                                               var direction = '';\r
+                                               if ( resizeHorizontal && !resizeVertical )\r
+                                                       direction = ' cke_resizer_horizontal';\r
+                                               if ( !resizeHorizontal && resizeVertical )\r
+                                                       direction = ' cke_resizer_vertical';\r
+\r
+                                               var resizerHtml =\r
+                                                       '<div' +\r
+                                                       ' class="cke_resizer' + direction + ' cke_resizer_' + resizeDir + '"' +\r
+                                                       ' title="' + CKEDITOR.tools.htmlEncode( editor.lang.resize ) + '"' +\r
+                                                       ' onmousedown="CKEDITOR.tools.callFunction(' + mouseDownFn + ', event)"' +\r
+                                                       '></div>';\r
+\r
+                                               // Always sticks the corner of botttom space.\r
+                                               resizeDir == 'ltr' && direction == 'ltr' ?\r
+                                                       event.data.html += resizerHtml :\r
+                                                       event.data.html = resizerHtml + event.data.html;\r
+                                       }\r
+                               }, editor, null, 100 );\r
+               }\r
+       }\r
+} );\r
+\r
+/**\r
+ * The minimum editor width, in pixels, when resizing it with the resize handle.\r
+ * Note: It fallbacks to editor's actual width if that's smaller than the default value.\r
+ * @name CKEDITOR.config.resize_minWidth\r
+ * @type Number\r
+ * @default 750\r
+ * @example\r
+ * config.resize_minWidth = 500;\r
+ */\r
+\r
+/**\r
+ * The minimum editor height, in pixels, when resizing it with the resize handle.\r
+ * Note: It fallbacks to editor's actual height if that's smaller than the default value.\r
+ * @name CKEDITOR.config.resize_minHeight\r
+ * @type Number\r
+ * @default 250\r
+ * @example\r
+ * config.resize_minHeight = 600;\r
+ */\r
+\r
+/**\r
+ * The maximum editor width, in pixels, when resizing it with the resize handle.\r
+ * @name CKEDITOR.config.resize_maxWidth\r
+ * @type Number\r
+ * @default 3000\r
+ * @example\r
+ * config.resize_maxWidth = 750;\r
+ */\r
+\r
+/**\r
+ * The maximum editor height, in pixels, when resizing it with the resize handle.\r
+ * @name CKEDITOR.config.resize_maxHeight\r
+ * @type Number\r
+ * @default 3000\r
+ * @example\r
+ * config.resize_maxHeight = 600;\r
+ */\r
+\r
+/**\r
+ * Whether to enable the resizing feature. If disabled the resize handler will not be visible.\r
+ * @name CKEDITOR.config.resize_enabled\r
+ * @type Boolean\r
+ * @default true\r
+ * @example\r
+ * config.resize_enabled = false;\r
+ */\r
+\r
+/**\r
+ * The directions to which the editor resizing is enabled. Possible values\r
+ * are "both", "vertical" and "horizontal".\r
+ * @name CKEDITOR.config.resize_dir\r
+ * @type String\r
+ * @default 'both'\r
+ * @since 3.3\r
+ * @example\r
+ * config.resize_dir = 'vertical';\r
+ */\r