settings: Make the enter key go to panels.

This is less than perfect, but for most settings hitting
the enter key will now take you to the first element in
the right panel.

The two exceptions are below.  They have checkboxes with
kind of strange markup:

    Notifications
    Authentication methods
This commit is contained in:
Steve Howell 2018-06-04 10:52:42 +00:00 committed by Tim Abbott
parent 8af04ac3cd
commit 3065bf0c58
1 changed files with 17 additions and 1 deletions

View File

@ -32,6 +32,7 @@ exports.make_menu = function (opts) {
handlers: {
left_arrow: toggler.maybe_go_left,
right_arrow: toggler.maybe_go_right,
enter_key: self.enter_panel,
up_arrow: self.prev,
down_arrow: self.next,
},
@ -48,6 +49,15 @@ exports.make_menu = function (opts) {
return true;
};
self.enter_panel = function () {
var panel = self.get_panel();
var sel = 'input:visible:first,button:visible:first,select:visible:first';
var panel_elem = panel.find(sel).first();
panel_elem.focus();
return true;
};
self.activate_section = function (opts) {
var li_elem = opts.li_elem;
var section = li_elem.data('section');
@ -65,8 +75,14 @@ exports.make_menu = function (opts) {
load_section(section);
self.get_panel().addClass('show');
};
self.get_panel = function () {
var section = curr_li.data('section');
var sel = "[data-name='" + section + "']";
$(".settings-section" + sel + ", .settings-wrapper" + sel).addClass("show");
var panel = $(".settings-section" + sel + ", .settings-wrapper" + sel);
return panel;
};
main_elem.on("click", "li[data-section]", function (e) {