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 const 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 modules.__defineGetter__("content", function () window.content);
21 util.overlayWindow(window, { append: <><hbox id="statusTextBox" flex=""/></> });
24 get browser() window.getBrowser(),
26 get commandContainer() document.documentElement.id,
29 __proto__: Class.makeClosure.call(window.document.getElementById("tabmail")),
30 get mTabContainer() this.tabContainer,
31 get mTabs() this.tabContainer.childNodes,
32 get mCurrentTab() this.tabContainer.selectedItem,
33 get mStrip() this.tabStrip,
34 get browsers() [browser for (browser in Iterator(this.mTabs))],
36 loadOneTab: function loadOneTab(uri) {
37 return this.openTab("contentTab", { contentPage: uri });
39 loadURIWithFlags: function loadURIWithFlags() {
40 return this.mCurrentTab.loadURIWithFlags.apply(this.mCurrentTab, arguments);
44 get hasTabbrowser() !this.isComposeWindow,
46 get tabStip() this.tabbrowser.tabContainer,
48 get isComposeWindow() window.wintype == "msgcompose",
50 get mainWidget() this.isComposeWindow ? document.getElementById("content-frame") : window.GetThreadTree(),
52 get mainWindowId() this.isComposeWindow ? "msgcomposeWindow" : "messengerWindow",
53 get browserModes() [modules.modes.MESSAGE],
54 get mailModes() [modules.modes.NORMAL],
56 // NOTE: as I don't use TB I have no idea how robust this is. --djk
58 if (!this.isComposeWindow) {
59 let container = document.getElementById("tabpanelcontainer").boxObject;
60 let deck = document.getElementById("displayDeck");
61 let box = document.getElementById("messagepanebox");
62 let splitter = document.getElementById("threadpane-splitter").boxObject;
64 if (splitter.width > splitter.height)
65 return container.height - deck.minHeight - box.minHeight- splitter.height;
67 return container.height - Math.max(deck.minHeight, box.minHeight);
70 return document.getElementById("appcontent").boxObject.height;
73 removeTab: function removeTab(tab) {
74 if (this.tabbrowser.mTabs.length > 1)
75 this.tabbrowser.removeTab(tab);
80 completers: Class.memoize(function () update({ mailfolder: "mailFolder" }, this.__proto__.completers)),
83 about: ["About Thunderbird",
84 function () { window.openAboutDialog(); }],
85 addons: ["Manage Add-ons",
86 function () { window.openAddonsMgr(); }],
87 addressbook: ["Address book",
88 function () { window.toAddressBook(); }],
89 checkupdates: ["Check for updates",
90 function () { window.checkForUpdates(); }],
91 console: ["JavaScript console",
92 function () { window.toJavaScriptConsole(); }],
93 dominspector: ["DOM Inspector",
94 function () { window.inspectDOMDocument(content.document); }],
95 downloads: ["Manage Downloads",
96 function () { window.toOpenWindowByType('Download:Manager', 'chrome://mozapps/content/downloads/downloads.xul', 'chrome,dialog=no,resizable'); }],
97 preferences: ["Show Thunderbird preferences dialog",
98 function () { window.openOptionsDialog(); }],
99 printsetup: ["Setup the page size and orientation before printing",
100 function () { window.PrintUtils.showPageSetup(); }],
101 print: ["Show print dialog",
102 function () { window.PrintUtils.print(); }],
103 saveframe: ["Save frame to disk",
104 function () { window.saveFrameDocument(); }],
105 savepage: ["Save page to disk",
106 function () { window.saveDocument(window.content.document); }],
109 focusChange: function focusChange(win) {
110 const { modes } = modules;
112 // we switch to -- MESSAGE -- mode for Teledactyl when the main HTML widget gets focus
113 if (win && win.document instanceof Ci.nsIHTMLDocument || dactyl.focus instanceof Ci.nsIHTMLAnchorElement) {
114 if (this.isComposeWindow)
115 modes.set(modes.INSERT, modes.TEXT_EDIT);
116 else if (dactyl.mode != modes.MESSAGE)
117 modes.main = modes.MESSAGE;
123 DOMLoad: "Triggered when a page's DOM content has fully loaded",
124 FolderLoad: "Triggered after switching folders in Thunderbird",
125 PageLoadPre: "Triggered after a page load is initiated",
126 PageLoad: "Triggered when a page gets (re)loaded/opened",
127 Enter: "Triggered after Thunderbird starts",
128 Leave: "Triggered before exiting Thunderbird",
129 LeavePre: "Triggered before exiting Thunderbird"
136 titlestring: "Teledactyl"
139 /*** optional options, there are checked for existence and a fallback provided ***/
140 features: Class.memoize(function () set(
141 this.isComposeWindow ? ["addressbook"]
142 : ["hints", "mail", "marks", "addressbook", "tabs"])),
145 m: ["MenuBar", ["mail-toolbar-menubar2"]],
146 T: ["Toolbar" , ["mail-bar2"]],
147 f: ["Folder list", ["folderPaneBox", "folderpane_splitter"]],
148 F: ["Folder list header", ["folderPaneHeader"]]
151 // they are sorted by relevance, not alphabetically
152 helpFiles: ["intro.html", "version.html"],
155 ["MESSAGE", { char: "m" }],
159 get scripts() this.isComposeWindow ? ["compose/compose"] : [
165 overlayChrome: ["chrome://messenger/content/messenger.xul",
166 "chrome://messenger/content/messengercompose/messengercompose.xul"],
167 styleableChrome: ["chrome://messenger/content/messenger.xul",
168 "chrome://messenger/content/messengercompose/messengercompose.xul"],
170 // to allow Vim to :set ft=mail automatically
171 tempFile: "teledactyl.eml"
174 commands: function initCommands(dactyl, modules, window) {
175 const { commands } = modules;
177 commands.add(["pref[erences]", "prefs"],
178 "Show " + config.host + " preferences",
179 function () { window.openOptionsDialog(); },
182 modes: function initModes(dactyl, modules, window) {
183 const { modes } = modules;
186 "<Return>": modes.NORMAL | modes.INSERT,
187 "<Space>": modes.NORMAL | modes.INSERT,
188 "<Up>": modes.NORMAL | modes.INSERT,
189 "<Down>": modes.NORMAL | modes.INSERT
192 options: function initOptions(dactyl, modules, window) {
193 const { options } = modules;
195 // FIXME: comment obviously incorrect
196 // 0: never automatically edit externally
197 // 1: automatically edit externally when message window is shown the first time
198 // 2: automatically edit externally, once the message text gets focus (not working currently)
199 options.add(["autoexternal", "ae"],
200 "Edit message with external editor by default",
203 options.add(["online"],
204 "Set the 'work offline' option",
207 setter: function (value) {
208 if (window.MailOfflineMgr.isOnline() != value)
209 window.MailOfflineMgr.toggleOfflineStatus();
212 getter: function () window.MailOfflineMgr.isOnline()
217 // vim: set fdm=marker sw=4 ts=4 et: