Skip to content

Commit

Permalink
Update tablesorter to version 2.26.0
Browse files Browse the repository at this point in the history
Update tablesorter to fix
Mottie/tablesorter#1196
  • Loading branch information
h3llrais3r committed May 2, 2016
1 parent 8bae10b commit 4db962f
Show file tree
Hide file tree
Showing 3 changed files with 213 additions and 133 deletions.
76 changes: 45 additions & 31 deletions interface/media/scripts/jquery.tablesorter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! TableSorter (FORK) v2.25.3 *//*
/*! TableSorter (FORK) v2.26.0 *//*
* Client-side table sorting with ease!
* @requires jQuery v1.2.6+
*
Expand All @@ -21,7 +21,7 @@
'use strict';
var ts = $.tablesorter = {

version : '2.25.3',
version : '2.26.0',

parsers : [],
widgets : [],
Expand Down Expand Up @@ -177,7 +177,7 @@

},

// digit sort text location; keeping max+/- for backwards compatibility
// digit sort, text location
string : {
max : 1,
min : -1,
Expand Down Expand Up @@ -733,7 +733,7 @@
}
}
if ( add ) {
ts.parsers.push( parser );
ts.parsers[ ts.parsers.length ] = parser;
}
},

Expand Down Expand Up @@ -941,8 +941,15 @@
index = 0;
while ( index <= span ) {
// duplicate text (or not) to spanned columns
rowData.raw[ cacheIndex + index ] = c.duplicateSpan || index === 0 ? val : '';
cols[ cacheIndex + index ] = c.duplicateSpan || index === 0 ? val : '';
// instead of setting duplicate span to empty string, use textExtraction to try to get a value
// see http://stackoverflow.com/q/36449711/145346
txt = c.duplicateSpan || index === 0 ?
val :
typeof c.textExtraction !== 'string' ?
ts.getElementText( c, cell, cacheIndex + index ) || '' :
'';
rowData.raw[ cacheIndex + index ] = txt;
cols[ cacheIndex + index ] = txt;
index++;
}
cacheIndex += span;
Expand All @@ -953,7 +960,7 @@
}
// ensure rowData is always in the same location (after the last column)
cols[ c.columns ] = rowData;
cache.normalized.push( cols );
cache.normalized[ cache.normalized.length ] = cols;
}
cache.colMax = colMax;
// total up rows, not including child rows
Expand Down Expand Up @@ -1022,9 +1029,9 @@
});
}
if ( result !== false ) {
data.parsed.push( parsed );
data.raw.push( raw );
data.$cell.push( $cell );
data.parsed[ data.parsed.length ] = parsed;
data.raw[ data.raw.length ] = raw;
data.$cell[ data.$cell.length ] = $cell;
}
}
}
Expand Down Expand Up @@ -1213,7 +1220,7 @@
}
primary = indx === 0 ? dir : primary;
group = [ col, parseInt( dir, 10 ) || 0 ];
c.sortList.push( group );
c.sortList[ c.sortList.length ] = group;
dir = $.inArray( group[ 1 ], order ); // fixes issue #167
c.sortVars[ col ].count = dir >= 0 ? dir : group[ 1 ] % ( c.sortReset ? 3 : 2 );
}
Expand Down Expand Up @@ -1312,7 +1319,7 @@
},

addRows : function( c, $row, resort, callback ) {
var txt, val, tbodyIndex, rowIndex, rows, cellIndex, len,
var txt, val, tbodyIndex, rowIndex, rows, cellIndex, len, order,
cacheIndex, rowData, cells, cell, span,
// allow passing a row string if only one non-info tbody exists in the table
valid = typeof $row === 'string' && c.$tbodies.length === 1 && /<tr/.test( $row || '' ),
Expand Down Expand Up @@ -1347,12 +1354,13 @@
for ( rowIndex = 0; rowIndex < rows; rowIndex++ ) {
cacheIndex = 0;
len = $row[ rowIndex ].cells.length;
order = c.cache[ tbodyIndex ].normalized.length;
cells = [];
rowData = {
child : [],
raw : [],
$row : $row.eq( rowIndex ),
order : c.cache[ tbodyIndex ].normalized.length
order : order
};
// add each cell
for ( cellIndex = 0; cellIndex < len; cellIndex++ ) {
Expand All @@ -1375,7 +1383,7 @@
// add the row data to the end
cells[ c.columns ] = rowData;
// update cache
c.cache[ tbodyIndex ].normalized.push( cells );
c.cache[ tbodyIndex ].normalized[ order ] = cells;
}
// resort using current settings
ts.checkResort( c, resort, callback );
Expand Down Expand Up @@ -1417,7 +1425,7 @@
parsed = cache[ tbodyIndex ].normalized;
totalRows = parsed.length;
for ( rowIndex = 0; rowIndex < totalRows; rowIndex++ ) {
rows.push( parsed[ rowIndex ][ c.columns ].$row );
rows[rows.length] = parsed[ rowIndex ][ c.columns ].$row;
// removeRows used by the pager plugin; don't render if using ajax - fixes #411
if ( !c.appender || ( c.pager && ( !c.pager.removeRows || !wo.pager_removeRows ) && !c.pager.ajax ) ) {
$curTbody.append( parsed[ rowIndex ][ c.columns ].$row );
Expand Down Expand Up @@ -1499,18 +1507,18 @@
arry = c.sortForce;
for ( indx = 0; indx < arry.length; indx++ ) {
if ( arry[ indx ][ 0 ] !== col ) {
c.sortList.push( arry[ indx ] );
c.sortList[ c.sortList.length ] = arry[ indx ];
}
}
}
// add column to sort list
dir = order[ c.sortVars[ col ].count ];
if ( dir < 2 ) {
c.sortList.push( [ col, dir ] );
c.sortList[ c.sortList.length ] = [ col, dir ];
// add other columns if header spans across multiple
if ( cell.colSpan > 1 ) {
for ( indx = 1; indx < cell.colSpan; indx++ ) {
c.sortList.push( [ col + indx, dir ] );
c.sortList[ c.sortList.length ] = [ col + indx, dir ];
// update count on columns in colSpan
c.sortVars[ col + indx ].count = $.inArray( dir, order );
}
Expand Down Expand Up @@ -1539,11 +1547,11 @@
// add column to sort list array
dir = order[ c.sortVars[ col ].count ];
if ( dir < 2 ) {
c.sortList.push( [ col, dir ] );
c.sortList[ c.sortList.length ] = [ col, dir ];
// add other columns if header spans across multiple
if ( cell.colSpan > 1 ) {
for ( indx = 1; indx < cell.colSpan; indx++ ) {
c.sortList.push( [ col + indx, dir ] );
c.sortList[ c.sortList.length ] = [ col + indx, dir ];
// update count on columns in colSpan
c.sortVars[ col + indx ].count = $.inArray( dir, order );
}
Expand Down Expand Up @@ -1580,7 +1588,7 @@
break;
}
}
c.sortList.push( [ arry[ indx ][ 0 ], dir ] );
c.sortList[ c.sortList.length ] = [ arry[ indx ][ 0 ], dir ];
}
}
}
Expand Down Expand Up @@ -1847,7 +1855,10 @@
███████▀ ██ █████▀ ▀████▀ ██████ ██ █████▀
*/
addWidget : function( widget ) {
ts.widgets.push( widget );
if ( widget.id && !ts.isEmptyObject( ts.getWidgetById( widget.id ) ) ) {
console.warn( '"' + widget.id + '" widget was loaded more than once!' );
}
ts.widgets[ ts.widgets.length ] = widget;
},

hasWidget : function( $table, name ) {
Expand Down Expand Up @@ -1895,13 +1906,14 @@
len = widgets.length;
for ( indx = 0; indx < len; indx++ ) {
if ( widgets[ indx ].match( widgetClass ) ) {
c.widgets.push( widgets[ indx ].replace( widgetClass, '$1' ) );
c.widgets[ c.widgets.length ] = widgets[ indx ].replace( widgetClass, '$1' );
}
}
}
},

applyWidgetId : function( table, id, init ) {
table = $(table)[0];
var applied, time, name,
c = table.config,
wo = c.widgetOptions,
Expand All @@ -1911,7 +1923,7 @@
applied = false;
// add widget name to option list so it gets reapplied after sorting, filtering, etc
if ( $.inArray( name, c.widgets ) < 0 ) {
c.widgets.push( name );
c.widgets[ c.widgets.length ] = name;
}
if ( c.debug ) { time = new Date(); }

Expand Down Expand Up @@ -1974,6 +1986,8 @@
// set priority to 10 if not defined
if ( !widget.priority ) { widget.priority = 10; }
widgets[ indx ] = widget;
} else if ( c.debug ) {
console.warn( '"' + names[ indx ] + '" widget code does not exist!' );
}
}
// sort widgets by priority
Expand Down Expand Up @@ -2021,7 +2035,7 @@
for ( indx = 0; indx < len; indx++ ) {
widget = ts.widgets[ indx ];
if ( widget && widget.id ) {
name.push( widget.id );
name[ name.length ] = widget.id;
}
}
} else {
Expand All @@ -2033,17 +2047,17 @@
for ( index = 0; index < len; index++ ) {
widget = ts.getWidgetById( name[ index ] );
indx = $.inArray( name[ index ], c.widgets );
// don't remove the widget from config.widget if refreshing
if ( indx >= 0 && refreshing !== true ) {
c.widgets.splice( indx, 1 );
}
if ( widget && widget.remove ) {
if ( c.debug ) {
console.log( ( refreshing ? 'Refreshing' : 'Removing' ) + ' "' + name[ index ] + '" widget' );
}
widget.remove( table, c, c.widgetOptions, refreshing );
c.widgetInit[ name[ index ] ] = false;
}
// don't remove the widget from config.widget if refreshing
if ( indx >= 0 && refreshing !== true ) {
c.widgets.splice( indx, 1 );
}
}
},

Expand All @@ -2062,7 +2076,7 @@
for ( indx = 0; indx < len; indx++ ) {
widget = widgets[ indx ];
if ( widget && widget.id && ( doAll || $.inArray( widget.id, curWidgets ) < 0 ) ) {
list.push( widget.id );
list[ list.length ] = widget.id;
}
}
ts.removeWidget( table, list.join( ',' ), true );
Expand Down Expand Up @@ -2449,7 +2463,7 @@
console = {};
console.log = console.warn = console.error = console.table = function() {
var arg = arguments.length > 1 ? arguments : arguments[0];
ts.logs.push({ date: Date.now(), log: arg });
ts.logs[ ts.logs.length ] = { date: Date.now(), log: arg };
};
}

Expand Down
Loading

0 comments on commit 4db962f

Please sign in to comment.