Skip to content

actualreports/jQuery-Selectric

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

#jQuery Selectric ϟ

jQuery Selectric is a jQuery plugin designed to help at stylizing and manipulating HTML selects.

##How to use:

Make sure to include jQuery in your page:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

Include jQuery Selectric:

<script src="js/jquery.selectric.min.js"></script>

Put styles in your CSS and change it to your taste :D

/* Selectric */
.selectricWrapper { position: relative; margin: 0 0 10px; }
.selectricWrapper.selectricOpen { z-index: 9999; }
.selectricHideSelect { position: relative; overflow: hidden; }
.selectricHideSelect select { position: absolute; left: -100%; }
.selectric { border: 1px solid #CCC; background: #F0F0F0; width: 300px; position: relative; -moz-border-radius: 2px; -webkit-border-radius: 2px; border-radius: 2px; cursor: pointer; line-height: 16px; }
.selectricOpen .selectric { border: 1px solid #999; background: #E8E8E8; z-index: 9999; }
.selectric .label { display: block; white-space: nowrap; overflow: hidden; margin: 0 30px 0 0; padding: 5px 0 5px 5px; font-size: 13px; }
.selectric .label span { background: #09F; color: #FFF; }
.selectric span.button { position: absolute; right: 2px; top: 2px; font-size: 9px; line-height: 22px; height: 22px; width: 23px; -moz-border-radius: 2px; -webkit-border-radius: 2px; border-radius: 2px; color: #FFF; text-align: center; background: #A7C7DC; }
.hover span.button { background: #85B2D3; }

/* Items box */
.selectricItems ul,
.selectricItems li { list-style: none; padding: 0; margin: 0; min-height: 20px; font-size: 13px; }
.selectricItems { display: none; position: absolute; overflow: auto; top: 100%; left: 0; background: #F0F0F0; border: 1px solid #CCC; z-index: 9998; }
.selectricItems li { padding: 5px; cursor: pointer; display: block; border-bottom: 1px solid #DFDFDF; }
.selectricItems li + li { border-top: 1px solid #FFF; }
.selectricItems li.selected { background: #888; color: #F0F0F0; }
.selectricItems li:hover { background: #999; color: #F0F0F0; }

Initialize jQuery Selectric:

<script>
$(function(){
	$('select').selectric();
});
</script>

##Options:

Option Default Type Description
onOpen function() {} Function Function called when select options is opened
onClose function() {} Function Function called when select options is closed
maxHeight 300 Integer Maximum height options box can be
keySearchTimeout 500 Integer After this time without pressing any key, the search string is reseted
highlight true Boolean Highlight searched string in label
arrowButtonMarkup <span class="button">&#9660;</span> String [HTML] Markup for open options button
disableOnMobile true Boolean Initialize plugin on mobile browsers
margin 5 Integer Minimum space between opened options and window
bindSufix .sl String Bind events namespace

##Public methods:

$('select').selectric('refresh'); // Reconstruct the instance of plugin
$('select').selectric('destroy'); // Destroy Selectric and go back to normal
$('select').selectric('open'); // Open options
$('select').selectric('close'); // Close options

##Browser support:

  • Firefox
  • Chrome
  • Safari
  • Internet Explorer 7+
  • Opera

About

jQuery plugin for easy manipulation and customization of HTML selects

Resources

Stars

Watchers

Forks

Packages

No packages published