|
|
|
!function(a){"use strict";var b=a.tablesorter,c={error:{0:"Infinity result: Divide by zero",1:"Need more than one element to make this calculation",undef:"No elements found"},invalid:function(a,b,d){return console.log(b,c.error[d]),a&&a.widgetOptions.math_none||""},events:"tablesorter-initialized update updateAll updateRows addRows updateCell filterReset ".split(" ").join(".tsmath "),processText:function(a,d){var e=b.getElementText(a,d,c.getCellIndex(d));return e=b.formatFloat(e.replace(/[^\w,. \-()]/g,""),a.table)||0,isNaN(e)?0:e},getRow:function(b,d,e){var f,g=b.widgetOptions,h=[],i=d.closest("tr"),j=i.hasClass(g.filter_filteredRow||"filtered");return e&&(i=i.filter(e)),(e||!j)&&(f=i.children().not("["+g.math_dataAttrib+"=ignore]"),g.math_ignore.length&&(f=f.filter(function(b){return-1===a.inArray(c.getCellIndex(a(this)),g.math_ignore)})),h=f.not(d).map(function(){return c.processText(b,a(this))}).get()),h},getColumn:function(b,d,e,f){var g,h,i,j,k,l,m=b.widgetOptions,n=[],o=d.closest("tr"),p=m.math_dataAttrib,q="["+p+"=ignore]",r=m.filter_filteredRow||"filtered",s=c.getCellIndex(d),t=b.$table.children("tbody").children(),u=["["+p+"^=above]","["+p+"^=below]","["+p+"^=col]","["+p+"^=all]"];if("above"===e)for(j=t.index(o),g=j;g>=0;)i=t.eq(g),l=i.children().filter(u[0]).length,f&&(i=i.filter(f)),h=i.children().filter(function(b){return c.getCellIndex(a(this))===s}),((f||!i.hasClass(r))&&i.not(q).length&&g!==j||l&&g!==j)&&(l?g=0:h.length&&n.push(c.processText(b,h))),g--;else if("below"===e)for(j=t.length,g=t.index(o)+1;j>g&&(i=t.eq(g),!i.children().filter(u[1]).length);g++)f&&(i=i.filter(f)),h=i.children().filter(function(b){return c.getCellIndex(a(this))===s}),(f||!i.hasClass(r))&&i.not(q).length&&h.length&&n.push(c.processText(b,h));else for(k=t.not(q),j=k.length,g=0;j>g;g++)i=k.eq(g),f&&(i=i.filter(f)),h=i.children().filter(function(b){return c.getCellIndex(a(this))===s}),!f&&i.hasClass(r)||!h.not(u.join(",")).length||h.is(d)||n.push(c.processText(b,h));return n},getAll:function(b,d){var e,f,g,h,i,j,k,l,m=[],n=b.widgetOptions,o=n.math_dataAttrib,p="["+o+"=ignore]",q=n.filter_filteredRow||"filtered",r=b.$table.children("tbody").children().not(p);for(i=r.length,h=0;i>h;h++)if(g=r.eq(h),d&&(g=g.filter(d)),d||!g.hasClass(q))for(j=g.children().not(p),l=j.length,k=0;l>k;k++)e=j.eq(k),f=c.getCellIndex(e),!e.filter("["+o+"]").length&&a.inArray(f,n.math_ignore)<0&&m.push(c.processText(b,e));return m},setColumnIndexes:function(c){c.$table.after('<div id="_tablesorter_table_placeholder"></div>');var d=c.$table.detach(),e=1,f=d.children("tbody").children().filter(function(){var b,c,d=a(this),f=d.children("[colspan]").length>0;if(e>1?(e--,f=!0):1>e&&(e=1),d.children("[rowspan]").length>0)for(b=this.cells,c=0;c<b.length;c++)e=Math.max(b[c].rowSpan,e);return f});b.computeColumnIndex(f,c),a("#_tablesorter_table_placeholder").after(d).remove()},getCellIndex:function(a){var b=a.attr("data-column");return"undefined"==typeof b?a[0].cellIndex:parseInt(b,10)},recalculate:function(d,e,f){if(d&&(!e.math_isUpdating||f)){var g,h,i,j,k,l=!1,m={};d.debug&&(h=new Date),f&&c.setColumnIndexes(d),e.math_dataAttrib="data-"+(e.math_data||"math"),i=e.math_dataAttrib,j=d.$tbodies.children("tr").children("["+i+"]"),l=c.mathType(d,j,e.math_priority)||l,j=d.$table.children("."+d.cssInfoBlock+", tfoot").children("tr").children("["+i+"]"),c.mathType(d,j,e.math_priority),j=d.$table.children().children("tr").children("["+i+"^=all]"),k=j.length,j.each(function(b,c){var d=a(c),f=j.eq(b).attr(i+"-filter")||e.math_rowFilter;m[f]=m[f]?m[f].add(d):d}),a.each(m,function(a,b){l=c.mathType(d,b,["all"],a)||l}),l&&(e.math_isUpdating=!0,d.debug&&console[console.group?"group":"log"]("Math widget triggering an update after recalculation"),b.update(d,g,function(){c.updateComplete(d)}),d.debug&&console.log("Math widget update completed"+b.benchmark(h)))}},updateComplete:function(a){var b=a.widgetOptions;b.math_isUpdating&&a.debug&&console.groupEnd&&console.groupEnd(),b.math_isUpdating=!1},mathType:function(d,e,f,g){if(e.length){var h,i=!1,j=d.widgetOptions,k=j.math_dataAttrib,
|