New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zebra_accordion

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zebra_accordion

A tiny, easily configurable, fully customizable, cross-browser accordion jQuery plugin

  • 1.2.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by266.67%
Maintainers
1
Weekly downloads
 
Created
Source
zebrajs

Zebra_Accordion

A tiny (3 KB minified, 1.3KB gzipped), easily configurable, fully customizable, cross-browser accordion jQuery plugin

npm Total Monthly License

Zebra_Accordion is a tiny (3KB minified, ~1.3KB gzipped) accordion plugin for jQuery. It transforms a basic definition list, without requiring any specific markup, into a small-footprint, easily configurable, fully customizable, cross-browser accordion widget, useful for better organizing larger groups of content.

Support the development of this project

Donate

Features

  • no additional markup required other than a basic definition list
  • no default style allowing you to fully customize it to suit your needs
  • works with responsive layouts
  • allows for a single expanded tab at a time, or for any number of tabs to be expanded/collapsed
  • allows for tabs to expand on mouse over, not just on click
  • if an expanded tab's content is not in the viewport it automatically scrolls the browser window so that the content is visible
  • callback functions can be used for further customizations
  • works in all major browsers (Firefox, Opera, Safari, Chrome, Internet Explorer 6+)

Requirements

Zebra_Accordion has no dependencies other than jQuery 1.7.0+

Installation

Zebra_Accordion is available as a npm package. To install it use:

npm install zebra_accordion

Zebra_Accordion is also available as a Bower package. To install it use:

bower install zebra_accordion

How to use

First, load jQuery from a CDN and provide a fallback to a local source like:

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script>window.jQuery || document.write('<script src="path/to/jquery-3.2.1.js"><\/script>')</script>

Load the Zebra_Accordion jQuery plugin:

<script src="path/to/zebra_accordion.min.js"></script>

Alternatively, you can load Zebra_Accordion from JSDelivr CDN like this:

<!-- for the most recent version -->
<script src="https://cdn.jsdelivr.net/gh/stefangabos/Zebra_Accordion/dist/zebra_accordion.min.js"></script>

<!-- for a specific version -->
<script src="https://cdn.jsdelivr.net/gh/stefangabos/Zebra_Accordion@1.2.5/dist/zebra_accordion.min.js"></script>

<!-- replacing "min" with "src" will serve you the non-compressed version -->

Load the style sheet file from a local source

<link rel="stylesheet" href="path/to/zebra_accordion.min.css">

...or from JSDelivr CDN

<!-- for the most recent version -->
<link rel="stylesheet" href=="https://cdn.jsdelivr.net/gh/stefangabos/Zebra_Accordion/dist/zebra_accordion.min.css">

<!-- for a specific version -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/stefangabos/Zebra_Accordion@1.2.5/dist/zebra_accordion.min.css">

<!-- replacing "min" with "src" will serve you the non-compressed version -->

You need a basic definition list for your HTML markup

Don't forget to add the Zebra_Accordion class to the list container! If you haven't had a look, all it does is to set display:hidden the all the tabs and add cursor:pointer to titles, so it will not add too much to your CSS.

<dl class="Zebra_Accordion">
    <dt>Lorem ipsum dolor sit amet consectetuer</dt>
    <dd>
        Lorem ipsum dolor sit amet consectetuer facilisis lacinia sapien ac et.
        Quis hendrerit neque congue pretium iaculis justo laoreet orci elit condimentum.
        Eros natoque Curabitur accumsan eget quis porttitor Sed Vestibulum amet sed.
    </dd>
    <dt>Lorem ipsum dolor sit amet consectetuer</dt>
    <dd>
        Lorem ipsum dolor sit amet consectetuer facilisis lacinia sapien ac et.
        Quis hendrerit neque congue pretium iaculis justo laoreet orci elit condimentum.
        Eros natoque Curabitur accumsan eget quis porttitor Sed Vestibulum amet sed.
    </dd>
    <dt>Lorem ipsum dolor sit amet consectetuer</dt>
    <dd>
        Lorem ipsum dolor sit amet consectetuer facilisis lacinia sapien ac et.
        Quis hendrerit neque congue pretium iaculis justo laoreet orci elit condimentum.
        Eros natoque Curabitur accumsan eget quis porttitor Sed Vestibulum amet sed.
    </dd>
    <dt>Lorem ipsum dolor sit amet consectetuer</dt>
    <dd>
        Lorem ipsum dolor sit amet consectetuer facilisis lacinia sapien ac et.
        Quis hendrerit neque congue pretium iaculis justo laoreet orci elit condimentum.
        Eros natoque Curabitur accumsan eget quis porttitor Sed Vestibulum amet sed.
    </dd>
</dl>

Now, within the DOM-ready event do

$(document).ready(function() {
    new $.Zebra_Accordion($('.Zebra_Accordion'));
});

Configuration options

Properties

PropertyTypeDefaultDescription
animate_opacitybooleanTRUEShould a tab's opacity be also animated when expanding/collapsing?
collapsiblemixedFALSE - when set to TRUE it indicates that all tabs can be collapsed
- if set to FALSE, an expanded tab can be collapsed only by expanding another tab
- if set to 0, the behavior is the same when set to FALSE with the difference that an open tab can also be closed.
expanded_classstringZebra_Accordion_Expanded The name of the class to append to an expanded tab's associated title element.
Use it to customize the aspect of expanded tabs.
hide_speedinteger400 The speed (in milliseconds) to use when collapsing a tab.
scroll_speedinteger600 If an tab's content is not entirely visible once it is expanded, the browser window will be scrolled so that the entire content is visible (if is possible).
This value represents the speed (in milliseconds) used for scrolling browser window to the right position.
show_speedinteger400 The speed (in milliseconds) to use when expanding a tab.
showmixed0 The index (0 based) of the tab to be expanded by default.
The value of this property can also be boolean FALSE, indicating that all tabs should be collapsed by default.
If the value of the collapsible property is TRUE, the value of this property can also be boolean TRUE, indicating that all tabs should be expanded by default. In this case, you can also provide an array of indexes to be expanded by default.
toggle_on_mouseoverbooleanFALSE Set this to TRUE if tabs should be expanded when hovering the mouse over their associated titles.

If the collapsible property is TRUE, this property will always be considered as FALSE!

Events

EventDescription
onBeforeClose Event fired before a tab is collapsed
The callback function takes 3 arguments:
  • the tab's position in the accordion (0 based)
  • the associated title element, as a jQuery object
  • the tab, as a jQuery object
onBeforeOpen Event fired before a tab is expanded
The callback function takes 3 arguments:
  • the tab's position in the accordion (0 based)
  • the associated title element, as a jQuery object
  • the tab, as a jQuery object
onClose Event fired after a tab is collapsed
The callback function takes 3 arguments:
  • the tab's position in the accordion (0 based)
  • the associated title element, as a jQuery object
  • the tab, as a jQuery object
onOpen Event fired after a tab is collapsed
The callback function takes 3 arguments:
  • the tab's position in the accordion (0 based)
  • the associated title element, as a jQuery object
  • the tab, as a jQuery object

Methods

show(index, [noFx = FALSE], [noScroll = FALSE])

Expands a tab.

Arguments

index - the 0-based index of the tab to expand

noFx - (optional) - if set to TRUE, the tab will be instantly expanded without animation.

Default is FALSE.

noScroll - (optional) - if set to TRUE, the browser window will not be scrolled to the newly expanded tab.

Default is FALSE.

var myAccordion = new $.Zebra_Accordion($('#accordion'));

// expand the third tab
myAccordion.show(2);

hide(index, [noFx = FALSE])

Expands a tab.

Arguments

index - the 0-based index of the tab to collapse

noFx - (optional) - if set to TRUE, the tab will be instantly collapsed without animation.

Default is FALSE.

var myAccordion = new $.Zebra_Accordion($('#accordion'));

// collapse the first tab
myAccordion.hide(0);

Demo

See the demos

Keywords

FAQs

Package last updated on 13 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc