Ticket #3601: 3601_3.patch

File 3601_3.patch, 4.9 KB (added by Garry Yao, 14 years ago)
  • _source/core/env.js

     
    6161                        air             : ( agent.indexOf( ' adobeair/' ) > -1 ),
    6262
    6363                        /**
     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                        /**
    6473                         * Indicates that CKEditor is running on Macintosh.
    6574                         * @type Boolean
    6675                         * @example
  • _source/plugins/resize/plugin.js

     
    77{
    88        init : function( editor )
    99        {
    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 );
    1115
    1216                if ( config.resize_enabled )
    1317                {
    14                         var container = null,
     18                        var resizeable = null,
     19                                proxy,
     20                                pixel = CKEDITOR.tools.cssLength,
    1521                                origin,
    1622                                startSize,
     23                                width, height, adjustmentX, adjustmentY,
    1724                                resizeHorizontal = ( config.resize_dir == 'both' || config.resize_dir == 'horizontal' ) &&
    1825                                        ( config.resize_minWidth != config.resize_maxWidth ),
    1926                                resizeVertical = ( config.resize_dir == 'both' || config.resize_dir == 'vertical' ) &&
     
    2330                        {
    2431                                var dx = evt.data.$.screenX - origin.x,
    2532                                        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;
    3035
    3136                                if ( resizeHorizontal )
    3237                                        width =  Math.max( config.resize_minWidth, Math.min( internalWidth, config.resize_maxWidth ) );
     
    3439                                if ( resizeVertical )
    3540                                        height =  Math.max( config.resize_minHeight, Math.min( internalHeight, config.resize_maxHeight ) );
    3641
    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 );
    3846                        }
    3947
    4048                        function dragEndHandler ( evt )
    4149                        {
     50                                useProxy && proxy.hide();
     51
     52                                editor.resize( width + adjustmentX, height + adjustmentY );
     53
    4254                                CKEDITOR.document.removeListener( 'mousemove', dragHandler );
    4355                                CKEDITOR.document.removeListener( 'mouseup', dragEndHandler );
    4456
     
    5163
    5264                        var mouseDownFn = CKEDITOR.tools.addFunction( function( $event )
    5365                                {
    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>' ) );
    5670
    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 };
    5880                                        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;
    5983
     84                                        useProxy && showProxy();
     85
    6086                                        CKEDITOR.document.on( 'mousemove', dragHandler );
    6187                                        CKEDITOR.document.on( 'mouseup', dragEndHandler );
    6288
     
    6793                                        }
    6894                                });
    6995
    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                        } );
    71101
    72102                        editor.on( 'themeSpace', function( event )
    73103                                {
     
    144174 * config.resize_dir = 'vertical';
    145175 */
    146176CKEDITOR.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 */
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy