tablesorter/dist/js/widgets/widget-formatter.min.js

5 lines
1.2 KiB
JavaScript
Raw Normal View History

/*! 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(c){var d=a.trim(c.widgetOptions.formatter_event)+" pagerComplete updateComplete ".split(" ").join(".tsformatter ");c.$table.off(a.trim(d)).on(a.trim(d),function(){b.formatter.setup(c)}),b.formatter.setup(c)},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.$headers.filter('[data-column="'+j+'"]:last'),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);