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

« back to all changes in this revision

Viewing changes to wiki/htdocs/applets/FCKeditor/editor/_source/commandclasses/fck_othercommands.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_othercommands.js
 
14
 *      Definition of other commands that are not available internaly in the
 
15
 *      browser (see FCKNamedCommand).
 
16
 * 
 
17
 * File Authors:
 
18
 *              Frederico Caldeira Knabben (fredck@fckeditor.net)
 
19
 */
 
20
 
 
21
// ### General Dialog Box Commands.
 
22
var FCKDialogCommand = function( name, title, url, width, height, getStateFunction, getStateParam )
 
23
{
 
24
        this.Name       = name ;
 
25
        this.Title      = title ;
 
26
        this.Url        = url ;
 
27
        this.Width      = width ;
 
28
        this.Height     = height ;
 
29
 
 
30
        this.GetStateFunction   = getStateFunction ;
 
31
        this.GetStateParam              = getStateParam ;
 
32
}
 
33
 
 
34
FCKDialogCommand.prototype.Execute = function()
 
35
{
 
36
        FCKDialog.OpenDialog( 'FCKDialog_' + this.Name , this.Title, this.Url, this.Width, this.Height ) ;
 
37
}
 
38
 
 
39
FCKDialogCommand.prototype.GetState = function()
 
40
{
 
41
        if ( this.GetStateFunction )
 
42
                return this.GetStateFunction( this.GetStateParam ) ;
 
43
        else
 
44
                return FCK_TRISTATE_OFF ;
 
45
}
 
46
 
 
47
// Generic Undefined command (usually used when a command is under development).
 
48
var FCKUndefinedCommand = function()
 
49
{
 
50
        this.Name = 'Undefined' ;
 
51
}
 
52
 
 
53
FCKUndefinedCommand.prototype.Execute = function()
 
54
{
 
55
        alert( FCKLang.NotImplemented ) ;
 
56
}
 
57
 
 
58
FCKUndefinedCommand.prototype.GetState = function()
 
59
{
 
60
        return FCK_TRISTATE_OFF ;
 
61
}
 
62
 
 
63
// ### FontName
 
64
var FCKFontNameCommand = function()
 
65
{
 
66
        this.Name = 'FontName' ;
 
67
}
 
68
 
 
69
FCKFontNameCommand.prototype.Execute = function( fontName )
 
70
{
 
71
        if (fontName == null || fontName == "")
 
72
        {
 
73
                // TODO: Remove font name attribute.
 
74
        }
 
75
        else
 
76
                FCK.ExecuteNamedCommand( 'FontName', fontName ) ;
 
77
}
 
78
 
 
79
FCKFontNameCommand.prototype.GetState = function()
 
80
{
 
81
        return FCK.GetNamedCommandValue( 'FontName' ) ;
 
82
}
 
83
 
 
84
// ### FontSize
 
85
var FCKFontSizeCommand = function()
 
86
{
 
87
        this.Name = 'FontSize' ;
 
88
}
 
89
 
 
90
FCKFontSizeCommand.prototype.Execute = function( fontSize )
 
91
{
 
92
        if ( typeof( fontSize ) == 'string' ) fontSize = parseInt(fontSize) ;
 
93
 
 
94
        if ( fontSize == null || fontSize == '' )
 
95
        {
 
96
                // TODO: Remove font size attribute (Now it works with size 3. Will it work forever?)
 
97
                FCK.ExecuteNamedCommand( 'FontSize', 3 ) ;
 
98
        }
 
99
        else
 
100
                FCK.ExecuteNamedCommand( 'FontSize', fontSize ) ;
 
101
}
 
102
 
 
103
FCKFontSizeCommand.prototype.GetState = function()
 
104
{
 
105
        return FCK.GetNamedCommandValue( 'FontSize' ) ;
 
106
}
 
107
 
 
108
// ### FormatBlock
 
109
var FCKFormatBlockCommand = function()
 
110
{
 
111
        this.Name = 'FormatBlock' ;
 
112
}
 
113
 
 
114
FCKFormatBlockCommand.prototype.Execute = function( formatName )
 
115
{
 
116
        if ( formatName == null || formatName == '' )
 
117
                FCK.ExecuteNamedCommand( 'FormatBlock', '<P>' ) ;
 
118
        else if ( formatName == 'div' && FCKBrowserInfo.IsGecko )
 
119
                FCK.ExecuteNamedCommand( 'FormatBlock', 'div' ) ;
 
120
        else
 
121
                FCK.ExecuteNamedCommand( 'FormatBlock', '<' + formatName + '>' ) ;
 
122
}
 
123
 
 
124
FCKFormatBlockCommand.prototype.GetState = function()
 
125
{
 
126
        return FCK.GetNamedCommandValue( 'FormatBlock' ) ;
 
127
}
 
128
 
 
129
// ### Preview
 
130
var FCKPreviewCommand = function()
 
131
{
 
132
        this.Name = 'Preview' ;
 
133
}
 
134
 
 
135
FCKPreviewCommand.prototype.Execute = function()
 
136
{
 
137
     FCK.Preview() ;
 
138
}
 
139
 
 
140
FCKPreviewCommand.prototype.GetState = function()
 
141
{
 
142
        return FCK_TRISTATE_OFF ;
 
143
}
 
144
 
 
145
// ### Save
 
146
var FCKSaveCommand = function()
 
147
{
 
148
        this.Name = 'Save' ;
 
149
}
 
150
 
 
151
FCKSaveCommand.prototype.Execute = function()
 
152
{
 
153
        // Get the linked field form.
 
154
        var oForm = FCK.LinkedField.form ;
 
155
 
 
156
        if ( typeof( oForm.onsubmit ) == 'function' )
 
157
        {
 
158
                var bRet = oForm.onsubmit() ;
 
159
                if ( bRet != null && bRet === false )
 
160
                        return ;
 
161
        }
 
162
 
 
163
        // Submit the form.
 
164
        oForm.submit() ;
 
165
}
 
166
 
 
167
FCKSaveCommand.prototype.GetState = function()
 
168
{
 
169
        return FCK_TRISTATE_OFF ;
 
170
}
 
171
 
 
172
// ### NewPage
 
173
var FCKNewPageCommand = function()
 
174
{
 
175
        this.Name = 'NewPage' ;
 
176
}
 
177
 
 
178
FCKNewPageCommand.prototype.Execute = function()
 
179
{
 
180
        FCKUndo.SaveUndoStep() ;
 
181
        FCK.SetHTML( '' ) ;
 
182
        FCKUndo.Typing = true ;
 
183
//      FCK.SetHTML( FCKBrowserInfo.IsGecko ? '&nbsp;' : '' ) ;
 
184
//      FCK.SetHTML( FCKBrowserInfo.IsGecko ? GECKO_BOGUS : '' ) ;
 
185
}
 
186
 
 
187
FCKNewPageCommand.prototype.GetState = function()
 
188
{
 
189
        return FCK_TRISTATE_OFF ;
 
190
}
 
191
 
 
192
// ### Source button
 
193
var FCKSourceCommand = function()
 
194
{
 
195
        this.Name = 'Source' ;
 
196
}
 
197
 
 
198
FCKSourceCommand.prototype.Execute = function()
 
199
{
 
200
        if ( FCKBrowserInfo.IsGecko )
 
201
        {
 
202
                var iWidth      = FCKConfig.ScreenWidth * 0.65 ;
 
203
                var iHeight     = FCKConfig.ScreenHeight * 0.65 ;
 
204
                FCKDialog.OpenDialog( 'FCKDialog_Source', FCKLang.Source, 'dialog/fck_source.html', iWidth, iHeight, null, null, true ) ;
 
205
        }
 
206
        else
 
207
            FCK.SwitchEditMode() ;
 
208
}
 
209
 
 
210
FCKSourceCommand.prototype.GetState = function()
 
211
{
 
212
        return ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ? FCK_TRISTATE_OFF : FCK_TRISTATE_ON ) ;
 
213
}
 
214
 
 
215
// ### Undo
 
216
var FCKUndoCommand = function()
 
217
{
 
218
        this.Name = 'Undo' ;
 
219
}
 
220
 
 
221
FCKUndoCommand.prototype.Execute = function()
 
222
{
 
223
        if ( FCKBrowserInfo.IsIE )
 
224
                FCKUndo.Undo() ;
 
225
        else
 
226
                FCK.ExecuteNamedCommand( 'Undo' ) ;
 
227
}
 
228
 
 
229
FCKUndoCommand.prototype.GetState = function()
 
230
{
 
231
        if ( FCKBrowserInfo.IsIE )
 
232
                return ( FCKUndo.CheckUndoState() ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ) ;
 
233
        else
 
234
                return FCK.GetNamedCommandState( 'Undo' ) ;
 
235
}
 
236
 
 
237
// ### Redo
 
238
var FCKRedoCommand = function()
 
239
{
 
240
        this.Name = 'Redo' ;
 
241
}
 
242
 
 
243
FCKRedoCommand.prototype.Execute = function()
 
244
{
 
245
        if ( FCKBrowserInfo.IsIE )
 
246
                FCKUndo.Redo() ;
 
247
        else
 
248
                FCK.ExecuteNamedCommand( 'Redo' ) ;
 
249
}
 
250
 
 
251
FCKRedoCommand.prototype.GetState = function()
 
252
{
 
253
        if ( FCKBrowserInfo.IsIE )
 
254
                return ( FCKUndo.CheckRedoState() ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ) ;
 
255
        else
 
256
                return FCK.GetNamedCommandState( 'Redo' ) ;
 
257
}
 
258
 
 
259
// ### Page Break
 
260
var FCKPageBreakCommand = function()
 
261
{
 
262
        this.Name = 'PageBreak' ;
 
263
}
 
264
 
 
265
FCKPageBreakCommand.prototype.Execute = function()
 
266
{
 
267
//      var e = FCK.EditorDocument.createElement( 'CENTER' ) ;
 
268
//      e.style.pageBreakAfter = 'always' ;
 
269
 
 
270
        // Tidy was removing the empty CENTER tags, so the following solution has 
 
271
        // been found. It also validates correctly as XHTML 1.0 Strict.
 
272
        var e = FCK.EditorDocument.createElement( 'DIV' ) ;
 
273
        e.style.pageBreakAfter = 'always' ;
 
274
        e.innerHTML = '<span style="DISPLAY:none">&nbsp;</span>' ;
 
275
        
 
276
        var oFakeImage = FCKDocumentProcessors_CreateFakeImage( 'FCK__PageBreak', e ) ;
 
277
        oFakeImage      = FCK.InsertElement( oFakeImage ) ;
 
278
}
 
279
 
 
280
FCKPageBreakCommand.prototype.GetState = function()
 
281
{
 
282
        return 0 ; // FCK_TRISTATE_OFF
 
283
}
 
 
b'\\ No newline at end of file'