Combine the actions popover with the timeinfo popover

The message timestamp is now always clickable, and the popover contains the
full long-form date and time.  This addresses one problem from usability
testing (see #470).

(imported from commit ad502dff128ad1c934fc0d3faaf5e2931c91c37e)
This commit is contained in:
Keegan McAllister
2013-02-08 21:29:40 -05:00
parent 520d7b1f97
commit 16d62fe5de
9 changed files with 55 additions and 41 deletions

View File

@@ -30,9 +30,6 @@
<script id="template_actions_popover_content" type="text/x-handlebars-template"> <script id="template_actions_popover_content" type="text/x-handlebars-template">
{% rawjstemplate "actions_popover_content" %} {% rawjstemplate "actions_popover_content" %}
</script> </script>
<script id="template_timeinfo_popover_content" type="text/x-handlebars-template">
{% rawjstemplate "timeinfo_popover_content" %}
</script>
{% compressed_css 'app' %} {% compressed_css 'app' %}
<link rel="stylesheet" href="/static/third/spectrum/spectrum.css" /> <link rel="stylesheet" href="/static/third/spectrum/spectrum.css" />

View File

@@ -1,14 +1,28 @@
{{! Contents of the "message actions" popup }} {{! Contents of the "message actions" popup }}
<ul class="nav nav-list actions_popover"> <ul class="nav nav-list actions_popover">
<div class="popover_info">
<li>{{message.full_date_str}}</li>
<li>{{message.full_time_str}}</li>
<hr />
</div>
{{#if narrowed}}
<li> <li>
<a onclick="respond_to_message();"> <a onclick="ui.hide_actions_popover(); narrow.target({{message.id}}); narrow.activate([]);">
<i class="icon-share-alt"></i> Reply to this {{#if is_stream}}stream{{else}}private message{{/if}} <i class="icon-time"></i> Narrow to messages around this time
</a> </a>
</li> </li>
{{#unless is_private}} {{/if}}
<li>
<a onclick="respond_to_message();">
<i class="icon-share-alt"></i>
Reply to this {{#if message.is_stream}}stream{{else}}private message{{/if}}
</a>
</li>
{{#unless message.is_private}}
<li> <li>
<a onclick="respond_to_message('personal');"> <a onclick="respond_to_message('personal');">
<i class="icon-user"></i> Reply to {{sender_full_name}} only <i class="icon-user"></i> Reply to {{message.sender_full_name}} only
</a> </a>
</li> </li>
{{/unless}} {{/unless}}

View File

@@ -1,3 +1,8 @@
{{! Title of the "message actions" popup }} {{! Title of the "message actions" popup }}
<span title="{{sender_full_name}}"><b>{{sender_full_name}}</b></span><br /> <span title="{{message.sender_full_name}}">
<span class='my_email' title="{{sender_email}}">{{sender_email}}</span> <b>{{message.sender_full_name}}</b>
</span><br />
<span class='my_email' title="{{message.sender_email}}">
{{message.sender_email}}
</span>

View File

@@ -60,8 +60,7 @@
<span class="sender_email invisible">{{sender_email}}</span> <span class="sender_email invisible">{{sender_email}}</span>
</span> </span>
{{/include_sender}} {{/include_sender}}
<span class="message_time actions_hover" <span class="message_time actions_hover">{{{timestr}}}</span>
title="{{full_date_str}}">{{{timestr}}}</span>
<div class="message_content">{{{content}}}</div> <div class="message_content">{{{content}}}</div>
</td> </td>
</tr> </tr>

View File

@@ -1,8 +0,0 @@
{{! Client-side Mustache template for the contents of the little "timeinfo" popup that shows up when you click on a time }}
<ul class="nav nav-list actions_popover">
<li>
<a onclick="ui.hide_actions_popover(); narrow.target({{id}}); narrow.activate([]);">
<i class="icon-time"></i> Narrow to messages around this time
</a>
</li>
</ul>

View File

@@ -13,7 +13,7 @@ $(function () {
// Compile Handlebars templates. // Compile Handlebars templates.
$.each(['message', 'subscription', $.each(['message', 'subscription',
'actions_popover_title', 'actions_popover_content', 'actions_popover_title', 'actions_popover_content',
'timeinfo_popover_content', 'invite_subscription', 'new_stream_users'], 'invite_subscription', 'new_stream_users'],
function (index, name) { function (index, name) {
templates[name] = Handlebars.compile($('#template_'+name).html()); templates[name] = Handlebars.compile($('#template_'+name).html());
} }

View File

@@ -387,24 +387,16 @@ function show_actions_popover(element, id) {
select_message_by_id(id); select_message_by_id(id);
var elt = $(element); var elt = $(element);
if (elt.data('popover') === undefined) { if (elt.data('popover') === undefined) {
var content, message = message_dict[id]; var args = {
if (elt.hasClass("message_sender") || elt.hasClass("profile_picture")) { message: message_dict[id],
elt.popover({placement: "bottom", narrowed: narrow.active()
title: templates.actions_popover_title(message), };
content: templates.actions_popover_content(message), elt.popover({
trigger: "manual" placement: "bottom",
}); title: templates.actions_popover_title(args),
} else if (elt.hasClass("message_time")) { content: templates.actions_popover_content(args),
if (!narrow.active()) { trigger: "manual"
// Only show the time-travel popover when narrowed });
return;
}
// Bootstrap takes the title from the 'title' attribute of elt
elt.popover({placement: "bottom",
content: templates.timeinfo_popover_content(message),
trigger: "manual"
});
}
elt.popover("show"); elt.popover("show");
current_actions_popover_elem = elt; current_actions_popover_elem = elt;
} }

View File

@@ -272,9 +272,15 @@ function add_display_time(message, prev) {
} else { } else {
message.timestr = time.toString("HH:mm"); message.timestr = time.toString("HH:mm");
} }
// Rather than using time.toLocaleString(), which varies by
// browser, just do our own hardcoded formatting. // Convert to number of hours ahead/behind UTC.
message.full_date_str = time.toDateString() + " " + time.toTimeString(); // The sign of getTimezoneOffset() is reversed wrt
// the conventional meaning of UTC+n / UTC-n
var tz_offset = -time.getTimezoneOffset() / 60;
message.full_date_str = time.toLocaleDateString();
message.full_time_str = time.toLocaleTimeString() +
' (UTC' + ((tz_offset < 0) ? '' : '+') + tz_offset + ')';
} }
function add_to_table(messages, table_name, filter_function, where, allow_collapse) { function add_to_table(messages, table_name, filter_function, where, allow_collapse) {

View File

@@ -648,6 +648,15 @@ table.floating_recipient {
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.popover_info {
text-align: center;
}
.popover hr {
margin-top: 5px;
margin-bottom: 5px;
}
.hotkeys_table { .hotkeys_table {
float: left; float: left;
width: 250px; width: 250px;