feat(widgets): feature intro shared JS + plate info count-mates
Move FeatureIntro tab/media script into widget-set.js; align plate info stats with zibll count-mates layout and residual CSS.
This commit is contained in:
@@ -344,6 +344,41 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Feature intro media tabs.
|
||||
function initFeatureIntro() {
|
||||
document.querySelectorAll('[data-aksrt-feature-intro]').forEach(function (root) {
|
||||
if (root.dataset.aksrtFiBound === '1') return;
|
||||
root.dataset.aksrtFiBound = '1';
|
||||
var tabs = [].slice.call(root.querySelectorAll('.aksrt-fi__tab'));
|
||||
var panels = [].slice.call(root.querySelectorAll('.aksrt-fi__panel'));
|
||||
if (!tabs.length || !panels.length) return;
|
||||
function go(i) {
|
||||
tabs.forEach(function (t, idx) {
|
||||
t.classList.toggle('is-active', idx === i);
|
||||
});
|
||||
panels.forEach(function (p, idx) {
|
||||
p.classList.toggle('is-active', idx === i);
|
||||
var v = p.querySelector('video');
|
||||
if (!v) return;
|
||||
if (idx === i) {
|
||||
if (!v.getAttribute('src') && v.getAttribute('data-src')) {
|
||||
v.setAttribute('src', v.getAttribute('data-src'));
|
||||
}
|
||||
if (v.play) v.play().catch(function () {});
|
||||
} else if (v.pause) {
|
||||
v.pause();
|
||||
}
|
||||
});
|
||||
}
|
||||
tabs.forEach(function (t) {
|
||||
t.addEventListener('click', function () {
|
||||
go(parseInt(t.getAttribute('data-index') || '0', 10));
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function initFloatingQRCodes() {
|
||||
var wrap = document.querySelector('.float-right');
|
||||
if (!wrap) return;
|
||||
@@ -388,6 +423,7 @@
|
||||
initForumTabTopics();
|
||||
initProductTabs();
|
||||
initMainPostsLazy();
|
||||
initFeatureIntro();
|
||||
initFloatingQRCodes();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user