(function(l,i){var w=document.createElement("div");i(document);l.table=function(m,f){var p=m=i(m);f||(f={});var x=f.rowIdPrefix||"row_",C=f.rightMenuId||"right_menu",D=l.func(f.dblclickHandler||"dblclick_handler")||function(){},r=l.func(f.rowCallback||"init_row_event")||function(){},E=l.func(f.jsonLoaded||"json_loaded")||function(){},F=i.trim(f.template||""),q=i("#"+(f.pagerId||"pagination")),G=f.pageVar||"page",y=f.pagesizeVar||"pagesize",k=f.pageSize||12,z=f.baseUrl||"",s=z+(q.length?"&"+y+"="+
k:""),h={},n=[],o=null,u=function(b){var c=F;for(var d in b)c=c.replace(RegExp("{"+d+"}","gm"),b[d]);w.innerHTML=c;var a=i(w.firstChild),j=a[0].id.substr(x.length);h[j]=a;var g=a.find("input:checkbox");if(g.length){a.bind("check",function(){a.addClass("row_chked");g[0].checked=true}).bind("unCheck",function(){a.removeClass("row_chked");g[0].checked=false});c=function(e){var t=g[0].checked;if(e.target==g[0]){t=!t;e.stopPropagation()}a.trigger(t?"unCheck":"check")};g.click(c);a.click(c);n.push(g);a.bind("beforeRemove",
function(){var e=n.indexOf(g);e!=-1&&n.splice(e,1);delete h[j]})}else a.click(function(){a.trigger("check")}).bind("check",function(){if(o!=a){o&&o.trigger("unCheck");o=a;a.addClass("row_chked")}}).bind("unCheck",function(){a.removeClass("row_chked")}).bind("beforeRemove",function(){delete h[j]});a.dblclick(function(){D(j,a,b)});if(i.fn.contextMenu){a.bind("contextMenu",function(){for(var e in h)h[e].trigger("unCheck");a.trigger("check")});a.contextMenu("#"+(a.attr("right_menu_id")||C),function(e){(e=
l.func(e))&&e(j,a,b)})}return a};this.addRow=function(b,c){var d=u(b);c?p.prepend(d):p.append(d);r(d[0].id.substr(x.length),d);m.trigger("update");return d};this.updateRow=function(b,c){var d=h[b];d.trigger("beforeRemove");var a=u(c);d.replaceWith(a);a.trigger("check");r(b,a);m.trigger("update");return a};this.deleteRow=function(b){b==undefined?b=this.checkedIds():typeof b=="number"?b=[b]:!i.isArray(b)&&(b=(b+"").split(","));for(var c=0,d=b.length;c<d;c++){var a=h[b[c]];a&&(a.trigger("beforeRemove"),
a.remove())}};this.checkedIds=function(){for(var b=[],c=0,d;d=n[c++];)d[0].checked&&b.push(d.val());return b};this.checkedRow=function(){return o};this.setPageSize=function(b){k=parseInt(b)||12;A.items_per_page=k;s=z+(q.length?"&"+y+"="+k:"")};this.getPageSize=function(){return k};var v="",A={callback:function(b){B(s+"&"+(G+"="+(b+1)),v)},items_per_page:k,num_display_entries:5,num_edge_entries:2,prev_text:"&#x4E0A;&#x4E00;&#x9875;",next_text:"&#x4E0B;&#x4E00;&#x9875;"},B=function(b,c,d){i.getJSON(b,
c,function(a){h={};n=[];p.empty();for(var j=0,g;g=a.data[j++];){g=u(g);p.append(g)}m.trigger("update");for(var e in h)r(e,h[e]);typeof d=="function"&&d(a.total);E(a)})};this.load=function(b){b&&(v=b.jquery?b.serialize():b);B(s,v,function(c){q.length&&q.pagination(c,A)})}}})(cmstop,jQuery);
