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

jquery.input

v0.1.0

Published

A Common interface for html input elements.

Downloads

4

Readme

#jquery.input ##A normalized interface for html input elements.

jquery.input exposes a unified interface for interacting with html input elements. You can call the methods on specific input elements $('input[name="foo"]').inputVal('bar'); groups of radio buttons or checkboxes, or non input elements that contain input elements $('.input-container').inputVal({ name: 'bar' }).

##Methods

###inputVal "inputVal" works similarly to how jQuery's val method works.

Calling "inputVal" without a parameter gets the inputs value.

var data = $input.inputVal();

Calling "inputVal" with a parameter sets the inputs value.

$input.inputVal('foo');

"inputVal" sets and gets inputs with string, with the exception of checkboxes, multiple select's and multiple file inputs. These elements are get set with arrays (since they can hold multiple values). Note that file inputs cannot be set, and its get value will be the name of its selected file.

// checks checkboxes with values 'a' and 'c', all other checkboxes are unchecked.
$checkboxGroup.inputVal(['a', 'c']);

If "inputVal" is called on an element that is not an input, the selected element's children will be searched for all input elements with name attributes.

<div class="container">
    <input type="text" name="text-input" value="foo">

    <select name="multiple-select-input" multiple>
        <option value="a" selected>A</option>
        <option value="b" selected>B</option>
    </select>

    <!-- not found, since this element doesn't have a name attribute -->
    <input type="checkbox" value="b">
</div>
// get returns containing input values that have name attributes as an object
// where the keys are the names of the inputs, and the values are the inputs
// values.
$('.container').inputVal();
// in this example will return
// {
//     'text-input': 'foo',
//     'multiple-select-input': ['a', 'b']
// }

// set a container by passing an object whose keys are the names attributes
// of the input to set.
$('.container').inputVal({
    'text-input': 'bar',
    'multiple-select-input': ['a']
});

###inputOnChange Detect changes on input attributes. Binds to "change", "keyup", and "keydown" events for text, and text like inputs (textarea, password, etc.) and to the "change" event for other inputs. "inputOnChange" will only be fired if the value has actually changed since the last time the "inputOnChange" callback was fired. This allows the extra responsiveness of binding to both keyup, and keydown, without firing the "inputOnChange" callback more often then necessary.

$input.inputOnChange(function (e) {
    console.log('input has changed', $(this).inputVal());
});

"inputOnChange" may also be called on a an element containing multiple named html input elements. In this case, the "inputOnChange" callback will be fired if any of the inputs change. The value of "this" will be bound to the html element that has changed. (Note that if a group of checkboxes or radio buttons are called, the value of "this" will be the individual input whose value has changed, not the group)

$('.container').inputOnChange(function (e) {
   console.log('input has changed', $(this).attr('name'));
});

###inputEnable/inputDisable May be called on an individual input element or a container of input elements

// equivalent to $input.prop('disabled', true);
$input.inputDisable();

// disables all named form inputs in the containing div
$('.container').inputDisable();

//inputEnable is analogous to inputDisable
$('.container').inputEnable();

###inputClear Clears the input's value. May be called on an individual element or a container of input elements

$input.inputClear();