mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 06:50:55 -04:00
Enabled usign raw HTML with email templates
This commit is contained in:
parent
8a1d4d35ec
commit
8d0adbde61
@ -2130,6 +2130,9 @@ $LANG = array(
|
||||
'limits_not_met' => 'This invoice does not meet the limits for that payment type.',
|
||||
|
||||
'date_range' => 'Date Range',
|
||||
'raw' => 'Raw',
|
||||
'raw_html' => 'Raw HTML',
|
||||
'update' => 'Update',
|
||||
|
||||
);
|
||||
|
||||
|
@ -64,10 +64,11 @@
|
||||
</div>
|
||||
<p> <p/>
|
||||
<div class="row">
|
||||
<div class="col-md-10 show-when-ready" style="display:none">
|
||||
<div class="col-md-9 show-when-ready" style="display:none">
|
||||
@include('partials/quill_toolbar', ['name' => $field])
|
||||
</div>
|
||||
<div class="col-md-2 pull-right" style="padding-top:10px">
|
||||
<div class="col-md-3 pull-right" style="padding-top:10px">
|
||||
{!! Button::normal(trans('texts.raw'))->withAttributes(['onclick' => 'showRaw("'.$field.'")'])->small() !!}
|
||||
{!! Button::primary(trans('texts.preview'))->withAttributes(['onclick' => 'serverPreview("'.$field.'")'])->small() !!}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -104,6 +104,25 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="rawModal" tabindex="-1" role="dialog" aria-labelledby="rawModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" style="width:800px">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="rawModalLabel">{{ trans('texts.raw_html') }}</h4>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<textarea id="raw-textarea" rows="20" style="width:100%"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer" style="margin-top: 0px">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.close') }}</button>
|
||||
<button type="button" onclick="updateRaw()" class="btn btn-success" data-dismiss="modal">{{ trans('texts.update') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="templateHelpModal" tabindex="-1" role="dialog" aria-labelledby="templateHelpModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" style="min-width:150px">
|
||||
@ -184,7 +203,6 @@
|
||||
}
|
||||
|
||||
function serverPreview(field) {
|
||||
console.log(field);
|
||||
$('#templatePreviewModal').modal('show');
|
||||
var template = $('#email_template_' + field).val();
|
||||
var url = '{{ URL::to('settings/email_preview') }}?template=' + template;
|
||||
@ -314,6 +332,55 @@
|
||||
});
|
||||
}
|
||||
|
||||
function showRaw(field) {
|
||||
window.rawHtmlField = field;
|
||||
var template = $('#email_template_' + field).val();
|
||||
$('#raw-textarea').val(formatXml(template));
|
||||
$('#rawModal').modal('show');
|
||||
}
|
||||
|
||||
function updateRaw() {
|
||||
var value = $('#raw-textarea').val();
|
||||
var field = window.rawHtmlField;
|
||||
editors[field].setHTML(value);
|
||||
value = editors[field].getHTML();
|
||||
var fieldName = 'email_template_' + field;
|
||||
$('#' + fieldName).val(value);
|
||||
refreshPreview();
|
||||
}
|
||||
|
||||
// https://gist.github.com/sente/1083506
|
||||
function formatXml(xml) {
|
||||
var formatted = '';
|
||||
var reg = /(>)(<)(\/*)/g;
|
||||
xml = xml.replace(reg, '$1\r\n$2$3');
|
||||
var pad = 0;
|
||||
jQuery.each(xml.split('\r\n'), function(index, node) {
|
||||
var indent = 0;
|
||||
if (node.match( /.+<\/\w[^>]*>$/ )) {
|
||||
indent = 0;
|
||||
} else if (node.match( /^<\/\w/ )) {
|
||||
if (pad != 0) {
|
||||
pad -= 1;
|
||||
}
|
||||
} else if (node.match( /^<\w[^>]*[^\/]>.*$/ )) {
|
||||
indent = 1;
|
||||
} else {
|
||||
indent = 0;
|
||||
}
|
||||
|
||||
var padding = '';
|
||||
for (var i = 0; i < pad; i++) {
|
||||
padding += ' ';
|
||||
}
|
||||
|
||||
formatted += padding + node + '\r\n';
|
||||
pad += indent;
|
||||
});
|
||||
|
||||
return formatted;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@stop
|
||||
|
Loading…
x
Reference in New Issue
Block a user