Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

refactoring begins - separate tooltip and linkification into own files

  • Loading branch information...
commit eeee83cf0f05803cfc4b8e96b6dc6687a1207a5c 1 parent 64c22b6
@harthur authored
View
4 chrome/content/firefoxOverlay.xul
@@ -39,11 +39,13 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="BugIdHelper.onload();">
- <stringbundleset id="stringbundleset">
+ <stringbundleset id="stringbundleset">
<stringbundle id="bugid-strings" src="chrome://bugid/locale/bugid.properties"/>
</stringbundleset>
<script type="application/x-javascript" src="chrome://bugid/content/overlay.js"/>
+ <script type="application/x-javascript" src="chrome://bugid/content/links.js"/>
+ <script type="application/x-javascript" src="chrome://bugid/content/tooltips.js"/>
<script type="application/x-javascript" src="chrome://bugid/content/bugzillaRPC.js"/>
<popup id="contentAreaContextMenu">
View
53 chrome/content/links.js
@@ -0,0 +1,53 @@
+bugidLinkifier = {
+ linkifyContent : function(doc, target) {
+ var textnodes = bugidHelper.xpathNodes(doc,
+ "descendant::text()[contains(translate(., 'BUG', 'bug'),'bug')]", target);
+
+ for(var i = 0, len = textnodes.length; i < len; i++) {
+ var node = textnodes[i];
+ /* handle one match at a time so we can get index of regex */
+ while(node.data) {
+ var matches = bugidHelper.bugExp.exec(node.data);
+ var urlmatches = bugidHelper.urlExp.exec(node.data);
+
+ // we need to make sure we don't skip over plain text urls
+ if(matches && (!urlmatches || matches.index < urlmatches.index)) {
+ var index = matches.index;
+ var prelen = matches[1].length;
+ var bugtext = matches[2];
+ var url = bugidHelper.baseUrl + "id=" + matches[3];
+ }
+ else if (urlmatches) {
+ var index = urlmatches.index;
+ var prelen = 0;
+ var bugtext = urlmatches[0];
+ var url = "http://" + urlmatches[1];
+ }
+ else
+ break;
+
+ /* snip out bug id */
+ var bug = node.splitText(index + prelen);
+ node = bug.splitText(bugtext.length);
+
+ var anchor = doc.createElement("a");
+ var text = doc.createTextNode(bugtext);
+ anchor.appendChild(text);
+ anchor.className = "__firefox_bugidHelper";
+
+
+ /* insert link */
+ node.parentNode.replaceChild(anchor, bug);
+
+ if(bugidHelper.canSetHref(doc, anchor))
+ this.setLink(anchor, url);
+ }
+ }
+ },
+
+ setLink : function(element, url) {
+ element.setAttribute("href", url);
+ if(bugidHelper.getBoolPref("link.diverted"))
+ element.setAttribute("target", "_blank");
+ },
+}
View
14 chrome/content/options.xul
@@ -61,9 +61,7 @@
<preference id="toolcomppref" name="extensions.bugid.tooltip.showcomp" type="bool" />
<preference id="toolassignpref" name="extensions.bugid.tooltip.showassign" type="bool"/>
<preference id="toolcommpref" name="extensions.bugid.tooltip.showcommenter" type="bool"/>
- <preference id="toolerrorpref" name="extensions.bugid.tooltip.showerror" type="bool"/>
- <preference id="filterpref" name="extensions.bugid.filter" type="bool" />
- <preference id="whitelistpref" name="extensions.bugid.whitelist" type="string" />
+ <preference id="toolerrorpref" name="extensions.bugid.tooltip.showerror" type="bool"/>
</preferences>
<vbox class="category-prime">
@@ -119,15 +117,5 @@
tooltiptext="&toolerrorpref.tooltip;" />
</vbox>
</vbox>
-
- <vbox class="category">
- <checkbox id="filtboolpref" preference="filterpref" label="&filterpref.label;" control="whitelisttext"
- onsyncfrompreference="togglePrefs('filtersubpref', 'filtboolpref')"
- onsynctopreference="togglePrefs('filtersubpref', 'filtboolpref')" />
- <vbox class="subpref">
- <textbox id="whitelisttext" class="filtersubpref" preference="whitelistpref"/>
- </vbox>
- </vbox>
-
</prefpane>
</prefwindow>
View
287 chrome/content/overlay.js
@@ -33,9 +33,9 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-window.addEventListener("load", function(){ bugIdHelper.init(); }, false);
+window.addEventListener("load", function(){ bugidHelper.init(); }, false);
-var bugIdHelper = {
+var bugidHelper = {
/* 1 - bug id */
contextExp : /^(?:.*bug|ug|g)?\s*#?(\d{2,7})(?:$|\b)/i,
@@ -66,28 +66,19 @@ var bugIdHelper = {
this.baseUrl = this.toBaseUrl(this.userUrl);
this.prefService.addObserver("extensions.bugid.url", this, false);
- var urls = this.prefService.getCharPref("extensions.bugid.whitelist");
- this.domainExps = this.toDomains(urls);
- this.prefService.addObserver("extensions.bugid.whitelist", this, false);
-
var resos = this.prefService.getCharPref("extensions.bugid.link.strike.resos");
this.strikeResos = resos.split(/[\.,\s]+/);
this.prefService.addObserver("extensions.bugid.link.strike.resos", this, false);
- /* add context menu popup listener */
- var contextmenu = document.getElementById("contentAreaContextMenu");
- if(contextmenu)
- contextmenu.addEventListener("popupshowing", function(){ bugIdHelper.contextShowing(); }, false);
-
/* add content page load listener */
var content = document.getElementById("appcontent");
if(content)
- content.addEventListener("load", function(e) { bugIdHelper.contentLoad(e); }, true);
+ content.addEventListener("load", function(e) { bugidHelper.contentLoad(e); }, true);
/* thunderbird email load */
var messagepane = document.getElementById("messagepane");
if(messagepane)
- messagepane.addEventListener("load", function(e) { bugIdHelper.contentLoad(e); }, true);
+ messagepane.addEventListener("load", function(e) { bugidHelper.contentLoad(e); }, true);
},
observe : function(subject, topic, data) {
@@ -118,257 +109,27 @@ var bugIdHelper = {
gBrowser.loadOneTab(bugurl, null, null, null, loadInBackground, false);
},
- contextShowing : function() {
- var bugItem = document.getElementById("context-bugid");
- var selection = getBrowserSelection();
- var matches = selection.match(this.contextExp);
-
- if(matches) {
- this.selectedBug = matches[1];
- bugItem.hidden = false;
- bugItem.label = this.strings.getFormattedString("contextItem", [this.selectedBug]);
- }
- else
- bugItem.hidden = true;
- },
-
/*--- linkification ---*/
contentLoad : function(event) {
var doc = event.originalTarget;
if(this.canBugify(doc)) {
- bugIdHelper.bugifyContent(doc, doc.body);
+ bugidHelper.bugifyContent(doc, doc.body);
/* listen for node insertion (gmail, etc.) */
doc.addEventListener("DOMNodeInserted", function(e) {
if(e.target.className == "__firefox_bugidhelper")
return; // prevent possible infinite recursion
- bugIdHelper.bugifyContent(doc, e.target);
+ bugidHelper.bugifyContent(doc, e.target);
}, true);
}
},
bugifyContent : function(doc, target) {
if(this.getBoolPref("linkify"))
- this.linkifyContent(doc, target);
+ bugidLinkifier.linkifyContent(doc, target);
if(this.getBoolPref("tooltipify"))
- this.tooltipifyContent(doc, target);
+ bugidTooltipifier.tooltipifyContent(doc, target);
},
- linkifyContent : function(doc, target) {
- var textnodes = this.xpathNodes(doc,
- "descendant::text()[contains(translate(., 'BUG', 'bug'),'bug')]", target);
-
- for(var i = 0, len = textnodes.length; i < len; i++) {
- var node = textnodes[i];
- /* handle one match at a time so we can get index of regex */
- while(node.data) {
- var matches = this.bugExp.exec(node.data);
- var urlmatches = this.urlExp.exec(node.data);
-
- // we need to make sure we don't skip over plain text urls
- if(matches && (!urlmatches || matches.index < urlmatches.index)) {
- var index = matches.index;
- var prelen = matches[1].length;
- var bugtext = matches[2];
- var url = this.baseUrl + "id=" + matches[3];
- }
- else if (urlmatches) {
- var index = urlmatches.index;
- var prelen = 0;
- var bugtext = urlmatches[0];
- var url = "http://" + urlmatches[1];
- }
- else
- break;
-
- /* snip out bug id */
- var bug = node.splitText(index + prelen);
- node = bug.splitText(bugtext.length);
-
- var anchor = doc.createElement("a");
- var text = doc.createTextNode(bugtext);
- anchor.appendChild(text);
- anchor.className = "__firefox_bugidhelper";
-
-
- /* insert link */
- node.parentNode.replaceChild(anchor, bug);
-
- if(this.canSetHref(doc, anchor))
- this.setLink(anchor, url);
- }
- }
- },
-
- setLink : function(element, url) {
- element.setAttribute("href", url);
- if(this.getBoolPref("link.diverted"))
- element.setAttribute("target", "_blank");
- },
-
- /*--- tooltip ---*/
- tooltipifyContent : function(doc, target) {
- var links = this.xpathNodes(doc, 'descendant::a[contains(@href, "show_bug.cgi")]', target);
- if(links.length > 0) {
- var login = this.getLogin();
- if(login.username) {
- var userUrl = this.prefService.getCharPref("extensions.bugid.url");
- bugzillaRPC.setUrl(this.toBugzillaDomain(userUrl));
- bugzillaRPC.login(login.username, login.password,
- function(){ bugIdHelper.tooltipifyLinks(doc, links);},
- function(){ bugIdHelper.tooltipifyLinks(doc, links);});
- }
- else
- this.tooltipifyLinks(doc, links);
- }
- else
- this.tooltipifyLinks(doc, links);
- },
-
- tooltipifyLinks : function(doc, links) {
- for(var i = 0; i < links.length; i++) {
- var link = links[i];
- var matches = bugIdHelper.urlExp.exec(link.getAttribute("href"));
- if(matches) {
- var base = matches[2];
- if(base.length < 15) // on a bugzilla domain -override tooltip
- base = bugIdHelper.domainExp.exec(doc.location.href)[1] + "/show_bug.cgi?";
- var url = "http://" + base + "ctype=xml&excludefield=attachment&id=" + matches[3];
- var commentId = matches[4];
- if(commentId)
- bugIdHelper.setComment(link, url, commentId);
- else
- bugIdHelper.setTooltip(link, url);
- }
- }
- },
-
- setTooltip : function(element, url) {
- this.xhr(url,
- function(wasSuccess, xml) {
- if(!bugIdHelper) // this happens sometimes
- return;
- var showerror = bugIdHelper.getBoolPref("tooltip.showerror");
- if(!wasSuccess) {
- if(showerror)
- element.title = bugIdHelper.strings.getFormattedString("invalidPage", [url]);
- return;
- }
- var bug = xml.getElementsByTagName("bug");
- if(bug && bug[0] && bug[0].hasAttribute("error")) {
- var error = bug[0].getAttribute("error");
- if(showerror)
- element.title = bugIdHelper.strings.getFormattedString("invalidId",
- [bugIdHelper.userUrl, error]);
- return;
- }
- var tooltip = [];
- if(bugIdHelper.getBoolPref("tooltip.showid"))
- tooltip.push(bugIdHelper.strings.getString("bug") + " " +
- bugIdHelper.bugAttribute(xml, "bug_id"));
- if(bugIdHelper.getBoolPref("tooltip.showstat")) {
- var status = bugIdHelper.bugAttribute(xml, "bug_status");
- var reso = bugIdHelper.bugAttribute(xml, "resolution");
- if(reso)
- tooltip.push(status + " " + reso);
- else
- tooltip.push(status);
- }
- if(bugIdHelper.getBoolPref("tooltip.showcomp")) {
- var prod = bugIdHelper.bugAttribute(xml, "product");
- var comp = bugIdHelper.bugAttribute(xml, "component");
- tooltip.push(prod + "/" + comp);
- }
- if(bugIdHelper.getBoolPref("tooltip.showdate"))
- tooltip.push(bugIdHelper.toDate(bugIdHelper.bugAttribute(xml, "creation_ts")));
- if(bugIdHelper.getBoolPref("tooltip.showassign"))
- tooltip.push(bugIdHelper.bugAttribute(xml, "assigned_to"));
- if(bugIdHelper.getBoolPref("tooltip.showdesc"))
- tooltip.push(bugIdHelper.bugAttribute(xml, "short_desc"));
-
- if(bugIdHelper.getBoolPref("link.strikethrough")) {
- var reso = bugIdHelper.bugAttribute(xml, "resolution");
- if(bugIdHelper.strikeResos.indexOf(reso) != -1)
- element.style.textDecoration = "underline line-through";
- }
-
- /* set title attribute to tooltip text */
- element.title = tooltip.join(" -- ");
- });
- },
-
- setComment : function(element, url, cid) {
- this.xhr(url,
- function(wasSuccess, xml) {
- if(!bugIdHelper) // this happens sometimes
- return;
- var showerror = bugIdHelper.getBoolPref("tooltip.showerror");
- if(!wasSuccess) {
- if(showerror)
- element.title = bugIdHelper.strings.getFormattedString("invalidPage", [url]);
- return;
- }
- var bug = xml.getElementsByTagName("bug");
- if(bug && bug[0] && bug[0].hasAttribute("error")) {
- var error = bug[0].getAttribute("error");
- if(showerror)
- element.title = bugIdHelper.strings.getFormattedString("invalidId",
- [bugIdHelper.userUrl, error]);
- return;
- }
- /* set title attribute to comment text */
- var comment = xml.getElementsByTagName("long_desc")[cid];
- if(comment) {
- var text = bugIdHelper.bugAttribute(comment, "thetext");
- var tooltip = "";
- if(bugIdHelper.getBoolPref("tooltip.showcommenter"))
- tooltip += bugIdHelper.bugAttribute(comment, "who") + " -- ";
- element.title = tooltip + text.substring(0, Math.min(text.length, 180)) + " ...";
- }
- });
- },
-
- /* Adapted from browser.js - Firefox. Adds full tooltip support to Thunderbird content */
- fillTBirdTooltip : function(tipElement) {
- var retVal = false;
- if (tipElement.namespaceURI == "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul")
- return retVal;
- const XLinkNS = "http://www.w3.org/1999/xlink";
- var titleText = null;
- var XLinkTitleText = null;
- var direction = tipElement.ownerDocument.dir;
-
- while (!titleText && !XLinkTitleText && tipElement) {
- if (tipElement.nodeType == Node.ELEMENT_NODE) {
- titleText = tipElement.getAttribute("title");
- XLinkTitleText = tipElement.getAttributeNS(XLinkNS, "title");
- var defView = tipElement.ownerDocument.defaultView;
- // Work around bug 350679: "Tooltips can be fired in documents with no view"
- if (!defView)
- return retVal;
- direction = defView.getComputedStyle(tipElement, "")
- .getPropertyValue("direction");
- }
- tipElement = tipElement.parentNode;
- }
-
- var tipNode = document.getElementById("bugidTooltip");
- tipNode.style.direction = direction;
-
- for each (var t in [titleText, XLinkTitleText]) {
- if (t && /\S/.test(t)) {
- // Per HTML 4.01 6.2 (CDATA section), literal CRs and tabs should be
- // replaced with spaces, and LFs should be removed entirely
- t = t.replace(/[\r\t]/g, ' ');
- t = t.replace(/\n/g, '');
-
- tipNode.setAttribute("label", t);
- retVal = true;
- }
- }
- return retVal;
- },
-
- /*--- utility functions ---*/
toBugzillaDomain : function (fragment) {
var matches = fragment.match(this.baseUrlExp);
if(matches)
@@ -381,34 +142,11 @@ var bugIdHelper = {
return "http://" + matches[1] + "/show_bug.cgi?";
},
- toDomainRegex : function(userDomain) {
- if(userDomain.indexOf("://") != -1)
- return new RegExp("^" + userDomain);
- return new RegExp("^(?:https?|file):\/\/(www\.)?" + userDomain);
- },
-
- toDomains : function(urlStr) {
- var urls = urlStr.split(/[\s,;]+/);
- var domains = [];
- for(var i = 0, len = urls.length; i < len; i++)
- domains.push(this.toDomainRegex(urls[i]));
- return domains;
- },
-
- /* return true if can linkify and add tooltips to this document */
canBugify : function(doc) {
if(!doc.location || doc.location.href.indexOf("about:") == 0)
return false;
if(!this.getBoolPref("linkify") && !this.getBoolPref("tooltipify"))
return false;
- if(this.prefService.getBoolPref("extensions.bugid.filter")) {
- var isValidDomain = false;
- for(var i = 0, len = this.domainExps.length; i < len; i++) {
- if(this.domainExps[i].test(doc.location.href))
- isValidDomain = true;
- }
- return isValidDomain;
- }
return true;
},
@@ -417,11 +155,6 @@ var bugIdHelper = {
"boolean(ancestor-or-self::*[@href])", elem);
},
- canSetTitle : function(doc, elem) {
- return !this.xpathBool(doc,
- "boolean(ancestor-or-self::*[@title or @onmouseover])", elem);
- },
-
canLink : function(doc, elem) {
return !this.xpathBool(doc, "boolean(ancestor-or-self::*[@class='__firefox_bugidhelper'])");
},
@@ -438,7 +171,7 @@ var bugIdHelper = {
var e = passwordManager.enumerator;
while (e.hasMoreElements()) {
var loginInfo = e.getNext().QueryInterface(Components.interfaces.nsIPassword);
- if (loginInfo.host == bugIdHelper.hostUrl)
+ if (loginInfo.host == bugidHelper.hostUrl)
return {username: loginInfo.user, password: loginInfo.password};
}
}
@@ -447,7 +180,7 @@ var bugIdHelper = {
var loginManager = Components.classes["@mozilla.org/login-manager;1"]
.getService(Components.interfaces.nsILoginManager);
- var logins = loginManager.findLogins({}, bugIdHelper.hostUrl, "", null);
+ var logins = loginManager.findLogins({}, bugidHelper.hostUrl, "", null);
if(logins.length > 0)
return {username: logins[0].username, password: logins[0].password};
}
View
4 chrome/content/tbirdOverlay.xul
@@ -38,7 +38,9 @@
<overlay id="bugid-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
- <script type="application/x-javascript" src="chrome://bugid/content/overlay.js"/>
+ <script type="application/x-javascript" src="chrome://bugid/content/overlay.js"/>
+ <script type="application/x-javascript" src="chrome://bugid/content/links.js"/>
+ <script type="application/x-javascript" src="chrome://bugid/content/tooltips.js"/>
<script type="application/x-javascript" src="chrome://bugid/content/bugzillaRPC.js"/>
<stringbundleset id="stringbundleset">
View
22 chrome/content/test.html
@@ -0,0 +1,22 @@
+<html>
+<head>
+ <style>
+ ul {
+ list-style: none;
+ }
+ </style>
+</head>
+<body>
+<ul>
+<li>bug 3455</li>
+<li>Bug 3455</li>
+<li>BUG 3455</li>
+<li>bug#3455</li>
+<li>bug3455</li>
+<li>http://bugzilla.mozilla.org/show_bug.cgi?id=3455</li>
+<li>http://bugs.gentoo.org/show_bug.cgi?id=3455</li>
+<li>bugzilla.mozilla.org/show_bug.cgi?id=3455/li>
+<li>https://bugzilla.mozilla.org/show_bug.cgi?id=3455</li>
+</ul>
+</body>
+</html>
View
165 chrome/content/tooltips.js
@@ -0,0 +1,165 @@
+var bugidTooltipifier = {
+
+ /*--- tooltip ---*/
+ tooltipifyContent : function(doc, target) {
+ var links = bugidHelper.xpathNodes(doc, 'descendant::a[contains(@href, "show_bug.cgi")]', target);
+ if(links.length > 0) {
+ var login = bugidHelper.getLogin();
+ if(login.username) {
+ var userUrl = bugidHelper.prefService.getCharPref("extensions.bugid.url");
+ bugzillaRPC.setUrl(bugidHelper.toBugzillaDomain(userUrl));
+ bugzillaRPC.login(login.username, login.password,
+ function(){ bugidTooltipifier.tooltipifyLinks(doc, links);},
+ function(){ bugidToolipifier.tooltipifyLinks(doc, links);});
+ }
+ else
+ this.tooltipifyLinks(doc, links);
+ }
+ else
+ this.tooltipifyLinks(doc, links);
+ },
+
+ tooltipifyLinks : function(doc, links) {
+ for(var i = 0; i < links.length; i++) {
+ var link = links[i];
+ var matches = bugidHelper.urlExp.exec(link.getAttribute("href"));
+ if(matches) {
+ var base = matches[2];
+ if(base.length < 15) // on a bugzilla domain -override tooltip
+ base = bugidHelper.domainExp.exec(doc.location.href)[1] + "/show_bug.cgi?";
+ var url = "http://" + base + "ctype=xml&excludefield=attachment&id=" + matches[3];
+ var commentId = matches[4];
+ if(commentId)
+ bugidTooltipifier.setComment(link, url, commentId);
+ else
+ bugidTooltipifier.setTooltip(link, url);
+ }
+ }
+ },
+
+ setTooltip : function(element, url) {
+ bugidHelper.xhr(url,
+ function(wasSuccess, xml) {
+ if(!bugidHelper) // this happens sometimes
+ return;
+ var showerror = bugidHelper.getBoolPref("tooltip.showerror");
+ if(!wasSuccess) {
+ if(showerror)
+ element.title = bugidHelper.strings.getFormattedString("invalidPage", [url]);
+ return;
+ }
+ var bug = xml.getElementsByTagName("bug");
+ if(bug && bug[0] && bug[0].hasAttribute("error")) {
+ var error = bug[0].getAttribute("error");
+ if(showerror)
+ element.title = bugidHelper.strings.getFormattedString("invalidId",
+ [bugidHelper.userUrl, error]);
+ return;
+ }
+ var tooltip = [];
+ if(bugidHelper.getBoolPref("tooltip.showid"))
+ tooltip.push(bugidHelper.strings.getString("bug") + " " +
+ bugidHelper.bugAttribute(xml, "bug_id"));
+ if(bugidHelper.getBoolPref("tooltip.showstat")) {
+ var status = bugidHelper.bugAttribute(xml, "bug_status");
+ var reso = bugidHelper.bugAttribute(xml, "resolution");
+ if(reso)
+ tooltip.push(status + " " + reso);
+ else
+ tooltip.push(status);
+ }
+ if(bugidHelper.getBoolPref("tooltip.showcomp")) {
+ var prod = bugidHelper.bugAttribute(xml, "product");
+ var comp = bugidHelper.bugAttribute(xml, "component");
+ tooltip.push(prod + "/" + comp);
+ }
+ if(bugidHelper.getBoolPref("tooltip.showdate"))
+ tooltip.push(bugidHelper.toDate(bugidHelper.bugAttribute(xml, "creation_ts")));
+ if(bugidHelper.getBoolPref("tooltip.showassign"))
+ tooltip.push(bugidHelper.bugAttribute(xml, "assigned_to"));
+ if(bugidHelper.getBoolPref("tooltip.showdesc"))
+ tooltip.push(bugidHelper.bugAttribute(xml, "short_desc"));
+
+ if(bugidHelper.getBoolPref("link.strikethrough")) {
+ var reso = bugidHelper.bugAttribute(xml, "resolution");
+ if(bugidHelper.strikeResos.indexOf(reso) != -1)
+ element.style.textDecoration = "underline line-through";
+ }
+
+ /* set title attribute to tooltip text */
+ element.title = tooltip.join(" -- ");
+ });
+ },
+
+ setComment : function(element, url, cid) {
+ bugidHelper.xhr(url,
+ function(wasSuccess, xml) {
+ if(!bugidHelper) // this happens sometimes
+ return;
+ var showerror = bugidHelper.getBoolPref("tooltip.showerror");
+ if(!wasSuccess) {
+ if(showerror)
+ element.title = bugidHelper.strings.getFormattedString("invalidPage", [url]);
+ return;
+ }
+ var bug = xml.getElementsByTagName("bug");
+ if(bug && bug[0] && bug[0].hasAttribute("error")) {
+ var error = bug[0].getAttribute("error");
+ if(showerror)
+ element.title = bugidHelper.strings.getFormattedString("invalidId",
+ [bugidHelper.userUrl, error]);
+ return;
+ }
+ /* set title attribute to comment text */
+ var comment = xml.getElementsByTagName("long_desc")[cid];
+ if(comment) {
+ var text = bugidHelper.bugAttribute(comment, "thetext");
+ var tooltip = "";
+ if(bugidHelper.getBoolPref("tooltip.showcommenter"))
+ tooltip += bugidHelper.bugAttribute(comment, "who") + " -- ";
+ element.title = tooltip + text.substring(0, Math.min(text.length, 180)) + " ...";
+ }
+ });
+ },
+
+ /* Adapted from browser.js - Firefox. Adds full tooltip support to Thunderbird content */
+ fillTBirdTooltip : function(tipElement) {
+ var retVal = false;
+ if (tipElement.namespaceURI == "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul")
+ return retVal;
+ const XLinkNS = "http://www.w3.org/1999/xlink";
+ var titleText = null;
+ var XLinkTitleText = null;
+ var direction = tipElement.ownerDocument.dir;
+
+ while (!titleText && !XLinkTitleText && tipElement) {
+ if (tipElement.nodeType == Node.ELEMENT_NODE) {
+ titleText = tipElement.getAttribute("title");
+ XLinkTitleText = tipElement.getAttributeNS(XLinkNS, "title");
+ var defView = tipElement.ownerDocument.defaultView;
+ // Work around bug 350679: "Tooltips can be fired in documents with no view"
+ if (!defView)
+ return retVal;
+ direction = defView.getComputedStyle(tipElement, "")
+ .getPropertyValue("direction");
+ }
+ tipElement = tipElement.parentNode;
+ }
+
+ var tipNode = document.getElementById("bugidTooltip");
+ tipNode.style.direction = direction;
+
+ for each (var t in [titleText, XLinkTitleText]) {
+ if (t && /\S/.test(t)) {
+ // Per HTML 4.01 6.2 (CDATA section), literal CRs and tabs should be
+ // replaced with spaces, and LFs should be removed entirely
+ t = t.replace(/[\r\t]/g, ' ');
+ t = t.replace(/\n/g, '');
+
+ tipNode.setAttribute("label", t);
+ retVal = true;
+ }
+ }
+ return retVal;
+ },
+}
View
2  defaults/preferences/preferences.js
@@ -12,8 +12,6 @@ pref("extensions.bugid.tooltip.showcomp", false);
pref("extensions.bugid.tooltip.showerror", true);
pref("extensions.bugid.tooltip.showassign", false);
pref("extensions.bugid.tooltip.showcommenter", true);
-pref("extensions.bugid.filter", false);
-pref("extensions.bugid.whitelist", "mxr.mozilla.org, www.google.com");
View
6 install.rdf
@@ -4,7 +4,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>bugid@linkification.org</em:id>
<em:name>Bug Id Helper</em:name>
- <em:version>1.3.1</em:version>
+ <em:version>1.4</em:version>
<em:type>2</em:type>
<em:creator>Heather Arthur</em:creator>
<em:description>Bugzilla bug id linkifier</em:description>
@@ -16,7 +16,7 @@
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>3.0</em:minVersion>
- <em:maxVersion>3.6a1pre</em:maxVersion>
+ <em:maxVersion>3.7a3pre</em:maxVersion>
</Description>
</em:targetApplication>
@@ -25,7 +25,7 @@
<Description>
<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
<em:minVersion>2.0</em:minVersion>
- <em:maxVersion>3.1a1pre</em:maxVersion>
+ <em:maxVersion>3.2a1pre</em:maxVersion>
</Description>
</em:targetApplication>
Please sign in to comment.
Something went wrong with that request. Please try again.