Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 1 | [# Display a <select> widget with options to set/append/remove/clear the field. |
| 2 | Args: |
| 3 | arg0: element ID of widget to disable if Clear is selected. The form name and ID |
| 4 | of the <select> will be "op_" + arg0. |
| 5 | arg1: "multi" for multi-valued fields so that "Append" and "Remove" are offered. |
| 6 | ] |
| 7 | <select name="op_[arg0]" id="op_[arg0]" style="width:9em" tabindex="-1"> |
| 8 | [is arg1 "multi"] |
| 9 | <option value="append" selected="selected">Append +=</option> |
| 10 | <option value="remove">Remove -=</option> |
| 11 | [# TODO(jrobbins): <option value="setexact">Set exactly :=</option>] |
| 12 | [else] |
| 13 | <option value="set" selected="selected">Set =</option> |
| 14 | <option value="clear">Clear</option> |
| 15 | [end] |
| 16 | </select> |
| 17 | |
| 18 | [is arg1 "multi"][else] |
| 19 | <script type="text/javascript" nonce="[nonce]"> |
| 20 | |
| 21 | runOnLoad(function() { |
| 22 | if ($("op_[arg0]")) { |
| 23 | $("op_[arg0]").addEventListener("change", function(event) { |
| 24 | TKR_ignoreWidgetIfOpIsClear(event.target, '[arg0]'); |
| 25 | }); |
| 26 | } |
| 27 | }); |
| 28 | </script> |
| 29 | [end] |