mirror of
https://github.com/9001/copyparty.git
synced 2025-08-19 18:02:28 -06:00
fence focus inside modals
This commit is contained in:
parent
4802f8cf07
commit
7e84f4f015
|
@ -1013,6 +1013,8 @@ html.light #rui {
|
||||||
#barpos,
|
#barpos,
|
||||||
#u2conf label,
|
#u2conf label,
|
||||||
#rui label,
|
#rui label,
|
||||||
|
#modal-ok,
|
||||||
|
#modal-ng,
|
||||||
#ops {
|
#ops {
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
-moz-user-select: none;
|
-moz-user-select: none;
|
||||||
|
|
|
@ -725,11 +725,15 @@ var modal = (function () {
|
||||||
a.onclick = ok;
|
a.onclick = ok;
|
||||||
|
|
||||||
(ebi('modali') || a).focus();
|
(ebi('modali') || a).focus();
|
||||||
|
document.addEventListener('focus', onfocus);
|
||||||
|
timer.add(onfocus);
|
||||||
};
|
};
|
||||||
|
|
||||||
r.hide = function () {
|
r.hide = function () {
|
||||||
o.parentNode.removeChild(o);
|
timer.rm(onfocus);
|
||||||
|
document.removeEventListener('focus', onfocus);
|
||||||
document.removeEventListener('keydown', onkey);
|
document.removeEventListener('keydown', onkey);
|
||||||
|
o.parentNode.removeChild(o);
|
||||||
r.busy = false;
|
r.busy = false;
|
||||||
setTimeout(next, 50);
|
setTimeout(next, 50);
|
||||||
};
|
};
|
||||||
|
@ -748,6 +752,17 @@ var modal = (function () {
|
||||||
cb_ng(null);
|
cb_ng(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onfocus(e) {
|
||||||
|
var ctr = ebi('modalc');
|
||||||
|
if (!ctr || !ctr.contains || !document.activeElement || ctr.contains(document.activeElement))
|
||||||
|
return;
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
ebi('modal-ok').focus();
|
||||||
|
}, 20);
|
||||||
|
ev(e);
|
||||||
|
}
|
||||||
|
|
||||||
function onkey(e) {
|
function onkey(e) {
|
||||||
if (e.code == 'Enter') {
|
if (e.code == 'Enter') {
|
||||||
var a = ebi('modal-ng');
|
var a = ebi('modal-ng');
|
||||||
|
|
Loading…
Reference in a new issue