feat(pages): 1:1 网址导航 page-links (zibll links.php)
Add WP bookmarks-based navigation page with multi-category sticky nav, search-engine cover, front submit modal/AJAX, page meta, and styles.
This commit is contained in:
@@ -0,0 +1,459 @@
|
||||
/**
|
||||
* AKSRT 网址导航 — zibll links page shell/styles.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
/* ---- cards ---- */
|
||||
.links-cat-header {
|
||||
padding: 0 15px 10px;
|
||||
}
|
||||
|
||||
.links-box:not(.zib-widget):not(.links-style-simple):not(.links-style-image) {
|
||||
margin: -5px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.links-box .links-card {
|
||||
padding: 10px 4px 10px 8px;
|
||||
min-width: 0;
|
||||
margin: 5px;
|
||||
width: calc(50% - 10px);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.links-style-bigcard {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.links-box .links-card.big-card {
|
||||
padding: 20px 10px 15px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.links-box:not(.zib-widget) .links-card {
|
||||
background: var(--main-bg-color, var(--surface-1, #fff));
|
||||
}
|
||||
|
||||
.author-minicard.links-card {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 1px 4px var(--main-shadow, rgba(0, 0, 0, 0.06));
|
||||
transition: transform 0.15s ease, box-shadow 0.15s ease;
|
||||
}
|
||||
|
||||
.author-minicard.links-card:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 14px var(--main-shadow, rgba(0, 0, 0, 0.1));
|
||||
}
|
||||
|
||||
.links-card a {
|
||||
display: block;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.links-card .list-inline {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.links-card .list-inline > li {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.link-img {
|
||||
--this-size: 42px;
|
||||
width: var(--this-size);
|
||||
height: var(--this-size);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.link-img img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.links-card.big-card .link-img {
|
||||
--this-size: 58px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.links-card.big-card .link-img img {
|
||||
border-radius: 100px;
|
||||
}
|
||||
|
||||
.links-style-image {
|
||||
--link-img-size: 60px;
|
||||
--this-margin: 10px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.links-style-image .link-img.link-only-img {
|
||||
margin: var(--this-margin);
|
||||
--this-size: var(--link-img-size);
|
||||
}
|
||||
|
||||
.links-style-image .link-img.link-only-img img {
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
/* ---- fixed category nav ---- */
|
||||
.fixed-wrap .fixed-wrap-nav.zib-widget,
|
||||
.link-nav-box .zib-widget {
|
||||
padding: 8px 15px;
|
||||
}
|
||||
|
||||
.fixed-wrap-nav .tab-nav-theme {
|
||||
border-bottom: none;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.link-nav-box .nav > li > a {
|
||||
display: block;
|
||||
padding: 6px;
|
||||
color: var(--muted-2-color, #888);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.link-nav-box .nav > li > a:hover,
|
||||
.link-nav-box .nav > .active > a {
|
||||
color: var(--focus-color, var(--color-primary, #f04494));
|
||||
}
|
||||
|
||||
.link-nav-submit,
|
||||
.link-cat-submit {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.link-cat-submit {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.links-page-container .title-theme {
|
||||
font-weight: 600;
|
||||
font-size: 1.15em;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
/* ---- search cover ---- */
|
||||
.link-page-search-cover.page-cover {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
padding-bottom: calc(25% + 100px);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.link-page-search-cover .fit-cover {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.link-page-search-cover .header-slider-search {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: min(560px, 92%);
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.link-page-search-cover .tab-nav-theme {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0 0 8px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.link-page-search-cover .tab-nav-theme li a {
|
||||
opacity: 0.7;
|
||||
padding: 0 10px;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.link-page-search-cover .tab-nav-theme li a:hover,
|
||||
.link-page-search-cover .tab-nav-theme li.active a {
|
||||
color: #fff;
|
||||
opacity: 1;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.link-page-search-cover .tab-pane {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.link-page-search-cover .tab-pane.active,
|
||||
.link-page-search-cover .tab-pane.in.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.link-page-search-cover .line-form {
|
||||
position: relative;
|
||||
background: rgba(255, 255, 255, 0.92);
|
||||
border-radius: 8px;
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
.link-page-search-cover .line-form-input {
|
||||
width: 100%;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
outline: none;
|
||||
font-size: 15px;
|
||||
padding: 8px 36px 8px 4px;
|
||||
}
|
||||
|
||||
.link-page-search-cover .abs-right {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
.link-page-search-cover .abs-right button {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
color: var(--muted-2-color, #666);
|
||||
}
|
||||
|
||||
.link-page-search-cover .header-slider-search-more {
|
||||
color: #fff;
|
||||
text-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
/* ---- submit modal ---- */
|
||||
#submit-links-modal.modal {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1050;
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
#submit-links-modal.modal.is-open,
|
||||
#submit-links-modal.modal.show {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
#submit-links-modal .modal-dialog {
|
||||
width: min(520px, 100%);
|
||||
max-height: 90vh;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#submit-links-modal .modal-content {
|
||||
background: var(--main-bg-color, #fff);
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
|
||||
}
|
||||
|
||||
#submit-links-modal .modal-body {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
#submit-links-modal .close {
|
||||
float: right;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
#submit-links-modal .preview-square {
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
border: 1px dashed var(--main-border-color, #ddd);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#submit-links-modal .preview-square img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
#submit-links-modal .hide {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
#submit-links-modal .form-control {
|
||||
width: 100%;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid var(--main-border-color, #ddd);
|
||||
border-radius: 6px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#submit-links-modal .row.gutters-5 {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
margin: 0 -5px;
|
||||
}
|
||||
|
||||
#submit-links-modal .col-sm-6,
|
||||
#submit-links-modal .col-sm-12 {
|
||||
padding: 0 5px;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media (min-width: 576px) {
|
||||
#submit-links-modal .col-sm-6 {
|
||||
width: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- responsive grid ---- */
|
||||
@media (min-width: 992px) {
|
||||
.links-box .links-card {
|
||||
width: calc(25% - 10px);
|
||||
}
|
||||
|
||||
.site-layout-1 .links-box .links-card,
|
||||
.fluid-widget-wrap .links-box .links-card {
|
||||
width: calc(20% - 10px);
|
||||
}
|
||||
|
||||
.fluid-widget-wrap .links-box.links-style-bigcard .links-card,
|
||||
.site-layout-1 .links-box.links-style-bigcard .links-card {
|
||||
width: calc(16.6665% - 10px);
|
||||
}
|
||||
|
||||
.sidebar .links-box .links-card {
|
||||
width: calc(50% - 10px);
|
||||
}
|
||||
|
||||
.fixed-wrap {
|
||||
position: relative;
|
||||
--fixed-width: 120px;
|
||||
}
|
||||
|
||||
.fixed-wrap > .fixed-wrap-nav {
|
||||
position: absolute;
|
||||
width: var(--fixed-width);
|
||||
}
|
||||
|
||||
.fixed-wrap > .fixed-wrap-nav + .fixed-wrap-content {
|
||||
margin-left: calc(var(--fixed-width) + 15px);
|
||||
}
|
||||
|
||||
.fixed-wrap-nav.affix {
|
||||
position: sticky;
|
||||
top: 80px;
|
||||
}
|
||||
|
||||
.fixed-wrap .tab-nav-theme.mini-scrollbar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: auto;
|
||||
max-height: 70vh;
|
||||
text-align: center;
|
||||
border-bottom: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.fixed-wrap .tab-nav-theme.mini-scrollbar > li > a {
|
||||
padding: 6px;
|
||||
margin: 1px 0;
|
||||
display: block;
|
||||
font-size: 16px;
|
||||
color: var(--muted-2-color, #888);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.fixed-wrap .tab-nav-theme.mini-scrollbar > li > a:hover {
|
||||
color: var(--main-color, var(--color-primary));
|
||||
}
|
||||
|
||||
.fixed-wrap .tab-nav-theme.mini-scrollbar > li.active > a {
|
||||
color: var(--focus-color, var(--color-primary));
|
||||
font-weight: 500;
|
||||
background: color-mix(in srgb, var(--focus-color, var(--color-primary)) 12%, transparent);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.link-nav-submit {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 991px) {
|
||||
.link-nav-submit {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.link-cat-submit {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.link-nav-box > .zib-widget {
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.link-nav-box .nav {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
overflow-x: auto;
|
||||
margin: 0 0 10px;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.link-nav-box .nav > li {
|
||||
display: inline-block;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.link-nav-box .nav > li > a {
|
||||
padding: 2px 6px;
|
||||
font-size: 1.05em;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.links-box .links-card {
|
||||
width: calc(50% - 10px);
|
||||
}
|
||||
|
||||
.link-page-search-cover .tab-nav-theme li a {
|
||||
padding: 0 3px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.links-page-container .fixed-wrap {
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
/**
|
||||
* AKSRT 网址导航页 — search tabs, sticky cat nav, submit modal/AJAX.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
function qs(sel, root) {
|
||||
return (root || document).querySelector(sel);
|
||||
}
|
||||
|
||||
function qsa(sel, root) {
|
||||
return Array.prototype.slice.call((root || document).querySelectorAll(sel));
|
||||
}
|
||||
|
||||
function ajaxUrl() {
|
||||
if (window.aksrtData && window.aksrtData.ajaxUrl) return window.aksrtData.ajaxUrl;
|
||||
if (window.ajaxurl) return window.ajaxurl;
|
||||
return '/wp-admin/admin-ajax.php';
|
||||
}
|
||||
|
||||
function toast(msg, type) {
|
||||
if (window.aksrt && typeof window.aksrt.toast === 'function') {
|
||||
window.aksrt.toast(msg, type || 'info');
|
||||
return;
|
||||
}
|
||||
if (window.notyf) {
|
||||
try {
|
||||
window.notyf(msg, type === 'danger' ? 'danger' : '');
|
||||
return;
|
||||
} catch (e) { /* ignore */ }
|
||||
}
|
||||
// eslint-disable-next-line no-alert
|
||||
window.alert(msg);
|
||||
}
|
||||
|
||||
/* ---------- search engine tabs ---------- */
|
||||
function initSearchTabs() {
|
||||
var cover = qs('.link-page-search-cover');
|
||||
if (!cover) return;
|
||||
|
||||
qsa('.tab-nav-theme a[data-aksrt-tab-target]', cover).forEach(function (a) {
|
||||
a.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
var target = a.getAttribute('data-aksrt-tab-target');
|
||||
if (!target) return;
|
||||
qsa('.tab-nav-theme li', cover).forEach(function (li) {
|
||||
li.classList.remove('active');
|
||||
});
|
||||
if (a.parentElement) a.parentElement.classList.add('active');
|
||||
qsa('.tab-pane', cover).forEach(function (pane) {
|
||||
pane.classList.remove('active', 'in');
|
||||
});
|
||||
var pane = qs(target, cover);
|
||||
if (pane) pane.classList.add('active', 'in');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- sticky category nav highlight ---------- */
|
||||
function initCatNav() {
|
||||
var wrap = qs('.links-page-container .fixed-wrap');
|
||||
if (!wrap) return;
|
||||
var nav = qs('.link-nav-box', wrap);
|
||||
var links = qsa('.link-nav-box a[href^="#"]', wrap);
|
||||
var sections = links
|
||||
.map(function (a) {
|
||||
var id = a.getAttribute('href');
|
||||
return id ? document.getElementById(id.replace(/^#/, '')) : null;
|
||||
})
|
||||
.filter(Boolean);
|
||||
if (!links.length || !sections.length) return;
|
||||
|
||||
links.forEach(function (a) {
|
||||
a.addEventListener('click', function (e) {
|
||||
var id = a.getAttribute('href');
|
||||
var el = id ? document.getElementById(id.replace(/^#/, '')) : null;
|
||||
if (!el) return;
|
||||
e.preventDefault();
|
||||
var top = el.getBoundingClientRect().top + window.pageYOffset - 90;
|
||||
window.scrollTo({ top: top, behavior: 'smooth' });
|
||||
});
|
||||
});
|
||||
|
||||
function updateActive() {
|
||||
var y = window.pageYOffset + 120;
|
||||
var current = sections[0];
|
||||
for (var i = 0; i < sections.length; i++) {
|
||||
if (sections[i].offsetTop <= y) current = sections[i];
|
||||
}
|
||||
if (!current) return;
|
||||
links.forEach(function (a) {
|
||||
var li = a.parentElement;
|
||||
if (!li) return;
|
||||
if (a.getAttribute('href') === '#' + current.id) {
|
||||
li.classList.add('active');
|
||||
} else {
|
||||
li.classList.remove('active');
|
||||
}
|
||||
});
|
||||
if (nav) nav.classList.add('affix');
|
||||
}
|
||||
|
||||
window.addEventListener('scroll', updateActive, { passive: true });
|
||||
updateActive();
|
||||
}
|
||||
|
||||
/* ---------- submit modal ---------- */
|
||||
function initSubmitModal() {
|
||||
var modal = qs('#submit-links-modal');
|
||||
if (!modal) return;
|
||||
|
||||
function openModal(e) {
|
||||
if (e) e.preventDefault();
|
||||
modal.classList.add('is-open', 'show');
|
||||
modal.setAttribute('aria-hidden', 'false');
|
||||
document.documentElement.classList.add('aksrt-modal-open');
|
||||
}
|
||||
|
||||
function closeModal(e) {
|
||||
if (e) e.preventDefault();
|
||||
modal.classList.remove('is-open', 'show');
|
||||
modal.setAttribute('aria-hidden', 'true');
|
||||
document.documentElement.classList.remove('aksrt-modal-open');
|
||||
}
|
||||
|
||||
qsa('a[href="#submit-links-modal"], [data-toggle="modal"][href="#submit-links-modal"]').forEach(function (btn) {
|
||||
btn.addEventListener('click', openModal);
|
||||
});
|
||||
|
||||
qsa('[data-dismiss="modal"]', modal).forEach(function (btn) {
|
||||
btn.addEventListener('click', closeModal);
|
||||
});
|
||||
|
||||
modal.addEventListener('click', function (e) {
|
||||
if (e.target === modal) closeModal(e);
|
||||
});
|
||||
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (e.key === 'Escape' && modal.classList.contains('is-open')) closeModal(e);
|
||||
});
|
||||
|
||||
var fileInput = qs('.aksrt-links-logo-input', modal);
|
||||
var preview = qs('.aksrt-links-logo-preview', modal);
|
||||
if (fileInput && preview) {
|
||||
fileInput.addEventListener('change', function () {
|
||||
var file = fileInput.files && fileInput.files[0];
|
||||
if (!file) return;
|
||||
var url = URL.createObjectURL(file);
|
||||
preview.src = url;
|
||||
});
|
||||
}
|
||||
|
||||
var form = qs('.aksrt-links-submit-form', modal);
|
||||
if (!form) return;
|
||||
|
||||
form.addEventListener('submit', function (e) {
|
||||
e.preventDefault();
|
||||
var btn = qs('.aksrt-links-submit-btn', form);
|
||||
if (btn) {
|
||||
btn.disabled = true;
|
||||
btn.classList.add('loading');
|
||||
}
|
||||
|
||||
var fd = new FormData(form);
|
||||
if (!fd.get('action')) fd.set('action', 'aksrt_frontend_links_submit');
|
||||
|
||||
fetch(ajaxUrl(), {
|
||||
method: 'POST',
|
||||
body: fd,
|
||||
credentials: 'same-origin',
|
||||
})
|
||||
.then(function (r) {
|
||||
return r.json();
|
||||
})
|
||||
.then(function (data) {
|
||||
if (!data || data.error) {
|
||||
toast((data && data.msg) || '提交失败', 'danger');
|
||||
return;
|
||||
}
|
||||
toast(data.msg || '提交成功', 'success');
|
||||
if (data.reload) {
|
||||
window.setTimeout(function () {
|
||||
window.location.reload();
|
||||
}, 600);
|
||||
} else {
|
||||
closeModal();
|
||||
form.reset();
|
||||
}
|
||||
})
|
||||
.catch(function () {
|
||||
toast('网络错误,请稍后重试', 'danger');
|
||||
})
|
||||
.finally(function () {
|
||||
if (btn) {
|
||||
btn.disabled = false;
|
||||
btn.classList.remove('loading');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
if (!document.body.classList.contains('page-template-templates-pages-page-links-php')
|
||||
&& !qs('.page-template-links')
|
||||
&& !qs('.links-page-container')
|
||||
&& !qs('#submit-links-modal')) {
|
||||
// Still bind if modal exists alone.
|
||||
}
|
||||
initSearchTabs();
|
||||
initCatNav();
|
||||
initSubmitModal();
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user