Files
piratepoet/views/settings.html
Jonathan Labreuille 2e88d7cce0 Added API/Endpoint abstract class
- (re)Added Endpoints folder to both API and Router
- fixed syntax in namespaces
- xhr.responseJSON is returned to the fail()
- fixed Router endpoints (view in browser, cron,...)
2016-08-02 17:08:43 +02:00

125 lines
3.8 KiB
HTML

<% extends 'layout.html' %>
<% block content %>
<div id="mailpoet_settings">
<h1 class="title"><%= __('Settings') %></h1>
<!-- settings form -->
<form
id="mailpoet_settings_form"
name="mailpoet_settings_form"
class="mailpoet_form"
autocomplete="off"
novalidate
>
<!-- tabs -->
<h2 class="nav-tab-wrapper" id="mailpoet_settings_tabs">
<a class="nav-tab" href="#basics"><%= __('Basics') %></a>
<a class="nav-tab" href="#signup"><%= __('Signup Confirmation') %></a>
<a class="nav-tab" href="#mta"><%= __('Send With...') %></a>
<a class="nav-tab" href="#advanced"><%= __('Advanced') %></a>
</h2>
<!-- basics -->
<div data-tab="basics" class="mailpoet_panel">
<% include 'settings/basics.html' %>
</div>
<!-- signup confirmation -->
<div data-tab="signup" class="mailpoet_panel">
<% include 'settings/signup.html' %>
</div>
<!-- sending method -->
<div data-tab="mta" class="mailpoet_panel">
<% include 'settings/mta.html' %>
</div>
<!-- advanced -->
<div data-tab="advanced" class="mailpoet_panel">
<% include 'settings/advanced.html' %>
</div>
<p class="submit mailpoet_settings_submit" style="display:none;">
<input
type="submit"
class="button button-primary"
name="submit"
value="<%= ('Save settings') %>"
/>
</p>
</form>
</div>
<script type="text/javascript">
jQuery(function($) {
// on dom loaded
$(function() {
// on form submission
$('#mailpoet_settings_form').on('submit', function() {
// if we're setting up a sending method, try to activate it
if ($('.mailpoet_mta_setup_save').is(':visible')) {
$('.mailpoet_mta_setup_save').trigger('click');
}
saveSettings();
return false;
});
function saveSettings() {
// serialize form data
var settings_data = $('#mailpoet_settings_form').serializeObject();
// show loading screen
MailPoet.Modal.loading(true);
MailPoet.Ajax.post({
endpoint: 'settings',
action: 'set',
data: settings_data
}).done(function(response) {
MailPoet.Notice.success(
"<%= __('Settings saved') %>",
{ scroll: true }
);
MailPoet.Modal.loading(false);
}).fail(function(response) {
if (response.errors !== undefined) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
}
MailPoet.Modal.loading(false);
});
}
// setup toggle checkboxes
function toggleContent() {
$('#'+$(this).data('toggle'))[
($(this).is(':checked'))
? 'show'
: 'hide'
]();
}
$(document).on('click', 'input[data-toggle]', toggleContent);
$('input[data-toggle]').each(toggleContent);
// page preview
$('.mailpoet_page_preview').on('click', function() {
var selection = $(this).siblings('.mailpoet_page_selection');
if(selection.length > 0) {
$(this).attr('href', $(selection).find('option[value="'+$(selection).val()+'"]').data('preview-url'));
$(this).attr('target', '_blank');
} else {
$(this).attr('href', 'javascript:;');
$(this).removeAttr('target');
}
});
});
});
</script>
<% endblock %>