npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dcjqaccordion

v2.7.1

Published

NPM version of dcjqaccordion

Downloads

593

Readme

Installation

Install with Bower: bower install dcjqaccordion.

Overview

The plugin takes standard html nested lists and turns them into vertical accordion menus.

Some features include:

  • Ability to handle any number of levels
  • Select either “click” or “hover” event
  • State saving using cookies
  • Set sub-menus to auto-expand on page load based on CSS class
  • Allow all sub-menus to be expanded or auto-close open sub-menus
  • Disable parent links
  • Add count of number of child links
  • Uses the jquery cookie plugin by Klaus Hartl for saving the menu state and the hoverIntent plugin by Brian Cherne if the “hover” event is selected.

## Quick Start

1. Create a HTML Nested List

<ul id="accordion" class="menu">
    <li><a href="#">Home</a></li>
    <li>
        <a href="#">Products</a>
        <ul>
            <li>
                <a href="#">Mobile Phones &#038; Accessories</a>
                <ul>
                    <li><a href="#">Product 1</a></li>
                    <li><a href="#">Product 2</a></li>
                    <li><a href="#">Product 3</a></li>
                </ul>
            </li>
            <li>
                <a href="#">Desktop</a>
                <ul>
                    <li><a href="#">Product 4</a></li>
                    <li><a href="#">Product 5</a></li>
                    <li><a href="#">Product 6</a></li>
                    <li><a href="#">Product 7</a></li>
                    <li><a href="#">Product 8</a></li>
                    <li><a href="#">Product 9</a></li>
                </ul>
            </li>
            <li>
                <a href="#">Laptop</a>
                <ul>
                    <li><a href="#">Product 10</a></li>
                    <li><a href="#">Product 11</a></li>
                    <li><a href="#">Product 12</a></li>
                    <li><a href="#">Product 13</a></li>
                </ul>
            </li>
            <li>
                <a href="#">Accessories</a>
                <ul>
                    <li><a href="#">Product 14</a></li>
                    <li><a href="#">Product 15</a></li>
                </ul>
            </li>
            <li><a href="#">Software</a>
                <ul>
                    <li><a href="#">Product 16</a></li>
                    <li><a href="#">Product 17</a></li>
                    <li><a href="#">Product 18</a></li>
                    <li><a href="#">Product 19</a></li>
                </ul>
            </li>
        </ul>
    </li>
    <li>
        <a href="#">Sale</a>
        <ul>
            <li><a href="#">Special Offers</a>
        <ul>
            <li><a href="#">Offer 1</a></li>
            <li><a href="#">Offer 2</a></li>
            <li><a href="#">Offer 3</a></li>
        </ul>
    </li>
    <li>
        <a href="#">Reduced Price</a>
        <ul>
            <li><a href="#">Offer 4</a></li>
            <li><a href="#">Offer 5</a></li>
            <li><a href="#">Offer 6</a></li>
            <li><a href="#">Offer 7</a></li>
        </ul>
    </li>
    <li>
        <a href="#">Clearance Items</a>
        <ul>
            <li><a href="#">Offer 9</a></li>
        </ul>
    </li>
    <li class="menu-item-129">
        <a href="#">Ex-Stock</a>
        <ul>
            <li><a href="#">Offer 10</a></li>
            <li><a href="#">Offer 11</a></li>
            <li><a href="#">Offer 12</a></li>
            <li><a href="#">Offer 13</a></li>
        </ul>
    </li>
    <li>
        <a href="#">About Us</a>
        <ul>
            <li><a href="#">About Page 1</a></li>
            <li><a href="#">About Page 2</a></li>
        </ul>
    </li>
    <li>
        <a href="#">Services</a>
        <ul>
            <li>
                <a href="#">Service 1</a>
                <ul>
                    <li><a href="#">Service Detail A</a></li>
                    <li><a href="#">Service Detail B</a></li>
                </ul>
            </li>
            <li>
                <a href="#">Service 2</a>
                <ul>
                    <li><a href="#">Service Detail C</a></li>
                </ul>
            </li>
            <li>
                <a href="#">Service 3</a>
                <ul>
                    <li><a href="#">Service Detail D</a></li>
                    <li><a href="#">Service Detail E</a></li>
                    <li><a href="#">Service Detail F</a></li>
                </ul>
            </li>
            <li><a href="#">Service 4</a></li>
        </ul>
    </li>
    <li><a href="#">Contact us</a></li>
</ul>

2. Include The jQuery Vertical Accordion Menu Plugin

Add the jQuery plugin to the head of your document – also add the cookie plugin and hoverIntent plugin if required:

<script type='text/javascript' src='js/jquery.cookie.js'></script>
<script type='text/javascript' src='js/jquery.hoverIntent.minified.js'></script>
<script type='text/javascript' src='js/jquery.dcjqaccordion.2.7.min.js'></script>

3. Vertical Accordion CSS

The plugin doesn’t require any essential CSS styling in order to create the vertical accordion effect and will create the menu from any standard list. One benefit of this is that in the event that the users browser does not have javascript enabled the menu will still be available.

See the jQuery vertical accordion menu examples page for samples skins.

4. Initialise The Vertical Accordion Menu

The menu can be quickly and easily initialised using the default options by adding the following code to the head of your document:

jQuery(document).ready(function($) {
    jQuery('#accordion').dcAccordion();
});

For more information on changing the menu settings refer to the Options page.

Options

Plugin Defaults

The jQuery vertical accordion menu plugin defaults are:

$.fn.dcAccordion = function(options) {
    //set default options
    var defaults = {
        classParent : 'dcjq-parent',         //Class of parent menu item
        classActive : 'active',              // Class of active parent link
        classArrow  : 'dcjq-icon',           // Class of span tag for parent arrows
        classCount  : 'dcjq-count',          // Class of span tag containing count (if addCount: true)
        classExpand : 'dcjq-current-parent', // Class of parent li tag for auto-expand option
        eventType   : 'click',               // Event for activating menu - options are "click" or "hover"
        hoverDelay  : 300,                   // Hover delay for hoverIntent plugin
        menuClose   : true,                  // If set "true" with event "hover" menu will close fully when mouseout
        autoClose   : true,                  // If set to "true" only one sub-menu open at any time
        autoExpand  : false,                 // If set to "true" all sub-menus of parent tags with class 'classExpand' will expand on page load
        speed       : 'slow',                // Speed of animation
        saveState   : true,                  // Save menu state using cookies
        disableLink : true,                  // Disable all links of parent items
        showCount   : true,                  // If "true" will add a count of the number of links under each parent menu item
        cookie      : 'dcjq-accordion'       // Sets the cookie name for saving menu state - each menu instance on a single page requires a unique cookie name.
};

Overiding Default Options

All of the default options can be overidden by passing an object into the Vertical Accordion Menu method upon initialisation – e.g:

$('#accordion').dcAccordion({
        eventType   : 'hover',
        hoverDelay  : 600,
        menuClose   : false,
        autoClose   : false,
        autoExpand  : true,
        classExpand : 'parent-item',
        speed       : 'fast',
        cookie      : 'my-cookie'
});