X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=pentadactyl%2Fcontent%2Fconfig.js;h=183f6d103999f489740ed12869f14a1d53f3e66c;hb=3d837eb266a3a01d424192aa4ec1a167366178c5;hp=2dd3b532110a60ad0474c07156935af6d036a7da;hpb=eeed0be1a8abf7e3c97f43b63c1d595e940fef21;p=dactyl.git diff --git a/pentadactyl/content/config.js b/pentadactyl/content/config.js index 2dd3b53..183f6d1 100644 --- a/pentadactyl/content/config.js +++ b/pentadactyl/content/config.js @@ -7,19 +7,9 @@ "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"); }], @@ -42,11 +32,9 @@ var Config = Module("config", ConfigBase, { function () { window.inspectDOMDocument(window.content.document); }, function () "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", @@ -79,7 +67,9 @@ var Config = Module("config", ConfigBase, { }, 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) { @@ -89,81 +79,12 @@ var Config = Module("config", ConfigBase, { 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 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; @@ -205,7 +126,7 @@ var Config = Module("config", ConfigBase, { let title = document.getElementById("sidebar-title"); dactyl.assert(args.length || title.value || args.bang && config.lastSidebar, - "Argument required"); + _("error.argumentRequired")); if (!args.length) return window.toggleSidebar(title.value ? null : config.lastSidebar); @@ -227,7 +148,7 @@ var Config = Module("config", ConfigBase, { return; } - return dactyl.echoerr("No sidebar " + args[0] + " found"); + return dactyl.echoerr(_("error.invalidArgument", args[0])); }, { argCount: "?", @@ -242,13 +163,13 @@ var Config = Module("config", ConfigBase, { 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); }); }, { - argCount: "+", + argCount: "1", completer: function (context) completion.ex(context), literal: 0, subCommand: 0 @@ -274,69 +195,27 @@ var Config = Module("config", ConfigBase, { 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, function (n) n.hasAttribute("label")) + .map(function (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"); @@ -345,17 +224,13 @@ var Config = Module("config", ConfigBase, { mappings: function initMappings(dactyl, modules, window) { const { Events, mappings, modes } = modules; mappings.add([modes.NORMAL], - ["", "", "", ""], + ["", "", ""], "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); }); - }, - 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) { @@ -368,4 +243,4 @@ var Config = Module("config", ConfigBase, { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: