snappymail/dev/View/Popup/ViewOpenPgpKey.js

47 lines
838 B
JavaScript
Raw Normal View History

import { Scope } from 'Common/Enums';
import { doc } from 'Common/Globals';
import { AbstractViewPopup } from 'Knoin/AbstractViews';
class ViewOpenPgpKeyPopupView extends AbstractViewPopup {
constructor() {
super('ViewOpenPgpKey');
this.addObservables({
key: '',
keyDom: null
});
}
clearPopup() {
this.key('');
}
selectKey() {
const el = this.keyDom();
2019-07-05 03:19:24 +08:00
if (el) {
let sel = getSelection(),
range = doc.createRange();
sel.removeAllRanges();
range.selectNodeContents(el);
sel.addRange(range);
}
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() {
shortcuts.add('a', 'meta', Scope.ViewOpenPgpKey, () => {
this.selectKey();
return false;
});
}
}
2019-07-05 03:19:24 +08:00
export { ViewOpenPgpKeyPopupView, ViewOpenPgpKeyPopupView as default };