refactor: rename the theme brand and every identifier from AKSRT to Jio
Full-project rename. `git grep -i aksrt` is now empty apart from the
DBMigrator 3.3.0 changelog note that documents the rename itself.
Code identifiers
- PHP namespace AKSRT\ -> Jio\ (composer PSR-4 + 378 declarations)
- global constants AKSRT_* -> JIO_* (VERSION/DIR/URI, PAY_TYPE_*, CAPTCHA_*)
- procedural functions, hooks, options, meta keys, table names,
cookies, query vars, ajax actions and nonces: aksrt_ -> jio_
- text domain aksrt -> jio; Theme Name -> Jio
- JS globals: aksrtData/aksrtAdminData/... -> jioData/jioAdminData/...,
window.AKSRTCaptcha & friends -> window.JioCaptcha, Aksrt* -> Jio*
- Vue components Aks*.vue -> Jio*.vue (15 files renamed + imports)
- CSS classes/data-attrs/custom properties: aksrt- -> jio-
- REST namespace aksrt/v1 -> jio/v1 (incl. payment gateway callbacks)
Storage layer
- DB tables {prefix}aksrt_* -> {prefix}jio_*; SCHEMA_VERSION 3.2.0 -> 3.3.0
so dbDelta creates the new names on install
- widget id_base aksrt_widget_* -> jio_widget_*
- uninstall.php drop list rebuilt from the actual migrator tables
(dropped 3 stale entries, added the 17 missing ones)
Removed
- hardcoded https://api.aksrt.com/version.json default update endpoint;
get_endpoint() now reads the 「更新端点」 setting and do_check() no-ops
when it is empty
Files renamed: inc/helpers/aksrt-*.php -> jio-*.php (54),
assets/admin/src/components/form/Aks*.vue -> Jio*.vue (15).
Build artifacts regenerated: assets/css/build, assets/js/runtime,
assets/admin/build.
Verified: audit-psr4-paths errors=0, audit-admin-contracts errors=0
(warnings=56, unchanged baseline), 813/813 widget-system tests,
44/44 phpunit, php -l clean across all PHP.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
5b16bc6e15
commit
35bb96e82f
997 files changed
+28216
-28188
No files matched your search
@@ -1,12 +1,12 @@
|
||||
/**
|
||||
* AKSRT AJAX Debug — 排查 vendor main.min.js / legacy_ajax 产生的失败请求
|
||||
* Jio AJAX Debug — 排查 vendor main.min.js / legacy_ajax 产生的失败请求
|
||||
*
|
||||
* 启用条件(见 inc/aksrt-ajax-debug.php):WP_DEBUG 开启,或 URL 带 ?aksrt_ajax_debug=1
|
||||
* 启用条件(见 inc/jio-ajax-debug.php):WP_DEBUG 开启,或 URL 带 ?jio_ajax_debug=1
|
||||
*
|
||||
* 输出:
|
||||
* - [aksrt→ajax] 所有发往 admin-ajax.php 的 jQuery 请求(含 action 与参数)
|
||||
* - [aksrt✗ajax] 所有失败的 jQuery 请求(url / data / status / responseText)
|
||||
* - [aksrt✗fetch] 所有非 2xx 的 fetch 请求
|
||||
* - [jio→ajax] 所有发往 admin-ajax.php 的 jQuery 请求(含 action 与参数)
|
||||
* - [jio✗ajax] 所有失败的 jQuery 请求(url / data / status / responseText)
|
||||
* - [jio✗fetch] 所有非 2xx 的 fetch 请求
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
@@ -29,27 +29,27 @@
|
||||
return data;
|
||||
}
|
||||
|
||||
console.log('%c[aksrt] ajax 调试已开启(?aksrt_ajax_debug=1 或 WP_DEBUG)', 'color:#2abd4e;background:#16171a;padding:2px 6px;');
|
||||
console.log('%c[jio] ajax 调试已开启(?jio_ajax_debug=1 或 WP_DEBUG)', 'color:#2abd4e;background:#16171a;padding:2px 6px;');
|
||||
|
||||
if (window.jQuery) {
|
||||
jQuery(document).ajaxSend(function (e, jqXHR, settings) {
|
||||
if (!settings || !settings.url || settings.url.indexOf('admin-ajax.php') === -1) return;
|
||||
console.log('[aksrt→ajax]', settings.type || 'GET', settings.url, paramsToObject(settings.data));
|
||||
console.log('[jio→ajax]', settings.type || 'GET', settings.url, paramsToObject(settings.data));
|
||||
});
|
||||
|
||||
jQuery(document).ajaxError(function (e, jqXHR, settings, thrownError) {
|
||||
console.warn('[aksrt✗ajax]', (settings && settings.type) || '?', (settings && settings.url) || '?',
|
||||
console.warn('[jio✗ajax]', (settings && settings.type) || '?', (settings && settings.url) || '?',
|
||||
'data:', paramsToObject(settings && settings.data),
|
||||
'status:', jqXHR && jqXHR.status,
|
||||
'response:', clip(jqXHR && jqXHR.responseText),
|
||||
'thrown:', thrownError);
|
||||
// 定位触发元素:记录调用栈帮助回溯 legacy_ajax 调用来源
|
||||
if (settings && settings.url && settings.url.indexOf('admin-ajax.php') !== -1) {
|
||||
console.warn('[aksrt✗ajax] 发出的 action 参数见上方 data —— 在 admin-ajax 无对应处理器时 WP 返回 400 "0"');
|
||||
console.warn('[jio✗ajax] 发出的 action 参数见上方 data —— 在 admin-ajax 无对应处理器时 WP 返回 400 "0"');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.warn('[aksrt] jQuery 未加载,ajax 调试仅覆盖 fetch');
|
||||
console.warn('[jio] jQuery 未加载,ajax 调试仅覆盖 fetch');
|
||||
}
|
||||
|
||||
var rawFetch = window.fetch;
|
||||
@@ -61,7 +61,7 @@
|
||||
return rawFetch.apply(this, args).then(function (res) {
|
||||
if (!res.ok) {
|
||||
res.clone().text().then(function (text) {
|
||||
console.warn('[aksrt✗fetch]', res.status, url, 'body:', clip(body), 'response:', clip(text));
|
||||
console.warn('[jio✗fetch]', res.status, url, 'body:', clip(body), 'response:', clip(text));
|
||||
}).catch(function () {});
|
||||
}
|
||||
return res;
|
||||
|
||||
+22
-22
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* AKSRT Ajax List Engine — legacy .ajax-next / ajax-replace / route parity.
|
||||
* Jio Ajax List Engine — legacy .ajax-next / ajax-replace / route parity.
|
||||
*
|
||||
* DOM contract:
|
||||
* .ajaxpager list container
|
||||
@@ -10,12 +10,12 @@
|
||||
* [win-ajax-replace] partial header sync from response HTML
|
||||
*
|
||||
* Transport:
|
||||
* - Prefer data-aksrt-ajax-url JSON { html, header_html, paginate_html, title }
|
||||
* - Prefer data-jio-ajax-url JSON { html, header_html, paginate_html, title }
|
||||
* - Else fetch href as HTML fragment and parse .ajaxpager / .ajax-item
|
||||
*
|
||||
* Events: post_ajax.before / post_ajax.ed on container (bubbles).
|
||||
*
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
(function (window, document) {
|
||||
"use strict";
|
||||
@@ -23,9 +23,9 @@
|
||||
var loadingMap = new WeakMap();
|
||||
|
||||
function restHeaders() {
|
||||
var h = { Accept: "application/json, text/html", "X-AKSRT-Ajax": "list" };
|
||||
if (window.aksrtData && aksrtData.restNonce) {
|
||||
h["X-WP-Nonce"] = aksrtData.restNonce;
|
||||
var h = { Accept: "application/json, text/html", "X-Jio-Ajax": "list" };
|
||||
if (window.jioData && jioData.restNonce) {
|
||||
h["X-WP-Nonce"] = jioData.restNonce;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
@@ -34,8 +34,8 @@
|
||||
if (!el) return null;
|
||||
return (
|
||||
el.closest(".ajaxpager") ||
|
||||
el.closest("[data-aksrt-ajaxpager]") ||
|
||||
el.closest(".aksrt-ajaxpager")
|
||||
el.closest("[data-jio-ajaxpager]") ||
|
||||
el.closest(".jio-ajaxpager")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -80,8 +80,8 @@
|
||||
var doc = parseHtml(html);
|
||||
var pager =
|
||||
doc.querySelector(".ajaxpager") ||
|
||||
doc.querySelector("[data-aksrt-ajaxpager]") ||
|
||||
doc.querySelector(".aksrt-ajaxpager");
|
||||
doc.querySelector("[data-jio-ajaxpager]") ||
|
||||
doc.querySelector(".jio-ajaxpager");
|
||||
var items = [];
|
||||
var scope = pager || doc;
|
||||
scope.querySelectorAll(".ajax-item").forEach(function (n) {
|
||||
@@ -161,7 +161,7 @@
|
||||
var child = container.children[i];
|
||||
if (
|
||||
child.matches &&
|
||||
child.matches(".posts-row.post-grid, .aksrt-home-widget__post-grid")
|
||||
child.matches(".posts-row.post-grid, .jio-home-widget__post-grid")
|
||||
) {
|
||||
return child;
|
||||
}
|
||||
@@ -181,7 +181,7 @@
|
||||
n.remove();
|
||||
});
|
||||
// If container itself holds only items, clear non-loader children.
|
||||
if (container.getAttribute("data-aksrt-ajax-clear") === "1") {
|
||||
if (container.getAttribute("data-jio-ajax-clear") === "1") {
|
||||
Array.prototype.slice.call(container.children).forEach(function (child) {
|
||||
if (
|
||||
child.classList.contains("post_ajax_loader") ||
|
||||
@@ -217,7 +217,7 @@
|
||||
}
|
||||
if (payload.headerHtml) {
|
||||
var headerHost = document.querySelector(
|
||||
options.headerSelector || "[data-aksrt-ajax-header]"
|
||||
options.headerSelector || "[data-jio-ajax-header]"
|
||||
);
|
||||
if (headerHost) headerHost.innerHTML = payload.headerHtml;
|
||||
}
|
||||
@@ -261,7 +261,7 @@
|
||||
closestPager(link);
|
||||
if (!container) {
|
||||
// Fall back: parent stream list.
|
||||
container = link.closest("[data-aksrt-ajax-list]");
|
||||
container = link.closest("[data-jio-ajax-list]");
|
||||
}
|
||||
if (!container) return Promise.resolve();
|
||||
|
||||
@@ -276,7 +276,7 @@
|
||||
|
||||
var href =
|
||||
override.url ||
|
||||
link.getAttribute("data-aksrt-ajax-url") ||
|
||||
link.getAttribute("data-jio-ajax-url") ||
|
||||
link.getAttribute("ajax-href") ||
|
||||
link.getAttribute("href") ||
|
||||
"";
|
||||
@@ -331,7 +331,7 @@
|
||||
// legacy 契约:post_ajax.ed 之后调用全局 auto_fun 重扫新内容。
|
||||
if (typeof window.auto_fun === "function") window.auto_fun();
|
||||
document.dispatchEvent(
|
||||
new CustomEvent("aksrt:posts:rendered", {
|
||||
new CustomEvent("jio:posts:rendered", {
|
||||
bubbles: true,
|
||||
detail: { container: container, replace: replace },
|
||||
})
|
||||
@@ -351,24 +351,24 @@
|
||||
}
|
||||
|
||||
document.addEventListener("click", function (e) {
|
||||
var link = e.target.closest("a.ajax-next, .ajax-next a, button.ajax-next, [data-aksrt-ajax-next]");
|
||||
var link = e.target.closest("a.ajax-next, .ajax-next a, button.ajax-next, [data-jio-ajax-next]");
|
||||
if (!link) return;
|
||||
// Ignore if inside a component that opts out.
|
||||
if (link.closest("[data-aksrt-ajax-list='off']")) return;
|
||||
if (link.closest("[data-jio-ajax-list='off']")) return;
|
||||
// The canonical pagination engine exclusively owns these controls.
|
||||
if (link.closest("[data-aksrt-pagination], .aksrt-comment-pagination")) return;
|
||||
if (link.closest("[data-jio-pagination], .jio-comment-pagination")) return;
|
||||
// 排序菜单与 pane 触发器是 runtime post_ajax 管线(zib_ajax_option_menu /
|
||||
// zib_index_tab 契约)的专属控件,这里不能并行处理造成双请求。
|
||||
if (link.closest(".ajax-option, .post_ajax_trigger")) return;
|
||||
|
||||
var href = link.getAttribute("href") || link.getAttribute("ajax-href") || link.getAttribute("data-aksrt-ajax-url");
|
||||
if (!href && !link.getAttribute("data-aksrt-ajax-url")) return;
|
||||
var href = link.getAttribute("href") || link.getAttribute("ajax-href") || link.getAttribute("data-jio-ajax-url");
|
||||
if (!href && !link.getAttribute("data-jio-ajax-url")) return;
|
||||
|
||||
e.preventDefault();
|
||||
loadFromLink(link.tagName === "A" || link.classList.contains("ajax-next") ? link : link.closest(".ajax-next") || link);
|
||||
});
|
||||
|
||||
window.AksrtAjaxList = {
|
||||
window.JioAjaxList = {
|
||||
load: loadFromLink,
|
||||
inject: inject,
|
||||
extractFromHtml: extractFromHtml,
|
||||
|
||||
+16
-16
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* AKSRT Article Tools — password toggles, article actions, interaction bar
|
||||
* Jio Article Tools — password toggles, article actions, interaction bar
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
@@ -24,8 +24,8 @@
|
||||
if (!buttons.length) return;
|
||||
|
||||
buttons.forEach(function (button) {
|
||||
if (button.dataset.aksrtArticleToolBound) return;
|
||||
button.dataset.aksrtArticleToolBound = "1";
|
||||
if (button.dataset.jioArticleToolBound) return;
|
||||
button.dataset.jioArticleToolBound = "1";
|
||||
button.addEventListener("click", function () {
|
||||
var tool = button.getAttribute("data-article-tool");
|
||||
if (tool === "print") {
|
||||
@@ -110,7 +110,7 @@
|
||||
}
|
||||
|
||||
function formatStatCount(count) {
|
||||
// 与 PHP aksrt_format_number() 同一套缩写:≥10000 → 1.2W+,≥1000 → 1.5K。
|
||||
// 与 PHP jio_format_number() 同一套缩写:≥10000 → 1.2W+,≥1000 → 1.5K。
|
||||
var safeCount = Math.max(0, count);
|
||||
if (safeCount >= 10000) {
|
||||
return Math.round((safeCount / 10000) * 10) / 10 + "W+";
|
||||
@@ -142,17 +142,17 @@
|
||||
}
|
||||
|
||||
function requestInteraction(actionName, postId, active) {
|
||||
if (!window.aksrtData || !aksrtData.ajaxUrl || !aksrtData.nonce) {
|
||||
if (!window.jioData || !jioData.ajaxUrl || !jioData.nonce) {
|
||||
return Promise.reject(new Error("互动服务未配置"));
|
||||
}
|
||||
|
||||
var body = new URLSearchParams();
|
||||
body.set("action", actionName);
|
||||
body.set("nonce", aksrtData.nonce);
|
||||
body.set("nonce", jioData.nonce);
|
||||
body.set("postId", String(postId));
|
||||
body.set("active", active ? "1" : "0");
|
||||
|
||||
return fetch(aksrtData.ajaxUrl, {
|
||||
return fetch(jioData.ajaxUrl, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" },
|
||||
credentials: "same-origin",
|
||||
@@ -253,17 +253,17 @@
|
||||
|
||||
if (likeBtns.length) {
|
||||
var seedLike = likeBtns[0];
|
||||
if (!seedLike.dataset.aksrtInteractionBound) {
|
||||
if (!seedLike.dataset.jioInteractionBound) {
|
||||
applyLikeState(seedLike.dataset.initialActive === "1", getBaseStatCount("likes"));
|
||||
likeBtns.forEach(function (likeBtn) {
|
||||
if (likeBtn.dataset.aksrtInteractionBound) return;
|
||||
likeBtn.dataset.aksrtInteractionBound = "1";
|
||||
if (likeBtn.dataset.jioInteractionBound) return;
|
||||
likeBtn.dataset.jioInteractionBound = "1";
|
||||
likeBtn.addEventListener("click", function () {
|
||||
var postId = likeBtn.dataset.postId ? String(likeBtn.dataset.postId) : "";
|
||||
if (!postId || likeBtn.disabled) return;
|
||||
var nextState = likeBtn.dataset.initialActive !== "1";
|
||||
setButtonBusy(likeBtn, true);
|
||||
requestInteraction("aksrt_toggle_like", postId, nextState).then(function (data) {
|
||||
requestInteraction("jio_toggle_like", postId, nextState).then(function (data) {
|
||||
applyLikeState(!!data.active, parseInt(data.count, 10) || 0, true);
|
||||
notyf(data.active ? "感谢你的点赞" : "已取消点赞", "success");
|
||||
}).catch(function (error) {
|
||||
@@ -278,17 +278,17 @@
|
||||
|
||||
if (favBtns.length) {
|
||||
var seedFav = favBtns[0];
|
||||
if (!seedFav.dataset.aksrtInteractionBound) {
|
||||
if (!seedFav.dataset.jioInteractionBound) {
|
||||
applyFavoriteState(seedFav.dataset.initialActive === "1", getBaseStatCount("favorites"));
|
||||
favBtns.forEach(function (favBtn) {
|
||||
if (favBtn.dataset.aksrtInteractionBound) return;
|
||||
favBtn.dataset.aksrtInteractionBound = "1";
|
||||
if (favBtn.dataset.jioInteractionBound) return;
|
||||
favBtn.dataset.jioInteractionBound = "1";
|
||||
favBtn.addEventListener("click", function () {
|
||||
var postId = favBtn.dataset.postId ? String(favBtn.dataset.postId) : "";
|
||||
if (!postId || favBtn.disabled) return;
|
||||
var nextState = favBtn.dataset.initialActive !== "1";
|
||||
setButtonBusy(favBtn, true);
|
||||
requestInteraction("aksrt_toggle_favorite", postId, nextState).then(function (data) {
|
||||
requestInteraction("jio_toggle_favorite", postId, nextState).then(function (data) {
|
||||
applyFavoriteState(!!data.active, parseInt(data.count, 10) || 0, true);
|
||||
notyf(data.active ? "收藏成功" : "已取消收藏", "success");
|
||||
}).catch(function (error) {
|
||||
@@ -316,6 +316,6 @@
|
||||
}
|
||||
// AJAX 注入新内容后由 auto_fun 重扫(各 init 均带 data 标记,重复调用幂等)。
|
||||
if (window.jQuery) {
|
||||
window.jQuery(document).off("auto_fun.aksrt-article").on("auto_fun.aksrt-article", function () { init(); });
|
||||
window.jQuery(document).off("auto_fun.jio-article").on("auto_fun.jio-article", function () { init(); });
|
||||
}
|
||||
})();
|
||||
@@ -72,7 +72,7 @@
|
||||
// Expose for submit hide.
|
||||
var respond = document.getElementById('respond');
|
||||
if (respond) {
|
||||
respond.aksrtFixedInput = function (action) {
|
||||
respond.jioFixedInput = function (action) {
|
||||
FixedInput(respond, action);
|
||||
};
|
||||
}
|
||||
@@ -83,5 +83,5 @@
|
||||
// AJAX 注入新内容后由 auto_fun 重扫(dataset 标记保证幂等)。
|
||||
if (window.jQuery) window.jQuery(document).on('auto_fun', init);
|
||||
|
||||
window.AksrtFixedInput = FixedInput;
|
||||
window.JioFixedInput = FixedInput;
|
||||
})();
|
||||
@@ -5,7 +5,7 @@
|
||||
'use strict';
|
||||
|
||||
var respondId = 'respond';
|
||||
var tempId = 'aksrt-wp-temp-form-div';
|
||||
var tempId = 'jio-wp-temp-form-div';
|
||||
var editingId = 0;
|
||||
|
||||
function getRespond() {
|
||||
@@ -13,12 +13,12 @@
|
||||
}
|
||||
|
||||
function restRoot() {
|
||||
var d = window.aksrtData || {};
|
||||
return (d.restUrl || d.rest_url || '/wp-json/aksrt/v1').replace(/\/$/, '');
|
||||
var d = window.jioData || {};
|
||||
return (d.restUrl || d.rest_url || '/wp-json/jio/v1').replace(/\/$/, '');
|
||||
}
|
||||
|
||||
function nonce() {
|
||||
var d = window.aksrtData || {};
|
||||
var d = window.jioData || {};
|
||||
return d.restNonce || d.nonce || '';
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
if (textarea) textarea.value = '';
|
||||
editingId = 0;
|
||||
cancel.style.display = 'none';
|
||||
if (window.AksrtFixedInput) window.AksrtFixedInput(r, 'hide');
|
||||
if (window.JioFixedInput) window.JioFixedInput(r, 'hide');
|
||||
else if (r) r.classList.remove('show');
|
||||
return false;
|
||||
};
|
||||
@@ -154,8 +154,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (window.AksrtFixedInput) {
|
||||
window.AksrtFixedInput(respond, 'show');
|
||||
if (window.JioFixedInput) {
|
||||
window.JioFixedInput(respond, 'show');
|
||||
} else {
|
||||
respond.classList.add('show');
|
||||
}
|
||||
@@ -227,6 +227,6 @@
|
||||
if (el) el.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
});
|
||||
|
||||
window.aksrtCommentMoveForm = moveForm;
|
||||
window.aksrtGetEditingCommentId = function () { return editingId; };
|
||||
window.jioCommentMoveForm = moveForm;
|
||||
window.jioGetEditingCommentId = function () { return editingId; };
|
||||
})();
|
||||
+28
-28
@@ -1,13 +1,13 @@
|
||||
/**
|
||||
* AKSRT Comment System — AJAX submit, captcha, ordering, author filter
|
||||
* Jio Comment System — AJAX submit, captcha, ordering, author filter
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function initCommentSystem() {
|
||||
var form = document.querySelector("#commentform");
|
||||
if (!form || form.dataset.aksrtCommentInit === "1") return;
|
||||
form.dataset.aksrtCommentInit = "1";
|
||||
if (!form || form.dataset.jioCommentInit === "1") return;
|
||||
form.dataset.jioCommentInit = "1";
|
||||
|
||||
// 修复:同时匹配 button 和 input 元素
|
||||
var submitBtn = form.querySelector('[type="submit"]');
|
||||
@@ -35,7 +35,7 @@
|
||||
isSubmitting = true;
|
||||
submitBtn.classList.add("is-loading");
|
||||
submitBtn.disabled = true;
|
||||
var loadingText = (window.aksrtData && aksrtData.commentSubmittingText) || '发送中...';
|
||||
var loadingText = (window.jioData && jioData.commentSubmittingText) || '发送中...';
|
||||
setSubmitBtnContent('<i class="fa fas fa-spinner fa-spin"></i> ' + loadingText, loadingText);
|
||||
} else {
|
||||
isSubmitting = false;
|
||||
@@ -98,10 +98,10 @@
|
||||
setLoading(true);
|
||||
|
||||
var formData = collectFormData();
|
||||
var restRoot = (window.aksrtData && aksrtData.siteUrl) ? String(aksrtData.siteUrl).replace(/\/$/, '') : '';
|
||||
var restRoot = (window.jioData && jioData.siteUrl) ? String(jioData.siteUrl).replace(/\/$/, '') : '';
|
||||
var editId = form.querySelector('[name="edit_comment_ID"]');
|
||||
var isEdit = editId && parseInt(editId.value, 10) > 0;
|
||||
var restBase = (restRoot || '') + '/wp-json/aksrt/v1/comment/' + (isEdit ? 'edit' : 'submit');
|
||||
var restBase = (restRoot || '') + '/wp-json/jio/v1/comment/' + (isEdit ? 'edit' : 'submit');
|
||||
|
||||
// Try REST endpoint for local-insert HTML response
|
||||
var restBody = {};
|
||||
@@ -116,7 +116,7 @@
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-WP-Nonce': (window.aksrtData && aksrtData.restNonce) || ''
|
||||
'X-WP-Nonce': (window.jioData && jioData.restNonce) || ''
|
||||
},
|
||||
credentials: 'same-origin',
|
||||
body: JSON.stringify(restBody)
|
||||
@@ -135,7 +135,7 @@
|
||||
setLoading(false);
|
||||
notyf(json.message || '评论已更新', 'success');
|
||||
var respondEl = document.getElementById('respond');
|
||||
if (respondEl && window.AksrtFixedInput) window.AksrtFixedInput(respondEl, 'hide');
|
||||
if (respondEl && window.JioFixedInput) window.JioFixedInput(respondEl, 'hide');
|
||||
return;
|
||||
}
|
||||
if (json && json.success && json.html) {
|
||||
@@ -160,8 +160,8 @@
|
||||
|
||||
// Hide mobile FixedInput after successful submit.
|
||||
var respondEl = document.getElementById('respond');
|
||||
if (respondEl && window.AksrtFixedInput) {
|
||||
window.AksrtFixedInput(respondEl, 'hide');
|
||||
if (respondEl && window.JioFixedInput) {
|
||||
window.JioFixedInput(respondEl, 'hide');
|
||||
} else if (respondEl) {
|
||||
respondEl.classList.remove('show');
|
||||
}
|
||||
@@ -185,12 +185,12 @@
|
||||
setTimeout(function () { reloadCommentList(); }, 500);
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error('[AKSRT Comment] 提交失败:', error);
|
||||
console.error('[Jio Comment] 提交失败:', error);
|
||||
notyf((error && error.message) || '网络连接失败,请检查网络后重试', 'danger');
|
||||
setLoading(false);
|
||||
})
|
||||
.finally(function () {
|
||||
if (window.AKSRTCaptcha) window.AKSRTCaptcha.reset('comment', form);
|
||||
if (window.JioCaptcha) window.JioCaptcha.reset('comment', form);
|
||||
if (!countdownTimer && isSubmitting) setLoading(false);
|
||||
});
|
||||
}
|
||||
@@ -277,7 +277,7 @@
|
||||
// 阻止默认表单提交
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
var captcha = window.AKSRTCaptcha;
|
||||
var captcha = window.JioCaptcha;
|
||||
setLoading(true);
|
||||
(captcha ? captcha.run('comment', form) : Promise.resolve({})).then(function (captchaPayload) {
|
||||
if (captchaPayload === null) {
|
||||
@@ -301,8 +301,8 @@
|
||||
|
||||
|
||||
function getCommentsRestBase() {
|
||||
var root = (window.aksrtData && aksrtData.siteUrl) ? String(aksrtData.siteUrl).replace(/\/$/, "") : "";
|
||||
return root + "/wp-json/aksrt/v1";
|
||||
var root = (window.jioData && jioData.siteUrl) ? String(jioData.siteUrl).replace(/\/$/, "") : "";
|
||||
return root + "/wp-json/jio/v1";
|
||||
}
|
||||
|
||||
function getCurrentCommentPostId() {
|
||||
@@ -317,7 +317,7 @@
|
||||
var active = document.querySelector("#comments .comment-order-box li.active .comment-orderby");
|
||||
if (active && active.dataset && active.dataset.order) return active.dataset.order;
|
||||
var url = new URL(window.location.href);
|
||||
return url.searchParams.get("aksrt_comment_order") || "newest";
|
||||
return url.searchParams.get("jio_comment_order") || "newest";
|
||||
}
|
||||
|
||||
function getCurrentAuthorOnly() {
|
||||
@@ -326,7 +326,7 @@
|
||||
}
|
||||
|
||||
/* ====== 全局无参数加载:评论状态仅保存在客户端,地址栏不携带 ? 参数 ====== */
|
||||
var COMMENT_URL_PARAMS = ["cpage", "aksrt_comment_order", "aksrt_author_only"];
|
||||
var COMMENT_URL_PARAMS = ["cpage", "jio_comment_order", "jio_author_only"];
|
||||
var commentUrlStateCleaned = false;
|
||||
|
||||
function stripCommentUrlParams() {
|
||||
@@ -448,7 +448,7 @@
|
||||
method: "GET",
|
||||
credentials: "same-origin",
|
||||
headers: {
|
||||
"X-WP-Nonce": (window.aksrtData && aksrtData.restNonce) || ""
|
||||
"X-WP-Nonce": (window.jioData && jioData.restNonce) || ""
|
||||
}
|
||||
}).then(function (r) { return r.json(); });
|
||||
}
|
||||
@@ -474,7 +474,7 @@
|
||||
|
||||
function reloadCommentList() {
|
||||
loadCommentPage(1, { noScroll: true }).catch(function (error) {
|
||||
console.error('[AKSRT Comment] 刷新评论列表失败:', error);
|
||||
console.error('[Jio Comment] 刷新评论列表失败:', error);
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
@@ -525,7 +525,7 @@
|
||||
throw new Error("order fragment failed");
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error("[AKSRT Comment] 排序刷新失败:", error);
|
||||
console.error("[Jio Comment] 排序刷新失败:", error);
|
||||
// 兜底整页刷新,地址栏保持无参。
|
||||
window.location.reload();
|
||||
});
|
||||
@@ -545,7 +545,7 @@
|
||||
throw new Error("author fragment failed");
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error("[AKSRT Comment] Author filter failed:", error);
|
||||
console.error("[Jio Comment] Author filter failed:", error);
|
||||
// 兜底整页刷新,地址栏保持无参。
|
||||
window.location.reload();
|
||||
});
|
||||
@@ -577,7 +577,7 @@
|
||||
if (page > 0) {
|
||||
e.preventDefault();
|
||||
loadCommentPage(page).catch(function (error) {
|
||||
console.error("[AKSRT Comment] 分页刷新失败:", error);
|
||||
console.error("[Jio Comment] 分页刷新失败:", error);
|
||||
// AJAX 不可用时退回原始链接(pretty 链接本身无 ? 参数)。
|
||||
window.location.href = pageLink.href;
|
||||
});
|
||||
@@ -592,7 +592,7 @@
|
||||
|
||||
function jumpToCommentPage(page) {
|
||||
loadCommentPage(page).catch(function (error) {
|
||||
console.error("[AKSRT Comment] 跳页失败:", error);
|
||||
console.error("[Jio Comment] 跳页失败:", error);
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
@@ -623,17 +623,17 @@
|
||||
function closeAllCommentDropdowns() {
|
||||
document.querySelectorAll("#postcomments .dropdown.open").forEach(function (wrap) {
|
||||
wrap.classList.remove("open");
|
||||
var trigger = wrap.querySelector("[data-aksrt-comment-drop]");
|
||||
var trigger = wrap.querySelector("[data-jio-comment-drop]");
|
||||
if (trigger) trigger.setAttribute("aria-expanded", "false");
|
||||
});
|
||||
}
|
||||
|
||||
function initCommentActionDropdowns() {
|
||||
if (document.documentElement.dataset.aksrtCommentDropBound === "1") return;
|
||||
document.documentElement.dataset.aksrtCommentDropBound = "1";
|
||||
if (document.documentElement.dataset.jioCommentDropBound === "1") return;
|
||||
document.documentElement.dataset.jioCommentDropBound = "1";
|
||||
|
||||
document.addEventListener("click", function (event) {
|
||||
var trigger = event.target.closest ? event.target.closest("[data-aksrt-comment-drop]") : null;
|
||||
var trigger = event.target.closest ? event.target.closest("[data-jio-comment-drop]") : null;
|
||||
if (trigger) {
|
||||
event.preventDefault();
|
||||
var wrap = trigger.closest(".dropdown");
|
||||
@@ -684,7 +684,7 @@
|
||||
}
|
||||
|
||||
// 供 pagination.js 等模块复用:评论页码加载 / 列表刷新(局部 DOM,无 ? 参数)。
|
||||
window.AksrtComments = {
|
||||
window.JioComments = {
|
||||
loadPage: function (page, opts) { return loadCommentPage(page, opts); },
|
||||
reload: function () { reloadCommentList(); }
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/**
|
||||
* AKSRT Footer Tabbar
|
||||
* Jio Footer Tabbar
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function initFooterTabbar() {
|
||||
var tabbar = document.getElementById("footer-tabbar");
|
||||
if (!tabbar || tabbar.dataset.aksrtTabbarInit === "1") return;
|
||||
tabbar.dataset.aksrtTabbarInit = "1";
|
||||
if (!tabbar || tabbar.dataset.jioTabbarInit === "1") return;
|
||||
tabbar.dataset.jioTabbarInit = "1";
|
||||
var addBackdrop = document.getElementById("tabbar-add-backdrop");
|
||||
|
||||
var ticking = false;
|
||||
@@ -102,8 +102,8 @@
|
||||
var searchBtn = e.target.closest('.tabbar-item[data-type="search"]');
|
||||
if (searchBtn) {
|
||||
e.preventDefault();
|
||||
if (typeof window.__aksrtOpenSearchPanel === "function") {
|
||||
window.__aksrtOpenSearchPanel();
|
||||
if (typeof window.__jioOpenSearchPanel === "function") {
|
||||
window.__jioOpenSearchPanel();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
+16
-16
@@ -1,21 +1,21 @@
|
||||
/**
|
||||
* AKSRT Misc — image gradients and hidden content
|
||||
* Jio Misc — image gradients and hidden content
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function renderGradientBackground(container) {
|
||||
if (!container || container.dataset.aksrtGradientState || typeof window.Grade !== "function") return;
|
||||
if (!container || container.dataset.jioGradientState || typeof window.Grade !== "function") return;
|
||||
|
||||
var source = container.querySelector("img");
|
||||
if (!source || (!source.classList.contains("lazyloaded") && !(source.complete && source.naturalWidth > 0))) return;
|
||||
|
||||
container.dataset.aksrtGradientState = "loading";
|
||||
container.dataset.jioGradientState = "loading";
|
||||
window.Grade(container, null, function (result) {
|
||||
var gradientData = result && result[0];
|
||||
var colors = gradientData && gradientData.gradientData;
|
||||
if (!gradientData || !colors || !colors[0] || !colors[1]) {
|
||||
delete container.dataset.aksrtGradientState;
|
||||
delete container.dataset.jioGradientState;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
gradientData.element.classList.add("gradient-bg-loaded");
|
||||
gradientData.element.style.backgroundImage = "linear-gradient(135deg, " + color1 + ", " + color2 + ")";
|
||||
container.dataset.aksrtGradientState = "loaded";
|
||||
container.dataset.jioGradientState = "loaded";
|
||||
});
|
||||
}
|
||||
|
||||
@@ -65,16 +65,16 @@
|
||||
|
||||
function initHiddenContent() {
|
||||
document.addEventListener("click", function (e) {
|
||||
var btn = e.target.closest(".aksrt-hidden-content__submit-btn");
|
||||
var btn = e.target.closest(".jio-hidden-content__submit-btn");
|
||||
if (!btn) return;
|
||||
|
||||
e.preventDefault();
|
||||
var wrapper = btn.closest(".aksrt-hidden-content--locked");
|
||||
var wrapper = btn.closest(".jio-hidden-content--locked");
|
||||
if (!wrapper) return;
|
||||
|
||||
var mode = wrapper.getAttribute("data-aksrt-visibility-mode");
|
||||
var pid = wrapper.getAttribute("data-aksrt-visibility-pid");
|
||||
var input = wrapper.querySelector(".aksrt-hidden-content__password-input");
|
||||
var mode = wrapper.getAttribute("data-jio-visibility-mode");
|
||||
var pid = wrapper.getAttribute("data-jio-visibility-pid");
|
||||
var input = wrapper.querySelector(".jio-hidden-content__password-input");
|
||||
var password = input ? input.value.trim() : "";
|
||||
|
||||
if (mode === "password" && !password) {
|
||||
@@ -83,8 +83,8 @@
|
||||
}
|
||||
|
||||
var formData = new FormData();
|
||||
formData.append("action", "aksrt_check_visibility");
|
||||
formData.append("_nonce", (window.aksrtData && aksrtData.visibilityNonce) || "");
|
||||
formData.append("action", "jio_check_visibility");
|
||||
formData.append("_nonce", (window.jioData && jioData.visibilityNonce) || "");
|
||||
formData.append("mode", mode);
|
||||
formData.append("pid", pid);
|
||||
if (password) formData.append("password", password);
|
||||
@@ -92,7 +92,7 @@
|
||||
btn.disabled = true;
|
||||
btn.textContent = "...";
|
||||
|
||||
fetch((window.aksrtData && aksrtData.ajaxUrl) || "/wp-admin/admin-ajax.php", {
|
||||
fetch((window.jioData && jioData.ajaxUrl) || "/wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
credentials: "same-origin",
|
||||
@@ -117,11 +117,11 @@
|
||||
|
||||
// Handle Enter key on password input
|
||||
document.addEventListener("keydown", function (e) {
|
||||
if (e.key === "Enter" && e.target.classList.contains("aksrt-hidden-content__password-input")) {
|
||||
if (e.key === "Enter" && e.target.classList.contains("jio-hidden-content__password-input")) {
|
||||
e.preventDefault();
|
||||
var wrapper = e.target.closest(".aksrt-hidden-content--locked");
|
||||
var wrapper = e.target.closest(".jio-hidden-content--locked");
|
||||
if (wrapper) {
|
||||
var btn = wrapper.querySelector(".aksrt-hidden-content__submit-btn");
|
||||
var btn = wrapper.querySelector(".jio-hidden-content__submit-btn");
|
||||
if (btn) btn.click();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* User-scoped in-memory modal cache with short TTLs and request deduplication.
|
||||
* Private modal payloads are never persisted to browser storage.
|
||||
*
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
(function (window, document) {
|
||||
"use strict";
|
||||
@@ -13,7 +13,7 @@
|
||||
var lastScope = "";
|
||||
|
||||
function scope() {
|
||||
var config = window.aksrtData || window.aksrt || {};
|
||||
var config = window.jioData || window.jio || {};
|
||||
var userId = parseInt(config.userId || 0, 10) || 0;
|
||||
var current = (config.isLoggedIn && userId > 0 ? "user:" + userId : "guest") + ":v1";
|
||||
if (lastScope && lastScope !== current) clear();
|
||||
@@ -74,7 +74,7 @@
|
||||
}
|
||||
});
|
||||
// 广播失效标签,供页面常驻视图(如待支付浮窗)按标签自行刷新。
|
||||
document.dispatchEvent(new CustomEvent("aksrt:cache:invalidated", { detail: { tags: wanted.slice() } }));
|
||||
document.dispatchEvent(new CustomEvent("jio:cache:invalidated", { detail: { tags: wanted.slice() } }));
|
||||
return removed;
|
||||
}
|
||||
|
||||
@@ -141,11 +141,11 @@
|
||||
};
|
||||
}
|
||||
|
||||
["aksrt:auth:logout", "aksrt:account-switch", "aksrt:logout", "aksrt:user:logout", "aksrt:auth:changed", "wp_logout"].forEach(function (eventName) {
|
||||
["jio:auth:logout", "jio:account-switch", "jio:logout", "jio:user:logout", "jio:auth:changed", "wp_logout"].forEach(function (eventName) {
|
||||
document.addEventListener(eventName, clear);
|
||||
});
|
||||
|
||||
window.AksrtModalCache = {
|
||||
window.JioModalCache = {
|
||||
get: function (key) { return read(key); },
|
||||
set: set,
|
||||
acquire: acquire,
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
* short in-memory caching, request deduplication, retryable errors, focus
|
||||
* restoration, and legacy `loaded.bs.modal` content lifecycle (auto_fun rescan).
|
||||
*
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
(function (window, document) {
|
||||
"use strict";
|
||||
|
||||
var ROOT_ID = "aksrt-modal-runtime-root";
|
||||
var ROOT_ID = "jio-modal-runtime-root";
|
||||
var active = null;
|
||||
var sessions = [];
|
||||
var sequence = 0;
|
||||
@@ -25,7 +25,7 @@
|
||||
if (root) return root;
|
||||
root = document.createElement("div");
|
||||
root.id = ROOT_ID;
|
||||
root.className = "aksrt-modal-runtime-host";
|
||||
root.className = "jio-modal-runtime-host";
|
||||
document.body.appendChild(root);
|
||||
return root;
|
||||
}
|
||||
@@ -65,13 +65,13 @@
|
||||
scrollLock.push(padRight(element, gap));
|
||||
});
|
||||
}
|
||||
html.classList.add("aksrt-modal-runtime-open");
|
||||
body.classList.add("aksrt-modal-runtime-open");
|
||||
html.classList.add("jio-modal-runtime-open");
|
||||
body.classList.add("jio-modal-runtime-open");
|
||||
return;
|
||||
}
|
||||
if (!scrollLock) return;
|
||||
html.classList.remove("aksrt-modal-runtime-open");
|
||||
body.classList.remove("aksrt-modal-runtime-open");
|
||||
html.classList.remove("jio-modal-runtime-open");
|
||||
body.classList.remove("jio-modal-runtime-open");
|
||||
scrollLock.forEach(function (entry) {
|
||||
entry.element.style.paddingRight = entry.inline;
|
||||
});
|
||||
@@ -80,25 +80,25 @@
|
||||
|
||||
function skeleton(options) {
|
||||
if (options && options.loading === "spinner") {
|
||||
return '<div class="aksrt-modal-runtime__loading flex jc"><div class="em2x opacity5"><svg class="loading-circle" viewBox="0 0 50 50"><circle cx="25" cy="25" r="20"></circle></svg></div></div>';
|
||||
return '<div class="jio-modal-runtime__loading flex jc"><div class="em2x opacity5"><svg class="loading-circle" viewBox="0 0 50 50"><circle cx="25" cy="25" r="20"></circle></svg></div></div>';
|
||||
}
|
||||
return (options && options.skeleton) ||
|
||||
'<div class="aksrt-modal-runtime__skeleton" aria-live="polite" aria-busy="true">' +
|
||||
'<span class="aksrt-modal-runtime__skeleton-line is-wide"></span>' +
|
||||
'<span class="aksrt-modal-runtime__skeleton-line"></span>' +
|
||||
'<span class="aksrt-modal-runtime__skeleton-line is-short"></span>' +
|
||||
'<span class="aksrt-modal-runtime__skeleton-block"></span>' +
|
||||
'<div class="jio-modal-runtime__skeleton" aria-live="polite" aria-busy="true">' +
|
||||
'<span class="jio-modal-runtime__skeleton-line is-wide"></span>' +
|
||||
'<span class="jio-modal-runtime__skeleton-line"></span>' +
|
||||
'<span class="jio-modal-runtime__skeleton-line is-short"></span>' +
|
||||
'<span class="jio-modal-runtime__skeleton-block"></span>' +
|
||||
'</div>';
|
||||
}
|
||||
|
||||
function telemetryStart(kind) {
|
||||
if (kind === false) return "";
|
||||
return window.AksrtModalTelemetry.start(kind || "generic");
|
||||
return window.JioModalTelemetry.start(kind || "generic");
|
||||
}
|
||||
|
||||
function telemetryMark(session, event) {
|
||||
if (!session || !session.telemetryId) return;
|
||||
window.AksrtModalTelemetry.mark(session.telemetryId, event);
|
||||
window.JioModalTelemetry.mark(session.telemetryId, event);
|
||||
}
|
||||
|
||||
function isLive(session) {
|
||||
@@ -109,7 +109,7 @@
|
||||
session.state.status = status;
|
||||
session.state.error = error || null;
|
||||
session.state.updatedAt = Date.now();
|
||||
if (session.shell) session.shell.setAttribute("data-aksrt-modal-state", status);
|
||||
if (session.shell) session.shell.setAttribute("data-jio-modal-state", status);
|
||||
if (typeof session.options.onState === "function") {
|
||||
session.options.onState(status, session);
|
||||
}
|
||||
@@ -120,7 +120,7 @@
|
||||
}
|
||||
|
||||
function closeSelector() {
|
||||
return "[data-aksrt-modal-close], .aksrt-modal-runtime__close";
|
||||
return "[data-jio-modal-close], .jio-modal-runtime__close";
|
||||
}
|
||||
|
||||
function bindChrome(session) {
|
||||
@@ -133,11 +133,11 @@
|
||||
close("control");
|
||||
return;
|
||||
}
|
||||
if (event.target === shell || event.target.classList.contains("aksrt-modal-runtime__overlay")) {
|
||||
if (event.target === shell || event.target.classList.contains("jio-modal-runtime__overlay")) {
|
||||
close("overlay");
|
||||
return;
|
||||
}
|
||||
var retry = event.target.closest("[data-aksrt-modal-retry]");
|
||||
var retry = event.target.closest("[data-jio-modal-retry]");
|
||||
if (retry) {
|
||||
event.preventDefault();
|
||||
refresh();
|
||||
@@ -178,32 +178,32 @@
|
||||
var heightStyle = options.height ? "min-height:" + parseInt(options.height, 10) + "px;" : "";
|
||||
var initialHtml = options.html !== undefined ? options.html : skeleton(options);
|
||||
var swipeHandle = bottom && options.swipeClose ? '<div class="touch-close" aria-hidden="true"></div>' : "";
|
||||
var titleId = "aksrt-modal-title-" + String(sequence + 1);
|
||||
var titleId = "jio-modal-title-" + String(sequence + 1);
|
||||
var titleHtml = options.title
|
||||
? '<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>'
|
||||
? '<header class="jio-modal-runtime__header"><h3 class="jio-modal-runtime__title" id="' + titleId + '">' + escapeHtml(options.title) + '</h3><button type="button" class="jio-modal-runtime__close" data-jio-modal-close aria-label="关闭">×</button></header>'
|
||||
: "";
|
||||
|
||||
shell.className =
|
||||
"aksrt-modal-runtime" +
|
||||
(active ? " aksrt-modal-runtime--child" : "") +
|
||||
(bottom ? " aksrt-modal-runtime--bottom" : "") +
|
||||
"jio-modal-runtime" +
|
||||
(active ? " jio-modal-runtime--child" : "") +
|
||||
(bottom ? " jio-modal-runtime--bottom" : "") +
|
||||
(options.className ? " " + options.className : "");
|
||||
shell.setAttribute("role", "dialog");
|
||||
shell.setAttribute("aria-modal", "true");
|
||||
if (options.title) shell.setAttribute("aria-labelledby", titleId);
|
||||
shell.setAttribute("tabindex", "-1");
|
||||
shell.innerHTML =
|
||||
'<div class="aksrt-modal-runtime__overlay" data-aksrt-modal-close></div>' +
|
||||
'<div class="aksrt-modal-runtime__dialog" style="' + heightStyle + '">' +
|
||||
'<div class="jio-modal-runtime__overlay" data-jio-modal-close></div>' +
|
||||
'<div class="jio-modal-runtime__dialog" style="' + heightStyle + '">' +
|
||||
titleHtml +
|
||||
'<div class="aksrt-modal-runtime__content">' + initialHtml + "</div>" + swipeHandle + "</div>";
|
||||
'<div class="jio-modal-runtime__content">' + initialHtml + "</div>" + swipeHandle + "</div>";
|
||||
|
||||
var session = {
|
||||
id: String(++sequence),
|
||||
shell: shell,
|
||||
content: shell.querySelector(".aksrt-modal-runtime__content"),
|
||||
content: shell.querySelector(".jio-modal-runtime__content"),
|
||||
options: options,
|
||||
state: window.AksrtModalState.create(options.kind || "generic"),
|
||||
state: window.JioModalState.create(options.kind || "generic"),
|
||||
focusReturn: options.focusReturn !== undefined ? options.focusReturn : document.activeElement,
|
||||
controller: null,
|
||||
flight: null,
|
||||
@@ -212,7 +212,7 @@
|
||||
};
|
||||
|
||||
if (active) {
|
||||
active.shell.classList.add("aksrt-modal-runtime--parent");
|
||||
active.shell.classList.add("jio-modal-runtime--parent");
|
||||
active.shell.setAttribute("aria-modal", "false");
|
||||
active.shell.setAttribute("aria-hidden", "true");
|
||||
active.shell.setAttribute("inert", "");
|
||||
@@ -222,7 +222,7 @@
|
||||
if (bottom && options.swipeClose && window.jQuery && window.jQuery.fn && typeof window.jQuery.fn.minitouch === "function") {
|
||||
window.jQuery(shell).minitouch({
|
||||
direction: "bottom",
|
||||
selector: ".aksrt-modal-runtime__dialog",
|
||||
selector: ".jio-modal-runtime__dialog",
|
||||
start_selector: ".modal-colorful-header,.touch-close,.touch",
|
||||
depreciation: 50,
|
||||
stop: function () { return active !== session; },
|
||||
@@ -244,7 +244,7 @@
|
||||
(nodes.length ? nodes[0] : shell).focus();
|
||||
} catch (error) {}
|
||||
|
||||
document.dispatchEvent(new CustomEvent("aksrt:modal:open", {
|
||||
document.dispatchEvent(new CustomEvent("jio:modal:open", {
|
||||
detail: { shell: shell, options: options, session: session },
|
||||
}));
|
||||
|
||||
@@ -285,19 +285,19 @@
|
||||
if (!preserveRequest) abortSessionRequest(session);
|
||||
session.shell.classList.remove("is-open");
|
||||
if (active && resumeParent) {
|
||||
active.shell.classList.remove("aksrt-modal-runtime--parent");
|
||||
active.shell.classList.remove("jio-modal-runtime--parent");
|
||||
active.shell.setAttribute("aria-modal", "true");
|
||||
active.shell.removeAttribute("aria-hidden");
|
||||
active.shell.removeAttribute("inert");
|
||||
}
|
||||
if (!active && !preserveRequest) lockScroll(false);
|
||||
document.dispatchEvent(new CustomEvent("aksrt:modal:close", {
|
||||
document.dispatchEvent(new CustomEvent("jio:modal:close", {
|
||||
detail: { shell: session.shell, reason: reason || "close", session: session },
|
||||
}));
|
||||
|
||||
var node = session.shell;
|
||||
var exitDelay = 220;
|
||||
var dialog = node.querySelector(".aksrt-modal-runtime__dialog");
|
||||
var dialog = node.querySelector(".jio-modal-runtime__dialog");
|
||||
if (dialog) {
|
||||
var durations = window.getComputedStyle(dialog).transitionDuration || "";
|
||||
durations.split(",").forEach(function (duration) {
|
||||
@@ -348,11 +348,11 @@
|
||||
setState(session, unauthorized ? "unauthorized" : "error", error);
|
||||
telemetryMark(session, unauthorized ? "unauthorized" : "error");
|
||||
session.content.innerHTML =
|
||||
'<div class="aksrt-modal-runtime__error touch border-title"><b>提示</b></div>' +
|
||||
'<div class="aksrt-modal-runtime__error-body">' + escapeHtml(errorMessage(error)) +
|
||||
'<div class="jio-modal-runtime__error touch border-title"><b>提示</b></div>' +
|
||||
'<div class="jio-modal-runtime__error-body">' + escapeHtml(errorMessage(error)) +
|
||||
'</div><div class="but-average modal-buts">' +
|
||||
'<button type="button" class="but" data-aksrt-modal-retry>重试</button>' +
|
||||
'<button type="button" class="but" data-aksrt-modal-close>关闭</button></div>';
|
||||
'<button type="button" class="but" data-jio-modal-retry>重试</button>' +
|
||||
'<button type="button" class="but" data-jio-modal-close>关闭</button></div>';
|
||||
notifyContentLoaded(session);
|
||||
if (typeof session.options.onError === "function") session.options.onError(error, session);
|
||||
}
|
||||
@@ -366,7 +366,7 @@
|
||||
setState(session, "empty");
|
||||
telemetryMark(session, "first-content");
|
||||
telemetryMark(session, "ready");
|
||||
session.content.innerHTML = '<div class="aksrt-modal-runtime__error-body">暂无内容</div>';
|
||||
session.content.innerHTML = '<div class="jio-modal-runtime__error-body">暂无内容</div>';
|
||||
return;
|
||||
}
|
||||
if (typeof session.options.renderData === "function") {
|
||||
@@ -385,7 +385,7 @@
|
||||
setState(session, "empty");
|
||||
telemetryMark(session, "first-content");
|
||||
telemetryMark(session, "ready");
|
||||
session.content.innerHTML = '<div class="aksrt-modal-runtime__error-body">暂无内容</div>';
|
||||
session.content.innerHTML = '<div class="jio-modal-runtime__error-body">暂无内容</div>';
|
||||
return;
|
||||
}
|
||||
session.content.innerHTML = html;
|
||||
@@ -415,14 +415,14 @@
|
||||
if (!requestOptions.signal) delete requestOptions.signal;
|
||||
|
||||
var request = function () {
|
||||
return window.AksrtRequest.request(session.options.url, requestOptions);
|
||||
return window.JioRequest.request(session.options.url, requestOptions);
|
||||
};
|
||||
|
||||
var method = String(session.options.method || "GET").toUpperCase();
|
||||
var cacheable = method === "GET" && session.options.cache !== false;
|
||||
var cacheKey = session.options.cacheKey ||
|
||||
method + ":" + window.AksrtRequest.url(session.options.url, session.options.query);
|
||||
var cache = window.AksrtModalCache;
|
||||
method + ":" + window.JioRequest.url(session.options.url, session.options.query);
|
||||
var cache = window.JioModalCache;
|
||||
var acquireOptions = {
|
||||
ttl: Number(session.options.cacheTtl || 15000),
|
||||
tags: session.options.cacheTags || session.options.tags || [],
|
||||
@@ -471,7 +471,7 @@
|
||||
function sessionKey(options) {
|
||||
if (!options || !options.url) return "";
|
||||
var method = String(options.method || "GET").toUpperCase();
|
||||
var requestUrl = window.AksrtRequest.url(options.url, options.query);
|
||||
var requestUrl = window.JioRequest.url(options.url, options.query);
|
||||
return method + ":" + requestUrl;
|
||||
}
|
||||
|
||||
@@ -505,10 +505,10 @@
|
||||
}
|
||||
|
||||
function invalidate(tags) {
|
||||
return window.AksrtModalCache.invalidate(tags);
|
||||
return window.JioModalCache.invalidate(tags);
|
||||
}
|
||||
|
||||
window.AksrtModalRuntime = {
|
||||
window.JioModalRuntime = {
|
||||
open: open,
|
||||
openRemote: openRemote,
|
||||
close: close,
|
||||
@@ -520,13 +520,13 @@
|
||||
getState: function () { return active ? active.state : null; },
|
||||
};
|
||||
|
||||
document.dispatchEvent(new CustomEvent("aksrt:modal-runtime:ready"));
|
||||
document.dispatchEvent(new CustomEvent("jio:modal-runtime:ready"));
|
||||
|
||||
// legacy 契约(只绑定一次):modal 展示/内容注入后调用全局 auto_fun 重扫。
|
||||
if (window.jQuery) {
|
||||
window.jQuery(document).on(
|
||||
"loaded.bs.modal show.bs.modal",
|
||||
".modal, .aksrt-modal-runtime",
|
||||
".modal, .jio-modal-runtime",
|
||||
function () {
|
||||
if (typeof window.auto_fun === "function") window.auto_fun();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Shared modal state vocabulary.
|
||||
*
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
(function (window) {
|
||||
"use strict";
|
||||
@@ -27,7 +27,7 @@
|
||||
};
|
||||
}
|
||||
|
||||
window.AksrtModalState = {
|
||||
window.JioModalState = {
|
||||
statuses: statuses,
|
||||
create: create,
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Records only bounded domain/event names and timing data. Never include
|
||||
* payment credentials, order contents, identity evidence, or user payloads.
|
||||
*
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
(function (window) {
|
||||
'use strict';
|
||||
@@ -41,7 +41,7 @@
|
||||
}
|
||||
|
||||
function markName(session, event) {
|
||||
return 'aksrt-modal-' + session.kind + '-' + session.id + '-' + event;
|
||||
return 'jio-modal-' + session.kind + '-' + session.id + '-' + event;
|
||||
}
|
||||
|
||||
function emit(session, event) {
|
||||
@@ -54,7 +54,7 @@
|
||||
if (typeof window.performance.measure === 'function' && session.marks.click && event !== 'click') {
|
||||
try {
|
||||
window.performance.measure(
|
||||
'aksrt-modal-' + session.kind + '-' + session.id + '-click-to-' + event,
|
||||
'jio-modal-' + session.kind + '-' + session.id + '-click-to-' + event,
|
||||
session.marks.click,
|
||||
name
|
||||
);
|
||||
@@ -103,7 +103,7 @@
|
||||
mark(id, 'error');
|
||||
}
|
||||
|
||||
window.AksrtModalTelemetry = {
|
||||
window.JioModalTelemetry = {
|
||||
start: start,
|
||||
mark: mark,
|
||||
finish: finish,
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
/**
|
||||
* Declarative modal triggers.
|
||||
*
|
||||
* The only modal entry point is AksrtModalRuntime. Triggers carry an
|
||||
* The only modal entry point is JioModalRuntime. Triggers carry an
|
||||
* explicit URL and never create a second modal implementation.
|
||||
*
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
(function (window, document) {
|
||||
"use strict";
|
||||
|
||||
function openFromTrigger(element) {
|
||||
var runtime = window.AksrtModalRuntime;
|
||||
var url = element.getAttribute("data-aksrt-modal-url") || "";
|
||||
var runtime = window.JioModalRuntime;
|
||||
var url = element.getAttribute("data-jio-modal-url") || "";
|
||||
if (!url || url === "#") return;
|
||||
|
||||
var ttl = parseInt(element.getAttribute("data-aksrt-modal-cache-ttl") || "15000", 10);
|
||||
var cache = element.getAttribute("data-aksrt-modal-cache") !== "false";
|
||||
var tags = (element.getAttribute("data-aksrt-modal-cache-tags") || "").split(",").map(function (tag) {
|
||||
var ttl = parseInt(element.getAttribute("data-jio-modal-cache-ttl") || "15000", 10);
|
||||
var cache = element.getAttribute("data-jio-modal-cache") !== "false";
|
||||
var tags = (element.getAttribute("data-jio-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",
|
||||
newModal: element.getAttribute("data-aksrt-modal-new") === "true",
|
||||
loading: element.getAttribute("data-aksrt-modal-loading") || "",
|
||||
swipeClose: element.getAttribute("data-aksrt-modal-swipe-close") === "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") || "",
|
||||
method: element.getAttribute("data-jio-modal-method") || "GET",
|
||||
className: element.getAttribute("data-jio-modal-class") || "modal-mini full-sm",
|
||||
height: parseInt(element.getAttribute("data-jio-modal-height") || "0", 10) || 0,
|
||||
mobileBottom: element.getAttribute("data-jio-modal-mobile-bottom") === "true",
|
||||
newModal: element.getAttribute("data-jio-modal-new") === "true",
|
||||
loading: element.getAttribute("data-jio-modal-loading") || "",
|
||||
swipeClose: element.getAttribute("data-jio-modal-swipe-close") === "true",
|
||||
bottom: element.getAttribute("data-jio-modal-bottom") === "true",
|
||||
kind: element.getAttribute("data-jio-modal-kind") || "generic",
|
||||
cacheKey: element.getAttribute("data-jio-modal-cache-key") || "",
|
||||
cache: cache,
|
||||
cacheTtl: ttl > 0 ? ttl : 15000,
|
||||
cacheTags: tags,
|
||||
@@ -39,7 +39,7 @@
|
||||
}
|
||||
|
||||
document.addEventListener("click", function (event) {
|
||||
var trigger = event.target.closest('[data-aksrt-modal="remote"]');
|
||||
var trigger = event.target.closest('[data-jio-modal="remote"]');
|
||||
if (!trigger) return;
|
||||
event.preventDefault();
|
||||
openFromTrigger(trigger);
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
/**
|
||||
* AKSRT AJAX Pagination & Lazy Load
|
||||
* Jio AJAX Pagination & Lazy Load
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function hasAjaxConfig() {
|
||||
return !!(window.aksrtData && aksrtData.ajaxUrl && aksrtData.nonce);
|
||||
return !!(window.jioData && jioData.ajaxUrl && jioData.nonce);
|
||||
}
|
||||
|
||||
function initAjaxPagination(root) {
|
||||
var containers = (root || document).querySelectorAll("[data-aksrt-pagination], .aksrt-comment-pagination");
|
||||
var containers = (root || document).querySelectorAll("[data-jio-pagination], .jio-comment-pagination");
|
||||
if (!containers.length) return;
|
||||
|
||||
var triggerText = (window.aksrtData && aksrtData.ajaxTrigger) || "加载更多";
|
||||
var nomoreText = (window.aksrtData && aksrtData.ajaxNomore) || "没有更多了";
|
||||
var errorText = (window.aksrtData && aksrtData.ajaxLoadError) || "加载失败,请重试";
|
||||
var triggerText = (window.jioData && jioData.ajaxTrigger) || "加载更多";
|
||||
var nomoreText = (window.jioData && jioData.ajaxNomore) || "没有更多了";
|
||||
var errorText = (window.jioData && jioData.ajaxLoadError) || "加载失败,请重试";
|
||||
|
||||
containers.forEach(function (container) {
|
||||
if (container.dataset.aksrtPaginationBound === "1") return;
|
||||
container.dataset.aksrtPaginationBound = "1";
|
||||
if (container.dataset.jioPaginationBound === "1") return;
|
||||
container.dataset.jioPaginationBound = "1";
|
||||
|
||||
var mode = container.dataset.mode || "load_more";
|
||||
var nextPage = parseInt(container.dataset.nextPage, 10) || 2;
|
||||
var maxPages = parseInt(container.dataset.maxPages, 10) || 1;
|
||||
var isComment = container.classList.contains("aksrt-comment-pagination");
|
||||
var isComment = container.classList.contains("jio-comment-pagination");
|
||||
var postId = container.dataset.postId || "";
|
||||
var commentOrder = container.dataset.commentOrder || "newest";
|
||||
var loading = false;
|
||||
var failed = false;
|
||||
var clickTarget = container.querySelector(".next-page.ajax-next, .ias-btn") || container;
|
||||
var loadMoreBtn = container.querySelector("[data-aksrt-load-more]") || clickTarget;
|
||||
var loadMoreBtn = container.querySelector("[data-jio-load-more]") || clickTarget;
|
||||
var successfulAutoLoads = 0;
|
||||
var iasMax = isComment
|
||||
? ((window.aksrtData && typeof aksrtData.commentIasMax !== "undefined") ? parseInt(aksrtData.commentIasMax, 10) : 0)
|
||||
: ((window.aksrtData && typeof aksrtData.iasMax !== "undefined") ? parseInt(aksrtData.iasMax, 10) : 0);
|
||||
? ((window.jioData && typeof jioData.commentIasMax !== "undefined") ? parseInt(jioData.commentIasMax, 10) : 0)
|
||||
: ((window.jioData && typeof jioData.iasMax !== "undefined") ? parseInt(jioData.iasMax, 10) : 0);
|
||||
// legacy 契约:分页容器与列表同处一个 .ajaxpager 内(首页 tab pane、归档流),
|
||||
// 此时追加目标就是列表容器本身,新卡片插到分页控件之前。
|
||||
var listContainer = container.closest(".ajaxpager, .posts-row");
|
||||
@@ -50,7 +50,7 @@
|
||||
target = container.parentElement.querySelector(".post-grid, .comment-list, .commentlist, .content-stream__list");
|
||||
}
|
||||
|
||||
// 文章骨架:与 runtime/main.js 的 .ajax-next 处理器、aksrt_render_placeholder()
|
||||
// 文章骨架:与 runtime/main.js 的 .ajax-next 处理器、jio_render_placeholder()
|
||||
// 同源同款(1:1 对齐参考主题 zib_get_post_placeholder)。刻意不写 ajax-item:
|
||||
// 否则会被 inject() / find('.ajax-item') 当成真实条目删除或定位。
|
||||
var CARD_ITEM =
|
||||
@@ -94,7 +94,7 @@
|
||||
// 兜底(非文章列表面,例如评论区没有 .posts-item 时):转圈 + 文案,
|
||||
// 绝不用按钮自身文字来表达加载态。
|
||||
function fallbackLoader() {
|
||||
var text = (window.aksrtData && aksrtData.ajaxLoading) || "加载中...";
|
||||
var text = (window.jioData && jioData.ajaxLoading) || "加载中...";
|
||||
return (
|
||||
'<div class="mb20"><div class="text-center muted-2-color mt20">' +
|
||||
'<i class="loading mr10"></i>' + text +
|
||||
@@ -167,13 +167,13 @@
|
||||
// 只操作 .post_ajax_loader,不触碰「加载更多」按钮自身的文字)。
|
||||
showSkeleton();
|
||||
|
||||
var action = isComment ? "aksrt_load_more_comments" : "aksrt_load_more_posts";
|
||||
var action = isComment ? "jio_load_more_comments" : "jio_load_more_posts";
|
||||
var queryContext = container.dataset.queryContext || "";
|
||||
var queryVars = container.dataset.queryVars || "";
|
||||
var renderConfig = container.dataset.renderConfig || "";
|
||||
var body = new URLSearchParams();
|
||||
body.set("action", action);
|
||||
body.set("nonce", aksrtData.nonce);
|
||||
body.set("nonce", jioData.nonce);
|
||||
body.set("page", String(nextPage));
|
||||
if (queryContext) {
|
||||
body.set("query_context", queryContext);
|
||||
@@ -191,7 +191,7 @@
|
||||
if (authorOnly === "1") body.set("author_only", "1");
|
||||
}
|
||||
|
||||
return fetch(aksrtData.ajaxUrl, {
|
||||
return fetch(jioData.ajaxUrl, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" },
|
||||
credentials: "same-origin",
|
||||
@@ -285,9 +285,9 @@
|
||||
var max = parseInt(jumpInput.dataset.maxPages || String(maxPages), 10) || maxPages;
|
||||
targetPage = Math.max(1, Math.min(max, targetPage));
|
||||
// 评论跳页:本地 DOM 刷新,地址栏不携带 ? 参数。
|
||||
if (window.AksrtComments && typeof window.AksrtComments.loadPage === "function") {
|
||||
if (window.JioComments && typeof window.JioComments.loadPage === "function") {
|
||||
e.preventDefault();
|
||||
window.AksrtComments.loadPage(targetPage);
|
||||
window.JioComments.loadPage(targetPage);
|
||||
return;
|
||||
}
|
||||
window.location.hash = "comments";
|
||||
@@ -329,7 +329,7 @@
|
||||
}
|
||||
|
||||
if (mode === "infinite") {
|
||||
if ((isComment && window.aksrtData && aksrtData.commentIasAuto === false) || !hasAjaxConfig()) {
|
||||
if ((isComment && window.jioData && jioData.commentIasAuto === false) || !hasAjaxConfig()) {
|
||||
var autoTrigger = clickTarget.closest(".next-page") || clickTarget;
|
||||
autoTrigger.classList.remove("lazyload");
|
||||
autoTrigger.removeAttribute("lazyload-action");
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/**
|
||||
* AKSRT frontend request adapter.
|
||||
* Jio frontend request adapter.
|
||||
*
|
||||
* Owns the injected REST root, nonce headers, response envelopes, and
|
||||
* abort-aware error normalization used by modal loaders.
|
||||
*
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
(function (window) {
|
||||
"use strict";
|
||||
|
||||
function data() {
|
||||
return window.aksrtData || window.aksrt || {};
|
||||
return window.jioData || window.jio || {};
|
||||
}
|
||||
|
||||
function createIdempotencyKey() {
|
||||
@@ -40,7 +40,7 @@
|
||||
}
|
||||
|
||||
if (raw) return String(raw).replace(/\/$/, "");
|
||||
return String(siteUrl).replace(/\/$/, "") + "/index.php?rest_route=/aksrt/v1";
|
||||
return String(siteUrl).replace(/\/$/, "") + "/index.php?rest_route=/jio/v1";
|
||||
}
|
||||
|
||||
function appendQuery(url, query) {
|
||||
@@ -158,7 +158,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
window.AksrtRequest = {
|
||||
window.JioRequest = {
|
||||
url: url,
|
||||
request: request,
|
||||
createIdempotencyKey: createIdempotencyKey,
|
||||
|
||||
+13
-13
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* AKSRT Theme Toggle — dark/light mode switching with transitions
|
||||
* Jio Theme Toggle — dark/light mode switching with transitions
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
var THEME_KEY = "aksrt-theme";
|
||||
var THEME_KEY = "jio-theme";
|
||||
var THEME_COOKIE_KEY = "theme_mode";
|
||||
|
||||
function normalizeStoredTheme(value) {
|
||||
@@ -103,29 +103,29 @@
|
||||
function syncThemeImages(isDark) {
|
||||
document.querySelectorAll("img[switch-src], img[data-switch-src]").forEach(function (img) {
|
||||
var darkSrc = getThemeImageAttr(img, "switch-src");
|
||||
if (!img.dataset.aksrtThemeLightSrc) {
|
||||
img.dataset.aksrtThemeLightSrc = img.getAttribute("src") || "";
|
||||
if (!img.dataset.jioThemeLightSrc) {
|
||||
img.dataset.jioThemeLightSrc = img.getAttribute("src") || "";
|
||||
}
|
||||
setThemeImageSource(img, isDark && darkSrc ? darkSrc : img.dataset.aksrtThemeLightSrc);
|
||||
setThemeImageSource(img, isDark && darkSrc ? darkSrc : img.dataset.jioThemeLightSrc);
|
||||
});
|
||||
|
||||
document.querySelectorAll("img[white-src], img[dark-src], img[data-white-src], img[data-dark-src]").forEach(function (img) {
|
||||
var lightSrc = getThemeImageAttr(img, "white-src") || img.dataset.aksrtThemeLightSrc || img.getAttribute("src") || "";
|
||||
var lightSrc = getThemeImageAttr(img, "white-src") || img.dataset.jioThemeLightSrc || img.getAttribute("src") || "";
|
||||
var darkSrc = getThemeImageAttr(img, "dark-src");
|
||||
if (!img.dataset.aksrtThemeLightSrc && lightSrc) {
|
||||
img.dataset.aksrtThemeLightSrc = lightSrc;
|
||||
if (!img.dataset.jioThemeLightSrc && lightSrc) {
|
||||
img.dataset.jioThemeLightSrc = lightSrc;
|
||||
}
|
||||
setThemeImageSource(img, isDark && darkSrc ? darkSrc : lightSrc);
|
||||
});
|
||||
}
|
||||
|
||||
function syncCodeHighlightTheme(isDark) {
|
||||
if (typeof window.AksrtPrecodeApplyTheme === "function") {
|
||||
window.AksrtPrecodeApplyTheme(isDark);
|
||||
if (typeof window.JioPrecodeApplyTheme === "function") {
|
||||
window.JioPrecodeApplyTheme(isDark);
|
||||
return;
|
||||
}
|
||||
|
||||
var settings = (window.aksrtData && window.aksrtData.codeHighlight) || {};
|
||||
var settings = (window.jioData && window.jioData.codeHighlight) || {};
|
||||
var theme = isDark ? (settings.darkTheme || "monokai") : (settings.lightTheme || "enlighter");
|
||||
document.querySelectorAll(".enlighter-default").forEach(function (el) {
|
||||
el.className = el.className.replace(/\benlighter-t-[\w-]+\b/g, "").replace(/\s+/g, " ").trim();
|
||||
@@ -135,7 +135,7 @@
|
||||
|
||||
function dispatchThemeChange(isDark) {
|
||||
try {
|
||||
document.dispatchEvent(new CustomEvent("aksrt:theme-change", {
|
||||
document.dispatchEvent(new CustomEvent("jio:theme-change", {
|
||||
detail: {
|
||||
theme: isDark ? "dark" : "light",
|
||||
isDark: isDark
|
||||
@@ -185,7 +185,7 @@
|
||||
themeInitialized = true;
|
||||
|
||||
var stored = getStoredTheme();
|
||||
var configuredMode = (window.aksrtData && window.aksrtData.themeMode) || "light";
|
||||
var configuredMode = (window.jioData && window.jioData.themeMode) || "light";
|
||||
if (stored === "dark" || stored === "light") {
|
||||
applyTheme(stored);
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 订单相关缓存标签失效(下单待支付 / 支付 / 关闭)时,向服务端拉取最新浮窗片段
|
||||
* 并替换现有节点;无待支付订单时移除浮窗。
|
||||
*
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
(function (window, document) {
|
||||
"use strict";
|
||||
@@ -14,7 +14,7 @@
|
||||
var seq = 0;
|
||||
|
||||
function loggedIn() {
|
||||
var config = window.aksrtData || window.aksrt || {};
|
||||
var config = window.jioData || window.jio || {};
|
||||
return !!config.isLoggedIn;
|
||||
}
|
||||
|
||||
@@ -44,16 +44,16 @@
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
if (!loggedIn() || !window.AksrtRequest) return;
|
||||
if (!loggedIn() || !window.JioRequest) return;
|
||||
var id = ++seq;
|
||||
window.AksrtRequest.get("/orders/wait-pay-float").then(function (result) {
|
||||
window.JioRequest.get("/orders/wait-pay-float").then(function (result) {
|
||||
if (id !== seq) return;
|
||||
var data = result.data || {};
|
||||
render(String(data.html || ""));
|
||||
}).catch(function () { /* 保留现有浮窗 */ });
|
||||
}
|
||||
|
||||
document.addEventListener("aksrt:cache:invalidated", function (event) {
|
||||
document.addEventListener("jio:cache:invalidated", function (event) {
|
||||
if (!touchesOrders(event.detail && event.detail.tags)) return;
|
||||
window.clearTimeout(timer);
|
||||
timer = window.setTimeout(refresh, 300);
|
||||
|
||||
Reference in new issue
Block a user