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

foundation-contextmenu

v0.0.9

Published

Context Menu plugin for Foundation 6.

Downloads

49

Readme

ContextMenu

Context Menu plugin for Foundation 6.

Usage

The plugin comes in two ways, one that depends on Foundation 6 and one that works as a standalone version by having the neccessary Foundation ressources packed.

To embed the Foundation dependend version of Context Menu into your page, you just need to include the CSS and the JS files right after the Foundation includes.

  <script src="foundation.contextMenu.js"></script>
  <link rel="stylesheet" type="text/css" href="foundation.contextMenu.css" />

When using the standalone version, just use the following snippet.

  <script src="solo.contextMenu.js"></script>
  <link rel="stylesheet" type="text/css" href="solo.contextMenu.css" />

To configure your menus, either render them in HTML following the Foundation menu structure, or use JavaScript to register different types of context menus.

  Foundation.ContextMenu.prototype.addConfig('listitem', {
    accessible: true,
    single: true,
    structure: [{
      text: 'Move to',
      help: 'Alt + M',
      key: 'ALT_M',  
      click: function($item) {
        alert('Moving item: ' + $item.attr('data-id'));
      }
    }, {
      icon: 'fa fa-paper-plane',
      text: 'Send via mail',  
      click: function($item) {
        alert('Sending a mail!');
      }
    }, {
      cssClass: 'divider'
    }, {
      text: 'More...',
      children: [{
        text: 'Delete'
      }, {
        text: 'Download...',
        children: [{
          text: 'Save as PDF'
        }, {
          text: 'Save as PNG'
        }]
      }]
    }]
  });

To add a context menu to one of your elements, e.g. elements within lists, simply add the data-context-menu attribute, having either a defined menu type or the reference to your rendered HTML list as a value.

  <!-- This li uses the JSON from the config for "listitem" and renders it as the context menu -->
  <li data-context-menu="listitem">
    First item here
  </li>
  <!-- This li uses the JSON from the config for "listitem" and renders it as the context menu -->
  <li data-context-menu="#menu">
    Second item here
  </li>

Make sure to initialize Foundation, whether you use the standalone version or not by calling

$(document).foundation();

and check out the Foundation installation page for more information on how to get started.

Accessibility

This plugin is partly accessible. To allow keyboard users to open the context menus, simply add the following buttons into your trigger elements. Elements having the data-context-menu-trigger attribute will trigger the context menu of their parent element when clicked.

  <li data-context-menu="#menu">
    Second item here
    <button data-context-menu-trigger class="button tiny show-on-focus pull-right">Open menu</button>
  </li>

Touch support

This plugin is also optimized for mobile and touch devices. You can toggle the context menu with a long-touch event, which duration can be adjusted in the plugin's options.

Installation

To install this plugin you can either directly download the files

or install it via NPM:

npm install foundation-contextmenu

In that case you can embed the files using:

  <script src="node_modules/foundation-contextmenu/dist/foundation.contextMenu.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="node_modules/foundation-contextmenu/dist/foundation.contextMenu.css" />

Demo

Test the Context Menu on your own at the demo page!

https://Owlbertz.github.io/ContextMenu/

Acknowledgments

As this project is a plugin for Foundation by ZURB, a big thanks for their stunning framework.

License

Context Menu is available under the MIT License.