mirror of
https://github.com/zulip/zulip.git
synced 2026-07-12 21:04:41 +08:00
Add arrow tab sections to home page.
This lets you use up and down arrows in certain sections on the site to navigate lists. It also prevents potentially unwanted actions caused by using up/down arrows in those sections. Fixes: #1696.
This commit is contained in:
parent
63f92adfbb
commit
65ab368ff0
@ -61,6 +61,25 @@ var hotkeys_shift_insensitive = {
|
||||
119: {name: 'query_streams', message_view_only: false} // 'w'
|
||||
};
|
||||
|
||||
var tab_up_down = (function () {
|
||||
var list = ["#group-pm-list", "#stream_filters", "#global_filters", "#user_presences"];
|
||||
|
||||
return function (e) {
|
||||
var $target = $(e.target);
|
||||
var flag = $target.closest(list.join(", "));
|
||||
|
||||
return {
|
||||
flag: flag,
|
||||
next: function () {
|
||||
return $target.closest("li").next().find("a");
|
||||
},
|
||||
prev: function () {
|
||||
return $target.closest("li").prev().find("a");
|
||||
}
|
||||
};
|
||||
};
|
||||
}());
|
||||
|
||||
function get_hotkey_from_event(e) {
|
||||
|
||||
// We're in the middle of a combo; stop processing because
|
||||
@ -95,6 +114,17 @@ function process_hotkey(e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var tab_list = tab_up_down(e);
|
||||
if (tab_list.flag) {
|
||||
if (hotkey.name === "up_arrow") {
|
||||
tab_list.prev().focus();
|
||||
return true;
|
||||
} else if (hotkey.name === "down_arrow") {
|
||||
tab_list.next().focus();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (event_name === 'ignore') {
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user