]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/modules/config.jsm
Import r6923 from upstream hg supporting Firefox up to 22.0a1
[dactyl.git] / common / modules / config.jsm
index f92ea2258989cf5c8b8518303ce7b96aaf257ec4..305880d3cbd5bdae938f6ad985ca10696892f56a 100644 (file)
@@ -1,25 +1,24 @@
 // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
 // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
-// Copyright (c) 2008-2011 by Kris Maglione <maglione.k@gmail.com>
+// Copyright (c) 2008-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";
 
 let global = this;
-Components.utils.import("resource://dactyl/bootstrap.jsm");
 defineModule("config", {
     exports: ["ConfigBase", "Config", "config"],
     require: ["dom", "io", "protocol", "services", "util", "template"]
-}, this);
+});
 
-this.lazyRequire("addons", ["AddonManager"]);
-this.lazyRequire("cache", ["cache"]);
-this.lazyRequire("highlight", ["highlight"]);
-this.lazyRequire("messages", ["_"]);
-this.lazyRequire("prefs", ["localPrefs", "prefs"]);
-this.lazyRequire("storage", ["storage", "File"]);
-this.lazyRequire("styles", ["Styles"]);
+lazyRequire("addons", ["AddonManager"]);
+lazyRequire("cache", ["cache"]);
+lazyRequire("highlight", ["highlight"]);
+lazyRequire("messages", ["_"]);
+lazyRequire("prefs", ["localPrefs", "prefs"]);
+lazyRequire("storage", ["storage", "File"]);
+lazyRequire("styles", ["Styles"]);
 
 function AboutHandler() {}
 AboutHandler.prototype = {
@@ -109,6 +108,7 @@ var ConfigBase = Class("ConfigBase", {
         global: ["addons",
                  "base",
                  "io",
+                 ["bookmarkcache", "bookmarkcache"],
                  "buffer",
                  "cache",
                  "commands",
@@ -156,7 +156,7 @@ var ConfigBase = Class("ConfigBase", {
         highlight.loadCSS(this.helpCSS.replace(/__MSG_(.*?)__/g, function (m0, m1) _(m1)));
 
         if (!this.haveGecko("2b"))
-            highlight.loadCSS(<![CDATA[
+            highlight.loadCSS(literal(/*
                 !TabNumber               font-weight: bold; margin: 0px; padding-right: .8ex;
                 !TabIconNumber  {
                     font-weight: bold;
@@ -164,7 +164,7 @@ var ConfigBase = Class("ConfigBase", {
                     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 () {
@@ -261,7 +261,7 @@ var ConfigBase = Class("ConfigBase", {
             }
         }
         function processJar(file) {
-            let jar = services.ZipReader(file);
+            let jar = services.ZipReader(file.file);
             if (jar)
                 try {
                     if (jar.hasEntry("chrome.manifest"))
@@ -423,9 +423,9 @@ var ConfigBase = Class("ConfigBase", {
         "xmlns.html":   "http://www.w3.org/1999/xhtml",
         "xmlns.xul":    "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
 
-        "tag.command-line": <link topic="command-line">command line</link>,
-        "tag.status-line":  <link topic="status-line">status line</link>,
-        "mode.command-line": <link topic="command-line-mode">Command Line</link>,
+        "tag.command-line": ["link", { xmlns: "dactyl", topic: "command-line" }, "command line"],
+        "tag.status-line":  ["link", { xmlns: "dactyl", topic: "status-line" }, "status line"],
+        "mode.command-line": ["link", { xmlns: "dactyl", topic: "command-line-mode" }, "Command Line"]
     },
 
     dtdStrings: [
@@ -452,21 +452,22 @@ var ConfigBase = Class("ConfigBase", {
         init: function init() {
             this.loadConfig(document.documentURI);
 
-            let append = <e4x xmlns={XUL} xmlns:dactyl={NS}>
-                    <menupopup id="viewSidebarMenu"/>
-                    <broadcasterset id="mainBroadcasterSet"/>
-            </e4x>;
+            let append = [
+                    ["menupopup", { id: "viewSidebarMenu", xmlns: "xul" }],
+                    ["broadcasterset", { id: "mainBroadcasterSet", xmlns: "xul" }]];
+
             for each (let [id, [name, key, uri]] in Iterator(this.sidebars)) {
-                append.XUL::menupopup[0].* +=
-                        <menuitem observes={"pentadactyl-" + id + "Sidebar"} label={name} accesskey={key} xmlns={XUL}/>;
-                append.XUL::broadcasterset[0].* +=
-                        <broadcaster id={"pentadactyl-" + id + "Sidebar"}
-                            autoCheck="false" type="checkbox" group="sidebar"
-                            sidebartitle={name} sidebarurl={uri}
-                            oncommand="toggleSidebar(this.id || this.observes);" xmlns={XUL}/>;
+                append[0].push(
+                        ["menuitem", { observes: "pentadactyl-" + id + "Sidebar", label: name,
+                                       accesskey: key }]);
+                append[1].push(
+                        ["broadcaster", { id: "pentadactyl-" + id + "Sidebar", autoCheck: "false",
+                                          type: "checkbox", group: "sidebar", sidebartitle: name,
+                                          sidebarurl: uri,
+                                          oncommand: "toggleSidebar(this.id || this.observes);" }]);
             }
 
-            util.overlayWindow(window, { append: append.elements() });
+            util.overlayWindow(window, { append: append });
         },
 
         get window() window,
@@ -592,12 +593,14 @@ config.INIT = update(Object.create(config.INIT), config.INIT, {
         let img = window.Image();
         img.src = this.logo || "resource://dactyl-local-content/logo.png";
         img.onload = util.wrapCallback(function () {
-            highlight.loadCSS(<>{"!Logo  {"}
+            highlight.loadCSS(literal(/*
+                !Logo  {
                      display:    inline-block;
-                     background: url({img.src});
-                     width:      {img.width}px;
-                     height:     {img.height}px;
-                 {"}"}</>);
+                     background: url({src});
+                     width:      {width}px;
+                     height:     {height}px;
+                }
+            */).replace(/\{(.*?)\}/g, function (m, m1) img[m1]));
             img = null;
         });
     },