Ticket #8348: 8348.patch

File 8348.patch, 3.9 KB (added by Garry Yao, 14 years ago)
  • _source/themes/default/theme.js

     
    335335 * @example
    336336 * editor.resize( '100%', 450, true );
    337337 */
    338 CKEDITOR.editor.prototype.resize = function( width, height, isContentHeight, resizeInner )
    339 {
    340         var container = this.container,
    341                 contents = CKEDITOR.document.getById( 'cke_contents_' + this.name ),
    342                 outer = resizeInner ? container.getChild( 1 ) : container;
     338( function()
     339{
     340        var resizerFixer = CKEDITOR.tools.withInterval( function( container )
     341        {
     342                // We can't simply hide the entire editor otherwise it breaks the host page scroll. (#6212)
     343                container.setStyle( 'display', 'inline-block' );
     344                setTimeout( function() { container.setStyle( 'display', 'block' ); }, 0 );
     345        }, 500 );
     346
     347        CKEDITOR.editor.prototype.resize = function( width, height, isContentHeight, resizeInner )
     348        {
     349                var container = this.container,
     350                        contents = CKEDITOR.document.getById( 'cke_contents_' + this.name ),
     351                        outer = resizeInner ? container.getChild( 1 ) : container;
    343352
    344         // Set as border box width. (#5353)
    345         outer.setSize( 'width',  width, true );
     353                // WEBKIT: Webkit requires a chrome re-layout. (#8348)
     354                CKEDITOR.env.webkit && resizerFixer( this, null, outer );
     355
     356                // Set as border box width. (#5353)
     357                outer.setSize( 'width',  width, true );
    346358
    347         // Get the height delta between the outer table and the content area.
    348         // If we're setting the content area's height, then we don't need the delta.
    349         var delta = isContentHeight ? 0 : ( outer.$.offsetHeight || 0 ) - ( contents.$.clientHeight || 0 );
    350         contents.setStyle( 'height', Math.max( height - delta, 0 ) + 'px' );
     359                // Get the height delta between the outer table and the content area.
     360                // If we're setting the content area's height, then we don't need the delta.
     361                var delta = isContentHeight ? 0 : ( outer.$.offsetHeight || 0 ) - ( contents.$.clientHeight || 0 );
     362                contents.setStyle( 'height', Math.max( height - delta, 0 ) + 'px' );
    351363
    352         // Emit a resize event.
    353         this.fire( 'resize' );
    354 };
     364                // Emit a resize event.
     365                this.fire( 'resize' );
     366        };
    355367
     368} )();
     369
    356370/**
    357371 * Gets the element that can be freely used to check the editor size. This method
    358372 * is mainly used by the resize plugin, which adds a UI handle that can be used
  • _source/core/tools.js

     
    756756                genKey : function()
    757757                {
    758758                        return Array.prototype.slice.call( arguments ).join( '-' );
    759                 }
    760         };
     759                },
     760
     761                /**
     762                 *  Guarantee a function to be executed with at least some interval even when invoked consequently..
     763                 *  <strong>Note:</strong> The proxy function should be invoked with the first argument a target object subjected to defer the function.
     764                 *  @param {Function} fn The function to be executed.
     765                 *  @param {Number} interval The least amount of time between each execution.
     766                 *  @return {Function} proxy(target, scope, arguments) The proxy function to substitute the original function.
     767                 */
     768                withInterval : ( function()
     769                {
     770                        var id = 0;
     771                        return function( fn, interval )
     772                                        {
     773                                                return ( function( taskId )
     774                                                {
     775                                                        taskId = 'task_' + taskId;
     776                                                        return function( obj, scope )
     777                                                        {
     778                                                                function clean()
     779                                                                {
     780                                                                        return setTimeout( function()
     781                                                                        {
     782                                                                                delete obj[ taskId ];
     783                                                                        }, interval );
     784                                                                }
     785
     786                                                                if ( !obj[ taskId ] )
     787                                                                {
     788                                                                        fn.apply( scope, Array.prototype.slice.call( arguments, 2 ) );
     789                                                                        obj[ taskId ] = clean();
     790                                                                }
     791
     792                                                        };
     793
     794                                                } )( id++ );
     795                                        }
     796
     797                } )()
     798        };
    761799})();
    762800
    763801// PACKAGER_RENAME( CKEDITOR.tools )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy