Tabs


Simple start

                    
                <div class="simpletabs">
                    <div class="nav">
                        <ul>
                            <li><a href="#tab1">HTML</a></li>
                            <li><a href="#tab2">JS</a></li>
                        </ul>
                    </div>
                    <div class="content">
                        <div data-name="tab1">... </div>
                        <div data-name="tab2">...</div>
                    </div>
                </div>
                                    
                
                                

                                    $('.simpletabs').tabs();

                                
                            

Slide animate

Set parameters by data-*="":

                    
                <div class="tabs" data-animation="slide">
                    <div class="nav">
                        <ul>
                            <li><a href="#tab1">HTML</a></li>
                            <li><a href="#tab2">JS</a></li>
                        </ul>
                    </div>
                    <div class="content">
                        <div data-name="tab1">... </div>
                        <div data-name="tab2">...</div>
                    </div>
                </div>
                                    
                
                                

                                    $('.simpletabs').tabs();

                                
                            

Set parameters via javascript:

                    
                <div class="tabs">
                    <div class="nav">
                        <ul>
                            <li><a href="#tab1">HTML</a></li>
                            <li><a href="#tab2">JS</a></li>
                        </ul>
                    </div>
                    <div class="content">
                        <div data-name="tab1">... </div>
                        <div data-name="tab2">...</div>
                    </div>
                </div>
                                    
                
                                

                                    $('.simpletabs').tabs({
                                        animation: 'slide'
                                    });

                                
                            

Position tab

                    
                <div  class="simpletabs" data-side="left"">
                    <div class="nav">
                        <ul>
                            <li><a href="#tab1">HTML</a></li>
                            <li><a href="#tab2">JS</a></li>
                        </ul>
                    </div>
                    <div class="content">
                        <div data-name="tab1">... </div>
                        <div data-name="tab2">...</div>
                    </div>
                </div>
                                    
                
                                

                                    $('.simpletabs').tabs();

                                
                            

Load tab content

                    
                <div class="simpletabs">
                    <div class="nav">
                        <ul>
                            <li><a href="#tab1">HTML</a></li>
                            <li><a href="#tab2">JS</a></li>
                        </ul>
                    </div>
                    <div class="content">
                        <div data-name="tab1">... </div>
                        <div data-name="tab2">...</div>
                    </div>
                </div>
                                    
                
                                

                                    $('.simpletabs').tabs();

                                
                            

Load tabs from json

Add/remove tabs

Add Remove #tab1


                                
                <div class="simpletabsadd">
                    <div class="nav">
                        <ul>
                            <li><a href="#tab1">HTML</a></li>
                            <li><a href="#tab2">JS</a></li>
                        </ul>
                    </div>
                    <div class="content">
                        <div data-name="tab1">... </div>
                        <div data-name="tab2">...</div>
                    </div>
                </div>
                                                
                            
                                
    var add = $('.simpletabsadd').tabs();

    $('.addTab').on('click', function(){
       add.add('name', '.....4');
    });

    $('.removeTab').on('click', function(){
       add.remove('tab1');
    });
                                
                            

Action button

                                
                <div class="exampleaction">
                    <div class="nav">
                        <ul>
                            <li><a href="#tab1">HTML</a></li>
                            <li><a href="#tab2">JS</a></li>
                        </ul>
                    </div>
                    <div class="content">
                        <div data-name="tab1">... </div>
                        <div data-name="tab2">...</div>
                    </div>
                </div>
                                                
                            
                                
                                        $('.exampleaction').tabs({
                                            'action-tab' : [
                                                {
                                                    name : '<i class="far fa-play-circle"></i> Action 1',
                                                    position : 1,
                                                    id : 'tab2',
                                                    insert : 'before',
                                                    action : function(e){
                                                        alert('insert before');
                                                    }
                                                },
                                                {
                                                    name : '<i class="far fa-play-circle"></i> Action 2',
                                                    position : 1,
                                                    id : 'tab2',
                                                    insert : 'after',
                                                    action : function(e){
                                                        alert('insert after');
                                                    }
                                                },
                                                {
                                                    name : '<i class="fas fa-plus-circle"></i> Add tab',
                                                    action : function(e){
                                                        e.add('new', 'content');
                                                    }
                                                }
                                            ]
                                        });
                                
                            



Options

main options

                    
            side : 'top',                        // show action maker - top/bottom/left/right
            json : false,                        // load full tab from json, url - string
            float-navigation : false,            // move navigation - true/false
            animation : 'none',                  // none/slide
            auto-height : false,                 // true/false
            action-tab : [{actionJson}]
                    
                

actionJson

                    
                        {
                            title : '',                     // tab title
                            position : 1,                   // index position
                            id : 'tab2',                    // id reference tab - priority before "position"
                            insert : 'after',               // relative insert tab - before/after
                            action : function(e){}          // function to run
                        }
                    
                

tab option

                    
            load-html : false,                   // load content from url
                    
                

Methods

                    
            add(name, content)
            remove(id)
            init()
            destroy()
                    
                

Licence

The MIT License

Copyright 2018 VeoLab.me

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.

Download

tabs.veo.zip