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.formelements

v0.0.9

Published

jQuery plugin to easily customize radio buttons, checkboxes and select elements

Downloads

26

Readme

#jQuery Formelements

jQuery plugin to easily customize radio buttons, checkboxes and select elements

Formelements gives a reliable way to customize the appearence and functionality of radio buttons, checkboxes and select elements.

Refer to the demo folder for examples.

###Note

This used to be a privately used project but has by request been shared publicly, which means that a major cleanup will be needed, especially in the documentation and demo section.

###Setup

Just include jquery.formelements.js after jQuery and add the formelements_base.css

####Standard

<script src='jquery.js'></script>
<script src='jquery.formelements.js'></script>
<link href="formelements_base.css" rel="stylesheet" type="text/css" />
<script src='jquery.js'></script>
<script src='jquery.formelements.js'></script>
<link href="formelements_base.css" rel="stylesheet" type="text/css" />

####NPM $ npm install --save jquery.formelements

var $ = jQuery = require('jquery');
require('jquery.formelements');

###Usage

Code needs to be run after the elements are created ( and updated if changed )

$(function(){
	$('input[type="checkbox"], input[type="radio"], select').formelements();
});

###Available Options

$('element').formelements({
	'classlist': "formelements_item my_custom_class"
});
{
	// For all elements
	'classlist': "formelements_item",
	
	// For select only
	'sel_multiselect_control': false,
	'sel_tinyscroll': false,
	'sel_searchbar': false,
	'sel_searchbar_focus': true,
	'text_search_placeholder': "Search...",
	'sel_delegate_click': false,
	'sel_label': function( $li, $input, index ) {},
	'sel_open': function( e, dd ) {
		dd.optwrap.not( ".open" ).fadeIn( 200, function() {
			if( dd.settings.sel_searchbar_focus ) {
				$( this ).find( 'input' ).focus();
			}
		});
		dd.optwrap.addClass( "open" );
		dd.wrap.addClass( "open" );
	},
	'sel_close': function( e, dd ) {
		dd.optwrap.fadeOut( 200, function() {
			dd.optwrap.removeClass( "open" );
			dd.wrap.removeClass( "open" );
		});
	},
	'search_function': function( search, $el ) {
		var text = $el.text();
	
		// hide the item if it is a placeholder, or if the searchvalue is not in its text
		if( $el.hasClass( 'placeholder' ) || text.toLowerCase().indexOf( search.toLowerCase() ) === -1 ) {
			return 0;
		}
		return 1;
	},
	'render_display': function() {
		var $select = $(this);
		var $display = $select.closest('.formelements_select').find('.formelements_select_display');
		var $opts = $select.formelements('selected');
	
		var labels = [];
		$opts.each(function(){
			labels.push( $(this).text() );
		});
	
		$display.html(labels.join(', '));
	}
}

Option | ----------------------- | ----------------------- classlist | sel_multiselect_control | sel_tinyscroll | sel_searchbar | sel_searchbar_focus | text_search_placeholder | sel_delegate_click | sel_label | sel_open | sel_close |
search_function |
render_display |

###Available Methods

Method | Explanation ----------------------- | ----------------------- destroy | Destroys the formelement object, reverting the element to the native form disable | Disables the dropdown, disallowing clicks and changes and applies the class .formelements_disabled to the wrapper enable | Enables the dropdown after disabling it updateScroll | Update the tinyscrollbar height if used refresh | Recreates the dropdown, usefull if the options are re-populated selected | Returns the selected option elements settings | Returns an object containing the current options