mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 12:39:20 +03:00
Bugfix: Help screen broken tabbing shortcuts
This commit is contained in:
parent
8b116fa8ba
commit
64a7b82408
3 changed files with 45 additions and 59 deletions
|
|
@ -8,29 +8,44 @@ class KeyboardShortcutsHelpPopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
onBuild(dom) {
|
||||
dom.querySelectorAll('a[data-toggle="tab"]').forEach(node => node.Tab || new BSN.Tab(node));
|
||||
const tabs = dom.querySelectorAll('.nav.nav-tabs > li'),
|
||||
last = tabs.length - 1,
|
||||
show = tab => {
|
||||
if (!tab.classList.contains('active')) {
|
||||
const previous = tab.parentElement.querySelector('.active');
|
||||
previous.classList.remove('active');
|
||||
dom.querySelector(previous.firstElementChild.getAttribute('href')).classList.remove('active');
|
||||
|
||||
tab.classList.add('active');
|
||||
dom.querySelector(tab.firstElementChild.getAttribute('href')).classList.add('active');
|
||||
}
|
||||
};
|
||||
|
||||
tabs.forEach(node => {
|
||||
node.addEventListener('click', e => {
|
||||
e.preventDefault();
|
||||
show(node);
|
||||
});
|
||||
});
|
||||
|
||||
// shortcuts.add('tab', 'shift',
|
||||
shortcuts.add('tab,arrowleft,arrowright', '',
|
||||
Scope.KeyboardShortcutsHelp,
|
||||
((event, handler)=>{
|
||||
if (event && handler) {
|
||||
const tabs = dom.querySelectorAll('.nav.nav-tabs > li'),
|
||||
last = tabs.length - 1;
|
||||
let next = 0;
|
||||
tabs.forEach((node, index) => {
|
||||
if (node.matches('.active')) {
|
||||
if (['tab','arrowright'].includes(handler.shortcut)) {
|
||||
next = index < last ? index+1 : 0;
|
||||
} else {
|
||||
next = index ? index-1 : last;
|
||||
}
|
||||
event => {
|
||||
let next = 0;
|
||||
tabs.forEach((node, index) => {
|
||||
if (node.matches('.active')) {
|
||||
if (['Tab','ArrowRight'].includes(event.key)) {
|
||||
next = index < last ? index+1 : 0;
|
||||
} else {
|
||||
next = index ? index-1 : last;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
tabs[next].querySelector('a[data-toggle="tab"]').Tab.show();
|
||||
}
|
||||
}).throttle(100)
|
||||
show(tabs[next]);
|
||||
return false;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue