source: companies/serpro/expressoMail1_2/js/fckeditor/editor/_source/internals/fck_2_gecko.js @ 903

Revision 903, 4.8 KB checked in by niltonneto, 15 years ago (diff)

Importacao inicial do Expresso do Serpro

Line 
1/*
2 * FCKeditor - The text editor for internet
3 * Copyright (C) 2003-2006 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_2_gecko.js
14 *      This is the second part of the "FCK" object creation. This is the main
15 *      object that represents an editor instance.
16 *      (Gecko specific implementations)
17 *
18 * File Authors:
19 *              Frederico Caldeira Knabben (fredck@fckeditor.net)
20 */
21
22// GetNamedCommandState overload for Gecko.
23FCK._BaseGetNamedCommandState = FCK.GetNamedCommandState ;
24FCK.GetNamedCommandState = function( commandName )
25{
26        switch ( commandName )
27        {
28                case 'Unlink' :
29                        return FCKSelection.HasAncestorNode('A') ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ;
30                default :
31                        return FCK._BaseGetNamedCommandState( commandName ) ;
32        }
33}
34
35// Named commands to be handled by this browsers specific implementation.
36FCK.RedirectNamedCommands =
37{
38        Print   : true,
39        Paste   : true,
40        Cut             : true,
41        Copy    : true
42}
43
44// ExecuteNamedCommand overload for Gecko.
45FCK.ExecuteRedirectedNamedCommand = function( commandName, commandParameter )
46{
47        switch ( commandName )
48        {
49                case 'Print' :
50                        FCK.EditorWindow.print() ;
51                        break ;
52                case 'Paste' :
53                        try                     { if ( FCK.Paste() ) FCK.ExecuteNamedCommand( 'Paste', null, true ) ; }
54                        catch (e)       { alert(FCKLang.PasteErrorPaste) ; }
55                        break ;
56                case 'Cut' :
57                        try                     { FCK.ExecuteNamedCommand( 'Cut', null, true ) ; }
58                        catch (e)       { alert(FCKLang.PasteErrorCut) ; }
59                        break ;
60                case 'Copy' :
61                        try                     { FCK.ExecuteNamedCommand( 'Copy', null, true ) ; }
62                        catch (e)       { alert(FCKLang.PasteErrorCopy) ; }
63                        break ;                 
64                default :
65                        FCK.ExecuteNamedCommand( commandName, commandParameter ) ;
66        }
67}
68
69FCK.AttachToOnSelectionChange = function( functionPointer )
70{
71        this.Events.AttachEvent( 'OnSelectionChange', functionPointer ) ;
72}
73
74FCK.Paste = function()
75{
76        if ( FCKConfig.ForcePasteAsPlainText )
77        {
78                FCK.PasteAsPlainText() ;       
79                return false ;
80        }
81/* For now, the AutoDetectPasteFromWord feature is IE only.
82        else if ( FCKConfig.AutoDetectPasteFromWord )
83        {
84                var sHTML = FCK.GetClipboardHTML() ;
85                var re = /<\w[^>]* class="?MsoNormal"?/gi ;
86                if ( re.test( sHTML ) )
87                {
88                        if ( confirm( FCKLang["PasteWordConfirm"] ) )
89                        {
90                                FCK.PasteFromWord() ;
91                                return false ;
92                        }
93                }
94        }
95*/
96        else
97                return true ;
98}
99
100//**
101// FCK.InsertHtml: Inserts HTML at the current cursor location. Deletes the
102// selected content if any.
103FCK.InsertHtml = function( html )
104{
105        html = FCKConfig.ProtectedSource.Protect( html ) ;
106        html = FCK.ProtectUrls( html ) ;
107
108        // Delete the actual selection.
109        var oSel = FCKSelection.Delete() ;
110       
111        // Get the first available range.
112        var oRange = oSel.getRangeAt(0) ;
113       
114        // Create a fragment with the input HTML.
115        var oFragment = oRange.createContextualFragment( html ) ;
116       
117        // Get the last available node.
118        var oLastNode = oFragment.lastChild ;
119
120        // Insert the fragment in the range.
121        oRange.insertNode(oFragment) ;
122       
123        // Set the cursor after the inserted fragment.
124        FCKSelection.SelectNode( oLastNode ) ;
125        FCKSelection.Collapse( false ) ;
126       
127        this.Focus() ;
128}
129
130FCK.InsertElement = function( element )
131{
132        // Deletes the actual selection.
133        var oSel = FCKSelection.Delete() ;
134       
135        // Gets the first available range.
136        var oRange = oSel.getRangeAt(0) ;
137       
138        // Inserts the element in the range.
139        oRange.insertNode( element ) ;
140       
141        // Set the cursor after the inserted fragment.
142        FCKSelection.SelectNode( element ) ;
143        FCKSelection.Collapse( false ) ;
144
145        this.Focus() ;
146}
147
148FCK.PasteAsPlainText = function()
149{
150        // TODO: Implement the "Paste as Plain Text" code.
151       
152        FCKDialog.OpenDialog( 'FCKDialog_Paste', FCKLang.PasteAsText, 'dialog/fck_paste.html', 400, 330, 'PlainText' ) ;
153       
154/*
155        var sText = FCKTools.HTMLEncode( clipboardData.getData("Text") ) ;
156        sText = sText.replace( /\n/g, '<BR>' ) ;
157        this.InsertHtml( sText ) ;     
158*/
159}
160/*
161FCK.PasteFromWord = function()
162{
163        // TODO: Implement the "Paste as Plain Text" code.
164       
165        FCKDialog.OpenDialog( 'FCKDialog_Paste', FCKLang.PasteFromWord, 'dialog/fck_paste.html', 400, 330, 'Word' ) ;
166
167//      FCK.CleanAndPaste( FCK.GetClipboardHTML() ) ;
168}
169*/
170FCK.GetClipboardHTML = function()
171{
172        return '' ;
173}
174
175FCK.CreateLink = function( url )
176{       
177        FCK.ExecuteNamedCommand( 'Unlink' ) ;
178       
179        if ( url.length > 0 )
180        {
181                // Generate a temporary name for the link.
182                var sTempUrl = 'javascript:void(0);/*' + ( new Date().getTime() ) + '*/' ;
183               
184                // Use the internal "CreateLink" command to create the link.
185                FCK.ExecuteNamedCommand( 'CreateLink', sTempUrl ) ;
186
187                // Retrieve the just created link using XPath.
188                var oLink = document.evaluate("//a[@href='" + sTempUrl + "']", this.EditorDocument.body, null, 9, null).singleNodeValue ;
189               
190                if ( oLink )
191                {
192                        oLink.href = url ;
193                        return oLink ;
194                }
195        }
196}
Note: See TracBrowser for help on using the repository browser.