diff --git a/css/qsm-admin.css b/css/qsm-admin.css index ba30f3e62..cf47d894f 100644 --- a/css/qsm-admin.css +++ b/css/qsm-admin.css @@ -465,26 +465,22 @@ span.qsm-quiz-name { .results-page-header, #qsm_emails .qsm-email-header { display: flex; align-items: center; - justify-content: flex-end; + justify-content: space-between; background-color: #fff; padding: 10px; border-bottom: 1px solid #dfd4d4; } -#qsm_emails .delete-email-button { +.qsm-delete-email-button, +.qsm-duplicate-email-template-button, +.qsm-toggle-email-template-button, +.qsm-delete-result-button, +.qsm-duplicate-result-page-button, +.qsm-toggle-result-page-button{ background: none; border: none; - color: #dc3232; - cursor: pointer; transition-duration: 200ms; -} -.delete-page-button { - border: none; - background: transparent; cursor: pointer; } -#qsm_emails .delete-email-button:hover { - transform: scale(1.2); -} .results-page-content, .qsm-email-content { display: flex; flex-direction: column; @@ -521,9 +517,6 @@ span.qsm-quiz-name { .qsm-email-condition-title { font-size: 16px; } -input[type="text"].results-page-redirect { - min-width: 100%; -} .qsm-result-condition-mode, .qsm-email-condition-mode { margin-bottom: 15px; @@ -553,13 +546,15 @@ input[type="text"].results-page-redirect { .email-show .label { display: block; } -.qsm-email-reply-to{ - margin-top: 10px; -} -.results-page-show textarea, .to-email, .subject, .email-template { +.results-page-show textarea, .email-show .qsm-email-reply-to, .qsm_tab_content input[type="text"].qsm-email-subject, .email-template, .qsm-to-email, .qsm_tab_content input[type="text"].results-page-redirect { width: 100%; margin-bottom: 10px; } +.qsm_tab_content input[type="text"].qsm-email-subject, +.qsm_tab_content input[type="text"].results-page-redirect{ + border-radius: 3px; + border-color: #8C8FAC; +} @media screen and (min-width: 760px) { .results-page-content, .qsm-email-content { flex-direction: row; diff --git a/js/qsm-admin.js b/js/qsm-admin.js index c3beda9b4..b4b1b2d3b 100644 --- a/js/qsm-admin.js +++ b/js/qsm-admin.js @@ -1475,8 +1475,8 @@ var QSMContact; } email = { 'conditions': [], - 'to': $(this).find('.to-email').val(), - 'subject': $(this).find('.subject').val(), + 'to': $(this).find('.qsm-to-email').val(), + 'subject': $(this).find('.qsm-email-subject').val(), 'content': email_content, 'replyTo': $(this).find('.reply-to').prop('checked'), }; @@ -1615,6 +1615,32 @@ var QSMContact; event.preventDefault(); QSMAdminEmails.newEmail(); }); + jQuery(document).on('click', '.qsm-duplicate-email-template-button', function () { + let template = jQuery(this).closest("header").next("main"); + let email_content = ''; + if (template.find('.email-template').parent('.wp-editor-container').length > 0) { + email_content = wp.editor.getContent(template.find('.email-template').attr('id')); + } else { + email_content = template.find('.email-template').val() + } + let conditions = []; + template.find('.email-condition').each(function () { + conditions.push({ + 'category': jQuery(this).find('.email-condition-category').val(), + 'extra_condition': jQuery(this).find('.email-extra-condition-category').val(), + 'criteria': jQuery(this).find('.email-condition-criteria').val(), + 'operator': jQuery(this).find('.email-condition-operator').val(), + 'value': jQuery(this).find('.email-condition-value').val() + }); + }); + let to = template.find('.qsm-to-email').val(); + let subject = template.find('.qsm-email-subject').val(); + let content = email_content; + let replyTo = template.find('.reply-to').prop('checked'); + + QSMAdminEmails.addEmail(conditions, to, subject, content, replyTo); + jQuery('html, body').animate({ scrollTop: jQuery('.qsm-email:last-child').offset().top - 150 }, 1000); + }); $('.save-emails').on('click', function (event) { event.preventDefault(); QSMAdminEmails.saveEmails(); @@ -1624,10 +1650,13 @@ var QSMContact; $page = $(this).closest('.qsm-email'); QSMAdminEmails.newCondition($page); }); - $('#qsm_emails').on('click', '.delete-email-button', function (event) { + $('#qsm_emails').on('click', '.qsm-delete-email-button', function (event) { event.preventDefault(); $(this).closest('.qsm-email').remove(); }); + jQuery(document).on('click', '.qsm-toggle-email-template-button', function () { + jQuery(this).closest("header").next("main").slideToggle(); + }); $('#qsm_emails').on('click', '.delete-condition-button', function (event) { event.preventDefault(); $(this).closest('.email-condition').remove(); @@ -3598,6 +3627,23 @@ var import_button; event.preventDefault(); QSMAdminResults.newResultsPage(); }); + jQuery(document).on('click', '.qsm-duplicate-result-page-button', function () { + let result_page = jQuery(this).closest("header").next("main"); + let conditions = []; + let redirect_value = result_page.find('.results-page-redirect').val(); + let page = wp.editor.getContent( result_page.find('.results-page-template').attr('id') ); + result_page.find('.results-page-condition').each(function () { + conditions.push({ + 'category': $(this).find('.results-page-condition-category').val(), + 'extra_condition': $(this).find('.results-page-extra-condition-category').val(), + 'criteria': $(this).find('.results-page-condition-criteria').val(), + 'operator': $(this).find('.results-page-condition-operator').val(), + 'value': $(this).find('.results-page-condition-value').val() + }); + }); + QSMAdminResults.addResultsPage(conditions, page, redirect_value); + jQuery('html, body').animate({ scrollTop: jQuery('.results-page:last-child').offset().top - 150 }, 1000); + }); $('.save-pages').on('click', function (event) { event.preventDefault(); QSMAdminResults.saveResults(); @@ -3607,7 +3653,7 @@ var import_button; $page = $(this).closest('.results-page'); QSMAdminResults.newCondition($page); }); - $('#results-pages').on('click', '.delete-page-button', function (event) { + $('#results-pages').on('click', '.qsm-delete-result-button', function (event) { event.preventDefault(); $(this).closest('.results-page').remove(); }); @@ -3615,6 +3661,9 @@ var import_button; event.preventDefault(); $(this).closest('.results-page-condition').remove(); }); + jQuery(document).on('click', '.qsm-toggle-result-page-button', function () { + jQuery(this).closest("header").next("main").slideToggle(); + }); }); } } diff --git a/php/admin/options-page-email-tab.php b/php/admin/options-page-email-tab.php index 7fcc1666b..476564933 100644 --- a/php/admin/options-page-email-tab.php +++ b/php/admin/options-page-email-tab.php @@ -170,7 +170,12 @@ function qsm_options_emails_tab_template() {