补充主题静态资源与归档模板
This commit is contained in:
1 parent
1268a55dd0
commit
3247db7ed1
265 files changed
+59174
No files matched your search
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* AKSRT Widget Set
|
||||
*
|
||||
* Handles widget-local interactions and floating QR widgets.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
function initWidgetTabs() {
|
||||
document.querySelectorAll('.widget-tab-posts').forEach(function (widget) {
|
||||
if (widget.dataset.aksrtWidgetTabsBound === '1') return;
|
||||
widget.dataset.aksrtWidgetTabsBound = '1';
|
||||
|
||||
var tabs = widget.querySelectorAll('.widget-tab-posts__tab');
|
||||
var panels = widget.querySelectorAll('.widget-tab-posts__panel');
|
||||
if (!tabs.length || !panels.length) return;
|
||||
|
||||
tabs.forEach(function (tab) {
|
||||
tab.addEventListener('click', function () {
|
||||
var target = tab.getAttribute('data-tab');
|
||||
|
||||
tabs.forEach(function (item) {
|
||||
var active = item === tab;
|
||||
item.classList.toggle('active', active);
|
||||
item.setAttribute('aria-selected', active ? 'true' : 'false');
|
||||
});
|
||||
|
||||
panels.forEach(function (panel) {
|
||||
var active = panel.getAttribute('data-tab-panel') === target;
|
||||
panel.classList.toggle('active', active);
|
||||
if (active) {
|
||||
panel.removeAttribute('hidden');
|
||||
} else {
|
||||
panel.setAttribute('hidden', '');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function initFloatingQRCodes() {
|
||||
var wrap = document.querySelector('.float-right');
|
||||
if (!wrap) return;
|
||||
|
||||
wrap.querySelectorAll('.service-wechat .hover-show-con p, .service-qq .hover-show-con p').forEach(function (node) {
|
||||
node.remove();
|
||||
});
|
||||
|
||||
if (typeof window.kjua !== 'function') return;
|
||||
|
||||
wrap.querySelectorAll('.float-btn-qrcode').forEach(function (node) {
|
||||
if (node.dataset.qrReady === '1') return;
|
||||
|
||||
var qrText = node.getAttribute('data-qr-text') || window.location.href;
|
||||
var qrSize = parseInt(node.getAttribute('data-qr-size') || '120', 10);
|
||||
if (!qrText || !qrSize) return;
|
||||
|
||||
try {
|
||||
node.innerHTML = '';
|
||||
node.appendChild(window.kjua({
|
||||
render: 'svg',
|
||||
text: qrText,
|
||||
size: qrSize,
|
||||
ecLevel: 'H',
|
||||
fill: '#15171A',
|
||||
back: '#FFFFFF',
|
||||
quiet: 0,
|
||||
crisp: true
|
||||
}));
|
||||
node.style.width = qrSize + 'px';
|
||||
node.style.height = qrSize + 'px';
|
||||
node.dataset.qrReady = '1';
|
||||
} catch (error) {
|
||||
node.dataset.qrReady = '0';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
initWidgetTabs();
|
||||
initFloatingQRCodes();
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
})();
|
||||
Reference in new issue
Block a user