mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
The code here used to live in hotkey.js. Its complicated calling protocol made it difficult to unit test. We are also trying to slim down hotkey.js. Our arrow navigation for things like `#stream_filters` has always been kind of awkward, since it's difficult to get the focus to their list items. This commit does nothing to fix that yet.
30 lines
648 B
JavaScript
30 lines
648 B
JavaScript
var list_util = (function () {
|
|
|
|
var exports = {};
|
|
|
|
var list_selectors = ["#group-pm-list", "#stream_filters", "#global_filters", "#user_presences"];
|
|
|
|
exports.inside_list = function (e) {
|
|
var $target = $(e.target);
|
|
var in_list = $target.closest(list_selectors.join(", ")).length > 0;
|
|
return in_list;
|
|
};
|
|
|
|
exports.go_down = function (e) {
|
|
var $target = $(e.target);
|
|
$target.closest("li").next().find("a").focus();
|
|
};
|
|
|
|
exports.go_up = function (e) {
|
|
var $target = $(e.target);
|
|
$target.closest("li").prev().find("a").focus();
|
|
};
|
|
|
|
return exports;
|
|
|
|
}());
|
|
|
|
if (typeof module !== 'undefined') {
|
|
module.exports = list_util;
|
|
}
|