From 6aa7386138b6041e1e1bc6b28ca43fc4dc28258e Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 2 Sep 2021 18:46:51 +0200 Subject: [PATCH] modals: onDisplay callback --- copyparty/web/util.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/copyparty/web/util.js b/copyparty/web/util.js index 873fbf5a..1d81647a 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -909,6 +909,8 @@ var modal = (function () { document.addEventListener('focus', onfocus); timer.add(onfocus); + if (cb_up) + setTimeout(cb_up, 1); }; r.hide = function () { @@ -963,40 +965,43 @@ var modal = (function () { q.shift()(); } - r.alert = function (html, cb) { + r.alert = function (html, cb, fun) { q.push(function () { - _alert(lf2br(html), cb); + _alert(lf2br(html), cb, fun); }); next(); }; - function _alert(html, cb) { + function _alert(html, cb, fun) { cb_ok = cb_ng = cb; + cb_up = fun; html += '
OK
'; r.show(html); } - r.confirm = function (html, cok, cng) { + r.confirm = function (html, cok, cng, fun) { q.push(function () { - _confirm(lf2br(html), cok, cng); + _confirm(lf2br(html), cok, cng, fun); }); next(); } - function _confirm(html, cok, cng) { + function _confirm(html, cok, cng, fun) { cb_ok = cok; cb_ng = cng === undefined ? cok : null; + cb_up = fun; html += '
' + ok_cancel + '
'; r.show(html); } - r.prompt = function (html, v, cok, cng) { + r.prompt = function (html, v, cok, cng, fun) { q.push(function () { - _prompt(lf2br(html), v, cok, cng); + _prompt(lf2br(html), v, cok, cng, fun); }); next(); } - function _prompt(html, v, cok, cng) { + function _prompt(html, v, cok, cng, fun) { cb_ok = cok; cb_ng = cng === undefined ? cok : null; + cb_up = fun; html += '
' + ok_cancel + '
'; r.show(html);