snappymail/dev/View/Popup/ViewOpenPgpKey.js

51 lines
925 B
JavaScript
Raw Normal View History

import ko from 'ko';
2019-07-05 03:19:24 +08:00
import { KeyState } from 'Common/Enums';
import { selectElement } from 'Common/Utils';
2019-07-05 03:19:24 +08:00
import { popup } from 'Knoin/Knoin';
import { AbstractViewNext } from 'Knoin/AbstractViewNext';
2016-09-10 06:38:16 +08:00
@popup({
name: 'View/Popup/ViewOpenPgpKey',
2016-09-30 21:42:38 +08:00
templateID: 'PopupsViewOpenPgpKey'
})
2019-07-05 03:19:24 +08:00
class ViewOpenPgpKeyPopupView extends AbstractViewNext {
constructor() {
super();
this.key = ko.observable('');
this.keyDom = ko.observable(null);
this.sDefaultKeyScope = KeyState.PopupViewOpenPGP;
}
clearPopup() {
this.key('');
}
selectKey() {
const el = this.keyDom();
2019-07-05 03:19:24 +08:00
if (el) {
selectElement(el);
}
2016-06-30 08:02:45 +08:00
}
2016-09-30 21:42:38 +08:00
onShow(openPgpKey) {
this.clearPopup();
2019-07-05 03:19:24 +08:00
if (openPgpKey) {
2016-09-30 21:42:38 +08:00
this.key(openPgpKey.armor);
}
2016-06-30 08:02:45 +08:00
}
2015-09-02 03:50:30 +08:00
onBuild() {
key('ctrl+a, command+a', KeyState.PopupViewOpenPGP, () => {
this.selectKey();
return false;
});
}
}
2019-07-05 03:19:24 +08:00
export { ViewOpenPgpKeyPopupView, ViewOpenPgpKeyPopupView as default };