mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 13:09:21 +03:00
Code refactoring
This commit is contained in:
parent
4a95dd6195
commit
36329110e5
81 changed files with 3474 additions and 2124 deletions
104
dev/Settings/App/SettingsIdentity.js
Normal file
104
dev/Settings/App/SettingsIdentity.js
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
(function (module, require) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('ko'),
|
||||
_ = require('_'),
|
||||
|
||||
Enums = require('Enums'),
|
||||
Utils = require('Utils'),
|
||||
NewHtmlEditorWrapper = require('NewHtmlEditorWrapper'),
|
||||
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function SettingsIdentity()
|
||||
{
|
||||
this.editor = null;
|
||||
|
||||
this.displayName = Data.displayName;
|
||||
this.signature = Data.signature;
|
||||
this.signatureToAll = Data.signatureToAll;
|
||||
this.replyTo = Data.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);
|
||||
}
|
||||
|
||||
SettingsIdentity.prototype.onFocus = function ()
|
||||
{
|
||||
if (!this.editor && this.signatureDom())
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
sSignature = Data.signature()
|
||||
;
|
||||
|
||||
this.editor = new NewHtmlEditorWrapper(self.signatureDom(), function () {
|
||||
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
|
||||
f1 = Utils.settingsSaveHelperSimpleFunction(self.displayNameTrigger, self),
|
||||
f2 = Utils.settingsSaveHelperSimpleFunction(self.replyTrigger, self),
|
||||
f3 = Utils.settingsSaveHelperSimpleFunction(self.signatureTrigger, self)
|
||||
;
|
||||
|
||||
Data.displayName.subscribe(function (sValue) {
|
||||
Remote.saveSettings(f1, {
|
||||
'DisplayName': sValue
|
||||
});
|
||||
});
|
||||
|
||||
Data.replyTo.subscribe(function (sValue) {
|
||||
Remote.saveSettings(f2, {
|
||||
'ReplyTo': sValue
|
||||
});
|
||||
});
|
||||
|
||||
Data.signature.subscribe(function (sValue) {
|
||||
Remote.saveSettings(f3, {
|
||||
'Signature': sValue
|
||||
});
|
||||
});
|
||||
|
||||
Data.signatureToAll.subscribe(function (bValue) {
|
||||
Remote.saveSettings(null, {
|
||||
'SignatureToAll': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
}, 50);
|
||||
};
|
||||
|
||||
module.exports = SettingsIdentity;
|
||||
|
||||
}(module, require));
|
||||
Loading…
Add table
Add a link
Reference in a new issue