[Pkg-mozext-commits] [tabmixplus] 19/73: Add 'Report a Bug' button in tab-mix-plus page at addons.mozilla.org

David Prévot taffit at moszumanska.debian.org
Mon May 9 02:30:51 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository tabmixplus.

commit 72704c2b0752423b4e0bb1b0258038af26a4a131
Author: onemen <tabmix.onemen at gmail.com>
Date:   Fri Apr 1 15:25:41 2016 +0300

    Add 'Report a Bug' button in tab-mix-plus page at addons.mozilla.org
---
 chrome/content/content.js             | 69 +++++++++++++++++++++++++++++++++++
 chrome/locale/en-US/tabmix.properties |  1 +
 2 files changed, 70 insertions(+)

diff --git a/chrome/content/content.js b/chrome/content/content.js
index 43d66d5..114d38a 100644
--- a/chrome/content/content.js
+++ b/chrome/content/content.js
@@ -391,7 +391,76 @@ var ContextMenuHandler = {
   }
 };
 
+const AMO = "https://addons.mozilla.org/en-us/firefox/addon/tab-mix-plus/";
+const BITBUCKET = "https://bitbucket.org/onemen/tabmixplus/issues?status=new&status=open";
+
+var TabmixPageHandler = {
+  init: function(global) {
+    global.addEventListener("DOMContentLoaded", this);
+  },
+
+  handleEvent: function(event) {
+    const doc = content.document;
+    if (event.target != doc) {
+      return;
+    }
+
+    switch (doc.documentURI.toLowerCase()) {
+      case AMO:
+        if (event.type == "DOMContentLoaded") {
+          this.count = 0;
+          content.addEventListener("pageshow", this);
+        }
+        this.addAMOButton(event.type);
+        break;
+      case BITBUCKET:
+        this.styleBitbucket();
+        break;
+    }
+  },
+
+  count: 0,
+  addAMOButton: function(eventType) {
+    const doc = content.document;
+    // add-review is null on DOMContentLoaded
+    const addReview = doc.getElementById("add-review");
+    if (eventType != "pageshow" && !addReview && this.count++ < 10) {
+      this._timeoutID = setTimeout(() => this.addAMOButton("timeout"), 250);
+      return;
+    }
+    if (eventType == "pageshow" || addReview) {
+      content.removeEventListener("pageshow", this);
+    }
+    if (addReview && this._timeoutID) {
+      clearTimeout(this._timeoutID);
+      this._timeoutID = null;
+    }
+    const ID = "tabmixplus-bug-report";
+    if (addReview && !doc.getElementById(ID)) {
+      const bugReport = doc.createElement("a");
+      bugReport.href = BITBUCKET;
+      bugReport.textContent = TabmixSvc.getString("bugReport.label");
+      bugReport.id = ID;
+      bugReport.className = "button";
+      bugReport.target = "_blank";
+      bugReport.style.marginBottom = "4px";
+      const div = doc.createElement("DIV");
+      div.appendChild(bugReport);
+      addReview.parentNode.insertBefore(div, addReview);
+    }
+  },
+
+  styleBitbucket: function() {
+    let createIssue = content.document.getElementById("create-issue-contextual");
+    if (createIssue) {
+      createIssue.classList.remove("aui-button-subtle");
+      createIssue.classList.add("aui-button-primary");
+    }
+  },
+};
+
 TabmixContentHandler.init();
 TabmixClickEventHandler.init(this);
 AboutNewTabHandler.init(this);
 ContextMenuHandler.init(this);
+TabmixPageHandler.init(this);
diff --git a/chrome/locale/en-US/tabmix.properties b/chrome/locale/en-US/tabmix.properties
index d547e41..afb2e4c 100644
--- a/chrome/locale/en-US/tabmix.properties
+++ b/chrome/locale/en-US/tabmix.properties
@@ -47,3 +47,4 @@ tabmixoption.error.msg= You must have one browser window to use Tab Mix Plus Opt
 # multiple rows.
 rowsTooltip.rowscount=;#1 Rows
 rowsTooltip.activetab=Active tab on row #1
+bugReport.label=Report a Bug

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git



More information about the Pkg-mozext-commits mailing list