aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bzpage.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-07-25 22:29:24 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-07-25 22:32:04 +0200
commit9ab5c9dbd495d3bd0b9bec88f8a5db7213fc30c7 (patch)
tree0caaf8f57271d829e89d4db5cf03c51043bbe686 /lib/bzpage.js
parent9f1bc2cfff3bfd7050c7dfd1c02954347923f643 (diff)
downloadbugzilla-triage-9ab5c9dbd495d3bd0b9bec88f8a5db7213fc30c7.tar.gz
Fix RHBugzillaPage.addClosingUpstream and BZPage.selectOptionByLabel method
Fixes #32
Diffstat (limited to 'lib/bzpage.js')
-rw-r--r--lib/bzpage.js25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js
index e315922..e8f11aa 100644
--- a/lib/bzpage.js
+++ b/lib/bzpage.js
@@ -9,7 +9,9 @@ var selfMod = require("self");
var fileMod = require("file");
var simpleStorage = require("simple-storage");
var preferences = require("preferences-service");
+var selection = require("selection");
var prompts = require("prompts");
+var tabs = require("tabs");
var Color = require("color").Color;
var bugURL = "https://bugzilla.redhat.com/show_bug.cgi?id=";
@@ -557,7 +559,7 @@ BZPage.prototype.collectComments = function collectComments () {
/**
- * Select option with given label on the <SELECT> element with given id.
+ * Select option with given value on the <SELECT> element with given id.
*
* Also execute change HTMLEvent, so that the form behaves accordingly.
*
@@ -579,6 +581,27 @@ BZPage.prototype.selectOption = function selectOption (id, label, fireEvent) {
}
};
+BZPage.prototype.selectOptionByLabel = function selectOptionByLabel(id, label, fireEvent) {
+ if (!fireEvent) {
+ fireEvent = true;
+ }
+ var sel = this.doc.getElementById(id);
+ var labelRE = new RegExp(label.trim());
+ var ourOption = Array.filter(sel.options, function (op) {
+ return op.textContent.trim() == label;
+ }, this);
+
+ if (ourOption[0]) {
+ sel.value = ourOption[0].value;
+ }
+
+ if (fireEvent) {
+ var intEvent = this.doc.createEvent("HTMLEvents");
+ intEvent.initEvent("change", true, true);
+ sel.dispatchEvent(intEvent);
+ }
+};
+
/**
* Send mouse click to the specified element
*