1 // Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org>
3 // This work is licensed for reuse under an MIT license. Details are
4 // given in the LICENSE.txt file included with this file.
7 var Compose = Module("compose", {
8 init: function init() {
10 QueryInterface: function (id) {
11 if (id.equals(Ci.nsIDocumentStateListener))
13 throw Cr.NS_NOINTERFACE;
16 // this is (also) fired once the new compose window loaded the message for the first time
17 NotifyDocumentStateChanged: function (nowDirty) {
18 // only edit with external editor if this window was not cached!
19 if (options["autoexternal"] && !window.messageWasEditedExternally/* && !gMsgCompose.recycledWindow*/) {
20 window.messageWasEditedExternally = true;
21 editor.editFieldExternally();
25 NotifyDocumentCreated: function () {},
26 NotifyDocumentWillBeDestroyed: function () {}
29 events.listen(window.document, "load", function () {
30 if (window.messageWasEditedExternally === undefined) {
31 window.messageWasEditedExternally = false;
32 GetCurrentEditor().addDocumentStateListener(stateListener);
36 events.listen(window, "compose-window-close", function () {
37 window.messageWasEditedExternally = false;
42 mappings: function initMappings(dactyl, modules, window) {
43 mappings.add([modes.COMPOSE],
44 ["e"], "Edit message",
45 function () { editor.editFieldExternally(); });
47 mappings.add([modes.COMPOSE],
48 ["y"], "Send message now",
49 function () { window.goDoCommand("cmd_sendNow"); });
51 mappings.add([modes.COMPOSE],
52 ["Y"], "Send message later",
53 function () { window.goDoCommand("cmd_sendLater"); });
55 // FIXME: does not really work reliably
56 mappings.add([modes.COMPOSE],
57 ["t"], "Select To: field",
58 function () { awSetFocus(0, awGetInputElement(1)); });
60 mappings.add([modes.COMPOSE],
61 ["s"], "Select Subject: field",
62 function () { GetMsgSubjectElement().focus(); });
64 mappings.add([modes.COMPOSE],
65 ["i"], "Select message body",
66 function () { SetMsgBodyFrameFocus(); });
68 mappings.add([modes.COMPOSE],
69 ["q"], "Close composer, ask when for unsaved changes",
70 function () { DoCommandClose(); });
72 mappings.add([modes.COMPOSE],
73 ["Q", "ZQ"], "Force closing composer",
74 function () { MsgComposeCloseWindow(true); /* cache window for better performance*/ });
76 modes: function initModes(dactyl, modules, window) {
77 modes.addMode("COMPOSE", {
83 // vim: set fdm=marker sw=4 ts=4 et: