2
* FCKeditor - The text editor for internet
3
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
5
* Licensed under the terms of the GNU Lesser General Public License:
6
* http://www.opensource.org/licenses/lgpl-license.php
8
* For further information visit:
9
* http://www.fckeditor.net/
11
* "Support Open Source software. What about a donation today?"
13
* File Name: fckselection_ie.js
14
* Active selection functions. (IE specific implementation)
17
* Frederico Caldeira Knabben (fredck@fckeditor.net)
20
// Get the selection type.
21
FCKSelection.GetType = function()
23
return FCK.EditorDocument.selection.type ;
26
// Retrieves the selected element (if any), just in the case that a single
27
// element (object like and image or a table) is selected.
28
FCKSelection.GetSelectedElement = function()
30
if ( this.GetType() == 'Control' )
32
var oRange = FCK.EditorDocument.selection.createRange() ;
34
if ( oRange && oRange.item )
35
return FCK.EditorDocument.selection.createRange().item(0) ;
39
FCKSelection.GetParentElement = function()
41
switch ( this.GetType() )
44
return FCKSelection.GetSelectedElement().parentElement ;
48
return FCK.EditorDocument.selection.createRange().parentElement() ;
52
FCKSelection.SelectNode = function( node )
55
FCK.EditorDocument.selection.empty() ;
56
var oRange = FCK.EditorDocument.selection.createRange() ;
57
oRange.moveToElementText( node ) ;
61
FCKSelection.Collapse = function( toStart )
64
var oRange = FCK.EditorDocument.selection.createRange() ;
65
oRange.collapse( toStart == null || toStart === true ) ;
69
// The "nodeTagName" parameter must be Upper Case.
70
FCKSelection.HasAncestorNode = function( nodeTagName )
74
if ( FCK.EditorDocument.selection.type == "Control" )
76
oContainer = this.GetSelectedElement() ;
80
var oRange = FCK.EditorDocument.selection.createRange() ;
81
oContainer = oRange.parentElement() ;
86
if ( oContainer.tagName == nodeTagName ) return true ;
87
oContainer = oContainer.parentNode ;
93
// The "nodeTagName" parameter must be UPPER CASE.
94
FCKSelection.MoveToAncestorNode = function( nodeTagName )
98
if ( FCK.EditorDocument.selection.type == "Control" )
100
var oRange = FCK.EditorDocument.selection.createRange() ;
101
for ( i = 0 ; i < oRange.length ; i++ )
103
if (oRange(i).parentNode)
105
oNode = oRange(i).parentNode ;
112
var oRange = FCK.EditorDocument.selection.createRange() ;
113
oNode = oRange.parentElement() ;
116
while ( oNode && oNode.nodeName != nodeTagName )
117
oNode = oNode.parentNode ;
122
FCKSelection.Delete = function()
124
// Gets the actual selection.
125
var oSel = FCK.EditorDocument.selection ;
127
// Deletes the actual selection contents.
128
if ( oSel.type.toLowerCase() != "none" )
135
// START iCM Modifications
137
// Move the cursor position (the selection point) to a specific offset within a specific node
138
// If no offset specified, the start of the node is assumed
139
FCKSelection.SetCursorPosition = function ( oNode, nOffset )
141
if ( typeof nOffset == "undefined" ) nOffset = 0 ;
143
FCK.Selection.SelectNode( oNode ) ; // Doesn't handle offsets currently but offset always zero at mo
144
FCK.Selection.Collapse( true ) ;
146
oNode.scrollIntoView( false );
149
// END iCM Modifications