]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/modules/highlight.jsm
Import r6923 from upstream hg supporting Firefox up to 22.0a1
[dactyl.git] / common / modules / highlight.jsm
index 7d6cfaf03cf61a7cef814116d9128b535cc169b7..bf242e08f70eed2c3caaa0354166c9ac38a35c78 100644 (file)
@@ -1,16 +1,16 @@
-// Copyright (c) 2008-2011 by Kris Maglione <maglione.k at Gmail>
+// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail>
 //
 // 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("highlight", {
     exports: ["Highlight", "Highlights", "highlight"],
     require: ["services", "util"]
-}, this);
+});
 
-this.lazyRequire("styles", ["Styles", "styles"]);
+lazyRequire("styles", ["Styles", "styles"]);
+lazyRequire("template", ["template"]);
 
 var Highlight = Struct("class", "selector", "sites",
                        "defaultExtends", "defaultValue",
@@ -197,7 +197,7 @@ var Highlights = Module("Highlight", {
      * @param {string} group
      */
     highlightNode: function highlightNode(node, group, applyBindings) {
-        node.setAttributeNS(NS.uri, "highlight", group);
+        node.setAttributeNS(NS, "highlight", group);
 
         let groups = group.split(" ");
         for each (let group in groups)
@@ -224,14 +224,14 @@ var Highlights = Module("Highlight", {
                 (self.highlight[hl] && self.highlight[hl].class != class_
                     ? self.highlight[hl].selector : "[dactyl|highlight~=" + hl + "]")),
 
-    groupRegexp: util.regexp(<![CDATA[
+    groupRegexp: util.regexp(literal(/*
         ^
         (\s* (?:\S|\s\S)+ \s+)
         \{ ([^}]*) \}
         \s*
         $
-    ]]>, "gmx"),
-    sheetRegexp: util.regexp(<![CDATA[
+    */), "gmx"),
+    sheetRegexp: util.regexp(literal(/*
         ^\s*
         !? \*?
              (?P<group>    (?:[^;\s]|\s[^;\s])+ )
@@ -240,7 +240,8 @@ var Highlights = Module("Highlight", {
         (?:; (?P<extends>  (?:[^;\s]|\s[^;\s])+ )? )?
         \s*  (?P<css>      .*)
         $
-    ]]>, "x"),
+    */), "x"),
+    // </css>
 
     /**
      * Bulk loads new CSS rules, in the format of,
@@ -322,7 +323,7 @@ var Highlights = Module("Highlight", {
         commands.add(["hi[ghlight]"],
             "Set the style of certain display elements",
             function (args) {
-                let style = <![CDATA[
+                let style = literal(/*
                     ;
                     display: inline-block !important;
                     position: static !important;
@@ -330,7 +331,7 @@ var Highlights = Module("Highlight", {
                     width: 3em !important; min-width: 3em !important; max-width: 3em !important;
                     height: 1em !important; min-height: 1em !important; max-height: 1em !important;
                     overflow: hidden !important;
-                ]]>;
+                */);
                 let clear = args[0] == "clear";
                 if (clear)
                     args.shift();
@@ -349,10 +350,10 @@ var Highlights = Module("Highlight", {
                             ["padding: 0 1em 0 0; vertical-align: top; max-width: 16em; overflow: hidden;",
                              "text-align: center"],
                             ([h.class,
-                              <span style={"text-align: center; line-height: 1em;" + h.value + style}>XXX</span>,
-                              template.map(h.extends, function (s) template.highlight(s), <>,</>),
+                              ["span", { style: "text-align: center; line-height: 1em;" + h.value + style }, "XXX"],
+                              template.map(h.extends, function (s) template.highlight(s), ","),
                               template.highlightRegexp(h.value, /\b[-\w]+(?=:)|\/\*.*?\*\//g,
-                                                       function (match) <span highlight={match[0] == "/" ? "Comment" : "Key"}>{match}</span>)
+                                                       function (match) ["span", { highlight: match[0] == "/" ? "Comment" : "Key" }, match])
                              ]
                              for (h in highlight)
                              if (!key || h.class.indexOf(key) > -1))));