Initial commit
This commit is contained in:
@@ -0,0 +1,263 @@
|
||||
/* ============================================================
|
||||
THALIM Newsletter — Admin styles
|
||||
All rules scoped to .thalim-nl-* or .wrap.thalim-nl-wrap
|
||||
============================================================ */
|
||||
|
||||
.thalim-nl-layout {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 360px;
|
||||
gap: 30px;
|
||||
margin-top: 20px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
/* ---- Month row ---- */
|
||||
.thalim-nl-month-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.thalim-nl-month-row input[type="month"] {
|
||||
font-size: 15px;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
.thalim-nl-spinner.spinner {
|
||||
float: none;
|
||||
margin: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.thalim-nl-spinner.spinner.is-active {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
/* ---- Intro / Conclusion editors ---- */
|
||||
.thalim-nl-intro,
|
||||
.thalim-nl-conclusion {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.thalim-nl-intro label,
|
||||
.thalim-nl-conclusion label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.thalim-nl-conclusion {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
/* ---- Category groups ---- */
|
||||
.thalim-nl-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.thalim-nl-group-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
color: #50575e;
|
||||
margin: 0 0 8px 0;
|
||||
padding-bottom: 4px;
|
||||
border-bottom: 2px solid #dcdcde;
|
||||
}
|
||||
|
||||
/* ---- Section dropdowns (details/summary) ---- */
|
||||
.thalim-nl-section {
|
||||
border: 1px solid #ccd0d4;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 6px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.thalim-nl-section-summary {
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
color: #1d2327;
|
||||
padding: 8px 14px;
|
||||
cursor: pointer;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.thalim-nl-section-summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.thalim-nl-section-summary::before {
|
||||
content: '▸';
|
||||
display: inline-block;
|
||||
font-size: 11px;
|
||||
color: #888;
|
||||
transition: transform 0.15s ease;
|
||||
flex-shrink: 0;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
.thalim-nl-section[open] > .thalim-nl-section-summary::before {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.thalim-nl-section-summary:hover {
|
||||
background: #f6f7f7;
|
||||
}
|
||||
|
||||
.thalim-nl-section-body {
|
||||
padding: 2px 14px 10px 14px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.thalim-nl-count {
|
||||
font-weight: normal;
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.thalim-nl-post-row {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
padding: 4px 0;
|
||||
cursor: pointer;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.thalim-nl-post-row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.thalim-nl-post-row input[type="checkbox"] {
|
||||
flex-shrink: 0;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.thalim-nl-post-title {
|
||||
flex: 1;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.thalim-nl-post-view {
|
||||
flex-shrink: 0;
|
||||
color: #b4b9be;
|
||||
text-decoration: none;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.thalim-nl-post-view:hover {
|
||||
color: #2271b1;
|
||||
}
|
||||
|
||||
.thalim-nl-post-view .dashicons {
|
||||
font-size: 16px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.thalim-nl-post-date {
|
||||
font-size: 11px;
|
||||
color: #888;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* ---- Séances list under seminars ---- */
|
||||
.thalim-nl-seances-list {
|
||||
margin: 2px 0 6px 28px;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
border-left: 2px solid #dcdcde;
|
||||
padding-left: 12px;
|
||||
}
|
||||
|
||||
.thalim-nl-seance-item {
|
||||
padding: 3px 0;
|
||||
font-size: 12px;
|
||||
color: #50575e;
|
||||
}
|
||||
|
||||
.thalim-nl-seance-title {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.thalim-nl-seance-meta {
|
||||
display: block;
|
||||
color: #888;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
/* ---- Empty state ---- */
|
||||
.thalim-nl-empty {
|
||||
color: #666;
|
||||
font-style: italic;
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
/* ---- Past newsletters table ---- */
|
||||
.thalim-nl-past {
|
||||
background: #fff;
|
||||
border: 1px solid #ccd0d4;
|
||||
border-radius: 4px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.thalim-nl-past h2 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.thalim-nl-past-table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.thalim-nl-past-table th,
|
||||
.thalim-nl-past-table td {
|
||||
padding: 8px 10px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.thalim-nl-past-table th {
|
||||
font-weight: 600;
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.thalim-nl-past-table td:last-child {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.thalim-nl-past-table .button + .button {
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
/* ---- Subscribe / Unsubscribe link fields ---- */
|
||||
.thalim-nl-links-row {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.thalim-nl-link-field {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.thalim-nl-link-field label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.thalim-nl-link-field input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* ---- Responsive fallback ---- */
|
||||
@media (max-width: 1100px) {
|
||||
.thalim-nl-layout {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
/* global thalimNL, tinymce */
|
||||
(function ($) {
|
||||
'use strict';
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Month change → AJAX reload sections + update TinyMCE intro
|
||||
// -------------------------------------------------------------------------
|
||||
$('#thalim-nl-month').on('change', function () {
|
||||
var month = $(this).val();
|
||||
var $wrap = $('#thalim-nl-sections-wrap');
|
||||
var $spin = $('.thalim-nl-spinner');
|
||||
|
||||
if (!month) return;
|
||||
|
||||
$spin.addClass('is-active');
|
||||
$wrap.css('opacity', '0.5');
|
||||
|
||||
$.post(thalimNL.ajaxUrl, {
|
||||
action: 'thalim_nl_load_month',
|
||||
month: month,
|
||||
_wpnonce: thalimNL.nonce,
|
||||
})
|
||||
.done(function (response) {
|
||||
if (!response.success) return;
|
||||
|
||||
$wrap.html(response.data.html);
|
||||
|
||||
// Update TinyMCE intro — do NOT re-render wp_editor
|
||||
var introEditor = typeof tinymce !== 'undefined' && tinymce.get('thalim_nl_intro');
|
||||
if (introEditor) {
|
||||
introEditor.setContent(response.data.intro || '');
|
||||
} else {
|
||||
$('#thalim_nl_intro').val(response.data.intro || '');
|
||||
}
|
||||
|
||||
// Update TinyMCE conclusion
|
||||
var conclusionEditor = typeof tinymce !== 'undefined' && tinymce.get('thalim_nl_conclusion');
|
||||
if (conclusionEditor) {
|
||||
conclusionEditor.setContent(response.data.conclusion || '');
|
||||
} else {
|
||||
$('#thalim_nl_conclusion').val(response.data.conclusion || '');
|
||||
}
|
||||
|
||||
// Update subscribe/unsubscribe URLs
|
||||
$('#thalim-nl-subscribe').val(response.data.subscribe_url || '');
|
||||
$('#thalim-nl-unsubscribe').val(response.data.unsubscribe_url || '');
|
||||
})
|
||||
.fail(function () {
|
||||
$wrap.html('<p class="thalim-nl-empty">Erreur lors du chargement.</p>');
|
||||
})
|
||||
.always(function () {
|
||||
$spin.removeClass('is-active');
|
||||
$wrap.css('opacity', '1');
|
||||
});
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Fetch newsletter HTML (shared by download & preview)
|
||||
// -------------------------------------------------------------------------
|
||||
function fetchNewsletterHTML(postId) {
|
||||
return $.post(thalimNL.ajaxUrl, {
|
||||
action: 'thalim_nl_export_html',
|
||||
post_id: postId,
|
||||
_wpnonce: thalimNL.nonce,
|
||||
});
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Download HTML file
|
||||
// -------------------------------------------------------------------------
|
||||
$(document).on('click', '.thalim-nl-download', function () {
|
||||
var $btn = $(this);
|
||||
var postId = $btn.data('post-id');
|
||||
var filename = $btn.data('filename') || 'newsletter-THALIM.html';
|
||||
var origText = $btn.text();
|
||||
|
||||
$btn.prop('disabled', true).text('…');
|
||||
|
||||
fetchNewsletterHTML(postId)
|
||||
.done(function (response) {
|
||||
if (!response.success) {
|
||||
alert('Erreur : ' + (response.data || 'Impossible d\'exporter le HTML.'));
|
||||
return;
|
||||
}
|
||||
var blob = new Blob([response.data.html], { type: 'text/html;charset=utf-8' });
|
||||
var url = URL.createObjectURL(blob);
|
||||
var a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
})
|
||||
.fail(function () {
|
||||
alert('Erreur réseau lors de l\'export.');
|
||||
})
|
||||
.always(function () {
|
||||
$btn.prop('disabled', false).text(origText);
|
||||
});
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Preview in new window
|
||||
// -------------------------------------------------------------------------
|
||||
$(document).on('click', '.thalim-nl-preview', function () {
|
||||
var $btn = $(this);
|
||||
var postId = $btn.data('post-id');
|
||||
var origText = $btn.text();
|
||||
|
||||
$btn.prop('disabled', true).text('…');
|
||||
|
||||
fetchNewsletterHTML(postId)
|
||||
.done(function (response) {
|
||||
if (!response.success) {
|
||||
alert('Erreur : ' + (response.data || 'Impossible de charger la prévisualisation.'));
|
||||
return;
|
||||
}
|
||||
var win = window.open('', '_blank');
|
||||
if (win) {
|
||||
win.document.open();
|
||||
win.document.write(response.data.html);
|
||||
win.document.close();
|
||||
} else {
|
||||
alert('Le navigateur a bloqué l\'ouverture de la fenêtre. Autorisez les pop-ups pour ce site.');
|
||||
}
|
||||
})
|
||||
.fail(function () {
|
||||
alert('Erreur réseau lors du chargement.');
|
||||
})
|
||||
.always(function () {
|
||||
$btn.prop('disabled', false).text(origText);
|
||||
});
|
||||
});
|
||||
|
||||
}(jQuery));
|
||||
Reference in New Issue
Block a user