aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--data/js/bug-page-mod.js52
-rw-r--r--data/js/cc-context.js8
-rw-r--r--data/js/checkin-context.js11
-rw-r--r--data/js/urltest.js3
-rw-r--r--lib/main.js65
-rw-r--r--package.json5
6 files changed, 92 insertions, 52 deletions
diff --git a/data/js/bug-page-mod.js b/data/js/bug-page-mod.js
index 540ae2f..1e4341a 100644
--- a/data/js/bug-page-mod.js
+++ b/data/js/bug-page-mod.js
@@ -35,56 +35,9 @@
*
* ***** END LICENSE BLOCK ***** */
-exports.main = function(options, callback) {
- require("tab-browser").whenContentLoaded(
- function(window) {
- if (onBugzillaPage(window)) {
- tweakBugzilla(window.document);
- }
- }
- );
-
- // Allow toggling of CC event displays using a context menu entry
- var contextMenu = require("context-menu");
- var ccMenuItem = contextMenu.Item({
- label: "Toggle CC History",
- context: function(context) onBugzillaPage(context.window),
- onClick: function(context) {
- var style = context.document.getElementById("bztw_cc");
- style.disabled = !style.disabled;
- }
- });
- contextMenu.add(ccMenuItem);
-
- var copyCheckinCommentItem = contextMenu.Item({
- label: "Copy Check-in Comment",
- context: function(context) {
- if (!onBugzillaPage(context.window))
- return false;
- var d = context.document;
- var message = d.getElementById("__bz_tw_checkin_comment");
- return !!message;
- },
- onClick: function(context) {
- var d = context.document;
- var message = d.getElementById("__bz_tw_checkin_comment");
- require("clipboard").set(message.textContent);
- }
- });
- contextMenu.add(copyCheckinCommentItem);
-};
-
-function onBugzillaPage(window) {
- if ("window" in window) {
- window = window.window;
- }
- return window.location.protocol == "https:" &&
- /bugzilla(-[a-zA-Z]+)*\.mozilla\.org/.test(window.location.href);
-}
-
function tweakBugzilla(d) {
// run on both bugzilla.m.o and bugzilla-stage-tip.m.o
- if (!/bugzilla(-[a-zA-Z]+)*\.mozilla\.org/.test(d.location.href))
+ if (!onBugzillaPage(d.URL))
return;
// Put the quicksearch text in the quicksearch boxes
@@ -524,6 +477,7 @@ AttachmentFlag.prototype = {
var reAttachmentDiff = /attachment\.cgi\?id=(\d+)&action=diff$/i;
var reviewBoardUrlBase = "http://reviews.visophyte.org/";
+
/**
* Whenever we find a patch with a diff, insert an additional link to asuth's
* review board magic.
@@ -1146,3 +1100,5 @@ function tbplbotSpamCollapser(d) {
li.appendChild(a);
collapseExpandBox.appendChild(li);
}
+
+tweakBugzilla(document);
diff --git a/data/js/cc-context.js b/data/js/cc-context.js
new file mode 100644
index 0000000..38397a9
--- /dev/null
+++ b/data/js/cc-context.js
@@ -0,0 +1,8 @@
+on('click', function(node, data) {
+ var style = document.getElementById("bztw_cc");
+ style.disabled = !style.disabled;
+});
+
+on('context', function(node) {
+ return onBugzillaPage(document.URL);
+});
diff --git a/data/js/checkin-context.js b/data/js/checkin-context.js
new file mode 100644
index 0000000..4d073be
--- /dev/null
+++ b/data/js/checkin-context.js
@@ -0,0 +1,11 @@
+on('click', function(node, data) {
+ var message = document.getElementById("__bz_tw_checkin_comment");
+ postMessage(message.textContent);
+});
+
+on('context', function(node) {
+ if (!onBugzillaPage(document.URL))
+ return false;
+ var message = document.getElementById("__bz_tw_checkin_comment");
+ return !!message;
+});
diff --git a/data/js/urltest.js b/data/js/urltest.js
new file mode 100644
index 0000000..f6a379a
--- /dev/null
+++ b/data/js/urltest.js
@@ -0,0 +1,3 @@
+function onBugzillaPage(url) {
+ return /https:\/\/bugzilla(-[a-zA-Z]+)*\.mozilla\.org/.test(url);
+} \ No newline at end of file
diff --git a/lib/main.js b/lib/main.js
new file mode 100644
index 0000000..bb40d7a
--- /dev/null
+++ b/lib/main.js
@@ -0,0 +1,65 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Bugzilla Tweaks.
+ *
+ * The Initial Developer of the Original Code is Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Johnathan Nightingale <johnath@mozilla.com>
+ * Ehsan Akhgari <ehsan@mozilla.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+var self = require("self"),
+ contextMenu = require("context-menu"),
+ pageMod = require("page-mod");
+
+exports.main = function(options, callback) {
+ pageMod.PageMod({
+ include: ["*.mozilla.org"], // filtered further in the page mod script
+ contentScriptWhen: 'ready',
+ contentScriptFile: [self.data.url('js/urltest.js'),
+ self.data.url('js/bug-page-mod.js')]
+ });
+
+ // Allow toggling of CC event displays using a context menu entry
+ contextMenu.Item({
+ label: "Toggle CC History",
+ contentScriptFile: [self.data.url('js/urltest.js'),
+ self.data.url('js/cc-context.js')]
+ });
+
+ contextMenu.Item({
+ label: "Copy Check-in Comment",
+ contentScriptFile: [self.data.url('js/urltest.js'),
+ self.data.url('js/checkin-context.js')],
+ onMessage: function (comment) {
+ require("clipboard").set(comment);
+ }
+ });
+};
diff --git a/package.json b/package.json
index 8757090..71e2270 100644
--- a/package.json
+++ b/package.json
@@ -4,10 +4,7 @@
"author": "Ehsan Akhgari (http://ehsanakhgari.org/) <ehsan@mozilla.com>",
"contributors": ["Johnathan Nightingale (http://johnath.com) <johnath@mozilla.com>"],
"url": "http://ehsanakhgari.org/mozilla/extensions/firefox/bugzilla-tweaks",
- "version": "1.6",
- "dependencies": [
- "jetpack-core"
- ],
+ "version": "1.6",
"fullName": "Bugzilla Tweaks",
"id": "jid0-qBnIpLfDFa4LpdrjhAC6vBqN20Q"
}