diff options
author | Matěj Cepl <mcepl@redhat.com> | 2010-07-15 12:31:43 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2010-07-15 12:31:43 +0200 |
commit | 4bc527b9fd39cecafc35d6ec35c833b5ba1ead9a (patch) | |
tree | d93bf2c2587096a1cf28aac1ec397bc09c7935f4 /lib/bzpage.js | |
parent | e2ce2de1e5900fadcc9c75c6f6b4a5c465eaa069 (diff) | |
download | bugzilla-triage-4bc527b9fd39cecafc35d6ec35c833b5ba1ead9a.tar.gz |
Make the script more robust against different HTML versions of the comment
box location.
- use getElementsByName("add_comment")[0].parentNode instead
- fix bzpage.prototype.changeAssignee Javadoc, which didn't make any sense
- remove superfluous TODOs
Fixes #17.
Diffstat (limited to 'lib/bzpage.js')
-rw-r--r-- | lib/bzpage.js | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js index 997ac5b..d9d679d 100644 --- a/lib/bzpage.js +++ b/lib/bzpage.js @@ -90,8 +90,11 @@ var BZPage = function BZPage(win, config) { this.CCList = this.getCCList(); // Prepare for query buttons - // TODO getting null for commentArea sometimes - var commentArea = this.doc.getElementById("comment_status_commit"); + // element ID brElementPlace_location is later used in JSON files + // Stay with this add_comment element even if RH BZ upgrades, this seems + // to be generally much more stable (even with other bugzillas, e.g. b.gnome.org) + // then some getElementById. + var commentArea = this.doc.getElementsByName("add_comment")[0].parentNode; if (commentArea) { var brElementPlacer = commentArea.getElementsByTagName("br"); brElementPlacer = brElementPlacer[0]; @@ -265,14 +268,19 @@ BZPage.prototype.executeCommand = function executeCommand (cmd) { }; /** - * Add XGL to the CC list + * Change assignee of the bug * - * @param evt Event which made this function active + * @param newAssignee String with the email address of new assigneeAElement + * or 'default' if the component's default assignee should be used. + * Value null clears "Reset Assignee to default for component" checkbox * @return none */ BZPage.prototype.changeAssignee = function changeAssignee (newAssignee) { var defAssigneeButton = null; + // Previous assignee should know what's going on in his bug this.addToCCList(this.owner); + + // Optional value null if (newAssignee === null) { this.doc.getElementById("set_default_assignee").removeAttribute( "checked"); @@ -502,12 +510,17 @@ BZPage.prototype.collectComments = function collectComments () { * @return none * */ -BZPage.prototype.selectOption = function selectOption (id, label) { +BZPage.prototype.selectOption = function selectOption (id, label, fireEvent) { + if (fireEvent === null) { + fireEvent = true; + } var sel = this.doc.getElementById(id); sel.value = label; - var intEvent = this.doc.createEvent("HTMLEvents"); - intEvent.initEvent("change", true, true); - sel.dispatchEvent(intEvent); + if (fireEvent) { + var intEvent = this.doc.createEvent("HTMLEvents"); + intEvent.initEvent("change", true, true); + sel.dispatchEvent(intEvent); + } }; /** @@ -693,9 +706,6 @@ BZPage.prototype.setUpLogging = function setUpLogging () { var that = this; // logging all submits for timesheet - // TODO we should merge in functionality of RHBugzillaPage.submitCallback - // and actually make it working - // Maybe rewriting whole offline capability into a separate object? if (!this.submitHandlerInstalled) { console.log("Installing submit callback!"); this.doc.forms.namedItem("changeform").addEventListener("submit",function (evt) { |