- Hello! I'm a placerholder message.
+ Please enter the email address to send a test to:
@@ -355,7 +355,50 @@
mdlDialog.className += ' ' + mdlClass;
testContainer.style.display = 'block';
md.setTitle('Test your Newsletter');
- md.setContent(testContainer);
+
+ var modalContent = $('
').append(testContainer).html();
+ md.setContent(modalContent);
+
+ testContainer = $(".gjs-mdl-dialog #test-form");
+
+ var statusFormElC = document.querySelector('.form-status');
+ var statusFormEl = document.querySelector('.form-status i');
+
+ var ajaxTest = ajaxable(testContainer, { headers: { 'X-CSRF-TOKEN': '{{csrfToken}}' } })
+ .onStart(function() {
+ statusFormEl.className = 'fa fa-refresh anim-spin';
+ statusFormElC.style.opacity = '1';
+ statusFormElC.className = 'form-status';
+ })
+ .onResponse(function(res) {
+ if (res.data) {
+ statusFormElC.style.opacity = '0';
+ statusFormEl.removeAttribute('data-tooltip');
+ md.close();
+ toastr.success('Testmail sent');
+ } else if (res.errors) {
+ statusFormEl.className = 'fa fa-exclamation-circle';
+ statusFormEl.setAttribute('data-tooltip', res.errors);
+ statusFormElC.className = 'form-status text-danger';
+ toastr.error(res.errors);
+ }
+ });
+
+ // Remember testemail address
+
+ var isValidEmail = function(email) {
+ return /\S+@\S+\.\S+/.test(email);
+ };
+
+ if (isValidEmail(localStorage.getItem('testemail'))) {
+ $('#test-form input[name=email]').val(localStorage.getItem('testemail'));
+ }
+
+ $('#test-form').on('submit', function() {
+ var email = $('#test-form input[name=email]').val();
+ isValidEmail(email) && localStorage.setItem('testemail', email);
+ });
+
md.open();
md.getModel().once('change:open', function() {
mdlDialog.className = mdlDialog.className.replace(mdlClass, '');
@@ -375,43 +418,6 @@
},
});
- var statusFormElC = document.querySelector('.form-status');
- var statusFormEl = document.querySelector('.form-status i');
-
- var ajaxTest = ajaxable(testContainer, { headers: { 'X-CSRF-TOKEN': '{{csrfToken}}' } })
- .onStart(function() {
- statusFormEl.className = 'fa fa-refresh anim-spin';
- statusFormElC.style.opacity = '1';
- statusFormElC.className = 'form-status';
- })
- .onResponse(function(res) {
- if (res.data) {
- statusFormElC.style.opacity = '0';
- statusFormEl.removeAttribute('data-tooltip');
- md.close();
- toastr.success('Testmail sent');
- } else if (res.errors) {
- statusFormEl.className = 'fa fa-exclamation-circle';
- statusFormEl.setAttribute('data-tooltip', res.errors);
- statusFormElC.className = 'form-status text-danger';
- toastr.error(res.errors);
- }
- });
-
- // Remember testemail address
-
- var isValidEmail = function(email) {
- return /\S+@\S+\.\S+/.test(email);
- };
-
- if (isValidEmail(localStorage.getItem('testemail'))) {
- $('#test-form input[name=email]').val(localStorage.getItem('testemail'));
- }
-
- $('#test-form').on('submit', function() {
- var email = $('#test-form input[name=email]').val();
- isValidEmail(email) && localStorage.setItem('testemail', email);
- });
// Merge Tag Reference command