Ticket #4174: 4174.patch

File 4174.patch, 6.1 KB (added by Garry Yao, 15 years ago)
  • _source/core/tools.js

     
    533533                repeat : function( str, times )
    534534                {
    535535                        return new Array( times + 1 ).join( str );
     536                },
     537
     538                capitalize: function( str )
     539                {
     540                  return str.charAt(0).toUpperCase() + str.substring(1).toLowerCase();
    536541                }
     542               
    537543        };
    538544})();
    539545
  • _source/core/dom/element.js

     
    456456                 * alert( <b>element.getComputedStyle( 'display' )</b> );  // "inline"
    457457                 */
    458458                getComputedStyle :
    459                         CKEDITOR.env.ie ?
    460                                 function( propertyName )
    461                                 {
    462                                         return this.$.currentStyle[ CKEDITOR.tools.cssStyleToDomStyle( propertyName ) ];
    463                                 }
     459                        CKEDITOR.env.ie ? ( function()
     460                        {
     461                                var offsetReviseMap =
     462                                {
     463                                        width: ['Left', 'Right'],
     464                                        height: ['Top', 'Bottom'],
     465                                        top: ['Top'],
     466                                        bottom: ['Bottom']
     467                                };
     468
     469                                return function( propertyName )
     470                                {
     471                                        var style = this.$.currentStyle[ CKEDITOR.tools.cssStyleToDomStyle( propertyName ) ];
     472                                        // IE computed width/height incorrect with auto/percentage values,
     473                                        // compute by subtracting padding and border from offset size.
     474                                        if( propertyName in offsetReviseMap
     475                                                && ( style == 'auto' || style.match( '%' ) ) )
     476                                        {
     477                                                var style = this.$[ 'offset' + CKEDITOR.tools.capitalize( propertyName ) ],
     478                                                        revisement = offsetReviseMap[ propertyName ];
     479                                                if( !CKEDITOR.env.quirks )
     480                                                {
     481                                                        for( var i = 0 ; i < 2 ; i++ )
     482                                                        {
     483                                                                var side = revisement[ i ];
     484                                                                // Justification for content-box-model.
     485                                                                if ( side )
     486                                                                {
     487                                                                        // Todo: Converting the style to pix-based unit.
     488                                                                        style -= parseInt( this.getComputedStyle( 'padding' + side ) ) || 0;
     489                                                                        style -= parseInt( this.getComputedStyle( 'border' + side ) ) || 0;
     490                                                                }
     491                                                        }
     492
     493                                                }
     494                                                style += 'px';
     495                                        }
     496                                       
     497                                        return style;
     498                                }
     499                        } )()
    464500                        :
    465501                                function( propertyName )
    466502                                {
  • _source/plugins/dialog/plugin.js

     
    489489                {
    490490                        return function( width, height )
    491491                        {
    492                                 if ( this._.contentSize && this._.contentSize.width == width && this._.contentSize.height == height )
    493                                         return;
    494492
    495493                                CKEDITOR.dialog.fire( 'resize',
    496494                                        {
     
    500498                                                height : height
    501499                                        }, this._.editor );
    502500
    503                                 this._.contentSize = { width : width, height : height };
    504501                                this._.updateSize = true;
    505502                        };
    506503                })(),
     
    516513                        if ( !this._.updateSize )
    517514                                return this._.size;
    518515                        var element = this._.element.getFirst();
    519                         var size = this._.size = { width : element.$.offsetWidth || 0, height : element.$.offsetHeight || 0};
     516                        var size = this._.size =
     517                                    { width :  parseInt( element.getComputedStyle( 'width' ) ),
     518                                          height : parseInt( element.getComputedStyle( 'height' ) ) };
    520519
    521520                        // If either the offsetWidth or offsetHeight is 0, the element isn't visible.
    522521                        this._.updateSize = !size.width || !size.height;
     
    603602                        }
    604603
    605604
    606                         // First, set the dialog to an appropriate size.
    607                         this.resize( definition.minWidth, definition.minHeight );
    608605
    609                         // Select the first tab by default.
    610                         this.selectPage( this.definition.contents[0].id );
    611 
    612606                        // Reset all inputs back to their default value.
    613607                        this.reset();
    614608
     
    652646                        // Rearrange the dialog to the middle of the window.
    653647                        CKEDITOR.tools.setTimeout( function()
    654648                                {
     649                                        // Save the initial values of the dialog.
     650                                        this.foreach( function( contentObj ) { contentObj.setInitValue && contentObj.setInitValue(); } );
     651
     652                                        // Select the first tab by default.
     653                                        this.selectPage( this.definition.contents[0].id );
     654
    655655                                        var viewSize = CKEDITOR.document.getWindow().getViewPaneSize();
    656656                                        var dialogSize = this.getSize();
    657657
     
    664664                                        // Execute onLoad for the first show.
    665665                                        this.fireOnce( 'load', {} );
    666666                                        this.fire( 'show', {} );
    667 
    668                                         // Save the initial values of the dialog.
    669                                         this.foreach( function( contentObj ) { contentObj.setInitValue && contentObj.setInitValue(); } );
    670 
    671667                                },
    672668                                100, this );
    673669                },
     
    876872                        selected[1].show();
    877873                        this._.currentTabId = id;
    878874                        this._.currentTabIndex = CKEDITOR.tools.indexOf( this._.tabIdList, id );
     875
     876                        this.resize( this.definition.minWidth, this.definition.minHeight );
    879877                },
    880878
    881879                /**
  • _source/skins/kama/skin.js

     
    216216                        if ( data.skin != 'kama' )
    217217                                return;
    218218
     219                        // Make the dialog area size fitable for contents with any size while
     220                        // preserve the defined minimum size.(#3878 and #4174)
    219221                        contents.setStyles(
    220                                 ( CKEDITOR.env.ie || ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 ) ) ?         // IE && FF2
    221                                         {
    222                                                 width : width + 'px',
    223                                                 height : height + 'px'
    224                                         }
     222                                // Only IE6 has no support for min-width/height, but in IE7 we're inside
     223                                // a fixed-positioned element where this style is broken too.
     224                                ( CKEDITOR.env.ie6Compat || CKEDITOR.env.ie7Compat ) ?
     225                                ( function ()
     226                                {
     227                                        // Reveal the real element size.
     228                                        contents.setStyles( { height: 'auto', width : 'auto' } );
     229                                        return {
     230                                                width : width >= parseInt( contents.getComputedStyle( 'width' ) ) ? width + 'px' : 'auto',
     231                                                height : height >= parseInt( contents.getComputedStyle( 'height' ) ) ? height + 'px' : 'auto'
     232                                        };
     233
     234                                } )()
    225235                                :
    226236                                        {
    227237                                                // To avoid having scrollbars in the dialogs, we're
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy