diff options
Diffstat (limited to 'extensions/TrackingFlags/web')
-rw-r--r-- | extensions/TrackingFlags/web/js/admin.js | 42 | ||||
-rw-r--r-- | extensions/TrackingFlags/web/js/tracking_flags.js | 85 | ||||
-rw-r--r-- | extensions/TrackingFlags/web/styles/admin.css | 4 |
3 files changed, 92 insertions, 39 deletions
diff --git a/extensions/TrackingFlags/web/js/admin.js b/extensions/TrackingFlags/web/js/admin.js index e3eb81714..58bdd294f 100644 --- a/extensions/TrackingFlags/web/js/admin.js +++ b/extensions/TrackingFlags/web/js/admin.js @@ -80,7 +80,7 @@ function update_flag_values() { for (var i = 0, l = flag_values.length; i < l; i++) { var value = flag_values[i]; - var row = tbl.insertRow(2 + i); + var row = tbl.insertRow(2 + (i * 2)); var cell; // value @@ -157,10 +157,31 @@ function update_flag_values() { ? '<span class="txt_icon"> - </span>' : '<a class="txt_icon" href="#" onclick="value_move_down(' + i + ');return false"> ∇ </a>' ); - if (value.value != '---') - html += '| <a href="#" onclick="remove_value(' + i + ');return false">Remove</a>'; - html += ']'; + if (value.value != '---') { + var lbl = value.comment == '' ? 'Set Comment' : 'Edit Comment'; + html += + '|<a href="#" onclick="remove_value(' + i + ');return false">Remove</a>' + + '|<a href="#" onclick="toggle_value_comment(this, ' + i + ');return false">' + lbl + '</a>' + + } + html += ' ]'; cell.innerHTML = html; + + row = tbl.insertRow(3 + (i * 2)); + row.className = 'bz_default_hidden'; + row.id = 'comment_row_' + i; + cell = row.insertCell(0); + cell = row.insertCell(1); + cell.colSpan = 3; + var ta = document.createElement('textarea'); + ta.className = 'value_comment'; + ta.id = 'value_comment_' + i; + ta.rows = 5; + ta.value = value.comment; + cell.appendChild(ta); + Event.addListener(ta, 'blur', function(e, idx) { + flag_values[idx].comment = e.target.value; + }, i); } tag_invalid_values(); @@ -229,6 +250,19 @@ function update_value(e, o) { flag_values[i].value = o.value; } +function toggle_value_comment(btn, idx) { + var row = Dom.get('comment_row_' + idx); + if (Dom.hasClass(row, 'bz_default_hidden')) { + Dom.removeClass(row, 'bz_default_hidden'); + btn.innerHTML = 'Hide Comment'; + Dom.get('value_comment_' + idx).select(); + Dom.get('value_comment_' + idx).focus(); + } else { + Dom.addClass(row, 'bz_default_hidden'); + btn.innerHTML = flag_values[idx].comment == '' ? 'Set Comment' : 'Edit Comment'; + } +} + // visibility function update_flag_visibility() { diff --git a/extensions/TrackingFlags/web/js/tracking_flags.js b/extensions/TrackingFlags/web/js/tracking_flags.js index 135b93dba..17513ffe4 100644 --- a/extensions/TrackingFlags/web/js/tracking_flags.js +++ b/extensions/TrackingFlags/web/js/tracking_flags.js @@ -8,49 +8,64 @@ var Dom = YAHOO.util.Dom; -var TrackingFlags = { - flags: {}, - types: [] -}; - function hide_tracking_flags() { - for (var i = 0, l = TrackingFlags.types.length; i < l; i++) { - var flag_type = TrackingFlags.types[i]; - for (var field in TrackingFlags.flags[flag_type]) { - var el = Dom.get(field); - var value = el ? el.value : TrackingFlags.flags[flag_type][field]; - if (el && (value != TrackingFlags.flags[flag_type][field])) { - show_tracking_flags(flag_type); - return; - } - if (value == '---') { - Dom.addClass('row_' + field, 'bz_default_hidden'); - } else { - Dom.addClass(field, 'bz_default_hidden'); - Dom.removeClass('ro_' + field, 'bz_default_hidden'); - } + for (var i = 0, l = TrackingFlags.types.length; i < l; i++) { + var flag_type = TrackingFlags.types[i]; + for (var field in TrackingFlags.flags[flag_type]) { + var el = Dom.get(field); + var value = el ? el.value : TrackingFlags.flags[flag_type][field]; + if (el && (value != TrackingFlags.flags[flag_type][field])) { + show_tracking_flags(flag_type); + return; + } + if (value == '---') { + Dom.addClass('row_' + field, 'bz_default_hidden'); + } else { + Dom.addClass(field, 'bz_default_hidden'); + Dom.removeClass('ro_' + field, 'bz_default_hidden'); + } + } } - } } function show_tracking_flags(flag_type) { - Dom.addClass('edit_' + flag_type + '_flags_action', 'bz_default_hidden'); - for (var field in TrackingFlags.flags[flag_type]) { - if (Dom.get(field).value == '---') { - Dom.removeClass('row_' + field, 'bz_default_hidden'); + Dom.addClass('edit_' + flag_type + '_flags_action', 'bz_default_hidden'); + for (var field in TrackingFlags.flags[flag_type]) { + if (Dom.get(field).value == '---') { + Dom.removeClass('row_' + field, 'bz_default_hidden'); + } else { + Dom.removeClass(field, 'bz_default_hidden'); + Dom.addClass('ro_' + field, 'bz_default_hidden'); + } + } +} + +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) + return; + var commentEl = document.getElementById('comment'); + if (!commentEl) + return; + var value = commentEl.value; + if (value == prefill) + return; + if (value == '') { + commentEl.value = prefill; } else { - Dom.removeClass(field, 'bz_default_hidden'); - Dom.addClass('ro_' + field, 'bz_default_hidden'); + commentEl.value = prefill + "\n\n" + value; } - } } YAHOO.util.Event.onDOMReady(function() { - var edit_tracking_links = Dom.getElementsByClassName('edit_tracking_flags_link'); - for (var i = 0, l = edit_tracking_links.length; i < l; i++) { - YAHOO.util.Event.addListener(edit_tracking_links[i], 'click', function(e) { - e.preventDefault(); - show_tracking_flags(this.name); - }); - } + var edit_tracking_links = Dom.getElementsByClassName('edit_tracking_flags_link'); + for (var i = 0, l = edit_tracking_links.length; i < l; i++) { + YAHOO.util.Event.addListener(edit_tracking_links[i], 'click', function(e) { + e.preventDefault(); + show_tracking_flags(this.name); + }); + } }); diff --git a/extensions/TrackingFlags/web/styles/admin.css b/extensions/TrackingFlags/web/styles/admin.css index 374409ce6..51c6ab966 100644 --- a/extensions/TrackingFlags/web/styles/admin.css +++ b/extensions/TrackingFlags/web/styles/admin.css @@ -87,6 +87,10 @@ width: 10em; } +.value_comment { + width: 100%; +} + .hidden { display: none; } |