1 |
- UI.extend.htmlSelect=function(a){var b={type:this.getAttribute("type")||1,skip:this.getAttribute("skip")||"orange"},b=$.extend(b,a),e=$(this).find("option").first(),g=$(this).find("option"),c="";a="";"orange"==b.skip&&(a="_orange");switch(parseInt(b.type)){case 1:c="";for(b=1;b<g.length;b++){var d=g.eq(b),f="",l="";$.each(d[0].attributes,function(){/^(onclick|class)$/.test(this.name)||(f+=" "+this.name+"\x3d'"+this.value+"'")});d.attr("checked")&&(f+=' class\x3d"checked"',l="sure_icon_on");c+="\x3cli "+f+'\x3e\x3ca href\x3d"javascript:void(0)"\x3e'+d.html()+'\x3ci class\x3d"icon_skin sure_icon '+l+'"\x3e\x3c/i\x3e\x3c/a\x3e\x3c/li\x3e'}var c='\x3cspan click style\x3d"cursor:pointer;width:100%;"\x3e'+e.html()+'\x3c/span\x3e\x3ci class\x3d"icon_skin show_select_arrow'+a+'" click\x3e\x3c/i\x3e\t\x3cdiv class\x3d"show_listbox'+a+'" style\x3d"display:none;"\x3e\t\t\x3cul\x3e'+c+"\t\t\x3c/ul\x3e\t\x3c/div\x3e",e=$(this).parent(),h=this.onchange,g=this.id;a=this.name;$(this).replaceWith("\x3cdiv class\x3d'htmlSelect' id\x3d'"+g+"' name\x3d'"+a+"' type\x3d'1'\x3e"+c+"\x3c/div\x3e");var k=e.find("[click]");k.mousedown(function(){$("ul[type\x3d2]").hide();return!1}).click(function(){var a=$(this).nextAll(".show_listbox");a.toggle(150);$(window).height()-20<a.offset().top+a.height()&&a.css("top",-a.height()-5)}).next().find("li").click(function(){this.className=$(this).find("i").toggleClass("sure_icon_on").hasClass("sure_icon_on")?"checked":"";h&&h.call(this)});break;case 2:c="";for(b=1;b<g.length;b++)d=g.eq(b),f="",$.each(d[0].attributes,function(){/^(onclick|class)$/.test(this.name)||(f+=" "+this.name+"\x3d'"+this.value+"'")}),d.attr("onclick")&&(f+=' onclick\x3d"this.ismousedown\x3dtrue;'+d.attr("onclick")+';"'),c+="\x3cli "+f+"\x3e"+d.html()+"\x3c/li\x3e";g=this.id||"";c='\x3cdiv class\x3d"select_box'+a.substring(1)+'"\x3e\x3cspan click style\x3d"cursor:pointer;width:100%;display:inline-block;"\x3e'+e.html()+'\x3c/span\x3e\t\t\x3cspan class\x3d"icon_skin select_arrow'+a+'" click\x3e\x3c/span\x3e\t\t\x3cul class\x3d"select_listvalue" style\x3d"display:none" id\x3d"'+g+'" type\x3d2 \x3e'+c+"\t\t\x3c/ul\x3e\t\x3c/div\x3e";e=$(this).parent();h=this.onchange;$(this).replaceWith("\x3cdiv class\x3d'htmlSelect' type\x3d'2'\x3e"+c+"\x3c/div\x3e");k=e.find("[click]");k.mousedown(function(){}).click(function(){var a=$(this).nextAll(".select_listvalue");a.toggle();0!=a.find("li").length&&$(window).height()-20<a.offset().top+a.height()&&a.css("top",-a.height()-5)}).next().delegate("li","click",function(){this.ismousedown||(k.nextAll(".select_listvalue").hide(),h&&h.call(this))});break;case 3:a=c="";for(b=0;b<g.length;b++)d=g.eq(b),f="",$.each(d[0].attributes,function(){/^(onclick|class)$/.test(this.name)||(f+=" "+this.name+"\x3d'"+this.value+"'")}),d.attr("checked")&&(f+=' checked\x3d"true"',a=d.html()),c+="\x3cli "+f+"\x3e"+d.html()+"\x3c/li\x3e";c='\x3cdiv class\x3d"inputbg_focus pad_none set_typeinput"\x3e\x3cinput type\x3d"text" '+("\u81ea\u5b9a\u4e49"==a?"":"readonly")+' value\x3d"'+a+'"\x3e\t\x3cdiv class\x3d"listbox dn" style\x3d"width:100%;display: none;"\x3e\t\t\t\t\t\x3cul\x3e'+c+'\t\t\t\t\t\x3c/ul\x3e\t\x3c/div\x3e\t\x3ci class\x3d"icon_skin inputbg_rt_downarrow" click\x3e\x3c/i\x3e\x3c/div\x3e';e=$(this).parent();h=this.onchange;a=this.className;$(this).replaceWith("\x3cdiv class\x3d'"+a+"'\x3e"+c+"\x3c/div\x3e");k=e.find("[click]");e.find("input").click(function(){$(this).next().toggle()});k.click(function(){$(this).prev().toggle();var a=$(this).prev().prev();$(this).prev().is(":visible")&&a.focus();return!1}).prev().prev().blur(function(){var a=this;setTimeout(function(){$(a).next().hide()},100)}).next().find("li").mousedown(function(){$(this).parent().parent().hide().prev().val(this.innerHTML);h&&h.call(this)})}};$(document).mousedown(function(a){a=a.srcElement||a.target;var b=$(".htmlSelect ul:visible");if(0!=b.length){var e=b.parent().parent()[0];e.contains(a)||e==a||0<$(a).parents(".type_showselect").length||0<$(a).parents(".show_select").length||b.each(function(){$(this).attr("class")?$(this).hide():$(this).parent().hide()})}});
|