diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php
index 9606ed251d78..ea174b32d1a6 100644
--- a/resources/lang/en/texts.php
+++ b/resources/lang/en/texts.php
@@ -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',
);
diff --git a/resources/views/accounts/template.blade.php b/resources/views/accounts/template.blade.php
index 629b582d8e3a..acdfbdb83151 100644
--- a/resources/views/accounts/template.blade.php
+++ b/resources/views/accounts/template.blade.php
@@ -64,10 +64,11 @@
-
+
@include('partials/quill_toolbar', ['name' => $field])
-
+
+ {!! Button::normal(trans('texts.raw'))->withAttributes(['onclick' => 'showRaw("'.$field.'")'])->small() !!}
{!! Button::primary(trans('texts.preview'))->withAttributes(['onclick' => 'serverPreview("'.$field.'")'])->small() !!}
diff --git a/resources/views/accounts/templates_and_reminders.blade.php b/resources/views/accounts/templates_and_reminders.blade.php
index 91b82c3598fc..cdfc7ee4ebba 100644
--- a/resources/views/accounts/templates_and_reminders.blade.php
+++ b/resources/views/accounts/templates_and_reminders.blade.php
@@ -104,6 +104,25 @@
+
@@ -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;
+ }
+
@stop