diff options
author | Byron Jones <glob@mozilla.com> | 2014-08-12 07:44:08 +0200 |
---|---|---|
committer | Byron Jones <glob@mozilla.com> | 2014-08-12 07:44:08 +0200 |
commit | 2957d625cc4390d99154fa37fb2158b597cdaec4 (patch) | |
tree | 7bdaafa4e809f4a1116b0e69a44a006654200d96 /extensions/TrackingFlags/web/js | |
parent | cf5c16469d47bbf265191ac6e3996a068b0703fe (diff) | |
download | bugzilla-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/js')
-rw-r--r-- | extensions/TrackingFlags/web/js/tracking_flags.js | 32 |
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; |