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

boost-js-collapse

v0.0.1

Published

A style-free and accessible collapse plugin for jQuery and Boost JS

Downloads

7

Readme

Boost JS Collapse Build Status

A style-free and accessible collapse plugin for jQuery and Boost JS. While other plugins style everything for you, this plugin only handles the functionality, leaving the layout and styling up to you.

Installation

Install with npm:

npm install boost-js-collapse

Install in browser:

<script src="https://cdn.rawgit.com/marksmccann/boost-js-collapse/v0.0.1/dist/collapse.min.js"></script>

Usage

Create Plugin

var boost = require('boost-js');
// var boost = $.fn.boost; (browser install)

var collapse = require('boost-js-collapse');
// var collapse = $.fn.boost.collapse; (browser install)

$.fn.collapse = boost( collapse.plugin, collapse.defaults );

Markup Structure

<div id="collapse">
    <a href="#drawer1" data-bind="#collapse" data-role="handle">Handle 1</a>
    <div id="drawer1" data-bind="#collapse" data-role="drawer">Drawer 1</div>
    <a href="#drawer2" data-bind="#collapse" data-role="handle">Handle 2</a>
    <div id="drawer2" data-bind="#collapse" data-role="drawer">Drawer 2</div>
</div>

Note: data-bind is used to link the element to the instance, data-role is used to define the element's role in that instance. See Boost JS for more details.

Instantiate Plugin

$('#collapse').collapse();

Options

Name | Default | Description --- | --- | --- accordian | false | when true, will only open one drawer at a time activeClass | "is-open" | the class added to handle and drawer when active onOpen | null | a callback function called when any drawer opens onClose | null | a callback function called when any drawer closes onInit | null | a callback function called when plugin is intialized

Usage

$('#collapse').collapse({
	onInit: function() {
    	console.log( this.id ); // 'collapse'
    }
});

- or -

<div id="collapse" data-accordian="true">...</div>

API

openDrawer( 'drawerID', callback )

Open a drawer by providing the desired panel's id. Optional callback function called after opening. If drawer is already open, callback will not be run.

instance.openDrawer( 'drawer2', function(){
    console.log("Drawer 2 is now open.");
});

closeDrawer( 'drawerID', callback )

Close a drawer by providing the desired drawer's id. Optional callback function called after closing. If drawer is already closed, callback will not be run.

instance.closeDrawer( 'drawer2', function(){
    console.log("Drawer 2 is now closed.");
});

toggleDrawer( 'drawerID', callback )

Will toggle a given drawer open or close. Optional callback function called whether opened or closed.

instance.toggleDrawer( 'drawer2' );

drawerIsOpen( 'drawerID', callback )

Determine whether a given drawer is open or not.

instance.drawerIsOpen( 'drawer2' ); // true or false

activeDrawers

The ids of the currently active drawers in an array

instance.activeDrawers // [ drawer1, drawer2 ... ]

pairsByDrawer

Each handle and corresponding drawer grouped into a jquery object and organized by drawer id.

instance.pairsByDrawer // { drawer1: $( 0:handle1, 1:drawer1 ), ... }

Running Tests

$ npm install && npm test

License

Copyright © 2016, Mark McCann. Released under the MIT license.