Ticket #4893: 4893.patch

File 4893.patch, 9.7 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/tabletools/dialogs/tableCell.js

     
    104104                                                                                                        widths : [ '71%', '29%' ],
    105105                                                                                                        labelLayout : 'horizontal',
    106106                                                                                                        validate : validate[ 'number' ]( langCell.invalidWidth ),
    107                                                                                                         setup : function( selectedCell )
     107                                                                                                        setup : function( element )
    108108                                                                                                        {
    109                                                                                                                 var widthMatch = widthPattern.exec( selectedCell.$.style.width );
    110                                                                                                                 if ( widthMatch )
    111                                                                                                                         this.setValue( widthMatch[1] );
     109                                                                                                                var widthAttr = parseInt( element.getAttribute( 'width' ), 10 ),
     110                                                                                                                                widthStyle = parseInt( element.getStyle( 'width' ), 10 );
     111
     112                                                                                                                !isNaN( widthAttr ) && this.setValue( widthAttr );
     113                                                                                                                !isNaN( widthStyle ) && this.setValue( widthStyle );
    112114                                                                                                        },
    113                                                                                                         commit : function( selectedCell )
     115                                                                                                        commit : function( element )
    114116                                                                                                        {
    115                                                                                                                 var unit = this.getDialog().getValueOf( 'info', 'widthType' );
    116                                                                                                                 if ( this.getValue() !== '' )
    117                                                                                                                         selectedCell.$.style.width = this.getValue() + unit;
     117                                                                                                                var value = parseInt( this.getValue(), 10 ),
     118                                                                                                                                unit = this.getDialog().getValueOf( 'info', 'widthType' );
     119
     120                                                                                                                if ( !isNaN( value ) )
     121                                                                                                                        element.setStyle( 'width', value + unit );
    118122                                                                                                                else
    119                                                                                                                         selectedCell.$.style.width = '';
     123                                                                                                                        element.removeStyle( 'width' );
     124
     125                                                                                                                element.removeAttribute( 'width' );
    120126                                                                                                        },
    121127                                                                                                        'default' : ''
    122128                                                                                                },
     
    154160                                                                                                        widths : [ '71%', '29%' ],
    155161                                                                                                        labelLayout : 'horizontal',
    156162                                                                                                        validate : validate[ 'number' ]( langCell.invalidHeight ),
    157                                                                                                         setup : function( selectedCell )
     163                                                                                                        setup : function( element )
    158164                                                                                                        {
    159                                                                                                                 var heightMatch = heightPattern.exec( selectedCell.$.style.height );
    160                                                                                                                 if ( heightMatch )
    161                                                                                                                         this.setValue( heightMatch[1] );
     165                                                                                                                var heightAttr = parseInt( element.getAttribute( 'height' ), 10 ),
     166                                                                                                                                heightStyle = parseInt( element.getStyle( 'height' ), 10 );
     167
     168                                                                                                                !isNaN( heightAttr ) && this.setValue( heightAttr );
     169                                                                                                                !isNaN( heightStyle ) && this.setValue( heightStyle );
    162170                                                                                                        },
    163                                                                                                         commit : function( selectedCell )
     171                                                                                                        commit : function( element )
    164172                                                                                                        {
    165                                                                                                                 if ( this.getValue() !== '' )
    166                                                                                                                         selectedCell.$.style.height = this.getValue() + 'px';
     173                                                                                                                var value = parseInt( this.getValue(), 10 );
     174
     175                                                                                                                if ( !isNaN( value ) )
     176                                                                                                                        element.setStyle( 'height', CKEDITOR.tools.cssLength( value ) );
    167177                                                                                                                else
    168                                                                                                                         selectedCell.$.style.height = '';
     178                                                                                                                        element.removeStyle( 'height' );
     179
     180                                                                                                                element.removeAttribute( 'height' );
    169181                                                                                                        }
    170182                                                                                                },
    171183                                                                                                {
     
    187199                                                                                                [ langCell.yes, 'yes' ],
    188200                                                                                                [ langCell.no, 'no' ]
    189201                                                                                        ],
    190                                                                                         setup : function( selectedCell )
     202                                                                                        setup : function( element )
    191203                                                                                        {
    192                                                                                                 if ( selectedCell.getAttribute( 'noWrap' ) )
     204                                                                                                var wordWrapAttr = element.getAttribute( 'noWrap' ),
     205                                                                                                                wordWrapStyle = element.getStyle( 'white-space' );
     206
     207                                                                                                if ( wordWrapStyle == 'nowrap' || wordWrapAttr )
    193208                                                                                                        this.setValue( 'no' );
    194209                                                                                        },
    195                                                                                         commit : function( selectedCell )
     210                                                                                        commit : function( element )
    196211                                                                                        {
    197212                                                                                                if ( this.getValue() == 'no' )
    198                                                                                                         selectedCell.setAttribute( 'noWrap', 'nowrap' );
     213                                                                                                        element.setStyle( 'white-space', 'nowrap' );
    199214                                                                                                else
    200                                                                                                         selectedCell.removeAttribute( 'noWrap' );
     215                                                                                                        element.removeStyle( 'white-space' );
     216
     217                                                                                                element.removeAttribute( 'noWrap' );
    201218                                                                                        }
    202219                                                                                },
    203220                                                                                spacer(),
     
    215232                                                                                                [ langTable.alignCenter, 'center' ],
    216233                                                                                                [ langTable.alignRight, 'right' ]
    217234                                                                                        ],
    218                                                                                         setup : function( selectedCell )
     235                                                                                        setup : function( element )
    219236                                                                                        {
    220                                                                                                 this.setValue( selectedCell.getAttribute( 'align' ) || '' );
     237                                                                                                var alignAttr = element.getAttribute( 'align' ),
     238                                                                                                                textAlignStyle = element.getStyle( 'text-align');
     239
     240                                                                                                this.setValue(  textAlignStyle || alignAttr );
    221241                                                                                        },
    222242                                                                                        commit : function( selectedCell )
    223243                                                                                        {
    224                                                                                                 if ( this.getValue() )
    225                                                                                                         selectedCell.setAttribute( 'align', this.getValue() );
     244                                                                                                var value = this.getValue();
     245
     246                                                                                                if ( value )
     247                                                                                                        selectedCell.setStyle( 'text-align', value );
    226248                                                                                                else
    227                                                                                                         selectedCell.removeAttribute( 'align' );
     249                                                                                                        selectedCell.removeStyle( 'text-align' );
     250
     251                                                                                                selectedCell.removeAttribute( 'align' );
    228252                                                                                        }
    229253                                                                                },
    230254                                                                                {
     
    242266                                                                                                [ langCell.alignBottom, 'bottom' ],
    243267                                                                                                [ langCell.alignBaseline, 'baseline' ]
    244268                                                                                        ],
    245                                                                                         setup : function( selectedCell )
     269                                                                                        setup : function( element )
    246270                                                                                        {
    247                                                                                                 this.setValue( selectedCell.getAttribute( 'vAlign' ) || '' );
     271                                                                                                var vAlignAttr = element.getAttribute( 'vAlign' ),
     272                                                                                                                vAlignStyle = element.getStyle( 'vertical-align' );
     273
     274                                                                                                switch( vAlignStyle )
     275                                                                                                {
     276                                                                                                        // Ignore all other unrelated style values..
     277                                                                                                        case 'top':
     278                                                                                                        case 'middle':
     279                                                                                                        case 'bottom':
     280                                                                                                        case 'baseline':
     281                                                                                                                break;
     282                                                                                                        default:
     283                                                                                                                vAlignStyle = '';
     284                                                                                                }
     285
     286                                                                                                this.setValue( vAlignStyle || vAlignAttr  );
    248287                                                                                        },
    249                                                                                         commit : function( selectedCell )
     288                                                                                        commit : function( element )
    250289                                                                                        {
    251                                                                                                 if ( this.getValue() )
    252                                                                                                         selectedCell.setAttribute( 'vAlign', this.getValue() );
     290                                                                                                var value = this.getValue();
     291
     292                                                                                                if ( value )
     293                                                                                                        element.setStyle( 'vertical-align', value );
    253294                                                                                                else
    254                                                                                                         selectedCell.removeAttribute( 'vAlign' );
     295                                                                                                        element.removeStyle( 'vertical-align' );
     296
     297                                                                                                element.removeAttribute( 'vAlign' );
    255298                                                                                        }
    256299                                                                                }
    257300                                                                        ]
     
    294337                                                                                        validate : validate.integer( langCell.invalidRowSpan ),
    295338                                                                                        setup : function( selectedCell )
    296339                                                                                        {
    297                                                                                                 this.setValue( selectedCell.getAttribute( 'rowSpan' ) || '' );
     340                                                                                                var attrVal = parseInt( selectedCell.getAttribute( 'rowSpan' ), 10 );
     341                                                                                                attrVal  != 1 && this.setValue(  attrVal );
    298342                                                                                        },
    299343                                                                                        commit : function( selectedCell )
    300344                                                                                        {
     
    312356                                                                                        widths : [ '50%', '50%' ],
    313357                                                                                        'default' : '',
    314358                                                                                        validate : validate.integer( langCell.invalidColSpan ),
    315                                                                                         setup : function( selectedCell )
     359                                                                                        setup : function( element )
    316360                                                                                        {
    317                                                                                                 this.setValue( selectedCell.getAttribute( 'colSpan' ) || '' );
     361                                                                                                var attrVal = parseInt( element.getAttribute( 'colSpan' ), 10 );
     362                                                                                                attrVal  != 1 && this.setValue(  attrVal );
    318363                                                                                        },
    319364                                                                                        commit : function( selectedCell )
    320365                                                                                        {
     
    338383                                                                                                        labelLayout : 'horizontal',
    339384                                                                                                        widths : [ '70%', '30%' ],
    340385                                                                                                        'default' : '',
    341                                                                                                         setup : function( selectedCell )
     386                                                                                                        setup : function( element )
    342387                                                                                                        {
    343                                                                                                                 this.setValue( selectedCell.getAttribute( 'bgColor' ) || '' );
     388                                                                                                                var bgColorAttr = element.getAttribute( 'bgColor' ),
     389                                                                                                                                bgColorStyle = element.getStyle( 'background-color' );
     390
     391                                                                                                                this.setValue( bgColorStyle || bgColorAttr );
    344392                                                                                                        },
    345393                                                                                                        commit : function( selectedCell )
    346394                                                                                                        {
    347                                                                                                                 if ( this.getValue() )
    348                                                                                                                         selectedCell.setAttribute( 'bgColor', this.getValue() );
     395                                                                                                                var value = this.getValue();
     396
     397                                                                                                                if ( value )
     398                                                                                                                        selectedCell.setStyle( 'background-color', this.getValue() );
    349399                                                                                                                else
    350                                                                                                                         selectedCell.removeAttribute( 'bgColor' );
     400                                                                                                                        selectedCell.removeStyle( 'background-color' );
     401
     402                                                                                                                selectedCell.removeAttribute( 'bgColor');
    351403                                                                                                        }
    352404                                                                                                },
    353405                                                                                                {
     
    382434                                                                                                        labelLayout : 'horizontal',
    383435                                                                                                        widths : [ '70%', '30%' ],
    384436                                                                                                        'default' : '',
    385                                                                                                         setup : function( selectedCell )
     437                                                                                                        setup : function( element )
    386438                                                                                                        {
    387                                                                                                                 this.setValue( selectedCell.getStyle( 'border-color' ) || '' );
     439                                                                                                                var borderColorAttr = element.getAttribute( 'borderColor' ),
     440                                                                                                                                borderColorStyle = element.getStyle( 'background-color' );
     441
     442                                                                                                                this.setValue( borderColorStyle || borderColorAttr );
    388443                                                                                                        },
    389444                                                                                                        commit : function( selectedCell )
    390445                                                                                                        {
    391                                                                                                                 if ( this.getValue() )
     446                                                                                                                var value = this.getValue();
     447                                                                                                                if ( value )
    392448                                                                                                                        selectedCell.setStyle( 'border-color', this.getValue() );
    393449                                                                                                                else
    394450                                                                                                                        selectedCell.removeStyle( 'border-color' );
     451
     452                                                                                                                selectedCell.removeAttribute( 'borderColor');
    395453                                                                                                        }
    396454                                                                                                },
    397455                                                                                                {
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy