~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to wiki/htdocs/applets/FCKeditor/editor/_source/internals/fck_1_ie.js

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20080622211713-inlv5k4eifxckelr
ImportĀ upstreamĀ versionĀ 1.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 * "Support Open Source software. What about a donation today?"
 
12
 * 
 
13
 * File Name: fck_1_ie.js
 
14
 *      This is the first part of the "FCK" object creation. This is the main
 
15
 *      object that represents an editor instance.
 
16
 *      (IE specific implementations)
 
17
 * 
 
18
 * File Authors:
 
19
 *              Frederico Caldeira Knabben (fredck@fckeditor.net)
 
20
 */
 
21
 
 
22
FCK.Description = "FCKeditor for Internet Explorer 5.5+" ;
 
23
 
 
24
// The behaviors should be pointed using the FullBasePath to avoid security
 
25
// errors when using a differente BaseHref.
 
26
FCK._BehaviorsStyle =
 
27
        '<style type="text/css" _fcktemp="true"> \
 
28
                INPUT { behavior: url(' + FCKConfig.FullBasePath + 'css/behaviors/hiddenfield.htc) ; } ' ;
 
29
 
 
30
if ( FCKConfig.ShowBorders )
 
31
        FCK._BehaviorsStyle += 'TABLE { behavior: url(' + FCKConfig.FullBasePath + 'css/behaviors/showtableborders.htc) ; }' ;
 
32
 
 
33
// Disable resize handlers.
 
34
var sNoHandlers = 'INPUT, TEXTAREA, SELECT, .FCK__Anchor, .FCK__PageBreak' ;
 
35
 
 
36
if ( FCKConfig.DisableImageHandles )
 
37
        sNoHandlers += ', IMG' ;
 
38
 
 
39
if ( FCKConfig.DisableTableHandles )
 
40
        sNoHandlers += ', TABLE' ;
 
41
 
 
42
FCK._BehaviorsStyle += sNoHandlers + ' { behavior: url(' + FCKConfig.FullBasePath + 'css/behaviors/disablehandles.htc) ; }' ;
 
43
 
 
44
FCK._BehaviorsStyle += '</style>' ;
 
45
 
 
46
function Doc_OnMouseUp()
 
47
{
 
48
        if ( FCK.EditorWindow.event.srcElement.tagName == 'HTML' )
 
49
        {
 
50
                FCK.Focus() ;
 
51
                FCK.EditorWindow.event.cancelBubble     = true ;
 
52
                FCK.EditorWindow.event.returnValue      = false ;
 
53
        }
 
54
}
 
55
 
 
56
function Doc_OnPaste()
 
57
{
 
58
        if ( FCK.Status == FCK_STATUS_COMPLETE )
 
59
                return FCK.Events.FireEvent( "OnPaste" ) ;
 
60
        else
 
61
                return false ;
 
62
}
 
63
 
 
64
function Doc_OnContextMenu()
 
65
{
 
66
        var e = FCK.EditorWindow.event ;
 
67
        
 
68
        FCK.ShowContextMenu( e.screenX, e.screenY ) ;
 
69
        return false ;
 
70
}
 
71
 
 
72
function Doc_OnKeyDown()
 
73
{
 
74
        var e = FCK.EditorWindow.event ;
 
75
 
 
76
 
 
77
        switch ( e.keyCode )
 
78
        {
 
79
                case 13 :       // ENTER
 
80
                        if ( FCKConfig.UseBROnCarriageReturn && !(e.ctrlKey || e.altKey || e.shiftKey) )
 
81
                        {
 
82
                                Doc_OnKeyDownUndo() ;
 
83
                                
 
84
                                // We must ignore it if we are inside a List.
 
85
                                if ( FCK.EditorDocument.queryCommandState( 'InsertOrderedList' ) || FCK.EditorDocument.queryCommandState( 'InsertUnorderedList' ) )
 
86
                                        return true ;
 
87
 
 
88
                                // Insert the <BR> (The &nbsp; must be also inserted to make it work)
 
89
                                FCK.InsertHtml( '<br>&nbsp;' ) ;
 
90
 
 
91
                                // Remove the &nbsp;
 
92
                                var oRange = FCK.EditorDocument.selection.createRange() ;
 
93
                                oRange.moveStart( 'character', -1 ) ;
 
94
                                oRange.select() ;
 
95
                                FCK.EditorDocument.selection.clear() ;
 
96
 
 
97
                                return false ;
 
98
                        }
 
99
                        break ;
 
100
                
 
101
                case 8 :        // BACKSPACE
 
102
                        // We must delete a control selection by code and cancels the 
 
103
                        // keystroke, otherwise IE will execute the browser's "back" button.
 
104
                        if ( FCKSelection.GetType() == 'Control' )
 
105
                        {
 
106
                                FCKSelection.Delete() ;
 
107
                                return false ;
 
108
                        }
 
109
                        break ;
 
110
                
 
111
                case 9 :        // TAB
 
112
                        if ( FCKConfig.TabSpaces > 0 && !(e.ctrlKey || e.altKey || e.shiftKey) )
 
113
                        {
 
114
                                Doc_OnKeyDownUndo() ;
 
115
                                
 
116
                                FCK.InsertHtml( window.FCKTabHTML ) ;
 
117
                                return false ;
 
118
                        }
 
119
                        break ;
 
120
                case 90 :       // Z
 
121
                        if ( e.ctrlKey && !(e.altKey || e.shiftKey) )
 
122
                        {
 
123
                                FCKUndo.Undo() ;
 
124
                                return false ;
 
125
                        }
 
126
                        break ;
 
127
                case 89 :       // Y
 
128
                        if ( e.ctrlKey && !(e.altKey || e.shiftKey) )
 
129
                        {
 
130
                                FCKUndo.Redo() ;
 
131
                                return false ;
 
132
                        }
 
133
                        break ;
 
134
        }
 
135
        
 
136
        if ( !( e.keyCode >=16 && e.keyCode <= 18 ) )
 
137
                Doc_OnKeyDownUndo() ;
 
138
        return true ;
 
139
}
 
140
 
 
141
function Doc_OnKeyDownUndo()
 
142
{
 
143
        if ( !FCKUndo.Typing )
 
144
        {
 
145
                FCKUndo.SaveUndoStep() ;
 
146
                FCKUndo.Typing = true ;
 
147
                FCK.Events.FireEvent( "OnSelectionChange" ) ;
 
148
        }
 
149
        
 
150
        FCKUndo.TypesCount++ ;
 
151
 
 
152
        if ( FCKUndo.TypesCount > FCKUndo.MaxTypes )
 
153
        {
 
154
                FCKUndo.TypesCount = 0 ;
 
155
                FCKUndo.SaveUndoStep() ;
 
156
        }
 
157
}
 
158
 
 
159
function Doc_OnDblClick()
 
160
{
 
161
        FCK.OnDoubleClick( FCK.EditorWindow.event.srcElement ) ;
 
162
        FCK.EditorWindow.event.cancelBubble = true ;
 
163
}
 
164
 
 
165
function Doc_OnSelectionChange()
 
166
{
 
167
        FCK.Events.FireEvent( "OnSelectionChange" ) ;
 
168
}
 
169
 
 
170
FCK.InitializeBehaviors = function( dontReturn )
 
171
{
 
172
        // Set the focus to the editable area when clicking in the document area.
 
173
        // TODO: The cursor must be positioned at the end.
 
174
        this.EditorDocument.attachEvent( 'onmouseup', Doc_OnMouseUp ) ;
 
175
 
 
176
        // Intercept pasting operations
 
177
        this.EditorDocument.body.attachEvent( 'onpaste', Doc_OnPaste ) ;
 
178
 
 
179
        // Disable Right-Click and shows the context menu.
 
180
        this.EditorDocument.attachEvent('oncontextmenu', Doc_OnContextMenu ) ;
 
181
 
 
182
        // Build the "TAB" key replacement (if necessary).
 
183
        if ( FCKConfig.TabSpaces > 0 )
 
184
        {
 
185
                window.FCKTabHTML = '' ;
 
186
                for ( i = 0 ; i < FCKConfig.TabSpaces ; i++ )
 
187
                        window.FCKTabHTML += "&nbsp;" ;
 
188
        }
 
189
        this.EditorDocument.attachEvent("onkeydown", Doc_OnKeyDown ) ;
 
190
 
 
191
        this.EditorDocument.attachEvent("ondblclick", Doc_OnDblClick ) ;
 
192
 
 
193
        // Catch cursor movements
 
194
        this.EditorDocument.attachEvent("onselectionchange", Doc_OnSelectionChange ) ;
 
195
 
 
196
        //Enable editing
 
197
//      this.EditorDocument.body.contentEditable = true ;
 
198
}
 
199
 
 
200
FCK.Focus = function()
 
201
{
 
202
        try
 
203
        {
 
204
                if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG )
 
205
                        FCK.EditorDocument.body.focus() ;
 
206
                else
 
207
                        document.getElementById('eSourceField').focus() ;
 
208
        }
 
209
        catch(e) {}
 
210
}
 
211
 
 
212
FCK.SetHTML = function( html, forceWYSIWYG )
 
213
{
 
214
        if ( forceWYSIWYG || FCK.EditMode == FCK_EDITMODE_WYSIWYG )
 
215
        {
 
216
                html = FCKConfig.ProtectedSource.Protect( html ) ;
 
217
                html = FCK.ProtectUrls( html ) ;
 
218
 
 
219
                var sHtml ;
 
220
 
 
221
                if ( FCKConfig.FullPage )
 
222
                {
 
223
                        var sHtml =
 
224
                                FCK._BehaviorsStyle +
 
225
                                '<link href="' + FCKConfig.FullBasePath + 'css/fck_internal.css' + '" rel="stylesheet" type="text/css" _fcktemp="true" />' ;
 
226
 
 
227
                        if ( FCK.TempBaseTag.length > 0 && !FCKRegexLib.HasBaseTag.test( html ) )
 
228
                                sHtml += FCK.TempBaseTag ;
 
229
 
 
230
                        sHtml = html.replace( FCKRegexLib.HeadOpener, '$&' + sHtml ) ;
 
231
                }
 
232
                else
 
233
                {
 
234
                        sHtml =
 
235
                                FCKConfig.DocType +
 
236
                                '<html dir="' + FCKConfig.ContentLangDirection + '"' ;
 
237
                        
 
238
                        if ( FCKConfig.IEForceVScroll )
 
239
                                sHtml += ' style="overflow-y: scroll"' ;
 
240
                        
 
241
                        sHtml +=
 
242
                                '><head><title></title>' +
 
243
                                '<link href="' + FCKConfig.EditorAreaCSS + '" rel="stylesheet" type="text/css" />' +
 
244
                                '<link href="' + FCKConfig.FullBasePath + 'css/fck_internal.css' + '" rel="stylesheet" type="text/css" _fcktemp="true" />' ;
 
245
 
 
246
                        sHtml += FCK._BehaviorsStyle ;
 
247
                        sHtml += FCK.TempBaseTag ;
 
248
                        sHtml += '</head><body>' + html  + '</body></html>' ;
 
249
                }
 
250
 
 
251
//              this.EditorDocument.open( '', '_self', '', true ) ;             // This one opens popups in IE 5.5 - BUG 1204220 (I was not able to reproduce the problem).
 
252
                this.EditorDocument.open( '', 'replace' ) ;
 
253
                this.EditorDocument.write( sHtml ) ;
 
254
                this.EditorDocument.close() ;
 
255
 
 
256
                this.InitializeBehaviors() ;
 
257
                this.EditorDocument.body.contentEditable = true ;
 
258
 
 
259
                FCK.OnAfterSetHTML() ;
 
260
        }
 
261
        else
 
262
                document.getElementById('eSourceField').value = html ;
 
263
}
 
264
 
 
265
FCK.InsertHtml = function( html )
 
266
{
 
267
        html = FCKConfig.ProtectedSource.Protect( html ) ;
 
268
        html = FCK.ProtectUrls( html ) ;
 
269
 
 
270
        FCK.Focus() ;
 
271
 
 
272
        FCKUndo.SaveUndoStep() ;
 
273
 
 
274
        // Gets the actual selection.
 
275
        var oSel = FCK.EditorDocument.selection ;
 
276
 
 
277
        // Deletes the actual selection contents.
 
278
        if ( oSel.type.toLowerCase() != "none" )
 
279
                oSel.clear() ;
 
280
 
 
281
        // Insert the HTML.
 
282
        oSel.createRange().pasteHTML( html ) ;
 
283
}
 
284
 
 
285
FCK.SetInnerHtml = function( html )             // IE Only
 
286
{
 
287
        var oDoc = FCK.EditorDocument ;
 
288
        // Using the following trick, any comment in the begining of the HTML will
 
289
        // be preserved.
 
290
        oDoc.body.innerHTML = '<div id="__fakeFCKRemove__">&nbsp;</div>' + html ;
 
291
        oDoc.getElementById('__fakeFCKRemove__').removeNode( true ) ;
 
292
}
 
 
b'\\ No newline at end of file'