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

@wponion/dependon

v2.0.5

Published

A jQuery plugin to facilitate the handling of form field dependencies.

Downloads

13

Readme

WPOnion DependsOn

A jQuery plugin to facilitate the handling of form field dependencies.

$( subject ).WPOnion_dependsOn( dependencySet, [options] );

Examples

Demo

Installation

with npm

npm install --save @wponion/jquery-depends-on

Download directly

Latest Release

Build from source

git clone https://github.com/wponion/dependsOn.git
cd dependsOn
npm install
gulp

# --> dist/wponion-dependsOn.js

Usage

Include jQuery (requires v1.7 or higher)

<script type="text/javascript" src="jquery/jquery-1.7.2.min.js"></script>

Include dependsOn

<script type="text/javascript" src="wponion-dependsOn.js"></script>

Add form components

<form id="myForm">
	<label for="myCheck">Check Me</label>
	<input type="checkbox" id="myCheck">

	<label for="myText">Input</label>
	<input type="text" id="myText" value="">
</form>

Activate plugin

$('#myText').WPOnion_dependsOn({
	// The selector for the depenency
	'#myCheck': {
		// The dependency qualifiers
		enabled: true,
		checked: true
	}
});

Qualifiers

|Qualifiers|Description|Alias| |----------|-----------|-----| | enabled| (Boolean) If true, then dependency must not have the "disabled" attribute.|| | checked | (Boolean) If true, then dependency must not have the "checked" attribute. Used for checkboxes only. || | values| (Array/String) Dependency value must equal one of the provided values. if provided value is array. if provided value is string then it must match.| = , == , === , equals , OR , or , \|\|| | not_equals| (String) Dependency value must not match.| != , !== , !=== , !equals| | empty| Dependency value must be empty.|'' , "" , EMPTY| | not_empty| Dependency value must not be empty.|!'' , !"" , !empty , !EMPTY| | not| (Array) Dependency value must not equal any of the provided values.| | | match| (RegEx) Dependency value must match the regular expression.| | | notMatch| (RegEx) Dependency value must not match the regular expression.|| | contains| (Array) One of the provided values must be contained in an array of dependency values. Used for select fields with the "multiple" attribute.|in , IN , has , HAS| | email| (Boolean) If true, dependency value must match an email address.|| | url| (Boolean) If true, Dependency value must match an URL.|| | range| (Array) Dependency value must be within the given range.|| | gt| (Int) Dependency value must be greater than given value.| > | | gte| (Int) Dependency value must be greater than given or equal value.| >= | | lt| (Int) Dependency value must be lesser than given value.| < | | lte| (Int) Dependency value must be lesser than given or equal value.| <= | | Custom| (Function) Custom function which return true or false.||

Options

| Option Name | Description | Default | | ----------- | ----------- | ------- | |disable | (Boolean) Add "disabled" attribute to the subject's form field. | true | |readonly | (Boolean) Add "readonly" attribute to the subject's form field.| false | |hide | (Boolean) Hide the subject on disable and reveal the subject on enable.| true | |duration | (Number) The time in milliseconds for the fade transition. Used only if hide is set to true| 200 | |trigger | (String) The event used to check dependencies.| 'change' | |onEnable | (Function) The callback function to execute when the subject has been enabled| - | |onDisable | (Function) The callback function to execute when the subject has been disabled.| - | |valueOnEnable | (String) The value to set the subject to when enabled.| - | |valueOnDisable | (String) The value to set the subject to when disabled.| - | |checkOnEnable | (Boolean) If true, "checked" attribute will be added to subject when enabled. If false, "checked" attribute will be removed from subject when enabled. For checkboxes and radio buttons.| - | |checkOnDisable | (Boolean) If true, "checked" attribute will be added to subject when disabled. If false, "checked" attribute will be removed from subject when disabled. For checkboxes and radio buttons.| - | |valueTarget | (String) jQuery selector for the object to you want to target for editing the value. Use if you want to alter the value of something other than the subject.| - | |toggleClass | (String) The class you wish to be appended to the subject when enabled. The class will be removed when the subject is disabled.| - |

Callbacks

When the onEnable and onDisable callbacks are called, this is set to the last triggered dependency, and the function is passed two arguments:

  • e: The triggering event object
  • $subject: The jQuery object of the subject

Other Libraries

License

This project is licensed under MIT. See the LICENSE file for more info.

Backed By

| DigitalOcean | JetBrains | Tidio Chat | | --- | --- | --- |