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

data-ws-hooks

v0.0.12

Published

Hooks html tags to js actions by using custom data attributes. Bootsratp style. Specifically useful for easily handling click events.

Downloads

1,870

Readme

Easily hook html to js

TL;DR

data-ws-onclick="foo"

It hooks between HTML tags and attributes to js functions or events.

See published npm package

Import:

  • Web: <script src="https://unpkg.com/data-ws-hooks/build/bundle.min.js"></script>
  • Node: npm i data-ws-hooks

How to use?

Important! This works if css defines class "hidden" as "display:none", as the hiding here works by toggling this class

- HTML Attributes

| Attribute | Note | Example | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------| | data-ws-onclick | When element is clicked - it will trigger one of the 3, in that order of precedence: - Fire an action, like hide all elements of class x. See list of actions later. - Fire a window.wsGlobals function - Fire a global window function. Supports nested functions by dot notation. | - <button data-ws-onclick="hideClass:popup">Close popup</button> - <button data-ws-onclick="signin">Sign In</button> | | data-ws-src | Sets a "src" attribute with its value as the "data-ws-src", so to lazy load src instead of blocking the user experience. | - <iframe data-ws-src="/embedded/feedback_form.html"/> | | data-ws-tab | Combined with the classes: "tab-selector", "tab-selector selected", "tab-section", "tab-section hidden" it gives a tab functionality. Important! Allows a single set of tabs per page! | <div><span class="tab-selector selected" data-ws-tab="tab1">Tab1</span><span class="tab-selector" data-ws-tab="tab2">Tab2</span></div> | | data-ws-toggle-hidden-data | Defines elements to be toggled 'hidden' class when a respective button is clicked. | <div data-ws-toggle-hidden-data='signin-dialog'>...</div> | | data-ws-toggle-hidden-button | When clicked, toggle 'hidden' class on all elements that share the value in their "data-ws-toggle-hidden-data" attribute. | <button data-ws-toggle-hidden-button='signin-dialog'>Sign In</button> |

- Built-in onclick actions

Run as: data-ws-onclick="some_action:optional_param"

| Actions | Note | Example | |-----------------------|------------------------------------------------------|----------------------------------------------------------------------------| | hideClass:some_class | Hide all elements of class some_class. | - <button data-ws-onclick="hideClass:popup">Close popup</button> | | copy: | Copy the value attribute of clicked element | - <input data-ws-onclick="copy" type:"text" value="this will be copied"/> | | copy:#some_element_id | Copy the value attribute of #some_element_id element | - <button data-ws-onclick="copy:#some_element_id" >Copy</button> |

Showcases

This is used on the following sites:

TODOs:

  • It sometimes hides by styling directly and sometimes by toggling "hidden" class. Inconsistent...
  • Allow more than a single set of tabs on page... Perhaps contain tabs in a parent...

How to contribute & publish updates to this package?

  • This package is published both on GitHub and on npmjs.
  • To publish an updated version - simply run npm publish, it will commit & push updates both to github and npm.