VRFS-274 hide friends panel when showing search results

This commit is contained in:
Brian Smith 2013-03-09 23:28:21 -05:00
parent c40460e3fb
commit 8751572596
1 changed files with 28 additions and 2 deletions

View File

@ -65,7 +65,6 @@
error: app.ajaxError
});
hidePanels();
return false;
}
@ -122,7 +121,9 @@
$('div[layout=sidebar] div[user-id=' + val.id + ']').find('#btn-connect-friend').click(sendFriendRequest);
$('#sidebar-search-header').show();
hidePanels();
});
$('#sidebar-search-results').height(getHeight() + 'px');
},
error: app.ajaxError
});
@ -130,11 +131,34 @@
}
function hidePanels() {
//$('[layout-panel="expanded"]').hide();
$('[layout-panel="contents"]').hide();
$('[layout-panel="contents"]').css({"height": "1px"});
}
function getHeight() {
// TODO: refactor this - copied from layout.js
var sidebarHeight = $(context).height() - 75 - 2 * 60 + $('[layout-sidebar-expander]').height();
var combinedHeaderHeight = $('[layout-panel="contents"]').length * 36;
var searchHeight = $('.sidebar .search').first().height();
var expanderHeight = $('[layout-sidebar-expander]').height();
var expandedPanelHeight = sidebarHeight - (combinedHeaderHeight + expanderHeight + searchHeight);
return expandedPanelHeight;
}
function showFriendsPanel() {
var $expandedPanelContents = $('[layout-id="panelFriends"] [layout-panel="contents"]');
var expandedPanelHeight = getHeight();
// hide all other contents
$('[layout-panel="contents"]').hide();
$('[layout-panel="contents"]').css({"height": "1px"});
// show the appropriate contens
$expandedPanelContents.show();
$expandedPanelContents.animate({"height": expandedPanelHeight + "px"}, 400);
}
// TODO: same code is in searchResults.js - REFACTOR
function sendFriendRequest(evt) {
evt.stopPropagation();
@ -161,10 +185,12 @@
emptySearchResults();
$('#search-input').val('');
$('#sidebar-search-header').hide();
showFriendsPanel();
}
function emptySearchResults() {
$('#sidebar-search-results').empty();
$('#sidebar-search-results').height('0px');
}
// TODO