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

lintel-contrib-dropdowns

v0.1.5

Published

Dropdowns for lintel.

Downloads

14

Readme

lintel-contrib-dropdowns

Dropdowns for lintel.

npm Bower

Getting Started

This module requires Lintel.

If you haven't used Lintel before, be sure to check out the Getting Started guide, as it explains how to install and use this module. Once you're familiar with that process, you may install this module with this command:

bower install lintel-contrib-dropdowns --save

Once the module has been installed, you will have to load it in your main SASS file:

@import "bower_components/lintel-contrib-dropdowns/sass/dropdowns.scss"

This module also includes a JavaScript component, which you will have to load separately.

<script src="bower_components/lintel-contrib-dropdowns/dist/dropdowns.min.js" type="text/javascript"></script>

You can use wiredep or grunt-wiredep to automatically inject files in your build process.

Variables

Check the vars file in the sass folder to see the full list of variables you can customize.

$dropdown-*

Variables relating to the dropdown list.

$dropdown-item-*

Variables relating to individual items (<a>s).

$dropdown-divider-*

Variables related to the dropdown divider.

JavaScript

Options

Name | Type | Default | Description --------- | ------------------------------ | ------------------- | ----------- onShow | function | | Callback function to execute every time dropdown is shown. onHide | function | | Callback function to execute every time dropdown is hidden. esc | boolean | true | Close modal on escape key.

Methods

Name | Description --------- | ----------- toggle | Toggle dropdown. show | Show dropdown. hide | Hide modal.

Events

Event | Description -------------------- | ------------------------------ show.lt.dropdown | Fires immediately before dropdown is shown. Can prevent dropdown from showing here. shown.lt.dropdown | Fires immediately after dropdown is shown. hide.lt.dropdown | Fires immediately before dropdown is hidden. Can prevent dropdown from hiding here. hidden.lt.dropdown | Fires immediately after dropdown is hidden.

Data-attr

Add data-toggle="dropdown" to the .btn-dropdown-toggle. You can add additional options as data-attributes.

<div class="btn-group">
  <button class="btn btn-dropdown-toggle" data-toggle="dropdown" type="button" aria-haspopup="true" aria-expanded="false">
    Dropdown
    <span class="btn-caret" aria-hidden="true"></span>
  </button>
  <ul class="dropdown" role="menu">
    ...
  </ul>
</div>

jQuery

Call the jQuery plugin on the modal, passing in any options and the related target (button).

var options = {
  onShow: function(menu, button) {
    console.log('onShow', this, menu, button);
  },
  onHide: function(menu, button) {
    console.log('onHide', this, menu, button);
  },
  esc: false
};

$('#myButton').click(function(e) {
  $(this).dropdown(options);  // this == #myButton
});

Alternatively, you can use the default options:

$('#myButton').click(function(e) {
  $(this).dropdown('toggle'); // this == #myButton
});

Examples

Single Dropdown

<div class="btn-group">
  <button class="btn btn-dropdown-toggle" type="button" aria-expanded="false">
    Dropdown
    <span class="btn-caret" aria-hidden="true"></span>
  </button>
  <ul class="dropdown" role="menu">
    <li><a href="#">Action 1</a></li>
    <li><a href="#">Action 2</a></li>
    <li><a href="#">Action 3</a></li>
  </ul>
</div>

Split Dropdown

<div class="btn-group">
  <button class="btn" type="button" aria-expanded="false">Split Dropdown</button>
  <button class="btn btn-dropdown-toggle" type="button" aria-label="More Options"><span class="btn-caret" aria-hidden="true"></span></button>
  <ul class="dropdown" role="menu">
    <li><a href="#">Action 1</a></li>
    <li><a href="#">Action 2</a></li>
    <li><a href="#">Action 3</a></li>
    <li class="dropdown-divider"></li>
    <li><a href="#">Alt Action 1</a></li>
  </ul>
</div>

Open Dropdown

The javascript component of this library will take care of the .open and aria-expanded property.

<div class="btn-group open">
  <button class="btn btn-dropdown-toggle" type="button" aria-expanded="true">...</button>
  ...
</div>

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

License

Copyright (c) 2015 Marius Craciunoiu. Licensed under the MIT license.