Ticket #3601: 3601_3.patch
File 3601_3.patch, 4.9 KB (added by , 15 years ago) |
---|
-
_source/core/env.js
61 61 air : ( agent.indexOf( ' adobeair/' ) > -1 ), 62 62 63 63 /** 64 * Indicates Google Chrome. 65 * @type Boolean 66 * @example 67 * if ( CKEDITOR.env.chrome ) 68 * alert( "I'm on Chrome!" ); 69 */ 70 chrome : ( agent.indexOf( 'Chrome/' ) > -1 ), 71 72 /** 64 73 * Indicates that CKEditor is running on Macintosh. 65 74 * @type Boolean 66 75 * @example -
_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_livepreview != true 12 && ( config.resize_livepreview === false 13 || CKEDITOR.env.webkit && !CKEDITOR.env.chrome && !CKEDITOR.env.mac 14 || CKEDITOR.env.ie && CKEDITOR.env.version < 7 ); 11 15 12 16 if ( config.resize_enabled ) 13 17 { 14 var container = null, 18 var resizeable = null, 19 proxy, 20 pixel = CKEDITOR.tools.cssLength, 15 21 origin, 16 22 startSize, 23 width, height, adjustmentX, adjustmentY, 17 24 resizeHorizontal = ( config.resize_dir == 'both' || config.resize_dir == 'horizontal' ) && 18 25 ( config.resize_minWidth != config.resize_maxWidth ), 19 26 resizeVertical = ( config.resize_dir == 'both' || config.resize_dir == 'vertical' ) && … … 23 30 { 24 31 var dx = evt.data.$.screenX - origin.x, 25 32 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; 33 internalWidth = startSize.width + dx * ( editor.lang.dir == 'rtl' ? -1 : 1 ), 34 internalHeight = startSize.height + dy; 30 35 31 36 if ( resizeHorizontal ) 32 37 width = Math.max( config.resize_minWidth, Math.min( internalWidth, config.resize_maxWidth ) ); … … 34 39 if ( resizeVertical ) 35 40 height = Math.max( config.resize_minHeight, Math.min( internalHeight, config.resize_maxHeight ) ); 36 41 37 editor.resize( width, height ); 42 if ( useProxy ) 43 proxy.setStyles( { width: pixel( width ), height: pixel( height ) } ); 44 else 45 editor.resize( width + adjustmentX, height + adjustmentY ); 38 46 } 39 47 40 48 function dragEndHandler ( evt ) 41 49 { 50 useProxy && proxy.hide(); 51 52 editor.resize( width + adjustmentX, height + adjustmentY ); 53 42 54 CKEDITOR.document.removeListener( 'mousemove', dragHandler ); 43 55 CKEDITOR.document.removeListener( 'mouseup', dragEndHandler ); 44 56 … … 51 63 52 64 var mouseDownFn = CKEDITOR.tools.addFunction( function( $event ) 53 65 { 54 if ( !container ) 55 container = editor.getResizable(); 66 function showProxy() 67 { 68 if ( !( proxy = CKEDITOR.document.getById( 'cke_resize_livepreview' ) ) ) 69 proxy = CKEDITOR.document.getBody().append( CKEDITOR.dom.element.createFromHtml( '<div id="cke_resize_livepreview" style="position:absolute;border:dotted 1px;"></div>' ) ); 56 70 57 startSize = { width : container.$.offsetWidth || 0, height : container.$.offsetHeight || 0 }; 71 var docPosition = editor.container.getDocumentPosition(); 72 proxy.setStyles( { left : pixel( docPosition.x ), top: pixel( docPosition.y ), width: pixel( startSize.width ), height: pixel( startSize.height ) } ); 73 proxy.show(); 74 } 75 76 if ( !resizeable ) 77 resizeable = editor.getResizable(); 78 79 startSize = { width : resizeable.$.offsetWidth || 0, height : resizeable.$.offsetHeight || 0 }; 58 80 origin = { x : $event.screenX, y : $event.screenY }; 81 adjustmentX = CKEDITOR.env.quirks ? editor.container.$.offsetHeight - resizeable.$.offsetHeight : 0; 82 adjustmentY = editor.container.$.offsetHeight - resizeable.$.offsetHeight; 59 83 84 useProxy && showProxy(); 85 60 86 CKEDITOR.document.on( 'mousemove', dragHandler ); 61 87 CKEDITOR.document.on( 'mouseup', dragEndHandler ); 62 88 … … 67 93 } 68 94 }); 69 95 70 editor.on( 'destroy', function() { CKEDITOR.tools.removeFunction( mouseDownFn ); } ); 96 editor.on( 'destroy', function() 97 { 98 CKEDITOR.tools.removeFunction( mouseDownFn ); 99 proxy && proxy.remove(); 100 } ); 71 101 72 102 editor.on( 'themeSpace', function( event ) 73 103 { … … 144 174 * config.resize_dir = 'vertical'; 145 175 */ 146 176 CKEDITOR.config.resize_dir = 'both'; 177 178 /** 179 * Whether use a proxy element to present the resizing rectangle 180 * instead of live content resizing. 181 * @name CKEDITOR.config.resize_livepreview 182 * @type String 183 * @default "true" for all browsers except Safari (Windows) and IE6. 184 * @since 3.4 185 * @example 186 * config.resize_livepreview = false; 187 */