inherit
201938
0
Nov 11, 2013 3:31:26 GMT -8
Beedle
69
November 2013
kyprioth
|
Post by Beedle on Mar 14, 2021 6:18:31 GMT -8
Forum URL: landetimidten.proboards.com/I have four different tabs and I'd like if they could switch every x seconds. I'm sure there's a script for it, but I couldn't seem to find any. Also: Can you force the code not to switch, if a user is interacting specifically with the tabs? Or give them the option to pause the "slideshow" manually even? Our chatbox is in one of the tabs and it'd be super annoying if you were writing a response and suddenly you're forced to wait x seconds for the tab to pop back to the chat.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Mar 17, 2021 0:43:54 GMT -8
code (Global Footer):<script type="text/javascript"> /* Automate Header Tabs for landetimidten.proboards.com */ class TabWalker { constructor(tab_wrapper, speed_ms = 3500, options = { tabclass: '.tab', tabclick: 'label[for]', tabcontent: '.tab__content', input: '[name=tabgroup]', active: '>:checked', input_attribute: 'checked' }) {
if (tab_wrapper && tab_wrapper.querySelectorAll) { function settimer() { if (current >= tabs.length - 1) current = -1; $(tabs[current + 1]).trigger('click'); } const tabs = $(options.tabclass, tab_wrapper); const contents = $(options.tabcontent, tab_wrapper); let current = options.active ? parseInt(tabs.index(tabs.find(options.active).closest(options.tabclass)), 10) || 0 : 0; let timer = setTimeout(settimer, speed_ms); function event_tab_click() { tabs.each((i, tab) => { $(tab).on('click dblclick', (e) => { let i = tabs.index(tab); if (i >= tabs.length) i = 0;
switch (e.type) { case 'click': if (i > -1) { current = i; options.input && $(tab).find(options.input).prop(options.input_attribute, !0); if (!e.isTrigger) { timer && clearTimeout(timer); tabs.off('mouseenter mouseleave click'); } else { timer = setTimeout(settimer, speed_ms); } }; break; case 'dblclick': timer && clearTimeout(timer); tabs.off('mouseenter mouseleave click'); event_tab_click(); event_content_pause(); current = i; timer = setTimeout(settimer, speed_ms); } }); options.input && (tab.setAttribute('data-index', i)); }) }
function event_content_pause() { tabs.on('mouseenter mouseleave keydown focus', options.tabcontent, (e) => { switch (e.type) { case 'mouseleave': timer = setTimeout(settimer, speed_ms); break; case 'focus': case 'keydown': case 'mouseenter': clearTimeout(timer); } }); }
event_tab_click(); event_content_pause() } } } new TabWalker(document.querySelector('#tabaliciouswrapper'))
</script>
|
|
inherit
201938
0
Nov 11, 2013 3:31:26 GMT -8
Beedle
69
November 2013
kyprioth
|
Post by Beedle on Mar 17, 2021 3:22:44 GMT -8
It's beautiful. Thank you, Chris.
|
|