]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/content/statusline.js
Imported Upstream version 1.1+hg7904
[dactyl.git] / common / content / statusline.js
index 4cf50c47813e4a8b119dcfa837eabe5cc4c82941..caf0390f0bf335d25bfa93ae5047c2a2ec6ccab9 100644 (file)
@@ -1,6 +1,6 @@
 // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
 // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
-// Copyright (c) 2008-2012 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.
@@ -12,29 +12,55 @@ var StatusLine = Module("statusline", {
     init: function init() {
         this._statusLine = document.getElementById("status-bar");
         this.statusBar = document.getElementById("addon-bar") || this._statusLine;
+
         this.baseGroup = this.statusBar == this._statusLine ? "StatusLine " : "";
 
+        if (this.statusBar.localName == "toolbar" &&
+            this.statusBar.parentNode.id != "browser-bottombox")
+            overlay.overlayWindow(window, {
+                objects: this,
+                append: [
+                    ["vbox", { id: "browser-bottombox", xmlns: "xul" },
+                        ["toolbar", { id: "dactyl-addon-bar",
+                                      customizable: true,
+                                      defaultset: "",
+                                      toolboxid: "navigator-toolbox",
+                                      toolbarname: /*L*/ "Add-on Bar",
+                                      class: "toolbar-primary chromeclass-toolbar",
+                                      mode: "icons",
+                                      iconsize: "small", defaulticonsize: "small",
+                                      key: "statusBar" },
+                            ["statusbar", { id: "dactyl-status-bar", key: "_statusLine" }]]]
+                ]
+            });
+
+        if (config.haveGecko("25"))
+            config.tabbrowser.getStatusPanel().hidden = true;
+
         if (this.statusBar.localName == "toolbar") {
             styles.system.add("addon-bar", config.styleableChrome, literal(/*
-                #status-bar { margin-top: 0 !important; }
-                #addon-bar > statusbar { -moz-box-flex: 1 }
+                #status-bar, #dactyl-status-bar { margin-top: 0 !important; }
+                #dactyl-status-bar { min-height: 0 !important; }
+                :-moz-any(#addon-bar, #dactyl-addon-bar) > statusbar { -moz-box-flex: 1 }
+                :-moz-any(#addon-bar, #dactyl-addon-bar) > xul|toolbarspring { visibility: collapse; }
                 #addon-bar > #addonbar-closebutton { visibility: collapse; }
-                #addon-bar > xul|toolbarspring { visibility: collapse; }
             */));
 
             overlay.overlayWindow(window, {
                 append: [
-                    ["statusbar", { id: "status-bar", ordinal: "0" }]]
+                    ["statusbar", { id: this._statusLine.id, ordinal: "0" }]]
             });
 
             highlight.loadCSS(util.compileMacro(literal(/*
-                !AddonBar;#addon-bar {
+                !AddonBar;#addon-bar,#dactyl-addon-bar {
                     padding-left: 0 !important;
+                    padding-top: 0 !important;
+                    padding-bottom: 0 !important;
                     min-height: 18px !important;
                     -moz-appearance: none !important;
                     <padding>
                 }
-                !AddonButton;#addon-bar xul|toolbarbutton {
+                !AddonButton;,:-moz-any(#addon-bar, #dactyl-addon-bar) xul|toolbarbutton {
                     -moz-appearance: none !important;
                     padding: 0 !important;
                     border-width: 0px !important;
@@ -54,7 +80,7 @@ var StatusLine = Module("statusline", {
         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" },
+            ["statusbar", { id: this._statusLine.id, 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" },
@@ -96,6 +122,11 @@ var StatusLine = Module("statusline", {
         catch (e) {}
     },
 
+    cleanup: function cleanup(reason) {
+        if (reason != "unload" && "CustomizableUI" in window)
+            CustomizableUI.unregisterArea(this.statusBar.id, false);
+    },
+
     get visible() !this.statusBar.collapsed && !this.statusBar.hidden,
 
     signals: {
@@ -245,7 +276,7 @@ var StatusLine = Module("statusline", {
                 url = _("buffer.noName");
         }
         else {
-            url = url.replace(RegExp("^dactyl://help/(\\S+)#(.*)"), function (m, n1, n2) n1 + " " + decodeURIComponent(n2) + " " + _("buffer.help"))
+            url = url.replace(RegExp("^dactyl://help/(\\S+)#(.*)"), (m, n1, n2) => n1 + " " + decodeURIComponent(n2) + " " + _("buffer.help"))
                      .replace(RegExp("^dactyl://help/(\\S+)"), "$1 " + _("buffer.help"));
         }
 
@@ -330,7 +361,7 @@ var StatusLine = Module("statusline", {
     updateTabCount: function updateTabCount(delayed) {
         if (dactyl.has("tabs")) {
             if (delayed) {
-                this.timeout(function () this.updateTabCount(false), 0);
+                this.timeout(() => { this.updateTabCount(false); }, 0);
                 return;
             }
 
@@ -377,10 +408,7 @@ var StatusLine = Module("statusline", {
      * @param {number} percent The zoom level, as a percentage. @optional
      * @param {boolean} full True if full zoom is in operation. @optional
      */
-    updateZoomLevel: function updateZoomLevel(percent, full) {
-        if (arguments.length == 0)
-            [percent, full] = [buffer.zoomLevel, buffer.fullZoom];
-
+    updateZoomLevel: function updateZoomLevel(percent=buffer.zoomLevel, full=buffer.fullZoom) {
         if (percent == 100)
             this.widgets.zoomlevel.value = "";
         else {