From 14ceb7e8888a0ac7528ae0fc3ae910080beb8e1a Mon Sep 17 00:00:00 2001 From: Jessica McKellar Date: Tue, 25 Sep 2012 10:04:27 -0400 Subject: [PATCH] Add hotkeys for composing a new message and toggling betweeen message types. (imported from commit 5778b12d204f803a4c46b0f32ec19d9410108b36) --- templates/zephyr/index.html | 2 +- zephyr/static/js/hotkey.js | 14 +++++++++++++- zephyr/static/js/zephyr.js | 9 +++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/templates/zephyr/index.html b/templates/zephyr/index.html index 67dd2c07a9..a5a2f81575 100644 --- a/templates/zephyr/index.html +++ b/templates/zephyr/index.html @@ -57,7 +57,7 @@ var people_list = {{ people }};
  • Settings
  • Invite a friend

  • - New Message + New Message diff --git a/zephyr/static/js/hotkey.js b/zephyr/static/js/hotkey.js index 883790a5a4..043e50d2be 100644 --- a/zephyr/static/js/hotkey.js +++ b/zephyr/static/js/hotkey.js @@ -67,7 +67,9 @@ function process_hotkey(code) { case 27: // Esc: hide compose pane hide_compose(); return process_hotkey; - + case 67: // 'c': compose + compose_button(); + return process_compose_hotkey; case 82: // 'r': respond to zephyr respond_to_zephyr(); return process_key_in_input; @@ -105,6 +107,16 @@ function process_key_in_input(code) { return false; } +function process_compose_hotkey(code) { + if (code === 9) { // Tab: toggle between class and huddle compose tabs. + toggle_compose(); + return process_compose_hotkey; + } else { + keydown_handler = process_key_in_input; + simulate_keypress(code); + } +} + /* The current handler function for keydown events. It should return a new handler, or 'false' to decline to handle the event. */ diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index 89b56930dc..5883a4930d 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -128,6 +128,15 @@ function show_compose(tabname, focus_area) { focus_area.select(); } +function toggle_compose() { + if ($("#zephyr-type-tabs li.active").find("a[href=#class-message]").length !== 0) { + // In class tab, switch to personals. + show_compose('personal', $("#recipient")); + } else { + show_compose('class', $("#class")); + } +} + function compose_class_name() { return $.trim($("#class").val()); }