]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/content/statusline.js
Import r6923 from upstream hg supporting Firefox up to 22.0a1
[dactyl.git] / common / content / statusline.js
index 5b7d2a8898696d69d6231bfa1e9972de07cc0a87..0de02088a37cb79f91c3f8b811796feff49f07f2 100644 (file)
@@ -1,10 +1,10 @@
 // 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";
 
 /** @scope modules */
 
@@ -15,25 +15,26 @@ var StatusLine = Module("statusline", {
         this.baseGroup = this.statusBar == this._statusLine ? "StatusLine " : "";
 
         if (this.statusBar.localName == "toolbar") {
-            styles.system.add("addon-bar", config.styleableChrome, <css><![CDATA[
+            styles.system.add("addon-bar", config.styleableChrome, literal(/*
                 #status-bar { margin-top: 0 !important; }
                 #addon-bar > statusbar { -moz-box-flex: 1 }
                 #addon-bar > #addonbar-closebutton { visibility: collapse; }
                 #addon-bar > xul|toolbarspring { visibility: collapse; }
-            ]]></css>);
+            */));
 
-            overlay.overlayWindow(window, { append: <><statusbar id="status-bar" ordinal="0"/></> });
+            overlay.overlayWindow(window, {
+                append: [
+                    ["statusbar", { id: "status-bar", ordinal: "0" }]]
+            });
 
-            highlight.loadCSS(util.compileMacro(<![CDATA[
+            highlight.loadCSS(util.compileMacro(literal(/*
                 !AddonBar;#addon-bar {
-                    /* The Add-on Bar */
                     padding-left: 0 !important;
                     min-height: 18px !important;
                     -moz-appearance: none !important;
                     <padding>
                 }
                 !AddonButton;#addon-bar xul|toolbarbutton {
-                    /* An Add-on Bar button */
                     -moz-appearance: none !important;
                     padding: 0 !important;
                     border-width: 0px !important;
@@ -41,50 +42,52 @@ var StatusLine = Module("statusline", {
                     color: inherit !important;
                 }
                 AddonButton:not(:hover)  background: transparent;
-            ]]>)({ padding: config.OS.isMacOSX ? "padding-right: 10px !important;" : "" }));
+            */))({ padding: config.OS.isMacOSX ? "padding-right: 10px !important;" : "" }));
 
             if (document.getElementById("appmenu-button"))
-                highlight.loadCSS(<![CDATA[
-                    AppmenuButton       /* The app-menu button */ \
-                                        min-width: 0 !important; padding: 0 .5em !important;
-                ]]>);
+                highlight.loadCSS(literal(/*
+                    AppmenuButton       min-width: 0 !important; padding: 0 .5em !important;
+                */));
         }
 
-        XML.ignoreWhitespace = true;
         let _commandline = "if (window.dactyl) return dactyl.modules.commandline";
-        let prepend = <e4x xmlns={XUL} xmlns:dactyl={NS}>
-            <button id="appmenu-button" label="" image="chrome://branding/content/icon16.png" highlight="AppmenuButton" />
-            <toolbarbutton id="appmenu-toolbar-button" label="" image="chrome://branding/content/icon16.png" />
-            <statusbar id="status-bar" highlight="StatusLine">
-                <!-- insertbefore="dactyl.statusBefore;" insertafter="dactyl.statusAfter;" -->
-                <hbox key="container" hidden="false" align="center"  flex="1">
-                    <stack orient="horizontal"       align="stretch" flex="1" highlight="CmdLine StatusCmdLine" class="dactyl-container">
-                        <hbox                                                 highlight="CmdLine StatusCmdLine" class="dactyl-container">
-                            <label key="mode"          crop="end"                                               class="plain" collapsed="true"/>
-                            <stack  id="dactyl-statusline-stack"     flex="1" highlight="CmdLine StatusCmdLine" class="dactyl-container">
-                                <textbox key="url"     crop="end"    flex="1" style="background: transparent;"  class="plain dactyl-status-field-url" readonly="true"/>
-                                <textbox key="message" crop="end"    flex="1" highlight="Normal StatusNormal"   class="plain"                         readonly="true"/>
-                            </stack>
-                        </hbox>
-                    </stack>
-                    <label class="plain" key="inputbuffer"    flex="0"/>
-                    <label class="plain" key="progress"       flex="0"/>
-                    <label class="plain" key="tabcount"       flex="0"/>
-                    <label class="plain" key="bufferposition" flex="0"/>
-                    <label class="plain" key="zoomlevel"      flex="0"/>
-                </hbox>
-                <!-- just hide them since other elements expect them -->
-                <statusbarpanel id="statusbar-display"       hidden="true"/>
-                <statusbarpanel id="statusbar-progresspanel" hidden="true"/>
-            </statusbar>
-        </e4x>;
-
-        for each (let attr in prepend..@key)
-            attr.parent().@id = "dactyl-statusline-field-" + attr;
+        let prepend = [
+            ["button", { id: "appmenu-button", label: "", image: "chrome://branding/content/icon16.png", highlight: "AppmenuButton", xmlns: "xul" }],
+            ["toolbarbutton", { id: "appmenu-toolbar-button", label: "", image: "chrome://branding/content/icon16.png" }],
+            ["statusbar", { id: "status-bar", highlight: "StatusLine", xmlns: "xul" },
+                // <!-- insertbefore="dactyl.statusBefore;" insertafter="dactyl.statusAfter;" -->
+                ["hbox", { key: "container", hidden: "false", align: "center",  flex: "1" },
+                    ["stack", { orient: "horizontal",       align: "stretch", flex: "1", highlight: "CmdLine StatusCmdLine", class: "dactyl-container" },
+                        ["hbox", {                                                       highlight: "CmdLine StatusCmdLine", class: "dactyl-container" },
+                            ["label", { key: "mode",          crop: "end",                                                   class: "plain", collapsed: "true" }],
+                            ["stack", {  id: "dactyl-statusline-stack",       flex: "1", highlight: "CmdLine StatusCmdLine", class: "dactyl-container" },
+                                ["textbox", { key: "url",     crop: "end",    flex: "1", style: "background: transparent;",  class: "plain dactyl-status-field-url",
+                                              readonly: "true" }],
+                                ["hbox", { key: "message-box" },
+                                    ["label", { key: "message-pre", highlight: "WarningMsg StatusWarningMsg", class: "plain", readonly: "true" }],
+                                    ["textbox", { key: "message", crop: "end",    flex: "1", highlight: "Normal StatusNormal",   class: "plain",
+                                                  readonly: "true" }]]]]],
+                    ["label", { class: "plain", key: "inputbuffer",    flex: "0" }],
+                    ["label", { class: "plain", key: "progress",       flex: "0" }],
+                    ["label", { class: "plain", key: "tabcount",       flex: "0" }],
+                    ["label", { class: "plain", key: "bufferposition", flex: "0" }],
+                    ["label", { class: "plain", key: "zoomlevel",      flex: "0" }]],
+                // just hide them since other elements expect them
+                ["statusbarpanel", { id: "statusbar-display",       hidden: "true" }],
+                ["statusbarpanel", { id: "statusbar-progresspanel", hidden: "true" }]]];
+
+        (function rec(ary) {
+            ary.forEach(function (elem) {
+                if ("key" in elem[1])
+                    elem[1].id = "dactyl-statusline-field-" + elem[1].key;
+                if (elem.length > 2)
+                    rec(elem.slice(2));
+            });
+        })(prepend);
 
         overlay.overlayWindow(window, {
             objects: this.widgets = { get status() this.container },
-            prepend: prepend.elements()
+            prepend: prepend
         });
 
         try {
@@ -157,6 +160,16 @@ var StatusLine = Module("statusline", {
             this.timeout(function () {
                 this.status = message || buffer.uri;
             });
+        },
+        "fullscreen": function onFullscreen(fullscreen) {
+            let go = options.get("guioptions");
+            if (fullscreen) {
+                this.wasVisible = go.has("s");
+                go.op("-", "s");
+            }
+            else if (this.wasVisible) {
+                go.op("+", "s");
+            }
         }
     },