source: trunk/admin/inc/FCKeditor/editor/_source/internals/fck_2.js@ 2

Last change on this file since 2 was 2, checked in by root, 15 years ago

importo il progetto

File size: 4.1 KB
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.js
14 * This is the second part of the "FCK" object creation. This is the main
15 * object that represents an editor instance.
16 *
17 * File Authors:
18 * Frederico Caldeira Knabben (fredck@fckeditor.net)
19 */
20
21// This collection is used by the browser specific implementations to tell
22// wich named commands must be handled separately.
23FCK.RedirectNamedCommands = new Object() ;
24
25FCK.ExecuteNamedCommand = function( commandName, commandParameter, noRedirect )
26{
27 FCKUndo.SaveUndoStep() ;
28
29 if ( !noRedirect && FCK.RedirectNamedCommands[ commandName ] != null )
30 FCK.ExecuteRedirectedNamedCommand( commandName, commandParameter ) ;
31 else
32 {
33 FCK.Focus() ;
34 FCK.EditorDocument.execCommand( commandName, false, commandParameter ) ;
35 FCK.Events.FireEvent( 'OnSelectionChange' ) ;
36 }
37
38 FCKUndo.SaveUndoStep() ;
39}
40
41FCK.GetNamedCommandState = function( commandName )
42{
43 try
44 {
45 if ( !FCK.EditorDocument.queryCommandEnabled( commandName ) )
46 return FCK_TRISTATE_DISABLED ;
47 else
48 return FCK.EditorDocument.queryCommandState( commandName ) ? FCK_TRISTATE_ON : FCK_TRISTATE_OFF ;
49 }
50 catch ( e )
51 {
52 return FCK_TRISTATE_OFF ;
53 }
54}
55
56FCK.GetNamedCommandValue = function( commandName )
57{
58 var sValue = '' ;
59 var eState = FCK.GetNamedCommandState( commandName ) ;
60
61 if ( eState == FCK_TRISTATE_DISABLED )
62 return null ;
63
64 try
65 {
66 sValue = this.EditorDocument.queryCommandValue( commandName ) ;
67 }
68 catch(e) {}
69
70 return sValue ? sValue : '' ;
71}
72
73FCK.PasteFromWord = function()
74{
75 FCKDialog.OpenDialog( 'FCKDialog_Paste', FCKLang.PasteFromWord, 'dialog/fck_paste.html', 400, 330, 'Word' ) ;
76}
77
78FCK.Preview = function()
79{
80 var iWidth = FCKConfig.ScreenWidth * 0.8 ;
81 var iHeight = FCKConfig.ScreenHeight * 0.7 ;
82 var iLeft = ( FCKConfig.ScreenWidth - iWidth ) / 2 ;
83 var oWindow = window.open( '', null, 'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + iWidth + ',height=' + iHeight + ',left=' + iLeft ) ;
84
85 var sHTML ;
86
87 if ( FCKConfig.FullPage )
88 {
89 if ( FCK.TempBaseTag.length > 0 )
90 sHTML = FCK.TempBaseTag + FCK.GetXHTML() ;
91 else
92 sHTML = FCK.GetXHTML() ;
93 }
94 else
95 {
96 sHTML =
97 FCKConfig.DocType +
98 '<html dir="' + FCKConfig.ContentLangDirection + '">' +
99 '<head>' +
100 FCK.TempBaseTag +
101 '<title>' + FCKLang.Preview + '</title>' +
102 FCK._GetEditorAreaStyleTags() +
103 '</head><body>' +
104 FCK.GetXHTML() +
105 '</body></html>' ;
106 }
107
108 oWindow.document.write( sHTML );
109 oWindow.document.close();
110}
111
112FCK.SwitchEditMode = function( noUndo )
113{
114 var bIsWysiwyg = ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ) ;
115 var sHtml ;
116
117 // Update the HTML in the view output to show.
118 if ( bIsWysiwyg )
119 {
120 if ( !noUndo && FCKBrowserInfo.IsIE )
121 FCKUndo.SaveUndoStep() ;
122
123 sHtml = FCK.GetXHTML( FCKConfig.FormatSource ) ;
124 }
125 else
126 sHtml = this.EditingArea.Textarea.value ;
127
128 FCK.EditMode = bIsWysiwyg ? FCK_EDITMODE_SOURCE : FCK_EDITMODE_WYSIWYG ;
129
130 FCK.SetHTML( sHtml ) ;
131
132 // Set the Focus.
133 FCK.Focus() ;
134
135 // Update the toolbar (Running it directly causes IE to fail).
136 FCKTools.RunFunction( FCK.ToolbarSet.RefreshModeState, FCK.ToolbarSet ) ;
137}
138
139FCK.CreateElement = function( tag )
140{
141 var e = FCK.EditorDocument.createElement( tag ) ;
142 return FCK.InsertElementAndGetIt( e ) ;
143}
144
145FCK.InsertElementAndGetIt = function( e )
146{
147 e.setAttribute( 'FCKTempLabel', 'true' ) ;
148
149 this.InsertElement( e ) ;
150
151 var aEls = FCK.EditorDocument.getElementsByTagName( e.tagName ) ;
152
153 for ( var i = 0 ; i < aEls.length ; i++ )
154 {
155 if ( aEls[i].getAttribute( 'FCKTempLabel' ) )
156 {
157 aEls[i].removeAttribute( 'FCKTempLabel' ) ;
158 return aEls[i] ;
159 }
160 }
161 return null ;
162}
Note: See TracBrowser for help on using the repository browser.