diff options
Diffstat (limited to 'extensions/BMO/web')
-rw-r--r-- | extensions/BMO/web/js/attachment_bounty_form.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/extensions/BMO/web/js/attachment_bounty_form.js b/extensions/BMO/web/js/attachment_bounty_form.js index cdec78276..59ffe8479 100644 --- a/extensions/BMO/web/js/attachment_bounty_form.js +++ b/extensions/BMO/web/js/attachment_bounty_form.js @@ -8,11 +8,27 @@ function add_bounty_attachment(bug_id) { var nodes = YAHOO.util.Selector.query('#attachment_table tr.bz_attach_footer td'); if (nodes) { + var existing = document.getElementById('bounty_attachment'); var td = nodes[0]; var a = document.createElement('a'); a.href = 'page.cgi?id=attachment_bounty_form.html&bug_id=' + bug_id; - a.appendChild(document.createTextNode('Add bounty tracking attachment')); + a.appendChild(document.createTextNode(existing + ? 'Edit bounty tracking attachment' + : 'Add bounty tracking attachment')); td.appendChild(document.createElement('br')); td.appendChild(a); + + if (existing) { + var tr = existing.parentNode.parentNode; + if (tr.nodeName != 'TR') + return; + nodes = tr.getElementsByTagName('a'); + for (var i = 0, il = nodes.length; i < il; i++) { + if (nodes[i].href.match(/attachment\.cgi\?id=\d+$/)) { + nodes[i].href = a.href; + return; + } + } + } } } |