Limit jQuery calls in ui.left_userlist_get_new_heights().

Calling $('#foo') is expensive, so if you need it twice, you
should store it in a variable.  I did this for stream_filters
and user_presences, and added the expectOne() call for them as
well.

(imported from commit 69e689e28b1248a93ef426a89c14033d2fb36104)
This commit is contained in:
Steve Howell 2013-12-06 11:00:14 -05:00
parent 2f6d722d9b
commit 6354b712fc
1 changed files with 8 additions and 5 deletions

View File

@ -419,8 +419,11 @@ function left_userlist_get_new_heights() {
var invite_user_link_height = $("#invite-user-link").outerHeight(true) || 0; var invite_user_link_height = $("#invite-user-link").outerHeight(true) || 0;
var share_the_love_height = $("#share-the-love").is(":visible") ? $("#share-the-love").outerHeight(true) : 0; var share_the_love_height = $("#share-the-love").is(":visible") ? $("#share-the-love").outerHeight(true) : 0;
var stream_filters_real_height = $("#stream_filters").prop("scrollHeight"); var stream_filters = $('#stream_filters').expectOne();
var user_list_real_height = $("#user_presences").prop("scrollHeight"); var user_presences = $('#user_presences').expectOne();
var stream_filters_real_height = stream_filters.prop("scrollHeight");
var user_list_real_height = user_presences.prop("scrollHeight");
res.bottom_whitespace_height = viewport_height * 0.4; res.bottom_whitespace_height = viewport_height * 0.4;
@ -435,9 +438,9 @@ function left_userlist_get_new_heights() {
- $("#global_filters").outerHeight(true) - $("#global_filters").outerHeight(true)
- $("#streams_header").outerHeight(true) - $("#streams_header").outerHeight(true)
- $("#userlist-header").outerHeight(true) - $("#userlist-header").outerHeight(true)
- parseInt($("#stream_filters").css("marginBottom"),10) - parseInt(stream_filters.css("marginBottom"),10)
- parseInt($("#user_presences").css("marginTop"), 10) - parseInt(user_presences.css("marginTop"), 10)
- parseInt($("#user_presences").css("marginBottom"), 10) - parseInt(user_presences.css("marginBottom"), 10)
- invite_user_link_height - invite_user_link_height
- share_the_love_height - share_the_love_height
- 15; - 15;