!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998-1999
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Simon Fraser (sfraser@netscape.com)
24 * Ryan Cassin (rcassin@supernova.org)
25 * Kathleen Brade (brade@netscape.com)
26 * Daniel Glazman (glazman@netscape.com)
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * either of the GNU General Public License Version 2 or later (the "GPL"),
30 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31 * in which case the provisions of the GPL or the LGPL are applicable instead
32 * of those above. If you wish to allow use of your version of this file only
33 * under the terms of either the GPL or the LGPL, and not to allow others to
34 * use your version of this file under the terms of the MPL, indicate your
35 * decision by deleting the provisions above and replace them with the notice
36 * and other provisions required by the GPL or the LGPL. If you do not delete
37 * the provisions above, a recipient may use your version of this file under
38 * the terms of any one of the MPL, the GPL or the LGPL.
39 *
40 * ***** END LICENSE BLOCK ***** */
41
42 /* Implementations of nsIControllerCommand for composer commands */
43
44 var gComposerJSCommandControllerID = 0;
45
46
47 //-----------------------------------------------------------------------------------
SetupHTMLEditorCommands
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
48 function SetupHTMLEditorCommands()
49 {
50 var commandTable = GetComposerCommandTable();
51 if (!commandTable)
52 return;
53
54 // Include everthing a text editor does
55 SetupTextEditorCommands();
56
57 //dump("Registering HTML editor commands\n");
58
59 commandTable.registerCommand("cmd_renderedHTMLEnabler", nsDummyHTMLCommand);
60
61 commandTable.registerCommand("cmd_grid", nsGridCommand);
62
63 commandTable.registerCommand("cmd_listProperties", nsListPropertiesCommand);
64 commandTable.registerCommand("cmd_pageProperties", nsPagePropertiesCommand);
65 commandTable.registerCommand("cmd_colorProperties", nsColorPropertiesCommand);
66 commandTable.registerCommand("cmd_advancedProperties", nsAdvancedPropertiesCommand);
67 commandTable.registerCommand("cmd_objectProperties", nsObjectPropertiesCommand);
68 commandTable.registerCommand("cmd_removeNamedAnchors", nsRemoveNamedAnchorsCommand);
69 commandTable.registerCommand("cmd_editLink", nsEditLinkCommand);
70
71 commandTable.registerCommand("cmd_form", nsFormCommand);
72 commandTable.registerCommand("cmd_inputtag", nsInputTagCommand);
73 commandTable.registerCommand("cmd_inputimage", nsInputImageCommand);
74 commandTable.registerCommand("cmd_textarea", nsTextAreaCommand);
75 commandTable.registerCommand("cmd_select", nsSelectCommand);
76 commandTable.registerCommand("cmd_button", nsButtonCommand);
77 commandTable.registerCommand("cmd_label", nsLabelCommand);
78 commandTable.registerCommand("cmd_fieldset", nsFieldSetCommand);
79 commandTable.registerCommand("cmd_isindex", nsIsIndexCommand);
80 commandTable.registerCommand("cmd_image", nsImageCommand);
81 commandTable.registerCommand("cmd_hline", nsHLineCommand);
82 commandTable.registerCommand("cmd_link", nsLinkCommand);
83 commandTable.registerCommand("cmd_anchor", nsAnchorCommand);
84 commandTable.registerCommand("cmd_insertHTMLWithDialog", nsInsertHTMLWithDialogCommand);
85 commandTable.registerCommand("cmd_insertBreak", nsInsertBreakCommand);
86 commandTable.registerCommand("cmd_insertBreakAll",nsInsertBreakAllCommand);
87
88 commandTable.registerCommand("cmd_table", nsInsertOrEditTableCommand);
89 commandTable.registerCommand("cmd_editTable", nsEditTableCommand);
90 commandTable.registerCommand("cmd_SelectTable", nsSelectTableCommand);
91 commandTable.registerCommand("cmd_SelectRow", nsSelectTableRowCommand);
92 commandTable.registerCommand("cmd_SelectColumn", nsSelectTableColumnCommand);
93 commandTable.registerCommand("cmd_SelectCell", nsSelectTableCellCommand);
94 commandTable.registerCommand("cmd_SelectAllCells", nsSelectAllTableCellsCommand);
95 commandTable.registerCommand("cmd_InsertTable", nsInsertTableCommand);
96 commandTable.registerCommand("cmd_InsertRowAbove", nsInsertTableRowAboveCommand);
97 commandTable.registerCommand("cmd_InsertRowBelow", nsInsertTableRowBelowCommand);
98 commandTable.registerCommand("cmd_InsertColumnBefore", nsInsertTableColumnBeforeCommand);
99 commandTable.registerCommand("cmd_InsertColumnAfter", nsInsertTableColumnAfterCommand);
100 commandTable.registerCommand("cmd_InsertCellBefore", nsInsertTableCellBeforeCommand);
101 commandTable.registerCommand("cmd_InsertCellAfter", nsInsertTableCellAfterCommand);
102 commandTable.registerCommand("cmd_DeleteTable", nsDeleteTableCommand);
103 commandTable.registerCommand("cmd_DeleteRow", nsDeleteTableRowCommand);
104 commandTable.registerCommand("cmd_DeleteColumn", nsDeleteTableColumnCommand);
105 commandTable.registerCommand("cmd_DeleteCell", nsDeleteTableCellCommand);
106 commandTable.registerCommand("cmd_DeleteCellContents", nsDeleteTableCellContentsCommand);
107 commandTable.registerCommand("cmd_JoinTableCells", nsJoinTableCellsCommand);
108 commandTable.registerCommand("cmd_SplitTableCell", nsSplitTableCellCommand);
109 commandTable.registerCommand("cmd_TableOrCellColor", nsTableOrCellColorCommand);
110 commandTable.registerCommand("cmd_NormalizeTable", nsNormalizeTableCommand);
111 commandTable.registerCommand("cmd_smiley", nsSetSmiley);
112 commandTable.registerCommand("cmd_ConvertToTable", nsConvertToTable);
113 }
114
SetupTextEditorCommands
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
115 function SetupTextEditorCommands()
116 {
117 var commandTable = GetComposerCommandTable();
118 if (!commandTable)
119 return;
120
121 //dump("Registering plain text editor commands\n");
122
123 commandTable.registerCommand("cmd_find", nsFindCommand);
124 commandTable.registerCommand("cmd_findNext", nsFindAgainCommand);
125 commandTable.registerCommand("cmd_findPrev", nsFindAgainCommand);
126 commandTable.registerCommand("cmd_rewrap", nsRewrapCommand);
127 commandTable.registerCommand("cmd_spelling", nsSpellingCommand);
128 commandTable.registerCommand("cmd_validate", nsValidateCommand);
129 commandTable.registerCommand("cmd_checkLinks", nsCheckLinksCommand);
130 commandTable.registerCommand("cmd_insertChars", nsInsertCharsCommand);
131 }
132
SetupComposerWindowCommands
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
133 function SetupComposerWindowCommands()
134 {
135 // Don't need to do this if already done
136 if (gComposerWindowControllerID)
137 return;
138
139 // Create a command controller and register commands
140 // specific to Web Composer window (file-related commands, HTML Source...)
141 // We can't use the composer controller created on the content window else
142 // we can't process commands when in HTMLSource editor
143 // IMPORTANT: For each of these commands, the doCommand method
144 // must first call FinishHTMLSource()
145 // to go from HTML Source mode to any other edit mode
146
147 var windowControllers = window.controllers;
148
149 if (!windowControllers) return;
150
151 var commandTable;
152 var composerController;
153 var editorController;
154 try {
155 composerController = Components.classes["@mozilla.org/embedcomp/base-command-controller;1"].createInstance();
156
157 editorController = composerController.QueryInterface(Components.interfaces.nsIControllerContext);
158 editorController.init(null); // init it without passing in a command table
159
160 // Get the nsIControllerCommandTable interface we need to register commands
161 var interfaceRequestor = composerController.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
162 commandTable = interfaceRequestor.getInterface(Components.interfaces.nsIControllerCommandTable);
163 }
164 catch (e)
165 {
166 dump("Failed to create composerController\n");
167 return;
168 }
169
170
171 if (!commandTable)
172 {
173 dump("Failed to get interface for nsIControllerCommandManager\n");
174 return;
175 }
176
177 // File-related commands
178 commandTable.registerCommand("cmd_open", nsOpenCommand);
179 commandTable.registerCommand("cmd_save", nsSaveCommand);
180 commandTable.registerCommand("cmd_saveAs", nsSaveAsCommand);
181 commandTable.registerCommand("cmd_exportToText", nsExportToTextCommand);
182 commandTable.registerCommand("cmd_saveAndChangeEncoding", nsSaveAndChangeEncodingCommand);
183 commandTable.registerCommand("cmd_publish", nsPublishCommand);
184 commandTable.registerCommand("cmd_publishAs", nsPublishAsCommand);
185 commandTable.registerCommand("cmd_publishSettings",nsPublishSettingsCommand);
186 commandTable.registerCommand("cmd_revert", nsRevertCommand);
187 commandTable.registerCommand("cmd_openRemote", nsOpenRemoteCommand);
188 commandTable.registerCommand("cmd_preview", nsPreviewCommand);
189 commandTable.registerCommand("cmd_editSendPage", nsSendPageCommand);
190 commandTable.registerCommand("cmd_print", nsPrintCommand);
191 commandTable.registerCommand("cmd_printSetup", nsPrintSetupCommand);
192 commandTable.registerCommand("cmd_quit", nsQuitCommand);
193 commandTable.registerCommand("cmd_close", nsCloseCommand);
194 commandTable.registerCommand("cmd_preferences", nsPreferencesCommand);
195
196 // Edit Mode commands
197 if (GetCurrentEditorType() == "html")
198 {
199 commandTable.registerCommand("cmd_NormalMode", nsNormalModeCommand);
200 commandTable.registerCommand("cmd_AllTagsMode", nsAllTagsModeCommand);
201 commandTable.registerCommand("cmd_HTMLSourceMode", nsHTMLSourceModeCommand);
202 commandTable.registerCommand("cmd_PreviewMode", nsPreviewModeCommand);
203 commandTable.registerCommand("cmd_FinishHTMLSource", nsFinishHTMLSource);
204 commandTable.registerCommand("cmd_CancelHTMLSource", nsCancelHTMLSource);
205 commandTable.registerCommand("cmd_updateStructToolbar", nsUpdateStructToolbarCommand);
206 }
207
208 windowControllers.insertControllerAt(0, editorController);
209
210 // Store the controller ID so we can be sure to get the right one later
211 gComposerWindowControllerID = windowControllers.getControllerId(editorController);
212 }
213
214 //-----------------------------------------------------------------------------------
GetComposerCommandTable
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
215 function GetComposerCommandTable()
216 {
217 var controller;
218 if (gComposerJSCommandControllerID)
219 {
220 try {
221 controller = window.content.controllers.getControllerById(gComposerJSCommandControllerID);
222 } catch (e) {}
223 }
224 if (!controller)
225 {
226 //create it
227 controller = Components.classes["@mozilla.org/embedcomp/base-command-controller;1"].createInstance();
228
229 var editorController = controller.QueryInterface(Components.interfaces.nsIControllerContext);
230 editorController.init(null);
231 editorController.setCommandContext(GetCurrentEditorElement());
232 window.content.controllers.insertControllerAt(0, controller);
233
234 // Store the controller ID so we can be sure to get the right one later
235 gComposerJSCommandControllerID = window.content.controllers.getControllerId(controller);
236 }
237
238 if (controller)
239 {
240 var interfaceRequestor = controller.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
241 return interfaceRequestor.getInterface(Components.interfaces.nsIControllerCommandTable);
242 }
243 return null;
244 }
245
246 //-----------------------------------------------------------------------------------
goUpdateCommandState
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
247 function goUpdateCommandState(command)
248 {
249 try
250 {
251 var controller = top.document.commandDispatcher.getControllerForCommand(command);
252 if (!(controller instanceof Components.interfaces.nsICommandController))
253 return;
254
255 var params = newCommandParams();
256 if (!params) return;
257
258 controller.getCommandStateWithParams(command, params);
259
260 switch (command)
261 {
262 case "cmd_bold":
263 case "cmd_italic":
264 case "cmd_underline":
265 case "cmd_var":
266 case "cmd_samp":
267 case "cmd_code":
268 case "cmd_acronym":
269 case "cmd_abbr":
270 case "cmd_cite":
271 case "cmd_strong":
272 case "cmd_em":
273 case "cmd_superscript":
274 case "cmd_subscript":
275 case "cmd_strikethrough":
276 case "cmd_tt":
277 case "cmd_nobreak":
278 case "cmd_ul":
279 case "cmd_ol":
280 pokeStyleUI(command, params.getBooleanValue("state_all"));
281 break;
282
283 case "cmd_paragraphState":
284 case "cmd_align":
285 case "cmd_highlight":
286 case "cmd_backgroundColor":
287 case "cmd_fontColor":
288 case "cmd_fontFace":
289 case "cmd_fontSize":
290 case "cmd_absPos":
291 pokeMultiStateUI(command, params);
292 break;
293
294 case "cmd_decreaseZIndex":
295 case "cmd_increaseZIndex":
296 case "cmd_indent":
297 case "cmd_outdent":
298 case "cmd_increaseFont":
299 case "cmd_decreaseFont":
300 case "cmd_removeStyles":
301 case "cmd_smiley":
302 break;
303
304 default: dump("no update for command: " +command+"\n");
305 }
306 }
307 catch (e) { dump("An error occurred updating the "+command+" command: \n"+e+"\n"); }
308 }
309
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
310 function goUpdateComposerMenuItems(commandset)
311 {
312 //dump("Updating commands for " + commandset.id + "\n");
313
314 for (var i = 0; i < commandset.childNodes.length; i++)
315 {
316 var commandNode = commandset.childNodes[i];
317 var commandID = commandNode.id;
318 if (commandID)
319 {
320 goUpdateCommand(commandID); // enable or disable
321 if (commandNode.hasAttribute("state"))
322 goUpdateCommandState(commandID);
323 }
324 }
325 }
326
327 //-----------------------------------------------------------------------------------
goDoCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
328 function goDoCommandParams(command, params)
329 {
330 try
331 {
332 var controller = top.document.commandDispatcher.getControllerForCommand(command);
333 if (controller && controller.isCommandEnabled(command))
334 {
335 if (controller instanceof Components.interfaces.nsICommandController)
336 {
337 controller.doCommandWithParams(command, params);
338
339 // the following two lines should be removed when we implement observers
340 if (params)
341 controller.getCommandStateWithParams(command, params);
342 }
343 else
344 {
345 controller.doCommand(command);
346 }
347 ResetStructToolbar();
348 }
349 }
350 catch (e)
351 {
352 dump("An error occurred executing the "+command+" command\n");
353 }
354 }
355
pokeStyleUI
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
356 function pokeStyleUI(uiID, aDesiredState)
357 {
358 try {
359 var commandNode = top.document.getElementById(uiID);
360 if (!commandNode)
361 return;
362
363 var uiState = ("true" == commandNode.getAttribute("state"));
364 if (aDesiredState != uiState)
365 {
366 var newState;
367 if (aDesiredState)
368 newState = "true";
369 else
370 newState = "false";
371 commandNode.setAttribute("state", newState);
372 }
373 } catch(e) { dump("poking UI for "+uiID+" failed: "+e+"\n"); }
374 }
375
doStyleUICommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
376 function doStyleUICommand(cmdStr)
377 {
378 try
379 {
380 var cmdParams = newCommandParams();
381 goDoCommandParams(cmdStr, cmdParams);
382 if (cmdParams)
383 pokeStyleUI(cmdStr, cmdParams.getBooleanValue("state_all"));
384
385 ResetStructToolbar();
386 } catch(e) {}
387 }
388
pokeMultiStateUI
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
389 function pokeMultiStateUI(uiID, cmdParams)
390 {
391 try
392 {
393 var commandNode = document.getElementById(uiID);
394 if (!commandNode)
395 return;
396
397 var isMixed = cmdParams.getBooleanValue("state_mixed");
398 var desiredAttrib;
399 if (isMixed)
400 desiredAttrib = "mixed";
401 else {
402 var valuetype = cmdParams.getValueType("state_attribute");
403 if (valuetype == Components.interfaces.nsICommandParams.eStringType) {
404 desiredAttrib = cmdParams.getCStringValue("state_attribute");
405 } else {
406 desiredAttrib = cmdParams.getStringValue("state_attribute");
407 }
408
409 }
410
411 var uiState = commandNode.getAttribute("state");
412 if (desiredAttrib != uiState)
413 {
414 commandNode.setAttribute("state", desiredAttrib);
415 }
416 } catch(e) {}
417 }
418
doStatefulCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
419 function doStatefulCommand(commandID, newState)
420 {
421 var commandNode = document.getElementById(commandID);
422 if (commandNode)
423 commandNode.setAttribute("state", newState);
424 gContentWindow.focus(); // needed for command dispatch to work
425
426 try
427 {
428 var cmdParams = newCommandParams();
429 if (!cmdParams) return;
430
431 cmdParams.setStringValue("state_attribute", newState);
432 goDoCommandParams(commandID, cmdParams);
433
434 pokeMultiStateUI(commandID, cmdParams);
435
436 ResetStructToolbar();
437 } catch(e) { dump("error thrown in doStatefulCommand: "+e+"\n"); }
438 }
439
440 //-----------------------------------------------------------------------------------
PrintObject
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
441 function PrintObject(obj)
442 {
443 dump("-----" + obj + "------\n");
444 var names = "";
445 for (var i in obj)
446 {
447 if (i == "value")
448 names += i + ": " + obj.value + "\n";
449 else if (i == "id")
450 names += i + ": " + obj.id + "\n";
451 else
452 names += i + "\n";
453 }
454
455 dump(names + "-----------\n");
456 }
457
458 //-----------------------------------------------------------------------------------
PrintNodeID
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
459 function PrintNodeID(id)
460 {
461 PrintObject(document.getElementById(id));
462 }
463
464 //-----------------------------------------------------------------------------------
465 var nsDummyHTMLCommand =
466 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
467 isCommandEnabled: function(aCommand, dummy)
468 {
469 return (IsDocumentEditable() && IsEditingRenderedHTML());
470 },
471
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
472 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
473 doCommandParams: function(aCommand, aParams, aRefCon) {},
474
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
475 doCommand: function(aCommand)
476 {
477 // do nothing
478 dump("Hey, who's calling the dummy command?\n");
479 }
480
481 };
482
483 //-----------------------------------------------------------------------------------
484 var nsOpenCommand =
485 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
486 isCommandEnabled: function(aCommand, dummy)
487 {
488 return true; // we can always do this
489 },
490
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
491 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
492 doCommandParams: function(aCommand, aParams, aRefCon) {},
493
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
494 doCommand: function(aCommand)
495 {
496 var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
497 fp.init(window, GetString("OpenHTMLFile"), nsIFilePicker.modeOpen);
498
499 SetFilePickerDirectory(fp, "html");
500
501 // When loading into Composer, direct user to prefer HTML files and text files,
502 // so we call separately to control the order of the filter list
503 fp.appendFilters(nsIFilePicker.filterHTML);
504 fp.appendFilters(nsIFilePicker.filterText);
505 fp.appendFilters(nsIFilePicker.filterAll);
506
507 /* doesn't handle *.shtml files */
508 try {
509 fp.show();
510 /* need to handle cancel (uncaught exception at present) */
511 }
512 catch (ex) {
513 dump("filePicker.chooseInputFile threw an exception\n");
514 }
515
516 /* This checks for already open window and activates it...
517 * note that we have to test the native path length
518 * since file.URL will be "file:///" if no filename picked (Cancel button used)
519 */
520 if (fp.file && fp.file.path.length > 0) {
521 SaveFilePickerDirectory(fp, "html");
522 editPage(fp.fileURL.spec, window, false);
523 }
524 }
525 };
526
527 // STRUCTURE TOOLBAR
528 //
529 var nsUpdateStructToolbarCommand =
530 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
531 isCommandEnabled: function(aCommand, dummy)
532 {
533 UpdateStructToolbar();
534 return true;
535 },
536
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
537 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
538 doCommandParams: function(aCommand, aParams, aRefCon) {},
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
539 doCommand: function(aCommand) {}
540 }
541
542 // ******* File output commands and utilities ******** //
543 //-----------------------------------------------------------------------------------
544 var nsSaveCommand =
545 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
546 isCommandEnabled: function(aCommand, dummy)
547 {
548 // Always allow saving when editing a remote document,
549 // otherwise the document modified state would prevent that
550 // when you first open a remote file.
551 try {
552 var docUrl = GetDocumentUrl();
553 return IsDocumentEditable() &&
554 (IsDocumentModified() || IsHTMLSourceChanged() ||
555 IsUrlAboutBlank(docUrl) || GetScheme(docUrl) != "file");
556 } catch (e) {return false;}
557 },
558
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
559 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
560 doCommandParams: function(aCommand, aParams, aRefCon) {},
561
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
562 doCommand: function(aCommand)
563 {
564 var result = false;
565 var editor = GetCurrentEditor();
566 if (editor)
567 {
568 FinishHTMLSource();
569 result = SaveDocument(IsUrlAboutBlank(GetDocumentUrl()), false, editor.contentsMIMEType);
570 window.content.focus();
571 }
572 return result;
573 }
574 }
575
576 var nsSaveAsCommand =
577 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
578 isCommandEnabled: function(aCommand, dummy)
579 {
580 return (IsDocumentEditable());
581 },
582
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
583 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
584 doCommandParams: function(aCommand, aParams, aRefCon) {},
585
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
586 doCommand: function(aCommand)
587 {
588 var editor = GetCurrentEditor();
589 if (editor)
590 {
591 FinishHTMLSource();
592 var result = SaveDocument(true, false, editor.contentsMIMEType);
593 window.content.focus();
594 return result;
595 }
596 return false;
597 }
598 }
599
600 var nsExportToTextCommand =
601 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
602 isCommandEnabled: function(aCommand, dummy)
603 {
604 return (IsDocumentEditable());
605 },
606
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
607 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
608 doCommandParams: function(aCommand, aParams, aRefCon) {},
609
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
610 doCommand: function(aCommand)
611 {
612 if (GetCurrentEditor())
613 {
614 FinishHTMLSource();
615 var result = SaveDocument(true, true, "text/plain");
616 window.content.focus();
617 return result;
618 }
619 return false;
620 }
621 }
622
623 var nsSaveAndChangeEncodingCommand =
624 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
625 isCommandEnabled: function(aCommand, dummy)
626 {
627 return (IsDocumentEditable());
628 },
629
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
630 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
631 doCommandParams: function(aCommand, aParams, aRefCon) {},
632
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
633 doCommand: function(aCommand)
634 {
635 FinishHTMLSource();
636 window.ok = false;
637 window.exportToText = false;
638 var oldTitle = GetDocumentTitle();
639 window.openDialog("chrome://editor/content/EditorSaveAsCharset.xul","_blank", "chrome,close,titlebar,modal,resizable=yes");
640
641 if (GetDocumentTitle() != oldTitle)
642 UpdateWindowTitle();
643
644 if (window.ok)
645 {
646 if (window.exportToText)
647 {
648 window.ok = SaveDocument(true, true, "text/plain");
649 }
650 else
651 {
652 var editor = GetCurrentEditor();
653 window.ok = SaveDocument(true, false, editor ? editor.contentsMIMEType : null);
654 }
655 }
656
657 window.content.focus();
658 return window.ok;
659 }
660 };
661
662 var nsPublishCommand =
663 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
664 isCommandEnabled: function(aCommand, dummy)
665 {
666 if (IsDocumentEditable())
667 {
668 // Always allow publishing when editing a local document,
669 // otherwise the document modified state would prevent that
670 // when you first open any local file.
671 try {
672 var docUrl = GetDocumentUrl();
673 return IsDocumentModified() || IsHTMLSourceChanged()
674 || IsUrlAboutBlank(docUrl) || GetScheme(docUrl) == "file";
675 } catch (e) {return false;}
676 }
677 return false;
678 },
679
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
680 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
681 doCommandParams: function(aCommand, aParams, aRefCon) {},
682
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
683 doCommand: function(aCommand)
684 {
685 if (GetCurrentEditor())
686 {
687 var docUrl = GetDocumentUrl();
688 var filename = GetFilename(docUrl);
689 var publishData;
690 var showPublishDialog = false;
691
692 // First check pref to always show publish dialog
693 try {
694 var prefs = GetPrefs();
695 if (prefs)
696 showPublishDialog = prefs.getBoolPref("editor.always_show_publish_dialog");
697 } catch(e) {}
698
699 if (!showPublishDialog && filename)
700 {
701 // Try to get publish data from the document url
702 publishData = CreatePublishDataFromUrl(docUrl);
703
704 // If none, use default publishing site? Need a pref for this
705 //if (!publishData)
706 // publishData = GetPublishDataFromSiteName(GetDefaultPublishSiteName(), filename);
707 }
708
709 if (showPublishDialog || !publishData)
710 {
711 // Show the publish dialog
712 publishData = {};
713 window.ok = false;
714 var oldTitle = GetDocumentTitle();
715 window.openDialog("chrome://editor/content/EditorPublish.xul","_blank",
716 "chrome,close,titlebar,modal", "", "", publishData);
717 if (GetDocumentTitle() != oldTitle)
718 UpdateWindowTitle();
719
720 window.content.focus();
721 if (!window.ok)
722 return false;
723 }
724 if (publishData)
725 {
726 FinishHTMLSource();
727 return Publish(publishData);
728 }
729 }
730 return false;
731 }
732 }
733
734 var nsPublishAsCommand =
735 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
736 isCommandEnabled: function(aCommand, dummy)
737 {
738 return (IsDocumentEditable());
739 },
740
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
741 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
742 doCommandParams: function(aCommand, aParams, aRefCon) {},
743
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
744 doCommand: function(aCommand)
745 {
746 if (GetCurrentEditor())
747 {
748 FinishHTMLSource();
749
750 window.ok = false;
751 var publishData = {};
752 var oldTitle = GetDocumentTitle();
753 window.openDialog("chrome://editor/content/EditorPublish.xul","_blank",
754 "chrome,close,titlebar,modal", "", "", publishData);
755 if (GetDocumentTitle() != oldTitle)
756 UpdateWindowTitle();
757
758 window.content.focus();
759 if (window.ok)
760 return Publish(publishData);
761 }
762 return false;
763 }
764 }
765
766 // ------- output utilites ----- //
767
768 // returns a fileExtension string
GetExtensionBasedOnMimeType
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
769 function GetExtensionBasedOnMimeType(aMIMEType)
770 {
771 try {
772 var mimeService = null;
773 mimeService = Components.classes["@mozilla.org/mime;1"].getService();
774 mimeService = mimeService.QueryInterface(Components.interfaces.nsIMIMEService);
775
776 var fileExtension = mimeService.getPrimaryExtension(aMIMEType, null);
777
778 // the MIME service likes to give back ".htm" for text/html files,
779 // so do a special-case fix here.
780 if (fileExtension == "htm")
781 fileExtension = "html";
782
783 return fileExtension;
784 }
785 catch (e) {}
786 return "";
787 }
788
GetSuggestedFileName
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
789 function GetSuggestedFileName(aDocumentURLString, aMIMEType)
790 {
791 var extension = GetExtensionBasedOnMimeType(aMIMEType);
792 if (extension)
793 extension = "." + extension;
794
795 // check for existing file name we can use
796 if (aDocumentURLString.length >= 0 && !IsUrlAboutBlank(aDocumentURLString))
797 {
798 var docURI = null;
799 try {
800
801 var ioService = GetIOService();
802 docURI = ioService.newURI(aDocumentURLString, GetCurrentEditor().documentCharacterSet, null);
803 docURI = docURI.QueryInterface(Components.interfaces.nsIURL);
804
805 // grab the file name
806 var url = docURI.fileBaseName;
807 if (url)
808 return url+extension;
809 } catch(e) {}
810 }
811
812 // check if there is a title we can use
813 var title = GetDocumentTitle();
814 // generate a valid filename, if we can't just go with "untitled"
815 return GenerateValidFilename(title, extension) || GetString("untitled") + extension;
816 }
817
818 // returns file picker result
PromptForSaveLocation
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
819 function PromptForSaveLocation(aDoSaveAsText, aEditorType, aMIMEType, aDocumentURLString)
820 {
821 var dialogResult = {};
822 dialogResult.filepickerClick = nsIFilePicker.returnCancel;
823 dialogResult.resultingURI = "";
824 dialogResult.resultingLocalFile = null;
825
826 var fp = null;
827 try {
828 fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
829 } catch (e) {}
830 if (!fp) return dialogResult;
831
832 // determine prompt string based on type of saving we'll do
833 var promptString;
834 if (aDoSaveAsText || aEditorType == "text")
835 promptString = GetString("ExportToText");
836 else
837 promptString = GetString("SaveDocumentAs")
838
839 fp.init(window, promptString, nsIFilePicker.modeSave);
840
841 // Set filters according to the type of output
842 if (aDoSaveAsText)
843 fp.appendFilters(nsIFilePicker.filterText);
844 else
845 fp.appendFilters(nsIFilePicker.filterHTML);
846 fp.appendFilters(nsIFilePicker.filterAll);
847
848 // now let's actually set the filepicker's suggested filename
849 var suggestedFileName = GetSuggestedFileName(aDocumentURLString, aMIMEType);
850 if (suggestedFileName)
851 fp.defaultString = suggestedFileName;
852
853 // set the file picker's current directory
854 // assuming we have information needed (like prior saved location)
855 try {
856 var ioService = GetIOService();
857 var fileHandler = GetFileProtocolHandler();
858
859 var isLocalFile = true;
860 try {
861 var docURI = ioService.newURI(aDocumentURLString, GetCurrentEditor().documentCharacterSet, null);
862 isLocalFile = docURI.schemeIs("file");
863 }
864 catch (e) {}
865
866 var parentLocation = null;
867 if (isLocalFile)
868 {
869 var fileLocation = fileHandler.getFileFromURLSpec(aDocumentURLString); // this asserts if url is not local
870 parentLocation = fileLocation.parent;
871 }
872 if (parentLocation)
873 {
874 // Save current filepicker's default location
875 if ("gFilePickerDirectory" in window)
876 gFilePickerDirectory = fp.displayDirectory;
877
878 fp.displayDirectory = parentLocation;
879 }
880 else
881 {
882 // Initialize to the last-used directory for the particular type (saved in prefs)
883 SetFilePickerDirectory(fp, aEditorType);
884 }
885 }
886 catch(e) {}
887
888 dialogResult.filepickerClick = fp.show();
889 if (dialogResult.filepickerClick != nsIFilePicker.returnCancel)
890 {
891 // reset urlstring to new save location
892 dialogResult.resultingURIString = fileHandler.getURLSpecFromFile(fp.file);
893 dialogResult.resultingLocalFile = fp.file;
894 SaveFilePickerDirectory(fp, aEditorType);
895 }
896 else if ("gFilePickerDirectory" in window && gFilePickerDirectory)
897 fp.displayDirectory = gFilePickerDirectory;
898
899 return dialogResult;
900 }
901
902 // returns a boolean (whether to continue (true) or not (false) because user canceled)
PromptAndSetTitleIfNone
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
903 function PromptAndSetTitleIfNone()
904 {
905 if (GetDocumentTitle()) // we have a title; no need to prompt!
906 return true;
907
908 var promptService = GetPromptService();
909 if (!promptService) return false;
910
911 var result = {value:null};
912 var captionStr = GetString("DocumentTitle");
913 var msgStr = GetString("NeedDocTitle") + '\n' + GetString("DocTitleHelp");
914 var confirmed = promptService.prompt(window, captionStr, msgStr, result, null, {value:0});
915 if (confirmed)
916 SetDocumentTitle(TrimString(result.value));
917
918 return confirmed;
919 }
920
921 var gPersistObj;
922
923 // Don't forget to do these things after calling OutputFileWithPersistAPI:
924 // we need to update the uri before notifying listeners
925 // if (doUpdateURI)
926 // SetDocumentURI(docURI);
927 // UpdateWindowTitle();
928 // if (!aSaveCopy)
929 // editor.resetModificationCount();
930 // this should cause notification to listeners that document has changed
931
932 const webPersist = Components.interfaces.nsIWebBrowserPersist;
OutputFileWithPersistAPI
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
933 function OutputFileWithPersistAPI(editorDoc, aDestinationLocation, aRelatedFilesParentDir, aMimeType)
934 {
935 gPersistObj = null;
936 var editor = GetCurrentEditor();
937 try {
938 var imeEditor = editor.QueryInterface(Components.interfaces.nsIEditorIMESupport);
939 imeEditor.forceCompositionEnd();
940 } catch (e) {}
941
942 var isLocalFile = false;
943 try {
944 var tmp1 = aDestinationLocation.QueryInterface(Components.interfaces.nsIFile);
945 isLocalFile = true;
946 }
947 catch (e) {
948 try {
949 var tmp = aDestinationLocation.QueryInterface(Components.interfaces.nsIURI);
950 isLocalFile = tmp.schemeIs("file");
951 }
952 catch (e) {}
953 }
954
955 try {
956 // we should supply a parent directory if/when we turn on functionality to save related documents
957 var persistObj = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(webPersist);
958 persistObj.progressListener = gEditorOutputProgressListener;
959
960 var wrapColumn = GetWrapColumn();
961 var outputFlags = GetOutputFlags(aMimeType, wrapColumn);
962
963 // for 4.x parity as well as improving readability of file locally on server
964 // this will always send crlf for upload (http/ftp)
965 if (!isLocalFile) // if we aren't saving locally then send both cr and lf
966 {
967 outputFlags |= webPersist.ENCODE_FLAGS_CR_LINEBREAKS | webPersist.ENCODE_FLAGS_LF_LINEBREAKS;
968
969 // we want to serialize the output for all remote publishing
970 // some servers can handle only one connection at a time
971 // some day perhaps we can make this user-configurable per site?
972 persistObj.persistFlags = persistObj.persistFlags | webPersist.PERSIST_FLAGS_SERIALIZE_OUTPUT;
973 }
974
975 // note: we always want to set the replace existing files flag since we have
976 // already given user the chance to not replace an existing file (file picker)
977 // or the user picked an option where the file is implicitly being replaced (save)
978 persistObj.persistFlags = persistObj.persistFlags
979 | webPersist.PERSIST_FLAGS_NO_BASE_TAG_MODIFICATIONS
980 | webPersist.PERSIST_FLAGS_REPLACE_EXISTING_FILES
981 | webPersist.PERSIST_FLAGS_DONT_FIXUP_LINKS
982 | webPersist.PERSIST_FLAGS_DONT_CHANGE_FILENAMES
983 | webPersist.PERSIST_FLAGS_FIXUP_ORIGINAL_DOM;
984 persistObj.saveDocument(editorDoc, aDestinationLocation, aRelatedFilesParentDir,
985 aMimeType, outputFlags, wrapColumn);
986 gPersistObj = persistObj;
987 }
988 catch(e) { dump("caught an error, bail\n"); return false; }
989
990 return true;
991 }
992
993 // returns output flags based on mimetype, wrapCol and prefs
GetOutputFlags
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
994 function GetOutputFlags(aMimeType, aWrapColumn)
995 {
996 var outputFlags = 0;
997 var editor = GetCurrentEditor();
998 var outputEntity = (editor && editor.documentCharacterSet == "ISO-8859-1")
999 ? webPersist.ENCODE_FLAGS_ENCODE_LATIN1_ENTITIES
1000 : webPersist.ENCODE_FLAGS_ENCODE_BASIC_ENTITIES;
1001 if (aMimeType == "text/plain")
1002 {
1003 // When saving in "text/plain" format, always do formatting
1004 outputFlags |= webPersist.ENCODE_FLAGS_FORMATTED;
1005 }
1006 else
1007 {
1008 try {
1009 // Should we prettyprint? Check the pref
1010 var prefs = GetPrefs();
1011 if (prefs.getBoolPref("editor.prettyprint"))
1012 outputFlags |= webPersist.ENCODE_FLAGS_FORMATTED;
1013
1014 // How much entity names should we output? Check the pref
1015 var encodeEntity = prefs.getCharPref("editor.encode_entity");
1016 switch (encodeEntity) {
1017 case "basic" : outputEntity = webPersist.ENCODE_FLAGS_ENCODE_BASIC_ENTITIES; break;
1018 case "latin1" : outputEntity = webPersist.ENCODE_FLAGS_ENCODE_LATIN1_ENTITIES; break;
1019 case "html" : outputEntity = webPersist.ENCODE_FLAGS_ENCODE_HTML_ENTITIES; break;
1020 case "none" : outputEntity = 0; break;
1021 }
1022 }
1023 catch (e) {}
1024 }
1025 outputFlags |= outputEntity;
1026
1027 if (aWrapColumn > 0)
1028 outputFlags |= webPersist.ENCODE_FLAGS_WRAP;
1029
1030 return outputFlags;
1031 }
1032
1033 // returns number of column where to wrap
1034 const nsIWebBrowserPersist = Components.interfaces.nsIWebBrowserPersist;
GetWrapColumn
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1035 function GetWrapColumn()
1036 {
1037 try {
1038 return GetCurrentEditor().wrapWidth;
1039 } catch (e) {}
1040 return 0;
1041 }
1042
GetPromptService
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1043 function GetPromptService()
1044 {
1045 var promptService;
1046 try {
1047 promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
1048 promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService);
1049 }
1050 catch (e) {}
1051 return promptService;
1052 }
1053
1054 const gShowDebugOutputStateChange = false;
1055 const gShowDebugOutputProgress = false;
1056 const gShowDebugOutputStatusChange = false;
1057
1058 const gShowDebugOutputLocationChange = false;
1059 const gShowDebugOutputSecurityChange = false;
1060
1061 const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
1062 const nsIChannel = Components.interfaces.nsIChannel;
1063
1064 const kErrorBindingAborted = 2152398850;
1065 const kErrorBindingRedirected = 2152398851;
1066 const kFileNotFound = 2152857618;
1067
1068 var gEditorOutputProgressListener =
1069 {
onStateChange
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1070 onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
1071 {
1072 var editor = GetCurrentEditor();
1073
1074 // Use this to access onStateChange flags
1075 var requestSpec;
1076 try {
1077 var channel = aRequest.QueryInterface(nsIChannel);
1078 requestSpec = StripUsernamePasswordFromURI(channel.URI);
1079 } catch (e) {
1080 if ( gShowDebugOutputStateChange)
1081 dump("***** onStateChange; NO REQUEST CHANNEL\n");
1082 }
1083
1084 var pubSpec;
1085 if (gPublishData)
1086 pubSpec = gPublishData.publishUrl + gPublishData.docDir + gPublishData.filename;
1087
1088 if (gShowDebugOutputStateChange)
1089 {
1090 dump("\n***** onStateChange request: " + requestSpec + "\n");
1091 dump(" state flags: ");
1092
1093 if (aStateFlags & nsIWebProgressListener.STATE_START)
1094 dump(" STATE_START, ");
1095 if (aStateFlags & nsIWebProgressListener.STATE_STOP)
1096 dump(" STATE_STOP, ");
1097 if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK)
1098 dump(" STATE_IS_NETWORK ");
1099
1100 dump("\n * requestSpec="+requestSpec+", pubSpec="+pubSpec+", aStatus="+aStatus+"\n");
1101
1102 DumpDebugStatus(aStatus);
1103 }
1104 // The rest only concerns publishing, so bail out if no dialog
1105 if (!gProgressDialog)
1106 return;
1107
1108 // Detect start of file upload of any file:
1109 // (We ignore any START messages after gPersistObj says publishing is finished
1110 if ((aStateFlags & nsIWebProgressListener.STATE_START)
1111 && gPersistObj && requestSpec
1112 && (gPersistObj.currentState != gPersistObj.PERSIST_STATE_FINISHED))
1113 {
1114 try {
1115 // Add url to progress dialog's list showing each file uploading
1116 gProgressDialog.SetProgressStatus(GetFilename(requestSpec), "busy");
1117 } catch(e) {}
1118 }
1119
1120 // Detect end of file upload of any file:
1121 if (aStateFlags & nsIWebProgressListener.STATE_STOP)
1122 {
1123 // ignore aStatus == kErrorBindingAborted; check http response for possible errors
1124 try {
1125 // check http channel for response: 200 range is ok; other ranges are not
1126 var httpChannel = aRequest.QueryInterface(Components.interfaces.nsIHttpChannel);
1127 var httpResponse = httpChannel.responseStatus;
1128 if (httpResponse < 200 || httpResponse >= 300)
1129 aStatus = httpResponse; // not a real error but enough to pass check below
1130 else if (aStatus == kErrorBindingAborted)
1131 aStatus = 0;
1132
1133 if (gShowDebugOutputStateChange)
1134 dump("http response is: "+httpResponse+"\n");
1135 }
1136 catch(e)
1137 {
1138 if (aStatus == kErrorBindingAborted)
1139 aStatus = 0;
1140 }
1141
1142 // We abort publishing for all errors except if image src file is not found
1143 var abortPublishing = (aStatus != 0 && aStatus != kFileNotFound);
1144
1145 // Notify progress dialog when we receive the STOP
1146 // notification for a file if there was an error
1147 // or a successful finish
1148 // (Check requestSpec to be sure message is for destination url)
1149 if (aStatus != 0
1150 || (requestSpec && requestSpec.indexOf(GetScheme(gPublishData.publishUrl)) == 0))
1151 {
1152 try {
1153 gProgressDialog.SetProgressFinished(GetFilename(requestSpec), aStatus);
1154 } catch(e) {}
1155 }
1156
1157
1158 if (abortPublishing)
1159 {
1160 // Cancel publishing
1161 gPersistObj.cancelSave();
1162
1163 // Don't do any commands after failure
1164 gCommandAfterPublishing = null;
1165
1166 // Restore original document to undo image src url adjustments
1167 if (gRestoreDocumentSource)
1168 {
1169 try {
1170 editor.rebuildDocumentFromSource(gRestoreDocumentSource);
1171
1172 // Clear transaction cache since we just did a potentially
1173 // very large insert and this will eat up memory
1174 editor.transactionManager.clear();
1175 }
1176 catch (e) {}
1177 }
1178
1179 // Notify progress dialog that we're finished
1180 // and keep open to show error
1181 gProgressDialog.SetProgressFinished(null, 0);
1182
1183 // We don't want to change location or reset mod count, etc.
1184 return;
1185 }
1186
1187 //XXX HACK: "file://" protocol is not supported in network code
1188 // (bug 151867 filed to add this support, bug 151869 filed
1189 // to remove this and other code in nsIWebBrowserPersist)
1190 // nsIWebBrowserPersist *does* copy the file(s), but we don't
1191 // get normal onStateChange messages.
1192
1193 // Case 1: If images are included, we get fairly normal
1194 // STATE_START/STATE_STOP & STATE_IS_NETWORK messages associated with the image files,
1195 // thus we must finish HTML file progress below
1196
1197 // Case 2: If just HTML file is uploaded, we get STATE_START and STATE_STOP
1198 // notification with a null "requestSpec", and
1199 // the gPersistObj is destroyed before we get here!
1200 // So create an new object so we can flow through normal processing below
1201 if (!requestSpec && GetScheme(gPublishData.publishUrl) == "file"
1202 && (!gPersistObj || gPersistObj.currentState == nsIWebBrowserPersist.PERSIST_STATE_FINISHED))
1203 {
1204 aStateFlags |= nsIWebProgressListener.STATE_IS_NETWORK;
1205 if (!gPersistObj)
1206 {
1207 gPersistObj =
1208 {
1209 result : aStatus,
1210 currentState : nsIWebBrowserPersist.PERSIST_STATE_FINISHED
1211 }
1212 }
1213 }
1214
1215 // STATE_IS_NETWORK signals end of publishing, as does the gPersistObj.currentState
1216 if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK
1217 && gPersistObj.currentState == nsIWebBrowserPersist.PERSIST_STATE_FINISHED)
1218 {
1219 if (GetScheme(gPublishData.publishUrl) == "file")
1220 {
1221 //XXX "file://" hack: We don't get notified about the HTML file, so end progress for it
1222 // (This covers both "Case 1 and 2" described above)
1223 gProgressDialog.SetProgressFinished(gPublishData.filename, gPersistObj.result);
1224 }
1225
1226 if (gPersistObj.result == 0)
1227 {
1228 // All files are finished and publishing succeeded (some images may have failed)
1229 try {
1230 // Make a new docURI from the "browse location" in case "publish location" was FTP
1231 // We need to set document uri before notifying listeners
1232 var docUrl = GetDocUrlFromPublishData(gPublishData);
1233 SetDocumentURI(GetIOService().newURI(docUrl, editor.documentCharacterSet, null));
1234
1235 UpdateWindowTitle();
1236
1237 // this should cause notification to listeners that doc has changed
1238 editor.resetModificationCount();
1239
1240 // Set UI based on whether we're editing a remote or local url
1241 SetSaveAndPublishUI(urlstring);
1242
1243 } catch (e) {}
1244
1245 // Save publishData to prefs
1246 if (gPublishData)
1247 {
1248 if (gPublishData.savePublishData)
1249 {
1250 // We published successfully, so we can safely
1251 // save docDir and otherDir to prefs
1252 gPublishData.saveDirs = true;
1253 SavePublishDataToPrefs(gPublishData);
1254 }
1255 else
1256 SavePassword(gPublishData);
1257 }
1258
1259 // Ask progress dialog to close, but it may not
1260 // if user checked checkbox to keep it open
1261 gProgressDialog.RequestCloseDialog();
1262 }
1263 else
1264 {
1265 // We previously aborted publishing because of error:
1266 // Calling gPersistObj.cancelSave() resulted in a non-zero gPersistObj.result,
1267 // so notify progress dialog we're finished
1268 gProgressDialog.SetProgressFinished(null, 0);
1269 }
1270 }
1271 }
1272 },
1273
onProgressChange
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1274 onProgressChange : function(aWebProgress, aRequest, aCurSelfProgress,
1275 aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
1276 {
1277 if (!gPersistObj)
1278 return;
1279
1280 if (gShowDebugOutputProgress)
1281 {
1282 dump("\n onProgressChange: gPersistObj.result="+gPersistObj.result+"\n");
1283 try {
1284 var channel = aRequest.QueryInterface(nsIChannel);
1285 dump("***** onProgressChange request: " + channel.URI.spec + "\n");
1286 }
1287 catch (e) {}
1288 dump("***** self: "+aCurSelfProgress+" / "+aMaxSelfProgress+"\n");
1289 dump("***** total: "+aCurTotalProgress+" / "+aMaxTotalProgress+"\n\n");
1290
1291 if (gPersistObj.currentState == gPersistObj.PERSIST_STATE_READY)
1292 dump(" Persister is ready to save data\n\n");
1293 else if (gPersistObj.currentState == gPersistObj.PERSIST_STATE_SAVING)
1294 dump(" Persister is saving data.\n\n");
1295 else if (gPersistObj.currentState == gPersistObj.PERSIST_STATE_FINISHED)
1296 dump(" PERSISTER HAS FINISHED SAVING DATA\n\n\n");
1297 }
1298 },
1299
onLocationChange
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1300 onLocationChange : function(aWebProgress, aRequest, aLocation)
1301 {
1302 if (gShowDebugOutputLocationChange)
1303 {
1304 dump("***** onLocationChange: "+aLocation.spec+"\n");
1305 try {
1306 var channel = aRequest.QueryInterface(nsIChannel);
1307 dump("***** request: " + channel.URI.spec + "\n");
1308 }
1309 catch(e) {}
1310 }
1311 },
1312
onStatusChange
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1313 onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage)
1314 {
1315 if (gShowDebugOutputStatusChange)
1316 {
1317 dump("***** onStatusChange: "+aMessage+"\n");
1318 try {
1319 var channel = aRequest.QueryInterface(nsIChannel);
1320 dump("***** request: " + channel.URI.spec + "\n");
1321 }
1322 catch (e) { dump(" couldn't get request\n"); }
1323
1324 DumpDebugStatus(aStatus);
1325
1326 if (gPersistObj)
1327 {
1328 if(gPersistObj.currentState == gPersistObj.PERSIST_STATE_READY)
1329 dump(" Persister is ready to save data\n\n");
1330 else if(gPersistObj.currentState == gPersistObj.PERSIST_STATE_SAVING)
1331 dump(" Persister is saving data.\n\n");
1332 else if(gPersistObj.currentState == gPersistObj.PERSIST_STATE_FINISHED)
1333 dump(" PERSISTER HAS FINISHED SAVING DATA\n\n\n");
1334 }
1335 }
1336 },
1337
onSecurityChange
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1338 onSecurityChange : function(aWebProgress, aRequest, state)
1339 {
1340 if (gShowDebugOutputSecurityChange)
1341 {
1342 try {
1343 var channel = aRequest.QueryInterface(nsIChannel);
1344 dump("***** onSecurityChange request: " + channel.URI.spec + "\n");
1345 } catch (e) {}
1346 }
1347 },
1348
QueryInterface
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1349 QueryInterface : function(aIID)
1350 {
1351 if (aIID.equals(Components.interfaces.nsIWebProgressListener)
1352 || aIID.equals(Components.interfaces.nsISupports)
1353 || aIID.equals(Components.interfaces.nsISupportsWeakReference)
1354 || aIID.equals(Components.interfaces.nsIPrompt)
1355 || aIID.equals(Components.interfaces.nsIAuthPrompt))
1356 return this;
1357 throw Components.results.NS_NOINTERFACE;
1358 },
1359
1360 // nsIPrompt
alert
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1361 alert : function(dlgTitle, text)
1362 {
1363 AlertWithTitle(dlgTitle, text, gProgressDialog ? gProgressDialog : window);
1364 },
alertCheck
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1365 alertCheck : function(dialogTitle, text, checkBoxLabel, checkObj)
1366 {
1367 AlertWithTitle(dialogTitle, text);
1368 },
confirm
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1369 confirm : function(dlgTitle, text)
1370 {
1371 return ConfirmWithTitle(dlgTitle, text, null, null);
1372 },
confirmCheck
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1373 confirmCheck : function(dlgTitle, text, checkBoxLabel, checkObj)
1374 {
1375 var promptServ = GetPromptService();
1376 if (!promptServ)
1377 return;
1378
1379 promptServ.confirmEx(window, dlgTitle, text, nsIPromptService.STD_OK_CANCEL_BUTTONS,
1380 "", "", "", checkBoxLabel, checkObj);
1381 },
confirmEx
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1382 confirmEx : function(dlgTitle, text, btnFlags, btn0Title, btn1Title, btn2Title, checkBoxLabel, checkVal)
1383 {
1384 var promptServ = GetPromptService();
1385 if (!promptServ)
1386 return 0;
1387
1388 return promptServ.confirmEx(window, dlgTitle, text, btnFlags,
1389 btn0Title, btn1Title, btn2Title,
1390 checkBoxLabel, checkVal);
1391 },
prompt
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1392 prompt : function(dlgTitle, text, inoutText, checkBoxLabel, checkObj)
1393 {
1394 var promptServ = GetPromptService();
1395 if (!promptServ)
1396 return false;
1397
1398 return promptServ.prompt(window, dlgTitle, text, inoutText, checkBoxLabel, checkObj);
1399 },
promptPassword
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1400 promptPassword : function(dlgTitle, text, pwObj, checkBoxLabel, savePWObj)
1401 {
1402
1403 var promptServ = GetPromptService();
1404 if (!promptServ)
1405 return false;
1406
1407 var ret = false;
1408 try {
1409 // Note difference with nsIAuthPrompt::promptPassword, which has
1410 // just "in" savePassword param, while nsIPrompt is "inout"
1411 // Initialize with user's previous preference for this site
1412 if (gPublishData)
1413 savePWObj.value = gPublishData.savePassword;
1414
1415 ret = promptServ.promptPassword(gProgressDialog ? gProgressDialog : window,
1416 dlgTitle, text, pwObj, checkBoxLabel, savePWObj);
1417
1418 if (!ret)
1419 setTimeout(CancelPublishing, 0);
1420
1421 if (ret && gPublishData)
1422 UpdateUsernamePasswordFromPrompt(gPublishData, gPublishData.username, pwObj.value, savePWObj.value);
1423 } catch(e) {}
1424
1425 return ret;
1426 },
promptUsernameAndPassword
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1427 promptUsernameAndPassword : function(dlgTitle, text, userObj, pwObj, checkBoxLabel, savePWObj)
1428 {
1429 var ret = PromptUsernameAndPassword(dlgTitle, text, savePWObj.value, userObj, pwObj);
1430 if (!ret)
1431 setTimeout(CancelPublishing, 0);
1432
1433 return ret;
1434 },
select
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1435 select : function(dlgTitle, text, count, selectList, outSelection)
1436 {
1437 var promptServ = GetPromptService();
1438 if (!promptServ)
1439 return false;
1440
1441 return promptServ.select(window, dlgTitle, text, count, selectList, outSelection);
1442 },
1443
1444 // nsIAuthPrompt
prompt
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1445 prompt : function(dlgTitle, text, pwrealm, savePW, defaultText, result)
1446 {
1447 var promptServ = GetPromptService();
1448 if (!promptServ)
1449 return false;
1450
1451 var savePWObj = {value:savePW};
1452 var ret = promptServ.prompt(gProgressDialog ? gProgressDialog : window,
1453 dlgTitle, text, defaultText, pwrealm, savePWObj);
1454 if (!ret)
1455 setTimeout(CancelPublishing, 0);
1456 return ret;
1457 },
1458
promptUsernameAndPassword
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1459 promptUsernameAndPassword : function(dlgTitle, text, pwrealm, savePW, userObj, pwObj)
1460 {
1461 var ret = PromptUsernameAndPassword(dlgTitle, text, savePW, userObj, pwObj);
1462 if (!ret)
1463 setTimeout(CancelPublishing, 0);
1464 return ret;
1465 },
1466
promptPassword
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1467 promptPassword : function(dlgTitle, text, pwrealm, savePW, pwObj)
1468 {
1469 var ret = false;
1470 try {
1471 var promptServ = GetPromptService();
1472 if (!promptServ)
1473 return false;
1474
1475 // Note difference with nsIPrompt::promptPassword, which has
1476 // "inout" savePassword param, while nsIAuthPrompt is just "in"
1477 // Also nsIAuth doesn't supply "checkBoxLabel"
1478 // Initialize with user's previous preference for this site
1479 var savePWObj = {value:savePW};
1480 // Initialize with user's previous preference for this site
1481 if (gPublishData)
1482 savePWObj.value = gPublishData.savePassword;
1483
1484 ret = promptServ.promptPassword(gProgressDialog ? gProgressDialog : window,
1485 dlgTitle, text, pwObj, GetString("SavePassword"), savePWObj);
1486
1487 if (!ret)
1488 setTimeout(CancelPublishing, 0);
1489
1490 if (ret && gPublishData)
1491 UpdateUsernamePasswordFromPrompt(gPublishData, gPublishData.username, pwObj.value, savePWObj.value);
1492 } catch(e) {}
1493
1494 return ret;
1495 }
1496 }
1497
PromptUsernameAndPassword
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1498 function PromptUsernameAndPassword(dlgTitle, text, savePW, userObj, pwObj)
1499 {
1500 // HTTP prompts us twice even if user Cancels from 1st attempt!
1501 // So never put up dialog if there's no publish data
1502 if (!gPublishData)
1503 return false
1504
1505 var ret = false;
1506 try {
1507 var promptServ = GetPromptService();
1508 if (!promptServ)
1509 return false;
1510
1511 var savePWObj = {value:savePW};
1512
1513 // Initialize with user's previous preference for this site
1514 if (gPublishData)
1515 {
1516 // HTTP put uses this dialog if either username or password is bad,
1517 // so prefill username input field with the previous value for modification
1518 savePWObj.value = gPublishData.savePassword;
1519 if (!userObj.value)
1520 userObj.value = gPublishData.username;
1521 }
1522
1523 ret = promptServ.promptUsernameAndPassword(gProgressDialog ? gProgressDialog : window,
1524 dlgTitle, text, userObj, pwObj,
1525 GetString("SavePassword"), savePWObj);
1526 if (ret && gPublishData)
1527 UpdateUsernamePasswordFromPrompt(gPublishData, userObj.value, pwObj.value, savePWObj.value);
1528
1529 } catch (e) {}
1530
1531 return ret;
1532 }
1533
DumpDebugStatus
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1534 function DumpDebugStatus(aStatus)
1535 {
1536 // see nsError.h and netCore.h and ftpCore.h
1537
1538 if (aStatus == kErrorBindingAborted)
1539 dump("***** status is NS_BINDING_ABORTED\n");
1540 else if (aStatus == kErrorBindingRedirected)
1541 dump("***** status is NS_BINDING_REDIRECTED\n");
1542 else if (aStatus == 2152398859) // in netCore.h 11
1543 dump("***** status is ALREADY_CONNECTED\n");
1544 else if (aStatus == 2152398860) // in netCore.h 12
1545 dump("***** status is NOT_CONNECTED\n");
1546 else if (aStatus == 2152398861) // in nsISocketTransportService.idl 13
1547 dump("***** status is CONNECTION_REFUSED\n");
1548 else if (aStatus == 2152398862) // in nsISocketTransportService.idl 14
1549 dump("***** status is NET_TIMEOUT\n");
1550 else if (aStatus == 2152398863) // in netCore.h 15
1551 dump("***** status is IN_PROGRESS\n");
1552 else if (aStatus == 2152398864) // 0x804b0010 in netCore.h 16
1553 dump("***** status is OFFLINE\n");
1554 else if (aStatus == 2152398865) // in netCore.h 17
1555 dump("***** status is NO_CONTENT\n");
1556 else if (aStatus == 2152398866) // in netCore.h 18
1557 dump("***** status is UNKNOWN_PROTOCOL\n");
1558 else if (aStatus == 2152398867) // in netCore.h 19
1559 dump("***** status is PORT_ACCESS_NOT_ALLOWED\n");
1560 else if (aStatus == 2152398868) // in nsISocketTransportService.idl 20
1561 dump("***** status is NET_RESET\n");
1562 else if (aStatus == 2152398869) // in ftpCore.h 21
1563 dump("***** status is FTP_LOGIN\n");
1564 else if (aStatus == 2152398870) // in ftpCore.h 22
1565 dump("***** status is FTP_CWD\n");
1566 else if (aStatus == 2152398871) // in ftpCore.h 23
1567 dump("***** status is FTP_PASV\n");
1568 else if (aStatus == 2152398872) // in ftpCore.h 24
1569 dump("***** status is FTP_PWD\n");
1570 else if (aStatus == 2152857601)
1571 dump("***** status is UNRECOGNIZED_PATH\n");
1572 else if (aStatus == 2152857602)
1573 dump("***** status is UNRESOLABLE SYMLINK\n");
1574 else if (aStatus == 2152857604)
1575 dump("***** status is UNKNOWN_TYPE\n");
1576 else if (aStatus == 2152857605)
1577 dump("***** status is DESTINATION_NOT_DIR\n");
1578 else if (aStatus == 2152857606)
1579 dump("***** status is TARGET_DOES_NOT_EXIST\n");
1580 else if (aStatus == 2152857608)
1581 dump("***** status is ALREADY_EXISTS\n");
1582 else if (aStatus == 2152857609)
1583 dump("***** status is INVALID_PATH\n");
1584 else if (aStatus == 2152857610)
1585 dump("***** status is DISK_FULL\n");
1586 else if (aStatus == 2152857612)
1587 dump("***** status is NOT_DIRECTORY\n");
1588 else if (aStatus == 2152857613)
1589 dump("***** status is IS_DIRECTORY\n");
1590 else if (aStatus == 2152857614)
1591 dump("***** status is IS_LOCKED\n");
1592 else if (aStatus == 2152857615)
1593 dump("***** status is TOO_BIG\n");
1594 else if (aStatus == 2152857616)
1595 dump("***** status is NO_DEVICE_SPACE\n");
1596 else if (aStatus == 2152857617)
1597 dump("***** status is NAME_TOO_LONG\n");
1598 else if (aStatus == 2152857618) // 80520012
1599 dump("***** status is FILE_NOT_FOUND\n");
1600 else if (aStatus == 2152857619)
1601 dump("***** status is READ_ONLY\n");
1602 else if (aStatus == 2152857620)
1603 dump("***** status is DIR_NOT_EMPTY\n");
1604 else if (aStatus == 2152857621)
1605 dump("***** status is ACCESS_DENIED\n");
1606 else if (aStatus == 2152398878)
1607 dump("***** status is ? (No connection or time out?)\n");
1608 else
1609 dump("***** status is " + aStatus + "\n");
1610 }
1611
1612 // Update any data that the user supplied in a prompt dialog
UpdateUsernamePasswordFromPrompt
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1613 function UpdateUsernamePasswordFromPrompt(publishData, username, password, savePassword)
1614 {
1615 if (!publishData)
1616 return;
1617
1618 // Set flag to save publish data after publishing if it changed in dialog
1619 // and the "SavePassword" checkbox was checked
1620 // or we already had site data for this site
1621 // (Thus we don't automatically create a site until user brings up Publish As dialog)
1622 publishData.savePublishData = (gPublishData.username != username || gPublishData.password != password)
1623 && (savePassword || !publishData.notInSiteData);
1624
1625 publishData.username = username;
1626 publishData.password = password;
1627 publishData.savePassword = savePassword;
1628 }
1629
1630 const kSupportedTextMimeTypes =
1631 [
1632 "text/plain",
1633 "text/css",
1634 "text/rdf",
1635 "text/xsl",
1636 "text/javascript",
1637 "text/ecmascript",
1638 "application/javascript",
1639 "application/ecmascript",
1640 "application/x-javascript",
1641 "text/xul",
1642 "application/vnd.mozilla.xul+xml"
1643 ];
1644
IsSupportedTextMimeType
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1645 function IsSupportedTextMimeType(aMimeType)
1646 {
1647 for (var i = 0; i < kSupportedTextMimeTypes.length; i++)
1648 {
1649 if (kSupportedTextMimeTypes[i] == aMimeType)
1650 return true;
1651 }
1652 return false;
1653 }
1654
1655 // throws an error or returns true if user attempted save; false if user canceled save
SaveDocument
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1656 function SaveDocument(aSaveAs, aSaveCopy, aMimeType)
1657 {
1658 var editor = GetCurrentEditor();
1659 if (!aMimeType || aMimeType == "" || !editor)
1660 throw NS_ERROR_NOT_INITIALIZED;
1661
1662 var editorDoc = editor.document;
1663 if (!editorDoc)
1664 throw NS_ERROR_NOT_INITIALIZED;
1665
1666 // if we don't have the right editor type bail (we handle text and html)
1667 var editorType = GetCurrentEditorType();
1668 if (editorType != "text" && editorType != "html"
1669 && editorType != "htmlmail" && editorType != "textmail")
1670 throw NS_ERROR_NOT_IMPLEMENTED;
1671
1672 var saveAsTextFile = IsSupportedTextMimeType(aMimeType);
1673
1674 // check if the file is to be saved is a format we don't understand; if so, bail
1675 if (aMimeType != "text/html" && !saveAsTextFile)
1676 throw NS_ERROR_NOT_IMPLEMENTED;
1677
1678 if (saveAsTextFile)
1679 aMimeType = "text/plain";
1680
1681 var urlstring = GetDocumentUrl();
1682 var mustShowFileDialog = (aSaveAs || IsUrlAboutBlank(urlstring) || (urlstring == ""));
1683
1684 // If editing a remote URL, force SaveAs dialog
1685 if (!mustShowFileDialog && GetScheme(urlstring) != "file")
1686 mustShowFileDialog = true;
1687
1688 var replacing = !aSaveAs;
1689 var titleChanged = false;
1690 var doUpdateURI = false;
1691 var tempLocalFile = null;
1692
1693 if (mustShowFileDialog)
1694 {
1695 try {
1696 // Prompt for title if we are saving to HTML
1697 if (!saveAsTextFile && (editorType == "html"))
1698 {
1699 var userContinuing = PromptAndSetTitleIfNone(); // not cancel
1700 if (!userContinuing)
1701 return false;
1702 }
1703
1704 var dialogResult = PromptForSaveLocation(saveAsTextFile, editorType, aMimeType, urlstring);
1705 if (dialogResult.filepickerClick == nsIFilePicker.returnCancel)
1706 return false;
1707
1708 replacing = (dialogResult.filepickerClick == nsIFilePicker.returnReplace);
1709 urlstring = dialogResult.resultingURIString;
1710 tempLocalFile = dialogResult.resultingLocalFile;
1711
1712 // update the new URL for the webshell unless we are saving a copy
1713 if (!aSaveCopy)
1714 doUpdateURI = true;
1715 } catch (e) { return false; }
1716 } // mustShowFileDialog
1717
1718 var success = true;
1719 var ioService;
1720 try {
1721 // if somehow we didn't get a local file but we did get a uri,
1722 // attempt to create the localfile if it's a "file" url
1723 var docURI;
1724 if (!tempLocalFile)
1725 {
1726 ioService = GetIOService();
1727 docURI = ioService.newURI(urlstring, editor.documentCharacterSet, null);
1728
1729 if (docURI.schemeIs("file"))
1730 {
1731 var fileHandler = GetFileProtocolHandler();
1732 tempLocalFile = fileHandler.getFileFromURLSpec(urlstring).QueryInterface(Components.interfaces.nsILocalFile);
1733 }
1734 }
1735
1736 // this is the location where the related files will go
1737 var relatedFilesDir = null;
1738
1739 // First check pref for saving associated files
1740 var saveAssociatedFiles = false;
1741 try {
1742 var prefs = GetPrefs();
1743 saveAssociatedFiles = prefs.getBoolPref("editor.save_associated_files");
1744 } catch (e) {}
1745
1746 // Only change links or move files if pref is set
1747 // and we are saving to a new location
1748 if (saveAssociatedFiles && aSaveAs)
1749 {
1750 try {
1751 if (tempLocalFile)
1752 {
1753 // if we are saving to the same parent directory, don't set relatedFilesDir
1754 // grab old location, chop off file
1755 // grab new location, chop off file, compare
1756 var oldLocation = GetDocumentUrl();
1757 var oldLocationLastSlash = oldLocation.lastIndexOf("\/");
1758 if (oldLocationLastSlash != -1)
1759 oldLocation = oldLocation.slice(0, oldLocationLastSlash);
1760
1761 var relatedFilesDirStr = urlstring;
1762 var newLocationLastSlash = relatedFilesDirStr.lastIndexOf("\/");
1763 if (newLocationLastSlash != -1)
1764 relatedFilesDirStr = relatedFilesDirStr.slice(0, newLocationLastSlash);
1765 if (oldLocation == relatedFilesDirStr || IsUrlAboutBlank(oldLocation))
1766 relatedFilesDir = null;
1767 else
1768 relatedFilesDir = tempLocalFile.parent;
1769 }
1770 else
1771 {
1772 var lastSlash = urlstring.lastIndexOf("\/");
1773 if (lastSlash != -1)
1774 {
1775 var relatedFilesDirString = urlstring.slice(0, lastSlash + 1); // include last slash
1776 ioService = GetIOService();
1777 relatedFilesDir = ioService.newURI(relatedFilesDirString, editor.documentCharacterSet, null);
1778 }
1779 }
1780 } catch(e) { relatedFilesDir = null; }
1781 }
1782
1783 var destinationLocation;
1784 if (tempLocalFile)
1785 destinationLocation = tempLocalFile;
1786 else
1787 destinationLocation = docURI;
1788
1789 success = OutputFileWithPersistAPI(editorDoc, destinationLocation, relatedFilesDir, aMimeType);
1790 }
1791 catch (e)
1792 {
1793 success = false;
1794 }
1795
1796 if (success)
1797 {
1798 try {
1799 if (doUpdateURI)
1800 {
1801 // If a local file, we must create a new uri from nsILocalFile
1802 if (tempLocalFile)
1803 docURI = GetFileProtocolHandler().newFileURI(tempLocalFile);
1804
1805 // We need to set new document uri before notifying listeners
1806 SetDocumentURI(docURI);
1807 }
1808
1809 // Update window title to show possibly different filename
1810 // This also covers problem that after undoing a title change,
1811 // window title loses the extra [filename] part that this adds
1812 UpdateWindowTitle();
1813
1814 if (!aSaveCopy)
1815 editor.resetModificationCount();
1816 // this should cause notification to listeners that document has changed
1817
1818 // Set UI based on whether we're editing a remote or local url
1819 SetSaveAndPublishUI(urlstring);
1820 } catch (e) {}
1821 }
1822 else
1823 {
1824 var saveDocStr = GetString("SaveDocument");
1825 var failedStr = GetString("SaveFileFailed");
1826 AlertWithTitle(saveDocStr, failedStr);
1827 }
1828 return success;
1829 }
1830
SetDocumentURI
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1831 function SetDocumentURI(uri)
1832 {
1833 try {
1834 // XXX WE'LL NEED TO GET "CURRENT" CONTENT FRAME ONCE MULTIPLE EDITORS ARE ALLOWED
1835 GetCurrentEditorElement().docShell.setCurrentURI(uri);
1836 } catch (e) { dump("SetDocumentURI:\n"+e +"\n"); }
1837 }
1838
1839
1840 //------------------------------- Publishing
1841 var gPublishData;
1842 var gProgressDialog;
1843 var gCommandAfterPublishing = null;
1844 var gRestoreDocumentSource;
1845
Publish
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1846 function Publish(publishData)
1847 {
1848 if (!publishData)
1849 return false;
1850
1851 // Set data in global for username password requests
1852 // and to do "post saving" actions after monitoring nsIWebProgressListener messages
1853 // and we are sure file transfer was successful
1854 gPublishData = publishData;
1855
1856 gPublishData.docURI = CreateURIFromPublishData(publishData, true);
1857 if (!gPublishData.docURI)
1858 {
1859 AlertWithTitle(GetString("Publish"), GetString("PublishFailed"));
1860 return false;
1861 }
1862
1863 if (gPublishData.publishOtherFiles)
1864 gPublishData.otherFilesURI = CreateURIFromPublishData(publishData, false);
1865 else
1866 gPublishData.otherFilesURI = null;
1867
1868 if (gShowDebugOutputStateChange)
1869 {
1870 dump("\n *** publishData: PublishUrl="+publishData.publishUrl+", BrowseUrl="+publishData.browseUrl+
1871 ", Username="+publishData.username+", Dir="+publishData.docDir+
1872 ", Filename="+publishData.filename+"\n");
1873 dump(" * gPublishData.docURI.spec w/o pass="+StripPassword(gPublishData.docURI.spec)+", PublishOtherFiles="+gPublishData.publishOtherFiles+"\n");
1874 }
1875
1876 // XXX Missing username will make FTP fail
1877 // and it won't call us for prompt dialog (bug 132320)
1878 // (It does prompt if just password is missing)
1879 // So we should do the prompt ourselves before trying to publish
1880 if (GetScheme(publishData.publishUrl) == "ftp" && !publishData.username)
1881 {
1882 var message = GetString("PromptFTPUsernamePassword").replace(/%host%/, GetHost(publishData.publishUrl));
1883 var savePWobj = {value:publishData.savePassword};
1884 var userObj = {value:publishData.username};
1885 var pwObj = {value:publishData.password};
1886 if (!PromptUsernameAndPassword(GetString("Prompt"), message, savePWobj, userObj, pwObj))
1887 return false; // User canceled out of dialog
1888
1889 // Reset data in URI objects
1890 gPublishData.docURI.username = publishData.username;
1891 gPublishData.docURI.password = publishData.password;
1892
1893 if (gPublishData.otherFilesURI)
1894 {
1895 gPublishData.otherFilesURI.username = publishData.username;
1896 gPublishData.otherFilesURI.password = publishData.password;
1897 }
1898 }
1899
1900 try {
1901 // We launch dialog as a dependent
1902 // Don't allow editing document!
1903 SetDocumentEditable(false);
1904
1905 // Start progress monitoring
1906 gProgressDialog =
1907 window.openDialog("chrome://editor/content/EditorPublishProgress.xul", "_blank",
1908 "chrome,dependent,titlebar", gPublishData, gPersistObj);
1909
1910 } catch (e) {}
1911
1912 // Network transfer is often too quick for the progress dialog to be initialized
1913 // and we can completely miss messages for quickly-terminated bad URLs,
1914 // so we can't call OutputFileWithPersistAPI right away.
1915 // StartPublishing() is called at the end of the dialog's onload method
1916 return true;
1917 }
1918
StartPublishing
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1919 function StartPublishing()
1920 {
1921 var editor = GetCurrentEditor();
1922 if (editor && gPublishData && gPublishData.docURI && gProgressDialog)
1923 {
1924 gRestoreDocumentSource = null;
1925
1926 // Save backup document since nsIWebBrowserPersist changes image src urls
1927 // but we only need to do this if publishing images and other related files
1928 if (gPublishData.otherFilesURI)
1929 {
1930 try {
1931 gRestoreDocumentSource =
1932 editor.outputToString(editor.contentsMIMEType, kOutputEncodeW3CEntities);
1933 } catch (e) {}
1934 }
1935
1936 OutputFileWithPersistAPI(editor.document,
1937 gPublishData.docURI, gPublishData.otherFilesURI,
1938 editor.contentsMIMEType);
1939 return gPersistObj;
1940 }
1941 return null;
1942 }
1943
CancelPublishing
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1944 function CancelPublishing()
1945 {
1946 try {
1947 gPersistObj.cancelSave();
1948 gProgressDialog.SetProgressStatusCancel();
1949 } catch (e) {}
1950
1951 // If canceling publishing do not do any commands after this
1952 gCommandAfterPublishing = null;
1953
1954 if (gProgressDialog)
1955 {
1956 // Close Progress dialog
1957 // (this will call FinishPublishing())
1958 gProgressDialog.CloseDialog();
1959 }
1960 else
1961 FinishPublishing();
1962 }
1963
FinishPublishing
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1964 function FinishPublishing()
1965 {
1966 SetDocumentEditable(true);
1967 gProgressDialog = null;
1968 gPublishData = null;
1969 gRestoreDocumentSource = null;
1970
1971 if (gCommandAfterPublishing)
1972 {
1973 // Be sure to null out the global now incase of trouble when executing command
1974 var command = gCommandAfterPublishing;
1975 gCommandAfterPublishing = null;
1976 goDoCommand(command);
1977 }
1978 }
1979
1980 // Create a nsIURI object filled in with all required publishing info
CreateURIFromPublishData
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1981 function CreateURIFromPublishData(publishData, doDocUri)
1982 {
1983 if (!publishData || !publishData.publishUrl)
1984 return null;
1985
1986 var URI;
1987 try {
1988 var spec = publishData.publishUrl;
1989 if (doDocUri)
1990 spec += FormatDirForPublishing(publishData.docDir) + publishData.filename;
1991 else
1992 spec += FormatDirForPublishing(publishData.otherDir);
1993
1994 var ioService = GetIOService();
1995 URI = ioService.newURI(spec, GetCurrentEditor().documentCharacterSet, null);
1996
1997 if (publishData.username)
1998 URI.username = publishData.username;
1999 if (publishData.password)
2000 URI.password = publishData.password;
2001 }
2002 catch (e) {}
2003
2004 return URI;
2005 }
2006
2007 // Resolve the correct "http:" document URL when publishing via ftp
GetDocUrlFromPublishData
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2008 function GetDocUrlFromPublishData(publishData)
2009 {
2010 if (!publishData || !publishData.filename || !publishData.publishUrl)
2011 return "";
2012
2013 // If user was previously editing an "ftp" url, then keep that as the new scheme
2014 var url;
2015 var docScheme = GetScheme(GetDocumentUrl());
2016
2017 // Always use the "HTTP" address if available
2018 // XXX Should we do some more validation here for bad urls???
2019 // Let's at least check for a scheme!
2020 if (!GetScheme(publishData.browseUrl))
2021 url = publishData.publishUrl;
2022 else
2023 url = publishData.browseUrl;
2024
2025 url += FormatDirForPublishing(publishData.docDir) + publishData.filename;
2026
2027 if (GetScheme(url) == "ftp")
2028 url = InsertUsernameIntoUrl(url, publishData.username);
2029
2030 return url;
2031 }
2032
SetSaveAndPublishUI
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2033 function SetSaveAndPublishUI(urlstring)
2034 {
2035 // Be sure enabled state of toolbar buttons are correct
2036 goUpdateCommand("cmd_save");
2037 goUpdateCommand("cmd_publish");
2038 }
2039
SetDocumentEditable
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2040 function SetDocumentEditable(isDocEditable)
2041 {
2042 var editor = GetCurrentEditor();
2043 if (editor && editor.document)
2044 {
2045 try {
2046 var flags = editor.flags;
2047 editor.flags = isDocEditable ?
2048 flags &= ~nsIPlaintextEditor.eEditorReadonlyMask :
2049 flags | nsIPlaintextEditor.eEditorReadonlyMask;
2050 } catch(e) {}
2051
2052 // update all commands
2053 window.updateCommands("create");
2054 }
2055 }
2056
2057 // ****** end of save / publish **********//
2058
2059 //-----------------------------------------------------------------------------------
2060 var nsPublishSettingsCommand =
2061 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2062 isCommandEnabled: function(aCommand, dummy)
2063 {
2064 return (IsDocumentEditable());
2065 },
2066
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2067 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2068 doCommandParams: function(aCommand, aParams, aRefCon) {},
2069
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2070 doCommand: function(aCommand)
2071 {
2072 if (GetCurrentEditor())
2073 {
2074 // Launch Publish Settings dialog
2075
2076 window.ok = window.openDialog("chrome://editor/content/EditorPublishSettings.xul","_blank", "chrome,close,titlebar,modal", "");
2077 window.content.focus();
2078 return window.ok;
2079 }
2080 return false;
2081 }
2082 }
2083
2084 //-----------------------------------------------------------------------------------
2085 var nsRevertCommand =
2086 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2087 isCommandEnabled: function(aCommand, dummy)
2088 {
2089 return (IsDocumentEditable() &&
2090 IsDocumentModified() &&
2091 !IsUrlAboutBlank(GetDocumentUrl()));
2092 },
2093
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2094 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2095 doCommandParams: function(aCommand, aParams, aRefCon) {},
2096
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2097 doCommand: function(aCommand)
2098 {
2099 // Confirm with the user to abandon current changes
2100 var promptService = GetPromptService();
2101 if (promptService)
2102 {
2103 // Put the page title in the message string
2104 var title = GetDocumentTitle();
2105 if (!title)
2106 title = GetString("untitled");
2107
2108 var msg = GetString("AbandonChanges").replace(/%title%/,title);
2109
2110 var result = promptService.confirmEx(window, GetString("RevertCaption"), msg,
2111 (promptService.BUTTON_TITLE_REVERT * promptService.BUTTON_POS_0) +
2112 (promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
2113 null, null, null, null, {value:0});
2114
2115 // Reload page if first button (Revert) was pressed
2116 if(result == 0)
2117 {
2118 CancelHTMLSource();
2119 EditorLoadUrl(GetDocumentUrl());
2120 }
2121 }
2122 }
2123 };
2124
2125 //-----------------------------------------------------------------------------------
2126 var nsCloseCommand =
2127 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2128 isCommandEnabled: function(aCommand, dummy)
2129 {
2130 return GetCurrentEditor() != null;
2131 },
2132
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2133 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2134 doCommandParams: function(aCommand, aParams, aRefCon) {},
2135
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2136 doCommand: function(aCommand)
2137 {
2138 CloseWindow();
2139 }
2140 };
2141
CloseWindow
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2142 function CloseWindow()
2143 {
2144 // Check to make sure document is saved. "true" means allow "Don't Save" button,
2145 // so user can choose to close without saving
2146 if (CheckAndSaveDocument("cmd_close", true))
2147 {
2148 if (window.InsertCharWindow)
2149 SwitchInsertCharToAnotherEditorOrClose();
2150
2151 try {
2152 var basewin = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
2153 .getInterface(Components.interfaces.nsIWebNavigation)
2154 .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
2155 .treeOwner
2156 .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
2157 .getInterface(Components.interfaces.nsIBaseWindow);
2158 basewin.destroy();
2159 } catch (e) {}
2160 }
2161 }
2162
2163 //-----------------------------------------------------------------------------------
2164 var nsOpenRemoteCommand =
2165 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2166 isCommandEnabled: function(aCommand, dummy)
2167 {
2168 return true; // we can always do this
2169 },
2170
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2171 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2172 doCommandParams: function(aCommand, aParams, aRefCon) {},
2173
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2174 doCommand: function(aCommand)
2175 {
2176 var params = { browser: null, action: null, url: "" };
2177 openDialog( "chrome://communicator/content/openLocation.xul", "_blank", "chrome,modal,titlebar", params);
2178 var win = getTopWin();
2179 switch (params.action) {
2180 case "0": // current window
2181 win.focus();
2182 win.loadURI(params.url, null,
2183 nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP);
2184 break;
2185 case "1": // new window
2186 openDialog(getBrowserURL(), "_blank", "all,dialog=no", params.url, null,
2187 null, nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP);
2188 break;
2189 case "2": // edit
2190 editPage(params.url);
2191 break;
2192 case "3": // new tab
2193 win.focus();
2194 var browser = win.getBrowser();
2195 browser.selectedTab = browser.addTab(params.url, null, null, false,
2196 nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP);
2197 break;
2198 default:
2199 window.content.focus();
2200 break;
2201 }
2202 }
2203 };
2204
2205 //-----------------------------------------------------------------------------------
2206 var nsPreviewCommand =
2207 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2208 isCommandEnabled: function(aCommand, dummy)
2209 {
2210 return (IsDocumentEditable() &&
2211 IsHTMLEditor() &&
2212 (DocumentHasBeenSaved() || IsDocumentModified()));
2213 },
2214
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2215 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2216 doCommandParams: function(aCommand, aParams, aRefCon) {},
2217
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2218 doCommand: function(aCommand)
2219 {
2220 // Don't continue if user canceled during prompt for saving
2221 // DocumentHasBeenSaved will test if we have a URL and suppress "Don't Save" button if not
2222 if (!CheckAndSaveDocument("cmd_preview", DocumentHasBeenSaved()))
2223 return;
2224
2225 // Check if we saved again just in case?
2226 if (DocumentHasBeenSaved())
2227 {
2228 var browser;
2229 try {
2230 // Find a browser with this URL
2231 var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
2232 var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
2233 var enumerator = windowManagerInterface.getEnumerator("navigator:browser");
2234
2235 var documentURI = GetDocumentUrl();
2236 while ( enumerator.hasMoreElements() )
2237 {
2238 browser = enumerator.getNext().QueryInterface(Components.interfaces.nsIDOMWindowInternal);
2239 if ( browser && (documentURI == browser.getBrowser().currentURI.spec))
2240 break;
2241
2242 browser = null;
2243 }
2244 }
2245 catch (ex) {}
2246
2247 // If none found, open a new browser
2248 if (!browser)
2249 {
2250 browser = window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", documentURI);
2251 }
2252 else
2253 {
2254 try {
2255 browser.BrowserReloadSkipCache();
2256 browser.focus();
2257 } catch (ex) {}
2258 }
2259 }
2260 }
2261 };
2262
2263 //-----------------------------------------------------------------------------------
2264 var nsSendPageCommand =
2265 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2266 isCommandEnabled: function(aCommand, dummy)
2267 {
2268 return (IsDocumentEditable() &&
2269 (DocumentHasBeenSaved() || IsDocumentModified()));
2270 },
2271
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2272 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2273 doCommandParams: function(aCommand, aParams, aRefCon) {},
2274
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2275 doCommand: function(aCommand)
2276 {
2277 // Don't continue if user canceled during prompt for saving
2278 // DocumentHasBeenSaved will test if we have a URL and suppress "Don't Save" button if not
2279 if (!CheckAndSaveDocument("cmd_editSendPage", DocumentHasBeenSaved()))
2280 return;
2281
2282 // Check if we saved again just in case?
2283 if (DocumentHasBeenSaved())
2284 {
2285 // Launch Messenger Composer window with current page as contents
2286 try
2287 {
2288 openComposeWindow(GetDocumentUrl(), GetDocumentTitle());
2289 } catch (ex) { dump("Cannot Send Page: " + ex + "\n"); }
2290 }
2291 }
2292 };
2293
2294 //-----------------------------------------------------------------------------------
2295 var nsPrintCommand =
2296 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2297 isCommandEnabled: function(aCommand, dummy)
2298 {
2299 return true; // we can always do this
2300 },
2301
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2302 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2303 doCommandParams: function(aCommand, aParams, aRefCon) {},
2304
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2305 doCommand: function(aCommand)
2306 {
2307 // In editor.js
2308 FinishHTMLSource();
2309 try {
2310 PrintUtils.print();
2311 } catch (e) {}
2312 }
2313 };
2314
2315 //-----------------------------------------------------------------------------------
2316 var nsPrintSetupCommand =
2317 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2318 isCommandEnabled: function(aCommand, dummy)
2319 {
2320 return true; // we can always do this
2321 },
2322
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2323 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2324 doCommandParams: function(aCommand, aParams, aRefCon) {},
2325
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2326 doCommand: function(aCommand)
2327 {
2328 // In editor.js
2329 FinishHTMLSource();
2330 PrintUtils.showPageSetup();
2331 }
2332 };
2333
2334 //-----------------------------------------------------------------------------------
2335 var nsQuitCommand =
2336 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2337 isCommandEnabled: function(aCommand, dummy)
2338 {
2339 return true; // we can always do this
2340 },
2341
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2342 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2343 doCommandParams: function(aCommand, aParams, aRefCon) {}
2344
2345 /* The doCommand is not used, since cmd_quit's oncommand="goQuitApplication()" in platformCommunicatorOverlay.xul
2346 doCommand: function(aCommand)
2347 {
2348 // In editor.js
2349 FinishHTMLSource();
2350 goQuitApplication();
2351 }
2352 */
2353 };
2354
2355 //-----------------------------------------------------------------------------------
2356 var nsFindCommand =
2357 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2358 isCommandEnabled: function(aCommand, editorElement)
2359 {
2360 return editorElement.getEditor(editorElement.contentWindow) != null;
2361 },
2362
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2363 getCommandStateParams: function(aCommand, aParams, editorElement) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2364 doCommandParams: function(aCommand, aParams, editorElement) {},
2365
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2366 doCommand: function(aCommand, editorElement)
2367 {
2368 try {
2369 window.openDialog("chrome://editor/content/EdReplace.xul", "_blank",
2370 "chrome,modal,titlebar", editorElement);
2371 }
2372 catch(ex) {
2373 dump("*** Exception: couldn't open Replace Dialog\n");
2374 }
2375 //window.content.focus();
2376 }
2377 };
2378
2379 //-----------------------------------------------------------------------------------
2380 var nsFindAgainCommand =
2381 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2382 isCommandEnabled: function(aCommand, editorElement)
2383 {
2384 // we can only do this if the search pattern is non-empty. Not sure how
2385 // to get that from here
2386 return editorElement.getEditor(editorElement.contentWindow) != null;
2387 },
2388
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2389 getCommandStateParams: function(aCommand, aParams, editorElement) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2390 doCommandParams: function(aCommand, aParams, editorElement) {},
2391
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2392 doCommand: function(aCommand, editorElement)
2393 {
2394 try {
2395 var findPrev = aCommand == "cmd_findPrev";
2396 var findInst = editorElement.webBrowserFind;
2397 var findService = Components.classes["@mozilla.org/find/find_service;1"]
2398 .getService(Components.interfaces.nsIFindService);
2399 findInst.findBackwards = findService.findBackwards ^ findPrev;
2400 findInst.findNext();
2401 // reset to what it was in dialog, otherwise dialog setting can get reversed
2402 findInst.findBackwards = findService.findBackwards;
2403 }
2404 catch (ex) {}
2405 }
2406 };
2407
2408 //-----------------------------------------------------------------------------------
2409 var nsRewrapCommand =
2410 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2411 isCommandEnabled: function(aCommand, dummy)
2412 {
2413 return (IsDocumentEditable() && !IsInHTMLSourceMode() &&
2414 GetCurrentEditor() instanceof Components.interfaces.nsIEditorMailSupport);
2415 },
2416
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2417 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2418 doCommandParams: function(aCommand, aParams, aRefCon) {},
2419
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2420 doCommand: function(aCommand)
2421 {
2422 GetCurrentEditor().QueryInterface(Components.interfaces.nsIEditorMailSupport).rewrap(false);
2423 }
2424 };
2425
2426 //-----------------------------------------------------------------------------------
2427 var nsSpellingCommand =
2428 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2429 isCommandEnabled: function(aCommand, dummy)
2430 {
2431 return (IsDocumentEditable() &&
2432 !IsInHTMLSourceMode() && IsSpellCheckerInstalled());
2433 },
2434
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2435 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2436 doCommandParams: function(aCommand, aParams, aRefCon) {},
2437
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2438 doCommand: function(aCommand)
2439 {
2440 window.cancelSendMessage = false;
2441 try {
2442 var skipBlockQuotes = (window.document.documentElement.getAttribute("windowtype") == "msgcompose");
2443 window.openDialog("chrome://editor/content/EdSpellCheck.xul", "_blank",
2444 "chrome,close,titlebar,modal", false, skipBlockQuotes, true);
2445 }
2446 catch(ex) {}
2447 window.content.focus();
2448 }
2449 };
2450
2451 // Validate using http://validator.w3.org/file-upload.html
2452 var URL2Validate;
2453 var nsValidateCommand =
2454 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2455 isCommandEnabled: function(aCommand, dummy)
2456 {
2457 return GetCurrentEditor() != null;
2458 },
2459
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2460 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2461 doCommandParams: function(aCommand, aParams, aRefCon) {},
2462
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2463 doCommand: function(aCommand)
2464 {
2465 // If the document hasn't been modified,
2466 // then just validate the current url.
2467 if (IsDocumentModified() || IsHTMLSourceChanged())
2468 {
2469 if (!CheckAndSaveDocument("cmd_validate", false))
2470 return;
2471
2472 // Check if we saved again just in case?
2473 if (!DocumentHasBeenSaved()) // user hit cancel?
2474 return;
2475 }
2476
2477 URL2Validate = GetDocumentUrl();
2478 // See if it's a file:
2479 var ifile;
2480 try {
2481 var fileHandler = GetFileProtocolHandler();
2482 ifile = fileHandler.getFileFromURLSpec(URL2Validate);
2483 // nsIFile throws an exception if it's not a file url
2484 } catch (e) { ifile = null; }
2485 if (ifile)
2486 {
2487 URL2Validate = ifile.path;
2488 var vwin = window.open("http://validator.w3.org/file-upload.html",
2489 "EditorValidate");
2490 // Window loads asynchronously, so pass control to the load listener:
2491 vwin.addEventListener("load", this.validateFilePageLoaded, false);
2492 }
2493 else
2494 {
2495 var vwin2 = window.open("http://validator.w3.org/check?uri="
2496 + URL2Validate
2497 + "&doctype=Inline",
2498 "EditorValidate");
2499 // This does the validation, no need to wait for page loaded.
2500 }
2501 },
validateFilePageLoaded
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2502 validateFilePageLoaded: function(event)
2503 {
2504 event.target.forms[0].uploaded_file.value = URL2Validate;
2505 }
2506 };
2507
2508 var nsCheckLinksCommand =
2509 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2510 isCommandEnabled: function(aCommand, dummy)
2511 {
2512 return (IsDocumentEditable());
2513 },
2514
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2515 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2516 doCommandParams: function(aCommand, aParams, aRefCon) {},
2517
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2518 doCommand: function(aCommand)
2519 {
2520 window.openDialog("chrome://editor/content/EdLinkChecker.xul","_blank", "chrome,close,titlebar,modal");
2521 window.content.focus();
2522 }
2523 };
2524
2525 //-----------------------------------------------------------------------------------
2526 var nsFormCommand =
2527 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2528 isCommandEnabled: function(aCommand, dummy)
2529 {
2530 return (IsDocumentEditable() && IsEditingRenderedHTML());
2531 },
2532
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2533 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2534 doCommandParams: function(aCommand, aParams, aRefCon) {},
2535
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2536 doCommand: function(aCommand)
2537 {
2538 window.openDialog("chrome://editor/content/EdFormProps.xul", "_blank", "chrome,close,titlebar,modal");
2539 window.content.focus();
2540 }
2541 };
2542
2543 //-----------------------------------------------------------------------------------
2544 var nsInputTagCommand =
2545 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2546 isCommandEnabled: function(aCommand, dummy)
2547 {
2548 return (IsDocumentEditable() && IsEditingRenderedHTML());
2549 },
2550
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2551 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2552 doCommandParams: function(aCommand, aParams, aRefCon) {},
2553
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2554 doCommand: function(aCommand)
2555 {
2556 window.openDialog("chrome://editor/content/EdInputProps.xul", "_blank", "chrome,close,titlebar,modal");
2557 window.content.focus();
2558 }
2559 };
2560
2561 //-----------------------------------------------------------------------------------
2562 var nsInputImageCommand =
2563 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2564 isCommandEnabled: function(aCommand, dummy)
2565 {
2566 return (IsDocumentEditable() && IsEditingRenderedHTML());
2567 },
2568
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2569 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2570 doCommandParams: function(aCommand, aParams, aRefCon) {},
2571
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2572 doCommand: function(aCommand)
2573 {
2574 window.openDialog("chrome://editor/content/EdInputImage.xul", "_blank", "chrome,close,titlebar,modal");
2575 window.content.focus();
2576 }
2577 };
2578
2579 //-----------------------------------------------------------------------------------
2580 var nsTextAreaCommand =
2581 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2582 isCommandEnabled: function(aCommand, dummy)
2583 {
2584 return (IsDocumentEditable() && IsEditingRenderedHTML());
2585 },
2586
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2587 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2588 doCommandParams: function(aCommand, aParams, aRefCon) {},
2589
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2590 doCommand: function(aCommand)
2591 {
2592 window.openDialog("chrome://editor/content/EdTextAreaProps.xul", "_blank", "chrome,close,titlebar,modal");
2593 window.content.focus();
2594 }
2595 };
2596
2597 //-----------------------------------------------------------------------------------
2598 var nsSelectCommand =
2599 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2600 isCommandEnabled: function(aCommand, dummy)
2601 {
2602 return (IsDocumentEditable() && IsEditingRenderedHTML());
2603 },
2604
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2605 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2606 doCommandParams: function(aCommand, aParams, aRefCon) {},
2607
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2608 doCommand: function(aCommand)
2609 {
2610 window.openDialog("chrome://editor/content/EdSelectProps.xul", "_blank", "chrome,close,titlebar,modal");
2611 window.content.focus();
2612 }
2613 };
2614
2615 //-----------------------------------------------------------------------------------
2616 var nsButtonCommand =
2617 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2618 isCommandEnabled: function(aCommand, dummy)
2619 {
2620 return (IsDocumentEditable() && IsEditingRenderedHTML());
2621 },
2622
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2623 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2624 doCommandParams: function(aCommand, aParams, aRefCon) {},
2625
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2626 doCommand: function(aCommand)
2627 {
2628 window.openDialog("chrome://editor/content/EdButtonProps.xul", "_blank", "chrome,close,titlebar,modal");
2629 window.content.focus();
2630 }
2631 };
2632
2633 //-----------------------------------------------------------------------------------
2634 var nsLabelCommand =
2635 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2636 isCommandEnabled: function(aCommand, dummy)
2637 {
2638 return (IsDocumentEditable() && IsEditingRenderedHTML());
2639 },
2640
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2641 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2642 doCommandParams: function(aCommand, aParams, aRefCon) {},
2643
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2644 doCommand: function(aCommand)
2645 {
2646 var tagName = "label";
2647 try {
2648 var editor = GetCurrentEditor();
2649 // Find selected label or if start/end of selection is in label
2650 var labelElement = editor.getSelectedElement(tagName);
2651 if (!labelElement)
2652 labelElement = editor.getElementOrParentByTagName(tagName, editor.selection.anchorNode);
2653 if (!labelElement)
2654 labelElement = editor.getElementOrParentByTagName(tagName, editor.selection.focusNode);
2655 if (labelElement) {
2656 // We only open the dialog for an existing label
2657 window.openDialog("chrome://editor/content/EdLabelProps.xul", "_blank", "chrome,close,titlebar,modal", labelElement);
2658 window.content.focus();
2659 } else {
2660 EditorSetTextProperty(tagName, "", "");
2661 }
2662 } catch (e) {}
2663 }
2664 };
2665
2666 //-----------------------------------------------------------------------------------
2667 var nsFieldSetCommand =
2668 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2669 isCommandEnabled: function(aCommand, dummy)
2670 {
2671 return (IsDocumentEditable() && IsEditingRenderedHTML());
2672 },
2673
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2674 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2675 doCommandParams: function(aCommand, aParams, aRefCon) {},
2676
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2677 doCommand: function(aCommand)
2678 {
2679 window.openDialog("chrome://editor/content/EdFieldSetProps.xul", "_blank", "chrome,close,titlebar,modal");
2680 window.content.focus();
2681 }
2682 };
2683
2684 //-----------------------------------------------------------------------------------
2685 var nsIsIndexCommand =
2686 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2687 isCommandEnabled: function(aCommand, dummy)
2688 {
2689 return (IsDocumentEditable() && IsEditingRenderedHTML());
2690 },
2691
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2692 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2693 doCommandParams: function(aCommand, aParams, aRefCon) {},
2694
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2695 doCommand: function(aCommand)
2696 {
2697 try {
2698 var editor = GetCurrentEditor();
2699 var isindexElement = editor.createElementWithDefaults("isindex");
2700 isindexElement.setAttribute("prompt", editor.outputToString("text/plain", kOutputSelectionOnly));
2701 editor.insertElementAtSelection(isindexElement, true);
2702 } catch (e) {}
2703 }
2704 };
2705
2706 //-----------------------------------------------------------------------------------
2707 var nsImageCommand =
2708 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2709 isCommandEnabled: function(aCommand, dummy)
2710 {
2711 return (IsDocumentEditable() && IsEditingRenderedHTML());
2712 },
2713
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2714 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2715 doCommandParams: function(aCommand, aParams, aRefCon) {},
2716
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2717 doCommand: function(aCommand)
2718 {
2719 window.openDialog("chrome://editor/content/EdImageProps.xul","_blank", "chrome,close,titlebar,modal");
2720 window.content.focus();
2721 }
2722 };
2723
2724 //-----------------------------------------------------------------------------------
2725 var nsHLineCommand =
2726 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2727 isCommandEnabled: function(aCommand, dummy)
2728 {
2729 return (IsDocumentEditable() && IsEditingRenderedHTML());
2730 },
2731
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2732 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2733 doCommandParams: function(aCommand, aParams, aRefCon) {},
2734
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2735 doCommand: function(aCommand)
2736 {
2737 // Inserting an HLine is different in that we don't use properties dialog
2738 // unless we are editing an existing line's attributes
2739 // We get the last-used attributes from the prefs and insert immediately
2740
2741 var tagName = "hr";
2742 var editor = GetCurrentEditor();
2743
2744 var hLine;
2745 try {
2746 hLine = editor.getSelectedElement(tagName);
2747 } catch (e) {return;}
2748
2749 if (hLine)
2750 {
2751 // We only open the dialog for an existing HRule
2752 window.openDialog("chrome://editor/content/EdHLineProps.xul", "_blank", "chrome,close,titlebar,modal");
2753 window.content.focus();
2754 }
2755 else
2756 {
2757 try {
2758 hLine = editor.createElementWithDefaults(tagName);
2759
2760 // We change the default attributes to those saved in the user prefs
2761 var prefs = GetPrefs();
2762 var align = prefs.getIntPref("editor.hrule.align");
2763 if (align == 0)
2764 editor.setAttributeOrEquivalent(hLine, "align", "left", true);
2765 else if (align == 2)
2766 editor.setAttributeOrEquivalent(hLine, "align", "right", true);
2767
2768 //Note: Default is center (don't write attribute)
2769
2770 var width = prefs.getIntPref("editor.hrule.width");
2771 var percent = prefs.getBoolPref("editor.hrule.width_percent");
2772 if (percent)
2773 width = width +"%";
2774
2775 editor.setAttributeOrEquivalent(hLine, "width", width, true);
2776
2777 var height = prefs.getIntPref("editor.hrule.height");
2778 editor.setAttributeOrEquivalent(hLine, "size", String(height), true);
2779
2780 var shading = prefs.getBoolPref("editor.hrule.shading");
2781 if (shading)
2782 hLine.removeAttribute("noshade");
2783 else
2784 hLine.setAttribute("noshade", "noshade");
2785
2786 editor.insertElementAtSelection(hLine, true);
2787
2788 } catch (e) {}
2789 }
2790 }
2791 };
2792
2793 //-----------------------------------------------------------------------------------
2794 var nsLinkCommand =
2795 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2796 isCommandEnabled: function(aCommand, dummy)
2797 {
2798 return (IsDocumentEditable() && IsEditingRenderedHTML());
2799 },
2800
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2801 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2802 doCommandParams: function(aCommand, aParams, aRefCon) {},
2803
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2804 doCommand: function(aCommand)
2805 {
2806 // If selected element is an image, launch that dialog instead
2807 // since last tab panel handles link around an image
2808 var element = GetObjectForProperties();
2809 if (element && element.nodeName.toLowerCase() == "img")
2810 window.openDialog("chrome://editor/content/EdImageProps.xul","_blank", "chrome,close,titlebar,modal", null, true);
2811 else
2812 window.openDialog("chrome://editor/content/EdLinkProps.xul","_blank", "chrome,close,titlebar,modal");
2813 window.content.focus();
2814 }
2815 };
2816
2817 //-----------------------------------------------------------------------------------
2818 var nsAnchorCommand =
2819 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2820 isCommandEnabled: function(aCommand, dummy)
2821 {
2822 return (IsDocumentEditable() && IsEditingRenderedHTML());
2823 },
2824
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2825 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2826 doCommandParams: function(aCommand, aParams, aRefCon) {},
2827
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2828 doCommand: function(aCommand)
2829 {
2830 window.openDialog("chrome://editor/content/EdNamedAnchorProps.xul", "_blank", "chrome,close,titlebar,modal", "");
2831 window.content.focus();
2832 }
2833 };
2834
2835 //-----------------------------------------------------------------------------------
2836 var nsInsertHTMLWithDialogCommand =
2837 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2838 isCommandEnabled: function(aCommand, dummy)
2839 {
2840 return (IsDocumentEditable() && IsEditingRenderedHTML());
2841 },
2842
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2843 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2844 doCommandParams: function(aCommand, aParams, aRefCon) {},
2845
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2846 doCommand: function(aCommand)
2847 {
2848 window.openDialog("chrome://editor/content/EdInsSrc.xul","_blank", "chrome,close,titlebar,modal,resizable", "");
2849 window.content.focus();
2850 }
2851 };
2852
2853 //-----------------------------------------------------------------------------------
2854 var nsInsertCharsCommand =
2855 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2856 isCommandEnabled: function(aCommand, dummy)
2857 {
2858 return (IsDocumentEditable());
2859 },
2860
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2861 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2862 doCommandParams: function(aCommand, aParams, aRefCon) {},
2863
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2864 doCommand: function(aCommand)
2865 {
2866 EditorFindOrCreateInsertCharWindow();
2867 }
2868 };
2869
2870 //-----------------------------------------------------------------------------------
2871 var nsInsertBreakCommand =
2872 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2873 isCommandEnabled: function(aCommand, dummy)
2874 {
2875 return (IsDocumentEditable() && IsEditingRenderedHTML());
2876 },
2877
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2878 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2879 doCommandParams: function(aCommand, aParams, aRefCon) {},
2880
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2881 doCommand: function(aCommand)
2882 {
2883 try {
2884 GetCurrentEditor().insertHTML("<br>");
2885 } catch (e) {}
2886 }
2887 };
2888
2889 //-----------------------------------------------------------------------------------
2890 var nsInsertBreakAllCommand =
2891 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2892 isCommandEnabled: function(aCommand, dummy)
2893 {
2894 return (IsDocumentEditable() && IsEditingRenderedHTML());
2895 },
2896
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2897 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2898 doCommandParams: function(aCommand, aParams, aRefCon) {},
2899
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2900 doCommand: function(aCommand)
2901 {
2902 try {
2903 GetCurrentEditor().insertHTML("<br clear='all'>");
2904 } catch (e) {}
2905 }
2906 };
2907
2908 //-----------------------------------------------------------------------------------
2909 var nsGridCommand =
2910 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2911 isCommandEnabled: function(aCommand, dummy)
2912 {
2913 return (IsDocumentEditable() && IsEditingRenderedHTML());
2914 },
2915
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2916 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2917 doCommandParams: function(aCommand, aParams, aRefCon) {},
2918
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2919 doCommand: function(aCommand)
2920 {
2921 window.openDialog("chrome://editor/content/EdSnapToGrid.xul","_blank", "chrome,close,titlebar,modal");
2922 window.content.focus();
2923 }
2924 };
2925
2926
2927 //-----------------------------------------------------------------------------------
2928 var nsListPropertiesCommand =
2929 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2930 isCommandEnabled: function(aCommand, dummy)
2931 {
2932 return (IsDocumentEditable() && IsEditingRenderedHTML());
2933 },
2934
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2935 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2936 doCommandParams: function(aCommand, aParams, aRefCon) {},
2937
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2938 doCommand: function(aCommand)
2939 {
2940 window.openDialog("chrome://editor/content/EdListProps.xul","_blank", "chrome,close,titlebar,modal");
2941 window.content.focus();
2942 }
2943 };
2944
2945
2946 //-----------------------------------------------------------------------------------
2947 var nsPagePropertiesCommand =
2948 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2949 isCommandEnabled: function(aCommand, dummy)
2950 {
2951 return (IsDocumentEditable() && IsEditingRenderedHTML());
2952 },
2953
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2954 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2955 doCommandParams: function(aCommand, aParams, aRefCon) {},
2956
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2957 doCommand: function(aCommand)
2958 {
2959 var oldTitle = GetDocumentTitle();
2960 window.openDialog("chrome://editor/content/EdPageProps.xul","_blank", "chrome,close,titlebar,modal", "");
2961
2962 // Update main window title and
2963 // recent menu data in prefs if doc title changed
2964 if (GetDocumentTitle() != oldTitle)
2965 UpdateWindowTitle();
2966
2967 window.content.focus();
2968 }
2969 };
2970
2971 //-----------------------------------------------------------------------------------
2972 var nsObjectPropertiesCommand =
2973 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2974 isCommandEnabled: function(aCommand, dummy)
2975 {
2976 var isEnabled = false;
2977 if (IsDocumentEditable() && IsEditingRenderedHTML())
2978 {
2979 isEnabled = (GetObjectForProperties() != null ||
2980 GetCurrentEditor().getSelectedElement("href") != null);
2981 }
2982 return isEnabled;
2983 },
2984
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2985 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2986 doCommandParams: function(aCommand, aParams, aRefCon) {},
2987
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
2988 doCommand: function(aCommand)
2989 {
2990 // Launch Object properties for appropriate selected element
2991 var element = GetObjectForProperties();
2992 if (element)
2993 {
2994 var name = element.nodeName.toLowerCase();
2995 switch (name)
2996 {
2997 case 'img':
2998 goDoCommand("cmd_image");
2999 break;
3000 case 'hr':
3001 goDoCommand("cmd_hline");
3002 break;
3003 case 'form':
3004 goDoCommand("cmd_form");
3005 break;
3006 case 'input':
3007 var type = element.getAttribute("type");
3008 if (type && type.toLowerCase() == "image")
3009 goDoCommand("cmd_inputimage");
3010 else
3011 goDoCommand("cmd_inputtag");
3012 break;
3013 case 'textarea':
3014 goDoCommand("cmd_textarea");
3015 break;
3016 case 'select':
3017 goDoCommand("cmd_select");
3018 break;
3019 case 'button':
3020 goDoCommand("cmd_button");
3021 break;
3022 case 'label':
3023 goDoCommand("cmd_label");
3024 break;
3025 case 'fieldset':
3026 goDoCommand("cmd_fieldset");
3027 break;
3028 case 'table':
3029 EditorInsertOrEditTable(false);
3030 break;
3031 case 'td':
3032 case 'th':
3033 EditorTableCellProperties();
3034 break;
3035 case 'ol':
3036 case 'ul':
3037 case 'dl':
3038 case 'li':
3039 goDoCommand("cmd_listProperties");
3040 break;
3041 case 'a':
3042 if (element.name)
3043 {
3044 goDoCommand("cmd_anchor");
3045 }
3046 else if(element.href)
3047 {
3048 goDoCommand("cmd_link");
3049 }
3050 break;
3051 default:
3052 doAdvancedProperties(element);
3053 break;
3054 }
3055 } else {
3056 // We get a partially-selected link if asked for specifically
3057 try {
3058 element = GetCurrentEditor().getSelectedElement("href");
3059 } catch (e) {}
3060 if (element)
3061 goDoCommand("cmd_link");
3062 }
3063 window.content.focus();
3064 }
3065 };
3066
3067
3068 //-----------------------------------------------------------------------------------
3069 var nsSetSmiley =
3070 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3071 isCommandEnabled: function(aCommand, dummy)
3072 {
3073 return (IsDocumentEditable() && IsEditingRenderedHTML());
3074 },
3075
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3076 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3077 doCommandParams: function(aCommand, aParams, aRefCon)
3078 {
3079 var smileyCode = aParams.getStringValue("state_attribute");
3080
3081 var strSml;
3082 switch(smileyCode)
3083 {
3084 case ":-)": strSml="s1";
3085 break;
3086 case ":-(": strSml="s2";
3087 break;
3088 case ";-)": strSml="s3";
3089 break;
3090 case ":-P":
3091 case ":-p":
3092 case ":-b": strSml="s4";
3093 break;
3094 case ":-D": strSml="s5";
3095 break;
3096 case ":-[": strSml="s6";
3097 break;
3098 case ":-/":
3099 case ":/":
3100 case ":-\\":
3101 case ":\\": strSml="s7";
3102 break;
3103 case "=-O":
3104 case "=-o": strSml="s8";
3105 break;
3106 case ":-*": strSml="s9";
3107 break;
3108 case ">:o":
3109 case ">:-o": strSml="s10";
3110 break;
3111 case "8-)": strSml="s11";
3112 break;
3113 case ":-$": strSml="s12";
3114 break;
3115 case ":-!": strSml="s13";
3116 break;
3117 case "O:-)":
3118 case "o:-)": strSml="s14";
3119 break;
3120 case ":'(": strSml="s15";
3121 break;
3122 case ":-X":
3123 case ":-x": strSml="s16";
3124 break;
3125 default: strSml="";
3126 break;
3127 }
3128
3129 try
3130 {
3131 var editor = GetCurrentEditor();
3132 var selection = editor.selection;
3133 var extElement = editor.createElementWithDefaults("span");
3134 extElement.setAttribute("class", "moz-smiley-" + strSml);
3135
3136 var intElement = editor.createElementWithDefaults("span");
3137 if (!intElement)
3138 return;
3139
3140 //just for mailnews, because of the way it removes HTML
3141 var smileButMenu = document.getElementById('smileButtonMenu');
3142 if (smileButMenu.getAttribute("padwithspace"))
3143 smileyCode = " " + smileyCode + " ";
3144
3145 var txtElement = editor.document.createTextNode(smileyCode);
3146 if (!txtElement)
3147 return;
3148
3149 intElement.appendChild (txtElement);
3150 extElement.appendChild (intElement);
3151
3152
3153 editor.insertElementAtSelection(extElement,true);
3154 window.content.focus();
3155
3156 }
3157 catch (e)
3158 {
3159 dump("Exception occured in smiley InsertElementAtSelection\n");
3160 }
3161 },
3162 // This is now deprecated in favor of "doCommandParams"
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3163 doCommand: function(aCommand) {}
3164 };
3165
3166
doAdvancedProperties
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3167 function doAdvancedProperties(element)
3168 {
3169 if (element)
3170 {
3171 window.openDialog("chrome://editor/content/EdAdvancedEdit.xul", "_blank", "chrome,close,titlebar,modal,resizable=yes", "", element);
3172 window.content.focus();
3173 }
3174 }
3175
3176 var nsAdvancedPropertiesCommand =
3177 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3178 isCommandEnabled: function(aCommand, dummy)
3179 {
3180 return (IsDocumentEditable() && IsEditingRenderedHTML());
3181 },
3182
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3183 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3184 doCommandParams: function(aCommand, aParams, aRefCon) {},
3185
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3186 doCommand: function(aCommand)
3187 {
3188 // Launch AdvancedEdit dialog for the selected element
3189 try {
3190 var element = GetCurrentEditor().getSelectedElement("");
3191 doAdvancedProperties(element);
3192 } catch (e) {}
3193 }
3194 };
3195
3196 //-----------------------------------------------------------------------------------
3197 var nsColorPropertiesCommand =
3198 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3199 isCommandEnabled: function(aCommand, dummy)
3200 {
3201 return (IsDocumentEditable() && IsEditingRenderedHTML());
3202 },
3203
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3204 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3205 doCommandParams: function(aCommand, aParams, aRefCon) {},
3206
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3207 doCommand: function(aCommand)
3208 {
3209 window.openDialog("chrome://editor/content/EdColorProps.xul","_blank", "chrome,close,titlebar,modal", "");
3210 UpdateDefaultColors();
3211 window.content.focus();
3212 }
3213 };
3214
3215 //-----------------------------------------------------------------------------------
3216 var nsRemoveNamedAnchorsCommand =
3217 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3218 isCommandEnabled: function(aCommand, dummy)
3219 {
3220 // We could see if there's any link in selection, but it doesn't seem worth the work!
3221 return (IsDocumentEditable() && IsEditingRenderedHTML());
3222 },
3223
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3224 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3225 doCommandParams: function(aCommand, aParams, aRefCon) {},
3226
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3227 doCommand: function(aCommand)
3228 {
3229 EditorRemoveTextProperty("name", "");
3230 window.content.focus();
3231 }
3232 };
3233
3234
3235 //-----------------------------------------------------------------------------------
3236 var nsEditLinkCommand =
3237 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3238 isCommandEnabled: function(aCommand, dummy)
3239 {
3240 // Not really used -- this command is only in context menu, and we do enabling there
3241 return (IsDocumentEditable() && IsEditingRenderedHTML());
3242 },
3243
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3244 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3245 doCommandParams: function(aCommand, aParams, aRefCon) {},
3246
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3247 doCommand: function(aCommand)
3248 {
3249 try {
3250 var element = GetCurrentEditor().getSelectedElement("href");
3251 if (element)
3252 editPage(element.href, window, false);
3253 } catch (e) {}
3254 window.content.focus();
3255 }
3256 };
3257
3258
3259 //-----------------------------------------------------------------------------------
3260 var nsNormalModeCommand =
3261 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3262 isCommandEnabled: function(aCommand, dummy)
3263 {
3264 return IsHTMLEditor() && IsDocumentEditable();
3265 },
3266
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3267 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3268 doCommandParams: function(aCommand, aParams, aRefCon) {},
3269
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3270 doCommand: function(aCommand)
3271 {
3272 SetEditMode(kDisplayModeNormal);
3273 }
3274 };
3275
3276 var nsAllTagsModeCommand =
3277 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3278 isCommandEnabled: function(aCommand, dummy)
3279 {
3280 return (IsDocumentEditable() && IsHTMLEditor());
3281 },
3282
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3283 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3284 doCommandParams: function(aCommand, aParams, aRefCon) {},
3285
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3286 doCommand: function(aCommand)
3287 {
3288 SetEditMode(kDisplayModeAllTags);
3289 }
3290 };
3291
3292 var nsHTMLSourceModeCommand =
3293 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3294 isCommandEnabled: function(aCommand, dummy)
3295 {
3296 return (IsDocumentEditable() && IsHTMLEditor());
3297 },
3298
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3299 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3300 doCommandParams: function(aCommand, aParams, aRefCon) {},
3301
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3302 doCommand: function(aCommand)
3303 {
3304 SetEditMode(kDisplayModeSource);
3305 }
3306 };
3307
3308 var nsPreviewModeCommand =
3309 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3310 isCommandEnabled: function(aCommand, dummy)
3311 {
3312 return (IsDocumentEditable() && IsHTMLEditor());
3313 },
3314
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3315 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3316 doCommandParams: function(aCommand, aParams, aRefCon) {},
3317
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3318 doCommand: function(aCommand)
3319 {
3320 SetEditMode(kDisplayModePreview);
3321 }
3322 };
3323
3324 //-----------------------------------------------------------------------------------
3325 var nsInsertOrEditTableCommand =
3326 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3327 isCommandEnabled: function(aCommand, dummy)
3328 {
3329 return (IsDocumentEditable() && IsEditingRenderedHTML());
3330 },
3331
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3332 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3333 doCommandParams: function(aCommand, aParams, aRefCon) {},
3334
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3335 doCommand: function(aCommand)
3336 {
3337 if (IsInTableCell())
3338 EditorTableCellProperties();
3339 else
3340 EditorInsertOrEditTable(true);
3341 }
3342 };
3343
3344 //-----------------------------------------------------------------------------------
3345 var nsEditTableCommand =
3346 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3347 isCommandEnabled: function(aCommand, dummy)
3348 {
3349 return IsInTable();
3350 },
3351
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3352 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3353 doCommandParams: function(aCommand, aParams, aRefCon) {},
3354
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3355 doCommand: function(aCommand)
3356 {
3357 EditorInsertOrEditTable(false);
3358 }
3359 };
3360
3361 //-----------------------------------------------------------------------------------
3362 var nsSelectTableCommand =
3363 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3364 isCommandEnabled: function(aCommand, dummy)
3365 {
3366 return IsInTable();
3367 },
3368
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3369 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3370 doCommandParams: function(aCommand, aParams, aRefCon) {},
3371
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3372 doCommand: function(aCommand)
3373 {
3374 try {
3375 GetCurrentTableEditor().selectTable();
3376 } catch(e) {}
3377 window.content.focus();
3378 }
3379 };
3380
3381 var nsSelectTableRowCommand =
3382 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3383 isCommandEnabled: function(aCommand, dummy)
3384 {
3385 return IsInTableCell();
3386 },
3387
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3388 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3389 doCommandParams: function(aCommand, aParams, aRefCon) {},
3390
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3391 doCommand: function(aCommand)
3392 {
3393 try {
3394 GetCurrentTableEditor().selectTableRow();
3395 } catch(e) {}
3396 window.content.focus();
3397 }
3398 };
3399
3400 var nsSelectTableColumnCommand =
3401 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3402 isCommandEnabled: function(aCommand, dummy)
3403 {
3404 return IsInTableCell();
3405 },
3406
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3407 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3408 doCommandParams: function(aCommand, aParams, aRefCon) {},
3409
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3410 doCommand: function(aCommand)
3411 {
3412 try {
3413 GetCurrentTableEditor().selectTableColumn();
3414 } catch(e) {}
3415 window.content.focus();
3416 }
3417 };
3418
3419 var nsSelectTableCellCommand =
3420 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3421 isCommandEnabled: function(aCommand, dummy)
3422 {
3423 return IsInTableCell();
3424 },
3425
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3426 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3427 doCommandParams: function(aCommand, aParams, aRefCon) {},
3428
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3429 doCommand: function(aCommand)
3430 {
3431 try {
3432 GetCurrentTableEditor().selectTableCell();
3433 } catch(e) {}
3434 window.content.focus();
3435 }
3436 };
3437
3438 var nsSelectAllTableCellsCommand =
3439 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3440 isCommandEnabled: function(aCommand, dummy)
3441 {
3442 return IsInTable();
3443 },
3444
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3445 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3446 doCommandParams: function(aCommand, aParams, aRefCon) {},
3447
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3448 doCommand: function(aCommand)
3449 {
3450 try {
3451 GetCurrentTableEditor().selectAllTableCells();
3452 } catch(e) {}
3453 window.content.focus();
3454 }
3455 };
3456
3457 //-----------------------------------------------------------------------------------
3458 var nsInsertTableCommand =
3459 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3460 isCommandEnabled: function(aCommand, dummy)
3461 {
3462 return IsDocumentEditable() && IsEditingRenderedHTML();
3463 },
3464
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3465 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3466 doCommandParams: function(aCommand, aParams, aRefCon) {},
3467
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3468 doCommand: function(aCommand)
3469 {
3470 EditorInsertTable();
3471 }
3472 };
3473
3474 var nsInsertTableRowAboveCommand =
3475 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3476 isCommandEnabled: function(aCommand, dummy)
3477 {
3478 return IsInTableCell();
3479 },
3480
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3481 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3482 doCommandParams: function(aCommand, aParams, aRefCon) {},
3483
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3484 doCommand: function(aCommand)
3485 {
3486 try {
3487 GetCurrentTableEditor().insertTableRow(1, false);
3488 } catch(e) {}
3489 window.content.focus();
3490 }
3491 };
3492
3493 var nsInsertTableRowBelowCommand =
3494 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3495 isCommandEnabled: function(aCommand, dummy)
3496 {
3497 return IsInTableCell();
3498 },
3499
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3500 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3501 doCommandParams: function(aCommand, aParams, aRefCon) {},
3502
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3503 doCommand: function(aCommand)
3504 {
3505 try {
3506 GetCurrentTableEditor().insertTableRow(1, true);
3507 } catch(e) {}
3508 window.content.focus();
3509 }
3510 };
3511
3512 var nsInsertTableColumnBeforeCommand =
3513 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3514 isCommandEnabled: function(aCommand, dummy)
3515 {
3516 return IsInTableCell();
3517 },
3518
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3519 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3520 doCommandParams: function(aCommand, aParams, aRefCon) {},
3521
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3522 doCommand: function(aCommand)
3523 {
3524 try {
3525 GetCurrentTableEditor().insertTableColumn(1, false);
3526 } catch(e) {}
3527 window.content.focus();
3528 }
3529 };
3530
3531 var nsInsertTableColumnAfterCommand =
3532 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3533 isCommandEnabled: function(aCommand, dummy)
3534 {
3535 return IsInTableCell();
3536 },
3537
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3538 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3539 doCommandParams: function(aCommand, aParams, aRefCon) {},
3540
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3541 doCommand: function(aCommand)
3542 {
3543 try {
3544 GetCurrentTableEditor().insertTableColumn(1, true);
3545 } catch(e) {}
3546 window.content.focus();
3547 }
3548 };
3549
3550 var nsInsertTableCellBeforeCommand =
3551 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3552 isCommandEnabled: function(aCommand, dummy)
3553 {
3554 return IsInTableCell();
3555 },
3556
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3557 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3558 doCommandParams: function(aCommand, aParams, aRefCon) {},
3559
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3560 doCommand: function(aCommand)
3561 {
3562 try {
3563 GetCurrentTableEditor().insertTableCell(1, false);
3564 } catch(e) {}
3565 window.content.focus();
3566 }
3567 };
3568
3569 var nsInsertTableCellAfterCommand =
3570 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3571 isCommandEnabled: function(aCommand, dummy)
3572 {
3573 return IsInTableCell();
3574 },
3575
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3576 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3577 doCommandParams: function(aCommand, aParams, aRefCon) {},
3578
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3579 doCommand: function(aCommand)
3580 {
3581 try {
3582 GetCurrentTableEditor().insertTableCell(1, true);
3583 } catch(e) {}
3584 window.content.focus();
3585 }
3586 };
3587
3588 //-----------------------------------------------------------------------------------
3589 var nsDeleteTableCommand =
3590 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3591 isCommandEnabled: function(aCommand, dummy)
3592 {
3593 return IsInTable();
3594 },
3595
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3596 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3597 doCommandParams: function(aCommand, aParams, aRefCon) {},
3598
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3599 doCommand: function(aCommand)
3600 {
3601 try {
3602 GetCurrentTableEditor().deleteTable();
3603 } catch(e) {}
3604 window.content.focus();
3605 }
3606 };
3607
3608 var nsDeleteTableRowCommand =
3609 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3610 isCommandEnabled: function(aCommand, dummy)
3611 {
3612 return IsInTableCell();
3613 },
3614
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3615 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3616 doCommandParams: function(aCommand, aParams, aRefCon) {},
3617
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3618 doCommand: function(aCommand)
3619 {
3620 var rows = GetNumberOfContiguousSelectedRows();
3621 // Delete at least one row
3622 if (rows == 0)
3623 rows = 1;
3624
3625 try {
3626 var editor = GetCurrentTableEditor();
3627 editor.beginTransaction();
3628
3629 // Loop to delete all blocks of contiguous, selected rows
3630 while (rows)
3631 {
3632 editor.deleteTableRow(rows);
3633 rows = GetNumberOfContiguousSelectedRows();
3634 }
3635 } finally { editor.endTransaction(); }
3636 window.content.focus();
3637 }
3638 };
3639
3640 var nsDeleteTableColumnCommand =
3641 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3642 isCommandEnabled: function(aCommand, dummy)
3643 {
3644 return IsInTableCell();
3645 },
3646
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3647 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3648 doCommandParams: function(aCommand, aParams, aRefCon) {},
3649
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3650 doCommand: function(aCommand)
3651 {
3652 var columns = GetNumberOfContiguousSelectedColumns();
3653 // Delete at least one column
3654 if (columns == 0)
3655 columns = 1;
3656
3657 try {
3658 var editor = GetCurrentTableEditor();
3659 editor.beginTransaction();
3660
3661 // Loop to delete all blocks of contiguous, selected columns
3662 while (columns)
3663 {
3664 editor.deleteTableColumn(columns);
3665 columns = GetNumberOfContiguousSelectedColumns();
3666 }
3667 } finally { editor.endTransaction(); }
3668 window.content.focus();
3669 }
3670 };
3671
3672 var nsDeleteTableCellCommand =
3673 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3674 isCommandEnabled: function(aCommand, dummy)
3675 {
3676 return IsInTableCell();
3677 },
3678
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3679 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3680 doCommandParams: function(aCommand, aParams, aRefCon) {},
3681
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3682 doCommand: function(aCommand)
3683 {
3684 try {
3685 GetCurrentTableEditor().deleteTableCell(1);
3686 } catch (e) {}
3687 window.content.focus();
3688 }
3689 };
3690
3691 var nsDeleteTableCellContentsCommand =
3692 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3693 isCommandEnabled: function(aCommand, dummy)
3694 {
3695 return IsInTableCell();
3696 },
3697
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3698 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3699 doCommandParams: function(aCommand, aParams, aRefCon) {},
3700
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3701 doCommand: function(aCommand)
3702 {
3703 try {
3704 GetCurrentTableEditor().deleteTableCellContents();
3705 } catch (e) {}
3706 window.content.focus();
3707 }
3708 };
3709
3710
3711 //-----------------------------------------------------------------------------------
3712 var nsNormalizeTableCommand =
3713 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3714 isCommandEnabled: function(aCommand, dummy)
3715 {
3716 return IsInTable();
3717 },
3718
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3719 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3720 doCommandParams: function(aCommand, aParams, aRefCon) {},
3721
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3722 doCommand: function(aCommand)
3723 {
3724 // Use nsnull to let editor find table enclosing current selection
3725 try {
3726 GetCurrentTableEditor().normalizeTable(null);
3727 } catch (e) {}
3728 window.content.focus();
3729 }
3730 };
3731
3732 //-----------------------------------------------------------------------------------
3733 var nsJoinTableCellsCommand =
3734 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3735 isCommandEnabled: function(aCommand, dummy)
3736 {
3737 if (IsDocumentEditable() && IsEditingRenderedHTML())
3738 {
3739 try {
3740 var editor = GetCurrentTableEditor();
3741 var tagNameObj = { value: "" };
3742 var countObj = { value: 0 };
3743 var cell = editor.getSelectedOrParentTableElement(tagNameObj, countObj);
3744
3745 // We need a cell and either > 1 selected cell or a cell to the right
3746 // (this cell may originate in a row spanned from above current row)
3747 // Note that editor returns "td" for "th" also.
3748 // (this is a pain! Editor and gecko use lowercase tagNames, JS uses uppercase!)
3749 if( cell && (tagNameObj.value == "td"))
3750 {
3751 // Selected cells
3752 if (countObj.value > 1) return true;
3753
3754 var colSpan = cell.getAttribute("colspan");
3755
3756 // getAttribute returns string, we need number
3757 // no attribute means colspan = 1
3758 if (!colSpan)
3759 colSpan = Number(1);
3760 else
3761 colSpan = Number(colSpan);
3762
3763 var rowObj = { value: 0 };
3764 var colObj = { value: 0 };
3765 editor.getCellIndexes(cell, rowObj, colObj);
3766
3767 // Test if cell exists to the right of current cell
3768 // (cells with 0 span should never have cells to the right
3769 // if there is, user can select the 2 cells to join them)
3770 return (colSpan && editor.getCellAt(null, rowObj.value,
3771 colObj.value + colSpan));
3772 }
3773 } catch (e) {}
3774 }
3775 return false;
3776 },
3777
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3778 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3779 doCommandParams: function(aCommand, aParams, aRefCon) {},
3780
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3781 doCommand: function(aCommand)
3782 {
3783 // Param: Don't merge non-contiguous cells
3784 try {
3785 GetCurrentTableEditor().joinTableCells(false);
3786 } catch (e) {}
3787 window.content.focus();
3788 }
3789 };
3790
3791 //-----------------------------------------------------------------------------------
3792 var nsSplitTableCellCommand =
3793 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3794 isCommandEnabled: function(aCommand, dummy)
3795 {
3796 if (IsDocumentEditable() && IsEditingRenderedHTML())
3797 {
3798 var tagNameObj = { value: "" };
3799 var countObj = { value: 0 };
3800 var cell;
3801 try {
3802 cell = GetCurrentTableEditor().getSelectedOrParentTableElement(tagNameObj, countObj);
3803 } catch (e) {}
3804
3805 // We need a cell parent and there's just 1 selected cell
3806 // or selection is entirely inside 1 cell
3807 if ( cell && (tagNameObj.value == "td") &&
3808 countObj.value <= 1 &&
3809 IsSelectionInOneCell() )
3810 {
3811 var colSpan = cell.getAttribute("colspan");
3812 var rowSpan = cell.getAttribute("rowspan");
3813 if (!colSpan) colSpan = 1;
3814 if (!rowSpan) rowSpan = 1;
3815 return (colSpan > 1 || rowSpan > 1 ||
3816 colSpan == 0 || rowSpan == 0);
3817 }
3818 }
3819 return false;
3820 },
3821
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3822 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3823 doCommandParams: function(aCommand, aParams, aRefCon) {},
3824
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3825 doCommand: function(aCommand)
3826 {
3827 try {
3828 GetCurrentTableEditor().splitTableCell();
3829 } catch (e) {}
3830 window.content.focus();
3831 }
3832 };
3833
3834 //-----------------------------------------------------------------------------------
3835 var nsTableOrCellColorCommand =
3836 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3837 isCommandEnabled: function(aCommand, dummy)
3838 {
3839 return IsInTable();
3840 },
3841
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3842 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3843 doCommandParams: function(aCommand, aParams, aRefCon) {},
3844
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3845 doCommand: function(aCommand)
3846 {
3847 EditorSelectColor("TableOrCell");
3848 }
3849 };
3850
3851 //-----------------------------------------------------------------------------------
3852 var nsPreferencesCommand =
3853 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3854 isCommandEnabled: function(aCommand, dummy)
3855 {
3856 return true;
3857 },
3858
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3859 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3860 doCommandParams: function(aCommand, aParams, aRefCon) {},
3861
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3862 doCommand: function(aCommand)
3863 {
3864 goPreferences('editor', 'chrome://editor/content/pref-composer.xul','editor');
3865 window.content.focus();
3866 }
3867 };
3868
3869
3870 var nsFinishHTMLSource =
3871 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3872 isCommandEnabled: function(aCommand, dummy)
3873 {
3874 return true;
3875 },
3876
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3877 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3878 doCommandParams: function(aCommand, aParams, aRefCon) {},
3879
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3880 doCommand: function(aCommand)
3881 {
3882 // In editor.js
3883 FinishHTMLSource();
3884 }
3885 };
3886
3887 var nsCancelHTMLSource =
3888 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3889 isCommandEnabled: function(aCommand, dummy)
3890 {
3891 return true;
3892 },
3893
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3894 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3895 doCommandParams: function(aCommand, aParams, aRefCon) {},
3896
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3897 doCommand: function(aCommand)
3898 {
3899 // In editor.js
3900 CancelHTMLSource();
3901 }
3902 };
3903
3904 var nsConvertToTable =
3905 {
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3906 isCommandEnabled: function(aCommand, dummy)
3907 {
3908 if (IsDocumentEditable() && IsEditingRenderedHTML())
3909 {
3910 var selection;
3911 try {
3912 selection = GetCurrentEditor().selection;
3913 } catch (e) {}
3914
3915 if (selection && !selection.isCollapsed)
3916 {
3917 // Don't allow if table or cell is the selection
3918 var element;
3919 try {
3920 element = GetCurrentEditor().getSelectedElement("");
3921 } catch (e) {}
3922 if (element)
3923 {
3924 var name = element.nodeName.toLowerCase();
3925 if (name == "td" ||
3926 name == "th" ||
3927 name == "caption" ||
3928 name == "table")
3929 return false;
3930 }
3931
3932 // Selection start and end must be in the same cell
3933 // in same cell or both are NOT in a cell
3934 if ( GetParentTableCell(selection.focusNode) !=
3935 GetParentTableCell(selection.anchorNode) )
3936 return false
3937
3938 return true;
3939 }
3940 }
3941 return false;
3942 },
3943
getCommandStateParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3944 getCommandStateParams: function(aCommand, aParams, aRefCon) {},
doCommandParams
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3945 doCommandParams: function(aCommand, aParams, aRefCon) {},
3946
doCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
3947 doCommand: function(aCommand)
3948 {
3949 if (this.isCommandEnabled())
3950 {
3951 window.openDialog("chrome://editor/content/EdConvertToTable.xul","_blank", "chrome,close,titlebar,modal")
3952 }
3953 window.content.focus();
3954 }
3955 };