mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-09 08:17:53 +08:00
106 lines
2.4 KiB
JavaScript
106 lines
2.4 KiB
JavaScript
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||
|
|
||
|
(function (module) {
|
||
|
|
||
|
'use strict';
|
||
|
|
||
|
var
|
||
|
ko = require('../External/ko.js'),
|
||
|
|
||
|
Enums = require('../Common/Enums.js'),
|
||
|
Utils = require('../Common/Utils.js'),
|
||
|
|
||
|
Remote = require('../Storages/WebMailAjaxRemoteStorage.js')
|
||
|
;
|
||
|
|
||
|
/**
|
||
|
* @constructor
|
||
|
*/
|
||
|
function SettingsIdentity()
|
||
|
{
|
||
|
var oData = RL.data();
|
||
|
|
||
|
this.editor = null;
|
||
|
|
||
|
this.displayName = oData.displayName;
|
||
|
this.signature = oData.signature;
|
||
|
this.signatureToAll = oData.signatureToAll;
|
||
|
this.replyTo = oData.replyTo;
|
||
|
|
||
|
this.signatureDom = ko.observable(null);
|
||
|
|
||
|
this.displayNameTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||
|
this.replyTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||
|
this.signatureTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||
|
}
|
||
|
|
||
|
kn.addSettingsViewModel(SettingsIdentity, 'SettingsIdentity', 'SETTINGS_LABELS/LABEL_IDENTITY_NAME', 'identity');
|
||
|
|
||
|
SettingsIdentity.prototype.onFocus = function ()
|
||
|
{
|
||
|
if (!this.editor && this.signatureDom())
|
||
|
{
|
||
|
var
|
||
|
self = this,
|
||
|
sSignature = RL.data().signature()
|
||
|
;
|
||
|
|
||
|
this.editor = new NewHtmlEditorWrapper(self.signatureDom(), function () {
|
||
|
RL.data().signature(
|
||
|
(self.editor.isHtml() ? ':HTML:' : '') + self.editor.getData()
|
||
|
);
|
||
|
}, function () {
|
||
|
if (':HTML:' === sSignature.substr(0, 6))
|
||
|
{
|
||
|
self.editor.setHtml(sSignature.substr(6), false);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
self.editor.setPlain(sSignature, false);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
|
||
|
SettingsIdentity.prototype.onBuild = function ()
|
||
|
{
|
||
|
var self = this;
|
||
|
_.delay(function () {
|
||
|
|
||
|
var
|
||
|
oData = RL.data(),
|
||
|
f1 = Utils.settingsSaveHelperSimpleFunction(self.displayNameTrigger, self),
|
||
|
f2 = Utils.settingsSaveHelperSimpleFunction(self.replyTrigger, self),
|
||
|
f3 = Utils.settingsSaveHelperSimpleFunction(self.signatureTrigger, self)
|
||
|
;
|
||
|
|
||
|
oData.displayName.subscribe(function (sValue) {
|
||
|
Remote.saveSettings(f1, {
|
||
|
'DisplayName': sValue
|
||
|
});
|
||
|
});
|
||
|
|
||
|
oData.replyTo.subscribe(function (sValue) {
|
||
|
Remote.saveSettings(f2, {
|
||
|
'ReplyTo': sValue
|
||
|
});
|
||
|
});
|
||
|
|
||
|
oData.signature.subscribe(function (sValue) {
|
||
|
Remote.saveSettings(f3, {
|
||
|
'Signature': sValue
|
||
|
});
|
||
|
});
|
||
|
|
||
|
oData.signatureToAll.subscribe(function (bValue) {
|
||
|
Remote.saveSettings(null, {
|
||
|
'SignatureToAll': bValue ? '1' : '0'
|
||
|
});
|
||
|
});
|
||
|
|
||
|
}, 50);
|
||
|
};
|
||
|
|
||
|
module.exports = SettingsIdentity;
|
||
|
|
||
|
}(module));
|