]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/content/statusline.js
Import 1.0b7.1 supporting Firefox up to 8.*
[dactyl.git] / common / content / statusline.js
index 54943425f6a650e99a916fd708911faba1dc896c..b5dbee70d417e97426443a35d5017ac4f563a8cb 100644 (file)
@@ -26,25 +26,28 @@ var StatusLine = Module("statusline", {
             util.overlayWindow(window, { append: <><statusbar id="status-bar" ordinal="0"/></> });
 
             highlight.loadCSS(util.compileMacro(<![CDATA[
-                !AddonBar;#addon-bar  {
+                !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  {
+                !AddonButton;#addon-bar xul|toolbarbutton {
+                    /* An Add-on Bar button */
                     -moz-appearance: none !important;
                     padding: 0 !important;
                     border-width: 0px !important;
                     min-width: 0 !important;
                     color: inherit !important;
                 }
-                AddonButton:not(:hover)  background: transparent !important;
+                AddonButton:not(:hover)  background: transparent;
             ]]>)({ padding: util.OS.isMacOSX ? "padding-right: 10px !important;" : "" }));
 
             if (document.getElementById("appmenu-button"))
                 highlight.loadCSS(<![CDATA[
-                    AppmenuButton       min-width: 0 !important; padding: 0 .5em !important;
+                    AppmenuButton       /* The app-menu button */ \
+                                        min-width: 0 !important; padding: 0 .5em !important;
                 ]]>);
         }
 
@@ -60,7 +63,7 @@ var StatusLine = Module("statusline", {
                         <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"                                   class="plain dactyl-status-field-url" readonly="true"/>
+                                <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>
@@ -96,7 +99,7 @@ var StatusLine = Module("statusline", {
     signals: {
         "browser.locationChange": function (webProgress, request, uri) {
             let win = webProgress.DOMWindow;
-            this.status = buffer.uri;
+            this.status = uri;
             this.progress = uri && win && win.dactylProgress || "";
 
             // if this is not delayed we get the position of the old buffer
@@ -142,12 +145,14 @@ var StatusLine = Module("statusline", {
                 this.progress = 0;
             if (flags & Ci.nsIWebProgressListener.STATE_STOP) {
                 this.progress = "";
-                this.status = buffer.uri;
+                this.updateStatus();
             }
         },
         "browser.statusChange": function onStatusChange(webProgress, request, status, message) {
-            this.status = message || buffer.uri;
-        },
+            this.timeout(function () {
+                this.status = message || buffer.uri;
+            });
+        }
     },
 
     /**
@@ -175,7 +180,7 @@ var StatusLine = Module("statusline", {
 
     // update all fields of the statusline
     update: function update() {
-        this.status = buffer.uri;
+        this.updateStatus();
         this.inputBuffer = "";
         this.progress = "";
         this.updateTabCount();
@@ -183,34 +188,8 @@ var StatusLine = Module("statusline", {
         this.updateZoomLevel();
     },
 
-    // ripped from Firefox; modified
-    unsafeURI: util.regexp(String.replace(<![CDATA[
-            [
-                \s
-                // Invisible characters (bug 452979)
-                U001C U001D U001E U001F // file/group/record/unit separator
-                U00AD // Soft hyphen
-                UFEFF // BOM
-                U2060 // Word joiner
-                U2062 U2063  // Invisible times/separator
-                U200B UFFFC // Zero-width space/no-break space
-
-                // Bidi formatting characters. (RFC 3987 sections 3.2 and 4.1 paragraph 6)
-                U200E U200F U202A U202B U202C U202D U202E
-            ]
-        ]]>, /U/g, "\\u"),
-        "gx"),
-    losslessDecodeURI: function losslessDecodeURI(url) {
-        return url.split("%25").map(function (url) {
-                // Non-UTF-8 compliant URLs cause "malformed URI sequence" errors.
-                try {
-                    return decodeURI(url).replace(this.unsafeURI, encodeURIComponent);
-                }
-                catch (e) {
-                    return url;
-                }
-            }, this).join("%25");
-    },
+    unsafeURI: deprecated("util.unsafeURI", { get: function unsafeURI() util.unsafeURI }),
+    losslessDecodeURI: deprecated("util.losslessDecodeURI", function losslessDecodeURI() util.losslessDecodeURI.apply(util, arguments)),
 
     /**
      * Update the URL displayed in the status line. Also displays status
@@ -230,29 +209,26 @@ var StatusLine = Module("statusline", {
             if (uri.equals(buffer.uri) && window.getWebNavigation) {
                 let sh = window.getWebNavigation().sessionHistory;
                 if (sh && sh.index > 0)
-                    modified += "+";
-                if (sh && sh.index < sh.count - 1)
                     modified += "-";
-            }
-
-            if (modules.bookmarkcache) {
-                if (bookmarkcache.isBookmarked(uri))
+                if (sh && sh.index < sh.count - 1)
+                    modified += "+";
+                if (this.bookmarked)
                     modified += UTF8("❤");
             }
 
             if (modules.quickmarks)
                 modified += quickmarks.find(uri.spec.replace(/#.*/, "")).join("");
 
-            url = this.losslessDecodeURI(uri.spec);
+            url = util.losslessDecodeURI(uri.spec);
         }
 
         if (url == "about:blank") {
             if (!buffer.title)
-                url = "[No Name]";
+                url = _("buffer.noName");
         }
         else {
-            url = url.replace(RegExp("^dactyl://help/(\\S+)#(.*)"), function (m, n1, n2) n1 + " " + decodeURIComponent(n2) + " [Help]")
-                     .replace(RegExp("^dactyl://help/(\\S+)"), "$1 [Help]");
+            url = url.replace(RegExp("^dactyl://help/(\\S+)#(.*)"), function (m, n1, n2) n1 + " " + decodeURIComponent(n2) + " " + _("buffer.help"))
+                     .replace(RegExp("^dactyl://help/(\\S+)"), "$1 " + _("buffer.help"));
         }
 
         if (modified)
@@ -260,10 +236,20 @@ var StatusLine = Module("statusline", {
 
         this.widgets.url.value = url;
         this._status = uri;
+    },
 
+    get bookmarked() this._bookmarked,
+    set bookmarked(val) {
+        this._bookmarked = val;
+        if (this.status)
+            this.status = this.status;
     },
 
-    updateStatus: function updateStatus() { this.status = buffer.uri; },
+    updateStatus: function updateStatus() {
+        this.timeout(function () {
+            this.status = buffer.uri;
+        });
+    },
 
     updateUrl: deprecated("statusline.status", function updateUrl(url) { this.status = url || buffer.uri }),
 
@@ -291,15 +277,15 @@ var StatusLine = Module("statusline", {
      */
     progress: Modes.boundProperty({
         get: function progress() this._progress,
-        set: function  progress(progress) {
+        set: function progress(progress) {
             this._progress = progress || "";
 
-            if (typeof progress == "string")
+            if (isinstance(progress, ["String", _]))
                 this.widgets.progress.value = this._progress;
             else if (typeof progress == "number") {
                 let progressStr = "";
                 if (this._progress <= 0)
-                    progressStr = "[ Loading...         ]";
+                    progressStr = /*L*/"[ Loading...         ]";
                 else if (this._progress < 1) {
                     let progress = Math.round(this._progress * 20);
                     progressStr = "["