Ticket #4784: 4784_2.patch
File 4784_2.patch, 2.4 KB (added by , 14 years ago) |
---|
-
_source/plugins/tabletools/plugin.js
85 85 86 86 return retval; 87 87 } 88 89 function getBesideFocusableCell( cell, cellsToDelete ) { 90 var focusedCell; 88 91 92 return ( 93 ( focusedCell = cell.getPrevious() ) && 94 indexOf( cellsToDelete, focusedCell ) == -1 && 95 focusedCell 96 ) 97 || 98 ( 99 ( focusedCell = cell.getNext() ) && 100 indexOf( cellsToDelete, focusedCell ) == -1 && 101 focusedCell 102 ); 103 104 function indexOf( cells, cell ) { 105 for ( var i = 0, len = cells.length ; i < len ; i++ ) 106 { 107 if ( cells[i].$ == cell.$) 108 return i; 109 } 110 111 return -1; 112 } 113 } 114 115 function getToFocusedCell( cellsToDelete ) { 116 var i = 0, 117 last = cellsToDelete.length - 1, 118 cell,parentTr,tr; 119 120 // 1.first we check left or right side focusable cell row by row; 121 while ( cell = cellsToDelete[ i++ ] ) 122 { 123 cell = getBesideFocusableCell( cell, cellsToDelete ); 124 if ( cell ) 125 return cell; 126 } 127 128 // 2. then we check the toppest row focusable cell 129 parentTr = cellsToDelete[ 0 ].getParent(); 130 if ( tr = parentTr.getPrevious() ) 131 return tr.getLast(); 132 133 // 3. last we check the lowerest row focusable cell 134 parentTr = cellsToDelete[ last ].getParent(); 135 if ( tr = parentTr.getNext() ) 136 return tr.getChild( 0 ); 137 138 return null; 139 } 140 89 141 function clearRow( $tr ) 90 142 { 91 143 // Get the array of row's cells. … … 277 329 if ( selectionOrCell instanceof CKEDITOR.dom.selection ) 278 330 { 279 331 var cellsToDelete = getSelectedCells( selectionOrCell ); 332 var table = cellsToDelete[ 0 ] && cellsToDelete[ 0 ].getAscendant( 'table' ); 333 var cellToFocus = getToFocusedCell( cellsToDelete ); 334 280 335 for ( var i = cellsToDelete.length - 1 ; i >= 0 ; i-- ) 281 336 deleteCells( cellsToDelete[ i ] ); 337 338 if ( cellToFocus ) 339 placeCursorInCell( cellToFocus, true ); 340 else if ( table ) 341 table.remove(); 282 342 } 283 343 else if ( selectionOrCell instanceof CKEDITOR.dom.element ) 284 344 { 285 if ( selectionOrCell.getParent().getChildCount() == 1 ) 286 selectionOrCell.getParent().remove(); 345 var tr = selectionOrCell.getParent(); 346 if ( tr.getChildCount() == 1 ) 347 tr.remove(); 287 348 else 288 349 selectionOrCell.remove(); 289 350 }