jquery.ui.dropdownchecklist optgroup
Testing optgroups
by litespeedtdf
HTML
<div id="jContainer" style="height: 200px;">
<select id="selCategory" name="selCategory" multiple="multiple" class="ddcl"></select>
</div>
<button id="test">test</button>
CSS
.ui-dropdownchecklist
{
height: 20px;
border: 1px solid #ddd;
border-right: 0;
background: #fff url("Images/dropdown.png") no-repeat center right;
}
.ui-dropdownchecklist-hover, .ui-dropdownchecklist-active
{
background-image:url("../content/images/dropdown_hover.png");
border-color: #5794bf;
}
/** Minimal stand-alone css for dropdownchecklist support
We highly recommend using JQuery ThemeRoller instead
*/
.ui-dropdownchecklist-selector {
height: 20px;
border: 1px solid #ddd;
background: #fff;
}
.ui-state-hover, .ui-state-active {
border-color: #5794bf;
}
.ui-dropdownchecklist-dropcontainer {
background-color: #fff;
border: 1px solid #999;
}
.ui-dropdownchecklist-item {
}
.ui-state-hover {
background-color: #39f;
}
.ui-state-disabled label {
color: #ccc;
}
.ui-dropdownchecklist-group {
font-weight: bold;
font-style: italic;
}
.ui-dropdownchecklist-indent {
padding-left: 20px;
}
/* Font size of 0 on the -selector and an explicit medium on -text required to eliminate
descender problems within the containers and still have a valid size for the text */
.ui-dropdownchecklist-selector-wrapper {
vertical-align: middle;
font-size: 0px;
}
.ui-dropdownchecklist-selector {
padding: 1px 2px 2px 2px;
font-size: 0px;
}
.ui-dropdownchecklist-text {
font-size: medium;
/* line-height: 20px; */
}
.ui-dropdownchecklist-group {
padding: 1px 2px 2px 2px;
}
JavaScript
(function($) {
/*
* ui.dropdownchecklist
*
* Copyright (c) 2008-2010 Adrian Tosca, Copyright (c) 2010-2011 Ittrium LLC
* Dual licensed under the MIT (MIT-LICENSE.txt) OR GPL (GPL-LICENSE.txt) licenses.
*
*/
// The dropdown check list jQuery plugin transforms a regular select html element into a dropdown check list.
$.widget("ui.dropdownchecklist", {
// Some globlals
// $.ui.dropdownchecklist.gLastOpened - keeps track of last opened dropdowncheck list so we can close it
// $.ui.dropdownchecklist.gIDCounter - simple counter to provide a unique ID as needed
version: function() {
alert('DropDownCheckList v1.4');
},
// Creates the drop container that keeps the items and appends it to the document
_appendDropContainer: function(controlItem) {
var wrapper = $("<div/>");
// the container is wrapped in a div
wrapper.addClass("ui-dropdownchecklist ui-dropdownchecklist-dropcontainer-wrapper");
wrapper.addClass("ui-widget");
// assign an id
wrapper.attr("id", controlItem.attr("id") + '-ddw');
// initially positioned way off screen to prevent it from displaying
// NOTE absolute position to enable width/height calculation
wrapper.css({
position: 'absolute',
left: "-33000px",
top: "-33000px"
});
var container = $("<div/>"); // the actual container
container.addClass("ui-dropdownchecklist-dropcontainer ui-widget-content");
container.css("overflow-y", "auto");
wrapper.append(container);
// insert the dropdown after the master control to try to keep the tab order intact
// if you just add it to the end, tabbing out of the drop down takes focus off the page
// @todo 22Sept2010 - check if size calculation is thrown off if the parent of the
// selector is hidden. We may need to add it to the end of the document here,
// calculate the size, and then move it back into proper position???
...