Allow copying and pasting from zephyrs without triggering a compose.

(imported from commit f98a14155904dda11d85ed81acee783494377e4d)
This commit is contained in:
Jessica McKellar
2012-09-26 17:37:21 -04:00
parent 1616782f8a
commit 1adb10d1ae
3 changed files with 54 additions and 2 deletions

View File

@@ -32,7 +32,7 @@
</td>
<td class="pointer"><p></p></td>
<td class="messagebox{{^include_sender}} prev_is_same_sender{{/include_sender}}{{^is_class}} personal-message{{/is_class}}"
onclick="select_zephyr_by_id({{id}}); respond_to_zephyr();">
onmousedown="zephyr_mousedown();" onmousemove="zephyr_mousemove();">
{{#include_sender}}
<span class="zephyr_label_clickable zephyr_sender"
onmouseover="show_email({{id}});"

View File

@@ -34,6 +34,12 @@ function process_hotkey(code) {
window_to_scroll = $(".active").find(".scrolling-tab");
}
if (num_pressed_keys() > 1) {
// If you are already holding down another key, none of these
// actions apply.
return false;
}
switch (code) {
case 33: // Page Up
window_to_scroll.scrollTop(window_to_scroll.scrollTop() - window_to_scroll.height());
@@ -96,6 +102,24 @@ function process_compose_hotkey(code) {
}
}
var pressed_keys = {};
function num_pressed_keys() {
var size = 0, key;
for (key in pressed_keys) {
if (pressed_keys.hasOwnProperty(key)) size++;
}
return size;
};
$(document).keydown(function (e) {
pressed_keys[e.which] = true;
});
$(document).keyup(function (e) {
pressed_keys = {};
});
/* The current handler function for keydown events.
It should return a new handler, or 'false' to
decline to handle the event. */

View File

@@ -31,6 +31,18 @@ function register_huddle_onclick(zephyr_row, sender) {
});
}
function register_onclick(zephyr_row, zephyr_id) {
zephyr_row.find(".messagebox").click(function (e) {
if (!(clicking && mouse_moved)) {
// Was a click (not a click-and-drag).
select_zephyr_by_id(zephyr_id);
respond_to_zephyr();
}
mouse_moved = false;
clicking = false;
});
}
var zephyr_array = [];
var zephyr_dict = {};
var instance_list = [];
@@ -427,6 +439,20 @@ function select_zephyr_by_id(zephyr_id) {
select_zephyr(get_zephyr_row(zephyr_id), false);
}
var clicking = false;
var mouse_moved = false;
function zephyr_mousedown() {
mouse_moved = false;
clicking = true;
}
function zephyr_mousemove() {
if (clicking) {
mouse_moved = true;
}
}
// Called on page load and when we [un]narrow.
// Forces a call to select_zephyr even if the id has not changed,
// because the visible table might have.
@@ -715,7 +741,9 @@ function add_to_table(zephyrs, table_name, filter_function) {
table.append(templates.zephyr({'zephyrs': zephyrs_to_render}));
$.each(zephyrs_to_render, function (index, zephyr) {
register_huddle_onclick(get_zephyr_row(zephyr.id), zephyr.sender_email);
var row = get_zephyr_row(zephyr.id);
register_huddle_onclick(row, zephyr.sender_email);
register_onclick(row, zephyr.id);
});
$.each(ids_where_next_is_same_sender, function (index, id) {