| Current Path : /home/jeromecohp/www/aesecure/third/tablesorter/js/widgets/ |
| Current File : /home/jeromecohp/www/aesecure/third/tablesorter/js/widgets/widget-formatter.js |
// @file : /third/tablesorter/js/widgets/widget-formatter.js
// @version : 2.0.2
// @author : AVONTURE Christophe - christophe@aesecure.com
// @copyright : (C) 2013-2015 - Christophe Avonture - all right reserved.
// @url : http://www.aesecure.com/
// @package : 2015-02-14 13:37:55
// @license : This program is a commercial software. You CAN'T redistribute it and/or modify it.
// Source code is the property of Christophe Avonture and can't be reused, in whole or in part, in any programs.
;(function($){
'use strict';var ts=$.tablesorter;
ts.formatter={
init:function( c ){
var events=$.trim( c.widgetOptions.formatter_event ) +
' pagerComplete updateComplete '.split(' ').join('.tsformatter ');
c.$table
.off( $.trim(events) )
.on( $.trim(events), function(){
ts.formatter.setup( c );});
ts.formatter.setup( c );},
setup:function( c ){
if( $.isEmptyObject( c.cache ) ){ return;}
var $tbody, tbodyIndex, rowIndex, rows, cell, len, column,
wo=c.widgetOptions,
data={ config: c, wo: wo },
formatter=[],
$headers=[];
for ( column=0; column < c.columns; column++ ){
$headers[ column ]=c.$headers.filter('[data-column="' + column + '"]:last');
formatter[ column ]=ts.getColumnData( c.table, wo.formatter_column, column ) || false;}
for ( tbodyIndex=0; tbodyIndex < c.$tbodies.length; tbodyIndex++ ){
$tbody=ts.processTbody( c.table, c.$tbodies.eq( tbodyIndex ), true );
rows=c.cache[ tbodyIndex ];
len=rows.normalized.length;
for ( rowIndex=0; rowIndex < len; rowIndex++ ){
data.$row=rows.normalized[ rowIndex ][ c.columns ].$row;
data.$cells=data.$row.children( 'th, td' );
for ( column=0; column < c.columns; column++ ){
if( formatter[ column ] ){
data.columnIndex=column;
data.$header=$headers[ column ];
data.$cell=data.$cells.eq( column );
cell=data.$cell[0];
data.text=cell.getAttribute( c.textAttribute ) || cell.textContent || data.$cell.text();
cell.innerHTML=formatter[ column ]( data.text, data );}}}
ts.processTbody( c.table, $tbody, false);}}};
ts.addWidget({
id: 'formatter',
priority: 100,
options: {
formatter_column:{},
formatter_event :'applyFormatter'
},
init: function( table ){
ts.formatter.init( table.config );}});})( jQuery );