A controller class for managing tabbed navigation within an Application instance.

See

Application

Param: config

The Tabs Configuration to use for this tabbed container

Example: Configure tab-control for a set of HTML elements

<!-- Example HTML -->
<nav class="tabs" data-group="primary-tabs">
<a class="item" data-tab="tab1" data-group="primary-tabs">Tab 1</li>
<a class="item" data-tab="tab2" data-group="primary-tabs">Tab 2</li>
</nav>

<section class="content">
<div class="tab" data-tab="tab1" data-group="primary-tabs">Content 1</div>
<div class="tab" data-tab="tab2" data-group="primary-tabs">Content 2</div>
</section>

Activate tab control in JavaScript

const tabs = new Tabs({navSelector: ".tabs", contentSelector: ".content", initial: "tab1"});
tabs.bind(html);

Properties

group: string

The name of the tabs group

active: string

The value of the active tab

callback: Function

A callback function to trigger when the tab is changed

_navSelector: string

The CSS selector used to target the tab navigation element

_nav: HTMLElement

A reference to the HTML navigation element the tab controller is bound to

_contentSelector: string

The CSS selector used to target the tab content element

_content: HTMLElement

A reference to the HTML container element of the tab content

Methods

  • Bind the Tabs controller to an HTML application

    Parameters

    • html: HTMLElement

    Returns void

  • Activate a new tab by name

    Parameters

    • tabName: string
    • triggerCallback: boolean = {}

    Returns void

  • Private

    Handle click events on the tab navigation entries

    Parameters

    • event: MouseEvent

      A left click event

    Returns void