(function(a){;var b={"元素":{"窗体":0,"初始化":function(){this.窗体=this.窗体||new LKSortZJSY_IFRAME}},"实现":{"显示":function(a,c){b.初始化();b.元素.窗体.loadIFrame(function(){a=a||[];for(var d={},c=0;c<a.length;c++)if(a[c]){d[c]=d[c]||{};d[c].分类名=a[c];d[c].类型=null}b.元素.窗体.show_iframe(Global.Object.clone(d),10)},function(a){a=a||{};var b=[];for(var d in a)a[d].分类名&&b.push(a[d].分类名);c(b)})}},"初始化":function(){this.元素.初始化()}};a.fn.tags=function(l){var d=a.extend({},a.fn.tags.defaults,l),j=this,k=d.className||"tags-input",p='<input style="position:relative;z-index:10;" class="'+k+'" value="'+o()+'" type="text" name="name" />',c=a(p);function f(a){return!a?[]:a.split(/(,|，)\s*/)}function i(a){return!a?[]:a.split(/(,|，)/)}function h(){var a=c.selection();c[0].csstart=a.start;c[0].csend=a.end;c[0].cstext=a.text}function q(){var g=c[0].csstart,b=c[0].cstext;if(b)return a.trim(b)==""||b.indexOf(",")!=-1||b.indexOf("，")!=-1?"":b;else{for(var j=0,d=0,h=i(c[0].value),f=0;f<h.length;f++){var e=h[f];d+=e.length;if(a.trim(e)!=""&&j<=g&&d>=g)return a.trim(e);d+=1;j=d}return""}}function n(l){for(var m=c[0].value,h=c[0].csstart,j=i(m),k=0,b=0,a=[],g=false,e=0;e<j.length;e++){var d=j[e];b+=d.length;if(g==false)if(h>=k&&h<=b){a.push(l);g=true}else a.push(d);else a.push(d);b+=1;k=b}a=f(a.join(","));a.push("");c[0].value=a.join(", ")}function m(){a('<a class="fl-his fl-his-new" title="点击查看最近使用分类">最近使用分类</a>').click(function(){b.实现.显示(d.source,function(a){a.length!=0&&a.push("");c.val(a.join(", "));e()})}).appendTo(j);c.appendTo(j).mouseup(function(){h();c.autocomplete("search",null)}).keyup(function(a){h();(a.keyCode==37||a.keyCode==39)&&c.autocomplete("search",null)}).autocomplete({minLength:0,source:function(d,b){var c=q();if(!c){b([]);return false}a.ajax({url:"/LKSort/Autocomplete",type:"POST",dataType:"json",data:{maxRows:12,name_startsWith:c},success:function(a){a.result&&b(a.info)},error:function(b,a){alert("查询分类异常：类型为"+a)}})},focus:function(){return false},select:function(b,a){n(a.item.value);e();return false}}).bind("keydown",function(b){if(b.keyCode==38||b.keyCode==40){a("#num").text(c[0].csstart);a("#Span1").text((parseInt(a("#Span1").text())||0)+1);c.selectRange(c[0].csstart,c[0].csend)}else b.keyCode==13&&c.selectRange(c[0].value.length);b.keyCode===a.ui.keyCode.TAB&&a(this).data("autocomplete").menu.active&&b.preventDefault()}).change(function(){e()});g("create")}function o(){if(Global.Object.isArray(d.source)){d.source.push("");return d.source.join(", ")}else return""}function e(){var b=c.val(),a=f(b);d.source=a;g("change",a)}function g(a,b){Global.Object.isFunction(d[a])&&d[a](b||null)}a.extend(c,{"get":function(){return f(c.val())},"set":function(a){if(Global.Object.isNumber(a)||Global.Object.isString(a)){d.source=[a];c.val(a)}else if(Global.Object.isArray(a)){d.source=Global.Object.clone(a);a.push("");c.val(a.join(", "))}else{d.source=[];c.val("")}},disable:function(){c.attr("disabled","disabled");return c},enable:function(){c.removeAttr("disabled");return c},destroy:function(){c.remove();g("destroy")}});m();return c};a.fn.tags.defaults={source:[],maxLength:10,className:"tags-input",create:function(){},change:function(){},destroy:function(){}}})(jQuery)