| 1 |
/* |
| 2 |
* FCKeditor - The text editor for Internet - http://www.fckeditor.net |
| 3 |
* Copyright (C) 2003-2009 Frederico Caldeira Knabben |
| 4 |
* |
| 5 |
* == BEGIN LICENSE == |
| 6 |
* |
| 7 |
* Licensed under the terms of any of the following licenses at your |
| 8 |
* choice: |
| 9 |
* |
| 10 |
* - GNU General Public License Version 2 or later (the "GPL") |
| 11 |
* http://www.gnu.org/licenses/gpl.html |
| 12 |
* |
| 13 |
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL") |
| 14 |
* http://www.gnu.org/licenses/lgpl.html |
| 15 |
* |
| 16 |
* - Mozilla Public License Version 1.1 or later (the "MPL") |
| 17 |
* http://www.mozilla.org/MPL/MPL-1.1.html |
| 18 |
* |
| 19 |
* == END LICENSE == |
| 20 |
* |
| 21 |
* Manage table operations (IE specific). |
| 22 |
*/ |
| 23 |
|
| 24 |
FCKTableHandler.GetSelectedCells = function() |
| 25 |
{ |
| 26 |
if ( FCKSelection.GetType() == 'Control' ) |
| 27 |
{ |
| 28 |
var td = FCKSelection.MoveToAncestorNode( ['TD', 'TH'] ) ; |
| 29 |
return td ? [ td ] : [] ; |
| 30 |
} |
| 31 |
|
| 32 |
var aCells = new Array() ; |
| 33 |
|
| 34 |
var oRange = FCKSelection.GetSelection().createRange() ; |
| 35 |
// var oParent = oRange.parentElement() ; |
| 36 |
var oParent = FCKSelection.GetParentElement() ; |
| 37 |
|
| 38 |
if ( oParent && oParent.tagName.Equals( 'TD', 'TH' ) ) |
| 39 |
aCells[0] = oParent ; |
| 40 |
else |
| 41 |
{ |
| 42 |
oParent = FCKSelection.MoveToAncestorNode( 'TABLE' ) ; |
| 43 |
|
| 44 |
if ( oParent ) |
| 45 |
{ |
| 46 |
// Loops throw all cells checking if the cell is, or part of it, is inside the selection |
| 47 |
// and then add it to the selected cells collection. |
| 48 |
for ( var i = 0 ; i < oParent.cells.length ; i++ ) |
| 49 |
{ |
| 50 |
var oCellRange = FCK.EditorDocument.body.createTextRange() ; |
| 51 |
oCellRange.moveToElementText( oParent.cells[i] ) ; |
| 52 |
|
| 53 |
if ( oRange.inRange( oCellRange ) |
| 54 |
|| ( oRange.compareEndPoints('StartToStart',oCellRange) >= 0 && oRange.compareEndPoints('StartToEnd',oCellRange) <= 0 ) |
| 55 |
|| ( oRange.compareEndPoints('EndToStart',oCellRange) >= 0 && oRange.compareEndPoints('EndToEnd',oCellRange) <= 0 ) ) |
| 56 |
{ |
| 57 |
aCells[aCells.length] = oParent.cells[i] ; |
| 58 |
} |
| 59 |
} |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
return aCells ; |
| 64 |
} |
| 65 |
|