Tab Controlcomponent

Bring your tabs to life with a simple plugin to toggle between content via tabs. This component required metro-tab-control.js.

Definition

To make tabs tabbable, create a .tab-control with unique ID for every tab and wrap them in .frame.

First Tab

  1. <div class="tab-control" data-role="tab-control">
  2. <ul class="tabs">
  3. <li class="active"><a href="#_page_1">Tab 1</a></li>
  4. <li><a href="#_page_2">Other Tab</a></li>
  5. <li><a href="#_page_3"><i class="icon-rocket"></i></a></li>
  6. <li class="place-right"><a href="#_page_4"><i class="icon-cog"></i></a></li>
  7. </ul>
  8.  
  9. <div class="frames">
  10. <div class="frame" id="_page_1">...</div>
  11. <div class="frame" id="_page_2">...</div>
  12. <div class="frame" id="_page_3">...</div>
  13. </div>
  14. </div>

Tab in Tab

Now you can create tab control in tab control.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus quis mollis arcu. Nam nibh nisi, tincidunt non tristique ut, venenatis quis sapien. Proin at sagittis magna, non pharetra nisi.

Usage

To activate tab-control with data-api you can add attribute data-role="tab-control" to component.

  1. <div class="tab-control" data-role="tab-control">...</div>

Call tab control manually with:

  1. $('.tab-control').tabcontrol();

Tab content showing effect

You can add tab content showing effect with effect parameter.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus quis mollis arcu. Nam nibh nisi, tincidunt non tristique ut, venenatis quis sapien. Proin at sagittis magna, non pharetra nisi. Pellentesque consectetur tellus metus, in feugiat risus pulvinar ut. Suspendisse magna enim, ornare vitae augue non, elementum feugiat arcu.
Effect with data-api:
  1. <div class="tab-control" data-effect="fade[slide]">...</div>
Effect with javascript:
  1. $('.tab-control').tabcontrol({
  2. effect: 'fade' // or 'slide'
  3. });

Events

When tab switched, tab control triggered event change. You can bind this event to additional manipulating with tab content.

  1. $('.tab-control').tabcontrol().bind("tabcontrolchange", function(event, frame){...});
Click on tabs
  1. <script>
  2. $(function(){
  3. $("#tab-with-event").tabcontrol().bind("tabcontrolchange", function(event, frame){
  4. var id = $(frame).attr("id");
  5. $(frame).html("Show in time " + (new Date()).getTime() + " frame id:"+id);
  6. })
  7. })
  8. </script>