2014-09-06 05:44:29 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
var
|
|
|
|
_ = require('_'),
|
|
|
|
ko = require('ko'),
|
|
|
|
key = require('key'),
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
Enums = require('Common/Enums'),
|
|
|
|
Utils = require('Common/Utils'),
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
kn = require('Knoin/Knoin'),
|
|
|
|
AbstractView = require('Knoin/AbstractView');
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
* @extends AbstractView
|
|
|
|
*/
|
|
|
|
function ViewOpenPgpKeyPopupView()
|
|
|
|
{
|
|
|
|
AbstractView.call(this, 'Popups', 'PopupsViewOpenPgpKey');
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
this.key = ko.observable('');
|
|
|
|
this.keyDom = ko.observable(null);
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
this.sDefaultKeyScope = Enums.KeyState.PopupViewOpenPGP;
|
2014-09-06 05:44:29 +08:00
|
|
|
|
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);
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
ViewOpenPgpKeyPopupView.prototype.clearPopup = function()
|
|
|
|
{
|
|
|
|
this.key('');
|
|
|
|
};
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
ViewOpenPgpKeyPopupView.prototype.selectKey = function()
|
|
|
|
{
|
|
|
|
var oEl = this.keyDom();
|
|
|
|
if (oEl)
|
2014-09-06 05:44:29 +08:00
|
|
|
{
|
2016-06-30 08:02:45 +08:00
|
|
|
Utils.selectElement(oEl);
|
|
|
|
}
|
|
|
|
};
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
ViewOpenPgpKeyPopupView.prototype.onShow = function(oOpenPgpKey)
|
|
|
|
{
|
|
|
|
this.clearPopup();
|
2014-09-06 05:44:29 +08:00
|
|
|
|
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));
|
|
|
|
};
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
module.exports = ViewOpenPgpKeyPopupView;
|