Chico UI - Doc

v1.0.0

ch.Tabs

Description

Tabs lets you create tabs for static and dynamic content.

How-to

// Create a new Tabs.
var tabs = new ch.Tabs($el);
// Create a new Tabs with jQuery or Zepto.
var tabs = $(selector).Tabs();

Parameters

  • $el - jQuerySelector | ZeptoSelector : A jQuery or Zepto Selector to create an instance of ch.Tabs.

Extends

Properties

.$container jQuerySelector | ZeptoSelector

The tabs container.

.$panel jQuerySelector | ZeptoSelector

The container of tab panels.

.$triggers jQuerySelector | ZeptoSelector

The tabs triggers.

.tabpanels Array

A collection of tab panel.

.uid Number

A unique id to identify the instance of a widget.

.Widget#name String

The name of a widget.

// You can reach the instance associated.
var widget = $(selector).data(name);

Methods

.disable(tab) → {tabs}



    

Disables an instance of Tabs or a specific tab panel.

  • tab - Number : A given number of tab panel to disable.
// Disabling an instance of Tabs.
tabs.disable();
// Disabling the second tab panel.
tabs.disable(2);

.enable(tab) → {tabs}



    

Enables an instance of Tabs or a specific tab panel.

  • tab - Number : A given number of tab panel to enable.
// Enabling an instance of Tabs.
tabs.enable();
// Enabling the second tab panel of a tabs.
tabs.enable(2);

.emit(event, var_args)



    

Execute each item in the listener collection in order with the specified data.

  • event - String : The name of the event you want to emit.
  • var_args - Object : Data to pass to the listeners.
// Will emit the 'ready' event with 'param1' and 'param2' as arguments.
widget.emit('ready', 'param1', 'param2');

.getListeners(event) → {Array}



    

Returns all listeners from the collection for a specified event.

  • event - String : The event name.
// Returns listeners from 'ready' event.
widget.getListeners('ready');

.off(event, listener) → {Object}



    

Removes a listener from the collection for a specified event.

  • event - String : Event name.
  • listener - Function : Listener function.
// Will remove event listener to 'ready' event.
widget.off('ready', listener);

.on(event, listener, once)



    

Adds a listener to the collection for a specified event.

  • event - String : The event name to subscribe.
  • listener - Function : Listener function.
  • once - Boolean : Indicate if a listener function will be called only one time.
// Will add an event listener to 'ready' event.
widget.on('ready', listener);

.once(event, listener) → {Object}



    

Adds a listener to the collection for a specified event to will execute only once.

  • event - String : Event name.
  • listener - Function : Listener function.
// Will add an event handler to 'contentLoad' event once.
widget.once('contentLoad', listener);

.constructor()



    

Returns a reference to the constructor function.

.destroy()



    

Destroys a Tabs instance.

// Destroying an instance of Tabs.
tabs.destroy();

.getShown() → {Boolean}



    

Returns the number of the shown tab panel.

if (tabs.getShown() === 1) {
    fn();
}

.show(tab) → {tabs}



    

Shows a specific tab panel.

  • tab - Number : A given number of tab panel.
// Shows the second tab panel.
tabs.show(2);

.constructor()



    

Returns a reference to the constructor function.

.destroy()



    

Destroys an instance of Widget and remove its data from asociated element.

// Destroying an instance of Widget.
widget.destroy();

.disable() → {instance}



    

Disables an instance of Widget.

// Disabling an instance of Widget.
widget.disable();

.enable() → {instance}



    

Enables an instance of Widget.

// Enabling an instance of Widget.
widget.enable();

.require() → {instance}



    

Adds functionality or abilities from other classes.

// You can require some abilitiest to use in your widget.
// For example you should require the collpasible abitliy.
var widget = new Widget(element, options);
widget.require('Collapsible');

Events

'destroy'



    

Emits when a widget is destroyed.

// Subscribe to "destroy" event.
widget.on('destroy', function () {
 // Some code here!
});

'disable'



    

Emits when a widget is disable.

// Subscribe to "disable" event.
widget.on('disable', function () {
 // Some code here!
});

'enable'



    

Emits when a widget is enable.

// Subscribe to "enable" event.
widget.on('enable', function () {
 // Some code here!
});

'ready'



    

Emits the event 'ready' when the widget is ready to use.

// Subscribe to "ready" event.
tabs.on('ready',function () {
    this.show();
});

'show'



    

Event emitted when the tabs shows a tab panel container.

// Subscribe to "show" event.
tabs.on('show', function (shownTabPanel) {
 // Some code here!
});

'show'



    

Event emitted when the tabs shows a tab panel container.

// Subscribe to "show" event.
tabs.on('show', function (shownTab) {
 // Some code here!
});