Giter Site home page Giter Site logo

jqm-inlinetabs's Introduction

jQuery Mobile InlineTabs Widget

by Michael Strobel

Licensed under the MIT License

Demo page: http://kryops.de/jqm/tabs/demo

About

The InlineTabs widget is an extension for the jQuery Mobile Framework.
It is targeted for web applications specifically desgined for tablet devices.

Usage

The InlineTabs widget requires the jQuery and jQuery Mobile libraries to be included (jQuery Mobile 1.3 required):

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>

The widget itself consists of one JavaScript and one CSS file. The JavaScript file has to be included after the files for jQuery and jQuery Mobile, the CSS file is best put in the <head> of the document.

<link rel="stylesheet" href="jqm-inlinetabs.min.css" />
<script src="jqm-inlinetabs.min.js"></script>

The widget is invoked with data-role="inlinetabs" on a container element.

The first child element of the container becomes the tab navigation. You can choose any element types you want, but unordered lists with <ul> and <li> are recommended.
All other child elements become the tabbed content. All but the active content element are hidden at page load.

The relationships between the tabs and their content elements are established with identical data-tab attributes.

<div data-role="inlinetabs">
	<ul>
		<li data-tab="1">First tab</li>
		<li data-tab="2">Second tab</li>
	</ul>
	
	<div data-tab="1">
		Content of Tab 1
	</div>
	
	<div data-tab="2">
		Content of Tab 2
	</div>
</div>

Options / data-attributes

Options for container element

data-theme
Set the theme for the tab bar background
Default: none

data-tab-theme
Set the theme for the tabs
Default: c

data-content-theme
Set the theme for the content area
Default: none

data-active-class
Set the class for the active tab
Default: jQuery Mobile default

data-mini="true"
The tabs are displayed smaller

data-scroll="true"
Activate touch/mousewheel scrolling behaviour for the tab bar.

With the default settings the tabs will wrap around if the screen is too small and occupy multiple lines. With touch scrolling activated, the tab bar is cut off on the right. The tabs can be scrolled by dragging the tab bar horizontally.

If you include the jQuery Mouse Wheel Plugin by Brandon Aaron, the tab bar will also be scrollable with the mouse wheel.

Options for tab elements

data-tab
Link to the corresponding content element, has to be identical there

data-active="true"
Marks the tab as active on page load

data-theme
Sets the theme for the tab, overwrites the data-tab-theme attribute of the container element
Default: inherited from container or c if container has none

data-icon
Adds an icon to the tab from the standard jQuery Mobile icon set (see here)

data-iconpos
Sets the position of the specified icon.
Possible values: left, right, top, bottom
Default: left

ui-disabled
By adding the CSS class ui-disabled to a tab element, it is displayed grey and has no functionality

Options for content elements

data-tab
Identifier, has to be identical to the data-tab attribute in the corresponding tab element

Other options

data-tab-ignore="true"
Leaves the element untouched at initialization. Useful for adding non-tab-elements to the tab bar.

Methods

.inlinetabs('refresh')
If you want to dynamically add tabs to the container, you have to call inlinetabs('refresh') on it afterwards to enhance the new markup.

.inlinetabs('show', 'tab-id')
Sets the active tab. The second parameter is the data-tab value of the tab that shall be activated.

Events

tab-show
Fired when the active tab changes. The event is fired both on the tab and on the content element

  • fired on the tab element before the content is changed
  • fired on the content element after it is set visible

Additional notes

If you leave white space between the tab elements in the source code, a blank will be inserted between the tabs. If you want to remove it without writing "ugly" HTML, you can add display:block; float:left to the CSS of the tab elements. Please note that this will break the touch scroll functionality!

jqm-inlinetabs's People

Contributors

kryops avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.