From 3d06fbf763188cd3a250236acabd888b922331c5 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 8 Oct 2018 11:03:06 -0700 Subject: [PATCH] web: fix layout problem with forum tables Forum messages are shown in a table: left column is sender info, right column is the message. The left column was fixed width (10em). On very hi-res monitors people increase their font size. This causes the "Send message" button to overflow the column. Solution: don't use fixed width, and make the right column 100% width. This makes the left column wide enough for its contents to fit, but no wider. This solves the problem, but introduces a (minor) new one: some users have extremely long user names, and this makes the left column too wide, not just for that post but for the whole thread. Solution: in this particular place, if name is > 30 chars, show only the first 30 chars followed by ellipsis. --- html/inc/forum.inc | 10 ++++------ html/inc/user.inc | 9 +++++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/html/inc/forum.inc b/html/inc/forum.inc index a5121a550f..8e1e35cb8d 100644 --- a/html/inc/forum.inc +++ b/html/inc/forum.inc @@ -220,17 +220,15 @@ function show_team_forum_title($forum, $thread=null, $link_thread=false) { echo ""; } -// start a table containing messages, where the layout is fixed -// (to accommodate long [pre] lines) -// and the left column (author info) has fixed size +// start a table of forum posts // function start_forum_table($headings) { $a = array(); foreach ($headings as $h) { $a[] = null; } - $a[0] = 'style="width: 10em;"'; - start_table('table-striped', 'table-layout:fixed'); + $a[1] = 'style="width: 100%"'; + start_table('table-striped'); row_heading_array($headings, $a); } @@ -588,7 +586,7 @@ function show_post( id\"> "; - echo user_links($user, 0); + echo user_links($user, 0, 30); echo "
"; if ($user->create_time > time()-ST_NEW_TIME) $fstatus.=ST_NEW."
"; echo ""; diff --git a/html/inc/user.inc b/html/inc/user.inc index 72533aa65e..98829f4d0c 100644 --- a/html/inc/user.inc +++ b/html/inc/user.inc @@ -326,8 +326,9 @@ function friend_links($user) { // show user name, with links to profile if present. // if $badge_height is > 0, show badges +// if $name_limit, limit name to N chars // -function user_links($user, $badge_height=0) { +function user_links($user, $badge_height=0, $name_limit=0) { BoincForumPrefs::lookup($user); if (is_banished($user)) { return "(banished: ID $user->id)"; @@ -337,7 +338,11 @@ function user_links($user, $badge_height=0) { $img_url = url_base()."img/head_20.png"; $x .= ' Profile'; } - $x .= " id."\">".$user->name.""; + $name = $user->name; + if ($name_limit && strlen($name) > $name_limit) { + $name = substr($name, 0, $name_limit)."..."; + } + $x .= " id."\">".$name.""; if (function_exists("project_user_links")){ $x .= project_user_links($user); }