Skip to content

Commit

Permalink
Merge pull request #2462 from QuizandSurveyMaster/CU-867968jpx-email-…
Browse files Browse the repository at this point in the history
…and-result-page-redesign

Cu 867968jpx email and result page redesign
  • Loading branch information
zubairraeen authored Feb 7, 2024
2 parents 99ef159 + 720ed5f commit b448f1a
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 29 deletions.
31 changes: 13 additions & 18 deletions css/qsm-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
57 changes: 53 additions & 4 deletions js/qsm-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
};
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -3607,14 +3653,17 @@ 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();
});
$('#results-pages').on('click', '.delete-condition-button', function (event) {
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();
});
});
}
}
Expand Down
16 changes: 12 additions & 4 deletions php/admin/options-page-email-tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,12 @@ function qsm_options_emails_tab_template() {
<script type="text/template" id="tmpl-email">
<div class="qsm-email">
<header class="qsm-email-header">
<div><button class="delete-email-button"><span class="dashicons dashicons-trash"></span></button></div>
<strong><?php esc_html_e( 'Email Template ', 'quiz-master-next' ); ?> {{data.id}}</strong>
<div class="qsm-template-btn-group">
<button class="qsm-delete-email-button"><span class="dashicons dashicons-trash"></span></button>
<button class="qsm-duplicate-email-template-button"><span class="dashicons dashicons-admin-page"></span></button>
<button class="qsm-toggle-email-template-button"><span class="dashicons dashicons-arrow-down-alt2"></span></button>
<div>
</header>
<main class="qsm-email-content">
<div class="email-when">
Expand All @@ -190,12 +195,15 @@ function qsm_options_emails_tab_template() {
</div>
<label><?php esc_html_e( 'Who to send the email to? Put %USER_EMAIL% to send to user', 'quiz-master-next' ); ?></label>
<?php do_action( 'qsm_after_send_email_label' ); ?>
<input type="email" class="to-email" value="{{ data.to }}">
<input type="email" class="qsm-to-email" value="{{ data.to }}">
<label class="qsm-email-reply-to">
<input type="checkbox" class="reply-to" <# if ( "true" == data.replyTo || true == data.replyTo ) { #>checked<# } #>>
<?php esc_html_e( 'Add user email as Reply-To', 'quiz-master-next' ); ?>
</label>
<label><?php esc_html_e( 'Email Subject', 'quiz-master-next' ); ?></label>
<input type="text" class="subject" value="{{ data.subject }}">
<input type="text" class="qsm-email-subject" value="{{ data.subject }}">
<label><?php esc_html_e( 'Email Content', 'quiz-master-next' ); ?></label>
<textarea id="email-template-{{ data.id }}" class="email-template">{{{ data.content }}}</textarea>
<label class="qsm-email-reply-to"><input type="checkbox" class="reply-to" <# if ( "true" == data.replyTo || true == data.replyTo ) { #>checked<# } #>>Add user email as Reply-To</label>
<?php do_action( 'qsm_email_page_after', $quiz_id, $categories ); ?>
</div>
</main>
Expand Down
7 changes: 6 additions & 1 deletion php/admin/options-page-results-page-tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,12 @@ function qsm_options_results_tab_template(){
<script type="text/template" id="tmpl-results-page">
<div class="results-page">
<header class="results-page-header">
<div><button class="delete-page-button"><span class="dashicons dashicons-trash"></span></button></div>
<strong><?php esc_html_e( 'Result Page ', 'quiz-master-next' ); ?> {{data.id}}</strong>
<div class="qsm-template-btn-group">
<button class="qsm-delete-result-button"><span class="dashicons dashicons-trash"></span></button>
<button class="qsm-duplicate-result-page-button"><span class="dashicons dashicons-admin-page"></span></button>
<button class="qsm-toggle-result-page-button"><span class="dashicons dashicons-arrow-down-alt2"></span></button>
<div>
</header>
<main class="results-page-content">
<div class="results-page-when">
Expand Down
4 changes: 2 additions & 2 deletions php/shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ function qsm_get_post_id_from_quiz_id( $quiz_id ) {
return $post_permalink;
}

add_filter( 'qmn_end_shortcode', 'qsm_display_popup_div', 10, 3 );
add_filter( 'qmn_end_shortcode', 'qsm_display_popup_div', 11, 3 );
function qsm_display_popup_div( $return_display, $qmn_quiz_options ) {
if ( '0' === $qmn_quiz_options->enable_result_after_timer_end && 0 < $qmn_quiz_options->timer_limit ) {
if ( 1 != $qmn_quiz_options->enable_result_after_timer_end && 0 < $qmn_quiz_options->timer_limit ) {
$return_display .= '<div style="display: none;" class="qsm-popup qsm-popup-slide" id="modal-3" aria-hidden="false">';
$return_display .= '<div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close="">';
$return_display .= '<div class="qsm-popup__container qmn_quiz_container" role="dialog" aria-modal="true">';
Expand Down

0 comments on commit b448f1a

Please sign in to comment.