// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
-// Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
+// Copyright (c) 2008-2014 Kris Maglione <maglione.k@gmail.com>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
let global = this;
defineModule("config", {
exports: ["ConfigBase", "Config", "config"],
- require: ["dom", "io", "protocol", "services", "util", "template"]
+ require: ["io", "protocol", "services"]
});
lazyRequire("addons", ["AddonManager"]);
lazyRequire("cache", ["cache"]);
+lazyRequire("dom", ["DOM"]);
lazyRequire("highlight", ["highlight"]);
lazyRequire("messages", ["_"]);
lazyRequire("prefs", ["localPrefs", "prefs"]);
lazyRequire("storage", ["storage", "File"]);
lazyRequire("styles", ["Styles"]);
+lazyRequire("template", ["template"]);
+lazyRequire("util", ["util"]);
function AboutHandler() {}
AboutHandler.prototype = {
* initialization code. Must call superclass's init function.
*/
init: function init() {
- this.loadConfig();
+ if (!config.haveGecko("26"))
+ this.modules.global = this.modules.global.filter(m => m != "downloads"); // FIXME
- this.features.push = deprecated("Set.add", function push(feature) Set.add(this, feature));
- if (this.haveGecko("2b"))
- Set.add(this.features, "Gecko2");
+ this.loadConfig();
- JSMLoader.registerFactory(JSMLoader.Factory(AboutHandler));
- JSMLoader.registerFactory(JSMLoader.Factory(
- Protocol("dactyl", "{9c8f2530-51c8-4d41-b356-319e0b155c44}",
- "resource://dactyl-content/")));
+ util.trapErrors(() => {
+ JSMLoader.registerFactory(JSMLoader.Factory(AboutHandler));
+ });
+ util.withProperErrors(() => {
+ JSMLoader.registerFactory(JSMLoader.Factory(
+ Protocol("dactyl", "{9c8f2530-51c8-4d41-b356-319e0b155c44}",
+ "resource://dactyl-content/")));
+ });
+ this.protocolLoaded = true;
this.timeout(function () {
- cache.register("config.dtd", () => util.makeDTD(config.dtd));
+ cache.register("config.dtd", () => util.makeDTD(config.dtd),
+ true);
+ });
+
+ // FIXME: May not be ready before first window opens.
+ AddonManager.getAddonByID("{972ce4c6-7e08-4474-a285-3208198ce6fd}", a => {
+ if (!a.isActive)
+ config.features.delete("default-theme");
});
services["dactyl:"].pages["dtd"] = () => [null, cache.get("config.dtd")];
get prefs() localPrefs,
- get has() Set.has(this.features),
+ has: function (feature) this.features.has(feature),
configFiles: [
"resource://dactyl-common/config.json",
loadConfig: function loadConfig(documentURL) {
- for each (let config in this.configs) {
+ for (let config of this.configs) {
if (documentURL)
config = config.overlays && config.overlays[documentURL] || {};
if (isArray(this[prop]))
this[prop] = [].concat(this[prop], value);
+ else if (isinstance(this[prop], ["Set"]))
+ for (let key of value)
+ this[prop].add(key);
else if (isObject(this[prop])) {
if (isArray(value))
value = Set(value);
"options",
"overlay",
"prefs",
+ ["promises", "Promise", "Task", "promises"],
"protocol",
"sanitizer",
"services",
highlight.loadCSS(this.helpCSS.replace(/__MSG_(.*?)__/g,
(m0, m1) => _(m1)));
- if (!this.haveGecko("2b"))
- highlight.loadCSS(literal(/*
- !TabNumber font-weight: bold; margin: 0px; padding-right: .8ex;
- !TabIconNumber {
- font-weight: bold;
- color: white;
- text-align: center;
- text-shadow: black -1px 0 1px, black 0 1px 1px, black 1px 0 1px, black 0 -1px 1px;
- }
- */));
-
let hl = highlight.set("Find", "");
hl.onChange = function () {
function hex(val) ("#" + util.regexp.iterate(/\d+/g, val)
bestLocale: function (list) {
return values([this.appLocale, this.appLocale.replace(/-.*/, ""),
"en", "en-US", list[0]])
- .nth(Set.has(Set(list)), 0);
+ .find(bind("has", RealSet(list)));
},
/**
// Horrible hack.
let res = {};
function process(manifest) {
- for each (let line in manifest.split(/\n+/)) {
+ for (let line of manifest.split(/\n+/)) {
let match = /^\s*(content|skin|locale|resource)\s+([^\s#]+)\s/.exec(line);
if (match)
res[match[2]] = true;
}
}
- for each (let dir in ["UChrm", "AChrom"]) {
+ for (let dir of ["UChrm", "AChrom"]) {
dir = File(services.directory.get(dir, Ci.nsIFile));
if (dir.exists() && dir.isDirectory())
for (let file in dir.iterDirectory())
dtd: Class.Memoize(function ()
iter(this.dtdExtra,
(["dactyl." + k, v] for ([k, v] in iter(config.dtdDactyl))),
- (["dactyl." + s, config[s]] for each (s in config.dtdStrings)))
+ (["dactyl." + s, config[s]] for (s of config.dtdStrings)))
.toObject()),
dtdDactyl: memoize({
["menupopup", { id: "viewSidebarMenu", xmlns: "xul" }],
["broadcasterset", { id: "mainBroadcasterSet", xmlns: "xul" }]];
- for each (let [id, [name, key, uri]] in Iterator(this.sidebars)) {
+ for (let [id, [name, key, uri]] in Iterator(this.sidebars)) {
append[0].push(
["menuitem", { observes: "pentadactyl-" + id + "Sidebar", label: name,
accesskey: key }]);
* dactyl.has(feature) to check for a feature's presence
* in this array.
*/
- features: {},
+ features: RealSet(["default-theme"]),
/**
* @property {string} The file extension used for command script files.
init: function init(dactyl, modules, window) {
init.superapply(this, arguments);
- let img = window.Image();
+ let img = new window.Image;
img.src = this.logo || "resource://dactyl-local-content/logo.png";
img.onload = util.wrapCallback(function () {
highlight.loadCSS(literal(/*