Changed source root directory

This commit is contained in:
2026-03-05 16:30:11 +01:00
parent dc85447ee1
commit 538f85d7a2
5868 changed files with 749734 additions and 99 deletions

View File

@@ -0,0 +1,469 @@
/**
* Deactivation survey modal styles.
*
* @package contact-form-7-mailchimp-extension
* @author renzo.johnson@gmail.com
* @copyright 2014-2026 https://renzojohnson.com
* @license GPL-3.0+
*/
:root {
--cmatic-modal-overlay-bg: rgba(0, 0, 0, 0.6);
--cmatic-modal-bg: #fff;
--cmatic-modal-max-width: 600px;
--cmatic-modal-border-radius: 8px;
--cmatic-modal-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
--cmatic-primary-color: #0073aa;
--cmatic-primary-hover: #005a87;
--cmatic-secondary-color: #f0f0f1;
--cmatic-secondary-hover: #dcdcde;
--cmatic-text-color: #1e1e1e;
--cmatic-text-light: #646970;
--cmatic-border-color: #dcdcde;
--cmatic-error-color: #d63638;
--cmatic-success-color: #00a32a;
--cmatic-transition: all 0.3s ease;
}
.cmatic-modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 100000;
overflow-y: auto;
}
.cmatic-modal--active {
display: flex;
align-items: center;
justify-content: center;
}
.cmatic-modal--active .cmatic-modal__overlay {
animation: modalOverlayFadeIn 0.3s ease;
}
.cmatic-modal--active .cmatic-modal__dialog {
animation: modalSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalOverlayFadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes modalSlideUp {
from { opacity: 0; transform: translateY(100px); }
to { opacity: 1; transform: translateY(0); }
}
.cmatic-modal--closing .cmatic-modal__overlay {
animation: modalOverlayFadeOut 0.3s ease;
}
.cmatic-modal--closing .cmatic-modal__dialog {
animation: modalSlideDown 0.3s ease;
}
@keyframes modalOverlayFadeOut {
from { opacity: 1; }
to { opacity: 0; }
}
@keyframes modalSlideDown {
from { opacity: 1; transform: translateY(0); }
to { opacity: 0; transform: translateY(50px); }
}
.cmatic-modal-open {
overflow: hidden;
}
.cmatic-modal__overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: var(--cmatic-modal-overlay-bg);
z-index: -1;
backdrop-filter: blur(5px);
}
.cmatic-modal__dialog {
position: relative;
max-width: var(--cmatic-modal-max-width);
width: 90%;
background: var(--cmatic-modal-bg);
border-radius: var(--cmatic-modal-border-radius);
box-shadow: var(--cmatic-modal-shadow);
margin: 20px auto;
}
.cmatic-modal__header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 6px 24px;
border-bottom: 1px solid var(--cmatic-border-color);
}
.cmatic-modal__header h2 {
margin: 0;
font-size: 16px;
font-weight: 600;
color: var(--cmatic-text-color);
}
.cmatic-modal__header .button {
margin-left: auto;
margin-right: 12px;
}
.cmatic-modal__close {
background: none;
border: none;
font-size: 28px;
line-height: 1;
color: var(--cmatic-text-light);
cursor: pointer;
padding: 0;
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 4px;
transition: var(--cmatic-transition);
}
.cmatic-modal__close:hover,
.cmatic-modal__close:focus {
background: var(--cmatic-secondary-color);
color: var(--cmatic-text-color);
}
.cmatic-modal__body {
padding: 24px;
max-height: calc(100vh - 300px);
overflow-y: auto;
}
.cmatic-modal__body > h3 {
margin: 0 0 20px;
font-size: 16px;
font-weight: 600;
color: var(--cmatic-text-color);
}
.cmatic-reasons {
display: flex;
flex-direction: column;
gap: 12px;
}
.cmatic-reason-btn {
background: linear-gradient(135deg, #f5f7fa 0%, #f8f9fa 100%);
border: 2px solid transparent;
padding: 16px 20px;
border-radius: 12px;
cursor: pointer;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
font-size: 14px;
color: var(--cmatic-text-color);
text-align: left;
font-family: inherit;
width: 100%;
line-height: 1.5;
position: relative;
overflow: hidden;
}
.cmatic-reason-btn:hover {
background: linear-gradient(135deg, #e8f0fe 0%, #f1f8ff 100%);
border-color: #f0f6fc;
}
.cmatic-reason-btn.selected {
background: linear-gradient(135deg, #f0f6fc 0%, #f0f6fc 100%);
border-color: #d8dde3;
color: var(--cmatic-text-color);
font-weight: 500;
box-shadow: 0 6px 16px rgba(26, 115, 232, 0.3);
}
.cmatic-reason-btn:focus-visible {
outline: 2px solid var(--cmatic-primary-color);
outline-offset: 2px;
}
.cmatic-input-wrapper {
margin-top: 12px;
animation: slideDown 0.3s ease;
}
@keyframes slideDown {
from { opacity: 0; transform: translateY(-10px); }
to { opacity: 1; transform: translateY(0); }
}
.cmatic-input-field {
width: 100%;
padding: 10px 14px;
border-radius: 6px;
font-size: 14px;
font-family: inherit;
}
.cmatic-input-field:focus {
outline: none;
}
.cmatic-input-field[type="text"] {
display: block;
}
select.cmatic-input-field {
cursor: pointer;
appearance: none;
background-color: #fff;
background-image: url(data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23646970' d='M6 9L1 4h10z'/%3E%3C/svg%3E);
background-repeat: no-repeat;
background-position: right 14px center;
background-size: 12px;
padding-right: 40px;
}
.cmatic-char-counter {
margin-top: 4px;
font-size: 12px;
color: var(--cmatic-text-light);
text-align: right;
}
.cmatic-error-message {
display: none;
margin-top: 16px;
padding: 12px;
background: #fcf0f1;
border: 1px solid var(--cmatic-error-color);
border-radius: 4px;
color: var(--cmatic-error-color);
font-size: 14px;
}
.cmatic-error-message--visible {
display: block;
}
.cmatic-modal__footer {
display: flex;
align-items: center;
justify-content: space-between;
flex-direction: row;
padding: 20px 24px;
border-top: 1px solid var(--cmatic-border-color);
gap: 16px;
}
.cmatic-modal__footer .button {
margin-left: auto;
}
.cmatic-skip-link {
color: var(--cmatic-text-light);
font-size: 13px;
text-decoration: none;
cursor: pointer;
transition: color 0.2s ease;
padding: 4px 8px;
}
.cmatic-skip-link:hover {
color: var(--cmatic-text-color);
text-decoration: underline;
}
@media (max-width: 640px) {
.cmatic-modal__dialog {
width: 95%;
margin: 10px auto;
}
.cmatic-modal__header,
.cmatic-modal__body,
.cmatic-modal__footer {
padding: 16px;
}
.cmatic-modal__footer {
flex-direction: column;
gap: 12px;
}
.cmatic-modal__footer .button {
width: 100%;
order: 1;
}
.cmatic-skip-link {
order: 2;
margin-top: 8px;
}
.cmatic-reason-btn {
padding: 14px 16px;
}
.cmatic-reasons {
gap: 10px;
}
}
.cmatic-modal__footer .button:focus-visible {
outline: 2px solid var(--cmatic-primary-color);
outline-offset: 2px;
}
@media (prefers-contrast: high) {
.cmatic-modal__dialog {
border: 2px solid currentcolor;
}
}
@media (prefers-reduced-motion: reduce) {
* {
transition: none !important;
}
}
/* ==========================================================================
Submission Feedback
========================================================================== */
.cmatic-modal__feedback {
display: flex;
align-items: flex-start;
gap: 12px;
padding: 16px;
margin-bottom: 16px;
border-radius: 8px;
background: #f0f6fc;
border: 1px solid #c3c4c7;
}
.cmatic-modal__feedback-icon {
flex-shrink: 0;
width: 24px;
height: 24px;
}
.cmatic-modal__feedback-icon .dashicons {
font-size: 24px;
width: 24px;
height: 24px;
}
.cmatic-modal__feedback-content {
flex: 1;
min-width: 0;
}
.cmatic-modal__feedback-title {
font-weight: 600;
font-size: 14px;
color: var(--cmatic-text-color);
margin-bottom: 4px;
}
.cmatic-modal__feedback-details {
font-size: 13px;
color: var(--cmatic-text-light);
}
/* Sent vs Received comparison table */
.cmatic-modal__feedback-table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
font-size: 13px;
}
.cmatic-modal__feedback-table th,
.cmatic-modal__feedback-table td {
padding: 6px 10px;
text-align: left;
border-bottom: 1px solid #e0e0e0;
}
.cmatic-modal__feedback-table th {
background: rgba(0, 0, 0, 0.03);
font-weight: 600;
font-size: 12px;
text-transform: uppercase;
letter-spacing: 0.5px;
color: var(--cmatic-text-light);
}
.cmatic-modal__feedback-table .field-key {
font-weight: 600;
color: var(--cmatic-text-color);
}
.cmatic-modal__feedback-table .field-empty {
color: #999;
font-style: italic;
}
.cmatic-modal__feedback-table .field-mismatch {
background: #fff8e5;
}
.cmatic-modal__feedback-table .field-mismatch td {
border-bottom-color: #f0c36d;
}
/* Success state */
.cmatic-modal__feedback--success {
background: #edfaef;
border-color: var(--cmatic-success-color);
}
.cmatic-modal__feedback--success .cmatic-modal__feedback-icon .dashicons {
color: var(--cmatic-success-color);
}
.cmatic-modal__feedback--success .cmatic-modal__feedback-title {
color: #006d1b;
}
/* Error state */
.cmatic-modal__feedback--error {
background: #fcf0f1;
border-color: var(--cmatic-error-color);
}
.cmatic-modal__feedback--error .cmatic-modal__feedback-icon .dashicons {
color: var(--cmatic-error-color);
}
.cmatic-modal__feedback--error .cmatic-modal__feedback-title {
color: #8a1f1f;
}
/* Skipped state */
.cmatic-modal__feedback--skipped {
background: #fff8e5;
border-color: #dba617;
}
.cmatic-modal__feedback--skipped .cmatic-modal__feedback-icon .dashicons {
color: #996800;
}
.cmatic-modal__feedback--skipped .cmatic-modal__feedback-title {
color: #614200;
}

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="7 9.5 8 1" enable-background="new 7 9.5 8 1" xml:space="preserve" preserveAspectRatio="none slice"><path fill="#CE1D00" d="M10.9 9.5l-1 1H12l1-1z"/><path fill="#2284C0" d="M14.9 9.5l-1 1H15v-1zM7 9.5v1h1l1-1z"/></svg>

After

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -0,0 +1,383 @@
/**
* Deactivation survey modal.
*
* @package contact-form-7-mailchimp-extension
* @author renzo.johnson@gmail.com
* @copyright 2014-2026 https://renzojohnson.com
* @license GPL-3.0+
*/
(function () {
'use strict';
const config = window.cmaticDeactivate || {};
let deactivateUrl = '';
let modalElement = null;
let pluginsCache = null;
const MAX_RETRIES = 3;
document.addEventListener('DOMContentLoaded', () => {
init();
});
function init() {
const deactivateLink = findDeactivateLink();
if (!deactivateLink) return;
deactivateUrl = deactivateLink.href;
buildModal();
attachEventListeners(deactivateLink);
}
function findDeactivateLink() {
const row = document.querySelector(`tr[data-slug="${config.pluginSlug}"]`);
return row ? row.querySelector('.deactivate a') : null;
}
function buildModal() {
modalElement = document.getElementById('cmatic-deactivate-modal');
if (!modalElement) return;
modalElement.innerHTML = `
<div class="cmatic-modal__overlay"></div>
<div class="cmatic-modal__dialog">
<div class="cmatic-modal__header">
<h2 id="cmatic-modal-title">${config.strings.title}</h2>
<button type="button" class="cmatic-modal__close" aria-label="${config.strings.closeLabel}">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="cmatic-modal__body">
<h3 id="cmatic-modal-description">${config.strings.description}</h3>
<form id="cmatic-deactivate-form">
<div class="cmatic-reasons" role="radiogroup" aria-labelledby="cmatic-modal-description">
${buildReasonsList()}
</div>
<div class="cmatic-error-message" role="alert" aria-live="assertive"></div>
</form>
</div>
<div class="cmatic-modal__footer">
<a href="#" class="cmatic-skip-link" style="display: none;">${config.strings.skipButton}</a>
<button type="submit" form="cmatic-deactivate-form" class="button button-primary cmatic-submit-button">
${config.strings.submitButton}
</button>
</div>
</div>
`;
}
function buildReasonsList() {
return config.reasons.map(reason => {
return `
<button type="button" class="cmatic-reason-btn" data-reason-id="${reason.id}" data-input-type="${reason.input_type}" aria-pressed="false">
${reason.text}
</button>
`;
}).join('');
}
function buildInputField(reasonId, inputType) {
const reason = config.reasons.find(r => r.id === reasonId);
if (!reason) return '';
let inputHtml = '';
if (inputType === 'plugin-dropdown') {
inputHtml = `<select class="cmatic-input-field" aria-label="${reason.placeholder || 'Select a plugin'}" disabled><option value="">Loading plugins...</option></select>`;
} else if (inputType === 'textfield') {
inputHtml = `<input type="text" class="cmatic-input-field" placeholder="${reason.placeholder}" maxlength="${reason.max_length || 200}" aria-label="${reason.placeholder}" />`;
}
if (inputHtml) {
return `<div class="cmatic-input-wrapper">${inputHtml}</div>`;
}
return '';
}
async function fetchPluginsList() {
if (pluginsCache) return pluginsCache;
try {
const response = await fetch(config.pluginsUrl, {
method: 'GET',
headers: {
'X-WP-Nonce': config.restNonce,
},
});
if (response.ok) {
pluginsCache = await response.json();
return pluginsCache;
}
} catch (error) {
console.error('ChimpMatic: Failed to fetch plugins list', error);
}
return [];
}
function populatePluginDropdown(selectElement, plugins) {
let optionsHtml = '<option value="">-- Select Plugin --</option>';
if (plugins && plugins.length > 0) {
plugins.forEach(plugin => {
optionsHtml += `<option value="${plugin.value}">${plugin.label}</option>`;
});
}
selectElement.innerHTML = optionsHtml;
selectElement.disabled = false;
}
function attachEventListeners(deactivateLink) {
deactivateLink.addEventListener('click', handleDeactivateClick);
modalElement.querySelector('.cmatic-modal__close').addEventListener('click', closeModal);
modalElement.querySelector('.cmatic-skip-link').addEventListener('click', handleSkip);
modalElement.querySelector('#cmatic-deactivate-form').addEventListener('submit', handleSubmit);
modalElement.querySelectorAll('.cmatic-reason-btn').forEach(btn => btn.addEventListener('click', handleReasonClick));
document.addEventListener('keydown', handleKeydown);
modalElement.querySelector('.cmatic-modal__overlay').addEventListener('click', handleOverlayClick);
}
function handleDeactivateClick(evt) {
evt.preventDefault();
openModal();
}
function openModal() {
modalElement.classList.add('cmatic-modal--active');
document.body.classList.add('cmatic-modal-open');
const firstBtn = modalElement.querySelector('.cmatic-reason-btn');
if (firstBtn) firstBtn.focus();
trapFocus();
setTimeout(() => {
const skipLink = modalElement.querySelector('.cmatic-skip-link');
if (skipLink) {
skipLink.style.display = 'inline';
skipLink.style.animation = 'fadeIn 0.3s ease';
}
}, 10000);
}
function closeModal() {
modalElement.classList.add('cmatic-modal--closing');
setTimeout(() => {
modalElement.classList.remove('cmatic-modal--active', 'cmatic-modal--closing');
document.body.classList.remove('cmatic-modal-open');
resetForm();
}, 300);
}
function handleSkip(evt) {
evt.preventDefault();
const skipData = {
reason_id: 0,
reason_text: '',
};
const submitBtn = modalElement.querySelector('.cmatic-submit-btn');
const skipLink = modalElement.querySelector('.cmatic-skip-link');
submitBtn.disabled = true;
submitBtn.textContent = cmaticData.i18n.submitting;
skipLink.style.display = 'none';
fetch(cmaticData.restUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-WP-Nonce': cmaticData.nonce,
},
body: JSON.stringify(skipData),
}).finally(() => {
window.location.href = deactivateUrl;
});
}
async function handleReasonClick(evt) {
const clickedBtn = evt.currentTarget;
const reasonId = parseInt(clickedBtn.dataset.reasonId, 10);
const inputType = clickedBtn.dataset.inputType;
modalElement.querySelectorAll('.cmatic-reason-btn').forEach(btn => {
btn.classList.remove('selected');
btn.setAttribute('aria-pressed', 'false');
const nextEl = btn.nextElementSibling;
if (nextEl && nextEl.classList.contains('cmatic-input-wrapper')) {
nextEl.remove();
}
});
clickedBtn.classList.add('selected');
clickedBtn.setAttribute('aria-pressed', 'true');
if (inputType && inputType !== '') {
const inputHtml = buildInputField(reasonId, inputType);
if (inputHtml) {
clickedBtn.insertAdjacentHTML('afterend', inputHtml);
const input = clickedBtn.nextElementSibling.querySelector('.cmatic-input-field');
if (inputType === 'plugin-dropdown' && input) {
const plugins = await fetchPluginsList();
populatePluginDropdown(input, plugins);
input.focus();
} else if (input) {
setTimeout(() => input.focus(), 100);
}
}
}
hideValidationError();
}
async function handleSubmit(evt) {
evt.preventDefault();
if (!validateForm()) return;
const selectedBtn = modalElement.querySelector('.cmatic-reason-btn.selected');
const reasonId = parseInt(selectedBtn.dataset.reasonId, 10);
const inputWrapper = selectedBtn.nextElementSibling;
const inputField = inputWrapper && inputWrapper.classList.contains('cmatic-input-wrapper')
? inputWrapper.querySelector('.cmatic-input-field')
: null;
const reasonText = inputField ? inputField.value.trim() : '';
setButtonsDisabled(true);
try {
await submitFeedback(reasonId, reasonText);
} catch (error) {
console.error('ChimpMatic: Failed to submit feedback', error);
}
window.location.href = deactivateUrl;
}
function validateForm() {
const selectedBtn = modalElement.querySelector('.cmatic-reason-btn.selected');
if (!selectedBtn) {
showValidationError(config.strings.errorRequired);
return false;
}
const inputWrapper = selectedBtn.nextElementSibling;
if (!inputWrapper || !inputWrapper.classList.contains('cmatic-input-wrapper')) {
hideValidationError();
return true;
}
const inputField = inputWrapper.querySelector('.cmatic-input-field');
if (!inputField) {
hideValidationError();
return true;
}
if (inputField.type === 'text' && inputField.value.trim() === '') {
showValidationError(config.strings.errorDetails);
inputField.focus();
return false;
}
if (inputField.tagName === 'SELECT' && inputField.value === '') {
showValidationError(config.strings.errorDropdown);
inputField.focus();
return false;
}
hideValidationError();
return true;
}
async function submitFeedback(reasonId, reasonText, retry = 0) {
const response = await fetch(config.restUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-WP-Nonce': config.restNonce,
},
body: JSON.stringify({ reason_id: reasonId, reason_text: reasonText }),
});
if (!response.ok) {
if (retry < MAX_RETRIES) {
const delay = Math.pow(2, retry) * 1000;
await new Promise(resolve => setTimeout(resolve, delay));
console.warn(`ChimpMatic: Retry ${retry + 1}/${MAX_RETRIES}`);
return submitFeedback(reasonId, reasonText, retry + 1);
}
throw new Error('Failed to submit feedback');
}
return response.json();
}
function showValidationError(message) {
const errorEl = modalElement.querySelector('.cmatic-error-message');
errorEl.textContent = message;
errorEl.classList.add('cmatic-error-message--visible');
}
function hideValidationError() {
const errorEl = modalElement.querySelector('.cmatic-error-message');
errorEl.textContent = '';
errorEl.classList.remove('cmatic-error-message--visible');
}
function handleKeydown(evt) {
if (!modalElement.classList.contains('cmatic-modal--active')) return;
if (evt.key === 'Escape') {
evt.preventDefault();
closeModal();
}
}
function handleOverlayClick() {
const textInputs = modalElement.querySelectorAll('input[type="text"]');
const selects = modalElement.querySelectorAll('select');
const hasContent = Array.from(textInputs).some(input => input.value.trim() !== '') ||
Array.from(selects).some(select => select.value !== '');
if (hasContent) {
const confirmed = confirm('You have unsaved feedback. Close anyway?');
if (confirmed) closeModal();
} else {
closeModal();
}
}
function trapFocus() {
const focusableElements = modalElement.querySelectorAll('button, input, select, [tabindex]:not([tabindex="-1"])');
if (focusableElements.length === 0) return;
const firstFocusable = focusableElements[0];
const lastFocusable = focusableElements[focusableElements.length - 1];
function handleTabKey(evt) {
if (evt.key !== 'Tab') return;
if (evt.shiftKey && document.activeElement === firstFocusable) {
evt.preventDefault();
lastFocusable.focus();
} else if (!evt.shiftKey && document.activeElement === lastFocusable) {
evt.preventDefault();
firstFocusable.focus();
}
}
modalElement.addEventListener('keydown', handleTabKey);
}
function resetForm() {
modalElement.querySelectorAll('.cmatic-reason-btn').forEach(btn => {
btn.classList.remove('selected');
btn.setAttribute('aria-pressed', 'false');
const nextEl = btn.nextElementSibling;
if (nextEl && nextEl.classList.contains('cmatic-input-wrapper')) {
nextEl.remove();
}
});
hideValidationError();
setButtonsDisabled(false);
const skipLink = modalElement.querySelector('.cmatic-skip-link');
if (skipLink) skipLink.style.display = 'none';
}
function setButtonsDisabled(disabled) {
modalElement.querySelectorAll('.button').forEach(button => button.disabled = disabled);
}
})();

View File

@@ -0,0 +1,56 @@
/**
* Admin notices handler.
*
* @package contact-form-7-mailchimp-extension
* @author renzo.johnson@gmail.com
* @copyright 2014-2026 https://renzojohnson.com
* @license GPL-3.0+
*/
'use strict';
(function() {
document.addEventListener('DOMContentLoaded', function() {
if (typeof chimpmaticNotices === 'undefined') {
return;
}
document.addEventListener('click', function(event) {
if (event.target.classList.contains('notice-dismiss')) {
const noticeElement = event.target.closest('#mce-notice');
if (noticeElement) {
event.preventDefault();
dismissNotice(noticeElement);
}
}
});
async function dismissNotice(noticeElement) {
try {
const response = await fetch(`${chimpmaticNotices.restUrl}/notices/dismiss`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-WP-Nonce': chimpmaticNotices.restNonce
}
});
const data = await response.json();
if (response.ok && data.success) {
noticeElement.style.transition = 'opacity 0.3s ease-out';
noticeElement.style.opacity = '0';
setTimeout(() => {
noticeElement.style.display = 'none';
}, 300);
}
} catch (error) {
console.error('[ChimpMatic Lite] Dismiss notice error:', error);
}
}
});
})();