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, {
8 Local: function Local(dactyl, modules, window)
9 let ({ config } = modules, { document } = window) {
10 init: function init() {
11 init.superapply(this, arguments);
13 if (!("content" in modules))
14 modules.__defineGetter__("content", function () window.content);
16 util.overlayWindow(window, { append: <><hbox id="statusTextBox" flex=""/></> });
20 let (tabmail = document.getElementById('tabmail'))
21 tabmail && tabmail.tabInfo.length ? tabmail.getBrowserForSelectedTab()
22 : document.getElementById("messagepane"),
25 __proto__: Class.makeClosure.call(window.document.getElementById("tabmail")),
26 get mTabContainer() this.tabContainer,
27 get mTabs() this.tabContainer.childNodes,
28 get mCurrentTab() this.tabContainer.selectedItem,
29 get mStrip() this.tabStrip,
30 get browsers() [browser for (browser in Iterator(this.mTabs))],
32 removeTab: function removeTab(tab) this.closeTab(tab),
34 loadOneTab: function loadOneTab(uri) {
35 return this.openTab("contentTab", { contentPage: uri });
37 loadURIWithFlags: function loadURIWithFlags() {
38 return this.mCurrentTab.loadURIWithFlags.apply(this.mCurrentTab, arguments);
42 get tabStip() this.tabbrowser.tabContainer,
44 get mainWidget() this.isComposeWindow ? document.getElementById("content-frame") : window.GetThreadTree(),
46 get browserModes() [modules.modes.MESSAGE],
48 get mailModes() [modules.modes.NORMAL],
50 // NOTE: as I don't use TB I have no idea how robust this is. --djk
52 if (!this.isComposeWindow) {
53 let container = document.getElementById("tabpanelcontainer").boxObject;
54 let deck = document.getElementById("displayDeck");
55 let box = document.getElementById("messagepanebox");
56 let splitter = document.getElementById("threadpane-splitter").boxObject;
58 if (splitter.width > splitter.height)
59 return container.height - deck.minHeight - box.minHeight- splitter.height;
61 return container.height - Math.max(deck.minHeight, box.minHeight);
64 return document.getElementById("appcontent").boxObject.height;
67 removeTab: function removeTab(tab) {
68 if (this.tabbrowser.mTabs.length > 1)
69 this.tabbrowser.removeTab(tab);
74 completers: Class.Memoize(function () update({ mailfolder: "mailFolder" }, this.__proto__.completers)),
77 about: ["About Thunderbird",
78 function () { window.openAboutDialog(); }],
79 addons: ["Manage Add-ons",
80 function () { window.openAddonsMgr(); }],
81 addressbook: ["Address book",
82 function () { window.toAddressBook(); }],
83 checkupdates: ["Check for updates",
84 function () { window.checkForUpdates(); }],
85 console: ["JavaScript console",
86 function () { window.toJavaScriptConsole(); }],
87 dominspector: ["DOM Inspector",
88 function () { window.inspectDOMDocument(content.document); }],
89 downloads: ["Manage Downloads",
90 function () { window.toOpenWindowByType('Download:Manager', 'chrome://mozapps/content/downloads/downloads.xul', 'chrome,dialog=no,resizable'); }],
91 preferences: ["Show Thunderbird preferences dialog",
92 function () { window.openOptionsDialog(); }],
93 printsetup: ["Setup the page size and orientation before printing",
94 function () { window.PrintUtils.showPageSetup(); }],
95 print: ["Show print dialog",
96 function () { window.PrintUtils.print(); }],
97 saveframe: ["Save frame to disk",
98 function () { window.saveFrameDocument(); }],
99 savepage: ["Save page to disk",
100 function () { window.saveDocument(window.content.document); }],
103 focusChange: function focusChange(win) {
104 const { modes } = modules;
106 if (win.top == window)
109 // we switch to -- MESSAGE -- mode for Teledactyl when the main HTML widget gets focus
110 if (win && win.document instanceof Ci.nsIDOMHTMLDocument
111 || dactyl.focusedElement instanceof Ci.nsIDOMHTMLAnchorElement) {
113 if (this.isComposeWindow)
114 modes.set(modes.INSERT, modes.TEXT_EDIT);
115 else if (dactyl.mode != modes.MESSAGE)
116 modes.main = modes.MESSAGE;
122 commands: function initCommands(dactyl, modules, window) {
123 const { commands } = modules;
125 commands.add(["pref[erences]", "prefs"],
126 "Show " + config.host + " preferences",
127 function () { window.openOptionsDialog(); },
130 modes: function initModes(dactyl, modules, window) {
131 const { modes } = modules;
134 "<Return>": modes.NORMAL | modes.INSERT,
135 "<Space>": modes.NORMAL | modes.INSERT,
136 "<Up>": modes.NORMAL | modes.INSERT,
137 "<Down>": modes.NORMAL | modes.INSERT
140 options: function initOptions(dactyl, modules, window) {
141 const { options } = modules;
143 // FIXME: comment obviously incorrect
144 // 0: never automatically edit externally
145 // 1: automatically edit externally when message window is shown the first time
146 // 2: automatically edit externally, once the message text gets focus (not working currently)
147 options.add(["autoexternal", "ae"],
148 "Edit message with external editor by default",
151 options.add(["online"],
152 "Set the 'work offline' option",
155 setter: function (value) {
156 if (window.MailOfflineMgr.isOnline() != value)
157 window.MailOfflineMgr.toggleOfflineStatus();
160 getter: function () window.MailOfflineMgr.isOnline()
165 // vim: set fdm=marker sw=4 sts=4 ts=8 et: