"use strict";
var Config = Module("config", ConfigBase, {
- name: "pentadactyl",
- appName: "Pentadactyl",
- idName: "PENTADACTYL",
- host: "Firefox",
- hostbin: "firefox",
-
- commandContainer: "browser-bottombox",
-
Local: function Local(dactyl, modules, window)
let ({ config } = modules) ({
- completers: Class.memoize(function () update({ sidebar: "sidebar", window: "window" }, this.__proto__.completers)),
-
dialogs: {
about: ["About Firefox",
function () { window.openDialog("chrome://browser/content/aboutDialog.xul", "_blank", "chrome,dialog,modal,centerscreen"); }],
function () { window.openDialog("chrome://browser/content/bookmarks/bookmarksPanel.xul", "Bookmarks", "dialog,centerscreen,width=600,height=600"); }],
checkupdates: ["Check for updates",
function () { window.checkForUpdates(); },
- function () "checkForUpdates" in window],
+ () => "checkForUpdates" in window],
cookies: ["List your cookies",
function () { window.toOpenWindowByType("Browser:Cookies", "chrome://browser/content/preferences/cookies.xul", "chrome,dialog=no,resizable"); }],
- console: ["JavaScript console",
- function () { window.toJavaScriptConsole(); }],
+ console: ["Browser console",
+ function () { window.HUDService.toggleBrowserConsole(); }],
customizetoolbar: ["Customize the Toolbar",
function () { window.BrowserCustomizeToolbar(); }],
dominspector: ["DOM Inspector",
function () { window.inspectDOMDocument(window.content.document); },
- function () "inspectDOMDocument" in window],
+ () => "inspectDOMDocument" in window],
downloads: ["Manage Downloads",
- function () { window.toOpenWindowByType("Download:Manager", "chrome://mozapps/content/downloads/downloads.xul", "chrome,dialog=no,resizable"); }],
+ function () { window.BrowserDownloadsUI(); }],
history: ["List your history",
function () { window.openDialog("chrome://browser/content/history/history-panel.xul", "History", "dialog,centerscreen,width=600,height=600"); }],
- import: ["Import Preferences, Bookmarks, History, etc. from other browsers",
- function () { window.BrowserImport(); }],
openfile: ["Open the file selector dialog",
function () { window.BrowserOpenFileWindow(); }],
pageinfo: ["Show information about the current page",
function () { modules.buffer.viewSelectionSource(); }],
venkman: ["The JavaScript debugger",
function () { dactyl.assert("start_venkman" in window, "Venkman is not installed"); window.start_venkman() },
- function () "start_venkman" in window]
+ () => "start_venkman" in window]
},
removeTab: function removeTab(tab) {
- if (this.tabbrowser.mTabs.length > 1)
+ if (window.gInPrintPreviewMode)
+ window.PrintUtils.exitPrintPreview();
+ else if (this.tabbrowser.mTabs.length > 1)
this.tabbrowser.removeTab(tab);
else {
if (modules.buffer.uri.spec !== "about:blank" || window.getWebNavigation().sessionHistory.count > 0) {
else
dactyl.beep();
}
- },
-
- get tempFile() {
- let prefix = this.name;
- try {
- prefix += "-" + window.content.document.location.hostname;
- }
- catch (e) {}
-
- return prefix + ".tmp";
}
- }),
-
- overlayChrome: ["chrome://browser/content/browser.xul"],
-
- styleableChrome: ["chrome://browser/content/browser.xul"],
-
- autocommands: {
- BookmarkAdd: "Triggered after a page is bookmarked",
- BookmarkChange: "Triggered after a page's bookmark is changed",
- BookmarkRemove: "Triggered after a page's bookmark is removed",
- ColorScheme: "Triggered after a color scheme has been loaded",
- DOMLoad: "Triggered when a page's DOM content has fully loaded",
- DownloadPost: "Triggered when a download has completed",
- Fullscreen: "Triggered when the browser's fullscreen state changes",
- LocationChange: "Triggered when changing tabs or when navigation to a new location",
- PageLoadPre: "Triggered after a page load is initiated",
- PageLoad: "Triggered when a page gets (re)loaded/opened",
- PrivateMode: "Triggered when private browsing mode is activated or deactivated",
- Sanitize: "Triggered when a sanitizeable item is cleared",
- ShellCmdPost: "Triggered after executing a shell command with :!cmd",
- Enter: "Triggered after Firefox starts",
- LeavePre: "Triggered before exiting Firefox, just before destroying each module",
- Leave: "Triggered before exiting Firefox"
- },
-
- defaults: {
- complete: "slf",
- guioptions: "bCrs",
- showtabline: "always",
- titlestring: "Pentadactyl"
- },
-
- features: Set([
- "bookmarks", "hints", "history", "marks", "quickmarks", "sanitizer",
- "session", "tabs", "tabs_undo", "windows"
- ]),
-
- guioptions: {
- m: ["Menubar", ["toolbar-menubar"]],
- T: ["Toolbar", ["nav-bar"]],
- B: ["Bookmark bar", ["PersonalToolbar"]]
- },
+ })
- hasTabbrowser: true,
-
- scripts: [
- "browser",
- "bookmarkcache",
- "bookmarks",
- "history",
- "quickmarks",
- "sanitizer",
- "tabs"
- ],
-
- sidebars: {
- viewAddons: ["Add-ons", "A", "chrome://mozapps/content/extensions/extensions.xul"],
- viewConsole: ["Console", "C", "chrome://global/content/console.xul"],
- viewDownloads: ["Downloads", "D", "chrome://mozapps/content/downloads/downloads.xul"],
- viewPreferences: ["Preferences", "P", "about:config"]
- }
}, {
}, {
- commands: function (dactyl, modules, window) {
+ commands: function initCommands(dactyl, modules, window) {
const { commands, completion, config } = modules;
const { document } = window;
commands.add(["wind[ow]"],
"Execute a command and tell it to output in a new window",
function (args) {
- dactyl.withSavedValues(["forceNewWindow"], function () {
- this.forceNewWindow = true;
+ dactyl.withSavedValues(["forceTarget"], function () {
+ this.forceTarget = dactyl.NEW_WINDOW;
this.execute(args[0], null, true);
});
},
privateData: true
});
},
- completion: function (dactyl, modules, window) {
+ completion: function initCompletion(dactyl, modules, window) {
const { CompletionContext, bookmarkcache, completion } = modules;
const { document } = window;
- var searchRunning = null; // only until Firefox fixes https://bugzilla.mozilla.org/show_bug.cgi?id=510589
completion.location = function location(context) {
- if (!services.autoCompleteSearch)
- return;
-
- if (searchRunning) {
- searchRunning.completions = searchRunning.completions;
- searchRunning.cancel();
- }
-
- context.anchored = false;
- context.compare = CompletionContext.Sort.unsorted;
- context.filterFunc = null;
-
- let words = context.filter.toLowerCase().split(/\s+/g);
- context.hasItems = true;
- context.completions = context.completions.filter(function ({ url, title })
- words.every(function (w) (url + " " + title).toLowerCase().indexOf(w) >= 0))
- context.incomplete = true;
-
- context.format = modules.bookmarks.format;
- context.keys.extra = function (item) (bookmarkcache.get(item.url) || {}).extra;
+ completion.autocomplete("history", context);
context.title = ["Smart Completions"];
-
- context.cancel = function () {
- this.incomplete = false;
- if (searchRunning === this) {
- services.autoCompleteSearch.stopSearch();
- searchRunning = null;
- }
- };
-
- services.autoCompleteSearch.startSearch(context.filter, "", context.result, {
- onSearchResult: function onSearchResult(search, result) {
- if (result.searchResult <= result.RESULT_SUCCESS)
- searchRunning = null;
-
- context.incomplete = result.searchResult >= result.RESULT_NOMATCH_ONGOING;
- context.completions = [
- { url: result.getValueAt(i), title: result.getCommentAt(i), icon: result.getImageAt(i) }
- for (i in util.range(0, result.matchCount))
- ];
- },
- get onUpdateSearchResult() this.onSearchResult
- });
- searchRunning = context;
};
- completion.addUrlCompleter("l",
+ completion.addUrlCompleter("location",
"Firefox location bar entries (bookmarks and history sorted in an intelligent way)",
completion.location);
completion.sidebar = function sidebar(context) {
let menu = document.getElementById("viewSidebarMenu");
context.title = ["Sidebar Panel"];
- context.completions = Array.map(menu.childNodes, function (n) [n.getAttribute("label"), ""]);
+ context.completions = Array.filter(menu.childNodes, n => n.hasAttribute("label"))
+ .map(n => [n.getAttribute("label"), ""]);
};
},
- events: function (dactyl, modules, window) {
+ events: function initEvents(dactyl, modules, window) {
modules.events.listen(window, "SidebarFocused", function (event) {
modules.config.lastSidebar = window.document.getElementById("sidebar-box")
.getAttribute("sidebarcommand");
mappings: function initMappings(dactyl, modules, window) {
const { Events, mappings, modes } = modules;
mappings.add([modes.NORMAL],
- ["<Return>", "<Space>", "<Up>", "<Down>"],
+ ["<Return>", "<Up>", "<Down>"],
"Handled by " + config.host,
- function () Events.PASS_THROUGH);
- },
- modes: function (dactyl, modules, window) {
- const { modes } = modules;
- config.modes.forEach(function (mode) { modes.addMode.apply(this, mode); });
+ () => Events.PASS_THROUGH);
},
- options: function (dactyl, modules, window) {
+ options: function initOptions(dactyl, modules, window) {
modules.options.add(["online"],
- "Set the 'work offline' option",
+ "Enables or disables offline mode",
"boolean", true,
{
setter: function (value) {
}
});
-// vim: set fdm=marker sw=4 ts=4 et:
+// vim: set fdm=marker sw=4 sts=4 ts=8 et: