form
9 years ago
newsletter
9 years ago
settings
9 years ago
subscribers
9 years ago
forms.html
9 years ago
index.html
9 years ago
index.php
9 years ago
layout.html
9 years ago
limit.html
9 years ago
newsletters.html
9 years ago
segments.html
9 years ago
settings.html
9 years ago
update.html
9 years ago
welcome.html
9 years ago
settings.html
125 lines
| 1 | <% extends 'layout.html' %> |
| 2 | |
| 3 | <% block content %> |
| 4 | <div id="mailpoet_settings"> |
| 5 | |
| 6 | <h1 class="title"><%= __('Settings') %></h1> |
| 7 | |
| 8 | <!-- settings form --> |
| 9 | <form |
| 10 | id="mailpoet_settings_form" |
| 11 | name="mailpoet_settings_form" |
| 12 | class="mailpoet_form" |
| 13 | autocomplete="off" |
| 14 | novalidate |
| 15 | > |
| 16 | <!-- tabs --> |
| 17 | <h2 class="nav-tab-wrapper" id="mailpoet_settings_tabs"> |
| 18 | <a class="nav-tab" href="#basics"><%= __('Basics') %></a> |
| 19 | <a class="nav-tab" href="#signup"><%= __('Signup Confirmation') %></a> |
| 20 | <a class="nav-tab" href="#mta"><%= __('Send With...') %></a> |
| 21 | <a class="nav-tab" href="#advanced"><%= __('Advanced') %></a> |
| 22 | </h2> |
| 23 | |
| 24 | <!-- basics --> |
| 25 | <div data-tab="basics" class="mailpoet_panel"> |
| 26 | <% include 'settings/basics.html' %> |
| 27 | </div> |
| 28 | |
| 29 | <!-- signup confirmation --> |
| 30 | <div data-tab="signup" class="mailpoet_panel"> |
| 31 | <% include 'settings/signup.html' %> |
| 32 | </div> |
| 33 | |
| 34 | <!-- sending method --> |
| 35 | <div data-tab="mta" class="mailpoet_panel"> |
| 36 | <% include 'settings/mta.html' %> |
| 37 | </div> |
| 38 | |
| 39 | <!-- advanced --> |
| 40 | <div data-tab="advanced" class="mailpoet_panel"> |
| 41 | <% include 'settings/advanced.html' %> |
| 42 | </div> |
| 43 | |
| 44 | <p class="submit mailpoet_settings_submit" style="display:none;"> |
| 45 | <input |
| 46 | type="submit" |
| 47 | class="button button-primary" |
| 48 | name="submit" |
| 49 | value="<%= ('Save settings') %>" |
| 50 | /> |
| 51 | </p> |
| 52 | </form> |
| 53 | </div> |
| 54 | |
| 55 | <script type="text/javascript"> |
| 56 | jQuery(function($) { |
| 57 | // on dom loaded |
| 58 | $(function() { |
| 59 | // on form submission |
| 60 | $('#mailpoet_settings_form').on('submit', function() { |
| 61 | // if we're setting up a sending method, try to activate it |
| 62 | if ($('.mailpoet_mta_setup_save').is(':visible')) { |
| 63 | $('.mailpoet_mta_setup_save').trigger('click'); |
| 64 | } |
| 65 | saveSettings(); |
| 66 | return false; |
| 67 | }); |
| 68 | |
| 69 | function saveSettings() { |
| 70 | // serialize form data |
| 71 | var settings_data = $('#mailpoet_settings_form').serializeObject(); |
| 72 | |
| 73 | // show loading screen |
| 74 | MailPoet.Modal.loading(true); |
| 75 | |
| 76 | MailPoet.Ajax.post({ |
| 77 | endpoint: 'settings', |
| 78 | action: 'set', |
| 79 | data: settings_data |
| 80 | }).always(function() { |
| 81 | MailPoet.Modal.loading(false); |
| 82 | }).done(function(response) { |
| 83 | MailPoet.Notice.success( |
| 84 | "<%= __('Settings saved') %>", |
| 85 | { scroll: true } |
| 86 | ); |
| 87 | }).fail(function(response) { |
| 88 | if (response.errors.length > 0) { |
| 89 | MailPoet.Notice.error( |
| 90 | response.errors.map(function(error) { return error.message; }), |
| 91 | { scroll: true } |
| 92 | ); |
| 93 | } |
| 94 | }); |
| 95 | } |
| 96 | |
| 97 | // setup toggle checkboxes |
| 98 | function toggleContent() { |
| 99 | $('#'+$(this).data('toggle'))[ |
| 100 | ($(this).is(':checked')) |
| 101 | ? 'show' |
| 102 | : 'hide' |
| 103 | ](); |
| 104 | } |
| 105 | |
| 106 | $(document).on('click', 'input[data-toggle]', toggleContent); |
| 107 | $('input[data-toggle]').each(toggleContent); |
| 108 | |
| 109 | // page preview |
| 110 | $('.mailpoet_page_preview').on('click', function() { |
| 111 | var selection = $(this).siblings('.mailpoet_page_selection'); |
| 112 | |
| 113 | if (selection.length > 0) { |
| 114 | $(this).attr('href', $(selection).find('option[value="'+$(selection).val()+'"]').data('preview-url')); |
| 115 | $(this).attr('target', '_blank'); |
| 116 | } else { |
| 117 | $(this).attr('href', 'javascript:;'); |
| 118 | $(this).removeAttr('target'); |
| 119 | } |
| 120 | }); |
| 121 | }); |
| 122 | }); |
| 123 | </script> |
| 124 | <% endblock %> |
| 125 |