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 Config = Module("config", ConfigBase, {
12 hostbin: "thunderbird",
14 Local: function Local(dactyl, modules, window)
15 let ({ config } = modules, { document } = window) {
16 init: function init() {
17 init.superapply(this, arguments);
19 if (!("content" in modules))
20 modules.__defineGetter__("content", function () window.content);
22 util.overlayWindow(window, { append: <><hbox id="statusTextBox" flex=""/></> });
26 let (tabmail = document.getElementById('tabmail'))
27 tabmail && tabmail.tabInfo.length ? tabmail.getBrowserForSelectedTab()
28 : document.getElementById("messagepane"),
30 get commandContainer() document.documentElement.id,
33 __proto__: Class.makeClosure.call(window.document.getElementById("tabmail")),
34 get mTabContainer() this.tabContainer,
35 get mTabs() this.tabContainer.childNodes,
36 get mCurrentTab() this.tabContainer.selectedItem,
37 get mStrip() this.tabStrip,
38 get browsers() [browser for (browser in Iterator(this.mTabs))],
40 removeTab: function removeTab(tab) this.closeTab(tab),
42 loadOneTab: function loadOneTab(uri) {
43 return this.openTab("contentTab", { contentPage: uri });
45 loadURIWithFlags: function loadURIWithFlags() {
46 return this.mCurrentTab.loadURIWithFlags.apply(this.mCurrentTab, arguments);
50 get hasTabbrowser() !this.isComposeWindow,
52 get tabStip() this.tabbrowser.tabContainer,
54 get isComposeWindow() window.wintype == "msgcompose",
56 get mainWidget() this.isComposeWindow ? document.getElementById("content-frame") : window.GetThreadTree(),
58 get mainWindowId() this.isComposeWindow ? "msgcomposeWindow" : "messengerWindow",
59 get browserModes() [modules.modes.MESSAGE],
60 get mailModes() [modules.modes.NORMAL],
62 // NOTE: as I don't use TB I have no idea how robust this is. --djk
64 if (!this.isComposeWindow) {
65 let container = document.getElementById("tabpanelcontainer").boxObject;
66 let deck = document.getElementById("displayDeck");
67 let box = document.getElementById("messagepanebox");
68 let splitter = document.getElementById("threadpane-splitter").boxObject;
70 if (splitter.width > splitter.height)
71 return container.height - deck.minHeight - box.minHeight- splitter.height;
73 return container.height - Math.max(deck.minHeight, box.minHeight);
76 return document.getElementById("appcontent").boxObject.height;
79 removeTab: function removeTab(tab) {
80 if (this.tabbrowser.mTabs.length > 1)
81 this.tabbrowser.removeTab(tab);
86 completers: Class.memoize(function () update({ mailfolder: "mailFolder" }, this.__proto__.completers)),
89 about: ["About Thunderbird",
90 function () { window.openAboutDialog(); }],
91 addons: ["Manage Add-ons",
92 function () { window.openAddonsMgr(); }],
93 addressbook: ["Address book",
94 function () { window.toAddressBook(); }],
95 checkupdates: ["Check for updates",
96 function () { window.checkForUpdates(); }],
97 console: ["JavaScript console",
98 function () { window.toJavaScriptConsole(); }],
99 dominspector: ["DOM Inspector",
100 function () { window.inspectDOMDocument(content.document); }],
101 downloads: ["Manage Downloads",
102 function () { window.toOpenWindowByType('Download:Manager', 'chrome://mozapps/content/downloads/downloads.xul', 'chrome,dialog=no,resizable'); }],
103 preferences: ["Show Thunderbird preferences dialog",
104 function () { window.openOptionsDialog(); }],
105 printsetup: ["Setup the page size and orientation before printing",
106 function () { window.PrintUtils.showPageSetup(); }],
107 print: ["Show print dialog",
108 function () { window.PrintUtils.print(); }],
109 saveframe: ["Save frame to disk",
110 function () { window.saveFrameDocument(); }],
111 savepage: ["Save page to disk",
112 function () { window.saveDocument(window.content.document); }],
115 focusChange: function focusChange(win) {
116 const { modes } = modules;
118 // we switch to -- MESSAGE -- mode for Teledactyl when the main HTML widget gets focus
119 if (win && win.document instanceof Ci.nsIHTMLDocument || dactyl.focus instanceof Ci.nsIHTMLAnchorElement) {
120 if (this.isComposeWindow)
121 modes.set(modes.INSERT, modes.TEXT_EDIT);
122 else if (dactyl.mode != modes.MESSAGE)
123 modes.main = modes.MESSAGE;
129 DOMLoad: "Triggered when a page's DOM content has fully loaded",
130 FolderLoad: "Triggered after switching folders in Thunderbird",
131 PageLoadPre: "Triggered after a page load is initiated",
132 PageLoad: "Triggered when a page gets (re)loaded/opened",
133 Enter: "Triggered after Thunderbird starts",
134 Leave: "Triggered before exiting Thunderbird",
135 LeavePre: "Triggered before exiting Thunderbird"
142 titlestring: "Teledactyl"
145 /*** optional options, there are checked for existence and a fallback provided ***/
146 features: Class.memoize(function () Set(
147 this.isComposeWindow ? ["addressbook"]
148 : ["hints", "mail", "marks", "addressbook", "tabs"])),
151 m: ["MenuBar", ["mail-toolbar-menubar2"]],
152 T: ["Toolbar" , ["mail-bar2"]],
153 f: ["Folder list", ["folderPaneBox", "folderpane_splitter"]],
154 F: ["Folder list header", ["folderPaneHeader"]]
157 // they are sorted by relevance, not alphabetically
158 helpFiles: ["intro.html", "version.html"],
161 ["MESSAGE", { char: "m" }],
165 get scripts() this.isComposeWindow ? ["compose/compose"] : [
171 overlayChrome: ["chrome://messenger/content/messenger.xul",
172 "chrome://messenger/content/messengercompose/messengercompose.xul"],
173 styleableChrome: ["chrome://messenger/content/messenger.xul",
174 "chrome://messenger/content/messengercompose/messengercompose.xul"],
176 // to allow Vim to :set ft=mail automatically
177 tempFile: "teledactyl.eml"
180 commands: function initCommands(dactyl, modules, window) {
181 const { commands } = modules;
183 commands.add(["pref[erences]", "prefs"],
184 "Show " + config.host + " preferences",
185 function () { window.openOptionsDialog(); },
188 modes: function initModes(dactyl, modules, window) {
189 const { modes } = modules;
192 "<Return>": modes.NORMAL | modes.INSERT,
193 "<Space>": modes.NORMAL | modes.INSERT,
194 "<Up>": modes.NORMAL | modes.INSERT,
195 "<Down>": modes.NORMAL | modes.INSERT
198 options: function initOptions(dactyl, modules, window) {
199 const { options } = modules;
201 // FIXME: comment obviously incorrect
202 // 0: never automatically edit externally
203 // 1: automatically edit externally when message window is shown the first time
204 // 2: automatically edit externally, once the message text gets focus (not working currently)
205 options.add(["autoexternal", "ae"],
206 "Edit message with external editor by default",
209 options.add(["online"],
210 "Set the 'work offline' option",
213 setter: function (value) {
214 if (window.MailOfflineMgr.isOnline() != value)
215 window.MailOfflineMgr.toggleOfflineStatus();
218 getter: function () window.MailOfflineMgr.isOnline()
223 // vim: set fdm=marker sw=4 ts=4 et: