Ticket #4246: 4246_3.patch

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

     
    428428                                                        return this.$.checked;
    429429                                                        break;
    430430
     431                                                case 'hspace':
     432                                                        return this.$.hspace;
     433
    431434                                                case 'style':
    432435                                                        // IE does not return inline styles via getAttribute(). See #2947.
    433436                                                        return this.$.style.cssText;
     
    988991                 */
    989992                removeStyle : function( name )
    990993                {
    991                         if ( this.$.style.removeAttribute )
    992                                 this.$.style.removeAttribute( CKEDITOR.tools.cssStyleToDomStyle( name ) );
    993                         else
    994                                 this.setStyle( name, '' );
     994                        this.setStyle( name, '' );
    995995
    996996                        if ( !this.$.style.cssText )
    997997                                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                                {
     
    539589                                                                                                                        labelLayout : 'horizontal',
    540590                                                                                                                        label : editor.lang.image.width,
    541591                                                                                                                        onKeyUp : onSizeChange,
     592                                                                                                                        onChange : function()
     593                                                                                                                        {
     594                                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
     595                                                                                                                        },
    542596                                                                                                                        validate: function()
    543597                                                                                                                        {
    544598                                                                                                                                var aMatch  =  this.getValue().match( regexGetSizeOrEmpty );
     
    547601                                                                                                                                return !!aMatch;
    548602                                                                                                                        },
    549603                                                                                                                        setup : setupDimension,
    550                                                                                                                         commit : function( type, element )
     604                                                                                                                        commit : function( type, element, internalCommit )
    551605                                                                                                                        {
     606                                                                                                                                var value = this.getValue();
    552607                                                                                                                                if ( type == IMAGE )
    553608                                                                                                                                {
    554                                                                                                                                         var value = this.getValue();
    555609                                                                                                                                        if ( value )
    556                                                                                                                                                 element.setAttribute( 'width', value );
    557                                                                                                                                         else if ( !value && this.isChanged() )
    558                                                                                                                                                 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' );
    559615                                                                                                                                }
    560616                                                                                                                                else if ( type == PREVIEW )
    561617                                                                                                                                {
    562                                                                                                                                         value = this.getValue();
    563618                                                                                                                                        var aMatch = value.match( regexGetSize );
    564619                                                                                                                                        if ( !aMatch )
    565620                                                                                                                                        {
     
    572627                                                                                                                                }
    573628                                                                                                                                else if ( type == CLEANUP )
    574629                                                                                                                                {
    575                                                                                                                                         element.setStyle( 'width', '0px' );     // If removeAttribute doesn't work.
    576630                                                                                                                                        element.removeAttribute( 'width' );
    577631                                                                                                                                        element.removeStyle( 'width' );
    578632                                                                                                                                }
     
    585639                                                                                                                        labelLayout : 'horizontal',
    586640                                                                                                                        label : editor.lang.image.height,
    587641                                                                                                                        onKeyUp : onSizeChange,
     642                                                                                                                        onChange : function()
     643                                                                                                                        {
     644                                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
     645                                                                                                                        },
    588646                                                                                                                        validate: function()
    589647                                                                                                                        {
    590648                                                                                                                                var aMatch = this.getValue().match( regexGetSizeOrEmpty );
     
    593651                                                                                                                                return !!aMatch;
    594652                                                                                                                        },
    595653                                                                                                                        setup : setupDimension,
    596                                                                                                                         commit : function( type, element )
     654                                                                                                                        commit : function( type, element, internalCommit )
    597655                                                                                                                        {
     656                                                                                                                                var value = this.getValue();
    598657                                                                                                                                if ( type == IMAGE )
    599658                                                                                                                                {
    600                                                                                                                                         var value = this.getValue();
    601659                                                                                                                                        if ( value )
    602                                                                                                                                                 element.setAttribute( 'height', value );
    603                                                                                                                                         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 )
    604665                                                                                                                                                element.removeAttribute( 'height' );
    605666                                                                                                                                }
    606667                                                                                                                                else if ( type == PREVIEW )
    607668                                                                                                                                {
    608                                                                                                                                         value = this.getValue();
    609669                                                                                                                                        var aMatch = value.match( regexGetSize );
    610670                                                                                                                                        if ( !aMatch )
    611671                                                                                                                                        {
    612672                                                                                                                                                var oImageOriginal = this.getDialog().originalElement;
    613673                                                                                                                                                if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' )
    614                                                                                                                                                         element.setStyle( 'height',  oImageOriginal.$.height + 'px');
     674                                                                                                                                                        element.setStyle( 'height', oImageOriginal.$.height + 'px' );
    615675                                                                                                                                        }
    616676                                                                                                                                        else
    617                                                                                                                                                 element.setStyle( 'height', value + 'px');
     677                                                                                                                                                element.setStyle( 'height', value + 'px' );
    618678                                                                                                                                }
    619679                                                                                                                                else if ( type == CLEANUP )
    620680                                                                                                                                {
    621                                                                                                                                         element.setStyle( 'height', '0px' );    // If removeAttribute doesn't work.
    622681                                                                                                                                        element.removeAttribute( 'height' );
    623682                                                                                                                                        element.removeStyle( 'height' );
    624683                                                                                                                                }
     
    703762                                                                                                        {
    704763                                                                                                                updatePreview( this.getDialog() );
    705764                                                                                                        },
     765                                                                                                        onChange : function()
     766                                                                                                        {
     767                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
     768                                                                                                        },
    706769                                                                                                        validate: function()
    707770                                                                                                        {
    708771                                                                                                                var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed );
     
    711774                                                                                                        setup : function( type, element )
    712775                                                                                                        {
    713776                                                                                                                if ( type == IMAGE )
    714                                                                                                                         this.setValue( element.getAttribute( 'border' ) );
     777                                                                                                                {
     778                                                                                                                        var value,
     779                                                                                                                                borderStyle = element.getStyle( 'border-width' );
     780
     781                                                                                                                        borderStyle = borderStyle && borderStyle.match( /^(\d+px)(?: \1 \1 \1)?$/ );
     782                                                                                                                        value = borderStyle && parseInt( borderStyle[ 1 ] );
     783                                                                                                                        !value && ( value = element.getAttribute( 'border' ) );
     784
     785                                                                                                                        this.setValue( value );
     786                                                                                                                }
    715787                                                                                                        },
    716                                                                                                         commit : function( type, element )
     788                                                                                                        commit : function( type, element, internalCommit )
    717789                                                                                                        {
    718                                                                                                                 if ( type == IMAGE )
     790                                                                                                                var value = parseInt( this.getValue() );
     791                                                                                                                if ( type == IMAGE || type == PREVIEW )
    719792                                                                                                                {
    720                                                                                                                         if ( this.getValue() || this.isChanged() )
    721                                                                                                                                 element.setAttribute( 'border', this.getValue() );
    722                                                                                                                 }
    723                                                                                                                 else if ( type == PREVIEW )
    724                                                                                                                 {
    725                                                                                                                         var value = parseInt( this.getValue(), 10 );
    726                                                                                                                         value = isNaN( value ) ? 0 : value;
    727                                                                                                                         element.setAttribute( 'border', value );
    728                                                                                                                         element.setStyle( 'border', value + 'px solid black' );
    729                                                                                                                 }
     793                                                                                                                        if ( value )
     794                                                                                                                                element.setStyle( 'border', CKEDITOR.tools.cssLength( value ) + ' solid' );
     795                                                                                                                        else if ( !value && this.isChanged() )
     796                                                                                                                        {
     797                                                                                                                                if( CKEDITOR.env.ie )
     798                                                                                                                                {
     799                                                                                                                                        element.removeStyle( 'border-width' );
     800                                                                                                                                        element.removeStyle( 'border-style' );
     801                                                                                                                                        element.removeStyle( 'border-color' );
     802                                                                                                                                }
     803                                                                                                                                else
     804                                                                                                                                        element.removeStyle( 'border' );
     805                                                                                                                        }
     806
     807                                                                                                                        if( !internalCommit && type == IMAGE )
     808                                                                                                                                element.removeAttribute( 'border' );
     809                                                                                                                }
    730810                                                                                                                else if ( type == CLEANUP )
    731811                                                                                                                {
    732812                                                                                                                        element.removeAttribute( 'border' );
     
    745825                                                                                                        {
    746826                                                                                                                updatePreview( this.getDialog() );
    747827                                                                                                        },
     828                                                                                                        onChange : function()
     829                                                                                                        {
     830                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
     831                                                                                                        },
    748832                                                                                                        validate: function()
    749833                                                                                                        {
    750834                                                                                                                var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed );
     
    754838                                                                                                        {
    755839                                                                                                                if ( type == IMAGE )
    756840                                                                                                                {
    757                                                                                                                         var value = element.getAttribute( 'hspace' );
    758                                                                                                                         if ( value != -1 )                              // In IE empty = -1.
    759                                                                                                                                 this.setValue( value );
     841                                                                                                                        var value,
     842                                                                                                                                marginLeftPx,
     843                                                                                                                                marginRightPx,
     844                                                                                                                                marginLeftStyle = element.getStyle( 'margin-left' ),
     845                                                                                                                                marginRightStyle = element.getStyle( 'margin-right' );
     846
     847                                                                                                                        marginLeftStyle = marginLeftStyle && marginLeftStyle.match( pxLengthRegex );
     848                                                                                                                        marginRightStyle = marginRightStyle && marginRightStyle.match( pxLengthRegex );
     849                                                                                                                        marginLeftPx = parseInt( marginLeftStyle );
     850                                                                                                                        marginRightPx = parseInt( marginRightStyle );
     851
     852                                                                                                                        value = ( marginLeftPx == marginRightPx ) && marginLeftPx;
     853                                                                                                                        !value && ( value = element.getAttribute( 'hspace' ) );
     854
     855                                                                                                                        this.setValue( value );
    760856                                                                                                                }
    761857                                                                                                        },
    762                                                                                                         commit : function( type, element )
     858                                                                                                        commit : function( type, element, internalCommit )
    763859                                                                                                        {
    764                                                                                                                 if ( type == IMAGE )
     860                                                                                                                var value = parseInt( this.getValue() );
     861                                                                                                                if ( type == IMAGE || type == PREVIEW )
    765862                                                                                                                {
    766                                                                                                                         if ( this.getValue() || this.isChanged() )
    767                                                                                                                                 element.setAttribute( 'hspace', this.getValue() );
    768                                                                                                                 }
    769                                                                                                                 else if ( type == PREVIEW )
    770                                                                                                                 {
    771                                                                                                                         var value = parseInt( this.getValue(), 10 );
    772                                                                                                                         value = isNaN( value ) ? 0 : value;
    773                                                                                                                         element.setAttribute( 'hspace', value );
    774                                                                                                                         element.setStyle( 'margin-left', value + 'px' );
    775                                                                                                                         element.setStyle( 'margin-right', value + 'px' );
    776                                                                                                                 }
     863                                                                                                                        if ( value )
     864                                                                                                                        {
     865                                                                                                                                element.setStyle( 'margin-left', CKEDITOR.tools.cssLength( value ) );
     866                                                                                                                                element.setStyle( 'margin-right', CKEDITOR.tools.cssLength( value ) );
     867                                                                                                                        }
     868                                                                                                                        else if ( !value && this.isChanged( ) )
     869                                                                                                                        {
     870                                                                                                                                element.removeStyle( 'margin-left' );
     871                                                                                                                                element.removeStyle( 'margin-right' );
     872                                                                                                                        }
     873
     874                                                                                                                        if( !internalCommit && type == IMAGE )
     875                                                                                                                                element.removeAttribute( 'hspace' );
     876                                                                                                                }
    777877                                                                                                                else if ( type == CLEANUP )
    778878                                                                                                                {
    779879                                                                                                                        element.removeAttribute( 'hspace' );
     
    793893                                                                                                        {
    794894                                                                                                                updatePreview( this.getDialog() );
    795895                                                                                                        },
     896                                                                                                        onChange : function()
     897                                                                                                        {
     898                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
     899                                                                                                        },
    796900                                                                                                        validate: function()
    797901                                                                                                        {
    798902                                                                                                                var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed );
     
    801905                                                                                                        setup : function( type, element )
    802906                                                                                                        {
    803907                                                                                                                if ( type == IMAGE )
    804                                                                                                                         this.setValue( element.getAttribute( 'vspace' ) );
     908                                                                                                                {
     909                                                                                                                        var value,
     910                                                                                                                                marginTopPx,
     911                                                                                                                                marginBottomPx,
     912                                                                                                                                marginTopStyle = element.getStyle( 'margin-top' ),
     913                                                                                                                                marginBottomStyle = element.getStyle( 'margin-bottom' );
     914
     915                                                                                                                        marginTopStyle = marginTopStyle && marginTopStyle.match( pxLengthRegex );
     916                                                                                                                        marginBottomStyle = marginBottomStyle && marginBottomStyle.match( pxLengthRegex );
     917                                                                                                                        marginTopPx = parseInt( marginTopStyle );
     918                                                                                                                        marginBottomPx = parseInt( marginBottomStyle );
     919
     920                                                                                                                        value = ( marginTopPx == marginBottomPx ) && marginTopPx;
     921                                                                                                                        !value && ( value = element.getAttribute( 'vspace' ) );
     922                                                                                                                        this.setValue( value );
     923                                                                                                                }
    805924                                                                                                        },
    806                                                                                                         commit : function( type, element )
     925                                                                                                        commit : function( type, element, internalCommit )
    807926                                                                                                        {
    808                                                                                                                 if ( type == IMAGE )
     927                                                                                                                var value = parseInt( this.getValue() );
     928                                                                                                                if ( type == IMAGE || type == PREVIEW )
    809929                                                                                                                {
    810                                                                                                                         if ( this.getValue() || this.isChanged() )
    811                                                                                                                                 element.setAttribute( 'vspace', this.getValue() );
    812                                                                                                                 }
    813                                                                                                                 else if ( type == PREVIEW )
    814                                                                                                                 {
    815                                                                                                                         var value = parseInt( this.getValue(), 10 );
    816                                                                                                                         value = isNaN( value ) ? 0 : value;
    817                                                                                                                         element.setAttribute( 'vspace', this.getValue() );
    818                                                                                                                         element.setStyle( 'margin-top', value + 'px' );
    819                                                                                                                         element.setStyle( 'margin-bottom', value + 'px' );
    820                                                                                                                 }
     930                                                                                                                        if ( value )
     931                                                                                                                        {
     932                                                                                                                                element.setStyle( 'margin-top', CKEDITOR.tools.cssLength( value ) );
     933                                                                                                                                element.setStyle( 'margin-bottom', CKEDITOR.tools.cssLength( value ) );
     934                                                                                                                        }
     935                                                                                                                        else if ( !value && this.isChanged( ) )
     936                                                                                                                        {
     937                                                                                                                                element.removeStyle( 'margin-top' );
     938                                                                                                                                element.removeStyle( 'margin-bottom' );
     939                                                                                                                        }
     940
     941                                                                                                                        if( !internalCommit && type == IMAGE )
     942                                                                                                                                element.removeAttribute( 'vspace' );
     943                                                                                                                }
    821944                                                                                                                else if ( type == CLEANUP )
    822945                                                                                                                {
    823946                                                                                                                        element.removeAttribute( 'vspace' );
     
    838961                                                                                                        [
    839962                                                                                                                [ editor.lang.common.notSet , ''],
    840963                                                                                                                [ editor.lang.image.alignLeft , 'left'],
    841                                                                                                                 [ editor.lang.image.alignAbsBottom , 'absBottom'],
    842                                                                                                                 [ editor.lang.image.alignAbsMiddle , 'absMiddle'],
    843                                                                                                                 [ editor.lang.image.alignBaseline , 'baseline'],
    844                                                                                                                 [ editor.lang.image.alignBottom , 'bottom'],
    845                                                                                                                 [ editor.lang.image.alignMiddle , 'middle'],
    846964                                                                                                                [ editor.lang.image.alignRight , 'right'],
    847                                                                                                                 [ editor.lang.image.alignTextTop , 'textTop'],
    848                                                                                                                 [ editor.lang.image.alignTop , 'top']
     965                                                                                                                // Backward compatible with v2 on setup when specified as attribute value,
     966                                                                                                                // while these values are no more available as select options.
     967                                                                                                                //      [ editor.lang.image.alignAbsBottom , 'absBottom'],
     968                                                                                                                //      [ editor.lang.image.alignAbsMiddle , 'absMiddle'],
     969                                                                                                                //  [ editor.lang.image.alignBaseline , 'baseline'],
     970                                                                                                                //  [ editor.lang.image.alignTextTop , 'text-top'],
     971                                                                                                                //  [ editor.lang.image.alignBottom , 'bottom'],
     972                                                                                                                //  [ editor.lang.image.alignMiddle , 'middle'],
     973                                                                                                                //  [ editor.lang.image.alignTop , 'top']
    849974                                                                                                        ],
    850975                                                                                                        onChange : function()
    851976                                                                                                        {
    852977                                                                                                                updatePreview( this.getDialog() );
     978                                                                                                                commitInternally.call( this, 'advanced:txtdlgGenStyle' );
    853979                                                                                                        },
    854980                                                                                                        setup : function( type, element )
    855981                                                                                                        {
    856982                                                                                                                if ( type == IMAGE )
    857                                                                                                                         this.setValue( element.getAttribute( 'align' ) );
    858                                                                                                         },
    859                                                                                                         commit : function( type, element )
    860                                                                                                         {
    861                                                                                                                 var value = this.getValue();
    862                                                                                                                 if ( type == IMAGE )
    863                                                                                                                 {
    864                                                                                                                         if ( value || this.isChanged() )
    865                                                                                                                                 element.setAttribute( 'align', value );
    866                                                                                                                 }
    867                                                                                                                 else if ( type == PREVIEW )
    868                                                                                                                 {
    869                                                                                                                         element.setAttribute( 'align', this.getValue() );
     983                                                                                                                {
     984                                                                                                                        var value = element.getStyle( 'float' );
     985                                                                                                                        switch( value )
     986                                                                                                                        {
     987                                                                                                                                // Ignore those unrelated values.
     988                                                                                                                                case 'inherit':
     989                                                                                                                                case 'none':
     990                                                                                                                                        value = '';
     991                                                                                                                        }
    870992
    871                                                                                                                         if ( value == 'absMiddle' || value == 'middle' )
    872                                                                                                                                 element.setStyle( 'vertical-align', 'middle' );
    873                                                                                                                         else if ( value == 'top' || value == 'textTop' )
    874                                                                                                                                 element.setStyle( 'vertical-align', 'top' );
    875                                                                                                                         else
    876                                                                                                                                 element.removeStyle( 'vertical-align' );
    877 
    878                                                                                                                         if ( value == 'right' || value == 'left' )
    879                                                                                                                                 element.setStyle( 'styleFloat', value );
    880                                                                                                                         else
    881                                                                                                                                 element.removeStyle( 'styleFloat' );
    882 
     993                                                                                                                        !value && ( value = ( element.getAttribute( 'align' ) || '' ).toLowerCase() );
     994                                                                                                                        this.setValue( value );
    883995                                                                                                                }
    884                                                                                                                 else if ( type == CLEANUP )
    885                                                                                                                 {
    886                                                                                                                         element.removeAttribute( 'align' );
    887                                                                                                                 }
    888                                                                                                         }
    889                                                                                                 }
     996                                                                                                        },
     997                                                                                                        commit : function( type, element, internalCommit )
     998                                                                                                        {
     999                                                                                                                var value = this.getValue();
     1000                                                                                                                if ( type == IMAGE || type == PREVIEW )
     1001                                                                                                                {
     1002                                                                                                                        if ( value )
     1003                                                                                                                                element.setStyle( 'float', value );
     1004                                                                                                                        else if ( !value && this.isChanged( ) )
     1005                                                                                                                                element.removeStyle( 'float' );
     1006
     1007                                                                                                                        if( !internalCommit && type == IMAGE )
     1008                                                                                                                        {
     1009                                                                                                                                value = ( element.getAttribute( 'align' ) || '' ).toLowerCase();
     1010                                                                                                                                switch( value )
     1011                                                                                                                                {
     1012                                                                                                                                        // we should remove it only if it matches "left" or "right",
     1013                                                                                                                                        // otherwise leave it intact.
     1014                                                                                                                                        case 'left':
     1015                                                                                                                                        case 'right':
     1016                                                                                                                                                element.removeAttribute( 'align' );
     1017                                                                                                                                }
     1018                                                                                                                        }
     1019                                                                                                                }
     1020                                                                                                                else if ( type == CLEANUP )
     1021                                                                                                                        element.removeStyle( 'float' );
     1022
     1023                                                                                                        }
     1024                                                                                                }
    8901025                                                                                        ]
    8911026                                                                                }
    8921027                                                                        ]
     
    11881323                                                                        };
    11891324                                                                }
    11901325                                                        },
     1326                                                        onChange : function ()
     1327                                                        {
     1328                                                                commitInternally.call( this,
     1329                                                                        [ 'info:cmbFloat', 'info:cmbAlign',
     1330                                                                          'info:txtVSpace', 'info:txtHSpace',
     1331                                                                          'info:txtBorder',
     1332                                                                          'info:txtWidth', 'info:txtHeight' ] );
     1333                                                        },
    11911334                                                        commit : function( type, element )
    11921335                                                        {
    11931336                                                                if ( type == IMAGE && ( this.getValue() || this.isChanged() ) )
    11941337                                                                {
    11951338                                                                        element.setAttribute( 'style', this.getValue() );
    1196 
    1197                                                                         // Set STYLE dimensions.
    1198                                                                         var height = element.getAttribute( 'height' ),
    1199                                                                                 width = element.getAttribute( 'width' );
    1200 
    1201                                                                         if ( this.attributesInStyle && this.attributesInStyle.height )
    1202                                                                         {
    1203                                                                                 if ( height )
    1204                                                                                 {
    1205                                                                                         if ( height.match( regexGetSize )[2] == '%' )                   // % is allowed
    1206                                                                                                 element.setStyle( 'height', height + '%' );
    1207                                                                                         else
    1208                                                                                                 element.setStyle( 'height', height + 'px' );
    1209                                                                                 }
    1210                                                                                 else
    1211                                                                                         element.removeStyle( 'height' );
    1212                                                                         }
    1213                                                                         if ( this.attributesInStyle && this.attributesInStyle.width )
    1214                                                                         {
    1215                                                                                 if ( width )
    1216                                                                                 {
    1217                                                                                         if ( width.match( regexGetSize )[2] == '%' )                    // % is allowed
    1218                                                                                                 element.setStyle( 'width', width + '%' );
    1219                                                                                         else
    1220                                                                                                 element.setStyle( 'width', width + 'px' );
    1221                                                                                 }
    1222                                                                                 else
    1223                                                                                         element.removeStyle( 'width' );
    1224                                                                         }
    1225                                                                 }
    1226                                                         }
    1227                                                 }
     1339                                                                }
     1340                                                        }
     1341                                                }
    12281342                                        ]
    12291343                                }
    12301344                        ]
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy