summaryrefslogtreecommitdiffstats
path: root/extensions/TrackingFlags/web
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2014-08-12 07:44:08 +0200
committerByron Jones <glob@mozilla.com>2014-08-12 07:44:08 +0200
commit2957d625cc4390d99154fa37fb2158b597cdaec4 (patch)
tree7bdaafa4e809f4a1116b0e69a44a006654200d96 /extensions/TrackingFlags/web
parentcf5c16469d47bbf265191ac6e3996a068b0703fe (diff)
downloadbugzilla-2957d625cc4390d99154fa37fb2158b597cdaec4.tar.gz
bugzilla-2957d625cc4390d99154fa37fb2158b597cdaec4.tar.xz
Bug 1041964: Autofocus on the comment textarea when selecting a value which has an auto-comment configured
Diffstat (limited to 'extensions/TrackingFlags/web')
-rw-r--r--extensions/TrackingFlags/web/js/tracking_flags.js32
1 files changed, 28 insertions, 4 deletions
diff --git a/extensions/TrackingFlags/web/js/tracking_flags.js b/extensions/TrackingFlags/web/js/tracking_flags.js
index 17513ffe4..041ae43f5 100644
--- a/extensions/TrackingFlags/web/js/tracking_flags.js
+++ b/extensions/TrackingFlags/web/js/tracking_flags.js
@@ -42,11 +42,35 @@ function show_tracking_flags(flag_type) {
function tracking_flag_change(e) {
var value = e.value;
- if (!TrackingFlags.comments[e.name])
- return;
- var prefill = TrackingFlags.comments[e.name][e.value];
- if (!prefill)
+ var prefill;
+ if (TrackingFlags.comments[e.name])
+ prefill = TrackingFlags.comments[e.name][e.value];
+ if (!prefill) {
+ var cr = document.getElementById('cr_' + e.id);
+ if (cr)
+ cr.parentElement.removeChild(cr);
return;
+ }
+ if (!document.getElementById('cr_' + e.id)) {
+ // create "comment required"
+ var span = document.createElement('span');
+ span.id = 'cr_' + e.id;
+ span.appendChild(document.createTextNode('('));
+ var a = document.createElement('a');
+ a.appendChild(document.createTextNode('comment required'));
+ a.href = '#';
+ a.onclick = function() {
+ var c = document.getElementById('comment');
+ c.focus();
+ c.select();
+ document.getElementById('add_comment').scrollIntoView();
+ return false;
+ };
+ span.appendChild(a);
+ span.appendChild(document.createTextNode(')'));
+ e.parentNode.appendChild(span);
+ }
+ // prefill comment
var commentEl = document.getElementById('comment');
if (!commentEl)
return;