- 删除 AksrtFrontend registry/rehydrate 双路架构及 build/public.js 拼包入口,
前台唯一初始路径为 PHP 本地栈(jQuery 1.9.1 → Bootstrap 3.4.1)
→ loader_js(_win/aksrtData 唯一注入)→ tbquire(['main']) → runtime/main.min.js
- window.auto_fun = debounce(z_auto_fun, 100) 为唯一重扫入口;所有模块改为
执行一次 + off/on('auto_fun.aksrt-*') 命名空间重扫,data/class 标记幂等
- 局部更新协议统一:HTML 注入 → post_ajax.ed → auto_fun();
远程 modal → loaded.bs.modal → auto_fun();JSON 成功 → zib_ajax.success
- 灯箱恢复 Miniimgbox/imgbox 唯一 owner(imgbox-container、a[data-imgbox]、
imgbox_data),删除 AksrtLightbox/data-aksrt-lightbox 第二实现及 CSS/overlay,
_win.imgbox* 重新接上 post-display 设置
- 死代码清理:runtime 下 11 组被自有实现替代的旧模块副本、无消费 vendored 库、
顶层 grade.min.js、revenue.js、无调用方的 aksrt_get_win_runtime_config(),
以及 loader 中 16 条死 mapping
- PHP 入队改为本地栈 + loader_js,routed/widget/submit 依赖统一换绑;
用户卡片发布按钮恢复 nav_user_newposts_btn 设置门控
- 测试对齐:新增 frontend-lifecycle-contract,重写 navigation/lazyload/toast/
auth-source/comment/page-display/post-visual 等断言为目标架构契约
验证:node --test widget-system+navigation 223 通过 0 失败;
构建脚本重建 main/imgbox min 与 CSS bundles;改动 PHP php -l、JS node --check
全部通过;git diff --check 干净;credits 重入 harness 通过。
135 lines
4.1 KiB
JavaScript
135 lines
4.1 KiB
JavaScript
/**
|
|
* AKSRT Docs Navigation
|
|
*
|
|
* Enhanced document sidebar navigation:
|
|
* - Collapsible section toggles
|
|
* - Keyboard navigation
|
|
* - Current section auto-expand
|
|
* - Sidebar search with live filtering
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
(function () {
|
|
'use strict';
|
|
|
|
var DocsNav = {
|
|
sidebar: null,
|
|
searchInput: null,
|
|
items: [],
|
|
|
|
init: function () {
|
|
this.sidebar = document.querySelector('.aksrt-doc-sidebar');
|
|
if (!this.sidebar || this.sidebar.dataset.aksrtDocsNavBound === '1') return;
|
|
this.sidebar.dataset.aksrtDocsNavBound = '1';
|
|
|
|
this.items = Array.from(this.sidebar.querySelectorAll('.aksrt-doc-sidebar__item'));
|
|
this.searchInput = this.sidebar.querySelector('.aksrt-doc-sidebar__search-input');
|
|
|
|
this.initToggle();
|
|
this.initSearch();
|
|
this.initKeyboard();
|
|
},
|
|
|
|
/**
|
|
* Toggle collapsible sections
|
|
*/
|
|
initToggle: function () {
|
|
var self = this;
|
|
this.sidebar.addEventListener('click', function (e) {
|
|
var toggle = e.target.closest('.aksrt-doc-sidebar__toggle');
|
|
if (!toggle) return;
|
|
|
|
e.preventDefault();
|
|
var link = toggle.closest('.aksrt-doc-sidebar__link');
|
|
if (!link) return;
|
|
|
|
var li = link.closest('.aksrt-doc-sidebar__item');
|
|
if (!li) return;
|
|
|
|
var sub = li.querySelector('.aksrt-doc-sidebar__sub, ul');
|
|
if (!sub) return;
|
|
|
|
var isOpen = li.classList.contains('is-open');
|
|
li.classList.toggle('is-open');
|
|
|
|
// Update icon
|
|
toggle.classList.remove('fa-chevron-down', 'fa-chevron-right');
|
|
toggle.classList.add(isOpen ? 'fa-chevron-right' : 'fa-chevron-down');
|
|
|
|
// Toggle sub-visibility
|
|
sub.style.display = isOpen ? 'none' : '';
|
|
});
|
|
|
|
// Auto-expand current path
|
|
var currentItems = this.sidebar.querySelectorAll('.aksrt-doc-sidebar__item.is-current, .aksrt-doc-sidebar__item.is-ancestor');
|
|
currentItems.forEach(function (item) {
|
|
item.classList.add('is-open');
|
|
var toggle = item.querySelector('.aksrt-doc-sidebar__toggle');
|
|
if (toggle) {
|
|
toggle.classList.remove('fa-chevron-right');
|
|
toggle.classList.add('fa-chevron-down');
|
|
}
|
|
var sub = item.querySelector('.aksrt-doc-sidebar__sub, ul');
|
|
if (sub) sub.style.display = '';
|
|
});
|
|
},
|
|
|
|
/**
|
|
* Live search filtering
|
|
*/
|
|
initSearch: function () {
|
|
if (!this.searchInput) return;
|
|
|
|
var debounceTimer = null;
|
|
var self = this;
|
|
this.searchInput.addEventListener('input', function () {
|
|
clearTimeout(debounceTimer);
|
|
debounceTimer = setTimeout(function () {
|
|
self.filterItems(self.searchInput.value.trim().toLowerCase());
|
|
}, 150);
|
|
});
|
|
},
|
|
|
|
filterItems: function (query) {
|
|
this.items.forEach(function (item) {
|
|
var link = item.querySelector('.aksrt-doc-sidebar__link');
|
|
var text = link ? link.textContent.toLowerCase() : '';
|
|
if (query === '' || text.indexOf(query) >= 0) {
|
|
item.style.display = '';
|
|
} else {
|
|
item.style.display = 'none';
|
|
}
|
|
});
|
|
},
|
|
|
|
/**
|
|
* Keyboard navigation (arrow keys)
|
|
*/
|
|
initKeyboard: function () {
|
|
this.sidebar.addEventListener('keydown', function (e) {
|
|
if (!['ArrowUp', 'ArrowDown', 'Enter', ' '].includes(e.key)) return;
|
|
|
|
var focused = document.activeElement;
|
|
if (!focused || !focused.closest('.aksrt-doc-sidebar')) return;
|
|
|
|
var links = Array.from(document.querySelectorAll('.aksrt-doc-sidebar__link'));
|
|
var idx = links.indexOf(focused);
|
|
|
|
if (e.key === 'ArrowDown') {
|
|
e.preventDefault();
|
|
if (idx < links.length - 1) links[idx + 1].focus();
|
|
} else if (e.key === 'ArrowUp') {
|
|
e.preventDefault();
|
|
if (idx > 0) links[idx - 1].focus();
|
|
} else if (e.key === 'Enter' || e.key === ' ') {
|
|
e.preventDefault();
|
|
focused.click();
|
|
}
|
|
});
|
|
},
|
|
};
|
|
|
|
jQuery(document).off('auto_fun.aksrt-docs-navigation').on('auto_fun.aksrt-docs-navigation', function () { DocsNav.init(); });
|
|
})();
|