+ {\r
+ cell = new CKEDITOR.dom.element( cloneCol[ i ] ).clone();\r
+ cell.removeAttribute( 'colSpan' );\r
+ !CKEDITOR.env.ie && cell.appendBogus();\r
+ cell[ insertBefore? 'insertBefore' : 'insertAfter' ].call( cell, new CKEDITOR.dom.element ( cloneCol[ i ] ) );\r
+ cell = cell.$;\r
+ }\r
+\r
+ i += cell.rowSpan - 1;\r
+ }\r
+ }\r
+\r
+ function deleteColumns( selectionOrCell )\r
+ {\r
+ var cells = getSelectedCells( selectionOrCell ),\r
+ firstCell = cells[ 0 ],\r
+ lastCell = cells[ cells.length - 1 ],\r
+ table = firstCell.getAscendant( 'table' ),\r
+ map = CKEDITOR.tools.buildTableMap( table ),\r
+ startColIndex,\r
+ endColIndex,\r
+ rowsToDelete = [];\r
+\r
+ // Figure out selected cells' column indices.\r
+ for ( var i = 0, rows = map.length; i < rows; i++ )\r
+ {\r
+ for ( var j = 0, cols = map[ i ].length; j < cols; j++ )\r
+ {\r
+ if ( map[ i ][ j ] == firstCell.$ )\r
+ startColIndex = j;\r
+ if ( map[ i ][ j ] == lastCell.$ )\r
+ endColIndex = j;\r
+ }\r
+ }\r
+\r
+ // Delete cell or reduce cell spans by checking through the table map.\r
+ for ( i = startColIndex; i <= endColIndex; i++ )\r
+ {\r
+ for ( j = 0; j < map.length; j++ )\r
+ {\r
+ var mapRow = map[ j ],\r
+ row = new CKEDITOR.dom.element( table.$.rows[ j ] ),\r
+ cell = new CKEDITOR.dom.element( mapRow[ i ] );\r
+\r
+ if ( cell.$ )\r
+ {\r
+ if ( cell.$.colSpan == 1 )\r
+ cell.remove();\r
+ // Reduce the col spans.\r
+ else\r
+ cell.$.colSpan -= 1;\r
+\r
+ j += cell.$.rowSpan - 1;\r
+\r
+ if ( !row.$.cells.length )\r
+ rowsToDelete.push( row );\r
+ }\r
+ }\r