aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEhsan Akhgari <ehsan@mozilla.com>2011-04-26 14:26:19 -0400
committerMatěj Cepl <mcepl@redhat.com>2011-06-05 14:42:16 +0200
commit195a45e8a52a5663cc9678ae295a279712544f36 (patch)
treea39f55af6741ac1f4fe21290bd06cf55bfb61b8a
parent3a4f8dc7980ddd9a18a5bf87a4374ef57647d69f (diff)
downloadbugzilla-triage-195a45e8a52a5663cc9678ae295a279712544f36.tar.gz
Correct the attachment linkification based on the changes in Bugzilla 4.0
-rw-r--r--data/js/bug-page-mod.js29
1 files changed, 20 insertions, 9 deletions
diff --git a/data/js/bug-page-mod.js b/data/js/bug-page-mod.js
index 561dda8..596e2c7 100644
--- a/data/js/bug-page-mod.js
+++ b/data/js/bug-page-mod.js
@@ -630,11 +630,18 @@ AttachmentFlagHandlerCtor.prototype = {
if (!(attachmentID in this._interestingFlags)) {
this._interestingFlags[attachmentID] = [];
}
+ var text = "";
+ var previousText = "";
+ var previousEl = null;
for (var el = item[1].firstChild; el.nextSibling; el = el.nextSibling) {
- if (el.nodeType != el.TEXT_NODE)
- continue;
- var text = trimContent(el).replace('\u2011', '-', 'g');
- if (!text)
+ var thisText = trimContent(el).replace('\u2011', '-', 'g');
+ text += thisText;
+ if (this._reParsePartToLinkify.test(thisText)) {
+ previousText = thisText;
+ previousEl = el;
+ }
+ if (el.nodeType != el.ELEMENT_NODE ||
+ el.localName.toLowerCase() != "br")
continue;
match = this._reParseInterestingFlag.exec(text);
if (match) {
@@ -666,22 +673,25 @@ AttachmentFlagHandlerCtor.prototype = {
// try to put the flag name and type part in a span which we will
// use in setupLinks to inject links into.
- match = this._reLinkifyInterestingFlag.exec(text);
+ match = this._reLinkifyInterestingFlag.exec(previousText);
if (match) {
- el.textContent = match[1];
+ previousEl.textContent = match[1];
if (match[3]) {
var textNode = doc.createTextNode(match[3]);
- el.parentNode.insertBefore(textNode, el.nextSibling);
+ previousEl.parentNode.insertBefore(textNode, previousEl.nextSibling);
}
var span = doc.createElement("span");
span.textContent = match[2];
- el.parentNode.insertBefore(span, el.nextSibling);
+ previousEl.parentNode.insertBefore(span, previousEl.nextSibling);
flag.placeholder = span;
}
this._interestingFlags[attachmentID].push(new AttachmentFlag(flag));
}
+ text = "";
+ previousText = "";
+ previousEl = null;
}
}
}
@@ -756,8 +766,9 @@ AttachmentFlagHandlerCtor.prototype = {
return "attachflag" + this._counter;
},
_reParseRequest: /^(.+)([\?\-\+])(\((.+)@.+\))?$/,
+ _reParsePartToLinkify: /^\s*:\s+.+[\-\+\?](\s*\()?\s*$/,
_reParseInterestingFlag: /^(.+):\s+(.+)(([\-\+])|\?(\s+(\((.+)\)))?)$/,
- _reLinkifyInterestingFlag: /^(.+:\s+)(.+[\-\+\?])(\s+\(.+\))?$/,
+ _reLinkifyInterestingFlag: /^(\s*:\s+)(.+[\-\+\?])(\s*\(\s*)?$/,
_reAttachmentHref: /attachment\.cgi\?id=(\d+)$/i,
_reAttachmentFlagName: /^Attachment\s+#(\d+)\s+Flags$/i
};