Dynamic tabs component with add, remove and order support.
May not works in ie < 9
component install chemzqm/tabs
or
npm install tab-component
<div id="tabs">
<ul class="tabs-header">
<li>tab1</li>
</ul>
<div class="tabs-body">
<div>
body
</div>
</div>
</div>
tabs-header
and tabs-body
is requried classes for header and body
var Tabs = require('tabs')
var parentNode = document.getElementById('tabs')
var tabs = new Tabs(parentNode)
tabs.closable()
tabs.sortable()
active
emitted with activated nav elementsort
emitted when the tabs get reorderedempty
emitted when all tabs removedremove
emitted with remove header and body
Init tabs inside parentNode and optional opts
, direct children of tabs-header
and tabs-body
matches selector are used as header item and body items
opts.headerSelector
selector for header item defaultli
opts.bodySelector
selector for body items defaultdiv
Add close icon to the tab navs to make the tabs closable.
Make the tab navs sortable
Add a tab with title and content (could be string of element)
Active the tab by css query(querySelector inside) or tab element.
Unbind all event handlers, including sort, click
Copyright (c) 2015 [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.