Ticket #4246: 4246_4.patch

File 4246_4.patch, 23.5 KB (added by Garry Yao, 14 years ago)
  • _source/core/dom/element.js

     
    433433                                                        return attrValue ? 'checked' : null;
    434434                                                }
    435435
     436                                                case 'hspace':
     437                                                        return this.$.hspace;
     438
    436439                                                case 'style':
    437440                                                        // IE does not return inline styles via getAttribute(). See #2947.
    438441                                                        return this.$.style.cssText;
     
    9981001                 */
    9991002                removeStyle : function( name )
    10001003                {
    1001                         if ( this.$.style.removeAttribute )
    1002                                 this.$.style.removeAttribute( CKEDITOR.tools.cssStyleToDomStyle( name ) );
    1003                         else
    1004                                 this.setStyle( name, '' );
     1004                        this.setStyle( name, '' );
    10051005
    10061006                        if ( !this.$.style.cssText )
    10071007                                this.removeAttribute( 'style' );
  • _source/lang/en.js

     
    385385                vSpace  : 'VSpace',
    386386                align           : 'Align',
    387387                alignLeft       : 'Left',
    388                 alignAbsBottom: 'Abs Bottom',
    389                 alignAbsMiddle: 'Abs Middle',
    390                 alignBaseline   : 'Baseline',
    391                 alignBottom     : 'Bottom',
    392                 alignMiddle     : 'Middle',
    393388                alignRight      : 'Right',
    394                 alignTextTop    : 'Text Top',
    395                 alignTop        : 'Top',
    396389                preview : 'Preview',
    397390                alertUrl        : 'Please type the image URL',
    398391                linkTab : 'Link',
  • _source/plugins/image/dialogs/image.js

     
    1111                PREVIEW = 4,
    1212                CLEANUP = 8,
    1313                regexGetSize = /^\s*(\d+)((px)|\%)?\s*$/i,
    14                 regexGetSizeOrEmpty = /(^\s*(\d+)((px)|\%)?\s*$)|^$/i;
     14                regexGetSizeOrEmpty = /(^\s*(\d+)((px)|\%)?\s*$)|^$/i,
     15                pxLengthRegex = /^\d+px$/;
    1516
    1617        var onSizeChange = function()
    1718        {
     
    6162                return 0;
    6263        };
    6364
     65        // Avoid recursions.
     66        var incommit;
     67        // Commit the
     68        function commitInternally( targetFields )
     69        {
     70                if( incommit )
     71                        return;
     72
     73                incommit = 1;
     74               
     75                var dialog = this.getDialog(),
     76                        element = dialog.imageElement;
     77                if( element )
     78                {
     79                        // Commit this field and broadcast to target fields.
     80                        this.commit( IMAGE, element );
     81
     82                        targetFields = [].concat( targetFields );
     83                        var length = targetFields.length,
     84                                field;
     85                        for ( var i = 0; i < length; i++ )
     86                        {
     87                                field = dialog.getContentElement.apply( dialog, targetFields[ i ].split( ':' ) );
     88                                // May cause recursion.
     89                                field && field.setup( IMAGE, element );
     90                        }
     91                }
     92               
     93                incommit = 0;
     94        }
     95
    6496        var switchLockRatio = function( dialog, value )
    6597        {
    6698                var oImageOriginal = dialog.originalElement,
     
    138170
    139171                if ( size )
    140172                        value = checkDimension( size, value );
    141                 value = checkDimension( element.$.style[ dimension ], value );
     173                value = checkDimension( element.getStyle( dimension ), value );
    142174
    143175                this.setValue( value );
    144176        };
     
    242274                                                this.setupContent( LINK, link );
    243275                                }
    244276
    245                                 if ( element && element.getName() == 'img' && !element.getAttribute( '_cke_realelement' ) )
    246                                         this.imageEditMode = 'img';
    247                                 else if ( element && element.getName() == 'input' && element.getAttribute( 'type' ) && element.getAttribute( 'type' ) == 'image' )
    248                                         this.imageEditMode = 'input';
    249 
    250                                 if ( this.imageEditMode || this.imageElement )
     277                                if ( element && element.getName() == 'img' && !element.getAttribute( '_cke_realelement' )
     278                                        || element && element.getName() == 'input' && element.getAttribute( 'type' ) == 'image' )
    251279                                {
    252                                         if ( !this.imageElement )
    253                                                 this.imageElement = element;
     280                                        this.imageEditMode = element.getName();
     281                                        this.imageElement = element;
     282                                }
    254283
     284                                if ( this.imageEditMode )
     285                                {
     286                                        // Use the original element as a buffer from  since we don't want
     287                                        // temporary changes to be committed, e.g. if the dialog is canceled.
     288                                        this.cleanImageElement = this.imageElement;
     289                                        this.imageElement = this.cleanImageElement.clone( true, true );
     290
    255291                                        // Fill out all fields.
    256292                                        this.setupContent( IMAGE, this.imageElement );
    257293
    258294                                        // Refresh LockRatio button
    259295                                        switchLockRatio ( this, true );
    260296                                }
     297                                else
     298                                        this.imageElement =  editor.document.createElement( 'img' );
    261299
    262300                                // Dont show preview if no URL given.
    263301                                if ( !CKEDITOR.tools.trim( this.getValueOf( 'info', 'txtUrl' ) ) )
     
    296334                                                );
    297335                                                editor.insertElement( this.imageElement );
    298336                                        }
    299                                 }
     337                                        else
     338                                        {
     339                                                // Restore the original element before all commits.
     340                                                this.imageElement = this.cleanImageElement;
     341                                                delete this.cleanImageElement;
     342                                        }
     343                                }
    300344                                else    // Create a new image.
    301345                                {
    302346                                        // Image dialog -> create IMG element.
     
    318362                                this.commitContent( IMAGE, this.imageElement );
    319363                                this.commitContent( LINK, this.linkElement );
    320364
     365                                // Remove empty style attribute.
     366                                if( !this.imageElement.getAttribute( 'style' ) )
     367                                        this.imageElement.removeAttribute( 'style' );
     368
    321369                                // Insert a new Image.
    322370                                if ( !this.imageEditMode )
    323371                                {
     
    372420                                        this.originalElement.remove();
    373421                                        this.originalElement = false;           // Dialog is closed.
    374422                                }
     423
     424                                delete this.imageElement;
    375425                        },
    376426                        contents : [
    377427                                {
     
    533583                                                                                                                        id : 'txtWidth',
    534584                                                                                                                        labelLayout : 'horizontal',
    535585                                                                                                                        label : editor.lang.image.width,
    536                                                                                                                         onKeyUp : onSizeChange,
     586                                                                                                                        onKeyUp : function()
     587                                                                                                                        {
     588                                                                                                                                onSizeChange.apply( this, arguments );
     589                                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
     590                                                                                                                        },
    537591                                                                                                                        validate: function()
    538592                                                                                                                        {
    539593                                                                                                                                var aMatch  =  this.getValue().match( regexGetSizeOrEmpty );
     
    542596                                                                                                                                return !!aMatch;
    543597                                                                                                                        },
    544598                                                                                                                        setup : setupDimension,
    545                                                                                                                         commit : function( type, element )
     599                                                                                                                        commit : function( type, element, internalCommit )
    546600                                                                                                                        {
     601                                                                                                                                var value = this.getValue();
    547602                                                                                                                                if ( type == IMAGE )
    548603                                                                                                                                {
    549                                                                                                                                         var value = this.getValue();
    550604                                                                                                                                        if ( value )
    551                                                                                                                                                 element.setAttribute( 'width', value );
    552                                                                                                                                         else if ( !value && this.isChanged() )
    553                                                                                                                                                 element.removeAttribute( 'width' );
     605                                                                                                                                                element.setStyle( 'width', CKEDITOR.tools.cssLength( value ) );
     606                                                                                                                                        else if ( !value && this.isChanged( ) )
     607                                                                                                                                                element.removeStyle( 'width' );
     608
     609                                                                                                                                        !internalCommit && element.removeAttribute( 'width' );
    554610                                                                                                                                }
    555611                                                                                                                                else if ( type == PREVIEW )
    556612                                                                                                                                {
    557                                                                                                                                         value = this.getValue();
    558613                                                                                                                                        var aMatch = value.match( regexGetSize );
    559614                                                                                                                                        if ( !aMatch )
    560615                                                                                                                                        {
     
    567622                                                                                                                                }
    568623                                                                                                                                else if ( type == CLEANUP )
    569624                                                                                                                                {
    570                                                                                                                                         element.setStyle( 'width', '0px' );     // If removeAttribute doesn't work.
    571625                                                                                                                                        element.removeAttribute( 'width' );
    572626                                                                                                                                        element.removeStyle( 'width' );
    573627                                                                                                                                }
     
    579633                                                                                                                        width: '40px',
    580634                                                                                                                        labelLayout : 'horizontal',
    581635                                                                                                                        label : editor.lang.image.height,
    582                                                                                                                         onKeyUp : onSizeChange,
     636                                                                                                                        onKeyUp : function()
     637                                                                                                                        {
     638                                                                                                                                onSizeChange.apply( this, arguments );
     639                                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
     640                                                                                                                        },
    583641                                                                                                                        validate: function()
    584642                                                                                                                        {
    585643                                                                                                                                var aMatch = this.getValue().match( regexGetSizeOrEmpty );
     
    588646                                                                                                                                return !!aMatch;
    589647                                                                                                                        },
    590648                                                                                                                        setup : setupDimension,
    591                                                                                                                         commit : function( type, element )
     649                                                                                                                        commit : function( type, element, internalCommit )
    592650                                                                                                                        {
     651                                                                                                                                var value = this.getValue();
    593652                                                                                                                                if ( type == IMAGE )
    594653                                                                                                                                {
    595                                                                                                                                         var value = this.getValue();
    596654                                                                                                                                        if ( value )
    597                                                                                                                                                 element.setAttribute( 'height', value );
    598                                                                                                                                         else if ( !value && this.isChanged() )
     655                                                                                                                                                element.setStyle( 'height', CKEDITOR.tools.cssLength( value ) );
     656                                                                                                                                        else if ( !value && this.isChanged( ) )
     657                                                                                                                                                element.removeStyle( 'height' );
     658                                                                                                                                       
     659                                                                                                                                        if( !internalCommit && type == IMAGE )
    599660                                                                                                                                                element.removeAttribute( 'height' );
    600661                                                                                                                                }
    601662                                                                                                                                else if ( type == PREVIEW )
    602663                                                                                                                                {
    603                                                                                                                                         value = this.getValue();
    604664                                                                                                                                        var aMatch = value.match( regexGetSize );
    605665                                                                                                                                        if ( !aMatch )
    606666                                                                                                                                        {
    607667                                                                                                                                                var oImageOriginal = this.getDialog().originalElement;
    608668                                                                                                                                                if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' )
    609                                                                                                                                                         element.setStyle( 'height',  oImageOriginal.$.height + 'px');
     669                                                                                                                                                        element.setStyle( 'height', oImageOriginal.$.height + 'px' );
    610670                                                                                                                                        }
    611671                                                                                                                                        else
    612                                                                                                                                                 element.setStyle( 'height', value + 'px');
     672                                                                                                                                                element.setStyle( 'height', value + 'px' );
    613673                                                                                                                                }
    614674                                                                                                                                else if ( type == CLEANUP )
    615675                                                                                                                                {
    616                                                                                                                                         element.setStyle( 'height', '0px' );    // If removeAttribute doesn't work.
    617676                                                                                                                                        element.removeAttribute( 'height' );
    618677                                                                                                                                        element.removeStyle( 'height' );
    619678                                                                                                                                }
     
    697756                                                                                                        onKeyUp : function()
    698757                                                                                                        {
    699758                                                                                                                updatePreview( this.getDialog() );
     759                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
    700760                                                                                                        },
    701761                                                                                                        validate: function()
    702762                                                                                                        {
     
    706766                                                                                                        setup : function( type, element )
    707767                                                                                                        {
    708768                                                                                                                if ( type == IMAGE )
    709                                                                                                                         this.setValue( element.getAttribute( 'border' ) );
     769                                                                                                                {
     770                                                                                                                        var value,
     771                                                                                                                                borderStyle = element.getStyle( 'border-width' );
     772
     773                                                                                                                        borderStyle = borderStyle && borderStyle.match( /^(\d+px)(?: \1 \1 \1)?$/ );
     774                                                                                                                        value = borderStyle && parseInt( borderStyle[ 1 ] );
     775                                                                                                                        !value && ( value = element.getAttribute( 'border' ) );
     776
     777                                                                                                                        this.setValue( value );
     778                                                                                                                }
    710779                                                                                                        },
    711                                                                                                         commit : function( type, element )
     780                                                                                                        commit : function( type, element, internalCommit )
    712781                                                                                                        {
    713                                                                                                                 if ( type == IMAGE )
     782                                                                                                                var value = parseInt( this.getValue() );
     783                                                                                                                if ( type == IMAGE || type == PREVIEW )
    714784                                                                                                                {
    715                                                                                                                         if ( this.getValue() || this.isChanged() )
    716                                                                                                                                 element.setAttribute( 'border', this.getValue() );
    717                                                                                                                 }
    718                                                                                                                 else if ( type == PREVIEW )
    719                                                                                                                 {
    720                                                                                                                         var value = parseInt( this.getValue(), 10 );
    721                                                                                                                         value = isNaN( value ) ? 0 : value;
    722                                                                                                                         element.setAttribute( 'border', value );
    723                                                                                                                         element.setStyle( 'border', value + 'px solid black' );
    724                                                                                                                 }
     785                                                                                                                        if ( value )
     786                                                                                                                                element.setStyle( 'border', CKEDITOR.tools.cssLength( value ) + ' solid' );
     787                                                                                                                        else if ( !value && this.isChanged() )
     788                                                                                                                        {
     789                                                                                                                                if( CKEDITOR.env.ie )
     790                                                                                                                                {
     791                                                                                                                                        element.removeStyle( 'border-width' );
     792                                                                                                                                        element.removeStyle( 'border-style' );
     793                                                                                                                                        element.removeStyle( 'border-color' );
     794                                                                                                                                }
     795                                                                                                                                else
     796                                                                                                                                        element.removeStyle( 'border' );
     797                                                                                                                        }
     798
     799                                                                                                                        if( !internalCommit && type == IMAGE )
     800                                                                                                                                element.removeAttribute( 'border' );
     801                                                                                                                }
    725802                                                                                                                else if ( type == CLEANUP )
    726803                                                                                                                {
    727804                                                                                                                        element.removeAttribute( 'border' );
     
    739816                                                                                                        onKeyUp : function()
    740817                                                                                                        {
    741818                                                                                                                updatePreview( this.getDialog() );
     819                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
    742820                                                                                                        },
    743821                                                                                                        validate: function()
    744822                                                                                                        {
     
    749827                                                                                                        {
    750828                                                                                                                if ( type == IMAGE )
    751829                                                                                                                {
    752                                                                                                                         var value = element.getAttribute( 'hspace' );
    753                                                                                                                         if ( value != -1 )                              // In IE empty = -1.
    754                                                                                                                                 this.setValue( value );
     830                                                                                                                        var value,
     831                                                                                                                                marginLeftPx,
     832                                                                                                                                marginRightPx,
     833                                                                                                                                marginLeftStyle = element.getStyle( 'margin-left' ),
     834                                                                                                                                marginRightStyle = element.getStyle( 'margin-right' );
     835
     836                                                                                                                        marginLeftStyle = marginLeftStyle && marginLeftStyle.match( pxLengthRegex );
     837                                                                                                                        marginRightStyle = marginRightStyle && marginRightStyle.match( pxLengthRegex );
     838                                                                                                                        marginLeftPx = parseInt( marginLeftStyle );
     839                                                                                                                        marginRightPx = parseInt( marginRightStyle );
     840
     841                                                                                                                        value = ( marginLeftPx == marginRightPx ) && marginLeftPx;
     842                                                                                                                        !value && ( value = element.getAttribute( 'hspace' ) );
     843
     844                                                                                                                        this.setValue( value );
    755845                                                                                                                }
    756846                                                                                                        },
    757                                                                                                         commit : function( type, element )
     847                                                                                                        commit : function( type, element, internalCommit )
    758848                                                                                                        {
    759                                                                                                                 if ( type == IMAGE )
     849                                                                                                                var value = parseInt( this.getValue() );
     850                                                                                                                if ( type == IMAGE || type == PREVIEW )
    760851                                                                                                                {
    761                                                                                                                         if ( this.getValue() || this.isChanged() )
    762                                                                                                                                 element.setAttribute( 'hspace', this.getValue() );
    763                                                                                                                 }
    764                                                                                                                 else if ( type == PREVIEW )
    765                                                                                                                 {
    766                                                                                                                         var value = parseInt( this.getValue(), 10 );
    767                                                                                                                         value = isNaN( value ) ? 0 : value;
    768                                                                                                                         element.setAttribute( 'hspace', value );
    769                                                                                                                         element.setStyle( 'margin-left', value + 'px' );
    770                                                                                                                         element.setStyle( 'margin-right', value + 'px' );
    771                                                                                                                 }
     852                                                                                                                        if ( value )
     853                                                                                                                        {
     854                                                                                                                                element.setStyle( 'margin-left', CKEDITOR.tools.cssLength( value ) );
     855                                                                                                                                element.setStyle( 'margin-right', CKEDITOR.tools.cssLength( value ) );
     856                                                                                                                        }
     857                                                                                                                        else if ( !value && this.isChanged( ) )
     858                                                                                                                        {
     859                                                                                                                                element.removeStyle( 'margin-left' );
     860                                                                                                                                element.removeStyle( 'margin-right' );
     861                                                                                                                        }
     862
     863                                                                                                                        if( !internalCommit && type == IMAGE )
     864                                                                                                                                element.removeAttribute( 'hspace' );
     865                                                                                                                }
    772866                                                                                                                else if ( type == CLEANUP )
    773867                                                                                                                {
    774868                                                                                                                        element.removeAttribute( 'hspace' );
     
    787881                                                                                                        onKeyUp : function()
    788882                                                                                                        {
    789883                                                                                                                updatePreview( this.getDialog() );
     884                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
    790885                                                                                                        },
    791886                                                                                                        validate: function()
    792887                                                                                                        {
     
    796891                                                                                                        setup : function( type, element )
    797892                                                                                                        {
    798893                                                                                                                if ( type == IMAGE )
    799                                                                                                                         this.setValue( element.getAttribute( 'vspace' ) );
     894                                                                                                                {
     895                                                                                                                        var value,
     896                                                                                                                                marginTopPx,
     897                                                                                                                                marginBottomPx,
     898                                                                                                                                marginTopStyle = element.getStyle( 'margin-top' ),
     899                                                                                                                                marginBottomStyle = element.getStyle( 'margin-bottom' );
     900
     901                                                                                                                        marginTopStyle = marginTopStyle && marginTopStyle.match( pxLengthRegex );
     902                                                                                                                        marginBottomStyle = marginBottomStyle && marginBottomStyle.match( pxLengthRegex );
     903                                                                                                                        marginTopPx = parseInt( marginTopStyle );
     904                                                                                                                        marginBottomPx = parseInt( marginBottomStyle );
     905
     906                                                                                                                        value = ( marginTopPx == marginBottomPx ) && marginTopPx;
     907                                                                                                                        !value && ( value = element.getAttribute( 'vspace' ) );
     908                                                                                                                        this.setValue( value );
     909                                                                                                                }
    800910                                                                                                        },
    801                                                                                                         commit : function( type, element )
     911                                                                                                        commit : function( type, element, internalCommit )
    802912                                                                                                        {
    803                                                                                                                 if ( type == IMAGE )
     913                                                                                                                var value = parseInt( this.getValue() );
     914                                                                                                                if ( type == IMAGE || type == PREVIEW )
    804915                                                                                                                {
    805                                                                                                                         if ( this.getValue() || this.isChanged() )
    806                                                                                                                                 element.setAttribute( 'vspace', this.getValue() );
    807                                                                                                                 }
    808                                                                                                                 else if ( type == PREVIEW )
    809                                                                                                                 {
    810                                                                                                                         var value = parseInt( this.getValue(), 10 );
    811                                                                                                                         value = isNaN( value ) ? 0 : value;
    812                                                                                                                         element.setAttribute( 'vspace', this.getValue() );
    813                                                                                                                         element.setStyle( 'margin-top', value + 'px' );
    814                                                                                                                         element.setStyle( 'margin-bottom', value + 'px' );
    815                                                                                                                 }
     916                                                                                                                        if ( value )
     917                                                                                                                        {
     918                                                                                                                                element.setStyle( 'margin-top', CKEDITOR.tools.cssLength( value ) );
     919                                                                                                                                element.setStyle( 'margin-bottom', CKEDITOR.tools.cssLength( value ) );
     920                                                                                                                        }
     921                                                                                                                        else if ( !value && this.isChanged( ) )
     922                                                                                                                        {
     923                                                                                                                                element.removeStyle( 'margin-top' );
     924                                                                                                                                element.removeStyle( 'margin-bottom' );
     925                                                                                                                        }
     926
     927                                                                                                                        if( !internalCommit && type == IMAGE )
     928                                                                                                                                element.removeAttribute( 'vspace' );
     929                                                                                                                }
    816930                                                                                                                else if ( type == CLEANUP )
    817931                                                                                                                {
    818932                                                                                                                        element.removeAttribute( 'vspace' );
     
    833947                                                                                                        [
    834948                                                                                                                [ editor.lang.common.notSet , ''],
    835949                                                                                                                [ editor.lang.image.alignLeft , 'left'],
    836                                                                                                                 [ editor.lang.image.alignAbsBottom , 'absBottom'],
    837                                                                                                                 [ editor.lang.image.alignAbsMiddle , 'absMiddle'],
    838                                                                                                                 [ editor.lang.image.alignBaseline , 'baseline'],
    839                                                                                                                 [ editor.lang.image.alignBottom , 'bottom'],
    840                                                                                                                 [ editor.lang.image.alignMiddle , 'middle'],
    841950                                                                                                                [ editor.lang.image.alignRight , 'right'],
    842                                                                                                                 [ editor.lang.image.alignTextTop , 'textTop'],
    843                                                                                                                 [ editor.lang.image.alignTop , 'top']
     951                                                                                                                // Backward compatible with v2 on setup when specified as attribute value,
     952                                                                                                                // while these values are no more available as select options.
     953                                                                                                                //      [ editor.lang.image.alignAbsBottom , 'absBottom'],
     954                                                                                                                //      [ editor.lang.image.alignAbsMiddle , 'absMiddle'],
     955                                                                                                                //  [ editor.lang.image.alignBaseline , 'baseline'],
     956                                                                                                                //  [ editor.lang.image.alignTextTop , 'text-top'],
     957                                                                                                                //  [ editor.lang.image.alignBottom , 'bottom'],
     958                                                                                                                //  [ editor.lang.image.alignMiddle , 'middle'],
     959                                                                                                                //  [ editor.lang.image.alignTop , 'top']
    844960                                                                                                        ],
    845961                                                                                                        onChange : function()
    846962                                                                                                        {
    847963                                                                                                                updatePreview( this.getDialog() );
     964                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
    848965                                                                                                        },
    849966                                                                                                        setup : function( type, element )
    850967                                                                                                        {
    851968                                                                                                                if ( type == IMAGE )
    852                                                                                                                         this.setValue( element.getAttribute( 'align' ) );
    853                                                                                                         },
    854                                                                                                         commit : function( type, element )
    855                                                                                                         {
    856                                                                                                                 var value = this.getValue();
    857                                                                                                                 if ( type == IMAGE )
    858                                                                                                                 {
    859                                                                                                                         if ( value || this.isChanged() )
    860                                                                                                                                 element.setAttribute( 'align', value );
    861                                                                                                                 }
    862                                                                                                                 else if ( type == PREVIEW )
    863                                                                                                                 {
    864                                                                                                                         element.setAttribute( 'align', this.getValue() );
     969                                                                                                                {
     970                                                                                                                        var value = element.getStyle( 'float' );
     971                                                                                                                        switch( value )
     972                                                                                                                        {
     973                                                                                                                                // Ignore those unrelated values.
     974                                                                                                                                case 'inherit':
     975                                                                                                                                case 'none':
     976                                                                                                                                        value = '';
     977                                                                                                                        }
    865978
    866                                                                                                                         if ( value == 'absMiddle' || value == 'middle' )
    867                                                                                                                                 element.setStyle( 'vertical-align', 'middle' );
    868                                                                                                                         else if ( value == 'top' || value == 'textTop' )
    869                                                                                                                                 element.setStyle( 'vertical-align', 'top' );
    870                                                                                                                         else
    871                                                                                                                                 element.removeStyle( 'vertical-align' );
    872 
    873                                                                                                                         if ( value == 'right' || value == 'left' )
    874                                                                                                                                 element.setStyle( 'styleFloat', value );
    875                                                                                                                         else
    876                                                                                                                                 element.removeStyle( 'styleFloat' );
    877 
     979                                                                                                                        !value && ( value = ( element.getAttribute( 'align' ) || '' ).toLowerCase() );
     980                                                                                                                        this.setValue( value );
    878981                                                                                                                }
    879                                                                                                                 else if ( type == CLEANUP )
    880                                                                                                                 {
    881                                                                                                                         element.removeAttribute( 'align' );
    882                                                                                                                 }
    883                                                                                                         }
    884                                                                                                 }
     982                                                                                                        },
     983                                                                                                        commit : function( type, element, internalCommit )
     984                                                                                                        {
     985                                                                                                                var value = this.getValue();
     986                                                                                                                if ( type == IMAGE || type == PREVIEW )
     987                                                                                                                {
     988                                                                                                                        if ( value )
     989                                                                                                                                element.setStyle( 'float', value );
     990                                                                                                                        else if ( !value && this.isChanged( ) )
     991                                                                                                                                element.removeStyle( 'float' );
     992
     993                                                                                                                        if( !internalCommit && type == IMAGE )
     994                                                                                                                        {
     995                                                                                                                                value = ( element.getAttribute( 'align' ) || '' ).toLowerCase();
     996                                                                                                                                switch( value )
     997                                                                                                                                {
     998                                                                                                                                        // we should remove it only if it matches "left" or "right",
     999                                                                                                                                        // otherwise leave it intact.
     1000                                                                                                                                        case 'left':
     1001                                                                                                                                        case 'right':
     1002                                                                                                                                                element.removeAttribute( 'align' );
     1003                                                                                                                                }
     1004                                                                                                                        }
     1005                                                                                                                }
     1006                                                                                                                else if ( type == CLEANUP )
     1007                                                                                                                        element.removeStyle( 'float' );
     1008
     1009                                                                                                        }
     1010                                                                                                }
    8851011                                                                                        ]
    8861012                                                                                }
    8871013                                                                        ]
     
    11831309                                                                        };
    11841310                                                                }
    11851311                                                        },
     1312                                                        onKeyUp : function ()
     1313                                                        {
     1314                                                                commitInternally.call( this,
     1315                                                                        [ 'info:cmbFloat', 'info:cmbAlign',
     1316                                                                          'info:txtVSpace', 'info:txtHSpace',
     1317                                                                          'info:txtBorder',
     1318                                                                          'info:txtWidth', 'info:txtHeight' ] );
     1319                                                        },
    11861320                                                        commit : function( type, element )
    11871321                                                        {
    11881322                                                                if ( type == IMAGE && ( this.getValue() || this.isChanged() ) )
    11891323                                                                {
    11901324                                                                        element.setAttribute( 'style', this.getValue() );
    1191 
    1192                                                                         // Set STYLE dimensions.
    1193                                                                         var height = element.getAttribute( 'height' ),
    1194                                                                                 width = element.getAttribute( 'width' );
    1195 
    1196                                                                         if ( this.attributesInStyle && this.attributesInStyle.height )
    1197                                                                         {
    1198                                                                                 if ( height )
    1199                                                                                 {
    1200                                                                                         if ( height.match( regexGetSize )[2] == '%' )                   // % is allowed
    1201                                                                                                 element.setStyle( 'height', height + '%' );
    1202                                                                                         else
    1203                                                                                                 element.setStyle( 'height', height + 'px' );
    1204                                                                                 }
    1205                                                                                 else
    1206                                                                                         element.removeStyle( 'height' );
    1207                                                                         }
    1208                                                                         if ( this.attributesInStyle && this.attributesInStyle.width )
    1209                                                                         {
    1210                                                                                 if ( width )
    1211                                                                                 {
    1212                                                                                         if ( width.match( regexGetSize )[2] == '%' )                    // % is allowed
    1213                                                                                                 element.setStyle( 'width', width + '%' );
    1214                                                                                         else
    1215                                                                                                 element.setStyle( 'width', width + 'px' );
    1216                                                                                 }
    1217                                                                                 else
    1218                                                                                         element.removeStyle( 'width' );
    1219                                                                         }
    1220                                                                 }
    1221                                                         }
    1222                                                 }
     1325                                                                }
     1326                                                        }
     1327                                                }
    12231328                                        ]
    12241329                                }
    12251330                        ]
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy