diff options
author | Ehsan Akhgari <ehsan@mozilla.com> | 2011-04-26 14:26:19 -0400 |
---|---|---|
committer | Ehsan Akhgari <ehsan@mozilla.com> | 2011-04-26 14:26:19 -0400 |
commit | 13c41fbe43472928a91132bcdbf980fe94f7bfeb (patch) | |
tree | ef80e4962c8867e4a9cf4efdfcf32478c1cfc007 | |
parent | 549ae985949985315c3bf4dfaabb058571a40c8d (diff) | |
download | bugzilla-triage-13c41fbe43472928a91132bcdbf980fe94f7bfeb.tar.gz |
Correct the attachment linkification based on the changes in Bugzilla 4.0
-rw-r--r-- | data/js/bug-page-mod.js | 29 |
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 }; |