Ticket #10021: table.js.diff

File table.js.diff, 10.4 KB (added by Stephen, 10 years ago)

diff with table 4.4.6

  • table.js

    old new  
    222222                                        if ( !table.getAttribute( 'style' ) )
    223223                                                table.removeAttribute( 'style' );
    224224                                }
     225                               
     226                                for ( row = 0; row < table.$.rows.length; row++ ) {
     227                                  for (index = 0, len = table.$.rows[ row ].cells.length; index < len; ++index) {
     228                                          newCell = new CKEDITOR.dom.element( table.$.rows[ row ].cells[ index ] );
     229                                          if(table.getStyle('border-width')){
     230                                            newCell.setStyle('border-width', table.getStyle('border-width'));
     231                                          }
     232                                    else{
     233                                            newCell.removeStyle('border');
     234                                          }             
     235                                    if(table.getAttribute('cellPadding')>0){
     236                                      newCell.setStyle('padding', table.getAttribute('cellPadding')+'px');
     237                                    }
     238                                          else{
     239                                            newCell.removeStyle('padding');
     240                                          }
     241                                          if(table.getStyle('border-color')){
     242                                            newCell.setStyle('border-color', table.getStyle('border-color'));
     243                                          }
     244                                          else{
     245                                            newCell.removeStyle('border-color');
     246                                          }
     247                                          if(table.getStyle('border-style')){
     248                                            newCell.setStyle('border-style', table.getStyle('border-style')); 
     249                                          }
     250                                          else{
     251                                            newCell.removeStyle('border-style');
     252                                          }
     253                                        }
     254                                }
     255        table.removeAttribute('cellPadding');
    225256
    226257                                // Insert the table element if we're creating one.
    227258                                if ( !this._.selectedElement ) {
     
    331362                                                        controlStyle: 'width:3em',
    332363                                                        validate: CKEDITOR.dialog.validate[ 'number' ]( editor.lang.table.invalidBorder ),
    333364                                                        setup: function( selectedTable ) {
    334                                                                 this.setValue( selectedTable.getAttribute( 'border' ) || '' );
     365                                                                if(selectedTable.getStyle('border-width')){
     366                                                                  this.setValue(selectedTable.getStyle('border-width').replace('px', ''));
     367                                                                }
     368                                                                else if(selectedTable.getAttribute('border')){
     369                                                                  this.setValue(selectedTable.getAttribute('border'));
     370                                                                  selectedTable.setStyle('border-style', 'solid');
     371                                                                }
     372                                                                else{
     373                                                                  this.setValue('');
     374                                                                }
    335375                                                        },
    336376                                                        commit: function( data, selectedTable ) {
    337                                                                 if ( this.getValue() )
    338                                                                         selectedTable.setAttribute( 'border', this.getValue() );
    339                                                                 else
    340                                                                         selectedTable.removeAttribute( 'border' );
     377                                              if(this.getValue()){
     378                                                if(this.getValue()>0){
     379                                                        selectedTable.setStyle('border-width', this.getValue()+'px');
     380                                                }
     381                                                else{
     382                                                  selectedTable.removeStyle('border');
     383                                                }
     384                                              }
     385                                              else{
     386                                                selectedTable.removeStyle('border');
     387                                              }
     388                                              selectedTable.removeAttribute('border');
    341389                                                        }
    342390                                                },
     391
     392                                            {
     393                                                        type: 'text',
     394                                                        id: 'txtBorderColor',
     395                                                        requiredContent: 'table{border-color}',
     396                                                        label: editor.lang.table.borderColor,
     397                                                        'default': '#cccccc',
     398                                                        setup: function( selectedTable ) {
     399                                                                if(selectedTable.getStyle('border-color')){
     400                                                                  this.setValue(selectedTable.getStyle('border-color'));
     401                                                                }
     402                                                                else if(selectedTable.getAttribute('bordercolor')){
     403                                                                  this.setValue(selectedTable.getAttribute('bordercolor'));
     404                                                                  selectedTable.removeAttribute('bordercolor');
     405                                                                }
     406                                                                else{
     407                                                                  this.setValue('');
     408                                                                }
     409                                                        },
     410                                                        commit: function( data, selectedTable ) {
     411                                              if(this.getValue()){
     412                                                      selectedTable.setStyle('border-color', this.getValue()); 
     413                                              }
     414                                              else{
     415                                                selectedTable.removeStyle('border-color');
     416                                              }
     417                                                        }
     418                                                },
     419
     420                                                        {
     421                                                        id: 'cmbBorderstyle',
     422                                                        type: 'select',
     423                                                        requiredContent: 'table{border-style}',
     424                                                        'default': 'solid',
     425                                                        label: editor.lang.common.borderstyle,
     426                                                        items: [
     427                                                                [ editor.lang.common.notSet, '' ],
     428                                                                [ editor.lang.common.borderstyleNone, 'none' ],
     429                                                                [ editor.lang.common.borderstyleSolid, 'solid' ],
     430                                                                [ editor.lang.common.borderstyleDotted, 'dotted' ],
     431                                                                [ editor.lang.common.borderstyleDashed, 'dashed' ],
     432                                                                [ editor.lang.common.borderstyleHidden, 'hidden' ],
     433                                                                [ editor.lang.common.borderstyleDouble, 'double' ],
     434                                                                [ editor.lang.common.borderstyleGroove, 'groove' ],
     435                                                                [ editor.lang.common.borderstyleRidge, 'ridge' ],
     436                                                                [ editor.lang.common.borderstyleInset, 'inset' ],
     437                                                                [ editor.lang.common.borderstyleOutset, 'outset' ],
     438                                                                [ editor.lang.common.borderstyleInitial, 'initial' ],
     439                                                                [ editor.lang.common.borderstyleInherit, 'inherit' ]
     440                                                                ],
     441                                                        setup: function( selectedTable ) {
     442                                                          if(this.getValue(selectedTable.getStyle('border-style'))){
     443                                                            this.setValue(selectedTable.getStyle('border-style'));
     444                                                          }
     445                                                          else{
     446                                                            this.setValue('solid');
     447                                                          }
     448                                                        },
     449                                                        commit: function( data, selectedTable ) {
     450                                                          if (this.getValue()){
     451                                                            selectedTable.setStyle('border-style', this.getValue());
     452                                                          }
     453                                                          else {
     454                                                            selectedTable.setStyle('border-style', '');
     455                                                          }
     456                                                        }
     457                                                },
     458
    343459                                                        {
    344460                                                        id: 'cmbAlign',
    345461                                                        type: 'select',
    346462                                                        requiredContent: 'table[align]',
    347                                                         'default': '',
     463                                                        'default': 'center',
    348464                                                        label: editor.lang.common.align,
    349465                                                        items: [
    350466                                                                [ editor.lang.common.notSet, '' ],
     
    353469                                                                [ editor.lang.common.alignRight, 'right' ]
    354470                                                                ],
    355471                                                        setup: function( selectedTable ) {
    356                                                                 this.setValue( selectedTable.getAttribute( 'align' ) || '' );
     472                                                                if(selectedTable.getStyle('float')){
     473                                                                  this.setValue(selectedTable.getStyle('float'));
     474                                                                }
     475                                                                else if(selectedTable.getStyle('margin-left')){
     476                                                                  this.setValue('center');
     477                                                                }
     478                                                                else if(selectedTable.getAttribute('align')){
     479                                                                  this.setValue(selectedTable.getAttribute('align'));
     480                                                                }
     481                                                                else{
     482                                                                  this.setValue('');
     483                                                                }
    357484                                                        },
    358485                                                        commit: function( data, selectedTable ) {
    359                                                                 if ( this.getValue() )
    360                                                                         selectedTable.setAttribute( 'align', this.getValue() );
    361                                                                 else
    362                                                                         selectedTable.removeAttribute( 'align' );
     486                                                                if(this.getValue()){
     487                                                                  if(this.getValue()=='left'){
     488                                                                    selectedTable.setStyle('float', 'left');
     489                                                                    selectedTable.removeStyle('margin-left');
     490                                                                    selectedTable.removeStyle('margin-right');
     491                                                                  }
     492                                                                  else if(this.getValue()=='right'){
     493                                                                    selectedTable.setStyle('float', 'right');
     494                                                                    selectedTable.removeStyle('margin-left');
     495                                                                    selectedTable.removeStyle('margin-right');
     496                                                                  }
     497                                                                  else if(this.getValue()=='center'){
     498                                                                    selectedTable.setStyle('margin-left', 'auto');
     499                                                                    selectedTable.setStyle('margin-right', 'auto');
     500                                                                    selectedTable.removeStyle('float');
     501                                                                  }
     502                                                                }
     503                                                                else{
     504                                                                  selectedTable.removeStyle('margin-left');
     505                                                                  selectedTable.removeStyle('margin-right');
     506                                                                  selectedTable.removeStyle('float');
     507                                                                }
     508                                                                selectedTable.removeAttribute('align');
    363509                                                        }
    364510                                                }
    365511                                                ]
     
    432578                                                        requiredContent: 'table[cellspacing]',
    433579                                                        controlStyle: 'width:3em',
    434580                                                        label: editor.lang.table.cellSpace,
    435                                                         'default': editor.filter.check( 'table[cellspacing]' ) ? 1 : 0,
     581                                                        'default': editor.filter.check( 'table[cellspacing]' ) ? 0 : 0,
    436582                                                        validate: CKEDITOR.dialog.validate.number( editor.lang.table.invalidCellSpacing ),
    437583                                                        setup: function( selectedTable ) {
    438                                                                 this.setValue( selectedTable.getAttribute( 'cellSpacing' ) || '' );
     584                                                                if(selectedTable.getStyle('border-spacing')){
     585                                                                  this.setValue(selectedTable.getStyle('border-spacing').replace('px',''));
     586                                                                }
     587                                                                else if(selectedTable.getAttribute('cellspacing')){
     588                                                                  this.setValue(selectedTable.getAttribute('cellspacing'));
     589                                                                }
     590                                                                else{
     591                                                                  this.setValue(''); 
     592                                                                }
    439593                                                        },
    440594                                                        commit: function( data, selectedTable ) {
    441                                                                 if ( this.getValue() )
    442                                                                         selectedTable.setAttribute( 'cellSpacing', this.getValue() );
    443                                                                 else
    444                                                                         selectedTable.removeAttribute( 'cellSpacing' );
     595                                                                if(this.getValue()){
     596                                                                  if(this.getValue()>0){
     597                                                                    selectedTable.setStyle('border-collapse', 'separate');
     598                                                                  }
     599                                                                  else{
     600                                                                    selectedTable.setStyle('border-collapse', 'collapse');
     601                                                                  }
     602                                                                  selectedTable.setStyle('border-spacing', this.getValue()+'px');
     603                                                                }
     604                                                                else{
     605                                                                  selectedTable.setStyle('border-collapse', 'collapse');
     606                                                                  selectedTable.removeStyle('border-spacing');
     607                                                                }
     608                                                                selectedTable.removeAttribute('cellSpacing');
    445609                                                        }
    446610                                                },
    447611                                                        {
     
    450614                                                        requiredContent: 'table[cellpadding]',
    451615                                                        controlStyle: 'width:3em',
    452616                                                        label: editor.lang.table.cellPad,
    453                                                         'default': editor.filter.check( 'table[cellpadding]' ) ? 1 : 0,
     617                                                        'default': editor.filter.check( 'table[cellpadding]' ) ? 4 : 0,
    454618                                                        validate: CKEDITOR.dialog.validate.number( editor.lang.table.invalidCellPadding ),
    455619                                                        setup: function( selectedTable ) {
    456                                                                 this.setValue( selectedTable.getAttribute( 'cellPadding' ) || '' );
     620                                              if(selectedTable.getAttribute('cellpadding')){
     621                                                this.setValue(selectedTable.getAttribute('cellpadding'));
     622                                              }
     623                                              else if(selectedTable.getElementsByTag('tbody').getItem(0)){
     624                                                var cellpadding=0;
     625                                                                  var tbody = selectedTable.getElementsByTag('tbody').getItem(0);
     626                                                                  var theRow = tbody.getElementsByTag('tr').getItem(0);
     627                                                                  var td = theRow.getChild(0);
     628                                                                  if(td.getStyle('padding')){
     629                                                                    this.setValue(td.getStyle('padding').replace('px',''));
     630                                                                  }
     631                                                                  else{
     632                                                                    if(selectedTable.getElementsByTag('thead').getItem(0)){
     633                                                                      var thead = selectedTable.getElementsByTag('thead').getItem(0);
     634                                                                      var thead = tbody.getElementsByTag('tr').getItem(0);
     635                                                                      var th = theRow.getChild(0);
     636                                                                      if(th.getStyle('padding')){
     637                                                                        this.setValue(th.getStyle('padding').replace('px',''));
     638                                                                      }
     639                                                                      else{
     640                                                                        this.setValue('');
     641                                                                      }
     642                                                                    }
     643                                                                    else{
     644                                                                      this.setValue('');
     645                                                                    }
     646                                                                  }
     647                                                                }
    457648                                                        },
    458649                                                        commit: function( data, selectedTable ) {
    459650                                                                if ( this.getValue() )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy