1/*
2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3 * Copyright (C) 2003-2007 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 (non-IE).
22 */
23
24FCKTableHandler.GetSelectedCells = function()
25{
26	var aCells = new Array() ;
27
28	var oSelection = FCK.EditorWindow.getSelection() ;
29
30	// If the selection is a text.
31	if ( oSelection.rangeCount == 1 && oSelection.anchorNode.nodeType == 3 )
32	{
33		var oParent = FCKTools.GetElementAscensor( oSelection.anchorNode, 'TD,TH' ) ;
34
35		if ( oParent )
36			aCells[0] = oParent ;
37
38		return aCells ;
39	}
40
41	for ( var i = 0 ; i < oSelection.rangeCount ; i++ )
42	{
43		var oRange = oSelection.getRangeAt(i) ;
44		var oCell ;
45
46		if ( oRange.startContainer.tagName.Equals( 'TD', 'TH' ) )
47			oCell = oRange.startContainer ;
48		else
49			oCell = oRange.startContainer.childNodes[ oRange.startOffset ] ;
50
51		if ( oCell.tagName.Equals( 'TD', 'TH' ) )
52			aCells[aCells.length] = oCell ;
53	}
54
55	return aCells ;
56}
57