snappymail/dev/Model/Identity.js

45 lines
913 B
JavaScript
Raw Normal View History

2016-06-30 08:02:45 +08:00
var
_ = require('_'),
ko = require('ko'),
2014-08-25 23:49:01 +08:00
2016-06-30 08:02:45 +08:00
AbstractModel = require('Knoin/AbstractModel');
2014-08-20 23:03:12 +08:00
2016-06-30 08:02:45 +08:00
/**
* @constructor
* @param {string} sId
* @param {string} sEmail
*/
function IdentityModel(sId, sEmail)
{
AbstractModel.call(this, 'IdentityModel');
2014-10-04 19:58:01 +08:00
2016-06-30 08:02:45 +08:00
this.id = ko.observable(sId || '');
this.email = ko.observable(sEmail);
this.name = ko.observable('');
2016-06-30 08:02:45 +08:00
this.replyTo = ko.observable('');
this.bcc = ko.observable('');
2014-08-20 23:03:12 +08:00
2016-06-30 08:02:45 +08:00
this.signature = ko.observable('');
this.signatureInsertBefore = ko.observable(false);
2016-06-30 08:02:45 +08:00
this.deleteAccess = ko.observable(false);
this.canBeDeleted = ko.computed(function() {
return '' !== this.id();
}, this);
}
2014-08-20 23:03:12 +08:00
2016-06-30 08:02:45 +08:00
_.extend(IdentityModel.prototype, AbstractModel.prototype);
2014-10-04 19:58:01 +08:00
2016-06-30 08:02:45 +08:00
IdentityModel.prototype.formattedName = function()
{
var
sName = this.name(),
sEmail = this.email();
2014-08-20 23:03:12 +08:00
2016-06-30 08:02:45 +08:00
return ('' !== sName) ? sName + ' (' + sEmail + ')' : sEmail;
};
2014-08-20 23:03:12 +08:00
2016-06-30 08:02:45 +08:00
module.exports = IdentityModel;