Ticket #2800: 2800_2.patch
File 2800_2.patch, 2.3 KB (added by , 15 years ago) |
---|
-
fcktablehandler.js
157 157 158 158 if ( !oCell ) return ; 159 159 160 // Get the cell's table.161 160 var oTable = FCKTools.GetElementAscensor( oCell, 'TABLE' ) ; 161 var tableMap = this._CreateTableMap( oCell ) ; 162 var rowIdx = oCell.parentNode.rowIndex ; 163 var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, oCell ) ; 164 var colSpan = isNaN( oCell.colSpan ) ? 1 : oCell.colSpan ; 162 165 163 // Get the cell index. 164 var iIndex = oCell.cellIndex ; 166 // Put the columns to delete in an array. 167 var aColumns = new Array() ; 168 for ( var t = 0; t <= colSpan-t; t++ ) 169 aColumns[t] = colIdx + t ; 165 170 166 // Loop throw all rows (from down to up, because it's possible that some 167 // rows will be deleted). 168 for ( var i = oTable.rows.length - 1 ; i >= 0 ; i-- ) 171 // Build newTableMap. 172 var maxCol = 0 ; 173 var newTableMap = new Array() ; 174 for ( var i = 0 ; i < tableMap.length ; i++ ) 169 175 { 170 // Get the row.171 var oRow = oTable.rows[i];176 if ( j > maxCol ) 177 maxCol = j ; 172 178 173 // If the cell to be removed is the first one and the row has just one cell.174 if ( iIndex == 0 && oRow.cells.length == 1)179 var newRow = new Array() ; 180 for ( var j = 0; j < tableMap[i].length ; j++ ) 175 181 { 176 // Remove the entire row. 177 FCKTableHandler.DeleteRows( oRow ) ; 178 continue ; 182 // Check if the cell is in a column to delete. 183 var delCol = 0 ; 184 for( var t = 0; t < aColumns.length; t++ ) 185 { 186 if( j == aColumns[t] ) 187 { 188 delCol = 1 ; 189 if( tableMap[i][j].colSpan < 2 ) 190 this._MarkCells( [tableMap[i][j]], '_Replace' ) ; 191 } 192 } 193 if( delCol == 0 ) 194 newRow.push( tableMap[i][j] ) ; 179 195 } 196 newTableMap.push( newRow ) ; 197 } 180 198 181 // If the cell to be removed exists the delete it. 182 if ( oRow.cells[iIndex] ) 183 oRow.removeChild( oRow.cells[iIndex] ) ; 184 } 199 // If the number of columns in the table is equal to the colspan of the selected cell than remove the table. 200 // Otherwise build the table. 201 if( maxCol == colSpan ) 202 oTable.parentNode.removeChild ( oTable ) ; 203 else 204 this._InstallTableMap( newTableMap, oCell.parentNode.parentNode.parentNode ) ; 185 205 } 186 206 187 207 FCKTableHandler.InsertCell = function( cell, insertBefore )