Ticket #3601: 3601_2.patch
File 3601_2.patch, 4.3 KB (added by , 14 years ago) |
---|
-
_source/plugins/resize/plugin.js
7 7 { 8 8 init : function( editor ) 9 9 { 10 var config = editor.config; 10 var config = editor.config, 11 useProxy = config.resize_proxy || CKEDITOR.env.webkit || CKEDITOR.env.ie6Compat && !CKEDITOR.env.ie8; 11 12 12 13 if ( config.resize_enabled ) 13 14 { 14 var container = null, 15 var resizeable = null, 16 proxy, 17 pixel = CKEDITOR.tools.cssLength, 15 18 origin, 16 19 startSize, 20 width, height, adjustmentX, adjustmentY, 17 21 resizeHorizontal = ( config.resize_dir == 'both' || config.resize_dir == 'horizontal' ) && 18 22 ( config.resize_minWidth != config.resize_maxWidth ), 19 23 resizeVertical = ( config.resize_dir == 'both' || config.resize_dir == 'vertical' ) && … … 23 27 { 24 28 var dx = evt.data.$.screenX - origin.x, 25 29 dy = evt.data.$.screenY - origin.y, 26 width = startSize.width, 27 height = startSize.height, 28 internalWidth = width + dx * ( editor.lang.dir == 'rtl' ? -1 : 1 ), 29 internalHeight = height + dy; 30 internalWidth = startSize.width + dx * ( editor.lang.dir == 'rtl' ? -1 : 1 ), 31 internalHeight = startSize.height + dy; 30 32 31 33 if ( resizeHorizontal ) 32 34 width = Math.max( config.resize_minWidth, Math.min( internalWidth, config.resize_maxWidth ) ); … … 34 36 if ( resizeVertical ) 35 37 height = Math.max( config.resize_minHeight, Math.min( internalHeight, config.resize_maxHeight ) ); 36 38 37 editor.resize( width, height ); 39 if ( useProxy ) 40 proxy.setStyles( { width: pixel( width ), height: pixel( height ) } ); 41 else 42 editor.resize( width + adjustmentX, height + adjustmentY ); 38 43 } 39 44 40 45 function dragEndHandler ( evt ) 41 46 { 47 useProxy && proxy.hide(); 48 49 editor.resize( width + adjustmentX, height + adjustmentY ); 50 42 51 CKEDITOR.document.removeListener( 'mousemove', dragHandler ); 43 52 CKEDITOR.document.removeListener( 'mouseup', dragEndHandler ); 44 53 … … 51 60 52 61 var mouseDownFn = CKEDITOR.tools.addFunction( function( $event ) 53 62 { 54 if ( !container ) 55 container = editor.getResizable(); 63 function showProxy() 64 { 65 if ( !( proxy = CKEDITOR.document.getById( 'cke_resize_proxy' ) ) ) 66 proxy = CKEDITOR.document.getBody().append( CKEDITOR.dom.element.createFromHtml( '<div id="cke_resize_proxy" style="position:absolute;border:dotted 1px;"></div>' ) ); 56 67 57 startSize = { width : container.$.offsetWidth || 0, height : container.$.offsetHeight || 0 }; 68 var docPosition = editor.container.getDocumentPosition(); 69 proxy.setStyles( { left : pixel( docPosition.x ), top: pixel( docPosition.y ), width: pixel( startSize.width ), height: pixel( startSize.height ) } ); 70 proxy.show(); 71 } 72 73 if ( !resizeable ) 74 resizeable = editor.getResizable(); 75 76 startSize = { width : resizeable.$.offsetWidth || 0, height : resizeable.$.offsetHeight || 0 }; 58 77 origin = { x : $event.screenX, y : $event.screenY }; 78 adjustmentX = CKEDITOR.env.quirks ? editor.container.$.offsetHeight - resizeable.$.offsetHeight : 0; 79 adjustmentY = editor.container.$.offsetHeight - resizeable.$.offsetHeight; 59 80 81 useProxy && showProxy(); 82 60 83 CKEDITOR.document.on( 'mousemove', dragHandler ); 61 84 CKEDITOR.document.on( 'mouseup', dragEndHandler ); 62 85 … … 67 90 } 68 91 }); 69 92 70 editor.on( 'destroy', function() { CKEDITOR.tools.removeFunction( mouseDownFn ); } ); 93 editor.on( 'destroy', function() 94 { 95 CKEDITOR.tools.removeFunction( mouseDownFn ); 96 proxy && proxy.remove(); 97 } ); 71 98 72 99 editor.on( 'themeSpace', function( event ) 73 100 { … … 143 170 * config.resize_dir = 'vertical'; 144 171 */ 145 172 146 CKEDITOR.config.resize_dir = 'both'; 147 No newline at end of file 173 /** 174 * Whether use a proxy element to present the resizing rectangle 175 * instead of live content resizing. 176 * @name CKEDITOR.config.resize_proxy 177 * @type String 178 * @default "false" for all browsers except Safari and IE6. 179 * @since 3.4 180 * @example 181 * config.resize_proxy = true; 182 */ 183 184 CKEDITOR.config.resize_dir = 'both';