mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-16 20:55:36 +08:00
5ece4cc0ec
Import, Delete, Generate, View
61 lines
1.2 KiB
JavaScript
61 lines
1.2 KiB
JavaScript
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
|
|
/**
|
|
* @constructor
|
|
* @extends KnoinAbstractViewModel
|
|
*/
|
|
function PopupsAddOpenPgpKeyViewModel()
|
|
{
|
|
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAddOpenPgpKey');
|
|
|
|
this.key = ko.observable('');
|
|
this.key.error = ko.observable(false);
|
|
this.key.focus = ko.observable(false);
|
|
|
|
this.key.subscribe(function () {
|
|
this.key.error(false);
|
|
}, this);
|
|
|
|
this.addOpenPgpKeyCommand = Utils.createCommand(this, function () {
|
|
|
|
var
|
|
sKey = Utils.trim(this.key()),
|
|
oOpenpgpKeyring = RL.data().openpgpKeyring
|
|
;
|
|
|
|
this.key.error('' === sKey);
|
|
|
|
if (!oOpenpgpKeyring || this.key.error())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
oOpenpgpKeyring.importKey(sKey);
|
|
oOpenpgpKeyring.store();
|
|
|
|
RL.reloadOpenPgpKeys();
|
|
Utils.delegateRun(this, 'cancelCommand');
|
|
|
|
return true;
|
|
});
|
|
|
|
Knoin.constructorEnd(this);
|
|
}
|
|
|
|
Utils.extendAsViewModel('PopupsAddOpenPgpKeyViewModel', PopupsAddOpenPgpKeyViewModel);
|
|
|
|
PopupsAddOpenPgpKeyViewModel.prototype.clearPopup = function ()
|
|
{
|
|
this.key('');
|
|
this.key.error(false);
|
|
};
|
|
|
|
PopupsAddOpenPgpKeyViewModel.prototype.onShow = function ()
|
|
{
|
|
this.clearPopup();
|
|
};
|
|
|
|
PopupsAddOpenPgpKeyViewModel.prototype.onFocus = function ()
|
|
{
|
|
this.key.focus(true);
|
|
};
|