-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselecttodatalist.min.js
More file actions
1 lines (1 loc) · 1.57 KB
/
selecttodatalist.min.js
File metadata and controls
1 lines (1 loc) · 1.57 KB
1
function select_tolist(){Q_select_show=!1,$("select").each(function(a,b){var c,d,e,f=$(b).children().length;return 20>f?null:(c=$(b).position(),d=$(b).css("width"),e={position:"absolute",top:c.top+22,left:c.left},$(b).css(e).hide().attr("size",20).attr("data-i",a).addClass("select_hide").prepend("<optgroup></optgroup>"),$('<input type="text" style="width:'+d+'" class="selecttolist" data-i='+a+' value="'+$(b).find("option:selected").text()+'"/><lable style="margin-left: -15px;">∇</lable>').insertBefore(b),void 0)}),$(".selecttolist").bind("keyup",function(){select_show($(this).attr("data-i"),this.value)}),$(".selecttolist").bind("blur",function(){setTimeout("select_hide("+$(this).attr("data-i")+")",200)}),$(".selecttolist").bind("focus",function(){var a=$.trim(this.value);"全部"==a&&($(this).val(""),a=""),select_show($(this).attr("data-i"),a)}),$(".select_hide").click(function(){var a=$(this).attr("data-i");Q_select_show=!1,select_hide(a),$(".selecttolist[data-i="+a+"]").val($(this).find("option:selected").text())}),$(".select_hide").focus(function(){Q_select_show=!0}),$(".select_hide").blur(function(){Q_select_show=!1,$(this).hide()})}function select_show(a,b){var c,d=$(".select_hide[data-i="+a+"]");return d.show().find("optgroup").html(""),b=$.trim(b),c=thisop=null,"全部"==b||""==b?null:(d.find("option:contains("+b+")").each(function(){thisop=$(this),c+="<option value='"+thisop.val()+"'>"+thisop.text()+"</option>"}),d.find("optgroup").html(c).show(),void 0)}function select_hide(a){0==Q_select_show&&$(".select_hide[data-i="+a+"]").hide()}$(function(){select_tolist()});