snappymail/dev/View/Popup/ViewOpenPgpKey.js
djmaze e7180a86ce Made eslint using 'browser' environment and added globals, because RainLoop is used in browsers.
This also allowed to remove all webpack 'externals' overhead.
2020-08-12 00:25:36 +02:00

50 lines
925 B
JavaScript

import ko from 'ko';
import { KeyState } from 'Common/Enums';
import { selectElement } from 'Common/Utils';
import { popup } from 'Knoin/Knoin';
import { AbstractViewNext } from 'Knoin/AbstractViewNext';
@popup({
name: 'View/Popup/ViewOpenPgpKey',
templateID: 'PopupsViewOpenPgpKey'
})
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();
if (el) {
selectElement(el);
}
}
onShow(openPgpKey) {
this.clearPopup();
if (openPgpKey) {
this.key(openPgpKey.armor);
}
}
onBuild() {
key('ctrl+a, command+a', KeyState.PopupViewOpenPGP, () => {
this.selectKey();
return false;
});
}
}
export { ViewOpenPgpKeyPopupView, ViewOpenPgpKeyPopupView as default };