make per-game chats resize with the window like global chat.

This commit is contained in:
Andy Janata 2013-02-23 14:32:00 -08:00
parent d110b59b9c
commit b74aed03c1
1 changed files with 23 additions and 8 deletions

View File

@ -103,13 +103,13 @@ function chat_keyup(e) {
}
/**
* Generate a click handler for the chat submit button. This parses the line
* for any /-commands, then sends the request to the server.
*
* Generate a click handler for the chat submit button. This parses the line for any /-commands,
* then sends the request to the server.
*
* @param {number}
* Game ID to use in AJAX requests, or null for global chat
* game_id Game ID to use in AJAX requests, or null for global chat
* @param {jQuery.HTMLDivElement}
* Parent element, which contains one text-input-box element of class
* parent_element Parent element, which contains one text-input-box element of class
* "chat", which will be used to source the data.
*/
function chatsubmit_click(game_id, parent_element) {
@ -236,13 +236,20 @@ function app_resize() {
var chatWidth = $("#canvas").width() - 257;
$("#tabs").width(chatWidth + 'px');
log.width((chatWidth + 2) + 'px');
chat.width((chatWidth - 42) + 'px');
var bottomHeight = $(window).height() - $("#main").height() - $("#menubar").height() - 29;
$("#bottom").height(bottomHeight);
$("#info_area").height(bottomHeight);
$("#tabs").height(bottomHeight);
log.height(bottomHeight - chat.height() - 40);
// global chat
do_app_resize(chat, log);
// per-game chats
for ( var id in cah.currentGames) {
chat = $(".chat", $("#tab-chat-game_" + id));
log = $(".log", $("#tab-chat-game_" + id));
do_app_resize(chat, log);
}
// this is ugly and terrible.
if ($(window).height() < 650) {
$("body").css("overflow-y", "auto");
@ -250,3 +257,11 @@ function app_resize() {
$("body").css("overflow-y", "hidden");
}
}
function do_app_resize(chatElement, logElement) {
var chatWidth = $("#canvas").width() - 257;
logElement.width((chatWidth + 2) + 'px');
chatElement.width((chatWidth - 42) + 'px');
var bottomHeight = $(window).height() - $("#main").height() - $("#menubar").height() - 29;
logElement.height(bottomHeight - chatElement.height() - 40);
}