mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
Clean up select_zephyr
Eliminate some global variables, and other style fixes. (imported from commit 95dfbaa024d709f5b98238afcf904f3e92c8a260)
This commit is contained in:
@@ -87,19 +87,23 @@ selected_tag = '<p id="selected">▶</p>'
|
||||
var allow_hotkeys = true;
|
||||
|
||||
function select_zephyr(next_zephyr) {
|
||||
p = $("#selected");
|
||||
td = $(p).closest("td");
|
||||
if (next_zephyr.length != 0) { // We are not at the bottom or top of the zephyrs.
|
||||
td.empty(); // Clear the previous arrow.
|
||||
if (next_zephyr.length == 0) {
|
||||
// No match, e.g. bottom or top of page
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear the previous arrow.
|
||||
$("#selected").closest("td").empty();
|
||||
|
||||
next_zephyr.children("td:first").html(selected_tag);
|
||||
$.post("update", {pointer: next_zephyr.attr("id")});
|
||||
|
||||
if (($(next_zephyr).offset().top < $("#main_div").offset().top) ||
|
||||
($(next_zephyr).offset().top + $(next_zephyr).height() > $("#main_div").offset().top + $("#main_div").height())) {
|
||||
($(next_zephyr).offset().top + $(next_zephyr).height() >
|
||||
$("#main_div").offset().top + $("#main_div").height())) {
|
||||
scroll_to_selected();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NB: This just binds to current elements, and won't bind to elements
|
||||
// created after ready() is called.
|
||||
|
||||
Reference in New Issue
Block a user