1 | /* |
---|
2 | * FCKeditor - The text editor for Internet - http://www.fckeditor.net |
---|
3 | * Copyright (C) 2003-2007 Frederico Caldeira Knabben |
---|
4 | * |
---|
5 | * == BEGIN LICENSE == |
---|
6 | * |
---|
7 | * Licensed under the terms of any of the following licenses at your |
---|
8 | * choice: |
---|
9 | * |
---|
10 | * - GNU General Public License Version 2 or later (the "GPL") |
---|
11 | * http://www.gnu.org/licenses/gpl.html |
---|
12 | * |
---|
13 | * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") |
---|
14 | * http://www.gnu.org/licenses/lgpl.html |
---|
15 | * |
---|
16 | * - Mozilla Public License Version 1.1 or later (the "MPL") |
---|
17 | * http://www.mozilla.org/MPL/MPL-1.1.html |
---|
18 | * |
---|
19 | * == END LICENSE == |
---|
20 | * |
---|
21 | * Define all commands available in the editor. |
---|
22 | */ |
---|
23 | |
---|
24 | var FCKCommands = FCK.Commands = new Object() ; |
---|
25 | FCKCommands.LoadedCommands = new Object() ; |
---|
26 | |
---|
27 | FCKCommands.RegisterCommand = function( commandName, command ) |
---|
28 | { |
---|
29 | this.LoadedCommands[ commandName ] = command ; |
---|
30 | } |
---|
31 | |
---|
32 | FCKCommands.GetCommand = function( commandName ) |
---|
33 | { |
---|
34 | var oCommand = FCKCommands.LoadedCommands[ commandName ] ; |
---|
35 | |
---|
36 | if ( oCommand ) |
---|
37 | return oCommand ; |
---|
38 | |
---|
39 | switch ( commandName ) |
---|
40 | { |
---|
41 | case 'DocProps' : oCommand = new FCKDialogCommand( 'DocProps' , FCKLang.DocProps , 'dialog/fck_docprops.html' , 400, 390, FCKCommands.GetFullPageState ) ; break ; |
---|
42 | case 'Templates' : oCommand = new FCKDialogCommand( 'Templates' , FCKLang.DlgTemplatesTitle , 'dialog/fck_template.html' , 380, 450 ) ; break ; |
---|
43 | case 'Link' : oCommand = new FCKDialogCommand( 'Link' , FCKLang.DlgLnkWindowTitle , 'dialog/fck_link.html' , 400, 330 ) ; break ; |
---|
44 | case 'Unlink' : oCommand = new FCKUnlinkCommand() ; break ; |
---|
45 | case 'Anchor' : oCommand = new FCKDialogCommand( 'Anchor' , FCKLang.DlgAnchorTitle , 'dialog/fck_anchor.html' , 370, 170 ) ; break ; |
---|
46 | case 'BulletedList' : oCommand = new FCKDialogCommand( 'BulletedList', FCKLang.BulletedListProp , 'dialog/fck_listprop.html?UL' , 370, 170 ) ; break ; |
---|
47 | case 'NumberedList' : oCommand = new FCKDialogCommand( 'NumberedList', FCKLang.NumberedListProp , 'dialog/fck_listprop.html?OL' , 370, 170 ) ; break ; |
---|
48 | case 'About' : oCommand = new FCKDialogCommand( 'About' , FCKLang.About , 'dialog/fck_about.html' , 400, 330 ) ; break ; |
---|
49 | |
---|
50 | case 'Find' : oCommand = new FCKDialogCommand( 'Find' , FCKLang.DlgFindTitle , 'dialog/fck_find.html' , 340, 170 ) ; break ; |
---|
51 | case 'Replace' : oCommand = new FCKDialogCommand( 'Replace' , FCKLang.DlgReplaceTitle , 'dialog/fck_replace.html' , 340, 200 ) ; break ; |
---|
52 | |
---|
53 | case 'Image' : oCommand = new FCKDialogCommand( 'Image' , FCKLang.DlgImgTitle , 'dialog/fck_image.html' , 450, 400 ) ; break ; |
---|
54 | case 'Flash' : oCommand = new FCKDialogCommand( 'Flash' , FCKLang.DlgFlashTitle , 'dialog/fck_flash.html' , 450, 400 ) ; break ; |
---|
55 | case 'SpecialChar' : oCommand = new FCKDialogCommand( 'SpecialChar', FCKLang.DlgSpecialCharTitle , 'dialog/fck_specialchar.html' , 400, 320 ) ; break ; |
---|
56 | case 'Smiley' : oCommand = new FCKDialogCommand( 'Smiley' , FCKLang.DlgSmileyTitle , 'dialog/fck_smiley.html' , FCKConfig.SmileyWindowWidth, FCKConfig.SmileyWindowHeight ) ; break ; |
---|
57 | case 'Table' : oCommand = new FCKDialogCommand( 'Table' , FCKLang.DlgTableTitle , 'dialog/fck_table.html' , 450, 250 ) ; break ; |
---|
58 | case 'TableProp' : oCommand = new FCKDialogCommand( 'Table' , FCKLang.DlgTableTitle , 'dialog/fck_table.html?Parent', 400, 250 ) ; break ; |
---|
59 | case 'TableCellProp': oCommand = new FCKDialogCommand( 'TableCell' , FCKLang.DlgCellTitle , 'dialog/fck_tablecell.html' , 550, 250 ) ; break ; |
---|
60 | |
---|
61 | case 'Style' : oCommand = new FCKStyleCommand() ; break ; |
---|
62 | |
---|
63 | case 'FontName' : oCommand = new FCKFontNameCommand() ; break ; |
---|
64 | case 'FontSize' : oCommand = new FCKFontSizeCommand() ; break ; |
---|
65 | case 'FontFormat' : oCommand = new FCKFormatBlockCommand() ; break ; |
---|
66 | |
---|
67 | case 'Source' : oCommand = new FCKSourceCommand() ; break ; |
---|
68 | case 'Preview' : oCommand = new FCKPreviewCommand() ; break ; |
---|
69 | case 'Save' : oCommand = new FCKSaveCommand() ; break ; |
---|
70 | case 'NewPage' : oCommand = new FCKNewPageCommand() ; break ; |
---|
71 | case 'PageBreak' : oCommand = new FCKPageBreakCommand() ; break ; |
---|
72 | |
---|
73 | case 'TextColor' : oCommand = new FCKTextColorCommand('ForeColor') ; break ; |
---|
74 | case 'BGColor' : oCommand = new FCKTextColorCommand('BackColor') ; break ; |
---|
75 | |
---|
76 | case 'Paste' : oCommand = new FCKPasteCommand() ; break ; |
---|
77 | case 'PasteText' : oCommand = new FCKPastePlainTextCommand() ; break ; |
---|
78 | case 'PasteWord' : oCommand = new FCKPasteWordCommand() ; break ; |
---|
79 | |
---|
80 | case 'TableInsertRow' : oCommand = new FCKTableCommand('TableInsertRow') ; break ; |
---|
81 | case 'TableDeleteRows' : oCommand = new FCKTableCommand('TableDeleteRows') ; break ; |
---|
82 | case 'TableInsertColumn' : oCommand = new FCKTableCommand('TableInsertColumn') ; break ; |
---|
83 | case 'TableDeleteColumns' : oCommand = new FCKTableCommand('TableDeleteColumns') ; break ; |
---|
84 | case 'TableInsertCell' : oCommand = new FCKTableCommand('TableInsertCell') ; break ; |
---|
85 | case 'TableDeleteCells' : oCommand = new FCKTableCommand('TableDeleteCells') ; break ; |
---|
86 | case 'TableMergeCells' : oCommand = new FCKTableCommand('TableMergeCells') ; break ; |
---|
87 | case 'TableSplitCell' : oCommand = new FCKTableCommand('TableSplitCell') ; break ; |
---|
88 | case 'TableDelete' : oCommand = new FCKTableCommand('TableDelete') ; break ; |
---|
89 | |
---|
90 | case 'Form' : oCommand = new FCKDialogCommand( 'Form' , FCKLang.Form , 'dialog/fck_form.html' , 380, 230 ) ; break ; |
---|
91 | case 'Checkbox' : oCommand = new FCKDialogCommand( 'Checkbox' , FCKLang.Checkbox , 'dialog/fck_checkbox.html' , 380, 230 ) ; break ; |
---|
92 | case 'Radio' : oCommand = new FCKDialogCommand( 'Radio' , FCKLang.RadioButton , 'dialog/fck_radiobutton.html' , 380, 230 ) ; break ; |
---|
93 | case 'TextField' : oCommand = new FCKDialogCommand( 'TextField' , FCKLang.TextField , 'dialog/fck_textfield.html' , 380, 230 ) ; break ; |
---|
94 | case 'Textarea' : oCommand = new FCKDialogCommand( 'Textarea' , FCKLang.Textarea , 'dialog/fck_textarea.html' , 380, 230 ) ; break ; |
---|
95 | case 'HiddenField' : oCommand = new FCKDialogCommand( 'HiddenField', FCKLang.HiddenField , 'dialog/fck_hiddenfield.html' , 380, 230 ) ; break ; |
---|
96 | case 'Button' : oCommand = new FCKDialogCommand( 'Button' , FCKLang.Button , 'dialog/fck_button.html' , 380, 230 ) ; break ; |
---|
97 | case 'Select' : oCommand = new FCKDialogCommand( 'Select' , FCKLang.SelectionField, 'dialog/fck_select.html' , 400, 380 ) ; break ; |
---|
98 | case 'ImageButton' : oCommand = new FCKDialogCommand( 'ImageButton', FCKLang.ImageButton , 'dialog/fck_image.html?ImageButton', 450, 400 ) ; break ; |
---|
99 | |
---|
100 | case 'SpellCheck' : oCommand = new FCKSpellCheckCommand() ; break ; |
---|
101 | case 'FitWindow' : oCommand = new FCKFitWindow() ; break ; |
---|
102 | |
---|
103 | case 'Undo' : oCommand = new FCKUndoCommand() ; break ; |
---|
104 | case 'Redo' : oCommand = new FCKRedoCommand() ; break ; |
---|
105 | |
---|
106 | case 'SelectAll' : oCommand = new FCKSelectAllCommand() ; break ; |
---|
107 | |
---|
108 | // Generic Undefined command (usually used when a command is under development). |
---|
109 | case 'Undefined' : oCommand = new FCKUndefinedCommand() ; break ; |
---|
110 | |
---|
111 | // By default we assume that it is a named command. |
---|
112 | default: |
---|
113 | if ( FCKRegexLib.NamedCommands.test( commandName ) ) |
---|
114 | oCommand = new FCKNamedCommand( commandName ) ; |
---|
115 | else |
---|
116 | { |
---|
117 | alert( FCKLang.UnknownCommand.replace( /%1/g, commandName ) ) ; |
---|
118 | return null ; |
---|
119 | } |
---|
120 | } |
---|
121 | |
---|
122 | FCKCommands.LoadedCommands[ commandName ] = oCommand ; |
---|
123 | |
---|
124 | return oCommand ; |
---|
125 | } |
---|
126 | |
---|
127 | // Gets the state of the "Document Properties" button. It must be enabled only |
---|
128 | // when "Full Page" editing is available. |
---|
129 | FCKCommands.GetFullPageState = function() |
---|
130 | { |
---|
131 | return FCKConfig.FullPage ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ; |
---|
132 | } |
---|