Drop cancelCommand in favor of closeCommand and improve AbstractViewPopup handling

This commit is contained in:
the-djmaze 2022-02-24 22:40:17 +01:00
parent 06b5b83588
commit 2edd55f01f
36 changed files with 82 additions and 118 deletions

View file

@ -19,17 +19,16 @@ export class AskPopupView extends AbstractViewPopup {
this.fNoAction = null;
this.focusOnShow = true;
this.bDisabeCloseOnEsc = true;
}
yesClick() {
this.cancelCommand();
this.closeCommand();
isFunction(this.fYesAction) && this.fYesAction();
}
noClick() {
this.cancelCommand();
this.closeCommand();
isFunction(this.fNoAction) && this.fNoAction();
}
@ -52,10 +51,15 @@ export class AskPopupView extends AbstractViewPopup {
this.focusOnShow = focusOnShow ? (askPass ? 'input[type="password"]' : '.buttonYes') : '';
}
onShowWithDelay() {
afterShow() {
this.focusOnShow && this.querySelector(this.focusOnShow).focus();
}
onClose() {
this.noClick();
return false;
}
onBuild() {
// shortcuts.add('tab', 'shift', 'Ask', () => {
shortcuts.add('tab,arrowright,arrowleft', '', 'Ask', () => {
@ -66,11 +70,6 @@ export class AskPopupView extends AbstractViewPopup {
btn.focus();
return false;
});
shortcuts.add('escape', '', 'Ask', () => {
this.noClick();
return false;
});
}
}