mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 02:17:19 +00:00
Add hotkeys for composing a new message and toggling betweeen message types.
(imported from commit 5778b12d204f803a4c46b0f32ec19d9410108b36)
This commit is contained in:
@@ -57,7 +57,7 @@ var people_list = {{ people }};
|
||||
<li><a href="#settings" data-toggle="pill"><i class="icon-edit"></i> Settings</a></li>
|
||||
<li class="disabled"><a href="#"><i class="icon-envelope"></i> Invite a friend</a></li>
|
||||
<br>
|
||||
<a href="#" class="btn btn-large btn-block" id="new_message_button" onclick="compose_button()">New Message</a>
|
||||
<a href="#" class="btn btn-large btn-block" id="new_message_button" onclick="compose_button();">New Message</a>
|
||||
</ul>
|
||||
</div><!--/.well -->
|
||||
</div><!--/span-->
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user