Changeset 2373

Show
Ignore:
Timestamp:
2008-08-25 21:57:41 (5 months ago)
Author:
alfonsoml
Message:

Splitting a TH will create two TH. Some other little readjustments in that code. #2472

Location:
FCKeditor/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/_source/internals/fcktablehandler.js

    r2283 r2373  
    299299        this._MarkCells( cells, '_CellSelected' ) ; 
    300300 
    301         var tableMap = this._CreateTableMap( cells[0].parentNode.parentNode ) ; 
     301        var tableMap = this._CreateTableMap( cells[0] ) ; 
    302302        var rowIdx = cells[0].parentNode.rowIndex ; 
    303303        var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, cells[0] ) ; 
     
    358358        // Because the checking is already done by FCKTableCommand. 
    359359        var refCell = cells[0] ; 
    360         var tableMap = this._CreateTableMap( refCell.parentNode.parentNode ) ; 
     360        var tableMap = this._CreateTableMap( refCell ) ; 
    361361        var rowIdx = refCell.parentNode.rowIndex ; 
    362362        var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, refCell ) ; 
     
    451451 
    452452        var refCell = cells[0] ; 
    453         var tableMap = this._CreateTableMap( refCell.parentNode.parentNode ) ; 
     453        var tableMap = this._CreateTableMap( refCell ) ; 
    454454        var rowIdx = refCell.parentNode.rowIndex ; 
    455455        var colIdx = FCKTableHandler._GetCellIndexSpan( tableMap, rowIdx, refCell ) ; 
     
    458458        if ( cellSpan > 1 ) 
    459459        { 
    460                 // Splittng a multi-column cell - original cell gets ceil(colSpan/2) columns, 
     460                // Splitting a multi-column cell - original cell gets ceil(colSpan/2) columns, 
    461461                // new cell gets floor(colSpan/2). 
    462462                var newCellSpan = Math.ceil( cellSpan / 2 ) ; 
    463                 var newCell = FCKTools.GetElementDocument( refCell ).createElement( 'td' ) ; 
     463                var newCell = FCK.EditorDocument.createElement( refCell.nodeName ) ; 
    464464                if ( FCKBrowserInfo.IsGeckoLike ) 
    465465                        FCKTools.AppendBogusBr( newCell ) ; 
     
    489489                        { 
    490490                                newRow.push( refCell ) ; 
    491                                 newRow.push( FCKTools.GetElementDocument( refCell ).createElement( 'td' ) ) ; 
     491                                newRow.push( FCK.EditorDocument.createElement( refCell.nodeName ) ) ; 
    492492                                if ( FCKBrowserInfo.IsGeckoLike ) 
    493493                                        FCKTools.AppendBogusBr( newRow[newRow.length - 1] ) ; 
     
    515515 
    516516        var currentCell = cells[0] ; 
    517         var tableMap = this._CreateTableMap( currentCell.parentNode.parentNode ) ; 
    518         var cellIndex = FCKTableHandler._GetCellIndexSpan( tableMap, currentCell.parentNode.rowIndex, currentCell ) ; 
     517        var tableMap = this._CreateTableMap( currentCell ) ; 
     518        var currentRowIndex = currentCell.parentNode.rowIndex ; 
     519        var cellIndex = FCKTableHandler._GetCellIndexSpan( tableMap, currentRowIndex, currentCell ) ; 
    519520        var currentRowSpan = currentCell.rowSpan ; 
    520         var currentRowIndex = currentCell.parentNode.rowIndex ; 
    521521        if ( isNaN( currentRowSpan ) ) 
    522522                currentRowSpan = 1 ; 
     
    529529                // 2. Find the appropriate place to insert a new cell at the next row. 
    530530                var newCellRowIndex = currentRowIndex + Math.ceil( currentRowSpan / 2 ) ; 
     531                var oRow = tableMap[newCellRowIndex] ; 
    531532                var insertMarker = null ; 
    532                 for ( var i = cellIndex+1 ; i < tableMap[newCellRowIndex].length ; i++ ) 
    533                 { 
    534                         if ( tableMap[newCellRowIndex][i].parentNode.rowIndex == newCellRowIndex ) 
    535                         { 
    536                                 insertMarker = tableMap[newCellRowIndex][i] ; 
     533                for ( var i = cellIndex+1 ; i < oRow.length ; i++ ) 
     534                { 
     535                        if ( oRow[i].parentNode.rowIndex == newCellRowIndex ) 
     536                        { 
     537                                insertMarker = oRow[i] ; 
    537538                                break ; 
    538539                        } 
     
    540541 
    541542                // 3. Insert the new cell to the indicated place, with the appropriate rowSpan, next row. 
    542                 var newCell = FCK.EditorDocument.createElement( 'td' ) ; 
     543                var newCell = FCK.EditorDocument.createElement( currentCell.nodeName ) ; 
    543544                newCell.rowSpan = Math.floor( currentRowSpan / 2 ) ; 
    544545                if ( FCKBrowserInfo.IsGeckoLike ) 
     
    576577 
    577578                // 3. Insert a new cell to new row. 
    578                 var newCell = FCK.EditorDocument.createElement( 'td' ) ; 
     579                var newCell = FCK.EditorDocument.createElement( currentCell.nodeName ) ; 
    579580                if ( FCKBrowserInfo.IsGeckoLike ) 
    580581                        FCKTools.AppendBogusBr( newCell ) ; 
     
    632633// cells that are "spanned". For example, a row with 3 cells where the second cell has colSpan=2 and rowSpan=3 
    633634// will produce a bi-dimensional matrix with the following values (representing the cells): 
    634 //              Cell1, Cell2, Cell2, Cell 3 
    635 //              Cell4, Cell2, Cell2, Cell 5 
    636 FCKTableHandler._CreateTableMap = function( table ) 
    637 { 
     635//              Cell1, Cell2, Cell2, Cell2, Cell 3 
     636//              Cell4, Cell2, Cell2, Cell2, Cell 5 
     637FCKTableHandler._CreateTableMap = function( refCell ) 
     638{ 
     639        // It's really a tbody, thead or tfoot. This is only temporary. 
     640        var table = (refCell.nodeName == 'TABLE' ? refCell : refCell.parentNode.parentNode ) ; 
     641 
    638642        var aRows = table.rows ; 
    639643 
     
    820824 
    821825        var refCell = cells[0] ; 
    822         var tableMap = this._CreateTableMap( refCell.parentNode.parentNode ) ; 
     826        var tableMap = this._CreateTableMap( refCell ) ; 
    823827        var rowIdx = refCell.parentNode.rowIndex ; 
    824828        var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, refCell ) ; 
     
    848852 
    849853        var refCell = cells[0] ; 
    850         var tableMap = this._CreateTableMap( refCell.parentNode.parentNode ) ; 
     854        var tableMap = this._CreateTableMap( refCell ) ; 
    851855        var rowIdx = refCell.parentNode.rowIndex ; 
    852856        var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, refCell ) ; 
  • FCKeditor/trunk/_whatsnew.html

    r2363 r2373  
    5151                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2467">#2467</a>] Fixed JavaScript 
    5252                        error with the fit window command in source mode.</li> 
     53                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2472">#2472</a>] Splitting a TH 
     54                        will create a two TH, not a TH and a TD.</li> 
    5355        </ul> 
    5456        <p>