snappymail/dev/View/Popup/ViewOpenPgpKey.js

56 lines
943 B
JavaScript
Raw Normal View History

import ko from 'ko';
import key from 'key';
import {KeyState} from 'Common/Enums';
import {selectElement} from 'Common/Utils';
2016-09-10 06:38:16 +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'
})
class ViewOpenPgpKeyPopupView extends AbstractViewNext
2016-06-30 08:02:45 +08:00
{
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);
}
2016-06-30 08:02:45 +08:00
}
2016-09-30 21:42:38 +08:00
onShow(openPgpKey) {
this.clearPopup();
2016-09-30 21:42:38 +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;
});
}
}
2016-09-10 06:38:16 +08:00
export {ViewOpenPgpKeyPopupView, ViewOpenPgpKeyPopupView as default};