text: var Table=function(e,t){var n=$(e),i=$.extend({entityCheckbox:!1,checkboxChange:function(){}},t);n.on("change","input[name=__id_all]",function(){var e=$(this).is(":checked"),t=$("input[name=__id_all]");t.is(":checked")!=e&&t.prop("checked",e).trigger("change");var n=[];$('input[name="__id[]"]').each(function(t,i){var a=$(i);a.is(":checked")!=e&&(n.push(a),a.prop("checked",e))});for(var a=0;a<n.length;a++)n[a].trigger("change");return i.checkboxChange(),!1}),n.on("change",'input[name="__id[]"]',function(){var e=$('input[name="__id[]"]').length==$('input[name="__id[]"]:checked').length,t=$("input[name=__id_all]");t.is(":checked")!=e&&t.prop("checked",e),i.checkboxChange()}),this.clearCheckbox=function(){n.find('[type=checkbox][name="__id[]"]').prop("checked",!1),n.find('[type=checkbox][name="__id_all"]').prop("checked",!1)},this.loading=function(){if(n.find("thead").length){var e=n.find("thead > tr > th").length;n.find("tbody").html('<tr><td colspan="'+e+'"><div class="table-loading"><i class="uk-icon-spinner uk-icon-spin"></i> 正在加载...</div></td></tr>')}else n.html('<tbody><tr><td><div class="table-loading"><i class="uk-icon-spinner uk-icon-spin"></i> 正在加载...</div></td></tr></tbody>')},this.activeSelectedRow=function(){n.find("[data-item-id]").each(function(e,t){$(t).find('[name="__id[]"]:checked').length&&$(t).addClass("active"),$(t).find('[name="__id[]"]').on("change",function(){$(this).is(":checked")?$(t).addClass("active"):$(t).removeClass("active")})})},this.render=function(e){var t=e.list,a=e.head,d=[],h=0,c=[];c.push("<thead><tr>"),i.entityCheckbox&&(c.push('<th width="10"> <input type="checkbox" name="__id_all" /> </th>'),h++);for(var o=0;o<a.length;o++)c.push('<th data-item="'+a[o].field+'" '),"order"in a[o]&&c.push(' data-order="'+a[o].order+'" '),"attr"in a[o]&&c.push(a[o].attr+" "),"orderAble"in a[o]&&c.push(" data-orderAble "),c.push(">"+a[o].title+"</th>"),d.push(a[o].field),h++;if(c.push("</tr></thead><tbody>"),0==t.length)c.push('<tr><td colspan="'+h+'"><div class="table-none">暂无数据</div></td></tr>');else for(var o=0;o<t.length;o++){var r=t[o];c.push('<tr data-item-id="'+r._id+'">'),i.entityCheckbox&&c.push('<td> <input type="checkbox" name="__id[]" value="'+r._id+'" /> </td>');for(var s=0;s<d.length;s++)c.push('<td data-item="'+d[s]+'">'),c.push(r[d[s]]),c.push("</td>");c.push("</tr>")}c.push("</tbody>"),n.html(c.join("")),n.find("tbody > tr").each(function(e,n){$(n).data("data",t[e])})},this.getContainer=function(){return n}};module.exports=Table;