Ticket #4246: 4246_5.patch

File 4246_5.patch, 24.2 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,
     
    105137                var oImageOriginal = dialog.originalElement;
    106138                if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' )
    107139                {
    108                         dialog.setValueOf( 'info', 'txtWidth', oImageOriginal.$.width );
    109                         dialog.setValueOf( 'info', 'txtHeight', oImageOriginal.$.height );
     140                        var widthField = dialog.getContentElement( 'info', 'txtWidth' ),
     141                                heightField = dialog.getContentElement( 'info', 'txtHeight' );
     142
     143                        widthField.setValue( oImageOriginal.$.width );
     144                        heightField.setValue( oImageOriginal.$.height );
     145                        commitInternally.call( widthField, 'advanced:txtdlgGenStyle' );
     146                        commitInternally.call( heightField, 'advanced:txtdlgGenStyle' );
    110147                }
    111148                updatePreview( dialog );
    112149        };
     
    138175
    139176                if ( size )
    140177                        value = checkDimension( size, value );
    141                 value = checkDimension( element.$.style[ dimension ], value );
     178                value = checkDimension( element.getStyle( dimension ), value );
    142179
    143180                this.setValue( value );
    144181        };
     
    242279                                                this.setupContent( LINK, link );
    243280                                }
    244281
    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 )
     282                                if ( element && element.getName() == 'img' && !element.getAttribute( '_cke_realelement' )
     283                                        || element && element.getName() == 'input' && element.getAttribute( 'type' ) == 'image' )
    251284                                {
    252                                         if ( !this.imageElement )
    253                                                 this.imageElement = element;
     285                                        this.imageEditMode = element.getName();
     286                                        this.imageElement = element;
     287                                }
    254288
     289                                if ( this.imageEditMode )
     290                                {
     291                                        // Use the original element as a buffer from  since we don't want
     292                                        // temporary changes to be committed, e.g. if the dialog is canceled.
     293                                        this.cleanImageElement = this.imageElement;
     294                                        this.imageElement = this.cleanImageElement.clone( true, true );
     295
    255296                                        // Fill out all fields.
    256297                                        this.setupContent( IMAGE, this.imageElement );
    257298
    258299                                        // Refresh LockRatio button
    259300                                        switchLockRatio ( this, true );
    260301                                }
     302                                else
     303                                        this.imageElement =  editor.document.createElement( 'img' );
    261304
    262305                                // Dont show preview if no URL given.
    263306                                if ( !CKEDITOR.tools.trim( this.getValueOf( 'info', 'txtUrl' ) ) )
     
    296339                                                );
    297340                                                editor.insertElement( this.imageElement );
    298341                                        }
    299                                 }
     342                                        else
     343                                        {
     344                                                // Restore the original element before all commits.
     345                                                this.imageElement = this.cleanImageElement;
     346                                                delete this.cleanImageElement;
     347                                        }
     348                                }
    300349                                else    // Create a new image.
    301350                                {
    302351                                        // Image dialog -> create IMG element.
     
    318367                                this.commitContent( IMAGE, this.imageElement );
    319368                                this.commitContent( LINK, this.linkElement );
    320369
     370                                // Remove empty style attribute.
     371                                if( !this.imageElement.getAttribute( 'style' ) )
     372                                        this.imageElement.removeAttribute( 'style' );
     373
    321374                                // Insert a new Image.
    322375                                if ( !this.imageEditMode )
    323376                                {
     
    372425                                        this.originalElement.remove();
    373426                                        this.originalElement = false;           // Dialog is closed.
    374427                                }
     428
     429                                delete this.imageElement;
    375430                        },
    376431                        contents : [
    377432                                {
     
    533588                                                                                                                        id : 'txtWidth',
    534589                                                                                                                        labelLayout : 'horizontal',
    535590                                                                                                                        label : editor.lang.image.width,
    536                                                                                                                         onKeyUp : onSizeChange,
     591                                                                                                                        onKeyUp : function()
     592                                                                                                                        {
     593                                                                                                                                onSizeChange.apply( this, arguments );
     594                                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
     595                                                                                                                        },
    537596                                                                                                                        validate: function()
    538597                                                                                                                        {
    539598                                                                                                                                var aMatch  =  this.getValue().match( regexGetSizeOrEmpty );
     
    542601                                                                                                                                return !!aMatch;
    543602                                                                                                                        },
    544603                                                                                                                        setup : setupDimension,
    545                                                                                                                         commit : function( type, element )
     604                                                                                                                        commit : function( type, element, internalCommit )
    546605                                                                                                                        {
     606                                                                                                                                var value = this.getValue();
    547607                                                                                                                                if ( type == IMAGE )
    548608                                                                                                                                {
    549                                                                                                                                         var value = this.getValue();
    550609                                                                                                                                        if ( value )
    551                                                                                                                                                 element.setAttribute( 'width', value );
    552                                                                                                                                         else if ( !value && this.isChanged() )
    553                                                                                                                                                 element.removeAttribute( 'width' );
     610                                                                                                                                                element.setStyle( 'width', CKEDITOR.tools.cssLength( value ) );
     611                                                                                                                                        else if ( !value && this.isChanged( ) )
     612                                                                                                                                                element.removeStyle( 'width' );
     613
     614                                                                                                                                        !internalCommit && element.removeAttribute( 'width' );
    554615                                                                                                                                }
    555616                                                                                                                                else if ( type == PREVIEW )
    556617                                                                                                                                {
    557                                                                                                                                         value = this.getValue();
    558618                                                                                                                                        var aMatch = value.match( regexGetSize );
    559619                                                                                                                                        if ( !aMatch )
    560620                                                                                                                                        {
     
    567627                                                                                                                                }
    568628                                                                                                                                else if ( type == CLEANUP )
    569629                                                                                                                                {
    570                                                                                                                                         element.setStyle( 'width', '0px' );     // If removeAttribute doesn't work.
    571630                                                                                                                                        element.removeAttribute( 'width' );
    572631                                                                                                                                        element.removeStyle( 'width' );
    573632                                                                                                                                }
     
    579638                                                                                                                        width: '40px',
    580639                                                                                                                        labelLayout : 'horizontal',
    581640                                                                                                                        label : editor.lang.image.height,
    582                                                                                                                         onKeyUp : onSizeChange,
     641                                                                                                                        onKeyUp : function()
     642                                                                                                                        {
     643                                                                                                                                onSizeChange.apply( this, arguments );
     644                                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
     645                                                                                                                        },
    583646                                                                                                                        validate: function()
    584647                                                                                                                        {
    585648                                                                                                                                var aMatch = this.getValue().match( regexGetSizeOrEmpty );
     
    588651                                                                                                                                return !!aMatch;
    589652                                                                                                                        },
    590653                                                                                                                        setup : setupDimension,
    591                                                                                                                         commit : function( type, element )
     654                                                                                                                        commit : function( type, element, internalCommit )
    592655                                                                                                                        {
     656                                                                                                                                var value = this.getValue();
    593657                                                                                                                                if ( type == IMAGE )
    594658                                                                                                                                {
    595                                                                                                                                         var value = this.getValue();
    596659                                                                                                                                        if ( value )
    597                                                                                                                                                 element.setAttribute( 'height', value );
    598                                                                                                                                         else if ( !value && this.isChanged() )
     660                                                                                                                                                element.setStyle( 'height', CKEDITOR.tools.cssLength( value ) );
     661                                                                                                                                        else if ( !value && this.isChanged( ) )
     662                                                                                                                                                element.removeStyle( 'height' );
     663                                                                                                                                       
     664                                                                                                                                        if( !internalCommit && type == IMAGE )
    599665                                                                                                                                                element.removeAttribute( 'height' );
    600666                                                                                                                                }
    601667                                                                                                                                else if ( type == PREVIEW )
    602668                                                                                                                                {
    603                                                                                                                                         value = this.getValue();
    604669                                                                                                                                        var aMatch = value.match( regexGetSize );
    605670                                                                                                                                        if ( !aMatch )
    606671                                                                                                                                        {
    607672                                                                                                                                                var oImageOriginal = this.getDialog().originalElement;
    608673                                                                                                                                                if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' )
    609                                                                                                                                                         element.setStyle( 'height',  oImageOriginal.$.height + 'px');
     674                                                                                                                                                        element.setStyle( 'height', oImageOriginal.$.height + 'px' );
    610675                                                                                                                                        }
    611676                                                                                                                                        else
    612                                                                                                                                                 element.setStyle( 'height', value + 'px');
     677                                                                                                                                                element.setStyle( 'height', value + 'px' );
    613678                                                                                                                                }
    614679                                                                                                                                else if ( type == CLEANUP )
    615680                                                                                                                                {
    616                                                                                                                                         element.setStyle( 'height', '0px' );    // If removeAttribute doesn't work.
    617681                                                                                                                                        element.removeAttribute( 'height' );
    618682                                                                                                                                        element.removeStyle( 'height' );
    619683                                                                                                                                }
     
    697761                                                                                                        onKeyUp : function()
    698762                                                                                                        {
    699763                                                                                                                updatePreview( this.getDialog() );
     764                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
    700765                                                                                                        },
    701766                                                                                                        validate: function()
    702767                                                                                                        {
     
    706771                                                                                                        setup : function( type, element )
    707772                                                                                                        {
    708773                                                                                                                if ( type == IMAGE )
    709                                                                                                                         this.setValue( element.getAttribute( 'border' ) );
     774                                                                                                                {
     775                                                                                                                        var value,
     776                                                                                                                                borderStyle = element.getStyle( 'border-width' );
     777
     778                                                                                                                        borderStyle = borderStyle && borderStyle.match( /^(\d+px)(?: \1 \1 \1)?$/ );
     779                                                                                                                        value = borderStyle && parseInt( borderStyle[ 1 ] );
     780                                                                                                                        !value && ( value = element.getAttribute( 'border' ) );
     781
     782                                                                                                                        this.setValue( value );
     783                                                                                                                }
    710784                                                                                                        },
    711                                                                                                         commit : function( type, element )
     785                                                                                                        commit : function( type, element, internalCommit )
    712786                                                                                                        {
    713                                                                                                                 if ( type == IMAGE )
     787                                                                                                                var value = parseInt( this.getValue() );
     788                                                                                                                if ( type == IMAGE || type == PREVIEW )
    714789                                                                                                                {
    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                                                                                                                 }
     790                                                                                                                        if ( value )
     791                                                                                                                                element.setStyle( 'border', CKEDITOR.tools.cssLength( value ) + ' solid' );
     792                                                                                                                        else if ( !value && this.isChanged() )
     793                                                                                                                        {
     794                                                                                                                                if( CKEDITOR.env.ie )
     795                                                                                                                                {
     796                                                                                                                                        element.removeStyle( 'border-width' );
     797                                                                                                                                        element.removeStyle( 'border-style' );
     798                                                                                                                                        element.removeStyle( 'border-color' );
     799                                                                                                                                }
     800                                                                                                                                else
     801                                                                                                                                        element.removeStyle( 'border' );
     802                                                                                                                        }
     803
     804                                                                                                                        if( !internalCommit && type == IMAGE )
     805                                                                                                                                element.removeAttribute( 'border' );
     806                                                                                                                }
    725807                                                                                                                else if ( type == CLEANUP )
    726808                                                                                                                {
    727809                                                                                                                        element.removeAttribute( 'border' );
     
    739821                                                                                                        onKeyUp : function()
    740822                                                                                                        {
    741823                                                                                                                updatePreview( this.getDialog() );
     824                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
    742825                                                                                                        },
    743826                                                                                                        validate: function()
    744827                                                                                                        {
     
    749832                                                                                                        {
    750833                                                                                                                if ( type == IMAGE )
    751834                                                                                                                {
    752                                                                                                                         var value = element.getAttribute( 'hspace' );
    753                                                                                                                         if ( value != -1 )                              // In IE empty = -1.
    754                                                                                                                                 this.setValue( value );
     835                                                                                                                        var value,
     836                                                                                                                                marginLeftPx,
     837                                                                                                                                marginRightPx,
     838                                                                                                                                marginLeftStyle = element.getStyle( 'margin-left' ),
     839                                                                                                                                marginRightStyle = element.getStyle( 'margin-right' );
     840
     841                                                                                                                        marginLeftStyle = marginLeftStyle && marginLeftStyle.match( pxLengthRegex );
     842                                                                                                                        marginRightStyle = marginRightStyle && marginRightStyle.match( pxLengthRegex );
     843                                                                                                                        marginLeftPx = parseInt( marginLeftStyle );
     844                                                                                                                        marginRightPx = parseInt( marginRightStyle );
     845
     846                                                                                                                        value = ( marginLeftPx == marginRightPx ) && marginLeftPx;
     847                                                                                                                        !value && ( value = element.getAttribute( 'hspace' ) );
     848
     849                                                                                                                        this.setValue( value );
    755850                                                                                                                }
    756851                                                                                                        },
    757                                                                                                         commit : function( type, element )
     852                                                                                                        commit : function( type, element, internalCommit )
    758853                                                                                                        {
    759                                                                                                                 if ( type == IMAGE )
     854                                                                                                                var value = parseInt( this.getValue() );
     855                                                                                                                if ( type == IMAGE || type == PREVIEW )
    760856                                                                                                                {
    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                                                                                                                 }
     857                                                                                                                        if ( value )
     858                                                                                                                        {
     859                                                                                                                                element.setStyle( 'margin-left', CKEDITOR.tools.cssLength( value ) );
     860                                                                                                                                element.setStyle( 'margin-right', CKEDITOR.tools.cssLength( value ) );
     861                                                                                                                        }
     862                                                                                                                        else if ( !value && this.isChanged( ) )
     863                                                                                                                        {
     864                                                                                                                                element.removeStyle( 'margin-left' );
     865                                                                                                                                element.removeStyle( 'margin-right' );
     866                                                                                                                        }
     867
     868                                                                                                                        if( !internalCommit && type == IMAGE )
     869                                                                                                                                element.removeAttribute( 'hspace' );
     870                                                                                                                }
    772871                                                                                                                else if ( type == CLEANUP )
    773872                                                                                                                {
    774873                                                                                                                        element.removeAttribute( 'hspace' );
     
    787886                                                                                                        onKeyUp : function()
    788887                                                                                                        {
    789888                                                                                                                updatePreview( this.getDialog() );
     889                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
    790890                                                                                                        },
    791891                                                                                                        validate: function()
    792892                                                                                                        {
     
    796896                                                                                                        setup : function( type, element )
    797897                                                                                                        {
    798898                                                                                                                if ( type == IMAGE )
    799                                                                                                                         this.setValue( element.getAttribute( 'vspace' ) );
     899                                                                                                                {
     900                                                                                                                        var value,
     901                                                                                                                                marginTopPx,
     902                                                                                                                                marginBottomPx,
     903                                                                                                                                marginTopStyle = element.getStyle( 'margin-top' ),
     904                                                                                                                                marginBottomStyle = element.getStyle( 'margin-bottom' );
     905
     906                                                                                                                        marginTopStyle = marginTopStyle && marginTopStyle.match( pxLengthRegex );
     907                                                                                                                        marginBottomStyle = marginBottomStyle && marginBottomStyle.match( pxLengthRegex );
     908                                                                                                                        marginTopPx = parseInt( marginTopStyle );
     909                                                                                                                        marginBottomPx = parseInt( marginBottomStyle );
     910
     911                                                                                                                        value = ( marginTopPx == marginBottomPx ) && marginTopPx;
     912                                                                                                                        !value && ( value = element.getAttribute( 'vspace' ) );
     913                                                                                                                        this.setValue( value );
     914                                                                                                                }
    800915                                                                                                        },
    801                                                                                                         commit : function( type, element )
     916                                                                                                        commit : function( type, element, internalCommit )
    802917                                                                                                        {
    803                                                                                                                 if ( type == IMAGE )
     918                                                                                                                var value = parseInt( this.getValue() );
     919                                                                                                                if ( type == IMAGE || type == PREVIEW )
    804920                                                                                                                {
    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                                                                                                                 }
     921                                                                                                                        if ( value )
     922                                                                                                                        {
     923                                                                                                                                element.setStyle( 'margin-top', CKEDITOR.tools.cssLength( value ) );
     924                                                                                                                                element.setStyle( 'margin-bottom', CKEDITOR.tools.cssLength( value ) );
     925                                                                                                                        }
     926                                                                                                                        else if ( !value && this.isChanged( ) )
     927                                                                                                                        {
     928                                                                                                                                element.removeStyle( 'margin-top' );
     929                                                                                                                                element.removeStyle( 'margin-bottom' );
     930                                                                                                                        }
     931
     932                                                                                                                        if( !internalCommit && type == IMAGE )
     933                                                                                                                                element.removeAttribute( 'vspace' );
     934                                                                                                                }
    816935                                                                                                                else if ( type == CLEANUP )
    817936                                                                                                                {
    818937                                                                                                                        element.removeAttribute( 'vspace' );
     
    833952                                                                                                        [
    834953                                                                                                                [ editor.lang.common.notSet , ''],
    835954                                                                                                                [ 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'],
    841955                                                                                                                [ editor.lang.image.alignRight , 'right'],
    842                                                                                                                 [ editor.lang.image.alignTextTop , 'textTop'],
    843                                                                                                                 [ editor.lang.image.alignTop , 'top']
     956                                                                                                                // Backward compatible with v2 on setup when specified as attribute value,
     957                                                                                                                // while these values are no more available as select options.
     958                                                                                                                //      [ editor.lang.image.alignAbsBottom , 'absBottom'],
     959                                                                                                                //      [ editor.lang.image.alignAbsMiddle , 'absMiddle'],
     960                                                                                                                //  [ editor.lang.image.alignBaseline , 'baseline'],
     961                                                                                                                //  [ editor.lang.image.alignTextTop , 'text-top'],
     962                                                                                                                //  [ editor.lang.image.alignBottom , 'bottom'],
     963                                                                                                                //  [ editor.lang.image.alignMiddle , 'middle'],
     964                                                                                                                //  [ editor.lang.image.alignTop , 'top']
    844965                                                                                                        ],
    845966                                                                                                        onChange : function()
    846967                                                                                                        {
    847968                                                                                                                updatePreview( this.getDialog() );
     969                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
    848970                                                                                                        },
    849971                                                                                                        setup : function( type, element )
    850972                                                                                                        {
    851973                                                                                                                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() );
     974                                                                                                                {
     975                                                                                                                        var value = element.getStyle( 'float' );
     976                                                                                                                        switch( value )
     977                                                                                                                        {
     978                                                                                                                                // Ignore those unrelated values.
     979                                                                                                                                case 'inherit':
     980                                                                                                                                case 'none':
     981                                                                                                                                        value = '';
     982                                                                                                                        }
    865983
    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 
     984                                                                                                                        !value && ( value = ( element.getAttribute( 'align' ) || '' ).toLowerCase() );
     985                                                                                                                        this.setValue( value );
    878986                                                                                                                }
    879                                                                                                                 else if ( type == CLEANUP )
    880                                                                                                                 {
    881                                                                                                                         element.removeAttribute( 'align' );
    882                                                                                                                 }
    883                                                                                                         }
    884                                                                                                 }
     987                                                                                                        },
     988                                                                                                        commit : function( type, element, internalCommit )
     989                                                                                                        {
     990                                                                                                                var value = this.getValue();
     991                                                                                                                if ( type == IMAGE || type == PREVIEW )
     992                                                                                                                {
     993                                                                                                                        if ( value )
     994                                                                                                                                element.setStyle( 'float', value );
     995                                                                                                                        else if ( !value && this.isChanged( ) )
     996                                                                                                                                element.removeStyle( 'float' );
     997
     998                                                                                                                        if( !internalCommit && type == IMAGE )
     999                                                                                                                        {
     1000                                                                                                                                value = ( element.getAttribute( 'align' ) || '' ).toLowerCase();
     1001                                                                                                                                switch( value )
     1002                                                                                                                                {
     1003                                                                                                                                        // we should remove it only if it matches "left" or "right",
     1004                                                                                                                                        // otherwise leave it intact.
     1005                                                                                                                                        case 'left':
     1006                                                                                                                                        case 'right':
     1007                                                                                                                                                element.removeAttribute( 'align' );
     1008                                                                                                                                }
     1009                                                                                                                        }
     1010                                                                                                                }
     1011                                                                                                                else if ( type == CLEANUP )
     1012                                                                                                                        element.removeStyle( 'float' );
     1013
     1014                                                                                                        }
     1015                                                                                                }
    8851016                                                                                        ]
    8861017                                                                                }
    8871018                                                                        ]
     
    11831314                                                                        };
    11841315                                                                }
    11851316                                                        },
     1317                                                        onKeyUp : function ()
     1318                                                        {
     1319                                                                commitInternally.call( this,
     1320                                                                        [ 'info:cmbFloat', 'info:cmbAlign',
     1321                                                                          'info:txtVSpace', 'info:txtHSpace',
     1322                                                                          'info:txtBorder',
     1323                                                                          'info:txtWidth', 'info:txtHeight' ] );
     1324                                                        },
    11861325                                                        commit : function( type, element )
    11871326                                                        {
    11881327                                                                if ( type == IMAGE && ( this.getValue() || this.isChanged() ) )
    11891328                                                                {
    11901329                                                                        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                                                 }
     1330                                                                }
     1331                                                        }
     1332                                                }
    12231333                                        ]
    12241334                                }
    12251335                        ]
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy