snappymail/dev/View/Popup/ViewOpenPgpKey.js

65 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-06-30 08:02:45 +08:00
var
_ = require('_'),
ko = require('ko'),
key = require('key'),
2016-06-30 08:02:45 +08:00
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
2016-06-30 08:02:45 +08:00
kn = require('Knoin/Knoin'),
AbstractView = require('Knoin/AbstractView');
2016-06-30 08:02:45 +08:00
/**
* @constructor
* @extends AbstractView
*/
function ViewOpenPgpKeyPopupView()
{
AbstractView.call(this, 'Popups', 'PopupsViewOpenPgpKey');
2016-06-30 08:02:45 +08:00
this.key = ko.observable('');
this.keyDom = ko.observable(null);
2016-06-30 08:02:45 +08:00
this.sDefaultKeyScope = Enums.KeyState.PopupViewOpenPGP;
2016-06-30 08:02:45 +08:00
kn.constructorEnd(this);
}
2015-09-02 03:50:30 +08:00
2016-06-30 08:02:45 +08:00
kn.extendAsViewModel(['View/Popup/ViewOpenPgpKey', 'PopupsViewOpenPgpKeyViewModel'], ViewOpenPgpKeyPopupView);
_.extend(ViewOpenPgpKeyPopupView.prototype, AbstractView.prototype);
2016-06-30 08:02:45 +08:00
ViewOpenPgpKeyPopupView.prototype.clearPopup = function()
{
this.key('');
};
2016-06-30 08:02:45 +08:00
ViewOpenPgpKeyPopupView.prototype.selectKey = function()
{
var oEl = this.keyDom();
if (oEl)
{
2016-06-30 08:02:45 +08:00
Utils.selectElement(oEl);
}
};
2016-06-30 08:02:45 +08:00
ViewOpenPgpKeyPopupView.prototype.onShow = function(oOpenPgpKey)
{
this.clearPopup();
2016-06-30 08:02:45 +08:00
if (oOpenPgpKey)
2015-09-02 03:50:30 +08:00
{
2016-06-30 08:02:45 +08:00
this.key(oOpenPgpKey.armor);
}
};
2015-09-02 03:50:30 +08:00
2016-06-30 08:02:45 +08:00
ViewOpenPgpKeyPopupView.prototype.onBuild = function()
{
key('ctrl+a, command+a', Enums.KeyState.PopupViewOpenPGP, _.bind(function() {
this.selectKey();
return false;
}, this));
};
2016-06-30 08:02:45 +08:00
module.exports = ViewOpenPgpKeyPopupView;