(function($){ function hideoptions(speed){ if(speed.data){speed=speed.data} if($(document).data("nowselectoptions")) { $($(document).data("nowselectoptions")).slideup(speed); $($(document).data("nowselectoptions")).prev("div").removeclass("tag_select_open"); $(document).data("nowselectoptions",null); $(document).unbind("click",hideoptions); $(document).unbind("keyup",hideoptionsonesckey); } } function hideoptionsonesckey(e){ var myevent = e || window.event; var keycode = myevent.keycode; if(keycode==27)hideoptions(e.data); } function showoptions(speed){ $(document).bind("click",speed,hideoptions); $(document).bind("keyup",speed,hideoptionsonesckey); $($(document).data("nowselectoptions")).slidedown(speed); $($(document).data("nowselectoptions")).prev("div").addclass("tag_select_open"); } $.fn.selectcss=function(_speed){ $(this).each(function(){ var speed=_speed||"fast"; if($(this).data("cssobj")){ $($(this).data("cssobj")).remove(); } $(this).hide(); var divselect = $("
").insertafter(this).addclass("tag_select"); $(this).data("cssobj",divselect); var divoptions = $("").insertafter(divselect).addclass("tag_options").hide(); divselect.click(function(e){ if($($(document).data("nowselectoptions")).get(0) != $(this).next("ul").get(0)){ hideoptions(speed); } if(!$(this).next("ul").is(":visible")) { e.stoppropagation(); $(document).data("nowselectoptions",$(this).next("ul")); showoptions(speed); } }); divselect.hover(function(){ $(this).addclass("tag_select_hover"); } , function(){ $(this).removeclass("tag_select_hover"); }); $(this).change(function(){ $(this).nextall("ul").children("li:eq("+ $(this)[0].selectedindex +")").addclass("open_selected").siblings().removeclass("open_selected"); $(this).next("div").html($(this).children("option:eq("+ $(this)[0].selectedindex +")").text()); }); $(this).children("option").each(function(i){ var lioption= $("
  • ").html($(this).text()).attr("title",$(this).attr("title")).appendto(divoptions); if($(this).attr("selected")){ lioption.addclass("open_selected"); divselect.html($(this).text()); } lioption.data("option",this); lioption.click(function(){ lioption.data("option").selected=true; $(lioption.data("option")).trigger("change",true) }); lioption.hover( function(){$(this).addclass("open_hover");}, function(){ $(this).removeclass("open_hover"); } ); }); }); } })(jquery);