aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEhsan Akhgari <ehsan@mozilla.com>2010-05-30 20:47:18 -0400
committerEhsan Akhgari <ehsan@mozilla.com>2010-05-30 20:47:18 -0400
commitd3b1a4f3a2758062a0537ebd0c40a676a8a00b66 (patch)
treebe36962e86f610b60d0c01a132fa90067c6a0d44 /lib
parentef369e0ba4f4c8c1f0e3eaad49ff99050e798542 (diff)
downloadbugzilla-triage-d3b1a4f3a2758062a0537ebd0c40a676a8a00b66.tar.gz
Switch to using the context-menu API
Diffstat (limited to 'lib')
-rw-r--r--lib/main.js40
1 files changed, 23 insertions, 17 deletions
diff --git a/lib/main.js b/lib/main.js
index cd4de54..cb1da69 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -70,24 +70,19 @@ function tweakBugzilla(d) {
d.getElementsByTagName("head")[0].appendChild(style);
// Allow toggling of CC event displays using a context menu entry
- jetpack.menu.beforeShow = function (menu, context) {
- var style = context.document.getElementById("bztw_cc");
- menu.reset();
- menu.add({
- label: (style.disabled ? "Hide CC History" : "Show CC History"),
- command: function() style.disabled = !style.disabled
- });
- if (CheckinComment.isValid()) {
- var message = context.document.getElementById("__bz_tw_checkin_comment");
- if (message) {
- message = message.textContent;
- menu.add({
- label: "Copy Check-in Comment",
- command: function() jetpack.clipboard.set(message)
- });
- }
+ var contextMenu = require("context-menu");
+ function getCCMenuItemLabel(d) {
+ var style = d.getElementById("bztw_cc");
+ return (style.disabled ? "Hide CC History" : "Show CC History");
+ }
+ var ccMenuItem = contextMenu.Item({
+ label: getCCMenuItemLabel(d),
+ onClick: function(context, item) {
+ style.disabled = !style.disabled;
+ item.label = getCCMenuItemLabel(context.document);
}
- };
+ });
+ contextMenu.add(ccMenuItem);
var userNameCache = {};
function getUserName(email) {
@@ -159,6 +154,17 @@ 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",
+ onClick: function() jetpack.clipboard.set(message)
+ });
+ contextMenu.add(copyCheckinCommentItem);
+ }
+ }
var iframe = d.createElement('iframe');
iframe.src = historyLink.href;