Advance focus to the next input field after autocompleting class or instance.

(imported from commit 068009946f0581834e268f1ed3d5e7e6a940fcde)
This commit is contained in:
Jessica McKellar 2012-10-09 11:41:34 -04:00
parent 1fc80f40ff
commit 6050a0a251
2 changed files with 12 additions and 2 deletions

View File

@ -39,10 +39,10 @@
</tr> </tr>
<tr id="class-message"> <tr id="class-message">
<td colspan="2" class="zephyr_newstyle_class"> <td colspan="2" class="zephyr_newstyle_class">
<input type="text" class="zephyr_recipient_box" name="class" id="class" value="" placeholder="Stream" autocomplete="off"/> <input type="text" class="zephyr_recipient_box" name="class" id="class" onchange="focus_on('instance')" value="" placeholder="Stream" autocomplete="off"/>
</td> </td>
<td class="zephyr_newstyle_instance"> <td class="zephyr_newstyle_instance">
<input type="text" class="zephyr_recipient_box" name="instance" id="instance" value="" placeholder="Topic" autocomplete="off"/> <input type="text" class="zephyr_recipient_box" name="instance" id="instance" onchange="focus_on('new_zephyr')" value="" placeholder="Topic" autocomplete="off"/>
</td> </td>
</tr> </tr>
<tr id="personal-message"> <tr id="personal-message">

View File

@ -16,6 +16,16 @@ function register_onclick(zephyr_row, zephyr_id) {
}); });
} }
function focus_on(field_id) {
// Call after autocompleting on a field, to advance the focus to
// the next input field.
// Bootstrap's typeahead does not expose a callback for when an
// autocomplete selection has been made, so we have to do this
// manually.
$("#" + field_id).focus();
}
/* We use 'visibility' rather than 'display' and jQuery's show() / hide(), /* We use 'visibility' rather than 'display' and jQuery's show() / hide(),
because we want to reserve space for the email address. This avoids because we want to reserve space for the email address. This avoids
things jumping around slightly when the email address is shown. */ things jumping around slightly when the email address is shown. */