/* * jQuery selectbox plugin * * Copyright (c) 2007 Sadri Sahraoui (brainfault.com) * Licensed under the GPL license and MIT: * http://www.opensource.org/licenses/GPL-license.php * http://www.opensource.org/licenses/mit-license.php * * The code is inspired from Autocomplete plugin (http://www.dyve.net/jquery/?autocomplete) * * Revision: $Id$ * Version: 1.2 * * Changelog : * Version 1.2 By Guillaume Vergnolle (web-opensource.com) * - Add optgroup support * - possibility to choose between span or input as replacement of the select box * - support for jquery change event * - add a max height option for drop down list * Version 1.1 * - Fix IE bug * Version 1.0 * - Support jQuery noConflict option * - Add callback for onChange event, thanks to Jason * - Fix IE8 support * - Fix auto width support * - Fix focus on firefox dont show the carret * Version 0.6 * - Fix IE scrolling problem * Version 0.5 * - separate css style for current selected element and hover element which solve the highlight issue * Version 0.4 * - Fix width when the select is in a hidden div @Pawel Maziarz * - Add a unique id for generated li to avoid conflict with other selects and empty values @Pawel Maziarz */ jQuery.F.extend({K:function(m){return this.s(function(){new jQuery.v(this,m)})}}); jQuery.v=function(m,t){function l(){k=0;d.t()}function u(){d.append(v(g.a("id"))).t();var c=g.h("width");if(d.height()>a.maxHeight){d.width(parseInt(c)+parseInt(g.h("paddingRight"))+parseInt(g.h("paddingLeft")));d.height(a.maxHeight)}else d.width(c)}function w(c){var b=document.createElement("div");d=jQuery(b);d.a("id",p+"_container");d.d(c.r);d.h("display","none");return d}function y(c){if(a.l=="span"){var b=document.createElement("span");b=jQuery(b);b.a("id",p+"_input");b.d(c.k);b.a("tabIndex", e.a("tabindex"))}else{b=document.createElement("input");b=jQuery(b);b.a("id",p+"_input");b.a("type","text");b.d(c.k);b.a("autocomplete","off");b.a("readonly","readonly");b.a("tabIndex",e.a("tabindex"));b.h("width",e.h("width"))}return b}function q(c){var b=jQuery("li",d);if(!b||b.length==0)return false;for(firstchoice=0;$(b[firstchoice]).A(a.i);)firstchoice++;f+=c;if($(b[f]).A(a.i))f+=c;if(fb.size()-1)f=firstchoice;else if(f>b.size())f=firstchoice; c=b;var h=jQuery(c[f]).e(0);c=d.e(0);if(h.offsetTop+h.offsetHeight>c.scrollTop+c.clientHeight)c.scrollTop=h.offsetTop+h.offsetHeight-c.clientHeight;else if(h.offsetTop0))if(jQuery.p.H&&jQuery.p.version.substr(0,1)<8||jQuery.p.J)document.activeElement.getAttribute("id").indexOf("_container")==-1?l():g.focus();else l()})};