1. About
  2. Docs
  3. Examples
  4. Download
  5. Contact

FlyTabs version 1.0

FlyTabs is a jQuery plugin that allows tabs to be created in on-the-fly programatically. As of this writing all tabbing plugins require for the user to hardcode the HTML associated with the tabs onto the HTML page where it is used. Enters FlyTabs.

Why the name?

Primarily the name comes from the purpose of this plugin. One can create tabs on-the-fly. That, and the slang definition of "fly". Soon you will see how fly this plugin really is. This is also how I came up with my mean little fly mascot - notice how the wings are like two tabs.

Usage

It is fairly easy to learn FlyTabs. So much that one can pick it up merely by looking at the examples. In it's simplest form, it would be something like this:
  <script>
  $(document).ready(function() {

    $('#flytabs1').flyTabs.addTab();

  });
  </script>
  <ul id="flytabs1"></ul>
How much simpler could it get? FlyTabs has its own namespace as to not override any other plugins' methods that may bear the same name. It is therefore important to notice that one will always call FlyTabs methods using this syntax
    $(selector).flyTabs.method(options);
This is for your own good, so FlyTabs can co-exist with any other plugin you might want to use this plugin. In case you wonder how complex the configuration could get, the following will hopefully do the trick for you:
  $(document).ready(function() {

    $('#flytabs2').flyTabs.config({
                                   align: 'left',
                                   html: 'This would be a welcome screen',
                                   effect: 'no'
                                  }); 

    $('#flytabs2').flyTabs.addTab({ 
                                   icon: 'images.jpeg',
                                   caption: 'Second Tab',
                                   status: 'pinned',
                                   html: '<ul id="flytabs3"></ul>',
                                   code: function() { 
                                                     $('#flytabs3').flyTabs.config({align: 'left'});
                                                     $('#flytabs3').flyTabs.addTab({
                                                        caption: 'Kill the fly',
                                                        html: 'Splatch'
                                                      });
                                                     $('#flytabs3').flyTabs.addTab({
                                                        caption: 'Onion Soup',
                                                        html: 'Yum!',
                                                        icon: 'images.jpeg', 
                                                        code: function () { alert('Hi!') }
                                                      });
                                                    }
                                 });


  });
As is obvious, even a complex example is quite simple to follow. Notice how we can use the code and html directives together to dynamically add more tabs on-the-fly!

Design

FlyTabs attempts to make it easy to use, and therefore stresses that everything be optional - or at best as much as possible. This section will walk you through explaining the moving parts of FlyTabs.
  1. Hook
    This is the only HTML tag that needs to be inserted, or hardcoded, into the HTML document*. This will tell FlyTabs where you would like to insert the tabs on-the-fly.
  2. Config
    This configures the tabs. Tabs is the overall collection or grouping of all the individual tabs that belong to one common group. Notice how this is defined as the plural form: Tabs.
  3. Methods
    Finally there are the actual methods that will execute a particular action. A Tab is an individual tab. Notice how this is defined as the singular form: Tab. Methods generally deal with one tab at a time, though there are exceptions.
* Even this is not entirely true, since one could effectively create even that on-the-fly.

Hooks

A hook is just a <ul> tag that indicates the location where you would like the tabs to be inserted. A hook would simply look like this:
  <ul id="flytabs1"></ul>
Yes, it would just be an empty tag. Nothing more. Just that. That's right. The only condition is that it has an id of some sort. Be kind and give it a logical name. The name will be used internally, and this will be your jQuery selector! This means that to work with these particular tabs, you would call it jQuery-style as such:
  $("#flytabs1").flytabs.method()
Hooks can have any CSS formatting you desire, any spacing, any attributes, the only attribute FlyTabs cares about is the id.

Directives

This is the section that explains the various directives or options to the various moving parts of FlyTabs.

Config

    $('#flytabs2').flyTabs.config({
                                   align: 'left',
                                   effect: 'no',
                                   html: 'This can be HTML. <blink>SERIOUSLY!</blink>'
                                  }); 

Methods

addTab

Add a tab dynamically to the tabs group as per the jQuery selector.
    $(selector).flyTabs.addTab({
                                caption: 'My New Tab',
                                code: function(){ alert('hi') },
                                html: 'This can be any content including HTML',
                                icon: 'http://www.adamovsky.com/flytabs/icon.gif',
                                id: 'tabId',
                                index: 4,
                                status: 'off',
                                url: 'http://www.adamovsky.com/flytabs/'
                               });   
All options are optional!

clearTabs

Resets all tabs to an off status. This will in effect flush any states the tabs may have.
  $(selector).flyTabs.clearTabs();  
No arguments or options.

countTabs

Counts all the tabs that are in a tabs group as defined by the jQuery selector. Returns the number of items.
  $(selector).flyTabs.countTabs(); 
No arguments or options.

getTab

Pulls up the actual tab content of the specified tab.
  $(selector).flyTabs.getTab(3); 

pinTab

Pins the tab to appear as though it was clicked.
  $(selector).flyTabs.pinTab({
                              index: 3
                             }); 

removeTab

Removes a certain tab from the tabs.
  $(selector).flyTabs.removeTab({
                                 index: 3
                                }); 

That's It!

If you like it, let me know that you use it so I can add a link to you. I'm always appreciative of questions, comments, and ideas for future releases.

Milan Adamovsky created this.