Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
431 ddelon 1
/*
2
 * FCKeditor - The text editor for internet
3
 * Copyright (C) 2003-2005 Frederico Caldeira Knabben
4
 *
5
 * Licensed under the terms of the GNU Lesser General Public License:
6
 * 		http://www.opensource.org/licenses/lgpl-license.php
7
 *
8
 * For further information visit:
9
 * 		http://www.fckeditor.net/
10
 *
11
 * File Name: fck_2_ie.js
12
 * 	This is the second part of the "FCK" object creation. This is the main
13
 * 	object that represents an editor instance.
14
 * 	(IE specific implementations)
15
 *
16
 * File Authors:
17
 * 		Frederico Caldeira Knabben (fredck@fckeditor.net)
18
 */
19
 
20
/*
21
if ( FCKConfig.UseBROnCarriageReturn )
22
{
23
	// Named commands to be handled by this browsers specific implementation.
24
	FCK.RedirectNamedCommands =
25
	{
26
		InsertOrderedList	: true,
27
		InsertUnorderedList	: true
28
	}
29
 
30
	FCK.ExecuteRedirectedNamedCommand = function( commandName, commandParameter )
31
	{
32
		if ( commandName == 'InsertOrderedList' || commandName == 'InsertUnorderedList' )
33
		{
34
			if ( !(FCK.EditorDocument.queryCommandState( 'InsertOrderedList' ) || FCK.EditorDocument.queryCommandState( 'InsertUnorderedList' )) )
35
			{
36
			}
37
		}
38
 
39
		FCK.ExecuteNamedCommand( commandName, commandParameter ) ;
40
	}
41
}
42
*/
43
 
44
FCK.Paste = function()
45
{
46
	if ( FCKConfig.ForcePasteAsPlainText )
47
	{
48
		FCK.PasteAsPlainText() ;
49
		return false ;
50
	}
51
	else if ( FCKConfig.AutoDetectPasteFromWord )
52
	{
53
		var sHTML = FCK.GetClipboardHTML() ;
54
		var re = /<\w[^>]* class="?MsoNormal"?/gi ;
55
		if ( re.test( sHTML ) )
56
		{
57
			if ( confirm( FCKLang["PasteWordConfirm"] ) )
58
			{
59
				FCK.PasteFromWord() ;
60
				return false ;
61
			}
62
		}
63
	}
64
	else
65
		return true ;
66
}
67
 
68
FCK.PasteAsPlainText = function()
69
{
70
	// Get the data available in the clipboard and encodes it in HTML.
71
	var sText = FCKTools.HTMLEncode( clipboardData.getData("Text") ) ;
72
 
73
	// Replace the carriage returns with <BR>
74
	sText = sText.replace( /\n/g, '<BR>' ) ;
75
 
76
	// Insert the resulting data in the editor.
77
	this.InsertHtml( sText ) ;
78
}
79
/*
80
FCK.PasteFromWord = function()
81
{
82
	FCK.CleanAndPaste( FCK.GetClipboardHTML() ) ;
83
}
84
*/
85
FCK.InsertElement = function( element )
86
{
87
	FCK.InsertHtml( element.outerHTML ) ;
88
}
89
 
90
FCK.GetClipboardHTML = function()
91
{
92
	var oDiv = document.getElementById( '___FCKHiddenDiv' ) ;
93
 
94
	if ( !oDiv )
95
	{
96
		var oDiv = document.createElement( 'DIV' ) ;
97
		oDiv.id = '___FCKHiddenDiv' ;
98
		oDiv.style.visibility	= 'hidden' ;
99
		oDiv.style.overflow		= 'hidden' ;
100
		oDiv.style.position		= 'absolute' ;
101
		oDiv.style.width		= 1 ;
102
		oDiv.style.height		= 1 ;
103
 
104
		document.body.appendChild( oDiv ) ;
105
	}
106
 
107
	oDiv.innerHTML = '' ;
108
 
109
	var oTextRange = document.body.createTextRange() ;
110
	oTextRange.moveToElementText( oDiv ) ;
111
	oTextRange.execCommand( 'Paste' ) ;
112
 
113
	var sData = oDiv.innerHTML ;
114
	oDiv.innerHTML = '' ;
115
 
116
	return sData ;
117
}
118
 
119
FCK.AttachToOnSelectionChange = function( functionPointer )
120
{
121
	this.Events.AttachEvent( 'OnSelectionChange', functionPointer ) ;
122
}
123
 
124
/*
125
FCK.AttachToOnSelectionChange = function( functionPointer )
126
{
127
	FCK.EditorDocument.attachEvent( 'onselectionchange', functionPointer ) ;
128
}
129
*/
130
 
131
FCK.CreateLink = function( url )
132
{
133
	FCK.ExecuteNamedCommand( 'Unlink' ) ;
134
 
135
	if ( url.length > 0 )
136
	{
137
		// Generate a temporary name for the link.
138
		var sTempUrl = 'javascript:void(0);/*' + ( new Date().getTime() ) + '*/' ;
139
 
140
		// Use the internal "CreateLink" command to create the link.
141
		FCK.ExecuteNamedCommand( 'CreateLink', sTempUrl ) ;
142
 
143
		// Loof for the just create link.
144
		var oLinks = this.EditorDocument.links ;
145
 
146
		for ( i = 0 ; i < oLinks.length ; i++ )
147
		{
148
			if ( oLinks[i].href == sTempUrl )
149
			{
150
				oLinks[i].href = url ;
151
				return oLinks[i] ;
152
			}
153
		}
154
	}
155
}