| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 /* 2 Copyright (c) 2003-2010, 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 !config.resize_dir && ( config.resize_dir = 'both' ); 13 ( config.resize_maxWidth == undefined ) && ( config.resize_maxWidth = 3000 ); 14 ( config.resize_maxHeight == undefined ) && ( config.resize_maxHeight = 3000 ); 15 ( config.resize_minWidth == undefined ) && ( config.resize_minWidth = 750 ); 16 ( config.resize_minHeight == undefined ) && ( config.resize_minHeight = 250 ); 17 18 if ( config.resize_enabled !== false ) 19 { 20 var container = null, 21 origin, 22 startSize, 23 resizeHorizontal = ( config.resize_dir == 'both' || config.resize_dir == 'horizontal' ) && 24 ( config.resize_minWidth != config.resize_maxWidth ), 25 resizeVertical = ( config.resize_dir == 'both' || config.resize_dir == 'vertical' ) && 26 ( config.resize_minHeight != config.resize_maxHeight ); 27 28 function dragHandler( evt ) 29 { 30 var dx = evt.data.$.screenX - origin.x, 31 dy = evt.data.$.screenY - origin.y, 32 width = startSize.width, 33 height = startSize.height, 34 internalWidth = width + dx * ( editor.lang.dir == 'rtl' ? -1 : 1 ), 35 internalHeight = height + dy; 36 37 if ( resizeHorizontal ) 38 width = Math.max( config.resize_minWidth, Math.min( internalWidth, config.resize_maxWidth ) ); 39 40 if ( resizeVertical ) 41 height = Math.max( config.resize_minHeight, Math.min( internalHeight, config.resize_maxHeight ) ); 42 43 editor.resize( width, height ); 44 } 45 46 function dragEndHandler ( evt ) 47 { 48 CKEDITOR.document.removeListener( 'mousemove', dragHandler ); 49 CKEDITOR.document.removeListener( 'mouseup', dragEndHandler ); 50 51 if ( editor.document ) 52 { 53 editor.document.removeListener( 'mousemove', dragHandler ); 54 editor.document.removeListener( 'mouseup', dragEndHandler ); 55 } 56 } 57 58 var mouseDownFn = CKEDITOR.tools.addFunction( function( $event ) 59 { 60 if ( !container ) 61 container = editor.getResizable(); 62 63 startSize = { width : container.$.offsetWidth || 0, height : container.$.offsetHeight || 0 }; 64 origin = { x : $event.screenX, y : $event.screenY }; 65 66 config.resize_minWidth > startSize.width && ( config.resize_minWidth = startSize.width ); 67 config.resize_minHeight > startSize.height && ( config.resize_minHeight = startSize.height ); 68 69 CKEDITOR.document.on( 'mousemove', dragHandler ); 70 CKEDITOR.document.on( 'mouseup', dragEndHandler ); 71 72 if ( editor.document ) 73 { 74 editor.document.on( 'mousemove', dragHandler ); 75 editor.document.on( 'mouseup', dragEndHandler ); 76 } 77 }); 78 79 editor.on( 'destroy', function() { CKEDITOR.tools.removeFunction( mouseDownFn ); } ); 80 81 editor.on( 'themeSpace', function( event ) 82 { 83 if ( event.data.space == 'bottom' ) 84 { 85 var direction = ''; 86 if ( resizeHorizontal && !resizeVertical) 87 direction = ' cke_resizer_horizontal'; 88 if ( !resizeHorizontal && resizeVertical) 89 direction = ' cke_resizer_vertical'; 90 91 event.data.html += '<div class="cke_resizer' + direction + '"' + 92 ' title="' + CKEDITOR.tools.htmlEncode( editor.lang.resize ) + '"' + 93 ' onmousedown="CKEDITOR.tools.callFunction(' + mouseDownFn + ', event)"' + 94 '></div>'; 95 } 96 }, editor, null, 100 ); 97 } 98 } 99 } ); 100 101 /** 102 * The minimum editor width, in pixels, when resizing it with the resize handle. 103 * Note: It fallbacks to editor's actual width if that's smaller than the default value. 104 * @name CKEDITOR.config.resize_minWidth 105 * @type Number 106 * @default 750 107 * @example 108 * config.resize_minWidth = 500; 109 */ 110 111 /** 112 * The minimum editor height, in pixels, when resizing it with the resize handle. 113 * Note: It fallbacks to editor's actual height if that's smaller than the default value. 114 * @name CKEDITOR.config.resize_minHeight 115 * @type Number 116 * @default 250 117 * @example 118 * config.resize_minHeight = 600; 119 */ 120 121 /** 122 * The maximum editor width, in pixels, when resizing it with the resize handle. 123 * @name CKEDITOR.config.resize_maxWidth 124 * @type Number 125 * @default 3000 126 * @example 127 * config.resize_maxWidth = 750; 128 */ 129 130 /** 131 * The maximum editor height, in pixels, when resizing it with the resize handle. 132 * @name CKEDITOR.config.resize_maxHeight 133 * @type Number 134 * @default 3000 135 * @example 136 * config.resize_maxHeight = 600; 137 */ 138 139 /** 140 * Whether to enable the resizing feature. If disabled the resize handler will not be visible. 141 * @name CKEDITOR.config.resize_enabled 142 * @type Boolean 143 * @default true 144 * @example 145 * config.resize_enabled = false; 146 */ 147 148 /** 149 * The directions to which the editor resizing is enabled. Possible values 150 * are "both", "vertical" and "horizontal". 151 * @name CKEDITOR.config.resize_dir 152 * @type String 153 * @default 'both' 154 * @since 3.3 155 * @example 156 * config.resize_dir = 'vertical'; 157 */
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |