aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEhsan Akhgari <ehsan@mozilla.com>2010-06-28 20:22:47 -0400
committerEhsan Akhgari <ehsan@mozilla.com>2010-06-28 20:22:47 -0400
commitc889af0aae7a564662727e67823f8bcca6359199 (patch)
tree6c971f749584e92414cb50e3b8946cff144676d6
parent468f145fb626e6d699fbaf964d1e90599f4e090f (diff)
downloadbugzilla-triage-c889af0aae7a564662727e67823f8bcca6359199.tar.gz
Re-enable the context menu; work-around and initial patch by Drew Willcoxontweaks-1.0
-rw-r--r--lib/main.js73
1 files changed, 36 insertions, 37 deletions
diff --git a/lib/main.js b/lib/main.js
index 3a2bda6..1fb0c95 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -43,6 +43,35 @@ exports.main = function(options, callback) {
}
}
);
+
+ // 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) {
@@ -111,21 +140,6 @@ function tweakBugzilla(d) {
));
d.getElementsByTagName("head")[0].appendChild(style);
- /*
- // Allow toggling of CC event displays using a context menu entry
- var contextMenu = require("context-menu");
- var style = d.getElementById("bztw_cc");
- var ccMenuItem = contextMenu.Item({
- label: "Toggle CC History",
- context: onBugzillaPage,
- onClick: function() style.disabled = !style.disabled
- });
- contextMenu.add(ccMenuItem);
- d.defaultView.addEventListener("unload", function() {
- contextMenu.remove(ccMenuItem);
- }, false);
- */
-
var userNameCache = {};
function getUserName(email) {
if (email in userNameCache) {
@@ -196,23 +210,6 @@ function tweakBugzilla(d) {
var CheckinComment = new CheckinCommentCtor();
CheckinComment.initialize(d, AttachmentFlagHandler._interestingFlags);
- if (CheckinComment.isValid()) {
- var message = d.getElementById("__bz_tw_checkin_comment");
- if (message) {
- message = message.textContent;
- /*
- var copyCheckinCommentItem = contextMenu.Item({
- label: "Copy Check-in Comment",
- context: onBugzillaPage,
- onClick: function() require("clipboard").set(message)
- });
- contextMenu.add(copyCheckinCommentItem);
- d.defaultView.addEventListener("unload", function() {
- contextMenu.remove(copyCheckinCommentItem);
- }, false);
- */
- }
- }
var iframe = d.createElement('iframe');
iframe.src = historyLink.href;
@@ -796,11 +793,13 @@ CheckinCommentCtor.prototype = {
checkinFlags.push(flag);
}
this.checkinFlags = checkinFlags.join(" ");
- var div = doc.createElement("div");
- div.setAttribute("style", "display: none;");
- div.id = "__bz_tw_checkin_comment";
- div.appendChild(doc.createTextNode(this.toString()));
- doc.body.appendChild(div);
+ if (this.isValid()) {
+ var div = doc.createElement("div");
+ div.setAttribute("style", "display: none;");
+ div.id = "__bz_tw_checkin_comment";
+ div.appendChild(doc.createTextNode(this.toString()));
+ doc.body.appendChild(div);
+ }
},
isValid: function() {
return this.bugNumber != null &&