summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jquery.tablesorter.js2895
-rw-r--r--jquery.tablesorter.widgets.js3175
-rw-r--r--parsers/parser-network.js141
-rw-r--r--widgets/widget-pager.js1371
4 files changed, 4 insertions, 7578 deletions
diff --git a/jquery.tablesorter.js b/jquery.tablesorter.js
index e072473..c03262f 100644
--- a/jquery.tablesorter.js
+++ b/jquery.tablesorter.js
@@ -18,2897 +18,4 @@
* @docs (fork) - https://mottie.github.io/tablesorter/docs/
*/
/*jshint browser:true, jquery:true, unused:false, expr: true */
-;( function( $ ) {
- 'use strict';
- var ts = $.tablesorter = {
-
- version : '2.31.1',
-
- parsers : [],
- widgets : [],
- defaults : {
-
- // *** appearance
- theme : 'default', // adds tablesorter-{theme} to the table for styling
- widthFixed : false, // adds colgroup to fix widths of columns
- showProcessing : false, // show an indeterminate timer icon in the header when the table is sorted or filtered.
-
- headerTemplate : '{content}',// header layout template (HTML ok); {content} = innerHTML, {icon} = <i/> // class from cssIcon
- onRenderTemplate : null, // function( index, template ) { return template; }, // template is a string
- onRenderHeader : null, // function( index ) {}, // nothing to return
-
- // *** functionality
- cancelSelection : true, // prevent text selection in the header
- tabIndex : true, // add tabindex to header for keyboard accessibility
- dateFormat : 'mmddyyyy', // other options: 'ddmmyyy' or 'yyyymmdd'
- sortMultiSortKey : 'shiftKey', // key used to select additional columns
- sortResetKey : 'ctrlKey', // key used to remove sorting on a column
- usNumberFormat : true, // false for German '1.234.567,89' or French '1 234 567,89'
- delayInit : false, // if false, the parsed table contents will not update until the first sort
- serverSideSorting: false, // if true, server-side sorting should be performed because client-side sorting will be disabled, but the ui and events will still be used.
- resort : true, // default setting to trigger a resort after an 'update', 'addRows', 'updateCell', etc has completed
-
- // *** sort options
- headers : {}, // set sorter, string, empty, locked order, sortInitialOrder, filter, etc.
- ignoreCase : true, // ignore case while sorting
- sortForce : null, // column(s) first sorted; always applied
- sortList : [], // Initial sort order; applied initially; updated when manually sorted
- sortAppend : null, // column(s) sorted last; always applied
- sortStable : false, // when sorting two rows with exactly the same content, the original sort order is maintained
-
- sortInitialOrder : 'asc', // sort direction on first click
- sortLocaleCompare: false, // replace equivalent character (accented characters)
- sortReset : false, // third click on the header will reset column to default - unsorted
- sortRestart : false, // restart sort to 'sortInitialOrder' when clicking on previously unsorted columns
-
- emptyTo : 'bottom', // sort empty cell to bottom, top, none, zero, emptyMax, emptyMin
- stringTo : 'max', // sort strings in numerical column as max, min, top, bottom, zero
- duplicateSpan : true, // colspan cells in the tbody will have duplicated content in the cache for each spanned column
- textExtraction : 'basic', // text extraction method/function - function( node, table, cellIndex ) {}
- textAttribute : 'data-text',// data-attribute that contains alternate cell text (used in default textExtraction function)
- textSorter : null, // choose overall or specific column sorter function( a, b, direction, table, columnIndex ) [alt: ts.sortText]
- numberSorter : null, // choose overall numeric sorter function( a, b, direction, maxColumnValue )
-
- // *** widget options
- initWidgets : true, // apply widgets on tablesorter initialization
- widgetClass : 'widget-{name}', // table class name template to match to include a widget
- widgets : [], // method to add widgets, e.g. widgets: ['zebra']
- widgetOptions : {
- zebra : [ 'even', 'odd' ] // zebra widget alternating row class names
- },
-
- // *** callbacks
- initialized : null, // function( table ) {},
-
- // *** extra css class names
- tableClass : '',
- cssAsc : '',
- cssDesc : '',
- cssNone : '',
- cssHeader : '',
- cssHeaderRow : '',
- cssProcessing : '', // processing icon applied to header during sort/filter
-
- cssChildRow : 'tablesorter-childRow', // class name indiciating that a row is to be attached to its parent
- cssInfoBlock : 'tablesorter-infoOnly', // don't sort tbody with this class name (only one class name allowed here!)
- cssNoSort : 'tablesorter-noSort', // class name added to element inside header; clicking on it won't cause a sort
- cssIgnoreRow : 'tablesorter-ignoreRow',// header row to ignore; cells within this row will not be added to c.$headers
-
- cssIcon : 'tablesorter-icon', // if this class does not exist, the {icon} will not be added from the headerTemplate
- cssIconNone : '', // class name added to the icon when there is no column sort
- cssIconAsc : '', // class name added to the icon when the column has an ascending sort
- cssIconDesc : '', // class name added to the icon when the column has a descending sort
- cssIconDisabled : '', // class name added to the icon when the column has a disabled sort
-
- // *** events
- pointerClick : 'click',
- pointerDown : 'mousedown',
- pointerUp : 'mouseup',
-
- // *** selectors
- selectorHeaders : '> thead th, > thead td',
- selectorSort : 'th, td', // jQuery selector of content within selectorHeaders that is clickable to trigger a sort
- selectorRemove : '.remove-me',
-
- // *** advanced
- debug : false,
-
- // *** Internal variables
- headerList: [],
- empties: {},
- strings: {},
- parsers: [],
-
- // *** parser options for validator; values must be falsy!
- globalize: 0,
- imgAttr: 0
-
- // removed: widgetZebra: { css: ['even', 'odd'] }
-
- },
-
- // internal css classes - these will ALWAYS be added to
- // the table and MUST only contain one class name - fixes #381
- css : {
- table : 'tablesorter',
- cssHasChild: 'tablesorter-hasChildRow',
- childRow : 'tablesorter-childRow',
- colgroup : 'tablesorter-colgroup',
- header : 'tablesorter-header',
- headerRow : 'tablesorter-headerRow',
- headerIn : 'tablesorter-header-inner',
- icon : 'tablesorter-icon',
- processing : 'tablesorter-processing',
- sortAsc : 'tablesorter-headerAsc',
- sortDesc : 'tablesorter-headerDesc',
- sortNone : 'tablesorter-headerUnSorted'
- },
-
- // labels applied to sortable headers for accessibility (aria) support
- language : {
- sortAsc : 'Ascending sort applied, ',
- sortDesc : 'Descending sort applied, ',
- sortNone : 'No sort applied, ',
- sortDisabled : 'sorting is disabled',
- nextAsc : 'activate to apply an ascending sort',
- nextDesc : 'activate to apply a descending sort',
- nextNone : 'activate to remove the sort'
- },
-
- regex : {
- templateContent : /\{content\}/g,
- templateIcon : /\{icon\}/g,
- templateName : /\{name\}/i,
- spaces : /\s+/g,
- nonWord : /\W/g,
- formElements : /(input|select|button|textarea)/i,
-
- // *** sort functions ***
- // regex used in natural sort
- // chunk/tokenize numbers & letters
- chunk : /(^([+\-]?(?:\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,
- // replace chunks @ ends
- chunks : /(^\\0|\\0$)/,
- hex : /^0x[0-9a-f]+$/i,
-
- // *** formatFloat ***
- comma : /,/g,
- digitNonUS : /[\s|\.]/g,
- digitNegativeTest : /^\s*\([.\d]+\)/,
- digitNegativeReplace : /^\s*\(([.\d]+)\)/,
-
- // *** isDigit ***
- digitTest : /^[\-+(]?\d+[)]?$/,
- digitReplace : /[,.'"\s]/g
-
- },
-
- // digit sort, text location
- string : {
- max : 1,
- min : -1,
- emptymin : 1,
- emptymax : -1,
- zero : 0,
- none : 0,
- 'null' : 0,
- top : true,
- bottom : false
- },
-
- keyCodes : {
- enter : 13
- },
-
- // placeholder date parser data (globalize)
- dates : {},
-
- // These methods can be applied on table.config instance
- instanceMethods : {},
-
- /*
- ▄█████ ██████ ██████ ██ ██ █████▄
- ▀█▄ ██▄▄ ██ ██ ██ ██▄▄██
- ▀█▄ ██▀▀ ██ ██ ██ ██▀▀▀
- █████▀ ██████ ██ ▀████▀ ██
- */
-
- setup : function( table, c ) {
- // if no thead or tbody, or tablesorter is already present, quit
- if ( !table || !table.tHead || table.tBodies.length === 0 || table.hasInitialized === true ) {
- if ( ts.debug(c, 'core') ) {
- if ( table.hasInitialized ) {
- console.warn( 'Stopping initialization. Tablesorter has already been initialized' );
- } else {
- console.error( 'Stopping initialization! No table, thead or tbody', table );
- }
- }
- return;
- }
-
- var tmp = '',
- $table = $( table ),
- meta = $.metadata;
- // initialization flag
- table.hasInitialized = false;
- // table is being processed flag
- table.isProcessing = true;
- // make sure to store the config object
- table.config = c;
- // save the settings where they read
- $.data( table, 'tablesorter', c );
- if ( ts.debug(c, 'core') ) {
- console[ console.group ? 'group' : 'log' ]( 'Initializing tablesorter v' + ts.version );
- $.data( table, 'startoveralltimer', new Date() );
- }
-
- // removing this in version 3 (only supports jQuery 1.7+)
- c.supportsDataObject = ( function( version ) {
- version[ 0 ] = parseInt( version[ 0 ], 10 );
- return ( version[ 0 ] > 1 ) || ( version[ 0 ] === 1 && parseInt( version[ 1 ], 10 ) >= 4 );
- })( $.fn.jquery.split( '.' ) );
- // ensure case insensitivity
- c.emptyTo = c.emptyTo.toLowerCase();
- c.stringTo = c.stringTo.toLowerCase();
- c.last = { sortList : [], clickedIndex : -1 };
- // add table theme class only if there isn't already one there
- if ( !/tablesorter\-/.test( $table.attr( 'class' ) ) ) {
- tmp = ( c.theme !== '' ? ' tablesorter-' + c.theme : '' );
- }
-
- // give the table a unique id, which will be used in namespace binding
- if ( !c.namespace ) {
- c.namespace = '.tablesorter' + Math.random().toString( 16 ).slice( 2 );
- } else {
- // make sure namespace starts with a period & doesn't have weird characters
- c.namespace = '.' + c.namespace.replace( ts.regex.nonWord, '' );
- }
-
- c.table = table;
- c.$table = $table
- // add namespace to table to allow bindings on extra elements to target
- // the parent table (e.g. parser-input-select)
- .addClass( ts.css.table + ' ' + c.tableClass + tmp + ' ' + c.namespace.slice(1) )
- .attr( 'role', 'grid' );
- c.$headers = $table.find( c.selectorHeaders );
-
- c.$table.children().children( 'tr' ).attr( 'role', 'row' );
- c.$tbodies = $table.children( 'tbody:not(.' + c.cssInfoBlock + ')' ).attr({
- 'aria-live' : 'polite',
- 'aria-relevant' : 'all'
- });
- if ( c.$table.children( 'caption' ).length ) {
- tmp = c.$table.children( 'caption' )[ 0 ];
- if ( !tmp.id ) { tmp.id = c.namespace.slice( 1 ) + 'caption'; }
- c.$table.attr( 'aria-labelledby', tmp.id );
- }
- c.widgetInit = {}; // keep a list of initialized widgets
- // change textExtraction via data-attribute
- c.textExtraction = c.$table.attr( 'data-text-extraction' ) || c.textExtraction || 'basic';
- // build headers
- ts.buildHeaders( c );
- // fixate columns if the users supplies the fixedWidth option
- // do this after theme has been applied
- ts.fixColumnWidth( table );
- // add widgets from class name
- ts.addWidgetFromClass( table );
- // add widget options before parsing (e.g. grouping widget has parser settings)
- ts.applyWidgetOptions( table );
- // try to auto detect column type, and store in tables config
- ts.setupParsers( c );
- // start total row count at zero
- c.totalRows = 0;
- // only validate options while debugging. See #1528
- if (c.debug) {
- ts.validateOptions( c );
- }
- // build the cache for the tbody cells
- // delayInit will delay building the cache until the user starts a sort
- if ( !c.delayInit ) { ts.buildCache( c ); }
- // bind all header events and methods
- ts.bindEvents( table, c.$headers, true );
- ts.bindMethods( c );
- // get sort list from jQuery data or metadata
- // in jQuery < 1.4, an error occurs when calling $table.data()
- if ( c.supportsDataObject && typeof $table.data().sortlist !== 'undefined' ) {
- c.sortList = $table.data().sortlist;
- } else if ( meta && ( $table.metadata() && $table.metadata().sortlist ) ) {
- c.sortList = $table.metadata().sortlist;
- }
- // apply widget init code
- ts.applyWidget( table, true );
- // if user has supplied a sort list to constructor
- if ( c.sortList.length > 0 ) {
- // save sortList before any sortAppend is added
- c.last.sortList = c.sortList;
- ts.sortOn( c, c.sortList, {}, !c.initWidgets );
- } else {
- ts.setHeadersCss( c );
- if ( c.initWidgets ) {
- // apply widget format
- ts.applyWidget( table, false );
- }
- }
-
- // show processesing icon
- if ( c.showProcessing ) {
- $table
- .unbind( 'sortBegin' + c.namespace + ' sortEnd' + c.namespace )
- .bind( 'sortBegin' + c.namespace + ' sortEnd' + c.namespace, function( e ) {
- clearTimeout( c.timerProcessing );
- ts.isProcessing( table );
- if ( e.type === 'sortBegin' ) {
- c.timerProcessing = setTimeout( function() {
- ts.isProcessing( table, true );
- }, 500 );
- }
- });
- }
-
- // initialized
- table.hasInitialized = true;
- table.isProcessing = false;
- if ( ts.debug(c, 'core') ) {
- console.log( 'Overall initialization time:' + ts.benchmark( $.data( table, 'startoveralltimer' ) ) );
- if ( ts.debug(c, 'core') && console.groupEnd ) { console.groupEnd(); }
- }
- $table.triggerHandler( 'tablesorter-initialized', table );
- if ( typeof c.initialized === 'function' ) {
- c.initialized( table );
- }
- },
-
- bindMethods : function( c ) {
- var $table = c.$table,
- namespace = c.namespace,
- events = ( 'sortReset update updateRows updateAll updateHeaders addRows updateCell updateComplete ' +
- 'sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets destroy mouseup ' +
- 'mouseleave ' ).split( ' ' )
- .join( namespace + ' ' );
- // apply easy methods that trigger bound events
- $table
- .unbind( events.replace( ts.regex.spaces, ' ' ) )
- .bind( 'sortReset' + namespace, function( e, callback ) {
- e.stopPropagation();
- // using this.config to ensure functions are getting a non-cached version of the config
- ts.sortReset( this.config, function( table ) {
- if (table.isApplyingWidgets) {
- // multiple triggers in a row... filterReset, then sortReset - see #1361
- // wait to update widgets
- setTimeout( function() {
- ts.applyWidget( table, '', callback );
- }, 100 );
- } else {
- ts.applyWidget( table, '', callback );
- }
- });
- })
- .bind( 'updateAll' + namespace, function( e, resort, callback ) {
- e.stopPropagation();
- ts.updateAll( this.config, resort, callback );
- })
- .bind( 'update' + namespace + ' updateRows' + namespace, function( e, resort, callback ) {
- e.stopPropagation();
- ts.update( this.config, resort, callback );
- })
- .bind( 'updateHeaders' + namespace, function( e, callback ) {
- e.stopPropagation();
- ts.updateHeaders( this.config, callback );
- })
- .bind( 'updateCell' + namespace, function( e, cell, resort, callback ) {
- e.stopPropagation();
- ts.updateCell( this.config, cell, resort, callback );
- })
- .bind( 'addRows' + namespace, function( e, $row, resort, callback ) {
- e.stopPropagation();
- ts.addRows( this.config, $row, resort, callback );
- })
- .bind( 'updateComplete' + namespace, function() {
- this.isUpdating = false;
- })
- .bind( 'sorton' + namespace, function( e, list, callback, init ) {
- e.stopPropagation();
- ts.sortOn( this.config, list, callback, init );
- })
- .bind( 'appendCache' + namespace, function( e, callback, init ) {
- e.stopPropagation();
- ts.appendCache( this.config, init );
- if ( $.isFunction( callback ) ) {
- callback( this );
- }
- })
- // $tbodies variable is used by the tbody sorting widget
- .bind( 'updateCache' + namespace, function( e, callback, $tbodies ) {
- e.stopPropagation();
- ts.updateCache( this.config, callback, $tbodies );
- })
- .bind( 'applyWidgetId' + namespace, function( e, id ) {
- e.stopPropagation();
- ts.applyWidgetId( this, id );
- })
- .bind( 'applyWidgets' + namespace, function( e, callback ) {
- e.stopPropagation();
- // apply widgets (false = not initializing)
- ts.applyWidget( this, false, callback );
- })
- .bind( 'refreshWidgets' + namespace, function( e, all, dontapply ) {
- e.stopPropagation();
- ts.refreshWidgets( this, all, dontapply );
- })
- .bind( 'removeWidget' + namespace, function( e, name, refreshing ) {
- e.stopPropagation();
- ts.removeWidget( this, name, refreshing );
- })
- .bind( 'destroy' + namespace, function( e, removeClasses, callback ) {
- e.stopPropagation();
- ts.destroy( this, removeClasses, callback );
- })
- .bind( 'resetToLoadState' + namespace, function( e ) {
- e.stopPropagation();
- // remove all widgets
- ts.removeWidget( this, true, false );
- var tmp = $.extend( true, {}, c.originalSettings );
- // restore original settings; this clears out current settings, but does not clear
- // values saved to storage.
- c = $.extend( true, {}, ts.defaults, tmp );
- c.originalSettings = tmp;
- this.hasInitialized = false;
- // setup the entire table again
- ts.setup( this, c );
- });
- },
-
- bindEvents : function( table, $headers, core ) {
- table = $( table )[ 0 ];
- var tmp,
- c = table.config,
- namespace = c.namespace,
- downTarget = null;
- if ( core !== true ) {
- $headers.addClass( namespace.slice( 1 ) + '_extra_headers' );
- tmp = ts.getClosest( $headers, 'table' );
- if ( tmp.length && tmp[ 0 ].nodeName === 'TABLE' && tmp[ 0 ] !== table ) {
- $( tmp[ 0 ] ).addClass( namespace.slice( 1 ) + '_extra_table' );
- }
- }
- tmp = ( c.pointerDown + ' ' + c.pointerUp + ' ' + c.pointerClick + ' sort keyup ' )
- .replace( ts.regex.spaces, ' ' )
- .split( ' ' )
- .join( namespace + ' ' );
- // apply event handling to headers and/or additional headers (stickyheaders, scroller, etc)
- $headers
- // http://stackoverflow.com/questions/5312849/jquery-find-self;
- .find( c.selectorSort )
- .add( $headers.filter( c.selectorSort ) )
- .unbind( tmp )
- .bind( tmp, function( e, external ) {
- var $cell, cell, temp,
- $target = $( e.target ),
- // wrap event type in spaces, so the match doesn't trigger on inner words
- type = ' ' + e.type + ' ';
- // only recognize left clicks
- if ( ( ( e.which || e.button ) !== 1 && !type.match( ' ' + c.pointerClick + ' | sort | keyup ' ) ) ||
- // allow pressing enter
- ( type === ' keyup ' && e.which !== ts.keyCodes.enter ) ||
- // allow triggering a click event (e.which is undefined) & ignore physical clicks
- ( type.match( ' ' + c.pointerClick + ' ' ) && typeof e.which !== 'undefined' ) ) {
- return;
- }
- // ignore mouseup if mousedown wasn't on the same target
- if ( type.match( ' ' + c.pointerUp + ' ' ) && downTarget !== e.target && external !== true ) {
- return;
- }
- // set target on mousedown
- if ( type.match( ' ' + c.pointerDown + ' ' ) ) {
- downTarget = e.target;
- // preventDefault needed or jQuery v1.3.2 and older throws an
- // "Uncaught TypeError: handler.apply is not a function" error
- temp = $target.jquery.split( '.' );
- if ( temp[ 0 ] === '1' && temp[ 1 ] < 4 ) { e.preventDefault(); }
- return;
- }
- downTarget = null;
- $cell = ts.getClosest( $( this ), '.' + ts.css.header );
- // prevent sort being triggered on form elements
- if ( ts.regex.formElements.test( e.target.nodeName ) ||
- // nosort class name, or elements within a nosort container
- $target.hasClass( c.cssNoSort ) || $target.parents( '.' + c.cssNoSort ).length > 0 ||
- // disabled cell directly clicked
- $cell.hasClass( 'sorter-false' ) ||
- // elements within a button
- $target.parents( 'button' ).length > 0 ) {
- return !c.cancelSelection;
- }
- if ( c.delayInit && ts.isEmptyObject( c.cache ) ) {
- ts.buildCache( c );
- }
- // use column index from data-attribute or index of current row; fixes #1116
- c.last.clickedIndex = $cell.attr( 'data-column' ) || $cell.index();
- cell = c.$headerIndexed[ c.last.clickedIndex ][0];
- if ( cell && !cell.sortDisabled ) {
- ts.initSort( c, cell, e );
- }
- });
- if ( c.cancelSelection ) {
- // cancel selection
- $headers
- .attr( 'unselectable', 'on' )
- .bind( 'selectstart', false )
- .css({
- 'user-select' : 'none',
- 'MozUserSelect' : 'none' // not needed for jQuery 1.8+
- });
- }
- },
-
- buildHeaders : function( c ) {
- var $temp, icon, timer, indx;
- c.headerList = [];
- c.headerContent = [];
- c.sortVars = [];
- if ( ts.debug(c, 'core') ) {
- timer = new Date();
- }
- // children tr in tfoot - see issue #196 & #547
- // don't pass table.config to computeColumnIndex here - widgets (math) pass it to "quickly" index tbody cells
- c.columns = ts.computeColumnIndex( c.$table.children( 'thead, tfoot' ).children( 'tr' ) );
- // add icon if cssIcon option exists
- icon = c.cssIcon ?
- '<i class="' + ( c.cssIcon === ts.css.icon ? ts.css.icon : c.cssIcon + ' ' + ts.css.icon ) + '"></i>' :
- '';
- // redefine c.$headers here in case of an updateAll that replaces or adds an entire header cell - see #683
- c.$headers = $( $.map( c.$table.find( c.selectorHeaders ), function( elem, index ) {
- var configHeaders, header, column, template, tmp,
- $elem = $( elem );
- // ignore cell (don't add it to c.$headers) if row has ignoreRow class
- if ( ts.getClosest( $elem, 'tr' ).hasClass( c.cssIgnoreRow ) ) { return; }
- // transfer data-column to element if not th/td - #1459
- if ( !/(th|td)/i.test( elem.nodeName ) ) {
- tmp = ts.getClosest( $elem, 'th, td' );
- $elem.attr( 'data-column', tmp.attr( 'data-column' ) );
- }
- // make sure to get header cell & not column indexed cell
- configHeaders = ts.getColumnData( c.table, c.headers, index, true );
- // save original header content
- c.headerContent[ index ] = $elem.html();
- // if headerTemplate is empty, don't reformat the header cell
- if ( c.headerTemplate !== '' && !$elem.find( '.' + ts.css.headerIn ).length ) {
- // set up header template
- template = c.headerTemplate
- .replace( ts.regex.templateContent, $elem.html() )
- .replace( ts.regex.templateIcon, $elem.find( '.' + ts.css.icon ).length ? '' : icon );
- if ( c.onRenderTemplate ) {
- header = c.onRenderTemplate.apply( $elem, [ index, template ] );
- // only change t if something is returned
- if ( header && typeof header === 'string' ) {
- template = header;
- }
- }
- $elem.html( '<div class="' + ts.css.headerIn + '">' + template + '</div>' ); // faster than wrapInner
- }
- if ( c.onRenderHeader ) {
- c.onRenderHeader.apply( $elem, [ index, c, c.$table ] );
- }
- column = parseInt( $elem.attr( 'data-column' ), 10 );
- elem.column = column;
- tmp = ts.getOrder( ts.getData( $elem, configHeaders, 'sortInitialOrder' ) || c.sortInitialOrder );
- // this may get updated numerous times if there are multiple rows
- c.sortVars[ column ] = {
- count : -1, // set to -1 because clicking on the header automatically adds one
- order : tmp ?
- ( c.sortReset ? [ 1, 0, 2 ] : [ 1, 0 ] ) : // desc, asc, unsorted
- ( c.sortReset ? [ 0, 1, 2 ] : [ 0, 1 ] ), // asc, desc, unsorted
- lockedOrder : false,
- sortedBy : ''
- };
- tmp = ts.getData( $elem, configHeaders, 'lockedOrder' ) || false;
- if ( typeof tmp !== 'undefined' && tmp !== false ) {
- c.sortVars[ column ].lockedOrder = true;
- c.sortVars[ column ].order = ts.getOrder( tmp ) ? [ 1, 1 ] : [ 0, 0 ];
- }
- // add cell to headerList
- c.headerList[ index ] = elem;
- $elem.addClass( ts.css.header + ' ' + c.cssHeader );
- // add to parent in case there are multiple rows
- ts.getClosest( $elem, 'tr' )
- .addClass( ts.css.headerRow + ' ' + c.cssHeaderRow )
- .attr( 'role', 'row' );
- // allow keyboard cursor to focus on element
- if ( c.tabIndex ) {
- $elem.attr( 'tabindex', 0 );
- }
- return elem;
- }) );
- // cache headers per column
- c.$headerIndexed = [];
- for ( indx = 0; indx < c.columns; indx++ ) {
- // colspan in header making a column undefined
- if ( ts.isEmptyObject( c.sortVars[ indx ] ) ) {
- c.sortVars[ indx ] = {};
- }
- // Use c.$headers.parent() in case selectorHeaders doesn't point to the th/td
- $temp = c.$headers.filter( '[data-column="' + indx + '"]' );
- // target sortable column cells, unless there are none, then use non-sortable cells
- // .last() added in jQuery 1.4; use .filter(':last') to maintain compatibility with jQuery v1.2.6
- c.$headerIndexed[ indx ] = $temp.length ?
- $temp.not( '.sorter-false' ).length ?
- $temp.not( '.sorter-false' ).filter( ':last' ) :
- $temp.filter( ':last' ) :
- $();
- }
- c.$table.find( c.selectorHeaders ).attr({
- scope: 'col',
- role : 'columnheader'
- });
- // enable/disable sorting
- ts.updateHeader( c );
- if ( ts.debug(c, 'core') ) {
- console.log( 'Built headers:' + ts.benchmark( timer ) );
- console.log( c.$headers );
- }
- },
-
- // Use it to add a set of methods to table.config which will be available for all tables.
- // This should be done before table initialization
- addInstanceMethods : function( methods ) {
- $.extend( ts.instanceMethods, methods );
- },
-
- /*
- █████▄ ▄████▄ █████▄ ▄█████ ██████ █████▄ ▄█████
- ██▄▄██ ██▄▄██ ██▄▄██ ▀█▄ ██▄▄ ██▄▄██ ▀█▄
- ██▀▀▀ ██▀▀██ ██▀██ ▀█▄ ██▀▀ ██▀██ ▀█▄
- ██ ██ ██ ██ ██ █████▀ ██████ ██ ██ █████▀
- */
- setupParsers : function( c, $tbodies ) {
- var rows, list, span, max, colIndex, indx, header, configHeaders,
- noParser, parser, extractor, time, tbody, len,
- table = c.table,
- tbodyIndex = 0,
- debug = ts.debug(c, 'core'),
- debugOutput = {};
- // update table bodies in case we start with an empty table
- c.$tbodies = c.$table.children( 'tbody:not(.' + c.cssInfoBlock + ')' );
- tbody = typeof $tbodies === 'undefined' ? c.$tbodies : $tbodies;
- len = tbody.length;
- if ( len === 0 ) {
- return debug ? console.warn( 'Warning: *Empty table!* Not building a parser cache' ) : '';
- } else if ( debug ) {
- time = new Date();
- console[ console.group ? 'group' : 'log' ]( 'Detecting parsers for each column' );
- }
- list = {
- extractors: [],
- parsers: []
- };
- while ( tbodyIndex < len ) {
- rows = tbody[ tbodyIndex ].rows;
- if ( rows.length ) {
- colIndex = 0;
- max = c.columns;
- for ( indx = 0; indx < max; indx++ ) {
- header = c.$headerIndexed[ colIndex ];
- if ( header && header.length ) {
- // get column indexed table cell; adding true parameter fixes #1362 but
- // it would break backwards compatibility...
- configHeaders = ts.getColumnData( table, c.headers, colIndex ); // , true );
- // get column parser/extractor
- extractor = ts.getParserById( ts.getData( header, configHeaders, 'extractor' ) );
- parser = ts.getParserById( ts.getData( header, configHeaders, 'sorter' ) );
- noParser = ts.getData( header, configHeaders, 'parser' ) === 'false';
- // empty cells behaviour - keeping emptyToBottom for backwards compatibility
- c.empties[colIndex] = (
- ts.getData( header, configHeaders, 'empty' ) ||
- c.emptyTo || ( c.emptyToBottom ? 'bottom' : 'top' ) ).toLowerCase();
- // text strings behaviour in numerical sorts
- c.strings[colIndex] = (
- ts.getData( header, configHeaders, 'string' ) ||
- c.stringTo ||
- 'max' ).toLowerCase();
- if ( noParser ) {
- parser = ts.getParserById( 'no-parser' );
- }
- if ( !extractor ) {
- // For now, maybe detect someday
- extractor = false;
- }
- if ( !parser ) {
- parser = ts.detectParserForColumn( c, rows, -1, colIndex );
- }
- if ( debug ) {
- debugOutput[ '(' + colIndex + ') ' + header.text() ] = {
- parser : parser.id,
- extractor : extractor ? extractor.id : 'none',
- string : c.strings[ colIndex ],
- empty : c.empties[ colIndex ]
- };
- }
- list.parsers[ colIndex ] = parser;
- list.extractors[ colIndex ] = extractor;
- span = header[ 0 ].colSpan - 1;
- if ( span > 0 ) {
- colIndex += span;
- max += span;
- while ( span + 1 > 0 ) {
- // set colspan columns to use the same parsers & extractors
- list.parsers[ colIndex - span ] = parser;
- list.extractors[ colIndex - span ] = extractor;
- span--;
- }
- }
- }
- colIndex++;
- }
- }
- tbodyIndex += ( list.parsers.length ) ? len : 1;
- }
- if ( debug ) {
- if ( !ts.isEmptyObject( debugOutput ) ) {
- console[ console.table ? 'table' : 'log' ]( debugOutput );
- } else {
- console.warn( ' No parsers detected!' );
- }
- console.log( 'Completed detecting parsers' + ts.benchmark( time ) );
- if ( console.groupEnd ) { console.groupEnd(); }
- }
- c.parsers = list.parsers;
- c.extractors = list.extractors;
- },
-
- addParser : function( parser ) {
- var indx,
- len = ts.parsers.length,
- add = true;
- for ( indx = 0; indx < len; indx++ ) {
- if ( ts.parsers[ indx ].id.toLowerCase() === parser.id.toLowerCase() ) {
- add = false;
- }
- }
- if ( add ) {
- ts.parsers[ ts.parsers.length ] = parser;
- }
- },
-
- getParserById : function( name ) {
- /*jshint eqeqeq:false */ // eslint-disable-next-line eqeqeq
- if ( name == 'false' ) { return false; }
- var indx,
- len = ts.parsers.length;
- for ( indx = 0; indx < len; indx++ ) {
- if ( ts.parsers[ indx ].id.toLowerCase() === ( name.toString() ).toLowerCase() ) {
- return ts.parsers[ indx ];
- }
- }
- return false;
- },
-
- detectParserForColumn : function( c, rows, rowIndex, cellIndex ) {
- var cur, $node, row,
- indx = ts.parsers.length,
- node = false,
- nodeValue = '',
- debug = ts.debug(c, 'core'),
- keepLooking = true;
- while ( nodeValue === '' && keepLooking ) {
- rowIndex++;
- row = rows[ rowIndex ];
- // stop looking after 50 empty rows
- if ( row && rowIndex < 50 ) {
- if ( row.className.indexOf( ts.cssIgnoreRow ) < 0 ) {
- node = rows[ rowIndex ].cells[ cellIndex ];
- nodeValue = ts.getElementText( c, node, cellIndex );
- $node = $( node );
- if ( debug ) {
- console.log( 'Checking if value was empty on row ' + rowIndex + ', column: ' +
- cellIndex + ': "' + nodeValue + '"' );
- }
- }
- } else {
- keepLooking = false;
- }
- }
- while ( --indx >= 0 ) {
- cur = ts.parsers[ indx ];
- // ignore the default text parser because it will always be true
- if ( cur && cur.id !== 'text' && cur.is && cur.is( nodeValue, c.table, node, $node ) ) {
- return cur;
- }
- }
- // nothing found, return the generic parser (text)
- return ts.getParserById( 'text' );
- },
-
- getElementText : function( c, node, cellIndex ) {
- if ( !node ) { return ''; }
- var tmp,
- extract = c.textExtraction || '',
- // node could be a jquery object
- // http://jsperf.com/jquery-vs-instanceof-jquery/2
- $node = node.jquery ? node : $( node );
- if ( typeof extract === 'string' ) {
- // check data-attribute first when set to 'basic'; don't use node.innerText - it's really slow!
- // http://www.kellegous.com/j/2013/02/27/innertext-vs-textcontent/
- if ( extract === 'basic' && typeof ( tmp = $node.attr( c.textAttribute ) ) !== 'undefined' ) {
- return $.trim( tmp );
- }
- return $.trim( node.textContent || $node.text() );
- } else {
- if ( typeof extract === 'function' ) {
- return $.trim( extract( $node[ 0 ], c.table, cellIndex ) );
- } else if ( typeof ( tmp = ts.getColumnData( c.table, extract, cellIndex ) ) === 'function' ) {
- return $.trim( tmp( $node[ 0 ], c.table, cellIndex ) );
- }
- }
- // fallback
- return $.trim( $node[ 0 ].textContent || $node.text() );
- },
-
- // centralized function to extract/parse cell contents
- getParsedText : function( c, cell, colIndex, txt ) {
- if ( typeof txt === 'undefined' ) {
- txt = ts.getElementText( c, cell, colIndex );
- }
- // if no parser, make sure to return the txt
- var val = '' + txt,
- parser = c.parsers[ colIndex ],
- extractor = c.extractors[ colIndex ];
- if ( parser ) {
- // do extract before parsing, if there is one
- if ( extractor && typeof extractor.format === 'function' ) {
- txt = extractor.format( txt, c.table, cell, colIndex );
- }
- // allow parsing if the string is empty, previously parsing would change it to zero,
- // in case the parser needs to extract data from the table cell attributes
- val = parser.id === 'no-parser' ? '' :
- // make sure txt is a string (extractor may have converted it)
- parser.format( '' + txt, c.table, cell, colIndex );
- if ( c.ignoreCase && typeof val === 'string' ) {
- val = val.toLowerCase();
- }
- }
- return val;
- },
-
- /*
- ▄████▄ ▄████▄ ▄████▄ ██ ██ ██████
- ██ ▀▀ ██▄▄██ ██ ▀▀ ██▄▄██ ██▄▄
- ██ ▄▄ ██▀▀██ ██ ▄▄ ██▀▀██ ██▀▀
- ▀████▀ ██ ██ ▀████▀ ██ ██ ██████
- */
- buildCache : function( c, callback, $tbodies ) {
- var cache, val, txt, rowIndex, colIndex, tbodyIndex, $tbody, $row,
- cols, $cells, cell, cacheTime, totalRows, rowData, prevRowData,
- colMax, span, cacheIndex, hasParser, max, len, index,
- table = c.table,
- parsers = c.parsers,
- debug = ts.debug(c, 'core');
- // update tbody variable
- c.$tbodies = c.$table.children( 'tbody:not(.' + c.cssInfoBlock + ')' );
- $tbody = typeof $tbodies === 'undefined' ? c.$tbodies : $tbodies,
- c.cache = {};
- c.totalRows = 0;
- // if no parsers found, return - it's an empty table.
- if ( !parsers ) {
- return debug ? console.warn( 'Warning: *Empty table!* Not building a cache' ) : '';
- }
- if ( debug ) {
- cacheTime = new Date();
- }
- // processing icon
- if ( c.showProcessing ) {
- ts.isProcessing( table, true );
- }
- for ( tbodyIndex = 0; tbodyIndex < $tbody.length; tbodyIndex++ ) {
- colMax = []; // column max value per tbody
- cache = c.cache[ tbodyIndex ] = {
- normalized: [] // array of normalized row data; last entry contains 'rowData' above
- // colMax: # // added at the end
- };
-
- totalRows = ( $tbody[ tbodyIndex ] && $tbody[ tbodyIndex ].rows.length ) || 0;
- for ( rowIndex = 0; rowIndex < totalRows; ++rowIndex ) {
- rowData = {
- // order: original row order #
- // $row : jQuery Object[]
- child: [], // child row text (filter widget)
- raw: [] // original row text
- };
- /** Add the table data to main data array */
- $row = $( $tbody[ tbodyIndex ].rows[ rowIndex ] );
- cols = [];
- // ignore "remove-me" rows
- if ( $row.hasClass( c.selectorRemove.slice(1) ) ) {
- continue;
- }
- // if this is a child row, add it to the last row's children and continue to the next row
- // ignore child row class, if it is the first row
- if ( $row.hasClass( c.cssChildRow ) && rowIndex !== 0 ) {
- len = cache.normalized.length - 1;
- prevRowData = cache.normalized[ len ][ c.columns ];
- prevRowData.$row = prevRowData.$row.add( $row );
- // add 'hasChild' class name to parent row
- if ( !$row.prev().hasClass( c.cssChildRow ) ) {
- $row.prev().addClass( ts.css.cssHasChild );
- }
- // save child row content (un-parsed!)
- $cells = $row.children( 'th, td' );
- len = prevRowData.child.length;
- prevRowData.child[ len ] = [];
- // child row content does not account for colspans/rowspans; so indexing may be off
- cacheIndex = 0;
- max = c.columns;
- for ( colIndex = 0; colIndex < max; colIndex++ ) {
- cell = $cells[ colIndex ];
- if ( cell ) {
- prevRowData.child[ len ][ colIndex ] = ts.getParsedText( c, cell, colIndex );
- span = $cells[ colIndex ].colSpan - 1;
- if ( span > 0 ) {
- cacheIndex += span;
- max += span;
- }
- }
- cacheIndex++;
- }
- // go to the next for loop
- continue;
- }
- rowData.$row = $row;
- rowData.order = rowIndex; // add original row position to rowCache
- cacheIndex = 0;
- max = c.columns;
- for ( colIndex = 0; colIndex < max; ++colIndex ) {
- cell = $row[ 0 ].cells[ colIndex ];
- if ( cell && cacheIndex < c.columns ) {
- hasParser = typeof parsers[ cacheIndex ] !== 'undefined';
- if ( !hasParser && debug ) {
- console.warn( 'No parser found for row: ' + rowIndex + ', column: ' + colIndex +
- '; cell containing: "' + $(cell).text() + '"; does it have a header?' );
- }
- val = ts.getElementText( c, cell, cacheIndex );
- rowData.raw[ cacheIndex ] = val; // save original row text
- // save raw column text even if there is no parser set
- txt = ts.getParsedText( c, cell, cacheIndex, val );
- cols[ cacheIndex ] = txt;
- if ( hasParser && ( parsers[ cacheIndex ].type || '' ).toLowerCase() === 'numeric' ) {
- // determine column max value (ignore sign)
- colMax[ cacheIndex ] = Math.max( Math.abs( txt ) || 0, colMax[ cacheIndex ] || 0 );
- }
- // allow colSpan in tbody
- span = cell.colSpan - 1;
- if ( span > 0 ) {
- index = 0;
- while ( index <= span ) {
- // duplicate text (or not) to spanned columns
- // 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;
- max += span;
- }
- }
- cacheIndex++;
- }
- // ensure rowData is always in the same location (after the last column)
- cols[ c.columns ] = rowData;
- cache.normalized[ cache.normalized.length ] = cols;
- }
- cache.colMax = colMax;
- // total up rows, not including child rows
- c.totalRows += cache.normalized.length;
-
- }
- if ( c.showProcessing ) {
- ts.isProcessing( table ); // remove processing icon
- }
- if ( debug ) {
- len = Math.min( 5, c.cache[ 0 ].normalized.length );
- console[ console.group ? 'group' : 'log' ]( 'Building cache for ' + c.totalRows +
- ' rows (showing ' + len + ' rows in log) and ' + c.columns + ' columns' +
- ts.benchmark( cacheTime ) );
- val = {};
- for ( colIndex = 0; colIndex < c.columns; colIndex++ ) {
- for ( cacheIndex = 0; cacheIndex < len; cacheIndex++ ) {
- if ( !val[ 'row: ' + cacheIndex ] ) {
- val[ 'row: ' + cacheIndex ] = {};
- }
- val[ 'row: ' + cacheIndex ][ c.$headerIndexed[ colIndex ].text() ] =
- c.cache[ 0 ].normalized[ cacheIndex ][ colIndex ];
- }
- }
- console[ console.table ? 'table' : 'log' ]( val );
- if ( console.groupEnd ) { console.groupEnd(); }
- }
- if ( $.isFunction( callback ) ) {
- callback( table );
- }
- },
-
- getColumnText : function( table, column, callback, rowFilter ) {
- table = $( table )[0];
- var tbodyIndex, rowIndex, cache, row, tbodyLen, rowLen, raw, parsed, $cell, result,
- hasCallback = typeof callback === 'function',
- allColumns = column === 'all',
- data = { raw : [], parsed: [], $cell: [] },
- c = table.config;
- if ( ts.isEmptyObject( c ) ) {
- if ( ts.debug(c, 'core') ) {
- console.warn( 'No cache found - aborting getColumnText function!' );
- }
- } else {
- tbodyLen = c.$tbodies.length;
- for ( tbodyIndex = 0; tbodyIndex < tbodyLen; tbodyIndex++ ) {
- cache = c.cache[ tbodyIndex ].normalized;
- rowLen = cache.length;
- for ( rowIndex = 0; rowIndex < rowLen; rowIndex++ ) {
- row = cache[ rowIndex ];
- if ( rowFilter && !row[ c.columns ].$row.is( rowFilter ) ) {
- continue;
- }
- result = true;
- parsed = ( allColumns ) ? row.slice( 0, c.columns ) : row[ column ];
- row = row[ c.columns ];
- raw = ( allColumns ) ? row.raw : row.raw[ column ];
- $cell = ( allColumns ) ? row.$row.children() : row.$row.children().eq( column );
- if ( hasCallback ) {
- result = callback({
- tbodyIndex : tbodyIndex,
- rowIndex : rowIndex,
- parsed : parsed,
- raw : raw,
- $row : row.$row,
- $cell : $cell
- });
- }
- if ( result !== false ) {
- data.parsed[ data.parsed.length ] = parsed;
- data.raw[ data.raw.length ] = raw;
- data.$cell[ data.$cell.length ] = $cell;
- }
- }
- }
- // return everything
- return data;
- }
- },
-
- /*
- ██ ██ █████▄ █████▄ ▄████▄ ██████ ██████
- ██ ██ ██▄▄██ ██ ██ ██▄▄██ ██ ██▄▄
- ██ ██ ██▀▀▀ ██ ██ ██▀▀██ ██ ██▀▀
- ▀████▀ ██ █████▀ ██ ██ ██ ██████
- */
- setHeadersCss : function( c ) {
- var indx, column,
- list = c.sortList,
- len = list.length,
- none = ts.css.sortNone + ' ' + c.cssNone,
- css = [ ts.css.sortAsc + ' ' + c.cssAsc, ts.css.sortDesc + ' ' + c.cssDesc ],
- cssIcon = [ c.cssIconAsc, c.cssIconDesc, c.cssIconNone ],
- aria = [ 'ascending', 'descending' ],
- updateColumnSort = function($el, index) {
- $el
- .removeClass( none )
- .addClass( css[ index ] )
- .attr( 'aria-sort', aria[ index ] )
- .find( '.' + ts.css.icon )
- .removeClass( cssIcon[ 2 ] )
- .addClass( cssIcon[ index ] );
- },
- // find the footer
- $extras = c.$table
- .find( 'tfoot tr' )
- .children( 'td, th' )
- .add( $( c.namespace + '_extra_headers' ) )
- .removeClass( css.join( ' ' ) ),
- // remove all header information
- $sorted = c.$headers
- .add( $( 'thead ' + c.namespace + '_extra_headers' ) )
- .removeClass( css.join( ' ' ) )
- .addClass( none )
- .attr( 'aria-sort', 'none' )
- .find( '.' + ts.css.icon )
- .removeClass( cssIcon.join( ' ' ) )
- .end();
- // add css none to all sortable headers
- $sorted
- .not( '.sorter-false' )
- .find( '.' + ts.css.icon )
- .addClass( cssIcon[ 2 ] );
- // add disabled css icon class
- if ( c.cssIconDisabled ) {
- $sorted
- .filter( '.sorter-false' )
- .find( '.' + ts.css.icon )
- .addClass( c.cssIconDisabled );
- }
- for ( indx = 0; indx < len; indx++ ) {
- // direction = 2 means reset!
- if ( list[ indx ][ 1 ] !== 2 ) {
- // multicolumn sorting updating - see #1005
- // .not(function() {}) needs jQuery 1.4
- // filter(function(i, el) {}) <- el is undefined in jQuery v1.2.6
- $sorted = c.$headers.filter( function( i ) {
- // only include headers that are in the sortList (this includes colspans)
- var include = true,
- $el = c.$headers.eq( i ),
- col = parseInt( $el.attr( 'data-column' ), 10 ),
- end = col + ts.getClosest( $el, 'th, td' )[0].colSpan;
- for ( ; col < end; col++ ) {
- include = include ? include || ts.isValueInArray( col, c.sortList ) > -1 : false;
- }
- return include;
- });
-
- // choose the :last in case there are nested columns
- $sorted = $sorted
- .not( '.sorter-false' )
- .filter( '[data-column="' + list[ indx ][ 0 ] + '"]' + ( len === 1 ? ':last' : '' ) );
- if ( $sorted.length ) {
- for ( column = 0; column < $sorted.length; column++ ) {
- if ( !$sorted[ column ].sortDisabled ) {
- updateColumnSort( $sorted.eq( column ), list[ indx ][ 1 ] );
- }
- }
- }
- // add sorted class to footer & extra headers, if they exist
- if ( $extras.length ) {
- updateColumnSort( $extras.filter( '[data-column="' + list[ indx ][ 0 ] + '"]' ), list[ indx ][ 1 ] );
- }
- }
- }
- // add verbose aria labels
- len = c.$headers.length;
- for ( indx = 0; indx < len; indx++ ) {
- ts.setColumnAriaLabel( c, c.$headers.eq( indx ) );
- }
- },
-
- getClosest : function( $el, selector ) {
- // jQuery v1.2.6 doesn't have closest()
- if ( $.fn.closest ) {
- return $el.closest( selector );
- }
- return $el.is( selector ) ?
- $el :
- $el.parents( selector ).filter( ':first' );
- },
-
- // nextSort (optional), lets you disable next sort text
- setColumnAriaLabel : function( c, $header, nextSort ) {
- if ( $header.length ) {
- var column = parseInt( $header.attr( 'data-column' ), 10 ),
- vars = c.sortVars[ column ],
- tmp = $header.hasClass( ts.css.sortAsc ) ?
- 'sortAsc' :
- $header.hasClass( ts.css.sortDesc ) ? 'sortDesc' : 'sortNone',
- txt = $.trim( $header.text() ) + ': ' + ts.language[ tmp ];
- if ( $header.hasClass( 'sorter-false' ) || nextSort === false ) {
- txt += ts.language.sortDisabled;
- } else {
- tmp = ( vars.count + 1 ) % vars.order.length;
- nextSort = vars.order[ tmp ];
- // if nextSort
- txt += ts.language[ nextSort === 0 ? 'nextAsc' : nextSort === 1 ? 'nextDesc' : 'nextNone' ];
- }
- $header.attr( 'aria-label', txt );
- if (vars.sortedBy) {
- $header.attr( 'data-sortedBy', vars.sortedBy );
- } else {
- $header.removeAttr('data-sortedBy');
- }
- }
- },
-
- updateHeader : function( c ) {
- var index, isDisabled, $header, col,
- table = c.table,
- len = c.$headers.length;
- for ( index = 0; index < len; index++ ) {
- $header = c.$headers.eq( index );
- col = ts.getColumnData( table, c.headers, index, true );
- // add 'sorter-false' class if 'parser-false' is set
- isDisabled = ts.getData( $header, col, 'sorter' ) === 'false' || ts.getData( $header, col, 'parser' ) === 'false';
- ts.setColumnSort( c, $header, isDisabled );
- }
- },
-
- setColumnSort : function( c, $header, isDisabled ) {
- var id = c.table.id;
- $header[ 0 ].sortDisabled = isDisabled;
- $header[ isDisabled ? 'addClass' : 'removeClass' ]( 'sorter-false' )
- .attr( 'aria-disabled', '' + isDisabled );
- // disable tab index on disabled cells
- if ( c.tabIndex ) {
- if ( isDisabled ) {
- $header.removeAttr( 'tabindex' );
- } else {
- $header.attr( 'tabindex', '0' );
- }
- }
- // aria-controls - requires table ID
- if ( id ) {
- if ( isDisabled ) {
- $header.removeAttr( 'aria-controls' );
- } else {
- $header.attr( 'aria-controls', id );
- }
- }
- },
-
- updateHeaderSortCount : function( c, list ) {
- var col, dir, group, indx, primary, temp, val, order,
- sortList = list || c.sortList,
- len = sortList.length;
- c.sortList = [];
- for ( indx = 0; indx < len; indx++ ) {
- val = sortList[ indx ];
- // ensure all sortList values are numeric - fixes #127
- col = parseInt( val[ 0 ], 10 );
- // prevents error if sorton array is wrong
- if ( col < c.columns ) {
-
- // set order if not already defined - due to colspan header without associated header cell
- // adding this check prevents a javascript error
- if ( !c.sortVars[ col ].order ) {
- if ( ts.getOrder( c.sortInitialOrder ) ) {
- order = c.sortReset ? [ 1, 0, 2 ] : [ 1, 0 ];
- } else {
- order = c.sortReset ? [ 0, 1, 2 ] : [ 0, 1 ];
- }
- c.sortVars[ col ].order = order;
- c.sortVars[ col ].count = 0;
- }
-
- order = c.sortVars[ col ].order;
- dir = ( '' + val[ 1 ] ).match( /^(1|d|s|o|n)/ );
- dir = dir ? dir[ 0 ] : '';
- // 0/(a)sc (default), 1/(d)esc, (s)ame, (o)pposite, (n)ext
- switch ( dir ) {
- case '1' : case 'd' : // descending
- dir = 1;
- break;
- case 's' : // same direction (as primary column)
- // if primary sort is set to 's', make it ascending
- dir = primary || 0;
- break;
- case 'o' :
- temp = order[ ( primary || 0 ) % order.length ];
- // opposite of primary column; but resets if primary resets
- dir = temp === 0 ? 1 : temp === 1 ? 0 : 2;
- break;
- case 'n' :
- dir = order[ ( ++c.sortVars[ col ].count ) % order.length ];
- break;
- default : // ascending
- dir = 0;
- break;
- }
- primary = indx === 0 ? dir : primary;
- group = [ col, parseInt( dir, 10 ) || 0 ];
- c.sortList[ c.sortList.length ] = group;
- dir = $.inArray( group[ 1 ], order ); // fixes issue #167
- c.sortVars[ col ].count = dir >= 0 ? dir : group[ 1 ] % order.length;
- }
- }
- },
-
- updateAll : function( c, resort, callback ) {
- var table = c.table;
- table.isUpdating = true;
- ts.refreshWidgets( table, true, true );
- ts.buildHeaders( c );
- ts.bindEvents( table, c.$headers, true );
- ts.bindMethods( c );
- ts.commonUpdate( c, resort, callback );
- },
-
- update : function( c, resort, callback ) {
- var table = c.table;
- table.isUpdating = true;
- // update sorting (if enabled/disabled)
- ts.updateHeader( c );
- ts.commonUpdate( c, resort, callback );
- },
-
- // simple header update - see #989
- updateHeaders : function( c, callback ) {
- c.table.isUpdating = true;
- ts.buildHeaders( c );
- ts.bindEvents( c.table, c.$headers, true );
- ts.resortComplete( c, callback );
- },
-
- updateCell : function( c, cell, resort, callback ) {
- // updateCell for child rows is a mess - we'll ignore them for now
- // eventually I'll break out the "update" row cache code to make everything consistent
- if ( $( cell ).closest( 'tr' ).hasClass( c.cssChildRow ) ) {
- console.warn('Tablesorter Warning! "updateCell" for child row content has been disabled, use "update" instead');
- return;
- }
- if ( ts.isEmptyObject( c.cache ) ) {
- // empty table, do an update instead - fixes #1099
- ts.updateHeader( c );
- ts.commonUpdate( c, resort, callback );
- return;
- }
- c.table.isUpdating = true;
- c.$table.find( c.selectorRemove ).remove();
- // get position from the dom
- var tmp, indx, row, icell, cache, len,
- $tbodies = c.$tbodies,
- $cell = $( cell ),
- // update cache - format: function( s, table, cell, cellIndex )
- // no closest in jQuery v1.2.6
- tbodyIndex = $tbodies.index( ts.getClosest( $cell, 'tbody' ) ),
- tbcache = c.cache[ tbodyIndex ],
- $row = ts.getClosest( $cell, 'tr' );
- cell = $cell[ 0 ]; // in case cell is a jQuery object
- // tbody may not exist if update is initialized while tbody is removed for processing
- if ( $tbodies.length && tbodyIndex >= 0 ) {
- row = $tbodies.eq( tbodyIndex ).find( 'tr' ).not( '.' + c.cssChildRow ).index( $row );
- cache = tbcache.normalized[ row ];
- len = $row[ 0 ].cells.length;
- if ( len !== c.columns ) {
- // colspan in here somewhere!
- icell = 0;
- tmp = false;
- for ( indx = 0; indx < len; indx++ ) {
- if ( !tmp && $row[ 0 ].cells[ indx ] !== cell ) {
- icell += $row[ 0 ].cells[ indx ].colSpan;
- } else {
- tmp = true;
- }
- }
- } else {
- icell = $cell.index();
- }
- tmp = ts.getElementText( c, cell, icell ); // raw
- cache[ c.columns ].raw[ icell ] = tmp;
- tmp = ts.getParsedText( c, cell, icell, tmp );
- cache[ icell ] = tmp; // parsed
- if ( ( c.parsers[ icell ].type || '' ).toLowerCase() === 'numeric' ) {
- // update column max value (ignore sign)
- tbcache.colMax[ icell ] = Math.max( Math.abs( tmp ) || 0, tbcache.colMax[ icell ] || 0 );
- }
- tmp = resort !== 'undefined' ? resort : c.resort;
- if ( tmp !== false ) {
- // widgets will be reapplied
- ts.checkResort( c, tmp, callback );
- } else {
- // don't reapply widgets is resort is false, just in case it causes
- // problems with element focus
- ts.resortComplete( c, callback );
- }
- } else {
- if ( ts.debug(c, 'core') ) {
- console.error( 'updateCell aborted, tbody missing or not within the indicated table' );
- }
- c.table.isUpdating = false;
- }
- },
-
- addRows : function( c, $row, resort, callback ) {
- 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 || '' ),
- table = c.table;
- if ( valid ) {
- $row = $( $row );
- c.$tbodies.append( $row );
- } else if (
- !$row ||
- // row is a jQuery object?
- !( $row instanceof $ ) ||
- // row contained in the table?
- ( ts.getClosest( $row, 'table' )[ 0 ] !== c.table )
- ) {
- if ( ts.debug(c, 'core') ) {
- console.error( 'addRows method requires (1) a jQuery selector reference to rows that have already ' +
- 'been added to the table, or (2) row HTML string to be added to a table with only one tbody' );
- }
- return false;
- }
- table.isUpdating = true;
- if ( ts.isEmptyObject( c.cache ) ) {
- // empty table, do an update instead - fixes #450
- ts.updateHeader( c );
- ts.commonUpdate( c, resort, callback );
- } else {
- rows = $row.filter( 'tr' ).attr( 'role', 'row' ).length;
- tbodyIndex = c.$tbodies.index( $row.parents( 'tbody' ).filter( ':first' ) );
- // fixes adding rows to an empty table - see issue #179
- if ( !( c.parsers && c.parsers.length ) ) {
- ts.setupParsers( c );
- }
- // add each row
- 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 : order
- };
- // add each cell
- for ( cellIndex = 0; cellIndex < len; cellIndex++ ) {
- cell = $row[ rowIndex ].cells[ cellIndex ];
- txt = ts.getElementText( c, cell, cacheIndex );
- rowData.raw[ cacheIndex ] = txt;
- val = ts.getParsedText( c, cell, cacheIndex, txt );
- cells[ cacheIndex ] = val;
- if ( ( c.parsers[ cacheIndex ].type || '' ).toLowerCase() === 'numeric' ) {
- // update column max value (ignore sign)
- c.cache[ tbodyIndex ].colMax[ cacheIndex ] =
- Math.max( Math.abs( val ) || 0, c.cache[ tbodyIndex ].colMax[ cacheIndex ] || 0 );
- }
- span = cell.colSpan - 1;
- if ( span > 0 ) {
- cacheIndex += span;
- }
- cacheIndex++;
- }
- // add the row data to the end
- cells[ c.columns ] = rowData;
- // update cache
- c.cache[ tbodyIndex ].normalized[ order ] = cells;
- }
- // resort using current settings
- ts.checkResort( c, resort, callback );
- }
- },
-
- updateCache : function( c, callback, $tbodies ) {
- // rebuild parsers
- if ( !( c.parsers && c.parsers.length ) ) {
- ts.setupParsers( c, $tbodies );
- }
- // rebuild the cache map
- ts.buildCache( c, callback, $tbodies );
- },
-
- // init flag (true) used by pager plugin to prevent widget application
- // renamed from appendToTable
- appendCache : function( c, init ) {
- var parsed, totalRows, $tbody, $curTbody, rowIndex, tbodyIndex, appendTime,
- table = c.table,
- $tbodies = c.$tbodies,
- rows = [],
- cache = c.cache;
- // empty table - fixes #206/#346
- if ( ts.isEmptyObject( cache ) ) {
- // run pager appender in case the table was just emptied
- return c.appender ? c.appender( table, rows ) :
- table.isUpdating ? c.$table.triggerHandler( 'updateComplete', table ) : ''; // Fixes #532
- }
- if ( ts.debug(c, 'core') ) {
- appendTime = new Date();
- }
- for ( tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
- $tbody = $tbodies.eq( tbodyIndex );
- if ( $tbody.length ) {
- // detach tbody for manipulation
- $curTbody = ts.processTbody( table, $tbody, true );
- parsed = cache[ tbodyIndex ].normalized;
- totalRows = parsed.length;
- for ( rowIndex = 0; rowIndex < totalRows; rowIndex++ ) {
- 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 && !c.pager.ajax ) ) {
- $curTbody.append( parsed[ rowIndex ][ c.columns ].$row );
- }
- }
- // restore tbody
- ts.processTbody( table, $curTbody, false );
- }
- }
- if ( c.appender ) {
- c.appender( table, rows );
- }
- if ( ts.debug(c, 'core') ) {
- console.log( 'Rebuilt table' + ts.benchmark( appendTime ) );
- }
- // apply table widgets; but not before ajax completes
- if ( !init && !c.appender ) {
- ts.applyWidget( table );
- }
- if ( table.isUpdating ) {
- c.$table.triggerHandler( 'updateComplete', table );
- }
- },
-
- commonUpdate : function( c, resort, callback ) {
- // remove rows/elements before update
- c.$table.find( c.selectorRemove ).remove();
- // rebuild parsers
- ts.setupParsers( c );
- // rebuild the cache map
- ts.buildCache( c );
- ts.checkResort( c, resort, callback );
- },
-
- /*
- ▄█████ ▄████▄ █████▄ ██████ ██ █████▄ ▄████▄
- ▀█▄ ██ ██ ██▄▄██ ██ ██ ██ ██ ██ ▄▄▄
- ▀█▄ ██ ██ ██▀██ ██ ██ ██ ██ ██ ▀██
- █████▀ ▀████▀ ██ ██ ██ ██ ██ ██ ▀████▀
- */
- initSort : function( c, cell, event ) {
- if ( c.table.isUpdating ) {
- // let any updates complete before initializing a sort
- return setTimeout( function() {
- ts.initSort( c, cell, event );
- }, 50 );
- }
-
- var arry, indx, headerIndx, dir, temp, tmp, $header,
- notMultiSort = !event[ c.sortMultiSortKey ],
- table = c.table,
- len = c.$headers.length,
- th = ts.getClosest( $( cell ), 'th, td' ),
- col = parseInt( th.attr( 'data-column' ), 10 ),
- sortedBy = event.type === 'mouseup' ? 'user' : event.type,
- order = c.sortVars[ col ].order;
- th = th[0];
- // Only call sortStart if sorting is enabled
- c.$table.triggerHandler( 'sortStart', table );
- // get current column sort order
- tmp = ( c.sortVars[ col ].count + 1 ) % order.length;
- c.sortVars[ col ].count = event[ c.sortResetKey ] ? 2 : tmp;
- // reset all sorts on non-current column - issue #30
- if ( c.sortRestart ) {
- for ( headerIndx = 0; headerIndx < len; headerIndx++ ) {
- $header = c.$headers.eq( headerIndx );
- tmp = parseInt( $header.attr( 'data-column' ), 10 );
- // only reset counts on columns that weren't just clicked on and if not included in a multisort
- if ( col !== tmp && ( notMultiSort || $header.hasClass( ts.css.sortNone ) ) ) {
- c.sortVars[ tmp ].count = -1;
- }
- }
- }
- // user only wants to sort on one column
- if ( notMultiSort ) {
- $.each( c.sortVars, function( i ) {
- c.sortVars[ i ].sortedBy = '';
- });
- // flush the sort list
- c.sortList = [];
- c.last.sortList = [];
- if ( c.sortForce !== null ) {
- arry = c.sortForce;
- for ( indx = 0; indx < arry.length; indx++ ) {
- if ( arry[ indx ][ 0 ] !== col ) {
- c.sortList[ c.sortList.length ] = arry[ indx ];
- c.sortVars[ arry[ indx ][ 0 ] ].sortedBy = 'sortForce';
- }
- }
- }
- // add column to sort list
- dir = order[ c.sortVars[ col ].count ];
- if ( dir < 2 ) {
- c.sortList[ c.sortList.length ] = [ col, dir ];
- c.sortVars[ col ].sortedBy = sortedBy;
- // add other columns if header spans across multiple
- if ( th.colSpan > 1 ) {
- for ( indx = 1; indx < th.colSpan; indx++ ) {
- c.sortList[ c.sortList.length ] = [ col + indx, dir ];
- // update count on columns in colSpan
- c.sortVars[ col + indx ].count = $.inArray( dir, order );
- c.sortVars[ col + indx ].sortedBy = sortedBy;
- }
- }
- }
- // multi column sorting
- } else {
- // get rid of the sortAppend before adding more - fixes issue #115 & #523
- c.sortList = $.extend( [], c.last.sortList );
-
- // the user has clicked on an already sorted column
- if ( ts.isValueInArray( col, c.sortList ) >= 0 ) {
- // reverse the sorting direction
- c.sortVars[ col ].sortedBy = sortedBy;
- for ( indx = 0; indx < c.sortList.length; indx++ ) {
- tmp = c.sortList[ indx ];
- if ( tmp[ 0 ] === col ) {
- // order.count seems to be incorrect when compared to cell.count
- tmp[ 1 ] = order[ c.sortVars[ col ].count ];
- if ( tmp[1] === 2 ) {
- c.sortList.splice( indx, 1 );
- c.sortVars[ col ].count = -1;
- }
- }
- }
- } else {
- // add column to sort list array
- dir = order[ c.sortVars[ col ].count ];
- c.sortVars[ col ].sortedBy = sortedBy;
- if ( dir < 2 ) {
- c.sortList[ c.sortList.length ] = [ col, dir ];
- // add other columns if header spans across multiple
- if ( th.colSpan > 1 ) {
- for ( indx = 1; indx < th.colSpan; indx++ ) {
- c.sortList[ c.sortList.length ] = [ col + indx, dir ];
- // update count on columns in colSpan
- c.sortVars[ col + indx ].count = $.inArray( dir, order );
- c.sortVars[ col + indx ].sortedBy = sortedBy;
- }
- }
- }
- }
- }
- // save sort before applying sortAppend
- c.last.sortList = $.extend( [], c.sortList );
- if ( c.sortList.length && c.sortAppend ) {
- arry = $.isArray( c.sortAppend ) ? c.sortAppend : c.sortAppend[ c.sortList[ 0 ][ 0 ] ];
- if ( !ts.isEmptyObject( arry ) ) {
- for ( indx = 0; indx < arry.length; indx++ ) {
- if ( arry[ indx ][ 0 ] !== col && ts.isValueInArray( arry[ indx ][ 0 ], c.sortList ) < 0 ) {
- dir = arry[ indx ][ 1 ];
- temp = ( '' + dir ).match( /^(a|d|s|o|n)/ );
- if ( temp ) {
- tmp = c.sortList[ 0 ][ 1 ];
- switch ( temp[ 0 ] ) {
- case 'd' :
- dir = 1;
- break;
- case 's' :
- dir = tmp;
- break;
- case 'o' :
- dir = tmp === 0 ? 1 : 0;
- break;
- case 'n' :
- dir = ( tmp + 1 ) % order.length;
- break;
- default:
- dir = 0;
- break;
- }
- }
- c.sortList[ c.sortList.length ] = [ arry[ indx ][ 0 ], dir ];
- c.sortVars[ arry[ indx ][ 0 ] ].sortedBy = 'sortAppend';
- }
- }
- }
- }
- // sortBegin event triggered immediately before the sort
- c.$table.triggerHandler( 'sortBegin', table );
- // setTimeout needed so the processing icon shows up
- setTimeout( function() {
- // set css for headers
- ts.setHeadersCss( c );
- ts.multisort( c );
- ts.appendCache( c );
- c.$table.triggerHandler( 'sortBeforeEnd', table );
- c.$table.triggerHandler( 'sortEnd', table );
- }, 1 );
- },
-
- // sort multiple columns
- multisort : function( c ) { /*jshint loopfunc:true */
- var tbodyIndex, sortTime, colMax, rows, tmp,
- table = c.table,
- sorter = [],
- dir = 0,
- textSorter = c.textSorter || '',
- sortList = c.sortList,
- sortLen = sortList.length,
- len = c.$tbodies.length;
- if ( c.serverSideSorting || ts.isEmptyObject( c.cache ) ) {
- // empty table - fixes #206/#346
- return;
- }
- if ( ts.debug(c, 'core') ) { sortTime = new Date(); }
- // cache textSorter to optimize speed
- if ( typeof textSorter === 'object' ) {
- colMax = c.columns;
- while ( colMax-- ) {
- tmp = ts.getColumnData( table, textSorter, colMax );
- if ( typeof tmp === 'function' ) {
- sorter[ colMax ] = tmp;
- }
- }
- }
- for ( tbodyIndex = 0; tbodyIndex < len; tbodyIndex++ ) {
- colMax = c.cache[ tbodyIndex ].colMax;
- rows = c.cache[ tbodyIndex ].normalized;
-
- rows.sort( function( a, b ) {
- var sortIndex, num, col, order, sort, x, y;
- // rows is undefined here in IE, so don't use it!
- for ( sortIndex = 0; sortIndex < sortLen; sortIndex++ ) {
- col = sortList[ sortIndex ][ 0 ];
- order = sortList[ sortIndex ][ 1 ];
- // sort direction, true = asc, false = desc
- dir = order === 0;
-
- if ( c.sortStable && a[ col ] === b[ col ] && sortLen === 1 ) {
- return a[ c.columns ].order - b[ c.columns ].order;
- }
-
- // fallback to natural sort since it is more robust
- num = /n/i.test( ts.getSortType( c.parsers, col ) );
- if ( num && c.strings[ col ] ) {
- // sort strings in numerical columns
- if ( typeof ( ts.string[ c.strings[ col ] ] ) === 'boolean' ) {
- num = ( dir ? 1 : -1 ) * ( ts.string[ c.strings[ col ] ] ? -1 : 1 );
- } else {
- num = ( c.strings[ col ] ) ? ts.string[ c.strings[ col ] ] || 0 : 0;
- }
- // fall back to built-in numeric sort
- // var sort = $.tablesorter['sort' + s]( a[col], b[col], dir, colMax[col], table );
- sort = c.numberSorter ? c.numberSorter( a[ col ], b[ col ], dir, colMax[ col ], table ) :
- ts[ 'sortNumeric' + ( dir ? 'Asc' : 'Desc' ) ]( a[ col ], b[ col ], num, colMax[ col ], col, c );
- } else {
- // set a & b depending on sort direction
- x = dir ? a : b;
- y = dir ? b : a;
- // text sort function
- if ( typeof textSorter === 'function' ) {
- // custom OVERALL text sorter
- sort = textSorter( x[ col ], y[ col ], dir, col, table );
- } else if ( typeof sorter[ col ] === 'function' ) {
- // custom text sorter for a SPECIFIC COLUMN
- sort = sorter[ col ]( x[ col ], y[ col ], dir, col, table );
- } else {
- // fall back to natural sort
- sort = ts[ 'sortNatural' + ( dir ? 'Asc' : 'Desc' ) ]( a[ col ] || '', b[ col ] || '', col, c );
- }
- }
- if ( sort ) { return sort; }
- }
- return a[ c.columns ].order - b[ c.columns ].order;
- });
- }
- if ( ts.debug(c, 'core') ) {
- console.log( 'Applying sort ' + sortList.toString() + ts.benchmark( sortTime ) );
- }
- },
-
- resortComplete : function( c, callback ) {
- if ( c.table.isUpdating ) {
- c.$table.triggerHandler( 'updateComplete', c.table );
- }
- if ( $.isFunction( callback ) ) {
- callback( c.table );
- }
- },
-
- checkResort : function( c, resort, callback ) {
- var sortList = $.isArray( resort ) ? resort : c.sortList,
- // if no resort parameter is passed, fallback to config.resort (true by default)
- resrt = typeof resort === 'undefined' ? c.resort : resort;
- // don't try to resort if the table is still processing
- // this will catch spamming of the updateCell method
- if ( resrt !== false && !c.serverSideSorting && !c.table.isProcessing ) {
- if ( sortList.length ) {
- ts.sortOn( c, sortList, function() {
- ts.resortComplete( c, callback );
- }, true );
- } else {
- ts.sortReset( c, function() {
- ts.resortComplete( c, callback );
- ts.applyWidget( c.table, false );
- } );
- }
- } else {
- ts.resortComplete( c, callback );
- ts.applyWidget( c.table, false );
- }
- },
-
- sortOn : function( c, list, callback, init ) {
- var indx,
- table = c.table;
- c.$table.triggerHandler( 'sortStart', table );
- for (indx = 0; indx < c.columns; indx++) {
- c.sortVars[ indx ].sortedBy = ts.isValueInArray( indx, list ) > -1 ? 'sorton' : '';
- }
- // update header count index
- ts.updateHeaderSortCount( c, list );
- // set css for headers
- ts.setHeadersCss( c );
- // fixes #346
- if ( c.delayInit && ts.isEmptyObject( c.cache ) ) {
- ts.buildCache( c );
- }
- c.$table.triggerHandler( 'sortBegin', table );
- // sort the table and append it to the dom
- ts.multisort( c );
- ts.appendCache( c, init );
- c.$table.triggerHandler( 'sortBeforeEnd', table );
- c.$table.triggerHandler( 'sortEnd', table );
- ts.applyWidget( table );
- if ( $.isFunction( callback ) ) {
- callback( table );
- }
- },
-
- sortReset : function( c, callback ) {
- c.sortList = [];
- var indx;
- for (indx = 0; indx < c.columns; indx++) {
- c.sortVars[ indx ].count = -1;
- c.sortVars[ indx ].sortedBy = '';
- }
- ts.setHeadersCss( c );
- ts.multisort( c );
- ts.appendCache( c );
- if ( $.isFunction( callback ) ) {
- callback( c.table );
- }
- },
-
- getSortType : function( parsers, column ) {
- return ( parsers && parsers[ column ] ) ? parsers[ column ].type || '' : '';
- },
-
- getOrder : function( val ) {
- // look for 'd' in 'desc' order; return true
- return ( /^d/i.test( val ) || val === 1 );
- },
-
- // Natural sort - https://github.com/overset/javascript-natural-sort (date sorting removed)
- sortNatural : function( a, b ) {
- if ( a === b ) { return 0; }
- a = ( a || '' ).toString();
- b = ( b || '' ).toString();
- var aNum, bNum, aFloat, bFloat, indx, max,
- regex = ts.regex;
- // first try and sort Hex codes
- if ( regex.hex.test( b ) ) {
- aNum = parseInt( a.match( regex.hex ), 16 );
- bNum = parseInt( b.match( regex.hex ), 16 );
- if ( aNum < bNum ) { return -1; }
- if ( aNum > bNum ) { return 1; }
- }
- // chunk/tokenize
- aNum = a.replace( regex.chunk, '\\0$1\\0' ).replace( regex.chunks, '' ).split( '\\0' );
- bNum = b.replace( regex.chunk, '\\0$1\\0' ).replace( regex.chunks, '' ).split( '\\0' );
- max = Math.max( aNum.length, bNum.length );
- // natural sorting through split numeric strings and default strings
- for ( indx = 0; indx < max; indx++ ) {
- // find floats not starting with '0', string or 0 if not defined
- aFloat = isNaN( aNum[ indx ] ) ? aNum[ indx ] || 0 : parseFloat( aNum[ indx ] ) || 0;
- bFloat = isNaN( bNum[ indx ] ) ? bNum[ indx ] || 0 : parseFloat( bNum[ indx ] ) || 0;
- // handle numeric vs string comparison - number < string - (Kyle Adams)
- if ( isNaN( aFloat ) !== isNaN( bFloat ) ) { return isNaN( aFloat ) ? 1 : -1; }
- // rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
- if ( typeof aFloat !== typeof bFloat ) {
- aFloat += '';
- bFloat += '';
- }
- if ( aFloat < bFloat ) { return -1; }
- if ( aFloat > bFloat ) { return 1; }
- }
- return 0;
- },
-
- sortNaturalAsc : function( a, b, col, c ) {
- if ( a === b ) { return 0; }
- var empty = ts.string[ ( c.empties[ col ] || c.emptyTo ) ];
- if ( a === '' && empty !== 0 ) { return typeof empty === 'boolean' ? ( empty ? -1 : 1 ) : -empty || -1; }
- if ( b === '' && empty !== 0 ) { return typeof empty === 'boolean' ? ( empty ? 1 : -1 ) : empty || 1; }
- return ts.sortNatural( a, b );
- },
-
- sortNaturalDesc : function( a, b, col, c ) {
- if ( a === b ) { return 0; }
- var empty = ts.string[ ( c.empties[ col ] || c.emptyTo ) ];
- if ( a === '' && empty !== 0 ) { return typeof empty === 'boolean' ? ( empty ? -1 : 1 ) : empty || 1; }
- if ( b === '' && empty !== 0 ) { return typeof empty === 'boolean' ? ( empty ? 1 : -1 ) : -empty || -1; }
- return ts.sortNatural( b, a );
- },
-
- // basic alphabetical sort
- sortText : function( a, b ) {
- return a > b ? 1 : ( a < b ? -1 : 0 );
- },
-
- // return text string value by adding up ascii value
- // so the text is somewhat sorted when using a digital sort
- // this is NOT an alphanumeric sort
- getTextValue : function( val, num, max ) {
- if ( max ) {
- // make sure the text value is greater than the max numerical value (max)
- var indx,
- len = val ? val.length : 0,
- n = max + num;
- for ( indx = 0; indx < len; indx++ ) {
- n += val.charCodeAt( indx );
- }
- return num * n;
- }
- return 0;
- },
-
- sortNumericAsc : function( a, b, num, max, col, c ) {
- if ( a === b ) { return 0; }
- var empty = ts.string[ ( c.empties[ col ] || c.emptyTo ) ];
- if ( a === '' && empty !== 0 ) { return typeof empty === 'boolean' ? ( empty ? -1 : 1 ) : -empty || -1; }
- if ( b === '' && empty !== 0 ) { return typeof empty === 'boolean' ? ( empty ? 1 : -1 ) : empty || 1; }
- if ( isNaN( a ) ) { a = ts.getTextValue( a, num, max ); }
- if ( isNaN( b ) ) { b = ts.getTextValue( b, num, max ); }
- return a - b;
- },
-
- sortNumericDesc : function( a, b, num, max, col, c ) {
- if ( a === b ) { return 0; }
- var empty = ts.string[ ( c.empties[ col ] || c.emptyTo ) ];
- if ( a === '' && empty !== 0 ) { return typeof empty === 'boolean' ? ( empty ? -1 : 1 ) : empty || 1; }
- if ( b === '' && empty !== 0 ) { return typeof empty === 'boolean' ? ( empty ? 1 : -1 ) : -empty || -1; }
- if ( isNaN( a ) ) { a = ts.getTextValue( a, num, max ); }
- if ( isNaN( b ) ) { b = ts.getTextValue( b, num, max ); }
- return b - a;
- },
-
- sortNumeric : function( a, b ) {
- return a - b;
- },
-
- /*
- ██ ██ ██ ██ █████▄ ▄████▄ ██████ ██████ ▄█████
- ██ ██ ██ ██ ██ ██ ██ ▄▄▄ ██▄▄ ██ ▀█▄
- ██ ██ ██ ██ ██ ██ ██ ▀██ ██▀▀ ██ ▀█▄
- ███████▀ ██ █████▀ ▀████▀ ██████ ██ █████▀
- */
- addWidget : function( 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 ) {
- $table = $( $table );
- return $table.length && $table[ 0 ].config && $table[ 0 ].config.widgetInit[ name ] || false;
- },
-
- getWidgetById : function( name ) {
- var indx, widget,
- len = ts.widgets.length;
- for ( indx = 0; indx < len; indx++ ) {
- widget = ts.widgets[ indx ];
- if ( widget && widget.id && widget.id.toLowerCase() === name.toLowerCase() ) {
- return widget;
- }
- }
- },
-
- applyWidgetOptions : function( table ) {
- var indx, widget, wo,
- c = table.config,
- len = c.widgets.length;
- if ( len ) {
- for ( indx = 0; indx < len; indx++ ) {
- widget = ts.getWidgetById( c.widgets[ indx ] );
- if ( widget && widget.options ) {
- wo = $.extend( true, {}, widget.options );
- c.widgetOptions = $.extend( true, wo, c.widgetOptions );
- // add widgetOptions to defaults for option validator
- $.extend( true, ts.defaults.widgetOptions, widget.options );
- }
- }
- }
- },
-
- addWidgetFromClass : function( table ) {
- var len, indx,
- c = table.config,
- // look for widgets to apply from table class
- // don't match from 'ui-widget-content'; use \S instead of \w to include widgets
- // with dashes in the name, e.g. "widget-test-2" extracts out "test-2"
- regex = '^' + c.widgetClass.replace( ts.regex.templateName, '(\\S+)+' ) + '$',
- widgetClass = new RegExp( regex, 'g' ),
- // split up table class (widget id's can include dashes) - stop using match
- // otherwise only one widget gets extracted, see #1109
- widgets = ( table.className || '' ).split( ts.regex.spaces );
- if ( widgets.length ) {
- len = widgets.length;
- for ( indx = 0; indx < len; indx++ ) {
- if ( widgets[ indx ].match( widgetClass ) ) {
- 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,
- debug = ts.debug(c, 'core'),
- widget = ts.getWidgetById( id );
- if ( widget ) {
- name = widget.id;
- applied = false;
- // add widget name to option list so it gets reapplied after sorting, filtering, etc
- if ( $.inArray( name, c.widgets ) < 0 ) {
- c.widgets[ c.widgets.length ] = name;
- }
- if ( debug ) { time = new Date(); }
-
- if ( init || !( c.widgetInit[ name ] ) ) {
- // set init flag first to prevent calling init more than once (e.g. pager)
- c.widgetInit[ name ] = true;
- if ( table.hasInitialized ) {
- // don't reapply widget options on tablesorter init
- ts.applyWidgetOptions( table );
- }
- if ( typeof widget.init === 'function' ) {
- applied = true;
- if ( debug ) {
- console[ console.group ? 'group' : 'log' ]( 'Initializing ' + name + ' widget' );
- }
- widget.init( table, widget, c, wo );
- }
- }
- if ( !init && typeof widget.format === 'function' ) {
- applied = true;
- if ( debug ) {
- console[ console.group ? 'group' : 'log' ]( 'Updating ' + name + ' widget' );
- }
- widget.format( table, c, wo, false );
- }
- if ( debug ) {
- if ( applied ) {
- console.log( 'Completed ' + ( init ? 'initializing ' : 'applying ' ) + name + ' widget' + ts.benchmark( time ) );
- if ( console.groupEnd ) { console.groupEnd(); }
- }
- }
- }
- },
-
- applyWidget : function( table, init, callback ) {
- table = $( table )[ 0 ]; // in case this is called externally
- var indx, len, names, widget, time,
- c = table.config,
- debug = ts.debug(c, 'core'),
- widgets = [];
- // prevent numerous consecutive widget applications
- if ( init !== false && table.hasInitialized && ( table.isApplyingWidgets || table.isUpdating ) ) {
- return;
- }
- if ( debug ) { time = new Date(); }
- ts.addWidgetFromClass( table );
- // prevent "tablesorter-ready" from firing multiple times in a row
- clearTimeout( c.timerReady );
- if ( c.widgets.length ) {
- table.isApplyingWidgets = true;
- // ensure unique widget ids
- c.widgets = $.grep( c.widgets, function( val, index ) {
- return $.inArray( val, c.widgets ) === index;
- });
- names = c.widgets || [];
- len = names.length;
- // build widget array & add priority as needed
- for ( indx = 0; indx < len; indx++ ) {
- widget = ts.getWidgetById( names[ indx ] );
- if ( widget && widget.id ) {
- // set priority to 10 if not defined
- if ( !widget.priority ) { widget.priority = 10; }
- widgets[ indx ] = widget;
- } else if ( debug ) {
- console.warn( '"' + names[ indx ] + '" was enabled, but the widget code has not been loaded!' );
- }
- }
- // sort widgets by priority
- widgets.sort( function( a, b ) {
- return a.priority < b.priority ? -1 : a.priority === b.priority ? 0 : 1;
- });
- // add/update selected widgets
- len = widgets.length;
- if ( debug ) {
- console[ console.group ? 'group' : 'log' ]( 'Start ' + ( init ? 'initializing' : 'applying' ) + ' widgets' );
- }
- for ( indx = 0; indx < len; indx++ ) {
- widget = widgets[ indx ];
- if ( widget && widget.id ) {
- ts.applyWidgetId( table, widget.id, init );
- }
- }
- if ( debug && console.groupEnd ) { console.groupEnd(); }
- }
- c.timerReady = setTimeout( function() {
- table.isApplyingWidgets = false;
- $.data( table, 'lastWidgetApplication', new Date() );
- c.$table.triggerHandler( 'tablesorter-ready' );
- // callback executed on init only
- if ( !init && typeof callback === 'function' ) {
- callback( table );
- }
- if ( debug ) {
- widget = c.widgets.length;
- console.log( 'Completed ' +
- ( init === true ? 'initializing ' : 'applying ' ) + widget +
- ' widget' + ( widget !== 1 ? 's' : '' ) + ts.benchmark( time ) );
- }
- }, 10 );
- },
-
- removeWidget : function( table, name, refreshing ) {
- table = $( table )[ 0 ];
- var index, widget, indx, len,
- c = table.config;
- // if name === true, add all widgets from $.tablesorter.widgets
- if ( name === true ) {
- name = [];
- len = ts.widgets.length;
- for ( indx = 0; indx < len; indx++ ) {
- widget = ts.widgets[ indx ];
- if ( widget && widget.id ) {
- name[ name.length ] = widget.id;
- }
- }
- } else {
- // name can be either an array of widgets names,
- // or a space/comma separated list of widget names
- name = ( $.isArray( name ) ? name.join( ',' ) : name || '' ).toLowerCase().split( /[\s,]+/ );
- }
- len = name.length;
- 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 ( ts.debug(c, 'core') ) {
- console.log( ( refreshing ? 'Refreshing' : 'Removing' ) + ' "' + name[ index ] + '" widget' );
- }
- widget.remove( table, c, c.widgetOptions, refreshing );
- c.widgetInit[ name[ index ] ] = false;
- }
- }
- c.$table.triggerHandler( 'widgetRemoveEnd', table );
- },
-
- refreshWidgets : function( table, doAll, dontapply ) {
- table = $( table )[ 0 ]; // see issue #243
- var indx, widget,
- c = table.config,
- curWidgets = c.widgets,
- widgets = ts.widgets,
- len = widgets.length,
- list = [],
- callback = function( table ) {
- $( table ).triggerHandler( 'refreshComplete' );
- };
- // remove widgets not defined in config.widgets, unless doAll is true
- for ( indx = 0; indx < len; indx++ ) {
- widget = widgets[ indx ];
- if ( widget && widget.id && ( doAll || $.inArray( widget.id, curWidgets ) < 0 ) ) {
- list[ list.length ] = widget.id;
- }
- }
- ts.removeWidget( table, list.join( ',' ), true );
- if ( dontapply !== true ) {
- // call widget init if
- ts.applyWidget( table, doAll || false, callback );
- if ( doAll ) {
- // apply widget format
- ts.applyWidget( table, false, callback );
- }
- } else {
- callback( table );
- }
- },
-
- /*
- ██ ██ ██████ ██ ██ ██ ██████ ██ ██████ ▄█████
- ██ ██ ██ ██ ██ ██ ██ ██ ██▄▄ ▀█▄
- ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀█▄
- ▀████▀ ██ ██ ██████ ██ ██ ██ ██████ █████▀
- */
- benchmark : function( diff ) {
- return ( ' (' + ( new Date().getTime() - diff.getTime() ) + ' ms)' );
- },
- // deprecated ts.log
- log : function() {
- console.log( arguments );
- },
- debug : function(c, name) {
- return c && (
- c.debug === true ||
- typeof c.debug === 'string' && c.debug.indexOf(name) > -1
- );
- },
-
- // $.isEmptyObject from jQuery v1.4
- isEmptyObject : function( obj ) {
- /*jshint forin: false */
- for ( var name in obj ) {
- return false;
- }
- return true;
- },
-
- isValueInArray : function( column, arry ) {
- var indx,
- len = arry && arry.length || 0;
- for ( indx = 0; indx < len; indx++ ) {
- if ( arry[ indx ][ 0 ] === column ) {
- return indx;
- }
- }
- return -1;
- },
-
- formatFloat : function( str, table ) {
- if ( typeof str !== 'string' || str === '' ) { return str; }
- // allow using formatFloat without a table; defaults to US number format
- var num,
- usFormat = table && table.config ? table.config.usNumberFormat !== false :
- typeof table !== 'undefined' ? table : true;
- if ( usFormat ) {
- // US Format - 1,234,567.89 -> 1234567.89
- str = str.replace( ts.regex.comma, '' );
- } else {
- // German Format = 1.234.567,89 -> 1234567.89
- // French Format = 1 234 567,89 -> 1234567.89
- str = str.replace( ts.regex.digitNonUS, '' ).replace( ts.regex.comma, '.' );
- }
- if ( ts.regex.digitNegativeTest.test( str ) ) {
- // make (#) into a negative number -> (10) = -10
- str = str.replace( ts.regex.digitNegativeReplace, '-$1' );
- }
- num = parseFloat( str );
- // return the text instead of zero
- return isNaN( num ) ? $.trim( str ) : num;
- },
-
- isDigit : function( str ) {
- // replace all unwanted chars and match
- return isNaN( str ) ?
- ts.regex.digitTest.test( str.toString().replace( ts.regex.digitReplace, '' ) ) :
- str !== '';
- },
-
- // computeTableHeaderCellIndexes from:
- // http://www.javascripttoolbox.com/lib/table/examples.php
- // http://www.javascripttoolbox.com/temp/table_cellindex.html
- computeColumnIndex : function( $rows, c ) {
- var i, j, k, l, cell, cells, rowIndex, rowSpan, colSpan, firstAvailCol,
- // total columns has been calculated, use it to set the matrixrow
- columns = c && c.columns || 0,
- matrix = [],
- matrixrow = new Array( columns );
- for ( i = 0; i < $rows.length; i++ ) {
- cells = $rows[ i ].cells;
- for ( j = 0; j < cells.length; j++ ) {
- cell = cells[ j ];
- rowIndex = i;
- rowSpan = cell.rowSpan || 1;
- colSpan = cell.colSpan || 1;
- if ( typeof matrix[ rowIndex ] === 'undefined' ) {
- matrix[ rowIndex ] = [];
- }
- // Find first available column in the first row
- for ( k = 0; k < matrix[ rowIndex ].length + 1; k++ ) {
- if ( typeof matrix[ rowIndex ][ k ] === 'undefined' ) {
- firstAvailCol = k;
- break;
- }
- }
- // jscs:disable disallowEmptyBlocks
- if ( columns && cell.cellIndex === firstAvailCol ) {
- // don't to anything
- } else if ( cell.setAttribute ) {
- // jscs:enable disallowEmptyBlocks
- // add data-column (setAttribute = IE8+)
- cell.setAttribute( 'data-column', firstAvailCol );
- } else {
- // remove once we drop support for IE7 - 1/12/2016
- $( cell ).attr( 'data-column', firstAvailCol );
- }
- for ( k = rowIndex; k < rowIndex + rowSpan; k++ ) {
- if ( typeof matrix[ k ] === 'undefined' ) {
- matrix[ k ] = [];
- }
- matrixrow = matrix[ k ];
- for ( l = firstAvailCol; l < firstAvailCol + colSpan; l++ ) {
- matrixrow[ l ] = 'x';
- }
- }
- }
- }
- ts.checkColumnCount($rows, matrix, matrixrow.length);
- return matrixrow.length;
- },
-
- checkColumnCount : function($rows, matrix, columns) {
- // this DOES NOT report any tbody column issues, except for the math and
- // and column selector widgets
- var i, len,
- valid = true,
- cells = [];
- for ( i = 0; i < matrix.length; i++ ) {
- // some matrix entries are undefined when testing the footer because
- // it is using the rowIndex property
- if ( matrix[i] ) {
- len = matrix[i].length;
- if ( matrix[i].length !== columns ) {
- valid = false;
- break;
- }
- }
- }
- if ( !valid ) {
- $rows.each( function( indx, el ) {
- var cell = el.parentElement.nodeName;
- if ( cells.indexOf( cell ) < 0 ) {
- cells.push( cell );
- }
- });
- console.error(
- 'Invalid or incorrect number of columns in the ' +
- cells.join( ' or ' ) + '; expected ' + columns +
- ', but found ' + len + ' columns'
- );
- }
- },
-
- // automatically add a colgroup with col elements set to a percentage width
- fixColumnWidth : function( table ) {
- table = $( table )[ 0 ];
- var overallWidth, percent, $tbodies, len, index,
- c = table.config,
- $colgroup = c.$table.children( 'colgroup' );
- // remove plugin-added colgroup, in case we need to refresh the widths
- if ( $colgroup.length && $colgroup.hasClass( ts.css.colgroup ) ) {
- $colgroup.remove();
- }
- if ( c.widthFixed && c.$table.children( 'colgroup' ).length === 0 ) {
- $colgroup = $( '<colgroup class="' + ts.css.colgroup + '">' );
- overallWidth = c.$table.width();
- // only add col for visible columns - fixes #371
- $tbodies = c.$tbodies.find( 'tr:first' ).children( ':visible' );
- len = $tbodies.length;
- for ( index = 0; index < len; index++ ) {
- percent = parseInt( ( $tbodies.eq( index ).width() / overallWidth ) * 1000, 10 ) / 10 + '%';
- $colgroup.append( $( '<col>' ).css( 'width', percent ) );
- }
- c.$table.prepend( $colgroup );
- }
- },
-
- // get sorter, string, empty, etc options for each column from
- // jQuery data, metadata, header option or header class name ('sorter-false')
- // priority = jQuery data > meta > headers option > header class name
- getData : function( header, configHeader, key ) {
- var meta, cl4ss,
- val = '',
- $header = $( header );
- if ( !$header.length ) { return ''; }
- meta = $.metadata ? $header.metadata() : false;
- cl4ss = ' ' + ( $header.attr( 'class' ) || '' );
- if ( typeof $header.data( key ) !== 'undefined' ||
- typeof $header.data( key.toLowerCase() ) !== 'undefined' ) {
- // 'data-lockedOrder' is assigned to 'lockedorder'; but 'data-locked-order' is assigned to 'lockedOrder'
- // 'data-sort-initial-order' is assigned to 'sortInitialOrder'
- val += $header.data( key ) || $header.data( key.toLowerCase() );
- } else if ( meta && typeof meta[ key ] !== 'undefined' ) {
- val += meta[ key ];
- } else if ( configHeader && typeof configHeader[ key ] !== 'undefined' ) {
- val += configHeader[ key ];
- } else if ( cl4ss !== ' ' && cl4ss.match( ' ' + key + '-' ) ) {
- // include sorter class name 'sorter-text', etc; now works with 'sorter-my-custom-parser'
- val = cl4ss.match( new RegExp( '\\s' + key + '-([\\w-]+)' ) )[ 1 ] || '';
- }
- return $.trim( val );
- },
-
- getColumnData : function( table, obj, indx, getCell, $headers ) {
- if ( typeof obj !== 'object' || obj === null ) {
- return obj;
- }
- table = $( table )[ 0 ];
- var $header, key,
- c = table.config,
- $cells = ( $headers || c.$headers ),
- // c.$headerIndexed is not defined initially
- $cell = c.$headerIndexed && c.$headerIndexed[ indx ] ||
- $cells.find( '[data-column="' + indx + '"]:last' );
- if ( typeof obj[ indx ] !== 'undefined' ) {
- return getCell ? obj[ indx ] : obj[ $cells.index( $cell ) ];
- }
- for ( key in obj ) {
- if ( typeof key === 'string' ) {
- $header = $cell
- // header cell with class/id
- .filter( key )
- // find elements within the header cell with cell/id
- .add( $cell.find( key ) );
- if ( $header.length ) {
- return obj[ key ];
- }
- }
- }
- return;
- },
-
- // *** Process table ***
- // add processing indicator
- isProcessing : function( $table, toggle, $headers ) {
- $table = $( $table );
- var c = $table[ 0 ].config,
- // default to all headers
- $header = $headers || $table.find( '.' + ts.css.header );
- if ( toggle ) {
- // don't use sortList if custom $headers used
- if ( typeof $headers !== 'undefined' && c.sortList.length > 0 ) {
- // get headers from the sortList
- $header = $header.filter( function() {
- // get data-column from attr to keep compatibility with jQuery 1.2.6
- return this.sortDisabled ?
- false :
- ts.isValueInArray( parseFloat( $( this ).attr( 'data-column' ) ), c.sortList ) >= 0;
- });
- }
- $table.add( $header ).addClass( ts.css.processing + ' ' + c.cssProcessing );
- } else {
- $table.add( $header ).removeClass( ts.css.processing + ' ' + c.cssProcessing );
- }
- },
-
- // detach tbody but save the position
- // don't use tbody because there are portions that look for a tbody index (updateCell)
- processTbody : function( table, $tb, getIt ) {
- table = $( table )[ 0 ];
- if ( getIt ) {
- table.isProcessing = true;
- $tb.before( '<colgroup class="tablesorter-savemyplace"/>' );
- return $.fn.detach ? $tb.detach() : $tb.remove();
- }
- var holdr = $( table ).find( 'colgroup.tablesorter-savemyplace' );
- $tb.insertAfter( holdr );
- holdr.remove();
- table.isProcessing = false;
- },
-
- clearTableBody : function( table ) {
- $( table )[ 0 ].config.$tbodies.children().detach();
- },
-
- // used when replacing accented characters during sorting
- characterEquivalents : {
- 'a' : '\u00e1\u00e0\u00e2\u00e3\u00e4\u0105\u00e5', // áàâãäąå
- 'A' : '\u00c1\u00c0\u00c2\u00c3\u00c4\u0104\u00c5', // ÁÀÂÃÄĄÅ
- 'c' : '\u00e7\u0107\u010d', // çćč
- 'C' : '\u00c7\u0106\u010c', // ÇĆČ
- 'e' : '\u00e9\u00e8\u00ea\u00eb\u011b\u0119', // éèêëěę
- 'E' : '\u00c9\u00c8\u00ca\u00cb\u011a\u0118', // ÉÈÊËĚĘ
- 'i' : '\u00ed\u00ec\u0130\u00ee\u00ef\u0131', // íìİîïı
- 'I' : '\u00cd\u00cc\u0130\u00ce\u00cf', // ÍÌİÎÏ
- 'o' : '\u00f3\u00f2\u00f4\u00f5\u00f6\u014d', // óòôõöō
- 'O' : '\u00d3\u00d2\u00d4\u00d5\u00d6\u014c', // ÓÒÔÕÖŌ
- 'ss': '\u00df', // ß (s sharp)
- 'SS': '\u1e9e', // ẞ (Capital sharp s)
- 'u' : '\u00fa\u00f9\u00fb\u00fc\u016f', // úùûüů
- 'U' : '\u00da\u00d9\u00db\u00dc\u016e' // ÚÙÛÜŮ
- },
-
- replaceAccents : function( str ) {
- var chr,
- acc = '[',
- eq = ts.characterEquivalents;
- if ( !ts.characterRegex ) {
- ts.characterRegexArray = {};
- for ( chr in eq ) {
- if ( typeof chr === 'string' ) {
- acc += eq[ chr ];
- ts.characterRegexArray[ chr ] = new RegExp( '[' + eq[ chr ] + ']', 'g' );
- }
- }
- ts.characterRegex = new RegExp( acc + ']' );
- }
- if ( ts.characterRegex.test( str ) ) {
- for ( chr in eq ) {
- if ( typeof chr === 'string' ) {
- str = str.replace( ts.characterRegexArray[ chr ], chr );
- }
- }
- }
- return str;
- },
-
- validateOptions : function( c ) {
- var setting, setting2, typ, timer,
- // ignore options containing an array
- ignore = 'headers sortForce sortList sortAppend widgets'.split( ' ' ),
- orig = c.originalSettings;
- if ( orig ) {
- if ( ts.debug(c, 'core') ) {
- timer = new Date();
- }
- for ( setting in orig ) {
- typ = typeof ts.defaults[setting];
- if ( typ === 'undefined' ) {
- console.warn( 'Tablesorter Warning! "table.config.' + setting + '" option not recognized' );
- } else if ( typ === 'object' ) {
- for ( setting2 in orig[setting] ) {
- typ = ts.defaults[setting] && typeof ts.defaults[setting][setting2];
- if ( $.inArray( setting, ignore ) < 0 && typ === 'undefined' ) {
- console.warn( 'Tablesorter Warning! "table.config.' + setting + '.' + setting2 + '" option not recognized' );
- }
- }
- }
- }
- if ( ts.debug(c, 'core') ) {
- console.log( 'validate options time:' + ts.benchmark( timer ) );
- }
- }
- },
-
- // restore headers
- restoreHeaders : function( table ) {
- var index, $cell,
- c = $( table )[ 0 ].config,
- $headers = c.$table.find( c.selectorHeaders ),
- len = $headers.length;
- // don't use c.$headers here in case header cells were swapped
- for ( index = 0; index < len; index++ ) {
- $cell = $headers.eq( index );
- // only restore header cells if it is wrapped
- // because this is also used by the updateAll method
- if ( $cell.find( '.' + ts.css.headerIn ).length ) {
- $cell.html( c.headerContent[ index ] );
- }
- }
- },
-
- destroy : function( table, removeClasses, callback ) {
- table = $( table )[ 0 ];
- if ( !table.hasInitialized ) { return; }
- // remove all widgets
- ts.removeWidget( table, true, false );
- var events,
- $t = $( table ),
- c = table.config,
- $h = $t.find( 'thead:first' ),
- $r = $h.find( 'tr.' + ts.css.headerRow ).removeClass( ts.css.headerRow + ' ' + c.cssHeaderRow ),
- $f = $t.find( 'tfoot:first > tr' ).children( 'th, td' );
- if ( removeClasses === false && $.inArray( 'uitheme', c.widgets ) >= 0 ) {
- // reapply uitheme classes, in case we want to maintain appearance
- $t.triggerHandler( 'applyWidgetId', [ 'uitheme' ] );
- $t.triggerHandler( 'applyWidgetId', [ 'zebra' ] );
- }
- // remove widget added rows, just in case
- $h.find( 'tr' ).not( $r ).remove();
- // disable tablesorter - not using .unbind( namespace ) because namespacing was
- // added in jQuery v1.4.3 - see http://api.jquery.com/event.namespace/
- events = 'sortReset update updateRows updateAll updateHeaders updateCell addRows updateComplete sorton ' +
- 'appendCache updateCache applyWidgetId applyWidgets refreshWidgets removeWidget destroy mouseup mouseleave ' +
- 'keypress sortBegin sortEnd resetToLoadState '.split( ' ' )
- .join( c.namespace + ' ' );
- $t
- .removeData( 'tablesorter' )
- .unbind( events.replace( ts.regex.spaces, ' ' ) );
- c.$headers
- .add( $f )
- .removeClass( [ ts.css.header, c.cssHeader, c.cssAsc, c.cssDesc, ts.css.sortAsc, ts.css.sortDesc, ts.css.sortNone ].join( ' ' ) )
- .removeAttr( 'data-column' )
- .removeAttr( 'aria-label' )
- .attr( 'aria-disabled', 'true' );
- $r
- .find( c.selectorSort )
- .unbind( ( 'mousedown mouseup keypress '.split( ' ' ).join( c.namespace + ' ' ) ).replace( ts.regex.spaces, ' ' ) );
- ts.restoreHeaders( table );
- $t.toggleClass( ts.css.table + ' ' + c.tableClass + ' tablesorter-' + c.theme, removeClasses === false );
- $t.removeClass(c.namespace.slice(1));
- // clear flag in case the plugin is initialized again
- table.hasInitialized = false;
- delete table.config.cache;
- if ( typeof callback === 'function' ) {
- callback( table );
- }
- if ( ts.debug(c, 'core') ) {
- console.log( 'tablesorter has been removed' );
- }
- }
-
- };
-
- $.fn.tablesorter = function( settings ) {
- return this.each( function() {
- var table = this,
- // merge & extend config options
- c = $.extend( true, {}, ts.defaults, settings, ts.instanceMethods );
- // save initial settings
- c.originalSettings = settings;
- // create a table from data (build table widget)
- if ( !table.hasInitialized && ts.buildTable && this.nodeName !== 'TABLE' ) {
- // return the table (in case the original target is the table's container)
- ts.buildTable( table, c );
- } else {
- ts.setup( table, c );
- }
- });
- };
-
- // set up debug logs
- if ( !( window.console && window.console.log ) ) {
- // access $.tablesorter.logs for browsers that don't have a console...
- ts.logs = [];
- /*jshint -W020 */
- console = {};
- console.log = console.warn = console.error = console.table = function() {
- var arg = arguments.length > 1 ? arguments : arguments[0];
- ts.logs[ ts.logs.length ] = { date: Date.now(), log: arg };
- };
- }
-
- // add default parsers
- ts.addParser({
- id : 'no-parser',
- is : function() {
- return false;
- },
- format : function() {
- return '';
- },
- type : 'text'
- });
-
- ts.addParser({
- id : 'text',
- is : function() {
- return true;
- },
- format : function( str, table ) {
- var c = table.config;
- if ( str ) {
- str = $.trim( c.ignoreCase ? str.toLocaleLowerCase() : str );
- str = c.sortLocaleCompare ? ts.replaceAccents( str ) : str;
- }
- return str;
- },
- type : 'text'
- });
-
- ts.regex.nondigit = /[^\w,. \-()]/g;
- ts.addParser({
- id : 'digit',
- is : function( str ) {
- return ts.isDigit( str );
- },
- format : function( str, table ) {
- var num = ts.formatFloat( ( str || '' ).replace( ts.regex.nondigit, '' ), table );
- return str && typeof num === 'number' ? num :
- str ? $.trim( str && table.config.ignoreCase ? str.toLocaleLowerCase() : str ) : str;
- },
- type : 'numeric'
- });
-
- ts.regex.currencyReplace = /[+\-,. ]/g;
- ts.regex.currencyTest = /^\(?\d+[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]|[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]\d+\)?$/;
- ts.addParser({
- id : 'currency',
- is : function( str ) {
- str = ( str || '' ).replace( ts.regex.currencyReplace, '' );
- // test for £$€¤¥¢
- return ts.regex.currencyTest.test( str );
- },
- format : function( str, table ) {
- var num = ts.formatFloat( ( str || '' ).replace( ts.regex.nondigit, '' ), table );
- return str && typeof num === 'number' ? num :
- str ? $.trim( str && table.config.ignoreCase ? str.toLocaleLowerCase() : str ) : str;
- },
- type : 'numeric'
- });
-
- // too many protocols to add them all https://en.wikipedia.org/wiki/URI_scheme
- // now, this regex can be updated before initialization
- ts.regex.urlProtocolTest = /^(https?|ftp|file):\/\//;
- ts.regex.urlProtocolReplace = /(https?|ftp|file):\/\/(www\.)?/;
- ts.addParser({
- id : 'url',
- is : function( str ) {
- return ts.regex.urlProtocolTest.test( str );
- },
- format : function( str ) {
- return str ? $.trim( str.replace( ts.regex.urlProtocolReplace, '' ) ) : str;
- },
- type : 'text'
- });
-
- ts.regex.dash = /-/g;
- ts.regex.isoDate = /^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}/;
- ts.addParser({
- id : 'isoDate',
- is : function( str ) {
- return ts.regex.isoDate.test( str );
- },
- format : function( str ) {
- var date = str ? new Date( str.replace( ts.regex.dash, '/' ) ) : str;
- return date instanceof Date && isFinite( date ) ? date.getTime() : str;
- },
- type : 'numeric'
- });
-
- ts.regex.percent = /%/g;
- ts.regex.percentTest = /(\d\s*?%|%\s*?\d)/;
- ts.addParser({
- id : 'percent',
- is : function( str ) {
- return ts.regex.percentTest.test( str ) && str.length < 15;
- },
- format : function( str, table ) {
- return str ? ts.formatFloat( str.replace( ts.regex.percent, '' ), table ) : str;
- },
- type : 'numeric'
- });
-
- // added image parser to core v2.17.9
- ts.addParser({
- id : 'image',
- is : function( str, table, node, $node ) {
- return $node.find( 'img' ).length > 0;
- },
- format : function( str, table, cell ) {
- return $( cell ).find( 'img' ).attr( table.config.imgAttr || 'alt' ) || str;
- },
- parsed : true, // filter widget flag
- type : 'text'
- });
-
- ts.regex.dateReplace = /(\S)([AP]M)$/i; // used by usLongDate & time parser
- ts.regex.usLongDateTest1 = /^[A-Z]{3,10}\.?\s+\d{1,2},?\s+(\d{4})(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?$/i;
- ts.regex.usLongDateTest2 = /^\d{1,2}\s+[A-Z]{3,10}\s+\d{4}/i;
- ts.addParser({
- id : 'usLongDate',
- is : function( str ) {
- // two digit years are not allowed cross-browser
- // Jan 01, 2013 12:34:56 PM or 01 Jan 2013
- return ts.regex.usLongDateTest1.test( str ) || ts.regex.usLongDateTest2.test( str );
- },
- format : function( str ) {
- var date = str ? new Date( str.replace( ts.regex.dateReplace, '$1 $2' ) ) : str;
- return date instanceof Date && isFinite( date ) ? date.getTime() : str;
- },
- type : 'numeric'
- });
-
- // testing for ##-##-#### or ####-##-##, so it's not perfect; time can be included
- ts.regex.shortDateTest = /(^\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4})|(^\d{4}[\/\s]\d{1,2}[\/\s]\d{1,2})/;
- // escaped "-" because JSHint in Firefox was showing it as an error
- ts.regex.shortDateReplace = /[\-.,]/g;
- // XXY covers MDY & DMY formats
- ts.regex.shortDateXXY = /(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/;
- ts.regex.shortDateYMD = /(\d{4})[\/\s](\d{1,2})[\/\s](\d{1,2})/;
- ts.convertFormat = function( dateString, format ) {
- dateString = ( dateString || '' )
- .replace( ts.regex.spaces, ' ' )
- .replace( ts.regex.shortDateReplace, '/' );
- if ( format === 'mmddyyyy' ) {
- dateString = dateString.replace( ts.regex.shortDateXXY, '$3/$1/$2' );
- } else if ( format === 'ddmmyyyy' ) {
- dateString = dateString.replace( ts.regex.shortDateXXY, '$3/$2/$1' );
- } else if ( format === 'yyyymmdd' ) {
- dateString = dateString.replace( ts.regex.shortDateYMD, '$1/$2/$3' );
- }
- var date = new Date( dateString );
- return date instanceof Date && isFinite( date ) ? date.getTime() : '';
- };
-
- ts.addParser({
- id : 'shortDate', // 'mmddyyyy', 'ddmmyyyy' or 'yyyymmdd'
- is : function( str ) {
- str = ( str || '' ).replace( ts.regex.spaces, ' ' ).replace( ts.regex.shortDateReplace, '/' );
- return ts.regex.shortDateTest.test( str );
- },
- format : function( str, table, cell, cellIndex ) {
- if ( str ) {
- var c = table.config,
- $header = c.$headerIndexed[ cellIndex ],
- format = $header.length && $header.data( 'dateFormat' ) ||
- ts.getData( $header, ts.getColumnData( table, c.headers, cellIndex ), 'dateFormat' ) ||
- c.dateFormat;
- // save format because getData can be slow...
- if ( $header.length ) {
- $header.data( 'dateFormat', format );
- }
- return ts.convertFormat( str, format ) || str;
- }
- return str;
- },
- type : 'numeric'
- });
-
- // match 24 hour time & 12 hours time + am/pm - see http://regexr.com/3c3tk
- ts.regex.timeTest = /^(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)$|^((?:[01]\d|[2][0-4]):[0-5]\d)$/i;
- ts.regex.timeMatch = /(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)|((?:[01]\d|[2][0-4]):[0-5]\d)/i;
- ts.addParser({
- id : 'time',
- is : function( str ) {
- return ts.regex.timeTest.test( str );
- },
- format : function( str ) {
- // isolate time... ignore month, day and year
- var temp,
- timePart = ( str || '' ).match( ts.regex.timeMatch ),
- orig = new Date( str ),
- // no time component? default to 00:00 by leaving it out, but only if str is defined
- time = str && ( timePart !== null ? timePart[ 0 ] : '00:00 AM' ),
- date = time ? new Date( '2000/01/01 ' + time.replace( ts.regex.dateReplace, '$1 $2' ) ) : time;
- if ( date instanceof Date && isFinite( date ) ) {
- temp = orig instanceof Date && isFinite( orig ) ? orig.getTime() : 0;
- // if original string was a valid date, add it to the decimal so the column sorts in some kind of order
- // luckily new Date() ignores the decimals
- return temp ? parseFloat( date.getTime() + '.' + orig.getTime() ) : date.getTime();
- }
- return str;
- },
- type : 'numeric'
- });
-
- ts.addParser({
- id : 'metadata',
- is : function() {
- return false;
- },
- format : function( str, table, cell ) {
- var c = table.config,
- p = ( !c.parserMetadataName ) ? 'sortValue' : c.parserMetadataName;
- return $( cell ).metadata()[ p ];
- },
- type : 'numeric'
- });
-
- /*
- ██████ ██████ █████▄ █████▄ ▄████▄
- ▄█▀ ██▄▄ ██▄▄██ ██▄▄██ ██▄▄██
- ▄█▀ ██▀▀ ██▀▀██ ██▀▀█ ██▀▀██
- ██████ ██████ █████▀ ██ ██ ██ ██
- */
- // add default widgets
- ts.addWidget({
- id : 'zebra',
- priority : 90,
- format : function( table, c, wo ) {
- var $visibleRows, $row, count, isEven, tbodyIndex, rowIndex, len,
- child = new RegExp( c.cssChildRow, 'i' ),
- $tbodies = c.$tbodies.add( $( c.namespace + '_extra_table' ).children( 'tbody:not(.' + c.cssInfoBlock + ')' ) );
- for ( tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
- // loop through the visible rows
- count = 0;
- $visibleRows = $tbodies.eq( tbodyIndex ).children( 'tr:visible' ).not( c.selectorRemove );
- len = $visibleRows.length;
- for ( rowIndex = 0; rowIndex < len; rowIndex++ ) {
- $row = $visibleRows.eq( rowIndex );
- // style child rows the same way the parent row was styled
- if ( !child.test( $row[ 0 ].className ) ) { count++; }
- isEven = ( count % 2 === 0 );
- $row
- .removeClass( wo.zebra[ isEven ? 1 : 0 ] )
- .addClass( wo.zebra[ isEven ? 0 : 1 ] );
- }
- }
- },
- remove : function( table, c, wo, refreshing ) {
- if ( refreshing ) { return; }
- var tbodyIndex, $tbody,
- $tbodies = c.$tbodies,
- toRemove = ( wo.zebra || [ 'even', 'odd' ] ).join( ' ' );
- for ( tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
- $tbody = ts.processTbody( table, $tbodies.eq( tbodyIndex ), true ); // remove tbody
- $tbody.children().removeClass( toRemove );
- ts.processTbody( table, $tbody, false ); // restore tbody
- }
- }
- });
-
-})( jQuery );
+!function(e){"use strict";var t=e.tablesorter={version:"2.31.1",parsers:[],widgets:[],defaults:{theme:"default",widthFixed:!1,showProcessing:!1,headerTemplate:"{content}",onRenderTemplate:null,onRenderHeader:null,cancelSelection:!0,tabIndex:!0,dateFormat:"mmddyyyy",sortMultiSortKey:"shiftKey",sortResetKey:"ctrlKey",usNumberFormat:!0,delayInit:!1,serverSideSorting:!1,resort:!0,headers:{},ignoreCase:!0,sortForce:null,sortList:[],sortAppend:null,sortStable:!1,sortInitialOrder:"asc",sortLocaleCompare:!1,sortReset:!1,sortRestart:!1,emptyTo:"bottom",stringTo:"max",duplicateSpan:!0,textExtraction:"basic",textAttribute:"data-text",textSorter:null,numberSorter:null,initWidgets:!0,widgetClass:"widget-{name}",widgets:[],widgetOptions:{zebra:["even","odd"]},initialized:null,tableClass:"",cssAsc:"",cssDesc:"",cssNone:"",cssHeader:"",cssHeaderRow:"",cssProcessing:"",cssChildRow:"tablesorter-childRow",cssInfoBlock:"tablesorter-infoOnly",cssNoSort:"tablesorter-noSort",cssIgnoreRow:"tablesorter-ignoreRow",cssIcon:"tablesorter-icon",cssIconNone:"",cssIconAsc:"",cssIconDesc:"",cssIconDisabled:"",pointerClick:"click",pointerDown:"mousedown",pointerUp:"mouseup",selectorHeaders:"> thead th, > thead td",selectorSort:"th, td",selectorRemove:".remove-me",debug:!1,headerList:[],empties:{},strings:{},parsers:[],globalize:0,imgAttr:0},css:{table:"tablesorter",cssHasChild:"tablesorter-hasChildRow",childRow:"tablesorter-childRow",colgroup:"tablesorter-colgroup",header:"tablesorter-header",headerRow:"tablesorter-headerRow",headerIn:"tablesorter-header-inner",icon:"tablesorter-icon",processing:"tablesorter-processing",sortAsc:"tablesorter-headerAsc",sortDesc:"tablesorter-headerDesc",sortNone:"tablesorter-headerUnSorted"},language:{sortAsc:"Ascending sort applied, ",sortDesc:"Descending sort applied, ",sortNone:"No sort applied, ",sortDisabled:"sorting is disabled",nextAsc:"activate to apply an ascending sort",nextDesc:"activate to apply a descending sort",nextNone:"activate to remove the sort"},regex:{templateContent:/\{content\}/g,templateIcon:/\{icon\}/g,templateName:/\{name\}/i,spaces:/\s+/g,nonWord:/\W/g,formElements:/(input|select|button|textarea)/i,chunk:/(^([+\-]?(?:\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,chunks:/(^\\0|\\0$)/,hex:/^0x[0-9a-f]+$/i,comma:/,/g,digitNonUS:/[\s|\.]/g,digitNegativeTest:/^\s*\([.\d]+\)/,digitNegativeReplace:/^\s*\(([.\d]+)\)/,digitTest:/^[\-+(]?\d+[)]?$/,digitReplace:/[,.'"\s]/g},string:{max:1,min:-1,emptymin:1,emptymax:-1,zero:0,none:0,null:0,top:!0,bottom:!1},keyCodes:{enter:13},dates:{},instanceMethods:{},setup:function(r,s){if(r&&r.tHead&&0!==r.tBodies.length&&!0!==r.hasInitialized){var o,a="",n=e(r),i=e.metadata;r.hasInitialized=!1,r.isProcessing=!0,r.config=s,e.data(r,"tablesorter",s),t.debug(s,"core")&&(console[console.group?"group":"log"]("Initializing tablesorter v"+t.version),e.data(r,"startoveralltimer",new Date)),s.supportsDataObject=((o=e.fn.jquery.split("."))[0]=parseInt(o[0],10),o[0]>1||1===o[0]&&parseInt(o[1],10)>=4),s.emptyTo=s.emptyTo.toLowerCase(),s.stringTo=s.stringTo.toLowerCase(),s.last={sortList:[],clickedIndex:-1},/tablesorter\-/.test(n.attr("class"))||(a=""!==s.theme?" tablesorter-"+s.theme:""),s.namespace?s.namespace="."+s.namespace.replace(t.regex.nonWord,""):s.namespace=".tablesorter"+Math.random().toString(16).slice(2),s.table=r,s.$table=n.addClass(t.css.table+" "+s.tableClass+a+" "+s.namespace.slice(1)).attr("role","grid"),s.$headers=n.find(s.selectorHeaders),s.$table.children().children("tr").attr("role","row"),s.$tbodies=n.children("tbody:not(."+s.cssInfoBlock+")").attr({"aria-live":"polite","aria-relevant":"all"}),s.$table.children("caption").length&&((a=s.$table.children("caption")[0]).id||(a.id=s.namespace.slice(1)+"caption"),s.$table.attr("aria-labelledby",a.id)),s.widgetInit={},s.textExtraction=s.$table.attr("data-text-extraction")||s.textExtraction||"basic",t.buildHeaders(s),t.fixColumnWidth(r),t.addWidgetFromClass(r),t.applyWidgetOptions(r),t.setupParsers(s),s.totalRows=0,s.debug&&t.validateOptions(s),s.delayInit||t.buildCache(s),t.bindEvents(r,s.$headers,!0),t.bindMethods(s),s.supportsDataObject&&void 0!==n.data().sortlist?s.sortList=n.data().sortlist:i&&n.metadata()&&n.metadata().sortlist&&(s.sortList=n.metadata().sortlist),t.applyWidget(r,!0),s.sortList.length>0?(s.last.sortList=s.sortList,t.sortOn(s,s.sortList,{},!s.initWidgets)):(t.setHeadersCss(s),s.initWidgets&&t.applyWidget(r,!1)),s.showProcessing&&n.unbind("sortBegin"+s.namespace+" sortEnd"+s.namespace).bind("sortBegin"+s.namespace+" sortEnd"+s.namespace,function(e){clearTimeout(s.timerProcessing),t.isProcessing(r),"sortBegin"===e.type&&(s.timerProcessing=setTimeout(function(){t.isProcessing(r,!0)},500))}),r.hasInitialized=!0,r.isProcessing=!1,t.debug(s,"core")&&(console.log("Overall initialization time:"+t.benchmark(e.data(r,"startoveralltimer"))),t.debug(s,"core")&&console.groupEnd&&console.groupEnd()),n.triggerHandler("tablesorter-initialized",r),"function"==typeof s.initialized&&s.initialized(r)}else t.debug(s,"core")&&(r.hasInitialized?console.warn("Stopping initialization. Tablesorter has already been initialized"):console.error("Stopping initialization! No table, thead or tbody",r))},bindMethods:function(r){var s=r.$table,o=r.namespace,a="sortReset update updateRows updateAll updateHeaders addRows updateCell updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave ".split(" ").join(o+" ");s.unbind(a.replace(t.regex.spaces," ")).bind("sortReset"+o,function(e,r){e.stopPropagation(),t.sortReset(this.config,function(e){e.isApplyingWidgets?setTimeout(function(){t.applyWidget(e,"",r)},100):t.applyWidget(e,"",r)})}).bind("updateAll"+o,function(e,r,s){e.stopPropagation(),t.updateAll(this.config,r,s)}).bind("update"+o+" updateRows"+o,function(e,r,s){e.stopPropagation(),t.update(this.config,r,s)}).bind("updateHeaders"+o,function(e,r){e.stopPropagation(),t.updateHeaders(this.config,r)}).bind("updateCell"+o,function(e,r,s,o){e.stopPropagation(),t.updateCell(this.config,r,s,o)}).bind("addRows"+o,function(e,r,s,o){e.stopPropagation(),t.addRows(this.config,r,s,o)}).bind("updateComplete"+o,function(){this.isUpdating=!1}).bind("sorton"+o,function(e,r,s,o){e.stopPropagation(),t.sortOn(this.config,r,s,o)}).bind("appendCache"+o,function(r,s,o){r.stopPropagation(),t.appendCache(this.config,o),e.isFunction(s)&&s(this)}).bind("updateCache"+o,function(e,r,s){e.stopPropagation(),t.updateCache(this.config,r,s)}).bind("applyWidgetId"+o,function(e,r){e.stopPropagation(),t.applyWidgetId(this,r)}).bind("applyWidgets"+o,function(e,r){e.stopPropagation(),t.applyWidget(this,!1,r)}).bind("refreshWidgets"+o,function(e,r,s){e.stopPropagation(),t.refreshWidgets(this,r,s)}).bind("removeWidget"+o,function(e,r,s){e.stopPropagation(),t.removeWidget(this,r,s)}).bind("destroy"+o,function(e,r,s){e.stopPropagation(),t.destroy(this,r,s)}).bind("resetToLoadState"+o,function(s){s.stopPropagation(),t.removeWidget(this,!0,!1);var o=e.extend(!0,{},r.originalSettings);(r=e.extend(!0,{},t.defaults,o)).originalSettings=o,this.hasInitialized=!1,t.setup(this,r)})},bindEvents:function(r,s,o){var a,n=(r=e(r)[0]).config,i=n.namespace,l=null;!0!==o&&(s.addClass(i.slice(1)+"_extra_headers"),(a=t.getClosest(s,"table")).length&&"TABLE"===a[0].nodeName&&a[0]!==r&&e(a[0]).addClass(i.slice(1)+"_extra_table")),a=(n.pointerDown+" "+n.pointerUp+" "+n.pointerClick+" sort keyup ").replace(t.regex.spaces," ").split(" ").join(i+" "),s.find(n.selectorSort).add(s.filter(n.selectorSort)).unbind(a).bind(a,function(r,s){var o,a,i,d=e(r.target),c=" "+r.type+" ";if(!(1!==(r.which||r.button)&&!c.match(" "+n.pointerClick+" | sort | keyup ")||" keyup "===c&&r.which!==t.keyCodes.enter||c.match(" "+n.pointerClick+" ")&&void 0!==r.which||c.match(" "+n.pointerUp+" ")&&l!==r.target&&!0!==s)){if(c.match(" "+n.pointerDown+" "))return l=r.target,void("1"===(i=d.jquery.split("."))[0]&&i[1]<4&&r.preventDefault());if(l=null,o=t.getClosest(e(this),"."+t.css.header),t.regex.formElements.test(r.target.nodeName)||d.hasClass(n.cssNoSort)||d.parents("."+n.cssNoSort).length>0||o.hasClass("sorter-false")||d.parents("button").length>0)return!n.cancelSelection;n.delayInit&&t.isEmptyObject(n.cache)&&t.buildCache(n),n.last.clickedIndex=o.attr("data-column")||o.index(),(a=n.$headerIndexed[n.last.clickedIndex][0])&&!a.sortDisabled&&t.initSort(n,a,r)}}),n.cancelSelection&&s.attr("unselectable","on").bind("selectstart",!1).css({"user-select":"none",MozUserSelect:"none"})},buildHeaders:function(r){var s,o,a,n;for(r.headerList=[],r.headerContent=[],r.sortVars=[],t.debug(r,"core")&&(a=new Date),r.columns=t.computeColumnIndex(r.$table.children("thead, tfoot").children("tr")),o=r.cssIcon?'<i class="'+(r.cssIcon===t.css.icon?t.css.icon:r.cssIcon+" "+t.css.icon)+'"></i>':"",r.$headers=e(e.map(r.$table.find(r.selectorHeaders),function(s,a){var n,i,l,d,c,g=e(s);if(!t.getClosest(g,"tr").hasClass(r.cssIgnoreRow))return/(th|td)/i.test(s.nodeName)||(c=t.getClosest(g,"th, td"),g.attr("data-column",c.attr("data-column"))),n=t.getColumnData(r.table,r.headers,a,!0),r.headerContent[a]=g.html(),""===r.headerTemplate||g.find("."+t.css.headerIn).length||(d=r.headerTemplate.replace(t.regex.templateContent,g.html()).replace(t.regex.templateIcon,g.find("."+t.css.icon).length?"":o),r.onRenderTemplate&&(i=r.onRenderTemplate.apply(g,[a,d]))&&"string"==typeof i&&(d=i),g.html('<div class="'+t.css.headerIn+'">'+d+"</div>")),r.onRenderHeader&&r.onRenderHeader.apply(g,[a,r,r.$table]),l=parseInt(g.attr("data-column"),10),s.column=l,c=t.getOrder(t.getData(g,n,"sortInitialOrder")||r.sortInitialOrder),r.sortVars[l]={count:-1,order:c?r.sortReset?[1,0,2]:[1,0]:r.sortReset?[0,1,2]:[0,1],lockedOrder:!1,sortedBy:""},void 0!==(c=t.getData(g,n,"lockedOrder")||!1)&&!1!==c&&(r.sortVars[l].lockedOrder=!0,r.sortVars[l].order=t.getOrder(c)?[1,1]:[0,0]),r.headerList[a]=s,g.addClass(t.css.header+" "+r.cssHeader),t.getClosest(g,"tr").addClass(t.css.headerRow+" "+r.cssHeaderRow).attr("role","row"),r.tabIndex&&g.attr("tabindex",0),s})),r.$headerIndexed=[],n=0;n<r.columns;n++)t.isEmptyObject(r.sortVars[n])&&(r.sortVars[n]={}),s=r.$headers.filter('[data-column="'+n+'"]'),r.$headerIndexed[n]=s.length?s.not(".sorter-false").length?s.not(".sorter-false").filter(":last"):s.filter(":last"):e();r.$table.find(r.selectorHeaders).attr({scope:"col",role:"columnheader"}),t.updateHeader(r),t.debug(r,"core")&&(console.log("Built headers:"+t.benchmark(a)),console.log(r.$headers))},addInstanceMethods:function(r){e.extend(t.instanceMethods,r)},setupParsers:function(e,r){var s,o,a,n,i,l,d,c,g,p,u,f,h,m,b=e.table,y=0,w=t.debug(e,"core"),x={};if(e.$tbodies=e.$table.children("tbody:not(."+e.cssInfoBlock+")"),0===(m=(h=void 0===r?e.$tbodies:r).length))return w?console.warn("Warning: *Empty table!* Not building a parser cache"):"";for(w&&(f=new Date,console[console.group?"group":"log"]("Detecting parsers for each column")),o={extractors:[],parsers:[]};y<m;){if((s=h[y].rows).length)for(i=0,n=e.columns,l=0;l<n;l++){if((d=e.$headerIndexed[i])&&d.length&&(c=t.getColumnData(b,e.headers,i),u=t.getParserById(t.getData(d,c,"extractor")),p=t.getParserById(t.getData(d,c,"sorter")),g="false"===t.getData(d,c,"parser"),e.empties[i]=(t.getData(d,c,"empty")||e.emptyTo||(e.emptyToBottom?"bottom":"top")).toLowerCase(),e.strings[i]=(t.getData(d,c,"string")||e.stringTo||"max").toLowerCase(),g&&(p=t.getParserById("no-parser")),u||(u=!1),p||(p=t.detectParserForColumn(e,s,-1,i)),w&&(x["("+i+") "+d.text()]={parser:p.id,extractor:u?u.id:"none",string:e.strings[i],empty:e.empties[i]}),o.parsers[i]=p,o.extractors[i]=u,(a=d[0].colSpan-1)>0))for(i+=a,n+=a;a+1>0;)o.parsers[i-a]=p,o.extractors[i-a]=u,a--;i++}y+=o.parsers.length?m:1}w&&(t.isEmptyObject(x)?console.warn(" No parsers detected!"):console[console.table?"table":"log"](x),console.log("Completed detecting parsers"+t.benchmark(f)),console.groupEnd&&console.groupEnd()),e.parsers=o.parsers,e.extractors=o.extractors},addParser:function(e){var r,s=t.parsers.length,o=!0;for(r=0;r<s;r++)t.parsers[r].id.toLowerCase()===e.id.toLowerCase()&&(o=!1);o&&(t.parsers[t.parsers.length]=e)},getParserById:function(e){if("false"==e)return!1;var r,s=t.parsers.length;for(r=0;r<s;r++)if(t.parsers[r].id.toLowerCase()===e.toString().toLowerCase())return t.parsers[r];return!1},detectParserForColumn:function(r,s,o,a){for(var n,i,l,d=t.parsers.length,c=!1,g="",p=t.debug(r,"core"),u=!0;""===g&&u;)(l=s[++o])&&o<50?l.className.indexOf(t.cssIgnoreRow)<0&&(c=s[o].cells[a],g=t.getElementText(r,c,a),i=e(c),p&&console.log("Checking if value was empty on row "+o+", column: "+a+': "'+g+'"')):u=!1;for(;--d>=0;)if((n=t.parsers[d])&&"text"!==n.id&&n.is&&n.is(g,r.table,c,i))return n;return t.getParserById("text")},getElementText:function(r,s,o){if(!s)return"";var a,n=r.textExtraction||"",i=s.jquery?s:e(s);return"string"==typeof n?"basic"===n&&void 0!==(a=i.attr(r.textAttribute))?e.trim(a):e.trim(s.textContent||i.text()):"function"==typeof n?e.trim(n(i[0],r.table,o)):"function"==typeof(a=t.getColumnData(r.table,n,o))?e.trim(a(i[0],r.table,o)):e.trim(i[0].textContent||i.text())},getParsedText:function(e,r,s,o){void 0===o&&(o=t.getElementText(e,r,s));var a=""+o,n=e.parsers[s],i=e.extractors[s];return n&&(i&&"function"==typeof i.format&&(o=i.format(o,e.table,r,s)),a="no-parser"===n.id?"":n.format(""+o,e.table,r,s),e.ignoreCase&&"string"==typeof a&&(a=a.toLowerCase())),a},buildCache:function(r,s,o){var a,n,i,l,d,c,g,p,u,f,h,m,b,y,w,x,v,C,$,I,D,R,T=r.table,A=r.parsers,L=t.debug(r,"core");if(r.$tbodies=r.$table.children("tbody:not(."+r.cssInfoBlock+")"),g=void 0===o?r.$tbodies:o,r.cache={},r.totalRows=0,!A)return L?console.warn("Warning: *Empty table!* Not building a cache"):"";for(L&&(m=new Date),r.showProcessing&&t.isProcessing(T,!0),c=0;c<g.length;c++){for(x=[],a=r.cache[c]={normalized:[]},b=g[c]&&g[c].rows.length||0,l=0;l<b;++l)if(y={child:[],raw:[]},u=[],!(p=e(g[c].rows[l])).hasClass(r.selectorRemove.slice(1)))if(p.hasClass(r.cssChildRow)&&0!==l)for(D=a.normalized.length-1,(w=a.normalized[D][r.columns]).$row=w.$row.add(p),p.prev().hasClass(r.cssChildRow)||p.prev().addClass(t.css.cssHasChild),f=p.children("th, td"),D=w.child.length,w.child[D]=[],C=0,I=r.columns,d=0;d<I;d++)(h=f[d])&&(w.child[D][d]=t.getParsedText(r,h,d),(v=f[d].colSpan-1)>0&&(C+=v,I+=v)),C++;else{for(y.$row=p,y.order=l,C=0,I=r.columns,d=0;d<I;++d){if((h=p[0].cells[d])&&C<r.columns&&(!($=void 0!==A[C])&&L&&console.warn("No parser found for row: "+l+", column: "+d+'; cell containing: "'+e(h).text()+'"; does it have a header?'),n=t.getElementText(r,h,C),y.raw[C]=n,i=t.getParsedText(r,h,C,n),u[C]=i,$&&"numeric"===(A[C].type||"").toLowerCase()&&(x[C]=Math.max(Math.abs(i)||0,x[C]||0)),(v=h.colSpan-1)>0)){for(R=0;R<=v;)i=r.duplicateSpan||0===R?n:"string"!=typeof r.textExtraction&&t.getElementText(r,h,C+R)||"",y.raw[C+R]=i,u[C+R]=i,R++;C+=v,I+=v}C++}u[r.columns]=y,a.normalized[a.normalized.length]=u}a.colMax=x,r.totalRows+=a.normalized.length}if(r.showProcessing&&t.isProcessing(T),L){for(D=Math.min(5,r.cache[0].normalized.length),console[console.group?"group":"log"]("Building cache for "+r.totalRows+" rows (showing "+D+" rows in log) and "+r.columns+" columns"+t.benchmark(m)),n={},d=0;d<r.columns;d++)for(C=0;C<D;C++)n["row: "+C]||(n["row: "+C]={}),n["row: "+C][r.$headerIndexed[d].text()]=r.cache[0].normalized[C][d];console[console.table?"table":"log"](n),console.groupEnd&&console.groupEnd()}e.isFunction(s)&&s(T)},getColumnText:function(r,s,o,a){var n,i,l,d,c,g,p,u,f,h,m="function"==typeof o,b="all"===s,y={raw:[],parsed:[],$cell:[]},w=(r=e(r)[0]).config;if(!t.isEmptyObject(w)){for(c=w.$tbodies.length,n=0;n<c;n++)for(g=(l=w.cache[n].normalized).length,i=0;i<g;i++)d=l[i],a&&!d[w.columns].$row.is(a)||(h=!0,u=b?d.slice(0,w.columns):d[s],d=d[w.columns],p=b?d.raw:d.raw[s],f=b?d.$row.children():d.$row.children().eq(s),m&&(h=o({tbodyIndex:n,rowIndex:i,parsed:u,raw:p,$row:d.$row,$cell:f})),!1!==h&&(y.parsed[y.parsed.length]=u,y.raw[y.raw.length]=p,y.$cell[y.$cell.length]=f));return y}t.debug(w,"core")&&console.warn("No cache found - aborting getColumnText function!")},setHeadersCss:function(r){var s,o,a=r.sortList,n=a.length,i=t.css.sortNone+" "+r.cssNone,l=[t.css.sortAsc+" "+r.cssAsc,t.css.sortDesc+" "+r.cssDesc],d=[r.cssIconAsc,r.cssIconDesc,r.cssIconNone],c=["ascending","descending"],g=function(e,r){e.removeClass(i).addClass(l[r]).attr("aria-sort",c[r]).find("."+t.css.icon).removeClass(d[2]).addClass(d[r])},p=r.$table.find("tfoot tr").children("td, th").add(e(r.namespace+"_extra_headers")).removeClass(l.join(" ")),u=r.$headers.add(e("thead "+r.namespace+"_extra_headers")).removeClass(l.join(" ")).addClass(i).attr("aria-sort","none").find("."+t.css.icon).removeClass(d.join(" ")).end();for(u.not(".sorter-false").find("."+t.css.icon).addClass(d[2]),r.cssIconDisabled&&u.filter(".sorter-false").find("."+t.css.icon).addClass(r.cssIconDisabled),s=0;s<n;s++)if(2!==a[s][1]){if((u=(u=r.$headers.filter(function(e){for(var s=!0,o=r.$headers.eq(e),a=parseInt(o.attr("data-column"),10),n=a+t.getClosest(o,"th, td")[0].colSpan;a<n;a++)s=!!s&&(s||t.isValueInArray(a,r.sortList)>-1);return s})).not(".sorter-false").filter('[data-column="'+a[s][0]+'"]'+(1===n?":last":""))).length)for(o=0;o<u.length;o++)u[o].sortDisabled||g(u.eq(o),a[s][1]);p.length&&g(p.filter('[data-column="'+a[s][0]+'"]'),a[s][1])}for(n=r.$headers.length,s=0;s<n;s++)t.setColumnAriaLabel(r,r.$headers.eq(s))},getClosest:function(t,r){return e.fn.closest?t.closest(r):t.is(r)?t:t.parents(r).filter(":first")},setColumnAriaLabel:function(r,s,o){if(s.length){var a=parseInt(s.attr("data-column"),10),n=r.sortVars[a],i=s.hasClass(t.css.sortAsc)?"sortAsc":s.hasClass(t.css.sortDesc)?"sortDesc":"sortNone",l=e.trim(s.text())+": "+t.language[i];s.hasClass("sorter-false")||!1===o?l+=t.language.sortDisabled:(i=(n.count+1)%n.order.length,o=n.order[i],l+=t.language[0===o?"nextAsc":1===o?"nextDesc":"nextNone"]),s.attr("aria-label",l),n.sortedBy?s.attr("data-sortedBy",n.sortedBy):s.removeAttr("data-sortedBy")}},updateHeader:function(e){var r,s,o,a,n=e.table,i=e.$headers.length;for(r=0;r<i;r++)o=e.$headers.eq(r),a=t.getColumnData(n,e.headers,r,!0),s="false"===t.getData(o,a,"sorter")||"false"===t.getData(o,a,"parser"),t.setColumnSort(e,o,s)},setColumnSort:function(e,t,r){var s=e.table.id;t[0].sortDisabled=r,t[r?"addClass":"removeClass"]("sorter-false").attr("aria-disabled",""+r),e.tabIndex&&(r?t.removeAttr("tabindex"):t.attr("tabindex","0")),s&&(r?t.removeAttr("aria-controls"):t.attr("aria-controls",s))},updateHeaderSortCount:function(r,s){var o,a,n,i,l,d,c,g,p=s||r.sortList,u=p.length;for(r.sortList=[],i=0;i<u;i++)if(c=p[i],(o=parseInt(c[0],10))<r.columns){switch(r.sortVars[o].order||(g=t.getOrder(r.sortInitialOrder)?r.sortReset?[1,0,2]:[1,0]:r.sortReset?[0,1,2]:[0,1],r.sortVars[o].order=g,r.sortVars[o].count=0),g=r.sortVars[o].order,a=(a=(""+c[1]).match(/^(1|d|s|o|n)/))?a[0]:""){case"1":case"d":a=1;break;case"s":a=l||0;break;case"o":a=0===(d=g[(l||0)%g.length])?1:1===d?0:2;break;case"n":a=g[++r.sortVars[o].count%g.length];break;default:a=0}l=0===i?a:l,n=[o,parseInt(a,10)||0],r.sortList[r.sortList.length]=n,a=e.inArray(n[1],g),r.sortVars[o].count=a>=0?a:n[1]%g.length}},updateAll:function(e,r,s){var o=e.table;o.isUpdating=!0,t.refreshWidgets(o,!0,!0),t.buildHeaders(e),t.bindEvents(o,e.$headers,!0),t.bindMethods(e),t.commonUpdate(e,r,s)},update:function(e,r,s){e.table.isUpdating=!0,t.updateHeader(e),t.commonUpdate(e,r,s)},updateHeaders:function(e,r){e.table.isUpdating=!0,t.buildHeaders(e),t.bindEvents(e.table,e.$headers,!0),t.resortComplete(e,r)},updateCell:function(r,s,o,a){if(e(s).closest("tr").hasClass(r.cssChildRow))console.warn('Tablesorter Warning! "updateCell" for child row content has been disabled, use "update" instead');else{if(t.isEmptyObject(r.cache))return t.updateHeader(r),void t.commonUpdate(r,o,a);r.table.isUpdating=!0,r.$table.find(r.selectorRemove).remove();var n,i,l,d,c,g,p=r.$tbodies,u=e(s),f=p.index(t.getClosest(u,"tbody")),h=r.cache[f],m=t.getClosest(u,"tr");if(s=u[0],p.length&&f>=0){if(l=p.eq(f).find("tr").not("."+r.cssChildRow).index(m),c=h.normalized[l],(g=m[0].cells.length)!==r.columns)for(d=0,n=!1,i=0;i<g;i++)n||m[0].cells[i]===s?n=!0:d+=m[0].cells[i].colSpan;else d=u.index();n=t.getElementText(r,s,d),c[r.columns].raw[d]=n,n=t.getParsedText(r,s,d,n),c[d]=n,"numeric"===(r.parsers[d].type||"").toLowerCase()&&(h.colMax[d]=Math.max(Math.abs(n)||0,h.colMax[d]||0)),!1!==(n="undefined"!==o?o:r.resort)?t.checkResort(r,n,a):t.resortComplete(r,a)}else t.debug(r,"core")&&console.error("updateCell aborted, tbody missing or not within the indicated table"),r.table.isUpdating=!1}},addRows:function(r,s,o,a){var n,i,l,d,c,g,p,u,f,h,m,b,y,w="string"==typeof s&&1===r.$tbodies.length&&/<tr/.test(s||""),x=r.table;if(w)s=e(s),r.$tbodies.append(s);else if(!(s&&s instanceof e&&t.getClosest(s,"table")[0]===r.table))return t.debug(r,"core")&&console.error("addRows method requires (1) a jQuery selector reference to rows that have already been added to the table, or (2) row HTML string to be added to a table with only one tbody"),!1;if(x.isUpdating=!0,t.isEmptyObject(r.cache))t.updateHeader(r),t.commonUpdate(r,o,a);else{for(c=s.filter("tr").attr("role","row").length,l=r.$tbodies.index(s.parents("tbody").filter(":first")),r.parsers&&r.parsers.length||t.setupParsers(r),d=0;d<c;d++){for(f=0,p=s[d].cells.length,u=r.cache[l].normalized.length,m=[],h={child:[],raw:[],$row:s.eq(d),order:u},g=0;g<p;g++)b=s[d].cells[g],n=t.getElementText(r,b,f),h.raw[f]=n,i=t.getParsedText(r,b,f,n),m[f]=i,"numeric"===(r.parsers[f].type||"").toLowerCase()&&(r.cache[l].colMax[f]=Math.max(Math.abs(i)||0,r.cache[l].colMax[f]||0)),(y=b.colSpan-1)>0&&(f+=y),f++;m[r.columns]=h,r.cache[l].normalized[u]=m}t.checkResort(r,o,a)}},updateCache:function(e,r,s){e.parsers&&e.parsers.length||t.setupParsers(e,s),t.buildCache(e,r,s)},appendCache:function(e,r){var s,o,a,n,i,l,d,c=e.table,g=e.$tbodies,p=[],u=e.cache;if(t.isEmptyObject(u))return e.appender?e.appender(c,p):c.isUpdating?e.$table.triggerHandler("updateComplete",c):"";for(t.debug(e,"core")&&(d=new Date),l=0;l<g.length;l++)if((a=g.eq(l)).length){for(n=t.processTbody(c,a,!0),o=(s=u[l].normalized).length,i=0;i<o;i++)p[p.length]=s[i][e.columns].$row,e.appender&&(!e.pager||e.pager.removeRows||e.pager.ajax)||n.append(s[i][e.columns].$row);t.processTbody(c,n,!1)}e.appender&&e.appender(c,p),t.debug(e,"core")&&console.log("Rebuilt table"+t.benchmark(d)),r||e.appender||t.applyWidget(c),c.isUpdating&&e.$table.triggerHandler("updateComplete",c)},commonUpdate:function(e,r,s){e.$table.find(e.selectorRemove).remove(),t.setupParsers(e),t.buildCache(e),t.checkResort(e,r,s)},initSort:function(r,s,o){if(r.table.isUpdating)return setTimeout(function(){t.initSort(r,s,o)},50);var a,n,i,l,d,c,g,p=!o[r.sortMultiSortKey],u=r.table,f=r.$headers.length,h=t.getClosest(e(s),"th, td"),m=parseInt(h.attr("data-column"),10),b="mouseup"===o.type?"user":o.type,y=r.sortVars[m].order;if(h=h[0],r.$table.triggerHandler("sortStart",u),c=(r.sortVars[m].count+1)%y.length,r.sortVars[m].count=o[r.sortResetKey]?2:c,r.sortRestart)for(i=0;i<f;i++)g=r.$headers.eq(i),m!==(c=parseInt(g.attr("data-column"),10))&&(p||g.hasClass(t.css.sortNone))&&(r.sortVars[c].count=-1);if(p){if(e.each(r.sortVars,function(e){r.sortVars[e].sortedBy=""}),r.sortList=[],r.last.sortList=[],null!==r.sortForce)for(a=r.sortForce,n=0;n<a.length;n++)a[n][0]!==m&&(r.sortList[r.sortList.length]=a[n],r.sortVars[a[n][0]].sortedBy="sortForce");if((l=y[r.sortVars[m].count])<2&&(r.sortList[r.sortList.length]=[m,l],r.sortVars[m].sortedBy=b,h.colSpan>1))for(n=1;n<h.colSpan;n++)r.sortList[r.sortList.length]=[m+n,l],r.sortVars[m+n].count=e.inArray(l,y),r.sortVars[m+n].sortedBy=b}else if(r.sortList=e.extend([],r.last.sortList),t.isValueInArray(m,r.sortList)>=0)for(r.sortVars[m].sortedBy=b,n=0;n<r.sortList.length;n++)(c=r.sortList[n])[0]===m&&(c[1]=y[r.sortVars[m].count],2===c[1]&&(r.sortList.splice(n,1),r.sortVars[m].count=-1));else if(l=y[r.sortVars[m].count],r.sortVars[m].sortedBy=b,l<2&&(r.sortList[r.sortList.length]=[m,l],h.colSpan>1))for(n=1;n<h.colSpan;n++)r.sortList[r.sortList.length]=[m+n,l],r.sortVars[m+n].count=e.inArray(l,y),r.sortVars[m+n].sortedBy=b;if(r.last.sortList=e.extend([],r.sortList),r.sortList.length&&r.sortAppend&&(a=e.isArray(r.sortAppend)?r.sortAppend:r.sortAppend[r.sortList[0][0]],!t.isEmptyObject(a)))for(n=0;n<a.length;n++)if(a[n][0]!==m&&t.isValueInArray(a[n][0],r.sortList)<0){if(d=(""+(l=a[n][1])).match(/^(a|d|s|o|n)/))switch(c=r.sortList[0][1],d[0]){case"d":l=1;break;case"s":l=c;break;case"o":l=0===c?1:0;break;case"n":l=(c+1)%y.length;break;default:l=0}r.sortList[r.sortList.length]=[a[n][0],l],r.sortVars[a[n][0]].sortedBy="sortAppend"}r.$table.triggerHandler("sortBegin",u),setTimeout(function(){t.setHeadersCss(r),t.multisort(r),t.appendCache(r),r.$table.triggerHandler("sortBeforeEnd",u),r.$table.triggerHandler("sortEnd",u)},1)},multisort:function(e){var r,s,o,a,n=e.table,i=[],l=0,d=e.textSorter||"",c=e.sortList,g=c.length,p=e.$tbodies.length;if(!e.serverSideSorting&&!t.isEmptyObject(e.cache)){if(t.debug(e,"core")&&(s=new Date),"object"==typeof d)for(o=e.columns;o--;)"function"==typeof(a=t.getColumnData(n,d,o))&&(i[o]=a);for(r=0;r<p;r++)o=e.cache[r].colMax,e.cache[r].normalized.sort(function(r,s){var a,p,u,f,h,m,b;for(a=0;a<g;a++){if(u=c[a][0],f=c[a][1],l=0===f,e.sortStable&&r[u]===s[u]&&1===g)return r[e.columns].order-s[e.columns].order;if((p=/n/i.test(t.getSortType(e.parsers,u)))&&e.strings[u]?(p="boolean"==typeof t.string[e.strings[u]]?(l?1:-1)*(t.string[e.strings[u]]?-1:1):e.strings[u]&&t.string[e.strings[u]]||0,h=e.numberSorter?e.numberSorter(r[u],s[u],l,o[u],n):t["sortNumeric"+(l?"Asc":"Desc")](r[u],s[u],p,o[u],u,e)):(m=l?r:s,b=l?s:r,h="function"==typeof d?d(m[u],b[u],l,u,n):"function"==typeof i[u]?i[u](m[u],b[u],l,u,n):t["sortNatural"+(l?"Asc":"Desc")](r[u]||"",s[u]||"",u,e)),h)return h}return r[e.columns].order-s[e.columns].order});t.debug(e,"core")&&console.log("Applying sort "+c.toString()+t.benchmark(s))}},resortComplete:function(t,r){t.table.isUpdating&&t.$table.triggerHandler("updateComplete",t.table),e.isFunction(r)&&r(t.table)},checkResort:function(r,s,o){var a=e.isArray(s)?s:r.sortList;!1===(void 0===s?r.resort:s)||r.serverSideSorting||r.table.isProcessing?(t.resortComplete(r,o),t.applyWidget(r.table,!1)):a.length?t.sortOn(r,a,function(){t.resortComplete(r,o)},!0):t.sortReset(r,function(){t.resortComplete(r,o),t.applyWidget(r.table,!1)})},sortOn:function(r,s,o,a){var n,i=r.table;for(r.$table.triggerHandler("sortStart",i),n=0;n<r.columns;n++)r.sortVars[n].sortedBy=t.isValueInArray(n,s)>-1?"sorton":"";t.updateHeaderSortCount(r,s),t.setHeadersCss(r),r.delayInit&&t.isEmptyObject(r.cache)&&t.buildCache(r),r.$table.triggerHandler("sortBegin",i),t.multisort(r),t.appendCache(r,a),r.$table.triggerHandler("sortBeforeEnd",i),r.$table.triggerHandler("sortEnd",i),t.applyWidget(i),e.isFunction(o)&&o(i)},sortReset:function(r,s){var o;for(r.sortList=[],o=0;o<r.columns;o++)r.sortVars[o].count=-1,r.sortVars[o].sortedBy="";t.setHeadersCss(r),t.multisort(r),t.appendCache(r),e.isFunction(s)&&s(r.table)},getSortType:function(e,t){return e&&e[t]&&e[t].type||""},getOrder:function(e){return/^d/i.test(e)||1===e},sortNatural:function(e,r){if(e===r)return 0;e=(e||"").toString(),r=(r||"").toString();var s,o,a,n,i,l,d=t.regex;if(d.hex.test(r)){if((s=parseInt(e.match(d.hex),16))<(o=parseInt(r.match(d.hex),16)))return-1;if(s>o)return 1}for(s=e.replace(d.chunk,"\\0$1\\0").replace(d.chunks,"").split("\\0"),o=r.replace(d.chunk,"\\0$1\\0").replace(d.chunks,"").split("\\0"),l=Math.max(s.length,o.length),i=0;i<l;i++){if(a=isNaN(s[i])?s[i]||0:parseFloat(s[i])||0,n=isNaN(o[i])?o[i]||0:parseFloat(o[i])||0,isNaN(a)!==isNaN(n))return isNaN(a)?1:-1;if(typeof a!=typeof n&&(a+="",n+=""),a<n)return-1;if(a>n)return 1}return 0},sortNaturalAsc:function(e,r,s,o){if(e===r)return 0;var a=t.string[o.empties[s]||o.emptyTo];return""===e&&0!==a?"boolean"==typeof a?a?-1:1:-a||-1:""===r&&0!==a?"boolean"==typeof a?a?1:-1:a||1:t.sortNatural(e,r)},sortNaturalDesc:function(e,r,s,o){if(e===r)return 0;var a=t.string[o.empties[s]||o.emptyTo];return""===e&&0!==a?"boolean"==typeof a?a?-1:1:a||1:""===r&&0!==a?"boolean"==typeof a?a?1:-1:-a||-1:t.sortNatural(r,e)},sortText:function(e,t){return e>t?1:e<t?-1:0},getTextValue:function(e,t,r){if(r){var s,o=e?e.length:0,a=r+t;for(s=0;s<o;s++)a+=e.charCodeAt(s);return t*a}return 0},sortNumericAsc:function(e,r,s,o,a,n){if(e===r)return 0;var i=t.string[n.empties[a]||n.emptyTo];return""===e&&0!==i?"boolean"==typeof i?i?-1:1:-i||-1:""===r&&0!==i?"boolean"==typeof i?i?1:-1:i||1:(isNaN(e)&&(e=t.getTextValue(e,s,o)),isNaN(r)&&(r=t.getTextValue(r,s,o)),e-r)},sortNumericDesc:function(e,r,s,o,a,n){if(e===r)return 0;var i=t.string[n.empties[a]||n.emptyTo];return""===e&&0!==i?"boolean"==typeof i?i?-1:1:i||1:""===r&&0!==i?"boolean"==typeof i?i?1:-1:-i||-1:(isNaN(e)&&(e=t.getTextValue(e,s,o)),isNaN(r)&&(r=t.getTextValue(r,s,o)),r-e)},sortNumeric:function(e,t){return e-t},addWidget:function(e){e.id&&!t.isEmptyObject(t.getWidgetById(e.id))&&console.warn('"'+e.id+'" widget was loaded more than once!'),t.widgets[t.widgets.length]=e},hasWidget:function(t,r){return(t=e(t)).length&&t[0].config&&t[0].config.widgetInit[r]||!1},getWidgetById:function(e){var r,s,o=t.widgets.length;for(r=0;r<o;r++)if((s=t.widgets[r])&&s.id&&s.id.toLowerCase()===e.toLowerCase())return s},applyWidgetOptions:function(r){var s,o,a,n=r.config,i=n.widgets.length;if(i)for(s=0;s<i;s++)(o=t.getWidgetById(n.widgets[s]))&&o.options&&(a=e.extend(!0,{},o.options),n.widgetOptions=e.extend(!0,a,n.widgetOptions),e.extend(!0,t.defaults.widgetOptions,o.options))},addWidgetFromClass:function(e){var r,s,o=e.config,a="^"+o.widgetClass.replace(t.regex.templateName,"(\\S+)+")+"$",n=new RegExp(a,"g"),i=(e.className||"").split(t.regex.spaces);if(i.length)for(r=i.length,s=0;s<r;s++)i[s].match(n)&&(o.widgets[o.widgets.length]=i[s].replace(n,"$1"))},applyWidgetId:function(r,s,o){var a,n,i,l=(r=e(r)[0]).config,d=l.widgetOptions,c=t.debug(l,"core"),g=t.getWidgetById(s);g&&(i=g.id,a=!1,e.inArray(i,l.widgets)<0&&(l.widgets[l.widgets.length]=i),c&&(n=new Date),!o&&l.widgetInit[i]||(l.widgetInit[i]=!0,r.hasInitialized&&t.applyWidgetOptions(r),"function"==typeof g.init&&(a=!0,c&&console[console.group?"group":"log"]("Initializing "+i+" widget"),g.init(r,g,l,d))),o||"function"!=typeof g.format||(a=!0,c&&console[console.group?"group":"log"]("Updating "+i+" widget"),g.format(r,l,d,!1)),c&&a&&(console.log("Completed "+(o?"initializing ":"applying ")+i+" widget"+t.benchmark(n)),console.groupEnd&&console.groupEnd()))},applyWidget:function(r,s,o){var a,n,i,l,d,c=(r=e(r)[0]).config,g=t.debug(c,"core"),p=[];if(!1===s||!r.hasInitialized||!r.isApplyingWidgets&&!r.isUpdating){if(g&&(d=new Date),t.addWidgetFromClass(r),clearTimeout(c.timerReady),c.widgets.length){for(r.isApplyingWidgets=!0,c.widgets=e.grep(c.widgets,function(t,r){return e.inArray(t,c.widgets)===r}),n=(i=c.widgets||[]).length,a=0;a<n;a++)(l=t.getWidgetById(i[a]))&&l.id?(l.priority||(l.priority=10),p[a]=l):g&&console.warn('"'+i[a]+'" was enabled, but the widget code has not been loaded!');for(p.sort(function(e,t){return e.priority<t.priority?-1:e.priority===t.priority?0:1}),n=p.length,g&&console[console.group?"group":"log"]("Start "+(s?"initializing":"applying")+" widgets"),a=0;a<n;a++)(l=p[a])&&l.id&&t.applyWidgetId(r,l.id,s);g&&console.groupEnd&&console.groupEnd()}c.timerReady=setTimeout(function(){r.isApplyingWidgets=!1,e.data(r,"lastWidgetApplication",new Date),c.$table.triggerHandler("tablesorter-ready"),s||"function"!=typeof o||o(r),g&&(l=c.widgets.length,console.log("Completed "+(!0===s?"initializing ":"applying ")+l+" widget"+(1!==l?"s":"")+t.benchmark(d)))},10)}},removeWidget:function(r,s,o){var a,n,i,l,d=(r=e(r)[0]).config;if(!0===s)for(s=[],l=t.widgets.length,i=0;i<l;i++)(n=t.widgets[i])&&n.id&&(s[s.length]=n.id);else s=(e.isArray(s)?s.join(","):s||"").toLowerCase().split(/[\s,]+/);for(l=s.length,a=0;a<l;a++)n=t.getWidgetById(s[a]),(i=e.inArray(s[a],d.widgets))>=0&&!0!==o&&d.widgets.splice(i,1),n&&n.remove&&(t.debug(d,"core")&&console.log((o?"Refreshing":"Removing")+' "'+s[a]+'" widget'),n.remove(r,d,d.widgetOptions,o),d.widgetInit[s[a]]=!1);d.$table.triggerHandler("widgetRemoveEnd",r)},refreshWidgets:function(r,s,o){var a,n,i=(r=e(r)[0]).config.widgets,l=t.widgets,d=l.length,c=[],g=function(t){e(t).triggerHandler("refreshComplete")};for(a=0;a<d;a++)(n=l[a])&&n.id&&(s||e.inArray(n.id,i)<0)&&(c[c.length]=n.id);t.removeWidget(r,c.join(","),!0),!0!==o?(t.applyWidget(r,s||!1,g),s&&t.applyWidget(r,!1,g)):g(r)},benchmark:function(e){return" ("+((new Date).getTime()-e.getTime())+" ms)"},log:function(){console.log(arguments)},debug:function(e,t){return e&&(!0===e.debug||"string"==typeof e.debug&&e.debug.indexOf(t)>-1)},isEmptyObject:function(e){for(var t in e)return!1;return!0},isValueInArray:function(e,t){var r,s=t&&t.length||0;for(r=0;r<s;r++)if(t[r][0]===e)return r;return-1},formatFloat:function(r,s){return"string"!=typeof r||""===r?r:(r=(s&&s.config?!1!==s.config.usNumberFormat:void 0===s||s)?r.replace(t.regex.comma,""):r.replace(t.regex.digitNonUS,"").replace(t.regex.comma,"."),t.regex.digitNegativeTest.test(r)&&(r=r.replace(t.regex.digitNegativeReplace,"-$1")),o=parseFloat(r),isNaN(o)?e.trim(r):o);var o},isDigit:function(e){return isNaN(e)?t.regex.digitTest.test(e.toString().replace(t.regex.digitReplace,"")):""!==e},computeColumnIndex:function(r,s){var o,a,n,i,l,d,c,g,p,u,f=s&&s.columns||0,h=[],m=new Array(f);for(o=0;o<r.length;o++)for(d=r[o].cells,a=0;a<d.length;a++){for(c=o,g=(l=d[a]).rowSpan||1,p=l.colSpan||1,void 0===h[c]&&(h[c]=[]),n=0;n<h[c].length+1;n++)if(void 0===h[c][n]){u=n;break}for(f&&l.cellIndex===u||(l.setAttribute?l.setAttribute("data-column",u):e(l).attr("data-column",u)),n=c;n<c+g;n++)for(void 0===h[n]&&(h[n]=[]),m=h[n],i=u;i<u+p;i++)m[i]="x"}return t.checkColumnCount(r,h,m.length),m.length},checkColumnCount:function(e,t,r){var s,o,a=!0,n=[];for(s=0;s<t.length;s++)if(t[s]&&(o=t[s].length,t[s].length!==r)){a=!1;break}a||(e.each(function(e,t){var r=t.parentElement.nodeName;n.indexOf(r)<0&&n.push(r)}),console.error("Invalid or incorrect number of columns in the "+n.join(" or ")+"; expected "+r+", but found "+o+" columns"))},fixColumnWidth:function(r){var s,o,a,n,i,l=(r=e(r)[0]).config,d=l.$table.children("colgroup");if(d.length&&d.hasClass(t.css.colgroup)&&d.remove(),l.widthFixed&&0===l.$table.children("colgroup").length){for(d=e('<colgroup class="'+t.css.colgroup+'">'),s=l.$table.width(),n=(a=l.$tbodies.find("tr:first").children(":visible")).length,i=0;i<n;i++)o=parseInt(a.eq(i).width()/s*1e3,10)/10+"%",d.append(e("<col>").css("width",o));l.$table.prepend(d)}},getData:function(t,r,s){var o,a,n="",i=e(t);return i.length?(o=!!e.metadata&&i.metadata(),a=" "+(i.attr("class")||""),void 0!==i.data(s)||void 0!==i.data(s.toLowerCase())?n+=i.data(s)||i.data(s.toLowerCase()):o&&void 0!==o[s]?n+=o[s]:r&&void 0!==r[s]?n+=r[s]:" "!==a&&a.match(" "+s+"-")&&(n=a.match(new RegExp("\\s"+s+"-([\\w-]+)"))[1]||""),e.trim(n)):""},getColumnData:function(t,r,s,o,a){if("object"!=typeof r||null===r)return r;var n,i=(t=e(t)[0]).config,l=a||i.$headers,d=i.$headerIndexed&&i.$headerIndexed[s]||l.find('[data-column="'+s+'"]:last');if(void 0!==r[s])return o?r[s]:r[l.index(d)];for(n in r)if("string"==typeof n&&d.filter(n).add(d.find(n)).length)return r[n]},isProcessing:function(r,s,o){var a=(r=e(r))[0].config,n=o||r.find("."+t.css.header);s?(void 0!==o&&a.sortList.length>0&&(n=n.filter(function(){return!this.sortDisabled&&t.isValueInArray(parseFloat(e(this).attr("data-column")),a.sortList)>=0})),r.add(n).addClass(t.css.processing+" "+a.cssProcessing)):r.add(n).removeClass(t.css.processing+" "+a.cssProcessing)},processTbody:function(t,r,s){if(t=e(t)[0],s)return t.isProcessing=!0,r.before('<colgroup class="tablesorter-savemyplace"/>'),e.fn.detach?r.detach():r.remove();var o=e(t).find("colgroup.tablesorter-savemyplace");r.insertAfter(o),o.remove(),t.isProcessing=!1},clearTableBody:function(t){e(t)[0].config.$tbodies.children().detach()},characterEquivalents:{a:"áàâãäąå",A:"ÁÀÂÃÄĄÅ",c:"çćč",C:"ÇĆČ",e:"éèêëěę",E:"ÉÈÊËĚĘ",i:"íìİîïı",I:"ÍÌİÎÏ",o:"óòôõöō",O:"ÓÒÔÕÖŌ",ss:"ß",SS:"ẞ",u:"úùûüů",U:"ÚÙÛÜŮ"},replaceAccents:function(e){var r,s="[",o=t.characterEquivalents;if(!t.characterRegex){for(r in t.characterRegexArray={},o)"string"==typeof r&&(s+=o[r],t.characterRegexArray[r]=new RegExp("["+o[r]+"]","g"));t.characterRegex=new RegExp(s+"]")}if(t.characterRegex.test(e))for(r in o)"string"==typeof r&&(e=e.replace(t.characterRegexArray[r],r));return e},validateOptions:function(r){var s,o,a,n,i="headers sortForce sortList sortAppend widgets".split(" "),l=r.originalSettings;if(l){for(s in t.debug(r,"core")&&(n=new Date),l)if("undefined"===(a=typeof t.defaults[s]))console.warn('Tablesorter Warning! "table.config.'+s+'" option not recognized');else if("object"===a)for(o in l[s])a=t.defaults[s]&&typeof t.defaults[s][o],e.inArray(s,i)<0&&"undefined"===a&&console.warn('Tablesorter Warning! "table.config.'+s+"."+o+'" option not recognized');t.debug(r,"core")&&console.log("validate options time:"+t.benchmark(n))}},restoreHeaders:function(r){var s,o,a=e(r)[0].config,n=a.$table.find(a.selectorHeaders),i=n.length;for(s=0;s<i;s++)(o=n.eq(s)).find("."+t.css.headerIn).length&&o.html(a.headerContent[s])},destroy:function(r,s,o){if((r=e(r)[0]).hasInitialized){t.removeWidget(r,!0,!1);var a,n=e(r),i=r.config,l=n.find("thead:first"),d=l.find("tr."+t.css.headerRow).removeClass(t.css.headerRow+" "+i.cssHeaderRow),c=n.find("tfoot:first > tr").children("th, td");!1===s&&e.inArray("uitheme",i.widgets)>=0&&(n.triggerHandler("applyWidgetId",["uitheme"]),n.triggerHandler("applyWidgetId",["zebra"])),l.find("tr").not(d).remove(),a="sortReset update updateRows updateAll updateHeaders updateCell addRows updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets removeWidget destroy mouseup mouseleave "+"keypress sortBegin sortEnd resetToLoadState ".split(" ").join(i.namespace+" "),n.removeData("tablesorter").unbind(a.replace(t.regex.spaces," ")),i.$headers.add(c).removeClass([t.css.header,i.cssHeader,i.cssAsc,i.cssDesc,t.css.sortAsc,t.css.sortDesc,t.css.sortNone].join(" ")).removeAttr("data-column").removeAttr("aria-label").attr("aria-disabled","true"),d.find(i.selectorSort).unbind("mousedown mouseup keypress ".split(" ").join(i.namespace+" ").replace(t.regex.spaces," ")),t.restoreHeaders(r),n.toggleClass(t.css.table+" "+i.tableClass+" tablesorter-"+i.theme,!1===s),n.removeClass(i.namespace.slice(1)),r.hasInitialized=!1,delete r.config.cache,"function"==typeof o&&o(r),t.debug(i,"core")&&console.log("tablesorter has been removed")}}};e.fn.tablesorter=function(r){return this.each(function(){var s=e.extend(!0,{},t.defaults,r,t.instanceMethods);s.originalSettings=r,!this.hasInitialized&&t.buildTable&&"TABLE"!==this.nodeName?t.buildTable(this,s):t.setup(this,s)})},window.console&&window.console.log||(t.logs=[],console={},console.log=console.warn=console.error=console.table=function(){var e=arguments.length>1?arguments:arguments[0];t.logs[t.logs.length]={date:Date.now(),log:e}}),t.addParser({id:"no-parser",is:function(){return!1},format:function(){return""},type:"text"}),t.addParser({id:"text",is:function(){return!0},format:function(r,s){var o=s.config;return r&&(r=e.trim(o.ignoreCase?r.toLocaleLowerCase():r),r=o.sortLocaleCompare?t.replaceAccents(r):r),r},type:"text"}),t.regex.nondigit=/[^\w,. \-()]/g,t.addParser({id:"digit",is:function(e){return t.isDigit(e)},format:function(r,s){var o=t.formatFloat((r||"").replace(t.regex.nondigit,""),s);return r&&"number"==typeof o?o:r?e.trim(r&&s.config.ignoreCase?r.toLocaleLowerCase():r):r},type:"numeric"}),t.regex.currencyReplace=/[+\-,. ]/g,t.regex.currencyTest=/^\(?\d+[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]|[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]\d+\)?$/,t.addParser({id:"currency",is:function(e){return e=(e||"").replace(t.regex.currencyReplace,""),t.regex.currencyTest.test(e)},format:function(r,s){var o=t.formatFloat((r||"").replace(t.regex.nondigit,""),s);return r&&"number"==typeof o?o:r?e.trim(r&&s.config.ignoreCase?r.toLocaleLowerCase():r):r},type:"numeric"}),t.regex.urlProtocolTest=/^(https?|ftp|file):\/\//,t.regex.urlProtocolReplace=/(https?|ftp|file):\/\/(www\.)?/,t.addParser({id:"url",is:function(e){return t.regex.urlProtocolTest.test(e)},format:function(r){return r?e.trim(r.replace(t.regex.urlProtocolReplace,"")):r},type:"text"}),t.regex.dash=/-/g,t.regex.isoDate=/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}/,t.addParser({id:"isoDate",is:function(e){return t.regex.isoDate.test(e)},format:function(e){var r=e?new Date(e.replace(t.regex.dash,"/")):e;return r instanceof Date&&isFinite(r)?r.getTime():e},type:"numeric"}),t.regex.percent=/%/g,t.regex.percentTest=/(\d\s*?%|%\s*?\d)/,t.addParser({id:"percent",is:function(e){return t.regex.percentTest.test(e)&&e.length<15},format:function(e,r){return e?t.formatFloat(e.replace(t.regex.percent,""),r):e},type:"numeric"}),t.addParser({id:"image",is:function(e,t,r,s){return s.find("img").length>0},format:function(t,r,s){return e(s).find("img").attr(r.config.imgAttr||"alt")||t},parsed:!0,type:"text"}),t.regex.dateReplace=/(\S)([AP]M)$/i,t.regex.usLongDateTest1=/^[A-Z]{3,10}\.?\s+\d{1,2},?\s+(\d{4})(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?$/i,t.regex.usLongDateTest2=/^\d{1,2}\s+[A-Z]{3,10}\s+\d{4}/i,t.addParser({id:"usLongDate",is:function(e){return t.regex.usLongDateTest1.test(e)||t.regex.usLongDateTest2.test(e)},format:function(e){var r=e?new Date(e.replace(t.regex.dateReplace,"$1 $2")):e;return r instanceof Date&&isFinite(r)?r.getTime():e},type:"numeric"}),t.regex.shortDateTest=/(^\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4})|(^\d{4}[\/\s]\d{1,2}[\/\s]\d{1,2})/,t.regex.shortDateReplace=/[\-.,]/g,t.regex.shortDateXXY=/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/,t.regex.shortDateYMD=/(\d{4})[\/\s](\d{1,2})[\/\s](\d{1,2})/,t.convertFormat=function(e,r){e=(e||"").replace(t.regex.spaces," ").replace(t.regex.shortDateReplace,"/"),"mmddyyyy"===r?e=e.replace(t.regex.shortDateXXY,"$3/$1/$2"):"ddmmyyyy"===r?e=e.replace(t.regex.shortDateXXY,"$3/$2/$1"):"yyyymmdd"===r&&(e=e.replace(t.regex.shortDateYMD,"$1/$2/$3"));var s=new Date(e);return s instanceof Date&&isFinite(s)?s.getTime():""},t.addParser({id:"shortDate",is:function(e){return e=(e||"").replace(t.regex.spaces," ").replace(t.regex.shortDateReplace,"/"),t.regex.shortDateTest.test(e)},format:function(e,r,s,o){if(e){var a=r.config,n=a.$headerIndexed[o],i=n.length&&n.data("dateFormat")||t.getData(n,t.getColumnData(r,a.headers,o),"dateFormat")||a.dateFormat;return n.length&&n.data("dateFormat",i),t.convertFormat(e,i)||e}return e},type:"numeric"}),t.regex.timeTest=/^(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)$|^((?:[01]\d|[2][0-4]):[0-5]\d)$/i,t.regex.timeMatch=/(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)|((?:[01]\d|[2][0-4]):[0-5]\d)/i,t.addParser({id:"time",is:function(e){return t.regex.timeTest.test(e)},format:function(e){var r=(e||"").match(t.regex.timeMatch),s=new Date(e),o=e&&(null!==r?r[0]:"00:00 AM"),a=o?new Date("2000/01/01 "+o.replace(t.regex.dateReplace,"$1 $2")):o;return a instanceof Date&&isFinite(a)?(s instanceof Date&&isFinite(s)?s.getTime():0)?parseFloat(a.getTime()+"."+s.getTime()):a.getTime():e},type:"numeric"}),t.addParser({id:"metadata",is:function(){return!1},format:function(t,r,s){var o=r.config,a=o.parserMetadataName?o.parserMetadataName:"sortValue";return e(s).metadata()[a]},type:"numeric"}),t.addWidget({id:"zebra",priority:90,format:function(t,r,s){var o,a,n,i,l,d,c,g=new RegExp(r.cssChildRow,"i"),p=r.$tbodies.add(e(r.namespace+"_extra_table").children("tbody:not(."+r.cssInfoBlock+")"));for(l=0;l<p.length;l++)for(n=0,c=(o=p.eq(l).children("tr:visible").not(r.selectorRemove)).length,d=0;d<c;d++)a=o.eq(d),g.test(a[0].className)||n++,i=n%2==0,a.removeClass(s.zebra[i?1:0]).addClass(s.zebra[i?0:1])},remove:function(e,r,s,o){if(!o){var a,n,i=r.$tbodies,l=(s.zebra||["even","odd"]).join(" ");for(a=0;a<i.length;a++)(n=t.processTbody(e,i.eq(a),!0)).children().removeClass(l),t.processTbody(e,n,!1)}}})}(jQuery);
diff --git a/jquery.tablesorter.widgets.js b/jquery.tablesorter.widgets.js
index 5955f8c..3822a7e 100644
--- a/jquery.tablesorter.widgets.js
+++ b/jquery.tablesorter.widgets.js
@@ -6,3177 +6,4 @@
*/
/*! tablesorter (FORK) - updated 2018-11-20 (v2.31.1)*/
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
-(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery) {
-/*! Widget: storage - updated 2018-03-18 (v2.30.0) */
-/*global JSON:false */
-;(function ($, window, document) {
- 'use strict';
-
- var ts = $.tablesorter || {};
-
- // update defaults for validator; these values must be falsy!
- $.extend(true, ts.defaults, {
- fixedUrl: '',
- widgetOptions: {
- storage_fixedUrl: '',
- storage_group: '',
- storage_page: '',
- storage_storageType: '',
- storage_tableId: '',
- storage_useSessionStorage: ''
- }
- });
-
- // *** Store data in local storage, with a cookie fallback ***
- /* IE7 needs JSON library for JSON.stringify - (http://caniuse.com/#search=json)
- if you need it, then include https://github.com/douglascrockford/JSON-js
-
- $.parseJSON is not available is jQuery versions older than 1.4.1, using older
- versions will only allow storing information for one page at a time
-
- // *** Save data (JSON format only) ***
- // val must be valid JSON... use http://jsonlint.com/ to ensure it is valid
- var val = { "mywidget" : "data1" }; // valid JSON uses double quotes
- // $.tablesorter.storage(table, key, val);
- $.tablesorter.storage(table, 'tablesorter-mywidget', val);
-
- // *** Get data: $.tablesorter.storage(table, key); ***
- v = $.tablesorter.storage(table, 'tablesorter-mywidget');
- // val may be empty, so also check for your data
- val = (v && v.hasOwnProperty('mywidget')) ? v.mywidget : '';
- alert(val); // 'data1' if saved, or '' if not
- */
- ts.storage = function(table, key, value, options) {
- table = $(table)[0];
- var cookieIndex, cookies, date,
- hasStorage = false,
- values = {},
- c = table.config,
- wo = c && c.widgetOptions,
- debug = ts.debug(c, 'storage'),
- storageType = (
- ( options && options.storageType ) || ( wo && wo.storage_storageType )
- ).toString().charAt(0).toLowerCase(),
- // deprecating "useSessionStorage"; any storageType setting overrides it
- session = storageType ? '' :
- ( options && options.useSessionStorage ) || ( wo && wo.storage_useSessionStorage ),
- $table = $(table),
- // id from (1) options ID, (2) table 'data-table-group' attribute, (3) widgetOptions.storage_tableId,
- // (4) table ID, then (5) table index
- id = options && options.id ||
- $table.attr( options && options.group || wo && wo.storage_group || 'data-table-group') ||
- wo && wo.storage_tableId || table.id || $('.tablesorter').index( $table ),
- // url from (1) options url, (2) table 'data-table-page' attribute, (3) widgetOptions.storage_fixedUrl,
- // (4) table.config.fixedUrl (deprecated), then (5) window location path
- url = options && options.url ||
- $table.attr(options && options.page || wo && wo.storage_page || 'data-table-page') ||
- wo && wo.storage_fixedUrl || c && c.fixedUrl || window.location.pathname;
-
- // skip if using cookies
- if (storageType !== 'c') {
- storageType = (storageType === 's' || session) ? 'sessionStorage' : 'localStorage';
- // https://gist.github.com/paulirish/5558557
- if (storageType in window) {
- try {
- window[storageType].setItem('_tmptest', 'temp');
- hasStorage = true;
- window[storageType].removeItem('_tmptest');
- } catch (error) {
- console.warn( storageType + ' is not supported in this browser' );
- }
- }
- }
- if (debug) {
- console.log('Storage >> Using', hasStorage ? storageType : 'cookies');
- }
- // *** get value ***
- if ($.parseJSON) {
- if (hasStorage) {
- values = $.parseJSON( window[storageType][key] || 'null' ) || {};
- } else {
- // old browser, using cookies
- cookies = document.cookie.split(/[;\s|=]/);
- // add one to get from the key to the value
- cookieIndex = $.inArray(key, cookies) + 1;
- values = (cookieIndex !== 0) ? $.parseJSON(cookies[cookieIndex] || 'null') || {} : {};
- }
- }
- // allow value to be an empty string too
- if (typeof value !== 'undefined' && window.JSON && JSON.hasOwnProperty('stringify')) {
- // add unique identifiers = url pathname > table ID/index on page > data
- if (!values[url]) {
- values[url] = {};
- }
- values[url][id] = value;
- // *** set value ***
- if (hasStorage) {
- window[storageType][key] = JSON.stringify(values);
- } else {
- date = new Date();
- date.setTime(date.getTime() + (31536e+6)); // 365 days
- document.cookie = key + '=' + (JSON.stringify(values)).replace(/\"/g, '\"') + '; expires=' + date.toGMTString() + '; path=/';
- }
- } else {
- return values && values[url] ? values[url][id] : '';
- }
- };
-
-})(jQuery, window, document);
-
-/*! Widget: uitheme - updated 2018-03-18 (v2.30.0) */
-;(function ($) {
- 'use strict';
- var ts = $.tablesorter || {};
-
- ts.themes = {
- 'bootstrap' : {
- table : 'table table-bordered table-striped',
- caption : 'caption',
- // header class names
- header : 'bootstrap-header', // give the header a gradient background (theme.bootstrap_2.css)
- sortNone : '',
- sortAsc : '',
- sortDesc : '',
- active : '', // applied when column is sorted
- hover : '', // custom css required - a defined bootstrap style may not override other classes
- // icon class names
- icons : '', // add 'bootstrap-icon-white' to make them white; this icon class is added to the <i> in the header
- iconSortNone : 'bootstrap-icon-unsorted', // class name added to icon when column is not sorted
- iconSortAsc : 'glyphicon glyphicon-chevron-up', // class name added to icon when column has ascending sort
- iconSortDesc : 'glyphicon glyphicon-chevron-down', // class name added to icon when column has descending sort
- filterRow : '', // filter row class
- footerRow : '',
- footerCells : '',
- even : '', // even row zebra striping
- odd : '' // odd row zebra striping
- },
- 'jui' : {
- table : 'ui-widget ui-widget-content ui-corner-all', // table classes
- caption : 'ui-widget-content',
- // header class names
- header : 'ui-widget-header ui-corner-all ui-state-default', // header classes
- sortNone : '',
- sortAsc : '',
- sortDesc : '',
- active : 'ui-state-active', // applied when column is sorted
- hover : 'ui-state-hover', // hover class
- // icon class names
- icons : 'ui-icon', // icon class added to the <i> in the header
- iconSortNone : 'ui-icon-carat-2-n-s ui-icon-caret-2-n-s', // class name added to icon when column is not sorted
- iconSortAsc : 'ui-icon-carat-1-n ui-icon-caret-1-n', // class name added to icon when column has ascending sort
- iconSortDesc : 'ui-icon-carat-1-s ui-icon-caret-1-s', // class name added to icon when column has descending sort
- filterRow : '',
- footerRow : '',
- footerCells : '',
- even : 'ui-widget-content', // even row zebra striping
- odd : 'ui-state-default' // odd row zebra striping
- }
- };
-
- $.extend(ts.css, {
- wrapper : 'tablesorter-wrapper' // ui theme & resizable
- });
-
- ts.addWidget({
- id: 'uitheme',
- priority: 10,
- format: function(table, c, wo) {
- var i, tmp, hdr, icon, time, $header, $icon, $tfoot, $h, oldtheme, oldremove, oldIconRmv, hasOldTheme,
- themesAll = ts.themes,
- $table = c.$table.add( $( c.namespace + '_extra_table' ) ),
- $headers = c.$headers.add( $( c.namespace + '_extra_headers' ) ),
- theme = c.theme || 'jui',
- themes = themesAll[theme] || {},
- remove = $.trim( [ themes.sortNone, themes.sortDesc, themes.sortAsc, themes.active ].join( ' ' ) ),
- iconRmv = $.trim( [ themes.iconSortNone, themes.iconSortDesc, themes.iconSortAsc ].join( ' ' ) ),
- debug = ts.debug(c, 'uitheme');
- if (debug) { time = new Date(); }
- // initialization code - run once
- if (!$table.hasClass('tablesorter-' + theme) || c.theme !== c.appliedTheme || !wo.uitheme_applied) {
- wo.uitheme_applied = true;
- oldtheme = themesAll[c.appliedTheme] || {};
- hasOldTheme = !$.isEmptyObject(oldtheme);
- oldremove = hasOldTheme ? [ oldtheme.sortNone, oldtheme.sortDesc, oldtheme.sortAsc, oldtheme.active ].join( ' ' ) : '';
- oldIconRmv = hasOldTheme ? [ oldtheme.iconSortNone, oldtheme.iconSortDesc, oldtheme.iconSortAsc ].join( ' ' ) : '';
- if (hasOldTheme) {
- wo.zebra[0] = $.trim( ' ' + wo.zebra[0].replace(' ' + oldtheme.even, '') );
- wo.zebra[1] = $.trim( ' ' + wo.zebra[1].replace(' ' + oldtheme.odd, '') );
- c.$tbodies.children().removeClass( [ oldtheme.even, oldtheme.odd ].join(' ') );
- }
- // update zebra stripes
- if (themes.even) { wo.zebra[0] += ' ' + themes.even; }
- if (themes.odd) { wo.zebra[1] += ' ' + themes.odd; }
- // add caption style
- $table.children('caption')
- .removeClass(oldtheme.caption || '')
- .addClass(themes.caption);
- // add table/footer class names
- $tfoot = $table
- // remove other selected themes
- .removeClass( (c.appliedTheme ? 'tablesorter-' + (c.appliedTheme || '') : '') + ' ' + (oldtheme.table || '') )
- .addClass('tablesorter-' + theme + ' ' + (themes.table || '')) // add theme widget class name
- .children('tfoot');
- c.appliedTheme = c.theme;
-
- if ($tfoot.length) {
- $tfoot
- // if oldtheme.footerRow or oldtheme.footerCells are undefined, all class names are removed
- .children('tr').removeClass(oldtheme.footerRow || '').addClass(themes.footerRow)
- .children('th, td').removeClass(oldtheme.footerCells || '').addClass(themes.footerCells);
- }
- // update header classes
- $headers
- .removeClass( (hasOldTheme ? [ oldtheme.header, oldtheme.hover, oldremove ].join(' ') : '') || '' )
- .addClass(themes.header)
- .not('.sorter-false')
- .unbind('mouseenter.tsuitheme mouseleave.tsuitheme')
- .bind('mouseenter.tsuitheme mouseleave.tsuitheme', function(event) {
- // toggleClass with switch added in jQuery 1.3
- $(this)[ event.type === 'mouseenter' ? 'addClass' : 'removeClass' ](themes.hover || '');
- });
-
- $headers.each(function() {
- var $this = $(this);
- if (!$this.find('.' + ts.css.wrapper).length) {
- // Firefox needs this inner div to position the icon & resizer correctly
- $this.wrapInner('<div class="' + ts.css.wrapper + '" style="position:relative;height:100%;width:100%"></div>');
- }
- });
- if (c.cssIcon) {
- // if c.cssIcon is '', then no <i> is added to the header
- $headers
- .find('.' + ts.css.icon)
- .removeClass(hasOldTheme ? [ oldtheme.icons, oldIconRmv ].join(' ') : '')
- .addClass(themes.icons || '');
- }
- // filter widget initializes after uitheme
- if (ts.hasWidget( c.table, 'filter' )) {
- tmp = function() {
- $table.children('thead').children('.' + ts.css.filterRow)
- .removeClass(hasOldTheme ? oldtheme.filterRow || '' : '')
- .addClass(themes.filterRow || '');
- };
- if (wo.filter_initialized) {
- tmp();
- } else {
- $table.one('filterInit', function() {
- tmp();
- });
- }
- }
- }
- for (i = 0; i < c.columns; i++) {
- $header = c.$headers
- .add($(c.namespace + '_extra_headers'))
- .not('.sorter-false')
- .filter('[data-column="' + i + '"]');
- $icon = (ts.css.icon) ? $header.find('.' + ts.css.icon) : $();
- $h = $headers.not('.sorter-false').filter('[data-column="' + i + '"]:last');
- if ($h.length) {
- $header.removeClass(remove);
- $icon.removeClass(iconRmv);
- if ($h[0].sortDisabled) {
- // no sort arrows for disabled columns!
- $icon.removeClass(themes.icons || '');
- } else {
- hdr = themes.sortNone;
- icon = themes.iconSortNone;
- if ($h.hasClass(ts.css.sortAsc)) {
- hdr = [ themes.sortAsc, themes.active ].join(' ');
- icon = themes.iconSortAsc;
- } else if ($h.hasClass(ts.css.sortDesc)) {
- hdr = [ themes.sortDesc, themes.active ].join(' ');
- icon = themes.iconSortDesc;
- }
- $header.addClass(hdr);
- $icon.addClass(icon || '');
- }
- }
- }
- if (debug) {
- console.log('uitheme >> Applied ' + theme + ' theme' + ts.benchmark(time));
- }
- },
- remove: function(table, c, wo, refreshing) {
- if (!wo.uitheme_applied) { return; }
- var $table = c.$table,
- theme = c.appliedTheme || 'jui',
- themes = ts.themes[ theme ] || ts.themes.jui,
- $headers = $table.children('thead').children(),
- remove = themes.sortNone + ' ' + themes.sortDesc + ' ' + themes.sortAsc,
- iconRmv = themes.iconSortNone + ' ' + themes.iconSortDesc + ' ' + themes.iconSortAsc;
- $table.removeClass('tablesorter-' + theme + ' ' + themes.table);
- wo.uitheme_applied = false;
- if (refreshing) { return; }
- $table.find(ts.css.header).removeClass(themes.header);
- $headers
- .unbind('mouseenter.tsuitheme mouseleave.tsuitheme') // remove hover
- .removeClass(themes.hover + ' ' + remove + ' ' + themes.active)
- .filter('.' + ts.css.filterRow)
- .removeClass(themes.filterRow);
- $headers.find('.' + ts.css.icon).removeClass(themes.icons + ' ' + iconRmv);
- }
- });
-
-})(jQuery);
-
-/*! Widget: columns - updated 5/24/2017 (v2.28.11) */
-;(function ($) {
- 'use strict';
- var ts = $.tablesorter || {};
-
- ts.addWidget({
- id: 'columns',
- priority: 65,
- options : {
- columns : [ 'primary', 'secondary', 'tertiary' ]
- },
- format: function(table, c, wo) {
- var $tbody, tbodyIndex, $rows, rows, $row, $cells, remove, indx,
- $table = c.$table,
- $tbodies = c.$tbodies,
- sortList = c.sortList,
- len = sortList.length,
- // removed c.widgetColumns support
- css = wo && wo.columns || [ 'primary', 'secondary', 'tertiary' ],
- last = css.length - 1;
- remove = css.join(' ');
- // check if there is a sort (on initialization there may not be one)
- for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
- $tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // detach tbody
- $rows = $tbody.children('tr');
- // loop through the visible rows
- $rows.each(function() {
- $row = $(this);
- if (this.style.display !== 'none') {
- // remove all columns class names
- $cells = $row.children().removeClass(remove);
- // add appropriate column class names
- if (sortList && sortList[0]) {
- // primary sort column class
- $cells.eq(sortList[0][0]).addClass(css[0]);
- if (len > 1) {
- for (indx = 1; indx < len; indx++) {
- // secondary, tertiary, etc sort column classes
- $cells.eq(sortList[indx][0]).addClass( css[indx] || css[last] );
- }
- }
- }
- }
- });
- ts.processTbody(table, $tbody, false);
- }
- // add classes to thead and tfoot
- rows = wo.columns_thead !== false ? [ 'thead tr' ] : [];
- if (wo.columns_tfoot !== false) {
- rows.push('tfoot tr');
- }
- if (rows.length) {
- $rows = $table.find( rows.join(',') ).children().removeClass(remove);
- if (len) {
- for (indx = 0; indx < len; indx++) {
- // add primary. secondary, tertiary, etc sort column classes
- $rows.filter('[data-column="' + sortList[indx][0] + '"]').addClass(css[indx] || css[last]);
- }
- }
- }
- },
- remove: function(table, c, wo) {
- var tbodyIndex, $tbody,
- $tbodies = c.$tbodies,
- remove = (wo.columns || [ 'primary', 'secondary', 'tertiary' ]).join(' ');
- c.$headers.removeClass(remove);
- c.$table.children('tfoot').children('tr').children('th, td').removeClass(remove);
- for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
- $tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // remove tbody
- $tbody.children('tr').each(function() {
- $(this).children().removeClass(remove);
- });
- ts.processTbody(table, $tbody, false); // restore tbody
- }
- }
- });
-
-})(jQuery);
-
-/*! Widget: filter - updated 2018-03-18 (v2.30.0) *//*
- * Requires tablesorter v2.8+ and jQuery 1.7+
- * by Rob Garrison
- */
-;( function ( $ ) {
- 'use strict';
- var tsf, tsfRegex,
- ts = $.tablesorter || {},
- tscss = ts.css,
- tskeyCodes = ts.keyCodes;
-
- $.extend( tscss, {
- filterRow : 'tablesorter-filter-row',
- filter : 'tablesorter-filter',
- filterDisabled : 'disabled',
- filterRowHide : 'hideme'
- });
-
- $.extend( tskeyCodes, {
- backSpace : 8,
- escape : 27,
- space : 32,
- left : 37,
- down : 40
- });
-
- ts.addWidget({
- id: 'filter',
- priority: 50,
- options : {
- filter_cellFilter : '', // css class name added to the filter cell ( string or array )
- filter_childRows : false, // if true, filter includes child row content in the search
- filter_childByColumn : false, // ( filter_childRows must be true ) if true = search child rows by column; false = search all child row text grouped
- filter_childWithSibs : true, // if true, include matching child row siblings
- filter_columnAnyMatch: true, // if true, allows using '#:{query}' in AnyMatch searches ( column:query )
- filter_columnFilters : true, // if true, a filter will be added to the top of each table column
- filter_cssFilter : '', // css class name added to the filter row & each input in the row ( tablesorter-filter is ALWAYS added )
- filter_defaultAttrib : 'data-value', // data attribute in the header cell that contains the default filter value
- filter_defaultFilter : {}, // add a default column filter type '~{query}' to make fuzzy searches default; '{q1} AND {q2}' to make all searches use a logical AND.
- filter_excludeFilter : {}, // filters to exclude, per column
- filter_external : '', // jQuery selector string ( or jQuery object ) of external filters
- filter_filteredRow : 'filtered', // class added to filtered rows; define in css with "display:none" to hide the filtered-out rows
- filter_filterLabel : 'Filter "{{label}}" column by...', // Aria-label added to filter input/select; see #1495
- filter_formatter : null, // add custom filter elements to the filter row
- filter_functions : null, // add custom filter functions using this option
- filter_hideEmpty : true, // hide filter row when table is empty
- filter_hideFilters : false, // collapse filter row when mouse leaves the area
- filter_ignoreCase : true, // if true, make all searches case-insensitive
- filter_liveSearch : true, // if true, search column content while the user types ( with a delay )
- filter_matchType : { 'input': 'exact', 'select': 'exact' }, // global query settings ('exact' or 'match'); overridden by "filter-match" or "filter-exact" class
- filter_onlyAvail : 'filter-onlyAvail', // a header with a select dropdown & this class name will only show available ( visible ) options within the drop down
- filter_placeholder : { search : '', select : '' }, // default placeholder text ( overridden by any header 'data-placeholder' setting )
- filter_reset : null, // jQuery selector string of an element used to reset the filters
- filter_resetOnEsc : true, // Reset filter input when the user presses escape - normalized across browsers
- filter_saveFilters : false, // Use the $.tablesorter.storage utility to save the most recent filters
- filter_searchDelay : 300, // typing delay in milliseconds before starting a search
- filter_searchFiltered: true, // allow searching through already filtered rows in special circumstances; will speed up searching in large tables if true
- filter_selectSource : null, // include a function to return an array of values to be added to the column filter select
- filter_selectSourceSeparator : '|', // filter_selectSource array text left of the separator is added to the option value, right into the option text
- filter_serversideFiltering : false, // if true, must perform server-side filtering b/c client-side filtering is disabled, but the ui and events will still be used.
- filter_startsWith : false, // if true, filter start from the beginning of the cell contents
- filter_useParsedData : false // filter all data using parsed content
- },
- format: function( table, c, wo ) {
- if ( !c.$table.hasClass( 'hasFilters' ) ) {
- tsf.init( table, c, wo );
- }
- },
- remove: function( table, c, wo, refreshing ) {
- var tbodyIndex, $tbody,
- $table = c.$table,
- $tbodies = c.$tbodies,
- events = (
- 'addRows updateCell update updateRows updateComplete appendCache filterReset ' +
- 'filterAndSortReset filterFomatterUpdate filterEnd search stickyHeadersInit '
- ).split( ' ' ).join( c.namespace + 'filter ' );
- $table
- .removeClass( 'hasFilters' )
- // add filter namespace to all BUT search
- .unbind( events.replace( ts.regex.spaces, ' ' ) )
- // remove the filter row even if refreshing, because the column might have been moved
- .find( '.' + tscss.filterRow ).remove();
- wo.filter_initialized = false;
- if ( refreshing ) { return; }
- for ( tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
- $tbody = ts.processTbody( table, $tbodies.eq( tbodyIndex ), true ); // remove tbody
- $tbody.children().removeClass( wo.filter_filteredRow ).show();
- ts.processTbody( table, $tbody, false ); // restore tbody
- }
- if ( wo.filter_reset ) {
- $( document ).undelegate( wo.filter_reset, 'click' + c.namespace + 'filter' );
- }
- }
- });
-
- tsf = ts.filter = {
-
- // regex used in filter 'check' functions - not for general use and not documented
- regex: {
- regex : /^\/((?:\\\/|[^\/])+)\/([migyu]{0,5})?$/, // regex to test for regex
- child : /tablesorter-childRow/, // child row class name; this gets updated in the script
- filtered : /filtered/, // filtered (hidden) row class name; updated in the script
- type : /undefined|number/, // check type
- exact : /(^[\"\'=]+)|([\"\'=]+$)/g, // exact match (allow '==')
- operators : /[<>=]/g, // replace operators
- query : '(q|query)', // replace filter queries
- wild01 : /\?/g, // wild card match 0 or 1
- wild0More : /\*/g, // wild care match 0 or more
- quote : /\"/g,
- isNeg1 : /(>=?\s*-\d)/,
- isNeg2 : /(<=?\s*\d)/
- },
- // function( c, data ) { }
- // c = table.config
- // data.$row = jQuery object of the row currently being processed
- // data.$cells = jQuery object of all cells within the current row
- // data.filters = array of filters for all columns ( some may be undefined )
- // data.filter = filter for the current column
- // data.iFilter = same as data.filter, except lowercase ( if wo.filter_ignoreCase is true )
- // data.exact = table cell text ( or parsed data if column parser enabled; may be a number & not a string )
- // data.iExact = same as data.exact, except lowercase ( if wo.filter_ignoreCase is true; may be a number & not a string )
- // data.cache = table cell text from cache, so it has been parsed ( & in all lower case if c.ignoreCase is true )
- // data.cacheArray = An array of parsed content from each table cell in the row being processed
- // data.index = column index; table = table element ( DOM )
- // data.parsed = array ( by column ) of boolean values ( from filter_useParsedData or 'filter-parsed' class )
- types: {
- or : function( c, data, vars ) {
- // look for "|", but not if it is inside of a regular expression
- if ( ( tsfRegex.orTest.test( data.iFilter ) || tsfRegex.orSplit.test( data.filter ) ) &&
- // this test for regex has potential to slow down the overall search
- !tsfRegex.regex.test( data.filter ) ) {
- var indx, filterMatched, query, regex,
- // duplicate data but split filter
- data2 = $.extend( {}, data ),
- filter = data.filter.split( tsfRegex.orSplit ),
- iFilter = data.iFilter.split( tsfRegex.orSplit ),
- len = filter.length;
- for ( indx = 0; indx < len; indx++ ) {
- data2.nestedFilters = true;
- data2.filter = '' + ( tsf.parseFilter( c, filter[ indx ], data ) || '' );
- data2.iFilter = '' + ( tsf.parseFilter( c, iFilter[ indx ], data ) || '' );
- query = '(' + ( tsf.parseFilter( c, data2.filter, data ) || '' ) + ')';
- try {
- // use try/catch, because query may not be a valid regex if "|" is contained within a partial regex search,
- // e.g "/(Alex|Aar" -> Uncaught SyntaxError: Invalid regular expression: /(/(Alex)/: Unterminated group
- regex = new RegExp( data.isMatch ? query : '^' + query + '$', c.widgetOptions.filter_ignoreCase ? 'i' : '' );
- // filterMatched = data2.filter === '' && indx > 0 ? true
- // look for an exact match with the 'or' unless the 'filter-match' class is found
- filterMatched = regex.test( data2.exact ) || tsf.processTypes( c, data2, vars );
- if ( filterMatched ) {
- return filterMatched;
- }
- } catch ( error ) {
- return null;
- }
- }
- // may be null from processing types
- return filterMatched || false;
- }
- return null;
- },
- // Look for an AND or && operator ( logical and )
- and : function( c, data, vars ) {
- if ( tsfRegex.andTest.test( data.filter ) ) {
- var indx, filterMatched, result, query, regex,
- // duplicate data but split filter
- data2 = $.extend( {}, data ),
- filter = data.filter.split( tsfRegex.andSplit ),
- iFilter = data.iFilter.split( tsfRegex.andSplit ),
- len = filter.length;
- for ( indx = 0; indx < len; indx++ ) {
- data2.nestedFilters = true;
- data2.filter = '' + ( tsf.parseFilter( c, filter[ indx ], data ) || '' );
- data2.iFilter = '' + ( tsf.parseFilter( c, iFilter[ indx ], data ) || '' );
- query = ( '(' + ( tsf.parseFilter( c, data2.filter, data ) || '' ) + ')' )
- // replace wild cards since /(a*)/i will match anything
- .replace( tsfRegex.wild01, '\\S{1}' ).replace( tsfRegex.wild0More, '\\S*' );
- try {
- // use try/catch just in case RegExp is invalid
- regex = new RegExp( data.isMatch ? query : '^' + query + '$', c.widgetOptions.filter_ignoreCase ? 'i' : '' );
- // look for an exact match with the 'and' unless the 'filter-match' class is found
- result = ( regex.test( data2.exact ) || tsf.processTypes( c, data2, vars ) );
- if ( indx === 0 ) {
- filterMatched = result;
- } else {
- filterMatched = filterMatched && result;
- }
- } catch ( error ) {
- return null;
- }
- }
- // may be null from processing types
- return filterMatched || false;
- }
- return null;
- },
- // Look for regex
- regex: function( c, data ) {
- if ( tsfRegex.regex.test( data.filter ) ) {
- var matches,
- // cache regex per column for optimal speed
- regex = data.filter_regexCache[ data.index ] || tsfRegex.regex.exec( data.filter ),
- isRegex = regex instanceof RegExp;
- try {
- if ( !isRegex ) {
- // force case insensitive search if ignoreCase option set?
- // if ( c.ignoreCase && !regex[2] ) { regex[2] = 'i'; }
- data.filter_regexCache[ data.index ] = regex = new RegExp( regex[1], regex[2] );
- }
- matches = regex.test( data.exact );
- } catch ( error ) {
- matches = false;
- }
- return matches;
- }
- return null;
- },
- // Look for operators >, >=, < or <=
- operators: function( c, data ) {
- // ignore empty strings... because '' < 10 is true
- if ( tsfRegex.operTest.test( data.iFilter ) && data.iExact !== '' ) {
- var cachedValue, result, txt,
- table = c.table,
- parsed = data.parsed[ data.index ],
- query = ts.formatFloat( data.iFilter.replace( tsfRegex.operators, '' ), table ),
- parser = c.parsers[ data.index ] || {},
- savedSearch = query;
- // parse filter value in case we're comparing numbers ( dates )
- if ( parsed || parser.type === 'numeric' ) {
- txt = $.trim( '' + data.iFilter.replace( tsfRegex.operators, '' ) );
- result = tsf.parseFilter( c, txt, data, true );
- query = ( typeof result === 'number' && result !== '' && !isNaN( result ) ) ? result : query;
- }
- // iExact may be numeric - see issue #149;
- // check if cached is defined, because sometimes j goes out of range? ( numeric columns )
- if ( ( parsed || parser.type === 'numeric' ) && !isNaN( query ) &&
- typeof data.cache !== 'undefined' ) {
- cachedValue = data.cache;
- } else {
- txt = isNaN( data.iExact ) ? data.iExact.replace( ts.regex.nondigit, '' ) : data.iExact;
- cachedValue = ts.formatFloat( txt, table );
- }
- if ( tsfRegex.gtTest.test( data.iFilter ) ) {
- result = tsfRegex.gteTest.test( data.iFilter ) ? cachedValue >= query : cachedValue > query;
- } else if ( tsfRegex.ltTest.test( data.iFilter ) ) {
- result = tsfRegex.lteTest.test( data.iFilter ) ? cachedValue <= query : cachedValue < query;
- }
- // keep showing all rows if nothing follows the operator
- if ( !result && savedSearch === '' ) {
- result = true;
- }
- return result;
- }
- return null;
- },
- // Look for a not match
- notMatch: function( c, data ) {
- if ( tsfRegex.notTest.test( data.iFilter ) ) {
- var indx,
- txt = data.iFilter.replace( '!', '' ),
- filter = tsf.parseFilter( c, txt, data ) || '';
- if ( tsfRegex.exact.test( filter ) ) {
- // look for exact not matches - see #628
- filter = filter.replace( tsfRegex.exact, '' );
- return filter === '' ? true : $.trim( filter ) !== data.iExact;
- } else {
- indx = data.iExact.search( $.trim( filter ) );
- return filter === '' ? true :
- // return true if not found
- data.anyMatch ? indx < 0 :
- // return false if found
- !( c.widgetOptions.filter_startsWith ? indx === 0 : indx >= 0 );
- }
- }
- return null;
- },
- // Look for quotes or equals to get an exact match; ignore type since iExact could be numeric
- exact: function( c, data ) {
- /*jshint eqeqeq:false */
- if ( tsfRegex.exact.test( data.iFilter ) ) {
- var txt = data.iFilter.replace( tsfRegex.exact, '' ),
- filter = tsf.parseFilter( c, txt, data ) || '';
- // eslint-disable-next-line eqeqeq
- return data.anyMatch ? $.inArray( filter, data.rowArray ) >= 0 : filter == data.iExact;
- }
- return null;
- },
- // Look for a range ( using ' to ' or ' - ' ) - see issue #166; thanks matzhu!
- range : function( c, data ) {
- if ( tsfRegex.toTest.test( data.iFilter ) ) {
- var result, tmp, range1, range2,
- table = c.table,
- index = data.index,
- parsed = data.parsed[index],
- // make sure the dash is for a range and not indicating a negative number
- query = data.iFilter.split( tsfRegex.toSplit );
-
- tmp = query[0].replace( ts.regex.nondigit, '' ) || '';
- range1 = ts.formatFloat( tsf.parseFilter( c, tmp, data ), table );
- tmp = query[1].replace( ts.regex.nondigit, '' ) || '';
- range2 = ts.formatFloat( tsf.parseFilter( c, tmp, data ), table );
- // parse filter value in case we're comparing numbers ( dates )
- if ( parsed || c.parsers[ index ].type === 'numeric' ) {
- result = c.parsers[ index ].format( '' + query[0], table, c.$headers.eq( index ), index );
- range1 = ( result !== '' && !isNaN( result ) ) ? result : range1;
- result = c.parsers[ index ].format( '' + query[1], table, c.$headers.eq( index ), index );
- range2 = ( result !== '' && !isNaN( result ) ) ? result : range2;
- }
- if ( ( parsed || c.parsers[ index ].type === 'numeric' ) && !isNaN( range1 ) && !isNaN( range2 ) ) {
- result = data.cache;
- } else {
- tmp = isNaN( data.iExact ) ? data.iExact.replace( ts.regex.nondigit, '' ) : data.iExact;
- result = ts.formatFloat( tmp, table );
- }
- if ( range1 > range2 ) {
- tmp = range1; range1 = range2; range2 = tmp; // swap
- }
- return ( result >= range1 && result <= range2 ) || ( range1 === '' || range2 === '' );
- }
- return null;
- },
- // Look for wild card: ? = single, * = multiple, or | = logical OR
- wild : function( c, data ) {
- if ( tsfRegex.wildOrTest.test( data.iFilter ) ) {
- var query = '' + ( tsf.parseFilter( c, data.iFilter, data ) || '' );
- // look for an exact match with the 'or' unless the 'filter-match' class is found
- if ( !tsfRegex.wildTest.test( query ) && data.nestedFilters ) {
- query = data.isMatch ? query : '^(' + query + ')$';
- }
- // parsing the filter may not work properly when using wildcards =/
- try {
- return new RegExp(
- query.replace( tsfRegex.wild01, '\\S{1}' ).replace( tsfRegex.wild0More, '\\S*' ),
- c.widgetOptions.filter_ignoreCase ? 'i' : ''
- )
- .test( data.exact );
- } catch ( error ) {
- return null;
- }
- }
- return null;
- },
- // fuzzy text search; modified from https://github.com/mattyork/fuzzy ( MIT license )
- fuzzy: function( c, data ) {
- if ( tsfRegex.fuzzyTest.test( data.iFilter ) ) {
- var indx,
- patternIndx = 0,
- len = data.iExact.length,
- txt = data.iFilter.slice( 1 ),
- pattern = tsf.parseFilter( c, txt, data ) || '';
- for ( indx = 0; indx < len; indx++ ) {
- if ( data.iExact[ indx ] === pattern[ patternIndx ] ) {
- patternIndx += 1;
- }
- }
- return patternIndx === pattern.length;
- }
- return null;
- }
- },
- init: function( table ) {
- // filter language options
- ts.language = $.extend( true, {}, {
- to : 'to',
- or : 'or',
- and : 'and'
- }, ts.language );
-
- var options, string, txt, $header, column, val, fxn, noSelect,
- c = table.config,
- wo = c.widgetOptions,
- processStr = function(prefix, str, suffix) {
- str = str.trim();
- // don't include prefix/suffix if str is empty
- return str === '' ? '' : (prefix || '') + str + (suffix || '');
- };
- c.$table.addClass( 'hasFilters' );
- c.lastSearch = [];
-
- // define timers so using clearTimeout won't cause an undefined error
- wo.filter_searchTimer = null;
- wo.filter_initTimer = null;
- wo.filter_formatterCount = 0;
- wo.filter_formatterInit = [];
- wo.filter_anyColumnSelector = '[data-column="all"],[data-column="any"]';
- wo.filter_multipleColumnSelector = '[data-column*="-"],[data-column*=","]';
-
- val = '\\{' + tsfRegex.query + '\\}';
- $.extend( tsfRegex, {
- child : new RegExp( c.cssChildRow ),
- filtered : new RegExp( wo.filter_filteredRow ),
- alreadyFiltered : new RegExp( '(\\s+(-' + processStr('|', ts.language.or) + processStr('|', ts.language.to) + ')\\s+)', 'i' ),
- toTest : new RegExp( '\\s+(-' + processStr('|', ts.language.to) + ')\\s+', 'i' ),
- toSplit : new RegExp( '(?:\\s+(?:-' + processStr('|', ts.language.to) + ')\\s+)', 'gi' ),
- andTest : new RegExp( '\\s+(' + processStr('', ts.language.and, '|') + '&&)\\s+', 'i' ),
- andSplit : new RegExp( '(?:\\s+(?:' + processStr('', ts.language.and, '|') + '&&)\\s+)', 'gi' ),
- orTest : new RegExp( '(\\|' + processStr('|\\s+', ts.language.or, '\\s+') + ')', 'i' ),
- orSplit : new RegExp( '(?:\\|' + processStr('|\\s+(?:', ts.language.or, ')\\s+') + ')', 'gi' ),
- iQuery : new RegExp( val, 'i' ),
- igQuery : new RegExp( val, 'ig' ),
- operTest : /^[<>]=?/,
- gtTest : />/,
- gteTest : />=/,
- ltTest : /</,
- lteTest : /<=/,
- notTest : /^\!/,
- wildOrTest : /[\?\*\|]/,
- wildTest : /\?\*/,
- fuzzyTest : /^~/,
- exactTest : /[=\"\|!]/
- });
-
- // don't build filter row if columnFilters is false or all columns are set to 'filter-false'
- // see issue #156
- val = c.$headers.filter( '.filter-false, .parser-false' ).length;
- if ( wo.filter_columnFilters !== false && val !== c.$headers.length ) {
- // build filter row
- tsf.buildRow( table, c, wo );
- }
-
- txt = 'addRows updateCell update updateRows updateComplete appendCache filterReset ' +
- 'filterAndSortReset filterResetSaved filterEnd search '.split( ' ' ).join( c.namespace + 'filter ' );
- c.$table.bind( txt, function( event, filter ) {
- val = wo.filter_hideEmpty &&
- $.isEmptyObject( c.cache ) &&
- !( c.delayInit && event.type === 'appendCache' );
- // hide filter row using the 'filtered' class name
- c.$table.find( '.' + tscss.filterRow ).toggleClass( wo.filter_filteredRow, val ); // fixes #450
- if ( !/(search|filter)/.test( event.type ) ) {
- event.stopPropagation();
- tsf.buildDefault( table, true );
- }
- // Add filterAndSortReset - see #1361
- if ( event.type === 'filterReset' || event.type === 'filterAndSortReset' ) {
- c.$table.find( '.' + tscss.filter ).add( wo.filter_$externalFilters ).val( '' );
- if ( event.type === 'filterAndSortReset' ) {
- ts.sortReset( this.config, function() {
- tsf.searching( table, [] );
- });
- } else {
- tsf.searching( table, [] );
- }
- } else if ( event.type === 'filterResetSaved' ) {
- ts.storage( table, 'tablesorter-filters', '' );
- } else if ( event.type === 'filterEnd' ) {
- tsf.buildDefault( table, true );
- } else {
- // send false argument to force a new search; otherwise if the filter hasn't changed,
- // it will return
- filter = event.type === 'search' ? filter :
- event.type === 'updateComplete' ? c.$table.data( 'lastSearch' ) : '';
- if ( /(update|add)/.test( event.type ) && event.type !== 'updateComplete' ) {
- // force a new search since content has changed
- c.lastCombinedFilter = null;
- c.lastSearch = [];
- // update filterFormatters after update (& small delay) - Fixes #1237
- setTimeout(function() {
- c.$table.triggerHandler( 'filterFomatterUpdate' );
- }, 100);
- }
- // pass true ( skipFirst ) to prevent the tablesorter.setFilters function from skipping the first
- // input ensures all inputs are updated when a search is triggered on the table
- // $( 'table' ).trigger( 'search', [...] );
- tsf.searching( table, filter, true );
- }
- return false;
- });
-
- // reset button/link
- if ( wo.filter_reset ) {
- if ( wo.filter_reset instanceof $ ) {
- // reset contains a jQuery object, bind to it
- wo.filter_reset.click( function() {
- c.$table.triggerHandler( 'filterReset' );
- });
- } else if ( $( wo.filter_reset ).length ) {
- // reset is a jQuery selector, use event delegation
- $( document )
- .undelegate( wo.filter_reset, 'click' + c.namespace + 'filter' )
- .delegate( wo.filter_reset, 'click' + c.namespace + 'filter', function() {
- // trigger a reset event, so other functions ( filter_formatter ) know when to reset
- c.$table.triggerHandler( 'filterReset' );
- });
- }
- }
- if ( wo.filter_functions ) {
- for ( column = 0; column < c.columns; column++ ) {
- fxn = ts.getColumnData( table, wo.filter_functions, column );
- if ( fxn ) {
- // remove 'filter-select' from header otherwise the options added here are replaced with
- // all options
- $header = c.$headerIndexed[ column ].removeClass( 'filter-select' );
- // don't build select if 'filter-false' or 'parser-false' set
- noSelect = !( $header.hasClass( 'filter-false' ) || $header.hasClass( 'parser-false' ) );
- options = '';
- if ( fxn === true && noSelect ) {
- tsf.buildSelect( table, column );
- } else if ( typeof fxn === 'object' && noSelect ) {
- // add custom drop down list
- for ( string in fxn ) {
- if ( typeof string === 'string' ) {
- options += options === '' ?
- '<option value="">' +
- ( $header.data( 'placeholder' ) ||
- $header.attr( 'data-placeholder' ) ||
- wo.filter_placeholder.select ||
- ''
- ) +
- '</option>' : '';
- val = string;
- txt = string;
- if ( string.indexOf( wo.filter_selectSourceSeparator ) >= 0 ) {
- val = string.split( wo.filter_selectSourceSeparator );
- txt = val[1];
- val = val[0];
- }
- options += '<option ' +
- ( txt === val ? '' : 'data-function-name="' + string + '" ' ) +
- 'value="' + val + '">' + txt + '</option>';
- }
- }
- c.$table
- .find( 'thead' )
- .find( 'select.' + tscss.filter + '[data-column="' + column + '"]' )
- .append( options );
- txt = wo.filter_selectSource;
- fxn = typeof txt === 'function' ? true : ts.getColumnData( table, txt, column );
- if ( fxn ) {
- // updating so the extra options are appended
- tsf.buildSelect( c.table, column, '', true, $header.hasClass( wo.filter_onlyAvail ) );
- }
- }
- }
- }
- }
- // not really updating, but if the column has both the 'filter-select' class &
- // filter_functions set to true, it would append the same options twice.
- tsf.buildDefault( table, true );
-
- tsf.bindSearch( table, c.$table.find( '.' + tscss.filter ), true );
- if ( wo.filter_external ) {
- tsf.bindSearch( table, wo.filter_external );
- }
-
- if ( wo.filter_hideFilters ) {
- tsf.hideFilters( c );
- }
-
- // show processing icon
- if ( c.showProcessing ) {
- txt = 'filterStart filterEnd '.split( ' ' ).join( c.namespace + 'filter-sp ' );
- c.$table
- .unbind( txt.replace( ts.regex.spaces, ' ' ) )
- .bind( txt, function( event, columns ) {
- // only add processing to certain columns to all columns
- $header = ( columns ) ?
- c.$table
- .find( '.' + tscss.header )
- .filter( '[data-column]' )
- .filter( function() {
- return columns[ $( this ).data( 'column' ) ] !== '';
- }) : '';
- ts.isProcessing( table, event.type === 'filterStart', columns ? $header : '' );
- });
- }
-
- // set filtered rows count ( intially unfiltered )
- c.filteredRows = c.totalRows;
-
- // add default values
- txt = 'tablesorter-initialized pagerBeforeInitialized '.split( ' ' ).join( c.namespace + 'filter ' );
- c.$table
- .unbind( txt.replace( ts.regex.spaces, ' ' ) )
- .bind( txt, function() {
- tsf.completeInit( this );
- });
- // if filter widget is added after pager has initialized; then set filter init flag
- if ( c.pager && c.pager.initialized && !wo.filter_initialized ) {
- c.$table.triggerHandler( 'filterFomatterUpdate' );
- setTimeout( function() {
- tsf.filterInitComplete( c );
- }, 100 );
- } else if ( !wo.filter_initialized ) {
- tsf.completeInit( table );
- }
- },
- completeInit: function( table ) {
- // redefine 'c' & 'wo' so they update properly inside this callback
- var c = table.config,
- wo = c.widgetOptions,
- filters = tsf.setDefaults( table, c, wo ) || [];
- if ( filters.length ) {
- // prevent delayInit from triggering a cache build if filters are empty
- if ( !( c.delayInit && filters.join( '' ) === '' ) ) {
- ts.setFilters( table, filters, true );
- }
- }
- c.$table.triggerHandler( 'filterFomatterUpdate' );
- // trigger init after setTimeout to prevent multiple filterStart/End/Init triggers
- setTimeout( function() {
- if ( !wo.filter_initialized ) {
- tsf.filterInitComplete( c );
- }
- }, 100 );
- },
-
- // $cell parameter, but not the config, is passed to the filter_formatters,
- // so we have to work with it instead
- formatterUpdated: function( $cell, column ) {
- // prevent error if $cell is undefined - see #1056
- var $table = $cell && $cell.closest( 'table' );
- var config = $table.length && $table[0].config,
- wo = config && config.widgetOptions;
- if ( wo && !wo.filter_initialized ) {
- // add updates by column since this function
- // may be called numerous times before initialization
- wo.filter_formatterInit[ column ] = 1;
- }
- },
- filterInitComplete: function( c ) {
- var indx, len,
- wo = c.widgetOptions,
- count = 0,
- completed = function() {
- wo.filter_initialized = true;
- // update lastSearch - it gets cleared often
- c.lastSearch = c.$table.data( 'lastSearch' );
- c.$table.triggerHandler( 'filterInit', c );
- tsf.findRows( c.table, c.lastSearch || [] );
- if (ts.debug(c, 'filter')) {
- console.log('Filter >> Widget initialized');
- }
- };
- if ( $.isEmptyObject( wo.filter_formatter ) ) {
- completed();
- } else {
- len = wo.filter_formatterInit.length;
- for ( indx = 0; indx < len; indx++ ) {
- if ( wo.filter_formatterInit[ indx ] === 1 ) {
- count++;
- }
- }
- clearTimeout( wo.filter_initTimer );
- if ( !wo.filter_initialized && count === wo.filter_formatterCount ) {
- // filter widget initialized
- completed();
- } else if ( !wo.filter_initialized ) {
- // fall back in case a filter_formatter doesn't call
- // $.tablesorter.filter.formatterUpdated( $cell, column ), and the count is off
- wo.filter_initTimer = setTimeout( function() {
- completed();
- }, 500 );
- }
- }
- },
- // encode or decode filters for storage; see #1026
- processFilters: function( filters, encode ) {
- var indx,
- // fixes #1237; previously returning an encoded "filters" value
- result = [],
- mode = encode ? encodeURIComponent : decodeURIComponent,
- len = filters.length;
- for ( indx = 0; indx < len; indx++ ) {
- if ( filters[ indx ] ) {
- result[ indx ] = mode( filters[ indx ] );
- }
- }
- return result;
- },
- setDefaults: function( table, c, wo ) {
- var isArray, saved, indx, col, $filters,
- // get current ( default ) filters
- filters = ts.getFilters( table ) || [];
- if ( wo.filter_saveFilters && ts.storage ) {
- saved = ts.storage( table, 'tablesorter-filters' ) || [];
- isArray = $.isArray( saved );
- // make sure we're not just getting an empty array
- if ( !( isArray && saved.join( '' ) === '' || !isArray ) ) {
- filters = tsf.processFilters( saved );
- }
- }
- // if no filters saved, then check default settings
- if ( filters.join( '' ) === '' ) {
- // allow adding default setting to external filters
- $filters = c.$headers.add( wo.filter_$externalFilters )
- .filter( '[' + wo.filter_defaultAttrib + ']' );
- for ( indx = 0; indx <= c.columns; indx++ ) {
- // include data-column='all' external filters
- col = indx === c.columns ? 'all' : indx;
- filters[ indx ] = $filters
- .filter( '[data-column="' + col + '"]' )
- .attr( wo.filter_defaultAttrib ) || filters[indx] || '';
- }
- }
- c.$table.data( 'lastSearch', filters );
- return filters;
- },
- parseFilter: function( c, filter, data, parsed ) {
- return parsed || data.parsed[ data.index ] ?
- c.parsers[ data.index ].format( filter, c.table, [], data.index ) :
- filter;
- },
- buildRow: function( table, c, wo ) {
- var $filter, col, column, $header, makeSelect, disabled, name, ffxn, tmp,
- // c.columns defined in computeThIndexes()
- cellFilter = wo.filter_cellFilter,
- columns = c.columns,
- arry = $.isArray( cellFilter ),
- buildFilter = '<tr role="search" class="' + tscss.filterRow + ' ' + c.cssIgnoreRow + '">';
- for ( column = 0; column < columns; column++ ) {
- if ( c.$headerIndexed[ column ].length ) {
- // account for entire column set with colspan. See #1047
- tmp = c.$headerIndexed[ column ] && c.$headerIndexed[ column ][0].colSpan || 0;
- if ( tmp > 1 ) {
- buildFilter += '<td data-column="' + column + '-' + ( column + tmp - 1 ) + '" colspan="' + tmp + '"';
- } else {
- buildFilter += '<td data-column="' + column + '"';
- }
- if ( arry ) {
- buildFilter += ( cellFilter[ column ] ? ' class="' + cellFilter[ column ] + '"' : '' );
- } else {
- buildFilter += ( cellFilter !== '' ? ' class="' + cellFilter + '"' : '' );
- }
- buildFilter += '></td>';
- }
- }
- c.$filters = $( buildFilter += '</tr>' )
- .appendTo( c.$table.children( 'thead' ).eq( 0 ) )
- .children( 'td' );
- // build each filter input
- for ( column = 0; column < columns; column++ ) {
- disabled = false;
- // assuming last cell of a column is the main column
- $header = c.$headerIndexed[ column ];
- if ( $header && $header.length ) {
- // $filter = c.$filters.filter( '[data-column="' + column + '"]' );
- $filter = tsf.getColumnElm( c, c.$filters, column );
- ffxn = ts.getColumnData( table, wo.filter_functions, column );
- makeSelect = ( wo.filter_functions && ffxn && typeof ffxn !== 'function' ) ||
- $header.hasClass( 'filter-select' );
- // get data from jQuery data, metadata, headers option or header class name
- col = ts.getColumnData( table, c.headers, column );
- disabled = ts.getData( $header[0], col, 'filter' ) === 'false' ||
- ts.getData( $header[0], col, 'parser' ) === 'false';
-
- if ( makeSelect ) {
- buildFilter = $( '<select>' ).appendTo( $filter );
- } else {
- ffxn = ts.getColumnData( table, wo.filter_formatter, column );
- if ( ffxn ) {
- wo.filter_formatterCount++;
- buildFilter = ffxn( $filter, column );
- // no element returned, so lets go find it
- if ( buildFilter && buildFilter.length === 0 ) {
- buildFilter = $filter.children( 'input' );
- }
- // element not in DOM, so lets attach it
- if ( buildFilter && ( buildFilter.parent().length === 0 ||
- ( buildFilter.parent().length && buildFilter.parent()[0] !== $filter[0] ) ) ) {
- $filter.append( buildFilter );
- }
- } else {
- buildFilter = $( '<input type="search">' ).appendTo( $filter );
- }
- if ( buildFilter ) {
- tmp = $header.data( 'placeholder' ) ||
- $header.attr( 'data-placeholder' ) ||
- wo.filter_placeholder.search || '';
- buildFilter.attr( 'placeholder', tmp );
- }
- }
- if ( buildFilter ) {
- // add filter class name
- name = ( $.isArray( wo.filter_cssFilter ) ?
- ( typeof wo.filter_cssFilter[column] !== 'undefined' ? wo.filter_cssFilter[column] || '' : '' ) :
- wo.filter_cssFilter ) || '';
- // copy data-column from table cell (it will include colspan)
- buildFilter.addClass( tscss.filter + ' ' + name );
- name = wo.filter_filterLabel;
- tmp = name.match(/{{([^}]+?)}}/g);
- if (!tmp) {
- tmp = [ '{{label}}' ];
- }
- $.each(tmp, function(indx, attr) {
- var regex = new RegExp(attr, 'g'),
- data = $header.attr('data-' + attr.replace(/{{|}}/g, '')),
- text = typeof data === 'undefined' ? $header.text() : data;
- name = name.replace( regex, $.trim( text ) );
- });
- buildFilter.attr({
- 'data-column': $filter.attr( 'data-column' ),
- 'aria-label': name
- });
- if ( disabled ) {
- buildFilter.attr( 'placeholder', '' ).addClass( tscss.filterDisabled )[0].disabled = true;
- }
- }
- }
- }
- },
- bindSearch: function( table, $el, internal ) {
- table = $( table )[0];
- $el = $( $el ); // allow passing a selector string
- if ( !$el.length ) { return; }
- var tmp,
- c = table.config,
- wo = c.widgetOptions,
- namespace = c.namespace + 'filter',
- $ext = wo.filter_$externalFilters;
- if ( internal !== true ) {
- // save anyMatch element
- tmp = wo.filter_anyColumnSelector + ',' + wo.filter_multipleColumnSelector;
- wo.filter_$anyMatch = $el.filter( tmp );
- if ( $ext && $ext.length ) {
- wo.filter_$externalFilters = wo.filter_$externalFilters.add( $el );
- } else {
- wo.filter_$externalFilters = $el;
- }
- // update values ( external filters added after table initialization )
- ts.setFilters( table, c.$table.data( 'lastSearch' ) || [], internal === false );
- }
- // unbind events
- tmp = ( 'keypress keyup keydown search change input '.split( ' ' ).join( namespace + ' ' ) );
- $el
- // use data attribute instead of jQuery data since the head is cloned without including
- // the data/binding
- .attr( 'data-lastSearchTime', new Date().getTime() )
- .unbind( tmp.replace( ts.regex.spaces, ' ' ) )
- .bind( 'keydown' + namespace, function( event ) {
- if ( event.which === tskeyCodes.escape && !table.config.widgetOptions.filter_resetOnEsc ) {
- // prevent keypress event
- return false;
- }
- })
- .bind( 'keyup' + namespace, function( event ) {
- wo = table.config.widgetOptions; // make sure "wo" isn't cached
- var column = parseInt( $( this ).attr( 'data-column' ), 10 ),
- liveSearch = typeof wo.filter_liveSearch === 'boolean' ? wo.filter_liveSearch :
- ts.getColumnData( table, wo.filter_liveSearch, column );
- if ( typeof liveSearch === 'undefined' ) {
- liveSearch = wo.filter_liveSearch.fallback || false;
- }
- $( this ).attr( 'data-lastSearchTime', new Date().getTime() );
- // emulate what webkit does.... escape clears the filter
- if ( event.which === tskeyCodes.escape ) {
- // make sure to restore the last value on escape
- this.value = wo.filter_resetOnEsc ? '' : c.lastSearch[column];
- // don't return if the search value is empty ( all rows need to be revealed )
- } else if ( this.value !== '' && (
- // liveSearch can contain a min value length; ignore arrow and meta keys, but allow backspace
- ( typeof liveSearch === 'number' && this.value.length < liveSearch ) ||
- // let return & backspace continue on, but ignore arrows & non-valid characters
- ( event.which !== tskeyCodes.enter && event.which !== tskeyCodes.backSpace &&
- ( event.which < tskeyCodes.space || ( event.which >= tskeyCodes.left && event.which <= tskeyCodes.down ) ) ) ) ) {
- return;
- // live search
- } else if ( liveSearch === false ) {
- if ( this.value !== '' && event.which !== tskeyCodes.enter ) {
- return;
- }
- }
- // change event = no delay; last true flag tells getFilters to skip newest timed input
- tsf.searching( table, true, true, column );
- })
- // include change for select - fixes #473
- .bind( 'search change keypress input blur '.split( ' ' ).join( namespace + ' ' ), function( event ) {
- // don't get cached data, in case data-column changes dynamically
- var column = parseInt( $( this ).attr( 'data-column' ), 10 ),
- eventType = event.type,
- liveSearch = typeof wo.filter_liveSearch === 'boolean' ?
- wo.filter_liveSearch :
- ts.getColumnData( table, wo.filter_liveSearch, column );
- if ( table.config.widgetOptions.filter_initialized &&
- // immediate search if user presses enter
- ( event.which === tskeyCodes.enter ||
- // immediate search if a "search" or "blur" is triggered on the input
- ( eventType === 'search' || eventType === 'blur' ) ||
- // change & input events must be ignored if liveSearch !== true
- ( eventType === 'change' || eventType === 'input' ) &&
- // prevent search if liveSearch is a number
- ( liveSearch === true || liveSearch !== true && event.target.nodeName !== 'INPUT' ) &&
- // don't allow 'change' or 'input' event to process if the input value
- // is the same - fixes #685
- this.value !== c.lastSearch[column]
- )
- ) {
- event.preventDefault();
- // init search with no delay
- $( this ).attr( 'data-lastSearchTime', new Date().getTime() );
- tsf.searching( table, eventType !== 'keypress', true, column );
- }
- });
- },
- searching: function( table, filter, skipFirst, column ) {
- var liveSearch,
- wo = table.config.widgetOptions;
- if (typeof column === 'undefined') {
- // no delay
- liveSearch = false;
- } else {
- liveSearch = typeof wo.filter_liveSearch === 'boolean' ?
- wo.filter_liveSearch :
- // get column setting, or set to fallback value, or default to false
- ts.getColumnData( table, wo.filter_liveSearch, column );
- if ( typeof liveSearch === 'undefined' ) {
- liveSearch = wo.filter_liveSearch.fallback || false;
- }
- }
- clearTimeout( wo.filter_searchTimer );
- if ( typeof filter === 'undefined' || filter === true ) {
- // delay filtering
- wo.filter_searchTimer = setTimeout( function() {
- tsf.checkFilters( table, filter, skipFirst );
- }, liveSearch ? wo.filter_searchDelay : 10 );
- } else {
- // skip delay
- tsf.checkFilters( table, filter, skipFirst );
- }
- },
- equalFilters: function (c, filter1, filter2) {
- var indx,
- f1 = [],
- f2 = [],
- len = c.columns + 1; // add one to include anyMatch filter
- filter1 = $.isArray(filter1) ? filter1 : [];
- filter2 = $.isArray(filter2) ? filter2 : [];
- for (indx = 0; indx < len; indx++) {
- f1[indx] = filter1[indx] || '';
- f2[indx] = filter2[indx] || '';
- }
- return f1.join(',') === f2.join(',');
- },
- checkFilters: function( table, filter, skipFirst ) {
- var c = table.config,
- wo = c.widgetOptions,
- filterArray = $.isArray( filter ),
- filters = ( filterArray ) ? filter : ts.getFilters( table, true ),
- currentFilters = filters || []; // current filter values
- // prevent errors if delay init is set
- if ( $.isEmptyObject( c.cache ) ) {
- // update cache if delayInit set & pager has initialized ( after user initiates a search )
- if ( c.delayInit && ( !c.pager || c.pager && c.pager.initialized ) ) {
- ts.updateCache( c, function() {
- tsf.checkFilters( table, false, skipFirst );
- });
- }
- return;
- }
- // add filter array back into inputs
- if ( filterArray ) {
- ts.setFilters( table, filters, false, skipFirst !== true );
- if ( !wo.filter_initialized ) {
- c.lastSearch = [];
- c.lastCombinedFilter = '';
- }
- }
- if ( wo.filter_hideFilters ) {
- // show/hide filter row as needed
- c.$table
- .find( '.' + tscss.filterRow )
- .triggerHandler( tsf.hideFiltersCheck( c ) ? 'mouseleave' : 'mouseenter' );
- }
- // return if the last search is the same; but filter === false when updating the search
- // see example-widget-filter.html filter toggle buttons
- if ( tsf.equalFilters(c, c.lastSearch, currentFilters) && filter !== false ) {
- return;
- } else if ( filter === false ) {
- // force filter refresh
- c.lastCombinedFilter = '';
- c.lastSearch = [];
- }
- // define filter inside it is false
- filters = filters || [];
- // convert filters to strings - see #1070
- filters = Array.prototype.map ?
- filters.map( String ) :
- // for IE8 & older browsers - maybe not the best method
- filters.join( '\ufffd' ).split( '\ufffd' );
-
- if ( wo.filter_initialized ) {
- c.$table.triggerHandler( 'filterStart', [ filters ] );
- }
- if ( c.showProcessing ) {
- // give it time for the processing icon to kick in
- setTimeout( function() {
- tsf.findRows( table, filters, currentFilters );
- return false;
- }, 30 );
- } else {
- tsf.findRows( table, filters, currentFilters );
- return false;
- }
- },
- hideFiltersCheck: function( c ) {
- if (typeof c.widgetOptions.filter_hideFilters === 'function') {
- var val = c.widgetOptions.filter_hideFilters( c );
- if (typeof val === 'boolean') {
- return val;
- }
- }
- return ts.getFilters( c.$table ).join( '' ) === '';
- },
- hideFilters: function( c, $table ) {
- var timer;
- ( $table || c.$table )
- .find( '.' + tscss.filterRow )
- .addClass( tscss.filterRowHide )
- .bind( 'mouseenter mouseleave', function( e ) {
- // save event object - http://bugs.jquery.com/ticket/12140
- var event = e,
- $row = $( this );
- clearTimeout( timer );
- timer = setTimeout( function() {
- if ( /enter|over/.test( event.type ) ) {
- $row.removeClass( tscss.filterRowHide );
- } else {
- // don't hide if input has focus
- // $( ':focus' ) needs jQuery 1.6+
- if ( $( document.activeElement ).closest( 'tr' )[0] !== $row[0] ) {
- // don't hide row if any filter has a value
- $row.toggleClass( tscss.filterRowHide, tsf.hideFiltersCheck( c ) );
- }
- }
- }, 200 );
- })
- .find( 'input, select' ).bind( 'focus blur', function( e ) {
- var event = e,
- $row = $( this ).closest( 'tr' );
- clearTimeout( timer );
- timer = setTimeout( function() {
- clearTimeout( timer );
- // don't hide row if any filter has a value
- $row.toggleClass( tscss.filterRowHide, tsf.hideFiltersCheck( c ) && event.type !== 'focus' );
- }, 200 );
- });
- },
- defaultFilter: function( filter, mask ) {
- if ( filter === '' ) { return filter; }
- var regex = tsfRegex.iQuery,
- maskLen = mask.match( tsfRegex.igQuery ).length,
- query = maskLen > 1 ? $.trim( filter ).split( /\s/ ) : [ $.trim( filter ) ],
- len = query.length - 1,
- indx = 0,
- val = mask;
- if ( len < 1 && maskLen > 1 ) {
- // only one 'word' in query but mask has >1 slots
- query[1] = query[0];
- }
- // replace all {query} with query words...
- // if query = 'Bob', then convert mask from '!{query}' to '!Bob'
- // if query = 'Bob Joe Frank', then convert mask '{q} OR {q}' to 'Bob OR Joe OR Frank'
- while ( regex.test( val ) ) {
- val = val.replace( regex, query[indx++] || '' );
- if ( regex.test( val ) && indx < len && ( query[indx] || '' ) !== '' ) {
- val = mask.replace( regex, val );
- }
- }
- return val;
- },
- getLatestSearch: function( $input ) {
- if ( $input ) {
- return $input.sort( function( a, b ) {
- return $( b ).attr( 'data-lastSearchTime' ) - $( a ).attr( 'data-lastSearchTime' );
- });
- }
- return $input || $();
- },
- findRange: function( c, val, ignoreRanges ) {
- // look for multiple columns '1-3,4-6,8' in data-column
- var temp, ranges, range, start, end, singles, i, indx, len,
- columns = [];
- if ( /^[0-9]+$/.test( val ) ) {
- // always return an array
- return [ parseInt( val, 10 ) ];
- }
- // process column range
- if ( !ignoreRanges && /-/.test( val ) ) {
- ranges = val.match( /(\d+)\s*-\s*(\d+)/g );
- len = ranges ? ranges.length : 0;
- for ( indx = 0; indx < len; indx++ ) {
- range = ranges[indx].split( /\s*-\s*/ );
- start = parseInt( range[0], 10 ) || 0;
- end = parseInt( range[1], 10 ) || ( c.columns - 1 );
- if ( start > end ) {
- temp = start; start = end; end = temp; // swap
- }
- if ( end >= c.columns ) {
- end = c.columns - 1;
- }
- for ( ; start <= end; start++ ) {
- columns[ columns.length ] = start;
- }
- // remove processed range from val
- val = val.replace( ranges[ indx ], '' );
- }
- }
- // process single columns
- if ( !ignoreRanges && /,/.test( val ) ) {
- singles = val.split( /\s*,\s*/ );
- len = singles.length;
- for ( i = 0; i < len; i++ ) {
- if ( singles[ i ] !== '' ) {
- indx = parseInt( singles[ i ], 10 );
- if ( indx < c.columns ) {
- columns[ columns.length ] = indx;
- }
- }
- }
- }
- // return all columns
- if ( !columns.length ) {
- for ( indx = 0; indx < c.columns; indx++ ) {
- columns[ columns.length ] = indx;
- }
- }
- return columns;
- },
- getColumnElm: function( c, $elements, column ) {
- // data-column may contain multiple columns '1-3,5-6,8'
- // replaces: c.$filters.filter( '[data-column="' + column + '"]' );
- return $elements.filter( function() {
- var cols = tsf.findRange( c, $( this ).attr( 'data-column' ) );
- return $.inArray( column, cols ) > -1;
- });
- },
- multipleColumns: function( c, $input ) {
- // look for multiple columns '1-3,4-6,8' in data-column
- var wo = c.widgetOptions,
- // only target 'all' column inputs on initialization
- // & don't target 'all' column inputs if they don't exist
- targets = wo.filter_initialized || !$input.filter( wo.filter_anyColumnSelector ).length,
- val = $.trim( tsf.getLatestSearch( $input ).attr( 'data-column' ) || '' );
- return tsf.findRange( c, val, !targets );
- },
- processTypes: function( c, data, vars ) {
- var ffxn,
- filterMatched = null,
- matches = null;
- for ( ffxn in tsf.types ) {
- if ( $.inArray( ffxn, vars.excludeMatch ) < 0 && matches === null ) {
- matches = tsf.types[ffxn]( c, data, vars );
- if ( matches !== null ) {
- data.matchedOn = ffxn;
- filterMatched = matches;
- }
- }
- }
- return filterMatched;
- },
- matchType: function( c, columnIndex ) {
- var isMatch,
- wo = c.widgetOptions,
- $el = c.$headerIndexed[ columnIndex ];
- // filter-exact > filter-match > filter_matchType for type
- if ( $el.hasClass( 'filter-exact' ) ) {
- isMatch = false;
- } else if ( $el.hasClass( 'filter-match' ) ) {
- isMatch = true;
- } else {
- // filter-select is not applied when filter_functions are used, so look for a select
- if ( wo.filter_columnFilters ) {
- $el = c.$filters
- .find( '.' + tscss.filter )
- .add( wo.filter_$externalFilters )
- .filter( '[data-column="' + columnIndex + '"]' );
- } else if ( wo.filter_$externalFilters ) {
- $el = wo.filter_$externalFilters.filter( '[data-column="' + columnIndex + '"]' );
- }
- isMatch = $el.length ?
- c.widgetOptions.filter_matchType[ ( $el[ 0 ].nodeName || '' ).toLowerCase() ] === 'match' :
- // default to exact, if no inputs found
- false;
- }
- return isMatch;
- },
- processRow: function( c, data, vars ) {
- var result, filterMatched,
- fxn, ffxn, txt,
- wo = c.widgetOptions,
- showRow = true,
- hasAnyMatchInput = wo.filter_$anyMatch && wo.filter_$anyMatch.length,
-
- // if wo.filter_$anyMatch data-column attribute is changed dynamically
- // we don't want to do an "anyMatch" search on one column using data
- // for the entire row - see #998
- columnIndex = wo.filter_$anyMatch && wo.filter_$anyMatch.length ?
- // look for multiple columns '1-3,4-6,8'
- tsf.multipleColumns( c, wo.filter_$anyMatch ) :
- [];
- data.$cells = data.$row.children();
- data.matchedOn = null;
- if ( data.anyMatchFlag && columnIndex.length > 1 || ( data.anyMatchFilter && !hasAnyMatchInput ) ) {
- data.anyMatch = true;
- data.isMatch = true;
- data.rowArray = data.$cells.map( function( i ) {
- if ( $.inArray( i, columnIndex ) > -1 || ( data.anyMatchFilter && !hasAnyMatchInput ) ) {
- if ( data.parsed[ i ] ) {
- txt = data.cacheArray[ i ];
- } else {
- txt = data.rawArray[ i ];
- txt = $.trim( wo.filter_ignoreCase ? txt.toLowerCase() : txt );
- if ( c.sortLocaleCompare ) {
- txt = ts.replaceAccents( txt );
- }
- }
- return txt;
- }
- }).get();
- data.filter = data.anyMatchFilter;
- data.iFilter = data.iAnyMatchFilter;
- data.exact = data.rowArray.join( ' ' );
- data.iExact = wo.filter_ignoreCase ? data.exact.toLowerCase() : data.exact;
- data.cache = data.cacheArray.slice( 0, -1 ).join( ' ' );
- vars.excludeMatch = vars.noAnyMatch;
- filterMatched = tsf.processTypes( c, data, vars );
- if ( filterMatched !== null ) {
- showRow = filterMatched;
- } else {
- if ( wo.filter_startsWith ) {
- showRow = false;
- // data.rowArray may not contain all columns
- columnIndex = Math.min( c.columns, data.rowArray.length );
- while ( !showRow && columnIndex > 0 ) {
- columnIndex--;
- showRow = showRow || data.rowArray[ columnIndex ].indexOf( data.iFilter ) === 0;
- }
- } else {
- showRow = ( data.iExact + data.childRowText ).indexOf( data.iFilter ) >= 0;
- }
- }
- data.anyMatch = false;
- // no other filters to process
- if ( data.filters.join( '' ) === data.filter ) {
- return showRow;
- }
- }
-
- for ( columnIndex = 0; columnIndex < c.columns; columnIndex++ ) {
- data.filter = data.filters[ columnIndex ];
- data.index = columnIndex;
-
- // filter types to exclude, per column
- vars.excludeMatch = vars.excludeFilter[ columnIndex ];
-
- // ignore if filter is empty or disabled
- if ( data.filter ) {
- data.cache = data.cacheArray[ columnIndex ];
- result = data.parsed[ columnIndex ] ? data.cache : data.rawArray[ columnIndex ] || '';
- data.exact = c.sortLocaleCompare ? ts.replaceAccents( result ) : result; // issue #405
- data.iExact = !tsfRegex.type.test( typeof data.exact ) && wo.filter_ignoreCase ?
- data.exact.toLowerCase() : data.exact;
- data.isMatch = tsf.matchType( c, columnIndex );
-
- result = showRow; // if showRow is true, show that row
-
- // in case select filter option has a different value vs text 'a - z|A through Z'
- ffxn = wo.filter_columnFilters ?
- c.$filters.add( wo.filter_$externalFilters )
- .filter( '[data-column="' + columnIndex + '"]' )
- .find( 'select option:selected' )
- .attr( 'data-function-name' ) || '' : '';
- // replace accents - see #357
- if ( c.sortLocaleCompare ) {
- data.filter = ts.replaceAccents( data.filter );
- }
-
- // replace column specific default filters - see #1088
- if ( wo.filter_defaultFilter && tsfRegex.iQuery.test( vars.defaultColFilter[ columnIndex ] ) ) {
- data.filter = tsf.defaultFilter( data.filter, vars.defaultColFilter[ columnIndex ] );
- }
-
- // data.iFilter = case insensitive ( if wo.filter_ignoreCase is true ),
- // data.filter = case sensitive
- data.iFilter = wo.filter_ignoreCase ? ( data.filter || '' ).toLowerCase() : data.filter;
- fxn = vars.functions[ columnIndex ];
- filterMatched = null;
- if ( fxn ) {
- if ( typeof fxn === 'function' ) {
- // filter callback( exact cell content, parser normalized content,
- // filter input value, column index, jQuery row object )
- filterMatched = fxn( data.exact, data.cache, data.filter, columnIndex, data.$row, c, data );
- } else if ( typeof fxn[ ffxn || data.filter ] === 'function' ) {
- // selector option function
- txt = ffxn || data.filter;
- filterMatched =
- fxn[ txt ]( data.exact, data.cache, data.filter, columnIndex, data.$row, c, data );
- }
- }
- if ( filterMatched === null ) {
- // cycle through the different filters
- // filters return a boolean or null if nothing matches
- filterMatched = tsf.processTypes( c, data, vars );
- // select with exact match; ignore "and" or "or" within the text; fixes #1486
- txt = fxn === true && (data.matchedOn === 'and' || data.matchedOn === 'or');
- if ( filterMatched !== null && !txt) {
- result = filterMatched;
- // Look for match, and add child row data for matching
- } else {
- // check fxn (filter-select in header) after filter types are checked
- // without this, the filter + jQuery UI selectmenu demo was breaking
- if ( fxn === true ) {
- // default selector uses exact match unless 'filter-match' class is found
- result = data.isMatch ?
- // data.iExact may be a number
- ( '' + data.iExact ).search( data.iFilter ) >= 0 :
- data.filter === data.exact;
- } else {
- txt = ( data.iExact + data.childRowText ).indexOf( tsf.parseFilter( c, data.iFilter, data ) );
- result = ( ( !wo.filter_startsWith && txt >= 0 ) || ( wo.filter_startsWith && txt === 0 ) );
- }
- }
- } else {
- result = filterMatched;
- }
- showRow = ( result ) ? showRow : false;
- }
- }
- return showRow;
- },
- findRows: function( table, filters, currentFilters ) {
- if (
- tsf.equalFilters(table.config, table.config.lastSearch, currentFilters) ||
- !table.config.widgetOptions.filter_initialized
- ) {
- return;
- }
- var len, norm_rows, rowData, $rows, $row, rowIndex, tbodyIndex, $tbody, columnIndex,
- isChild, childRow, lastSearch, showRow, showParent, time, val, indx,
- notFiltered, searchFiltered, query, injected, res, id, txt,
- storedFilters = $.extend( [], filters ),
- c = table.config,
- wo = c.widgetOptions,
- debug = ts.debug(c, 'filter'),
- // data object passed to filters; anyMatch is a flag for the filters
- data = {
- anyMatch: false,
- filters: filters,
- // regex filter type cache
- filter_regexCache : []
- },
- vars = {
- // anyMatch really screws up with these types of filters
- noAnyMatch: [ 'range', 'operators' ],
- // cache filter variables that use ts.getColumnData in the main loop
- functions : [],
- excludeFilter : [],
- defaultColFilter : [],
- defaultAnyFilter : ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) || ''
- };
- // parse columns after formatter, in case the class is added at that point
- data.parsed = [];
- for ( columnIndex = 0; columnIndex < c.columns; columnIndex++ ) {
- data.parsed[ columnIndex ] = wo.filter_useParsedData ||
- // parser has a "parsed" parameter
- ( c.parsers && c.parsers[ columnIndex ] && c.parsers[ columnIndex ].parsed ||
- // getData may not return 'parsed' if other 'filter-' class names exist
- // ( e.g. <th class="filter-select filter-parsed"> )
- ts.getData && ts.getData( c.$headerIndexed[ columnIndex ],
- ts.getColumnData( table, c.headers, columnIndex ), 'filter' ) === 'parsed' ||
- c.$headerIndexed[ columnIndex ].hasClass( 'filter-parsed' ) );
-
- vars.functions[ columnIndex ] =
- ts.getColumnData( table, wo.filter_functions, columnIndex ) ||
- c.$headerIndexed[ columnIndex ].hasClass( 'filter-select' );
- vars.defaultColFilter[ columnIndex ] =
- ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) || '';
- vars.excludeFilter[ columnIndex ] =
- ( ts.getColumnData( table, wo.filter_excludeFilter, columnIndex, true ) || '' ).split( /\s+/ );
- }
-
- if ( debug ) {
- console.log( 'Filter >> Starting filter widget search', filters );
- time = new Date();
- }
- // filtered rows count
- c.filteredRows = 0;
- c.totalRows = 0;
- currentFilters = ( storedFilters || [] );
-
- for ( tbodyIndex = 0; tbodyIndex < c.$tbodies.length; tbodyIndex++ ) {
- $tbody = ts.processTbody( table, c.$tbodies.eq( tbodyIndex ), true );
- // skip child rows & widget added ( removable ) rows - fixes #448 thanks to @hempel!
- // $rows = $tbody.children( 'tr' ).not( c.selectorRemove );
- columnIndex = c.columns;
- // convert stored rows into a jQuery object
- norm_rows = c.cache[ tbodyIndex ].normalized;
- $rows = $( $.map( norm_rows, function( el ) {
- return el[ columnIndex ].$row.get();
- }) );
-
- if ( currentFilters.join('') === '' || wo.filter_serversideFiltering ) {
- $rows
- .removeClass( wo.filter_filteredRow )
- .not( '.' + c.cssChildRow )
- .css( 'display', '' );
- } else {
- // filter out child rows
- $rows = $rows.not( '.' + c.cssChildRow );
- len = $rows.length;
-
- if ( ( wo.filter_$anyMatch && wo.filter_$anyMatch.length ) ||
- typeof filters[c.columns] !== 'undefined' ) {
- data.anyMatchFlag = true;
- data.anyMatchFilter = '' + (
- filters[ c.columns ] ||
- wo.filter_$anyMatch && tsf.getLatestSearch( wo.filter_$anyMatch ).val() ||
- ''
- );
- if ( wo.filter_columnAnyMatch ) {
- // specific columns search
- query = data.anyMatchFilter.split( tsfRegex.andSplit );
- injected = false;
- for ( indx = 0; indx < query.length; indx++ ) {
- res = query[ indx ].split( ':' );
- if ( res.length > 1 ) {
- // make the column a one-based index ( non-developers start counting from one :P )
- if ( isNaN( res[0] ) ) {
- $.each( c.headerContent, function( i, txt ) {
- // multiple matches are possible
- if ( txt.toLowerCase().indexOf( res[0] ) > -1 ) {
- id = i;
- filters[ id ] = res[1];
- }
- });
- } else {
- id = parseInt( res[0], 10 ) - 1;
- }
- if ( id >= 0 && id < c.columns ) { // if id is an integer
- filters[ id ] = res[1];
- query.splice( indx, 1 );
- indx--;
- injected = true;
- }
- }
- }
- if ( injected ) {
- data.anyMatchFilter = query.join( ' && ' );
- }
- }
- }
-
- // optimize searching only through already filtered rows - see #313
- searchFiltered = wo.filter_searchFiltered;
- lastSearch = c.lastSearch || c.$table.data( 'lastSearch' ) || [];
- if ( searchFiltered ) {
- // cycle through all filters; include last ( columnIndex + 1 = match any column ). Fixes #669
- for ( indx = 0; indx < columnIndex + 1; indx++ ) {
- val = filters[indx] || '';
- // break out of loop if we've already determined not to search filtered rows
- if ( !searchFiltered ) { indx = columnIndex; }
- // search already filtered rows if...
- searchFiltered = searchFiltered && lastSearch.length &&
- // there are no changes from beginning of filter
- val.indexOf( lastSearch[indx] || '' ) === 0 &&
- // if there is NOT a logical 'or', or range ( 'to' or '-' ) in the string
- !tsfRegex.alreadyFiltered.test( val ) &&
- // if we are not doing exact matches, using '|' ( logical or ) or not '!'
- !tsfRegex.exactTest.test( val ) &&
- // don't search only filtered if the value is negative
- // ( '> -10' => '> -100' will ignore hidden rows )
- !( tsfRegex.isNeg1.test( val ) || tsfRegex.isNeg2.test( val ) ) &&
- // if filtering using a select without a 'filter-match' class ( exact match ) - fixes #593
- !( val !== '' && c.$filters && c.$filters.filter( '[data-column="' + indx + '"]' ).find( 'select' ).length &&
- !tsf.matchType( c, indx ) );
- }
- }
- notFiltered = $rows.not( '.' + wo.filter_filteredRow ).length;
- // can't search when all rows are hidden - this happens when looking for exact matches
- if ( searchFiltered && notFiltered === 0 ) { searchFiltered = false; }
- if ( debug ) {
- console.log( 'Filter >> Searching through ' +
- ( searchFiltered && notFiltered < len ? notFiltered : 'all' ) + ' rows' );
- }
- if ( data.anyMatchFlag ) {
- if ( c.sortLocaleCompare ) {
- // replace accents
- data.anyMatchFilter = ts.replaceAccents( data.anyMatchFilter );
- }
- if ( wo.filter_defaultFilter && tsfRegex.iQuery.test( vars.defaultAnyFilter ) ) {
- data.anyMatchFilter = tsf.defaultFilter( data.anyMatchFilter, vars.defaultAnyFilter );
- // clear search filtered flag because default filters are not saved to the last search
- searchFiltered = false;
- }
- // make iAnyMatchFilter lowercase unless both filter widget & core ignoreCase options are true
- // when c.ignoreCase is true, the cache contains all lower case data
- data.iAnyMatchFilter = !( wo.filter_ignoreCase && c.ignoreCase ) ?
- data.anyMatchFilter :
- data.anyMatchFilter.toLowerCase();
- }
-
- // loop through the rows
- for ( rowIndex = 0; rowIndex < len; rowIndex++ ) {
-
- txt = $rows[ rowIndex ].className;
- // the first row can never be a child row
- isChild = rowIndex && tsfRegex.child.test( txt );
- // skip child rows & already filtered rows
- if ( isChild || ( searchFiltered && tsfRegex.filtered.test( txt ) ) ) {
- continue;
- }
-
- data.$row = $rows.eq( rowIndex );
- data.rowIndex = rowIndex;
- data.cacheArray = norm_rows[ rowIndex ];
- rowData = data.cacheArray[ c.columns ];
- data.rawArray = rowData.raw;
- data.childRowText = '';
-
- if ( !wo.filter_childByColumn ) {
- txt = '';
- // child row cached text
- childRow = rowData.child;
- // so, if 'table.config.widgetOptions.filter_childRows' is true and there is
- // a match anywhere in the child row, then it will make the row visible
- // checked here so the option can be changed dynamically
- for ( indx = 0; indx < childRow.length; indx++ ) {
- txt += ' ' + childRow[indx].join( ' ' ) || '';
- }
- data.childRowText = wo.filter_childRows ?
- ( wo.filter_ignoreCase ? txt.toLowerCase() : txt ) :
- '';
- }
-
- showRow = false;
- showParent = tsf.processRow( c, data, vars );
- $row = rowData.$row;
-
- // don't pass reference to val
- val = showParent ? true : false;
- childRow = rowData.$row.filter( ':gt(0)' );
- if ( wo.filter_childRows && childRow.length ) {
- if ( wo.filter_childByColumn ) {
- if ( !wo.filter_childWithSibs ) {
- // hide all child rows
- childRow.addClass( wo.filter_filteredRow );
- // if only showing resulting child row, only include parent
- $row = $row.eq( 0 );
- }
- // cycle through each child row
- for ( indx = 0; indx < childRow.length; indx++ ) {
- data.$row = childRow.eq( indx );
- data.cacheArray = rowData.child[ indx ];
- data.rawArray = data.cacheArray;
- val = tsf.processRow( c, data, vars );
- // use OR comparison on child rows
- showRow = showRow || val;
- if ( !wo.filter_childWithSibs && val ) {
- childRow.eq( indx ).removeClass( wo.filter_filteredRow );
- }
- }
- }
- // keep parent row match even if no child matches... see #1020
- showRow = showRow || showParent;
- } else {
- showRow = val;
- }
- $row
- .toggleClass( wo.filter_filteredRow, !showRow )[0]
- .display = showRow ? '' : 'none';
- }
- }
- c.filteredRows += $rows.not( '.' + wo.filter_filteredRow ).length;
- c.totalRows += $rows.length;
- ts.processTbody( table, $tbody, false );
- }
- // lastCombinedFilter is no longer used internally
- c.lastCombinedFilter = storedFilters.join(''); // save last search
- // don't save 'filters' directly since it may have altered ( AnyMatch column searches )
- c.lastSearch = storedFilters;
- c.$table.data( 'lastSearch', storedFilters );
- if ( wo.filter_saveFilters && ts.storage ) {
- ts.storage( table, 'tablesorter-filters', tsf.processFilters( storedFilters, true ) );
- }
- if ( debug ) {
- console.log( 'Filter >> Completed search' + ts.benchmark(time) );
- }
- if ( wo.filter_initialized ) {
- c.$table.triggerHandler( 'filterBeforeEnd', c );
- c.$table.triggerHandler( 'filterEnd', c );
- }
- setTimeout( function() {
- ts.applyWidget( c.table ); // make sure zebra widget is applied
- }, 0 );
- },
- getOptionSource: function( table, column, onlyAvail ) {
- table = $( table )[0];
- var c = table.config,
- wo = c.widgetOptions,
- arry = false,
- source = wo.filter_selectSource,
- last = c.$table.data( 'lastSearch' ) || [],
- fxn = typeof source === 'function' ? true : ts.getColumnData( table, source, column );
-
- if ( onlyAvail && last[column] !== '' ) {
- onlyAvail = false;
- }
-
- // filter select source option
- if ( fxn === true ) {
- // OVERALL source
- arry = source( table, column, onlyAvail );
- } else if ( fxn instanceof $ || ( $.type( fxn ) === 'string' && fxn.indexOf( '</option>' ) >= 0 ) ) {
- // selectSource is a jQuery object or string of options
- return fxn;
- } else if ( $.isArray( fxn ) ) {
- arry = fxn;
- } else if ( $.type( source ) === 'object' && fxn ) {
- // custom select source function for a SPECIFIC COLUMN
- arry = fxn( table, column, onlyAvail );
- // abort - updating the selects from an external method
- if (arry === null) {
- return null;
- }
- }
- if ( arry === false ) {
- // fall back to original method
- arry = tsf.getOptions( table, column, onlyAvail );
- }
-
- return tsf.processOptions( table, column, arry );
-
- },
- processOptions: function( table, column, arry ) {
- if ( !$.isArray( arry ) ) {
- return false;
- }
- table = $( table )[0];
- var cts, txt, indx, len, parsedTxt, str,
- c = table.config,
- validColumn = typeof column !== 'undefined' && column !== null && column >= 0 && column < c.columns,
- direction = validColumn ? c.$headerIndexed[ column ].hasClass( 'filter-select-sort-desc' ) : false,
- parsed = [];
- // get unique elements and sort the list
- // if $.tablesorter.sortText exists ( not in the original tablesorter ),
- // then natural sort the list otherwise use a basic sort
- arry = $.grep( arry, function( value, indx ) {
- if ( value.text ) {
- return true;
- }
- return $.inArray( value, arry ) === indx;
- });
- if ( validColumn && c.$headerIndexed[ column ].hasClass( 'filter-select-nosort' ) ) {
- // unsorted select options
- return arry;
- } else {
- len = arry.length;
- // parse select option values
- for ( indx = 0; indx < len; indx++ ) {
- txt = arry[ indx ];
- // check for object
- str = txt.text ? txt.text : txt;
- // sortNatural breaks if you don't pass it strings
- parsedTxt = ( validColumn && c.parsers && c.parsers.length &&
- c.parsers[ column ].format( str, table, [], column ) || str ).toString();
- parsedTxt = c.widgetOptions.filter_ignoreCase ? parsedTxt.toLowerCase() : parsedTxt;
- // parse array data using set column parser; this DOES NOT pass the original
- // table cell to the parser format function
- if ( txt.text ) {
- txt.parsed = parsedTxt;
- parsed[ parsed.length ] = txt;
- } else {
- parsed[ parsed.length ] = {
- text : txt,
- // check parser length - fixes #934
- parsed : parsedTxt
- };
- }
- }
- // sort parsed select options
- cts = c.textSorter || '';
- parsed.sort( function( a, b ) {
- var x = direction ? b.parsed : a.parsed,
- y = direction ? a.parsed : b.parsed;
- if ( validColumn && typeof cts === 'function' ) {
- // custom OVERALL text sorter
- return cts( x, y, true, column, table );
- } else if ( validColumn && typeof cts === 'object' && cts.hasOwnProperty( column ) ) {
- // custom text sorter for a SPECIFIC COLUMN
- return cts[column]( x, y, true, column, table );
- } else if ( ts.sortNatural ) {
- // fall back to natural sort
- return ts.sortNatural( x, y );
- }
- // using an older version! do a basic sort
- return true;
- });
- // rebuild arry from sorted parsed data
- arry = [];
- len = parsed.length;
- for ( indx = 0; indx < len; indx++ ) {
- arry[ arry.length ] = parsed[indx];
- }
- return arry;
- }
- },
- getOptions: function( table, column, onlyAvail ) {
- table = $( table )[0];
- var rowIndex, tbodyIndex, len, row, cache, indx, child, childLen,
- c = table.config,
- wo = c.widgetOptions,
- arry = [];
- for ( tbodyIndex = 0; tbodyIndex < c.$tbodies.length; tbodyIndex++ ) {
- cache = c.cache[tbodyIndex];
- len = c.cache[tbodyIndex].normalized.length;
- // loop through the rows
- for ( rowIndex = 0; rowIndex < len; rowIndex++ ) {
- // get cached row from cache.row ( old ) or row data object
- // ( new; last item in normalized array )
- row = cache.row ?
- cache.row[ rowIndex ] :
- cache.normalized[ rowIndex ][ c.columns ].$row[0];
- // check if has class filtered
- if ( onlyAvail && row.className.match( wo.filter_filteredRow ) ) {
- continue;
- }
- // get non-normalized cell content
- if ( wo.filter_useParsedData ||
- c.parsers[column].parsed ||
- c.$headerIndexed[column].hasClass( 'filter-parsed' ) ) {
- arry[ arry.length ] = '' + cache.normalized[ rowIndex ][ column ];
- // child row parsed data
- if ( wo.filter_childRows && wo.filter_childByColumn ) {
- childLen = cache.normalized[ rowIndex ][ c.columns ].$row.length - 1;
- for ( indx = 0; indx < childLen; indx++ ) {
- arry[ arry.length ] = '' + cache.normalized[ rowIndex ][ c.columns ].child[ indx ][ column ];
- }
- }
- } else {
- // get raw cached data instead of content directly from the cells
- arry[ arry.length ] = cache.normalized[ rowIndex ][ c.columns ].raw[ column ];
- // child row unparsed data
- if ( wo.filter_childRows && wo.filter_childByColumn ) {
- childLen = cache.normalized[ rowIndex ][ c.columns ].$row.length;
- for ( indx = 1; indx < childLen; indx++ ) {
- child = cache.normalized[ rowIndex ][ c.columns ].$row.eq( indx ).children().eq( column );
- arry[ arry.length ] = '' + ts.getElementText( c, child, column );
- }
- }
- }
- }
- }
- return arry;
- },
- buildSelect: function( table, column, arry, updating, onlyAvail ) {
- table = $( table )[0];
- column = parseInt( column, 10 );
- if ( !table.config.cache || $.isEmptyObject( table.config.cache ) ) {
- return;
- }
-
- var indx, val, txt, t, $filters, $filter, option,
- c = table.config,
- wo = c.widgetOptions,
- node = c.$headerIndexed[ column ],
- // t.data( 'placeholder' ) won't work in jQuery older than 1.4.3
- options = '<option value="">' +
- ( node.data( 'placeholder' ) ||
- node.attr( 'data-placeholder' ) ||
- wo.filter_placeholder.select || ''
- ) + '</option>',
- // Get curent filter value
- currentValue = c.$table
- .find( 'thead' )
- .find( 'select.' + tscss.filter + '[data-column="' + column + '"]' )
- .val();
-
- // nothing included in arry ( external source ), so get the options from
- // filter_selectSource or column data
- if ( typeof arry === 'undefined' || arry === '' ) {
- arry = tsf.getOptionSource( table, column, onlyAvail );
- // abort, selects are updated by an external method
- if (arry === null) {
- return;
- }
- }
-
- if ( $.isArray( arry ) ) {
- // build option list
- for ( indx = 0; indx < arry.length; indx++ ) {
- option = arry[ indx ];
- if ( option.text ) {
- // OBJECT!! add data-function-name in case the value is set in filter_functions
- option['data-function-name'] = typeof option.value === 'undefined' ? option.text : option.value;
-
- // support jQuery < v1.8, otherwise the below code could be shortened to
- // options += $( '<option>', option )[ 0 ].outerHTML;
- options += '<option';
- for ( val in option ) {
- if ( option.hasOwnProperty( val ) && val !== 'text' ) {
- options += ' ' + val + '="' + option[ val ].replace( tsfRegex.quote, '&quot;' ) + '"';
- }
- }
- if ( !option.value ) {
- options += ' value="' + option.text.replace( tsfRegex.quote, '&quot;' ) + '"';
- }
- options += '>' + option.text.replace( tsfRegex.quote, '&quot;' ) + '</option>';
- // above code is needed in jQuery < v1.8
-
- // make sure we don't turn an object into a string (objects without a "text" property)
- } else if ( '' + option !== '[object Object]' ) {
- txt = option = ( '' + option ).replace( tsfRegex.quote, '&quot;' );
- val = txt;
- // allow including a symbol in the selectSource array
- // 'a-z|A through Z' so that 'a-z' becomes the option value
- // and 'A through Z' becomes the option text
- if ( txt.indexOf( wo.filter_selectSourceSeparator ) >= 0 ) {
- t = txt.split( wo.filter_selectSourceSeparator );
- val = t[0];
- txt = t[1];
- }
- // replace quotes - fixes #242 & ignore empty strings
- // see http://stackoverflow.com/q/14990971/145346
- options += option !== '' ?
- '<option ' +
- ( val === txt ? '' : 'data-function-name="' + option + '" ' ) +
- 'value="' + val + '">' + txt +
- '</option>' : '';
- }
- }
- // clear arry so it doesn't get appended twice
- arry = [];
- }
-
- // update all selects in the same column ( clone thead in sticky headers &
- // any external selects ) - fixes 473
- $filters = ( c.$filters ? c.$filters : c.$table.children( 'thead' ) )
- .find( '.' + tscss.filter );
- if ( wo.filter_$externalFilters ) {
- $filters = $filters && $filters.length ?
- $filters.add( wo.filter_$externalFilters ) :
- wo.filter_$externalFilters;
- }
- $filter = $filters.filter( 'select[data-column="' + column + '"]' );
-
- // make sure there is a select there!
- if ( $filter.length ) {
- $filter[ updating ? 'html' : 'append' ]( options );
- if ( !$.isArray( arry ) ) {
- // append options if arry is provided externally as a string or jQuery object
- // options ( default value ) was already added
- $filter.append( arry ).val( currentValue );
- }
- $filter.val( currentValue );
- }
- },
- buildDefault: function( table, updating ) {
- var columnIndex, $header, noSelect,
- c = table.config,
- wo = c.widgetOptions,
- columns = c.columns;
- // build default select dropdown
- for ( columnIndex = 0; columnIndex < columns; columnIndex++ ) {
- $header = c.$headerIndexed[columnIndex];
- noSelect = !( $header.hasClass( 'filter-false' ) || $header.hasClass( 'parser-false' ) );
- // look for the filter-select class; build/update it if found
- if ( ( $header.hasClass( 'filter-select' ) ||
- ts.getColumnData( table, wo.filter_functions, columnIndex ) === true ) && noSelect ) {
- tsf.buildSelect( table, columnIndex, '', updating, $header.hasClass( wo.filter_onlyAvail ) );
- }
- }
- }
- };
-
- // filter regex variable
- tsfRegex = tsf.regex;
-
- ts.getFilters = function( table, getRaw, setFilters, skipFirst ) {
- var i, $filters, $column, cols,
- filters = [],
- c = table ? $( table )[0].config : '',
- wo = c ? c.widgetOptions : '';
- if ( ( getRaw !== true && wo && !wo.filter_columnFilters ) ||
- // setFilters called, but last search is exactly the same as the current
- // fixes issue #733 & #903 where calling update causes the input values to reset
- ( $.isArray(setFilters) && tsf.equalFilters(c, setFilters, c.lastSearch) )
- ) {
- return $( table ).data( 'lastSearch' ) || [];
- }
- if ( c ) {
- if ( c.$filters ) {
- $filters = c.$filters.find( '.' + tscss.filter );
- }
- if ( wo.filter_$externalFilters ) {
- $filters = $filters && $filters.length ?
- $filters.add( wo.filter_$externalFilters ) :
- wo.filter_$externalFilters;
- }
- if ( $filters && $filters.length ) {
- filters = setFilters || [];
- for ( i = 0; i < c.columns + 1; i++ ) {
- cols = ( i === c.columns ?
- // 'all' columns can now include a range or set of columms ( data-column='0-2,4,6-7' )
- wo.filter_anyColumnSelector + ',' + wo.filter_multipleColumnSelector :
- '[data-column="' + i + '"]' );
- $column = $filters.filter( cols );
- if ( $column.length ) {
- // move the latest search to the first slot in the array
- $column = tsf.getLatestSearch( $column );
- if ( $.isArray( setFilters ) ) {
- // skip first ( latest input ) to maintain cursor position while typing
- if ( skipFirst && $column.length > 1 ) {
- $column = $column.slice( 1 );
- }
- if ( i === c.columns ) {
- // prevent data-column='all' from filling data-column='0,1' ( etc )
- cols = $column.filter( wo.filter_anyColumnSelector );
- $column = cols.length ? cols : $column;
- }
- $column
- .val( setFilters[ i ] )
- // must include a namespace here; but not c.namespace + 'filter'?
- .trigger( 'change' + c.namespace );
- } else {
- filters[i] = $column.val() || '';
- // don't change the first... it will move the cursor
- if ( i === c.columns ) {
- // don't update range columns from 'all' setting
- $column
- .slice( 1 )
- .filter( '[data-column*="' + $column.attr( 'data-column' ) + '"]' )
- .val( filters[ i ] );
- } else {
- $column
- .slice( 1 )
- .val( filters[ i ] );
- }
- }
- // save any match input dynamically
- if ( i === c.columns && $column.length ) {
- wo.filter_$anyMatch = $column;
- }
- }
- }
- }
- }
- return filters;
- };
-
- ts.setFilters = function( table, filter, apply, skipFirst ) {
- var c = table ? $( table )[0].config : '',
- valid = ts.getFilters( table, true, filter, skipFirst );
- // default apply to "true"
- if ( typeof apply === 'undefined' ) {
- apply = true;
- }
- if ( c && apply ) {
- // ensure new set filters are applied, even if the search is the same
- c.lastCombinedFilter = null;
- c.lastSearch = [];
- tsf.searching( c.table, filter, skipFirst );
- c.$table.triggerHandler( 'filterFomatterUpdate' );
- }
- return valid.length !== 0;
- };
-
-})( jQuery );
-
-/*! Widget: stickyHeaders - updated 9/27/2017 (v2.29.0) *//*
- * Requires tablesorter v2.8+ and jQuery 1.4.3+
- * by Rob Garrison
- */
-;(function ($, window) {
- 'use strict';
- var ts = $.tablesorter || {};
-
- $.extend(ts.css, {
- sticky : 'tablesorter-stickyHeader', // stickyHeader
- stickyVis : 'tablesorter-sticky-visible',
- stickyHide: 'tablesorter-sticky-hidden',
- stickyWrap: 'tablesorter-sticky-wrapper'
- });
-
- // Add a resize event to table headers
- ts.addHeaderResizeEvent = function(table, disable, settings) {
- table = $(table)[0]; // make sure we're using a dom element
- if ( !table.config ) { return; }
- var defaults = {
- timer : 250
- },
- options = $.extend({}, defaults, settings),
- c = table.config,
- wo = c.widgetOptions,
- checkSizes = function( triggerEvent ) {
- var index, headers, $header, sizes, width, height,
- len = c.$headers.length;
- wo.resize_flag = true;
- headers = [];
- for ( index = 0; index < len; index++ ) {
- $header = c.$headers.eq( index );
- sizes = $header.data( 'savedSizes' ) || [ 0, 0 ]; // fixes #394
- width = $header[0].offsetWidth;
- height = $header[0].offsetHeight;
- if ( width !== sizes[0] || height !== sizes[1] ) {
- $header.data( 'savedSizes', [ width, height ] );
- headers.push( $header[0] );
- }
- }
- if ( headers.length && triggerEvent !== false ) {
- c.$table.triggerHandler( 'resize', [ headers ] );
- }
- wo.resize_flag = false;
- };
- clearInterval(wo.resize_timer);
- if (disable) {
- wo.resize_flag = false;
- return false;
- }
- checkSizes( false );
- wo.resize_timer = setInterval(function() {
- if (wo.resize_flag) { return; }
- checkSizes();
- }, options.timer);
- };
-
- function getStickyOffset(c, wo) {
- var $el = isNaN(wo.stickyHeaders_offset) ? $(wo.stickyHeaders_offset) : [];
- return $el.length ?
- $el.height() || 0 :
- parseInt(wo.stickyHeaders_offset, 10) || 0;
- }
-
- // Sticky headers based on this awesome article:
- // http://css-tricks.com/13465-persistent-headers/
- // and https://github.com/jmosbech/StickyTableHeaders by Jonas Mosbech
- // **************************
- ts.addWidget({
- id: 'stickyHeaders',
- priority: 54, // sticky widget must be initialized after the filter & before pager widget!
- options: {
- stickyHeaders : '', // extra class name added to the sticky header row
- stickyHeaders_appendTo : null, // jQuery selector or object to phycially attach the sticky headers
- stickyHeaders_attachTo : null, // jQuery selector or object to attach scroll listener to (overridden by xScroll & yScroll settings)
- stickyHeaders_xScroll : null, // jQuery selector or object to monitor horizontal scroll position (defaults: xScroll > attachTo > window)
- stickyHeaders_yScroll : null, // jQuery selector or object to monitor vertical scroll position (defaults: yScroll > attachTo > window)
- stickyHeaders_offset : 0, // number or jquery selector targeting the position:fixed element
- stickyHeaders_filteredToTop: true, // scroll table top into view after filtering
- stickyHeaders_cloneId : '-sticky', // added to table ID, if it exists
- stickyHeaders_addResizeEvent : true, // trigger 'resize' event on headers
- stickyHeaders_includeCaption : true, // if false and a caption exist, it won't be included in the sticky header
- stickyHeaders_zIndex : 2 // The zIndex of the stickyHeaders, allows the user to adjust this to their needs
- },
- format: function(table, c, wo) {
- // filter widget doesn't initialize on an empty table. Fixes #449
- if ( c.$table.hasClass('hasStickyHeaders') || ($.inArray('filter', c.widgets) >= 0 && !c.$table.hasClass('hasFilters')) ) {
- return;
- }
- var index, len, $t,
- $table = c.$table,
- // add position: relative to attach element, hopefully it won't cause trouble.
- $attach = $(wo.stickyHeaders_attachTo || wo.stickyHeaders_appendTo),
- namespace = c.namespace + 'stickyheaders ',
- // element to watch for the scroll event
- $yScroll = $(wo.stickyHeaders_yScroll || wo.stickyHeaders_attachTo || window),
- $xScroll = $(wo.stickyHeaders_xScroll || wo.stickyHeaders_attachTo || window),
- $thead = $table.children('thead:first'),
- $header = $thead.children('tr').not('.sticky-false').children(),
- $tfoot = $table.children('tfoot'),
- stickyOffset = getStickyOffset(c, wo),
- // is this table nested? If so, find parent sticky header wrapper (div, not table)
- $nestedSticky = $table.parent().closest('.' + ts.css.table).hasClass('hasStickyHeaders') ?
- $table.parent().closest('table.tablesorter')[0].config.widgetOptions.$sticky.parent() : [],
- nestedStickyTop = $nestedSticky.length ? $nestedSticky.height() : 0,
- // clone table, then wrap to make sticky header
- $stickyTable = wo.$sticky = $table.clone()
- .addClass('containsStickyHeaders ' + ts.css.sticky + ' ' + wo.stickyHeaders + ' ' + c.namespace.slice(1) + '_extra_table' )
- .wrap('<div class="' + ts.css.stickyWrap + '">'),
- $stickyWrap = $stickyTable.parent()
- .addClass(ts.css.stickyHide)
- .css({
- position : $attach.length ? 'absolute' : 'fixed',
- padding : parseInt( $stickyTable.parent().parent().css('padding-left'), 10 ),
- top : stickyOffset + nestedStickyTop,
- left : 0,
- visibility : 'hidden',
- zIndex : wo.stickyHeaders_zIndex || 2
- }),
- $stickyThead = $stickyTable.children('thead:first'),
- $stickyCells,
- laststate = '',
- setWidth = function($orig, $clone) {
- var index, width, border, $cell, $this,
- $cells = $orig.filter(':visible'),
- len = $cells.length;
- for ( index = 0; index < len; index++ ) {
- $cell = $clone.filter(':visible').eq(index);
- $this = $cells.eq(index);
- // code from https://github.com/jmosbech/StickyTableHeaders
- if ($this.css('box-sizing') === 'border-box') {
- width = $this.outerWidth();
- } else {
- if ($cell.css('border-collapse') === 'collapse') {
- if (window.getComputedStyle) {
- width = parseFloat( window.getComputedStyle($this[0], null).width );
- } else {
- // ie8 only
- border = parseFloat( $this.css('border-width') );
- width = $this.outerWidth() - parseFloat( $this.css('padding-left') ) - parseFloat( $this.css('padding-right') ) - border;
- }
- } else {
- width = $this.width();
- }
- }
- $cell.css({
- 'width': width,
- 'min-width': width,
- 'max-width': width
- });
- }
- },
- getLeftPosition = function(yWindow) {
- if (yWindow === false && $nestedSticky.length) {
- return $table.position().left;
- }
- return $attach.length ?
- parseInt($attach.css('padding-left'), 10) || 0 :
- $table.offset().left - parseInt($table.css('margin-left'), 10) - $(window).scrollLeft();
- },
- resizeHeader = function() {
- $stickyWrap.css({
- left : getLeftPosition(),
- width: $table.outerWidth()
- });
- setWidth( $table, $stickyTable );
- setWidth( $header, $stickyCells );
- },
- scrollSticky = function( resizing ) {
- if (!$table.is(':visible')) { return; } // fixes #278
- // Detect nested tables - fixes #724
- nestedStickyTop = $nestedSticky.length ? $nestedSticky.offset().top - $yScroll.scrollTop() + $nestedSticky.height() : 0;
- var tmp,
- offset = $table.offset(),
- stickyOffset = getStickyOffset(c, wo),
- yWindow = $.isWindow( $yScroll[0] ), // $.isWindow needs jQuery 1.4.3
- yScroll = yWindow ?
- $yScroll.scrollTop() :
- // use parent sticky position if nested AND inside of a scrollable element - see #1512
- $nestedSticky.length ? parseInt($nestedSticky[0].style.top, 10) : $yScroll.offset().top,
- attachTop = $attach.length ? yScroll : $yScroll.scrollTop(),
- captionHeight = wo.stickyHeaders_includeCaption ? 0 : $table.children( 'caption' ).height() || 0,
- scrollTop = attachTop + stickyOffset + nestedStickyTop - captionHeight,
- tableHeight = $table.height() - ($stickyWrap.height() + ($tfoot.height() || 0)) - captionHeight,
- isVisible = ( scrollTop > offset.top ) && ( scrollTop < offset.top + tableHeight ) ? 'visible' : 'hidden',
- state = isVisible === 'visible' ? ts.css.stickyVis : ts.css.stickyHide,
- needsUpdating = !$stickyWrap.hasClass( state ),
- cssSettings = { visibility : isVisible };
- if ($attach.length) {
- // attached sticky headers always need updating
- needsUpdating = true;
- cssSettings.top = yWindow ? scrollTop - $attach.offset().top : $attach.scrollTop();
- }
- // adjust when scrolling horizontally - fixes issue #143
- tmp = getLeftPosition(yWindow);
- if (tmp !== parseInt($stickyWrap.css('left'), 10)) {
- needsUpdating = true;
- cssSettings.left = tmp;
- }
- cssSettings.top = ( cssSettings.top || 0 ) +
- // If nested AND inside of a scrollable element, only add parent sticky height
- (!yWindow && $nestedSticky.length ? $nestedSticky.height() : stickyOffset + nestedStickyTop);
- if (needsUpdating) {
- $stickyWrap
- .removeClass( ts.css.stickyVis + ' ' + ts.css.stickyHide )
- .addClass( state )
- .css(cssSettings);
- }
- if (isVisible !== laststate || resizing) {
- // make sure the column widths match
- resizeHeader();
- laststate = isVisible;
- }
- };
- // only add a position relative if a position isn't already defined
- if ($attach.length && !$attach.css('position')) {
- $attach.css('position', 'relative');
- }
- // fix clone ID, if it exists - fixes #271
- if ($stickyTable.attr('id')) { $stickyTable[0].id += wo.stickyHeaders_cloneId; }
- // clear out cloned table, except for sticky header
- // include caption & filter row (fixes #126 & #249) - don't remove cells to get correct cell indexing
- $stickyTable.find('> thead:gt(0), tr.sticky-false').hide();
- $stickyTable.find('> tbody, > tfoot').remove();
- $stickyTable.find('caption').toggle(wo.stickyHeaders_includeCaption);
- // issue #172 - find td/th in sticky header
- $stickyCells = $stickyThead.children().children();
- $stickyTable.css({ height:0, width:0, margin: 0 });
- // remove resizable block
- $stickyCells.find('.' + ts.css.resizer).remove();
- // update sticky header class names to match real header after sorting
- $table
- .addClass('hasStickyHeaders')
- .bind('pagerComplete' + namespace, function() {
- resizeHeader();
- });
-
- ts.bindEvents(table, $stickyThead.children().children('.' + ts.css.header));
-
- if (wo.stickyHeaders_appendTo) {
- $(wo.stickyHeaders_appendTo).append( $stickyWrap );
- } else {
- // add stickyheaders AFTER the table. If the table is selected by ID, the original one (first) will be returned.
- $table.after( $stickyWrap );
- }
-
- // onRenderHeader is defined, we need to do something about it (fixes #641)
- if (c.onRenderHeader) {
- $t = $stickyThead.children('tr').children();
- len = $t.length;
- for ( index = 0; index < len; index++ ) {
- // send second parameter
- c.onRenderHeader.apply( $t.eq( index ), [ index, c, $stickyTable ] );
- }
- }
- // make it sticky!
- $xScroll.add($yScroll)
- .unbind( ('scroll resize '.split(' ').join( namespace )).replace(/\s+/g, ' ') )
- .bind('scroll resize '.split(' ').join( namespace ), function( event ) {
- scrollSticky( event.type === 'resize' );
- });
- c.$table
- .unbind('stickyHeadersUpdate' + namespace)
- .bind('stickyHeadersUpdate' + namespace, function() {
- scrollSticky( true );
- });
-
- if (wo.stickyHeaders_addResizeEvent) {
- ts.addHeaderResizeEvent(table);
- }
-
- // look for filter widget
- if ($table.hasClass('hasFilters') && wo.filter_columnFilters) {
- // scroll table into view after filtering, if sticky header is active - #482
- $table.bind('filterEnd' + namespace, function() {
- // $(':focus') needs jQuery 1.6+
- var $td = $(document.activeElement).closest('td'),
- column = $td.parent().children().index($td);
- // only scroll if sticky header is active
- if ($stickyWrap.hasClass(ts.css.stickyVis) && wo.stickyHeaders_filteredToTop) {
- // scroll to original table (not sticky clone)
- window.scrollTo(0, $table.position().top);
- // give same input/select focus; check if c.$filters exists; fixes #594
- if (column >= 0 && c.$filters) {
- c.$filters.eq(column).find('a, select, input').filter(':visible').focus();
- }
- }
- });
- ts.filter.bindSearch( $table, $stickyCells.find('.' + ts.css.filter) );
- // support hideFilters
- if (wo.filter_hideFilters) {
- ts.filter.hideFilters(c, $stickyTable);
- }
- }
-
- // resize table (Firefox)
- if (wo.stickyHeaders_addResizeEvent) {
- $table.bind('resize' + c.namespace + 'stickyheaders', function() {
- resizeHeader();
- });
- }
-
- // make sure sticky is visible if page is partially scrolled
- scrollSticky( true );
- $table.triggerHandler('stickyHeadersInit');
-
- },
- remove: function(table, c, wo) {
- var namespace = c.namespace + 'stickyheaders ';
- c.$table
- .removeClass('hasStickyHeaders')
- .unbind( ('pagerComplete resize filterEnd stickyHeadersUpdate '.split(' ').join(namespace)).replace(/\s+/g, ' ') )
- .next('.' + ts.css.stickyWrap).remove();
- if (wo.$sticky && wo.$sticky.length) { wo.$sticky.remove(); } // remove cloned table
- $(window)
- .add(wo.stickyHeaders_xScroll)
- .add(wo.stickyHeaders_yScroll)
- .add(wo.stickyHeaders_attachTo)
- .unbind( ('scroll resize '.split(' ').join(namespace)).replace(/\s+/g, ' ') );
- ts.addHeaderResizeEvent(table, true);
- }
- });
-
-})(jQuery, window);
-
-/*! Widget: resizable - updated 2018-03-26 (v2.30.2) */
-/*jshint browser:true, jquery:true, unused:false */
-;(function ($, window) {
- 'use strict';
- var ts = $.tablesorter || {};
-
- $.extend(ts.css, {
- resizableContainer : 'tablesorter-resizable-container',
- resizableHandle : 'tablesorter-resizable-handle',
- resizableNoSelect : 'tablesorter-disableSelection',
- resizableStorage : 'tablesorter-resizable'
- });
-
- // Add extra scroller css
- $(function() {
- var s = '<style>' +
- 'body.' + ts.css.resizableNoSelect + ' { -ms-user-select: none; -moz-user-select: -moz-none;' +
- '-khtml-user-select: none; -webkit-user-select: none; user-select: none; }' +
- '.' + ts.css.resizableContainer + ' { position: relative; height: 1px; }' +
- // make handle z-index > than stickyHeader z-index, so the handle stays above sticky header
- '.' + ts.css.resizableHandle + ' { position: absolute; display: inline-block; width: 8px;' +
- 'top: 1px; cursor: ew-resize; z-index: 3; user-select: none; -moz-user-select: none; }' +
- '</style>';
- $('head').append(s);
- });
-
- ts.resizable = {
- init : function( c, wo ) {
- if ( c.$table.hasClass( 'hasResizable' ) ) { return; }
- c.$table.addClass( 'hasResizable' );
-
- var noResize, $header, column, storedSizes, tmp,
- $table = c.$table,
- $parent = $table.parent(),
- marginTop = parseInt( $table.css( 'margin-top' ), 10 ),
-
- // internal variables
- vars = wo.resizable_vars = {
- useStorage : ts.storage && wo.resizable !== false,
- $wrap : $parent,
- mouseXPosition : 0,
- $target : null,
- $next : null,
- overflow : $parent.css('overflow') === 'auto' ||
- $parent.css('overflow') === 'scroll' ||
- $parent.css('overflow-x') === 'auto' ||
- $parent.css('overflow-x') === 'scroll',
- storedSizes : []
- };
-
- // set default widths
- ts.resizableReset( c.table, true );
-
- // now get measurements!
- vars.tableWidth = $table.width();
- // attempt to autodetect
- vars.fullWidth = Math.abs( $parent.width() - vars.tableWidth ) < 20;
-
- /*
- // Hacky method to determine if table width is set to 'auto'
- // http://stackoverflow.com/a/20892048/145346
- if ( !vars.fullWidth ) {
- tmp = $table.width();
- $header = $table.wrap('<span>').parent(); // temp variable
- storedSizes = parseInt( $table.css( 'margin-left' ), 10 ) || 0;
- $table.css( 'margin-left', storedSizes + 50 );
- vars.tableWidth = $header.width() > tmp ? 'auto' : tmp;
- $table.css( 'margin-left', storedSizes ? storedSizes : '' );
- $header = null;
- $table.unwrap('<span>');
- }
- */
-
- if ( vars.useStorage && vars.overflow ) {
- // save table width
- ts.storage( c.table, 'tablesorter-table-original-css-width', vars.tableWidth );
- tmp = ts.storage( c.table, 'tablesorter-table-resized-width' ) || 'auto';
- ts.resizable.setWidth( $table, tmp, true );
- }
- wo.resizable_vars.storedSizes = storedSizes = ( vars.useStorage ?
- ts.storage( c.table, ts.css.resizableStorage ) :
- [] ) || [];
- ts.resizable.setWidths( c, wo, storedSizes );
- ts.resizable.updateStoredSizes( c, wo );
-
- wo.$resizable_container = $( '<div class="' + ts.css.resizableContainer + '">' )
- .css({ top : marginTop })
- .insertBefore( $table );
- // add container
- for ( column = 0; column < c.columns; column++ ) {
- $header = c.$headerIndexed[ column ];
- tmp = ts.getColumnData( c.table, c.headers, column );
- noResize = ts.getData( $header, tmp, 'resizable' ) === 'false';
- if ( !noResize ) {
- $( '<div class="' + ts.css.resizableHandle + '">' )
- .appendTo( wo.$resizable_container )
- .attr({
- 'data-column' : column,
- 'unselectable' : 'on'
- })
- .data( 'header', $header )
- .bind( 'selectstart', false );
- }
- }
- ts.resizable.bindings( c, wo );
- },
-
- updateStoredSizes : function( c, wo ) {
- var column, $header,
- len = c.columns,
- vars = wo.resizable_vars;
- vars.storedSizes = [];
- for ( column = 0; column < len; column++ ) {
- $header = c.$headerIndexed[ column ];
- vars.storedSizes[ column ] = $header.is(':visible') ? $header.width() : 0;
- }
- },
-
- setWidth : function( $el, width, overflow ) {
- // overflow tables need min & max width set as well
- $el.css({
- 'width' : width,
- 'min-width' : overflow ? width : '',
- 'max-width' : overflow ? width : ''
- });
- },
-
- setWidths : function( c, wo, storedSizes ) {
- var column, $temp,
- vars = wo.resizable_vars,
- $extra = $( c.namespace + '_extra_headers' ),
- $col = c.$table.children( 'colgroup' ).children( 'col' );
- storedSizes = storedSizes || vars.storedSizes || [];
- // process only if table ID or url match
- if ( storedSizes.length ) {
- for ( column = 0; column < c.columns; column++ ) {
- // set saved resizable widths
- ts.resizable.setWidth( c.$headerIndexed[ column ], storedSizes[ column ], vars.overflow );
- if ( $extra.length ) {
- // stickyHeaders needs to modify min & max width as well
- $temp = $extra.eq( column ).add( $col.eq( column ) );
- ts.resizable.setWidth( $temp, storedSizes[ column ], vars.overflow );
- }
- }
- $temp = $( c.namespace + '_extra_table' );
- if ( $temp.length && !ts.hasWidget( c.table, 'scroller' ) ) {
- ts.resizable.setWidth( $temp, c.$table.outerWidth(), vars.overflow );
- }
- }
- },
-
- setHandlePosition : function( c, wo ) {
- var startPosition,
- tableHeight = c.$table.height(),
- $handles = wo.$resizable_container.children(),
- handleCenter = Math.floor( $handles.width() / 2 );
-
- if ( ts.hasWidget( c.table, 'scroller' ) ) {
- tableHeight = 0;
- c.$table.closest( '.' + ts.css.scrollerWrap ).children().each(function() {
- var $this = $(this);
- // center table has a max-height set
- tableHeight += $this.filter('[style*="height"]').length ? $this.height() : $this.children('table').height();
- });
- }
-
- if ( !wo.resizable_includeFooter && c.$table.children('tfoot').length ) {
- tableHeight -= c.$table.children('tfoot').height();
- }
- // subtract out table left position from resizable handles. Fixes #864
- // jQuery v3.3.0+ appears to include the start position with the $header.position().left; see #1544
- startPosition = parseFloat($.fn.jquery) >= 3.3 ? 0 : c.$table.position().left;
- $handles.each( function() {
- var $this = $(this),
- column = parseInt( $this.attr( 'data-column' ), 10 ),
- columns = c.columns - 1,
- $header = $this.data( 'header' );
- if ( !$header ) { return; } // see #859
- if (
- !$header.is(':visible') ||
- ( !wo.resizable_addLastColumn && ts.resizable.checkVisibleColumns(c, column) )
- ) {
- $this.hide();
- } else if ( column < columns || column === columns && wo.resizable_addLastColumn ) {
- $this.css({
- display: 'inline-block',
- height : tableHeight,
- left : $header.position().left - startPosition + $header.outerWidth() - handleCenter
- });
- }
- });
- },
-
- // Fixes #1485
- checkVisibleColumns: function( c, column ) {
- var i,
- len = 0;
- for ( i = column + 1; i < c.columns; i++ ) {
- len += c.$headerIndexed[i].is( ':visible' ) ? 1 : 0;
- }
- return len === 0;
- },
-
- // prevent text selection while dragging resize bar
- toggleTextSelection : function( c, wo, toggle ) {
- var namespace = c.namespace + 'tsresize';
- wo.resizable_vars.disabled = toggle;
- $( 'body' ).toggleClass( ts.css.resizableNoSelect, toggle );
- if ( toggle ) {
- $( 'body' )
- .attr( 'unselectable', 'on' )
- .bind( 'selectstart' + namespace, false );
- } else {
- $( 'body' )
- .removeAttr( 'unselectable' )
- .unbind( 'selectstart' + namespace );
- }
- },
-
- bindings : function( c, wo ) {
- var namespace = c.namespace + 'tsresize';
- wo.$resizable_container.children().bind( 'mousedown', function( event ) {
- // save header cell and mouse position
- var column,
- vars = wo.resizable_vars,
- $extras = $( c.namespace + '_extra_headers' ),
- $header = $( event.target ).data( 'header' );
-
- column = parseInt( $header.attr( 'data-column' ), 10 );
- vars.$target = $header = $header.add( $extras.filter('[data-column="' + column + '"]') );
- vars.target = column;
-
- // if table is not as wide as it's parent, then resize the table
- vars.$next = event.shiftKey || wo.resizable_targetLast ?
- $header.parent().children().not( '.resizable-false' ).filter( ':last' ) :
- $header.nextAll( ':not(.resizable-false)' ).eq( 0 );
-
- column = parseInt( vars.$next.attr( 'data-column' ), 10 );
- vars.$next = vars.$next.add( $extras.filter('[data-column="' + column + '"]') );
- vars.next = column;
-
- vars.mouseXPosition = event.pageX;
- ts.resizable.updateStoredSizes( c, wo );
- ts.resizable.toggleTextSelection(c, wo, true );
- });
-
- $( document )
- .bind( 'mousemove' + namespace, function( event ) {
- var vars = wo.resizable_vars;
- // ignore mousemove if no mousedown
- if ( !vars.disabled || vars.mouseXPosition === 0 || !vars.$target ) { return; }
- if ( wo.resizable_throttle ) {
- clearTimeout( vars.timer );
- vars.timer = setTimeout( function() {
- ts.resizable.mouseMove( c, wo, event );
- }, isNaN( wo.resizable_throttle ) ? 5 : wo.resizable_throttle );
- } else {
- ts.resizable.mouseMove( c, wo, event );
- }
- })
- .bind( 'mouseup' + namespace, function() {
- if (!wo.resizable_vars.disabled) { return; }
- ts.resizable.toggleTextSelection( c, wo, false );
- ts.resizable.stopResize( c, wo );
- ts.resizable.setHandlePosition( c, wo );
- });
-
- // resizeEnd event triggered by scroller widget
- $( window ).bind( 'resize' + namespace + ' resizeEnd' + namespace, function() {
- ts.resizable.setHandlePosition( c, wo );
- });
-
- // right click to reset columns to default widths
- c.$table
- .bind( 'columnUpdate pagerComplete resizableUpdate '.split( ' ' ).join( namespace + ' ' ), function() {
- ts.resizable.setHandlePosition( c, wo );
- })
- .bind( 'resizableReset' + namespace, function() {
- ts.resizableReset( c.table );
- })
- .find( 'thead:first' )
- .add( $( c.namespace + '_extra_table' ).find( 'thead:first' ) )
- .bind( 'contextmenu' + namespace, function() {
- // $.isEmptyObject() needs jQuery 1.4+; allow right click if already reset
- var allowClick = wo.resizable_vars.storedSizes.length === 0;
- ts.resizableReset( c.table );
- ts.resizable.setHandlePosition( c, wo );
- wo.resizable_vars.storedSizes = [];
- return allowClick;
- });
-
- },
-
- mouseMove : function( c, wo, event ) {
- if ( wo.resizable_vars.mouseXPosition === 0 || !wo.resizable_vars.$target ) { return; }
- // resize columns
- var column,
- total = 0,
- vars = wo.resizable_vars,
- $next = vars.$next,
- tar = vars.storedSizes[ vars.target ],
- leftEdge = event.pageX - vars.mouseXPosition;
- if ( vars.overflow ) {
- if ( tar + leftEdge > 0 ) {
- vars.storedSizes[ vars.target ] += leftEdge;
- ts.resizable.setWidth( vars.$target, vars.storedSizes[ vars.target ], true );
- // update the entire table width
- for ( column = 0; column < c.columns; column++ ) {
- total += vars.storedSizes[ column ];
- }
- ts.resizable.setWidth( c.$table.add( $( c.namespace + '_extra_table' ) ), total );
- }
- if ( !$next.length ) {
- // if expanding right-most column, scroll the wrapper
- vars.$wrap[0].scrollLeft = c.$table.width();
- }
- } else if ( vars.fullWidth ) {
- vars.storedSizes[ vars.target ] += leftEdge;
- vars.storedSizes[ vars.next ] -= leftEdge;
- ts.resizable.setWidths( c, wo );
- } else {
- vars.storedSizes[ vars.target ] += leftEdge;
- ts.resizable.setWidths( c, wo );
- }
- vars.mouseXPosition = event.pageX;
- // dynamically update sticky header widths
- c.$table.triggerHandler('stickyHeadersUpdate');
- },
-
- stopResize : function( c, wo ) {
- var vars = wo.resizable_vars;
- ts.resizable.updateStoredSizes( c, wo );
- if ( vars.useStorage ) {
- // save all column widths
- ts.storage( c.table, ts.css.resizableStorage, vars.storedSizes );
- ts.storage( c.table, 'tablesorter-table-resized-width', c.$table.width() );
- }
- vars.mouseXPosition = 0;
- vars.$target = vars.$next = null;
- // will update stickyHeaders, just in case, see #912
- c.$table.triggerHandler('stickyHeadersUpdate');
- c.$table.triggerHandler('resizableComplete');
- }
- };
-
- // this widget saves the column widths if
- // $.tablesorter.storage function is included
- // **************************
- ts.addWidget({
- id: 'resizable',
- priority: 40,
- options: {
- resizable : true, // save column widths to storage
- resizable_addLastColumn : false,
- resizable_includeFooter: true,
- resizable_widths : [],
- resizable_throttle : false, // set to true (5ms) or any number 0-10 range
- resizable_targetLast : false
- },
- init: function(table, thisWidget, c, wo) {
- ts.resizable.init( c, wo );
- },
- format: function( table, c, wo ) {
- ts.resizable.setHandlePosition( c, wo );
- },
- remove: function( table, c, wo, refreshing ) {
- if (wo.$resizable_container) {
- var namespace = c.namespace + 'tsresize';
- c.$table.add( $( c.namespace + '_extra_table' ) )
- .removeClass('hasResizable')
- .children( 'thead' )
- .unbind( 'contextmenu' + namespace );
-
- wo.$resizable_container.remove();
- ts.resizable.toggleTextSelection( c, wo, false );
- ts.resizableReset( table, refreshing );
- $( document ).unbind( 'mousemove' + namespace + ' mouseup' + namespace );
- }
- }
- });
-
- ts.resizableReset = function( table, refreshing ) {
- $( table ).each(function() {
- var index, $t,
- c = this.config,
- wo = c && c.widgetOptions,
- vars = wo.resizable_vars;
- if ( table && c && c.$headerIndexed.length ) {
- // restore the initial table width
- if ( vars.overflow && vars.tableWidth ) {
- ts.resizable.setWidth( c.$table, vars.tableWidth, true );
- if ( vars.useStorage ) {
- ts.storage( table, 'tablesorter-table-resized-width', vars.tableWidth );
- }
- }
- for ( index = 0; index < c.columns; index++ ) {
- $t = c.$headerIndexed[ index ];
- if ( wo.resizable_widths && wo.resizable_widths[ index ] ) {
- ts.resizable.setWidth( $t, wo.resizable_widths[ index ], vars.overflow );
- } else if ( !$t.hasClass( 'resizable-false' ) ) {
- // don't clear the width of any column that is not resizable
- ts.resizable.setWidth( $t, '', vars.overflow );
- }
- }
-
- // reset stickyHeader widths
- c.$table.triggerHandler( 'stickyHeadersUpdate' );
- if ( ts.storage && !refreshing ) {
- ts.storage( this, ts.css.resizableStorage, [] );
- }
- }
- });
- };
-
-})( jQuery, window );
-
-/*! Widget: saveSort - updated 2018-03-19 (v2.30.1) *//*
-* Requires tablesorter v2.16+
-* by Rob Garrison
-*/
-;(function ($) {
- 'use strict';
- var ts = $.tablesorter || {};
-
- function getStoredSortList(c) {
- var stored = ts.storage( c.table, 'tablesorter-savesort' );
- return (stored && stored.hasOwnProperty('sortList') && $.isArray(stored.sortList)) ? stored.sortList : [];
- }
-
- function sortListChanged(c, sortList) {
- return (sortList || getStoredSortList(c)).join(',') !== c.sortList.join(',');
- }
-
- // this widget saves the last sort only if the
- // saveSort widget option is true AND the
- // $.tablesorter.storage function is included
- // **************************
- ts.addWidget({
- id: 'saveSort',
- priority: 20,
- options: {
- saveSort : true
- },
- init: function(table, thisWidget, c, wo) {
- // run widget format before all other widgets are applied to the table
- thisWidget.format(table, c, wo, true);
- },
- format: function(table, c, wo, init) {
- var time,
- $table = c.$table,
- saveSort = wo.saveSort !== false, // make saveSort active/inactive; default to true
- sortList = { 'sortList' : c.sortList },
- debug = ts.debug(c, 'saveSort');
- if (debug) {
- time = new Date();
- }
- if ($table.hasClass('hasSaveSort')) {
- if (saveSort && table.hasInitialized && ts.storage && sortListChanged(c)) {
- ts.storage( table, 'tablesorter-savesort', sortList );
- if (debug) {
- console.log('saveSort >> Saving last sort: ' + c.sortList + ts.benchmark(time));
- }
- }
- } else {
- // set table sort on initial run of the widget
- $table.addClass('hasSaveSort');
- sortList = '';
- // get data
- if (ts.storage) {
- sortList = getStoredSortList(c);
- if (debug) {
- console.log('saveSort >> Last sort loaded: "' + sortList + '"' + ts.benchmark(time));
- }
- $table.bind('saveSortReset', function(event) {
- event.stopPropagation();
- ts.storage( table, 'tablesorter-savesort', '' );
- });
- }
- // init is true when widget init is run, this will run this widget before all other widgets have initialized
- // this method allows using this widget in the original tablesorter plugin; but then it will run all widgets twice.
- if (init && sortList && sortList.length > 0) {
- c.sortList = sortList;
- } else if (table.hasInitialized && sortList && sortList.length > 0) {
- // update sort change
- if (sortListChanged(c, sortList)) {
- ts.sortOn(c, sortList);
- }
- }
- }
- },
- remove: function(table, c) {
- c.$table.removeClass('hasSaveSort');
- // clear storage
- if (ts.storage) { ts.storage( table, 'tablesorter-savesort', '' ); }
- }
- });
-
-})(jQuery);
-return jQuery.tablesorter;}));
+!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&"object"==typeof module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(e){return function(e,t,r){"use strict";var i=e.tablesorter||{};e.extend(!0,i.defaults,{fixedUrl:"",widgetOptions:{storage_fixedUrl:"",storage_group:"",storage_page:"",storage_storageType:"",storage_tableId:"",storage_useSessionStorage:""}}),i.storage=function(a,l,s,n){var o,c,d,f=!1,h={},u=(a=e(a)[0]).config,p=u&&u.widgetOptions,g=i.debug(u,"storage"),m=(n&&n.storageType||p&&p.storage_storageType).toString().charAt(0).toLowerCase(),b=m?"":n&&n.useSessionStorage||p&&p.storage_useSessionStorage,y=e(a),_=n&&n.id||y.attr(n&&n.group||p&&p.storage_group||"data-table-group")||p&&p.storage_tableId||a.id||e(".tablesorter").index(y),v=n&&n.url||y.attr(n&&n.page||p&&p.storage_page||"data-table-page")||p&&p.storage_fixedUrl||u&&u.fixedUrl||t.location.pathname;if("c"!==m&&(m="s"===m||b?"sessionStorage":"localStorage")in t)try{t[m].setItem("_tmptest","temp"),f=!0,t[m].removeItem("_tmptest")}catch(e){console.warn(m+" is not supported in this browser")}if(g&&console.log("Storage >> Using",f?m:"cookies"),e.parseJSON&&(f?h=e.parseJSON(t[m][l]||"null")||{}:(c=r.cookie.split(/[;\s|=]/),h=0!==(o=e.inArray(l,c)+1)&&e.parseJSON(c[o]||"null")||{})),void 0===s||!t.JSON||!JSON.hasOwnProperty("stringify"))return h&&h[v]?h[v][_]:"";h[v]||(h[v]={}),h[v][_]=s,f?t[m][l]=JSON.stringify(h):((d=new Date).setTime(d.getTime()+31536e6),r.cookie=l+"="+JSON.stringify(h).replace(/\"/g,'"')+"; expires="+d.toGMTString()+"; path=/")}}(e,window,document),function(e){"use strict";var t=e.tablesorter||{};t.themes={bootstrap:{table:"table table-bordered table-striped",caption:"caption",header:"bootstrap-header",sortNone:"",sortAsc:"",sortDesc:"",active:"",hover:"",icons:"",iconSortNone:"bootstrap-icon-unsorted",iconSortAsc:"glyphicon glyphicon-chevron-up",iconSortDesc:"glyphicon glyphicon-chevron-down",filterRow:"",footerRow:"",footerCells:"",even:"",odd:""},jui:{table:"ui-widget ui-widget-content ui-corner-all",caption:"ui-widget-content",header:"ui-widget-header ui-corner-all ui-state-default",sortNone:"",sortAsc:"",sortDesc:"",active:"ui-state-active",hover:"ui-state-hover",icons:"ui-icon",iconSortNone:"ui-icon-carat-2-n-s ui-icon-caret-2-n-s",iconSortAsc:"ui-icon-carat-1-n ui-icon-caret-1-n",iconSortDesc:"ui-icon-carat-1-s ui-icon-caret-1-s",filterRow:"",footerRow:"",footerCells:"",even:"ui-widget-content",odd:"ui-state-default"}},e.extend(t.css,{wrapper:"tablesorter-wrapper"}),t.addWidget({id:"uitheme",priority:10,format:function(r,i,a){var l,s,n,o,c,d,f,h,u,p,g,m,b,y=t.themes,_=i.$table.add(e(i.namespace+"_extra_table")),v=i.$headers.add(e(i.namespace+"_extra_headers")),w=i.theme||"jui",x=y[w]||{},S=e.trim([x.sortNone,x.sortDesc,x.sortAsc,x.active].join(" ")),C=e.trim([x.iconSortNone,x.iconSortDesc,x.iconSortAsc].join(" ")),z=t.debug(i,"uitheme");for(z&&(c=new Date),_.hasClass("tablesorter-"+w)&&i.theme===i.appliedTheme&&a.uitheme_applied||(a.uitheme_applied=!0,p=y[i.appliedTheme]||{},g=(b=!e.isEmptyObject(p))?[p.sortNone,p.sortDesc,p.sortAsc,p.active].join(" "):"",m=b?[p.iconSortNone,p.iconSortDesc,p.iconSortAsc].join(" "):"",b&&(a.zebra[0]=e.trim(" "+a.zebra[0].replace(" "+p.even,"")),a.zebra[1]=e.trim(" "+a.zebra[1].replace(" "+p.odd,"")),i.$tbodies.children().removeClass([p.even,p.odd].join(" "))),x.even&&(a.zebra[0]+=" "+x.even),x.odd&&(a.zebra[1]+=" "+x.odd),_.children("caption").removeClass(p.caption||"").addClass(x.caption),h=_.removeClass((i.appliedTheme?"tablesorter-"+(i.appliedTheme||""):"")+" "+(p.table||"")).addClass("tablesorter-"+w+" "+(x.table||"")).children("tfoot"),i.appliedTheme=i.theme,h.length&&h.children("tr").removeClass(p.footerRow||"").addClass(x.footerRow).children("th, td").removeClass(p.footerCells||"").addClass(x.footerCells),v.removeClass((b?[p.header,p.hover,g].join(" "):"")||"").addClass(x.header).not(".sorter-false").unbind("mouseenter.tsuitheme mouseleave.tsuitheme").bind("mouseenter.tsuitheme mouseleave.tsuitheme",function(t){e(this)["mouseenter"===t.type?"addClass":"removeClass"](x.hover||"")}),v.each(function(){var r=e(this);r.find("."+t.css.wrapper).length||r.wrapInner('<div class="'+t.css.wrapper+'" style="position:relative;height:100%;width:100%"></div>')}),i.cssIcon&&v.find("."+t.css.icon).removeClass(b?[p.icons,m].join(" "):"").addClass(x.icons||""),t.hasWidget(i.table,"filter")&&(s=function(){_.children("thead").children("."+t.css.filterRow).removeClass(b&&p.filterRow||"").addClass(x.filterRow||"")},a.filter_initialized?s():_.one("filterInit",function(){s()}))),l=0;l<i.columns;l++)d=i.$headers.add(e(i.namespace+"_extra_headers")).not(".sorter-false").filter('[data-column="'+l+'"]'),f=t.css.icon?d.find("."+t.css.icon):e(),(u=v.not(".sorter-false").filter('[data-column="'+l+'"]:last')).length&&(d.removeClass(S),f.removeClass(C),u[0].sortDisabled?f.removeClass(x.icons||""):(n=x.sortNone,o=x.iconSortNone,u.hasClass(t.css.sortAsc)?(n=[x.sortAsc,x.active].join(" "),o=x.iconSortAsc):u.hasClass(t.css.sortDesc)&&(n=[x.sortDesc,x.active].join(" "),o=x.iconSortDesc),d.addClass(n),f.addClass(o||"")));z&&console.log("uitheme >> Applied "+w+" theme"+t.benchmark(c))},remove:function(e,r,i,a){if(i.uitheme_applied){var l=r.$table,s=r.appliedTheme||"jui",n=t.themes[s]||t.themes.jui,o=l.children("thead").children(),c=n.sortNone+" "+n.sortDesc+" "+n.sortAsc,d=n.iconSortNone+" "+n.iconSortDesc+" "+n.iconSortAsc;l.removeClass("tablesorter-"+s+" "+n.table),i.uitheme_applied=!1,a||(l.find(t.css.header).removeClass(n.header),o.unbind("mouseenter.tsuitheme mouseleave.tsuitheme").removeClass(n.hover+" "+c+" "+n.active).filter("."+t.css.filterRow).removeClass(n.filterRow),o.find("."+t.css.icon).removeClass(n.icons+" "+d))}}})}(e),function(e){"use strict";var t=e.tablesorter||{};t.addWidget({id:"columns",priority:65,options:{columns:["primary","secondary","tertiary"]},format:function(r,i,a){var l,s,n,o,c,d,f,h,u=i.$table,p=i.$tbodies,g=i.sortList,m=g.length,b=a&&a.columns||["primary","secondary","tertiary"],y=b.length-1;for(f=b.join(" "),s=0;s<p.length;s++)(n=(l=t.processTbody(r,p.eq(s),!0)).children("tr")).each(function(){if(c=e(this),"none"!==this.style.display&&(d=c.children().removeClass(f),g&&g[0]&&(d.eq(g[0][0]).addClass(b[0]),m>1)))for(h=1;h<m;h++)d.eq(g[h][0]).addClass(b[h]||b[y])}),t.processTbody(r,l,!1);if(o=!1!==a.columns_thead?["thead tr"]:[],!1!==a.columns_tfoot&&o.push("tfoot tr"),o.length&&(n=u.find(o.join(",")).children().removeClass(f),m))for(h=0;h<m;h++)n.filter('[data-column="'+g[h][0]+'"]').addClass(b[h]||b[y])},remove:function(r,i,a){var l,s,n=i.$tbodies,o=(a.columns||["primary","secondary","tertiary"]).join(" ");for(i.$headers.removeClass(o),i.$table.children("tfoot").children("tr").children("th, td").removeClass(o),l=0;l<n.length;l++)(s=t.processTbody(r,n.eq(l),!0)).children("tr").each(function(){e(this).children().removeClass(o)}),t.processTbody(r,s,!1)}})}(e),function(e){"use strict";var t,r,i=e.tablesorter||{},a=i.css,l=i.keyCodes;e.extend(a,{filterRow:"tablesorter-filter-row",filter:"tablesorter-filter",filterDisabled:"disabled",filterRowHide:"hideme"}),e.extend(l,{backSpace:8,escape:27,space:32,left:37,down:40}),i.addWidget({id:"filter",priority:50,options:{filter_cellFilter:"",filter_childRows:!1,filter_childByColumn:!1,filter_childWithSibs:!0,filter_columnAnyMatch:!0,filter_columnFilters:!0,filter_cssFilter:"",filter_defaultAttrib:"data-value",filter_defaultFilter:{},filter_excludeFilter:{},filter_external:"",filter_filteredRow:"filtered",filter_filterLabel:'Filter "{{label}}" column by...',filter_formatter:null,filter_functions:null,filter_hideEmpty:!0,filter_hideFilters:!1,filter_ignoreCase:!0,filter_liveSearch:!0,filter_matchType:{input:"exact",select:"exact"},filter_onlyAvail:"filter-onlyAvail",filter_placeholder:{search:"",select:""},filter_reset:null,filter_resetOnEsc:!0,filter_saveFilters:!1,filter_searchDelay:300,filter_searchFiltered:!0,filter_selectSource:null,filter_selectSourceSeparator:"|",filter_serversideFiltering:!1,filter_startsWith:!1,filter_useParsedData:!1},format:function(e,r,i){r.$table.hasClass("hasFilters")||t.init(e,r,i)},remove:function(t,r,l,s){var n,o,c=r.$table,d=r.$tbodies,f="addRows updateCell update updateRows updateComplete appendCache filterReset filterAndSortReset filterFomatterUpdate filterEnd search stickyHeadersInit ".split(" ").join(r.namespace+"filter ");if(c.removeClass("hasFilters").unbind(f.replace(i.regex.spaces," ")).find("."+a.filterRow).remove(),l.filter_initialized=!1,!s){for(n=0;n<d.length;n++)(o=i.processTbody(t,d.eq(n),!0)).children().removeClass(l.filter_filteredRow).show(),i.processTbody(t,o,!1);l.filter_reset&&e(document).undelegate(l.filter_reset,"click"+r.namespace+"filter")}}}),t=i.filter={regex:{regex:/^\/((?:\\\/|[^\/])+)\/([migyu]{0,5})?$/,child:/tablesorter-childRow/,filtered:/filtered/,type:/undefined|number/,exact:/(^[\"\'=]+)|([\"\'=]+$)/g,operators:/[<>=]/g,query:"(q|query)",wild01:/\?/g,wild0More:/\*/g,quote:/\"/g,isNeg1:/(>=?\s*-\d)/,isNeg2:/(<=?\s*\d)/},types:{or:function(i,a,l){if((r.orTest.test(a.iFilter)||r.orSplit.test(a.filter))&&!r.regex.test(a.filter)){var s,n,o,c=e.extend({},a),d=a.filter.split(r.orSplit),f=a.iFilter.split(r.orSplit),h=d.length;for(s=0;s<h;s++){c.nestedFilters=!0,c.filter=""+(t.parseFilter(i,d[s],a)||""),c.iFilter=""+(t.parseFilter(i,f[s],a)||""),o="("+(t.parseFilter(i,c.filter,a)||"")+")";try{if(n=new RegExp(a.isMatch?o:"^"+o+"$",i.widgetOptions.filter_ignoreCase?"i":"").test(c.exact)||t.processTypes(i,c,l))return n}catch(e){return null}}return n||!1}return null},and:function(i,a,l){if(r.andTest.test(a.filter)){var s,n,o,c,d=e.extend({},a),f=a.filter.split(r.andSplit),h=a.iFilter.split(r.andSplit),u=f.length;for(s=0;s<u;s++){d.nestedFilters=!0,d.filter=""+(t.parseFilter(i,f[s],a)||""),d.iFilter=""+(t.parseFilter(i,h[s],a)||""),c=("("+(t.parseFilter(i,d.filter,a)||"")+")").replace(r.wild01,"\\S{1}").replace(r.wild0More,"\\S*");try{o=new RegExp(a.isMatch?c:"^"+c+"$",i.widgetOptions.filter_ignoreCase?"i":"").test(d.exact)||t.processTypes(i,d,l),n=0===s?o:n&&o}catch(e){return null}}return n||!1}return null},regex:function(e,t){if(r.regex.test(t.filter)){var i,a=t.filter_regexCache[t.index]||r.regex.exec(t.filter),l=a instanceof RegExp;try{l||(t.filter_regexCache[t.index]=a=new RegExp(a[1],a[2])),i=a.test(t.exact)}catch(e){i=!1}return i}return null},operators:function(a,l){if(r.operTest.test(l.iFilter)&&""!==l.iExact){var s,n,o,c=a.table,d=l.parsed[l.index],f=i.formatFloat(l.iFilter.replace(r.operators,""),c),h=a.parsers[l.index]||{},u=f;return(d||"numeric"===h.type)&&(o=e.trim(""+l.iFilter.replace(r.operators,"")),f="number"!=typeof(n=t.parseFilter(a,o,l,!0))||""===n||isNaN(n)?f:n),!d&&"numeric"!==h.type||isNaN(f)||void 0===l.cache?(o=isNaN(l.iExact)?l.iExact.replace(i.regex.nondigit,""):l.iExact,s=i.formatFloat(o,c)):s=l.cache,r.gtTest.test(l.iFilter)?n=r.gteTest.test(l.iFilter)?s>=f:s>f:r.ltTest.test(l.iFilter)&&(n=r.lteTest.test(l.iFilter)?s<=f:s<f),n||""!==u||(n=!0),n}return null},notMatch:function(i,a){if(r.notTest.test(a.iFilter)){var l,s=a.iFilter.replace("!",""),n=t.parseFilter(i,s,a)||"";return r.exact.test(n)?""===(n=n.replace(r.exact,""))||e.trim(n)!==a.iExact:(l=a.iExact.search(e.trim(n)),""===n||(a.anyMatch?l<0:!(i.widgetOptions.filter_startsWith?0===l:l>=0)))}return null},exact:function(i,a){if(r.exact.test(a.iFilter)){var l=a.iFilter.replace(r.exact,""),s=t.parseFilter(i,l,a)||"";return a.anyMatch?e.inArray(s,a.rowArray)>=0:s==a.iExact}return null},range:function(e,a){if(r.toTest.test(a.iFilter)){var l,s,n,o,c=e.table,d=a.index,f=a.parsed[d],h=a.iFilter.split(r.toSplit);return s=h[0].replace(i.regex.nondigit,"")||"",n=i.formatFloat(t.parseFilter(e,s,a),c),s=h[1].replace(i.regex.nondigit,"")||"",o=i.formatFloat(t.parseFilter(e,s,a),c),(f||"numeric"===e.parsers[d].type)&&(n=""===(l=e.parsers[d].format(""+h[0],c,e.$headers.eq(d),d))||isNaN(l)?n:l,o=""===(l=e.parsers[d].format(""+h[1],c,e.$headers.eq(d),d))||isNaN(l)?o:l),!f&&"numeric"!==e.parsers[d].type||isNaN(n)||isNaN(o)?(s=isNaN(a.iExact)?a.iExact.replace(i.regex.nondigit,""):a.iExact,l=i.formatFloat(s,c)):l=a.cache,n>o&&(s=n,n=o,o=s),l>=n&&l<=o||""===n||""===o}return null},wild:function(e,i){if(r.wildOrTest.test(i.iFilter)){var a=""+(t.parseFilter(e,i.iFilter,i)||"");!r.wildTest.test(a)&&i.nestedFilters&&(a=i.isMatch?a:"^("+a+")$");try{return new RegExp(a.replace(r.wild01,"\\S{1}").replace(r.wild0More,"\\S*"),e.widgetOptions.filter_ignoreCase?"i":"").test(i.exact)}catch(e){return null}}return null},fuzzy:function(e,i){if(r.fuzzyTest.test(i.iFilter)){var a,l=0,s=i.iExact.length,n=i.iFilter.slice(1),o=t.parseFilter(e,n,i)||"";for(a=0;a<s;a++)i.iExact[a]===o[l]&&(l+=1);return l===o.length}return null}},init:function(l){i.language=e.extend(!0,{},{to:"to",or:"or",and:"and"},i.language);var s,n,o,c,d,f,h,u,p=l.config,g=p.widgetOptions,m=function(e,t,r){return""===(t=t.trim())?"":(e||"")+t+(r||"")};if(p.$table.addClass("hasFilters"),p.lastSearch=[],g.filter_searchTimer=null,g.filter_initTimer=null,g.filter_formatterCount=0,g.filter_formatterInit=[],g.filter_anyColumnSelector='[data-column="all"],[data-column="any"]',g.filter_multipleColumnSelector='[data-column*="-"],[data-column*=","]',f="\\{"+r.query+"\\}",e.extend(r,{child:new RegExp(p.cssChildRow),filtered:new RegExp(g.filter_filteredRow),alreadyFiltered:new RegExp("(\\s+(-"+m("|",i.language.or)+m("|",i.language.to)+")\\s+)","i"),toTest:new RegExp("\\s+(-"+m("|",i.language.to)+")\\s+","i"),toSplit:new RegExp("(?:\\s+(?:-"+m("|",i.language.to)+")\\s+)","gi"),andTest:new RegExp("\\s+("+m("",i.language.and,"|")+"&&)\\s+","i"),andSplit:new RegExp("(?:\\s+(?:"+m("",i.language.and,"|")+"&&)\\s+)","gi"),orTest:new RegExp("(\\|"+m("|\\s+",i.language.or,"\\s+")+")","i"),orSplit:new RegExp("(?:\\|"+m("|\\s+(?:",i.language.or,")\\s+")+")","gi"),iQuery:new RegExp(f,"i"),igQuery:new RegExp(f,"ig"),operTest:/^[<>]=?/,gtTest:/>/,gteTest:/>=/,ltTest:/</,lteTest:/<=/,notTest:/^\!/,wildOrTest:/[\?\*\|]/,wildTest:/\?\*/,fuzzyTest:/^~/,exactTest:/[=\"\|!]/}),f=p.$headers.filter(".filter-false, .parser-false").length,!1!==g.filter_columnFilters&&f!==p.$headers.length&&t.buildRow(l,p,g),o="addRows updateCell update updateRows updateComplete appendCache filterReset "+"filterAndSortReset filterResetSaved filterEnd search ".split(" ").join(p.namespace+"filter "),p.$table.bind(o,function(r,s){return f=g.filter_hideEmpty&&e.isEmptyObject(p.cache)&&!(p.delayInit&&"appendCache"===r.type),p.$table.find("."+a.filterRow).toggleClass(g.filter_filteredRow,f),/(search|filter)/.test(r.type)||(r.stopPropagation(),t.buildDefault(l,!0)),"filterReset"===r.type||"filterAndSortReset"===r.type?(p.$table.find("."+a.filter).add(g.filter_$externalFilters).val(""),"filterAndSortReset"===r.type?i.sortReset(this.config,function(){t.searching(l,[])}):t.searching(l,[])):"filterResetSaved"===r.type?i.storage(l,"tablesorter-filters",""):"filterEnd"===r.type?t.buildDefault(l,!0):(s="search"===r.type?s:"updateComplete"===r.type?p.$table.data("lastSearch"):"",/(update|add)/.test(r.type)&&"updateComplete"!==r.type&&(p.lastCombinedFilter=null,p.lastSearch=[],setTimeout(function(){p.$table.triggerHandler("filterFomatterUpdate")},100)),t.searching(l,s,!0)),!1}),g.filter_reset&&(g.filter_reset instanceof e?g.filter_reset.click(function(){p.$table.triggerHandler("filterReset")}):e(g.filter_reset).length&&e(document).undelegate(g.filter_reset,"click"+p.namespace+"filter").delegate(g.filter_reset,"click"+p.namespace+"filter",function(){p.$table.triggerHandler("filterReset")})),g.filter_functions)for(d=0;d<p.columns;d++)if(h=i.getColumnData(l,g.filter_functions,d))if(u=!((c=p.$headerIndexed[d].removeClass("filter-select")).hasClass("filter-false")||c.hasClass("parser-false")),s="",!0===h&&u)t.buildSelect(l,d);else if("object"==typeof h&&u){for(n in h)"string"==typeof n&&(s+=""===s?'<option value="">'+(c.data("placeholder")||c.attr("data-placeholder")||g.filter_placeholder.select||"")+"</option>":"",f=n,o=n,n.indexOf(g.filter_selectSourceSeparator)>=0&&(o=(f=n.split(g.filter_selectSourceSeparator))[1],f=f[0]),s+="<option "+(o===f?"":'data-function-name="'+n+'" ')+'value="'+f+'">'+o+"</option>");p.$table.find("thead").find("select."+a.filter+'[data-column="'+d+'"]').append(s),(h="function"==typeof(o=g.filter_selectSource)||i.getColumnData(l,o,d))&&t.buildSelect(p.table,d,"",!0,c.hasClass(g.filter_onlyAvail))}t.buildDefault(l,!0),t.bindSearch(l,p.$table.find("."+a.filter),!0),g.filter_external&&t.bindSearch(l,g.filter_external),g.filter_hideFilters&&t.hideFilters(p),p.showProcessing&&(o="filterStart filterEnd ".split(" ").join(p.namespace+"filter-sp "),p.$table.unbind(o.replace(i.regex.spaces," ")).bind(o,function(t,r){c=r?p.$table.find("."+a.header).filter("[data-column]").filter(function(){return""!==r[e(this).data("column")]}):"",i.isProcessing(l,"filterStart"===t.type,r?c:"")})),p.filteredRows=p.totalRows,o="tablesorter-initialized pagerBeforeInitialized ".split(" ").join(p.namespace+"filter "),p.$table.unbind(o.replace(i.regex.spaces," ")).bind(o,function(){t.completeInit(this)}),p.pager&&p.pager.initialized&&!g.filter_initialized?(p.$table.triggerHandler("filterFomatterUpdate"),setTimeout(function(){t.filterInitComplete(p)},100)):g.filter_initialized||t.completeInit(l)},completeInit:function(e){var r=e.config,a=r.widgetOptions,l=t.setDefaults(e,r,a)||[];l.length&&(r.delayInit&&""===l.join("")||i.setFilters(e,l,!0)),r.$table.triggerHandler("filterFomatterUpdate"),setTimeout(function(){a.filter_initialized||t.filterInitComplete(r)},100)},formatterUpdated:function(e,t){var r=e&&e.closest("table"),i=r.length&&r[0].config,a=i&&i.widgetOptions;a&&!a.filter_initialized&&(a.filter_formatterInit[t]=1)},filterInitComplete:function(r){var a,l,s=r.widgetOptions,n=0,o=function(){s.filter_initialized=!0,r.lastSearch=r.$table.data("lastSearch"),r.$table.triggerHandler("filterInit",r),t.findRows(r.table,r.lastSearch||[]),i.debug(r,"filter")&&console.log("Filter >> Widget initialized")};if(e.isEmptyObject(s.filter_formatter))o();else{for(l=s.filter_formatterInit.length,a=0;a<l;a++)1===s.filter_formatterInit[a]&&n++;clearTimeout(s.filter_initTimer),s.filter_initialized||n!==s.filter_formatterCount?s.filter_initialized||(s.filter_initTimer=setTimeout(function(){o()},500)):o()}},processFilters:function(e,t){var r,i=[],a=t?encodeURIComponent:decodeURIComponent,l=e.length;for(r=0;r<l;r++)e[r]&&(i[r]=a(e[r]));return i},setDefaults:function(r,a,l){var s,n,o,c,d,f=i.getFilters(r)||[];if(l.filter_saveFilters&&i.storage&&(n=i.storage(r,"tablesorter-filters")||[],(s=e.isArray(n))&&""===n.join("")||!s||(f=t.processFilters(n))),""===f.join(""))for(d=a.$headers.add(l.filter_$externalFilters).filter("["+l.filter_defaultAttrib+"]"),o=0;o<=a.columns;o++)c=o===a.columns?"all":o,f[o]=d.filter('[data-column="'+c+'"]').attr(l.filter_defaultAttrib)||f[o]||"";return a.$table.data("lastSearch",f),f},parseFilter:function(e,t,r,i){return i||r.parsed[r.index]?e.parsers[r.index].format(t,e.table,[],r.index):t},buildRow:function(r,l,s){var n,o,c,d,f,h,u,p,g,m=s.filter_cellFilter,b=l.columns,y=e.isArray(m),_='<tr role="search" class="'+a.filterRow+" "+l.cssIgnoreRow+'">';for(c=0;c<b;c++)l.$headerIndexed[c].length&&(_+=(g=l.$headerIndexed[c]&&l.$headerIndexed[c][0].colSpan||0)>1?'<td data-column="'+c+"-"+(c+g-1)+'" colspan="'+g+'"':'<td data-column="'+c+'"',_+=y?m[c]?' class="'+m[c]+'"':"":""!==m?' class="'+m+'"':"",_+="></td>");for(l.$filters=e(_+="</tr>").appendTo(l.$table.children("thead").eq(0)).children("td"),c=0;c<b;c++)h=!1,(d=l.$headerIndexed[c])&&d.length&&(n=t.getColumnElm(l,l.$filters,c),p=i.getColumnData(r,s.filter_functions,c),f=s.filter_functions&&p&&"function"!=typeof p||d.hasClass("filter-select"),o=i.getColumnData(r,l.headers,c),h="false"===i.getData(d[0],o,"filter")||"false"===i.getData(d[0],o,"parser"),f?_=e("<select>").appendTo(n):((p=i.getColumnData(r,s.filter_formatter,c))?(s.filter_formatterCount++,(_=p(n,c))&&0===_.length&&(_=n.children("input")),_&&(0===_.parent().length||_.parent().length&&_.parent()[0]!==n[0])&&n.append(_)):_=e('<input type="search">').appendTo(n),_&&(g=d.data("placeholder")||d.attr("data-placeholder")||s.filter_placeholder.search||"",_.attr("placeholder",g))),_&&(u=(e.isArray(s.filter_cssFilter)?void 0!==s.filter_cssFilter[c]&&s.filter_cssFilter[c]||"":s.filter_cssFilter)||"",_.addClass(a.filter+" "+u),(g=(u=s.filter_filterLabel).match(/{{([^}]+?)}}/g))||(g=["{{label}}"]),e.each(g,function(t,r){var i=new RegExp(r,"g"),a=d.attr("data-"+r.replace(/{{|}}/g,"")),l=void 0===a?d.text():a;u=u.replace(i,e.trim(l))}),_.attr({"data-column":n.attr("data-column"),"aria-label":u}),h&&(_.attr("placeholder","").addClass(a.filterDisabled)[0].disabled=!0)))},bindSearch:function(r,a,s){if(r=e(r)[0],(a=e(a)).length){var n,o=r.config,c=o.widgetOptions,d=o.namespace+"filter",f=c.filter_$externalFilters;!0!==s&&(n=c.filter_anyColumnSelector+","+c.filter_multipleColumnSelector,c.filter_$anyMatch=a.filter(n),f&&f.length?c.filter_$externalFilters=c.filter_$externalFilters.add(a):c.filter_$externalFilters=a,i.setFilters(r,o.$table.data("lastSearch")||[],!1===s)),n="keypress keyup keydown search change input ".split(" ").join(d+" "),a.attr("data-lastSearchTime",(new Date).getTime()).unbind(n.replace(i.regex.spaces," ")).bind("keydown"+d,function(e){if(e.which===l.escape&&!r.config.widgetOptions.filter_resetOnEsc)return!1}).bind("keyup"+d,function(a){c=r.config.widgetOptions;var s=parseInt(e(this).attr("data-column"),10),n="boolean"==typeof c.filter_liveSearch?c.filter_liveSearch:i.getColumnData(r,c.filter_liveSearch,s);if(void 0===n&&(n=c.filter_liveSearch.fallback||!1),e(this).attr("data-lastSearchTime",(new Date).getTime()),a.which===l.escape)this.value=c.filter_resetOnEsc?"":o.lastSearch[s];else{if(""!==this.value&&("number"==typeof n&&this.value.length<n||a.which!==l.enter&&a.which!==l.backSpace&&(a.which<l.space||a.which>=l.left&&a.which<=l.down)))return;if(!1===n&&""!==this.value&&a.which!==l.enter)return}t.searching(r,!0,!0,s)}).bind("search change keypress input blur ".split(" ").join(d+" "),function(a){var s=parseInt(e(this).attr("data-column"),10),n=a.type,d="boolean"==typeof c.filter_liveSearch?c.filter_liveSearch:i.getColumnData(r,c.filter_liveSearch,s);!r.config.widgetOptions.filter_initialized||a.which!==l.enter&&"search"!==n&&"blur"!==n&&("change"!==n&&"input"!==n||!0!==d&&(!0===d||"INPUT"===a.target.nodeName)||this.value===o.lastSearch[s])||(a.preventDefault(),e(this).attr("data-lastSearchTime",(new Date).getTime()),t.searching(r,"keypress"!==n,!0,s))})}},searching:function(e,r,a,l){var s,n=e.config.widgetOptions;void 0===l?s=!1:void 0===(s="boolean"==typeof n.filter_liveSearch?n.filter_liveSearch:i.getColumnData(e,n.filter_liveSearch,l))&&(s=n.filter_liveSearch.fallback||!1),clearTimeout(n.filter_searchTimer),void 0===r||!0===r?n.filter_searchTimer=setTimeout(function(){t.checkFilters(e,r,a)},s?n.filter_searchDelay:10):t.checkFilters(e,r,a)},equalFilters:function(t,r,i){var a,l=[],s=[],n=t.columns+1;for(r=e.isArray(r)?r:[],i=e.isArray(i)?i:[],a=0;a<n;a++)l[a]=r[a]||"",s[a]=i[a]||"";return l.join(",")===s.join(",")},checkFilters:function(r,l,s){var n=r.config,o=n.widgetOptions,c=e.isArray(l),d=c?l:i.getFilters(r,!0),f=d||[];if(e.isEmptyObject(n.cache))n.delayInit&&(!n.pager||n.pager&&n.pager.initialized)&&i.updateCache(n,function(){t.checkFilters(r,!1,s)});else if(c&&(i.setFilters(r,d,!1,!0!==s),o.filter_initialized||(n.lastSearch=[],n.lastCombinedFilter="")),o.filter_hideFilters&&n.$table.find("."+a.filterRow).triggerHandler(t.hideFiltersCheck(n)?"mouseleave":"mouseenter"),!t.equalFilters(n,n.lastSearch,f)||!1===l){if(!1===l&&(n.lastCombinedFilter="",n.lastSearch=[]),d=d||[],d=Array.prototype.map?d.map(String):d.join("�").split("�"),o.filter_initialized&&n.$table.triggerHandler("filterStart",[d]),!n.showProcessing)return t.findRows(r,d,f),!1;setTimeout(function(){return t.findRows(r,d,f),!1},30)}},hideFiltersCheck:function(e){if("function"==typeof e.widgetOptions.filter_hideFilters){var t=e.widgetOptions.filter_hideFilters(e);if("boolean"==typeof t)return t}return""===i.getFilters(e.$table).join("")},hideFilters:function(r,i){var l;(i||r.$table).find("."+a.filterRow).addClass(a.filterRowHide).bind("mouseenter mouseleave",function(i){var s=i,n=e(this);clearTimeout(l),l=setTimeout(function(){/enter|over/.test(s.type)?n.removeClass(a.filterRowHide):e(document.activeElement).closest("tr")[0]!==n[0]&&n.toggleClass(a.filterRowHide,t.hideFiltersCheck(r))},200)}).find("input, select").bind("focus blur",function(i){var s=i,n=e(this).closest("tr");clearTimeout(l),l=setTimeout(function(){clearTimeout(l),n.toggleClass(a.filterRowHide,t.hideFiltersCheck(r)&&"focus"!==s.type)},200)})},defaultFilter:function(t,i){if(""===t)return t;var a=r.iQuery,l=i.match(r.igQuery).length,s=l>1?e.trim(t).split(/\s/):[e.trim(t)],n=s.length-1,o=0,c=i;for(n<1&&l>1&&(s[1]=s[0]);a.test(c);)c=c.replace(a,s[o++]||""),a.test(c)&&o<n&&""!==(s[o]||"")&&(c=i.replace(a,c));return c},getLatestSearch:function(t){return t?t.sort(function(t,r){return e(r).attr("data-lastSearchTime")-e(t).attr("data-lastSearchTime")}):t||e()},findRange:function(e,t,r){var i,a,l,s,n,o,c,d,f,h=[];if(/^[0-9]+$/.test(t))return[parseInt(t,10)];if(!r&&/-/.test(t))for(f=(a=t.match(/(\d+)\s*-\s*(\d+)/g))?a.length:0,d=0;d<f;d++){for(l=a[d].split(/\s*-\s*/),(s=parseInt(l[0],10)||0)>(n=parseInt(l[1],10)||e.columns-1)&&(i=s,s=n,n=i),n>=e.columns&&(n=e.columns-1);s<=n;s++)h[h.length]=s;t=t.replace(a[d],"")}if(!r&&/,/.test(t))for(f=(o=t.split(/\s*,\s*/)).length,c=0;c<f;c++)""!==o[c]&&(d=parseInt(o[c],10))<e.columns&&(h[h.length]=d);if(!h.length)for(d=0;d<e.columns;d++)h[h.length]=d;return h},getColumnElm:function(r,i,a){return i.filter(function(){var i=t.findRange(r,e(this).attr("data-column"));return e.inArray(a,i)>-1})},multipleColumns:function(r,i){var a=r.widgetOptions,l=a.filter_initialized||!i.filter(a.filter_anyColumnSelector).length,s=e.trim(t.getLatestSearch(i).attr("data-column")||"");return t.findRange(r,s,!l)},processTypes:function(r,i,a){var l,s=null,n=null;for(l in t.types)e.inArray(l,a.excludeMatch)<0&&null===n&&null!==(n=t.types[l](r,i,a))&&(i.matchedOn=l,s=n);return s},matchType:function(e,t){var r,i=e.widgetOptions,l=e.$headerIndexed[t];return l.hasClass("filter-exact")?r=!1:l.hasClass("filter-match")?r=!0:(i.filter_columnFilters?l=e.$filters.find("."+a.filter).add(i.filter_$externalFilters).filter('[data-column="'+t+'"]'):i.filter_$externalFilters&&(l=i.filter_$externalFilters.filter('[data-column="'+t+'"]')),r=!!l.length&&"match"===e.widgetOptions.filter_matchType[(l[0].nodeName||"").toLowerCase()]),r},processRow:function(a,l,s){var n,o,c,d,f,h=a.widgetOptions,u=!0,p=h.filter_$anyMatch&&h.filter_$anyMatch.length,g=h.filter_$anyMatch&&h.filter_$anyMatch.length?t.multipleColumns(a,h.filter_$anyMatch):[];if(l.$cells=l.$row.children(),l.matchedOn=null,l.anyMatchFlag&&g.length>1||l.anyMatchFilter&&!p){if(l.anyMatch=!0,l.isMatch=!0,l.rowArray=l.$cells.map(function(t){if(e.inArray(t,g)>-1||l.anyMatchFilter&&!p)return l.parsed[t]?f=l.cacheArray[t]:(f=l.rawArray[t],f=e.trim(h.filter_ignoreCase?f.toLowerCase():f),a.sortLocaleCompare&&(f=i.replaceAccents(f))),f}).get(),l.filter=l.anyMatchFilter,l.iFilter=l.iAnyMatchFilter,l.exact=l.rowArray.join(" "),l.iExact=h.filter_ignoreCase?l.exact.toLowerCase():l.exact,l.cache=l.cacheArray.slice(0,-1).join(" "),s.excludeMatch=s.noAnyMatch,null!==(o=t.processTypes(a,l,s)))u=o;else if(h.filter_startsWith)for(u=!1,g=Math.min(a.columns,l.rowArray.length);!u&&g>0;)g--,u=u||0===l.rowArray[g].indexOf(l.iFilter);else u=(l.iExact+l.childRowText).indexOf(l.iFilter)>=0;if(l.anyMatch=!1,l.filters.join("")===l.filter)return u}for(g=0;g<a.columns;g++)l.filter=l.filters[g],l.index=g,s.excludeMatch=s.excludeFilter[g],l.filter&&(l.cache=l.cacheArray[g],n=l.parsed[g]?l.cache:l.rawArray[g]||"",l.exact=a.sortLocaleCompare?i.replaceAccents(n):n,l.iExact=!r.type.test(typeof l.exact)&&h.filter_ignoreCase?l.exact.toLowerCase():l.exact,l.isMatch=t.matchType(a,g),n=u,d=h.filter_columnFilters&&a.$filters.add(h.filter_$externalFilters).filter('[data-column="'+g+'"]').find("select option:selected").attr("data-function-name")||"",a.sortLocaleCompare&&(l.filter=i.replaceAccents(l.filter)),h.filter_defaultFilter&&r.iQuery.test(s.defaultColFilter[g])&&(l.filter=t.defaultFilter(l.filter,s.defaultColFilter[g])),l.iFilter=h.filter_ignoreCase?(l.filter||"").toLowerCase():l.filter,o=null,(c=s.functions[g])&&("function"==typeof c?o=c(l.exact,l.cache,l.filter,g,l.$row,a,l):"function"==typeof c[d||l.filter]&&(o=c[f=d||l.filter](l.exact,l.cache,l.filter,g,l.$row,a,l))),null===o?(o=t.processTypes(a,l,s),f=!0===c&&("and"===l.matchedOn||"or"===l.matchedOn),null===o||f?!0===c?n=l.isMatch?(""+l.iExact).search(l.iFilter)>=0:l.filter===l.exact:(f=(l.iExact+l.childRowText).indexOf(t.parseFilter(a,l.iFilter,l)),n=!h.filter_startsWith&&f>=0||h.filter_startsWith&&0===f):n=o):n=o,u=!!n&&u);return u},findRows:function(a,l,s){if(!t.equalFilters(a.config,a.config.lastSearch,s)&&a.config.widgetOptions.filter_initialized){var n,o,c,d,f,h,u,p,g,m,b,y,_,v,w,x,S,C,z,$,F,R,T,k=e.extend([],l),H=a.config,A=H.widgetOptions,I=i.debug(H,"filter"),O={anyMatch:!1,filters:l,filter_regexCache:[]},E={noAnyMatch:["range","operators"],functions:[],excludeFilter:[],defaultColFilter:[],defaultAnyFilter:i.getColumnData(a,A.filter_defaultFilter,H.columns,!0)||""};for(O.parsed=[],g=0;g<H.columns;g++)O.parsed[g]=A.filter_useParsedData||H.parsers&&H.parsers[g]&&H.parsers[g].parsed||i.getData&&"parsed"===i.getData(H.$headerIndexed[g],i.getColumnData(a,H.headers,g),"filter")||H.$headerIndexed[g].hasClass("filter-parsed"),E.functions[g]=i.getColumnData(a,A.filter_functions,g)||H.$headerIndexed[g].hasClass("filter-select"),E.defaultColFilter[g]=i.getColumnData(a,A.filter_defaultFilter,g)||"",E.excludeFilter[g]=(i.getColumnData(a,A.filter_excludeFilter,g,!0)||"").split(/\s+/);for(I&&(console.log("Filter >> Starting filter widget search",l),v=new Date),H.filteredRows=0,H.totalRows=0,s=k||[],u=0;u<H.$tbodies.length;u++){if(p=i.processTbody(a,H.$tbodies.eq(u),!0),g=H.columns,o=H.cache[u].normalized,d=e(e.map(o,function(e){return e[g].$row.get()})),""===s.join("")||A.filter_serversideFiltering)d.removeClass(A.filter_filteredRow).not("."+H.cssChildRow).css("display","");else{if(n=(d=d.not("."+H.cssChildRow)).length,(A.filter_$anyMatch&&A.filter_$anyMatch.length||void 0!==l[H.columns])&&(O.anyMatchFlag=!0,O.anyMatchFilter=""+(l[H.columns]||A.filter_$anyMatch&&t.getLatestSearch(A.filter_$anyMatch).val()||""),A.filter_columnAnyMatch)){for(z=O.anyMatchFilter.split(r.andSplit),$=!1,x=0;x<z.length;x++)(F=z[x].split(":")).length>1&&(isNaN(F[0])?e.each(H.headerContent,function(e,t){t.toLowerCase().indexOf(F[0])>-1&&(l[R=e]=F[1])}):R=parseInt(F[0],10)-1,R>=0&&R<H.columns&&(l[R]=F[1],z.splice(x,1),x--,$=!0));$&&(O.anyMatchFilter=z.join(" && "))}if(C=A.filter_searchFiltered,b=H.lastSearch||H.$table.data("lastSearch")||[],C)for(x=0;x<g+1;x++)w=l[x]||"",C||(x=g),C=C&&b.length&&0===w.indexOf(b[x]||"")&&!r.alreadyFiltered.test(w)&&!r.exactTest.test(w)&&!(r.isNeg1.test(w)||r.isNeg2.test(w))&&!(""!==w&&H.$filters&&H.$filters.filter('[data-column="'+x+'"]').find("select").length&&!t.matchType(H,x));for(S=d.not("."+A.filter_filteredRow).length,C&&0===S&&(C=!1),I&&console.log("Filter >> Searching through "+(C&&S<n?S:"all")+" rows"),O.anyMatchFlag&&(H.sortLocaleCompare&&(O.anyMatchFilter=i.replaceAccents(O.anyMatchFilter)),A.filter_defaultFilter&&r.iQuery.test(E.defaultAnyFilter)&&(O.anyMatchFilter=t.defaultFilter(O.anyMatchFilter,E.defaultAnyFilter),C=!1),O.iAnyMatchFilter=A.filter_ignoreCase&&H.ignoreCase?O.anyMatchFilter.toLowerCase():O.anyMatchFilter),h=0;h<n;h++)if(T=d[h].className,!(h&&r.child.test(T)||C&&r.filtered.test(T))){if(O.$row=d.eq(h),O.rowIndex=h,O.cacheArray=o[h],c=O.cacheArray[H.columns],O.rawArray=c.raw,O.childRowText="",!A.filter_childByColumn){for(T="",m=c.child,x=0;x<m.length;x++)T+=" "+m[x].join(" ")||"";O.childRowText=A.filter_childRows?A.filter_ignoreCase?T.toLowerCase():T:""}if(y=!1,_=t.processRow(H,O,E),f=c.$row,w=!!_,m=c.$row.filter(":gt(0)"),A.filter_childRows&&m.length){if(A.filter_childByColumn)for(A.filter_childWithSibs||(m.addClass(A.filter_filteredRow),f=f.eq(0)),x=0;x<m.length;x++)O.$row=m.eq(x),O.cacheArray=c.child[x],O.rawArray=O.cacheArray,w=t.processRow(H,O,E),y=y||w,!A.filter_childWithSibs&&w&&m.eq(x).removeClass(A.filter_filteredRow);y=y||_}else y=w;f.toggleClass(A.filter_filteredRow,!y)[0].display=y?"":"none"}}H.filteredRows+=d.not("."+A.filter_filteredRow).length,H.totalRows+=d.length,i.processTbody(a,p,!1)}H.lastCombinedFilter=k.join(""),H.lastSearch=k,H.$table.data("lastSearch",k),A.filter_saveFilters&&i.storage&&i.storage(a,"tablesorter-filters",t.processFilters(k,!0)),I&&console.log("Filter >> Completed search"+i.benchmark(v)),A.filter_initialized&&(H.$table.triggerHandler("filterBeforeEnd",H),H.$table.triggerHandler("filterEnd",H)),setTimeout(function(){i.applyWidget(H.table)},0)}},getOptionSource:function(r,a,l){var s=(r=e(r)[0]).config,n=!1,o=s.widgetOptions.filter_selectSource,c=s.$table.data("lastSearch")||[],d="function"==typeof o||i.getColumnData(r,o,a);if(l&&""!==c[a]&&(l=!1),!0===d)n=o(r,a,l);else{if(d instanceof e||"string"===e.type(d)&&d.indexOf("</option>")>=0)return d;if(e.isArray(d))n=d;else if("object"===e.type(o)&&d&&null===(n=d(r,a,l)))return null}return!1===n&&(n=t.getOptions(r,a,l)),t.processOptions(r,a,n)},processOptions:function(t,r,a){if(!e.isArray(a))return!1;var l,s,n,o,c,d,f=(t=e(t)[0]).config,h=null!=r&&r>=0&&r<f.columns,u=!!h&&f.$headerIndexed[r].hasClass("filter-select-sort-desc"),p=[];if(a=e.grep(a,function(t,r){return!!t.text||e.inArray(t,a)===r}),h&&f.$headerIndexed[r].hasClass("filter-select-nosort"))return a;for(o=a.length,n=0;n<o;n++)d=(s=a[n]).text?s.text:s,c=(h&&f.parsers&&f.parsers.length&&f.parsers[r].format(d,t,[],r)||d).toString(),c=f.widgetOptions.filter_ignoreCase?c.toLowerCase():c,s.text?(s.parsed=c,p[p.length]=s):p[p.length]={text:s,parsed:c};for(l=f.textSorter||"",p.sort(function(e,a){var s=u?a.parsed:e.parsed,n=u?e.parsed:a.parsed;return h&&"function"==typeof l?l(s,n,!0,r,t):h&&"object"==typeof l&&l.hasOwnProperty(r)?l[r](s,n,!0,r,t):!i.sortNatural||i.sortNatural(s,n)}),a=[],o=p.length,n=0;n<o;n++)a[a.length]=p[n];return a},getOptions:function(t,r,a){var l,s,n,o,c,d,f,h,u=(t=e(t)[0]).config,p=u.widgetOptions,g=[];for(s=0;s<u.$tbodies.length;s++)for(c=u.cache[s],n=u.cache[s].normalized.length,l=0;l<n;l++)if(o=c.row?c.row[l]:c.normalized[l][u.columns].$row[0],!a||!o.className.match(p.filter_filteredRow))if(p.filter_useParsedData||u.parsers[r].parsed||u.$headerIndexed[r].hasClass("filter-parsed")){if(g[g.length]=""+c.normalized[l][r],p.filter_childRows&&p.filter_childByColumn)for(h=c.normalized[l][u.columns].$row.length-1,d=0;d<h;d++)g[g.length]=""+c.normalized[l][u.columns].child[d][r]}else if(g[g.length]=c.normalized[l][u.columns].raw[r],p.filter_childRows&&p.filter_childByColumn)for(h=c.normalized[l][u.columns].$row.length,d=1;d<h;d++)f=c.normalized[l][u.columns].$row.eq(d).children().eq(r),g[g.length]=""+i.getElementText(u,f,r);return g},buildSelect:function(i,l,s,n,o){if(i=e(i)[0],l=parseInt(l,10),i.config.cache&&!e.isEmptyObject(i.config.cache)){var c,d,f,h,u,p,g,m=i.config,b=m.widgetOptions,y=m.$headerIndexed[l],_='<option value="">'+(y.data("placeholder")||y.attr("data-placeholder")||b.filter_placeholder.select||"")+"</option>",v=m.$table.find("thead").find("select."+a.filter+'[data-column="'+l+'"]').val();if(void 0!==s&&""!==s||null!==(s=t.getOptionSource(i,l,o))){if(e.isArray(s)){for(c=0;c<s.length;c++)if((g=s[c]).text){for(d in g["data-function-name"]=void 0===g.value?g.text:g.value,_+="<option",g)g.hasOwnProperty(d)&&"text"!==d&&(_+=" "+d+'="'+g[d].replace(r.quote,"&quot;")+'"');g.value||(_+=' value="'+g.text.replace(r.quote,"&quot;")+'"'),_+=">"+g.text.replace(r.quote,"&quot;")+"</option>"}else""+g!="[object Object]"&&(d=f=g=(""+g).replace(r.quote,"&quot;"),f.indexOf(b.filter_selectSourceSeparator)>=0&&(d=(h=f.split(b.filter_selectSourceSeparator))[0],f=h[1]),_+=""!==g?"<option "+(d===f?"":'data-function-name="'+g+'" ')+'value="'+d+'">'+f+"</option>":"");s=[]}u=(m.$filters?m.$filters:m.$table.children("thead")).find("."+a.filter),b.filter_$externalFilters&&(u=u&&u.length?u.add(b.filter_$externalFilters):b.filter_$externalFilters),(p=u.filter('select[data-column="'+l+'"]')).length&&(p[n?"html":"append"](_),e.isArray(s)||p.append(s).val(v),p.val(v))}}},buildDefault:function(e,r){var a,l,s,n=e.config,o=n.widgetOptions,c=n.columns;for(a=0;a<c;a++)s=!((l=n.$headerIndexed[a]).hasClass("filter-false")||l.hasClass("parser-false")),(l.hasClass("filter-select")||!0===i.getColumnData(e,o.filter_functions,a))&&s&&t.buildSelect(e,a,"",r,l.hasClass(o.filter_onlyAvail))}},r=t.regex,i.getFilters=function(r,i,l,s){var n,o,c,d,f=[],h=r?e(r)[0].config:"",u=h?h.widgetOptions:"";if(!0!==i&&u&&!u.filter_columnFilters||e.isArray(l)&&t.equalFilters(h,l,h.lastSearch))return e(r).data("lastSearch")||[];if(h&&(h.$filters&&(o=h.$filters.find("."+a.filter)),u.filter_$externalFilters&&(o=o&&o.length?o.add(u.filter_$externalFilters):u.filter_$externalFilters),o&&o.length))for(f=l||[],n=0;n<h.columns+1;n++)d=n===h.columns?u.filter_anyColumnSelector+","+u.filter_multipleColumnSelector:'[data-column="'+n+'"]',(c=o.filter(d)).length&&(c=t.getLatestSearch(c),e.isArray(l)?(s&&c.length>1&&(c=c.slice(1)),n===h.columns&&(d=c.filter(u.filter_anyColumnSelector),c=d.length?d:c),c.val(l[n]).trigger("change"+h.namespace)):(f[n]=c.val()||"",n===h.columns?c.slice(1).filter('[data-column*="'+c.attr("data-column")+'"]').val(f[n]):c.slice(1).val(f[n])),n===h.columns&&c.length&&(u.filter_$anyMatch=c));return f},i.setFilters=function(r,a,l,s){var n=r?e(r)[0].config:"",o=i.getFilters(r,!0,a,s);return void 0===l&&(l=!0),n&&l&&(n.lastCombinedFilter=null,n.lastSearch=[],t.searching(n.table,a,s),n.$table.triggerHandler("filterFomatterUpdate")),0!==o.length}}(e),function(e,t){"use strict";var r=e.tablesorter||{};function i(t,r){var i=isNaN(r.stickyHeaders_offset)?e(r.stickyHeaders_offset):[];return i.length?i.height()||0:parseInt(r.stickyHeaders_offset,10)||0}e.extend(r.css,{sticky:"tablesorter-stickyHeader",stickyVis:"tablesorter-sticky-visible",stickyHide:"tablesorter-sticky-hidden",stickyWrap:"tablesorter-sticky-wrapper"}),r.addHeaderResizeEvent=function(t,r,i){if((t=e(t)[0]).config){var a=e.extend({},{timer:250},i),l=t.config,s=l.widgetOptions,n=function(e){var t,r,i,a,n,o,c=l.$headers.length;for(s.resize_flag=!0,r=[],t=0;t<c;t++)a=(i=l.$headers.eq(t)).data("savedSizes")||[0,0],n=i[0].offsetWidth,o=i[0].offsetHeight,n===a[0]&&o===a[1]||(i.data("savedSizes",[n,o]),r.push(i[0]));r.length&&!1!==e&&l.$table.triggerHandler("resize",[r]),s.resize_flag=!1};if(clearInterval(s.resize_timer),r)return s.resize_flag=!1,!1;n(!1),s.resize_timer=setInterval(function(){s.resize_flag||n()},a.timer)}},r.addWidget({id:"stickyHeaders",priority:54,options:{stickyHeaders:"",stickyHeaders_appendTo:null,stickyHeaders_attachTo:null,stickyHeaders_xScroll:null,stickyHeaders_yScroll:null,stickyHeaders_offset:0,stickyHeaders_filteredToTop:!0,stickyHeaders_cloneId:"-sticky",stickyHeaders_addResizeEvent:!0,stickyHeaders_includeCaption:!0,stickyHeaders_zIndex:2},format:function(a,l,s){if(!(l.$table.hasClass("hasStickyHeaders")||e.inArray("filter",l.widgets)>=0&&!l.$table.hasClass("hasFilters"))){var n,o,c,d,f=l.$table,h=e(s.stickyHeaders_attachTo||s.stickyHeaders_appendTo),u=l.namespace+"stickyheaders ",p=e(s.stickyHeaders_yScroll||s.stickyHeaders_attachTo||t),g=e(s.stickyHeaders_xScroll||s.stickyHeaders_attachTo||t),m=f.children("thead:first").children("tr").not(".sticky-false").children(),b=f.children("tfoot"),y=i(0,s),_=f.parent().closest("."+r.css.table).hasClass("hasStickyHeaders")?f.parent().closest("table.tablesorter")[0].config.widgetOptions.$sticky.parent():[],v=_.length?_.height():0,w=s.$sticky=f.clone().addClass("containsStickyHeaders "+r.css.sticky+" "+s.stickyHeaders+" "+l.namespace.slice(1)+"_extra_table").wrap('<div class="'+r.css.stickyWrap+'">'),x=w.parent().addClass(r.css.stickyHide).css({position:h.length?"absolute":"fixed",padding:parseInt(w.parent().parent().css("padding-left"),10),top:y+v,left:0,visibility:"hidden",zIndex:s.stickyHeaders_zIndex||2}),S=w.children("thead:first"),C="",z=function(e,r){var i,a,l,s,n,o=e.filter(":visible"),c=o.length;for(i=0;i<c;i++)s=r.filter(":visible").eq(i),"border-box"===(n=o.eq(i)).css("box-sizing")?a=n.outerWidth():"collapse"===s.css("border-collapse")?t.getComputedStyle?a=parseFloat(t.getComputedStyle(n[0],null).width):(l=parseFloat(n.css("border-width")),a=n.outerWidth()-parseFloat(n.css("padding-left"))-parseFloat(n.css("padding-right"))-l):a=n.width(),s.css({width:a,"min-width":a,"max-width":a})},$=function(r){return!1===r&&_.length?f.position().left:h.length?parseInt(h.css("padding-left"),10)||0:f.offset().left-parseInt(f.css("margin-left"),10)-e(t).scrollLeft()},F=function(){x.css({left:$(),width:f.outerWidth()}),z(f,w),z(m,d)},R=function(t){if(f.is(":visible")){v=_.length?_.offset().top-p.scrollTop()+_.height():0;var a,l=f.offset(),n=i(0,s),o=e.isWindow(p[0]),c=o?p.scrollTop():_.length?parseInt(_[0].style.top,10):p.offset().top,d=h.length?c:p.scrollTop(),u=s.stickyHeaders_includeCaption?0:f.children("caption").height()||0,g=d+n+v-u,m=f.height()-(x.height()+(b.height()||0))-u,y=g>l.top&&g<l.top+m?"visible":"hidden",w="visible"===y?r.css.stickyVis:r.css.stickyHide,S=!x.hasClass(w),z={visibility:y};h.length&&(S=!0,z.top=o?g-h.offset().top:h.scrollTop()),(a=$(o))!==parseInt(x.css("left"),10)&&(S=!0,z.left=a),z.top=(z.top||0)+(!o&&_.length?_.height():n+v),S&&x.removeClass(r.css.stickyVis+" "+r.css.stickyHide).addClass(w).css(z),(y!==C||t)&&(F(),C=y)}};if(h.length&&!h.css("position")&&h.css("position","relative"),w.attr("id")&&(w[0].id+=s.stickyHeaders_cloneId),w.find("> thead:gt(0), tr.sticky-false").hide(),w.find("> tbody, > tfoot").remove(),w.find("caption").toggle(s.stickyHeaders_includeCaption),d=S.children().children(),w.css({height:0,width:0,margin:0}),d.find("."+r.css.resizer).remove(),f.addClass("hasStickyHeaders").bind("pagerComplete"+u,function(){F()}),r.bindEvents(a,S.children().children("."+r.css.header)),s.stickyHeaders_appendTo?e(s.stickyHeaders_appendTo).append(x):f.after(x),l.onRenderHeader)for(o=(c=S.children("tr").children()).length,n=0;n<o;n++)l.onRenderHeader.apply(c.eq(n),[n,l,w]);g.add(p).unbind("scroll resize ".split(" ").join(u).replace(/\s+/g," ")).bind("scroll resize ".split(" ").join(u),function(e){R("resize"===e.type)}),l.$table.unbind("stickyHeadersUpdate"+u).bind("stickyHeadersUpdate"+u,function(){R(!0)}),s.stickyHeaders_addResizeEvent&&r.addHeaderResizeEvent(a),f.hasClass("hasFilters")&&s.filter_columnFilters&&(f.bind("filterEnd"+u,function(){var i=e(document.activeElement).closest("td"),a=i.parent().children().index(i);x.hasClass(r.css.stickyVis)&&s.stickyHeaders_filteredToTop&&(t.scrollTo(0,f.position().top),a>=0&&l.$filters&&l.$filters.eq(a).find("a, select, input").filter(":visible").focus())}),r.filter.bindSearch(f,d.find("."+r.css.filter)),s.filter_hideFilters&&r.filter.hideFilters(l,w)),s.stickyHeaders_addResizeEvent&&f.bind("resize"+l.namespace+"stickyheaders",function(){F()}),R(!0),f.triggerHandler("stickyHeadersInit")}},remove:function(i,a,l){var s=a.namespace+"stickyheaders ";a.$table.removeClass("hasStickyHeaders").unbind("pagerComplete resize filterEnd stickyHeadersUpdate ".split(" ").join(s).replace(/\s+/g," ")).next("."+r.css.stickyWrap).remove(),l.$sticky&&l.$sticky.length&&l.$sticky.remove(),e(t).add(l.stickyHeaders_xScroll).add(l.stickyHeaders_yScroll).add(l.stickyHeaders_attachTo).unbind("scroll resize ".split(" ").join(s).replace(/\s+/g," ")),r.addHeaderResizeEvent(i,!0)}})}(e,window),function(e,t){"use strict";var r=e.tablesorter||{};e.extend(r.css,{resizableContainer:"tablesorter-resizable-container",resizableHandle:"tablesorter-resizable-handle",resizableNoSelect:"tablesorter-disableSelection",resizableStorage:"tablesorter-resizable"}),e(function(){var t="<style>body."+r.css.resizableNoSelect+" { -ms-user-select: none; -moz-user-select: -moz-none;-khtml-user-select: none; -webkit-user-select: none; user-select: none; }."+r.css.resizableContainer+" { position: relative; height: 1px; }."+r.css.resizableHandle+" { position: absolute; display: inline-block; width: 8px;top: 1px; cursor: ew-resize; z-index: 3; user-select: none; -moz-user-select: none; }</style>";e("head").append(t)}),r.resizable={init:function(t,i){if(!t.$table.hasClass("hasResizable")){t.$table.addClass("hasResizable");var a,l,s,n,o=t.$table,c=o.parent(),d=parseInt(o.css("margin-top"),10),f=i.resizable_vars={useStorage:r.storage&&!1!==i.resizable,$wrap:c,mouseXPosition:0,$target:null,$next:null,overflow:"auto"===c.css("overflow")||"scroll"===c.css("overflow")||"auto"===c.css("overflow-x")||"scroll"===c.css("overflow-x"),storedSizes:[]};for(r.resizableReset(t.table,!0),f.tableWidth=o.width(),f.fullWidth=Math.abs(c.width()-f.tableWidth)<20,f.useStorage&&f.overflow&&(r.storage(t.table,"tablesorter-table-original-css-width",f.tableWidth),n=r.storage(t.table,"tablesorter-table-resized-width")||"auto",r.resizable.setWidth(o,n,!0)),i.resizable_vars.storedSizes=s=(f.useStorage?r.storage(t.table,r.css.resizableStorage):[])||[],r.resizable.setWidths(t,i,s),r.resizable.updateStoredSizes(t,i),i.$resizable_container=e('<div class="'+r.css.resizableContainer+'">').css({top:d}).insertBefore(o),l=0;l<t.columns;l++)a=t.$headerIndexed[l],n=r.getColumnData(t.table,t.headers,l),"false"===r.getData(a,n,"resizable")||e('<div class="'+r.css.resizableHandle+'">').appendTo(i.$resizable_container).attr({"data-column":l,unselectable:"on"}).data("header",a).bind("selectstart",!1);r.resizable.bindings(t,i)}},updateStoredSizes:function(e,t){var r,i,a=e.columns,l=t.resizable_vars;for(l.storedSizes=[],r=0;r<a;r++)i=e.$headerIndexed[r],l.storedSizes[r]=i.is(":visible")?i.width():0},setWidth:function(e,t,r){e.css({width:t,"min-width":r?t:"","max-width":r?t:""})},setWidths:function(t,i,a){var l,s,n=i.resizable_vars,o=e(t.namespace+"_extra_headers"),c=t.$table.children("colgroup").children("col");if((a=a||n.storedSizes||[]).length){for(l=0;l<t.columns;l++)r.resizable.setWidth(t.$headerIndexed[l],a[l],n.overflow),o.length&&(s=o.eq(l).add(c.eq(l)),r.resizable.setWidth(s,a[l],n.overflow));(s=e(t.namespace+"_extra_table")).length&&!r.hasWidget(t.table,"scroller")&&r.resizable.setWidth(s,t.$table.outerWidth(),n.overflow)}},setHandlePosition:function(t,i){var a,l=t.$table.height(),s=i.$resizable_container.children(),n=Math.floor(s.width()/2);r.hasWidget(t.table,"scroller")&&(l=0,t.$table.closest("."+r.css.scrollerWrap).children().each(function(){var t=e(this);l+=t.filter('[style*="height"]').length?t.height():t.children("table").height()})),!i.resizable_includeFooter&&t.$table.children("tfoot").length&&(l-=t.$table.children("tfoot").height()),a=parseFloat(e.fn.jquery)>=3.3?0:t.$table.position().left,s.each(function(){var s=e(this),o=parseInt(s.attr("data-column"),10),c=t.columns-1,d=s.data("header");d&&(!d.is(":visible")||!i.resizable_addLastColumn&&r.resizable.checkVisibleColumns(t,o)?s.hide():(o<c||o===c&&i.resizable_addLastColumn)&&s.css({display:"inline-block",height:l,left:d.position().left-a+d.outerWidth()-n}))})},checkVisibleColumns:function(e,t){var r,i=0;for(r=t+1;r<e.columns;r++)i+=e.$headerIndexed[r].is(":visible")?1:0;return 0===i},toggleTextSelection:function(t,i,a){var l=t.namespace+"tsresize";i.resizable_vars.disabled=a,e("body").toggleClass(r.css.resizableNoSelect,a),a?e("body").attr("unselectable","on").bind("selectstart"+l,!1):e("body").removeAttr("unselectable").unbind("selectstart"+l)},bindings:function(i,a){var l=i.namespace+"tsresize";a.$resizable_container.children().bind("mousedown",function(t){var l,s=a.resizable_vars,n=e(i.namespace+"_extra_headers"),o=e(t.target).data("header");l=parseInt(o.attr("data-column"),10),s.$target=o=o.add(n.filter('[data-column="'+l+'"]')),s.target=l,s.$next=t.shiftKey||a.resizable_targetLast?o.parent().children().not(".resizable-false").filter(":last"):o.nextAll(":not(.resizable-false)").eq(0),l=parseInt(s.$next.attr("data-column"),10),s.$next=s.$next.add(n.filter('[data-column="'+l+'"]')),s.next=l,s.mouseXPosition=t.pageX,r.resizable.updateStoredSizes(i,a),r.resizable.toggleTextSelection(i,a,!0)}),e(document).bind("mousemove"+l,function(e){var t=a.resizable_vars;t.disabled&&0!==t.mouseXPosition&&t.$target&&(a.resizable_throttle?(clearTimeout(t.timer),t.timer=setTimeout(function(){r.resizable.mouseMove(i,a,e)},isNaN(a.resizable_throttle)?5:a.resizable_throttle)):r.resizable.mouseMove(i,a,e))}).bind("mouseup"+l,function(){a.resizable_vars.disabled&&(r.resizable.toggleTextSelection(i,a,!1),r.resizable.stopResize(i,a),r.resizable.setHandlePosition(i,a))}),e(t).bind("resize"+l+" resizeEnd"+l,function(){r.resizable.setHandlePosition(i,a)}),i.$table.bind("columnUpdate pagerComplete resizableUpdate ".split(" ").join(l+" "),function(){r.resizable.setHandlePosition(i,a)}).bind("resizableReset"+l,function(){r.resizableReset(i.table)}).find("thead:first").add(e(i.namespace+"_extra_table").find("thead:first")).bind("contextmenu"+l,function(){var e=0===a.resizable_vars.storedSizes.length;return r.resizableReset(i.table),r.resizable.setHandlePosition(i,a),a.resizable_vars.storedSizes=[],e})},mouseMove:function(t,i,a){if(0!==i.resizable_vars.mouseXPosition&&i.resizable_vars.$target){var l,s=0,n=i.resizable_vars,o=n.$next,c=n.storedSizes[n.target],d=a.pageX-n.mouseXPosition;if(n.overflow){if(c+d>0){for(n.storedSizes[n.target]+=d,r.resizable.setWidth(n.$target,n.storedSizes[n.target],!0),l=0;l<t.columns;l++)s+=n.storedSizes[l];r.resizable.setWidth(t.$table.add(e(t.namespace+"_extra_table")),s)}o.length||(n.$wrap[0].scrollLeft=t.$table.width())}else n.fullWidth?(n.storedSizes[n.target]+=d,n.storedSizes[n.next]-=d,r.resizable.setWidths(t,i)):(n.storedSizes[n.target]+=d,r.resizable.setWidths(t,i));n.mouseXPosition=a.pageX,t.$table.triggerHandler("stickyHeadersUpdate")}},stopResize:function(e,t){var i=t.resizable_vars;r.resizable.updateStoredSizes(e,t),i.useStorage&&(r.storage(e.table,r.css.resizableStorage,i.storedSizes),r.storage(e.table,"tablesorter-table-resized-width",e.$table.width())),i.mouseXPosition=0,i.$target=i.$next=null,e.$table.triggerHandler("stickyHeadersUpdate"),e.$table.triggerHandler("resizableComplete")}},r.addWidget({id:"resizable",priority:40,options:{resizable:!0,resizable_addLastColumn:!1,resizable_includeFooter:!0,resizable_widths:[],resizable_throttle:!1,resizable_targetLast:!1},init:function(e,t,i,a){r.resizable.init(i,a)},format:function(e,t,i){r.resizable.setHandlePosition(t,i)},remove:function(t,i,a,l){if(a.$resizable_container){var s=i.namespace+"tsresize";i.$table.add(e(i.namespace+"_extra_table")).removeClass("hasResizable").children("thead").unbind("contextmenu"+s),a.$resizable_container.remove(),r.resizable.toggleTextSelection(i,a,!1),r.resizableReset(t,l),e(document).unbind("mousemove"+s+" mouseup"+s)}}}),r.resizableReset=function(t,i){e(t).each(function(){var e,a,l=this.config,s=l&&l.widgetOptions,n=s.resizable_vars;if(t&&l&&l.$headerIndexed.length){for(n.overflow&&n.tableWidth&&(r.resizable.setWidth(l.$table,n.tableWidth,!0),n.useStorage&&r.storage(t,"tablesorter-table-resized-width",n.tableWidth)),e=0;e<l.columns;e++)a=l.$headerIndexed[e],s.resizable_widths&&s.resizable_widths[e]?r.resizable.setWidth(a,s.resizable_widths[e],n.overflow):a.hasClass("resizable-false")||r.resizable.setWidth(a,"",n.overflow);l.$table.triggerHandler("stickyHeadersUpdate"),r.storage&&!i&&r.storage(this,r.css.resizableStorage,[])}})}}(e,window),function(e){"use strict";var t=e.tablesorter||{};function r(r){var i=t.storage(r.table,"tablesorter-savesort");return i&&i.hasOwnProperty("sortList")&&e.isArray(i.sortList)?i.sortList:[]}function i(e,t){return(t||r(e)).join(",")!==e.sortList.join(",")}t.addWidget({id:"saveSort",priority:20,options:{saveSort:!0},init:function(e,t,r,i){t.format(e,r,i,!0)},format:function(e,a,l,s){var n,o=a.$table,c=!1!==l.saveSort,d={sortList:a.sortList},f=t.debug(a,"saveSort");f&&(n=new Date),o.hasClass("hasSaveSort")?c&&e.hasInitialized&&t.storage&&i(a)&&(t.storage(e,"tablesorter-savesort",d),f&&console.log("saveSort >> Saving last sort: "+a.sortList+t.benchmark(n))):(o.addClass("hasSaveSort"),d="",t.storage&&(d=r(a),f&&console.log('saveSort >> Last sort loaded: "'+d+'"'+t.benchmark(n)),o.bind("saveSortReset",function(r){r.stopPropagation(),t.storage(e,"tablesorter-savesort","")})),s&&d&&d.length>0?a.sortList=d:e.hasInitialized&&d&&d.length>0&&i(a,d)&&t.sortOn(a,d))},remove:function(e,r){r.$table.removeClass("hasSaveSort"),t.storage&&t.storage(e,"tablesorter-savesort","")}})}(e),e.tablesorter});
diff --git a/parsers/parser-network.js b/parsers/parser-network.js
index 148f53a..94286c2 100644
--- a/parsers/parser-network.js
+++ b/parsers/parser-network.js
@@ -1,143 +1,4 @@
/*! Parser: network - updated 2018-01-10 (v2.29.3) */
/* IPv4, IPv6 and MAC Addresses */
/*global jQuery: false */
-;(function($) {
- 'use strict';
-
- var ts = $.tablesorter,
- ipv4Format,
- ipv4Is;
-
- /*! IPv6 Address parser (WIP) *//*
- * IPv6 Address (ffff:0000:0000:0000:0000:0000:0000:0000)
- * needs to support short versions like '::8' or '1:2::7:8'
- * and '::00:192.168.10.184' (embedded IPv4 address)
- * see http://www.intermapper.com/support/tools/IPV6-Validator.aspx
- */
- $.extend( ts.regex, {}, {
- ipv4Validate : /((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})/,
- ipv4Extract : /([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/,
-
- // simplified regex from http://www.intermapper.com/support/tools/IPV6-Validator.aspx
- // (specifically from http://download.dartware.com/thirdparty/ipv6validator.js)
- ipv6Validate : /^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/i
- });
-
- // used for internal testing; it's not useful to set this to true because the natural sort algorithm
- // is set up to only sort solitary hex values ("ffff") vs separated hex values ("ffff.ffff")
- ts.defaults.ipv6HexFormat = false;
-
- ts.addParser({
- id: 'ipv6Address',
- is: function(s) {
- return ts.regex.ipv6Validate.test(s);
- },
- format: function(address, table) {
- // code modified from http://zurb.com/forrst/posts/JS_Expand_Abbreviated_IPv6_Addresses-1OR
- // Saved to https://gist.github.com/Mottie/7018157
- var i, t, sides, groups, groupsPresent,
- hex = table ? (typeof table === 'boolean' ? table : table && table.config.ipv6HexFormat || false) : false,
- fullAddress = '',
- expandedAddress = '',
- validGroupCount = 8;
- // validGroupSize = 4; <- removed while loop
- // remove any extra spaces
- address = address.replace(/\s*/g, '');
- // look for embedded ipv4
- if (ts.regex.ipv4Validate.test(address)) {
- groups = address.match(ts.regex.ipv4Extract);
- t = '';
- for (i = 1; i < groups.length; i++) {
- t += ('00' + (parseInt(groups[i], 10).toString(16)) ).slice(-2) + ( i === 2 ? ':' : '' );
- }
- address = address.replace( ts.regex.ipv4Extract, t );
- }
-
- if (address.indexOf('::') === -1) {
- // All eight groups are present
- fullAddress = address;
- } else {
- // Consecutive groups of zeroes have been collapsed with '::'.
- sides = address.split('::');
- groupsPresent = 0;
- for (i = 0; i < sides.length; i++) {
- groupsPresent += sides[i].split(':').length;
- }
- fullAddress += sides[0] + ':';
- for (i = 0; i < validGroupCount - groupsPresent; i++) {
- fullAddress += '0000:';
- }
- fullAddress += sides[1];
- }
- groups = fullAddress.split(':');
- for (i = 0; i < validGroupCount; i++) {
- // it's fastest & easiest for tablesorter to sort decimal values (vs hex)
- groups[i] = hex ? ('0000' + groups[i]).slice(-4) :
- ('00000' + (parseInt(groups[i], 16) || 0)).slice(-5);
- expandedAddress += ( i !== validGroupCount - 1) ? groups[i] + ':' : groups[i];
- }
- return expandedAddress;
- },
- // uses natural sort hex compare
- type: 'text'
- });
-
- // ipv4 address
- // moved here from jquery.tablesorter.js (core file)
- ipv4Is = function(s) {
- return (/^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$/).test(s);
- };
- ipv4Format = function(s) {
- var i,
- a = s ? s.split('.') : '',
- r = [],
- l = a.length;
- for (i = 0; i < l; i++) {
- r.push(('000' + a[i]).slice(-3));
- }
- return s ? r.join('.') : s;
- };
-
- /*! Parser: ipv4Address (a.k.a. ipAddress) */
- // duplicate 'ipAddress' as 'ipv4Address' (to maintain backwards compatility)
- ts.addParser({
- id: 'ipAddress',
- is: ipv4Is,
- format: ipv4Format,
- type: 'text'
- });
- ts.addParser({
- id: 'ipv4Address',
- is: ipv4Is,
- format: ipv4Format,
- type: 'text'
- });
-
- /*! Parser: MAC address */
- /* MAC examples: 12:34:56:78:9A:BC, 1234.5678.9ABC, 12-34-56-78-9A-BC, and 123456789ABC
- */
- ts.addParser({
- id : 'MAC',
- is : function() {
- return false;
- },
- format : function( str ) {
- var indx, len,
- mac = [],
- val = ( str || '' ).replace( /[:.-]/g, '' ).match( /\w{2}/g );
- if ( val ) {
- // not assuming all mac addresses in the column will end up with six
- // groups of two to process, so it's not actually validating the address
- len = val.length;
- for ( indx = 0; indx < len; indx++ ) {
- mac.push(( '000' + parseInt( val[ indx ], 16 ) ).slice( -3 ));
- }
- return mac.join('.');
- }
- return str;
- },
- // uses natural sort hex compare
- type : 'text'
- });
-
-})( jQuery );
+!function(d){"use strict";var e,t,a=d.tablesorter;d.extend(a.regex,{},{ipv4Validate:/((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})/,ipv4Extract:/([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/,ipv6Validate:/^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/i}),a.defaults.ipv6HexFormat=!1,a.addParser({id:"ipv6Address",is:function(d){return a.regex.ipv6Validate.test(d)},format:function(d,e){var t,r,i,f,s,n=!!e&&("boolean"==typeof e?e:e&&e.config.ipv6HexFormat||!1),p="",o="";if(d=d.replace(/\s*/g,""),a.regex.ipv4Validate.test(d)){for(f=d.match(a.regex.ipv4Extract),r="",t=1;t<f.length;t++)r+=("00"+parseInt(f[t],10).toString(16)).slice(-2)+(2===t?":":"");d=d.replace(a.regex.ipv4Extract,r)}if(-1===d.indexOf("::"))p=d;else{for(i=d.split("::"),s=0,t=0;t<i.length;t++)s+=i[t].split(":").length;for(p+=i[0]+":",t=0;t<8-s;t++)p+="0000:";p+=i[1]}for(f=p.split(":"),t=0;t<8;t++)f[t]=n?("0000"+f[t]).slice(-4):("00000"+(parseInt(f[t],16)||0)).slice(-5),o+=7!==t?f[t]+":":f[t];return o},type:"text"}),t=function(d){return/^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$/.test(d)},e=function(d){var e,t=d?d.split("."):"",a=[],r=t.length;for(e=0;e<r;e++)a.push(("000"+t[e]).slice(-3));return d?a.join("."):d},a.addParser({id:"ipAddress",is:t,format:e,type:"text"}),a.addParser({id:"ipv4Address",is:t,format:e,type:"text"}),a.addParser({id:"MAC",is:function(){return!1},format:function(d){var e,t,a=[],r=(d||"").replace(/[:.-]/g,"").match(/\w{2}/g);if(r){for(t=r.length,e=0;e<t;e++)a.push(("000"+parseInt(r[e],16)).slice(-3));return a.join(".")}return d},type:"text"})}(jQuery);
diff --git a/widgets/widget-pager.js b/widgets/widget-pager.js
index 362e77b..b596d6d 100644
--- a/widgets/widget-pager.js
+++ b/widgets/widget-pager.js
@@ -3,1373 +3,4 @@
* by Rob Garrison
*/
/*jshint browser:true, jquery:true, unused:false */
-;(function($) {
- 'use strict';
- var tsp,
- ts = $.tablesorter;
-
- ts.addWidget({
- id: 'pager',
- priority: 55, // load pager after filter widget
- options: {
- // output default: '{page}/{totalPages}'
- // possible variables: {size}, {page}, {totalPages}, {filteredPages}, {startRow},
- // {endRow}, {filteredRows} and {totalRows}
- pager_output: '{startRow} to {endRow} of {totalRows} rows', // '{page}/{totalPages}'
-
- // apply disabled classname to the pager arrows when the rows at either extreme is visible
- pager_updateArrows: true,
-
- // starting page of the pager (zero based index)
- pager_startPage: 0,
-
- // reset pager after filtering; set to desired page #
- // set to false to not change page at filter start
- pager_pageReset: 0,
-
- // Number of visible rows
- pager_size: 10,
-
- // Number of options to include in the pager number selector
- pager_maxOptionSize: 20,
-
- // Save pager page & size if the storage script is loaded (requires $.tablesorter.storage
- // in jquery.tablesorter.widgets.js)
- pager_savePages: true,
-
- // defines custom storage key
- pager_storageKey: 'tablesorter-pager',
-
- // if true, the table will remain the same height no matter how many records are displayed.
- // The space is made up by an empty table row set to a height to compensate; default is false
- pager_fixedHeight: false,
-
- // count child rows towards the set page size? (set true if it is a visible table row within the pager)
- // if true, child row(s) may not appear to be attached to its parent row, may be split across pages or
- // may distort the table if rowspan or cellspans are included.
- pager_countChildRows: false,
-
- // remove rows from the table to speed up the sort of large tables.
- // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with
- // the pager enabled.
- pager_removeRows: false, // removing rows in larger tables speeds up the sort
-
- // use this format: 'http://mydatabase.com?page={page}&size={size}&{sortList:col}&{filterList:fcol}'
- // where {page} is replaced by the page number, {size} is replaced by the number of records to show,
- // {sortList:col} adds the sortList to the url into a 'col' array, and {filterList:fcol} adds
- // the filterList to the url into an 'fcol' array.
- // So a sortList = [[2,0],[3,0]] becomes '&col[2]=0&col[3]=0' in the url
- // and a filterList = [[2,Blue],[3,13]] becomes '&fcol[2]=Blue&fcol[3]=13' in the url
- pager_ajaxUrl: null,
-
- // modify the url after all processing has been applied
- pager_customAjaxUrl: function( table, url ) { return url; },
-
- // ajax error callback from $.tablesorter.showError function
- // pager_ajaxError: function( config, xhr, settings, exception ) { return exception; };
- // returning false will abort the error message
- pager_ajaxError: null,
-
- // modify the $.ajax object to allow complete control over your ajax requests
- pager_ajaxObject: {
- dataType: 'json'
- },
-
- // set this to false if you want to block ajax loading on init
- pager_processAjaxOnInit: true,
-
- // process ajax so that the following information is returned:
- // [ total_rows (number), rows (array of arrays), headers (array; optional) ]
- // example:
- // [
- // 100, // total rows
- // [
- // [ "row1cell1", "row1cell2", ... "row1cellN" ],
- // [ "row2cell1", "row2cell2", ... "row2cellN" ],
- // ...
- // [ "rowNcell1", "rowNcell2", ... "rowNcellN" ]
- // ],
- // [ "header1", "header2", ... "headerN" ] // optional
- // ]
- pager_ajaxProcessing: function( data ) { return data; },
-
- // css class names of pager arrows
- pager_css: {
- container : 'tablesorter-pager',
- // error information row (don't include period at beginning)
- errorRow : 'tablesorter-errorRow',
- // class added to arrows @ extremes (i.e. prev/first arrows 'disabled' on first page)
- disabled : 'disabled'
- },
-
- // jQuery selectors
- pager_selectors: {
- container : '.pager', // target the pager markup
- first : '.first', // go to first page arrow
- prev : '.prev', // previous page arrow
- next : '.next', // next page arrow
- last : '.last', // go to last page arrow
- // goto is a reserved word #657
- gotoPage : '.gotoPage', // go to page selector - select dropdown that sets the current page
- pageDisplay : '.pagedisplay', // location of where the 'output' is displayed
- pageSize : '.pagesize' // page size selector - select dropdown that sets the 'size' option
- }
- },
- init: function( table ) {
- tsp.init( table );
- },
- // only update to complete sorter initialization
- format: function( table, c ) {
- if ( !( c.pager && c.pager.initialized ) ) {
- return tsp.initComplete( c );
- }
- tsp.moveToPage( c, c.pager, false );
- },
- remove: function( table, c, wo, refreshing ) {
- tsp.destroyPager( c, refreshing );
- }
- });
-
- /* pager widget functions */
- tsp = ts.pager = {
-
- init: function( table ) {
- // check if tablesorter has initialized
- if ( table.hasInitialized && table.config.pager && table.config.pager.initialized ) { return; }
- var t,
- c = table.config,
- wo = c.widgetOptions,
- s = wo.pager_selectors,
-
- // save pager variables
- p = c.pager = $.extend({
- totalPages: 0,
- filteredRows: 0,
- filteredPages: 0,
- currentFilters: [],
- page: wo.pager_startPage,
- startRow: 0,
- endRow: 0,
- ajaxCounter: 0,
- $size: null,
- last: {},
- // save original pager size
- setSize: wo.pager_size,
- setPage: wo.pager_startPage
- }, c.pager );
-
- // Used by core appendCache; !undefined is always true
- p.removeRows = wo.pager_removeRows;
-
- // pager initializes multiple times before table has completed initialization
- if ( p.isInitializing ) { return; }
-
- p.isInitializing = true;
- if ( ts.debug(c, 'pager') ) {
- console.log( 'Pager >> Initializing' );
- }
-
- p.size = $.data( table, 'pagerLastSize' ) || wo.pager_size;
- // added in case the pager is reinitialized after being destroyed.
- p.$container = $( s.container ).addClass( wo.pager_css.container ).show();
- p.totalRows = c.$tbodies.eq( 0 )
- .children( 'tr' )
- .not( wo.pager_countChildRows ? '' : '.' + c.cssChildRow )
- .length;
- p.oldAjaxSuccess = p.oldAjaxSuccess || wo.pager_ajaxObject.success;
- c.appender = tsp.appender;
- p.initializing = true;
- if ( wo.pager_savePages && ts.storage ) {
- t = ts.storage( table, wo.pager_storageKey ) || {}; // fixes #387
- p.page = ( isNaN( t.page ) ? p.page : t.page ) || p.setPage || 0;
- p.size = t.size === 'all' ? t.size : ( isNaN( t.size ) ? p.size : t.size ) || p.setSize || 10;
- tsp.setPageSize( c, p.size );
- }
-
- // skipped rows
- p.regexRows = new RegExp( '(' + ( wo.filter_filteredRow || 'filtered' ) + '|' +
- c.selectorRemove.slice( 1 ) + '|' + c.cssChildRow + ')' );
- p.regexFiltered = new RegExp( wo.filter_filteredRow || 'filtered' );
-
- // clear initialized flag
- p.initialized = false;
- // before initialization event
- c.$table.triggerHandler( 'pagerBeforeInitialized', c );
-
- tsp.enablePager( c, false );
-
- // p must have ajaxObject
- p.ajaxObject = wo.pager_ajaxObject;
- p.ajaxObject.url = wo.pager_ajaxUrl;
-
- if ( typeof wo.pager_ajaxUrl === 'string' ) {
- // ajax pager; interact with database
- p.ajax = true;
- // When filtering with ajax, allow only custom filtering function, disable default filtering
- // since it will be done server side.
- wo.filter_serversideFiltering = true;
- c.serverSideSorting = true;
- tsp.moveToPage( c, p );
- } else {
- p.ajax = false;
- // Regular pager; all rows stored in memory
- ts.appendCache( c, true ); // true = don't apply widgets
- }
-
- },
-
- initComplete: function( c ) {
- var p = c.pager;
- tsp.bindEvents( c );
- if ( !p.ajax ) {
- tsp.hideRowsSetup( c );
- }
-
- // pager initialized
- p.initialized = true;
- p.initializing = false;
- p.isInitializing = false;
- tsp.setPageSize( c, p.size ); // page size 0 is ignored
- if ( ts.debug(c, 'pager') ) {
- console.log( 'Pager >> Triggering pagerInitialized' );
- }
- c.$table.triggerHandler( 'pagerInitialized', c );
- // filter widget not initialized; it will update the output display & fire off the pagerComplete event
- if ( !( c.widgetOptions.filter_initialized && ts.hasWidget( c.table, 'filter' ) ) ) {
- // if ajax, then don't fire off pagerComplete
- tsp.updatePageDisplay( c, !p.ajax );
- }
- },
-
- bindEvents: function( c ) {
- var ctrls, fxn, tmp,
- p = c.pager,
- wo = c.widgetOptions,
- namespace = c.namespace + 'pager',
- s = wo.pager_selectors,
- debug = ts.debug(c, 'pager');
- c.$table
- .off( namespace )
- .on( 'filterInit filterStart '.split( ' ' ).join( namespace + ' ' ), function( e, filters ) {
- p.currentFilters = $.isArray( filters ) ? filters : c.$table.data( 'lastSearch' );
- var filtersEqual;
- if (p.ajax && e.type === 'filterInit') {
- // ensure pager ajax is called after filter widget has initialized
- return tsp.moveToPage( c, p, false );
- }
- if (ts.filter.equalFilters) {
- filtersEqual = ts.filter.equalFilters(c, c.lastSearch, p.currentFilters);
- } else {
- // will miss filter changes of the same value in a different column, see #1363
- filtersEqual = ( c.lastSearch || [] ).join( '' ) !== ( p.currentFilters || [] ).join( '' );
- }
- // don't change page if filters are the same (pager updating, etc)
- if ( e.type === 'filterStart' && wo.pager_pageReset !== false && !filtersEqual ) {
- p.page = wo.pager_pageReset; // fixes #456 & #565
- }
- })
- // update pager after filter widget completes
- .on( 'filterEnd sortEnd '.split( ' ' ).join( namespace + ' ' ), function() {
- p.currentFilters = c.$table.data( 'lastSearch' );
- if ( p.initialized || p.initializing ) {
- if ( c.delayInit && c.rowsCopy && c.rowsCopy.length === 0 ) {
- // make sure we have a copy of all table rows once the cache has been built
- tsp.updateCache( c );
- }
- tsp.updatePageDisplay( c, false );
- ts.applyWidget( c.table );
- }
- })
- .on( 'disablePager' + namespace, function( e ) {
- e.stopPropagation();
- tsp.showAllRows( c );
- })
- .on( 'enablePager' + namespace, function( e ) {
- e.stopPropagation();
- tsp.enablePager( c, true );
- })
- .on( 'destroyPager' + namespace, function( e ) {
- e.stopPropagation();
- // call removeWidget to make sure internal flags are modified.
- ts.removeWidget( c.table, 'pager', false );
- })
- .on( 'updateComplete' + namespace, function( e, table, triggered ) {
- e.stopPropagation();
- // table can be unintentionally undefined in tablesorter v2.17.7 and earlier
- // don't recalculate total rows/pages if using ajax
- if ( !table || triggered || p.ajax ) { return; }
- var $rows = c.$tbodies.eq( 0 ).children( 'tr' ).not( c.selectorRemove );
- p.totalRows = $rows.length -
- ( wo.pager_countChildRows ? 0 : $rows.filter( '.' + c.cssChildRow ).length );
- p.totalPages = p.size === 'all' ? 1 : Math.ceil( p.totalRows / p.size );
- if ( $rows.length && c.rowsCopy && c.rowsCopy.length === 0 ) {
- // make a copy of all table rows once the cache has been built
- tsp.updateCache( c );
- }
- if ( p.page >= p.totalPages ) {
- tsp.moveToLastPage( c, p );
- }
- tsp.hideRows( c );
- tsp.changeHeight( c );
- // update without triggering pagerComplete
- tsp.updatePageDisplay( c, false );
- // make sure widgets are applied - fixes #450
- ts.applyWidget( table );
- tsp.updatePageDisplay( c );
- })
- .on( 'pageSize refreshComplete '.split( ' ' ).join( namespace + ' ' ), function( e, size ) {
- e.stopPropagation();
- tsp.setPageSize( c, tsp.parsePageSize( c, size, 'get' ) );
- tsp.moveToPage( c, p, true );
- tsp.hideRows( c );
- tsp.updatePageDisplay( c, false );
- })
- .on( 'pageSet pagerUpdate '.split( ' ' ).join( namespace + ' ' ), function( e, num ) {
- e.stopPropagation();
- // force pager refresh
- if ( e.type === 'pagerUpdate' ) {
- num = typeof num === 'undefined' ? p.page + 1 : num;
- p.last.page = true;
- }
- p.page = ( parseInt( num, 10 ) || 1 ) - 1;
- tsp.moveToPage( c, p, true );
- tsp.updatePageDisplay( c, false );
- })
- .on( 'pageAndSize' + namespace, function( e, page, size ) {
- e.stopPropagation();
- p.page = ( parseInt(page, 10) || 1 ) - 1;
- tsp.setPageSize( c, tsp.parsePageSize( c, size, 'get' ) );
- tsp.moveToPage( c, p, true );
- tsp.hideRows( c );
- tsp.updatePageDisplay( c, false );
- });
-
- // clicked controls
- ctrls = [ s.first, s.prev, s.next, s.last ];
- fxn = [ 'moveToFirstPage', 'moveToPrevPage', 'moveToNextPage', 'moveToLastPage' ];
- if ( debug && !p.$container.length ) {
- console.warn( 'Pager >> "container" not found' );
- }
- p.$container.find( ctrls.join( ',' ) )
- .attr( 'tabindex', 0 )
- .off( 'click' + namespace )
- .on( 'click' + namespace, function( e ) {
- e.stopPropagation();
- var i,
- $c = $( this ),
- l = ctrls.length;
- if ( !$c.hasClass( wo.pager_css.disabled ) ) {
- for ( i = 0; i < l; i++ ) {
- if ( $c.is( ctrls[ i ] ) ) {
- tsp[ fxn[ i ] ]( c, p );
- break;
- }
- }
- }
- });
-
- tmp = p.$container.find( wo.pager_selectors.gotoPage );
- if ( tmp.length ) {
- tmp
- .off( 'change' + namespace )
- .on( 'change' + namespace, function() {
- p.page = $( this ).val() - 1;
- tsp.moveToPage( c, p, true );
- tsp.updatePageDisplay( c, false );
- });
- } else if ( debug ) {
- console.warn( 'Pager >> "goto" selector not found' );
- }
-
- tmp = p.$container.find( wo.pager_selectors.pageSize );
- if ( tmp.length ) {
- // setting an option as selected appears to cause issues with initial page size
- tmp.find( 'option' ).removeAttr( 'selected' );
- tmp
- .off( 'change' + namespace )
- .on( 'change' + namespace, function() {
- if ( !$( this ).hasClass( wo.pager_css.disabled ) ) {
- var size = $( this ).val();
- // in case there are more than one pager
- p.$container.find( wo.pager_selectors.pageSize ).val( size );
- tsp.setPageSize( c, size );
- tsp.moveToPage( c, p, true );
- tsp.changeHeight( c );
- }
- return false;
- });
- } else if ( debug ) {
- console.warn('Pager >> "size" selector not found');
- }
-
- },
-
- // hide arrows at extremes
- pagerArrows: function( c, disable ) {
- var p = c.pager,
- dis = !!disable,
- first = dis || p.page === 0,
- tp = tsp.getTotalPages( c, p ),
- last = dis || p.page === tp - 1 || tp === 0,
- wo = c.widgetOptions,
- s = wo.pager_selectors;
- if ( wo.pager_updateArrows ) {
- p.$container
- .find( s.first + ',' + s.prev )
- .toggleClass( wo.pager_css.disabled, first )
- .prop( 'aria-disabled', first );
- p.$container
- .find( s.next + ',' + s.last )
- .toggleClass( wo.pager_css.disabled, last )
- .prop( 'aria-disabled', last );
- }
- },
-
- calcFilters: function( c ) {
- var normalized, indx, len,
- wo = c.widgetOptions,
- p = c.pager,
- hasFilters = c.$table.hasClass( 'hasFilters' );
- if ( hasFilters && !p.ajax ) {
- if ( $.isEmptyObject( c.cache ) ) {
- // delayInit: true so nothing is in the cache
- p.filteredRows = p.totalRows = c.$tbodies.eq( 0 )
- .children( 'tr' )
- .not( wo.pager_countChildRows ? '' : '.' + c.cssChildRow )
- .length;
- } else {
- p.filteredRows = 0;
- normalized = c.cache[ 0 ].normalized;
- len = normalized.length;
- for ( indx = 0; indx < len; indx++ ) {
- p.filteredRows += p.regexRows.test( normalized[ indx ][ c.columns ].$row[ 0 ].className ) ? 0 : 1;
- }
- }
- } else if ( !hasFilters ) {
- p.filteredRows = p.totalRows;
- }
- },
-
- updatePageDisplay: function( c, completed ) {
- if ( c.pager && c.pager.initializing ) { return; }
- var s, t, $out, options, indx, len, output,
- table = c.table,
- wo = c.widgetOptions,
- p = c.pager,
- namespace = c.namespace + 'pager',
- sz = tsp.parsePageSize( c, p.size, 'get' ); // don't allow dividing by zero
- if ( sz === 'all' ) { sz = p.totalRows; }
- if ( wo.pager_countChildRows ) { t[ t.length ] = c.cssChildRow; }
- p.$container.find( wo.pager_selectors.pageSize + ',' + wo.pager_selectors.gotoPage )
- .removeClass( wo.pager_css.disabled )
- .removeAttr( 'disabled' )
- .prop( 'aria-disabled', 'false' );
- p.totalPages = Math.ceil( p.totalRows / sz ); // needed for 'pageSize' method
- c.totalRows = p.totalRows;
- tsp.parsePageNumber( c, p );
- tsp.calcFilters( c );
- c.filteredRows = p.filteredRows;
- p.filteredPages = Math.ceil( p.filteredRows / sz ) || 0;
- if ( tsp.getTotalPages( c, p ) >= 0 ) {
- t = ( sz * p.page > p.filteredRows ) && completed;
- p.page = t ? wo.pager_pageReset || 0 : p.page;
- p.startRow = t ? sz * p.page + 1 : ( p.filteredRows === 0 ? 0 : sz * p.page + 1 );
- p.endRow = Math.min( p.filteredRows, p.totalRows, sz * ( p.page + 1 ) );
- $out = p.$container.find( wo.pager_selectors.pageDisplay );
-
- // Output param can be callback for custom rendering or string
- if ( typeof wo.pager_output === 'function' ) {
- s = wo.pager_output( table, p );
- } else {
- output = $out
- // get output template from data-pager-output or data-pager-output-filtered
- .attr('data-pager-output' + (p.filteredRows < p.totalRows ? '-filtered' : '')) ||
- wo.pager_output;
- // form the output string (can now get a new output string from the server)
- s = ( p.ajaxData && p.ajaxData.output ? p.ajaxData.output || output : output )
- // {page} = one-based index; {page+#} = zero based index +/- value
- .replace( /\{page([\-+]\d+)?\}/gi, function( m, n ) {
- return p.totalPages ? p.page + ( n ? parseInt( n, 10 ) : 1 ) : 0;
- })
- // {totalPages}, {extra}, {extra:0} (array) or {extra : key} (object)
- .replace( /\{\w+(\s*:\s*\w+)?\}/gi, function( m ) {
- var len, indx,
- str = m.replace( /[{}\s]/g, '' ),
- extra = str.split( ':' ),
- data = p.ajaxData,
- // return zero for default page/row numbers
- deflt = /(rows?|pages?)$/i.test( str ) ? 0 : '';
- if ( /(startRow|page)/.test( extra[ 0 ] ) && extra[ 1 ] === 'input' ) {
- len = ( '' + ( extra[ 0 ] === 'page' ? p.totalPages : p.totalRows ) ).length;
- indx = extra[ 0 ] === 'page' ? p.page + 1 : p.startRow;
- return '<input type="text" class="ts-' + extra[ 0 ] +
- '" style="max-width:' + len + 'em" value="' + indx + '"/>';
- }
- return extra.length > 1 && data && data[ extra[ 0 ] ] ?
- data[ extra[ 0 ] ][ extra[ 1 ] ] :
- p[ str ] || ( data ? data[ str ] : deflt ) || deflt;
- });
- }
- if ( p.$container.find( wo.pager_selectors.gotoPage ).length ) {
- t = '';
- options = tsp.buildPageSelect( c, p );
- len = options.length;
- for ( indx = 0; indx < len; indx++ ) {
- t += '<option value="' + options[ indx ] + '">' + options[ indx ] + '</option>';
- }
- // innerHTML doesn't work in IE9 - http://support2.microsoft.com/kb/276228
- p.$container.find( wo.pager_selectors.gotoPage ).html( t ).val( p.page + 1 );
- }
- if ( $out.length ) {
- $out[ ($out[ 0 ].nodeName === 'INPUT' ) ? 'val' : 'html' ]( s );
- // rebind startRow/page inputs
- $out
- .find( '.ts-startRow, .ts-page' )
- .off( 'change' + namespace )
- .on( 'change' + namespace, function() {
- var v = $( this ).val(),
- pg = $( this ).hasClass( 'ts-startRow' ) ? Math.floor( v / sz ) + 1 : v;
- c.$table.triggerHandler( 'pageSet' + namespace, [ pg ] );
- });
- }
- }
- tsp.pagerArrows( c );
- tsp.fixHeight( c );
- if ( p.initialized && completed !== false ) {
- if ( ts.debug(c, 'pager') ) {
- console.log( 'Pager >> Triggering pagerComplete' );
- }
- c.$table.triggerHandler( 'pagerComplete', c );
- // save pager info to storage
- if ( wo.pager_savePages && ts.storage ) {
- ts.storage( table, wo.pager_storageKey, {
- page : p.page,
- size : sz === p.totalRows ? 'all' : sz
- });
- }
- }
- },
-
- buildPageSelect: function( c, p ) {
- // Filter the options page number link array if it's larger than 'pager_maxOptionSize'
- // as large page set links will slow the browser on large dom inserts
- var i, centralFocusSize, focusOptionPages, insertIndex, optionLength, focusLength,
- wo = c.widgetOptions,
- pg = tsp.getTotalPages( c, p ) || 1,
- // make skip set size multiples of 5
- skipSetSize = Math.ceil( ( pg / wo.pager_maxOptionSize ) / 5 ) * 5,
- largeCollection = pg > wo.pager_maxOptionSize,
- currentPage = p.page + 1,
- startPage = skipSetSize,
- endPage = pg - skipSetSize,
- optionPages = [ 1 ],
- // construct default options pages array
- optionPagesStartPage = largeCollection ? skipSetSize : 1;
-
- for ( i = optionPagesStartPage; i <= pg; ) {
- optionPages[ optionPages.length ] = i;
- i = i + ( largeCollection ? skipSetSize : 1 );
- }
- optionPages[ optionPages.length ] = pg;
-
- if ( largeCollection ) {
- focusOptionPages = [];
- // don't allow central focus size to be > 5 on either side of current page
- centralFocusSize = Math.max( Math.floor( wo.pager_maxOptionSize / skipSetSize ) - 1, 5 );
-
- startPage = currentPage - centralFocusSize;
- if ( startPage < 1 ) { startPage = 1; }
- endPage = currentPage + centralFocusSize;
- if ( endPage > pg ) { endPage = pg; }
- // construct an array to get a focus set around the current page
- for ( i = startPage; i <= endPage ; i++ ) {
- focusOptionPages[ focusOptionPages.length ] = i;
- }
-
- // keep unique values
- optionPages = $.grep( optionPages, function( value, indx ) {
- return $.inArray( value, optionPages ) === indx;
- });
-
- optionLength = optionPages.length;
- focusLength = focusOptionPages.length;
-
- // make sure at all optionPages aren't replaced
- if ( optionLength - focusLength > skipSetSize / 2 && optionLength + focusLength > wo.pager_maxOptionSize ) {
- insertIndex = Math.floor( optionLength / 2 ) - Math.floor( focusLength / 2 );
- Array.prototype.splice.apply( optionPages, [ insertIndex, focusLength ] );
- }
- optionPages = optionPages.concat( focusOptionPages );
-
- }
-
- // keep unique values again
- optionPages = $.grep( optionPages, function( value, indx ) {
- return $.inArray( value, optionPages ) === indx;
- })
- .sort( function( a, b ) {
- return a - b;
- });
-
- return optionPages;
- },
-
- fixHeight: function( c ) {
- var d, h, bs,
- table = c.table,
- p = c.pager,
- wo = c.widgetOptions,
- $b = c.$tbodies.eq( 0 );
- $b.find( 'tr.pagerSavedHeightSpacer' ).remove();
- if ( wo.pager_fixedHeight && !p.isDisabled ) {
- h = $.data( table, 'pagerSavedHeight' );
- if ( h ) {
- bs = 0;
- if ( $(table).css('border-spacing').split(' ').length > 1 ) {
- bs = $(table).css('border-spacing').split(' ')[1].replace( /[^-\d\.]/g, '' );
- }
- d = h - $b.height() + (bs * p.size) - bs;
- if (
- d > 5 && $.data( table, 'pagerLastSize' ) === p.size &&
- $b.children( 'tr:visible' ).length < ( p.size === 'all' ? p.totalRows : p.size )
- ) {
- $b.append( '<tr class="pagerSavedHeightSpacer ' + c.selectorRemove.slice( 1 ) +
- '" style="height:' + d + 'px;"></tr>' );
- }
- }
- }
- },
-
- changeHeight: function( c ) {
- var h,
- table = c.table,
- p = c.pager,
- sz = p.size === 'all' ? p.totalRows : p.size,
- $b = c.$tbodies.eq( 0 );
- $b.find( 'tr.pagerSavedHeightSpacer' ).remove();
- if ( !$b.children( 'tr:visible' ).length ) {
- $b.append( '<tr class="pagerSavedHeightSpacer ' + c.selectorRemove.slice( 1 ) + '"><td>&nbsp</td></tr>' );
- }
- h = $b.children( 'tr' ).eq( 0 ).height() * sz;
- $.data( table, 'pagerSavedHeight', h );
- tsp.fixHeight( c );
- $.data( table, 'pagerLastSize', p.size );
- },
-
- hideRows: function( c ) {
- if ( !c.widgetOptions.pager_ajaxUrl ) {
- var tbodyIndex, rowIndex, $rows, len, lastIndex,
- p = c.pager,
- wo = c.widgetOptions,
- tbodyLen = c.$tbodies.length,
- sz = p.size === 'all' ? p.totalRows : p.size,
- start = ( p.page * sz ),
- end = start + sz,
- last = 0, // for cache indexing
- size = 0; // size counter
- p.cacheIndex = [];
- for ( tbodyIndex = 0; tbodyIndex < tbodyLen; tbodyIndex++ ) {
- $rows = c.$tbodies.eq( tbodyIndex ).children( 'tr' );
- len = $rows.length;
- lastIndex = 0;
- last = 0; // for cache indexing
- size = 0; // size counter
- for ( rowIndex = 0; rowIndex < len; rowIndex++ ) {
- if ( !p.regexFiltered.test( $rows[ rowIndex ].className ) ) {
- if ( size === start && $rows[ rowIndex ].className.match( c.cssChildRow ) ) {
- // hide child rows @ start of pager (if already visible)
- $rows[ rowIndex ].style.display = 'none';
- } else {
- $rows[ rowIndex ].style.display = ( size >= start && size < end ) ? '' : 'none';
- if ( last !== size && size >= start && size < end ) {
- p.cacheIndex[ p.cacheIndex.length ] = rowIndex;
- last = size;
- }
- // don't count child rows
- size += $rows[ rowIndex ].className
- .match( c.cssChildRow + '|' + c.selectorRemove.slice( 1 ) ) && !wo.pager_countChildRows ? 0 : 1;
- if ( size === end && $rows[ rowIndex ].style.display !== 'none' &&
- $rows[ rowIndex ].className.match( ts.css.cssHasChild ) ) {
- lastIndex = rowIndex;
- }
- }
- }
- }
- // add any attached child rows to last row of pager. Fixes part of issue #396
- if ( lastIndex > 0 && $rows[ lastIndex ].className.match( ts.css.cssHasChild ) ) {
- while ( ++lastIndex < len && $rows[ lastIndex ].className.match( c.cssChildRow ) ) {
- $rows[ lastIndex ].style.display = '';
- }
- }
- }
- }
- },
-
- hideRowsSetup: function( c ) {
- var p = c.pager,
- namespace = c.namespace + 'pager',
- $el = p.$container.find( c.widgetOptions.pager_selectors.pageSize ),
- size = $el.val();
- p.size = tsp.parsePageSize( c, size, 'get' );
- tsp.setPageSize( c, p.size );
- tsp.pagerArrows( c );
- if ( !c.widgetOptions.pager_removeRows ) {
- tsp.hideRows( c );
- c.$table.on( 'sortEnd filterEnd '.split( ' ' ).join( namespace + ' ' ), function() {
- tsp.hideRows( c );
- });
- }
- },
-
- renderAjax: function( data, c, xhr, settings, exception ) {
- var table = c.table,
- p = c.pager,
- wo = c.widgetOptions,
- debug = ts.debug(c, 'pager');
- // process data
- if ( $.isFunction( wo.pager_ajaxProcessing ) ) {
-
- // in case nothing is returned by ajax, empty out the table; see #1032
- // but do it before calling pager_ajaxProcessing because that function may add content
- // directly to the table
- c.$tbodies.eq( 0 ).empty();
-
- // ajaxProcessing result: [ total, rows, headers ]
- var i, j, t, hsh, $f, $sh, $headers, $h, icon, th, d, l, rr_count, len, sz,
- $table = c.$table,
- tds = '',
- result = wo.pager_ajaxProcessing( data, table, xhr ) || [ 0, [] ];
-
- // Clean up any previous error.
- ts.showError( table );
-
- if ( exception ) {
- if ( debug ) {
- console.error( 'Pager >> Ajax Error', xhr, settings, exception );
- }
- ts.showError( table, xhr, settings, exception );
- c.$tbodies.eq( 0 ).children( 'tr' ).detach();
- p.totalRows = 0;
- } else {
- // process ajax object
- if ( !$.isArray( result ) ) {
- p.ajaxData = result;
- c.totalRows = p.totalRows = result.total;
- c.filteredRows = p.filteredRows = typeof result.filteredRows !== 'undefined' ?
- result.filteredRows :
- result.total;
- th = result.headers;
- d = result.rows || [];
- } else {
- // allow [ total, rows, headers ] or [ rows, total, headers ]
- t = isNaN( result[ 0 ] ) && !isNaN( result[ 1 ] );
- // ensure a zero returned row count doesn't fail the logical ||
- rr_count = result[ t ? 1 : 0 ];
- p.totalRows = isNaN( rr_count ) ? p.totalRows || 0 : rr_count;
- // can't set filtered rows when returning an array
- c.totalRows = c.filteredRows = p.filteredRows = p.totalRows;
- // set row data to empty array if nothing found - see http://stackoverflow.com/q/30875583/145346
- d = p.totalRows === 0 ? [] : result[ t ? 0 : 1 ] || []; // row data
- th = result[ 2 ]; // headers
- }
- l = d && d.length;
- if ( d instanceof $ ) {
- if ( wo.pager_processAjaxOnInit ) {
- // append jQuery object
- c.$tbodies.eq( 0 ).empty();
- c.$tbodies.eq( 0 ).append( d );
- }
- } else if ( l ) {
- // build table from array
- for ( i = 0; i < l; i++ ) {
- tds += '<tr>';
- for ( j = 0; j < d[i].length; j++ ) {
- // build tbody cells; watch for data containing HTML markup - see #434
- tds += /^\s*<td/.test( d[ i ][ j ] ) ? $.trim( d[ i ][ j ] ) : '<td>' + d[ i ][ j ] + '</td>';
- }
- tds += '</tr>';
- }
- // add rows to first tbody
- if ( wo.pager_processAjaxOnInit ) {
- c.$tbodies.eq( 0 ).html( tds );
- }
- }
- wo.pager_processAjaxOnInit = true;
- // update new header text
- if ( th ) {
- hsh = $table.hasClass( 'hasStickyHeaders' );
- $sh = hsh ?
- wo.$sticky.children( 'thead:first' ).children( 'tr:not(.' + c.cssIgnoreRow + ')' ).children() :
- '';
- $f = $table.find( 'tfoot tr:first' ).children();
- // don't change td headers (may contain pager)
- $headers = c.$headers.filter( 'th' );
- len = $headers.length;
- for ( j = 0; j < len; j++ ) {
- $h = $headers.eq( j );
- // add new test within the first span it finds, or just in the header
- if ( $h.find( '.' + ts.css.icon ).length ) {
- icon = $h.find( '.' + ts.css.icon ).clone( true );
- $h.find( '.' + ts.css.headerIn ).html( th[ j ] ).append( icon );
- if ( hsh && $sh.length ) {
- icon = $sh.eq( j ).find( '.' + ts.css.icon ).clone( true );
- $sh.eq( j ).find( '.' + ts.css.headerIn ).html( th[ j ] ).append( icon );
- }
- } else {
- $h.find( '.' + ts.css.headerIn ).html( th[ j ] );
- if ( hsh && $sh.length ) {
- // add sticky header to container just in case it contains pager controls
- p.$container = p.$container.add( wo.$sticky );
- $sh.eq( j ).find( '.' + ts.css.headerIn ).html( th[ j ] );
- }
- }
- $f.eq( j ).html( th[ j ] );
- }
- if ( hsh ) {
- tsp.bindEvents( c );
- }
- }
- }
- if ( c.showProcessing ) {
- ts.isProcessing( table ); // remove loading icon
- }
- sz = tsp.parsePageSize( c, p.size, 'get' );
- // make sure last pager settings are saved, prevents multiple server side calls with
- // the same parameters
- p.totalPages = sz === 'all' ? 1 : Math.ceil( p.totalRows / sz );
- p.last.totalRows = p.totalRows;
- p.last.currentFilters = p.currentFilters;
- p.last.sortList = ( c.sortList || [] ).join( ',' );
- p.initializing = false;
- // update display without triggering pager complete... before updating cache
- tsp.updatePageDisplay( c, false );
- // tablesorter core updateCache (not pager)
- ts.updateCache( c, function() {
- if ( p.initialized ) {
- // apply widgets after table has rendered & after a delay to prevent
- // multiple applyWidget blocking code from blocking this trigger
- setTimeout( function() {
- if ( debug ) {
- console.log( 'Pager >> Triggering pagerChange' );
- }
- $table.triggerHandler( 'pagerChange', p );
- ts.applyWidget( table );
- tsp.updatePageDisplay( c );
- }, 0 );
- }
- });
- }
- if ( !p.initialized ) {
- ts.applyWidget( table );
- }
- },
-
- getAjax: function( c ) {
- var counter,
- url = tsp.getAjaxUrl( c ),
- $doc = $( document ),
- namespace = c.namespace + 'pager',
- p = c.pager;
- if ( url !== '' ) {
- if ( c.showProcessing ) {
- ts.isProcessing( c.table, true ); // show loading icon
- }
- $doc.on( 'ajaxError' + namespace, function( e, xhr, settings, exception ) {
- tsp.renderAjax( null, c, xhr, settings, exception );
- $doc.off( 'ajaxError' + namespace );
- });
- counter = ++p.ajaxCounter;
- p.last.ajaxUrl = url; // remember processed url
- p.ajaxObject.url = url; // from the ajaxUrl option and modified by customAjaxUrl
- p.ajaxObject.success = function( data, status, jqxhr ) {
- // Refuse to process old ajax commands that were overwritten by new ones - see #443
- if ( counter < p.ajaxCounter ) {
- return;
- }
- tsp.renderAjax( data, c, jqxhr );
- $doc.off( 'ajaxError' + namespace );
- if ( typeof p.oldAjaxSuccess === 'function' ) {
- p.oldAjaxSuccess( data );
- }
- };
- if ( ts.debug(c, 'pager') ) {
- console.log( 'Pager >> Ajax initialized', p.ajaxObject );
- }
- $.ajax( p.ajaxObject );
- }
- },
-
- getAjaxUrl: function( c ) {
- var indx, len,
- p = c.pager,
- wo = c.widgetOptions,
- url = wo.pager_ajaxUrl ? wo.pager_ajaxUrl
- // allow using '{page+1}' in the url string to switch to a non-zero based index
- .replace( /\{page([\-+]\d+)?\}/, function( s, n ) { return p.page + ( n ? parseInt( n, 10 ) : 0 ); })
- // this will pass "all" to server when size is set to "all"
- .replace( /\{size\}/g, p.size ) : '',
- sortList = c.sortList,
- filterList = p.currentFilters || c.$table.data( 'lastSearch' ) || [],
- sortCol = url.match( /\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/ ),
- filterCol = url.match( /\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/ ),
- arry = [];
- if ( sortCol ) {
- sortCol = sortCol[ 1 ];
- len = sortList.length;
- for ( indx = 0; indx < len; indx++ ) {
- arry[ arry.length ] = sortCol + '[' + sortList[ indx ][ 0 ] + ']=' + sortList[ indx ][ 1 ];
- }
- // if the arry is empty, just add the col parameter... '&{sortList:col}' becomes '&col'
- url = url.replace( /\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g, arry.length ? arry.join( '&' ) : sortCol );
- arry = [];
- }
- if ( filterCol ) {
- filterCol = filterCol[ 1 ];
- len = filterList.length;
- for ( indx = 0; indx < len; indx++ ) {
- if ( filterList[ indx ] ) {
- arry[ arry.length ] = filterCol + '[' + indx + ']=' + encodeURIComponent( filterList[ indx ] );
- }
- }
- // if the arry is empty, just add the fcol parameter... '&{filterList:fcol}' becomes '&fcol'
- url = url.replace( /\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/g, arry.length ? arry.join( '&' ) : filterCol );
- p.currentFilters = filterList;
- }
- if ( $.isFunction( wo.pager_customAjaxUrl ) ) {
- url = wo.pager_customAjaxUrl( c.table, url );
- }
- if ( ts.debug(c, 'pager') ) {
- console.log( 'Pager >> Ajax url = ' + url );
- }
- return url;
- },
-
- renderTable: function( c, rows ) {
- var $tb, index, count, added,
- table = c.table,
- p = c.pager,
- wo = c.widgetOptions,
- debug = ts.debug(c, 'pager'),
- f = c.$table.hasClass('hasFilters'),
- l = rows && rows.length || 0, // rows may be undefined
- e = p.size === 'all' ? p.totalRows : p.size,
- s = ( p.page * e );
- if ( l < 1 ) {
- if ( debug ) {
- console.warn( 'Pager >> No rows for pager to render' );
- }
- // empty table, abort!
- return;
- }
- if ( p.page >= p.totalPages ) {
- // lets not render the table more than once
- return tsp.moveToLastPage( c, p );
- }
- p.cacheIndex = [];
- p.isDisabled = false; // needed because sorting will change the page and re-enable the pager
- if ( p.initialized ) {
- if ( debug ) {
- console.log( 'Pager >> Triggering pagerChange' );
- }
- c.$table.triggerHandler( 'pagerChange', c );
- }
- if ( !wo.pager_removeRows ) {
- tsp.hideRows( c );
- } else {
- ts.clearTableBody( table );
- $tb = ts.processTbody( table, c.$tbodies.eq(0), true );
- // not filtered, start from the calculated starting point (s)
- // if filtered, start from zero
- index = f ? 0 : s;
- count = f ? 0 : s;
- added = 0;
- while ( added < e && index < rows.length ) {
- if ( !f || !p.regexFiltered.test( rows[ index ][ 0 ].className ) ) {
- count++;
- if ( count > s && added <= e ) {
- added++;
- p.cacheIndex[ p.cacheIndex.length ] = index;
- $tb.append( rows[ index ] );
- }
- }
- index++;
- }
- ts.processTbody( table, $tb, false );
- }
- tsp.updatePageDisplay( c );
-
- wo.pager_startPage = p.page;
- wo.pager_size = p.size;
- if ( table.isUpdating ) {
- if ( debug ) {
- console.log( 'Pager >> Triggering updateComplete' );
- }
- c.$table.triggerHandler( 'updateComplete', [ table, true ] );
- }
-
- },
-
- showAllRows: function( c ) {
- var index, $controls, len,
- table = c.table,
- p = c.pager,
- wo = c.widgetOptions;
- if ( p.ajax ) {
- tsp.pagerArrows( c, true );
- } else {
- $.data( table, 'pagerLastPage', p.page );
- $.data( table, 'pagerLastSize', p.size );
- p.page = 0;
- p.size = p.totalRows;
- p.totalPages = 1;
- c.$table
- .addClass( 'pagerDisabled' )
- .removeAttr( 'aria-describedby' )
- .find( 'tr.pagerSavedHeightSpacer' )
- .remove();
- tsp.renderTable( c, c.rowsCopy );
- p.isDisabled = true;
- ts.applyWidget( table );
- if ( ts.debug(c, 'pager') ) {
- console.log( 'Pager >> Disabled' );
- }
- }
- // disable size selector
- $controls = p.$container.find(
- wo.pager_selectors.pageSize + ',' +
- wo.pager_selectors.gotoPage + ',' +
- '.ts-startRow, .ts-page'
- );
- len = $controls.length;
- for ( index = 0; index < len; index++ ) {
- $controls.eq( index )
- .prop( 'aria-disabled', 'true' )
- .addClass( wo.pager_css.disabled )[ 0 ].disabled = true;
- }
- },
-
- // updateCache if delayInit: true
- // this is normally done by 'appendToTable' function in the tablesorter core AFTER a sort
- updateCache: function( c ) {
- var p = c.pager;
- // tablesorter core updateCache (not pager)
- ts.updateCache( c, function() {
- if ( !$.isEmptyObject( c.cache ) ) {
- var index,
- rows = [],
- normalized = c.cache[ 0 ].normalized;
- p.totalRows = normalized.length;
- for ( index = 0; index < p.totalRows; index++ ) {
- rows[ rows.length ] = normalized[ index ][ c.columns ].$row;
- }
- c.rowsCopy = rows;
- tsp.moveToPage( c, p, true );
- // clear out last search to force an update
- p.last.currentFilters = [ ' ' ];
- }
- });
- },
-
- moveToPage: function( c, p, pageMoved ) {
- if ( p.isDisabled ) { return; }
- if ( pageMoved !== false && p.initialized && $.isEmptyObject( c.cache ) ) {
- return tsp.updateCache( c );
- }
- var tmp,
- table = c.table,
- wo = c.widgetOptions,
- l = p.last,
- debug = ts.debug(c, 'pager');
-
- // abort page move if the table has filters and has not been initialized
- if ( p.ajax && !wo.filter_initialized && ts.hasWidget( table, 'filter' ) ) { return; }
-
- tsp.parsePageNumber( c, p );
- tsp.calcFilters( c );
- // fixes issue where one current filter is [] and the other is [ '', '', '' ],
- // making the next if comparison think the filters as different. Fixes #202.
- l.currentFilters = ( l.currentFilters || [] ).join( '' ) === '' ? [] : l.currentFilters;
- p.currentFilters = ( p.currentFilters || [] ).join( '' ) === '' ? [] : p.currentFilters;
- // don't allow rendering multiple times on the same page/size/totalRows/filters/sorts
- if ( l.page === p.page && l.size === p.size && l.totalRows === p.totalRows &&
- ( l.currentFilters || [] ).join( ',' ) === ( p.currentFilters || [] ).join( ',' ) &&
- // check for ajax url changes see #730
- ( l.ajaxUrl || '' ) === ( p.ajaxObject.url || '' ) &&
- // & ajax url option changes (dynamically add/remove/rename sort & filter parameters)
- ( l.optAjaxUrl || '' ) === ( wo.pager_ajaxUrl || '' ) &&
- l.sortList === ( c.sortList || [] ).join( ',' ) ) {
- return;
- }
- if ( debug ) {
- console.log( 'Pager >> Changing to page ' + p.page );
- }
- p.last = {
- page: p.page,
- size: p.size,
- // fixes #408; modify sortList otherwise it auto-updates
- sortList: ( c.sortList || [] ).join( ',' ),
- totalRows: p.totalRows,
- currentFilters: p.currentFilters || [],
- ajaxUrl: p.ajaxObject.url || '',
- optAjaxUrl: wo.pager_ajaxUrl
- };
- if ( p.ajax ) {
- if ( !wo.pager_processAjaxOnInit && !$.isEmptyObject(wo.pager_initialRows) ) {
- wo.pager_processAjaxOnInit = true;
- tmp = wo.pager_initialRows;
- p.totalRows = typeof tmp.total !== 'undefined' ? tmp.total :
- ( debug ? console.error('Pager >> No initial total page set!') || 0 : 0 );
- p.filteredRows = typeof tmp.filtered !== 'undefined' ? tmp.filtered :
- ( debug ? console.error('Pager >> No initial filtered page set!') || 0 : 0 );
- tsp.updatePageDisplay( c, false );
- } else {
- tsp.getAjax( c );
- }
- } else if ( !p.ajax ) {
- tsp.renderTable( c, c.rowsCopy );
- }
- $.data( table, 'pagerLastPage', p.page );
- if ( p.initialized && pageMoved !== false ) {
- if ( debug ) {
- console.log( 'Pager >> Triggering pageMoved' );
- }
- c.$table.triggerHandler( 'pageMoved', c );
- ts.applyWidget( table );
- if ( !p.ajax && table.isUpdating ) {
- if ( debug ) {
- console.log( 'Pager >> Triggering updateComplete' );
- }
- c.$table.triggerHandler( 'updateComplete', [ table, true ] );
- }
- }
- },
-
- getTotalPages: function( c, p ) {
- return ts.hasWidget( c.table, 'filter' ) ?
- Math.min( p.totalPages, p.filteredPages ) :
- p.totalPages;
- },
-
- parsePageNumber: function( c, p ) {
- var min = tsp.getTotalPages( c, p ) - 1;
- p.page = parseInt( p.page, 10 );
- if ( p.page < 0 || isNaN( p.page ) ) { p.page = 0; }
- if ( p.page > min && min >= 0 ) { p.page = min; }
- return p.page;
- },
-
- // set to either set or get value
- parsePageSize: function( c, size, mode ) {
- var p = c.pager,
- wo = c.widgetOptions,
- s = parseInt( size, 10 ) || p.size || wo.pager_size || 10;
- if (p.initialized && (/all/i.test( s + ' ' + size ) || s === p.totalRows)) {
- // Fixing #1364 & #1366
- return p.$container.find( wo.pager_selectors.pageSize + ' option[value="all"]').length ?
- 'all' : p.totalRows;
- }
- // "get" to set `p.size` or "set" to set `pageSize.val()`
- return mode === 'get' ? s : p.size;
- },
-
- setPageSize: function( c, size ) {
- var p = c.pager,
- table = c.table;
- // "all" size is only returned if an "all" option exists - fixes #1366
- p.size = tsp.parsePageSize( c, size, 'get' );
- p.$container
- .find( c.widgetOptions.pager_selectors.pageSize )
- .val( p.size );
- $.data( table, 'pagerLastPage', tsp.parsePageNumber( c, p ) );
- $.data( table, 'pagerLastSize', p.size );
- p.totalPages = p.size === 'all' ? 1 : Math.ceil( p.totalRows / p.size );
- p.filteredPages = p.size === 'all' ? 1 : Math.ceil( p.filteredRows / p.size );
- },
-
- moveToFirstPage: function( c, p ) {
- p.page = 0;
- tsp.moveToPage( c, p, true );
- },
-
- moveToLastPage: function( c, p ) {
- p.page = tsp.getTotalPages( c, p ) - 1;
- tsp.moveToPage( c, p, true );
- },
-
- moveToNextPage: function( c, p ) {
- p.page++;
- var last = tsp.getTotalPages( c, p ) - 1;
- if ( p.page >= last ) {
- p.page = last;
- }
- tsp.moveToPage( c, p, true );
- },
-
- moveToPrevPage: function( c, p ) {
- p.page--;
- if ( p.page <= 0 ) {
- p.page = 0;
- }
- tsp.moveToPage( c, p, true );
- },
-
- destroyPager: function( c, refreshing ) {
- var table = c.table,
- p = c.pager,
- s = c.widgetOptions.pager_selectors || {},
- ctrls = [ s.first, s.prev, s.next, s.last, s.gotoPage, s.pageSize ].join( ',' ),
- namespace = c.namespace + 'pager';
- // check pager object in case two successive pager destroys are triggered
- // e.g. "destroyPager" then "removeWidget" - see #1155
- if ( p ) {
- p.initialized = false;
- c.$table.off( namespace );
- p.$container
- // hide pager
- .hide()
- // unbind pager controls
- .find( ctrls )
- .off( namespace );
- if ( refreshing ) { return; }
- c.appender = null; // remove pager appender function
- tsp.showAllRows( c );
- if ( ts.storage ) {
- ts.storage( table, c.widgetOptions.pager_storageKey, '' );
- }
- p.$container = null;
- c.pager = null;
- c.rowsCopy = null;
- }
- },
-
- enablePager: function( c, triggered ) {
- var info, size,
- table = c.table,
- p = c.pager,
- wo = c.widgetOptions,
- $el = p.$container.find( wo.pager_selectors.pageSize );
- p.isDisabled = false;
- p.page = $.data( table, 'pagerLastPage' ) || p.page || 0;
- size = $el.find('option[selected]' ).val();
- p.size = $.data( table, 'pagerLastSize' ) || tsp.parsePageSize( c, size, 'get' );
- tsp.setPageSize( c, p.size ); // set page size
- p.totalPages = p.size === 'all' ? 1 : Math.ceil( tsp.getTotalPages( c, p ) / p.size );
- c.$table.removeClass( 'pagerDisabled' );
- // if table id exists, include page display with aria info
- if ( table.id && !c.$table.attr( 'aria-describedby' ) ) {
- $el = p.$container.find( wo.pager_selectors.pageDisplay );
- info = $el.attr( 'id' );
- if ( !info ) {
- // only add pageDisplay id if it doesn't exist - see #1288
- info = table.id + '_pager_info';
- $el.attr( 'id', info );
- }
- c.$table.attr( 'aria-describedby', info );
- }
- tsp.changeHeight( c );
- if ( triggered ) {
- // tablesorter core update table
- ts.update( c );
- tsp.setPageSize( c, p.size );
- tsp.moveToPage( c, p, true );
- tsp.hideRowsSetup( c );
- if ( ts.debug(c, 'pager') ) {
- console.log( 'Pager >> Enabled' );
- }
- }
- },
-
- appender: function( table, rows ) {
- var c = table.config,
- wo = c.widgetOptions,
- p = c.pager;
- if ( !p.ajax ) {
- c.rowsCopy = rows;
- p.totalRows = wo.pager_countChildRows ? c.$tbodies.eq( 0 ).children( 'tr' ).length : rows.length;
- p.size = $.data( table, 'pagerLastSize' ) || p.size || wo.pager_size || p.setSize || 10;
- p.totalPages = p.size === 'all' ? 1 : Math.ceil( p.totalRows / p.size );
- tsp.moveToPage( c, p );
- // update display here in case all rows are removed
- tsp.updatePageDisplay( c, false );
- } else {
- tsp.moveToPage( c, p, true );
- }
- }
-
- };
-
- // see #486
- ts.showError = function( table, xhr, settings, exception ) {
- var $table = $( table ),
- c = $table[ 0 ].config,
- wo = c && c.widgetOptions,
- errorRow = c.pager && c.pager.cssErrorRow ||
- wo && wo.pager_css && wo.pager_css.errorRow ||
- 'tablesorter-errorRow',
- typ = typeof xhr,
- valid = true,
- message = '',
- removeRow = function() {
- c.$table.find( 'thead' ).find( c.selectorRemove ).remove();
- };
-
- if ( !$table.length ) {
- console.error( 'tablesorter showError: no table parameter passed' );
- return;
- }
-
- // ajaxError callback for plugin or widget - see #992
- if ( typeof c.pager.ajaxError === 'function' ) {
- valid = c.pager.ajaxError( c, xhr, settings, exception );
- if ( valid === false ) {
- return removeRow();
- } else {
- message = valid;
- }
- } else if ( typeof wo.pager_ajaxError === 'function' ) {
- valid = wo.pager_ajaxError( c, xhr, settings, exception );
- if ( valid === false ) {
- return removeRow();
- } else {
- message = valid;
- }
- }
-
- if ( message === '' ) {
- if ( typ === 'object' ) {
- message =
- xhr.status === 0 ? 'Not connected, verify Network' :
- xhr.status === 404 ? 'Requested page not found [404]' :
- xhr.status === 500 ? 'Internal Server Error [500]' :
- exception === 'parsererror' ? 'Requested JSON parse failed' :
- exception === 'timeout' ? 'Time out error' :
- exception === 'abort' ? 'Ajax Request aborted' :
- 'Uncaught error: ' + xhr.statusText + ' [' + xhr.status + ']';
- } else if ( typ === 'string' ) {
- // keep backward compatibility (external usage just passes a message string)
- message = xhr;
- } else {
- // remove all error rows
- return removeRow();
- }
- }
-
- // allow message to include entire row HTML!
- $( /tr\>/.test( message ) ?
- message :
- '<tr><td colspan="' + c.columns + '">' + message + '</td></tr>'
- )
- .click( function() {
- $( this ).remove();
- })
- // add error row to thead instead of tbody, or clicking on the header will result in a parser error
- .appendTo( c.$table.find( 'thead:first' ) )
- .addClass( errorRow + ' ' + c.selectorRemove.slice( 1 ) )
- .attr({
- role: 'alert',
- 'aria-live': 'assertive'
- });
-
- };
-
-})(jQuery);
+!function(e){"use strict";var a,t=e.tablesorter;t.addWidget({id:"pager",priority:55,options:{pager_output:"{startRow} to {endRow} of {totalRows} rows",pager_updateArrows:!0,pager_startPage:0,pager_pageReset:0,pager_size:10,pager_maxOptionSize:20,pager_savePages:!0,pager_storageKey:"tablesorter-pager",pager_fixedHeight:!1,pager_countChildRows:!1,pager_removeRows:!1,pager_ajaxUrl:null,pager_customAjaxUrl:function(e,a){return a},pager_ajaxError:null,pager_ajaxObject:{dataType:"json"},pager_processAjaxOnInit:!0,pager_ajaxProcessing:function(e){return e},pager_css:{container:"tablesorter-pager",errorRow:"tablesorter-errorRow",disabled:"disabled"},pager_selectors:{container:".pager",first:".first",prev:".prev",next:".next",last:".last",gotoPage:".gotoPage",pageDisplay:".pagedisplay",pageSize:".pagesize"}},init:function(e){a.init(e)},format:function(e,t){if(!t.pager||!t.pager.initialized)return a.initComplete(t);a.moveToPage(t,t.pager,!1)},remove:function(e,t,r,i){a.destroyPager(t,i)}}),a=t.pager={init:function(r){if(!(r.hasInitialized&&r.config.pager&&r.config.pager.initialized)){var i,s=r.config,o=s.widgetOptions,g=o.pager_selectors,n=s.pager=e.extend({totalPages:0,filteredRows:0,filteredPages:0,currentFilters:[],page:o.pager_startPage,startRow:0,endRow:0,ajaxCounter:0,$size:null,last:{},setSize:o.pager_size,setPage:o.pager_startPage},s.pager);n.removeRows=o.pager_removeRows,n.isInitializing||(n.isInitializing=!0,t.debug(s,"pager")&&console.log("Pager >> Initializing"),n.size=e.data(r,"pagerLastSize")||o.pager_size,n.$container=e(g.container).addClass(o.pager_css.container).show(),n.totalRows=s.$tbodies.eq(0).children("tr").not(o.pager_countChildRows?"":"."+s.cssChildRow).length,n.oldAjaxSuccess=n.oldAjaxSuccess||o.pager_ajaxObject.success,s.appender=a.appender,n.initializing=!0,o.pager_savePages&&t.storage&&(i=t.storage(r,o.pager_storageKey)||{},n.page=(isNaN(i.page)?n.page:i.page)||n.setPage||0,n.size="all"===i.size?i.size:(isNaN(i.size)?n.size:i.size)||n.setSize||10,a.setPageSize(s,n.size)),n.regexRows=new RegExp("("+(o.filter_filteredRow||"filtered")+"|"+s.selectorRemove.slice(1)+"|"+s.cssChildRow+")"),n.regexFiltered=new RegExp(o.filter_filteredRow||"filtered"),n.initialized=!1,s.$table.triggerHandler("pagerBeforeInitialized",s),a.enablePager(s,!1),n.ajaxObject=o.pager_ajaxObject,n.ajaxObject.url=o.pager_ajaxUrl,"string"==typeof o.pager_ajaxUrl?(n.ajax=!0,o.filter_serversideFiltering=!0,s.serverSideSorting=!0,a.moveToPage(s,n)):(n.ajax=!1,t.appendCache(s,!0)))}},initComplete:function(e){var r=e.pager;a.bindEvents(e),r.ajax||a.hideRowsSetup(e),r.initialized=!0,r.initializing=!1,r.isInitializing=!1,a.setPageSize(e,r.size),t.debug(e,"pager")&&console.log("Pager >> Triggering pagerInitialized"),e.$table.triggerHandler("pagerInitialized",e),e.widgetOptions.filter_initialized&&t.hasWidget(e.table,"filter")||a.updatePageDisplay(e,!r.ajax)},bindEvents:function(r){var i,s,o,g=r.pager,n=r.widgetOptions,l=r.namespace+"pager",p=n.pager_selectors,d=t.debug(r,"pager");r.$table.off(l).on("filterInit filterStart ".split(" ").join(l+" "),function(i,s){var o;if(g.currentFilters=e.isArray(s)?s:r.$table.data("lastSearch"),g.ajax&&"filterInit"===i.type)return a.moveToPage(r,g,!1);o=t.filter.equalFilters?t.filter.equalFilters(r,r.lastSearch,g.currentFilters):(r.lastSearch||[]).join("")!==(g.currentFilters||[]).join(""),"filterStart"!==i.type||!1===n.pager_pageReset||o||(g.page=n.pager_pageReset)}).on("filterEnd sortEnd ".split(" ").join(l+" "),function(){g.currentFilters=r.$table.data("lastSearch"),(g.initialized||g.initializing)&&(r.delayInit&&r.rowsCopy&&0===r.rowsCopy.length&&a.updateCache(r),a.updatePageDisplay(r,!1),t.applyWidget(r.table))}).on("disablePager"+l,function(e){e.stopPropagation(),a.showAllRows(r)}).on("enablePager"+l,function(e){e.stopPropagation(),a.enablePager(r,!0)}).on("destroyPager"+l,function(e){e.stopPropagation(),t.removeWidget(r.table,"pager",!1)}).on("updateComplete"+l,function(e,i,s){if(e.stopPropagation(),i&&!s&&!g.ajax){var o=r.$tbodies.eq(0).children("tr").not(r.selectorRemove);g.totalRows=o.length-(n.pager_countChildRows?0:o.filter("."+r.cssChildRow).length),g.totalPages="all"===g.size?1:Math.ceil(g.totalRows/g.size),o.length&&r.rowsCopy&&0===r.rowsCopy.length&&a.updateCache(r),g.page>=g.totalPages&&a.moveToLastPage(r,g),a.hideRows(r),a.changeHeight(r),a.updatePageDisplay(r,!1),t.applyWidget(i),a.updatePageDisplay(r)}}).on("pageSize refreshComplete ".split(" ").join(l+" "),function(e,t){e.stopPropagation(),a.setPageSize(r,a.parsePageSize(r,t,"get")),a.moveToPage(r,g,!0),a.hideRows(r),a.updatePageDisplay(r,!1)}).on("pageSet pagerUpdate ".split(" ").join(l+" "),function(e,t){e.stopPropagation(),"pagerUpdate"===e.type&&(t=void 0===t?g.page+1:t,g.last.page=!0),g.page=(parseInt(t,10)||1)-1,a.moveToPage(r,g,!0),a.updatePageDisplay(r,!1)}).on("pageAndSize"+l,function(e,t,i){e.stopPropagation(),g.page=(parseInt(t,10)||1)-1,a.setPageSize(r,a.parsePageSize(r,i,"get")),a.moveToPage(r,g,!0),a.hideRows(r),a.updatePageDisplay(r,!1)}),i=[p.first,p.prev,p.next,p.last],s=["moveToFirstPage","moveToPrevPage","moveToNextPage","moveToLastPage"],d&&!g.$container.length&&console.warn('Pager >> "container" not found'),g.$container.find(i.join(",")).attr("tabindex",0).off("click"+l).on("click"+l,function(t){t.stopPropagation();var o,l=e(this),p=i.length;if(!l.hasClass(n.pager_css.disabled))for(o=0;o<p;o++)if(l.is(i[o])){a[s[o]](r,g);break}}),(o=g.$container.find(n.pager_selectors.gotoPage)).length?o.off("change"+l).on("change"+l,function(){g.page=e(this).val()-1,a.moveToPage(r,g,!0),a.updatePageDisplay(r,!1)}):d&&console.warn('Pager >> "goto" selector not found'),(o=g.$container.find(n.pager_selectors.pageSize)).length?(o.find("option").removeAttr("selected"),o.off("change"+l).on("change"+l,function(){if(!e(this).hasClass(n.pager_css.disabled)){var t=e(this).val();g.$container.find(n.pager_selectors.pageSize).val(t),a.setPageSize(r,t),a.moveToPage(r,g,!0),a.changeHeight(r)}return!1})):d&&console.warn('Pager >> "size" selector not found')},pagerArrows:function(e,t){var r=e.pager,i=!!t,s=i||0===r.page,o=a.getTotalPages(e,r),g=i||r.page===o-1||0===o,n=e.widgetOptions,l=n.pager_selectors;n.pager_updateArrows&&(r.$container.find(l.first+","+l.prev).toggleClass(n.pager_css.disabled,s).prop("aria-disabled",s),r.$container.find(l.next+","+l.last).toggleClass(n.pager_css.disabled,g).prop("aria-disabled",g))},calcFilters:function(a){var t,r,i,s=a.widgetOptions,o=a.pager,g=a.$table.hasClass("hasFilters");if(g&&!o.ajax)if(e.isEmptyObject(a.cache))o.filteredRows=o.totalRows=a.$tbodies.eq(0).children("tr").not(s.pager_countChildRows?"":"."+a.cssChildRow).length;else for(o.filteredRows=0,i=(t=a.cache[0].normalized).length,r=0;r<i;r++)o.filteredRows+=o.regexRows.test(t[r][a.columns].$row[0].className)?0:1;else g||(o.filteredRows=o.totalRows)},updatePageDisplay:function(r,i){if(!r.pager||!r.pager.initializing){var s,o,g,n,l,p,d,c=r.table,f=r.widgetOptions,u=r.pager,h=r.namespace+"pager",w=a.parsePageSize(r,u.size,"get");if("all"===w&&(w=u.totalRows),f.pager_countChildRows&&(o[o.length]=r.cssChildRow),u.$container.find(f.pager_selectors.pageSize+","+f.pager_selectors.gotoPage).removeClass(f.pager_css.disabled).removeAttr("disabled").prop("aria-disabled","false"),u.totalPages=Math.ceil(u.totalRows/w),r.totalRows=u.totalRows,a.parsePageNumber(r,u),a.calcFilters(r),r.filteredRows=u.filteredRows,u.filteredPages=Math.ceil(u.filteredRows/w)||0,a.getTotalPages(r,u)>=0){if(o=w*u.page>u.filteredRows&&i,u.page=o?f.pager_pageReset||0:u.page,u.startRow=o?w*u.page+1:0===u.filteredRows?0:w*u.page+1,u.endRow=Math.min(u.filteredRows,u.totalRows,w*(u.page+1)),g=u.$container.find(f.pager_selectors.pageDisplay),"function"==typeof f.pager_output?s=f.pager_output(c,u):(d=g.attr("data-pager-output"+(u.filteredRows<u.totalRows?"-filtered":""))||f.pager_output,s=(u.ajaxData&&u.ajaxData.output&&u.ajaxData.output||d).replace(/\{page([\-+]\d+)?\}/gi,function(e,a){return u.totalPages?u.page+(a?parseInt(a,10):1):0}).replace(/\{\w+(\s*:\s*\w+)?\}/gi,function(e){var a,t,r=e.replace(/[{}\s]/g,""),i=r.split(":"),s=u.ajaxData,o=/(rows?|pages?)$/i.test(r)?0:"";return/(startRow|page)/.test(i[0])&&"input"===i[1]?(a=(""+("page"===i[0]?u.totalPages:u.totalRows)).length,t="page"===i[0]?u.page+1:u.startRow,'<input type="text" class="ts-'+i[0]+'" style="max-width:'+a+'em" value="'+t+'"/>'):i.length>1&&s&&s[i[0]]?s[i[0]][i[1]]:u[r]||(s?s[r]:o)||o})),u.$container.find(f.pager_selectors.gotoPage).length){for(o="",p=(n=a.buildPageSelect(r,u)).length,l=0;l<p;l++)o+='<option value="'+n[l]+'">'+n[l]+"</option>";u.$container.find(f.pager_selectors.gotoPage).html(o).val(u.page+1)}g.length&&(g["INPUT"===g[0].nodeName?"val":"html"](s),g.find(".ts-startRow, .ts-page").off("change"+h).on("change"+h,function(){var a=e(this).val(),t=e(this).hasClass("ts-startRow")?Math.floor(a/w)+1:a;r.$table.triggerHandler("pageSet"+h,[t])}))}a.pagerArrows(r),a.fixHeight(r),u.initialized&&!1!==i&&(t.debug(r,"pager")&&console.log("Pager >> Triggering pagerComplete"),r.$table.triggerHandler("pagerComplete",r),f.pager_savePages&&t.storage&&t.storage(c,f.pager_storageKey,{page:u.page,size:w===u.totalRows?"all":w}))}},buildPageSelect:function(t,r){var i,s,o,g,n,l,p=t.widgetOptions,d=a.getTotalPages(t,r)||1,c=5*Math.ceil(d/p.pager_maxOptionSize/5),f=d>p.pager_maxOptionSize,u=r.page+1,h=c,w=d-c,P=[1];for(i=f?c:1;i<=d;)P[P.length]=i,i+=f?c:1;if(P[P.length]=d,f){for(o=[],(h=u-(s=Math.max(Math.floor(p.pager_maxOptionSize/c)-1,5)))<1&&(h=1),(w=u+s)>d&&(w=d),i=h;i<=w;i++)o[o.length]=i;(n=(P=e.grep(P,function(a,t){return e.inArray(a,P)===t})).length)-(l=o.length)>c/2&&n+l>p.pager_maxOptionSize&&(g=Math.floor(n/2)-Math.floor(l/2),Array.prototype.splice.apply(P,[g,l])),P=P.concat(o)}return P=e.grep(P,function(a,t){return e.inArray(a,P)===t}).sort(function(e,a){return e-a})},fixHeight:function(a){var t,r,i,s=a.table,o=a.pager,g=a.widgetOptions,n=a.$tbodies.eq(0);n.find("tr.pagerSavedHeightSpacer").remove(),g.pager_fixedHeight&&!o.isDisabled&&(r=e.data(s,"pagerSavedHeight"))&&(i=0,e(s).css("border-spacing").split(" ").length>1&&(i=e(s).css("border-spacing").split(" ")[1].replace(/[^-\d\.]/g,"")),(t=r-n.height()+i*o.size-i)>5&&e.data(s,"pagerLastSize")===o.size&&n.children("tr:visible").length<("all"===o.size?o.totalRows:o.size)&&n.append('<tr class="pagerSavedHeightSpacer '+a.selectorRemove.slice(1)+'" style="height:'+t+'px;"></tr>'))},changeHeight:function(t){var r,i=t.table,s=t.pager,o="all"===s.size?s.totalRows:s.size,g=t.$tbodies.eq(0);g.find("tr.pagerSavedHeightSpacer").remove(),g.children("tr:visible").length||g.append('<tr class="pagerSavedHeightSpacer '+t.selectorRemove.slice(1)+'"><td>&nbsp</td></tr>'),r=g.children("tr").eq(0).height()*o,e.data(i,"pagerSavedHeight",r),a.fixHeight(t),e.data(i,"pagerLastSize",s.size)},hideRows:function(e){if(!e.widgetOptions.pager_ajaxUrl){var a,r,i,s,o,g=e.pager,n=e.widgetOptions,l=e.$tbodies.length,p="all"===g.size?g.totalRows:g.size,d=g.page*p,c=d+p,f=0,u=0;for(g.cacheIndex=[],a=0;a<l;a++){for(s=(i=e.$tbodies.eq(a).children("tr")).length,o=0,f=0,u=0,r=0;r<s;r++)g.regexFiltered.test(i[r].className)||(u===d&&i[r].className.match(e.cssChildRow)?i[r].style.display="none":(i[r].style.display=u>=d&&u<c?"":"none",f!==u&&u>=d&&u<c&&(g.cacheIndex[g.cacheIndex.length]=r,f=u),(u+=i[r].className.match(e.cssChildRow+"|"+e.selectorRemove.slice(1))&&!n.pager_countChildRows?0:1)===c&&"none"!==i[r].style.display&&i[r].className.match(t.css.cssHasChild)&&(o=r)));if(o>0&&i[o].className.match(t.css.cssHasChild))for(;++o<s&&i[o].className.match(e.cssChildRow);)i[o].style.display=""}}},hideRowsSetup:function(e){var t=e.pager,r=e.namespace+"pager",i=t.$container.find(e.widgetOptions.pager_selectors.pageSize).val();t.size=a.parsePageSize(e,i,"get"),a.setPageSize(e,t.size),a.pagerArrows(e),e.widgetOptions.pager_removeRows||(a.hideRows(e),e.$table.on("sortEnd filterEnd ".split(" ").join(r+" "),function(){a.hideRows(e)}))},renderAjax:function(r,i,s,o,g){var n=i.table,l=i.pager,p=i.widgetOptions,d=t.debug(i,"pager");if(e.isFunction(p.pager_ajaxProcessing)){i.$tbodies.eq(0).empty();var c,f,u,h,w,P,b,z,R,v,m,x,j,_,y,S=i.$table,C="",$=p.pager_ajaxProcessing(r,n,s)||[0,[]];if(t.showError(n),g)d&&console.error("Pager >> Ajax Error",s,o,g),t.showError(n,s,o,g),i.$tbodies.eq(0).children("tr").detach(),l.totalRows=0;else{if(e.isArray($)?(j=$[(u=isNaN($[0])&&!isNaN($[1]))?1:0],l.totalRows=isNaN(j)?l.totalRows||0:j,i.totalRows=i.filteredRows=l.filteredRows=l.totalRows,m=0===l.totalRows?[]:$[u?0:1]||[],v=$[2]):(l.ajaxData=$,i.totalRows=l.totalRows=$.total,i.filteredRows=l.filteredRows=void 0!==$.filteredRows?$.filteredRows:$.total,v=$.headers,m=$.rows||[]),x=m&&m.length,m instanceof e)p.pager_processAjaxOnInit&&(i.$tbodies.eq(0).empty(),i.$tbodies.eq(0).append(m));else if(x){for(c=0;c<x;c++){for(C+="<tr>",f=0;f<m[c].length;f++)C+=/^\s*<td/.test(m[c][f])?e.trim(m[c][f]):"<td>"+m[c][f]+"</td>";C+="</tr>"}p.pager_processAjaxOnInit&&i.$tbodies.eq(0).html(C)}if(p.pager_processAjaxOnInit=!0,v){for(P=(h=S.hasClass("hasStickyHeaders"))?p.$sticky.children("thead:first").children("tr:not(."+i.cssIgnoreRow+")").children():"",w=S.find("tfoot tr:first").children(),_=(b=i.$headers.filter("th")).length,f=0;f<_;f++)(z=b.eq(f)).find("."+t.css.icon).length?(R=z.find("."+t.css.icon).clone(!0),z.find("."+t.css.headerIn).html(v[f]).append(R),h&&P.length&&(R=P.eq(f).find("."+t.css.icon).clone(!0),P.eq(f).find("."+t.css.headerIn).html(v[f]).append(R))):(z.find("."+t.css.headerIn).html(v[f]),h&&P.length&&(l.$container=l.$container.add(p.$sticky),P.eq(f).find("."+t.css.headerIn).html(v[f]))),w.eq(f).html(v[f]);h&&a.bindEvents(i)}}i.showProcessing&&t.isProcessing(n),y=a.parsePageSize(i,l.size,"get"),l.totalPages="all"===y?1:Math.ceil(l.totalRows/y),l.last.totalRows=l.totalRows,l.last.currentFilters=l.currentFilters,l.last.sortList=(i.sortList||[]).join(","),l.initializing=!1,a.updatePageDisplay(i,!1),t.updateCache(i,function(){l.initialized&&setTimeout(function(){d&&console.log("Pager >> Triggering pagerChange"),S.triggerHandler("pagerChange",l),t.applyWidget(n),a.updatePageDisplay(i)},0)})}l.initialized||t.applyWidget(n)},getAjax:function(r){var i,s=a.getAjaxUrl(r),o=e(document),g=r.namespace+"pager",n=r.pager;""!==s&&(r.showProcessing&&t.isProcessing(r.table,!0),o.on("ajaxError"+g,function(e,t,i,s){a.renderAjax(null,r,t,i,s),o.off("ajaxError"+g)}),i=++n.ajaxCounter,n.last.ajaxUrl=s,n.ajaxObject.url=s,n.ajaxObject.success=function(e,t,s){i<n.ajaxCounter||(a.renderAjax(e,r,s),o.off("ajaxError"+g),"function"==typeof n.oldAjaxSuccess&&n.oldAjaxSuccess(e))},t.debug(r,"pager")&&console.log("Pager >> Ajax initialized",n.ajaxObject),e.ajax(n.ajaxObject))},getAjaxUrl:function(a){var r,i,s=a.pager,o=a.widgetOptions,g=o.pager_ajaxUrl?o.pager_ajaxUrl.replace(/\{page([\-+]\d+)?\}/,function(e,a){return s.page+(a?parseInt(a,10):0)}).replace(/\{size\}/g,s.size):"",n=a.sortList,l=s.currentFilters||a.$table.data("lastSearch")||[],p=g.match(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/),d=g.match(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/),c=[];if(p){for(p=p[1],i=n.length,r=0;r<i;r++)c[c.length]=p+"["+n[r][0]+"]="+n[r][1];g=g.replace(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g,c.length?c.join("&"):p),c=[]}if(d){for(d=d[1],i=l.length,r=0;r<i;r++)l[r]&&(c[c.length]=d+"["+r+"]="+encodeURIComponent(l[r]));g=g.replace(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/g,c.length?c.join("&"):d),s.currentFilters=l}return e.isFunction(o.pager_customAjaxUrl)&&(g=o.pager_customAjaxUrl(a.table,g)),t.debug(a,"pager")&&console.log("Pager >> Ajax url = "+g),g},renderTable:function(e,r){var i,s,o,g,n=e.table,l=e.pager,p=e.widgetOptions,d=t.debug(e,"pager"),c=e.$table.hasClass("hasFilters"),f=r&&r.length||0,u="all"===l.size?l.totalRows:l.size,h=l.page*u;if(f<1)d&&console.warn("Pager >> No rows for pager to render");else{if(l.page>=l.totalPages)return a.moveToLastPage(e,l);if(l.cacheIndex=[],l.isDisabled=!1,l.initialized&&(d&&console.log("Pager >> Triggering pagerChange"),e.$table.triggerHandler("pagerChange",e)),p.pager_removeRows){for(t.clearTableBody(n),i=t.processTbody(n,e.$tbodies.eq(0),!0),s=c?0:h,o=c?0:h,g=0;g<u&&s<r.length;)c&&l.regexFiltered.test(r[s][0].className)||++o>h&&g<=u&&(g++,l.cacheIndex[l.cacheIndex.length]=s,i.append(r[s])),s++;t.processTbody(n,i,!1)}else a.hideRows(e);a.updatePageDisplay(e),p.pager_startPage=l.page,p.pager_size=l.size,n.isUpdating&&(d&&console.log("Pager >> Triggering updateComplete"),e.$table.triggerHandler("updateComplete",[n,!0]))}},showAllRows:function(r){var i,s,o,g=r.table,n=r.pager,l=r.widgetOptions;for(n.ajax?a.pagerArrows(r,!0):(e.data(g,"pagerLastPage",n.page),e.data(g,"pagerLastSize",n.size),n.page=0,n.size=n.totalRows,n.totalPages=1,r.$table.addClass("pagerDisabled").removeAttr("aria-describedby").find("tr.pagerSavedHeightSpacer").remove(),a.renderTable(r,r.rowsCopy),n.isDisabled=!0,t.applyWidget(g),t.debug(r,"pager")&&console.log("Pager >> Disabled")),o=(s=n.$container.find(l.pager_selectors.pageSize+","+l.pager_selectors.gotoPage+",.ts-startRow, .ts-page")).length,i=0;i<o;i++)s.eq(i).prop("aria-disabled","true").addClass(l.pager_css.disabled)[0].disabled=!0},updateCache:function(r){var i=r.pager;t.updateCache(r,function(){if(!e.isEmptyObject(r.cache)){var t,s=[],o=r.cache[0].normalized;for(i.totalRows=o.length,t=0;t<i.totalRows;t++)s[s.length]=o[t][r.columns].$row;r.rowsCopy=s,a.moveToPage(r,i,!0),i.last.currentFilters=[" "]}})},moveToPage:function(r,i,s){if(!i.isDisabled){if(!1!==s&&i.initialized&&e.isEmptyObject(r.cache))return a.updateCache(r);var o,g=r.table,n=r.widgetOptions,l=i.last,p=t.debug(r,"pager");i.ajax&&!n.filter_initialized&&t.hasWidget(g,"filter")||(a.parsePageNumber(r,i),a.calcFilters(r),l.currentFilters=""===(l.currentFilters||[]).join("")?[]:l.currentFilters,i.currentFilters=""===(i.currentFilters||[]).join("")?[]:i.currentFilters,l.page===i.page&&l.size===i.size&&l.totalRows===i.totalRows&&(l.currentFilters||[]).join(",")===(i.currentFilters||[]).join(",")&&(l.ajaxUrl||"")===(i.ajaxObject.url||"")&&(l.optAjaxUrl||"")===(n.pager_ajaxUrl||"")&&l.sortList===(r.sortList||[]).join(",")||(p&&console.log("Pager >> Changing to page "+i.page),i.last={page:i.page,size:i.size,sortList:(r.sortList||[]).join(","),totalRows:i.totalRows,currentFilters:i.currentFilters||[],ajaxUrl:i.ajaxObject.url||"",optAjaxUrl:n.pager_ajaxUrl},i.ajax?n.pager_processAjaxOnInit||e.isEmptyObject(n.pager_initialRows)?a.getAjax(r):(n.pager_processAjaxOnInit=!0,o=n.pager_initialRows,i.totalRows=void 0!==o.total?o.total:p&&console.error("Pager >> No initial total page set!")||0,i.filteredRows=void 0!==o.filtered?o.filtered:p&&console.error("Pager >> No initial filtered page set!")||0,a.updatePageDisplay(r,!1)):i.ajax||a.renderTable(r,r.rowsCopy),e.data(g,"pagerLastPage",i.page),i.initialized&&!1!==s&&(p&&console.log("Pager >> Triggering pageMoved"),r.$table.triggerHandler("pageMoved",r),t.applyWidget(g),!i.ajax&&g.isUpdating&&(p&&console.log("Pager >> Triggering updateComplete"),r.$table.triggerHandler("updateComplete",[g,!0])))))}},getTotalPages:function(e,a){return t.hasWidget(e.table,"filter")?Math.min(a.totalPages,a.filteredPages):a.totalPages},parsePageNumber:function(e,t){var r=a.getTotalPages(e,t)-1;return t.page=parseInt(t.page,10),(t.page<0||isNaN(t.page))&&(t.page=0),t.page>r&&r>=0&&(t.page=r),t.page},parsePageSize:function(e,a,t){var r=e.pager,i=e.widgetOptions,s=parseInt(a,10)||r.size||i.pager_size||10;return r.initialized&&(/all/i.test(s+" "+a)||s===r.totalRows)?r.$container.find(i.pager_selectors.pageSize+' option[value="all"]').length?"all":r.totalRows:"get"===t?s:r.size},setPageSize:function(t,r){var i=t.pager,s=t.table;i.size=a.parsePageSize(t,r,"get"),i.$container.find(t.widgetOptions.pager_selectors.pageSize).val(i.size),e.data(s,"pagerLastPage",a.parsePageNumber(t,i)),e.data(s,"pagerLastSize",i.size),i.totalPages="all"===i.size?1:Math.ceil(i.totalRows/i.size),i.filteredPages="all"===i.size?1:Math.ceil(i.filteredRows/i.size)},moveToFirstPage:function(e,t){t.page=0,a.moveToPage(e,t,!0)},moveToLastPage:function(e,t){t.page=a.getTotalPages(e,t)-1,a.moveToPage(e,t,!0)},moveToNextPage:function(e,t){t.page++;var r=a.getTotalPages(e,t)-1;t.page>=r&&(t.page=r),a.moveToPage(e,t,!0)},moveToPrevPage:function(e,t){t.page--,t.page<=0&&(t.page=0),a.moveToPage(e,t,!0)},destroyPager:function(e,r){var i=e.table,s=e.pager,o=e.widgetOptions.pager_selectors||{},g=[o.first,o.prev,o.next,o.last,o.gotoPage,o.pageSize].join(","),n=e.namespace+"pager";if(s){if(s.initialized=!1,e.$table.off(n),s.$container.hide().find(g).off(n),r)return;e.appender=null,a.showAllRows(e),t.storage&&t.storage(i,e.widgetOptions.pager_storageKey,""),s.$container=null,e.pager=null,e.rowsCopy=null}},enablePager:function(r,i){var s,o,g=r.table,n=r.pager,l=r.widgetOptions,p=n.$container.find(l.pager_selectors.pageSize);n.isDisabled=!1,n.page=e.data(g,"pagerLastPage")||n.page||0,o=p.find("option[selected]").val(),n.size=e.data(g,"pagerLastSize")||a.parsePageSize(r,o,"get"),a.setPageSize(r,n.size),n.totalPages="all"===n.size?1:Math.ceil(a.getTotalPages(r,n)/n.size),r.$table.removeClass("pagerDisabled"),g.id&&!r.$table.attr("aria-describedby")&&((s=(p=n.$container.find(l.pager_selectors.pageDisplay)).attr("id"))||(s=g.id+"_pager_info",p.attr("id",s)),r.$table.attr("aria-describedby",s)),a.changeHeight(r),i&&(t.update(r),a.setPageSize(r,n.size),a.moveToPage(r,n,!0),a.hideRowsSetup(r),t.debug(r,"pager")&&console.log("Pager >> Enabled"))},appender:function(t,r){var i=t.config,s=i.widgetOptions,o=i.pager;o.ajax?a.moveToPage(i,o,!0):(i.rowsCopy=r,o.totalRows=s.pager_countChildRows?i.$tbodies.eq(0).children("tr").length:r.length,o.size=e.data(t,"pagerLastSize")||o.size||s.pager_size||o.setSize||10,o.totalPages="all"===o.size?1:Math.ceil(o.totalRows/o.size),a.moveToPage(i,o),a.updatePageDisplay(i,!1))}},t.showError=function(a,t,r,i){var s=e(a),o=s[0].config,g=o&&o.widgetOptions,n=o.pager&&o.pager.cssErrorRow||g&&g.pager_css&&g.pager_css.errorRow||"tablesorter-errorRow",l=typeof t,p=!0,d="",c=function(){o.$table.find("thead").find(o.selectorRemove).remove()};if(s.length){if("function"==typeof o.pager.ajaxError){if(!1===(p=o.pager.ajaxError(o,t,r,i)))return c();d=p}else if("function"==typeof g.pager_ajaxError){if(!1===(p=g.pager_ajaxError(o,t,r,i)))return c();d=p}if(""===d)if("object"===l)d=0===t.status?"Not connected, verify Network":404===t.status?"Requested page not found [404]":500===t.status?"Internal Server Error [500]":"parsererror"===i?"Requested JSON parse failed":"timeout"===i?"Time out error":"abort"===i?"Ajax Request aborted":"Uncaught error: "+t.statusText+" ["+t.status+"]";else{if("string"!==l)return c();d=t}e(/tr\>/.test(d)?d:'<tr><td colspan="'+o.columns+'">'+d+"</td></tr>").click(function(){e(this).remove()}).appendTo(o.$table.find("thead:first")).addClass(n+" "+o.selectorRemove.slice(1)).attr({role:"alert","aria-live":"assertive"})}else console.error("tablesorter showError: no table parameter passed")}}(jQuery);