$.fn.floatDiv=function(b){b=$.extend({hiddenid:"cmstopHiddenImg",thtml:"body",InnerHtmls:"CMSTOP\u6f02\u6d6e\u5c42\u5185\u5bb9!",Xoffset:"6",Yoffset:"10",background:"#ccc",padding:"5px",border:"1px solid #fff",index:"888888888",width:"",height:""},b);$(b.thtml).append('<div id="'+b.hiddenid+'"></div>');var c=$("#"+b.hiddenid);c.css({position:"absolute",overflow:"hidden",display:"none","z-index":b.index,cursor:"pointer"});c.html("");var d=$(this).offset(),g=d.left+parseInt($(this).width())+parseInt(b.Xoffset)+
"px";d=d.top-1+"px";var a="<div>";a+='<div ><a style="color:red;" href="javascript:;" id="Close_FloatDiv" title="\u5173\u95ed">\u5173\u95ed</a></div>';a+="<div>";a+=b.InnerHtmls;a+="</div>";a+="</div>";c.html(a);c.css({position:"absolute",overflow:"hidden",top:d,left:g,padding:b.padding,background:b.background,border:b.border,"z-index":b.index,cursor:"pointer",width:b.width,height:b.height}).show();$("#Close_FloatDiv").bind("click",function(){c.html("");c.hide();return false})};
(function(){var b;window.App={init:function(){b=document.getElementById("ruleForm");$(b).ajaxForm(function(a){a.state?ct.confirm(a.info+"\uff0c\u7ee7\u7eed\u7f16\u8f91\u89c4\u5219\uff1f",null,function(){ct.assoc.close()}):ct.error(a.error)});var c=$(b.maintable).focus(function(){$.getJSON("?app=push&controller=push&action=tables&dsnid="+b.dsnid.value,function(a){if(a.state){c.floatDiv({InnerHtmls:a.html});$("#cmstopHiddenImg select").change(function(){c.val(this.value)}).val(c.val())}else c.floatDiv({InnerHtmls:"\u6570\u636e\u5e93\u8fde\u63a5\u51fa\u73b0\u9519\u8bef!"})})});
$("#adddsn").click(function(){ct.form("\u6dfb\u52a0\u6570\u636e\u6e90","?app=system&controller=dsn&action=add",400,370,function(a){if(a.state){a=new Option(a.data.name,a.data.dsnid);b.dsnid.options.add(a);return a.selected=true}})});var d=$("#addtable"),g=d.parents("tbody");g.find("input[name^=jointable]:enabled").each(function(){var a=$(this).focus(function(){$.getJSON("?app=push&controller=push&action=tables&dsnid="+b.dsnid.value,function(e){if(e.state){a.floatDiv({InnerHtmls:e.html});$("#cmstopHiddenImg select").change(function(){a.val(this.value)}).val(a.val())}else a.floatDiv({InnerHtmls:"\u6570\u636e\u5e93\u8fde\u63a5\u51fa\u73b0\u9519\u8bef!"})})})});
d.click(function(){var a=g.find(">tr:last"),e=a.clone(),f=e.find("input").removeAttr("disabled").eq(0);f.focus(function(){$.getJSON("?app=push&controller=push&action=tables&dsnid="+b.dsnid.value,function(h){if(h.state){f.floatDiv({InnerHtmls:h.html});$("#cmstopHiddenImg select").change(function(){f.val(this.value)}).val(f.val())}else f.floatDiv({InnerHtmls:"\u6570\u636e\u5e93\u8fde\u63a5\u51fa\u73b0\u9519\u8bef!"})})});a.before(e.show())});$(b.primary).focus(function(){var a=$(this),e=["dsnid="+b.dsnid.value,
"tables[]="+b.maintable.value];$(b["jointable[]"]).filter(":visible").each(function(){this.value&&e.push("tables[]="+this.value)});$.getJSON("?app=push&controller=push&action=primary",e.join("&"),function(f){if(f.state){a.floatDiv({InnerHtmls:f.html});$("#cmstopHiddenImg select").change(function(){a.val(this.value)}).val(a.val())}else a.floatDiv({InnerHtmls:"\u6570\u636e\u5e93\u8fde\u63a5\u51fa\u73b0\u9519\u8bef!"})})});$("#fields input.field").focus(function(){var a=$(this),e=["dsnid="+b.dsnid.value,
"tables[]="+b.maintable.value];$(b["jointable[]"]).filter(":visible").each(function(){this.value&&e.push("tables[]="+this.value)});$.getJSON("?app=push&controller=push&action=fields",e.join("&"),function(f){if(f.state){a.floatDiv({InnerHtmls:f.html});$("#cmstopHiddenImg select").change(function(){a.val(this.value)}).val(a.val())}else a.floatDiv({InnerHtmls:"\u6570\u636e\u5e93\u8fde\u63a5\u51fa\u73b0\u9519\u8bef!"})})})},testGetList:function(){var c=$(b).formSerialize();$.post("?app=push&controller=push&action=testGetList",
c,function(d){if(d.state)var g=$("<div></div>").html(d.html||"").dialog({autoOpen:true,bgiframe:true,modal:false,height:350,width:400,title:"\u83b7\u53d6\u6d4b\u8bd5",close:function(){g.dialog("destroy").remove()}});else ct.tips("\u83b7\u53d6\u5931\u8d25","error")},"json")},testlink:function(c){c=$(c);$.post("?app=system&controller=dsn&action=test",c.serialize(),function(d){var g=d.state?$('<div class="success"><sub></sub>\u8d44\u6e90\u6b63\u5e38</div>'):$('<div class="error"><sub></sub>'+d.error+
"</div>");c.before(g);setTimeout(function(){g&&g.hide()},3E3)},"json")}}})();
