set the value saved to empty string if the email is identical to
original
this causes the original to be used since empty string is falsy
v1.18.x
barisusakli 9 years ago
parent 6acfb02316
commit 55c9e6f4b6

@ -34,16 +34,23 @@ define('admin/settings/email', ['admin/settings'], function(settings) {
emailEditor.setTheme("ace/theme/twilight"); emailEditor.setTheme("ace/theme/twilight");
emailEditor.getSession().setMode("ace/mode/html"); emailEditor.getSession().setMode("ace/mode/html");
emailEditor.on('change', function(event) { emailEditor.on('change', function() {
$('#email-editor-holder').val(emailEditor.getValue()); var emailPath = $('#email-editor-selector').val();
var original;
ajaxify.data.emails.forEach(function(email) {
if (email.path === emailPath) {
original = email.original;
}
});
var newEmail = emailEditor.getValue();
$('#email-editor-holder').val(newEmail !== original ? newEmail : '');
}); });
$('button[data-action="email.revert"]').off('click').on('click', function() { $('button[data-action="email.revert"]').off('click').on('click', function() {
ajaxify.data.emails.forEach(function(email) { ajaxify.data.emails.forEach(function(email) {
if (email.path === $('#email-editor-selector').val()) { if (email.path === $('#email-editor-selector').val()) {
emailEditor.getSession().setValue(email.original); emailEditor.getSession().setValue(email.original);
$('#email-editor-holder') $('#email-editor-holder').val('');
.val(email.original);
} }
}); });
}); });
@ -56,7 +63,7 @@ define('admin/settings/email', ['admin/settings'], function(settings) {
if (email.path === $('#email-editor-selector').val()) { if (email.path === $('#email-editor-selector').val()) {
emailEditor.getSession().setValue(email.text); emailEditor.getSession().setValue(email.text);
$('#email-editor-holder') $('#email-editor-holder')
.val(email.text) .val(email.text !== email.original ? email.text : '')
.attr('data-field', 'email:custom:' + email.path); .attr('data-field', 'email:custom:' + email.path);
} }
}); });

@ -19,9 +19,9 @@ settingsController.get = function(req, res, next) {
function renderEmail(req, res, next) { function renderEmail(req, res, next) {
var fs = require('fs'), var fs = require('fs');
path = require('path'), var path = require('path');
utils = require('../../../public/src/utils'); var utils = require('../../../public/src/utils');
var emailsPath = path.join(__dirname, '../../../public/templates/emails'); var emailsPath = path.join(__dirname, '../../../public/templates/emails');
utils.walk(emailsPath, function(err, emails) { utils.walk(emailsPath, function(err, emails) {

Loading…
Cancel
Save