fix compose signature compiler

This commit is contained in:
RainLoop Team 2014-08-14 17:09:42 +04:00
parent 25cf891037
commit 7c25098c1b
7 changed files with 70 additions and 20 deletions

View file

@ -1689,7 +1689,7 @@ Utils.htmlToPlain = function (sHtml)
sText = sHtml sText = sHtml
.replace(/[\s]+/gm, ' ') .replace(/[\s]+/gm, ' ')
.replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue) .replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue)
.replace(/<br\s?\/?>/gmi, '\n') .replace(/<br[^>]*>/gmi, '\n')
.replace(/<\/h[\d]>/gi, '\n') .replace(/<\/h[\d]>/gi, '\n')
.replace(/<\/p>/gi, '\n\n') .replace(/<\/p>/gi, '\n\n')
.replace(/<\/li>/gi, '\n') .replace(/<\/li>/gi, '\n')

View file

@ -594,13 +594,15 @@ PopupsComposeViewModel.prototype.onHide = function ()
/** /**
* @param {string} sSignature * @param {string} sSignature
* @param {string=} sFrom * @param {string=} sFrom
* @param {string=} sData
* @param {string=} sComposeType
* @return {string} * @return {string}
*/ */
PopupsComposeViewModel.prototype.convertSignature = function (sSignature, sFrom) PopupsComposeViewModel.prototype.convertSignature = function (sSignature, sFrom, sData, sComposeType)
{ {
var bHtml = false, bData = false;
if ('' !== sSignature) if ('' !== sSignature)
{ {
var bHtml = false;
if (':HTML:' === sSignature.substr(0, 6)) if (':HTML:' === sSignature.substr(0, 6))
{ {
bHtml = true; bHtml = true;
@ -620,12 +622,34 @@ PopupsComposeViewModel.prototype.convertSignature = function (sSignature, sFrom)
sSignature = sSignature.replace(/{{FROM}}/, ''); sSignature = sSignature.replace(/{{FROM}}/, '');
sSignature = sSignature.replace(/{{DATE}}/, moment().format('llll')); sSignature = sSignature.replace(/{{DATE}}/, moment().format('llll'));
if (sData && Enums.ComposeType.Empty === sComposeType &&
-1 < sSignature.indexOf('{{DATA}}'))
{
bData = true;
sSignature = sSignature.replace('{{DATA}}', sData);
}
sSignature = sSignature.replace(/{{DATA}}/, '');
if (!bHtml) if (!bHtml)
{ {
sSignature = Utils.convertPlainTextToHtml(sSignature); sSignature = Utils.convertPlainTextToHtml(sSignature);
} }
} }
if (sData && !bData)
{
switch (sComposeType)
{
case Enums.ComposeType.Empty:
sSignature = sData + '<br />' + sSignature;
break;
default:
sSignature = sSignature + '<br />' + sData;
break;
}
}
return sSignature; return sSignature;
}; };
@ -839,7 +863,7 @@ PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToE
if (bSignatureToAll && '' !== sSignature && if (bSignatureToAll && '' !== sSignature &&
Enums.ComposeType.EditAsNew !== sComposeType && Enums.ComposeType.Draft !== sComposeType) Enums.ComposeType.EditAsNew !== sComposeType && Enums.ComposeType.Draft !== sComposeType)
{ {
sText = this.convertSignature(sSignature, fEmailArrayToStringLineHelper(oMessage.from, true)) + '<br />' + sText; sText = this.convertSignature(sSignature, fEmailArrayToStringLineHelper(oMessage.from, true), sText, sComposeType);
} }
this.editor(function (oEditor) { this.editor(function (oEditor) {
@ -855,9 +879,10 @@ PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToE
this.subject(Utils.isNormal(sCustomSubject) ? '' + sCustomSubject : ''); this.subject(Utils.isNormal(sCustomSubject) ? '' + sCustomSubject : '');
sText = Utils.isNormal(sCustomPlainText) ? '' + sCustomPlainText : ''; sText = Utils.isNormal(sCustomPlainText) ? '' + sCustomPlainText : '';
if (bSignatureToAll && '' !== sSignature && '' !== sText) if (bSignatureToAll && '' !== sSignature)
{ {
sText = this.convertSignature(sSignature) + '<br />' + sText; sText = this.convertSignature(sSignature, '',
Utils.convertPlainTextToHtml(sText), sComposeType);
} }
this.editor(function (oEditor) { this.editor(function (oEditor) {

View file

@ -14,7 +14,7 @@
var sText = sHtml var sText = sHtml
.replace(/[\s]+/gm, ' ') .replace(/[\s]+/gm, ' ')
.replace(/<br\s?\/?>/gmi, '\n') .replace(/<br[^>]*>/gmi, '\n')
.replace(/<\/h[\d]>/gi, '\n') .replace(/<\/h[\d]>/gi, '\n')
.replace(/<\/p>/gi, '\n\n') .replace(/<\/p>/gi, '\n\n')
.replace(/<\/li>/gi, '\n') .replace(/<\/li>/gi, '\n')

View file

@ -2488,7 +2488,7 @@ Utils.htmlToPlain = function (sHtml)
sText = sHtml sText = sHtml
.replace(/[\s]+/gm, ' ') .replace(/[\s]+/gm, ' ')
.replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue) .replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue)
.replace(/<br\s?\/?>/gmi, '\n') .replace(/<br[^>]*>/gmi, '\n')
.replace(/<\/h[\d]>/gi, '\n') .replace(/<\/h[\d]>/gi, '\n')
.replace(/<\/p>/gi, '\n\n') .replace(/<\/p>/gi, '\n\n')
.replace(/<\/li>/gi, '\n') .replace(/<\/li>/gi, '\n')

File diff suppressed because one or more lines are too long

View file

@ -2491,7 +2491,7 @@ Utils.htmlToPlain = function (sHtml)
sText = sHtml sText = sHtml
.replace(/[\s]+/gm, ' ') .replace(/[\s]+/gm, ' ')
.replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue) .replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue)
.replace(/<br\s?\/?>/gmi, '\n') .replace(/<br[^>]*>/gmi, '\n')
.replace(/<\/h[\d]>/gi, '\n') .replace(/<\/h[\d]>/gi, '\n')
.replace(/<\/p>/gi, '\n\n') .replace(/<\/p>/gi, '\n\n')
.replace(/<\/li>/gi, '\n') .replace(/<\/li>/gi, '\n')
@ -9673,13 +9673,15 @@ PopupsComposeViewModel.prototype.onHide = function ()
/** /**
* @param {string} sSignature * @param {string} sSignature
* @param {string=} sFrom * @param {string=} sFrom
* @param {string=} sData
* @param {string=} sComposeType
* @return {string} * @return {string}
*/ */
PopupsComposeViewModel.prototype.convertSignature = function (sSignature, sFrom) PopupsComposeViewModel.prototype.convertSignature = function (sSignature, sFrom, sData, sComposeType)
{ {
var bHtml = false, bData = false;
if ('' !== sSignature) if ('' !== sSignature)
{ {
var bHtml = false;
if (':HTML:' === sSignature.substr(0, 6)) if (':HTML:' === sSignature.substr(0, 6))
{ {
bHtml = true; bHtml = true;
@ -9699,12 +9701,34 @@ PopupsComposeViewModel.prototype.convertSignature = function (sSignature, sFrom)
sSignature = sSignature.replace(/{{FROM}}/, ''); sSignature = sSignature.replace(/{{FROM}}/, '');
sSignature = sSignature.replace(/{{DATE}}/, moment().format('llll')); sSignature = sSignature.replace(/{{DATE}}/, moment().format('llll'));
if (sData && Enums.ComposeType.Empty === sComposeType &&
-1 < sSignature.indexOf('{{DATA}}'))
{
bData = true;
sSignature = sSignature.replace('{{DATA}}', sData);
}
sSignature = sSignature.replace(/{{DATA}}/, '');
if (!bHtml) if (!bHtml)
{ {
sSignature = Utils.convertPlainTextToHtml(sSignature); sSignature = Utils.convertPlainTextToHtml(sSignature);
} }
} }
if (sData && !bData)
{
switch (sComposeType)
{
case Enums.ComposeType.Empty:
sSignature = sData + '<br />' + sSignature;
break;
default:
sSignature = sSignature + '<br />' + sData;
break;
}
}
return sSignature; return sSignature;
}; };
@ -9918,7 +9942,7 @@ PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToE
if (bSignatureToAll && '' !== sSignature && if (bSignatureToAll && '' !== sSignature &&
Enums.ComposeType.EditAsNew !== sComposeType && Enums.ComposeType.Draft !== sComposeType) Enums.ComposeType.EditAsNew !== sComposeType && Enums.ComposeType.Draft !== sComposeType)
{ {
sText = this.convertSignature(sSignature, fEmailArrayToStringLineHelper(oMessage.from, true)) + '<br />' + sText; sText = this.convertSignature(sSignature, fEmailArrayToStringLineHelper(oMessage.from, true), sText, sComposeType);
} }
this.editor(function (oEditor) { this.editor(function (oEditor) {
@ -9934,9 +9958,10 @@ PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToE
this.subject(Utils.isNormal(sCustomSubject) ? '' + sCustomSubject : ''); this.subject(Utils.isNormal(sCustomSubject) ? '' + sCustomSubject : '');
sText = Utils.isNormal(sCustomPlainText) ? '' + sCustomPlainText : ''; sText = Utils.isNormal(sCustomPlainText) ? '' + sCustomPlainText : '';
if (bSignatureToAll && '' !== sSignature && '' !== sText) if (bSignatureToAll && '' !== sSignature)
{ {
sText = this.convertSignature(sSignature) + '<br />' + sText; sText = this.convertSignature(sSignature, '',
Utils.convertPlainTextToHtml(sText), sComposeType);
} }
this.editor(function (oEditor) { this.editor(function (oEditor) {

File diff suppressed because one or more lines are too long