-// Copyright (c) 2010-2011 by Kris Maglione <maglione.k@gmail.com>
+// Copyright (c) 2010-2012 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.
-/* use strict */
+"use strict";
-Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("contexts", {
exports: ["Contexts", "Group", "contexts"],
require: ["services", "util"]
-}, this);
+});
-this.lazyRequire("overlay", ["overlay"]);
+lazyRequire("commands", ["ArgType", "CommandOption", "commands"]);
+lazyRequire("options", ["Option"]);
+lazyRequire("overlay", ["overlay"]);
+lazyRequire("storage", ["File"]);
+lazyRequire("template", ["template"]);
var Const = function Const(val) Class.Property({ enumerable: true, value: val });
return update(siteFilter, {
toString: function () this.filters.join(","),
- toXML: function (modules) let (uri = modules && modules.buffer.uri)
+ toJSONXML: function (modules) let (uri = modules && modules.buffer.uri)
template.map(this.filters,
- function (f) <span highlight={uri && f(uri) ? "Filter" : ""}>{f}</span>,
- <>,</>),
+ function (f) ["span", { highlight: uri && f(uri) ? "Filter" : "" },
+ "toJSONXML" in f ? f.toJSONXML() : String(f)],
+ ","),
filters: Option.parse.sitelist(patterns)
});
return {
__proto__: frame,
filename: this.context.file[0] == "[" ? this.context.file
- : services.io.newFileURI(File(this.context.file)).spec,
+ : File(this.context.file).URI.spec,
lineNumber: this.context.line
};
return frame;
getDocs: function getDocs(context) {
try {
if (isinstance(context, ["Sandbox"])) {
- let info = "INFO" in context && Cu.evalInSandbox("this.INFO instanceof XML && INFO.toXMLString()", context);
- return info && XML(info);
+ let info = "INFO" in context && Cu.evalInSandbox("this.INFO instanceof XML ? INFO.toXMLString() : this.INFO", context);
+ return /^</.test(info) ? XML(info) : info;
}
- if (typeof context.INFO == "xml")
+ if (DOM.isJSONXML(context.INFO))
+ return context.INFO;
+ if (typeof context.INFO == "xml" && config.haveGecko(null, "14.*"))
return context.INFO;
}
catch (e) {}
{
names: ["-description", "-desc", "-d"],
description: "A description of this group",
- default: ["User-defined group"],
+ default: "User-defined group",
type: CommandOption.STRING
},
{
names: ["-locations", "-locs", "-loc", "-l"],
- description: ["The URLs for which this group should be active"],
+ description: "The URLs for which this group should be active",
default: ["*"],
type: CommandOption.LIST
},
context.keys = {
active: function (group) group.filter(uri),
text: "name",
- description: function (g) <>{g.filter.toXML ? g.filter.toXML(modules) + <> </> : ""}{g.description || ""}</>
+ description: function (g) ["", g.filter.toJSONXML ? g.filter.toJSONXML(modules).concat("\u00a0") : "", g.description || ""]
};
context.completions = (active === undefined ? contexts.groupList : contexts.initializedGroups(active))
.slice(0, -1);