Ticket #6212: 6212.patch

File 6212.patch, 4.2 KB (added by Garry Yao, 12 years ago)
  • _source/themes/default/theme.js

     
    321321 * @example
    322322 * editor.resize( '100%', 450, true );
    323323 */
    324 CKEDITOR.editor.prototype.resize = function( width, height, isContentHeight, resizeInner )
    325 {
    326         var container = this.container,
    327                 contents = CKEDITOR.document.getById( 'cke_contents_' + this.name ),
    328                 outer = resizeInner ? container.getChild( 1 ) : container;
     324( function()
     325{
     326
     327        var resizerFixer = CKEDITOR.tools.withInterval( function( container )
     328        {
     329                // We can't simply hide the entire editor otherwise it breaks the host page scroll. (#6212)
     330                container.setStyle( 'display', 'inline-block' );
     331                setTimeout( function() { container.setStyle( 'display', 'block' ); }, 0 );
     332        }, 500 );
     333
     334        CKEDITOR.editor.prototype.resize = function( width, height, isContentHeight, resizeInner )
     335        {
     336                var container = this.container,
     337                        contents = CKEDITOR.document.getById( 'cke_contents_' + this.name ),
     338                        outer = resizeInner ? container.getChild( 1 ) : container;
    329339
    330         // Resize the width first.
    331         // WEBKIT BUG: Webkit requires that we put the editor off from display when we
    332         // resize it. If we don't, the browser crashes!
    333         CKEDITOR.env.webkit && outer.setStyle( 'display', 'none' );
    334         // Set as border box width. (#5353)
    335         outer.setSize( 'width',  width, true );
    336         if ( CKEDITOR.env.webkit )
    337         {
    338                 outer.$.offsetWidth;
    339                 outer.setStyle( 'display', '' );
    340         }
     340                // WEBKIT: Webkit requires a chrome re-layout. (#5729)
     341                CKEDITOR.env.webkit && resizerFixer( this, null, outer );
     342
     343                // Set as border box width. (#5353)
     344                outer.setSize( 'width',  width, true );
    341345
    342         // Get the height delta between the outer table and the content area.
    343         // If we're setting the content area's height, then we don't need the delta.
    344         var delta = isContentHeight ? 0 : ( outer.$.offsetHeight || 0 ) - ( contents.$.clientHeight || 0 );
    345         contents.setStyle( 'height', Math.max( height - delta, 0 ) + 'px' );
     346                // Get the height delta between the outer table and the content area.
     347                // If we're setting the content area's height, then we don't need the delta.
     348                var delta = isContentHeight ? 0 : ( outer.$.offsetHeight || 0 ) - ( contents.$.clientHeight || 0 );
     349                contents.setStyle( 'height', Math.max( height - delta, 0 ) + 'px' );
    346350
    347         // Emit a resize event.
    348         this.fire( 'resize' );
    349 };
     351                // Emit a resize event.
     352                this.fire( 'resize' );
     353        };
    350354
     355
     356} )();
     357
    351358/**
    352359 * Gets the element that can be freely used to check the editor size. This method
    353360 * 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                                                                        fn.apply( scope, Array.prototype.slice.call( arguments, 2 ) );
     788                                                                else
     789                                                                        clearTimeout( obj[ taskId ] );
     790
     791                                                                obj[ taskId ] = clean();
     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