Skip to content

reinos/jquery-selectBox

 
 

Repository files navigation

jQuery selectBox

	A cosmetic, styleable replacement for SELECT elements.

	Homepage:  http:https://abeautifulsite.net/blog/2011/01/jquery-selectbox-plugin/
	Demo:      http:https://labs.abeautifulsite.dev/jquery-selectBox/

	Copyright 2012 Cory LaViska for A Beautiful Site, LLC.

Features:

	- Supports OPTGROUPS
	- Supports standard dropdown controls
	- Supports multi-select controls (i.e. multiple="multiple")
	- Supports inline controls (i.e. size="5")
	- Fully accessible via keyboard
	- Shift + click (or shift + enter) to select a range of options in multi-select controls
	- Type to search when the control has focus
	- Auto-height based on the size attribute (to use, omit the height property in your CSS!)
	- Tested in IE7-IE9, Firefox 3-4, recent WebKit browsers, and Opera


License:

	Licensed under both the MIT license and the GNU GPLv2 (same as jQuery: http:https://jquery.org/license)


Usage:

	Link to the JS file:

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

	Add the CSS file (or append contents to your own stylesheet):

		<link href="jquery.selectbox.min.css" rel="stylesheet" type="text/css" />

	To create:

		$("SELECT").selectBox([settings]);


Settings:

	To specify settings, use this syntax: $("SELECT").selectBox('settings', { settingName: value, ... });

		menuTransition: ['default', 'slide', 'fade'] - the show/hide transition for dropdown menus
		menuSpeed: [integer, 'slow', 'normal', 'fast'] - the show/hide transition speed
		loopOptions: [boolean] - flag to allow arrow keys to loop through options


Methods:

	To call a method use this syntax: $("SELECT").selectBox('methodName', [options]);

		create - Creates the control (default method)
		destroy - Destroys the selectBox control and reverts back to the original form control
		disable - Disables the control (i.e. disabled="disabled")
		enable - Enables the control
		value - if passed with a value, sets the control to that value; otherwise returns the current value
		options - pass in either a string of HTML or a JSON object to replace the existing options
		control - returns the selectBox control element (an anchor tag) for working with directly
		refresh - updates the selectBox control's options based on the original controls options


Events:

	Events are fired on the original select element. You can bind events like this:

		$("SELECT").selectBox().change( function() { alert( $(this).val() ); } );

		focus - Fired when the control gains focus
		blur - Fired when the control loses focus
		change - Fired when the value of a control changes


Change Log:

	v1.0.0 (2011-04-03) - Complete rewrite with added support for inline and multi-select controls
	v1.0.1 (2011-04-04) - Fixed options method so it doesn't destroy/recreate the control when called.
	                    - Added a check for iOS devices (their native controls are much better for
	                      touch-based devices; you can still use selectBox API methods for theme)
	                    - Fixed issue where IE window would lose focus on XP
	                    - Fixed premature selection issue in Webkit browsers
	v1.0.2 (2011-04-13) - Fixed auto-height for inline controls when control is invisible on load
	                    - Removed auto-width for dropdown and inline controls; now relies 100% on CSS
	                      for setting the width
	                   	- Added 'control' method for working directly with the selectBox control
	v1.0.3 (2011-04-22) - Fixed bug in value method that errored if the control didn't exist
	v1.0.4 (2011-04-22) - Fixed bug where controls without any options would render with incorrect heights
	v1.0.5 (2011-04-22) - Removed 'tick' image in lieu of background colors to indicate selection
	                    - Clicking no longer toggles selected/unselected in multi-selects; use CTRL/CMD and
	                      SHIFT like in normal browser controls
	                    - Fixed bug where inline controls would not receive focus unless tabbed into
	v1.0.6 (2011-04-29) - Fixed bug where inline controls could be "dragged" when selecting an empty area
	v1.0.7 (2011-05-18) - Expanded iOS check to include Android devices as well
	                    - Added autoWidth option; set to false on init to use CSS widths for dropdown menus
	v1.0.8 (2011-12-29) - Added refresh method (contributed by xjamundx)
	                    - Hide menus when window is resized or scrolled (#9)
	                    - Fixed autoWidth data issue (#13)
	                    - SelectBox now gains focus when associated label is clicked
	                    - Dropdown now inherits classes from original control (suffixed by -selectBox-dropdown-menu)
	                    - Fixed meta/ctrl key issue (#41)
	                    - Expanded iOS/Android check to include Windows 7 Phone and BlackBerry
	v1.0.9 (2012-01-04) - Dropdown label class now syncs with selected option's class(es)
	v1.1.0 (2012-01-06) - Removed autoWidth option; control now inherits the size of the original select element


Known Issues:

	- The blur and focus callbacks are not very reliable in IE7. The change callback works fine.

About

A jQuery plugin for replacing <select> elements.

Resources

Stars

Watchers

Forks

Packages

No packages published