-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathjquery.yaselect.min.js
3 lines (3 loc) · 1.21 KB
/
jquery.yaselect.min.js
1
2
3
jQuery.fn.yaselect=function(e){e=e||{};return this.each(function(k,f){var a=jQuery(f).css({position:"absolute",top:0,left:0,zIndex:1}).addClass("yaselect-select"),c=jQuery('<div class="yaselect-wrap" tabindex="0"><div class="yaselect-current"></div></div>'),d=c.wrap('<div class="yaselect-anchor" style="position:relative;"></div>').parent(),j=function(){d.toggleClass("yaselect-open",a.is(":visible"))},g=function(){return a.find("option:nth("+(f.selectedIndex||0)+")").text()},h=c.find(".yaselect-current").text(g()),
i=function(b){a.blur();h.text(g());a.css({top:c.outerHeight()});b&&c.focus()};if(e.hoverOnly||window.navigator&&navigator.userAgent.match(/iphone|ipod|ipad/i))return a.before(d).css({opacity:0.0010}).change(function(){h.text(g())}).appendTo(d);a.before(d).keydown(function(b){if(b.which==13||b.which==32){b.preventDefault();i(true)}}).change(function(){h.text(g())}).blur(function(){a.hide();j()}).click(function(){if(a.is(":hidden")){a.show();j();setTimeout(function(){a.focus()})}else i(true)}).appendTo(d);
c.mousedown(function(){a.click()}).keydown(function(b){switch(b.which){case 13:case 32:case 37:case 38:case 39:case 40:b.preventDefault();a.click()}});f.size=Math.min(f.options.length,e.size||10);i()})};