/* * jquery basic table * author: jerry low */(function(e){e.fn.basictable=function(t){var n=function(t,n){var i=[];n.tablewrap&&t.wrap('
');var s="";t.find("thead tr th").length?s="thead th":t.find("tbody tr th").length?s="tbody tr th":t.find("th").length?s="tr:first th":s="tr:first td",e.each(t.find(s),function(){var t=e(this),n=parseint(t.attr("colspan"),10)||1,r=t.closest("tr").index();i[r]||(i[r]=[]);for(var s=0;s')}else t.addclass("bt-hide")})},i=function(t){e.each(t.find("td"),function(){var t=e(this),n=t.children(".bt-content").html();t.html(n)})},s=function(t,n){n.forceresponsive?e(window).width()<=n.breakpoint?o(t,n):u(t,n):t.removeclass("bt").outerwidth()>t.parent().width()?o(t,n):u(t,n)},o=function(e,t){e.addclass("bt"),t.tablewrap&&e.parent(".bt-wrapper").addclass("active")},u=function(e,t){e.removeclass("bt"),t.tablewrap&&e.parent(".bt-wrapper").removeclass("active")},a=function(e,t){e.find("td").removeattr("data-th"),t.tablewrap&&e.unwrap(),t.contentwrap&&i(e),e.removedata("basictable")},f=function(e){e.data("basictable")&&s(e,e.data("basictable"))};this.each(function(){var r=e(this);if(r.length===0||r.data("basictable"))return r.data("basictable")&&(t=="destroy"?a(r,r.data("basictable")):t==="start"?o(r,r.data("basictable")):t==="stop"?u(r,r.data("basictable")):s(r,r.data("basictable"))),!1;var i=e.extend({},e.fn.basictable.defaults,t),l={breakpoint:i.breakpoint,contentwrap:i.contentwrap,forceresponsive:i.forceresponsive,noresize:i.noresize,tablewrap:i.tablewrap,showemptycells:i.showemptycells};r.data("basictable",l),n(r,r.data("basictable")),l.noresize||(s(r,r.data("basictable")),e(window).bind("resize.basictable",function(){f(r)}))})},e.fn.basictable.defaults={breakpoint:568,contentwrap:!0,forceresponsive:!0,noresize:!1,tablewrap:!1,showemptycells:!1}})(jquery);