Change signature of ui.process_condensing().

I renamed ui.process_condensing() to ui.condense_and_collapse(),
and, more importantly, it now takes a list of elements, not a single
element, which allows us to do some computations outside the loop.

(imported from commit d5984088030c2a0d4ec8b258c7fcec3e84caf2b1)
This commit is contained in:
Steve Howell
2013-12-04 16:02:34 -05:00
parent 983f29eac4
commit f923c15ba8
3 changed files with 31 additions and 29 deletions

View File

@@ -401,7 +401,7 @@ MessageListView.prototype = {
// Must happen after the elements are inserted into the document for // Must happen after the elements are inserted into the document for
// getBoundingClientRect to work. // getBoundingClientRect to work.
_.each(rendered_elems, ui.process_condensing); ui.condense_and_collapse(rendered_elems);
// Must happen after anything that changes the height of messages has // Must happen after anything that changes the height of messages has
// taken effect. // taken effect.

View File

@@ -249,7 +249,7 @@ exports.activate = function (operators, opts) {
// above us could change size -- which is problematic, because it // above us could change size -- which is problematic, because it
// could cause us to lose our position. But doing this here, right // could cause us to lose our position. But doing this here, right
// after showing the table, seems to cause us to win the race. // after showing the table, seems to cause us to win the race.
_.each($("tr.message_row"), ui.process_condensing); ui.condense_and_collapse($("tr.message_row"));
reset_load_more_status(); reset_load_more_status();
if (! defer_selecting_closest) { if (! defer_selecting_closest) {

View File

@@ -1705,13 +1705,14 @@ exports.restore_compose_cursor = function () {
.caret(saved_compose_cursor, saved_compose_cursor); .caret(saved_compose_cursor, saved_compose_cursor);
}; };
exports.process_condensing = function (elem) { exports.condense_and_collapse = function (elems) {
var height_cutoff = viewport.height() * 0.65; var height_cutoff = viewport.height() * 0.65;
function could_be_condensed(elem) { function could_be_condensed(elem) {
return elem.getBoundingClientRect().height > height_cutoff; return elem.getBoundingClientRect().height > height_cutoff;
} }
_.each(elems, function (elem) {
var content = $(elem).find(".message_content"); var content = $(elem).find(".message_content");
var message = current_msg_list.get(rows.id($(elem))); var message = current_msg_list.get(rows.id($(elem)));
if (content !== undefined && message !== undefined) { if (content !== undefined && message !== undefined) {
@@ -1741,6 +1742,7 @@ exports.process_condensing = function (elem) {
$(elem).find(".message_expander").show(); $(elem).find(".message_expander").show();
} }
} }
});
}; };
$(function () { $(function () {