Files
zulip/zephyr/static/js/dom_access.js
Waseem Daher cada47a981 Slight speedup in get_next_visible/get_prev_visible.
http://api.jquery.com/first-selector/ mentions that using ":first" in
query selectors can be a little slow since we can't use the browser's
native querySelectorForAll implementation.

In my tests, this cut the average time down from 6.70ms to 6.38ms.
So, not great, but this function is most frequently called
many times in a big while loop, so, better than nothing.

(imported from commit d7725edd0c81431829fe353c6dd2bc61b1de6b19)
2012-10-16 17:06:36 -04:00

30 lines
749 B
JavaScript

function get_next_visible(message_row) {
if (message_row === undefined)
return [];
return message_row.nextAll('.message_row').filter(':first');
}
function get_prev_visible(message_row) {
if (message_row === undefined)
return [];
return message_row.prevAll('.message_row').filter(':first');
}
function get_first_visible() {
return $('.focused_table .message_row:first');
}
function get_last_visible() {
return $('.focused_table .message_row:last');
}
function get_id(message_row) {
return message_row.attr('zid');
}
function get_message_row(message_id, table_name) {
if (table_name === undefined)
table_name = (narrowed ? 'zfilt' : 'zhome');
return $('#' + table_name + message_id);
}