tablesorter/dist/js/widgets/widget-formatter.min.js
Mottie a69a746fdf Core: merge in modified addInstanceMethods. Closes #826
Removed `$columnHeader` & replaced it with new `$headerIndexed` variable
2015-02-27 14:33:27 -06:00

5 lines
1.2 KiB
JavaScript

/*! tablesorter Formatter widget - 2/9/2015 (v2.19.1)
* Requires tablesorter v2.8+ and jQuery 1.7+
* by Rob Garrison
*/
!function(a){"use strict";var b=a.tablesorter;b.formatter={init:function(a){var c=a.widgetOptions.formatter_event+" pagerComplete updateComplete ".split(" ").join(".tsformatter ");a.$table.off(c.replace(/\s+/g," ")).on(c,function(){b.formatter.setup(a)}),b.formatter.setup(a)},setup:function(c){if(!a.isEmptyObject(c.cache)){var d,e,f,g,h,i,j,k=c.widgetOptions,l={config:c,wo:k},m=[],n=[];for(j=0;j<c.columns;j++)n[j]=c.$headerIndexed[j],m[j]=b.getColumnData(c.table,k.formatter_column,j)||!1;for(e=0;e<c.$tbodies.length;e++){for(d=b.processTbody(c.table,c.$tbodies.eq(e),!0),g=c.cache[e],i=g.normalized.length,f=0;i>f;f++)for(l.$row=g.normalized[f][c.columns].$row,l.$cells=l.$row.children("th, td"),j=0;j<c.columns;j++)m[j]&&(l.columnIndex=j,l.$header=n[j],l.$cell=l.$cells.eq(j),h=l.$cell[0],l.text=h.getAttribute(c.textAttribute)||h.textContent||l.$cell.text(),h.innerHTML=m[j](l.text,l));b.processTbody(c.table,d,!1)}}}},b.addWidget({id:"formatter",priority:100,options:{formatter_column:{},formatter_event:"applyFormatter"},init:function(a){b.formatter.init(a.config)}})}(jQuery);