Replaced prompt() into a AskPopupView.password() Promise

This commit is contained in:
the-djmaze 2022-02-07 17:30:41 +01:00
parent 1f0af5c0ac
commit d9f50fa829
3 changed files with 38 additions and 8 deletions

View file

@ -42,8 +42,8 @@ class AskPopupView extends AbstractViewPopup {
* @param {boolean=} bFocusYesOnShow = true
* @returns {void}
*/
onShow(askDesc, fYesFunc = null, fNoFunc = null, yesButton = '', noButton = '', isFocusYesOnShow = true) {
this.askDesc(askDesc || '');
onShow(sAskDesc, fYesFunc = null, fNoFunc = null, yesButton = '', noButton = '', isFocusYesOnShow = true) {
this.askDesc(sAskDesc || '');
this.yesButton(yesButton || i18n('POPUPS_ASK/BUTTON_YES'));
this.noButton(noButton || i18n('POPUPS_ASK/BUTTON_NO'));
this.fYesAction = fYesFunc;
@ -75,4 +75,17 @@ class AskPopupView extends AbstractViewPopup {
}
}
AskPopupView.password = function(sAskDesc) {
return new Promise(resolve => {
this.showModal([
sAskDesc + `<p>${i18n('GLOBAL/PASSWORD')}: <input type="password" autofocus=""></p>`,
() => resolve(this.__dom.querySelector('input[type="password"]').value),
() => resolve(null),
'',
i18n('GLOBAL/CANCEL'),
false
]);
});
}
export { AskPopupView, AskPopupView as default };