fix(theme): align reference layouts and restore passing contracts
Align homepage and category discovery, modern widgets, admin controls, quotes, and comments with the reference theme. Remove superseded paths and add rendering and behavior coverage. Update stale asset and finance contracts; all 760 Node tests and 139 widget assertions pass.
This commit is contained in:
1 parent
b520d29368
commit
8aa116ec43
63 files changed
+1985
-2304
No files matched your search
@@ -48,9 +48,17 @@
|
||||
});
|
||||
}
|
||||
|
||||
function resolveWidgetNumber(inputName, widgetId, fallback) {
|
||||
var inputMatch = String(inputName || '').match(/\[(\d+)\]/);
|
||||
var idMatch = String(widgetId || '').match(/-(\d+)$/);
|
||||
var number = inputMatch ? inputMatch[1] : (idMatch ? idMatch[1] : String(fallback || ''));
|
||||
return /^\d+$/.test(number) && Number(number) > 0 ? number : '';
|
||||
}
|
||||
|
||||
return {
|
||||
parseDependency: parseDependency,
|
||||
dependencyVisible: dependencyVisible,
|
||||
replaceRepeaterIndexes: replaceRepeaterIndexes
|
||||
replaceRepeaterIndexes: replaceRepeaterIndexes,
|
||||
resolveWidgetNumber: resolveWidgetNumber
|
||||
};
|
||||
});
|
||||
+80
-19
@@ -1,13 +1,15 @@
|
||||
.aksrt-widget-form {
|
||||
--aksrt-field-border: #dcdcde;
|
||||
--aksrt-field-accent: #2271b1;
|
||||
--aksrt-field-accent: #0991f5;
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
padding: 4px 0 10px;
|
||||
gap: 0;
|
||||
padding: 0 0 8px;
|
||||
}
|
||||
|
||||
.aksrt-widget-field {
|
||||
min-width: 0;
|
||||
padding: 11px 0;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.aksrt-widget-field[hidden] {
|
||||
@@ -18,12 +20,27 @@
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
font-weight: 600;
|
||||
color: #0991f5;
|
||||
}
|
||||
|
||||
.customize-control-widget_form .aksrt-widget-field__label { color: inherit; }
|
||||
|
||||
.aksrt-widget-field .description {
|
||||
margin: -2px 0 7px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.aksrt-widget-field--switcher {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
column-gap: 12px;
|
||||
}
|
||||
|
||||
.aksrt-widget-field--switcher .aksrt-widget-field__label { margin: 0; }
|
||||
.aksrt-widget-field--switcher .description { grid-column: 1 / -1; grid-row: 2; }
|
||||
.aksrt-widget-field--switcher > .aksrt-widget-switch { grid-column: 2; grid-row: 1; }
|
||||
|
||||
.aksrt-widget-switch {
|
||||
display: inline-flex;
|
||||
cursor: pointer;
|
||||
@@ -70,12 +87,12 @@
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.aksrt-widget-choices label span {
|
||||
.aksrt-widget-choices label > span {
|
||||
display: block;
|
||||
padding: 5px 9px;
|
||||
padding: 5px 10px;
|
||||
border: 1px solid var(--aksrt-field-border);
|
||||
border-radius: 5px;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
background: #f7f8fa;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@@ -85,6 +102,14 @@
|
||||
box-shadow: 0 0 0 1px var(--aksrt-field-accent);
|
||||
}
|
||||
|
||||
.aksrt-widget-choices label input:focus-visible + span { outline: 2px solid #72aee6; outline-offset: 2px; }
|
||||
|
||||
.aksrt-widget-choices--palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 5px; }
|
||||
.aksrt-widget-choices--palette label > span { padding: 4px; text-align: center; }
|
||||
.aksrt-widget-palette-choice { display: grid; justify-items: center; gap: 3px; }
|
||||
.aksrt-widget-palette-choice i { display: block; width: 100%; height: 18px; border: 1px solid rgba(0, 0, 0, .12); border-radius: 3px; }
|
||||
.aksrt-widget-palette-choice small { font-size: 10px; line-height: 1.2; }
|
||||
|
||||
.aksrt-widget-number,
|
||||
.aksrt-widget-link,
|
||||
.aksrt-widget-background {
|
||||
@@ -130,7 +155,7 @@
|
||||
.aksrt-widget-nested {
|
||||
margin-bottom: 9px;
|
||||
border: 1px solid var(--aksrt-field-border);
|
||||
border-radius: 6px;
|
||||
border-radius: 4px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
@@ -140,15 +165,42 @@
|
||||
gap: 7px;
|
||||
padding: 8px 10px;
|
||||
border-bottom: 1px solid var(--aksrt-field-border);
|
||||
background: #f6f7f7;
|
||||
background: #f9fafc;
|
||||
}
|
||||
|
||||
.aksrt-widget-repeater__bar::-webkit-details-marker { display: none; }
|
||||
.aksrt-widget-repeater__bar { list-style: none; cursor: pointer; }
|
||||
.aksrt-widget-repeater__bar::after { content: "\f140"; margin-left: auto; font: 20px/1 dashicons; color: #646970; }
|
||||
.aksrt-widget-repeater__row[open] > .aksrt-widget-repeater__bar::after { content: "\f142"; }
|
||||
.aksrt-widget-repeater__bar .dashicons { cursor: move; }
|
||||
.aksrt-widget-repeater__bar strong { flex: 1; }
|
||||
.aksrt-widget-repeater__remove:disabled { visibility: hidden; }
|
||||
.aksrt-widget-repeater__add:disabled { opacity: .55; cursor: not-allowed; }
|
||||
.aksrt-widget-repeater__fields,
|
||||
.aksrt-widget-nested__body { display: grid; gap: 12px; padding: 10px; }
|
||||
.aksrt-widget-nested > summary { padding: 9px 10px; font-weight: 600; cursor: pointer; }
|
||||
|
||||
.aksrt-widget-form input[type="text"],
|
||||
.aksrt-widget-form input[type="url"],
|
||||
.aksrt-widget-form input[type="number"],
|
||||
.aksrt-widget-form select,
|
||||
.aksrt-widget-form textarea {
|
||||
min-height: 32px;
|
||||
border-color: #d5d8dc;
|
||||
border-radius: 3px;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.aksrt-widget-form input:focus,
|
||||
.aksrt-widget-form select:focus,
|
||||
.aksrt-widget-form textarea:focus {
|
||||
border-color: #0991f5;
|
||||
box-shadow: 0 0 0 1px #0991f5;
|
||||
}
|
||||
|
||||
.aksrt-widget-form .button { min-height: 32px; line-height: 30px; border-radius: 3px; }
|
||||
.aksrt-widget-form .button-primary { background: #0991f5; border-color: #087bcf; }
|
||||
|
||||
.aksrt-widget-form-lazy {
|
||||
padding: 14px;
|
||||
border: 1px dashed #c3c4c7;
|
||||
@@ -175,20 +227,29 @@
|
||||
color: #614200;
|
||||
}
|
||||
|
||||
.aksrt-widget-transfer { margin: 16px 20px 16px 0; }
|
||||
.aksrt-widget-transfer__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
|
||||
.aksrt-widget-transfer form { display: grid; align-content: start; gap: 9px; padding: 12px; border: 1px solid #dcdcde; border-radius: 6px; }
|
||||
.aksrt-widget-transfer form h3 { margin: 0 0 3px; }
|
||||
.aksrt-widget-transfer select,
|
||||
.aksrt-widget-transfer input[type="file"] { width: 100%; }
|
||||
.aksrt-widget-transfer-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
|
||||
.aksrt-widget-transfer-toolbar .button { margin: 0; }
|
||||
.aksrt-widget-customizer-remove { margin-left: 8px; color: #b32d2e; }
|
||||
.aksrt-widget-transfer-modal[hidden] { display: none !important; }
|
||||
.aksrt-widget-transfer-modal.is-open { position: fixed; inset: 0; z-index: 1000100; display: flex; align-items: center; justify-content: center; padding: 20px; }
|
||||
.aksrt-widget-transfer-modal__backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(0, 0, 0, .45); }
|
||||
.aksrt-widget-transfer-modal__dialog { position: relative; z-index: 1; box-sizing: border-box; width: min(720px, 96vw); max-height: 90vh; overflow: auto; padding: 18px 20px 16px; border: 1px solid #c3c4c7; border-radius: 6px; background: #fff; box-shadow: 0 8px 32px rgba(0, 0, 0, .14); }
|
||||
.aksrt-widget-transfer-modal__dialog h2 { margin: 0 36px 10px 0; font-size: 16px; }
|
||||
.aksrt-widget-transfer-modal__area { margin: 0 0 12px; }
|
||||
.aksrt-widget-transfer-modal__close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border: 0; background: transparent; color: #646970; font-size: 22px; cursor: pointer; }
|
||||
.aksrt-widget-transfer-modal__tabs { display: flex; gap: 6px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid #dcdcde; }
|
||||
.aksrt-widget-transfer-modal__tabs .is-active { border-color: #0991f5; color: #087bcf; box-shadow: inset 0 -2px #0991f5; }
|
||||
.aksrt-widget-transfer-modal__panel form { display: grid; align-content: start; gap: 10px; }
|
||||
.aksrt-widget-transfer-modal__panel select,
|
||||
.aksrt-widget-transfer-modal__panel input[type="file"] { width: 100%; }
|
||||
.aksrt-widget-transfer__actions { display: flex; flex-wrap: wrap; gap: 8px; }
|
||||
.aksrt-widget-template-preview-output { grid-column: 1 / -1; max-height: 520px; overflow: auto; padding: 14px; border: 1px solid #dcdcde; background: #fff; }
|
||||
.aksrt-widget-template-preview-output { max-height: 420px; overflow: auto; margin-top: 14px; padding: 14px; border: 1px solid #dcdcde; background: #fff; }
|
||||
.aksrt-widget-template-preview__area { margin-bottom: 18px; }
|
||||
.aksrt-widget-template-preview__module { margin: 10px 0; padding: 12px; border: 1px dashed #c3c4c7; border-radius: 6px; }
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.aksrt-widget-transfer__grid { grid-template-columns: 1fr; }
|
||||
.aksrt-widget-template-preview-output { grid-column: auto; }
|
||||
@media (max-width: 600px) {
|
||||
.aksrt-widget-transfer-modal.is-open { padding: 10px; }
|
||||
.aksrt-widget-transfer-modal__dialog { width: 100%; padding: 16px; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
|
||||
+154
-7
@@ -23,6 +23,7 @@
|
||||
evaluateDependencies($root);
|
||||
updateWidgetTitle($root);
|
||||
updatePlacementWarning($root);
|
||||
updateRepeaterControls($root);
|
||||
}
|
||||
|
||||
/* terms 字段:以“已选标签”为唯一真源,同步隐藏输入(选择顺序)与复选框。 */
|
||||
@@ -63,17 +64,91 @@
|
||||
$hint.toggleClass('is-warning', (size === 'wide' && isSidebar) || (size === 'sidebar' && !isSidebar && area !== ''));
|
||||
}
|
||||
|
||||
function injectTransferToolbar($anchor, sidebarId) {
|
||||
if (!$anchor?.length || !sidebarId || $anchor.next('.aksrt-widget-transfer-toolbar').length) return;
|
||||
const $toolbar = $('<div class="aksrt-widget-transfer-toolbar" role="group"></div>');
|
||||
[
|
||||
['export', config.i18n?.export || '导出'],
|
||||
['import', config.i18n?.import || '导入'],
|
||||
['template', config.i18n?.template || '应用模板'],
|
||||
].forEach(([action, label]) => {
|
||||
$('<button type="button" class="button button-small"></button>')
|
||||
.text(label)
|
||||
.attr('data-aksrt-transfer-action', action)
|
||||
.attr('data-sidebar-id', sidebarId)
|
||||
.appendTo($toolbar);
|
||||
});
|
||||
$anchor.after($toolbar);
|
||||
}
|
||||
|
||||
function scanWidgetAreas() {
|
||||
$('.widgets-holder-wrap:not(#available-widgets):not(.inactive-sidebar)').each(function () {
|
||||
const $wrap = $(this);
|
||||
const $sortables = $wrap.find('.widgets-sortables').first();
|
||||
const sidebarId = String($sortables.attr('id') || '');
|
||||
if (!sidebarId) return;
|
||||
const $description = $sortables.find('.sidebar-description .description').first();
|
||||
const $anchor = $description.length ? $description : $sortables.find('.description').first();
|
||||
if ($anchor.length) injectTransferToolbar($anchor, sidebarId);
|
||||
});
|
||||
|
||||
$('.control-section-sidebar').each(function () {
|
||||
const $section = $(this);
|
||||
const sectionId = String($section.attr('id') || '');
|
||||
const prefix = 'sub-accordion-section-sidebar-widgets-';
|
||||
if (!sectionId.startsWith(prefix)) return;
|
||||
const sidebarId = sectionId.slice(prefix.length);
|
||||
const $description = $section.find('.section-meta .description').first();
|
||||
const $anchor = $description.length ? $description : $section.find('.accordion-section-title, .customize-section-title').first();
|
||||
if ($anchor.length) injectTransferToolbar($anchor, sidebarId);
|
||||
});
|
||||
|
||||
$('.customize-control-widget_form').each(function () {
|
||||
const $control = $(this);
|
||||
const $nav = $control.find('.widget-reorder-nav').first();
|
||||
if (!$nav.length || $nav.find('.aksrt-widget-customizer-remove').length) return;
|
||||
$('<button type="button" class="button-link-delete aksrt-widget-customizer-remove" aria-label="移除此小工具">移除</button>').appendTo($nav);
|
||||
});
|
||||
}
|
||||
|
||||
function openTransferModal(action, sidebarId) {
|
||||
const $modal = $('#aksrt-widget-transfer-modal');
|
||||
if (!$modal.length) return;
|
||||
const sidebars = config.sidebars || {};
|
||||
const areaName = sidebars[sidebarId] || sidebarId;
|
||||
$modal.find('.aksrt-widget-transfer-modal__area').text(areaName);
|
||||
$modal.find('input[name="sidebar"], input[name="target_sidebar"]').val(sidebarId);
|
||||
$modal.find('[data-transfer-tab]').removeClass('is-active');
|
||||
$modal.find(`[data-transfer-tab="${action}"]`).addClass('is-active');
|
||||
$modal.find('[data-transfer-panel]').prop('hidden', true);
|
||||
$modal.find(`[data-transfer-panel="${action}"]`).prop('hidden', false);
|
||||
$modal.prop('hidden', false).addClass('is-open').attr('aria-hidden', 'false');
|
||||
$modal.find('[data-transfer-panel="' + action + '"] button, [data-transfer-panel="' + action + '"] input, [data-transfer-panel="' + action + '"] select').filter(':visible').first().trigger('focus');
|
||||
}
|
||||
|
||||
function closeTransferModal() {
|
||||
$('#aksrt-widget-transfer-modal').removeClass('is-open').attr('aria-hidden', 'true').prop('hidden', true);
|
||||
}
|
||||
|
||||
function loadForm(container) {
|
||||
const $container = $(container);
|
||||
if ($container.data('loading') || $container.data('loaded')) return;
|
||||
const $widget = $container.closest('.widget, .customize-control-widget_form');
|
||||
const inputName = String($widget.find('input[name^="widget-"]').first().attr('name') || '');
|
||||
const number = core.resolveWidgetNumber(inputName, $widget.attr('id'), $container.data('widget-number'));
|
||||
// New-widget templates use __i__ until WordPress assigns a real instance number.
|
||||
if (!number) return;
|
||||
$container.data('loading', true).find('.aksrt-widget-form-lazy__status').text(config.i18n?.loading || 'Loading…');
|
||||
$.post(config.ajaxUrl, {
|
||||
action: config.action,
|
||||
nonce: config.nonce,
|
||||
id_base: $container.data('id-base'),
|
||||
widget_number: $container.data('widget-number'),
|
||||
widget_number: number,
|
||||
}).done((response) => {
|
||||
if (!response?.success || !response.data?.html) throw new Error('Invalid response');
|
||||
if (!response?.success || !response.data?.html) {
|
||||
$container.data('loading', false).find('.aksrt-widget-form-lazy__status').text(response?.data?.message || config.i18n?.error || 'Failed to load.');
|
||||
return;
|
||||
}
|
||||
const $form = $(response.data.html);
|
||||
$container.replaceWith($form);
|
||||
initForm($form);
|
||||
@@ -94,6 +169,31 @@
|
||||
if (!rowIndexes.length) return;
|
||||
this.name = core.replaceRepeaterIndexes(this.name, rowIndexes);
|
||||
});
|
||||
updateRepeaterTitles($form);
|
||||
}
|
||||
|
||||
function updateRepeaterTitles($form) {
|
||||
$form.find('.aksrt-widget-repeater__rows').each(function () {
|
||||
$(this).children('.aksrt-widget-repeater__row').each(function (index) {
|
||||
const $row = $(this);
|
||||
const $title = $row.find('.aksrt-widget-repeater__title').first();
|
||||
const prefix = String($title.data('title-prefix') || '项目');
|
||||
const $firstControl = $row.children('.aksrt-widget-repeater__fields').find('input:not([type="hidden"]), select, textarea').first();
|
||||
const value = String($firstControl.val() || '').trim();
|
||||
$title.text(prefix + (index + 1) + (value ? ':' + value : ''));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function updateRepeaterControls($root) {
|
||||
$root.filter('.aksrt-widget-repeater').add($root.find('.aksrt-widget-repeater')).each(function () {
|
||||
const $repeater = $(this);
|
||||
const count = $repeater.children('.aksrt-widget-repeater__rows').children('.aksrt-widget-repeater__row').length;
|
||||
const min = Number($repeater.data('min-items') || 0);
|
||||
const max = Number($repeater.data('max-items') || 50);
|
||||
$repeater.children('.aksrt-widget-repeater__rows').children('.aksrt-widget-repeater__row').children('.aksrt-widget-repeater__bar').children('.aksrt-widget-repeater__remove').prop('disabled', count <= min);
|
||||
$repeater.children('.aksrt-widget-repeater__add').prop('disabled', count >= max);
|
||||
});
|
||||
}
|
||||
|
||||
function fieldValue($form, id) {
|
||||
@@ -116,12 +216,29 @@
|
||||
}
|
||||
|
||||
$(document)
|
||||
.on('click', '[data-aksrt-transfer-action]', function () {
|
||||
openTransferModal(String($(this).data('aksrt-transfer-action')), String($(this).data('sidebar-id')));
|
||||
})
|
||||
.on('click', '[data-aksrt-transfer-close]', closeTransferModal)
|
||||
.on('click', '[data-transfer-tab]', function () {
|
||||
const $modal = $(this).closest('.aksrt-widget-transfer-modal');
|
||||
const panel = String($(this).data('transfer-tab'));
|
||||
$modal.find('[data-transfer-tab]').removeClass('is-active');
|
||||
$(this).addClass('is-active');
|
||||
$modal.find('[data-transfer-panel]').prop('hidden', true);
|
||||
$modal.find(`[data-transfer-panel="${panel}"]`).prop('hidden', false);
|
||||
})
|
||||
.on('click', '.aksrt-widget-customizer-remove', function (event) {
|
||||
event.preventDefault();
|
||||
$(this).closest('.customize-control-widget_form').find('.widget-control-remove').first().trigger('click');
|
||||
})
|
||||
.on('click', '.aksrt-widget-form-lazy__load', function () { loadForm($(this).closest('.aksrt-widget-form-lazy')); })
|
||||
.on('click', '.widget.open .aksrt-widget-form-lazy', function () { loadForm(this); })
|
||||
.on('click', '.widget.open .aksrt-widget-form-lazy, .customize-control-widget_form .aksrt-widget-form-lazy', function () { loadForm(this); })
|
||||
.on('change input', '.aksrt-widget-form input, .aksrt-widget-form select, .aksrt-widget-form textarea', function () {
|
||||
const $form = $(this).closest('.aksrt-widget-form');
|
||||
evaluateDependencies($form);
|
||||
updateWidgetTitle($form);
|
||||
updateRepeaterTitles($form);
|
||||
})
|
||||
.on('click', '.aksrt-widget-repeater__add', function () {
|
||||
const $repeater = $(this).closest('.aksrt-widget-repeater');
|
||||
@@ -134,11 +251,17 @@
|
||||
const $row = $(html).appendTo($rows);
|
||||
initForm($row);
|
||||
renumberRepeaters.call($rows[0]);
|
||||
updateRepeaterControls($repeater);
|
||||
})
|
||||
.on('click', '.aksrt-widget-repeater__remove', function () {
|
||||
const $rows = $(this).closest('.aksrt-widget-repeater__rows');
|
||||
.on('click', '.aksrt-widget-repeater__remove', function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
const $repeater = $(this).closest('.aksrt-widget-repeater');
|
||||
const $rows = $repeater.children('.aksrt-widget-repeater__rows');
|
||||
if ($rows.children('.aksrt-widget-repeater__row').length <= Number($repeater.data('min-items') || 0)) return;
|
||||
$(this).closest('.aksrt-widget-repeater__row').remove();
|
||||
renumberRepeaters.call($rows[0]);
|
||||
updateRepeaterControls($repeater);
|
||||
})
|
||||
.on('click', '.aksrt-widget-terms__remove', function () {
|
||||
$(this).closest('.aksrt-widget-terms__chip').remove();
|
||||
@@ -150,6 +273,7 @@
|
||||
const id = String(this.value);
|
||||
const name = (option.querySelector('[data-term-name]') || option).getAttribute('data-term-name');
|
||||
if (this.checked) addTermChip(wrap, id, name || id);
|
||||
else $(wrap).find('.aksrt-widget-terms__chip').filter((_index, chip) => String($(chip).data('term-id')) === id).remove();
|
||||
syncTerms(wrap);
|
||||
})
|
||||
.on('input', '.aksrt-widget-terms__search', function () {
|
||||
@@ -186,17 +310,40 @@
|
||||
nonce: config.transferNonce,
|
||||
template: $form.find('[name="template"]').val(),
|
||||
}).done((response) => {
|
||||
if (!response?.success) throw new Error('Invalid response');
|
||||
if (!response?.success || !response.data) {
|
||||
$output.empty().append($('<p class="notice notice-error"></p>').text(response?.data?.message || config.i18n?.error || '预览加载失败,请重试。'));
|
||||
return;
|
||||
}
|
||||
$output.html(response.data.html || '<p>模板为空。</p>');
|
||||
}).fail(() => $output.html('<p class="notice notice-error">预览加载失败。</p>'));
|
||||
}).fail((xhr) => {
|
||||
const message = xhr?.responseJSON?.data?.message || config.i18n?.error || '预览加载失败,请重试。';
|
||||
$output.empty().append($('<p class="notice notice-error"></p>').text(message));
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('widget-added widget-updated', function (_event, widget) {
|
||||
$(widget).find('.aksrt-widget-form-lazy').each(function () { loadForm(this); });
|
||||
updatePlacementWarning(widget);
|
||||
scanWidgetAreas();
|
||||
});
|
||||
|
||||
if (window.wp?.customize?.bind) {
|
||||
window.wp.customize.bind('ready', function () {
|
||||
$('#customize-theme-controls').on('expanded', function (_event, section) {
|
||||
if (!section || !String(section.id || section).includes('sidebar-widgets')) return;
|
||||
window.setTimeout(function () {
|
||||
scanWidgetAreas();
|
||||
$('.customize-control-widget_form .aksrt-widget-form-lazy').each(function () { loadForm(this); });
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$(function () {
|
||||
scanWidgetAreas();
|
||||
$(document).on('keydown', function (event) {
|
||||
if (event.key === 'Escape') closeTransferModal();
|
||||
});
|
||||
$('.aksrt-widget-form').each(function () { initForm(this); });
|
||||
$('.widget.open .aksrt-widget-form-lazy').each(function () { loadForm(this); });
|
||||
});
|
||||
|
||||
@@ -50,16 +50,19 @@
|
||||
.aksrt-widget-search--compact button span { display: none; }
|
||||
.aksrt-widget-search--large { min-height: 58px; border-radius: 14px; }
|
||||
|
||||
.aksrt-widget-quote { position: relative; min-height: 130px; margin: 0; padding: 24px 48px 24px 25px; overflow: hidden; border-radius: var(--aksrt-widget-radius); background: linear-gradient(135deg, #6772e5, #8b5cf6); color: #fff; }
|
||||
.aksrt-widget-quote > i { opacity: .35; font-size: 26px; }
|
||||
.aksrt-widget-quote blockquote { margin: 12px 0 0; font-size: 16px; line-height: 1.8; }
|
||||
.aksrt-widget-quote button { position: absolute; right: 13px; bottom: 13px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; cursor: pointer; }
|
||||
.aksrt-widget-quote { margin: 0; padding: 12px 15px; border-radius: var(--aksrt-widget-radius); background: var(--main-bg-color, #fff); color: var(--main-color, inherit); box-shadow: 0 0 10px var(--main-shadow, rgba(116,116,116,.08)); }
|
||||
.aksrt-widget-quote .yiyan { line-height: 1.8; }
|
||||
.aksrt-widget-quote .yiyan .en { font-size: .9em; opacity: .8; }
|
||||
.aksrt-widget-quote.is-loading { opacity: .65; }
|
||||
|
||||
/* The AKSRT base stylesheet already carries Zibll's icon-card and utility rules.
|
||||
* Restore the one renamed primitive used verbatim by these two widget renderers. */
|
||||
.zib-widget { clear:both; margin-bottom:20px; padding:15px; border-radius:var(--main-radius,8px); background:var(--main-bg-color,#fff); box-shadow:0 0 10px var(--main-shadow,rgba(116,116,116,.08)); }
|
||||
.zib-widget.padding-10 { padding:10px; }
|
||||
.zib-widget.nobottom.notop { padding-top:0; padding-bottom:0; }
|
||||
.zib-widget.posts-mini-lists { padding:5px; }
|
||||
.zib-widget.posts-mini-lists .relative > .tab-nav-theme ~ .scroll-x-prev,
|
||||
.zib-widget.posts-mini-lists .relative > .tab-nav-theme ~ .scroll-x-next { top:10px; }
|
||||
|
||||
.zib-widget-wrap { padding:var(--aksrt-widget-space-top,0) var(--aksrt-widget-space-right,0) var(--aksrt-widget-space-bottom,0) var(--aksrt-widget-space-left,0); background-color:var(--aksrt-widget-bg-light,transparent); background-image:var(--aksrt-widget-bg-image-light,none); background-position:center; background-size:cover; }
|
||||
.dark-theme .zib-widget-wrap, [data-theme="dark"] .zib-widget-wrap { background-color:var(--aksrt-widget-bg-dark,var(--aksrt-widget-bg-light,transparent)); background-image:var(--aksrt-widget-bg-image-dark,var(--aksrt-widget-bg-image-light,none)); }
|
||||
@@ -151,12 +154,7 @@
|
||||
/* Zibll modern widget contracts */
|
||||
.widget-tab-post .tab-content > .tab-pane { display: none; }
|
||||
.widget-tab-post .tab-content > .tab-pane.active { display: block; }
|
||||
.widget-tab-post .list-inline { margin: 0 0 15px; padding: 0; list-style: none; }
|
||||
.widget-tab-post .list-inline > li { display: inline-block; margin: 0 15px 0 0; }
|
||||
.widget-tab-post .list-inline > li > a { color: inherit; text-decoration: none; cursor: pointer; }
|
||||
.widget-tab-post .list-inline > li.active > a { color: var(--focus-color, #f04494); }
|
||||
.widget-tab-post .tab-nav-theme > li { position: relative; padding-bottom: 5px; }
|
||||
.widget-tab-post .tab-nav-theme > li.active::before { content: ''; position: absolute; right: 0; bottom: 0; left: 0; height: 2px; background: var(--focus-color, #f04494); }
|
||||
.widget-tab-post, .term-aggregation { line-height:1.42857143; }
|
||||
.widget-tab-post .post_ajax_loader { min-height: 40px; }
|
||||
/* Widget pagination mirrors the reference .ajax-next rules while staying on the REST client. */
|
||||
.theme-pagination { margin: 20px 0; }
|
||||
|
||||
@@ -74,26 +74,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
function updateQuote(figure) {
|
||||
if (figure.dataset.source !== 'api' || !config.quoteUrl) return Promise.resolve();
|
||||
var button = figure.querySelector('button');
|
||||
if (button) button.disabled = true;
|
||||
return fetch(config.quoteUrl, { credentials: 'same-origin', headers: { Accept: 'application/json' } })
|
||||
.then(function (response) { if (!response.ok) throw new Error('quote'); return response.json(); })
|
||||
.then(function (data) {
|
||||
if (data && data.text) figure.querySelector('blockquote').textContent = data.text;
|
||||
})
|
||||
.catch(function () {})
|
||||
.finally(function () { if (button) button.disabled = false; });
|
||||
}
|
||||
|
||||
function initQuote(figure) {
|
||||
if (!once(figure, 'Quote')) return;
|
||||
var button = figure.querySelector('button');
|
||||
if (button) button.addEventListener('click', function () { updateQuote(figure); });
|
||||
if (!reducedMotion && figure.dataset.source === 'api') {
|
||||
window.setInterval(function () { if (!document.hidden) updateQuote(figure); }, Math.max(5, Number(figure.dataset.interval || 30)) * 1000);
|
||||
}
|
||||
if (window.AksrtYiyan) window.AksrtYiyan.init(figure);
|
||||
}
|
||||
|
||||
function errorMarkup() {
|
||||
@@ -187,6 +170,7 @@
|
||||
Array.prototype.slice.call(container.querySelectorAll(':scope > .ajax-pag')).forEach(function (node) { node.remove(); });
|
||||
if (data.paginate_html) container.insertAdjacentHTML('beforeend', data.paginate_html);
|
||||
container.dataset.page = String(data.page || page);
|
||||
container.dataset.loaded = '1';
|
||||
anchorLoader(container);
|
||||
scan(container);
|
||||
})
|
||||
@@ -247,7 +231,7 @@
|
||||
if (!panel) return;
|
||||
panel.dataset.segment = button.dataset.segment;
|
||||
panel.setAttribute('aria-labelledby', button.id);
|
||||
loadItems(panel, 1, false);
|
||||
if (panel.dataset.loaded !== '1') loadItems(panel, 1, false);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user