- if you want ES5 support you have to use babel or browserify with babelify extension
- Nested tabs
- Lazy load
- No dependencies
- ES2015 support (use babel)
if you need IE9 support, it should work (i didn't test yet) with classList polyfill
npm i -S future-tabs
bower i -S future-tabs
group tabs with tabs
block, internal structure does not matter
<div class="tabs">
<div class="tabs__toggle tabs__toggle_active">tab 1</div>
<div class="tabs__toggle">tab 2</div>
<div class="tabs__tab">tab 1 content</div>
<div class="tabs__tab">tab 2 content</div>
</div>
<div class="tabs">
<div class="tabs__toggle tabs__toggle_active">tab 1</div>
<div class="tabs__toggle">tab 2</div>
<div class="tabs__tab">tab 1 content</div>
<div class="tabs__tab" data-src="path/to/contentToBeLoaded">preloader</div>
</div>
import initTabs from 'future-tabs';
initTabs('.tabs');
or
initTabs({
selector: '.tabs',
blockClassName: 'tabs' //optional
})
import {Tabs} from 'future-tabs';
const tabs = new Tabs(document.querySelector('.tabs'));
or
import {Tabs} from 'future-tabs';
const tabsDiv = document.getElementById('someCustomId');
new Tabs(tabsDiv, 'tabs'); // 'tabs' here is _bem block class name
const tabs = new Tabs(DOMElement);
tabs.destroy();
if you want to init again just do
tabs.init();
If you don't use commonjs build system (like browserify or webpack) you should add this before script
<script>
var module = {exports: {}};
var exports = module.exports;
</script>
gulp
- tests
- add destroy method #5
- add nested tabs
- xhr error output to console
- add lazy load
- block class name (prefix) can be set
- you are welcome to use it and contribute