"Add your signature to all the outgoing messages" configuration (close #52)

This commit is contained in:
RainLoop Team 2014-01-18 01:18:45 +04:00
parent fa35368e45
commit b0593b813e
23 changed files with 161 additions and 22 deletions

View file

@ -8573,6 +8573,26 @@ PopupsComposeViewModel.prototype.onHide = function ()
kn.routeOn();
};
PopupsComposeViewModel.prototype.convertSignature = function (sSignature, sFrom)
{
if ('' !== sSignature)
{
sFrom = Utils.pString(sFrom);
if ('' !== sFrom)
{
sSignature = sSignature.replace(/{{FROM}}/, sFrom);
}
else
{
sSignature = sSignature.replace(/{{IF:FROM}}[\s\S]+{{\/IF:FROM}}/gm, '');
}
sSignature = Utils.trim(sSignature.replace(/{{FROM}}/, '').replace(/{{IF:FROM}}/, '').replace(/{{\/IF:FROM}}/, ''));
}
return sSignature;
};
/**
* @param {string=} sType = Enums.ComposeType.Empty
* @param {?MessageModel|Array=} oMessageOrArray = null
@ -8595,11 +8615,13 @@ PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToE
aResplyAllParts = [],
oExcludeEmail = {},
mEmail = RL.data().accountEmail(),
sSignature = RL.data().signature(),
bSignatureToAll = RL.data().signatureToAll(),
aDownloads = [],
aDraftInfo = null,
oMessage = null,
sComposeType = sType || Enums.ComposeType.Empty,
fEmailArrayToStringLineHelper = function (aList) {
fEmailArrayToStringLineHelper = function (aList, bFriendly) {
var
iIndex = 0,
@ -8609,7 +8631,7 @@ PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToE
for (; iIndex < iLen; iIndex++)
{
aResult.push(aList[iIndex].toLine(false));
aResult.push(aList[iIndex].toLine(!!bFriendly));
}
return aResult.join(', ');
@ -8740,12 +8762,19 @@ PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToE
break;
}
if (bSignatureToAll && '' !== sSignature)
{
sText = Utils.convertPlainTextToHtml(this.convertSignature(sSignature,
fEmailArrayToStringLineHelper(oMessage.from, true))) + '<br />' + sText;
}
this.oEditor.setRawText(sText, oMessage.isHtml());
}
}
else if (this.oEditor && Enums.ComposeType.Empty === sComposeType)
{
this.oEditor.setRawText('<br />' + Utils.convertPlainTextToHtml(RL.data().signature()), Enums.EditorDefaultType.Html === RL.data().editorDefaultType());
this.oEditor.setRawText(Utils.convertPlainTextToHtml(this.convertSignature(sSignature)),
Enums.EditorDefaultType.Html === RL.data().editorDefaultType());
}
else if (Utils.isNonEmptyArray(oMessageOrArray))
{
@ -12687,6 +12716,7 @@ function SettingsIdentity()
this.displayName = oData.displayName;
this.signature = oData.signature;
this.signatureToAll = oData.signatureToAll;
this.replyTo = oData.replyTo;
this.displayNameTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
@ -12725,6 +12755,12 @@ SettingsIdentity.prototype.onBuild = function ()
'Signature': sValue
});
});
oData.signatureToAll.subscribe(function (bValue) {
RL.remote().saveSettings(null, {
'SignatureToAll': bValue ? '1' : '0'
});
});
}, 50);
};
@ -12738,6 +12774,7 @@ function SettingsIdentities()
this.displayName = oData.displayName;
this.signature = oData.signature;
this.signatureToAll = oData.signatureToAll;
this.replyTo = oData.replyTo;
this.displayNameTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
@ -12848,6 +12885,12 @@ SettingsIdentities.prototype.onBuild = function (oDom)
});
});
oData.signatureToAll.subscribe(function (bValue) {
RL.remote().saveSettings(null, {
'SignatureToAll': bValue ? '1' : '0'
});
});
}, 50);
};
/**
@ -13528,6 +13571,7 @@ function WebMailDataStorage()
// personal
this.displayName = ko.observable('');
this.signature = ko.observable('');
this.signatureToAll = ko.observable(false);
this.replyTo = ko.observable('');
// accounts
@ -13860,6 +13904,7 @@ WebMailDataStorage.prototype.populateDataOnStart = function()
this.displayName(RL.settingsGet('DisplayName'));
this.replyTo(RL.settingsGet('ReplyTo'));
this.signature(RL.settingsGet('Signature'));
this.signatureToAll(!!RL.settingsGet('SignatureToAll'));
this.lastFoldersHash = RL.local().get(Enums.ClientSideKeyName.FoldersLashHash) || '';

File diff suppressed because one or more lines are too long