refactor(modal): remove legacy compatibility paths
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,17 +1,17 @@
|
|||||||
/**
|
/**
|
||||||
* Remote modal + ajax list primitives (shared).
|
* Modal runtime + ajax list primitives (shared).
|
||||||
*
|
*
|
||||||
* @package AKSRT
|
* @package AKSRT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* ---- scroll lock ---- */
|
/* ---- scroll lock ---- */
|
||||||
html.aksrt-remote-modal-open,
|
html.aksrt-modal-runtime-open,
|
||||||
body.aksrt-remote-modal-open {
|
body.aksrt-modal-runtime-open {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---- remote modal shell ---- */
|
/* ---- modal runtime shell ---- */
|
||||||
.aksrt-remote-modal {
|
.aksrt-modal-runtime {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
z-index: 100050;
|
z-index: 100050;
|
||||||
@@ -24,20 +24,20 @@ body.aksrt-remote-modal-open {
|
|||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal.is-open {
|
.aksrt-modal-runtime.is-open {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal__overlay {
|
.aksrt-modal-runtime__overlay {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
background: rgba(15, 18, 28, 0.48);
|
background: rgba(15, 18, 28, 0.48);
|
||||||
backdrop-filter: blur(2px);
|
backdrop-filter: blur(2px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal__dialog {
|
.aksrt-modal-runtime__dialog {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
width: min(440px, calc(100vw - 32px));
|
width: min(440px, calc(100vw - 32px));
|
||||||
@@ -51,15 +51,15 @@ body.aksrt-remote-modal-open {
|
|||||||
color: var(--color-ink, #1f2937);
|
color: var(--color-ink, #1f2937);
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal.is-open .aksrt-remote-modal__dialog {
|
.aksrt-modal-runtime.is-open .aksrt-modal-runtime__dialog {
|
||||||
transform: translateY(0) scale(1);
|
transform: translateY(0) scale(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal--bottom {
|
.aksrt-modal-runtime--bottom {
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal--bottom .aksrt-remote-modal__dialog {
|
.aksrt-modal-runtime--bottom .aksrt-modal-runtime__dialog {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
border-radius: 16px 16px 0 0;
|
border-radius: 16px 16px 0 0;
|
||||||
@@ -67,11 +67,11 @@ body.aksrt-remote-modal-open {
|
|||||||
transform: translateY(24px);
|
transform: translateY(24px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal--bottom.is-open .aksrt-remote-modal__dialog {
|
.aksrt-modal-runtime--bottom.is-open .aksrt-modal-runtime__dialog {
|
||||||
transform: translateY(0);
|
transform: translateY(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal__header {
|
.aksrt-modal-runtime__header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@@ -79,32 +79,32 @@ body.aksrt-remote-modal-open {
|
|||||||
padding: 16px 18px 0;
|
padding: 16px 18px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal__title {
|
.aksrt-modal-runtime__title {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 17px;
|
font-size: 17px;
|
||||||
line-height: 1.35;
|
line-height: 1.35;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal__content {
|
.aksrt-modal-runtime__content {
|
||||||
padding: 18px 18px 16px;
|
padding: 18px 18px 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal__loading,
|
.aksrt-modal-runtime__loading,
|
||||||
.aksrt-remote-modal__error-body {
|
.aksrt-modal-runtime__error-body {
|
||||||
padding: 28px 8px;
|
padding: 28px 8px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: var(--color-ink-2, #6b7280);
|
color: var(--color-ink-2, #6b7280);
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal__skeleton {
|
.aksrt-modal-runtime__skeleton {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
padding: 8px 2px;
|
padding: 8px 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal__skeleton-line,
|
.aksrt-modal-runtime__skeleton-line,
|
||||||
.aksrt-remote-modal__skeleton-block {
|
.aksrt-modal-runtime__skeleton-block {
|
||||||
display: block;
|
display: block;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
background: linear-gradient(90deg, rgba(148, 163, 184, 0.16), rgba(148, 163, 184, 0.3), rgba(148, 163, 184, 0.16));
|
background: linear-gradient(90deg, rgba(148, 163, 184, 0.16), rgba(148, 163, 184, 0.3), rgba(148, 163, 184, 0.16));
|
||||||
@@ -112,26 +112,26 @@ body.aksrt-remote-modal-open {
|
|||||||
animation: aksrt-modal-skeleton 1.2s ease-in-out infinite;
|
animation: aksrt-modal-skeleton 1.2s ease-in-out infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal__skeleton-line {
|
.aksrt-modal-runtime__skeleton-line {
|
||||||
width: 72%;
|
width: 72%;
|
||||||
height: 12px;
|
height: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal__skeleton-line.is-wide {
|
.aksrt-modal-runtime__skeleton-line.is-wide {
|
||||||
width: 92%;
|
width: 92%;
|
||||||
height: 18px;
|
height: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal__skeleton-line.is-short {
|
.aksrt-modal-runtime__skeleton-line.is-short {
|
||||||
width: 44%;
|
width: 44%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal__skeleton-block {
|
.aksrt-modal-runtime__skeleton-block {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 84px;
|
min-height: 84px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal__retry {
|
.aksrt-modal-runtime__retry {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,8 +140,8 @@ body.aksrt-remote-modal-open {
|
|||||||
100% { background-position: -100% 0; }
|
100% { background-position: -100% 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal .touch.border-title,
|
.aksrt-modal-runtime .touch.border-title,
|
||||||
.aksrt-remote-modal .border-title {
|
.aksrt-modal-runtime .border-title {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
margin: 0 0 14px;
|
margin: 0 0 14px;
|
||||||
@@ -151,8 +151,7 @@ body.aksrt-remote-modal-open {
|
|||||||
gap: 6px;
|
gap: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal .abs-close,
|
.aksrt-modal-runtime .aksrt-modal-runtime__close {
|
||||||
.aksrt-remote-modal .aksrt-remote-modal__close {
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 10px;
|
top: 10px;
|
||||||
right: 10px;
|
right: 10px;
|
||||||
@@ -167,17 +166,17 @@ body.aksrt-remote-modal-open {
|
|||||||
line-height: 1;
|
line-height: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal .but-average.modal-buts,
|
.aksrt-modal-runtime .but-average.modal-buts,
|
||||||
.aksrt-remote-modal .modal-buts {
|
.aksrt-modal-runtime .modal-buts {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal .but-average.modal-buts .but,
|
.aksrt-modal-runtime .but-average.modal-buts .but,
|
||||||
.aksrt-remote-modal .modal-buts .but,
|
.aksrt-modal-runtime .modal-buts .but,
|
||||||
.aksrt-remote-modal .modal-buts button {
|
.aksrt-modal-runtime .modal-buts button {
|
||||||
min-height: 40px;
|
min-height: 40px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
border: 1px solid var(--color-line, #e5e7eb);
|
border: 1px solid var(--color-line, #e5e7eb);
|
||||||
@@ -187,9 +186,9 @@ body.aksrt-remote-modal-open {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal .modal-buts .but.c-blue,
|
.aksrt-modal-runtime .modal-buts .but.c-blue,
|
||||||
.aksrt-remote-modal .modal-buts button.c-blue,
|
.aksrt-modal-runtime .modal-buts button.c-blue,
|
||||||
.aksrt-remote-modal .modal-buts .btn-primary {
|
.aksrt-modal-runtime .modal-buts .btn-primary {
|
||||||
background: var(--color-primary, #f04494);
|
background: var(--color-primary, #f04494);
|
||||||
border-color: color-mix(in srgb, var(--color-primary, #f04494) 70%, #000 0%);
|
border-color: color-mix(in srgb, var(--color-primary, #f04494) 70%, #000 0%);
|
||||||
color: var(--color-on-primary, #fff);
|
color: var(--color-on-primary, #fff);
|
||||||
@@ -351,7 +350,7 @@ body.aksrt-remote-modal-open {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.aksrt-remote-modal:not(.aksrt-remote-modal--bottom) .aksrt-remote-modal__dialog {
|
.aksrt-modal-runtime:not(.aksrt-modal-runtime--bottom) .aksrt-modal-runtime__dialog {
|
||||||
width: calc(100vw - 20px);
|
width: calc(100vw - 20px);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,26 +2,7 @@
|
|||||||
* VIP pay modal + hover cards (zibll payvip-modal / vip-card).
|
* VIP pay modal + hover cards (zibll payvip-modal / vip-card).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.aksrt-vip-modal-open {
|
.aksrt-vip-modal-panel {
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.aksrt-vip-modal-overlay {
|
|
||||||
position: fixed;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 1200;
|
|
||||||
display: none;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 16px;
|
|
||||||
background: rgba(0, 0, 0, 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
.aksrt-vip-modal-overlay.is-open {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.aksrt-vip-modal-dialog {
|
|
||||||
width: min(560px, 100%);
|
width: min(560px, 100%);
|
||||||
max-height: min(90vh, 760px);
|
max-height: min(90vh, 760px);
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
@@ -31,11 +12,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* VIP now uses the shared modal runtime host. */
|
/* VIP now uses the shared modal runtime host. */
|
||||||
.aksrt-remote-modal.aksrt-vip-modal-shell {
|
.aksrt-modal-runtime.aksrt-vip-modal-shell {
|
||||||
z-index: 1200;
|
z-index: 1200;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal.aksrt-vip-modal-shell .aksrt-remote-modal__dialog {
|
.aksrt-modal-runtime.aksrt-vip-modal-shell .aksrt-modal-runtime__dialog {
|
||||||
width: min(560px, 100%);
|
width: min(560px, 100%);
|
||||||
max-height: min(90vh, 760px);
|
max-height: min(90vh, 760px);
|
||||||
background: var(--main-bg-color, #fff);
|
background: var(--main-bg-color, #fff);
|
||||||
@@ -43,7 +24,7 @@
|
|||||||
box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
|
box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
|
||||||
}
|
}
|
||||||
|
|
||||||
.aksrt-remote-modal.aksrt-vip-modal-shell .aksrt-remote-modal__content {
|
.aksrt-modal-runtime.aksrt-vip-modal-shell .aksrt-modal-runtime__content {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,8 +33,7 @@
|
|||||||
padding: 18px 16px 16px;
|
padding: 18px 16px 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.payvip-modal .close,
|
.aksrt-modal-close {
|
||||||
.aksrt-vip-modal-close {
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 8px;
|
top: 8px;
|
||||||
right: 12px;
|
right: 12px;
|
||||||
@@ -121,7 +101,7 @@
|
|||||||
|
|
||||||
/* Modal-only equity (admin HTML; no forced bullets) */
|
/* Modal-only equity (admin HTML; no forced bullets) */
|
||||||
.payvip-modal .v-equity,
|
.payvip-modal .v-equity,
|
||||||
.aksrt-vip-modal-dialog .v-equity {
|
.aksrt-vip-modal-panel .v-equity {
|
||||||
display: block;
|
display: block;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
margin: 8px 0 0;
|
margin: 8px 0 0;
|
||||||
@@ -130,7 +110,7 @@
|
|||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
}
|
}
|
||||||
.payvip-modal .v-equity > li,
|
.payvip-modal .v-equity > li,
|
||||||
.aksrt-vip-modal-dialog .v-equity > li {
|
.aksrt-vip-modal-panel .v-equity > li {
|
||||||
display: block;
|
display: block;
|
||||||
margin: 0 0 6px;
|
margin: 0 0 6px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@@ -138,8 +118,8 @@
|
|||||||
}
|
}
|
||||||
.payvip-modal .v-equity > li::before,
|
.payvip-modal .v-equity > li::before,
|
||||||
.payvip-modal .v-equity > li::after,
|
.payvip-modal .v-equity > li::after,
|
||||||
.aksrt-vip-modal-dialog .v-equity > li::before,
|
.aksrt-vip-modal-panel .v-equity > li::before,
|
||||||
.aksrt-vip-modal-dialog .v-equity > li::after {
|
.aksrt-vip-modal-panel .v-equity > li::after {
|
||||||
content: none !important;
|
content: none !important;
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,7 +166,7 @@
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
margin-bottom: 14px;
|
margin-bottom: 14px;
|
||||||
}
|
}
|
||||||
.aksrt-checkin-modal__head .aksrt-remote-modal__close {
|
.aksrt-checkin-modal__head .aksrt-modal-runtime__close {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
border: 0;
|
border: 0;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
* aksrt.tbquire(deps, cb) — lazy script/CSS loader
|
* aksrt.tbquire(deps, cb) — lazy script/CSS loader
|
||||||
* aksrt.notyf(msg, opts) — unified toast (same-ID update)
|
* aksrt.notyf(msg, opts) — unified toast (same-ID update)
|
||||||
* aksrt.confirm(msg, opts) — i18n confirm dialog
|
* aksrt.confirm(msg, opts) — i18n confirm dialog
|
||||||
* aksrt.refreshModal(opts) — remote content modal
|
|
||||||
* aksrt.scrollTopTo(target, off) — smart scroll with header offset
|
* aksrt.scrollTopTo(target, off) — smart scroll with header offset
|
||||||
* aksrt.loading(el, show) — element-level loading overlay
|
* aksrt.loading(el, show) — element-level loading overlay
|
||||||
* aksrt.Drawer(opts) — mobile fullscreen drawer + route
|
* aksrt.Drawer(opts) — mobile fullscreen drawer + route
|
||||||
@@ -313,68 +312,6 @@
|
|||||||
el.appendChild(mask);
|
el.appendChild(mask);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ══════════════════════════════════════════════════════════════
|
|
||||||
// §10.10 — refreshModal: remote content modal
|
|
||||||
// ══════════════════════════════════════════════════════════════
|
|
||||||
|
|
||||||
function closeRefreshModal() {
|
|
||||||
if (window.AksrtModalRuntime && typeof window.AksrtModalRuntime.close === 'function') {
|
|
||||||
window.AksrtModalRuntime.close('refresh-modal');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
aksrt.refreshModal = function (opts) {
|
|
||||||
opts = opts || {};
|
|
||||||
var runtime = window.AksrtModalRuntime;
|
|
||||||
if (!runtime || typeof runtime.open !== 'function' || typeof runtime.openRemote !== 'function') {
|
|
||||||
return Promise.reject(new Error('modal runtime unavailable'));
|
|
||||||
}
|
|
||||||
|
|
||||||
var base = {
|
|
||||||
title: opts.title || '',
|
|
||||||
className: opts.class || '',
|
|
||||||
bottom: opts.mobile_from_bottom === true,
|
|
||||||
mobileBottom: opts.mobile_from_bottom === true,
|
|
||||||
cache: opts.cache !== false,
|
|
||||||
cacheTtl: opts.cacheTtl || 15000,
|
|
||||||
cacheTags: opts.cacheTags || opts.tags || [],
|
|
||||||
kind: opts.kind || 'generic',
|
|
||||||
};
|
|
||||||
|
|
||||||
if (opts.content !== undefined) {
|
|
||||||
return Promise.resolve(runtime.open(Object.assign({}, base, { html: opts.content })))
|
|
||||||
.catch(function () { return null; });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts.remote) {
|
|
||||||
return runtime.openRemote(Object.assign({}, base, {
|
|
||||||
url: opts.remote,
|
|
||||||
method: opts.method || 'GET',
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts.action) {
|
|
||||||
var ajaxUrl = (window.aksrtData && window.aksrtData.ajaxUrl) || '/wp-admin/admin-ajax.php';
|
|
||||||
var params = new URLSearchParams();
|
|
||||||
params.set('action', opts.action);
|
|
||||||
if (window.aksrtData && window.aksrtData.nonce) params.set('nonce', window.aksrtData.nonce);
|
|
||||||
if (opts.data) {
|
|
||||||
Object.keys(opts.data).forEach(function (key) { params.set(key, opts.data[key]); });
|
|
||||||
}
|
|
||||||
return runtime.openRemote(Object.assign({}, base, {
|
|
||||||
url: ajaxUrl,
|
|
||||||
method: 'POST',
|
|
||||||
cache: false,
|
|
||||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
|
|
||||||
body: params.toString(),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve(runtime.open(base));
|
|
||||||
};
|
|
||||||
|
|
||||||
aksrt.refreshModal.close = closeRefreshModal;
|
|
||||||
|
|
||||||
// ══════════════════════════════════════════════════════════════
|
// ══════════════════════════════════════════════════════════════
|
||||||
// §10.11 — Drawer: mobile fullscreen slide-in + route
|
// §10.11 — Drawer: mobile fullscreen slide-in + route
|
||||||
// ══════════════════════════════════════════════════════════════
|
// ══════════════════════════════════════════════════════════════
|
||||||
@@ -707,7 +644,12 @@
|
|||||||
btn.classList.remove('is-loading');
|
btn.classList.remove('is-loading');
|
||||||
if (json && json.success) {
|
if (json && json.success) {
|
||||||
if (json.data && json.data.show_modal) {
|
if (json.data && json.data.show_modal) {
|
||||||
aksrt.refreshModal({ content: json.data.show_modal, mobile_from_bottom: true });
|
window.AksrtModalRuntime.open({
|
||||||
|
html: json.data.show_modal,
|
||||||
|
bottom: true,
|
||||||
|
mobileBottom: true,
|
||||||
|
kind: 'generic',
|
||||||
|
});
|
||||||
} else if (json.data && json.data.message) {
|
} else if (json.data && json.data.message) {
|
||||||
aksrt.notyf(json.data.message, 'success');
|
aksrt.notyf(json.data.message, 'success');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* Canonical frontend modal runtime.
|
* Canonical frontend modal runtime.
|
||||||
*
|
*
|
||||||
* Keeps the existing remote-modal shell while adding cancellable loaders,
|
* Owns the modal shell while adding cancellable loaders,
|
||||||
* short in-memory caching, request deduplication, retryable errors, focus
|
* short in-memory caching, request deduplication, retryable errors, focus
|
||||||
* restoration, and modal-scoped rehydration.
|
* restoration, and modal-scoped rehydration.
|
||||||
*
|
*
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
(function (window, document) {
|
(function (window, document) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var ROOT_ID = "aksrt-remote-modal-root";
|
var ROOT_ID = "aksrt-modal-runtime-root";
|
||||||
var active = null;
|
var active = null;
|
||||||
var sequence = 0;
|
var sequence = 0;
|
||||||
var loaders = Object.create(null);
|
var loaders = Object.create(null);
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
if (root) return root;
|
if (root) return root;
|
||||||
root = document.createElement("div");
|
root = document.createElement("div");
|
||||||
root.id = ROOT_ID;
|
root.id = ROOT_ID;
|
||||||
root.className = "aksrt-remote-modal-host";
|
root.className = "aksrt-modal-runtime-host";
|
||||||
document.body.appendChild(root);
|
document.body.appendChild(root);
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
@@ -39,31 +39,28 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function lockScroll(lock) {
|
function lockScroll(lock) {
|
||||||
document.documentElement.classList.toggle("aksrt-remote-modal-open", !!lock);
|
document.documentElement.classList.toggle("aksrt-modal-runtime-open", !!lock);
|
||||||
document.body.classList.toggle("aksrt-remote-modal-open", !!lock);
|
document.body.classList.toggle("aksrt-modal-runtime-open", !!lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
function skeleton(options) {
|
function skeleton(options) {
|
||||||
return (options && options.skeleton) ||
|
return (options && options.skeleton) ||
|
||||||
'<div class="aksrt-remote-modal__skeleton" aria-live="polite" aria-busy="true">' +
|
'<div class="aksrt-modal-runtime__skeleton" aria-live="polite" aria-busy="true">' +
|
||||||
'<span class="aksrt-remote-modal__skeleton-line is-wide"></span>' +
|
'<span class="aksrt-modal-runtime__skeleton-line is-wide"></span>' +
|
||||||
'<span class="aksrt-remote-modal__skeleton-line"></span>' +
|
'<span class="aksrt-modal-runtime__skeleton-line"></span>' +
|
||||||
'<span class="aksrt-remote-modal__skeleton-line is-short"></span>' +
|
'<span class="aksrt-modal-runtime__skeleton-line is-short"></span>' +
|
||||||
'<span class="aksrt-remote-modal__skeleton-block"></span>' +
|
'<span class="aksrt-modal-runtime__skeleton-block"></span>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function telemetryStart(kind) {
|
function telemetryStart(kind) {
|
||||||
if (kind === false) return "";
|
if (kind === false) return "";
|
||||||
var telemetry = window.AksrtModalTelemetry;
|
return window.AksrtModalTelemetry.start(kind || "generic");
|
||||||
if (!telemetry || typeof telemetry.start !== "function") return "";
|
|
||||||
return telemetry.start(kind || "unknown");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function telemetryMark(session, event) {
|
function telemetryMark(session, event) {
|
||||||
var telemetry = window.AksrtModalTelemetry;
|
if (!session || !session.telemetryId) return;
|
||||||
if (!session || !session.telemetryId || !telemetry || typeof telemetry.mark !== "function") return;
|
window.AksrtModalTelemetry.mark(session.telemetryId, event);
|
||||||
telemetry.mark(session.telemetryId, event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setState(session, status, error) {
|
function setState(session, status, error) {
|
||||||
@@ -81,7 +78,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function closeSelector() {
|
function closeSelector() {
|
||||||
return "[data-aksrt-remote-modal-close], [data-aksrt-modal-close], [data-dismiss='modal'], .aksrt-remote-modal__close, .aksrt-vip-modal-close, .payvip-modal .close";
|
return "[data-aksrt-modal-close], .aksrt-modal-runtime__close";
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindChrome(session) {
|
function bindChrome(session) {
|
||||||
@@ -93,11 +90,11 @@
|
|||||||
close("control");
|
close("control");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.target === shell || event.target.classList.contains("aksrt-remote-modal__overlay")) {
|
if (event.target === shell || event.target.classList.contains("aksrt-modal-runtime__overlay")) {
|
||||||
close("overlay");
|
close("overlay");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var retry = event.target.closest("[data-aksrt-remote-modal-retry], [data-aksrt-modal-retry]");
|
var retry = event.target.closest("[data-aksrt-modal-retry]");
|
||||||
if (retry) {
|
if (retry) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
refresh();
|
refresh();
|
||||||
@@ -138,31 +135,29 @@
|
|||||||
var initialHtml = options.html !== undefined ? options.html : skeleton(options);
|
var initialHtml = options.html !== undefined ? options.html : skeleton(options);
|
||||||
var titleId = "aksrt-modal-title-" + String(sequence + 1);
|
var titleId = "aksrt-modal-title-" + String(sequence + 1);
|
||||||
var titleHtml = options.title
|
var titleHtml = options.title
|
||||||
? '<header class="aksrt-remote-modal__header"><h3 class="aksrt-remote-modal__title" id="' + titleId + '">' + escapeHtml(options.title) + '</h3><button type="button" class="aksrt-remote-modal__close" data-aksrt-modal-close aria-label="关闭">×</button></header>'
|
? '<header class="aksrt-modal-runtime__header"><h3 class="aksrt-modal-runtime__title" id="' + titleId + '">' + escapeHtml(options.title) + '</h3><button type="button" class="aksrt-modal-runtime__close" data-aksrt-modal-close aria-label="关闭">×</button></header>'
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
shell.className =
|
shell.className =
|
||||||
"aksrt-remote-modal" +
|
"aksrt-modal-runtime" +
|
||||||
(bottom ? " aksrt-remote-modal--bottom" : "") +
|
(bottom ? " aksrt-modal-runtime--bottom" : "") +
|
||||||
(options.className ? " " + options.className : "");
|
(options.className ? " " + options.className : "");
|
||||||
shell.setAttribute("role", "dialog");
|
shell.setAttribute("role", "dialog");
|
||||||
shell.setAttribute("aria-modal", "true");
|
shell.setAttribute("aria-modal", "true");
|
||||||
if (options.title) shell.setAttribute("aria-labelledby", titleId);
|
if (options.title) shell.setAttribute("aria-labelledby", titleId);
|
||||||
shell.setAttribute("tabindex", "-1");
|
shell.setAttribute("tabindex", "-1");
|
||||||
shell.innerHTML =
|
shell.innerHTML =
|
||||||
'<div class="aksrt-remote-modal__overlay" data-aksrt-remote-modal-close></div>' +
|
'<div class="aksrt-modal-runtime__overlay" data-aksrt-modal-close></div>' +
|
||||||
'<div class="aksrt-remote-modal__dialog" style="' + heightStyle + '">' +
|
'<div class="aksrt-modal-runtime__dialog" style="' + heightStyle + '">' +
|
||||||
titleHtml +
|
titleHtml +
|
||||||
'<div class="aksrt-remote-modal__content">' + initialHtml + "</div></div>";
|
'<div class="aksrt-modal-runtime__content">' + initialHtml + "</div></div>";
|
||||||
|
|
||||||
var session = {
|
var session = {
|
||||||
id: String(++sequence),
|
id: String(++sequence),
|
||||||
shell: shell,
|
shell: shell,
|
||||||
content: shell.querySelector(".aksrt-remote-modal__content"),
|
content: shell.querySelector(".aksrt-modal-runtime__content"),
|
||||||
options: options,
|
options: options,
|
||||||
state: window.AksrtModalState && typeof window.AksrtModalState.create === "function"
|
state: window.AksrtModalState.create(options.kind || "generic"),
|
||||||
? window.AksrtModalState.create(options.kind || "generic")
|
|
||||||
: { status: "idle", error: null },
|
|
||||||
focusReturn: document.activeElement,
|
focusReturn: document.activeElement,
|
||||||
controller: null,
|
controller: null,
|
||||||
flight: null,
|
flight: null,
|
||||||
@@ -184,9 +179,6 @@
|
|||||||
(nodes.length ? nodes[0] : shell).focus();
|
(nodes.length ? nodes[0] : shell).focus();
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
|
|
||||||
document.dispatchEvent(new CustomEvent("aksrt:remote-modal:open", {
|
|
||||||
detail: { shell: shell, options: options, session: session },
|
|
||||||
}));
|
|
||||||
document.dispatchEvent(new CustomEvent("aksrt:modal:open", {
|
document.dispatchEvent(new CustomEvent("aksrt:modal:open", {
|
||||||
detail: { shell: shell, options: options, session: session },
|
detail: { shell: shell, options: options, session: session },
|
||||||
}));
|
}));
|
||||||
@@ -203,9 +195,7 @@
|
|||||||
|
|
||||||
function rehydrate(session) {
|
function rehydrate(session) {
|
||||||
if (!session || !session.content) return;
|
if (!session || !session.content) return;
|
||||||
if (window.AksrtFrontend && typeof window.AksrtFrontend.rehydrate === "function") {
|
window.AksrtFrontend.rehydrate(session.content, "modal");
|
||||||
window.AksrtFrontend.rehydrate(session.content, "modal");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function abortSessionRequest(session) {
|
function abortSessionRequest(session) {
|
||||||
@@ -226,9 +216,6 @@
|
|||||||
if (!preserveRequest) abortSessionRequest(session);
|
if (!preserveRequest) abortSessionRequest(session);
|
||||||
session.shell.classList.remove("is-open");
|
session.shell.classList.remove("is-open");
|
||||||
if (!preserveRequest) lockScroll(false);
|
if (!preserveRequest) lockScroll(false);
|
||||||
document.dispatchEvent(new CustomEvent("aksrt:remote-modal:close", {
|
|
||||||
detail: { shell: session.shell, reason: reason || "close", session: session },
|
|
||||||
}));
|
|
||||||
document.dispatchEvent(new CustomEvent("aksrt:modal:close", {
|
document.dispatchEvent(new CustomEvent("aksrt:modal:close", {
|
||||||
detail: { shell: session.shell, reason: reason || "close", session: session },
|
detail: { shell: session.shell, reason: reason || "close", session: session },
|
||||||
}));
|
}));
|
||||||
@@ -249,8 +236,6 @@
|
|||||||
if (json) {
|
if (json) {
|
||||||
if (typeof json.html === "string") return json.html;
|
if (typeof json.html === "string") return json.html;
|
||||||
if (json.data && typeof json.data.html === "string") return json.data.html;
|
if (json.data && typeof json.data.html === "string") return json.data.html;
|
||||||
if (json.data && typeof json.data.show_modal === "string") return json.data.show_modal;
|
|
||||||
if (typeof json.data === "string") return json.data;
|
|
||||||
}
|
}
|
||||||
return typeof result.text === "string" ? result.text : "";
|
return typeof result.text === "string" ? result.text : "";
|
||||||
}
|
}
|
||||||
@@ -266,11 +251,11 @@
|
|||||||
setState(session, unauthorized ? "unauthorized" : "error", error);
|
setState(session, unauthorized ? "unauthorized" : "error", error);
|
||||||
telemetryMark(session, unauthorized ? "unauthorized" : "error");
|
telemetryMark(session, unauthorized ? "unauthorized" : "error");
|
||||||
session.content.innerHTML =
|
session.content.innerHTML =
|
||||||
'<div class="aksrt-remote-modal__error touch border-title"><b>提示</b></div>' +
|
'<div class="aksrt-modal-runtime__error touch border-title"><b>提示</b></div>' +
|
||||||
'<div class="aksrt-remote-modal__error-body">' + escapeHtml(errorMessage(error)) +
|
'<div class="aksrt-modal-runtime__error-body">' + escapeHtml(errorMessage(error)) +
|
||||||
'</div><div class="but-average modal-buts">' +
|
'</div><div class="but-average modal-buts">' +
|
||||||
'<button type="button" class="but" data-aksrt-remote-modal-retry>重试</button>' +
|
'<button type="button" class="but" data-aksrt-modal-retry>重试</button>' +
|
||||||
'<button type="button" class="but" data-aksrt-remote-modal-close>关闭</button></div>';
|
'<button type="button" class="but" data-aksrt-modal-close>关闭</button></div>';
|
||||||
rehydrate(session);
|
rehydrate(session);
|
||||||
if (typeof session.options.onError === "function") session.options.onError(error, session);
|
if (typeof session.options.onError === "function") session.options.onError(error, session);
|
||||||
}
|
}
|
||||||
@@ -282,7 +267,7 @@
|
|||||||
setState(session, "empty");
|
setState(session, "empty");
|
||||||
telemetryMark(session, "first-content");
|
telemetryMark(session, "first-content");
|
||||||
telemetryMark(session, "ready");
|
telemetryMark(session, "ready");
|
||||||
session.content.innerHTML = '<div class="aksrt-remote-modal__error-body">暂无内容</div>';
|
session.content.innerHTML = '<div class="aksrt-modal-runtime__error-body">暂无内容</div>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
session.content.innerHTML = html;
|
session.content.innerHTML = html;
|
||||||
@@ -311,21 +296,14 @@
|
|||||||
if (requestOptions.body === undefined) delete requestOptions.body;
|
if (requestOptions.body === undefined) delete requestOptions.body;
|
||||||
if (!requestOptions.signal) delete requestOptions.signal;
|
if (!requestOptions.signal) delete requestOptions.signal;
|
||||||
|
|
||||||
var request = window.AksrtRequest && typeof window.AksrtRequest.request === "function"
|
var request = function () {
|
||||||
? function () { return window.AksrtRequest.request(session.options.url, requestOptions); }
|
return window.AksrtRequest.request(session.options.url, requestOptions);
|
||||||
: function () {
|
};
|
||||||
return window.fetch(session.options.url, requestOptions).then(function (response) {
|
|
||||||
return response.text().then(function (text) { return { ok: response.ok, status: response.status, text: text, json: null }; });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
var method = String(session.options.method || "GET").toUpperCase();
|
var method = String(session.options.method || "GET").toUpperCase();
|
||||||
var cacheable = method === "GET" && session.options.cache !== false;
|
var cacheable = method === "GET" && session.options.cache !== false;
|
||||||
var cacheKey = session.options.cacheKey ||
|
var cacheKey = session.options.cacheKey ||
|
||||||
method + ":" +
|
method + ":" + window.AksrtRequest.url(session.options.url, session.options.query);
|
||||||
(window.AksrtRequest && typeof window.AksrtRequest.url === "function"
|
|
||||||
? window.AksrtRequest.url(session.options.url, session.options.query)
|
|
||||||
: session.options.url);
|
|
||||||
var cache = window.AksrtModalCache;
|
var cache = window.AksrtModalCache;
|
||||||
var acquireOptions = {
|
var acquireOptions = {
|
||||||
ttl: Number(session.options.cacheTtl || 15000),
|
ttl: Number(session.options.cacheTtl || 15000),
|
||||||
@@ -339,7 +317,7 @@
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
session.flight = cacheable && cache && typeof cache.acquire === "function"
|
session.flight = cacheable
|
||||||
? cache.acquire(cacheKey, request, acquireOptions)
|
? cache.acquire(cacheKey, request, acquireOptions)
|
||||||
: { promise: request(), release: function () {} };
|
: { promise: request(), release: function () {} };
|
||||||
|
|
||||||
@@ -367,9 +345,7 @@
|
|||||||
function sessionKey(options) {
|
function sessionKey(options) {
|
||||||
if (!options || !options.url) return "";
|
if (!options || !options.url) return "";
|
||||||
var method = String(options.method || "GET").toUpperCase();
|
var method = String(options.method || "GET").toUpperCase();
|
||||||
var requestUrl = window.AksrtRequest && typeof window.AksrtRequest.url === "function"
|
var requestUrl = window.AksrtRequest.url(options.url, options.query);
|
||||||
? window.AksrtRequest.url(options.url, options.query)
|
|
||||||
: String(options.url);
|
|
||||||
return method + ":" + requestUrl;
|
return method + ":" + requestUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,10 +376,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function invalidate(tags) {
|
function invalidate(tags) {
|
||||||
if (window.AksrtModalCache && typeof window.AksrtModalCache.invalidate === "function") {
|
return window.AksrtModalCache.invalidate(tags);
|
||||||
return window.AksrtModalCache.invalidate(tags);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.AksrtModalRuntime = {
|
window.AksrtModalRuntime = {
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* Declarative modal triggers.
|
||||||
|
*
|
||||||
|
* The only modal entry point is AksrtModalRuntime. Triggers carry an
|
||||||
|
* explicit URL and never create a second modal implementation.
|
||||||
|
*
|
||||||
|
* @package AKSRT
|
||||||
|
*/
|
||||||
|
(function (window, document) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
function openFromTrigger(element) {
|
||||||
|
var runtime = window.AksrtModalRuntime;
|
||||||
|
var url = element.getAttribute("data-aksrt-modal-url") || "";
|
||||||
|
if (!url || url === "#") return;
|
||||||
|
|
||||||
|
var ttl = parseInt(element.getAttribute("data-aksrt-modal-cache-ttl") || "15000", 10);
|
||||||
|
var tags = (element.getAttribute("data-aksrt-modal-cache-tags") || "").split(",").map(function (tag) {
|
||||||
|
return tag.trim();
|
||||||
|
}).filter(Boolean);
|
||||||
|
|
||||||
|
runtime.openRemote({
|
||||||
|
url: url,
|
||||||
|
method: element.getAttribute("data-aksrt-modal-method") || "GET",
|
||||||
|
className: element.getAttribute("data-aksrt-modal-class") || "modal-mini full-sm",
|
||||||
|
height: parseInt(element.getAttribute("data-aksrt-modal-height") || "0", 10) || 0,
|
||||||
|
mobileBottom: element.getAttribute("data-aksrt-modal-mobile-bottom") === "true",
|
||||||
|
bottom: element.getAttribute("data-aksrt-modal-bottom") === "true",
|
||||||
|
kind: element.getAttribute("data-aksrt-modal-kind") || "generic",
|
||||||
|
cacheKey: element.getAttribute("data-aksrt-modal-cache-key") || "",
|
||||||
|
cacheTtl: ttl > 0 ? ttl : 15000,
|
||||||
|
cacheTags: tags,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("click", function (event) {
|
||||||
|
var trigger = event.target.closest('[data-aksrt-modal="remote"]');
|
||||||
|
if (!trigger) return;
|
||||||
|
event.preventDefault();
|
||||||
|
openFromTrigger(trigger);
|
||||||
|
});
|
||||||
|
})(window, document);
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
/**
|
|
||||||
* AKSRT Remote Modal compatibility bridge.
|
|
||||||
*
|
|
||||||
* The lifecycle implementation lives in AksrtModalRuntime. This file keeps
|
|
||||||
* the legacy trigger contract and the AksrtRemoteModal public alias stable.
|
|
||||||
*
|
|
||||||
* @package AKSRT
|
|
||||||
*/
|
|
||||||
(function (window, document) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function runtime() {
|
|
||||||
return window.AksrtModalRuntime || null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fromTrigger(element) {
|
|
||||||
var modalRuntime = runtime();
|
|
||||||
if (!modalRuntime || !element) return Promise.reject(new Error("modal runtime unavailable"));
|
|
||||||
|
|
||||||
var url = element.getAttribute("data-remote") ||
|
|
||||||
element.getAttribute("data-aksrt-remote") ||
|
|
||||||
element.getAttribute("href") || "";
|
|
||||||
if (!url || url === "#") return Promise.resolve(null);
|
|
||||||
|
|
||||||
var ttl = parseInt(element.getAttribute("data-modal-cache-ttl") || "15000", 10);
|
|
||||||
var tags = (element.getAttribute("data-modal-cache-tags") || "").split(",").map(function (tag) {
|
|
||||||
return tag.trim();
|
|
||||||
}).filter(Boolean);
|
|
||||||
|
|
||||||
return modalRuntime.openRemote({
|
|
||||||
url: url,
|
|
||||||
method: element.getAttribute("data-method") || "GET",
|
|
||||||
className: element.getAttribute("data-class") || element.getAttribute("data-aksrt-class") || "modal-mini full-sm",
|
|
||||||
height: parseInt(element.getAttribute("data-height") || element.getAttribute("data-aksrt-height") || "0", 10) || 0,
|
|
||||||
mobileBottom: element.getAttribute("mobile-bottom") !== "false",
|
|
||||||
bottom: element.getAttribute("data-bottom") === "true",
|
|
||||||
kind: element.getAttribute("data-modal-kind") || "generic",
|
|
||||||
cacheKey: element.getAttribute("data-modal-cache-key") || "",
|
|
||||||
cacheTtl: ttl > 0 ? ttl : 15000,
|
|
||||||
cacheTags: tags,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function bind() {
|
|
||||||
if (window.__aksrtRemoteModalBound) return;
|
|
||||||
if (!runtime()) return;
|
|
||||||
window.__aksrtRemoteModalBound = true;
|
|
||||||
|
|
||||||
document.addEventListener("click", function (event) {
|
|
||||||
var trigger = event.target.closest(
|
|
||||||
'[data-toggle="AksrtRemoteModal"], [data-toggle="RefreshModal"], [data-aksrt-remote-modal], a.aksrt-remote-modal-link'
|
|
||||||
);
|
|
||||||
if (!trigger || trigger.getAttribute("data-aksrt-remote-modal") === "off") return;
|
|
||||||
event.preventDefault();
|
|
||||||
fromTrigger(trigger);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function expose() {
|
|
||||||
var modalRuntime = runtime();
|
|
||||||
if (!modalRuntime) return;
|
|
||||||
window.AksrtRemoteModal = {
|
|
||||||
open: modalRuntime.open,
|
|
||||||
openRemote: modalRuntime.openRemote,
|
|
||||||
close: modalRuntime.close,
|
|
||||||
refresh: modalRuntime.refresh,
|
|
||||||
fromTrigger: fromTrigger,
|
|
||||||
getActive: modalRuntime.getActive,
|
|
||||||
};
|
|
||||||
bind();
|
|
||||||
}
|
|
||||||
|
|
||||||
expose();
|
|
||||||
if (!window.AksrtModalRuntime) {
|
|
||||||
document.addEventListener("aksrt:modal-runtime:ready", expose, { once: true });
|
|
||||||
}
|
|
||||||
})(window, document);
|
|
||||||
@@ -302,7 +302,7 @@
|
|||||||
initParallax();
|
initParallax();
|
||||||
initFloatLabels();
|
initFloatLabels();
|
||||||
initSigninCalendar();
|
initSigninCalendar();
|
||||||
document.addEventListener('aksrt:remote-modal:open', function () {
|
document.addEventListener('aksrt:modal:open', function () {
|
||||||
// Remote modal may inject calendar markup after open.
|
// Remote modal may inject calendar markup after open.
|
||||||
window.setTimeout(initSigninCalendar, 30);
|
window.setTimeout(initSigninCalendar, 30);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,21 +16,10 @@
|
|||||||
var detailOrderNumber = "";
|
var detailOrderNumber = "";
|
||||||
|
|
||||||
function toast(message, type) {
|
function toast(message, type) {
|
||||||
if (typeof window.AksrtToast === "function") {
|
window.AksrtToast(message, type || "info");
|
||||||
window.AksrtToast(message, type || "info");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (typeof window.aksrtNotify === "function") {
|
|
||||||
window.aksrtNotify(message, type || "info");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
window.alert(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function request(path, body, method) {
|
function request(path, body, method) {
|
||||||
if (!window.AksrtRequest || typeof window.AksrtRequest.request !== "function") {
|
|
||||||
return Promise.resolve({ success: false, message: "请求适配器未加载" });
|
|
||||||
}
|
|
||||||
var options = { method: method || "POST" };
|
var options = { method: method || "POST" };
|
||||||
if (body !== undefined) options.body = JSON.stringify(body || {});
|
if (body !== undefined) options.body = JSON.stringify(body || {});
|
||||||
return window.AksrtRequest.request(path, options).then(function (response) {
|
return window.AksrtRequest.request(path, options).then(function (response) {
|
||||||
@@ -219,9 +208,7 @@
|
|||||||
button.disabled = true;
|
button.disabled = true;
|
||||||
request(orderPath(number, "/pay"), method ? { payment_method: method } : {}).then(function (result) {
|
request(orderPath(number, "/pay"), method ? { payment_method: method } : {}).then(function (result) {
|
||||||
if (!result.success) throw new Error(result.message || "支付失败");
|
if (!result.success) throw new Error(result.message || "支付失败");
|
||||||
if (window.AksrtModalRuntime && typeof window.AksrtModalRuntime.invalidate === "function") {
|
window.AksrtModalRuntime.invalidate(["orders", "vip"]);
|
||||||
window.AksrtModalRuntime.invalidate(["orders", "vip"]);
|
|
||||||
}
|
|
||||||
var data = result.data || {};
|
var data = result.data || {};
|
||||||
if (data.redirect && data.payment_url) {
|
if (data.redirect && data.payment_url) {
|
||||||
window.location.assign(data.payment_url);
|
window.location.assign(data.payment_url);
|
||||||
@@ -246,9 +233,7 @@
|
|||||||
button.disabled = true;
|
button.disabled = true;
|
||||||
request(orderPath(number, "/cancel")).then(function (result) {
|
request(orderPath(number, "/cancel")).then(function (result) {
|
||||||
if (!result.success) throw new Error(result.message || "关闭订单失败");
|
if (!result.success) throw new Error(result.message || "关闭订单失败");
|
||||||
if (window.AksrtModalRuntime && typeof window.AksrtModalRuntime.invalidate === "function") {
|
window.AksrtModalRuntime.invalidate(["orders", "vip"]);
|
||||||
window.AksrtModalRuntime.invalidate(["orders", "vip"]);
|
|
||||||
}
|
|
||||||
toast("订单已关闭");
|
toast("订单已关闭");
|
||||||
refreshView();
|
refreshView();
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
|
|||||||
+6
-29
@@ -6,16 +6,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function api(path, options) {
|
function api(path, options) {
|
||||||
var opts = Object.assign({}, options || {});
|
return window.AksrtRequest.request(path, Object.assign({}, options || {})).then(function (response) {
|
||||||
var request = window.AksrtRequest && typeof window.AksrtRequest.request === "function"
|
|
||||||
? window.AksrtRequest.request(path, opts)
|
|
||||||
: fetch(path, Object.assign({ credentials: "same-origin" }, opts)).then(function (response) {
|
|
||||||
return response.json().then(function (json) {
|
|
||||||
return { ok: response.ok, status: response.status, json: json };
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return request.then(function (response) {
|
|
||||||
return {
|
return {
|
||||||
ok: response.ok,
|
ok: response.ok,
|
||||||
status: response.status,
|
status: response.status,
|
||||||
@@ -34,11 +25,10 @@
|
|||||||
var activeVipShell = null;
|
var activeVipShell = null;
|
||||||
|
|
||||||
function openModal() {
|
function openModal() {
|
||||||
if (!window.AksrtModalRuntime || typeof window.AksrtModalRuntime.open !== "function") return null;
|
|
||||||
activeVipShell = window.AksrtModalRuntime.open({
|
activeVipShell = window.AksrtModalRuntime.open({
|
||||||
className: "aksrt-vip-modal-shell",
|
className: "aksrt-vip-modal-shell",
|
||||||
mobileBottom: false,
|
mobileBottom: false,
|
||||||
skeleton: '<div class="aksrt-vip-modal-dialog"><div class="aksrt-vip-modal-content" data-aksrt-vip-modal-body><div class="text-center padding-20 muted-2-color">加载中…</div></div></div>',
|
skeleton: '<div class="aksrt-vip-modal-panel"><div class="aksrt-vip-modal-content" data-aksrt-vip-modal-body><div class="text-center padding-20 muted-2-color">加载中…</div></div></div>',
|
||||||
telemetry: false,
|
telemetry: false,
|
||||||
kind: "vip",
|
kind: "vip",
|
||||||
});
|
});
|
||||||
@@ -46,9 +36,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function closeModal() {
|
function closeModal() {
|
||||||
if (window.AksrtModalRuntime && typeof window.AksrtModalRuntime.close === "function") {
|
window.AksrtModalRuntime.close("vip");
|
||||||
window.AksrtModalRuntime.close("vip");
|
|
||||||
}
|
|
||||||
activeVipShell = null;
|
activeVipShell = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,17 +139,13 @@
|
|||||||
}
|
}
|
||||||
var data = r.json && r.json.data ? r.json.data : r.json;
|
var data = r.json && r.json.data ? r.json.data : r.json;
|
||||||
if (data && data.redirect && (data.payment_url || data.qr_content)) {
|
if (data && data.redirect && (data.payment_url || data.qr_content)) {
|
||||||
if (window.AksrtModalRuntime && typeof window.AksrtModalRuntime.invalidate === "function") {
|
window.AksrtModalRuntime.invalidate(["vip", "orders"]);
|
||||||
window.AksrtModalRuntime.invalidate(["vip", "orders"]);
|
|
||||||
}
|
|
||||||
if (data.payment_url) window.open(data.payment_url, "_blank");
|
if (data.payment_url) window.open(data.payment_url, "_blank");
|
||||||
setTip(pane, data.message || "请完成支付,支付成功后将自动刷新。");
|
setTip(pane, data.message || "请完成支付,支付成功后将自动刷新。");
|
||||||
if (data.order_number) pollOrder(data.order_number);
|
if (data.order_number) pollOrder(data.order_number);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (window.AksrtModalRuntime && typeof window.AksrtModalRuntime.invalidate === "function") {
|
window.AksrtModalRuntime.invalidate(["vip", "orders"]);
|
||||||
window.AksrtModalRuntime.invalidate(["vip", "orders"]);
|
|
||||||
}
|
|
||||||
setTip(pane, (data && data.message) || "开通成功,正在刷新…");
|
setTip(pane, (data && data.message) || "开通成功,正在刷新…");
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
@@ -189,11 +173,6 @@
|
|||||||
if (telemetry && telemetryId && typeof telemetry.mark === "function") telemetry.mark(telemetryId, event);
|
if (telemetry && telemetryId && typeof telemetry.mark === "function") telemetry.mark(telemetryId, event);
|
||||||
}
|
}
|
||||||
var shell = openModal();
|
var shell = openModal();
|
||||||
if (!shell) {
|
|
||||||
loading = false;
|
|
||||||
telemetryMark("error");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var body = shell.querySelector("[data-aksrt-vip-modal-body]");
|
var body = shell.querySelector("[data-aksrt-vip-modal-body]");
|
||||||
telemetryMark("shell");
|
telemetryMark("shell");
|
||||||
|
|
||||||
@@ -220,9 +199,7 @@
|
|||||||
if (body) {
|
if (body) {
|
||||||
body.innerHTML = r.json.html;
|
body.innerHTML = r.json.html;
|
||||||
telemetryMark("first-content");
|
telemetryMark("first-content");
|
||||||
if (window.AksrtFrontend && typeof window.AksrtFrontend.rehydrate === "function") {
|
window.AksrtFrontend.rehydrate(body, "modal");
|
||||||
window.AksrtFrontend.rehydrate(body, "modal");
|
|
||||||
}
|
|
||||||
bindModalUi(body);
|
bindModalUi(body);
|
||||||
telemetryMark("ready");
|
telemetryMark("ready");
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-29
@@ -3,15 +3,12 @@
|
|||||||
*
|
*
|
||||||
* User-center modal: category-grouped medal card grid + in-modal detail
|
* User-center modal: category-grouped medal card grid + in-modal detail
|
||||||
* view (medal-background card, obtain time, wear action). Also provides the
|
* view (medal-background card, obtain time, wear action). Also provides the
|
||||||
* global wear handler used inside remote (AJAX HTML) badge modals.
|
* global wear handler used inside runtime-loaded badge modals.
|
||||||
*/
|
*/
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function api(path, options) {
|
function api(path, options) {
|
||||||
if (!window.AksrtRequest || typeof window.AksrtRequest.request !== 'function') {
|
|
||||||
return Promise.resolve({ ok: false, status: 0, json: { message: '请求适配器未加载' } });
|
|
||||||
}
|
|
||||||
return window.AksrtRequest.request(path, options || {}).then(function (response) {
|
return window.AksrtRequest.request(path, options || {}).then(function (response) {
|
||||||
return { ok: response.ok, status: response.status, json: response.json || {} };
|
return { ok: response.ok, status: response.status, json: response.json || {} };
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
@@ -25,15 +22,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toast(msg, type) {
|
function toast(msg, type) {
|
||||||
if (typeof window.AksrtToast === 'function') {
|
window.AksrtToast(msg, type || 'info');
|
||||||
window.AksrtToast(msg, type || 'info');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (typeof window.aksrtNotify === 'function') {
|
|
||||||
window.aksrtNotify(msg, type || 'info');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try { console.log('[AKSRT badges]', msg); } catch (_) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function escapeHtml(s) {
|
function escapeHtml(s) {
|
||||||
@@ -260,9 +249,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
toast((r.json && r.json.message) || '已佩戴徽章', 'success');
|
toast((r.json && r.json.message) || '已佩戴徽章', 'success');
|
||||||
if (window.AksrtModalRuntime && typeof window.AksrtModalRuntime.invalidate === 'function') {
|
window.AksrtModalRuntime.invalidate(['badges', 'identity']);
|
||||||
window.AksrtModalRuntime.invalidate(['badges', 'identity']);
|
|
||||||
}
|
|
||||||
state.data = (r.json && r.json.data) || state.data;
|
state.data = (r.json && r.json.data) || state.data;
|
||||||
renderHead();
|
renderHead();
|
||||||
renderGrid();
|
renderGrid();
|
||||||
@@ -352,9 +339,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
toast((r.json && r.json.message) || '已佩戴徽章', 'success');
|
toast((r.json && r.json.message) || '已佩戴徽章', 'success');
|
||||||
if (window.AksrtModalRuntime && typeof window.AksrtModalRuntime.invalidate === 'function') {
|
window.AksrtModalRuntime.invalidate(['badges', 'identity']);
|
||||||
window.AksrtModalRuntime.invalidate(['badges', 'identity']);
|
|
||||||
}
|
|
||||||
// Re-open the refreshed single-badge modal so state stays in sync.
|
// Re-open the refreshed single-badge modal so state stays in sync.
|
||||||
var refreshed = null;
|
var refreshed = null;
|
||||||
try {
|
try {
|
||||||
@@ -362,19 +347,21 @@
|
|||||||
var data = r.json && r.json.data;
|
var data = r.json && r.json.data;
|
||||||
var isSelf = data && data.is_self;
|
var isSelf = data && data.is_self;
|
||||||
if (isSelf && data.wear) {
|
if (isSelf && data.wear) {
|
||||||
refreshed = (window.aksrtData && aksrtData.ajaxUrl)
|
refreshed = (window.aksrtData && window.aksrtData.ajaxUrl)
|
||||||
? aksrtData.ajaxUrl + '?action=aksrt_single_badge_info_modal&name=' + encodeURIComponent(data.wear) + '&user_id=' + (uid || 0)
|
? window.aksrtData.ajaxUrl + '?action=aksrt_single_badge_info_modal&name=' + encodeURIComponent(data.wear) + '&user_id=' + (uid || 0)
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
try {
|
if (refreshed) {
|
||||||
if (refreshed && window.AksrtRemoteModal && typeof window.AksrtRemoteModal.openRemote === 'function') {
|
window.AksrtModalRuntime.openRemote({
|
||||||
window.AksrtRemoteModal.openRemote({ url: refreshed, className: 'modal-mini', mobileBottom: true });
|
url: refreshed,
|
||||||
} else {
|
className: 'modal-mini',
|
||||||
document.dispatchEvent(new CustomEvent('aksrt:remote-modal:close'));
|
mobileBottom: true,
|
||||||
}
|
kind: 'badges',
|
||||||
} catch (_) {
|
cache: false,
|
||||||
try { document.dispatchEvent(new CustomEvent('aksrt:remote-modal:close')); } catch (__) {}
|
});
|
||||||
|
} else {
|
||||||
|
window.AksrtModalRuntime.close('badge-wear');
|
||||||
}
|
}
|
||||||
}).catch(function () {
|
}).catch(function () {
|
||||||
toast('网络错误', 'error');
|
toast('网络错误', 'error');
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Ajax list + remote modal helpers (zibll ajax-next / RefreshModal parity).
|
* Ajax list helpers and declarative modal trigger markup.
|
||||||
*
|
*
|
||||||
* @package AKSRT
|
* @package AKSRT
|
||||||
*/
|
*/
|
||||||
@@ -64,9 +64,9 @@ if (!function_exists('aksrt_get_ajax_next_paginate')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('aksrt_get_remote_modal_link')) {
|
if (!function_exists('aksrt_get_modal_link')) {
|
||||||
/**
|
/**
|
||||||
* Build a remote-modal trigger (zibll zib_get_refresh_modal_link subset).
|
* Build a declarative modal runtime trigger.
|
||||||
*
|
*
|
||||||
* @param array{
|
* @param array{
|
||||||
* tag?:string,class?:string,text?:string,url?:string,
|
* tag?:string,class?:string,text?:string,url?:string,
|
||||||
@@ -74,7 +74,7 @@ if (!function_exists('aksrt_get_remote_modal_link')) {
|
|||||||
* query_arg?:array<string,scalar>
|
* query_arg?:array<string,scalar>
|
||||||
* } $args
|
* } $args
|
||||||
*/
|
*/
|
||||||
function aksrt_get_remote_modal_link(array $args = []): string {
|
function aksrt_get_modal_link(array $args = []): string {
|
||||||
$tag = sanitize_key((string) ($args['tag'] ?? 'a'));
|
$tag = sanitize_key((string) ($args['tag'] ?? 'a'));
|
||||||
if (!in_array($tag, ['a', 'button', 'span'], true)) {
|
if (!in_array($tag, ['a', 'button', 'span'], true)) {
|
||||||
$tag = 'a';
|
$tag = 'a';
|
||||||
@@ -90,15 +90,15 @@ if (!function_exists('aksrt_get_remote_modal_link')) {
|
|||||||
$height = isset($args['height']) ? (int) $args['height'] : 0;
|
$height = isset($args['height']) ? (int) $args['height'] : 0;
|
||||||
$mobile = !isset($args['mobile_bottom']) || !empty($args['mobile_bottom']);
|
$mobile = !isset($args['mobile_bottom']) || !empty($args['mobile_bottom']);
|
||||||
|
|
||||||
$attrs = ' class="' . esc_attr(trim($class . ' aksrt-remote-modal-link')) . '"';
|
$attrs = ' class="' . esc_attr(trim($class . ' aksrt-modal-link')) . '"';
|
||||||
$attrs .= ' data-toggle="AksrtRemoteModal"';
|
$attrs .= ' data-aksrt-modal="remote"';
|
||||||
$attrs .= ' data-remote="' . esc_url($url) . '"';
|
$attrs .= ' data-aksrt-modal-url="' . esc_url($url) . '"';
|
||||||
$attrs .= ' data-class="' . esc_attr($data_class) . '"';
|
$attrs .= ' data-aksrt-modal-class="' . esc_attr($data_class) . '"';
|
||||||
if ($height > 0) {
|
if ($height > 0) {
|
||||||
$attrs .= ' data-height="' . esc_attr((string) $height) . '"';
|
$attrs .= ' data-aksrt-modal-height="' . esc_attr((string) $height) . '"';
|
||||||
}
|
}
|
||||||
if ($mobile) {
|
if ($mobile) {
|
||||||
$attrs .= ' mobile-bottom="true"';
|
$attrs .= ' data-aksrt-modal-mobile-bottom="true"';
|
||||||
}
|
}
|
||||||
if ($tag === 'a') {
|
if ($tag === 'a') {
|
||||||
$attrs .= ' href="' . esc_url($url !== '' ? $url : '#') . '"';
|
$attrs .= ' href="' . esc_url($url !== '' ? $url : '#') . '"';
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ trait VipServiceModal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$html = '<div class="box-body payvip-modal" data-aksrt-vip-modal>';
|
$html = '<div class="box-body payvip-modal" data-aksrt-vip-modal>';
|
||||||
$html .= '<button type="button" class="close aksrt-vip-modal-close" aria-label="Close">×</button>';
|
$html .= '<button type="button" class="aksrt-modal-close" data-aksrt-modal-close aria-label="Close">×</button>';
|
||||||
$html .= '<ul class="list-inline user-box flex ac mb10"><li class="avatar-img">' . $avatar . '</li>';
|
$html .= '<ul class="list-inline user-box flex ac mb10"><li class="avatar-img">' . $avatar . '</li>';
|
||||||
$html .= '<li><b class="em12">' . esc_html($name) . '</b>';
|
$html .= '<li><b class="em12">' . esc_html($name) . '</b>';
|
||||||
if ($desc !== '') {
|
if ($desc !== '') {
|
||||||
@@ -232,7 +232,7 @@ trait VipServiceModal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$html = '<div class="box-body payvip-modal" data-aksrt-vip-modal>';
|
$html = '<div class="box-body payvip-modal" data-aksrt-vip-modal>';
|
||||||
$html .= '<button type="button" class="close aksrt-vip-modal-close" aria-label="Close">×</button>';
|
$html .= '<button type="button" class="aksrt-modal-close" data-aksrt-modal-close aria-label="Close">×</button>';
|
||||||
$html .= '<ul class="list-inline user-box flex ac mb10"><li class="avatar-img">' . $avatar . '</li>';
|
$html .= '<ul class="list-inline user-box flex ac mb10"><li class="avatar-img">' . $avatar . '</li>';
|
||||||
$html .= '<li><b class="em12">' . esc_html($name) . '</b>';
|
$html .= '<li><b class="em12">' . esc_html($name) . '</b>';
|
||||||
$html .= '<div class="muted-2-color em09"><span class="badg c-yellow vip-expdate-tag">'
|
$html .= '<div class="muted-2-color em09"><span class="badg c-yellow vip-expdate-tag">'
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ trait ScriptsPart1b {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 4a-b. 全局补充样式(骨架屏、空状态、分页、加载指示器)
|
// 4a-b. 全局补充样式(骨架屏、空状态、分页、加载指示器)
|
||||||
foreach (['skeleton', 'empty-state', 'pagination', 'ajax-spinner', 'remote-modal'] as $slug) {
|
foreach (['skeleton', 'empty-state', 'pagination', 'ajax-spinner', 'modal-runtime'] as $slug) {
|
||||||
$css_path = get_template_directory() . '/assets/css/frontend/' . $slug . '.css';
|
$css_path = get_template_directory() . '/assets/css/frontend/' . $slug . '.css';
|
||||||
if (file_exists($css_path)) {
|
if (file_exists($css_path)) {
|
||||||
wp_enqueue_style(
|
wp_enqueue_style(
|
||||||
@@ -894,7 +894,7 @@ $hmb_js = get_template_directory() . '/assets/js/header-newadd.js';
|
|||||||
wp_enqueue_script(
|
wp_enqueue_script(
|
||||||
'aksrt-user-badges',
|
'aksrt-user-badges',
|
||||||
$base_uri . '/assets/js/user-badges.js',
|
$base_uri . '/assets/js/user-badges.js',
|
||||||
['aksrt-script', 'aksrt-core-request', 'aksrt-core-modal-runtime', 'aksrt-core-remote-modal'],
|
['aksrt-script', 'aksrt-core-request', 'aksrt-core-modal-runtime', 'aksrt-core-modal-triggers'],
|
||||||
(string) filemtime($badges_js_path),
|
(string) filemtime($badges_js_path),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
@@ -917,7 +917,7 @@ $hmb_js = get_template_directory() . '/assets/js/header-newadd.js';
|
|||||||
wp_enqueue_script(
|
wp_enqueue_script(
|
||||||
'aksrt-user-badges',
|
'aksrt-user-badges',
|
||||||
$base_uri . '/assets/js/user-badges.js',
|
$base_uri . '/assets/js/user-badges.js',
|
||||||
['aksrt-script', 'aksrt-core-request', 'aksrt-core-modal-runtime', 'aksrt-core-remote-modal'],
|
['aksrt-script', 'aksrt-core-request', 'aksrt-core-modal-runtime', 'aksrt-core-modal-triggers'],
|
||||||
(string) filemtime($badges_js_path_global),
|
(string) filemtime($badges_js_path_global),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ trait ScriptsPart1c {
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
// Runtime infrastructure: tbquire / notyf / confirm / refreshModal / scrollTopTo / [data-*] declarative
|
// Runtime infrastructure: tbquire / notyf / confirm / scrollTopTo / [data-*] declarative
|
||||||
$runtime_js = get_template_directory() . '/assets/js/aksrt-runtime.js';
|
$runtime_js = get_template_directory() . '/assets/js/aksrt-runtime.js';
|
||||||
if (file_exists($runtime_js)) {
|
if (file_exists($runtime_js)) {
|
||||||
wp_enqueue_script(
|
wp_enqueue_script(
|
||||||
@@ -132,7 +132,7 @@ trait ScriptsPart1c {
|
|||||||
'aksrt-core-modal-cache' => 'modal-cache.js',
|
'aksrt-core-modal-cache' => 'modal-cache.js',
|
||||||
'aksrt-core-modal-state' => 'modal-state.js',
|
'aksrt-core-modal-state' => 'modal-state.js',
|
||||||
'aksrt-core-modal-runtime' => 'modal-runtime.js',
|
'aksrt-core-modal-runtime' => 'modal-runtime.js',
|
||||||
'aksrt-core-remote-modal' => 'remote-modal.js',
|
'aksrt-core-modal-triggers' => 'modal-triggers.js',
|
||||||
'aksrt-core-pagination' => 'pagination.js',
|
'aksrt-core-pagination' => 'pagination.js',
|
||||||
'aksrt-core-archive' => 'archive.js',
|
'aksrt-core-archive' => 'archive.js',
|
||||||
'aksrt-core-footer-tabbar' => 'footer-tabbar.js',
|
'aksrt-core-footer-tabbar' => 'footer-tabbar.js',
|
||||||
@@ -153,7 +153,7 @@ trait ScriptsPart1c {
|
|||||||
'aksrt-core-modal-cache',
|
'aksrt-core-modal-cache',
|
||||||
'aksrt-core-modal-state',
|
'aksrt-core-modal-state',
|
||||||
]);
|
]);
|
||||||
} elseif ($handle === 'aksrt-core-remote-modal') {
|
} elseif ($handle === 'aksrt-core-modal-triggers') {
|
||||||
$deps[] = 'aksrt-core-modal-runtime';
|
$deps[] = 'aksrt-core-modal-runtime';
|
||||||
}
|
}
|
||||||
wp_enqueue_script(
|
wp_enqueue_script(
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ class Signin {
|
|||||||
$html .= '<div class="aksrt-checkin-modal__head">';
|
$html .= '<div class="aksrt-checkin-modal__head">';
|
||||||
$html .= '<i class="fa fa-calendar-check-o" aria-hidden="true"></i>';
|
$html .= '<i class="fa fa-calendar-check-o" aria-hidden="true"></i>';
|
||||||
$html .= '<strong>' . esc_html__('签到领奖励', 'aksrt') . '</strong>';
|
$html .= '<strong>' . esc_html__('签到领奖励', 'aksrt') . '</strong>';
|
||||||
$html .= '<button type="button" class="aksrt-remote-modal__close" data-aksrt-remote-modal-close aria-label="' . esc_attr__('关闭', 'aksrt') . '">×</button>';
|
$html .= '<button type="button" class="aksrt-modal-runtime__close" data-aksrt-modal-close aria-label="' . esc_attr__('关闭', 'aksrt') . '">×</button>';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
|
|
||||||
$html .= '<div class="aksrt-checkin-modal__user">';
|
$html .= '<div class="aksrt-checkin-modal__user">';
|
||||||
|
|||||||
+10
-10
@@ -30,7 +30,7 @@ class Badges {
|
|||||||
public function init(): void {
|
public function init(): void {
|
||||||
add_action('rest_api_init', [$this, 'register_routes']);
|
add_action('rest_api_init', [$this, 'register_routes']);
|
||||||
add_action('aksrt_badge_granted', [$this, 'on_badge_granted_notify'], 10, 3);
|
add_action('aksrt_badge_granted', [$this, 'on_badge_granted_notify'], 10, 3);
|
||||||
// HTML modal for remote-modal (zibll user_medal_info_modal).
|
// HTML modal for modal runtime (zibll user_medal_info_modal).
|
||||||
add_action('wp_ajax_aksrt_user_badge_info_modal', [$this, 'ajax_info_modal']);
|
add_action('wp_ajax_aksrt_user_badge_info_modal', [$this, 'ajax_info_modal']);
|
||||||
add_action('wp_ajax_nopriv_aksrt_user_badge_info_modal', [$this, 'ajax_info_modal']);
|
add_action('wp_ajax_nopriv_aksrt_user_badge_info_modal', [$this, 'ajax_info_modal']);
|
||||||
add_action('wp_ajax_aksrt_single_badge_info_modal', [$this, 'ajax_single_info_modal']);
|
add_action('wp_ajax_aksrt_single_badge_info_modal', [$this, 'ajax_single_info_modal']);
|
||||||
@@ -102,8 +102,8 @@ class Badges {
|
|||||||
* Badge list modal HTML (zibll zib_get_user_medal_info_modal parity).
|
* Badge list modal HTML (zibll zib_get_user_medal_info_modal parity).
|
||||||
*
|
*
|
||||||
* Head (avatar + owner + worn medal) + category-grouped medal card grid.
|
* Head (avatar + owner + worn medal) + category-grouped medal card grid.
|
||||||
* Each card deep-links into the single badge modal via the remote-modal
|
* Each card deep-links into the single badge modal via the modal runtime
|
||||||
* contract (data-toggle="AksrtRemoteModal" + data-remote).
|
* contract (data-aksrt-modal="remote" + data-aksrt-modal-url).
|
||||||
*/
|
*/
|
||||||
public static function render_info_modal_html(int $user_id): string {
|
public static function render_info_modal_html(int $user_id): string {
|
||||||
$user = get_userdata($user_id);
|
$user = get_userdata($user_id);
|
||||||
@@ -134,7 +134,7 @@ class Badges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$html = '<div class="medal-modal">';
|
$html = '<div class="medal-modal">';
|
||||||
$html .= '<button type="button" class="aksrt-remote-modal__close" data-aksrt-remote-modal-close aria-label="' . esc_attr__('关闭', 'aksrt') . '">×</button>';
|
$html .= '<button type="button" class="aksrt-modal-runtime__close" data-aksrt-modal-close aria-label="' . esc_attr__('关闭', 'aksrt') . '">×</button>';
|
||||||
$html .= '<div class="medal-modal__head">';
|
$html .= '<div class="medal-modal__head">';
|
||||||
$html .= '<img class="medal-modal__avatar" src="' . esc_url((string) $avatar) . '" alt="" width="42" height="42" />';
|
$html .= '<img class="medal-modal__avatar" src="' . esc_url((string) $avatar) . '" alt="" width="42" height="42" />';
|
||||||
$html .= '<div class="medal-modal__title"><span class="em09">' . esc_html(sprintf(__('%s的徽章', 'aksrt'), $display)) . '</span>' . $wear_slot . '</div>';
|
$html .= '<div class="medal-modal__title"><span class="em09">' . esc_html(sprintf(__('%s的徽章', 'aksrt'), $display)) . '</span>' . $wear_slot . '</div>';
|
||||||
@@ -164,7 +164,7 @@ class Badges {
|
|||||||
if (!$is_self && $current > 0) {
|
if (!$is_self && $current > 0) {
|
||||||
$my_url = add_query_arg(['action' => 'aksrt_user_badge_info_modal', 'id' => $current], admin_url('admin-ajax.php'));
|
$my_url = add_query_arg(['action' => 'aksrt_user_badge_info_modal', 'id' => $current], admin_url('admin-ajax.php'));
|
||||||
$html .= '<div class="medal-modal__buts">';
|
$html .= '<div class="medal-modal__buts">';
|
||||||
$html .= '<a class="but c-blue" href="' . esc_url($my_url) . '" data-toggle="AksrtRemoteModal" data-remote="' . esc_url($my_url) . '" data-class="full-sm" mobile-bottom="true"><i class="fas fa-medal" aria-hidden="true"></i> ' . esc_html__('查看我的徽章', 'aksrt') . '</a>';
|
$html .= '<a class="but c-blue" href="' . esc_url($my_url) . '" data-aksrt-modal="remote" data-aksrt-modal-url="' . esc_url($my_url) . '" data-aksrt-modal-class="full-sm" data-aksrt-modal-mobile-bottom="true"><i class="fas fa-medal" aria-hidden="true"></i> ' . esc_html__('查看我的徽章', 'aksrt') . '</a>';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ class Badges {
|
|||||||
admin_url('admin-ajax.php')
|
admin_url('admin-ajax.php')
|
||||||
);
|
);
|
||||||
|
|
||||||
return '<a class="medal-list" href="' . esc_url($url) . '" data-toggle="AksrtRemoteModal" data-remote="' . esc_url($url) . '" data-class="modal-mini" mobile-bottom="true">' . $card . '</a>';
|
return '<a class="medal-list" href="' . esc_url($url) . '" data-aksrt-modal="remote" data-aksrt-modal-url="' . esc_url($url) . '" data-aksrt-modal-class="modal-mini" data-aksrt-modal-mobile-bottom="true">' . $card . '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -244,7 +244,7 @@ class Badges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$html = '<div class="medal-modal medal-modal--single">';
|
$html = '<div class="medal-modal medal-modal--single">';
|
||||||
$html .= '<button type="button" class="aksrt-remote-modal__close" data-aksrt-remote-modal-close aria-label="' . esc_attr__('关闭', 'aksrt') . '">×</button>';
|
$html .= '<button type="button" class="aksrt-modal-runtime__close" data-aksrt-modal-close aria-label="' . esc_attr__('关闭', 'aksrt') . '">×</button>';
|
||||||
$html .= '<div class="medal-single-card">';
|
$html .= '<div class="medal-single-card">';
|
||||||
$html .= '<div class="medal-single-bg"><img class="fit-cover" src="' . esc_url($bg) . '" alt="" /></div>';
|
$html .= '<div class="medal-single-bg"><img class="fit-cover" src="' . esc_url($bg) . '" alt="" /></div>';
|
||||||
$html .= '<div class="medal-single-main">' . $icon_html;
|
$html .= '<div class="medal-single-main">' . $icon_html;
|
||||||
@@ -263,7 +263,7 @@ class Badges {
|
|||||||
// Back to the full badge list modal.
|
// Back to the full badge list modal.
|
||||||
if ($user_id > 0) {
|
if ($user_id > 0) {
|
||||||
$back_url = add_query_arg(['action' => 'aksrt_user_badge_info_modal', 'id' => $user_id], admin_url('admin-ajax.php'));
|
$back_url = add_query_arg(['action' => 'aksrt_user_badge_info_modal', 'id' => $user_id], admin_url('admin-ajax.php'));
|
||||||
$html .= '<a class="medal-modal__back muted-2-color em09" href="' . esc_url($back_url) . '" data-toggle="AksrtRemoteModal" data-remote="' . esc_url($back_url) . '" data-class="full-sm" mobile-bottom="true"><i class="fas fa-angle-left" aria-hidden="true"></i> ' . esc_html__('返回徽章列表', 'aksrt') . '</a>';
|
$html .= '<a class="medal-modal__back muted-2-color em09" href="' . esc_url($back_url) . '" data-aksrt-modal="remote" data-aksrt-modal-url="' . esc_url($back_url) . '" data-aksrt-modal-class="full-sm" data-aksrt-modal-mobile-bottom="true"><i class="fas fa-angle-left" aria-hidden="true"></i> ' . esc_html__('返回徽章列表', 'aksrt') . '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
@@ -280,7 +280,7 @@ class Badges {
|
|||||||
if ($text === null) {
|
if ($text === null) {
|
||||||
$text = __('徽章明细', 'aksrt');
|
$text = __('徽章明细', 'aksrt');
|
||||||
}
|
}
|
||||||
if (!function_exists('aksrt_get_remote_modal_link')) {
|
if (!function_exists('aksrt_get_modal_link')) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$url = add_query_arg(
|
$url = add_query_arg(
|
||||||
@@ -290,7 +290,7 @@ class Badges {
|
|||||||
],
|
],
|
||||||
admin_url('admin-ajax.php')
|
admin_url('admin-ajax.php')
|
||||||
);
|
);
|
||||||
return aksrt_get_remote_modal_link([
|
return aksrt_get_modal_link([
|
||||||
'tag' => 'a',
|
'tag' => 'a',
|
||||||
'class' => trim('user-medal-info ' . $class),
|
'class' => trim('user-medal-info ' . $class),
|
||||||
'text' => $text,
|
'text' => $text,
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ $pm_url = ($pm_enabled && $messages_url !== '')
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// Badge detail remote-modal (zibll user medal info).
|
// Badge detail modal runtime link.
|
||||||
if (class_exists('\AKSRT\User\Badges') && \AKSRT\User\Badges::enabled() && \AKSRT\User\Badges::public_display()) {
|
if (class_exists('\AKSRT\User\Badges') && \AKSRT\User\Badges::enabled() && \AKSRT\User\Badges::public_display()) {
|
||||||
$badge_link = \AKSRT\User\Badges::get_info_link($user_id, 'but but-sm jb-blue mt6', __('徽章明细', 'aksrt'));
|
$badge_link = \AKSRT\User\Badges::get_info_link($user_id, 'but but-sm jb-blue mt6', __('徽章明细', 'aksrt'));
|
||||||
if ($badge_link !== '') {
|
if ($badge_link !== '') {
|
||||||
|
|||||||
Reference in New Issue
Block a user