mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-01 00:05:51 +00:00
61
dev/ViewModels/PopupsAddOpenPgpKeyViewModel.js
Normal file
61
dev/ViewModels/PopupsAddOpenPgpKeyViewModel.js
Normal file
@@ -0,0 +1,61 @@
|
||||
/* 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);
|
||||
};
|
||||
Reference in New Issue
Block a user