Ticket #2800: 2800.patch
File 2800.patch, 2.2 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 be delete. 183 var delCol = 0 ; 184 for( var t = 0; t < aColumns.length; t++ ) 185 { 186 if( j == aColumns[t] ) 187 delCol = 1 ; 188 } 189 190 if( delCol == 0 ) 191 newRow.push( tableMap[i][j] ) ; 179 192 } 193 newTableMap.push( newRow ) ; 194 } 180 195 181 // If the cell to be removed exists the delete it. 182 if ( oRow.cells[iIndex] ) 183 oRow.removeChild( oRow.cells[iIndex] ) ; 184 } 196 // If the number of columns in the table is equal to the colspan of the selected cell than remove the table. 197 // Otherwise build the table. 198 if( maxCol == colSpan ) 199 oTable.parentNode.removeChild ( oTable ) ; 200 else 201 this._InstallTableMap( newTableMap, oCell.parentNode.parentNode.parentNode ) ; 185 202 } 186 203 187 204 FCKTableHandler.InsertCell = function( cell, insertBefore )