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

wuibuttonbehavior

v0.2.0

Published

Generic button WizUI behavior

Downloads

4

Readme

wuiButtonBehavior

Circle CI

What it is

wuiButtonBehavior is a behavior made for WizUI. It behaves like an HTML5 button would be expected to. Setting the behavior to a WuiDom would make it able to listen for various events.

wuiButtonBehavior will attach methods and events to the WuiDom element;

var button = new WuiDom('div');
wuiButtonBehavior(button);

See the full example at the end of the file

Methods

enable

The enable method can be called to enable tap interaction.

function Button() {
    WuiDom.call(this);
    wuiButtonBehavior(this);
}

disable

The disable method can be called to prevent tap interaction on the element.

button.disable();

tap

The tap method will trigger the a successful cycle of tap events.

Events

tap

This event occurs when a successful tap by the user happened. Most likely used to trigger action.

tapstart

This event occurs when the user first presses the WuiDom. Most likely used for design purpose.

tapend

This event occurs when the user release the WuiDom he was pressing or when the tap got cancelled. It receives a boolean as parameter which will be set to true if the tap has been cancelled. Most likely used for design purpose.

enabled

The enabled event is called when the tap behavior is enabled, such as by the enable method.

disabled

The disabled event is called when the tap behavior is disabled, such as by the disable method.

How to use

See the example below:

var inherits = require('util').inherits;
var WuiDom = require('WuiDom');
var wuiButtonBehavior = require('wuiButtonBehavior');

function Button(label) {
    WuiDom.call(this, 'div', { text: label, className: 'button' });
    wuiButtonBehavior(this);

    this.on('tapstart', function () {
        this.addClassNames('pressed');
    });

    this.on('tapend', function () {
        this.delClassNames('pressed');
    });

    this.on('disabled', function () {
        this.addClassNames('disabled');
    });

    this.on('enabled', function () {
        this.delClassNames('disabled');
    });
}

inherits(Button, WuiDom);

var button = new Button('My Button');

button.on('tap', function () {
    doSomething();
});