Giter VIP home page Giter VIP logo

panelgroup's Introduction

panelGroup

panelGroup is a jQuery plugin for creating simple tabs and accordions. But here's the real kicker, you can turn your tabs into accordions. The intended use of this feature is for responsive sites where tabs might become less usable at smaller screen sizes.

Use

For simplest use, just call .panelGroup() on your elements.

$('.panel-group').panelGroup();

The following markup is assumed:

<div class="panel-group" data-group-type="accordion">
  <div class="item">
    <h4 class="item-header">Item 1</h4>
    <div class="item-content">
      <p>Item content</p>
    </div><!-- .item-content -->
  </div><!-- .panel-group-item -->
  <div class="item">
    <h4 class="item-header">Item 2</h4>
    <div class="item-content">
    <p>Item content</p>
    </div><!-- .item-content -->
  </div><!-- .panel-group-item -->
  <div class="item">
    <h4 class="item-header">Item 3</h4>
    <div class="item-content">
    <p>Item content</p>
    </div><!-- .item-content -->
  </div><!-- .panel-group-item -->
</div><!-- .panel-group -->

A class of item for each tab/accordion item.item-header and item-content are used for the header and content. These can be changed in the options section though.

data-group-type

Note that the group type (accordion/tabs), is specified in a data-group-type attribute on the containing element.

Options

The following options are available, with defaults indicated:

type: "auto", // options: tabs, accordion, auto (reads data attribute)
defaultType: 'tabs', // incase in invalid data attribute is provided
selectors: { // customize the classes used in markup
    item: '.item',
    header: '.item-header',
    content: '.item-content'
  },
accordionSpeed: 300, // The animation speed of opening/collapsing accordion items
firstAccordionOpen: true, // Whether or not the first accordion item should be open
onlyKeepOneOpen: true //If Accordion should collapse all other '.active' items on open

Methods for changing types (used for responsive)

Methods are provided to turn tabs into accordions, and then to turn tabs back into tabs.

  • tabsToAccordions turns tabs into accordions
  • tabsBackToTabs turns tabs back into tabs after they've been turned into accordions

Methods are called by passing in the method name as follows:

$('.panel-group').panelGroup('tabsToAccordions');

The inteded use here is you use Harvey.js or enquire.js to call tabsToAccordions at your small breakpoint, and then tabsBackToTabs once you leave that breakpoint again.

panelgroup's People

Contributors

nmwd avatar reubenmoes avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

lancejanocha

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.