From 1407cd3504d18ab702f54d0f83db167acb448efd Mon Sep 17 00:00:00 2001 From: Lennard Berger Date: Mon, 17 Jul 2017 12:47:15 +0200 Subject: [PATCH 1/2] Widget: Add removeWidgetEnd event --- js/jquery.tablesorter.js | 5685 +++++++++++++++++++------------------- testing/testing.js | 1915 ++++++------- 2 files changed, 3801 insertions(+), 3799 deletions(-) diff --git a/js/jquery.tablesorter.js b/js/jquery.tablesorter.js index f83a1d13f..902910f3e 100644 --- a/js/jquery.tablesorter.js +++ b/js/jquery.tablesorter.js @@ -19,2847 +19,2848 @@ */ /*jshint browser:true, jquery:true, unused:false, expr: true */ ;( function( $ ) { - 'use strict'; - var ts = $.tablesorter = { - - version : '2.28.15', - - 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} = // 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 ( c.debug ) { - 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 ( c.debug ) { - 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; - 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 ) { - 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 ( c.debug ) { - console.log( 'Overall initialization time:' + ts.benchmark( $.data( table, 'startoveralltimer' ) ) ); - if ( c.debug && 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, init ) { - e.stopPropagation(); - // apply widgets - ts.applyWidget( this, init ); - }) - .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 = $.fn.closest ? $headers.closest( 'table' )[ 0 ] : $headers.parents( 'table' )[ 0 ]; - if ( tmp && tmp.nodeName === 'TABLE' && tmp !== table ) { - $( tmp ).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; - // 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 || - // elements within a button - $target.parents( 'button' ).length > 0 ) { - return !c.cancelSelection; - } - if ( c.delayInit && ts.isEmptyObject( c.cache ) ) { - ts.buildCache( c ); - } - // jQuery v1.2.6 doesn't have closest() - $cell = $.fn.closest ? $( this ).closest( 'th, td' ) : - /TH|TD/.test( this.nodeName ) ? $( this ) : $( this ).parents( 'th, td' ); - // reference original table headers and find the same cell - // don't use $headers or IE8 throws an error - see #987 - temp = $headers.index( $cell ); - c.last.clickedIndex = ( temp < 0 ) ? $cell.attr( 'data-column' ) : temp; - // use column index if $headers is undefined - cell = c.$headers[ c.last.clickedIndex ]; - 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 ( c.debug ) { - 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 ? - '' : - ''; - // 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 ( $elem.parent().hasClass( c.cssIgnoreRow ) ) { return; } - // 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( '
' + template + '
' ); // 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 - }; - 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; - // add to parent in case there are multiple rows - $elem - .addClass( ts.css.header + ' ' + c.cssHeader ) - .parent() - .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 ] = {}; - } - $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 ( c.debug ) { - 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 = {}; - // 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 c.debug ? console.warn( 'Warning: *Empty table!* Not building a parser cache' ) : ''; - } else if ( c.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 ( c.debug ) { - debug[ '(' + 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 ( c.debug ) { - if ( !ts.isEmptyObject( debug ) ) { - console[ console.table ? 'table' : 'log' ]( debug ); - } 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 */ - 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 = '', - 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 ( c.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; - // 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 c.debug ? console.warn( 'Warning: *Empty table!* Not building a cache' ) : ''; - } - if ( c.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 && c.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 ( c.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 ( c.debug ) { - 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' ], - // 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 + c.$headers[ i ].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 ) { - $sorted - .eq( column ) - .removeClass( none ) - .addClass( css[ list[ indx ][ 1 ] ] ) - .attr( 'aria-sort', aria[ list[ indx ][ 1 ] ] ) - .find( '.' + ts.css.icon ) - .removeClass( cssIcon[ 2 ] ) - .addClass( cssIcon[ list[ indx ][ 1 ] ] ); - } - } - // add sorted class to footer & extra headers, if they exist - if ( $extras.length ) { - $extras - .filter( '[data-column="' + list[ indx ][ 0 ] + '"]' ) - .removeClass( none ) - .addClass( css[ list[ indx ][ 1 ] ] ); - } - } - } - } - // add verbose aria labels - len = c.$headers.length; - for ( indx = 0; indx < len; indx++ ) { - ts.setColumnAriaLabel( c, c.$headers.eq( indx ) ); - } - }, - - // 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 ); - } - }, - - 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( $.fn.closest ? $cell.closest( 'tbody' ) : $cell.parents( 'tbody' ).filter( ':first' ) ), - tbcache = c.cache[ tbodyIndex ], - $row = $.fn.closest ? $cell.closest( 'tr' ) : $cell.parents( 'tr' ).filter( ':first' ); - 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 ( c.debug ) { - 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 && / 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, - wo = c.widgetOptions, - $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 ( c.debug ) { - 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 || !wo.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 ( c.debug ) { - 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, - // get current column index - col = parseInt( $( cell ).attr( 'data-column' ), 10 ), - order = c.sortVars[ col ].order; - - // 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 ) { - // 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 ]; - } - } - } - // add column to sort list - dir = order[ c.sortVars[ col ].count ]; - if ( dir < 2 ) { - c.sortList[ c.sortList.length ] = [ col, dir ]; - // add other columns if header spans across multiple - if ( cell.colSpan > 1 ) { - for ( indx = 1; indx < cell.colSpan; indx++ ) { - c.sortList[ c.sortList.length ] = [ col + indx, dir ]; - // update count on columns in colSpan - c.sortVars[ col + indx ].count = $.inArray( dir, order ); - } - } - } - // 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 - 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 ]; - if ( dir < 2 ) { - c.sortList[ c.sortList.length ] = [ col, dir ]; - // add other columns if header spans across multiple - if ( cell.colSpan > 1 ) { - for ( indx = 1; indx < cell.colSpan; indx++ ) { - c.sortList[ c.sortList.length ] = [ col + indx, dir ]; - // update count on columns in colSpan - c.sortVars[ col + indx ].count = $.inArray( dir, order ); - } - } - } - } - } - // 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 ]; - } - } - } - } - // 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 ( c.debug ) { 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 ( c.debug ) { - 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 table = c.table; - c.$table.triggerHandler( 'sortStart', table ); - // 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 = []; - ts.setHeadersCss( c ); - ts.multisort( c ); - ts.appendCache( c ); - var indx; - for (indx = 0; indx < c.columns; indx++) { - c.sortVars[ indx ].count = -1; - } - 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, - 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 ( c.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 ( c.debug ) { - console[ console.group ? 'group' : 'log' ]( 'Initializing ' + name + ' widget' ); - } - widget.init( table, widget, c, wo ); - } - } - if ( !init && typeof widget.format === 'function' ) { - applied = true; - if ( c.debug ) { - console[ console.group ? 'group' : 'log' ]( 'Updating ' + name + ' widget' ); - } - widget.format( table, c, wo, false ); - } - if ( c.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, - widgets = []; - // prevent numerous consecutive widget applications - if ( init !== false && table.hasInitialized && ( table.isApplyingWidgets || table.isUpdating ) ) { - return; - } - if ( c.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 ( c.debug ) { - console.warn( '"' + names[ indx ] + '" widget code does not exist!' ); - } - } - // 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 ( c.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 ( c.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 ( c.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 ( c.debug ) { - console.log( ( refreshing ? 'Refreshing' : 'Removing' ) + ' "' + name[ index ] + '" widget' ); - } - widget.remove( table, c, c.widgetOptions, refreshing ); - c.widgetInit[ name[ index ] ] = false; - } - } - }, - - 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 ); - }, - - // $.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 = $( '' ); - 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( $( '' ).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.filter( '[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( '' ); - 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 ( c.debug ) { - 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 ( c.debug ) { - 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, - debug = c.debug, - $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 ( debug ) { - 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, table ) { - 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, table ) { - 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, table ) { - // 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 - } - } - }); + 'use strict'; + var ts = $.tablesorter = { + + version : '2.28.15', + + 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} = // 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 ( c.debug ) { + 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 ( c.debug ) { + 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; + 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 ) { + 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 ( c.debug ) { + console.log( 'Overall initialization time:' + ts.benchmark( $.data( table, 'startoveralltimer' ) ) ); + if ( c.debug && 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, init ) { + e.stopPropagation(); + // apply widgets + ts.applyWidget( this, init ); + }) + .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 = $.fn.closest ? $headers.closest( 'table' )[ 0 ] : $headers.parents( 'table' )[ 0 ]; + if ( tmp && tmp.nodeName === 'TABLE' && tmp !== table ) { + $( tmp ).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; + // 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 || + // elements within a button + $target.parents( 'button' ).length > 0 ) { + return !c.cancelSelection; + } + if ( c.delayInit && ts.isEmptyObject( c.cache ) ) { + ts.buildCache( c ); + } + // jQuery v1.2.6 doesn't have closest() + $cell = $.fn.closest ? $( this ).closest( 'th, td' ) : + /TH|TD/.test( this.nodeName ) ? $( this ) : $( this ).parents( 'th, td' ); + // reference original table headers and find the same cell + // don't use $headers or IE8 throws an error - see #987 + temp = $headers.index( $cell ); + c.last.clickedIndex = ( temp < 0 ) ? $cell.attr( 'data-column' ) : temp; + // use column index if $headers is undefined + cell = c.$headers[ c.last.clickedIndex ]; + 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 ( c.debug ) { + 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 ? + '' : + ''; + // 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 ( $elem.parent().hasClass( c.cssIgnoreRow ) ) { return; } + // 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( '
' + template + '
' ); // 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 + }; + 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; + // add to parent in case there are multiple rows + $elem + .addClass( ts.css.header + ' ' + c.cssHeader ) + .parent() + .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 ] = {}; + } + $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 ( c.debug ) { + 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 = {}; + // 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 c.debug ? console.warn( 'Warning: *Empty table!* Not building a parser cache' ) : ''; + } else if ( c.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 ( c.debug ) { + debug[ '(' + 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 ( c.debug ) { + if ( !ts.isEmptyObject( debug ) ) { + console[ console.table ? 'table' : 'log' ]( debug ); + } 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 */ + 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 = '', + 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 ( c.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; + // 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 c.debug ? console.warn( 'Warning: *Empty table!* Not building a cache' ) : ''; + } + if ( c.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 && c.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 ( c.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 ( c.debug ) { + 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' ], + // 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 + c.$headers[ i ].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 ) { + $sorted + .eq( column ) + .removeClass( none ) + .addClass( css[ list[ indx ][ 1 ] ] ) + .attr( 'aria-sort', aria[ list[ indx ][ 1 ] ] ) + .find( '.' + ts.css.icon ) + .removeClass( cssIcon[ 2 ] ) + .addClass( cssIcon[ list[ indx ][ 1 ] ] ); + } + } + // add sorted class to footer & extra headers, if they exist + if ( $extras.length ) { + $extras + .filter( '[data-column="' + list[ indx ][ 0 ] + '"]' ) + .removeClass( none ) + .addClass( css[ list[ indx ][ 1 ] ] ); + } + } + } + } + // add verbose aria labels + len = c.$headers.length; + for ( indx = 0; indx < len; indx++ ) { + ts.setColumnAriaLabel( c, c.$headers.eq( indx ) ); + } + }, + + // 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 ); + } + }, + + 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( $.fn.closest ? $cell.closest( 'tbody' ) : $cell.parents( 'tbody' ).filter( ':first' ) ), + tbcache = c.cache[ tbodyIndex ], + $row = $.fn.closest ? $cell.closest( 'tr' ) : $cell.parents( 'tr' ).filter( ':first' ); + 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 ( c.debug ) { + 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 && / 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, + wo = c.widgetOptions, + $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 ( c.debug ) { + 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 || !wo.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 ( c.debug ) { + 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, + // get current column index + col = parseInt( $( cell ).attr( 'data-column' ), 10 ), + order = c.sortVars[ col ].order; + + // 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 ) { + // 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 ]; + } + } + } + // add column to sort list + dir = order[ c.sortVars[ col ].count ]; + if ( dir < 2 ) { + c.sortList[ c.sortList.length ] = [ col, dir ]; + // add other columns if header spans across multiple + if ( cell.colSpan > 1 ) { + for ( indx = 1; indx < cell.colSpan; indx++ ) { + c.sortList[ c.sortList.length ] = [ col + indx, dir ]; + // update count on columns in colSpan + c.sortVars[ col + indx ].count = $.inArray( dir, order ); + } + } + } + // 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 + 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 ]; + if ( dir < 2 ) { + c.sortList[ c.sortList.length ] = [ col, dir ]; + // add other columns if header spans across multiple + if ( cell.colSpan > 1 ) { + for ( indx = 1; indx < cell.colSpan; indx++ ) { + c.sortList[ c.sortList.length ] = [ col + indx, dir ]; + // update count on columns in colSpan + c.sortVars[ col + indx ].count = $.inArray( dir, order ); + } + } + } + } + } + // 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 ]; + } + } + } + } + // 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 ( c.debug ) { 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 ( c.debug ) { + 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 table = c.table; + c.$table.triggerHandler( 'sortStart', table ); + // 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 = []; + ts.setHeadersCss( c ); + ts.multisort( c ); + ts.appendCache( c ); + var indx; + for (indx = 0; indx < c.columns; indx++) { + c.sortVars[ indx ].count = -1; + } + 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, + 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 ( c.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 ( c.debug ) { + console[ console.group ? 'group' : 'log' ]( 'Initializing ' + name + ' widget' ); + } + widget.init( table, widget, c, wo ); + } + } + if ( !init && typeof widget.format === 'function' ) { + applied = true; + if ( c.debug ) { + console[ console.group ? 'group' : 'log' ]( 'Updating ' + name + ' widget' ); + } + widget.format( table, c, wo, false ); + } + if ( c.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, + widgets = []; + // prevent numerous consecutive widget applications + if ( init !== false && table.hasInitialized && ( table.isApplyingWidgets || table.isUpdating ) ) { + return; + } + if ( c.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 ( c.debug ) { + console.warn( '"' + names[ indx ] + '" widget code does not exist!' ); + } + } + // 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 ( c.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 ( c.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 ( c.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 ( c.debug ) { + 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 ); + }, + + // $.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 = $( '' ); + 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( $( '' ).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.filter( '[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( '' ); + 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 ( c.debug ) { + 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 ( c.debug ) { + 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, + debug = c.debug, + $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 ( debug ) { + 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, table ) { + 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, table ) { + 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, table ) { + // 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 ); diff --git a/testing/testing.js b/testing/testing.js index 1b41822e9..f8d668a30 100644 --- a/testing/testing.js +++ b/testing/testing.js @@ -7,11 +7,11 @@ // Accepts a function with a single argument -- deferred object, which should be resolved at some point in a function. // Returns a promise, wrapping this function call. QUnit.deferredCallback = function(func) { - return function(){ - var defer = $.Deferred(); - func(defer); - return defer.promise(); - }; + return function(){ + var defer = $.Deferred(); + func(defer); + return defer.promise(); + }; }; // SequentialRunner is an object to build and run a list of asynchronous calls in a sequential way. @@ -37,24 +37,24 @@ QUnit.deferredCallback = function(func) { // .then(function(){ console.log('Login, demo and any other button were clicked in that order.') }); // QUnit.SequentialRunner = function(runnerCreator){ - var result = { - defer: $.Deferred().resolve(), - promise: function(){ - return this.defer.promise(); - }, - next: function(runner) { - this.defer = this.defer.then( QUnit.deferredCallback(runner) ); - return this; - } - }; - if (runnerCreator) { - result.nextTask = function(args) { // any argument list - var deferredRunner = QUnit.deferredCallback( runnerCreator.apply(this, arguments) ); - this.defer = this.defer.then(deferredRunner); - return this; - }; - } - return result; + var result = { + defer: $.Deferred().resolve(), + promise: function(){ + return this.defer.promise(); + }, + next: function(runner) { + this.defer = this.defer.then( QUnit.deferredCallback(runner) ); + return this; + } + }; + if (runnerCreator) { + result.nextTask = function(args) { // any argument list + var deferredRunner = QUnit.deferredCallback( runnerCreator.apply(this, arguments) ); + this.defer = this.defer.then(deferredRunner); + return this; + }; + } + return result; }; // Returns an runner which runs some actions and wait for an event to be triggered. @@ -79,966 +79,967 @@ QUnit.SequentialRunner = function(runnerCreator){ // }); // QUnit.assertOnEvent = function($element, eventType, actions, assertions) { - return function(defer){ - $element - .off(eventType) - .on(eventType, function() { - $element.off(eventType); - assertions(); - defer && defer.resolve(); - }); - actions(); - }; + return function(defer){ + $element + .off(eventType) + .on(eventType, function() { + $element.off(eventType); + assertions(); + defer && defer.resolve(); + }); + actions(); + }; }; QUnit.extend(QUnit.assert, { - /************************************************ - test table data cache - ************************************************/ - cacheCompare : function(table, col, expected, txt, filtered){ - var flat = [], - result = $.tablesorter.getColumnText( table, col, function( data ){ - return !( filtered && data.$row.hasClass( table.config.widgetOptions.filter_filteredRow ) ); - }); - // flatten array - flat = flat.concat.apply( flat, result.parsed ); - QUnit.assert.deepEqual( flat, expected, 'Comparing parser cache: ' + txt); - } + /************************************************ + test table data cache + ************************************************/ + cacheCompare : function(table, col, expected, txt, filtered){ + var flat = [], + result = $.tablesorter.getColumnText( table, col, function( data ){ + return !( filtered && data.$row.hasClass( table.config.widgetOptions.filter_filteredRow ) ); + }); + // flatten array + flat = flat.concat.apply( flat, result.parsed ); + QUnit.assert.deepEqual( flat, expected, 'Comparing parser cache: ' + txt); + } }); /* Core plugin tested ======================== OPTIONS: - cssAsc, cssChildRow, cssDesc, cssHeader, cssHeaderRow, cssInfoBlock, dateFormat, emptyTo, headerList, - headers, ignoreCase, initialized, parsers, sortList, sortLocaleCompare, sortReset, sortRestart, stringTo, tableClass, - usNumberFormat, widgets (just zebra), sortAppend, sortForce, sortMultiSortKey, sortResetKey, numberSorter, - cssIconAsc, cssIconDesc, cssIconNone, cssIconDisabled + cssAsc, cssChildRow, cssDesc, cssHeader, cssHeaderRow, cssInfoBlock, dateFormat, emptyTo, headerList, + headers, ignoreCase, initialized, parsers, sortList, sortLocaleCompare, sortReset, sortRestart, stringTo, tableClass, + usNumberFormat, widgets (just zebra), sortAppend, sortForce, sortMultiSortKey, sortResetKey, numberSorter, + cssIconAsc, cssIconDesc, cssIconNone, cssIconDisabled METHODS: - addRows, applyWidgets, destroy, sorton, sortReset, update/updateRow, updateAll, updateCell + addRows, applyWidgets, destroy, sorton, sortReset, update/updateRow, updateAll, updateCell EVENTS: - initialized, sortBegin, sortEnd, sortStart, updateComplete + initialized, sortBegin, sortEnd, sortStart, updateComplete Not yet tested ========================= OPTIONS: - cancelSelection, cssProcessing, debug, delayInit, headerTemplate, initWidgets, onRenderHeader, - onRenderTemplate, selectorHeaders, selectorRemove, selectorSort, serverSideSorting, showProcessing, - sortInitialOrder, strings, - textExtraction, textSorter, theme, widthFixed, widgets (also need priority testing) + cancelSelection, cssProcessing, debug, delayInit, headerTemplate, initWidgets, onRenderHeader, + onRenderTemplate, selectorHeaders, selectorRemove, selectorSort, serverSideSorting, showProcessing, + sortInitialOrder, strings, + textExtraction, textSorter, theme, widthFixed, widgets (also need priority testing) METHODS: - appendCache, applyWidgetId, sort, refreshWidgets + appendCache, applyWidgetId, sort, refreshWidgets EVENTS: - - + - */ jQuery(function($){ - var ts = $.tablesorter, - $table1 = $('#table1'), - $table2 = $('#table2'), - $table3 = $('#table3'), - $table4 = $('#table4'), - $table5 = $('#table5'), // empty table - $table6 = $('#table6'), // colspan table - table1 = $table1[0], - table2 = $table2[0], - table3 = $table3[0], - table4 = $table4[0], - table5 = $table5[0], - table6 = $table6[0], - th0 = $table1.find('th')[0], // first table header cell - init = false, - sortIndx = 0, - updateIndx = 0, - updateCallback = 0, - events = ['sortStart', 'sortBegin', 'sortEnd', ' '], - returnTime = function(string){ - return new Date(string).getTime(); - }, - undef, c1, c2, c3, c4, e, i, t; - - /* test widget */ - ts.addWidget({ - id : 'test', - options: { - 'test': [] - }, - format: function() {} - }); - - $table1 - .on('tablesorter-initialized', function(){ - init = true; - }) - .tablesorter({ - widgets: ['test'], - widgetOptions: { - // check widget option defaults across tables - test: [0,1] - } - }); - - $table2.tablesorter({ - headers: { - 0: { sorter: 'text' }, - 1: { sorter: 'text' }, - 2: { sorter: false } - }, - widgets: ['test'], - widgetOptions: { - // check widget option defaults across tables - test: [0] - } - }); - - $table3.tablesorter({ - emptyTo: 'bottom', - stringTo: 'max', // non-numeric content is treated as a MAX value - headers: { - 0: { empty : 'top' }, // sort empty cells to the top - 2: { string: 'min' }, // non-numeric content is treated as a MIN value - 3: { sorter: 'digit', empty : 'zero', string : 'top' } - }, - // check widget option defaults across tables - widgets: ['test'] - }); - - $table4.tablesorter({ - sortAppend : [[2,0],[3,0]], - sortForce : [[0,0],[1,0]], - textExtraction : { - '.te-test' : function(node){ - return $(node).find('span').text(); - }, - 2 : function(node){ - return $(node).find('span').text(); - } - }, - initialized: function(table){ - var e, c = table.config; - // trigger sort on 5th column - // this method is used because triggering a 'sorton' would ignore sortForce/sortAppend - c.$headers.eq(4).trigger('sort'); - e = $.Event('sort'); - e.which = 1; - e.shiftKey = true; - c.$headers.eq(5).trigger(e); - }, - numberSorter: function(a, b, dir){ - return dir ? a-b : b-a; - } - }); - - $table5.tablesorter(); - $table6.tablesorter(); - - QUnit.module('core'); - /************************************************ - Initialization - ************************************************/ - QUnit.test( 'tablesorter loaded & initialized', function(assert) { - assert.expect(3); - assert.equal( typeof ts, 'object', 'tablesorter loaded'); - assert.equal( table1.hasInitialized, true, 'tablesorter initialized flag'); - assert.equal( init, true, 'tablesorter initialized event'); - }); - - c1 = table1.config; - c2 = table2.config; - c3 = table3.config; - c4 = table4.config; - - /************************************************ - Test column numbering - ************************************************/ - // later: include a table header with colspan & rowspan - QUnit.test( 'column numbering', function(assert) { - assert.expect(2); - var internalColumn = true, - dataColumn = true; - $table4.find('thead th').each(function(i){ - internalColumn = internalColumn && this.column === i; - dataColumn = dataColumn && $(this).attr('data-column') == i; - }); - assert.equal( internalColumn, true, 'Correct internal column numbering' ); - assert.equal( dataColumn, true, 'Correct data-column attribute numbering' ); - }); - - /************************************************ - check isDigit function - ************************************************/ - var d = ts.isDigit; - QUnit.test( 'isDigit', function(assert) { - assert.expect(18); - assert.ok( d('-1'), 'allow negative (-1)'); - assert.ok( d('+1'), 'allow plus (+1)'); - assert.ok( d('(1)'), 'allow parenthesis (1)'); - assert.ok( d('123'), "string has numbers ('123')"); - assert.ok( d(123), 'has numbers (123)'); - assert.ok( d('1.2'), 'remove decimal (1.2)'); - assert.ok( d('1,234'),'remove commas (1,234)'); - assert.ok( d("11'"), "remove apostrophe's (11')"); // 11 feet - assert.ok( d('3\'4"'),"remove quotes (3'4\")"); // 3 foot 4 inches - assert.ok( d(' 12 '), 'remove spaces ( 12 )'); - assert.ok( !d('x'), 'non-digit alphabet'); - assert.ok( !d('1x'), 'digit + alphabet'); - assert.ok( !d('x1'), 'alphabet + digit'); - assert.ok( !d('@'), 'non-digit symbols'); - assert.ok( !d('1-'), 'negative after (1-) not allowed?'); - assert.ok( !d('1+'), 'plus after (1+) not allowed?'); - assert.ok( !d('$2'), 'no money; the currency parser will catch these'); - assert.ok( !d(''), "empty string ('')"); - }); - - /************************************************ - check formatFloat function - ************************************************/ - var ff = function(str) { - return ts.formatFloat(str, table1); - }; - QUnit.test( 'formatFloat', function(assert) { - assert.expect(18); - assert.strictEqual( ff(''), '', 'returns empty string' ); - assert.strictEqual( ff(5), 5, 'returns numerical values'); - - c1.usNumberFormat = false; - assert.strictEqual( ts.formatFloat('1,234,567.89'), 1234567.89, 'use format float without including table - defaults to US number format'); - - assert.strictEqual( ff('1 234,56'), 1234.56, 'parse non-U.S. (French) number format'); - assert.strictEqual( ff('1.234,56'), 1234.56, 'parse non-U.S. (German) number format'); - assert.strictEqual( ff('-32,32'), -32.32, 'negative non-U.S. signed numbers'); - assert.strictEqual( ff('-1.234,56'), -1234.56, 'negative non-U.S. signed numbers'); - assert.strictEqual( ff('(32,32)'), -32.32, 'parenthesis wrapped non-U.S. negative number'); - assert.strictEqual( ff(' (32,32) '), -32.32, 'space + parenthesis wrapped non-U.S. negative number'); - - c1.usNumberFormat = true; - assert.strictEqual( ff('1,234.56'), 1234.56, 'parse U.S. number format'); - assert.strictEqual( ff('-32.32'), -32.32, 'negative U.S. signed numbers'); - assert.strictEqual( ff('(32.32)'), -32.32, 'parenthesis wrapped U.S. negative number'); - assert.strictEqual( ff(' (32.32)'), -32.32, 'space + parenthesis wrapped U.S. negative number'); - - assert.strictEqual( ff('fred'), 'fred', 'return string if not a number'); - assert.strictEqual( ff(' fred '), 'fred', 'return trimmed string if not a number'); - assert.strictEqual( ff('fred 12'), 'fred 12', 'return string if number not at beginning'); - assert.strictEqual( ff('12fred'), 12, 'parse number + string into number only'); - assert.strictEqual( ff('(fred)'), '(fred)', 'leave parenthesis intact on strings'); - - }); - - /************************************************ - get data function - jQuery data > meta > headers option > header class name - ************************************************/ - var gd = function(n){ - return ts.getData( c2.$headers[n], c2.headers[n], 'sorter' ); - }; - - QUnit.test( 'getData', function(assert) { - assert.expect(4); - var txt = [ 'jQuery data', 'meta data', 'headers option', 'header class name' ]; - for (i = 0; i < 4; i++) { - assert.equal( gd(i), 'false', txt[i]); // all columns have sorter false set - } - }); - - /************************************************ - isValueInArray - ************************************************/ - - QUnit.test( 'isValueInArray', function(assert) { - var v = ts.isValueInArray; - assert.expect(6); - assert.ok( v( 0, null ) < 0, 'null' ); - assert.ok( v( 0, [] ) < 0, 'Empty array' ); - assert.ok( v( 1, [[ 1,0 ], [ 0,0 ]] ) === 0, 'Column found (first array)' ); - assert.ok( v( 1, [[ 0,0 ], [ 1,0 ]] ) === 1, 'Column found (second array)' ); - assert.ok( v( 4, [[ 0,0 ], [ 1,0 ], [ 4,0 ]] ) === 2, 'Column found (third array)' ); - assert.ok( v( 3, [[ 0,0 ], [ 1,0 ], [ 4,0 ]] ) < 0 , 'Column not found' ); - }); - - /************************************************ - isProcessing - ************************************************/ - QUnit.test( 'isProcessing', function(assert) { - $table3.trigger('sortReset'); - assert.expect(5); - var p = ts.isProcessing, - findClasses = function( applied, columns ) { - var i, tmp, - headers = 0, - len = columns.length, - headers = 0, - // if processing applied, class is added to the table - result = applied && $table3.hasClass( ts.css.processing ); - if ( len === 1 && columns[ 0 ] < 0 ) { - // processing class should not be found on headers - return ( !result || applied && result ) && c3.$headers.find( '.' + ts.css.processing ).length === 0; - } - for ( i = 0; i < len; i++ ) { - tmp = c3.$headers.eq( columns[ i ] ).hasClass( ts.css.processing ); - if ( tmp ) { headers++; } - result = result && tmp; - } - return result && headers === len; - }; - $table3.trigger('sorton', [[[0,0], [1,0]]]); - p( $table3, true ); - assert.ok( findClasses( true, [ 0, 1 ] ), 'Processing 2 columns' ); - p( $table3, false ); - assert.ok( findClasses( false, [ -1 ] ), 'No sort' ); - p( $table3, true, c3.$headers.eq(4) ); - assert.ok( findClasses( true, [ -1 ] ), 'Processing specified column not in sortList' ); - p( $table3, true, c3.$headers.eq(1) ); - assert.ok( findClasses( true, [ 1 ] ), 'Processing specified column in sortList' ); - $table3.trigger('sortReset'); - assert.ok( findClasses( false, [ -1 ] ), 'No sort' ); - }); - - /************************************************ - character equivalent replacement - ************************************************/ - QUnit.test( 'replace accents', function(assert) { - assert.expect(6); - assert.strictEqual( ts.replaceAccents('\u00e1\u00e0\u00e2\u00e3\u00e4\u0105\u00e5\u00c1\u00c0\u00c2\u00c3\u00c4\u0104\u00c5'), 'aaaaaaaAAAAAAA', "replaced a's"); - assert.strictEqual( ts.replaceAccents('\u00e9\u00e8\u00ea\u00eb\u011b\u0119\u00c9\u00c8\u00ca\u00cb\u011a\u0118'), 'eeeeeeEEEEEE', "replaced e's"); - assert.strictEqual( ts.replaceAccents('\u00ed\u00ec\u0130\u00ee\u00ef\u0131\u00cd\u00cc\u0130\u00ce\u00cf'), 'iiiiiiIIiII', "replaced i's"); - assert.strictEqual( ts.replaceAccents('\u00f3\u00f2\u00f4\u00f5\u00f6\u00d3\u00d2\u00d4\u00d5\u00d6'), 'oooooOOOOO', "replaced o's"); - assert.strictEqual( ts.replaceAccents('\u00fa\u00f9\u00fb\u00fc\u016f\u00da\u00d9\u00db\u00dc\u016e'), 'uuuuuUUUUU', "replaced u's"); - assert.strictEqual( ts.replaceAccents('\u00e7\u0107\u010d\u00c7\u0106\u010c\u00df\u1e9e'), 'cccCCCssSS', 'replaced c & s sharp'); - }); - - /************************************************ - detect parsers - ************************************************/ - QUnit.test( 'detect parsers', function(assert) { - var done = assert.async(); - assert.expect(2); - $('#testblock2').html('' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '
InfoDetails
First NameLast NameAgeTotalDiscountDate
PeterParker28$9.9920%Jul 6, 2006 8:14 AM
JohnHood33$19.9925%Dec 10, 2002 5:14 AM
ClarkKent18$15.8944%Jan 12, 2003 11:14 AM
BruceAlmighty45$153.1944%Jan 18, 2001 9:12 AM
BruceEvans22$13.1911%Jan 18, 2007 9:12 AM
') - .find('table') - .tablesorter({ - headers : { - 0 : { sorter: false }, - 1 : { sorter: false }, - 3 : { sorter: 'digit' } // 3 sets the 4th column, not the 3rd header cell now - }, - initialized: function(table){ - var i, - result = true, - parsers = [ 'text', 'digit', 'digit', 'currency', 'percent', 'usLongDate' ], - c = table.config; - for (i = 0; i < c.columns; i++){ - result = result && c.parsers[i].id === parsers[i]; - } - assert.equal( result, true, 'detect parsers by header index' ); - // table inception! - $(table) - .trigger('destroy') - .tablesorter({ - headers : { - '.col-first' : { sorter: 'url' }, - '.col-off' : { sorter: false }, - '.col-total' : { sorter : 'percent' }, - '#age, .col-last' : { sorter: 'currency' }, - '.col-date' : { sorter : 'time' }, - '.col-discount' : { sorter: 'digit' } - }, - initialized: function(table){ - var i, - result = true, - parsers = [ 'url', 'currency', 'currency', 'percent', 'digit', 'time' ], - c = table.config; - for (i = 0; i < c.columns; i++){ - result = result && c.parsers[i].id === parsers[i]; - } - assert.equal( result, true, 'detect parsers by class/id' ); - done(); - } - }); - } - }); - - }); - - /************************************************ - check all default parsers - ************************************************/ - var p = ts.parsers, - // test by parser - parserTests = 86, - // skipping metadata parser - sample1 = { - 'text' : { 'test': 'test', 'TesT': 'test', '\u00e1 test': '\u00e1 test' }, - 'currency' : { '\u00a31': 1, '($2.23)': -2.23, '5\u20ac': 5, '(11\u00a4)': -11, '500\u00a5': 500, '25\u00a2': 25, '$1,000.50': 1000.5 }, - 'ipAddress' : { '255.255.255.255': 255255255255, '32.32.32.32': 32032032032, '1.1.1.1': 1001001001 }, - 'url' : { 'http://google.com': 'google.com', 'ftp://fred.com': 'fred.com', 'https://github.com': 'github.com' }, - 'isoDate' : { '2012/12/12': returnTime('2012/12/12'), '2012-12/12': returnTime('2012/12/12'), '2013-1-1': returnTime('2013/1/1'), '2013/1/1 12:34:56 AM': returnTime('2013/1/1 12:34:56 AM') }, - 'percent' : { '100%': 100, '22%': 22, '%2': 2, '2 %': 2, '(4%)': -4, '1,234.56 %': 1234.56 }, - 'usLongDate': { 'Feb 23, 1999': returnTime('Feb 23, 1999'), 'Feb 23, 1999 12:34': returnTime('Feb 23, 1999 12:34'), 'Feb 23, 1999 12:34 AM': returnTime('Feb 23, 1999 12:34 AM'), 'Feb 23, 1999 12:34:56 PM': returnTime('Feb 23, 1999 12:34:56 PM'), '01 Jan 2013': returnTime('01 Jan 2013') }, - 'shortDate' : { '1/2/2001': returnTime('1/2/2001'), '1 2 2001': returnTime('1/2/2001'), '1.2.2001': returnTime('1/2/2001'), '1-2-2001': returnTime('1/2/2001'), '1/2/2001 12:34 PM' : returnTime('1/2/2001 12:34 PM'), '1.2.2001 13:34' : returnTime('1/2/2001 13:34') }, - 'time' : { '12:34 AM': returnTime('2000/01/01 12:34 AM'), '1:00 pm': returnTime('2000/01/01 1:00 pm'), '09:54 PM': returnTime('2000/01/01 9:54 PM') }, - 'digit' : { '12': 12, '$23': 23, '&44^': 44, '#(33)': -33, '1,000': 1000, '12.34': 12.34 } - }, - // switch ignoreCase, sortLocalCompare & shortDate 'ddmmyyyy' - sample2 = { - 'text' : { 'TesT': 'TesT', '\u00e1 test': 'a test' }, - 'currency' : { '\u20ac 123 456,78': 123456.78, '\u20ac 123.456,78': 123456.78 }, - 'shortDate' : { '2/1/2001': returnTime('1/2/2001'), '2-1-2001': returnTime('1/2/2001'), '2 1,2001': returnTime('1/2/2001') } - }, - // shortdate to 'yyyymmdd' - sample3 = { - 'shortDate' : { '2001/1/2': returnTime('1/2/2001'), '2001-1/2': returnTime('1/2/2001'), '2001,1.2': returnTime('1/2/2001') } - }, - report = function(assert, s) { - for (i = 0; i < p.length; i++) { - t = p[i].id; - if (s.hasOwnProperty(t)) { - /*jshint loopfunc:true */ - $.each(s[t], function(k,v){ - // check 'is' and 'format' functions - if (p[i].is(k)) { - assert.equal( p[i].format(k, table1, th0, 0), v, t + ' parser: "' + k + '" parsed to ' + v ); - } else { - assert.equal( p[i].format(k, table1, th0, 0), v, t + ' parser **NOT DETECTED**: "' + k + '", but returns ' + v ); - } - }); - // test for undefined & null - probably overkill - assert.strictEqual( p[i].format(undef, table1, th0, 0), undef, t + ' parser: will return undefined values properly' ); - assert.strictEqual( p[i].format(null, table1, th0, 0), null, t + ' parser: will return null values properly' ); - } - } - }; - - QUnit.test( 'testing parsers', function(assert) { - assert.expect(parserTests); - report(assert, sample1); - var $t = $(th0); - - c1.sortLocaleCompare = true; - c1.ignoreCase = false; - c1.usNumberFormat = false; - $t.data('dateFormat', 'ddmmyyyy'); - report(assert, sample2); - - c1.usNumberFormat = true; - $t.data('dateFormat', 'yyyymmdd'); - report(assert, sample3); - - // undocumented sortValue - assert.equal( ts.getParserById('metadata').format(null, table1, th0, 0), 'zzz', 'metadata parser found sortValue'); - c1.parserMetadataName = 'poe'; - assert.equal( ts.getParserById('metadata').format(null, table1, th0, 0), 'nevermore', 'metadata parser found poe'); - }); - - QUnit.test( 'textExtraction Method', function(assert) { - assert.expect(4); - - $table1.trigger('sorton', [[[ 0,0 ]]]); - assert.cacheCompare( table1, 0, [ 'test1', 'test2', 'test3', - 'testa', 'testb', 'testc', '' ], 'from data-attribute' ); - - $table3.trigger('sorton', [[[ 0,1 ]]]); - assert.cacheCompare( table3, 0, [ '', 'a255', 'a102', 'a87', 'a55', 'a43', 'a33', 'a10', 'a02', 'a1' ], 'ignore data-attribute' ); - - assert.cacheCompare( table4, 1, [ 'f11', 'f11', 'f12', 'f12', 'f12', 'f12', 'f12', 'f13', 'f13', 'f13' ], 'extract using class name' ); - - assert.cacheCompare( table4, 2, [ 'a21', 'a21', 'a23', 'a23', 'a23', 'a22', 'a22', 'a23', 'a24', 'a24' ], 'extract using column index' ); - - }); - - /************************************************ - test parser cache - ************************************************/ - QUnit.test( 'parser cache; sorton methods; empty & string', function(assert) { - assert.expect(18); - $table1.trigger('sortReset'); - - // lower case because table was parsed before c1.ignoreCase was changed - assert.cacheCompare( table1, 'all', [ 'test2', 'x2', 'test1', 'x3', 'test3', 'x1', - '', 'x0', 'testb', 'x5', 'testc', 'x4', 'testa', 'x6' ], 'unsorted' ); - - $table1.trigger('sorton', [[[ 0,0 ]]]); - assert.cacheCompare( table1, 'all', [ 'test1', 'x3', 'test2', 'x2', 'test3', 'x1', - 'testa', 'x6', 'testb', 'x5', 'testc', 'x4', '', 'x0' ], 'ascending sort' ); - - $table1.trigger('sorton', [[[ 0,1 ]]]); - assert.cacheCompare( table1, 'all', [ 'test3', 'x1', 'test2', 'x2', 'test1', 'x3', - 'testc', 'x4', 'testb', 'x5', 'testa', 'x6', '', 'x0' ], 'descending sort' ); - - // empty cell position - $table3.trigger('sorton', [[[ 0,0 ]]]); - assert.cacheCompare( table3, 0, [ '', 'a1', 'a02', 'a10', 'a33', 'a43', 'a55', 'a87', 'a102', 'a255' ], 'asc sort; empty to top' ); - - $table3.trigger('sorton', [[[ 0,1 ]]]); - assert.cacheCompare( table3, 0, [ '', 'a255', 'a102', 'a87', 'a55', 'a43', 'a33', 'a10', 'a02', 'a1' ], 'desc sort; empty to top' ); - - // string position within number column - $table3.trigger('sorton', [[[ 1,0 ]]]); - assert.cacheCompare( table3, 1, [ -35, -5, -1, 1, 2, 4, 33, 44, 'nr', '' ], 'asc sort; empty to bottom; string to max' ); - - $table3.trigger('sorton', [[[ 1,1 ]]]); - assert.cacheCompare( table3, 1, [ 'nr', 44, 33, 4, 2, 1, -1, -5, -35, '' ], 'desc sort; empty to bottom; string to max' ); - - $table3.trigger('sorton', [[[ 2,0 ]]]); - assert.cacheCompare( table3, 2, [ 'nr', 'nr', 1, 2, 3, 4, 5, 6, 7, '' ], 'asc sort; empty to bottom; string to min' ); - - $table3.trigger('sorton', [[[ 2,1 ]]]); - assert.cacheCompare( table3, 2, [ 7, 6, 5, 4, 3, 2, 1, 'nr', 'nr', '' ], 'desc sort; empty to bottom; string to min' ); - - $table3.trigger('sorton', [[[ 3,0 ]]]); - assert.cacheCompare( table3, 3, [ 'n/a #2', 'n/a #1', -8.4, -2.2, -0.1, '', 5.2, 11.4, 23.6, 97.4 ], 'asc sort; empty to zero; string to top' ); - - $table3.trigger('sorton', [[[ 3,1 ]]]); - assert.cacheCompare( table3, 3, [ 'n/a #2', 'n/a #1', 97.4, 23.6, 11.4, 5.2, '', -0.1, -2.2, -8.4 ], 'desc sort; empty to zero; string to top' ); - - $table3.find('th:eq(3)').data('string', 'bottom'); - $table3.trigger('update'); - assert.cacheCompare( table3, 3, [ 97.4, 23.6, 11.4, 5.2, '', -0.1, -2.2, -8.4, 'n/a #1', 'n/a #2' ], 'desc sort; empty to zero; string to bottom' ); - - $table3.trigger('sorton', [[[ 3,0 ]]]); - assert.cacheCompare( table3, 3, [ -8.4, -2.2, -0.1, '', 5.2, 11.4, 23.6, 97.4, 'n/a #1', 'n/a #2' ], 'asc sort; empty to zero; string to bottom' ); - - $table3.find('th:eq(3)').data('string', 'none'); - c3.headers[3].empty = 'bottom'; - c3.sortList = [[ 3, 1 ]]; // added to test sortList - $table3.trigger('update'); - assert.cacheCompare( table3, 3, [ 97.4, 23.6, 11.4, 5.2, 'n/a #1', 'n/a #2', -0.1, -2.2, -8.4, '' ], 'desc sort; empty to zero; string to none/zero' ); - - $table3.trigger('sorton', [[[ 3,0 ]]]); - assert.cacheCompare( table3, 3, [ -8.4, -2.2, -0.1, 'n/a #1', 'n/a #2', 5.2, 11.4, 23.6, 97.4, '' ], 'asc sort; empty to zero; string to none/zero' ); - - t = [ 'x', 'X', 'y', 'Y', 'z', 'Z', 'a', 'A', 'b', 'B', 'c', 'C' ]; - assert.deepEqual( t.sort($.tablesorter.sortText), [ 'A', 'B', 'C', 'X', 'Y', 'Z', 'a', 'b', 'c', 'x', 'y', 'z' ], 'test sortText function directly' ); - - t = [ 'a02', 'a10', 'a43', 'a255', 'a102', 'a33', '', 'a1', 'a55', 'a87' ]; - assert.deepEqual( t.sort($.tablesorter.sortNatural), [ '', 'a1', 'a02', 'a10', 'a33', 'a43', 'a55', 'a87', 'a102', 'a255' ], 'test sortNatural function directly' ); - - assert.cacheCompare( table4, 6, [ '', '', '', '', '', '', '', '', '', '' ], 'parser-false does not extract text' ); - - }); - - QUnit.test( 'colspan parsing', function(assert) { - assert.expect(3); - - t = [ - 'g1', '6', 'a9', 155, 'l', 'nytimes', - 'g1', '2', 'z1 957 K mit', 'z1 957 K mit', 'z1 957 K mit', 'z1 957 K mit', // colspan 4 - 'g3', '0', 'a13', '17 K', '17 K', 'google', - 'g2', '8', 'z9', 10, 'g', 'facebook', - 'g1', '3', 'z24 67', 'z24 67', 'b', 'whitehouse', - 'g4', '7 A10', '7 A10', 87, 'z', 'google', - 'g3', '9', 'z12', 0, 'K nasa', 'K nasa' - ]; - assert.cacheCompare( table6,'all', t, 'colspans in tbody (duplicateSpan:true)' ); - - $('#testblock').html('' + - '' + - '' + - '' + - '' + - '' + - '
1234
123
yz
abc
') - .find('table') - .tablesorter({ - headers : { '*' : { sorter: 'text' } }, - duplicateSpan: false - }); - t = [ - '1', '2', '', '3', - 'y', '', '', 'z', - 'a', 'b', 'c', '' - ]; - assert.cacheCompare( $('#testblock table')[0], 'all', t, 'colspans not duplicated in cache (duplicateSpan:false)' ); - - // See http://stackoverflow.com/q/36449711/145346 - $('#testblock').html('' + - '' + - '' + - '' + - '' + - '' + - '
1234
123
y0y1y2z
abc1c2
') - .find('table') - .tablesorter({ - headers : { '*' : { sorter: 'text' } }, - textExtraction: function(node, table, cellIndex) { - var $span = $(node).find('.col' + cellIndex); - if ($span.length) { - return $span.text(); - } - return node.textContent; - }, - duplicateSpan: false - }); - t = [ - '1', '2', '2', '3', - 'y0', 'y1', 'y2', 'z', - 'a', 'b', 'c1', 'c2' - ]; - assert.cacheCompare( $('#testblock table')[0], 'all', t, 'colspans not duplicated but textExtraction defined' ); - }); - - QUnit.test( 'sorton methods', function(assert) { - assert.expect(6); - - $table3.trigger('sorton', [[[ 0,'d' ]]]); - assert.equal( c3.sortList + '', '0,1', 'sorton desc [0,"d"]' ); - - $table3.trigger('sorton', [[[ 0,'a' ]]]); - assert.equal( c3.sortList + '', '0,0', 'sorton asc [0,"a"]' ); - - $table3.trigger('sorton', [[[ 0,'n' ]]]); - assert.equal( c3.sortList + '', '0,1', 'sorton next [0,"n"]' ); - $table3.trigger('sorton', [[[ 0,'n' ]]]); - assert.equal( c3.sortList + '', '0,0', 'sorton next [0,"n"]' ); - - $table3.trigger('sorton', [[ [ 0,'n'], [1,'o'], [2,'s'] ]]); - assert.equal( c3.sortList + '', '0,1,1,0,2,1', 'sorton next/opposite/same [0,"n"],[1,"o"],[2,"s"]' ); - - $table3.trigger('sorton', [[ [ 0,'n'], [1,'o'], [2,'s'] ]]); - assert.equal( c3.sortList + '', '0,0,1,1,2,0', 'sorton next/opposite/same [0,"n"],[1,"o"],[2,"s"]' ); - - }); + var ts = $.tablesorter, + $table1 = $('#table1'), + $table2 = $('#table2'), + $table3 = $('#table3'), + $table4 = $('#table4'), + $table5 = $('#table5'), // empty table + $table6 = $('#table6'), // colspan table + table1 = $table1[0], + table2 = $table2[0], + table3 = $table3[0], + table4 = $table4[0], + table5 = $table5[0], + table6 = $table6[0], + th0 = $table1.find('th')[0], // first table header cell + init = false, + sortIndx = 0, + updateIndx = 0, + updateCallback = 0, + events = ['sortStart', 'sortBegin', 'sortEnd', ' '], + returnTime = function(string){ + return new Date(string).getTime(); + }, + undef, c1, c2, c3, c4, e, i, t; + + /* test widget */ + ts.addWidget({ + id : 'test', + options: { + 'test': [] + }, + format: function() {} + }); + + $table1 + .on('tablesorter-initialized', function(){ + init = true; + }) + .tablesorter({ + widgets: ['test'], + widgetOptions: { + // check widget option defaults across tables + test: [0,1] + } + }); + + $table2.tablesorter({ + headers: { + 0: { sorter: 'text' }, + 1: { sorter: 'text' }, + 2: { sorter: false } + }, + widgets: ['test'], + widgetOptions: { + // check widget option defaults across tables + test: [0] + } + }); + + $table3.tablesorter({ + emptyTo: 'bottom', + stringTo: 'max', // non-numeric content is treated as a MAX value + headers: { + 0: { empty : 'top' }, // sort empty cells to the top + 2: { string: 'min' }, // non-numeric content is treated as a MIN value + 3: { sorter: 'digit', empty : 'zero', string : 'top' } + }, + // check widget option defaults across tables + widgets: ['test'] + }); + + $table4.tablesorter({ + sortAppend : [[2,0],[3,0]], + sortForce : [[0,0],[1,0]], + textExtraction : { + '.te-test' : function(node){ + return $(node).find('span').text(); + }, + 2 : function(node){ + return $(node).find('span').text(); + } + }, + initialized: function(table){ + var e, c = table.config; + // trigger sort on 5th column + // this method is used because triggering a 'sorton' would ignore sortForce/sortAppend + c.$headers.eq(4).trigger('sort'); + e = $.Event('sort'); + e.which = 1; + e.shiftKey = true; + c.$headers.eq(5).trigger(e); + }, + numberSorter: function(a, b, dir){ + return dir ? a-b : b-a; + } + }); + + $table5.tablesorter(); + $table6.tablesorter(); + + QUnit.module('core'); + /************************************************ + Initialization + ************************************************/ + QUnit.test( 'tablesorter loaded & initialized', function(assert) { + assert.expect(3); + assert.equal( typeof ts, 'object', 'tablesorter loaded'); + assert.equal( table1.hasInitialized, true, 'tablesorter initialized flag'); + assert.equal( init, true, 'tablesorter initialized event'); + }); + + c1 = table1.config; + c2 = table2.config; + c3 = table3.config; + c4 = table4.config; + + /************************************************ + Test column numbering + ************************************************/ + // later: include a table header with colspan & rowspan + QUnit.test( 'column numbering', function(assert) { + assert.expect(2); + var internalColumn = true, + dataColumn = true; + $table4.find('thead th').each(function(i){ + internalColumn = internalColumn && this.column === i; + dataColumn = dataColumn && $(this).attr('data-column') == i; + }); + assert.equal( internalColumn, true, 'Correct internal column numbering' ); + assert.equal( dataColumn, true, 'Correct data-column attribute numbering' ); + }); + + /************************************************ + check isDigit function + ************************************************/ + var d = ts.isDigit; + QUnit.test( 'isDigit', function(assert) { + assert.expect(18); + assert.ok( d('-1'), 'allow negative (-1)'); + assert.ok( d('+1'), 'allow plus (+1)'); + assert.ok( d('(1)'), 'allow parenthesis (1)'); + assert.ok( d('123'), "string has numbers ('123')"); + assert.ok( d(123), 'has numbers (123)'); + assert.ok( d('1.2'), 'remove decimal (1.2)'); + assert.ok( d('1,234'),'remove commas (1,234)'); + assert.ok( d("11'"), "remove apostrophe's (11')"); // 11 feet + assert.ok( d('3\'4"'),"remove quotes (3'4\")"); // 3 foot 4 inches + assert.ok( d(' 12 '), 'remove spaces ( 12 )'); + assert.ok( !d('x'), 'non-digit alphabet'); + assert.ok( !d('1x'), 'digit + alphabet'); + assert.ok( !d('x1'), 'alphabet + digit'); + assert.ok( !d('@'), 'non-digit symbols'); + assert.ok( !d('1-'), 'negative after (1-) not allowed?'); + assert.ok( !d('1+'), 'plus after (1+) not allowed?'); + assert.ok( !d('$2'), 'no money; the currency parser will catch these'); + assert.ok( !d(''), "empty string ('')"); + }); + + /************************************************ + check formatFloat function + ************************************************/ + var ff = function(str) { + return ts.formatFloat(str, table1); + }; + QUnit.test( 'formatFloat', function(assert) { + assert.expect(18); + assert.strictEqual( ff(''), '', 'returns empty string' ); + assert.strictEqual( ff(5), 5, 'returns numerical values'); + + c1.usNumberFormat = false; + assert.strictEqual( ts.formatFloat('1,234,567.89'), 1234567.89, 'use format float without including table - defaults to US number format'); + + assert.strictEqual( ff('1 234,56'), 1234.56, 'parse non-U.S. (French) number format'); + assert.strictEqual( ff('1.234,56'), 1234.56, 'parse non-U.S. (German) number format'); + assert.strictEqual( ff('-32,32'), -32.32, 'negative non-U.S. signed numbers'); + assert.strictEqual( ff('-1.234,56'), -1234.56, 'negative non-U.S. signed numbers'); + assert.strictEqual( ff('(32,32)'), -32.32, 'parenthesis wrapped non-U.S. negative number'); + assert.strictEqual( ff(' (32,32) '), -32.32, 'space + parenthesis wrapped non-U.S. negative number'); + + c1.usNumberFormat = true; + assert.strictEqual( ff('1,234.56'), 1234.56, 'parse U.S. number format'); + assert.strictEqual( ff('-32.32'), -32.32, 'negative U.S. signed numbers'); + assert.strictEqual( ff('(32.32)'), -32.32, 'parenthesis wrapped U.S. negative number'); + assert.strictEqual( ff(' (32.32)'), -32.32, 'space + parenthesis wrapped U.S. negative number'); + + assert.strictEqual( ff('fred'), 'fred', 'return string if not a number'); + assert.strictEqual( ff(' fred '), 'fred', 'return trimmed string if not a number'); + assert.strictEqual( ff('fred 12'), 'fred 12', 'return string if number not at beginning'); + assert.strictEqual( ff('12fred'), 12, 'parse number + string into number only'); + assert.strictEqual( ff('(fred)'), '(fred)', 'leave parenthesis intact on strings'); + + }); + + /************************************************ + get data function - jQuery data > meta > headers option > header class name + ************************************************/ + var gd = function(n){ + return ts.getData( c2.$headers[n], c2.headers[n], 'sorter' ); + }; + + QUnit.test( 'getData', function(assert) { + assert.expect(4); + var txt = [ 'jQuery data', 'meta data', 'headers option', 'header class name' ]; + for (i = 0; i < 4; i++) { + assert.equal( gd(i), 'false', txt[i]); // all columns have sorter false set + } + }); + + /************************************************ + isValueInArray + ************************************************/ + + QUnit.test( 'isValueInArray', function(assert) { + var v = ts.isValueInArray; + assert.expect(6); + assert.ok( v( 0, null ) < 0, 'null' ); + assert.ok( v( 0, [] ) < 0, 'Empty array' ); + assert.ok( v( 1, [[ 1,0 ], [ 0,0 ]] ) === 0, 'Column found (first array)' ); + assert.ok( v( 1, [[ 0,0 ], [ 1,0 ]] ) === 1, 'Column found (second array)' ); + assert.ok( v( 4, [[ 0,0 ], [ 1,0 ], [ 4,0 ]] ) === 2, 'Column found (third array)' ); + assert.ok( v( 3, [[ 0,0 ], [ 1,0 ], [ 4,0 ]] ) < 0 , 'Column not found' ); + }); + + /************************************************ + isProcessing + ************************************************/ + QUnit.test( 'isProcessing', function(assert) { + $table3.trigger('sortReset'); + assert.expect(5); + var p = ts.isProcessing, + findClasses = function( applied, columns ) { + var i, tmp, + headers = 0, + len = columns.length, + headers = 0, + // if processing applied, class is added to the table + result = applied && $table3.hasClass( ts.css.processing ); + if ( len === 1 && columns[ 0 ] < 0 ) { + // processing class should not be found on headers + return ( !result || applied && result ) && c3.$headers.find( '.' + ts.css.processing ).length === 0; + } + for ( i = 0; i < len; i++ ) { + tmp = c3.$headers.eq( columns[ i ] ).hasClass( ts.css.processing ); + if ( tmp ) { headers++; } + result = result && tmp; + } + return result && headers === len; + }; + $table3.trigger('sorton', [[[0,0], [1,0]]]); + p( $table3, true ); + assert.ok( findClasses( true, [ 0, 1 ] ), 'Processing 2 columns' ); + p( $table3, false ); + assert.ok( findClasses( false, [ -1 ] ), 'No sort' ); + p( $table3, true, c3.$headers.eq(4) ); + assert.ok( findClasses( true, [ -1 ] ), 'Processing specified column not in sortList' ); + p( $table3, true, c3.$headers.eq(1) ); + assert.ok( findClasses( true, [ 1 ] ), 'Processing specified column in sortList' ); + $table3.trigger('sortReset'); + assert.ok( findClasses( false, [ -1 ] ), 'No sort' ); + }); + + /************************************************ + character equivalent replacement + ************************************************/ + QUnit.test( 'replace accents', function(assert) { + assert.expect(6); + assert.strictEqual( ts.replaceAccents('\u00e1\u00e0\u00e2\u00e3\u00e4\u0105\u00e5\u00c1\u00c0\u00c2\u00c3\u00c4\u0104\u00c5'), 'aaaaaaaAAAAAAA', "replaced a's"); + assert.strictEqual( ts.replaceAccents('\u00e9\u00e8\u00ea\u00eb\u011b\u0119\u00c9\u00c8\u00ca\u00cb\u011a\u0118'), 'eeeeeeEEEEEE', "replaced e's"); + assert.strictEqual( ts.replaceAccents('\u00ed\u00ec\u0130\u00ee\u00ef\u0131\u00cd\u00cc\u0130\u00ce\u00cf'), 'iiiiiiIIiII', "replaced i's"); + assert.strictEqual( ts.replaceAccents('\u00f3\u00f2\u00f4\u00f5\u00f6\u00d3\u00d2\u00d4\u00d5\u00d6'), 'oooooOOOOO', "replaced o's"); + assert.strictEqual( ts.replaceAccents('\u00fa\u00f9\u00fb\u00fc\u016f\u00da\u00d9\u00db\u00dc\u016e'), 'uuuuuUUUUU', "replaced u's"); + assert.strictEqual( ts.replaceAccents('\u00e7\u0107\u010d\u00c7\u0106\u010c\u00df\u1e9e'), 'cccCCCssSS', 'replaced c & s sharp'); + }); + + /************************************************ + detect parsers + ************************************************/ + QUnit.test( 'detect parsers', function(assert) { + var done = assert.async(); + assert.expect(2); + $('#testblock2').html('' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
InfoDetails
First NameLast NameAgeTotalDiscountDate
PeterParker28$9.9920%Jul 6, 2006 8:14 AM
JohnHood33$19.9925%Dec 10, 2002 5:14 AM
ClarkKent18$15.8944%Jan 12, 2003 11:14 AM
BruceAlmighty45$153.1944%Jan 18, 2001 9:12 AM
BruceEvans22$13.1911%Jan 18, 2007 9:12 AM
') + .find('table') + .tablesorter({ + headers : { + 0 : { sorter: false }, + 1 : { sorter: false }, + 3 : { sorter: 'digit' } // 3 sets the 4th column, not the 3rd header cell now + }, + initialized: function(table){ + var i, + result = true, + parsers = [ 'text', 'digit', 'digit', 'currency', 'percent', 'usLongDate' ], + c = table.config; + for (i = 0; i < c.columns; i++){ + result = result && c.parsers[i].id === parsers[i]; + } + assert.equal( result, true, 'detect parsers by header index' ); + // table inception! + $(table) + .trigger('destroy') + .tablesorter({ + headers : { + '.col-first' : { sorter: 'url' }, + '.col-off' : { sorter: false }, + '.col-total' : { sorter : 'percent' }, + '#age, .col-last' : { sorter: 'currency' }, + '.col-date' : { sorter : 'time' }, + '.col-discount' : { sorter: 'digit' } + }, + initialized: function(table){ + var i, + result = true, + parsers = [ 'url', 'currency', 'currency', 'percent', 'digit', 'time' ], + c = table.config; + for (i = 0; i < c.columns; i++){ + result = result && c.parsers[i].id === parsers[i]; + } + assert.equal( result, true, 'detect parsers by class/id' ); + done(); + } + }); + } + }); + + }); + + /************************************************ + check all default parsers + ************************************************/ + var p = ts.parsers, + // test by parser + parserTests = 86, + // skipping metadata parser + sample1 = { + 'text' : { 'test': 'test', 'TesT': 'test', '\u00e1 test': '\u00e1 test' }, + 'currency' : { '\u00a31': 1, '($2.23)': -2.23, '5\u20ac': 5, '(11\u00a4)': -11, '500\u00a5': 500, '25\u00a2': 25, '$1,000.50': 1000.5 }, + 'ipAddress' : { '255.255.255.255': 255255255255, '32.32.32.32': 32032032032, '1.1.1.1': 1001001001 }, + 'url' : { 'http://google.com': 'google.com', 'ftp://fred.com': 'fred.com', 'https://github.com': 'github.com' }, + 'isoDate' : { '2012/12/12': returnTime('2012/12/12'), '2012-12/12': returnTime('2012/12/12'), '2013-1-1': returnTime('2013/1/1'), '2013/1/1 12:34:56 AM': returnTime('2013/1/1 12:34:56 AM') }, + 'percent' : { '100%': 100, '22%': 22, '%2': 2, '2 %': 2, '(4%)': -4, '1,234.56 %': 1234.56 }, + 'usLongDate': { 'Feb 23, 1999': returnTime('Feb 23, 1999'), 'Feb 23, 1999 12:34': returnTime('Feb 23, 1999 12:34'), 'Feb 23, 1999 12:34 AM': returnTime('Feb 23, 1999 12:34 AM'), 'Feb 23, 1999 12:34:56 PM': returnTime('Feb 23, 1999 12:34:56 PM'), '01 Jan 2013': returnTime('01 Jan 2013') }, + 'shortDate' : { '1/2/2001': returnTime('1/2/2001'), '1 2 2001': returnTime('1/2/2001'), '1.2.2001': returnTime('1/2/2001'), '1-2-2001': returnTime('1/2/2001'), '1/2/2001 12:34 PM' : returnTime('1/2/2001 12:34 PM'), '1.2.2001 13:34' : returnTime('1/2/2001 13:34') }, + 'time' : { '12:34 AM': returnTime('2000/01/01 12:34 AM'), '1:00 pm': returnTime('2000/01/01 1:00 pm'), '09:54 PM': returnTime('2000/01/01 9:54 PM') }, + 'digit' : { '12': 12, '$23': 23, '&44^': 44, '#(33)': -33, '1,000': 1000, '12.34': 12.34 } + }, + // switch ignoreCase, sortLocalCompare & shortDate 'ddmmyyyy' + sample2 = { + 'text' : { 'TesT': 'TesT', '\u00e1 test': 'a test' }, + 'currency' : { '\u20ac 123 456,78': 123456.78, '\u20ac 123.456,78': 123456.78 }, + 'shortDate' : { '2/1/2001': returnTime('1/2/2001'), '2-1-2001': returnTime('1/2/2001'), '2 1,2001': returnTime('1/2/2001') } + }, + // shortdate to 'yyyymmdd' + sample3 = { + 'shortDate' : { '2001/1/2': returnTime('1/2/2001'), '2001-1/2': returnTime('1/2/2001'), '2001,1.2': returnTime('1/2/2001') } + }, + report = function(assert, s) { + for (i = 0; i < p.length; i++) { + t = p[i].id; + if (s.hasOwnProperty(t)) { + /*jshint loopfunc:true */ + $.each(s[t], function(k,v){ + // check 'is' and 'format' functions + if (p[i].is(k)) { + assert.equal( p[i].format(k, table1, th0, 0), v, t + ' parser: "' + k + '" parsed to ' + v ); + } else { + assert.equal( p[i].format(k, table1, th0, 0), v, t + ' parser **NOT DETECTED**: "' + k + '", but returns ' + v ); + } + }); + // test for undefined & null - probably overkill + assert.strictEqual( p[i].format(undef, table1, th0, 0), undef, t + ' parser: will return undefined values properly' ); + assert.strictEqual( p[i].format(null, table1, th0, 0), null, t + ' parser: will return null values properly' ); + } + } + }; + + QUnit.test( 'testing parsers', function(assert) { + assert.expect(parserTests); + report(assert, sample1); + var $t = $(th0); + + c1.sortLocaleCompare = true; + c1.ignoreCase = false; + c1.usNumberFormat = false; + $t.data('dateFormat', 'ddmmyyyy'); + report(assert, sample2); + + c1.usNumberFormat = true; + $t.data('dateFormat', 'yyyymmdd'); + report(assert, sample3); + + // undocumented sortValue + assert.equal( ts.getParserById('metadata').format(null, table1, th0, 0), 'zzz', 'metadata parser found sortValue'); + c1.parserMetadataName = 'poe'; + assert.equal( ts.getParserById('metadata').format(null, table1, th0, 0), 'nevermore', 'metadata parser found poe'); + }); + + QUnit.test( 'textExtraction Method', function(assert) { + assert.expect(4); + + $table1.trigger('sorton', [[[ 0,0 ]]]); + assert.cacheCompare( table1, 0, [ 'test1', 'test2', 'test3', + 'testa', 'testb', 'testc', '' ], 'from data-attribute' ); + + $table3.trigger('sorton', [[[ 0,1 ]]]); + assert.cacheCompare( table3, 0, [ '', 'a255', 'a102', 'a87', 'a55', 'a43', 'a33', 'a10', 'a02', 'a1' ], 'ignore data-attribute' ); + + assert.cacheCompare( table4, 1, [ 'f11', 'f11', 'f12', 'f12', 'f12', 'f12', 'f12', 'f13', 'f13', 'f13' ], 'extract using class name' ); + + assert.cacheCompare( table4, 2, [ 'a21', 'a21', 'a23', 'a23', 'a23', 'a22', 'a22', 'a23', 'a24', 'a24' ], 'extract using column index' ); + + }); + + /************************************************ + test parser cache + ************************************************/ + QUnit.test( 'parser cache; sorton methods; empty & string', function(assert) { + assert.expect(18); + $table1.trigger('sortReset'); + + // lower case because table was parsed before c1.ignoreCase was changed + assert.cacheCompare( table1, 'all', [ 'test2', 'x2', 'test1', 'x3', 'test3', 'x1', + '', 'x0', 'testb', 'x5', 'testc', 'x4', 'testa', 'x6' ], 'unsorted' ); + + $table1.trigger('sorton', [[[ 0,0 ]]]); + assert.cacheCompare( table1, 'all', [ 'test1', 'x3', 'test2', 'x2', 'test3', 'x1', + 'testa', 'x6', 'testb', 'x5', 'testc', 'x4', '', 'x0' ], 'ascending sort' ); + + $table1.trigger('sorton', [[[ 0,1 ]]]); + assert.cacheCompare( table1, 'all', [ 'test3', 'x1', 'test2', 'x2', 'test1', 'x3', + 'testc', 'x4', 'testb', 'x5', 'testa', 'x6', '', 'x0' ], 'descending sort' ); + + // empty cell position + $table3.trigger('sorton', [[[ 0,0 ]]]); + assert.cacheCompare( table3, 0, [ '', 'a1', 'a02', 'a10', 'a33', 'a43', 'a55', 'a87', 'a102', 'a255' ], 'asc sort; empty to top' ); + + $table3.trigger('sorton', [[[ 0,1 ]]]); + assert.cacheCompare( table3, 0, [ '', 'a255', 'a102', 'a87', 'a55', 'a43', 'a33', 'a10', 'a02', 'a1' ], 'desc sort; empty to top' ); + + // string position within number column + $table3.trigger('sorton', [[[ 1,0 ]]]); + assert.cacheCompare( table3, 1, [ -35, -5, -1, 1, 2, 4, 33, 44, 'nr', '' ], 'asc sort; empty to bottom; string to max' ); + + $table3.trigger('sorton', [[[ 1,1 ]]]); + assert.cacheCompare( table3, 1, [ 'nr', 44, 33, 4, 2, 1, -1, -5, -35, '' ], 'desc sort; empty to bottom; string to max' ); + + $table3.trigger('sorton', [[[ 2,0 ]]]); + assert.cacheCompare( table3, 2, [ 'nr', 'nr', 1, 2, 3, 4, 5, 6, 7, '' ], 'asc sort; empty to bottom; string to min' ); + + $table3.trigger('sorton', [[[ 2,1 ]]]); + assert.cacheCompare( table3, 2, [ 7, 6, 5, 4, 3, 2, 1, 'nr', 'nr', '' ], 'desc sort; empty to bottom; string to min' ); + + $table3.trigger('sorton', [[[ 3,0 ]]]); + assert.cacheCompare( table3, 3, [ 'n/a #2', 'n/a #1', -8.4, -2.2, -0.1, '', 5.2, 11.4, 23.6, 97.4 ], 'asc sort; empty to zero; string to top' ); + + $table3.trigger('sorton', [[[ 3,1 ]]]); + assert.cacheCompare( table3, 3, [ 'n/a #2', 'n/a #1', 97.4, 23.6, 11.4, 5.2, '', -0.1, -2.2, -8.4 ], 'desc sort; empty to zero; string to top' ); + + $table3.find('th:eq(3)').data('string', 'bottom'); + $table3.trigger('update'); + assert.cacheCompare( table3, 3, [ 97.4, 23.6, 11.4, 5.2, '', -0.1, -2.2, -8.4, 'n/a #1', 'n/a #2' ], 'desc sort; empty to zero; string to bottom' ); + + $table3.trigger('sorton', [[[ 3,0 ]]]); + assert.cacheCompare( table3, 3, [ -8.4, -2.2, -0.1, '', 5.2, 11.4, 23.6, 97.4, 'n/a #1', 'n/a #2' ], 'asc sort; empty to zero; string to bottom' ); + + $table3.find('th:eq(3)').data('string', 'none'); + c3.headers[3].empty = 'bottom'; + c3.sortList = [[ 3, 1 ]]; // added to test sortList + $table3.trigger('update'); + assert.cacheCompare( table3, 3, [ 97.4, 23.6, 11.4, 5.2, 'n/a #1', 'n/a #2', -0.1, -2.2, -8.4, '' ], 'desc sort; empty to zero; string to none/zero' ); + + $table3.trigger('sorton', [[[ 3,0 ]]]); + assert.cacheCompare( table3, 3, [ -8.4, -2.2, -0.1, 'n/a #1', 'n/a #2', 5.2, 11.4, 23.6, 97.4, '' ], 'asc sort; empty to zero; string to none/zero' ); + + t = [ 'x', 'X', 'y', 'Y', 'z', 'Z', 'a', 'A', 'b', 'B', 'c', 'C' ]; + assert.deepEqual( t.sort($.tablesorter.sortText), [ 'A', 'B', 'C', 'X', 'Y', 'Z', 'a', 'b', 'c', 'x', 'y', 'z' ], 'test sortText function directly' ); + + t = [ 'a02', 'a10', 'a43', 'a255', 'a102', 'a33', '', 'a1', 'a55', 'a87' ]; + assert.deepEqual( t.sort($.tablesorter.sortNatural), [ '', 'a1', 'a02', 'a10', 'a33', 'a43', 'a55', 'a87', 'a102', 'a255' ], 'test sortNatural function directly' ); + + assert.cacheCompare( table4, 6, [ '', '', '', '', '', '', '', '', '', '' ], 'parser-false does not extract text' ); + + }); + + QUnit.test( 'colspan parsing', function(assert) { + assert.expect(3); + + t = [ + 'g1', '6', 'a9', 155, 'l', 'nytimes', + 'g1', '2', 'z1 957 K mit', 'z1 957 K mit', 'z1 957 K mit', 'z1 957 K mit', // colspan 4 + 'g3', '0', 'a13', '17 K', '17 K', 'google', + 'g2', '8', 'z9', 10, 'g', 'facebook', + 'g1', '3', 'z24 67', 'z24 67', 'b', 'whitehouse', + 'g4', '7 A10', '7 A10', 87, 'z', 'google', + 'g3', '9', 'z12', 0, 'K nasa', 'K nasa' + ]; + assert.cacheCompare( table6,'all', t, 'colspans in tbody (duplicateSpan:true)' ); + + $('#testblock').html('' + + '' + + '' + + '' + + '' + + '' + + '
1234
123
yz
abc
') + .find('table') + .tablesorter({ + headers : { '*' : { sorter: 'text' } }, + duplicateSpan: false + }); + t = [ + '1', '2', '', '3', + 'y', '', '', 'z', + 'a', 'b', 'c', '' + ]; + assert.cacheCompare( $('#testblock table')[0], 'all', t, 'colspans not duplicated in cache (duplicateSpan:false)' ); + + // See http://stackoverflow.com/q/36449711/145346 + $('#testblock').html('' + + '' + + '' + + '' + + '' + + '' + + '
1234
123
y0y1y2z
abc1c2
') + .find('table') + .tablesorter({ + headers : { '*' : { sorter: 'text' } }, + textExtraction: function(node, table, cellIndex) { + var $span = $(node).find('.col' + cellIndex); + if ($span.length) { + return $span.text(); + } + return node.textContent; + }, + duplicateSpan: false + }); + t = [ + '1', '2', '2', '3', + 'y0', 'y1', 'y2', 'z', + 'a', 'b', 'c1', 'c2' + ]; + assert.cacheCompare( $('#testblock table')[0], 'all', t, 'colspans not duplicated but textExtraction defined' ); + }); + + QUnit.test( 'sorton methods', function(assert) { + assert.expect(6); + + $table3.trigger('sorton', [[[ 0,'d' ]]]); + assert.equal( c3.sortList + '', '0,1', 'sorton desc [0,"d"]' ); + + $table3.trigger('sorton', [[[ 0,'a' ]]]); + assert.equal( c3.sortList + '', '0,0', 'sorton asc [0,"a"]' ); + + $table3.trigger('sorton', [[[ 0,'n' ]]]); + assert.equal( c3.sortList + '', '0,1', 'sorton next [0,"n"]' ); + $table3.trigger('sorton', [[[ 0,'n' ]]]); + assert.equal( c3.sortList + '', '0,0', 'sorton next [0,"n"]' ); + + $table3.trigger('sorton', [[ [ 0,'n'], [1,'o'], [2,'s'] ]]); + assert.equal( c3.sortList + '', '0,1,1,0,2,1', 'sorton next/opposite/same [0,"n"],[1,"o"],[2,"s"]' ); + + $table3.trigger('sorton', [[ [ 0,'n'], [1,'o'], [2,'s'] ]]); + assert.equal( c3.sortList + '', '0,0,1,1,2,0', 'sorton next/opposite/same [0,"n"],[1,"o"],[2,"s"]' ); + + }); /* - QUnit.test( 'sort Restart', function(assert) { - assert.expect(1); - var done = assert.async(); - c1.sortRestart = true; - QUnit.start(); - $.tablesorter.sortReset( c1, function(){ - // 1) click on header one - $table1.one('sortEnd', function(){ - // 2) click on header zero - $table1.one('sortEnd', function(){ - // 3) click on header one, sortRestart should have set it back to ascending sort - // see #1072 - $table1.one('sortEnd', function(){ - assert.equal( c1.$headers[1].className.indexOf( ts.css.sortAsc ) > -1, true ); - c1.sortRestart = false; - done(); - }); - c1.$headers.eq(1).click(); - }); - c1.$headers.eq(0).click(); - }); - c1.$headers.eq(1).click(); - }); - }); + QUnit.test( 'sort Restart', function(assert) { + assert.expect(1); + var done = assert.async(); + c1.sortRestart = true; + QUnit.start(); + $.tablesorter.sortReset( c1, function(){ + // 1) click on header one + $table1.one('sortEnd', function(){ + // 2) click on header zero + $table1.one('sortEnd', function(){ + // 3) click on header one, sortRestart should have set it back to ascending sort + // see #1072 + $table1.one('sortEnd', function(){ + assert.equal( c1.$headers[1].className.indexOf( ts.css.sortAsc ) > -1, true ); + c1.sortRestart = false; + done(); + }); + c1.$headers.eq(1).click(); + }); + c1.$headers.eq(0).click(); + }); + c1.$headers.eq(1).click(); + }); + }); */ - QUnit.test( 'sort Events', function(assert) { - assert.expect(1); - - $table1.add($table5).on( events.join('.testing '), function(e){ - if (e.type === events[sortIndx%3]) { - sortIndx++; - } - }); - - $table1.trigger('sorton', [[[ 0,0 ]]]); - $table1.trigger('sorton', [[[ 1,0 ]]]); - - // ensure all sort events fire on an empty table - $table5.trigger('sorton', [ [[0,0]] ]); - - $table1.add($table5).off( events.join('.testing ') ); - - // table1 sorted twice in the above test; sortIndx = 9 then empty table5 x1 (total = 3 events x 3) - assert.equal( sortIndx, 9, 'sortStart, sortBegin & sortEnd fired in order x2; including empty table' ); - }); - - /************************************************ - test update methods - ************************************************/ - QUnit.test( 'parser cache; update methods & callbacks', function(assert) { - assert.expect(12); - var oldColMax; - c1.ignoreCase = true; - // updateAll - $table1 - .trigger('sorton', [ [[0,1]] ]) - .on('updateComplete.testing', function(){ updateIndx++; }) - .find('th:eq(1)').removeAttr('class').html('num').end() - .find('td:nth-child(2)').html(function(i,h){ - return h.substring(1); - }); - $table1 - .trigger('updateAll', [false, function(){ - updateCallback++; - var nw = $table1.find('th:eq(1)')[0], - ht = c1.$headers.eq(1).text() === 'num' - hc = c1.headerContent[1] === 'num', - hd = c1.$headers[1] === nw, - hl = c1.headerList[1] === nw, - p1 = c1.parsers[1].id === 'digit'; - assert.equal(ht && hc && hd && hl && p1, true, 'testing header cache: updateAll - thead'); - assert.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3, - 'testc', 4, 'testb', 5, 'testa', 6, '', 0 ], 'updateAll - tbody' ); - }]); - - // updateHeader v2.23.0 - $table1 - .find('th:eq(1)').html('x-num').end() - .trigger('updateHeaders', function(){ - updateCallback++; - var nw = $table1.find('th:eq(1)')[0], - ht = c1.$headers.eq(1).text() === 'x-num', - hc = c1.headerContent[1] === 'x-num', - hd = c1.$headers[1] === nw, - hl = c1.headerList[1] === nw; - assert.equal(ht && hc && hd && hl, true, 'testing header cache: updateHeaders'); - }); - - // addRows - t = $('testd7'); - $table1.find('tbody:last').prepend(t); - oldColMax = c1.cache[1].colMax[1]; - $table1.trigger('addRows', [t, true, function(){ - updateCallback++; - assert.equal( oldColMax === 6 && c1.cache[1].colMax[1] === 7, true, 'addRows includes updating colMax value'); - assert.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3, - 'testd', 7, 'testc', 4, 'testb', 5, 'testa', 6, '', 0 ], 'addRows method' ); - }]); - // the next two methods shouldn't do anything; especially not cause a javascript error! - $table1.trigger('addRows', [null, true]); - $table1.trigger('addRows', [$(''), true]); - - // addRows as string to table with only one tbody - t = 'ghij'; - $table2.trigger('addRows', [t, true, function(){ - assert.cacheCompare( table2, 'all', [ 'a', 'b', 'c', 'd', - 'z', 'y', 'x', 'w', - 'g', 'h', 'i', 'j' ], 'addRows as string method' ); - }]); - $table2.find('tr.temp').remove(); - - // updateCell - t = $table1.find('td:contains("7")'); - t.html('-8'); - oldColMax = c1.cache[1].colMax[1]; - $table1.trigger('updateCell', [t[0], true, function(){ - updateCallback++; - assert.equal( oldColMax === 7 && c1.cache[1].colMax[1] === 8, true, 'updateCell includes updating colMax value'); - assert.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3, - 'testd', -8, 'testc', 4, 'testb', 5, 'testa', 6, '', 0 ], 'updateCell method' ); - }]); - - // update - $table1.find('tr.temp').remove(); - oldColMax = c1.cache[1].colMax[1]; - $table1.trigger('update', [true, function(){ - updateCallback++; - assert.equal( oldColMax === 8 && c1.cache[1].colMax[1] === 6, true, 'update includes updating colMax value'); - assert.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3, - 'testc', 4, 'testb', 5, 'testa', 6, '', 0 ], 'update method' ); - }]); - - $table5 - .on('updateComplete.testing', function(){ updateIndx++; }) - .trigger('update', [true, function(){ - updateCallback++; - assert.cacheCompare( table5, 'all', [], 'update method on empty table' ); - }]); - - $table1.add($table5).off('updateComplete.testing'); - - // table1 updated 4x in the above test - // table5 updated 1x - assert.equal( updateIndx, updateCallback, 'updatedComplete and update callback functions working properly' ); - - }); - - /************************************************ - test sortForce, sortAppend, sortMultiSortKey and sortResetKey options - ************************************************/ - QUnit.test( 'sortForce, sortAppend, sortMultiSortKey & sortResetKey; and numberSorter option', function(assert){ - assert.expect(3); - - assert.cacheCompare( table4, 3, [ 2, 1, 7, 6, 5, 3, 4, 8, 9, 10 ], 'force x2 + sorted x2 + append x2, ascending' ); - - return QUnit.SequentialRunner( - function(actions, assertions){ - return QUnit.assertOnEvent($table4, 'sortEnd', actions, assertions); - } - ).nextTask( - function(){ - c4.sortMultiSortKey = 'altKey'; - c4.$headers.eq(5).trigger( $.Event('sort', { which: 1, altKey: true }) ); - }, - function(){ - assert.cacheCompare( table4, 3, [ 2, 1, 6, 7, 5, 4, 3, 8, 10, 9 ], 'force x2 + sorted x2 + append x2, descending' ); - } - ).nextTask( - function() { - c4.sortResetKey = 'shiftKey'; - c4.$headers.eq(0).trigger( $.Event('sort', {which: 1, shiftKey: true}) ); - }, - function() { - assert.cacheCompare( table4, 3, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'sortResetKey' ); - } - ).promise(); - }); - - /************************************************ - check header css - ************************************************/ - QUnit.test( 'testing header css & sortReset method', function(assert) { - assert.expect(7); - t = $(th0); - assert.equal( $table1.hasClass(ts.css.table), true, 'table class applied'); - assert.equal( t.hasClass(ts.css.header), true, 'Header class present' ); - assert.equal( t.parent().hasClass(ts.css.headerRow), true, 'Header row class present' ); - assert.equal( $table1.find('tbody:eq(1)').hasClass(c1.cssInfoBlock), true, 'Tbody info block class present' ); - $table1.trigger('sorton', [[[ 0,1 ]]] ); - assert.equal( t.hasClass(ts.css.sortDesc), true, 'Descending class present' ); - $table1.trigger('sorton', [[[ 0,0 ]]] ); - assert.equal( t.hasClass(ts.css.sortAsc), true, 'Ascending class present' ); - $table1.trigger('sortReset'); - assert.equal( t.hasClass(ts.css.sortAsc) || t.hasClass(ts.css.sortDesc), false, 'Testing sortReset' ); - }); - - QUnit.test( 'testing header css icons', function(assert) { - var done = assert.async(); - assert.expect(1); - $('#testblock2').html('' + - '' + - '' + - '' + - '' + - '
ABCD
') - .find('table') - .tablesorter({ - sortList: [[0,0], [1,1]], - headerTemplate:'{content} {icon}', - cssIconAsc: 'asc', - cssIconDesc: 'desc', - cssIconNone: 'none', - cssIconDisabled: 'disabled', - initialized: function(table){ - var i, - results = [], - expected = ['asc', 'desc', 'none', 'disabled'], - c = table.config; - for (i = 0; i < c.columns; i++){ - results[i] = c.$headers.eq(i).find('.' + ts.css.icon).hasClass(expected[i]); - } - assert.deepEqual( results, [true, true, true, true], 'applies correct cssIcon classes' ); - done(); - } - }); - }); - - /************************************************ - test apply widgets function using zebra widget - ************************************************/ - var zebra = function(){ - t = true; - var classes = ['odd','even']; - $table2.find('tbody tr').each(function(i){ - t = t ? $(this).hasClass( classes[i%2] ) : false; - }); - return t; - }; - - QUnit.test( 'check widgetOption defaults across tables', function(assert) { - assert.expect(4); - assert.deepEqual(c1.widgetOptions.test, [0,1], 'widget option properly set'); - assert.deepEqual(c2.widgetOptions.test, [0], 'widget option properly set'); - assert.deepEqual(c3.widgetOptions.test, [], 'default widget option set on table'); - assert.deepEqual(ts.defaults.widgetOptions.test, [], 'default widget option set in core'); - }); - - QUnit.test( 'apply zebra widget', function(assert) { - assert.expect(3); - assert.equal( zebra(), false, 'zebra not applied' ); - c2.widgets = [ 'zebra' ]; - $table2.trigger('applyWidgets'); - assert.equal( zebra(), true, 'zebra is applied' ); - $table2 - .append('stuv') - .trigger('update'); - assert.equal( zebra(), true, 'zebra is applied after update' ); - }); - - /************************************************ - test has widget function - ************************************************/ - QUnit.test( 'has & remove zebra widget', function(assert) { - assert.expect(3); - c2.widgets = [ 'zebra' ]; - $table2.trigger('applyWidgets'); - assert.equal( ts.hasWidget( table2, 'zebra'), true, 'table has zebra widget (using table element object)' ); - assert.equal( ts.hasWidget( $table2, 'zebra'), true, 'table has zebra widget (using jQuery table object)' ); - ts.removeWidget( table2, 'zebra' ); - assert.equal( zebra() && c2.widgets.length === 0, false, 'zebra removed' ); - }); - - /************************************************ - check destroy method - ************************************************/ - QUnit.test('testing destroy method', function(assert) { - $table2.trigger('sorton', [[[ 0,1 ]]] ); - $table2.trigger('destroy'); - assert.expect(7); - t = $table2.find('th:first'); - e = jQuery._data(table2, 'events'); // get a list of all bound events - assert.equal( $.isEmptyObject(e), true, 'no events applied' ); - assert.equal( $table2.data().hasOwnProperty('tablesorter'), false, 'Data removed' ); - assert.equal( $table2.attr('class'), 'tester', 'All table classes removed' ); - assert.equal( $table2.find('tr:first').attr('class'), '', 'Header row class removed' ); - assert.equal( t.attr('class').match('tablesorter'), null, 'Header classes removed' ); - assert.equal( t.children().length, 0, 'Inner wrapper removed' ); - assert.equal( typeof (t.data().column) , 'undefined', 'data-column removed'); - - $table2.tablesorter(); - }); - - /************************************************ - extract widgets from table class - ************************************************/ - QUnit.test('extract widget names from table class', function(assert) { - assert.expect(2); - var widgets, - t = { - className: 'widget-filter widget-stickyHeaders ui-widget-content widget-test-2', - config: { - widgetClass: 'widget-{name}', - widgets: [] - } - }; - ts.addWidgetFromClass( t ); - assert.deepEqual( t.config.widgets, [ 'filter', 'stickyHeaders', 'test-2' ], 'Ignored "ui-widget-content"' ); - - t.className = 'stickyHeaders-widgey ui-widgey-content filter-widgey test-2-widgey'; - t.config.widgetClass = '{name}-widgey'; - t.config.widgets = []; - ts.addWidgetFromClass( t ); - assert.deepEqual( t.config.widgets, [ 'stickyHeaders', 'filter', 'test-2' ], 'Modified widgetClass option' ); - - }); - - - /************************************************ - ipv6 parser testing - ************************************************/ - ipv6tests(); + QUnit.test( 'sort Events', function(assert) { + assert.expect(1); + + $table1.add($table5).on( events.join('.testing '), function(e){ + if (e.type === events[sortIndx%3]) { + sortIndx++; + } + }); + + $table1.trigger('sorton', [[[ 0,0 ]]]); + $table1.trigger('sorton', [[[ 1,0 ]]]); + + // ensure all sort events fire on an empty table + $table5.trigger('sorton', [ [[0,0]] ]); + + $table1.add($table5).off( events.join('.testing ') ); + + // table1 sorted twice in the above test; sortIndx = 9 then empty table5 x1 (total = 3 events x 3) + assert.equal( sortIndx, 9, 'sortStart, sortBegin & sortEnd fired in order x2; including empty table' ); + }); + + /************************************************ + test update methods + ************************************************/ + QUnit.test( 'parser cache; update methods & callbacks', function(assert) { + assert.expect(12); + var oldColMax; + c1.ignoreCase = true; + // updateAll + $table1 + .trigger('sorton', [ [[0,1]] ]) + .on('updateComplete.testing', function(){ updateIndx++; }) + .find('th:eq(1)').removeAttr('class').html('num').end() + .find('td:nth-child(2)').html(function(i,h){ + return h.substring(1); + }); + $table1 + .trigger('updateAll', [false, function(){ + updateCallback++; + var nw = $table1.find('th:eq(1)')[0], + ht = c1.$headers.eq(1).text() === 'num' + hc = c1.headerContent[1] === 'num', + hd = c1.$headers[1] === nw, + hl = c1.headerList[1] === nw, + p1 = c1.parsers[1].id === 'digit'; + assert.equal(ht && hc && hd && hl && p1, true, 'testing header cache: updateAll - thead'); + assert.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3, + 'testc', 4, 'testb', 5, 'testa', 6, '', 0 ], 'updateAll - tbody' ); + }]); + + // updateHeader v2.23.0 + $table1 + .find('th:eq(1)').html('x-num').end() + .trigger('updateHeaders', function(){ + updateCallback++; + var nw = $table1.find('th:eq(1)')[0], + ht = c1.$headers.eq(1).text() === 'x-num', + hc = c1.headerContent[1] === 'x-num', + hd = c1.$headers[1] === nw, + hl = c1.headerList[1] === nw; + assert.equal(ht && hc && hd && hl, true, 'testing header cache: updateHeaders'); + }); + + // addRows + t = $('testd7'); + $table1.find('tbody:last').prepend(t); + oldColMax = c1.cache[1].colMax[1]; + $table1.trigger('addRows', [t, true, function(){ + updateCallback++; + assert.equal( oldColMax === 6 && c1.cache[1].colMax[1] === 7, true, 'addRows includes updating colMax value'); + assert.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3, + 'testd', 7, 'testc', 4, 'testb', 5, 'testa', 6, '', 0 ], 'addRows method' ); + }]); + // the next two methods shouldn't do anything; especially not cause a javascript error! + $table1.trigger('addRows', [null, true]); + $table1.trigger('addRows', [$(''), true]); + + // addRows as string to table with only one tbody + t = 'ghij'; + $table2.trigger('addRows', [t, true, function(){ + assert.cacheCompare( table2, 'all', [ 'a', 'b', 'c', 'd', + 'z', 'y', 'x', 'w', + 'g', 'h', 'i', 'j' ], 'addRows as string method' ); + }]); + $table2.find('tr.temp').remove(); + + // updateCell + t = $table1.find('td:contains("7")'); + t.html('-8'); + oldColMax = c1.cache[1].colMax[1]; + $table1.trigger('updateCell', [t[0], true, function(){ + updateCallback++; + assert.equal( oldColMax === 7 && c1.cache[1].colMax[1] === 8, true, 'updateCell includes updating colMax value'); + assert.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3, + 'testd', -8, 'testc', 4, 'testb', 5, 'testa', 6, '', 0 ], 'updateCell method' ); + }]); + + // update + $table1.find('tr.temp').remove(); + oldColMax = c1.cache[1].colMax[1]; + $table1.trigger('update', [true, function(){ + updateCallback++; + assert.equal( oldColMax === 8 && c1.cache[1].colMax[1] === 6, true, 'update includes updating colMax value'); + assert.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3, + 'testc', 4, 'testb', 5, 'testa', 6, '', 0 ], 'update method' ); + }]); + + $table5 + .on('updateComplete.testing', function(){ updateIndx++; }) + .trigger('update', [true, function(){ + updateCallback++; + assert.cacheCompare( table5, 'all', [], 'update method on empty table' ); + }]); + + $table1.add($table5).off('updateComplete.testing'); + + // table1 updated 4x in the above test + // table5 updated 1x + assert.equal( updateIndx, updateCallback, 'updatedComplete and update callback functions working properly' ); + + }); + + /************************************************ + test sortForce, sortAppend, sortMultiSortKey and sortResetKey options + ************************************************/ + QUnit.test( 'sortForce, sortAppend, sortMultiSortKey & sortResetKey; and numberSorter option', function(assert){ + assert.expect(3); + + assert.cacheCompare( table4, 3, [ 2, 1, 7, 6, 5, 3, 4, 8, 9, 10 ], 'force x2 + sorted x2 + append x2, ascending' ); + + return QUnit.SequentialRunner( + function(actions, assertions){ + return QUnit.assertOnEvent($table4, 'sortEnd', actions, assertions); + } + ).nextTask( + function(){ + c4.sortMultiSortKey = 'altKey'; + c4.$headers.eq(5).trigger( $.Event('sort', { which: 1, altKey: true }) ); + }, + function(){ + assert.cacheCompare( table4, 3, [ 2, 1, 6, 7, 5, 4, 3, 8, 10, 9 ], 'force x2 + sorted x2 + append x2, descending' ); + } + ).nextTask( + function() { + c4.sortResetKey = 'shiftKey'; + c4.$headers.eq(0).trigger( $.Event('sort', {which: 1, shiftKey: true}) ); + }, + function() { + assert.cacheCompare( table4, 3, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'sortResetKey' ); + } + ).promise(); + }); + + /************************************************ + check header css + ************************************************/ + QUnit.test( 'testing header css & sortReset method', function(assert) { + assert.expect(7); + t = $(th0); + assert.equal( $table1.hasClass(ts.css.table), true, 'table class applied'); + assert.equal( t.hasClass(ts.css.header), true, 'Header class present' ); + assert.equal( t.parent().hasClass(ts.css.headerRow), true, 'Header row class present' ); + assert.equal( $table1.find('tbody:eq(1)').hasClass(c1.cssInfoBlock), true, 'Tbody info block class present' ); + $table1.trigger('sorton', [[[ 0,1 ]]] ); + assert.equal( t.hasClass(ts.css.sortDesc), true, 'Descending class present' ); + $table1.trigger('sorton', [[[ 0,0 ]]] ); + assert.equal( t.hasClass(ts.css.sortAsc), true, 'Ascending class present' ); + $table1.trigger('sortReset'); + assert.equal( t.hasClass(ts.css.sortAsc) || t.hasClass(ts.css.sortDesc), false, 'Testing sortReset' ); + }); + + QUnit.test( 'testing header css icons', function(assert) { + var done = assert.async(); + assert.expect(1); + $('#testblock2').html('' + + '' + + '' + + '' + + '' + + '
ABCD
') + .find('table') + .tablesorter({ + sortList: [[0,0], [1,1]], + headerTemplate:'{content} {icon}', + cssIconAsc: 'asc', + cssIconDesc: 'desc', + cssIconNone: 'none', + cssIconDisabled: 'disabled', + initialized: function(table){ + var i, + results = [], + expected = ['asc', 'desc', 'none', 'disabled'], + c = table.config; + for (i = 0; i < c.columns; i++){ + results[i] = c.$headers.eq(i).find('.' + ts.css.icon).hasClass(expected[i]); + } + assert.deepEqual( results, [true, true, true, true], 'applies correct cssIcon classes' ); + done(); + } + }); + }); + + /************************************************ + test apply widgets function using zebra widget + ************************************************/ + var zebra = function(){ + t = true; + var classes = ['odd','even']; + $table2.find('tbody tr').each(function(i){ + t = t ? $(this).hasClass( classes[i%2] ) : false; + }); + return t; + }; + + QUnit.test( 'check widgetOption defaults across tables', function(assert) { + assert.expect(4); + assert.deepEqual(c1.widgetOptions.test, [0,1], 'widget option properly set'); + assert.deepEqual(c2.widgetOptions.test, [0], 'widget option properly set'); + assert.deepEqual(c3.widgetOptions.test, [], 'default widget option set on table'); + assert.deepEqual(ts.defaults.widgetOptions.test, [], 'default widget option set in core'); + }); + + QUnit.test( 'apply zebra widget', function(assert) { + assert.expect(3); + assert.equal( zebra(), false, 'zebra not applied' ); + c2.widgets = [ 'zebra' ]; + $table2.trigger('applyWidgets'); + assert.equal( zebra(), true, 'zebra is applied' ); + $table2 + .append('stuv') + .trigger('update'); + assert.equal( zebra(), true, 'zebra is applied after update' ); + }); + + /************************************************ + test has widget function + ************************************************/ + QUnit.test( 'has & remove zebra widget', function(assert) { + assert.expect(3); + c2.widgets = [ 'zebra' ]; + $table2.trigger('applyWidgets'); + assert.equal( ts.hasWidget( table2, 'zebra'), true, 'table has zebra widget (using table element object)' ); + assert.equal( ts.hasWidget( $table2, 'zebra'), true, 'table has zebra widget (using jQuery table object)' ); + ts.removeWidget( table2, 'zebra' ); + assert.equal( zebra() && c2.widgets.length === 0, false, 'zebra removed' ); + assert.equal( ts, 'removeWidgetEnd fired' ); + }); + + /************************************************ + check destroy method + ************************************************/ + QUnit.test('testing destroy method', function(assert) { + $table2.trigger('sorton', [[[ 0,1 ]]] ); + $table2.trigger('destroy'); + assert.expect(7); + t = $table2.find('th:first'); + e = jQuery._data(table2, 'events'); // get a list of all bound events + assert.equal( $.isEmptyObject(e), true, 'no events applied' ); + assert.equal( $table2.data().hasOwnProperty('tablesorter'), false, 'Data removed' ); + assert.equal( $table2.attr('class'), 'tester', 'All table classes removed' ); + assert.equal( $table2.find('tr:first').attr('class'), '', 'Header row class removed' ); + assert.equal( t.attr('class').match('tablesorter'), null, 'Header classes removed' ); + assert.equal( t.children().length, 0, 'Inner wrapper removed' ); + assert.equal( typeof (t.data().column) , 'undefined', 'data-column removed'); + + $table2.tablesorter(); + }); + + /************************************************ + extract widgets from table class + ************************************************/ + QUnit.test('extract widget names from table class', function(assert) { + assert.expect(2); + var widgets, + t = { + className: 'widget-filter widget-stickyHeaders ui-widget-content widget-test-2', + config: { + widgetClass: 'widget-{name}', + widgets: [] + } + }; + ts.addWidgetFromClass( t ); + assert.deepEqual( t.config.widgets, [ 'filter', 'stickyHeaders', 'test-2' ], 'Ignored "ui-widget-content"' ); + + t.className = 'stickyHeaders-widgey ui-widgey-content filter-widgey test-2-widgey'; + t.config.widgetClass = '{name}-widgey'; + t.config.widgets = []; + ts.addWidgetFromClass( t ); + assert.deepEqual( t.config.widgets, [ 'stickyHeaders', 'filter', 'test-2' ], 'Modified widgetClass option' ); + + }); + + + /************************************************ + ipv6 parser testing + ************************************************/ + ipv6tests(); }); From 9ce69510df396c7598a2b7a7ed3d4fe5022cf7cc Mon Sep 17 00:00:00 2001 From: Lennard Berger Date: Mon, 17 Jul 2017 12:48:32 +0200 Subject: [PATCH 2/2] Build: Add widgetRemoveEnd event --- dist/css/filter.formatter.min.css | 2 +- dist/css/jquery.tablesorter.pager.min.css | 2 +- dist/css/theme.blackice.min.css | 2 +- dist/css/theme.blue.min.css | 2 +- dist/css/theme.bootstrap.min.css | 2 +- dist/css/theme.bootstrap_2.min.css | 2 +- dist/css/theme.bootstrap_3.min.css | 2 +- dist/css/theme.bootstrap_4.min.css | 2 +- dist/css/theme.dark.min.css | 2 +- dist/css/theme.default.min.css | 2 +- dist/css/theme.dropbox.min.css | 2 +- dist/css/theme.green.min.css | 2 +- dist/css/theme.grey.min.css | 2 +- dist/css/theme.ice.min.css | 2 +- dist/css/theme.jui.min.css | 2 +- dist/css/theme.materialize.min.css | 2 +- dist/css/theme.metro-dark.min.css | 2 +- .../js/extras/jquery.tablesorter.pager.min.js | 2 +- dist/js/extras/semver-mod.min.js | 2 +- dist/js/jquery.tablesorter.combined.js | 5687 +++++++++-------- dist/js/jquery.tablesorter.combined.min.js | 4 +- dist/js/jquery.tablesorter.js | 5685 ++++++++-------- dist/js/jquery.tablesorter.min.js | 2 +- dist/js/jquery.tablesorter.widgets.js | 2 +- dist/js/jquery.tablesorter.widgets.min.js | 4 +- dist/js/parsers/parser-date-extract.min.js | 8 +- dist/js/parsers/parser-date-iso8601.min.js | 2 +- dist/js/parsers/parser-date-month.min.js | 2 +- dist/js/parsers/parser-date-weekday.min.js | 2 +- dist/js/parsers/parser-globalize.min.js | 2 +- dist/js/parsers/parser-huge-numbers.min.js | 2 +- dist/js/parsers/parser-ignore-articles.min.js | 2 +- dist/js/parsers/parser-input-select.min.js | 2 +- dist/js/parsers/parser-leading-zeros.min.js | 2 +- dist/js/parsers/parser-named-numbers.min.js | 2 +- dist/js/widgets/widget-currentSort.min.js | 2 +- .../widget-filter-type-insideRange.min.js | 2 +- dist/js/widgets/widget-math.min.js | 2 +- dist/js/widgets/widget-pager.min.js | 2 +- dist/js/widgets/widget-sortTbodies.min.js | 2 +- dist/js/widgets/widget-stickyHeaders.min.js | 2 +- dist/js/widgets/widget-toggle.min.js | 2 +- js/jquery.tablesorter.combined.js | 5687 +++++++++-------- js/jquery.tablesorter.widgets.js | 2 +- 44 files changed, 8577 insertions(+), 8574 deletions(-) diff --git a/dist/css/filter.formatter.min.css b/dist/css/filter.formatter.min.css index 7ea210ec0..42ab37558 100644 --- a/dist/css/filter.formatter.min.css +++ b/dist/css/filter.formatter.min.css @@ -1 +1 @@ -.tablesorter .tablesorter-filter-row td{text-align:center;font-size:.9em;font-weight:400}.tablesorter .ui-slider,.tablesorter input.range{width:90%;margin:2px auto 2px auto;font-size:.8em}.tablesorter .ui-slider{top:12px}.tablesorter .ui-slider .ui-slider-handle{width:.9em;height:.9em}.tablesorter .ui-datepicker{font-size:.8em}.tablesorter .ui-slider-horizontal{height:.5em}.tablesorter .value-popup:after{content:attr(data-value);position:absolute;bottom:14px;left:-7px;min-width:18px;height:12px;background-color:#444;background-image:-webkit-gradient(linear,left top,left bottom,from(#444),to(#999));background-image:-webkit-linear-gradient(top,#444,#999);background-image:-moz-linear-gradient(top,#444,#999);background-image:-o-linear-gradient(top,#444,#999);background-image:linear-gradient(to bottom,#444,#999);-webkit-border-radius:3px;border-radius:3px;-webkit-background-clip:padding-box;background-clip:padding-box;-webkit-box-shadow:0 0 4px 0 #777;box-shadow:0 0 4px 0 #777;border:#444 1px solid;color:#fff;font:1em/1.1em Arial,Sans-Serif;padding:1px;text-align:center}.tablesorter .value-popup:before{content:"";position:absolute;width:0;height:0;border-top:8px solid #777;border-left:8px solid transparent;border-right:8px solid transparent;top:-8px;left:50%;margin-left:-8px;margin-top:-1px}.tablesorter .dateFrom,.tablesorter .dateTo{width:80px;margin:2px 5px}.tablesorter .button{width:14px;height:14px;background:#fcfff4;background:-webkit-linear-gradient(top,#fcfff4 0,#dfe5d7 40%,#b3bead 100%);background:-moz-linear-gradient(top,#fcfff4 0,#dfe5d7 40%,#b3bead 100%);background:-o-linear-gradient(top,#fcfff4 0,#dfe5d7 40%,#b3bead 100%);background:-ms-linear-gradient(top,#fcfff4 0,#dfe5d7 40%,#b3bead 100%);background:linear-gradient(top,#fcfff4 0,#dfe5d7 40%,#b3bead 100%);margin:1px 5px 1px 1px;-webkit-border-radius:25px;-moz-border-radius:25px;border-radius:25px;-webkit-box-shadow:inset 0 1px 1px #fff,0 1px 3px rgba(0,0,0,.5);-moz-box-shadow:inset 0 1px 1px #fff,0 1px 3px rgba(0,0,0,.5);box-shadow:inset 0 1px 1px #fff,0 1px 3px rgba(0,0,0,.5);position:relative;top:3px;display:inline-block}.tablesorter .button label{cursor:pointer;position:absolute;width:10px;height:10px;-webkit-border-radius:25px;-moz-border-radius:25px;border-radius:25px;left:2px;top:2px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.5),0 1px 0 rgba(255,255,255,1);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,.5),0 1px 0 rgba(255,255,255,1);box-shadow:inset 0 1px 1px rgba(0,0,0,.5),0 1px 0 rgba(255,255,255,1);background:#45484d;background:-webkit-linear-gradient(top,#222 0,#45484d 100%);background:-moz-linear-gradient(top,#222 0,#45484d 100%);background:-o-linear-gradient(top,#222 0,#45484d 100%);background:-ms-linear-gradient(top,#222 0,#45484d 100%);background:linear-gradient(top,#222 0,#45484d 100%)}.tablesorter .button label:after{opacity:0;content:'';position:absolute;width:8px;height:8px;background:#55f;background:-webkit-linear-gradient(top,#aaf 0,#55f 100%);background:-moz-linear-gradient(top,#aaf 0,#55f 100%);background:-o-linear-gradient(top,#aaf 0,#55f 100%);background:-ms-linear-gradient(top,#aaf 0,#55f 100%);background:linear-gradient(top,#aaf 0,#55f 100%);-webkit-border-radius:25px;-moz-border-radius:25px;border-radius:25px;top:1px;left:1px;-webkit-box-shadow:inset 0 1px 1px #fff,0 1px 3px rgba(0,0,0,.5);-moz-box-shadow:inset 0 1px 1px #fff,0 1px 3px rgba(0,0,0,.5);box-shadow:inset 0 1px 1px #fff,0 1px 3px rgba(0,0,0,.5)}.tablesorter .button label:hover::after{opacity:.3}.tablesorter .button input[type=checkbox]{visibility:hidden}.tablesorter .button input[type=checkbox]:checked+label:after{opacity:1}.tablesorter .colorpicker{width:30px;height:18px}.tablesorter .ui-spinner-input{width:100px;height:18px}.tablesorter .currentColor,.tablesorter .ui-spinner{position:relative}.tablesorter input.number{position:relative}.tablesorter .tablesorter-filter-row.hideme td *{height:1px;min-height:0;border:0;padding:0;margin:0;/* don't use visibility: hidden because it disables tabbing */opacity:0} \ No newline at end of file +.tablesorter .tablesorter-filter-row td{text-align:center;font-size:.9em;font-weight:400}.tablesorter .ui-slider,.tablesorter input.range{width:90%;margin:2px auto 2px auto;font-size:.8em}.tablesorter .ui-slider{top:12px}.tablesorter .ui-slider .ui-slider-handle{width:.9em;height:.9em}.tablesorter .ui-datepicker{font-size:.8em}.tablesorter .ui-slider-horizontal{height:.5em}.tablesorter .value-popup:after{content:attr(data-value);position:absolute;bottom:14px;left:-7px;min-width:18px;height:12px;background-color:#444;background-image:-webkit-gradient(linear,left top,left bottom,from(#444),to(#999));background-image:-webkit-linear-gradient(top,#444,#999);background-image:-moz-linear-gradient(top,#444,#999);background-image:-o-linear-gradient(top,#444,#999);background-image:linear-gradient(to bottom,#444,#999);-webkit-border-radius:3px;border-radius:3px;-webkit-background-clip:padding-box;background-clip:padding-box;-webkit-box-shadow:0 0 4px 0 #777;box-shadow:0 0 4px 0 #777;border:#444 1px solid;color:#fff;font:1em/1.1em Arial,Sans-Serif;padding:1px;text-align:center}.tablesorter .value-popup:before{content:"";position:absolute;width:0;height:0;border-top:8px solid #777;border-left:8px solid transparent;border-right:8px solid transparent;top:-8px;left:50%;margin-left:-8px;margin-top:-1px}.tablesorter .dateFrom,.tablesorter .dateTo{width:80px;margin:2px 5px}.tablesorter .button{width:14px;height:14px;background:#fcfff4;background:-webkit-linear-gradient(top,#fcfff4 0,#dfe5d7 40%,#b3bead 100%);background:-moz-linear-gradient(top,#fcfff4 0,#dfe5d7 40%,#b3bead 100%);background:-o-linear-gradient(top,#fcfff4 0,#dfe5d7 40%,#b3bead 100%);background:-ms-linear-gradient(top,#fcfff4 0,#dfe5d7 40%,#b3bead 100%);background:linear-gradient(top,#fcfff4 0,#dfe5d7 40%,#b3bead 100%);margin:1px 5px 1px 1px;-webkit-border-radius:25px;-moz-border-radius:25px;border-radius:25px;-webkit-box-shadow:inset 0 1px 1px #fff,0 1px 3px rgba(0,0,0,.5);-moz-box-shadow:inset 0 1px 1px #fff,0 1px 3px rgba(0,0,0,.5);box-shadow:inset 0 1px 1px #fff,0 1px 3px rgba(0,0,0,.5);position:relative;top:3px;display:inline-block}.tablesorter .button label{cursor:pointer;position:absolute;width:10px;height:10px;-webkit-border-radius:25px;-moz-border-radius:25px;border-radius:25px;left:2px;top:2px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.5),0 1px 0 rgba(255,255,255,1);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,.5),0 1px 0 rgba(255,255,255,1);box-shadow:inset 0 1px 1px rgba(0,0,0,.5),0 1px 0 rgba(255,255,255,1);background:#45484d;background:-webkit-linear-gradient(top,#222 0,#45484d 100%);background:-moz-linear-gradient(top,#222 0,#45484d 100%);background:-o-linear-gradient(top,#222 0,#45484d 100%);background:-ms-linear-gradient(top,#222 0,#45484d 100%);background:linear-gradient(top,#222 0,#45484d 100%)}.tablesorter .button label:after{opacity:0;content:'';position:absolute;width:8px;height:8px;background:#55f;background:-webkit-linear-gradient(top,#aaf 0,#55f 100%);background:-moz-linear-gradient(top,#aaf 0,#55f 100%);background:-o-linear-gradient(top,#aaf 0,#55f 100%);background:-ms-linear-gradient(top,#aaf 0,#55f 100%);background:linear-gradient(top,#aaf 0,#55f 100%);-webkit-border-radius:25px;-moz-border-radius:25px;border-radius:25px;top:1px;left:1px;-webkit-box-shadow:inset 0 1px 1px #fff,0 1px 3px rgba(0,0,0,.5);-moz-box-shadow:inset 0 1px 1px #fff,0 1px 3px rgba(0,0,0,.5);box-shadow:inset 0 1px 1px #fff,0 1px 3px rgba(0,0,0,.5)}.tablesorter .button label:hover::after{opacity:.3}.tablesorter .button input[type=checkbox]{visibility:hidden}.tablesorter .button input[type=checkbox]:checked+label:after{opacity:1}.tablesorter .colorpicker{width:30px;height:18px}.tablesorter .ui-spinner-input{width:100px;height:18px}.tablesorter .currentColor,.tablesorter .ui-spinner{position:relative}.tablesorter input.number{position:relative}.tablesorter .tablesorter-filter-row.hideme td *{height:1px;min-height:0;border:0;padding:0;margin:0;opacity:0} \ No newline at end of file diff --git a/dist/css/jquery.tablesorter.pager.min.css b/dist/css/jquery.tablesorter.pager.min.css index 0c433697e..17bc885cf 100644 --- a/dist/css/jquery.tablesorter.pager.min.css +++ b/dist/css/jquery.tablesorter.pager.min.css @@ -1 +1 @@ -.tablesorter-pager{padding:5px}td.tablesorter-pager{background-color:#e6eeee;margin:0}.tablesorter-pager img{vertical-align:middle;margin-right:2px;cursor:pointer}.tablesorter-pager .pagedisplay{padding:0 5px 0 5px;width:auto;white-space:nowrap;text-align:center}.tablesorter-pager select{margin:0;padding:0}.tablesorter-pager.disabled{display:none}.tablesorter-pager .disabled{/* visibility: hidden */opacity:.5;cursor:default} \ No newline at end of file +.tablesorter-pager{padding:5px}td.tablesorter-pager{background-color:#e6eeee;margin:0}.tablesorter-pager img{vertical-align:middle;margin-right:2px;cursor:pointer}.tablesorter-pager .pagedisplay{padding:0 5px 0 5px;width:auto;white-space:nowrap;text-align:center}.tablesorter-pager select{margin:0;padding:0}.tablesorter-pager.disabled{display:none}.tablesorter-pager .disabled{opacity:.5;cursor:default} \ No newline at end of file diff --git a/dist/css/theme.blackice.min.css b/dist/css/theme.blackice.min.css index c739b8f49..9f1f41c33 100644 --- a/dist/css/theme.blackice.min.css +++ b/dist/css/theme.blackice.min.css @@ -1 +1 @@ -.tablesorter-blackice{width:100%;margin-right:auto;margin-left:auto;font:11px/18px Arial,Sans-serif;text-align:left;background-color:#000;border-collapse:collapse;border-spacing:0}.tablesorter-blackice th,.tablesorter-blackice thead td{padding:4px;font:13px/20px Arial,Sans-serif;font-weight:700;color:#e5e5e5;text-align:left;text-shadow:0 1px 0 rgba(0,0,0,.7);background-color:#111;border:1px solid #232323}.tablesorter-blackice .header,.tablesorter-blackice .tablesorter-header{padding:4px 20px 4px 4px;cursor:pointer;background-image:url(data:image/gif;base64,R0lGODlhFQAJAIAAAP///////yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);background-position:center right;background-repeat:no-repeat}.tablesorter-blackice .headerSortUp,.tablesorter-blackice .tablesorter-headerAsc,.tablesorter-blackice .tablesorter-headerSortUp{background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAAP///////yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7);color:#fff}.tablesorter-blackice .headerSortDown,.tablesorter-blackice .tablesorter-headerDesc,.tablesorter-blackice .tablesorter-headerSortDown{color:#fff;background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAAP///////yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7)}.tablesorter-blackice thead .sorter-false{background-image:none;cursor:default;padding:4px}.tablesorter-blackice tfoot .tablesorter-headerAsc,.tablesorter-blackice tfoot .tablesorter-headerDesc,.tablesorter-blackice tfoot .tablesorter-headerSortDown,.tablesorter-blackice tfoot .tablesorter-headerSortUp{background-image:none}.tablesorter-blackice td{padding:4px;color:#ccc;vertical-align:top;background-color:#333;border:1px solid #232323}.tablesorter-blackice tbody>tr.even:hover>td,.tablesorter-blackice tbody>tr.hover>td,.tablesorter-blackice tbody>tr.odd:hover>td,.tablesorter-blackice tbody>tr:hover>td{background-color:#000}.tablesorter-blackice .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-blackice tr.odd>td{background-color:#333}.tablesorter-blackice tr.even>td{background-color:#393939}.tablesorter-blackice td.primary,.tablesorter-blackice tr.odd td.primary{background-color:#2f3a40}.tablesorter-blackice tr.even td.primary{background-color:#3f4a50}.tablesorter-blackice td.secondary,.tablesorter-blackice tr.odd td.secondary{background-color:#3f4a50}.tablesorter-blackice tr.even td.secondary{background-color:#4f5a60}.tablesorter-blackice td.tertiary,.tablesorter-blackice tr.odd td.tertiary{background-color:#4f5a60}.tablesorter-blackice tr.even td.tertiary{background-color:#5a646b}caption{background-color:#fff}.tablesorter-blackice .tablesorter-filter-row{background-color:#222}.tablesorter-blackice .tablesorter-filter-row td{background-color:#222;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-blackice .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-blackice .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-blackice .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;/* don't use visibility: hidden because it disables tabbing */opacity:0}.tablesorter-blackice input.tablesorter-filter,.tablesorter-blackice select.tablesorter-filter{width:98%;height:auto;margin:0;padding:4px;background-color:#fff;border:1px solid #bbb;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file +.tablesorter-blackice{width:100%;margin-right:auto;margin-left:auto;font:11px/18px Arial,Sans-serif;text-align:left;background-color:#000;border-collapse:collapse;border-spacing:0}.tablesorter-blackice th,.tablesorter-blackice thead td{padding:4px;font:13px/20px Arial,Sans-serif;font-weight:700;color:#e5e5e5;text-align:left;text-shadow:0 1px 0 rgba(0,0,0,.7);background-color:#111;border:1px solid #232323}.tablesorter-blackice .header,.tablesorter-blackice .tablesorter-header{padding:4px 20px 4px 4px;cursor:pointer;background-image:url(data:image/gif;base64,R0lGODlhFQAJAIAAAP///////yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);background-position:center right;background-repeat:no-repeat}.tablesorter-blackice .headerSortUp,.tablesorter-blackice .tablesorter-headerAsc,.tablesorter-blackice .tablesorter-headerSortUp{background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAAP///////yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7);color:#fff}.tablesorter-blackice .headerSortDown,.tablesorter-blackice .tablesorter-headerDesc,.tablesorter-blackice .tablesorter-headerSortDown{color:#fff;background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAAP///////yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7)}.tablesorter-blackice thead .sorter-false{background-image:none;cursor:default;padding:4px}.tablesorter-blackice tfoot .tablesorter-headerAsc,.tablesorter-blackice tfoot .tablesorter-headerDesc,.tablesorter-blackice tfoot .tablesorter-headerSortDown,.tablesorter-blackice tfoot .tablesorter-headerSortUp{background-image:none}.tablesorter-blackice td{padding:4px;color:#ccc;vertical-align:top;background-color:#333;border:1px solid #232323}.tablesorter-blackice tbody>tr.even:hover>td,.tablesorter-blackice tbody>tr.hover>td,.tablesorter-blackice tbody>tr.odd:hover>td,.tablesorter-blackice tbody>tr:hover>td{background-color:#000}.tablesorter-blackice .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-blackice tr.odd>td{background-color:#333}.tablesorter-blackice tr.even>td{background-color:#393939}.tablesorter-blackice td.primary,.tablesorter-blackice tr.odd td.primary{background-color:#2f3a40}.tablesorter-blackice tr.even td.primary{background-color:#3f4a50}.tablesorter-blackice td.secondary,.tablesorter-blackice tr.odd td.secondary{background-color:#3f4a50}.tablesorter-blackice tr.even td.secondary{background-color:#4f5a60}.tablesorter-blackice td.tertiary,.tablesorter-blackice tr.odd td.tertiary{background-color:#4f5a60}.tablesorter-blackice tr.even td.tertiary{background-color:#5a646b}caption{background-color:#fff}.tablesorter-blackice .tablesorter-filter-row{background-color:#222}.tablesorter-blackice .tablesorter-filter-row td{background-color:#222;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-blackice .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-blackice .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-blackice .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;opacity:0}.tablesorter-blackice input.tablesorter-filter,.tablesorter-blackice select.tablesorter-filter{width:98%;height:auto;margin:0;padding:4px;background-color:#fff;border:1px solid #bbb;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file diff --git a/dist/css/theme.blue.min.css b/dist/css/theme.blue.min.css index 8538be0b9..f7ad0977d 100644 --- a/dist/css/theme.blue.min.css +++ b/dist/css/theme.blue.min.css @@ -1 +1 @@ -.tablesorter-blue{width:100%;background-color:#fff;margin:10px 0 15px;text-align:left;border-spacing:0;border:#cdcdcd 1px solid;border-width:1px 0 0 1px}.tablesorter-blue td,.tablesorter-blue th{border:#cdcdcd 1px solid;border-width:0 1px 1px 0}.tablesorter-blue th,.tablesorter-blue thead td{font:12px/18px Arial,Sans-serif;font-weight:700;color:#000;background-color:#99bfe6;border-collapse:collapse;padding:4px;text-shadow:0 1px 0 rgba(204,204,204,.7)}.tablesorter-blue tbody td,.tablesorter-blue tfoot td,.tablesorter-blue tfoot th{padding:4px;vertical-align:top}.tablesorter-blue .header,.tablesorter-blue .tablesorter-header{background-image:url(data:image/gif;base64,R0lGODlhFQAJAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);background-repeat:no-repeat;background-position:center right;padding:4px 18px 4px 4px;white-space:normal;cursor:pointer}.tablesorter-blue .headerSortUp,.tablesorter-blue .tablesorter-headerAsc,.tablesorter-blue .tablesorter-headerSortUp{background-color:#9fbfdf;background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7)}.tablesorter-blue .headerSortDown,.tablesorter-blue .tablesorter-headerDesc,.tablesorter-blue .tablesorter-headerSortDown{background-color:#8cb3d9;background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7)}.tablesorter-blue thead .sorter-false{background-image:none;cursor:default;padding:4px}.tablesorter-blue tfoot .tablesorter-headerAsc,.tablesorter-blue tfoot .tablesorter-headerDesc,.tablesorter-blue tfoot .tablesorter-headerSortDown,.tablesorter-blue tfoot .tablesorter-headerSortUp{background-image:none}.tablesorter-blue td{color:#3d3d3d;background-color:#fff;padding:4px;vertical-align:top}.tablesorter-blue tbody>tr.even.hover>td,.tablesorter-blue tbody>tr.even:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-blue tbody>tr.even:hover+tr.tablesorter-childRow>td,.tablesorter-blue tbody>tr.even:hover>td,.tablesorter-blue tbody>tr.hover>td,.tablesorter-blue tbody>tr:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-blue tbody>tr:hover+tr.tablesorter-childRow>td,.tablesorter-blue tbody>tr:hover>td{background-color:#d9d9d9}.tablesorter-blue tbody>tr.odd.hover>td,.tablesorter-blue tbody>tr.odd:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-blue tbody>tr.odd:hover+tr.tablesorter-childRow>td,.tablesorter-blue tbody>tr.odd:hover>td{background-color:#bfbfbf}.tablesorter-blue .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-blue tbody tr.odd>td{background-color:#ebf2fa}.tablesorter-blue tbody tr.even>td{background-color:#fff}.tablesorter-blue td.primary,.tablesorter-blue tr.odd td.primary{background-color:#99b3e6}.tablesorter-blue tr.even td.primary{background-color:#c2d1f0}.tablesorter-blue td.secondary,.tablesorter-blue tr.odd td.secondary{background-color:#c2d1f0}.tablesorter-blue tr.even td.secondary{background-color:#d6e0f5}.tablesorter-blue td.tertiary,.tablesorter-blue tr.odd td.tertiary{background-color:#d6e0f5}.tablesorter-blue tr.even td.tertiary{background-color:#ebf0fa}caption{background-color:#fff}.tablesorter-blue .tablesorter-filter-row{background-color:#eee}.tablesorter-blue .tablesorter-filter-row td{background-color:#eee;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-blue .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-blue .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-blue .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;/* don't use visibility: hidden because it disables tabbing */opacity:0}.tablesorter-blue input.tablesorter-filter,.tablesorter-blue select.tablesorter-filter{width:98%;height:auto;margin:0;padding:4px;background-color:#fff;border:1px solid #bbb;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file +.tablesorter-blue{width:100%;background-color:#fff;margin:10px 0 15px;text-align:left;border-spacing:0;border:#cdcdcd 1px solid;border-width:1px 0 0 1px}.tablesorter-blue td,.tablesorter-blue th{border:#cdcdcd 1px solid;border-width:0 1px 1px 0}.tablesorter-blue th,.tablesorter-blue thead td{font:12px/18px Arial,Sans-serif;font-weight:700;color:#000;background-color:#99bfe6;border-collapse:collapse;padding:4px;text-shadow:0 1px 0 rgba(204,204,204,.7)}.tablesorter-blue tbody td,.tablesorter-blue tfoot td,.tablesorter-blue tfoot th{padding:4px;vertical-align:top}.tablesorter-blue .header,.tablesorter-blue .tablesorter-header{background-image:url(data:image/gif;base64,R0lGODlhFQAJAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);background-repeat:no-repeat;background-position:center right;padding:4px 18px 4px 4px;white-space:normal;cursor:pointer}.tablesorter-blue .headerSortUp,.tablesorter-blue .tablesorter-headerAsc,.tablesorter-blue .tablesorter-headerSortUp{background-color:#9fbfdf;background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7)}.tablesorter-blue .headerSortDown,.tablesorter-blue .tablesorter-headerDesc,.tablesorter-blue .tablesorter-headerSortDown{background-color:#8cb3d9;background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7)}.tablesorter-blue thead .sorter-false{background-image:none;cursor:default;padding:4px}.tablesorter-blue tfoot .tablesorter-headerAsc,.tablesorter-blue tfoot .tablesorter-headerDesc,.tablesorter-blue tfoot .tablesorter-headerSortDown,.tablesorter-blue tfoot .tablesorter-headerSortUp{background-image:none}.tablesorter-blue td{color:#3d3d3d;background-color:#fff;padding:4px;vertical-align:top}.tablesorter-blue tbody>tr.even.hover>td,.tablesorter-blue tbody>tr.even:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-blue tbody>tr.even:hover+tr.tablesorter-childRow>td,.tablesorter-blue tbody>tr.even:hover>td,.tablesorter-blue tbody>tr.hover>td,.tablesorter-blue tbody>tr:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-blue tbody>tr:hover+tr.tablesorter-childRow>td,.tablesorter-blue tbody>tr:hover>td{background-color:#d9d9d9}.tablesorter-blue tbody>tr.odd.hover>td,.tablesorter-blue tbody>tr.odd:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-blue tbody>tr.odd:hover+tr.tablesorter-childRow>td,.tablesorter-blue tbody>tr.odd:hover>td{background-color:#bfbfbf}.tablesorter-blue .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-blue tbody tr.odd>td{background-color:#ebf2fa}.tablesorter-blue tbody tr.even>td{background-color:#fff}.tablesorter-blue td.primary,.tablesorter-blue tr.odd td.primary{background-color:#99b3e6}.tablesorter-blue tr.even td.primary{background-color:#c2d1f0}.tablesorter-blue td.secondary,.tablesorter-blue tr.odd td.secondary{background-color:#c2d1f0}.tablesorter-blue tr.even td.secondary{background-color:#d6e0f5}.tablesorter-blue td.tertiary,.tablesorter-blue tr.odd td.tertiary{background-color:#d6e0f5}.tablesorter-blue tr.even td.tertiary{background-color:#ebf0fa}caption{background-color:#fff}.tablesorter-blue .tablesorter-filter-row{background-color:#eee}.tablesorter-blue .tablesorter-filter-row td{background-color:#eee;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-blue .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-blue .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-blue .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;opacity:0}.tablesorter-blue input.tablesorter-filter,.tablesorter-blue select.tablesorter-filter{width:98%;height:auto;margin:0;padding:4px;background-color:#fff;border:1px solid #bbb;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file diff --git a/dist/css/theme.bootstrap.min.css b/dist/css/theme.bootstrap.min.css index 45a276fe3..9468a3f3f 100644 --- a/dist/css/theme.bootstrap.min.css +++ b/dist/css/theme.bootstrap.min.css @@ -1 +1 @@ -.tablesorter-bootstrap{width:100%}.tablesorter-bootstrap tfoot td,.tablesorter-bootstrap tfoot th,.tablesorter-bootstrap thead td,.tablesorter-bootstrap thead th{font:14px/20px Arial,Sans-serif;font-weight:700;padding:4px;margin:0 0 18px;background-color:#eee}.tablesorter-bootstrap .tablesorter-header{cursor:pointer}.tablesorter-bootstrap .sorter-false{cursor:default}.tablesorter-bootstrap .tablesorter-header.sorter-false i.tablesorter-icon{display:none}.tablesorter-bootstrap .tablesorter-header-inner{position:relative;padding:4px 18px 4px 4px}.tablesorter-bootstrap .sorter-false .tablesorter-header-inner{padding:4px}.tablesorter-bootstrap .tablesorter-header i.tablesorter-icon{font-size:11px;position:absolute;right:2px;top:50%;margin-top:-7px;width:14px;height:14px;background-repeat:no-repeat;line-height:14px;display:inline-block}.tablesorter-bootstrap .bootstrap-icon-unsorted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAOCAYAAAD5YeaVAAAA20lEQVR4AWJABpKSkoxALCstLb0aUAsZaCAMhVEY6B0amx8YZWDDEDSBa2AGe7XeIiAAClYwVGBvsAcIllsf/mvcC9DgOOd8h90fxWvngVEUbZIkuWRZZlE8eQjcisgZMM9zi+LJ6ZfwegmWZflZDugdHMfxTcGqql7TNBlUB/QObtv2VBSFrev6OY7jngzFk9OT/fn73fWYpqnlXNyXDMWT0zuYx/Bvel9ej+LJ6R08DMOu67q7DkTkrSA5vYPneV71fX/QASdTkJwezhs0TfMARn0wMDDGXEPgF4oijqwM5YjNAAAAAElFTkSuQmCC)}.tablesorter-bootstrap .icon-white.bootstrap-icon-unsorted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAOCAYAAAD5YeaVAAAAe0lEQVR4AbXQoRWDMBiF0Sh2QLAAQ8SxJGugWSA6A2STW1PxTsnB9cnkfuYvv8OGC1t5G3Y0QMP+Bm857keAdQIzWBP3+Bw4MADQE18B6/etRnCV/w9nnGuLezfAmXhABGtAGIkruvk6auIFRwQJDywllsEAjCecB20GP59BQQ+gtlRLAAAAAElFTkSuQmCC)}.tablesorter-bootstrap>tbody>tr.odd>td,.tablesorter-bootstrap>tbody>tr.tablesorter-hasChildRow.odd:hover~tr.tablesorter-hasChildRow.odd~.tablesorter-childRow.odd>td{background-color:#f9f9f9}.tablesorter-bootstrap>tbody>tr.even:hover>td,.tablesorter-bootstrap>tbody>tr.hover>td,.tablesorter-bootstrap>tbody>tr.odd:hover>td,.tablesorter-bootstrap>tbody>tr.tablesorter-hasChildRow.even:hover~.tablesorter-childRow.even>td,.tablesorter-bootstrap>tbody>tr.tablesorter-hasChildRow.odd:hover~.tablesorter-childRow.odd>td{background-color:#f5f5f5}.tablesorter-bootstrap>tbody>tr.even>td,.tablesorter-bootstrap>tbody>tr.tablesorter-hasChildRow.even:hover~tr.tablesorter-hasChildRow.even~.tablesorter-childRow.even>td{background-color:#fff}.tablesorter-bootstrap .tablesorter-processing{background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=);background-position:center center!important;background-repeat:no-repeat!important}.tablesorter-bootstrap>tbody>tr.odd td.primary{background-color:#bfbfbf}.tablesorter-bootstrap>tbody>tr td.primary,.tablesorter-bootstrap>tbody>tr.even td.primary{background-color:#d9d9d9}.tablesorter-bootstrap>tbody>tr.odd td.secondary{background-color:#d9d9d9}.tablesorter-bootstrap>tbody>tr td.secondary,.tablesorter-bootstrap>tbody>tr.even td.secondary{background-color:#e6e6e6}.tablesorter-bootstrap>tbody>tr.odd td.tertiary{background-color:#e6e6e6}.tablesorter-bootstrap>tbody>tr td.tertiary,.tablesorter-bootstrap>tbody>tr.even td.tertiary{background-color:#f2f2f2}.caption{background-color:#fff}.tablesorter-bootstrap .tablesorter-filter-row input.tablesorter-filter,.tablesorter-bootstrap .tablesorter-filter-row select.tablesorter-filter{width:98%;margin:0;padding:4px 6px;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter-bootstrap .tablesorter-filter-row .tablesorter-filter.disabled{background-color:#eee;color:#555;cursor:not-allowed;border:1px solid #ccc;border-radius:4px;box-shadow:0 1px 1px rgba(0,0,0,.075) inset;box-sizing:border-box;transition:height .1s ease}.tablesorter-bootstrap .tablesorter-filter-row{background-color:#efefef}.tablesorter-bootstrap .tablesorter-filter-row td{background-color:#efefef;line-height:normal;text-align:center;padding:4px 6px;vertical-align:middle;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-bootstrap .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0}.tablesorter-bootstrap .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;/* don't use visibility: hidden because it disables tabbing */opacity:0}.tablesorter .filtered{display:none}.tablesorter-bootstrap .tablesorter-pager select{padding:4px 6px}.tablesorter-bootstrap .tablesorter-pager .pagedisplay{border:0}.tablesorter-bootstrap tfoot i{font-size:11px}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file +.tablesorter-bootstrap{width:100%}.tablesorter-bootstrap tfoot td,.tablesorter-bootstrap tfoot th,.tablesorter-bootstrap thead td,.tablesorter-bootstrap thead th{font:14px/20px Arial,Sans-serif;font-weight:700;padding:4px;margin:0 0 18px;background-color:#eee}.tablesorter-bootstrap .tablesorter-header{cursor:pointer}.tablesorter-bootstrap .sorter-false{cursor:default}.tablesorter-bootstrap .tablesorter-header.sorter-false i.tablesorter-icon{display:none}.tablesorter-bootstrap .tablesorter-header-inner{position:relative;padding:4px 18px 4px 4px}.tablesorter-bootstrap .sorter-false .tablesorter-header-inner{padding:4px}.tablesorter-bootstrap .tablesorter-header i.tablesorter-icon{font-size:11px;position:absolute;right:2px;top:50%;margin-top:-7px;width:14px;height:14px;background-repeat:no-repeat;line-height:14px;display:inline-block}.tablesorter-bootstrap .bootstrap-icon-unsorted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAOCAYAAAD5YeaVAAAA20lEQVR4AWJABpKSkoxALCstLb0aUAsZaCAMhVEY6B0amx8YZWDDEDSBa2AGe7XeIiAAClYwVGBvsAcIllsf/mvcC9DgOOd8h90fxWvngVEUbZIkuWRZZlE8eQjcisgZMM9zi+LJ6ZfwegmWZflZDugdHMfxTcGqql7TNBlUB/QObtv2VBSFrev6OY7jngzFk9OT/fn73fWYpqnlXNyXDMWT0zuYx/Bvel9ej+LJ6R08DMOu67q7DkTkrSA5vYPneV71fX/QASdTkJwezhs0TfMARn0wMDDGXEPgF4oijqwM5YjNAAAAAElFTkSuQmCC)}.tablesorter-bootstrap .icon-white.bootstrap-icon-unsorted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAOCAYAAAD5YeaVAAAAe0lEQVR4AbXQoRWDMBiF0Sh2QLAAQ8SxJGugWSA6A2STW1PxTsnB9cnkfuYvv8OGC1t5G3Y0QMP+Bm857keAdQIzWBP3+Bw4MADQE18B6/etRnCV/w9nnGuLezfAmXhABGtAGIkruvk6auIFRwQJDywllsEAjCecB20GP59BQQ+gtlRLAAAAAElFTkSuQmCC)}.tablesorter-bootstrap>tbody>tr.odd>td,.tablesorter-bootstrap>tbody>tr.tablesorter-hasChildRow.odd:hover~tr.tablesorter-hasChildRow.odd~.tablesorter-childRow.odd>td{background-color:#f9f9f9}.tablesorter-bootstrap>tbody>tr.even:hover>td,.tablesorter-bootstrap>tbody>tr.hover>td,.tablesorter-bootstrap>tbody>tr.odd:hover>td,.tablesorter-bootstrap>tbody>tr.tablesorter-hasChildRow.even:hover~.tablesorter-childRow.even>td,.tablesorter-bootstrap>tbody>tr.tablesorter-hasChildRow.odd:hover~.tablesorter-childRow.odd>td{background-color:#f5f5f5}.tablesorter-bootstrap>tbody>tr.even>td,.tablesorter-bootstrap>tbody>tr.tablesorter-hasChildRow.even:hover~tr.tablesorter-hasChildRow.even~.tablesorter-childRow.even>td{background-color:#fff}.tablesorter-bootstrap .tablesorter-processing{background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=);background-position:center center!important;background-repeat:no-repeat!important}.tablesorter-bootstrap>tbody>tr.odd td.primary{background-color:#bfbfbf}.tablesorter-bootstrap>tbody>tr td.primary,.tablesorter-bootstrap>tbody>tr.even td.primary{background-color:#d9d9d9}.tablesorter-bootstrap>tbody>tr.odd td.secondary{background-color:#d9d9d9}.tablesorter-bootstrap>tbody>tr td.secondary,.tablesorter-bootstrap>tbody>tr.even td.secondary{background-color:#e6e6e6}.tablesorter-bootstrap>tbody>tr.odd td.tertiary{background-color:#e6e6e6}.tablesorter-bootstrap>tbody>tr td.tertiary,.tablesorter-bootstrap>tbody>tr.even td.tertiary{background-color:#f2f2f2}.caption{background-color:#fff}.tablesorter-bootstrap .tablesorter-filter-row input.tablesorter-filter,.tablesorter-bootstrap .tablesorter-filter-row select.tablesorter-filter{width:98%;margin:0;padding:4px 6px;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter-bootstrap .tablesorter-filter-row .tablesorter-filter.disabled{background-color:#eee;color:#555;cursor:not-allowed;border:1px solid #ccc;border-radius:4px;box-shadow:0 1px 1px rgba(0,0,0,.075) inset;box-sizing:border-box;transition:height .1s ease}.tablesorter-bootstrap .tablesorter-filter-row{background-color:#efefef}.tablesorter-bootstrap .tablesorter-filter-row td{background-color:#efefef;line-height:normal;text-align:center;padding:4px 6px;vertical-align:middle;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-bootstrap .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0}.tablesorter-bootstrap .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;opacity:0}.tablesorter .filtered{display:none}.tablesorter-bootstrap .tablesorter-pager select{padding:4px 6px}.tablesorter-bootstrap .tablesorter-pager .pagedisplay{border:0}.tablesorter-bootstrap tfoot i{font-size:11px}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file diff --git a/dist/css/theme.bootstrap_2.min.css b/dist/css/theme.bootstrap_2.min.css index 257271fd9..8222eb140 100644 --- a/dist/css/theme.bootstrap_2.min.css +++ b/dist/css/theme.bootstrap_2.min.css @@ -1 +1 @@ -.tablesorter-bootstrap{width:100%}.tablesorter-bootstrap .tablesorter-header,.tablesorter-bootstrap tfoot td,.tablesorter-bootstrap tfoot th{font:14px/20px Arial,Sans-serif;font-weight:700;position:relative;padding:8px;margin:0 0 18px;list-style:none;background-color:#fbfbfb;background-image:-moz-linear-gradient(top,#fff,#efefef);background-image:-ms-linear-gradient(top,#fff,#efefef);background-image:-webkit-gradient(linear,0 0,0 100%,from(white),to(#efefef));background-image:-webkit-linear-gradient(top,#fff,#efefef);background-image:-o-linear-gradient(top,#fff,#efefef);background-image:linear-gradient(to bottom,#fff,#efefef);background-repeat:repeat-x;-webkit-box-shadow:inset 0 1px 0 #fff;-moz-box-shadow:inset 0 1px 0 #fff;box-shadow:inset 0 1px 0 #fff}.tablesorter-bootstrap .tablesorter-header{cursor:pointer}.tablesorter-bootstrap .sorter-false{cursor:default}.tablesorter-bootstrap .tablesorter-header.sorter-false i.tablesorter-icon{display:none}.tablesorter-bootstrap .tablesorter-header-inner{position:relative;padding:4px 18px 4px 4px}.tablesorter-bootstrap .sorter-false .tablesorter-header-inner{padding:4px}.tablesorter-bootstrap .tablesorter-header i.tablesorter-icon{position:absolute;right:2px;top:50%;margin-top:-7px;width:14px;height:14px;background-repeat:no-repeat;line-height:14px;display:inline-block}.tablesorter-bootstrap .bootstrap-icon-unsorted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAOCAYAAAD5YeaVAAABGUlEQVR4AZWQAUfEYBzGC07fILfrbnfgqG1jmxliDitmYIaxb9Y3CEIEVHDaUGMfYF8gIyBqbd7eH7wWofB6/J7nN+x/IIRQbz6fH8p3slgsrkl4uv8QNU071XX9wTAMQcLTD6bi2WazubUsq3ddV5AwPftU1tbr9Z0UPhGDIHgjYXp2JS+Xy71t2wNCFEV113UxCdOzKznLshvf9z+SJHlp23ZHR8L07Er+6/u/LO96td1u3zmX/BmdjoTp2ZUchmHted4o/16sVqt7KR6TMD27kpumOc/z/EkOvWmaQp7rlYTp2ZU8juOsqqqLoij2UvhyHEeQMD27knl93x+VZXmZpukz9yVh+l+vMQzDrK7rXRzHjyQ83b8BlglBGLw1Kb4AAAAASUVORK5CYII=)}.tablesorter-bootstrap .icon-white.bootstrap-icon-unsorted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAOCAYAAAD5YeaVAAAAe0lEQVR4AbXQoRWDMBiF0Sh2QLAAQ8SxJGugWSA6A2STW1PxTsnB9cnkfuYvv8OGC1t5G3Y0QMP+Bm857keAdQIzWBP3+Bw4MADQE18B6/etRnCV/w9nnGuLezfAmXhABGtAGIkruvk6auIFRwQJDywllsEAjCecB20GP59BQQ+gtlRLAAAAAElFTkSuQmCC)}.tablesorter-bootstrap tr.odd>td{background-color:#f9f9f9}.tablesorter-bootstrap tbody>.even:hover>td,.tablesorter-bootstrap tbody>.odd:hover>td,.tablesorter-bootstrap tbody>tr.hover>td{background-color:#f5f5f5}.tablesorter-bootstrap tbody>tr.even>td{background-color:#fff}.tablesorter-bootstrap .tablesorter-processing{background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=);position:absolute;z-index:1000}.tablesorter-bootstrap>tbody>tr.odd td.primary{background-color:#bfbfbf}.tablesorter-bootstrap>tbody>tr td.primary,.tablesorter-bootstrap>tbody>tr.even td.primary{background-color:#d9d9d9}.tablesorter-bootstrap>tbody>tr.odd td.secondary{background-color:#d9d9d9}.tablesorter-bootstrap>tbody>tr td.secondary,.tablesorter-bootstrap>tbody>tr.even td.secondary{background-color:#e6e6e6}.tablesorter-bootstrap>tbody>tr.odd td.tertiary{background-color:#e6e6e6}.tablesorter-bootstrap>tbody>tr td.tertiary,.tablesorter-bootstrap>tbody>tr.even td.tertiary{background-color:#f2f2f2}caption{background-color:#fff}.tablesorter-bootstrap .tablesorter-filter-row input.tablesorter-filter,.tablesorter-bootstrap .tablesorter-filter-row select.tablesorter-filter{height:28px;width:98%;margin:0;padding:4px 6px;background-color:#fff;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter-bootstrap .tablesorter-filter-row .tablesorter-filter.disabled{background-color:#eee;cursor:not-allowed}.tablesorter-bootstrap .tablesorter-filter-row{background-color:#ddd}.tablesorter-bootstrap .tablesorter-filter-row td{background-color:#eee;line-height:normal;text-align:center;padding:4px 6px;vertical-align:middle;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-bootstrap tr.tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0}.tablesorter-bootstrap tr.tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;/* don't use visibility: hidden because it disables tabbing */opacity:0}.tablesorter .filtered{display:none}.tablesorter-bootstrap .tablesorter-pager select{padding:4px 6px}.tablesorter-bootstrap .tablesorter-pager .pagedisplay{border:0}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file +.tablesorter-bootstrap{width:100%}.tablesorter-bootstrap .tablesorter-header,.tablesorter-bootstrap tfoot td,.tablesorter-bootstrap tfoot th{font:14px/20px Arial,Sans-serif;font-weight:700;position:relative;padding:8px;margin:0 0 18px;list-style:none;background-color:#fbfbfb;background-image:-moz-linear-gradient(top,#fff,#efefef);background-image:-ms-linear-gradient(top,#fff,#efefef);background-image:-webkit-gradient(linear,0 0,0 100%,from(white),to(#efefef));background-image:-webkit-linear-gradient(top,#fff,#efefef);background-image:-o-linear-gradient(top,#fff,#efefef);background-image:linear-gradient(to bottom,#fff,#efefef);background-repeat:repeat-x;-webkit-box-shadow:inset 0 1px 0 #fff;-moz-box-shadow:inset 0 1px 0 #fff;box-shadow:inset 0 1px 0 #fff}.tablesorter-bootstrap .tablesorter-header{cursor:pointer}.tablesorter-bootstrap .sorter-false{cursor:default}.tablesorter-bootstrap .tablesorter-header.sorter-false i.tablesorter-icon{display:none}.tablesorter-bootstrap .tablesorter-header-inner{position:relative;padding:4px 18px 4px 4px}.tablesorter-bootstrap .sorter-false .tablesorter-header-inner{padding:4px}.tablesorter-bootstrap .tablesorter-header i.tablesorter-icon{position:absolute;right:2px;top:50%;margin-top:-7px;width:14px;height:14px;background-repeat:no-repeat;line-height:14px;display:inline-block}.tablesorter-bootstrap .bootstrap-icon-unsorted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAOCAYAAAD5YeaVAAABGUlEQVR4AZWQAUfEYBzGC07fILfrbnfgqG1jmxliDitmYIaxb9Y3CEIEVHDaUGMfYF8gIyBqbd7eH7wWofB6/J7nN+x/IIRQbz6fH8p3slgsrkl4uv8QNU071XX9wTAMQcLTD6bi2WazubUsq3ddV5AwPftU1tbr9Z0UPhGDIHgjYXp2JS+Xy71t2wNCFEV113UxCdOzKznLshvf9z+SJHlp23ZHR8L07Er+6/u/LO96td1u3zmX/BmdjoTp2ZUchmHted4o/16sVqt7KR6TMD27kpumOc/z/EkOvWmaQp7rlYTp2ZU8juOsqqqLoij2UvhyHEeQMD27knl93x+VZXmZpukz9yVh+l+vMQzDrK7rXRzHjyQ83b8BlglBGLw1Kb4AAAAASUVORK5CYII=)}.tablesorter-bootstrap .icon-white.bootstrap-icon-unsorted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAOCAYAAAD5YeaVAAAAe0lEQVR4AbXQoRWDMBiF0Sh2QLAAQ8SxJGugWSA6A2STW1PxTsnB9cnkfuYvv8OGC1t5G3Y0QMP+Bm857keAdQIzWBP3+Bw4MADQE18B6/etRnCV/w9nnGuLezfAmXhABGtAGIkruvk6auIFRwQJDywllsEAjCecB20GP59BQQ+gtlRLAAAAAElFTkSuQmCC)}.tablesorter-bootstrap tr.odd>td{background-color:#f9f9f9}.tablesorter-bootstrap tbody>.even:hover>td,.tablesorter-bootstrap tbody>.odd:hover>td,.tablesorter-bootstrap tbody>tr.hover>td{background-color:#f5f5f5}.tablesorter-bootstrap tbody>tr.even>td{background-color:#fff}.tablesorter-bootstrap .tablesorter-processing{background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=);position:absolute;z-index:1000}.tablesorter-bootstrap>tbody>tr.odd td.primary{background-color:#bfbfbf}.tablesorter-bootstrap>tbody>tr td.primary,.tablesorter-bootstrap>tbody>tr.even td.primary{background-color:#d9d9d9}.tablesorter-bootstrap>tbody>tr.odd td.secondary{background-color:#d9d9d9}.tablesorter-bootstrap>tbody>tr td.secondary,.tablesorter-bootstrap>tbody>tr.even td.secondary{background-color:#e6e6e6}.tablesorter-bootstrap>tbody>tr.odd td.tertiary{background-color:#e6e6e6}.tablesorter-bootstrap>tbody>tr td.tertiary,.tablesorter-bootstrap>tbody>tr.even td.tertiary{background-color:#f2f2f2}caption{background-color:#fff}.tablesorter-bootstrap .tablesorter-filter-row input.tablesorter-filter,.tablesorter-bootstrap .tablesorter-filter-row select.tablesorter-filter{height:28px;width:98%;margin:0;padding:4px 6px;background-color:#fff;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter-bootstrap .tablesorter-filter-row .tablesorter-filter.disabled{background-color:#eee;cursor:not-allowed}.tablesorter-bootstrap .tablesorter-filter-row{background-color:#ddd}.tablesorter-bootstrap .tablesorter-filter-row td{background-color:#eee;line-height:normal;text-align:center;padding:4px 6px;vertical-align:middle;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-bootstrap tr.tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0}.tablesorter-bootstrap tr.tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;opacity:0}.tablesorter .filtered{display:none}.tablesorter-bootstrap .tablesorter-pager select{padding:4px 6px}.tablesorter-bootstrap .tablesorter-pager .pagedisplay{border:0}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file diff --git a/dist/css/theme.bootstrap_3.min.css b/dist/css/theme.bootstrap_3.min.css index 45a276fe3..9468a3f3f 100644 --- a/dist/css/theme.bootstrap_3.min.css +++ b/dist/css/theme.bootstrap_3.min.css @@ -1 +1 @@ -.tablesorter-bootstrap{width:100%}.tablesorter-bootstrap tfoot td,.tablesorter-bootstrap tfoot th,.tablesorter-bootstrap thead td,.tablesorter-bootstrap thead th{font:14px/20px Arial,Sans-serif;font-weight:700;padding:4px;margin:0 0 18px;background-color:#eee}.tablesorter-bootstrap .tablesorter-header{cursor:pointer}.tablesorter-bootstrap .sorter-false{cursor:default}.tablesorter-bootstrap .tablesorter-header.sorter-false i.tablesorter-icon{display:none}.tablesorter-bootstrap .tablesorter-header-inner{position:relative;padding:4px 18px 4px 4px}.tablesorter-bootstrap .sorter-false .tablesorter-header-inner{padding:4px}.tablesorter-bootstrap .tablesorter-header i.tablesorter-icon{font-size:11px;position:absolute;right:2px;top:50%;margin-top:-7px;width:14px;height:14px;background-repeat:no-repeat;line-height:14px;display:inline-block}.tablesorter-bootstrap .bootstrap-icon-unsorted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAOCAYAAAD5YeaVAAAA20lEQVR4AWJABpKSkoxALCstLb0aUAsZaCAMhVEY6B0amx8YZWDDEDSBa2AGe7XeIiAAClYwVGBvsAcIllsf/mvcC9DgOOd8h90fxWvngVEUbZIkuWRZZlE8eQjcisgZMM9zi+LJ6ZfwegmWZflZDugdHMfxTcGqql7TNBlUB/QObtv2VBSFrev6OY7jngzFk9OT/fn73fWYpqnlXNyXDMWT0zuYx/Bvel9ej+LJ6R08DMOu67q7DkTkrSA5vYPneV71fX/QASdTkJwezhs0TfMARn0wMDDGXEPgF4oijqwM5YjNAAAAAElFTkSuQmCC)}.tablesorter-bootstrap .icon-white.bootstrap-icon-unsorted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAOCAYAAAD5YeaVAAAAe0lEQVR4AbXQoRWDMBiF0Sh2QLAAQ8SxJGugWSA6A2STW1PxTsnB9cnkfuYvv8OGC1t5G3Y0QMP+Bm857keAdQIzWBP3+Bw4MADQE18B6/etRnCV/w9nnGuLezfAmXhABGtAGIkruvk6auIFRwQJDywllsEAjCecB20GP59BQQ+gtlRLAAAAAElFTkSuQmCC)}.tablesorter-bootstrap>tbody>tr.odd>td,.tablesorter-bootstrap>tbody>tr.tablesorter-hasChildRow.odd:hover~tr.tablesorter-hasChildRow.odd~.tablesorter-childRow.odd>td{background-color:#f9f9f9}.tablesorter-bootstrap>tbody>tr.even:hover>td,.tablesorter-bootstrap>tbody>tr.hover>td,.tablesorter-bootstrap>tbody>tr.odd:hover>td,.tablesorter-bootstrap>tbody>tr.tablesorter-hasChildRow.even:hover~.tablesorter-childRow.even>td,.tablesorter-bootstrap>tbody>tr.tablesorter-hasChildRow.odd:hover~.tablesorter-childRow.odd>td{background-color:#f5f5f5}.tablesorter-bootstrap>tbody>tr.even>td,.tablesorter-bootstrap>tbody>tr.tablesorter-hasChildRow.even:hover~tr.tablesorter-hasChildRow.even~.tablesorter-childRow.even>td{background-color:#fff}.tablesorter-bootstrap .tablesorter-processing{background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=);background-position:center center!important;background-repeat:no-repeat!important}.tablesorter-bootstrap>tbody>tr.odd td.primary{background-color:#bfbfbf}.tablesorter-bootstrap>tbody>tr td.primary,.tablesorter-bootstrap>tbody>tr.even td.primary{background-color:#d9d9d9}.tablesorter-bootstrap>tbody>tr.odd td.secondary{background-color:#d9d9d9}.tablesorter-bootstrap>tbody>tr td.secondary,.tablesorter-bootstrap>tbody>tr.even td.secondary{background-color:#e6e6e6}.tablesorter-bootstrap>tbody>tr.odd td.tertiary{background-color:#e6e6e6}.tablesorter-bootstrap>tbody>tr td.tertiary,.tablesorter-bootstrap>tbody>tr.even td.tertiary{background-color:#f2f2f2}.caption{background-color:#fff}.tablesorter-bootstrap .tablesorter-filter-row input.tablesorter-filter,.tablesorter-bootstrap .tablesorter-filter-row select.tablesorter-filter{width:98%;margin:0;padding:4px 6px;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter-bootstrap .tablesorter-filter-row .tablesorter-filter.disabled{background-color:#eee;color:#555;cursor:not-allowed;border:1px solid #ccc;border-radius:4px;box-shadow:0 1px 1px rgba(0,0,0,.075) inset;box-sizing:border-box;transition:height .1s ease}.tablesorter-bootstrap .tablesorter-filter-row{background-color:#efefef}.tablesorter-bootstrap .tablesorter-filter-row td{background-color:#efefef;line-height:normal;text-align:center;padding:4px 6px;vertical-align:middle;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-bootstrap .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0}.tablesorter-bootstrap .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;/* don't use visibility: hidden because it disables tabbing */opacity:0}.tablesorter .filtered{display:none}.tablesorter-bootstrap .tablesorter-pager select{padding:4px 6px}.tablesorter-bootstrap .tablesorter-pager .pagedisplay{border:0}.tablesorter-bootstrap tfoot i{font-size:11px}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file +.tablesorter-bootstrap{width:100%}.tablesorter-bootstrap tfoot td,.tablesorter-bootstrap tfoot th,.tablesorter-bootstrap thead td,.tablesorter-bootstrap thead th{font:14px/20px Arial,Sans-serif;font-weight:700;padding:4px;margin:0 0 18px;background-color:#eee}.tablesorter-bootstrap .tablesorter-header{cursor:pointer}.tablesorter-bootstrap .sorter-false{cursor:default}.tablesorter-bootstrap .tablesorter-header.sorter-false i.tablesorter-icon{display:none}.tablesorter-bootstrap .tablesorter-header-inner{position:relative;padding:4px 18px 4px 4px}.tablesorter-bootstrap .sorter-false .tablesorter-header-inner{padding:4px}.tablesorter-bootstrap .tablesorter-header i.tablesorter-icon{font-size:11px;position:absolute;right:2px;top:50%;margin-top:-7px;width:14px;height:14px;background-repeat:no-repeat;line-height:14px;display:inline-block}.tablesorter-bootstrap .bootstrap-icon-unsorted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAOCAYAAAD5YeaVAAAA20lEQVR4AWJABpKSkoxALCstLb0aUAsZaCAMhVEY6B0amx8YZWDDEDSBa2AGe7XeIiAAClYwVGBvsAcIllsf/mvcC9DgOOd8h90fxWvngVEUbZIkuWRZZlE8eQjcisgZMM9zi+LJ6ZfwegmWZflZDugdHMfxTcGqql7TNBlUB/QObtv2VBSFrev6OY7jngzFk9OT/fn73fWYpqnlXNyXDMWT0zuYx/Bvel9ej+LJ6R08DMOu67q7DkTkrSA5vYPneV71fX/QASdTkJwezhs0TfMARn0wMDDGXEPgF4oijqwM5YjNAAAAAElFTkSuQmCC)}.tablesorter-bootstrap .icon-white.bootstrap-icon-unsorted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAOCAYAAAD5YeaVAAAAe0lEQVR4AbXQoRWDMBiF0Sh2QLAAQ8SxJGugWSA6A2STW1PxTsnB9cnkfuYvv8OGC1t5G3Y0QMP+Bm857keAdQIzWBP3+Bw4MADQE18B6/etRnCV/w9nnGuLezfAmXhABGtAGIkruvk6auIFRwQJDywllsEAjCecB20GP59BQQ+gtlRLAAAAAElFTkSuQmCC)}.tablesorter-bootstrap>tbody>tr.odd>td,.tablesorter-bootstrap>tbody>tr.tablesorter-hasChildRow.odd:hover~tr.tablesorter-hasChildRow.odd~.tablesorter-childRow.odd>td{background-color:#f9f9f9}.tablesorter-bootstrap>tbody>tr.even:hover>td,.tablesorter-bootstrap>tbody>tr.hover>td,.tablesorter-bootstrap>tbody>tr.odd:hover>td,.tablesorter-bootstrap>tbody>tr.tablesorter-hasChildRow.even:hover~.tablesorter-childRow.even>td,.tablesorter-bootstrap>tbody>tr.tablesorter-hasChildRow.odd:hover~.tablesorter-childRow.odd>td{background-color:#f5f5f5}.tablesorter-bootstrap>tbody>tr.even>td,.tablesorter-bootstrap>tbody>tr.tablesorter-hasChildRow.even:hover~tr.tablesorter-hasChildRow.even~.tablesorter-childRow.even>td{background-color:#fff}.tablesorter-bootstrap .tablesorter-processing{background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=);background-position:center center!important;background-repeat:no-repeat!important}.tablesorter-bootstrap>tbody>tr.odd td.primary{background-color:#bfbfbf}.tablesorter-bootstrap>tbody>tr td.primary,.tablesorter-bootstrap>tbody>tr.even td.primary{background-color:#d9d9d9}.tablesorter-bootstrap>tbody>tr.odd td.secondary{background-color:#d9d9d9}.tablesorter-bootstrap>tbody>tr td.secondary,.tablesorter-bootstrap>tbody>tr.even td.secondary{background-color:#e6e6e6}.tablesorter-bootstrap>tbody>tr.odd td.tertiary{background-color:#e6e6e6}.tablesorter-bootstrap>tbody>tr td.tertiary,.tablesorter-bootstrap>tbody>tr.even td.tertiary{background-color:#f2f2f2}.caption{background-color:#fff}.tablesorter-bootstrap .tablesorter-filter-row input.tablesorter-filter,.tablesorter-bootstrap .tablesorter-filter-row select.tablesorter-filter{width:98%;margin:0;padding:4px 6px;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter-bootstrap .tablesorter-filter-row .tablesorter-filter.disabled{background-color:#eee;color:#555;cursor:not-allowed;border:1px solid #ccc;border-radius:4px;box-shadow:0 1px 1px rgba(0,0,0,.075) inset;box-sizing:border-box;transition:height .1s ease}.tablesorter-bootstrap .tablesorter-filter-row{background-color:#efefef}.tablesorter-bootstrap .tablesorter-filter-row td{background-color:#efefef;line-height:normal;text-align:center;padding:4px 6px;vertical-align:middle;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-bootstrap .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0}.tablesorter-bootstrap .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;opacity:0}.tablesorter .filtered{display:none}.tablesorter-bootstrap .tablesorter-pager select{padding:4px 6px}.tablesorter-bootstrap .tablesorter-pager .pagedisplay{border:0}.tablesorter-bootstrap tfoot i{font-size:11px}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file diff --git a/dist/css/theme.bootstrap_4.min.css b/dist/css/theme.bootstrap_4.min.css index 6d4fbfc45..844a4d12c 100644 --- a/dist/css/theme.bootstrap_4.min.css +++ b/dist/css/theme.bootstrap_4.min.css @@ -1 +1 @@ -.tablesorter-bootstrap{width:100%}.tablesorter-bootstrap tfoot td,.tablesorter-bootstrap tfoot th,.tablesorter-bootstrap thead td,.tablesorter-bootstrap thead th{font:14px/20px Arial,Sans-serif;font-weight:700;padding:4px;margin:0 0 18px}.tablesorter-bootstrap thead .tablesorter-header{background-position:right 5px center;background-repeat:no-repeat;cursor:pointer;white-space:normal}.tablesorter-bootstrap:not(.table-inverse) tfoot td,.tablesorter-bootstrap:not(.table-inverse) tfoot th,.tablesorter-bootstrap:not(.table-inverse) thead:not(.thead-inverse) .tablesorter-header{background-color:#eee}.tablesorter-bootstrap thead .sorter-false{cursor:default;background-image:none}.tablesorter-bootstrap .tablesorter-header-inner{position:relative;padding:4px 18px 4px 4px}.tablesorter-bootstrap .sorter-false .tablesorter-header-inner{padding:4px}.tablesorter-bootstrap thead .tablesorter-headerUnSorted:not(.sorter-false){background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE0IDIwIj48cGF0aCBkPSJNMTQgMTNsLTIuNS0yLjVMNyAxNWwtNC41LTQuNUwwIDEzbDcgN3pNMTQgNy41TDExLjUgMTAgNyA1LjUgMi41IDEwIDAgNy41bDctN3oiLz48L3N2Zz4=)}.tablesorter-bootstrap thead .tablesorter-headerAsc{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDE0IDE0Ij48cGF0aCBkPSJNMTQgOS41TDExLjUgMTIgNyA3LjUgMi41IDEyIDAgOS41bDctN3oiLz48L3N2Zz4=)}.tablesorter-bootstrap thead .tablesorter-headerDesc{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDE0IDE0Ij48cGF0aCBkPSJNMTQgNWwtMi41LTIuNS00LjUgNC41LTQuNS00LjVMMCA1IDcgMTJ6Ii8+PC9zdmc+)}.tablesorter-bootstrap thead.thead-inverse .tablesorter-headerUnSorted:not(.sorter-false),.tablesorter-bootstrap.table-inverse thead .tablesorter-headerUnSorted:not(.sorter-false){background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE0IDIwIj48cGF0aCBmaWxsPSIjZmZmIiBkPSJNMTQgMTNsLTIuNS0yLjVMNyAxNWwtNC41LTQuNUwwIDEzbDcgN3pNMTQgNy41TDExLjUgMTAgNyA1LjUgMi41IDEwIDAgNy41bDctN3oiLz48L3N2Zz4=)}.tablesorter-bootstrap thead.thead-inverse .tablesorter-headerAsc,.tablesorter-bootstrap.table-inverse thead .tablesorter-headerAsc{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDE0IDE0Ij48cGF0aCBmaWxsPSIjZmZmIiBkPSJNMTQgOS41TDExLjUgMTIgNyA3LjUgMi41IDEyIDAgOS41bDctN3oiLz48L3N2Zz4=)}.tablesorter-bootstrap thead.thead-inverse .tablesorter-headerDesc,.tablesorter-bootstrap.table-inverse thead .tablesorter-headerDesc{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDE0IDE0Ij48cGF0aCBmaWxsPSIjZmZmIiBkPSJNMTQgNWwtMi41LTIuNS00LjUgNC41LTQuNS00LjVMMCA1IDcgMTJ6Ii8+PC9zdmc+)}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.odd>td,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.tablesorter-hasChildRow.odd:hover~tr.tablesorter-hasChildRow.odd~.tablesorter-childRow.odd>td{background-color:#f9f9f9}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.even:hover>td,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.hover>td,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.odd:hover>td,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.tablesorter-hasChildRow.even:hover~.tablesorter-childRow.even>td,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.tablesorter-hasChildRow.odd:hover~.tablesorter-childRow.odd>td{background-color:#f5f5f5}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.even>td,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.tablesorter-hasChildRow.even:hover~tr.tablesorter-hasChildRow.even~.tablesorter-childRow.even>td{background-color:#fff}.tablesorter-bootstrap .tablesorter-processing{background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=);background-position:center center!important;background-repeat:no-repeat!important}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.odd td.primary{background-color:#bfbfbf}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr td.primary,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.even td.primary{background-color:#d9d9d9}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.odd td.secondary{background-color:#d9d9d9}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr td.secondary,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.even td.secondary{background-color:#e6e6e6}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.odd td.tertiary{background-color:#e6e6e6}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr td.tertiary,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.even td.tertiary{background-color:#f2f2f2}.tablesorter-bootstrap:not(.table-inverse) .caption{background-color:#fff}.tablesorter-bootstrap .tablesorter-filter-row input.tablesorter-filter,.tablesorter-bootstrap .tablesorter-filter-row select.tablesorter-filter{width:98%;margin:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter-bootstrap:not(.table-inverse) .tablesorter-filter-row{background-color:#efefef}.tablesorter-bootstrap:not(.table-inverse) .tablesorter-filter-row input.tablesorter-filter,.tablesorter-bootstrap:not(.table-inverse) .tablesorter-filter-row select.tablesorter-filter{color:#333}.tablesorter-bootstrap .tablesorter-filter-row .tablesorter-filter.disabled{cursor:not-allowed;box-shadow:0 1px 1px rgba(0,0,0,.075) inset;box-sizing:border-box;transition:height .1s ease}.tablesorter-bootstrap:not(.table-inverse) .tablesorter-filter-row td{line-height:normal;text-align:center;padding:4px 6px;vertical-align:middle;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-bootstrap .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0}.tablesorter-bootstrap .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;/* don't use visibility: hidden because it disables tabbing */opacity:0}.tablesorter .filtered{display:none}.tablesorter-bootstrap .tablesorter-pager .pagedisplay{border:0}.tablesorter:not(.table-inverse) .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file +.tablesorter-bootstrap{width:100%}.tablesorter-bootstrap tfoot td,.tablesorter-bootstrap tfoot th,.tablesorter-bootstrap thead td,.tablesorter-bootstrap thead th{font:14px/20px Arial,Sans-serif;font-weight:700;padding:4px;margin:0 0 18px}.tablesorter-bootstrap thead .tablesorter-header{background-position:right 5px center;background-repeat:no-repeat;cursor:pointer;white-space:normal}.tablesorter-bootstrap:not(.table-inverse) tfoot td,.tablesorter-bootstrap:not(.table-inverse) tfoot th,.tablesorter-bootstrap:not(.table-inverse) thead:not(.thead-inverse) .tablesorter-header{background-color:#eee}.tablesorter-bootstrap thead .sorter-false{cursor:default;background-image:none}.tablesorter-bootstrap .tablesorter-header-inner{position:relative;padding:4px 18px 4px 4px}.tablesorter-bootstrap .sorter-false .tablesorter-header-inner{padding:4px}.tablesorter-bootstrap thead .tablesorter-headerUnSorted:not(.sorter-false){background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE0IDIwIj48cGF0aCBkPSJNMTQgMTNsLTIuNS0yLjVMNyAxNWwtNC41LTQuNUwwIDEzbDcgN3pNMTQgNy41TDExLjUgMTAgNyA1LjUgMi41IDEwIDAgNy41bDctN3oiLz48L3N2Zz4=)}.tablesorter-bootstrap thead .tablesorter-headerAsc{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDE0IDE0Ij48cGF0aCBkPSJNMTQgOS41TDExLjUgMTIgNyA3LjUgMi41IDEyIDAgOS41bDctN3oiLz48L3N2Zz4=)}.tablesorter-bootstrap thead .tablesorter-headerDesc{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDE0IDE0Ij48cGF0aCBkPSJNMTQgNWwtMi41LTIuNS00LjUgNC41LTQuNS00LjVMMCA1IDcgMTJ6Ii8+PC9zdmc+)}.tablesorter-bootstrap thead.thead-inverse .tablesorter-headerUnSorted:not(.sorter-false),.tablesorter-bootstrap.table-inverse thead .tablesorter-headerUnSorted:not(.sorter-false){background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE0IDIwIj48cGF0aCBmaWxsPSIjZmZmIiBkPSJNMTQgMTNsLTIuNS0yLjVMNyAxNWwtNC41LTQuNUwwIDEzbDcgN3pNMTQgNy41TDExLjUgMTAgNyA1LjUgMi41IDEwIDAgNy41bDctN3oiLz48L3N2Zz4=)}.tablesorter-bootstrap thead.thead-inverse .tablesorter-headerAsc,.tablesorter-bootstrap.table-inverse thead .tablesorter-headerAsc{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDE0IDE0Ij48cGF0aCBmaWxsPSIjZmZmIiBkPSJNMTQgOS41TDExLjUgMTIgNyA3LjUgMi41IDEyIDAgOS41bDctN3oiLz48L3N2Zz4=)}.tablesorter-bootstrap thead.thead-inverse .tablesorter-headerDesc,.tablesorter-bootstrap.table-inverse thead .tablesorter-headerDesc{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDE0IDE0Ij48cGF0aCBmaWxsPSIjZmZmIiBkPSJNMTQgNWwtMi41LTIuNS00LjUgNC41LTQuNS00LjVMMCA1IDcgMTJ6Ii8+PC9zdmc+)}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.odd>td,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.tablesorter-hasChildRow.odd:hover~tr.tablesorter-hasChildRow.odd~.tablesorter-childRow.odd>td{background-color:#f9f9f9}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.even:hover>td,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.hover>td,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.odd:hover>td,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.tablesorter-hasChildRow.even:hover~.tablesorter-childRow.even>td,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.tablesorter-hasChildRow.odd:hover~.tablesorter-childRow.odd>td{background-color:#f5f5f5}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.even>td,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.tablesorter-hasChildRow.even:hover~tr.tablesorter-hasChildRow.even~.tablesorter-childRow.even>td{background-color:#fff}.tablesorter-bootstrap .tablesorter-processing{background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=);background-position:center center!important;background-repeat:no-repeat!important}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.odd td.primary{background-color:#bfbfbf}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr td.primary,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.even td.primary{background-color:#d9d9d9}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.odd td.secondary{background-color:#d9d9d9}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr td.secondary,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.even td.secondary{background-color:#e6e6e6}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.odd td.tertiary{background-color:#e6e6e6}.tablesorter-bootstrap:not(.table-inverse)>tbody>tr td.tertiary,.tablesorter-bootstrap:not(.table-inverse)>tbody>tr.even td.tertiary{background-color:#f2f2f2}.tablesorter-bootstrap:not(.table-inverse) .caption{background-color:#fff}.tablesorter-bootstrap .tablesorter-filter-row input.tablesorter-filter,.tablesorter-bootstrap .tablesorter-filter-row select.tablesorter-filter{width:98%;margin:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter-bootstrap:not(.table-inverse) .tablesorter-filter-row{background-color:#efefef}.tablesorter-bootstrap:not(.table-inverse) .tablesorter-filter-row input.tablesorter-filter,.tablesorter-bootstrap:not(.table-inverse) .tablesorter-filter-row select.tablesorter-filter{color:#333}.tablesorter-bootstrap .tablesorter-filter-row .tablesorter-filter.disabled{cursor:not-allowed;box-shadow:0 1px 1px rgba(0,0,0,.075) inset;box-sizing:border-box;transition:height .1s ease}.tablesorter-bootstrap:not(.table-inverse) .tablesorter-filter-row td{line-height:normal;text-align:center;padding:4px 6px;vertical-align:middle;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-bootstrap .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0}.tablesorter-bootstrap .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;opacity:0}.tablesorter .filtered{display:none}.tablesorter-bootstrap .tablesorter-pager .pagedisplay{border:0}.tablesorter:not(.table-inverse) .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file diff --git a/dist/css/theme.dark.min.css b/dist/css/theme.dark.min.css index 404975b05..c47e73a5d 100644 --- a/dist/css/theme.dark.min.css +++ b/dist/css/theme.dark.min.css @@ -1 +1 @@ -.tablesorter-dark{width:100%;font:11px/18px Arial,Sans-serif;color:#ccc;text-align:left;background-color:#000;border-spacing:0}.tablesorter-dark th,.tablesorter-dark thead td{padding:4px;font:12px/20px Arial,Sans-serif;font-weight:700;color:#fff;background-color:#000;border-collapse:collapse}.tablesorter-dark thead th{border-bottom:#333 2px solid}.tablesorter-dark .header,.tablesorter-dark .tablesorter-header{padding:4px 20px 4px 4px;cursor:pointer;background-image:url(data:image/gif;base64,R0lGODlhFQAJAIAAAP///////yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);background-position:center right;background-repeat:no-repeat}.tablesorter-dark thead .headerSortUp,.tablesorter-dark thead .tablesorter-headerAsc,.tablesorter-dark thead .tablesorter-headerSortUp{background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAAP///////yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7);border-bottom:#888 1px solid}.tablesorter-dark thead .headerSortDown,.tablesorter-dark thead .tablesorter-headerDesc,.tablesorter-dark thead .tablesorter-headerSortDown{background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAAP///////yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7);border-bottom:#888 1px solid}.tablesorter-dark thead .sorter-false{background-image:none;cursor:default;padding:4px}.tablesorter-dark tfoot .tablesorter-headerAsc,.tablesorter-dark tfoot .tablesorter-headerDesc,.tablesorter-dark tfoot .tablesorter-headerSortDown,.tablesorter-dark tfoot .tablesorter-headerSortUp{border-top:#888 1px solid;background-image:none}.tablesorter-dark td{padding:4px;background-color:#000;border-bottom:#333 1px solid;color:#ccc}.tablesorter-dark tbody>tr.even:hover>td,.tablesorter-dark tbody>tr.hover>td,.tablesorter-dark tbody>tr.odd:hover>td,.tablesorter-dark tbody>tr:hover>td{background-color:#000}.tablesorter-dark .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-dark tr.odd>td{background-color:#202020}.tablesorter-dark tr.even>td{background-color:#101010}.tablesorter-dark td.primary,.tablesorter-dark tr.odd td.primary{background-color:#0a0a0a}.tablesorter-dark tr.even td.primary{background-color:#050505}.tablesorter-dark td.secondary,.tablesorter-dark tr.odd td.secondary{background-color:#0f0f0f}.tablesorter-dark tr.even td.secondary{background-color:#0a0a0a}.tablesorter-dark td.tertiary,.tablesorter-dark tr.odd td.tertiary{background-color:#191919}.tablesorter-dark tr.even td.tertiary{background-color:#0f0f0f}caption{background-color:#202020}.tablesorter-dark .tablesorter-filter-row{background-color:#202020}.tablesorter-dark .tablesorter-filter-row td{background-color:#202020;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-dark .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-dark .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-dark .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;/* don't use visibility: hidden because it disables tabbing */opacity:0}.tablesorter-dark input.tablesorter-filter,.tablesorter-dark select.tablesorter-filter{width:98%;height:auto;margin:0;padding:4px;background-color:#111;border:1px solid #222;color:#ddd;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file +.tablesorter-dark{width:100%;font:11px/18px Arial,Sans-serif;color:#ccc;text-align:left;background-color:#000;border-spacing:0}.tablesorter-dark th,.tablesorter-dark thead td{padding:4px;font:12px/20px Arial,Sans-serif;font-weight:700;color:#fff;background-color:#000;border-collapse:collapse}.tablesorter-dark thead th{border-bottom:#333 2px solid}.tablesorter-dark .header,.tablesorter-dark .tablesorter-header{padding:4px 20px 4px 4px;cursor:pointer;background-image:url(data:image/gif;base64,R0lGODlhFQAJAIAAAP///////yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);background-position:center right;background-repeat:no-repeat}.tablesorter-dark thead .headerSortUp,.tablesorter-dark thead .tablesorter-headerAsc,.tablesorter-dark thead .tablesorter-headerSortUp{background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAAP///////yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7);border-bottom:#888 1px solid}.tablesorter-dark thead .headerSortDown,.tablesorter-dark thead .tablesorter-headerDesc,.tablesorter-dark thead .tablesorter-headerSortDown{background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAAP///////yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7);border-bottom:#888 1px solid}.tablesorter-dark thead .sorter-false{background-image:none;cursor:default;padding:4px}.tablesorter-dark tfoot .tablesorter-headerAsc,.tablesorter-dark tfoot .tablesorter-headerDesc,.tablesorter-dark tfoot .tablesorter-headerSortDown,.tablesorter-dark tfoot .tablesorter-headerSortUp{border-top:#888 1px solid;background-image:none}.tablesorter-dark td{padding:4px;background-color:#000;border-bottom:#333 1px solid;color:#ccc}.tablesorter-dark tbody>tr.even:hover>td,.tablesorter-dark tbody>tr.hover>td,.tablesorter-dark tbody>tr.odd:hover>td,.tablesorter-dark tbody>tr:hover>td{background-color:#000}.tablesorter-dark .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-dark tr.odd>td{background-color:#202020}.tablesorter-dark tr.even>td{background-color:#101010}.tablesorter-dark td.primary,.tablesorter-dark tr.odd td.primary{background-color:#0a0a0a}.tablesorter-dark tr.even td.primary{background-color:#050505}.tablesorter-dark td.secondary,.tablesorter-dark tr.odd td.secondary{background-color:#0f0f0f}.tablesorter-dark tr.even td.secondary{background-color:#0a0a0a}.tablesorter-dark td.tertiary,.tablesorter-dark tr.odd td.tertiary{background-color:#191919}.tablesorter-dark tr.even td.tertiary{background-color:#0f0f0f}caption{background-color:#202020}.tablesorter-dark .tablesorter-filter-row{background-color:#202020}.tablesorter-dark .tablesorter-filter-row td{background-color:#202020;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-dark .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-dark .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-dark .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;opacity:0}.tablesorter-dark input.tablesorter-filter,.tablesorter-dark select.tablesorter-filter{width:98%;height:auto;margin:0;padding:4px;background-color:#111;border:1px solid #222;color:#ddd;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file diff --git a/dist/css/theme.default.min.css b/dist/css/theme.default.min.css index 67ef97244..5e4331c54 100644 --- a/dist/css/theme.default.min.css +++ b/dist/css/theme.default.min.css @@ -1 +1 @@ -.tablesorter-default{width:100%;font:12px/18px Arial,Sans-serif;color:#333;background-color:#fff;border-spacing:0;margin:10px 0 15px;text-align:left}.tablesorter-default th,.tablesorter-default thead td{font-weight:700;color:#000;background-color:#fff;border-collapse:collapse;border-bottom:#ccc 2px solid;padding:0}.tablesorter-default tfoot td,.tablesorter-default tfoot th{border:0}.tablesorter-default .header,.tablesorter-default .tablesorter-header{background-image:url(data:image/gif;base64,R0lGODlhFQAJAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);background-position:center right;background-repeat:no-repeat;cursor:pointer;white-space:normal;padding:4px 20px 4px 4px}.tablesorter-default thead .headerSortUp,.tablesorter-default thead .tablesorter-headerAsc,.tablesorter-default thead .tablesorter-headerSortUp{background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7);border-bottom:#000 2px solid}.tablesorter-default thead .headerSortDown,.tablesorter-default thead .tablesorter-headerDesc,.tablesorter-default thead .tablesorter-headerSortDown{background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7);border-bottom:#000 2px solid}.tablesorter-default thead .sorter-false{background-image:none;cursor:default;padding:4px}.tablesorter-default tfoot .tablesorter-headerAsc,.tablesorter-default tfoot .tablesorter-headerDesc,.tablesorter-default tfoot .tablesorter-headerSortDown,.tablesorter-default tfoot .tablesorter-headerSortUp{border-top:#000 2px solid}.tablesorter-default td{background-color:#fff;border-bottom:#ccc 1px solid;padding:4px;vertical-align:top}.tablesorter-default tbody>tr.even:hover>td,.tablesorter-default tbody>tr.hover>td,.tablesorter-default tbody>tr.odd:hover>td,.tablesorter-default tbody>tr:hover>td{background-color:#fff;color:#000}.tablesorter-default .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-default tr.odd>td{background-color:#dfdfdf}.tablesorter-default tr.even>td{background-color:#efefef}.tablesorter-default tr.odd td.primary{background-color:#bfbfbf}.tablesorter-default td.primary,.tablesorter-default tr.even td.primary{background-color:#d9d9d9}.tablesorter-default tr.odd td.secondary{background-color:#d9d9d9}.tablesorter-default td.secondary,.tablesorter-default tr.even td.secondary{background-color:#e6e6e6}.tablesorter-default tr.odd td.tertiary{background-color:#e6e6e6}.tablesorter-default td.tertiary,.tablesorter-default tr.even td.tertiary{background-color:#f2f2f2}caption{background-color:#fff}.tablesorter-default .tablesorter-filter-row{background-color:#eee}.tablesorter-default .tablesorter-filter-row td{background-color:#eee;border-bottom:#ccc 1px solid;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-default .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-default .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-default .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;/* don't use visibility: hidden because it disables tabbing */opacity:0}.tablesorter-default input.tablesorter-filter,.tablesorter-default select.tablesorter-filter{width:95%;height:auto;margin:4px auto;padding:4px;background-color:#fff;border:1px solid #bbb;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file +.tablesorter-default{width:100%;font:12px/18px Arial,Sans-serif;color:#333;background-color:#fff;border-spacing:0;margin:10px 0 15px;text-align:left}.tablesorter-default th,.tablesorter-default thead td{font-weight:700;color:#000;background-color:#fff;border-collapse:collapse;border-bottom:#ccc 2px solid;padding:0}.tablesorter-default tfoot td,.tablesorter-default tfoot th{border:0}.tablesorter-default .header,.tablesorter-default .tablesorter-header{background-image:url(data:image/gif;base64,R0lGODlhFQAJAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);background-position:center right;background-repeat:no-repeat;cursor:pointer;white-space:normal;padding:4px 20px 4px 4px}.tablesorter-default thead .headerSortUp,.tablesorter-default thead .tablesorter-headerAsc,.tablesorter-default thead .tablesorter-headerSortUp{background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7);border-bottom:#000 2px solid}.tablesorter-default thead .headerSortDown,.tablesorter-default thead .tablesorter-headerDesc,.tablesorter-default thead .tablesorter-headerSortDown{background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7);border-bottom:#000 2px solid}.tablesorter-default thead .sorter-false{background-image:none;cursor:default;padding:4px}.tablesorter-default tfoot .tablesorter-headerAsc,.tablesorter-default tfoot .tablesorter-headerDesc,.tablesorter-default tfoot .tablesorter-headerSortDown,.tablesorter-default tfoot .tablesorter-headerSortUp{border-top:#000 2px solid}.tablesorter-default td{background-color:#fff;border-bottom:#ccc 1px solid;padding:4px;vertical-align:top}.tablesorter-default tbody>tr.even:hover>td,.tablesorter-default tbody>tr.hover>td,.tablesorter-default tbody>tr.odd:hover>td,.tablesorter-default tbody>tr:hover>td{background-color:#fff;color:#000}.tablesorter-default .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-default tr.odd>td{background-color:#dfdfdf}.tablesorter-default tr.even>td{background-color:#efefef}.tablesorter-default tr.odd td.primary{background-color:#bfbfbf}.tablesorter-default td.primary,.tablesorter-default tr.even td.primary{background-color:#d9d9d9}.tablesorter-default tr.odd td.secondary{background-color:#d9d9d9}.tablesorter-default td.secondary,.tablesorter-default tr.even td.secondary{background-color:#e6e6e6}.tablesorter-default tr.odd td.tertiary{background-color:#e6e6e6}.tablesorter-default td.tertiary,.tablesorter-default tr.even td.tertiary{background-color:#f2f2f2}caption{background-color:#fff}.tablesorter-default .tablesorter-filter-row{background-color:#eee}.tablesorter-default .tablesorter-filter-row td{background-color:#eee;border-bottom:#ccc 1px solid;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-default .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-default .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-default .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;opacity:0}.tablesorter-default input.tablesorter-filter,.tablesorter-default select.tablesorter-filter{width:95%;height:auto;margin:4px auto;padding:4px;background-color:#fff;border:1px solid #bbb;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file diff --git a/dist/css/theme.dropbox.min.css b/dist/css/theme.dropbox.min.css index c17b00d24..f8a1176b6 100644 --- a/dist/css/theme.dropbox.min.css +++ b/dist/css/theme.dropbox.min.css @@ -1 +1 @@ -.tablesorter-dropbox{width:100%;font:13px/32px "Open Sans","lucida grande","Segoe UI",arial,verdana,"lucida sans unicode",tahoma,sans-serif;color:#555;text-align:left;background-color:#fff;border-collapse:collapse;border-top:1px solid #82cffa;border-spacing:0}.tablesorter-dropbox tfoot td,.tablesorter-dropbox tfoot th,.tablesorter-dropbox th,.tablesorter-dropbox thead td{background-color:#f0f9ff;border-color:#82cffa #e7f2fb #96c4ea;border-style:solid;border-width:1px;padding:3px 6px;font-size:13px;font-weight:400;line-height:29px;color:#2281cf;text-align:left}.tablesorter-dropbox .header,.tablesorter-dropbox .tablesorter-headerRow,.tablesorter-dropbox thead tr{background-color:#f0f9ff;border-bottom:1px solid #96c4ea;box-shadow:0 1px 1px rgba(0,0,0,.12),0 0 0 #000 inset;white-space:normal}.tablesorter-dropbox .tablesorter-headerAsc,.tablesorter-dropbox .tablesorter-headerDesc,.tablesorter-dropbox .tablesorter-headerSortDown,.tablesorter-dropbox .tablesorter-headerSortUp{font-weight:600}.tablesorter-dropbox .tablesorter-header{cursor:pointer}.tablesorter-dropbox .tablesorter-header i.tablesorter-icon{width:9px;height:9px;padding:0 10px 0 4px;display:inline-block;background-position:center right;background-repeat:no-repeat;content:""}.tablesorter-dropbox .tablesorter-headerAsc i.tablesorter-icon,.tablesorter-dropbox .tablesorter-headerSortUp i.tablesorter-icon{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAALhJREFUeNpi/P//PwMhwILMiexYx8bIxNTy/9+/muUVQb9g4kzIitg4edI4+YRLQTSyOCPMupjerUI8whK3OXgEhH58+fDuy9sXqkuKvd+hmMTOxdvCxS8sxMUvxACiQXwU6+Im7DDg5BNKY+fiY2BmYWMA0SA+SByuiJ2bbzIHrwAzMxsb0AGMDCAaxAeJg+SZ7wtaqfAISfQAdTIwMUM8ywhUyMTEzPD/71+5FXvPLWUkJpwAAgwAZqYvvHStbD4AAAAASUVORK5CYII=)}.tablesorter-dropbox .tablesorter-headerAsc:hover i.tablesorter-icon,.tablesorter-dropbox .tablesorter-headerSortUp:hover i.tablesorter-icon{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAALVJREFUeNpi/P//PwMhwILMCc+qZGNkYmr5/+9fzcpp7b9g4kzIitjYOdM4uXlLQTSyOCPMuqi8OiEefsHbHFzcQj++fX335eN71WWTmt6hmMTOwdXCycMnBDSJAUSD+CjWxRQ0GHBw86Sxc3AyMDOzMIBoEB8kDlfEzsk1mYOLByjPCnQAIwOIBvFB4iB55rsfmVS4+QV7QNYwMTNDHApUyMTExPDv/z+5Feu3L2UkJpwAAgwA244u+I9CleAAAAAASUVORK5CYII=)}.tablesorter-dropbox .tablesorter-headerDesc i.tablesorter-icon,.tablesorter-dropbox .tablesorter-headerSortDown i.tablesorter-icon{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAALdJREFUeNpi/P//PwMhwBLdtVGFhZ3zNhMzC4bkv79/GP78/K7KCDIpZ9mVw+xcfDaMTExwBf///WP4+e3TkSlROrZg7UxMLLns3HxnmFnZmGGK/v7+9ff3j2+5YHkQMSlC48Kv719m/f//D2IKkAbxQeJwRSDw4/OHmr+/fr0DqmAA0SA+TA6uaEq0zjugG+r//vkFcks9iA/3HbJvvn18O+vf379yP758mMXAoAAXZyQmnAACDADX316BiTFbMQAAAABJRU5ErkJggg==)}.tablesorter-dropbox .tablesorter-headerDesc:hover i.tablesorter-icon,.tablesorter-dropbox .tablesorter-headerSortDown:hover i.tablesorter-icon{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAALNJREFUeNpi/P//PwMhwBJf3uP879e3PUzMzBiS//7+ZWBi43JhBJmU2z7nIzMzEx8jIyNcAUj8799/nyZXpvCzgARYuXjTWBkZVjCzIEz7++cvw+//DGkgNiPMTWVT1l5hZvynDTINbMp/pqtdOcE6IDkmmM5fv3/5//v37z9QBQOIBvFhcnBFEwoj7/5jZFnz9+8fBhAN4sN9h+ybH9++JrGxscr/+vE1CVmckZhwAggwANvlUyq5Dd1wAAAAAElFTkSuQmCC)}.tablesorter-dropbox thead .sorter-false{cursor:default}.tablesorter-dropbox thead .sorter-false i.tablesorter-icon{display:none}.tablesorter-dropbox td{padding:5px 6px;line-height:32px;color:#555;text-align:left;border-top:1px solid #edf1f5;border-bottom:1px solid #edf1f5}.tablesorter-dropbox tbody>tr.even:hover>td,.tablesorter-dropbox tbody>tr.hover>td,.tablesorter-dropbox tbody>tr.odd:hover>td,.tablesorter-dropbox tbody>tr:hover>td{background-color:rgba(230,245,255,.3);border-right:0;border-left:0;border-color:#c6d8e4;border-style:double}.tablesorter-dropbox .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}caption{background-color:#fff}.tablesorter-dropbox .tablesorter-filter-row{background-color:#fff}.tablesorter-dropbox .tablesorter-filter-row td{background-color:#fff;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-dropbox .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-dropbox .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-dropbox .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;/* don't use visibility: hidden because it disables tabbing */opacity:0}.tablesorter-dropbox input.tablesorter-filter,.tablesorter-dropbox select.tablesorter-filter{width:98%;height:auto;margin:0;background-color:#fff;border:1px solid #bbb;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file +.tablesorter-dropbox{width:100%;font:13px/32px "Open Sans","lucida grande","Segoe UI",arial,verdana,"lucida sans unicode",tahoma,sans-serif;color:#555;text-align:left;background-color:#fff;border-collapse:collapse;border-top:1px solid #82cffa;border-spacing:0}.tablesorter-dropbox tfoot td,.tablesorter-dropbox tfoot th,.tablesorter-dropbox th,.tablesorter-dropbox thead td{background-color:#f0f9ff;border-color:#82cffa #e7f2fb #96c4ea;border-style:solid;border-width:1px;padding:3px 6px;font-size:13px;font-weight:400;line-height:29px;color:#2281cf;text-align:left}.tablesorter-dropbox .header,.tablesorter-dropbox .tablesorter-headerRow,.tablesorter-dropbox thead tr{background-color:#f0f9ff;border-bottom:1px solid #96c4ea;box-shadow:0 1px 1px rgba(0,0,0,.12),0 0 0 #000 inset;white-space:normal}.tablesorter-dropbox .tablesorter-headerAsc,.tablesorter-dropbox .tablesorter-headerDesc,.tablesorter-dropbox .tablesorter-headerSortDown,.tablesorter-dropbox .tablesorter-headerSortUp{font-weight:600}.tablesorter-dropbox .tablesorter-header{cursor:pointer}.tablesorter-dropbox .tablesorter-header i.tablesorter-icon{width:9px;height:9px;padding:0 10px 0 4px;display:inline-block;background-position:center right;background-repeat:no-repeat;content:""}.tablesorter-dropbox .tablesorter-headerAsc i.tablesorter-icon,.tablesorter-dropbox .tablesorter-headerSortUp i.tablesorter-icon{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAALhJREFUeNpi/P//PwMhwILMiexYx8bIxNTy/9+/muUVQb9g4kzIitg4edI4+YRLQTSyOCPMupjerUI8whK3OXgEhH58+fDuy9sXqkuKvd+hmMTOxdvCxS8sxMUvxACiQXwU6+Im7DDg5BNKY+fiY2BmYWMA0SA+SByuiJ2bbzIHrwAzMxsb0AGMDCAaxAeJg+SZ7wtaqfAISfQAdTIwMUM8ywhUyMTEzPD/71+5FXvPLWUkJpwAAgwAZqYvvHStbD4AAAAASUVORK5CYII=)}.tablesorter-dropbox .tablesorter-headerAsc:hover i.tablesorter-icon,.tablesorter-dropbox .tablesorter-headerSortUp:hover i.tablesorter-icon{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAALVJREFUeNpi/P//PwMhwILMCc+qZGNkYmr5/+9fzcpp7b9g4kzIitjYOdM4uXlLQTSyOCPMuqi8OiEefsHbHFzcQj++fX335eN71WWTmt6hmMTOwdXCycMnBDSJAUSD+CjWxRQ0GHBw86Sxc3AyMDOzMIBoEB8kDlfEzsk1mYOLByjPCnQAIwOIBvFB4iB55rsfmVS4+QV7QNYwMTNDHApUyMTExPDv/z+5Feu3L2UkJpwAAgwA244u+I9CleAAAAAASUVORK5CYII=)}.tablesorter-dropbox .tablesorter-headerDesc i.tablesorter-icon,.tablesorter-dropbox .tablesorter-headerSortDown i.tablesorter-icon{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAALdJREFUeNpi/P//PwMhwBLdtVGFhZ3zNhMzC4bkv79/GP78/K7KCDIpZ9mVw+xcfDaMTExwBf///WP4+e3TkSlROrZg7UxMLLns3HxnmFnZmGGK/v7+9ff3j2+5YHkQMSlC48Kv719m/f//D2IKkAbxQeJwRSDw4/OHmr+/fr0DqmAA0SA+TA6uaEq0zjugG+r//vkFcks9iA/3HbJvvn18O+vf379yP758mMXAoAAXZyQmnAACDADX316BiTFbMQAAAABJRU5ErkJggg==)}.tablesorter-dropbox .tablesorter-headerDesc:hover i.tablesorter-icon,.tablesorter-dropbox .tablesorter-headerSortDown:hover i.tablesorter-icon{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAALNJREFUeNpi/P//PwMhwBJf3uP879e3PUzMzBiS//7+ZWBi43JhBJmU2z7nIzMzEx8jIyNcAUj8799/nyZXpvCzgARYuXjTWBkZVjCzIEz7++cvw+//DGkgNiPMTWVT1l5hZvynDTINbMp/pqtdOcE6IDkmmM5fv3/5//v37z9QBQOIBvFhcnBFEwoj7/5jZFnz9+8fBhAN4sN9h+ybH9++JrGxscr/+vE1CVmckZhwAggwANvlUyq5Dd1wAAAAAElFTkSuQmCC)}.tablesorter-dropbox thead .sorter-false{cursor:default}.tablesorter-dropbox thead .sorter-false i.tablesorter-icon{display:none}.tablesorter-dropbox td{padding:5px 6px;line-height:32px;color:#555;text-align:left;border-top:1px solid #edf1f5;border-bottom:1px solid #edf1f5}.tablesorter-dropbox tbody>tr.even:hover>td,.tablesorter-dropbox tbody>tr.hover>td,.tablesorter-dropbox tbody>tr.odd:hover>td,.tablesorter-dropbox tbody>tr:hover>td{background-color:rgba(230,245,255,.3);border-right:0;border-left:0;border-color:#c6d8e4;border-style:double}.tablesorter-dropbox .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}caption{background-color:#fff}.tablesorter-dropbox .tablesorter-filter-row{background-color:#fff}.tablesorter-dropbox .tablesorter-filter-row td{background-color:#fff;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-dropbox .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-dropbox .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-dropbox .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;opacity:0}.tablesorter-dropbox input.tablesorter-filter,.tablesorter-dropbox select.tablesorter-filter{width:98%;height:auto;margin:0;background-color:#fff;border:1px solid #bbb;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file diff --git a/dist/css/theme.green.min.css b/dist/css/theme.green.min.css index 65ad4d5dc..a2b4b1d02 100644 --- a/dist/css/theme.green.min.css +++ b/dist/css/theme.green.min.css @@ -1 +1 @@ -.tablesorter-green{width:100%;text-align:left;border-spacing:0;border:#cdcdcd 1px solid;border-width:1px 0 0 1px}.tablesorter-green td,.tablesorter-green th{font:12px/18px Arial,Sans-serif;border:#cdcdcd 1px solid;border-width:0 1px 1px 0}.tablesorter-green tfoot tr,.tablesorter-green thead tr .tablesorter-header{background-position:center center;background-repeat:repeat-x;background-image:url(data:image/gif;base64,R0lGODlhAQBkAOYAAN/e39XU1fX19tTU1eXm5uTl5ePk5OLj4+Hi4vX29fT19PP08/Lz8vHy8fDx8O/w7+7v7uzt7Orr6ufo5/T08/Pz8ufn5uLi4eDg39/f3t3d3Nzc29HR0NDQz8/Pzuvq6urp6eno6Ojn5+fm5tfW1tbV1dTT09PS0tLR0dHQ0NDPz/f39/b29vX19fT09PPz8/Ly8vHx8e/v7+7u7u3t7ezs7Ovr6+rq6unp6ejo6Ofn5+bm5uXl5eTk5OPj4+Li4uHh4eDg4N/f397e3t3d3dzc3Nvb29ra2tnZ2djY2NfX19XV1dPT09LS0tHR0dDQ0M/Pz8rKysXFxf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAFMALAAAAAABAGQAAAdegCsrLC0tLi+ILi6FCSwsCS0KkhQVDA0OMjM0NTYfICEiIzw9P0AYGUQaG0ZHSEoDTU9Qs08pTk1MSyRJR0VDQT8+PTw7Ojg3NTMyMTAvi4WOhC0vMTI1OT9GTlFSgQA7)}.tablesorter-green th,.tablesorter-green thead td{font-weight:700;border-right:#cdcdcd 1px solid;border-collapse:collapse;padding:6px}.tablesorter-green .header,.tablesorter-green .tablesorter-header-inner{background-position:5px center;background-repeat:no-repeat;background-image:url(data:image/gif;base64,R0lGODlhEAAQAOYAAA5NDBBYDlWWUzRUM5DVjp7inJ/fnQ1ECiCsGhyYFxqKFRFdDhBXDQxCCiO8HSK2HCCqGh2aGByUFxuPFhqNFhmHFRZ2EhVvERRpEBBVDSS8HiGyHB+mGh6fGRuTFxiAFBd5Eww/Cgs5CRp7Fiu+JRx8GCy/JjHAKyynKCuhJzXCMDbCMDnDMyNuHz3EODy9N0LFPSl7JkvIRjycOFDKS1LKTVPLT1XLUFTCT17OWTBkLmbQYnDTbHXVcXnWdoXago/djGmUZ112XCJEIEdjRf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAEUALAAAAAAQABAAAAdlgEWCg4SFhoIvh4cVLECKhCMeJjwFj0UlEwgaMD4Gii0WFAkRHQ47BIY6IQAZDAwBCyAPOJa1toRBGBAwNTY3OT0/AoZCDQoOKi4yNDOKRCIfGycrKZYDBxIkKLZDFxy3RTHgloEAOw==);border-collapse:collapse;white-space:normal;cursor:pointer}.tablesorter-green thead .headerSortUp .tablesorter-header-inner,.tablesorter-green thead .tablesorter-headerAsc .tablesorter-header-inner,.tablesorter-green thead .tablesorter-headerSortUp .tablesorter-header-inner{background-image:url(data:image/gif;base64,R0lGODlhEAAQANUAAA5NDBBYDpDVjp7inJ/fnSCsGhyYFxFdDhBXDSO8HSK2HB2aGBuPFhqNFhmHFRZ2EhBVDSS8Hh6fGRuTFxd5Eww/Chp7Fhx8GCy/JjnDMyNuHzy9N0LFPVTCTzBkLmbQYnDTbHnWdo/djP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACMALAAAAAAQABAAAAY4wJFwSCwaj8ikcslMbpojR0bEtEwwoIHywihEOCECUvNoGBaSxEdg9FQAEAQicKAoOtC8fs8fBgEAOw==)}.tablesorter-green thead .headerSortDown .tablesorter-header-inner,.tablesorter-green thead .tablesorter-headerDesc .tablesorter-header-inner,.tablesorter-green thead .tablesorter-headerSortDown .tablesorter-header-inner{background-image:url(data:image/gif;base64,R0lGODlhEAAQANUAAFWWUzRUMw1EChqKFQxCCiO8HSCqGhyUFxVvERRpECGyHB+mGhiAFAs5CSu+JTHAKyynKCuhJzXCMDbCMD3EOELFPSl7JkvIRjycOFDKS1LKTVPLT1XLUF7OWXXVcYXagmmUZ112XCJEIEdjRf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACQALAAAAAAQABAAAAY4QJJwSCwaj8ikcskkghKGimbD6Xg+AGOIMChIKJcMBjlqMBSPSUQZEBwcEKYIsWiSLPa8fs9HBgEAOw==)}.tablesorter-green td.tablesorter-header .tablesorter-header-inner,.tablesorter-green th.tablesorter-header .tablesorter-header-inner{padding-left:23px}.tablesorter-green thead .tablesorter-header.sorter-false .tablesorter-header-inner{background-image:none;cursor:default;padding-left:6px}.tablesorter-green tbody td,.tablesorter-green tfoot th{padding:6px;vertical-align:top}.tablesorter-green td{color:#3d3d3d;padding:6px}.tablesorter-green tbody>tr.even.hover>td,.tablesorter-green tbody>tr.even:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-green tbody>tr.even:hover+tr.tablesorter-childRow>td,.tablesorter-green tbody>tr.even:hover>td,.tablesorter-green tbody>tr.hover>td,.tablesorter-green tbody>tr:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-green tbody>tr:hover+tr.tablesorter-childRow>td,.tablesorter-green tbody>tr:hover>td{background-color:#d9d9d9}.tablesorter-green tbody>tr.odd.hover>td,.tablesorter-green tbody>tr.odd:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-green tbody>tr.odd:hover+tr.tablesorter-childRow>td,.tablesorter-green tbody>tr.odd:hover>td{background-color:#bfbfbf}.tablesorter-green .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-green tr.odd>td{background-color:#ebfaeb}.tablesorter-green tr.even>td{background-color:#fff}.tablesorter-green td.primary,.tablesorter-green tr.odd td.primary{background-color:#99e6a6}.tablesorter-green tr.even td.primary{background-color:#c2f0c9}.tablesorter-green td.secondary,.tablesorter-green tr.odd td.secondary{background-color:#c2f0c9}.tablesorter-green tr.even td.secondary{background-color:#d6f5db}.tablesorter-green td.tertiary,.tablesorter-green tr.odd td.tertiary{background-color:#d6f5db}.tablesorter-green tr.even td.tertiary{background-color:#ebfaed}caption{background-color:#fff}.tablesorter-green .tablesorter-filter-row{background-color:#eee}.tablesorter-green .tablesorter-filter-row td{background-color:#eee;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-green .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-green .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-green .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;/* don't use visibility: hidden because it disables tabbing */opacity:0}.tablesorter-green input.tablesorter-filter,.tablesorter-green select.tablesorter-filter{width:98%;height:auto;margin:0;padding:4px;background-color:#fff;border:1px solid #bbb;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file +.tablesorter-green{width:100%;text-align:left;border-spacing:0;border:#cdcdcd 1px solid;border-width:1px 0 0 1px}.tablesorter-green td,.tablesorter-green th{font:12px/18px Arial,Sans-serif;border:#cdcdcd 1px solid;border-width:0 1px 1px 0}.tablesorter-green tfoot tr,.tablesorter-green thead tr .tablesorter-header{background-position:center center;background-repeat:repeat-x;background-image:url(data:image/gif;base64,R0lGODlhAQBkAOYAAN/e39XU1fX19tTU1eXm5uTl5ePk5OLj4+Hi4vX29fT19PP08/Lz8vHy8fDx8O/w7+7v7uzt7Orr6ufo5/T08/Pz8ufn5uLi4eDg39/f3t3d3Nzc29HR0NDQz8/Pzuvq6urp6eno6Ojn5+fm5tfW1tbV1dTT09PS0tLR0dHQ0NDPz/f39/b29vX19fT09PPz8/Ly8vHx8e/v7+7u7u3t7ezs7Ovr6+rq6unp6ejo6Ofn5+bm5uXl5eTk5OPj4+Li4uHh4eDg4N/f397e3t3d3dzc3Nvb29ra2tnZ2djY2NfX19XV1dPT09LS0tHR0dDQ0M/Pz8rKysXFxf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAFMALAAAAAABAGQAAAdegCsrLC0tLi+ILi6FCSwsCS0KkhQVDA0OMjM0NTYfICEiIzw9P0AYGUQaG0ZHSEoDTU9Qs08pTk1MSyRJR0VDQT8+PTw7Ojg3NTMyMTAvi4WOhC0vMTI1OT9GTlFSgQA7)}.tablesorter-green th,.tablesorter-green thead td{font-weight:700;border-right:#cdcdcd 1px solid;border-collapse:collapse;padding:6px}.tablesorter-green .header,.tablesorter-green .tablesorter-header-inner{background-position:5px center;background-repeat:no-repeat;background-image:url(data:image/gif;base64,R0lGODlhEAAQAOYAAA5NDBBYDlWWUzRUM5DVjp7inJ/fnQ1ECiCsGhyYFxqKFRFdDhBXDQxCCiO8HSK2HCCqGh2aGByUFxuPFhqNFhmHFRZ2EhVvERRpEBBVDSS8HiGyHB+mGh6fGRuTFxiAFBd5Eww/Cgs5CRp7Fiu+JRx8GCy/JjHAKyynKCuhJzXCMDbCMDnDMyNuHz3EODy9N0LFPSl7JkvIRjycOFDKS1LKTVPLT1XLUFTCT17OWTBkLmbQYnDTbHXVcXnWdoXago/djGmUZ112XCJEIEdjRf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAEUALAAAAAAQABAAAAdlgEWCg4SFhoIvh4cVLECKhCMeJjwFj0UlEwgaMD4Gii0WFAkRHQ47BIY6IQAZDAwBCyAPOJa1toRBGBAwNTY3OT0/AoZCDQoOKi4yNDOKRCIfGycrKZYDBxIkKLZDFxy3RTHgloEAOw==);border-collapse:collapse;white-space:normal;cursor:pointer}.tablesorter-green thead .headerSortUp .tablesorter-header-inner,.tablesorter-green thead .tablesorter-headerAsc .tablesorter-header-inner,.tablesorter-green thead .tablesorter-headerSortUp .tablesorter-header-inner{background-image:url(data:image/gif;base64,R0lGODlhEAAQANUAAA5NDBBYDpDVjp7inJ/fnSCsGhyYFxFdDhBXDSO8HSK2HB2aGBuPFhqNFhmHFRZ2EhBVDSS8Hh6fGRuTFxd5Eww/Chp7Fhx8GCy/JjnDMyNuHzy9N0LFPVTCTzBkLmbQYnDTbHnWdo/djP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACMALAAAAAAQABAAAAY4wJFwSCwaj8ikcslMbpojR0bEtEwwoIHywihEOCECUvNoGBaSxEdg9FQAEAQicKAoOtC8fs8fBgEAOw==)}.tablesorter-green thead .headerSortDown .tablesorter-header-inner,.tablesorter-green thead .tablesorter-headerDesc .tablesorter-header-inner,.tablesorter-green thead .tablesorter-headerSortDown .tablesorter-header-inner{background-image:url(data:image/gif;base64,R0lGODlhEAAQANUAAFWWUzRUMw1EChqKFQxCCiO8HSCqGhyUFxVvERRpECGyHB+mGhiAFAs5CSu+JTHAKyynKCuhJzXCMDbCMD3EOELFPSl7JkvIRjycOFDKS1LKTVPLT1XLUF7OWXXVcYXagmmUZ112XCJEIEdjRf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACQALAAAAAAQABAAAAY4QJJwSCwaj8ikcskkghKGimbD6Xg+AGOIMChIKJcMBjlqMBSPSUQZEBwcEKYIsWiSLPa8fs9HBgEAOw==)}.tablesorter-green td.tablesorter-header .tablesorter-header-inner,.tablesorter-green th.tablesorter-header .tablesorter-header-inner{padding-left:23px}.tablesorter-green thead .tablesorter-header.sorter-false .tablesorter-header-inner{background-image:none;cursor:default;padding-left:6px}.tablesorter-green tbody td,.tablesorter-green tfoot th{padding:6px;vertical-align:top}.tablesorter-green td{color:#3d3d3d;padding:6px}.tablesorter-green tbody>tr.even.hover>td,.tablesorter-green tbody>tr.even:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-green tbody>tr.even:hover+tr.tablesorter-childRow>td,.tablesorter-green tbody>tr.even:hover>td,.tablesorter-green tbody>tr.hover>td,.tablesorter-green tbody>tr:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-green tbody>tr:hover+tr.tablesorter-childRow>td,.tablesorter-green tbody>tr:hover>td{background-color:#d9d9d9}.tablesorter-green tbody>tr.odd.hover>td,.tablesorter-green tbody>tr.odd:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-green tbody>tr.odd:hover+tr.tablesorter-childRow>td,.tablesorter-green tbody>tr.odd:hover>td{background-color:#bfbfbf}.tablesorter-green .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-green tr.odd>td{background-color:#ebfaeb}.tablesorter-green tr.even>td{background-color:#fff}.tablesorter-green td.primary,.tablesorter-green tr.odd td.primary{background-color:#99e6a6}.tablesorter-green tr.even td.primary{background-color:#c2f0c9}.tablesorter-green td.secondary,.tablesorter-green tr.odd td.secondary{background-color:#c2f0c9}.tablesorter-green tr.even td.secondary{background-color:#d6f5db}.tablesorter-green td.tertiary,.tablesorter-green tr.odd td.tertiary{background-color:#d6f5db}.tablesorter-green tr.even td.tertiary{background-color:#ebfaed}caption{background-color:#fff}.tablesorter-green .tablesorter-filter-row{background-color:#eee}.tablesorter-green .tablesorter-filter-row td{background-color:#eee;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-green .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-green .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-green .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;opacity:0}.tablesorter-green input.tablesorter-filter,.tablesorter-green select.tablesorter-filter{width:98%;height:auto;margin:0;padding:4px;background-color:#fff;border:1px solid #bbb;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file diff --git a/dist/css/theme.grey.min.css b/dist/css/theme.grey.min.css index 244296c89..ec3e75aff 100644 --- a/dist/css/theme.grey.min.css +++ b/dist/css/theme.grey.min.css @@ -1 +1 @@ -.tablesorter-grey{width:100%;margin:10px 0 15px;text-align:left;border-spacing:0;border-left:#555 1px solid}.tablesorter-grey th,.tablesorter-grey thead td{font:bold 12px/18px Arial,Sans-serif;color:#c8c8c8;background-color:#3c3c3c;background-image:-moz-linear-gradient(top,#555,#3c3c3c);background-image:-ms-linear-gradient(top,#555,#3c3c3c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#555),to(#3c3c3c));background-image:-webkit-linear-gradient(top,#555,#3c3c3c);background-image:-o-linear-gradient(top,#555,#3c3c3c);background-image:linear-gradient(to bottom,#555,#3c3c3c);background-repeat:repeat-x;border-right:#555 1px solid;text-shadow:0 1px 0 rgba(128,128,128,.7);-webkit-box-shadow:inset 0 1px 0 #222;-moz-box-shadow:inset 0 1px 0 #222;box-shadow:inset 0 1px 0 #222;padding:4px}.tablesorter-grey .tablesorter-header-inner{position:relative;padding:4px 15px 4px 4px}.tablesorter-grey .header,.tablesorter-grey .tablesorter-header{cursor:pointer}.tablesorter-grey .header i,.tablesorter-grey .tablesorter-header i.tablesorter-icon{width:18px;height:10px;position:absolute;right:2px;top:50%;margin-top:-10px;background-image:url(data:image/gif;base64,R0lGODlhFQAJAIAAAP///////yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);background-repeat:no-repeat;background-position:center right;padding:4px;white-space:normal}.tablesorter-grey th.headerSortDown,.tablesorter-grey th.headerSortUp,.tablesorter-grey th.tablesorter-headerSortDown,.tablesorter-grey th.tablesorter-headerSortUp{color:#ddd;background-color:#135185;background-image:-moz-linear-gradient(top,#195c93,#0e4776);background-image:-ms-linear-gradient(top,#195c93,#0e4776);background-image:-webkit-gradient(linear,0 0,0 100%,from(#195c93),to(#0e4776));background-image:-webkit-linear-gradient(top,#195c93,#0e4776);background-image:-o-linear-gradient(top,#195c93,#0e4776);background-image:linear-gradient(to bottom,#195c93,#0e4776)}.tablesorter-grey .headerSortUp i.tablesorter-icon,.tablesorter-grey .tablesorter-headerAsc i.tablesorter-icon,.tablesorter-grey .tablesorter-headerSortUp i.tablesorter-icon{background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAAP///////yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7)}.tablesorter-grey .headerSortDown i.tablesorter-icon,.tablesorter-grey .tablesorter-headerDesc i.tablesorter-icon,.tablesorter-grey .tablesorter-headerSortDown i.tablesorter-icon{background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAAP///////yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7)}.tablesorter-grey thead .sorter-false{cursor:default}.tablesorter-grey thead .sorter-false i.tablesorter-icon{display:none}.tablesorter-grey tbody td,.tablesorter-grey tfoot td,.tablesorter-grey tfoot th{padding:4px;vertical-align:top;border-right:#555 1px solid}.tablesorter-grey tfoot td,.tablesorter-grey tfoot th{padding:8px}.tablesorter-grey td{color:#eee;background-color:#6d6d6d;padding:4px;vertical-align:top}.tablesorter-grey tbody>tr.even.hover>td,.tablesorter-grey tbody>tr.even:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-grey tbody>tr.even:hover+tr.tablesorter-childRow>td,.tablesorter-grey tbody>tr.even:hover>td,.tablesorter-grey tbody>tr.hover>td,.tablesorter-grey tbody>tr:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-grey tbody>tr:hover+tr.tablesorter-childRow>td,.tablesorter-grey tbody>tr:hover>td{background-color:#134b78}.tablesorter-grey tbody>tr.odd.hover>td,.tablesorter-grey tbody>tr.odd:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-grey tbody>tr.odd:hover+tr.tablesorter-childRow>td,.tablesorter-grey tbody>tr.odd:hover>td{background-color:#134b78}.tablesorter-grey .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-grey tbody tr.odd>td{background-color:#5e5e5e}.tablesorter-grey tbody tr.even>td{background-color:#6d6d6d}.tablesorter-grey td.primary,.tablesorter-grey tr.odd td.primary{color:#ddd;background-color:#165388}.tablesorter-grey tr.even td.primary{color:#ddd;background-color:#195c93}.tablesorter-grey td.secondary,.tablesorter-grey tr.odd td.secondary{color:#ddd;background-color:#185c9a}.tablesorter-grey tr.even td.secondary{color:#ddd;background-color:#1d67a5}.tablesorter-grey td.tertiary,.tablesorter-grey tr.odd td.tertiary{color:#ddd;background-color:#1b67ad}.tablesorter-grey tr.even td.tertiary{color:#ddd;background-color:#2073b7}caption{background-color:#fff}.tablesorter-grey .tablesorter-filter-row{background-color:#3c3c3c}.tablesorter-grey .tablesorter-filter-row td{background-color:#3c3c3c;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-grey .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-grey .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-grey .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;/* don't use visibility: hidden because it disables tabbing */opacity:0}.tablesorter-grey input.tablesorter-filter,.tablesorter-grey select.tablesorter-filter{width:98%;height:auto;margin:0;padding:4px;background-color:#6d6d6d;border:1px solid #555;color:#ddd;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file +.tablesorter-grey{width:100%;margin:10px 0 15px;text-align:left;border-spacing:0;border-left:#555 1px solid}.tablesorter-grey th,.tablesorter-grey thead td{font:bold 12px/18px Arial,Sans-serif;color:#c8c8c8;background-color:#3c3c3c;background-image:-moz-linear-gradient(top,#555,#3c3c3c);background-image:-ms-linear-gradient(top,#555,#3c3c3c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#555),to(#3c3c3c));background-image:-webkit-linear-gradient(top,#555,#3c3c3c);background-image:-o-linear-gradient(top,#555,#3c3c3c);background-image:linear-gradient(to bottom,#555,#3c3c3c);background-repeat:repeat-x;border-right:#555 1px solid;text-shadow:0 1px 0 rgba(128,128,128,.7);-webkit-box-shadow:inset 0 1px 0 #222;-moz-box-shadow:inset 0 1px 0 #222;box-shadow:inset 0 1px 0 #222;padding:4px}.tablesorter-grey .tablesorter-header-inner{position:relative;padding:4px 15px 4px 4px}.tablesorter-grey .header,.tablesorter-grey .tablesorter-header{cursor:pointer}.tablesorter-grey .header i,.tablesorter-grey .tablesorter-header i.tablesorter-icon{width:18px;height:10px;position:absolute;right:2px;top:50%;margin-top:-10px;background-image:url(data:image/gif;base64,R0lGODlhFQAJAIAAAP///////yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);background-repeat:no-repeat;background-position:center right;padding:4px;white-space:normal}.tablesorter-grey th.headerSortDown,.tablesorter-grey th.headerSortUp,.tablesorter-grey th.tablesorter-headerSortDown,.tablesorter-grey th.tablesorter-headerSortUp{color:#ddd;background-color:#135185;background-image:-moz-linear-gradient(top,#195c93,#0e4776);background-image:-ms-linear-gradient(top,#195c93,#0e4776);background-image:-webkit-gradient(linear,0 0,0 100%,from(#195c93),to(#0e4776));background-image:-webkit-linear-gradient(top,#195c93,#0e4776);background-image:-o-linear-gradient(top,#195c93,#0e4776);background-image:linear-gradient(to bottom,#195c93,#0e4776)}.tablesorter-grey .headerSortUp i.tablesorter-icon,.tablesorter-grey .tablesorter-headerAsc i.tablesorter-icon,.tablesorter-grey .tablesorter-headerSortUp i.tablesorter-icon{background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAAP///////yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7)}.tablesorter-grey .headerSortDown i.tablesorter-icon,.tablesorter-grey .tablesorter-headerDesc i.tablesorter-icon,.tablesorter-grey .tablesorter-headerSortDown i.tablesorter-icon{background-image:url(data:image/gif;base64,R0lGODlhFQAEAIAAAP///////yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7)}.tablesorter-grey thead .sorter-false{cursor:default}.tablesorter-grey thead .sorter-false i.tablesorter-icon{display:none}.tablesorter-grey tbody td,.tablesorter-grey tfoot td,.tablesorter-grey tfoot th{padding:4px;vertical-align:top;border-right:#555 1px solid}.tablesorter-grey tfoot td,.tablesorter-grey tfoot th{padding:8px}.tablesorter-grey td{color:#eee;background-color:#6d6d6d;padding:4px;vertical-align:top}.tablesorter-grey tbody>tr.even.hover>td,.tablesorter-grey tbody>tr.even:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-grey tbody>tr.even:hover+tr.tablesorter-childRow>td,.tablesorter-grey tbody>tr.even:hover>td,.tablesorter-grey tbody>tr.hover>td,.tablesorter-grey tbody>tr:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-grey tbody>tr:hover+tr.tablesorter-childRow>td,.tablesorter-grey tbody>tr:hover>td{background-color:#134b78}.tablesorter-grey tbody>tr.odd.hover>td,.tablesorter-grey tbody>tr.odd:hover+tr.tablesorter-childRow+tr.tablesorter-childRow>td,.tablesorter-grey tbody>tr.odd:hover+tr.tablesorter-childRow>td,.tablesorter-grey tbody>tr.odd:hover>td{background-color:#134b78}.tablesorter-grey .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-grey tbody tr.odd>td{background-color:#5e5e5e}.tablesorter-grey tbody tr.even>td{background-color:#6d6d6d}.tablesorter-grey td.primary,.tablesorter-grey tr.odd td.primary{color:#ddd;background-color:#165388}.tablesorter-grey tr.even td.primary{color:#ddd;background-color:#195c93}.tablesorter-grey td.secondary,.tablesorter-grey tr.odd td.secondary{color:#ddd;background-color:#185c9a}.tablesorter-grey tr.even td.secondary{color:#ddd;background-color:#1d67a5}.tablesorter-grey td.tertiary,.tablesorter-grey tr.odd td.tertiary{color:#ddd;background-color:#1b67ad}.tablesorter-grey tr.even td.tertiary{color:#ddd;background-color:#2073b7}caption{background-color:#fff}.tablesorter-grey .tablesorter-filter-row{background-color:#3c3c3c}.tablesorter-grey .tablesorter-filter-row td{background-color:#3c3c3c;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-grey .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-grey .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-grey .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;opacity:0}.tablesorter-grey input.tablesorter-filter,.tablesorter-grey select.tablesorter-filter{width:98%;height:auto;margin:0;padding:4px;background-color:#6d6d6d;border:1px solid #555;color:#ddd;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file diff --git a/dist/css/theme.ice.min.css b/dist/css/theme.ice.min.css index ae2fd2c15..d1bddcd90 100644 --- a/dist/css/theme.ice.min.css +++ b/dist/css/theme.ice.min.css @@ -1 +1 @@ -.tablesorter-ice{width:100%;background-color:#fff;margin:10px 0 15px;text-align:left;border-spacing:0;border:#ccc 1px solid;border-width:1px 0 0 1px}.tablesorter-ice td,.tablesorter-ice th{border:#ccc 1px solid;border-width:0 1px 1px 0}.tablesorter-ice th,.tablesorter-ice thead td{font:12px/18px Arial,Sans-serif;color:#555;background-color:#f6f8f9;border-collapse:collapse;padding:4px;text-shadow:0 1px 0 rgba(255,255,255,.7)}.tablesorter-ice tbody td,.tablesorter-ice tfoot td,.tablesorter-ice tfoot th{padding:4px;vertical-align:top}.tablesorter-ice .header,.tablesorter-ice .tablesorter-header{background-color:#f6f8f9;background-position:center right;background-repeat:no-repeat;background-image:url(data:image/gif;base64,R0lGODlhDAAMAMQAAAJEjAJCiwJBigJAiANFjgNGjgNEjQRIkQRHkANIkAVMlAVQmAZWnQZUnAdYoAhdpAhZoAlhqQlepQliqQppsApmrQxutgtutQtutAxwtwxwtg1yug1zugxtsw1yuP8A/yH5BAEAAB8ALAAAAAAMAAwAAAUx4Cd+3GiOW4ado2d9VMVm1xg9ptadTsP+QNZEcjoQTBDGCAFgLRSfQgCYMAiCn8EvBAA7);padding:4px 20px 4px 4px;white-space:normal;cursor:pointer}.tablesorter-ice .headerSortUp,.tablesorter-ice .tablesorter-headerAsc,.tablesorter-ice .tablesorter-headerSortUp{color:#333;background-color:#ebedee;background-position:center right;background-repeat:no-repeat;background-image:url(data:image/gif;base64,R0lGODlhDAAMANUAAAJCiwNHkANFjgNEjQRIkQNJkQRMlARKkwRKkgVPlwZSmgdaogdYnwhfpghcowlhqgliqglgqAlgpwljqwporwpmrQplrAtsswtqsgtrsgtqsQxttAtvtQtttAxyuQxwtwxxtwxvtg10uw1zuQ1xuP8A/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACUALAAAAAAMAAwAAAY6wJKwJBoahyNQ6Dj0fDoZCpPEuWgqk4jxs8FQLI+Gg8Esm5kQydFQMC7IwkOAqUiUCAIzIjA4lwBlQQA7)}.tablesorter-ice .headerSortDown,.tablesorter-ice .tablesorter-headerDesc,.tablesorter-ice .tablesorter-headerSortDown{color:#333;background-color:#ebedee;background-position:center right;background-repeat:no-repeat;background-image:url(data:image/gif;base64,R0lGODlhDAAMANUAAAE/iAJBigNFjgNEjQNFjQNDiwRHkQRHjwNHjwROlgRMlQRMlARJkgRKkgZQmAVPlgZWnQZSmgZRmAdXoAdXnwdUnAdbogdZoQhbowlhqAlepglkrAliqQtstAtqsQxyugxyuQxwuAxxuAxxtwxwtgxvtQ10vA12vA10u/8A/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACkALAAAAAAMAAwAAAY6wJQwdRoah6bP6DhEiVIdDxNEGm4yxlDpiJkwv2AmR2OhVCSJBsJ4gUQeCwOB6VAwBAXwYRAIpwBfQQA7)}.tablesorter-ice thead .sorter-false{background-image:none;cursor:default;padding:4px}.tablesorter-ice tfoot .tablesorter-headerAsc,.tablesorter-ice tfoot .tablesorter-headerDesc,.tablesorter-ice tfoot .tablesorter-headerSortDown,.tablesorter-ice tfoot .tablesorter-headerSortUp{background-color:#ebedee}.tablesorter-ice td{color:#333}.tablesorter-ice tbody>tr.even:hover>td,.tablesorter-ice tbody>tr.hover>td,.tablesorter-ice tbody>tr.odd:hover>td,.tablesorter-ice tbody>tr:hover>td{background-color:#ebf2fa}.tablesorter-ice .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-ice tr.odd>td{background-color:#dfdfdf}.tablesorter-ice tr.even>td{background-color:#efefef}.tablesorter-ice td.primary,.tablesorter-ice tr.odd td.primary{background-color:#9ae5e5}.tablesorter-ice tr.even td.primary{background-color:#c2f0f0}.tablesorter-ice td.secondary,.tablesorter-ice tr.odd td.secondary{background-color:#c2f0f0}.tablesorter-ice tr.even td.secondary{background-color:#d5f5f5}.tablesorter-ice td.tertiary,.tablesorter-ice tr.odd td.tertiary{background-color:#d5f5f5}.tablesorter-ice tr.even td.tertiary{background-color:#ebfafa}.tablesorter-ice.containsStickyHeaders thead tr:nth-child(1) td,.tablesorter-ice.containsStickyHeaders thead tr:nth-child(1) th{border-top:#ccc 1px solid}caption{background-color:#fff}.tablesorter-ice .tablesorter-filter-row{background-color:#eee}.tablesorter-ice .tablesorter-filter-row td{background-color:#eee;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-ice .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-ice .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-ice .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;/* don't use visibility: hidden because it disables tabbing */opacity:0}.tablesorter-ice input.tablesorter-filter,.tablesorter-ice select.tablesorter-filter{width:98%;height:auto;margin:0;padding:4px;background-color:#fff;border:1px solid #bbb;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file +.tablesorter-ice{width:100%;background-color:#fff;margin:10px 0 15px;text-align:left;border-spacing:0;border:#ccc 1px solid;border-width:1px 0 0 1px}.tablesorter-ice td,.tablesorter-ice th{border:#ccc 1px solid;border-width:0 1px 1px 0}.tablesorter-ice th,.tablesorter-ice thead td{font:12px/18px Arial,Sans-serif;color:#555;background-color:#f6f8f9;border-collapse:collapse;padding:4px;text-shadow:0 1px 0 rgba(255,255,255,.7)}.tablesorter-ice tbody td,.tablesorter-ice tfoot td,.tablesorter-ice tfoot th{padding:4px;vertical-align:top}.tablesorter-ice .header,.tablesorter-ice .tablesorter-header{background-color:#f6f8f9;background-position:center right;background-repeat:no-repeat;background-image:url(data:image/gif;base64,R0lGODlhDAAMAMQAAAJEjAJCiwJBigJAiANFjgNGjgNEjQRIkQRHkANIkAVMlAVQmAZWnQZUnAdYoAhdpAhZoAlhqQlepQliqQppsApmrQxutgtutQtutAxwtwxwtg1yug1zugxtsw1yuP8A/yH5BAEAAB8ALAAAAAAMAAwAAAUx4Cd+3GiOW4ado2d9VMVm1xg9ptadTsP+QNZEcjoQTBDGCAFgLRSfQgCYMAiCn8EvBAA7);padding:4px 20px 4px 4px;white-space:normal;cursor:pointer}.tablesorter-ice .headerSortUp,.tablesorter-ice .tablesorter-headerAsc,.tablesorter-ice .tablesorter-headerSortUp{color:#333;background-color:#ebedee;background-position:center right;background-repeat:no-repeat;background-image:url(data:image/gif;base64,R0lGODlhDAAMANUAAAJCiwNHkANFjgNEjQRIkQNJkQRMlARKkwRKkgVPlwZSmgdaogdYnwhfpghcowlhqgliqglgqAlgpwljqwporwpmrQplrAtsswtqsgtrsgtqsQxttAtvtQtttAxyuQxwtwxxtwxvtg10uw1zuQ1xuP8A/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACUALAAAAAAMAAwAAAY6wJKwJBoahyNQ6Dj0fDoZCpPEuWgqk4jxs8FQLI+Gg8Esm5kQydFQMC7IwkOAqUiUCAIzIjA4lwBlQQA7)}.tablesorter-ice .headerSortDown,.tablesorter-ice .tablesorter-headerDesc,.tablesorter-ice .tablesorter-headerSortDown{color:#333;background-color:#ebedee;background-position:center right;background-repeat:no-repeat;background-image:url(data:image/gif;base64,R0lGODlhDAAMANUAAAE/iAJBigNFjgNEjQNFjQNDiwRHkQRHjwNHjwROlgRMlQRMlARJkgRKkgZQmAVPlgZWnQZSmgZRmAdXoAdXnwdUnAdbogdZoQhbowlhqAlepglkrAliqQtstAtqsQxyugxyuQxwuAxxuAxxtwxwtgxvtQ10vA12vA10u/8A/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACkALAAAAAAMAAwAAAY6wJQwdRoah6bP6DhEiVIdDxNEGm4yxlDpiJkwv2AmR2OhVCSJBsJ4gUQeCwOB6VAwBAXwYRAIpwBfQQA7)}.tablesorter-ice thead .sorter-false{background-image:none;cursor:default;padding:4px}.tablesorter-ice tfoot .tablesorter-headerAsc,.tablesorter-ice tfoot .tablesorter-headerDesc,.tablesorter-ice tfoot .tablesorter-headerSortDown,.tablesorter-ice tfoot .tablesorter-headerSortUp{background-color:#ebedee}.tablesorter-ice td{color:#333}.tablesorter-ice tbody>tr.even:hover>td,.tablesorter-ice tbody>tr.hover>td,.tablesorter-ice tbody>tr.odd:hover>td,.tablesorter-ice tbody>tr:hover>td{background-color:#ebf2fa}.tablesorter-ice .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-ice tr.odd>td{background-color:#dfdfdf}.tablesorter-ice tr.even>td{background-color:#efefef}.tablesorter-ice td.primary,.tablesorter-ice tr.odd td.primary{background-color:#9ae5e5}.tablesorter-ice tr.even td.primary{background-color:#c2f0f0}.tablesorter-ice td.secondary,.tablesorter-ice tr.odd td.secondary{background-color:#c2f0f0}.tablesorter-ice tr.even td.secondary{background-color:#d5f5f5}.tablesorter-ice td.tertiary,.tablesorter-ice tr.odd td.tertiary{background-color:#d5f5f5}.tablesorter-ice tr.even td.tertiary{background-color:#ebfafa}.tablesorter-ice.containsStickyHeaders thead tr:nth-child(1) td,.tablesorter-ice.containsStickyHeaders thead tr:nth-child(1) th{border-top:#ccc 1px solid}caption{background-color:#fff}.tablesorter-ice .tablesorter-filter-row{background-color:#eee}.tablesorter-ice .tablesorter-filter-row td{background-color:#eee;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-ice .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-ice .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-ice .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;opacity:0}.tablesorter-ice input.tablesorter-filter,.tablesorter-ice select.tablesorter-filter{width:98%;height:auto;margin:0;padding:4px;background-color:#fff;border:1px solid #bbb;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file diff --git a/dist/css/theme.jui.min.css b/dist/css/theme.jui.min.css index 118665f9e..9ed0a4bf5 100644 --- a/dist/css/theme.jui.min.css +++ b/dist/css/theme.jui.min.css @@ -1 +1 @@ -.tablesorter-jui{width:100%;border-collapse:separate;border-spacing:2px;margin:10px 0 15px;padding:5px;font-size:.8em}.tablesorter-jui tfoot td,.tablesorter-jui tfoot th,.tablesorter-jui thead td,.tablesorter-jui thead th{position:relative;background-repeat:no-repeat;background-position:right center;font-weight:700!important;border-width:1px!important;text-align:left;padding:8px}.tablesorter-jui .header,.tablesorter-jui .tablesorter-header{cursor:pointer;white-space:normal}.tablesorter-jui .tablesorter-header-inner{padding-right:20px}.tablesorter-jui thead tr th .ui-icon{position:absolute;right:3px;top:50%;margin-top:-8px}.tablesorter-jui thead .sorter-false{cursor:default}.tablesorter-jui thead tr .sorter-false .ui-icon{display:none}.tablesorter-jui tfoot td,.tablesorter-jui tfoot th{font-weight:400!important;font-size:.9em;padding:2px}.tablesorter-jui td{padding:4px;vertical-align:top}.tablesorter-jui tbody>tr.hover>td,.tablesorter-jui tbody>tr:hover>td{opacity:.7}.tablesorter-jui .tablesorter-processing .tablesorter-header-inner{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-jui tr.ui-state-default{background-image:none;font-weight:400}.tablesorter-jui .tablesorter-processing{background-color:#ddd;background-color:rgba(255,255,255,.8)}.tablesorter-jui caption{border:0}.tablesorter-jui .tablesorter-filter-row{background-color:transparent}.tablesorter-jui .tablesorter-filter-row td{background-color:transparent;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-jui .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-jui .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-jui .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;/* don't use visibility: hidden because it disables tabbing */opacity:0}.tablesorter-jui input.tablesorter-filter,.tablesorter-jui select.tablesorter-filter{width:98%;height:auto;margin:0;padding:4px;background-color:#fff;border:1px solid #bbb;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file +.tablesorter-jui{width:100%;border-collapse:separate;border-spacing:2px;margin:10px 0 15px;padding:5px;font-size:.8em}.tablesorter-jui tfoot td,.tablesorter-jui tfoot th,.tablesorter-jui thead td,.tablesorter-jui thead th{position:relative;background-repeat:no-repeat;background-position:right center;font-weight:700!important;border-width:1px!important;text-align:left;padding:8px}.tablesorter-jui .header,.tablesorter-jui .tablesorter-header{cursor:pointer;white-space:normal}.tablesorter-jui .tablesorter-header-inner{padding-right:20px}.tablesorter-jui thead tr th .ui-icon{position:absolute;right:3px;top:50%;margin-top:-8px}.tablesorter-jui thead .sorter-false{cursor:default}.tablesorter-jui thead tr .sorter-false .ui-icon{display:none}.tablesorter-jui tfoot td,.tablesorter-jui tfoot th{font-weight:400!important;font-size:.9em;padding:2px}.tablesorter-jui td{padding:4px;vertical-align:top}.tablesorter-jui tbody>tr.hover>td,.tablesorter-jui tbody>tr:hover>td{opacity:.7}.tablesorter-jui .tablesorter-processing .tablesorter-header-inner{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-jui tr.ui-state-default{background-image:none;font-weight:400}.tablesorter-jui .tablesorter-processing{background-color:#ddd;background-color:rgba(255,255,255,.8)}.tablesorter-jui caption{border:0}.tablesorter-jui .tablesorter-filter-row{background-color:transparent}.tablesorter-jui .tablesorter-filter-row td{background-color:transparent;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-jui .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-jui .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-jui .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;opacity:0}.tablesorter-jui input.tablesorter-filter,.tablesorter-jui select.tablesorter-filter{width:98%;height:auto;margin:0;padding:4px;background-color:#fff;border:1px solid #bbb;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file diff --git a/dist/css/theme.materialize.min.css b/dist/css/theme.materialize.min.css index e6706e213..e7b481178 100644 --- a/dist/css/theme.materialize.min.css +++ b/dist/css/theme.materialize.min.css @@ -1 +1 @@ -.tablesorter-materialize{width:100%}.tablesorter-materialize tfoot td,.tablesorter-materialize tfoot th,.tablesorter-materialize thead td,.tablesorter-materialize thead th{font:14px/20px Arial,Sans-serif;font-weight:700;padding:4px;margin:0 0 18px;background-color:#eee}.tablesorter-materialize .tablesorter-header{cursor:pointer}.tablesorter-materialize .sorter-false{cursor:default}.tablesorter-materialize .tablesorter-header-inner{position:relative;padding:4px 18px 4px 4px}.tablesorter-materialize thead .tablesorter-header{background-repeat:no-repeat;background-position:center right;padding:4px 18px 4px 4px;white-space:normal;cursor:pointer}.tablesorter-materialize thead .tablesorter-headerUnSorted{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDI0IDE2Ij48cGF0aCBkPSJNMTUgOCAxIDggOCAwek0xNSA5IDEgOSA4IDE2eiIgZmlsbD0iIzIyMiIvPjwvc3ZnPg==)}.tablesorter-materialize thead .tablesorter-headerAsc{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDI0IDE2Ij48cGF0aCBkPSJNMTUgMTEgMSAxMSA4IDN6IiBmaWxsPSIjMjIyIi8+PC9zdmc+)}.tablesorter-materialize thead .tablesorter-headerDesc{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDI0IDE2Ij48cGF0aCBkPSJNMTUgNiAxIDYgOCAxM3oiIGZpbGw9IiMyMjIiLz48L3N2Zz4=)}.tablesorter-materialize-dark thead .tablesorter-headerUnSorted{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDI0IDE2Ij48cGF0aCBkPSJNMTUgOCAxIDggOCAwek0xNSA5IDEgOSA4IDE2eiIgZmlsbD0iI2ZmZiIvPjwvc3ZnPg==)}.tablesorter-materialize-dark thead .tablesorter-headerAsc{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDI0IDE2Ij48cGF0aCBkPSJNMTUgMTEgMSAxMSA4IDN6IiBmaWxsPSIjZmZmIi8+PC9zdmc+)}.tablesorter-materialize-dark thead .tablesorter-headerDesc{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDI0IDE2Ij48cGF0aCBkPSJNMTUgNiAxIDYgOCAxM3oiIGZpbGw9IiNmZmYiLz48L3N2Zz4=)}.tablesorter-materialize>tbody>tr.odd>td,.tablesorter-materialize>tbody>tr.tablesorter-hasChildRow.odd:hover~tr.tablesorter-hasChildRow.odd~.tablesorter-childRow.odd>td{background-color:#f9f9f9}.tablesorter-materialize>tbody>tr.even:hover>td,.tablesorter-materialize>tbody>tr.hover>td,.tablesorter-materialize>tbody>tr.odd:hover>td,.tablesorter-materialize>tbody>tr.tablesorter-hasChildRow.even:hover~.tablesorter-childRow.even>td,.tablesorter-materialize>tbody>tr.tablesorter-hasChildRow.odd:hover~.tablesorter-childRow.odd>td{background-color:#f5f5f5}.tablesorter-materialize>tbody>tr.even>td,.tablesorter-materialize>tbody>tr.tablesorter-hasChildRow.even:hover~tr.tablesorter-hasChildRow.even~.tablesorter-childRow.even>td{background-color:#fff}.tablesorter-materialize .tablesorter-processing{background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=);background-position:center center!important;background-repeat:no-repeat!important}.caption{background-color:#fff}.tablesorter-materialize .tablesorter-filter-row input.tablesorter-filter,.tablesorter-materialize .tablesorter-filter-row select.tablesorter-filter{width:98%;margin:0;padding:4px 6px;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter-materialize .tablesorter-filter-row .tablesorter-filter.disabled{background-color:#eee;color:#555;cursor:not-allowed;border:1px solid #ccc;border-radius:4px;box-shadow:0 1px 1px rgba(0,0,0,.075) inset;box-sizing:border-box;transition:height .1s ease}.tablesorter-materialize .tablesorter-filter-row{background-color:#efefef}.tablesorter-materialize .tablesorter-filter-row td{background-color:#efefef;line-height:normal;text-align:center;padding:4px 6px;vertical-align:middle;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-materialize .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0}.tablesorter-materialize .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;/* don't use visibility: hidden because it disables tabbing */opacity:0}.tablesorter .filtered{display:none}.tablesorter-materialize .tablesorter-pager select{padding:4px 6px;display:inline-block;width:auto}.tablesorter-materialize .tablesorter-pager .pagedisplay{border:0}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file +.tablesorter-materialize{width:100%}.tablesorter-materialize tfoot td,.tablesorter-materialize tfoot th,.tablesorter-materialize thead td,.tablesorter-materialize thead th{font:14px/20px Arial,Sans-serif;font-weight:700;padding:4px;margin:0 0 18px;background-color:#eee}.tablesorter-materialize .tablesorter-header{cursor:pointer}.tablesorter-materialize .sorter-false{cursor:default}.tablesorter-materialize .tablesorter-header-inner{position:relative;padding:4px 18px 4px 4px}.tablesorter-materialize thead .tablesorter-header{background-repeat:no-repeat;background-position:center right;padding:4px 18px 4px 4px;white-space:normal;cursor:pointer}.tablesorter-materialize thead .tablesorter-headerUnSorted{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDI0IDE2Ij48cGF0aCBkPSJNMTUgOCAxIDggOCAwek0xNSA5IDEgOSA4IDE2eiIgZmlsbD0iIzIyMiIvPjwvc3ZnPg==)}.tablesorter-materialize thead .tablesorter-headerAsc{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDI0IDE2Ij48cGF0aCBkPSJNMTUgMTEgMSAxMSA4IDN6IiBmaWxsPSIjMjIyIi8+PC9zdmc+)}.tablesorter-materialize thead .tablesorter-headerDesc{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDI0IDE2Ij48cGF0aCBkPSJNMTUgNiAxIDYgOCAxM3oiIGZpbGw9IiMyMjIiLz48L3N2Zz4=)}.tablesorter-materialize-dark thead .tablesorter-headerUnSorted{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDI0IDE2Ij48cGF0aCBkPSJNMTUgOCAxIDggOCAwek0xNSA5IDEgOSA4IDE2eiIgZmlsbD0iI2ZmZiIvPjwvc3ZnPg==)}.tablesorter-materialize-dark thead .tablesorter-headerAsc{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDI0IDE2Ij48cGF0aCBkPSJNMTUgMTEgMSAxMSA4IDN6IiBmaWxsPSIjZmZmIi8+PC9zdmc+)}.tablesorter-materialize-dark thead .tablesorter-headerDesc{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDI0IDE2Ij48cGF0aCBkPSJNMTUgNiAxIDYgOCAxM3oiIGZpbGw9IiNmZmYiLz48L3N2Zz4=)}.tablesorter-materialize>tbody>tr.odd>td,.tablesorter-materialize>tbody>tr.tablesorter-hasChildRow.odd:hover~tr.tablesorter-hasChildRow.odd~.tablesorter-childRow.odd>td{background-color:#f9f9f9}.tablesorter-materialize>tbody>tr.even:hover>td,.tablesorter-materialize>tbody>tr.hover>td,.tablesorter-materialize>tbody>tr.odd:hover>td,.tablesorter-materialize>tbody>tr.tablesorter-hasChildRow.even:hover~.tablesorter-childRow.even>td,.tablesorter-materialize>tbody>tr.tablesorter-hasChildRow.odd:hover~.tablesorter-childRow.odd>td{background-color:#f5f5f5}.tablesorter-materialize>tbody>tr.even>td,.tablesorter-materialize>tbody>tr.tablesorter-hasChildRow.even:hover~tr.tablesorter-hasChildRow.even~.tablesorter-childRow.even>td{background-color:#fff}.tablesorter-materialize .tablesorter-processing{background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=);background-position:center center!important;background-repeat:no-repeat!important}.caption{background-color:#fff}.tablesorter-materialize .tablesorter-filter-row input.tablesorter-filter,.tablesorter-materialize .tablesorter-filter-row select.tablesorter-filter{width:98%;margin:0;padding:4px 6px;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter-materialize .tablesorter-filter-row .tablesorter-filter.disabled{background-color:#eee;color:#555;cursor:not-allowed;border:1px solid #ccc;border-radius:4px;box-shadow:0 1px 1px rgba(0,0,0,.075) inset;box-sizing:border-box;transition:height .1s ease}.tablesorter-materialize .tablesorter-filter-row{background-color:#efefef}.tablesorter-materialize .tablesorter-filter-row td{background-color:#efefef;line-height:normal;text-align:center;padding:4px 6px;vertical-align:middle;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-materialize .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0}.tablesorter-materialize .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;opacity:0}.tablesorter .filtered{display:none}.tablesorter-materialize .tablesorter-pager select{padding:4px 6px;display:inline-block;width:auto}.tablesorter-materialize .tablesorter-pager .pagedisplay{border:0}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file diff --git a/dist/css/theme.metro-dark.min.css b/dist/css/theme.metro-dark.min.css index 9ae1813cf..f406edb00 100644 --- a/dist/css/theme.metro-dark.min.css +++ b/dist/css/theme.metro-dark.min.css @@ -1 +1 @@ -.tablesorter-metro-dark{width:100%;font:12px/18px 'Segoe UI Semilight','Open Sans',Verdana,Arial,Helvetica,sans-serif;color:#000;background-color:#333;border-spacing:0;margin:10px 0 15px;text-align:left}.tablesorter-metro-dark caption.dark-row,.tablesorter-metro-dark tr.dark-row td,.tablesorter-metro-dark tr.dark-row th{background-color:#222;color:#fff;padding:2px;text-align:left;font-size:14px}.tablesorter-metro-dark caption,.tablesorter-metro-dark tfoot td,.tablesorter-metro-dark tfoot th,.tablesorter-metro-dark th,.tablesorter-metro-dark thead td{font-weight:300;font-size:15px;color:#ddd;background-color:#333;padding:4px}.tablesorter-metro-dark .header,.tablesorter-metro-dark .tablesorter-header{background-image:url(data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAQBAMAAADQT4M0AAAAGFBMVEUAAADu7u7u7u7u7u7u7u7u7u7u7u7u7u5jNePWAAAACHRSTlMAMxIHKwEgMWD59H4AAABSSURBVAjXY2BgYFJgAAHzYhDJ6igSAKTYBAUTgJSioKAQAwNzoaCguAFDiCAQuDIkgigxBgiA8cJAVCpQt6AgSL+JoKAzA0gjUBsQqBcBCYhFAAE/CV4zeSzxAAAAAElFTkSuQmCC);background-position:right 5px center;background-repeat:no-repeat;cursor:pointer;white-space:normal}.tablesorter-metro-dark .tablesorter-header-inner{padding:0 18px 0 4px}.tablesorter-metro-dark thead .headerSortUp,.tablesorter-metro-dark thead .tablesorter-headerAsc,.tablesorter-metro-dark thead .tablesorter-headerSortUp{background-image:url(data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAQBAMAAADQT4M0AAAAIVBMVEUAAADu7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u5meJAOAAAACnRSTlMAMwsqXt+gIBUGxGoDMAAAAFlJREFUCNctzC0SQAAUReEzGNQ3AlHRiSRZFCVZYgeswRL8hLdK7834wj3tAlGP6y7fYHpKS6w6WwbVG0I1NZVnZPG8/DYxOYlnhUYkA06R1s9ESsxR4NIdPhkPFDFYuEnMAAAAAElFTkSuQmCC)}.tablesorter-metro-dark thead .headerSortDown,.tablesorter-metro-dark thead .tablesorter-headerDesc,.tablesorter-metro-dark thead .tablesorter-headerSortDown{background-image:url(data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAQBAMAAADQT4M0AAAALVBMVEUAAADu7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7i0NViAAAADnRSTlMAMiweCQITTvDctZZqaTlM310AAABcSURBVAjXY2BgYEtgAAFHERDJqigUAKSYBQUNgFSioKAYAwOLIBA4MASBKFUGQxAlzAAF+94BwWuGKBC1lIFl3rt3Lx0YGCzevWsGSjK9e6cAUlT3HKyW9wADAwDRrBiDy6bKzwAAAABJRU5ErkJggg==)}.tablesorter-metro-dark thead .sorter-false{background-image:none;cursor:default;padding:4px}.tablesorter-metro-dark td{background-color:#fff;padding:4px;vertical-align:top}.tablesorter-metro-dark tbody>tr.even:hover>td,.tablesorter-metro-dark tbody>tr.hover>td,.tablesorter-metro-dark tbody>tr.odd:hover>td,.tablesorter-metro-dark tbody>tr:hover>td{background-color:#bbb;color:#000}.tablesorter-metro-dark .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-metro-dark .tablesorter-pager button{background-color:#444;color:#eee;border:#555 1px solid;cursor:pointer}.tablesorter-metro-dark .tablesorter-pager button:hover{background-color:#555}.tablesorter-metro-dark tr.odd>td{background-color:#eee}.tablesorter-metro-dark tr.even>td{background-color:#fff}.tablesorter-metro-dark tr.odd td.primary{background-color:#bfbfbf}.tablesorter-metro-dark td.primary,.tablesorter-metro-dark tr.even td.primary{background-color:#d9d9d9}.tablesorter-metro-dark tr.odd td.secondary{background-color:#d9d9d9}.tablesorter-metro-dark td.secondary,.tablesorter-metro-dark tr.even td.secondary{background-color:#e6e6e6}.tablesorter-metro-dark tr.odd td.tertiary{background-color:#e6e6e6}.tablesorter-metro-dark td.tertiary,.tablesorter-metro-dark tr.even td.tertiary{background-color:#f2f2f2}.tablesorter-metro-dark .tablesorter-filter-row{background-color:#eee}.tablesorter-metro-dark .tablesorter-filter-row td{background-color:#eee;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-metro-dark .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-metro-dark .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-metro-dark .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;/* don't use visibility: hidden because it disables tabbing */opacity:0}.tablesorter-metro-dark input.tablesorter-filter,.tablesorter-metro-dark select.tablesorter-filter{width:95%;height:auto;margin:0;padding:4px;background-color:#fff;border:1px solid #bbb;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file +.tablesorter-metro-dark{width:100%;font:12px/18px 'Segoe UI Semilight','Open Sans',Verdana,Arial,Helvetica,sans-serif;color:#000;background-color:#333;border-spacing:0;margin:10px 0 15px;text-align:left}.tablesorter-metro-dark caption.dark-row,.tablesorter-metro-dark tr.dark-row td,.tablesorter-metro-dark tr.dark-row th{background-color:#222;color:#fff;padding:2px;text-align:left;font-size:14px}.tablesorter-metro-dark caption,.tablesorter-metro-dark tfoot td,.tablesorter-metro-dark tfoot th,.tablesorter-metro-dark th,.tablesorter-metro-dark thead td{font-weight:300;font-size:15px;color:#ddd;background-color:#333;padding:4px}.tablesorter-metro-dark .header,.tablesorter-metro-dark .tablesorter-header{background-image:url(data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAQBAMAAADQT4M0AAAAGFBMVEUAAADu7u7u7u7u7u7u7u7u7u7u7u7u7u5jNePWAAAACHRSTlMAMxIHKwEgMWD59H4AAABSSURBVAjXY2BgYFJgAAHzYhDJ6igSAKTYBAUTgJSioKAQAwNzoaCguAFDiCAQuDIkgigxBgiA8cJAVCpQt6AgSL+JoKAzA0gjUBsQqBcBCYhFAAE/CV4zeSzxAAAAAElFTkSuQmCC);background-position:right 5px center;background-repeat:no-repeat;cursor:pointer;white-space:normal}.tablesorter-metro-dark .tablesorter-header-inner{padding:0 18px 0 4px}.tablesorter-metro-dark thead .headerSortUp,.tablesorter-metro-dark thead .tablesorter-headerAsc,.tablesorter-metro-dark thead .tablesorter-headerSortUp{background-image:url(data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAQBAMAAADQT4M0AAAAIVBMVEUAAADu7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u5meJAOAAAACnRSTlMAMwsqXt+gIBUGxGoDMAAAAFlJREFUCNctzC0SQAAUReEzGNQ3AlHRiSRZFCVZYgeswRL8hLdK7834wj3tAlGP6y7fYHpKS6w6WwbVG0I1NZVnZPG8/DYxOYlnhUYkA06R1s9ESsxR4NIdPhkPFDFYuEnMAAAAAElFTkSuQmCC)}.tablesorter-metro-dark thead .headerSortDown,.tablesorter-metro-dark thead .tablesorter-headerDesc,.tablesorter-metro-dark thead .tablesorter-headerSortDown{background-image:url(data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAQBAMAAADQT4M0AAAALVBMVEUAAADu7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7i0NViAAAADnRSTlMAMiweCQITTvDctZZqaTlM310AAABcSURBVAjXY2BgYEtgAAFHERDJqigUAKSYBQUNgFSioKAYAwOLIBA4MASBKFUGQxAlzAAF+94BwWuGKBC1lIFl3rt3Lx0YGCzevWsGSjK9e6cAUlT3HKyW9wADAwDRrBiDy6bKzwAAAABJRU5ErkJggg==)}.tablesorter-metro-dark thead .sorter-false{background-image:none;cursor:default;padding:4px}.tablesorter-metro-dark td{background-color:#fff;padding:4px;vertical-align:top}.tablesorter-metro-dark tbody>tr.even:hover>td,.tablesorter-metro-dark tbody>tr.hover>td,.tablesorter-metro-dark tbody>tr.odd:hover>td,.tablesorter-metro-dark tbody>tr:hover>td{background-color:#bbb;color:#000}.tablesorter-metro-dark .tablesorter-processing{background-position:center center!important;background-repeat:no-repeat!important;background-image:url(data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=)!important}.tablesorter-metro-dark .tablesorter-pager button{background-color:#444;color:#eee;border:#555 1px solid;cursor:pointer}.tablesorter-metro-dark .tablesorter-pager button:hover{background-color:#555}.tablesorter-metro-dark tr.odd>td{background-color:#eee}.tablesorter-metro-dark tr.even>td{background-color:#fff}.tablesorter-metro-dark tr.odd td.primary{background-color:#bfbfbf}.tablesorter-metro-dark td.primary,.tablesorter-metro-dark tr.even td.primary{background-color:#d9d9d9}.tablesorter-metro-dark tr.odd td.secondary{background-color:#d9d9d9}.tablesorter-metro-dark td.secondary,.tablesorter-metro-dark tr.even td.secondary{background-color:#e6e6e6}.tablesorter-metro-dark tr.odd td.tertiary{background-color:#e6e6e6}.tablesorter-metro-dark td.tertiary,.tablesorter-metro-dark tr.even td.tertiary{background-color:#f2f2f2}.tablesorter-metro-dark .tablesorter-filter-row{background-color:#eee}.tablesorter-metro-dark .tablesorter-filter-row td{background-color:#eee;line-height:normal;text-align:center;-webkit-transition:line-height .1s ease;-moz-transition:line-height .1s ease;-o-transition:line-height .1s ease;transition:line-height .1s ease}.tablesorter-metro-dark .tablesorter-filter-row .disabled{opacity:.5;cursor:not-allowed}.tablesorter-metro-dark .tablesorter-filter-row.hideme td{padding:2px;margin:0;line-height:0;cursor:pointer}.tablesorter-metro-dark .tablesorter-filter-row.hideme *{height:1px;min-height:0;border:0;padding:0;margin:0;opacity:0}.tablesorter-metro-dark input.tablesorter-filter,.tablesorter-metro-dark select.tablesorter-filter{width:95%;height:auto;margin:0;padding:4px;background-color:#fff;border:1px solid #bbb;color:#333;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .1s ease;-moz-transition:height .1s ease;-o-transition:height .1s ease;transition:height .1s ease}.tablesorter .filtered{display:none}.tablesorter .tablesorter-errorRow td{text-align:center;cursor:pointer;background-color:#e6bf99} \ No newline at end of file diff --git a/dist/js/extras/jquery.tablesorter.pager.min.js b/dist/js/extras/jquery.tablesorter.pager.min.js index 82d170878..975257609 100644 --- a/dist/js/extras/jquery.tablesorter.pager.min.js +++ b/dist/js/extras/jquery.tablesorter.pager.min.js @@ -2,4 +2,4 @@ * tablesorter (FORK) pager plugin * updated 4/18/2017 (v2.28.8) */ -!function(e){"use strict";var t=e.tablesorter;e.extend({tablesorterPager:new function(){this.defaults={container:null,ajaxUrl:null,customAjaxUrl:function(e,t){return t},ajaxError:null,ajaxObject:{dataType:"json"},processAjaxOnInit:!0,ajaxProcessing:function(e){return[0,[],null]},output:"{startRow} to {endRow} of {totalRows} rows",updateArrows:!0,page:0,pageReset:0,size:10,maxOptionSize:20,savePages:!0,storageKey:"tablesorter-pager",fixedHeight:!1,countChildRows:!1,removeRows:!1,cssFirst:".first",cssPrev:".prev",cssNext:".next",cssLast:".last",cssGoto:".gotoPage",cssPageDisplay:".pagedisplay",cssPageSize:".pagesize",cssErrorRow:"tablesorter-errorRow",cssDisabled:"disabled",totalRows:0,totalPages:0,filteredRows:0,filteredPages:0,ajaxCounter:0,currentFilters:[],startRow:0,endRow:0,$size:null,last:{}};var a="filterInit filterStart filterEnd sortEnd disablePager enablePager destroyPager updateComplete pageSize pageSet pageAndSize pagerUpdate refreshComplete ",i=this,s=function(e,t,a){var i,s="addClass",r="removeClass",o=t.cssDisabled,n=!!a,l=n||0===t.page,g=z(e,t),c=n||t.page===g-1||0===g;t.updateArrows&&((i=t.$container.find(t.cssFirst+","+t.cssPrev))[l?s:r](o),i.each(function(){this.ariaDisabled=l}),(i=t.$container.find(t.cssNext+","+t.cssLast))[c?s:r](o),i.each(function(){this.ariaDisabled=c}))},r=function(e,a){var i,s,r,o=e.config,n=o.$table.hasClass("hasFilters");if(n&&!a.ajax)if(t.isEmptyObject(o.cache))a.filteredRows=a.totalRows=o.$tbodies.eq(0).children("tr").not(a.countChildRows?"":"."+o.cssChildRow).length;else for(a.filteredRows=0,r=(i=o.cache[0].normalized).length,s=0;s=0){if(c=P*i.page>i.filteredRows&&o,i.page=c?i.pageReset||0:i.page,i.startRow=c?P*i.page+1:0===i.filteredRows?0:P*i.page+1,i.endRow=Math.min(i.filteredRows,i.totalRows,P*(i.page+1)),d=i.$container.find(i.cssPageDisplay),"function"==typeof i.output?g=i.output(a,i):(w=d.attr("data-pager-output"+(i.filteredRows'):r.length>1&&o&&o[r[0]]?o[r[0]][r[1]]:i[s]||(o?o[s]:n)||n})),(p=i.$container.find(i.cssGoto)).length){for(c="",u=(h=n(a,i)).length,f=0;f'+h[f]+"";p.html(c).val(i.page+1)}d.length&&(d["INPUT"===d[0].nodeName?"val":"html"](g),d.find(".ts-startRow, .ts-page").unbind("change"+R).bind("change"+R,function(){var t=e(this).val(),a=e(this).hasClass("ts-startRow")?Math.floor(t/P)+1:t;b.$table.triggerHandler("pageSet"+R,[a])}))}s(a,i),l(a,i),i.initialized&&!1!==o&&(b.debug&&console.log("Pager: Triggering pagerComplete"),b.$table.triggerHandler("pagerComplete",i),i.savePages&&t.storage&&t.storage(a,i.storageKey,{page:i.page,size:P===i.totalRows?"all":P}))}},n=function(t,a){var i,s,r,o,n,l,g=z(t,a)||1,c=5*Math.ceil(g/a.maxOptionSize/5),d=g>a.maxOptionSize,p=a.page+1,f=c,u=g-c,h=[1];for(i=d?c:1;i<=g;)h[h.length]=i,i+=d?c:1;if(h[h.length]=g,d){for(r=[],(f=p-(s=Math.max(Math.floor(a.maxOptionSize/c)-1,5)))<1&&(f=1),(u=p+s)>g&&(u=g),i=f;i<=u;i++)r[r.length]=i;(n=(h=e.grep(h,function(t,a){return e.inArray(t,h)===a})).length)-(l=r.length)>c/2&&n+l>a.maxOptionSize&&(o=Math.floor(n/2)-Math.floor(l/2),Array.prototype.splice.apply(h,[o,l])),h=h.concat(r)}return h=e.grep(h,function(t,a){return e.inArray(t,h)===a}).sort(function(e,t){return e-t})},l=function(t,a){var i,s,r,o=t.config,n=o.$tbodies.eq(0);n.find("tr.pagerSavedHeightSpacer").remove(),a.fixedHeight&&!a.isDisabled&&(s=e.data(t,"pagerSavedHeight"))&&(r=0,e(t).css("border-spacing").split(" ").length>1&&(r=e(t).css("border-spacing").split(" ")[1].replace(/[^-\d\.]/g,"")),(i=s-n.height()+r*a.size-r)>5&&e.data(t,"pagerLastSize")===a.size&&n.children("tr:visible").length<("all"===a.size?a.totalRows:a.size)&&n.append(''))},g=function(t,a){var i,s=t.config,r=s.$tbodies.eq(0);r.find("tr.pagerSavedHeightSpacer").remove(),r.children("tr:visible").length||r.append(' '),i=r.children("tr").eq(0).height()*("all"===a.size?a.totalRows:a.size),e.data(t,"pagerSavedHeight",i),l(t,a),e.data(t,"pagerLastSize",a.size)},c=function(e,a){if(!a.ajaxUrl){var i,s=0,r=e.config,o=r.$tbodies.eq(0).children("tr"),n=o.length,l="all"===a.size?a.totalRows:a.size,g=a.page*l,c=g+l,d=0,p=0;for(a.cacheIndex=[],i=0;i=g&&p=g&&p0&&o[s].className.match(t.css.cssHasChild))for(;++s> Ajax Error",r,n,l),t.showError(i,r,n,l),y.$tbodies.eq(0).children("tr").detach(),s.totalRows=0;else{if(e.isArray(I)?(P=I[(d=isNaN(I[0])&&!isNaN(I[1]))?1:0],s.totalRows=isNaN(P)?s.totalRows||0:P,y.totalRows=y.filteredRows=s.filteredRows=s.totalRows,z=0===s.totalRows?[]:I[d?0:1]||[],R=I[2]):(s.ajaxData=I,y.totalRows=s.totalRows=I.total,y.filteredRows=s.filteredRows=void 0!==I.filteredRows?I.filteredRows:I.total,R=I.headers,z=I.rows||[]),x=z&&z.length,z instanceof jQuery)s.processAjaxOnInit&&(y.$tbodies.eq(0).empty(),y.$tbodies.eq(0).append(z));else if(x){for(g=0;g",c=0;c"+z[g][c]+"";$+=""}s.processAjaxOnInit&&y.$tbodies.eq(0).html($)}if(s.processAjaxOnInit=!0,R)for(u=(p=C.hasClass("hasStickyHeaders"))?y.widgetOptions.$sticky.children("thead:first").children("tr:not(."+y.cssIgnoreRow+")").children():"",f=C.find("tfoot tr:first").children(),v=(h=y.$headers.filter("th ")).length,c=0;c> No rows for pager to render");else{if(s.page>=s.totalPages&&m(a,s),s.cacheIndex=[],s.isDisabled=!1,s.initialized&&(p.debug&&console.log("Pager: Triggering pagerChange"),d.triggerHandler("pagerChange",s)),s.removeRows){for(t.clearTableBody(a),r=t.processTbody(a,p.$tbodies.eq(0),!0),n=f?0:w,l=f?0:w,g=0;gw&&g<=h&&(g++,s.cacheIndex[s.cacheIndex.length]=n,r.append(i[n])),n++;t.processTbody(a,r,!1)}else c(a,s);o(a,s),a.isUpdating&&(p.debug&&console.log("Pager: Triggering updateComplete"),d.triggerHandler("updateComplete",[a,!0]))}},w=function(a,i){var r,o,n;for(i.ajax?s(a,i,!0):(e.data(a,"pagerLastPage",i.page),e.data(a,"pagerLastSize",i.size),i.page=0,i.size=i.totalPages,i.totalPages=1,e(a).addClass("pagerDisabled").removeAttr("aria-describedby").find("tr.pagerSavedHeightSpacer").remove(),h(a,a.config.rowsCopy,i),i.isDisabled=!0,t.applyWidget(a),a.config.debug&&console.log("Pager: Disabled")),n=(o=i.$container.find(i.cssGoto+","+i.cssPageSize+", .ts-startRow, .ts-page")).length,r=0;ra&&a>=0&&(t.page=a),t.page},j=function(e,t,a){var i=parseInt(t,10)||e.size||e.settings.size||10;return e.initialized&&(/all/i.test(i+" "+t)||i===e.totalRows)?e.$container.find(e.cssPageSize+' option[value="all"]').length?"all":e.totalRows:"get"===a?i:e.size},P=function(t,a,i){i.size=j(i,a,"get"),i.$container.find(i.cssPageSize).val(i.size),e.data(t,"pagerLastPage",x(t,i)),e.data(t,"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)},v=function(e,t){t.page=0,R(e,t)},m=function(e,t){t.page=z(e,t)-1,R(e,t)},y=function(e,t){t.page++;var a=z(e,t)-1;t.page>=a&&(t.page=a),R(e,t)},C=function(e,t){--t.page<=0&&(t.page=0),R(e,t)},S=function(a,i){i.initialized=!0,i.initializing=!1,a.config.debug&&console.log("Pager: Triggering pagerInitialized"),e(a).triggerHandler("pagerInitialized",i),t.applyWidget(a),o(a,i)},$=function(t,a){t.config.pager=e.extend(!0,{},e.tablesorterPager.defaults,a.settings),F(t,a.settings)},I=function(e,a){var i=e.config,s=i.namespace+"pager",r=[a.cssFirst,a.cssPrev,a.cssNext,a.cssLast,a.cssGoto,a.cssPageSize].join(",");w(e,a),a.$container.hide().find(r).unbind(s),i.appender=null,i.$table.unbind(s),t.storage&&t.storage(e,a.storageKey,""),delete i.pager,delete i.rowsCopy},A=function(a,i,s){var r,o,n,l=a.config;i.$container.find(i.cssGoto+","+i.cssPageSize+",.ts-startRow, .ts-page").removeClass(i.cssDisabled).removeAttr("disabled").each(function(){this.ariaDisabled=!1}),i.isDisabled=!1,i.page=e.data(a,"pagerLastPage")||i.page||0,o=(n=i.$container.find(i.cssPageSize)).find("option[selected]").val(),i.size=e.data(a,"pagerLastSize")||j(i,o,"get"),i.totalPages="all"===i.size?1:Math.ceil(z(a,i)/i.size),P(a,i.size,i),a.id&&!l.$table.attr("aria-describedby")&&((r=(n=i.$container.find(i.cssPageDisplay)).attr("id"))||(r=a.id+"_pager_info",n.attr("id",r)),l.$table.attr("aria-describedby",r)),g(a,i),s&&(t.update(l),P(a,i.size,i),R(a,i),d(a,i),l.debug&&console.log("Pager: Enabled"))},F=function(s,r){var n,l,p,f,u=s.config,h=u.widgetOptions,z=u.pager=e.extend(!0,{},e.tablesorterPager.defaults,r),x=u.$table,S=u.namespace+"pager",F=z.$container=e(z.container).addClass("tablesorter-pager").show();z.settings=e.extend(!0,{},e.tablesorterPager.defaults,r),u.debug&&console.log("Pager: Initializing"),z.oldAjaxSuccess=z.oldAjaxSuccess||z.ajaxObject.success,u.appender=i.appender,z.initializing=!0,z.savePages&&t.storage&&(n=t.storage(s,z.storageKey)||{},z.page=isNaN(n.page)?z.page:n.page,z.size="all"===n.size?n.size:(isNaN(n.size)?z.size:n.size)||z.setSize||10,P(s,z.size,z)),z.regexRows=new RegExp("("+(h.filter_filteredRow||"filtered")+"|"+u.selectorRemove.slice(1)+"|"+u.cssChildRow+")"),z.regexFiltered=new RegExp(h.filter_filteredRow||"filtered"),x.unbind(a.split(" ").join(S+" ").replace(/\s+/g," ")).bind("filterInit filterStart ".split(" ").join(S+" "),function(a,i){z.currentFilters=e.isArray(i)?i:u.$table.data("lastSearch");var r;if(z.ajax&&"filterInit"===a.type)return R(s,z,!1);r=t.filter.equalFilters?t.filter.equalFilters(u,u.lastSearch,z.currentFilters):(u.lastSearch||[]).join("")!==(z.currentFilters||[]).join(""),"filterStart"!==a.type||!1===z.pageReset||r||(z.page=z.pageReset)}).bind("filterEnd sortEnd ".split(" ").join(S+" "),function(){z.currentFilters=u.$table.data("lastSearch"),(z.initialized||z.initializing)&&(u.delayInit&&u.rowsCopy&&0===u.rowsCopy.length&&b(s),o(s,z,!1),R(s,z,!1),t.applyWidget(s))}).bind("disablePager"+S,function(e){e.stopPropagation(),w(s,z)}).bind("enablePager"+S,function(e){e.stopPropagation(),A(s,z,!0)}).bind("destroyPager"+S,function(e){e.stopPropagation(),I(s,z)}).bind("resetToLoadState"+S,function(e){e.stopPropagation(),$(s,z)}).bind("updateComplete"+S,function(e,t,a){if(e.stopPropagation(),t&&!a&&!z.ajax){var i=u.$tbodies.eq(0).children("tr").not(u.selectorRemove);z.totalRows=i.length-(z.countChildRows?0:i.filter("."+u.cssChildRow).length),z.totalPages="all"===z.size?1:Math.ceil(z.totalRows/z.size),i.length&&u.rowsCopy&&0===u.rowsCopy.length&&b(t),z.page>=z.totalPages&&m(t,z),c(t,z),g(t,z),o(t,z,!0)}}).bind("pageSize refreshComplete ".split(" ").join(S+" "),function(e,t){e.stopPropagation(),P(s,j(z,t,"get"),z),R(s,z),c(s,z),o(s,z,!1)}).bind("pageSet pagerUpdate ".split(" ").join(S+" "),function(e,t){e.stopPropagation(),"pagerUpdate"===e.type&&(t=void 0===t?z.page+1:t,z.last.page=!0),z.page=(parseInt(t,10)||1)-1,R(s,z,!0),o(s,z,!1)}).bind("pageAndSize"+S,function(e,t,a){e.stopPropagation(),z.page=(parseInt(t,10)||1)-1,P(s,j(z,a,"get"),z),R(s,z,!0),c(s,z),o(s,z,!1)}),l=[z.cssFirst,z.cssPrev,z.cssNext,z.cssLast],p=[v,C,y,m],u.debug&&!F.length&&console.warn("Pager: >> Container not found"),F.find(l.join(",")).attr("tabindex",0).unbind("click"+S).bind("click"+S,function(t){t.stopPropagation();var a,i=e(this),r=l.length;if(!i.hasClass(z.cssDisabled))for(a=0;a> Goto selector not found"),(f=F.find(z.cssPageSize)).length?(f.find("option").removeAttr("selected"),f.unbind("change"+S).bind("change"+S,function(){if(!e(this).hasClass(z.cssDisabled)){var t=e(this).val();P(s,t,z),R(s,z),g(s,z)}return!1})):u.debug&&console.warn("Pager: >> Size selector not found"),z.initialized=!1,x.triggerHandler("pagerBeforeInitialized",z),A(s,z,!1),"string"==typeof z.ajaxUrl?(z.ajax=!0,u.widgetOptions.filter_serversideFiltering=!0,u.serverSideSorting=!0,R(s,z)):(z.ajax=!1,t.appendCache(u,!0),d(s,z)),z.ajax||z.initialized||(z.initializing=!1,z.initialized=!0,P(s,z.size,z),R(s,z),u.debug&&console.log("Pager: Triggering pagerInitialized"),u.$table.triggerHandler("pagerInitialized",z),u.widgetOptions.filter_initialized&&t.hasWidget(s,"filter")||o(s,z,!1)),u.widgetInit.pager=!0};i.appender=function(t,a){var i=t.config,s=i.pager;s.ajax||(i.rowsCopy=a,s.totalRows=s.countChildRows?i.$tbodies.eq(0).children("tr").length:a.length,s.size=e.data(t,"pagerLastSize")||s.size||s.settings.size||10,s.totalPages="all"===s.size?1:Math.ceil(s.totalRows/s.size),h(t,a,s),o(t,s,!1))},i.construct=function(e){return this.each(function(){this.config&&this.hasInitialized&&F(this,e)})}}}),t.showError=function(t,a,i,s){var r=e(t),o=r[0].config,n=o&&o.widgetOptions,l=o.pager&&o.pager.cssErrorRow||n&&n.pager_css&&n.pager_css.errorRow||"tablesorter-errorRow",g=typeof a,c=!0,d="",p=function(){o.$table.find("thead").find(o.selectorRemove).remove()};if(r.length){if("function"==typeof o.pager.ajaxError){if(!1===(c=o.pager.ajaxError(o,a,i,s)))return p();d=c}else if("function"==typeof n.pager_ajaxError){if(!1===(c=n.pager_ajaxError(o,a,i,s)))return p();d=c}if(""===d)if("object"===g)d=0===a.status?"Not connected, verify Network":404===a.status?"Requested page not found [404]":500===a.status?"Internal Server Error [500]":"parsererror"===s?"Requested JSON parse failed":"timeout"===s?"Time out error":"abort"===s?"Ajax Request aborted":"Uncaught error: "+a.statusText+" ["+a.status+"]";else{if("string"!==g)return p();d=a}e(/tr\>/.test(d)?d:''+d+"").click(function(){e(this).remove()}).appendTo(o.$table.find("thead:first")).addClass(l+" "+o.selectorRemove.slice(1)).attr({role:"alert","aria-live":"assertive"})}else console.error("tablesorter showError: no table parameter passed")},e.fn.extend({tablesorterPager:e.tablesorterPager.construct})}(jQuery); \ No newline at end of file +!function(e){"use strict";var t=e.tablesorter;e.extend({tablesorterPager:new function(){this.defaults={container:null,ajaxUrl:null,customAjaxUrl:function(e,t){return t},ajaxError:null,ajaxObject:{dataType:"json"},processAjaxOnInit:!0,ajaxProcessing:function(e){return[0,[],null]},output:"{startRow} to {endRow} of {totalRows} rows",updateArrows:!0,page:0,pageReset:0,size:10,maxOptionSize:20,savePages:!0,storageKey:"tablesorter-pager",fixedHeight:!1,countChildRows:!1,removeRows:!1,cssFirst:".first",cssPrev:".prev",cssNext:".next",cssLast:".last",cssGoto:".gotoPage",cssPageDisplay:".pagedisplay",cssPageSize:".pagesize",cssErrorRow:"tablesorter-errorRow",cssDisabled:"disabled",totalRows:0,totalPages:0,filteredRows:0,filteredPages:0,ajaxCounter:0,currentFilters:[],startRow:0,endRow:0,$size:null,last:{}};var a="filterInit filterStart filterEnd sortEnd disablePager enablePager destroyPager updateComplete pageSize pageSet pageAndSize pagerUpdate refreshComplete ",i=this,s=function(e,t,a){var i,s="addClass",r="removeClass",o=t.cssDisabled,n=!!a,l=n||0===t.page,g=z(e,t),c=n||t.page===g-1||0===g;t.updateArrows&&((i=t.$container.find(t.cssFirst+","+t.cssPrev))[l?s:r](o),i.each(function(){this.ariaDisabled=l}),(i=t.$container.find(t.cssNext+","+t.cssLast))[c?s:r](o),i.each(function(){this.ariaDisabled=c}))},r=function(e,a){var i,s,r,o=e.config,n=o.$table.hasClass("hasFilters");if(n&&!a.ajax)if(t.isEmptyObject(o.cache))a.filteredRows=a.totalRows=o.$tbodies.eq(0).children("tr").not(a.countChildRows?"":"."+o.cssChildRow).length;else for(a.filteredRows=0,r=(i=o.cache[0].normalized).length,s=0;s=0){if(c=P*i.page>i.filteredRows&&o,i.page=c?i.pageReset||0:i.page,i.startRow=c?P*i.page+1:0===i.filteredRows?0:P*i.page+1,i.endRow=Math.min(i.filteredRows,i.totalRows,P*(i.page+1)),d=i.$container.find(i.cssPageDisplay),"function"==typeof i.output?g=i.output(a,i):(w=d.attr("data-pager-output"+(i.filteredRows'):r.length>1&&o&&o[r[0]]?o[r[0]][r[1]]:i[s]||(o?o[s]:n)||n})),(p=i.$container.find(i.cssGoto)).length){for(c="",u=(h=n(a,i)).length,f=0;f'+h[f]+"";p.html(c).val(i.page+1)}d.length&&(d["INPUT"===d[0].nodeName?"val":"html"](g),d.find(".ts-startRow, .ts-page").unbind("change"+R).bind("change"+R,function(){var t=e(this).val(),a=e(this).hasClass("ts-startRow")?Math.floor(t/P)+1:t;b.$table.triggerHandler("pageSet"+R,[a])}))}s(a,i),l(a,i),i.initialized&&!1!==o&&(b.debug&&console.log("Pager: Triggering pagerComplete"),b.$table.triggerHandler("pagerComplete",i),i.savePages&&t.storage&&t.storage(a,i.storageKey,{page:i.page,size:P===i.totalRows?"all":P}))}},n=function(t,a){var i,s,r,o,n,l,g=z(t,a)||1,c=5*Math.ceil(g/a.maxOptionSize/5),d=g>a.maxOptionSize,p=a.page+1,f=c,u=g-c,h=[1];for(i=d?c:1;i<=g;)h[h.length]=i,i+=d?c:1;if(h[h.length]=g,d){for(r=[],(f=p-(s=Math.max(Math.floor(a.maxOptionSize/c)-1,5)))<1&&(f=1),(u=p+s)>g&&(u=g),i=f;i<=u;i++)r[r.length]=i;(n=(h=e.grep(h,function(t,a){return e.inArray(t,h)===a})).length)-(l=r.length)>c/2&&n+l>a.maxOptionSize&&(o=Math.floor(n/2)-Math.floor(l/2),Array.prototype.splice.apply(h,[o,l])),h=h.concat(r)}return h=e.grep(h,function(t,a){return e.inArray(t,h)===a}).sort(function(e,t){return e-t})},l=function(t,a){var i,s,r,o=t.config,n=o.$tbodies.eq(0);n.find("tr.pagerSavedHeightSpacer").remove(),a.fixedHeight&&!a.isDisabled&&(s=e.data(t,"pagerSavedHeight"))&&(r=0,e(t).css("border-spacing").split(" ").length>1&&(r=e(t).css("border-spacing").split(" ")[1].replace(/[^-\d\.]/g,"")),(i=s-n.height()+r*a.size-r)>5&&e.data(t,"pagerLastSize")===a.size&&n.children("tr:visible").length<("all"===a.size?a.totalRows:a.size)&&n.append(''))},g=function(t,a){var i,s=t.config,r=s.$tbodies.eq(0);r.find("tr.pagerSavedHeightSpacer").remove(),r.children("tr:visible").length||r.append(' '),i=r.children("tr").eq(0).height()*("all"===a.size?a.totalRows:a.size),e.data(t,"pagerSavedHeight",i),l(t,a),e.data(t,"pagerLastSize",a.size)},c=function(e,a){if(!a.ajaxUrl){var i,s=0,r=e.config,o=r.$tbodies.eq(0).children("tr"),n=o.length,l="all"===a.size?a.totalRows:a.size,g=a.page*l,c=g+l,d=0,p=0;for(a.cacheIndex=[],i=0;i=g&&p=g&&p0&&o[s].className.match(t.css.cssHasChild))for(;++s> Ajax Error",r,n,l),t.showError(i,r,n,l),y.$tbodies.eq(0).children("tr").detach(),s.totalRows=0;else{if(e.isArray(I)?(P=I[(d=isNaN(I[0])&&!isNaN(I[1]))?1:0],s.totalRows=isNaN(P)?s.totalRows||0:P,y.totalRows=y.filteredRows=s.filteredRows=s.totalRows,z=0===s.totalRows?[]:I[d?0:1]||[],R=I[2]):(s.ajaxData=I,y.totalRows=s.totalRows=I.total,y.filteredRows=s.filteredRows=void 0!==I.filteredRows?I.filteredRows:I.total,R=I.headers,z=I.rows||[]),x=z&&z.length,z instanceof jQuery)s.processAjaxOnInit&&(y.$tbodies.eq(0).empty(),y.$tbodies.eq(0).append(z));else if(x){for(g=0;g",c=0;c"+z[g][c]+"";$+=""}s.processAjaxOnInit&&y.$tbodies.eq(0).html($)}if(s.processAjaxOnInit=!0,R)for(u=(p=C.hasClass("hasStickyHeaders"))?y.widgetOptions.$sticky.children("thead:first").children("tr:not(."+y.cssIgnoreRow+")").children():"",f=C.find("tfoot tr:first").children(),v=(h=y.$headers.filter("th ")).length,c=0;c> No rows for pager to render");else{if(s.page>=s.totalPages&&m(a,s),s.cacheIndex=[],s.isDisabled=!1,s.initialized&&(p.debug&&console.log("Pager: Triggering pagerChange"),d.triggerHandler("pagerChange",s)),s.removeRows){for(t.clearTableBody(a),r=t.processTbody(a,p.$tbodies.eq(0),!0),n=f?0:w,l=f?0:w,g=0;gw&&g<=h&&(g++,s.cacheIndex[s.cacheIndex.length]=n,r.append(i[n])),n++;t.processTbody(a,r,!1)}else c(a,s);o(a,s),a.isUpdating&&(p.debug&&console.log("Pager: Triggering updateComplete"),d.triggerHandler("updateComplete",[a,!0]))}},w=function(a,i){var r,o,n;for(i.ajax?s(a,i,!0):(e.data(a,"pagerLastPage",i.page),e.data(a,"pagerLastSize",i.size),i.page=0,i.size=i.totalPages,i.totalPages=1,e(a).addClass("pagerDisabled").removeAttr("aria-describedby").find("tr.pagerSavedHeightSpacer").remove(),h(a,a.config.rowsCopy,i),i.isDisabled=!0,t.applyWidget(a),a.config.debug&&console.log("Pager: Disabled")),n=(o=i.$container.find(i.cssGoto+","+i.cssPageSize+", .ts-startRow, .ts-page")).length,r=0;ra&&a>=0&&(t.page=a),t.page},j=function(e,t,a){var i=parseInt(t,10)||e.size||e.settings.size||10;return e.initialized&&(/all/i.test(i+" "+t)||i===e.totalRows)?e.$container.find(e.cssPageSize+' option[value="all"]').length?"all":e.totalRows:"get"===a?i:e.size},P=function(t,a,i){i.size=j(i,a,"get"),i.$container.find(i.cssPageSize).val(i.size),e.data(t,"pagerLastPage",x(t,i)),e.data(t,"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)},v=function(e,t){t.page=0,R(e,t)},m=function(e,t){t.page=z(e,t)-1,R(e,t)},y=function(e,t){t.page++;var a=z(e,t)-1;t.page>=a&&(t.page=a),R(e,t)},C=function(e,t){t.page--,t.page<=0&&(t.page=0),R(e,t)},S=function(a,i){i.initialized=!0,i.initializing=!1,a.config.debug&&console.log("Pager: Triggering pagerInitialized"),e(a).triggerHandler("pagerInitialized",i),t.applyWidget(a),o(a,i)},$=function(t,a){t.config.pager=e.extend(!0,{},e.tablesorterPager.defaults,a.settings),F(t,a.settings)},I=function(e,a){var i=e.config,s=i.namespace+"pager",r=[a.cssFirst,a.cssPrev,a.cssNext,a.cssLast,a.cssGoto,a.cssPageSize].join(",");w(e,a),a.$container.hide().find(r).unbind(s),i.appender=null,i.$table.unbind(s),t.storage&&t.storage(e,a.storageKey,""),delete i.pager,delete i.rowsCopy},A=function(a,i,s){var r,o,n,l=a.config;i.$container.find(i.cssGoto+","+i.cssPageSize+",.ts-startRow, .ts-page").removeClass(i.cssDisabled).removeAttr("disabled").each(function(){this.ariaDisabled=!1}),i.isDisabled=!1,i.page=e.data(a,"pagerLastPage")||i.page||0,o=(n=i.$container.find(i.cssPageSize)).find("option[selected]").val(),i.size=e.data(a,"pagerLastSize")||j(i,o,"get"),i.totalPages="all"===i.size?1:Math.ceil(z(a,i)/i.size),P(a,i.size,i),a.id&&!l.$table.attr("aria-describedby")&&((r=(n=i.$container.find(i.cssPageDisplay)).attr("id"))||(r=a.id+"_pager_info",n.attr("id",r)),l.$table.attr("aria-describedby",r)),g(a,i),s&&(t.update(l),P(a,i.size,i),R(a,i),d(a,i),l.debug&&console.log("Pager: Enabled"))},F=function(s,r){var n,l,p,f,u=s.config,h=u.widgetOptions,z=u.pager=e.extend(!0,{},e.tablesorterPager.defaults,r),x=u.$table,S=u.namespace+"pager",F=z.$container=e(z.container).addClass("tablesorter-pager").show();z.settings=e.extend(!0,{},e.tablesorterPager.defaults,r),u.debug&&console.log("Pager: Initializing"),z.oldAjaxSuccess=z.oldAjaxSuccess||z.ajaxObject.success,u.appender=i.appender,z.initializing=!0,z.savePages&&t.storage&&(n=t.storage(s,z.storageKey)||{},z.page=isNaN(n.page)?z.page:n.page,z.size="all"===n.size?n.size:(isNaN(n.size)?z.size:n.size)||z.setSize||10,P(s,z.size,z)),z.regexRows=new RegExp("("+(h.filter_filteredRow||"filtered")+"|"+u.selectorRemove.slice(1)+"|"+u.cssChildRow+")"),z.regexFiltered=new RegExp(h.filter_filteredRow||"filtered"),x.unbind(a.split(" ").join(S+" ").replace(/\s+/g," ")).bind("filterInit filterStart ".split(" ").join(S+" "),function(a,i){z.currentFilters=e.isArray(i)?i:u.$table.data("lastSearch");var r;if(z.ajax&&"filterInit"===a.type)return R(s,z,!1);r=t.filter.equalFilters?t.filter.equalFilters(u,u.lastSearch,z.currentFilters):(u.lastSearch||[]).join("")!==(z.currentFilters||[]).join(""),"filterStart"!==a.type||!1===z.pageReset||r||(z.page=z.pageReset)}).bind("filterEnd sortEnd ".split(" ").join(S+" "),function(){z.currentFilters=u.$table.data("lastSearch"),(z.initialized||z.initializing)&&(u.delayInit&&u.rowsCopy&&0===u.rowsCopy.length&&b(s),o(s,z,!1),R(s,z,!1),t.applyWidget(s))}).bind("disablePager"+S,function(e){e.stopPropagation(),w(s,z)}).bind("enablePager"+S,function(e){e.stopPropagation(),A(s,z,!0)}).bind("destroyPager"+S,function(e){e.stopPropagation(),I(s,z)}).bind("resetToLoadState"+S,function(e){e.stopPropagation(),$(s,z)}).bind("updateComplete"+S,function(e,t,a){if(e.stopPropagation(),t&&!a&&!z.ajax){var i=u.$tbodies.eq(0).children("tr").not(u.selectorRemove);z.totalRows=i.length-(z.countChildRows?0:i.filter("."+u.cssChildRow).length),z.totalPages="all"===z.size?1:Math.ceil(z.totalRows/z.size),i.length&&u.rowsCopy&&0===u.rowsCopy.length&&b(t),z.page>=z.totalPages&&m(t,z),c(t,z),g(t,z),o(t,z,!0)}}).bind("pageSize refreshComplete ".split(" ").join(S+" "),function(e,t){e.stopPropagation(),P(s,j(z,t,"get"),z),R(s,z),c(s,z),o(s,z,!1)}).bind("pageSet pagerUpdate ".split(" ").join(S+" "),function(e,t){e.stopPropagation(),"pagerUpdate"===e.type&&(t=void 0===t?z.page+1:t,z.last.page=!0),z.page=(parseInt(t,10)||1)-1,R(s,z,!0),o(s,z,!1)}).bind("pageAndSize"+S,function(e,t,a){e.stopPropagation(),z.page=(parseInt(t,10)||1)-1,P(s,j(z,a,"get"),z),R(s,z,!0),c(s,z),o(s,z,!1)}),l=[z.cssFirst,z.cssPrev,z.cssNext,z.cssLast],p=[v,C,y,m],u.debug&&!F.length&&console.warn("Pager: >> Container not found"),F.find(l.join(",")).attr("tabindex",0).unbind("click"+S).bind("click"+S,function(t){t.stopPropagation();var a,i=e(this),r=l.length;if(!i.hasClass(z.cssDisabled))for(a=0;a> Goto selector not found"),(f=F.find(z.cssPageSize)).length?(f.find("option").removeAttr("selected"),f.unbind("change"+S).bind("change"+S,function(){if(!e(this).hasClass(z.cssDisabled)){var t=e(this).val();P(s,t,z),R(s,z),g(s,z)}return!1})):u.debug&&console.warn("Pager: >> Size selector not found"),z.initialized=!1,x.triggerHandler("pagerBeforeInitialized",z),A(s,z,!1),"string"==typeof z.ajaxUrl?(z.ajax=!0,u.widgetOptions.filter_serversideFiltering=!0,u.serverSideSorting=!0,R(s,z)):(z.ajax=!1,t.appendCache(u,!0),d(s,z)),z.ajax||z.initialized||(z.initializing=!1,z.initialized=!0,P(s,z.size,z),R(s,z),u.debug&&console.log("Pager: Triggering pagerInitialized"),u.$table.triggerHandler("pagerInitialized",z),u.widgetOptions.filter_initialized&&t.hasWidget(s,"filter")||o(s,z,!1)),u.widgetInit.pager=!0};i.appender=function(t,a){var i=t.config,s=i.pager;s.ajax||(i.rowsCopy=a,s.totalRows=s.countChildRows?i.$tbodies.eq(0).children("tr").length:a.length,s.size=e.data(t,"pagerLastSize")||s.size||s.settings.size||10,s.totalPages="all"===s.size?1:Math.ceil(s.totalRows/s.size),h(t,a,s),o(t,s,!1))},i.construct=function(e){return this.each(function(){this.config&&this.hasInitialized&&F(this,e)})}}}),t.showError=function(t,a,i,s){var r=e(t),o=r[0].config,n=o&&o.widgetOptions,l=o.pager&&o.pager.cssErrorRow||n&&n.pager_css&&n.pager_css.errorRow||"tablesorter-errorRow",g=typeof a,c=!0,d="",p=function(){o.$table.find("thead").find(o.selectorRemove).remove()};if(r.length){if("function"==typeof o.pager.ajaxError){if(!1===(c=o.pager.ajaxError(o,a,i,s)))return p();d=c}else if("function"==typeof n.pager_ajaxError){if(!1===(c=n.pager_ajaxError(o,a,i,s)))return p();d=c}if(""===d)if("object"===g)d=0===a.status?"Not connected, verify Network":404===a.status?"Requested page not found [404]":500===a.status?"Internal Server Error [500]":"parsererror"===s?"Requested JSON parse failed":"timeout"===s?"Time out error":"abort"===s?"Ajax Request aborted":"Uncaught error: "+a.statusText+" ["+a.status+"]";else{if("string"!==g)return p();d=a}e(/tr\>/.test(d)?d:''+d+"").click(function(){e(this).remove()}).appendTo(o.$table.find("thead:first")).addClass(l+" "+o.selectorRemove.slice(1)).attr({role:"alert","aria-live":"assertive"})}else console.error("tablesorter showError: no table parameter passed")},e.fn.extend({tablesorterPager:e.tablesorterPager.construct})}(jQuery); \ No newline at end of file diff --git a/dist/js/extras/semver-mod.min.js b/dist/js/extras/semver-mod.min.js index 9ce8c5453..9178477e1 100644 --- a/dist/js/extras/semver-mod.min.js +++ b/dist/js/extras/semver-mod.min.js @@ -1,2 +1,2 @@ /*! Modified semver.js for node.js (v4.3.3, 3/27/2015) */ -!function(){function r(r,e){if(r instanceof n)return r;if("string"!=typeof r)return null;if(r.length>L)return null;if(!(e?F[ur]:F[ar]).test(r))return null;try{return new n(r,e)}catch(r){return null}}function e(e,t){var n=r(e,t);return n?n.version:null}function t(e,t){var n=r(e.trim().replace(/^[=v]+/,""),t);return n?n.version:null}function n(r,e){if(r instanceof n){if(r.loose===e)return r;r=r.version}else if("string"!=typeof r)throw new TypeError("Invalid Version: "+r);if(r.length>L)throw new TypeError("version is longer than "+L+" characters");if(!(this instanceof n))return new n(r,e);q("SemVer",r,e),this.loose=e;var t=r.trim().match(e?F[ur]:F[ar]);if(!t)throw new TypeError("Invalid Version: "+r);if(this.raw=r,this.major=+t[1],this.minor=+t[2],this.patch=+t[3],this.major>U||this.major<0)throw new TypeError("Invalid major version");if(this.minor>U||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>U||this.patch<0)throw new TypeError("Invalid patch version");t[4]?this.prerelease=t[4].split(".").map(function(r){if(/^[0-9]+$/.test(r)){var e=+r;if(e>=0&&ee?1:0}function a(r,e){return s(e,r)}function p(r,e){return new n(r,e).major}function c(r,e){return new n(r,e).minor}function u(r,e){return new n(r,e).patch}function h(r,e,t){return new n(r,t).compare(e)}function f(r,e){return h(r,e,!0)}function l(r,e,t){return h(e,r,t)}function v(r,e){return r.sort(function(r,t){return B.compare(r,t,e)})}function m(r,e){return r.sort(function(r,t){return B.rcompare(r,t,e)})}function g(r,e,t){return h(r,e,t)>0}function w(r,e,t){return h(r,e,t)<0}function y(r,e,t){return 0===h(r,e,t)}function d(r,e,t){return 0!==h(r,e,t)}function j(r,e,t){return h(r,e,t)>=0}function E(r,e,t){return h(r,e,t)<=0}function b(r,e,t,n){var i;switch(e){case"===":"object"==typeof r&&(r=r.version),"object"==typeof t&&(t=t.version),i=r===t;break;case"!==":"object"==typeof r&&(r=r.version),"object"==typeof t&&(t=t.version),i=r!==t;break;case"":case"=":case"==":i=y(r,t,n);break;case"!=":i=d(r,t,n);break;case">":i=g(r,t,n);break;case">=":i=j(r,t,n);break;case"<":i=w(r,t,n);break;case"<=":i=E(r,t,n);break;default:throw new TypeError("Invalid operator: "+e)}return i}function $(r,e){if(r instanceof $){if(r.loose===e)return r;r=r.value}if(!(this instanceof $))return new $(r,e);q("comparator",r,e),this.loose=e,this.parse(r),this.semver===Mr?this.value="":this.value=this.operator+this.semver.version,q("comp",this)}function k(r,e){if(r instanceof k&&r.loose===e)return r;if(!(this instanceof k))return new k(r,e);if(this.loose=e,this.raw=r,this.set=r.split(/\s*\|\|\s*/).map(function(r){return this.parseRange(r.trim())},this).filter(function(r){return r.length}),!this.set.length)throw new TypeError("Invalid SemVer Range: "+r);this.format()}function R(r,e){return new k(r,e).set.map(function(r){return r.map(function(r){return r.value}).join(" ").trim().split(" ")})}function S(r,e){return q("comp",r),r=V(r,e),q("caret",r),r=I(r,e),q("tildes",r),r=C(r,e),q("xrange",r),r=M(r,e),q("stars",r),r}function x(r){return!r||"x"===r.toLowerCase()||"*"===r}function I(r,e){return r.trim().split(/\s+/).map(function(r){return T(r,e)}).join(" ")}function T(r,e){var t=e?F[Er]:F[jr];return r.replace(t,function(e,t,n,i,o){q("tilde",r,e,t,n,i,o);var s;return x(t)?s="":x(n)?s=">="+t+".0.0 <"+(+t+1)+".0.0":x(i)?s=">="+t+"."+n+".0 <"+t+"."+(+n+1)+".0":o?(q("replaceTilde pr",o),"-"!==o.charAt(0)&&(o="-"+o),s=">="+t+"."+n+"."+i+o+" <"+t+"."+(+n+1)+".0"):s=">="+t+"."+n+"."+i+" <"+t+"."+(+n+1)+".0",q("tilde return",s),s})}function V(r,e){return r.trim().split(/\s+/).map(function(r){return A(r,e)}).join(" ")}function A(r,e){q("caret",r,e);var t=e?F[Rr]:F[kr];return r.replace(t,function(e,t,n,i,o){q("caret",r,e,t,n,i,o);var s;return x(t)?s="":x(n)?s=">="+t+".0.0 <"+(+t+1)+".0.0":x(i)?s="0"===t?">="+t+"."+n+".0 <"+t+"."+(+n+1)+".0":">="+t+"."+n+".0 <"+(+t+1)+".0.0":o?(q("replaceCaret pr",o),"-"!==o.charAt(0)&&(o="-"+o),s="0"===t?"0"===n?">="+t+"."+n+"."+i+o+" <"+t+"."+n+"."+(+i+1):">="+t+"."+n+"."+i+o+" <"+t+"."+(+n+1)+".0":">="+t+"."+n+"."+i+o+" <"+(+t+1)+".0.0"):(q("no pr"),s="0"===t?"0"===n?">="+t+"."+n+"."+i+" <"+t+"."+n+"."+(+i+1):">="+t+"."+n+"."+i+" <"+t+"."+(+n+1)+".0":">="+t+"."+n+"."+i+" <"+(+t+1)+".0.0"),q("caret return",s),s})}function C(r,e){return q("replaceXRanges",r,e),r.split(/\s+/).map(function(r){return N(r,e)}).join(" ")}function N(r,e){r=r.trim();var t=e?F[wr]:F[gr];return r.replace(t,function(e,t,n,i,o,s){q("xRange",r,e,t,n,i,o,s);var a=x(n),p=a||x(i),c=p||x(o),u=c;return"="===t&&u&&(t=""),a?e=">"===t||"<"===t?"<0.0.0":"*":t&&u?(p&&(i=0),c&&(o=0),">"===t?(t=">=",p?(n=+n+1,i=0,o=0):c&&(i=+i+1,o=0)):"<="===t&&(t="<",p?n=+n+1:i=+i+1),e=t+n+"."+i+"."+o):p?e=">="+n+".0.0 <"+(+n+1)+".0.0":c&&(e=">="+n+"."+i+".0 <"+n+"."+(+i+1)+".0"),q("xRange return",e),e})}function M(r,e){return q("replaceStars",r,e),r.trim().replace(F[Ar],"")}function _(r,e,t,n,i,o,s,a,p,c,u,h,f){return e=x(t)?"":x(n)?">="+t+".0.0":x(i)?">="+t+"."+n+".0":">="+e,a=x(p)?"":x(c)?"<"+(+p+1)+".0.0":x(u)?"<"+p+"."+(+c+1)+".0":h?"<="+p+"."+c+"."+u+"-"+h:"<="+a,(e+" "+a).trim()}function D(r,e){for(t=0;t0){var n=r[t].semver;if(n.major===e.major&&n.minor===e.minor&&n.patch===e.patch)return!0}}return!1}return!0}function X(r,e,t){try{e=new k(e,t)}catch(r){return!1}return e.test(r)}function z(r,e,t){return r.filter(function(r){return X(r,e,t)}).sort(function(r,e){return l(r,e,t)})[0]||null}function G(r,e){try{return new k(r,e).range||"*"}catch(r){return null}}function O(r,e,t){return Z(r,e,"<",t)}function P(r,e,t){return Z(r,e,">",t)}function Z(r,e,t,i){r=new n(r,i),e=new k(e,i);var o,s,a,p,c;switch(t){case">":o=g,s=E,a=w,p=">",c=">=";break;case"<":o=w,s=j,a=g,p="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(X(r,e,i))return!1;for(var u=0;u)?=?)";var fr=J++;H[fr]=H[Q]+"|x|X|\\*";var lr=J++;H[lr]=H[K]+"|x|X|\\*";var vr=J++;H[vr]="[v=\\s]*("+H[lr]+")(?:\\.("+H[lr]+")(?:\\.("+H[lr]+")(?:"+H[nr]+")?"+H[sr]+"?)?)?";var mr=J++;H[mr]="[v=\\s]*("+H[fr]+")(?:\\.("+H[fr]+")(?:\\.("+H[fr]+")(?:"+H[ir]+")?"+H[sr]+"?)?)?";var gr=J++;H[gr]="^"+H[hr]+"\\s*"+H[vr]+"$";var wr=J++;H[wr]="^"+H[hr]+"\\s*"+H[mr]+"$";var yr=J++;H[yr]="(?:~>?)";var dr=J++;H[dr]="(\\s*)"+H[yr]+"\\s+",F[dr]=new RegExp(H[dr],"g");var jr=J++;H[jr]="^"+H[yr]+H[vr]+"$";var Er=J++;H[Er]="^"+H[yr]+H[mr]+"$";var br=J++;H[br]="(?:\\^)";var $r=J++;H[$r]="(\\s*)"+H[br]+"\\s+",F[$r]=new RegExp(H[$r],"g");var kr=J++;H[kr]="^"+H[br]+H[vr]+"$";var Rr=J++;H[Rr]="^"+H[br]+H[mr]+"$";var Sr=J++;H[Sr]="^"+H[hr]+"\\s*("+cr+")$|^$";var xr=J++;H[xr]="^"+H[hr]+"\\s*("+pr+")$|^$";var Ir=J++;H[Ir]="(\\s*)"+H[hr]+"\\s*("+cr+"|"+H[vr]+")",F[Ir]=new RegExp(H[Ir],"g");var Tr=J++;H[Tr]="^\\s*("+H[vr]+")\\s+-\\s+("+H[vr]+")\\s*$";var Vr=J++;H[Vr]="^\\s*("+H[mr]+")\\s+-\\s+("+H[mr]+")\\s*$";var Ar=J++;H[Ar]="(<|>)?=?\\s*\\*";for(var Cr=0;Cr'},n.prototype.toString=function(){return this.version},n.prototype.compare=function(r){return q("SemVer.compare",this.version,this.loose,r),r instanceof n||(r=new n(r,this.loose)),this.compareMain(r)||this.comparePre(r)},n.prototype.compareMain=function(r){return r instanceof n||(r=new n(r,this.loose)),s(this.major,r.major)||s(this.minor,r.minor)||s(this.patch,r.patch)},n.prototype.comparePre=function(r){if(r instanceof n||(r=new n(r,this.loose)),this.prerelease.length&&!r.prerelease.length)return-1;if(!this.prerelease.length&&r.prerelease.length)return 1;if(!this.prerelease.length&&!r.prerelease.length)return 0;var e=0;do{var t=this.prerelease[e],i=r.prerelease[e];if(q("prerelease compare",e,t,i),void 0===t&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===t)return-1;if(t!==i)return s(t,i)}while(++e)},n.prototype.inc=function(r,e){switch(r){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",e);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",e);break;case"prepatch":this.prerelease.length=0,this.inc("patch",e),this.inc("pre",e);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",e),this.inc("pre",e);break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":if(0===this.prerelease.length)this.prerelease=[0];else{for(var t=this.prerelease.length;--t>=0;)"number"==typeof this.prerelease[t]&&(this.prerelease[t]++,t=-2);-1===t&&this.prerelease.push(0)}e&&(this.prerelease[0]===e?isNaN(this.prerelease[1])&&(this.prerelease=[e,0]):this.prerelease=[e,0]);break;default:throw new Error("invalid increment argument: "+r)}return this.format(),this},B.inc=i,B.diff=o,B.compareIdentifiers=s;var Nr=/^[0-9]+$/;B.rcompareIdentifiers=a,B.major=p,B.minor=c,B.patch=u,B.compare=h,B.compareLoose=f,B.rcompare=l,B.sort=v,B.rsort=m,B.gt=g,B.lt=w,B.eq=y,B.neq=d,B.gte=j,B.lte=E,B.cmp=b,B.Comparator=$;var Mr={};$.prototype.parse=function(r){var e=this.loose?F[Sr]:F[xr],t=r.match(e);if(!t)throw new TypeError("Invalid comparator: "+r);this.operator=t[1],"="===this.operator&&(this.operator=""),t[2]?this.semver=new n(t[2],this.loose):this.semver=Mr},$.prototype.inspect=function(){return''},$.prototype.toString=function(){return this.value},$.prototype.test=function(r){return q("Comparator.test",r,this.loose),this.semver===Mr||("string"==typeof r&&(r=new n(r,this.loose)),b(r,this.operator,this.semver,this.loose))},B.Range=k,k.prototype.inspect=function(){return''},k.prototype.format=function(){return this.range=this.set.map(function(r){return r.join(" ").trim()}).join("||").trim(),this.range},k.prototype.toString=function(){return this.range},k.prototype.parseRange=function(r){var e=this.loose;r=r.trim(),q("range",r,e);var t=e?F[Vr]:F[Tr];r=r.replace(t,_),q("hyphen replace",r),r=r.replace(F[Ir],"$1$2$3"),q("comparator trim",r,F[Ir]),r=(r=(r=r.replace(F[dr],"$1~")).replace(F[$r],"$1^")).split(/\s+/).join(" ");var n=e?F[Sr]:F[xr],i=r.split(" ").map(function(r){return S(r,e)}).join(" ").split(/\s+/);return this.loose&&(i=i.filter(function(r){return!!r.match(n)})),i=i.map(function(r){return new $(r,e)})},B.toComparators=R,k.prototype.test=function(r){if(!r)return!1;"string"==typeof r&&(r=new n(r,this.loose));for(var e=0;eT)return null;if(!(t?A[H]:A[L]).test(r))return null;try{return new e(r,t)}catch(r){return null}}function e(r,t){if(r instanceof e){if(r.loose===t)return r;r=r.version}else if("string"!=typeof r)throw new TypeError("Invalid Version: "+r);if(r.length>T)throw new TypeError("version is longer than "+T+" characters");if(!(this instanceof e))return new e(r,t);x("SemVer",r,t),this.loose=t;var n=r.trim().match(t?A[H]:A[L]);if(!n)throw new TypeError("Invalid Version: "+r);if(this.raw=r,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>V||this.major<0)throw new TypeError("Invalid major version");if(this.minor>V||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>V||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(function(r){if(/^[0-9]+$/.test(r)){var e=+r;if(e>=0&&ee?1:0}function n(r,t,n){return new e(r,n).compare(t)}function i(r,e,t){return n(e,r,t)}function o(r,e,t){return n(r,e,t)>0}function s(r,e,t){return n(r,e,t)<0}function a(r,e,t){return 0===n(r,e,t)}function p(r,e,t){return 0!==n(r,e,t)}function c(r,e,t){return n(r,e,t)>=0}function u(r,e,t){return n(r,e,t)<=0}function h(r,e,t,n){var i;switch(e){case"===":"object"==typeof r&&(r=r.version),"object"==typeof t&&(t=t.version),i=r===t;break;case"!==":"object"==typeof r&&(r=r.version),"object"==typeof t&&(t=t.version),i=r!==t;break;case"":case"=":case"==":i=a(r,t,n);break;case"!=":i=p(r,t,n);break;case">":i=o(r,t,n);break;case">=":i=c(r,t,n);break;case"<":i=s(r,t,n);break;case"<=":i=u(r,t,n);break;default:throw new TypeError("Invalid operator: "+e)}return i}function f(r,e){if(r instanceof f){if(r.loose===e)return r;r=r.value}if(!(this instanceof f))return new f(r,e);x("comparator",r,e),this.loose=e,this.parse(r),this.semver===yr?this.value="":this.value=this.operator+this.semver.version,x("comp",this)}function l(r,e){if(r instanceof l&&r.loose===e)return r;if(!(this instanceof l))return new l(r,e);if(this.loose=e,this.raw=r,this.set=r.split(/\s*\|\|\s*/).map(function(r){return this.parseRange(r.trim())},this).filter(function(r){return r.length}),!this.set.length)throw new TypeError("Invalid SemVer Range: "+r);this.format()}function v(r,e){return x("comp",r),r=y(r,e),x("caret",r),r=g(r,e),x("tildes",r),r=j(r,e),x("xrange",r),r=b(r,e),x("stars",r),r}function m(r){return!r||"x"===r.toLowerCase()||"*"===r}function g(r,e){return r.trim().split(/\s+/).map(function(r){return w(r,e)}).join(" ")}function w(r,e){var t=e?A[or]:A[ir];return r.replace(t,function(e,t,n,i,o){x("tilde",r,e,t,n,i,o);var s;return m(t)?s="":m(n)?s=">="+t+".0.0 <"+(+t+1)+".0.0":m(i)?s=">="+t+"."+n+".0 <"+t+"."+(+n+1)+".0":o?(x("replaceTilde pr",o),"-"!==o.charAt(0)&&(o="-"+o),s=">="+t+"."+n+"."+i+o+" <"+t+"."+(+n+1)+".0"):s=">="+t+"."+n+"."+i+" <"+t+"."+(+n+1)+".0",x("tilde return",s),s})}function y(r,e){return r.trim().split(/\s+/).map(function(r){return d(r,e)}).join(" ")}function d(r,e){x("caret",r,e);var t=e?A[cr]:A[pr];return r.replace(t,function(e,t,n,i,o){x("caret",r,e,t,n,i,o);var s;return m(t)?s="":m(n)?s=">="+t+".0.0 <"+(+t+1)+".0.0":m(i)?s="0"===t?">="+t+"."+n+".0 <"+t+"."+(+n+1)+".0":">="+t+"."+n+".0 <"+(+t+1)+".0.0":o?(x("replaceCaret pr",o),"-"!==o.charAt(0)&&(o="-"+o),s="0"===t?"0"===n?">="+t+"."+n+"."+i+o+" <"+t+"."+n+"."+(+i+1):">="+t+"."+n+"."+i+o+" <"+t+"."+(+n+1)+".0":">="+t+"."+n+"."+i+o+" <"+(+t+1)+".0.0"):(x("no pr"),s="0"===t?"0"===n?">="+t+"."+n+"."+i+" <"+t+"."+n+"."+(+i+1):">="+t+"."+n+"."+i+" <"+t+"."+(+n+1)+".0":">="+t+"."+n+"."+i+" <"+(+t+1)+".0.0"),x("caret return",s),s})}function j(r,e){return x("replaceXRanges",r,e),r.split(/\s+/).map(function(r){return E(r,e)}).join(" ")}function E(r,e){r=r.trim();var t=e?A[er]:A[rr];return r.replace(t,function(e,t,n,i,o,s){x("xRange",r,e,t,n,i,o,s);var a=m(n),p=a||m(i),c=p||m(o),u=c;return"="===t&&u&&(t=""),a?e=">"===t||"<"===t?"<0.0.0":"*":t&&u?(p&&(i=0),c&&(o=0),">"===t?(t=">=",p?(n=+n+1,i=0,o=0):c&&(i=+i+1,o=0)):"<="===t&&(t="<",p?n=+n+1:i=+i+1),e=t+n+"."+i+"."+o):p?e=">="+n+".0.0 <"+(+n+1)+".0.0":c&&(e=">="+n+"."+i+".0 <"+n+"."+(+i+1)+".0"),x("xRange return",e),e})}function b(r,e){return x("replaceStars",r,e),r.trim().replace(A[mr],"")}function $(r,e,t,n,i,o,s,a,p,c,u,h,f){return e=m(t)?"":m(n)?">="+t+".0.0":m(i)?">="+t+"."+n+".0":">="+e,a=m(p)?"":m(c)?"<"+(+p+1)+".0.0":m(u)?"<"+p+"."+(+c+1)+".0":h?"<="+p+"."+c+"."+u+"-"+h:"<="+a,(e+" "+a).trim()}function k(r,e){for(t=0;t0){var n=r[t].semver;if(n.major===e.major&&n.minor===e.minor&&n.patch===e.patch)return!0}}return!1}return!0}function R(r,e,t){try{e=new l(e,t)}catch(r){return!1}return e.test(r)}function S(r,t,n,i){r=new e(r,i),t=new l(t,i);var a,p,h,f,v;switch(n){case">":a=o,p=u,h=s,f=">",v=">=";break;case"<":a=s,p=c,h=o,f="<",v="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(R(r,t,i))return!1;for(var m=0;m)?=?)";var K=N++;C[K]=C[_]+"|x|X|\\*";var Q=N++;C[Q]=C[M]+"|x|X|\\*";var W=N++;C[W]="[v=\\s]*("+C[Q]+")(?:\\.("+C[Q]+")(?:\\.("+C[Q]+")(?:"+C[P]+")?"+C[B]+"?)?)?";var Y=N++;C[Y]="[v=\\s]*("+C[K]+")(?:\\.("+C[K]+")(?:\\.("+C[K]+")(?:"+C[Z]+")?"+C[B]+"?)?)?";var rr=N++;C[rr]="^"+C[J]+"\\s*"+C[W]+"$";var er=N++;C[er]="^"+C[J]+"\\s*"+C[Y]+"$";var tr=N++;C[tr]="(?:~>?)";var nr=N++;C[nr]="(\\s*)"+C[tr]+"\\s+",A[nr]=new RegExp(C[nr],"g");var ir=N++;C[ir]="^"+C[tr]+C[W]+"$";var or=N++;C[or]="^"+C[tr]+C[Y]+"$";var sr=N++;C[sr]="(?:\\^)";var ar=N++;C[ar]="(\\s*)"+C[sr]+"\\s+",A[ar]=new RegExp(C[ar],"g");var pr=N++;C[pr]="^"+C[sr]+C[W]+"$";var cr=N++;C[cr]="^"+C[sr]+C[Y]+"$";var ur=N++;C[ur]="^"+C[J]+"\\s*("+F+")$|^$";var hr=N++;C[hr]="^"+C[J]+"\\s*("+U+")$|^$";var fr=N++;C[fr]="(\\s*)"+C[J]+"\\s*("+F+"|"+C[W]+")",A[fr]=new RegExp(C[fr],"g");var lr=N++;C[lr]="^\\s*("+C[W]+")\\s+-\\s+("+C[W]+")\\s*$";var vr=N++;C[vr]="^\\s*("+C[Y]+")\\s+-\\s+("+C[Y]+")\\s*$";var mr=N++;C[mr]="(<|>)?=?\\s*\\*";for(var gr=0;gr'},e.prototype.toString=function(){return this.version},e.prototype.compare=function(r){return x("SemVer.compare",this.version,this.loose,r),r instanceof e||(r=new e(r,this.loose)),this.compareMain(r)||this.comparePre(r)},e.prototype.compareMain=function(r){return r instanceof e||(r=new e(r,this.loose)),t(this.major,r.major)||t(this.minor,r.minor)||t(this.patch,r.patch)},e.prototype.comparePre=function(r){if(r instanceof e||(r=new e(r,this.loose)),this.prerelease.length&&!r.prerelease.length)return-1;if(!this.prerelease.length&&r.prerelease.length)return 1;if(!this.prerelease.length&&!r.prerelease.length)return 0;var n=0;do{var i=this.prerelease[n],o=r.prerelease[n];if(x("prerelease compare",n,i,o),void 0===i&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===i)return-1;if(i!==o)return t(i,o)}while(++n)},e.prototype.inc=function(r,e){switch(r){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",e);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",e);break;case"prepatch":this.prerelease.length=0,this.inc("patch",e),this.inc("pre",e);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",e),this.inc("pre",e);break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":if(0===this.prerelease.length)this.prerelease=[0];else{for(var t=this.prerelease.length;--t>=0;)"number"==typeof this.prerelease[t]&&(this.prerelease[t]++,t=-2);-1===t&&this.prerelease.push(0)}e&&(this.prerelease[0]===e?isNaN(this.prerelease[1])&&(this.prerelease=[e,0]):this.prerelease=[e,0]);break;default:throw new Error("invalid increment argument: "+r)}return this.format(),this},I.inc=function(r,t,n,i){"string"==typeof n&&(i=n,n=void 0);try{return new e(r,n).inc(t,i).version}catch(r){return null}},I.diff=function(e,t){if(a(e,t))return null;var n=r(e),i=r(t);if(n.prerelease.length||i.prerelease.length){for(var o in n)if(("major"===o||"minor"===o||"patch"===o)&&n[o]!==i[o])return"pre"+o;return"prerelease"}for(var o in n)if(("major"===o||"minor"===o||"patch"===o)&&n[o]!==i[o])return o},I.compareIdentifiers=t;var wr=/^[0-9]+$/;I.rcompareIdentifiers=function(r,e){return t(e,r)},I.major=function(r,t){return new e(r,t).major},I.minor=function(r,t){return new e(r,t).minor},I.patch=function(r,t){return new e(r,t).patch},I.compare=n,I.compareLoose=function(r,e){return n(r,e,!0)},I.rcompare=i,I.sort=function(r,e){return r.sort(function(r,t){return I.compare(r,t,e)})},I.rsort=function(r,e){return r.sort(function(r,t){return I.rcompare(r,t,e)})},I.gt=o,I.lt=s,I.eq=a,I.neq=p,I.gte=c,I.lte=u,I.cmp=h,I.Comparator=f;var yr={};f.prototype.parse=function(r){var t=this.loose?A[ur]:A[hr],n=r.match(t);if(!n)throw new TypeError("Invalid comparator: "+r);this.operator=n[1],"="===this.operator&&(this.operator=""),n[2]?this.semver=new e(n[2],this.loose):this.semver=yr},f.prototype.inspect=function(){return''},f.prototype.toString=function(){return this.value},f.prototype.test=function(r){return x("Comparator.test",r,this.loose),this.semver===yr||("string"==typeof r&&(r=new e(r,this.loose)),h(r,this.operator,this.semver,this.loose))},I.Range=l,l.prototype.inspect=function(){return''},l.prototype.format=function(){return this.range=this.set.map(function(r){return r.join(" ").trim()}).join("||").trim(),this.range},l.prototype.toString=function(){return this.range},l.prototype.parseRange=function(r){var e=this.loose;r=r.trim(),x("range",r,e);var t=e?A[vr]:A[lr];r=r.replace(t,$),x("hyphen replace",r),r=r.replace(A[fr],"$1$2$3"),x("comparator trim",r,A[fr]),r=(r=(r=r.replace(A[nr],"$1~")).replace(A[ar],"$1^")).split(/\s+/).join(" ");var n=e?A[ur]:A[hr],i=r.split(" ").map(function(r){return v(r,e)}).join(" ").split(/\s+/);return this.loose&&(i=i.filter(function(r){return!!r.match(n)})),i=i.map(function(r){return new f(r,e)})},I.toComparators=function(r,e){return new l(r,e).set.map(function(r){return r.map(function(r){return r.value}).join(" ").trim().split(" ")})},l.prototype.test=function(r){if(!r)return!1;"string"==typeof r&&(r=new e(r,this.loose));for(var t=0;t",t)},I.outside=S,"function"==typeof define&&define.amd&&define(I)}(); \ No newline at end of file diff --git a/dist/js/jquery.tablesorter.combined.js b/dist/js/jquery.tablesorter.combined.js index 574d798c0..d44ce1d32 100644 --- a/dist/js/jquery.tablesorter.combined.js +++ b/dist/js/jquery.tablesorter.combined.js @@ -1,4 +1,4 @@ -/*! tablesorter (FORK) - updated 07-04-2017 (v2.28.15)*/ +/*! tablesorter (FORK) - updated 07-17-2017 (v2.28.15)*/ /* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */ (function(factory) { if (typeof define === 'function' && define.amd) { @@ -31,2848 +31,2849 @@ */ /*jshint browser:true, jquery:true, unused:false, expr: true */ ;( function( $ ) { - 'use strict'; - var ts = $.tablesorter = { - - version : '2.28.15', - - 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} = // 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 ( c.debug ) { - 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 ( c.debug ) { - 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; - 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 ) { - 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 ( c.debug ) { - console.log( 'Overall initialization time:' + ts.benchmark( $.data( table, 'startoveralltimer' ) ) ); - if ( c.debug && 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, init ) { - e.stopPropagation(); - // apply widgets - ts.applyWidget( this, init ); - }) - .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 = $.fn.closest ? $headers.closest( 'table' )[ 0 ] : $headers.parents( 'table' )[ 0 ]; - if ( tmp && tmp.nodeName === 'TABLE' && tmp !== table ) { - $( tmp ).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; - // 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 || - // elements within a button - $target.parents( 'button' ).length > 0 ) { - return !c.cancelSelection; - } - if ( c.delayInit && ts.isEmptyObject( c.cache ) ) { - ts.buildCache( c ); - } - // jQuery v1.2.6 doesn't have closest() - $cell = $.fn.closest ? $( this ).closest( 'th, td' ) : - /TH|TD/.test( this.nodeName ) ? $( this ) : $( this ).parents( 'th, td' ); - // reference original table headers and find the same cell - // don't use $headers or IE8 throws an error - see #987 - temp = $headers.index( $cell ); - c.last.clickedIndex = ( temp < 0 ) ? $cell.attr( 'data-column' ) : temp; - // use column index if $headers is undefined - cell = c.$headers[ c.last.clickedIndex ]; - 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 ( c.debug ) { - 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 ? - '' : - ''; - // 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 ( $elem.parent().hasClass( c.cssIgnoreRow ) ) { return; } - // 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( '
' + template + '
' ); // 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 - }; - 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; - // add to parent in case there are multiple rows - $elem - .addClass( ts.css.header + ' ' + c.cssHeader ) - .parent() - .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 ] = {}; - } - $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 ( c.debug ) { - 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 = {}; - // 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 c.debug ? console.warn( 'Warning: *Empty table!* Not building a parser cache' ) : ''; - } else if ( c.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 ( c.debug ) { - debug[ '(' + 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 ( c.debug ) { - if ( !ts.isEmptyObject( debug ) ) { - console[ console.table ? 'table' : 'log' ]( debug ); - } 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 */ - 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 = '', - 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 ( c.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; - // 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 c.debug ? console.warn( 'Warning: *Empty table!* Not building a cache' ) : ''; - } - if ( c.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 && c.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 ( c.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 ( c.debug ) { - 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' ], - // 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 + c.$headers[ i ].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 ) { - $sorted - .eq( column ) - .removeClass( none ) - .addClass( css[ list[ indx ][ 1 ] ] ) - .attr( 'aria-sort', aria[ list[ indx ][ 1 ] ] ) - .find( '.' + ts.css.icon ) - .removeClass( cssIcon[ 2 ] ) - .addClass( cssIcon[ list[ indx ][ 1 ] ] ); - } - } - // add sorted class to footer & extra headers, if they exist - if ( $extras.length ) { - $extras - .filter( '[data-column="' + list[ indx ][ 0 ] + '"]' ) - .removeClass( none ) - .addClass( css[ list[ indx ][ 1 ] ] ); - } - } - } - } - // add verbose aria labels - len = c.$headers.length; - for ( indx = 0; indx < len; indx++ ) { - ts.setColumnAriaLabel( c, c.$headers.eq( indx ) ); - } - }, - - // 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 ); - } - }, - - 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( $.fn.closest ? $cell.closest( 'tbody' ) : $cell.parents( 'tbody' ).filter( ':first' ) ), - tbcache = c.cache[ tbodyIndex ], - $row = $.fn.closest ? $cell.closest( 'tr' ) : $cell.parents( 'tr' ).filter( ':first' ); - 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 ( c.debug ) { - 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 && / 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, - wo = c.widgetOptions, - $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 ( c.debug ) { - 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 || !wo.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 ( c.debug ) { - 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, - // get current column index - col = parseInt( $( cell ).attr( 'data-column' ), 10 ), - order = c.sortVars[ col ].order; - - // 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 ) { - // 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 ]; - } - } - } - // add column to sort list - dir = order[ c.sortVars[ col ].count ]; - if ( dir < 2 ) { - c.sortList[ c.sortList.length ] = [ col, dir ]; - // add other columns if header spans across multiple - if ( cell.colSpan > 1 ) { - for ( indx = 1; indx < cell.colSpan; indx++ ) { - c.sortList[ c.sortList.length ] = [ col + indx, dir ]; - // update count on columns in colSpan - c.sortVars[ col + indx ].count = $.inArray( dir, order ); - } - } - } - // 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 - 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 ]; - if ( dir < 2 ) { - c.sortList[ c.sortList.length ] = [ col, dir ]; - // add other columns if header spans across multiple - if ( cell.colSpan > 1 ) { - for ( indx = 1; indx < cell.colSpan; indx++ ) { - c.sortList[ c.sortList.length ] = [ col + indx, dir ]; - // update count on columns in colSpan - c.sortVars[ col + indx ].count = $.inArray( dir, order ); - } - } - } - } - } - // 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 ]; - } - } - } - } - // 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 ( c.debug ) { 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 ( c.debug ) { - 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 table = c.table; - c.$table.triggerHandler( 'sortStart', table ); - // 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 = []; - ts.setHeadersCss( c ); - ts.multisort( c ); - ts.appendCache( c ); - var indx; - for (indx = 0; indx < c.columns; indx++) { - c.sortVars[ indx ].count = -1; - } - 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, - 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 ( c.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 ( c.debug ) { - console[ console.group ? 'group' : 'log' ]( 'Initializing ' + name + ' widget' ); - } - widget.init( table, widget, c, wo ); - } - } - if ( !init && typeof widget.format === 'function' ) { - applied = true; - if ( c.debug ) { - console[ console.group ? 'group' : 'log' ]( 'Updating ' + name + ' widget' ); - } - widget.format( table, c, wo, false ); - } - if ( c.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, - widgets = []; - // prevent numerous consecutive widget applications - if ( init !== false && table.hasInitialized && ( table.isApplyingWidgets || table.isUpdating ) ) { - return; - } - if ( c.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 ( c.debug ) { - console.warn( '"' + names[ indx ] + '" widget code does not exist!' ); - } - } - // 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 ( c.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 ( c.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 ( c.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 ( c.debug ) { - console.log( ( refreshing ? 'Refreshing' : 'Removing' ) + ' "' + name[ index ] + '" widget' ); - } - widget.remove( table, c, c.widgetOptions, refreshing ); - c.widgetInit[ name[ index ] ] = false; - } - } - }, - - 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 ); - }, - - // $.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 = $( '' ); - 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( $( '' ).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.filter( '[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( '' ); - 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 ( c.debug ) { - 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 ( c.debug ) { - 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, - debug = c.debug, - $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 ( debug ) { - 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, table ) { - 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, table ) { - 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, table ) { - // 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 - } - } - }); + 'use strict'; + var ts = $.tablesorter = { + + version : '2.28.15', + + 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} = // 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 ( c.debug ) { + 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 ( c.debug ) { + 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; + 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 ) { + 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 ( c.debug ) { + console.log( 'Overall initialization time:' + ts.benchmark( $.data( table, 'startoveralltimer' ) ) ); + if ( c.debug && 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, init ) { + e.stopPropagation(); + // apply widgets + ts.applyWidget( this, init ); + }) + .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 = $.fn.closest ? $headers.closest( 'table' )[ 0 ] : $headers.parents( 'table' )[ 0 ]; + if ( tmp && tmp.nodeName === 'TABLE' && tmp !== table ) { + $( tmp ).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; + // 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 || + // elements within a button + $target.parents( 'button' ).length > 0 ) { + return !c.cancelSelection; + } + if ( c.delayInit && ts.isEmptyObject( c.cache ) ) { + ts.buildCache( c ); + } + // jQuery v1.2.6 doesn't have closest() + $cell = $.fn.closest ? $( this ).closest( 'th, td' ) : + /TH|TD/.test( this.nodeName ) ? $( this ) : $( this ).parents( 'th, td' ); + // reference original table headers and find the same cell + // don't use $headers or IE8 throws an error - see #987 + temp = $headers.index( $cell ); + c.last.clickedIndex = ( temp < 0 ) ? $cell.attr( 'data-column' ) : temp; + // use column index if $headers is undefined + cell = c.$headers[ c.last.clickedIndex ]; + 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 ( c.debug ) { + 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 ? + '' : + ''; + // 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 ( $elem.parent().hasClass( c.cssIgnoreRow ) ) { return; } + // 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( '
' + template + '
' ); // 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 + }; + 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; + // add to parent in case there are multiple rows + $elem + .addClass( ts.css.header + ' ' + c.cssHeader ) + .parent() + .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 ] = {}; + } + $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 ( c.debug ) { + 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 = {}; + // 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 c.debug ? console.warn( 'Warning: *Empty table!* Not building a parser cache' ) : ''; + } else if ( c.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 ( c.debug ) { + debug[ '(' + 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 ( c.debug ) { + if ( !ts.isEmptyObject( debug ) ) { + console[ console.table ? 'table' : 'log' ]( debug ); + } 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 */ + 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 = '', + 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 ( c.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; + // 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 c.debug ? console.warn( 'Warning: *Empty table!* Not building a cache' ) : ''; + } + if ( c.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 && c.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 ( c.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 ( c.debug ) { + 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' ], + // 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 + c.$headers[ i ].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 ) { + $sorted + .eq( column ) + .removeClass( none ) + .addClass( css[ list[ indx ][ 1 ] ] ) + .attr( 'aria-sort', aria[ list[ indx ][ 1 ] ] ) + .find( '.' + ts.css.icon ) + .removeClass( cssIcon[ 2 ] ) + .addClass( cssIcon[ list[ indx ][ 1 ] ] ); + } + } + // add sorted class to footer & extra headers, if they exist + if ( $extras.length ) { + $extras + .filter( '[data-column="' + list[ indx ][ 0 ] + '"]' ) + .removeClass( none ) + .addClass( css[ list[ indx ][ 1 ] ] ); + } + } + } + } + // add verbose aria labels + len = c.$headers.length; + for ( indx = 0; indx < len; indx++ ) { + ts.setColumnAriaLabel( c, c.$headers.eq( indx ) ); + } + }, + + // 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 ); + } + }, + + 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( $.fn.closest ? $cell.closest( 'tbody' ) : $cell.parents( 'tbody' ).filter( ':first' ) ), + tbcache = c.cache[ tbodyIndex ], + $row = $.fn.closest ? $cell.closest( 'tr' ) : $cell.parents( 'tr' ).filter( ':first' ); + 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 ( c.debug ) { + 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 && / 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, + wo = c.widgetOptions, + $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 ( c.debug ) { + 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 || !wo.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 ( c.debug ) { + 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, + // get current column index + col = parseInt( $( cell ).attr( 'data-column' ), 10 ), + order = c.sortVars[ col ].order; + + // 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 ) { + // 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 ]; + } + } + } + // add column to sort list + dir = order[ c.sortVars[ col ].count ]; + if ( dir < 2 ) { + c.sortList[ c.sortList.length ] = [ col, dir ]; + // add other columns if header spans across multiple + if ( cell.colSpan > 1 ) { + for ( indx = 1; indx < cell.colSpan; indx++ ) { + c.sortList[ c.sortList.length ] = [ col + indx, dir ]; + // update count on columns in colSpan + c.sortVars[ col + indx ].count = $.inArray( dir, order ); + } + } + } + // 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 + 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 ]; + if ( dir < 2 ) { + c.sortList[ c.sortList.length ] = [ col, dir ]; + // add other columns if header spans across multiple + if ( cell.colSpan > 1 ) { + for ( indx = 1; indx < cell.colSpan; indx++ ) { + c.sortList[ c.sortList.length ] = [ col + indx, dir ]; + // update count on columns in colSpan + c.sortVars[ col + indx ].count = $.inArray( dir, order ); + } + } + } + } + } + // 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 ]; + } + } + } + } + // 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 ( c.debug ) { 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 ( c.debug ) { + 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 table = c.table; + c.$table.triggerHandler( 'sortStart', table ); + // 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 = []; + ts.setHeadersCss( c ); + ts.multisort( c ); + ts.appendCache( c ); + var indx; + for (indx = 0; indx < c.columns; indx++) { + c.sortVars[ indx ].count = -1; + } + 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, + 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 ( c.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 ( c.debug ) { + console[ console.group ? 'group' : 'log' ]( 'Initializing ' + name + ' widget' ); + } + widget.init( table, widget, c, wo ); + } + } + if ( !init && typeof widget.format === 'function' ) { + applied = true; + if ( c.debug ) { + console[ console.group ? 'group' : 'log' ]( 'Updating ' + name + ' widget' ); + } + widget.format( table, c, wo, false ); + } + if ( c.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, + widgets = []; + // prevent numerous consecutive widget applications + if ( init !== false && table.hasInitialized && ( table.isApplyingWidgets || table.isUpdating ) ) { + return; + } + if ( c.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 ( c.debug ) { + console.warn( '"' + names[ indx ] + '" widget code does not exist!' ); + } + } + // 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 ( c.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 ( c.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 ( c.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 ( c.debug ) { + 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 ); + }, + + // $.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 = $( '' ); + 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( $( '' ).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.filter( '[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( '' ); + 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 ( c.debug ) { + 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 ( c.debug ) { + 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, + debug = c.debug, + $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 ( debug ) { + 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, table ) { + 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, table ) { + 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, table ) { + // 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 ); diff --git a/dist/js/jquery.tablesorter.combined.min.js b/dist/js/jquery.tablesorter.combined.min.js index fb08df4ef..17747bfe2 100644 --- a/dist/js/jquery.tablesorter.combined.min.js +++ b/dist/js/jquery.tablesorter.combined.min.js @@ -1,2 +1,2 @@ -/*! tablesorter (FORK) - updated 07-04-2017 (v2.28.15)*/ -!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(t){"use strict";var r=t.tablesorter={version:"2.28.15",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(e,a){if(e&&e.tHead&&0!==e.tBodies.length&&!0!==e.hasInitialized){var i="",s=t(e),o=t.metadata;e.hasInitialized=!1,e.isProcessing=!0,e.config=a,t.data(e,"tablesorter",a),a.debug&&(console[console.group?"group":"log"]("Initializing tablesorter v"+r.version),t.data(e,"startoveralltimer",new Date)),a.supportsDataObject=function(e){return e[0]=parseInt(e[0],10),e[0]>1||1===e[0]&&parseInt(e[1],10)>=4}(t.fn.jquery.split(".")),a.emptyTo=a.emptyTo.toLowerCase(),a.stringTo=a.stringTo.toLowerCase(),a.last={sortList:[],clickedIndex:-1},/tablesorter\-/.test(s.attr("class"))||(i=""!==a.theme?" tablesorter-"+a.theme:""),a.namespace?a.namespace="."+a.namespace.replace(r.regex.nonWord,""):a.namespace=".tablesorter"+Math.random().toString(16).slice(2),a.table=e,a.$table=s.addClass(r.css.table+" "+a.tableClass+i+" "+a.namespace.slice(1)).attr("role","grid"),a.$headers=s.find(a.selectorHeaders),a.$table.children().children("tr").attr("role","row"),a.$tbodies=s.children("tbody:not(."+a.cssInfoBlock+")").attr({"aria-live":"polite","aria-relevant":"all"}),a.$table.children("caption").length&&((i=a.$table.children("caption")[0]).id||(i.id=a.namespace.slice(1)+"caption"),a.$table.attr("aria-labelledby",i.id)),a.widgetInit={},a.textExtraction=a.$table.attr("data-text-extraction")||a.textExtraction||"basic",r.buildHeaders(a),r.fixColumnWidth(e),r.addWidgetFromClass(e),r.applyWidgetOptions(e),r.setupParsers(a),a.totalRows=0,r.validateOptions(a),a.delayInit||r.buildCache(a),r.bindEvents(e,a.$headers,!0),r.bindMethods(a),a.supportsDataObject&&void 0!==s.data().sortlist?a.sortList=s.data().sortlist:o&&s.metadata()&&s.metadata().sortlist&&(a.sortList=s.metadata().sortlist),r.applyWidget(e,!0),a.sortList.length>0?r.sortOn(a,a.sortList,{},!a.initWidgets):(r.setHeadersCss(a),a.initWidgets&&r.applyWidget(e,!1)),a.showProcessing&&s.unbind("sortBegin"+a.namespace+" sortEnd"+a.namespace).bind("sortBegin"+a.namespace+" sortEnd"+a.namespace,function(t){clearTimeout(a.timerProcessing),r.isProcessing(e),"sortBegin"===t.type&&(a.timerProcessing=setTimeout(function(){r.isProcessing(e,!0)},500))}),e.hasInitialized=!0,e.isProcessing=!1,a.debug&&(console.log("Overall initialization time:"+r.benchmark(t.data(e,"startoveralltimer"))),a.debug&&console.groupEnd&&console.groupEnd()),s.triggerHandler("tablesorter-initialized",e),"function"==typeof a.initialized&&a.initialized(e)}else a.debug&&(e.hasInitialized?console.warn("Stopping initialization. Tablesorter has already been initialized"):console.error("Stopping initialization! No table, thead or tbody",e))},bindMethods:function(e){var a=e.$table,i=e.namespace,s="sortReset update updateRows updateAll updateHeaders addRows updateCell updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave ".split(" ").join(i+" ");a.unbind(s.replace(r.regex.spaces," ")).bind("sortReset"+i,function(e,t){e.stopPropagation(),r.sortReset(this.config,function(e){e.isApplyingWidgets?setTimeout(function(){r.applyWidget(e,"",t)},100):r.applyWidget(e,"",t)})}).bind("updateAll"+i,function(e,t,a){e.stopPropagation(),r.updateAll(this.config,t,a)}).bind("update"+i+" updateRows"+i,function(e,t,a){e.stopPropagation(),r.update(this.config,t,a)}).bind("updateHeaders"+i,function(e,t){e.stopPropagation(),r.updateHeaders(this.config,t)}).bind("updateCell"+i,function(e,t,a,i){e.stopPropagation(),r.updateCell(this.config,t,a,i)}).bind("addRows"+i,function(e,t,a,i){e.stopPropagation(),r.addRows(this.config,t,a,i)}).bind("updateComplete"+i,function(){this.isUpdating=!1}).bind("sorton"+i,function(e,t,a,i){e.stopPropagation(),r.sortOn(this.config,t,a,i)}).bind("appendCache"+i,function(e,a,i){e.stopPropagation(),r.appendCache(this.config,i),t.isFunction(a)&&a(this)}).bind("updateCache"+i,function(e,t,a){e.stopPropagation(),r.updateCache(this.config,t,a)}).bind("applyWidgetId"+i,function(e,t){e.stopPropagation(),r.applyWidgetId(this,t)}).bind("applyWidgets"+i,function(e,t){e.stopPropagation(),r.applyWidget(this,t)}).bind("refreshWidgets"+i,function(e,t,a){e.stopPropagation(),r.refreshWidgets(this,t,a)}).bind("removeWidget"+i,function(e,t,a){e.stopPropagation(),r.removeWidget(this,t,a)}).bind("destroy"+i,function(e,t,a){e.stopPropagation(),r.destroy(this,t,a)}).bind("resetToLoadState"+i,function(a){a.stopPropagation(),r.removeWidget(this,!0,!1);var i=t.extend(!0,{},e.originalSettings);(e=t.extend(!0,{},r.defaults,i)).originalSettings=i,this.hasInitialized=!1,r.setup(this,e)})},bindEvents:function(e,a,i){var s,o=(e=t(e)[0]).config,n=o.namespace,l=null;!0!==i&&(a.addClass(n.slice(1)+"_extra_headers"),(s=t.fn.closest?a.closest("table")[0]:a.parents("table")[0])&&"TABLE"===s.nodeName&&s!==e&&t(s).addClass(n.slice(1)+"_extra_table")),s=(o.pointerDown+" "+o.pointerUp+" "+o.pointerClick+" sort keyup ").replace(r.regex.spaces," ").split(" ").join(n+" "),a.find(o.selectorSort).add(a.filter(o.selectorSort)).unbind(s).bind(s,function(e,i){var s,n,c,d=t(e.target),f=" "+e.type+" ";if(!(1!==(e.which||e.button)&&!f.match(" "+o.pointerClick+" | sort | keyup ")||" keyup "===f&&e.which!==r.keyCodes.enter||f.match(" "+o.pointerClick+" ")&&void 0!==e.which||f.match(" "+o.pointerUp+" ")&&l!==e.target&&!0!==i)){if(f.match(" "+o.pointerDown+" "))return l=e.target,void("1"===(c=d.jquery.split("."))[0]&&c[1]<4&&e.preventDefault());if(l=null,r.regex.formElements.test(e.target.nodeName)||d.hasClass(o.cssNoSort)||d.parents("."+o.cssNoSort).length>0||d.parents("button").length>0)return!o.cancelSelection;o.delayInit&&r.isEmptyObject(o.cache)&&r.buildCache(o),s=t.fn.closest?t(this).closest("th, td"):/TH|TD/.test(this.nodeName)?t(this):t(this).parents("th, td"),c=a.index(s),o.last.clickedIndex=c<0?s.attr("data-column"):c,(n=o.$headers[o.last.clickedIndex])&&!n.sortDisabled&&r.initSort(o,n,e)}}),o.cancelSelection&&a.attr("unselectable","on").bind("selectstart",!1).css({"user-select":"none",MozUserSelect:"none"})},buildHeaders:function(e){var a,i,s,o;for(e.headerList=[],e.headerContent=[],e.sortVars=[],e.debug&&(s=new Date),e.columns=r.computeColumnIndex(e.$table.children("thead, tfoot").children("tr")),i=e.cssIcon?'':"",e.$headers=t(t.map(e.$table.find(e.selectorHeaders),function(a,s){var o,n,l,c,d,f=t(a);if(!f.parent().hasClass(e.cssIgnoreRow))return o=r.getColumnData(e.table,e.headers,s,!0),e.headerContent[s]=f.html(),""===e.headerTemplate||f.find("."+r.css.headerIn).length||(c=e.headerTemplate.replace(r.regex.templateContent,f.html()).replace(r.regex.templateIcon,f.find("."+r.css.icon).length?"":i),e.onRenderTemplate&&(n=e.onRenderTemplate.apply(f,[s,c]))&&"string"==typeof n&&(c=n),f.html('
'+c+"
")),e.onRenderHeader&&e.onRenderHeader.apply(f,[s,e,e.$table]),l=parseInt(f.attr("data-column"),10),a.column=l,d=r.getOrder(r.getData(f,o,"sortInitialOrder")||e.sortInitialOrder),e.sortVars[l]={count:-1,order:d?e.sortReset?[1,0,2]:[1,0]:e.sortReset?[0,1,2]:[0,1],lockedOrder:!1},void 0!==(d=r.getData(f,o,"lockedOrder")||!1)&&!1!==d&&(e.sortVars[l].lockedOrder=!0,e.sortVars[l].order=r.getOrder(d)?[1,1]:[0,0]),e.headerList[s]=a,f.addClass(r.css.header+" "+e.cssHeader).parent().addClass(r.css.headerRow+" "+e.cssHeaderRow).attr("role","row"),e.tabIndex&&f.attr("tabindex",0),a})),e.$headerIndexed=[],o=0;o0))for(n+=s,o+=s;s+1>0;)i.parsers[n-s]=u,i.extractors[n-s]=g,s--;n++}y+=i.parsers.length?m:1}e.debug&&(r.isEmptyObject(w)?console.warn(" No parsers detected!"):console[console.table?"table":"log"](w),console.log("Completed detecting parsers"+r.benchmark(p)),console.groupEnd&&console.groupEnd()),e.parsers=i.parsers,e.extractors=i.extractors},addParser:function(e){var t,a=r.parsers.length,i=!0;for(t=0;t=0;)if((o=r.parsers[c])&&"text"!==o.id&&o.is&&o.is(f,e.table,d,n))return o;return r.getParserById("text")},getElementText:function(e,a,i){if(!a)return"";var s,o=e.textExtraction||"",n=a.jquery?a:t(a);return"string"==typeof o?"basic"===o&&void 0!==(s=n.attr(e.textAttribute))?t.trim(s):t.trim(a.textContent||n.text()):"function"==typeof o?t.trim(o(n[0],e.table,i)):"function"==typeof(s=r.getColumnData(e.table,o,i))?t.trim(s(n[0],e.table,i)):t.trim(n[0].textContent||n.text())},getParsedText:function(e,t,a,i){void 0===i&&(i=r.getElementText(e,t,a));var s=""+i,o=e.parsers[a],n=e.extractors[a];return o&&(n&&"function"==typeof n.format&&(i=n.format(i,e.table,t,a)),s="no-parser"===o.id?"":o.format(""+i,e.table,t,a),e.ignoreCase&&"string"==typeof s&&(s=s.toLowerCase())),s},buildCache:function(e,a,i){var s,o,n,l,c,d,f,u,g,p,h,m,b,y,w,v,x,C,_,$,S,z,F=e.table,R=e.parsers;if(e.$tbodies=e.$table.children("tbody:not(."+e.cssInfoBlock+")"),f=void 0===i?e.$tbodies:i,e.cache={},e.totalRows=0,!R)return e.debug?console.warn("Warning: *Empty table!* Not building a cache"):"";for(e.debug&&(m=new Date),e.showProcessing&&r.isProcessing(F,!0),d=0;d0&&(C+=x,$+=x)),C++;else{for(y.$row=u,y.order=l,C=0,$=e.columns,c=0;c<$;++c){if((h=u[0].cells[c])&&C0)){for(z=0;z<=x;)n=e.duplicateSpan||0===z?o:"string"!=typeof e.textExtraction?r.getElementText(e,h,C+z)||"":"",y.raw[C+z]=n,g[C+z]=n,z++;C+=x,$+=x}C++}g[e.columns]=y,s.normalized[s.normalized.length]=g}s.colMax=v,e.totalRows+=s.normalized.length}if(e.showProcessing&&r.isProcessing(F),e.debug){for(S=Math.min(5,e.cache[0].normalized.length),console[console.group?"group":"log"]("Building cache for "+e.totalRows+" rows (showing "+S+" rows in log) and "+e.columns+" columns"+r.benchmark(m)),o={},c=0;c-1);return a}),(u=u.not(".sorter-false").filter('[data-column="'+s[a][0]+'"]'+(1===o?":last":""))).length)){for(i=0;i=0?s:o[1]%f.length}},updateAll:function(e,t,a){var i=e.table;i.isUpdating=!0,r.refreshWidgets(i,!0,!0),r.buildHeaders(e),r.bindEvents(i,e.$headers,!0),r.bindMethods(e),r.commonUpdate(e,t,a)},update:function(e,t,a){e.table.isUpdating=!0,r.updateHeader(e),r.commonUpdate(e,t,a)},updateHeaders:function(e,t){e.table.isUpdating=!0,r.buildHeaders(e),r.bindEvents(e.table,e.$headers,!0),r.resortComplete(e,t)},updateCell:function(e,a,i,s){if(t(a).closest("tr").hasClass(e.cssChildRow))console.warn('Tablesorter Warning! "updateCell" for child row content has been disabled, use "update" instead');else{if(r.isEmptyObject(e.cache))return r.updateHeader(e),void r.commonUpdate(e,i,s);e.table.isUpdating=!0,e.$table.find(e.selectorRemove).remove();var o,n,l,c,d,f,u=e.$tbodies,g=t(a),p=u.index(t.fn.closest?g.closest("tbody"):g.parents("tbody").filter(":first")),h=e.cache[p],m=t.fn.closest?g.closest("tr"):g.parents("tr").filter(":first");if(a=g[0],u.length&&p>=0){if(l=u.eq(p).find("tr").not("."+e.cssChildRow).index(m),d=h.normalized[l],(f=m[0].cells.length)!==e.columns)for(c=0,o=!1,n=0;n0&&(h+=w),h++;b[a.columns]=m,a.cache[c].normalized[p]=b}r.checkResort(a,s,o)}},updateCache:function(e,t,a){e.parsers&&e.parsers.length||r.setupParsers(e,a),r.buildCache(e,t,a)},appendCache:function(e,t){var a,i,s,o,n,l,c,d=e.table,f=e.widgetOptions,u=e.$tbodies,g=[],p=e.cache;if(r.isEmptyObject(p))return e.appender?e.appender(d,g):d.isUpdating?e.$table.triggerHandler("updateComplete",d):"";for(e.debug&&(c=new Date),l=0;l1))for(o=1;o=0)for(o=0;o1))for(o=1;oi)return 1}for(a=(e||"").replace(c.chunk,"\\0$1\\0").replace(c.chunks,"").split("\\0"),i=(t||"").replace(c.chunk,"\\0$1\\0").replace(c.chunks,"").split("\\0"),l=Math.max(a.length,i.length),n=0;no)return 1}return 0},sortNaturalAsc:function(e,t,a,i){if(e===t)return 0;var s=r.string[i.empties[a]||i.emptyTo];return""===e&&0!==s?"boolean"==typeof s?s?-1:1:-s||-1:""===t&&0!==s?"boolean"==typeof s?s?1:-1:s||1:r.sortNatural(e,t)},sortNaturalDesc:function(e,t,a,i){if(e===t)return 0;var s=r.string[i.empties[a]||i.emptyTo];return""===e&&0!==s?"boolean"==typeof s?s?-1:1:s||1:""===t&&0!==s?"boolean"==typeof s?s?1:-1:-s||-1:r.sortNatural(t,e)},sortText:function(e,t){return e>t?1:e=0&&!0!==i&&c.widgets.splice(n,1),o&&o.remove&&(c.debug&&console.log((i?"Refreshing":"Removing")+' "'+a[s]+'" widget'),o.remove(e,c,c.widgetOptions,i),c.widgetInit[a[s]]=!1)},refreshWidgets:function(e,a,i){var s,o,n=(e=t(e)[0]).config.widgets,l=r.widgets,c=l.length,d=[],f=function(e){t(e).triggerHandler("refreshComplete")};for(s=0;s'),a=l.$table.width(),o=(s=l.$tbodies.find("tr:first").children(":visible")).length,n=0;n").css("width",i));l.$table.prepend(c)}},getData:function(e,r,a){var i,s,o="",n=t(e);return n.length?(i=!!t.metadata&&n.metadata(),s=" "+(n.attr("class")||""),void 0!==n.data(a)||void 0!==n.data(a.toLowerCase())?o+=n.data(a)||n.data(a.toLowerCase()):i&&void 0!==i[a]?o+=i[a]:r&&void 0!==r[a]?o+=r[a]:" "!==s&&s.match(" "+a+"-")&&(o=s.match(new RegExp("\\s"+a+"-([\\w-]+)"))[1]||""),t.trim(o)):""},getColumnData:function(e,r,a,i,s){if("object"!=typeof r||null===r)return r;var o,n=(e=t(e)[0]).config,l=s||n.$headers,c=n.$headerIndexed&&n.$headerIndexed[a]||l.filter('[data-column="'+a+'"]:last');if(void 0!==r[a])return i?r[a]:r[l.index(c)];for(o in r)if("string"==typeof o&&c.filter(o).add(c.find(o)).length)return r[o]},isProcessing:function(e,a,i){var s=(e=t(e))[0].config,o=i||e.find("."+r.css.header);a?(void 0!==i&&s.sortList.length>0&&(o=o.filter(function(){return!this.sortDisabled&&r.isValueInArray(parseFloat(t(this).attr("data-column")),s.sortList)>=0})),e.add(o).addClass(r.css.processing+" "+s.cssProcessing)):e.add(o).removeClass(r.css.processing+" "+s.cssProcessing)},processTbody:function(e,r,a){if(e=t(e)[0],a)return e.isProcessing=!0,r.before(''),t.fn.detach?r.detach():r.remove();var i=t(e).find("colgroup.tablesorter-savemyplace");r.insertAfter(i),i.remove(),e.isProcessing=!1},clearTableBody:function(e){t(e)[0].config.$tbodies.children().detach()},characterEquivalents:{a:"áàâãäąå",A:"ÁÀÂÃÄĄÅ",c:"çćč",C:"ÇĆČ",e:"éèêëěę",E:"ÉÈÊËĚĘ",i:"íìİîïı",I:"ÍÌİÎÏ",o:"óòôõöō",O:"ÓÒÔÕÖŌ",ss:"ß",SS:"ẞ",u:"úùûüů",U:"ÚÙÛÜŮ"},replaceAccents:function(e){var t,a="[",i=r.characterEquivalents;if(!r.characterRegex){r.characterRegexArray={};for(t in i)"string"==typeof t&&(a+=i[t],r.characterRegexArray[t]=new RegExp("["+i[t]+"]","g"));r.characterRegex=new RegExp(a+"]")}if(r.characterRegex.test(e))for(t in i)"string"==typeof t&&(e=e.replace(r.characterRegexArray[t],t));return e},validateOptions:function(e){var a,i,s,o,n="headers sortForce sortList sortAppend widgets".split(" "),l=e.originalSettings;if(l){e.debug&&(o=new Date);for(a in l)if("undefined"===(s=typeof r.defaults[a]))console.warn('Tablesorter Warning! "table.config.'+a+'" option not recognized');else if("object"===s)for(i in l[a])s=r.defaults[a]&&typeof r.defaults[a][i],t.inArray(a,n)<0&&"undefined"===s&&console.warn('Tablesorter Warning! "table.config.'+a+"."+i+'" option not recognized');e.debug&&console.log("validate options time:"+r.benchmark(o))}},restoreHeaders:function(e){var a,i,s=t(e)[0].config,o=s.$table.find(s.selectorHeaders),n=o.length;for(a=0;a tr").children("th, td");!1===a&&t.inArray("uitheme",n.widgets)>=0&&(o.triggerHandler("applyWidgetId",["uitheme"]),o.triggerHandler("applyWidgetId",["zebra"])),c.find("tr").not(d).remove(),s="sortReset update updateRows updateAll updateHeaders updateCell addRows updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets removeWidget destroy mouseup mouseleave "+"keypress sortBegin sortEnd resetToLoadState ".split(" ").join(n.namespace+" "),o.removeData("tablesorter").unbind(s.replace(r.regex.spaces," ")),n.$headers.add(f).removeClass([r.css.header,n.cssHeader,n.cssAsc,n.cssDesc,r.css.sortAsc,r.css.sortDesc,r.css.sortNone].join(" ")).removeAttr("data-column").removeAttr("aria-label").attr("aria-disabled","true"),d.find(n.selectorSort).unbind("mousedown mouseup keypress ".split(" ").join(n.namespace+" ").replace(r.regex.spaces," ")),r.restoreHeaders(e),o.toggleClass(r.css.table+" "+n.tableClass+" tablesorter-"+n.theme,!1===a),o.removeClass(n.namespace.slice(1)),e.hasInitialized=!1,delete e.config.cache,"function"==typeof i&&i(e),l&&console.log("tablesorter has been removed")}}};t.fn.tablesorter=function(e){return this.each(function(){var a=this,i=t.extend(!0,{},r.defaults,e,r.instanceMethods);i.originalSettings=e,!a.hasInitialized&&r.buildTable&&"TABLE"!==this.nodeName?r.buildTable(a,i):r.setup(a,i)})},window.console&&window.console.log||(r.logs=[],console={},console.log=console.warn=console.error=console.table=function(){var e=arguments.length>1?arguments:arguments[0];r.logs[r.logs.length]={date:Date.now(),log:e}}),r.addParser({id:"no-parser",is:function(){return!1},format:function(){return""},type:"text"}),r.addParser({id:"text",is:function(){return!0},format:function(e,a){var i=a.config;return e&&(e=t.trim(i.ignoreCase?e.toLocaleLowerCase():e),e=i.sortLocaleCompare?r.replaceAccents(e):e),e},type:"text"}),r.regex.nondigit=/[^\w,. \-()]/g,r.addParser({id:"digit",is:function(e){return r.isDigit(e)},format:function(e,a){var i=r.formatFloat((e||"").replace(r.regex.nondigit,""),a);return e&&"number"==typeof i?i:e?t.trim(e&&a.config.ignoreCase?e.toLocaleLowerCase():e):e},type:"numeric"}),r.regex.currencyReplace=/[+\-,. ]/g,r.regex.currencyTest=/^\(?\d+[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]|[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]\d+\)?$/,r.addParser({id:"currency",is:function(e){return e=(e||"").replace(r.regex.currencyReplace,""),r.regex.currencyTest.test(e)},format:function(e,a){var i=r.formatFloat((e||"").replace(r.regex.nondigit,""),a);return e&&"number"==typeof i?i:e?t.trim(e&&a.config.ignoreCase?e.toLocaleLowerCase():e):e},type:"numeric"}),r.regex.urlProtocolTest=/^(https?|ftp|file):\/\//,r.regex.urlProtocolReplace=/(https?|ftp|file):\/\/(www\.)?/,r.addParser({id:"url",is:function(e){return r.regex.urlProtocolTest.test(e)},format:function(e){return e?t.trim(e.replace(r.regex.urlProtocolReplace,"")):e},type:"text"}),r.regex.dash=/-/g,r.regex.isoDate=/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}/,r.addParser({id:"isoDate",is:function(e){return r.regex.isoDate.test(e)},format:function(e,t){var a=e?new Date(e.replace(r.regex.dash,"/")):e;return a instanceof Date&&isFinite(a)?a.getTime():e},type:"numeric"}),r.regex.percent=/%/g,r.regex.percentTest=/(\d\s*?%|%\s*?\d)/,r.addParser({id:"percent",is:function(e){return r.regex.percentTest.test(e)&&e.length<15},format:function(e,t){return e?r.formatFloat(e.replace(r.regex.percent,""),t):e},type:"numeric"}),r.addParser({id:"image",is:function(e,t,r,a){return a.find("img").length>0},format:function(e,r,a){return t(a).find("img").attr(r.config.imgAttr||"alt")||e},parsed:!0,type:"text"}),r.regex.dateReplace=/(\S)([AP]M)$/i,r.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,r.regex.usLongDateTest2=/^\d{1,2}\s+[A-Z]{3,10}\s+\d{4}/i,r.addParser({id:"usLongDate",is:function(e){return r.regex.usLongDateTest1.test(e)||r.regex.usLongDateTest2.test(e)},format:function(e,t){var a=e?new Date(e.replace(r.regex.dateReplace,"$1 $2")):e;return a instanceof Date&&isFinite(a)?a.getTime():e},type:"numeric"}),r.regex.shortDateTest=/(^\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4})|(^\d{4}[\/\s]\d{1,2}[\/\s]\d{1,2})/,r.regex.shortDateReplace=/[\-.,]/g,r.regex.shortDateXXY=/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/,r.regex.shortDateYMD=/(\d{4})[\/\s](\d{1,2})[\/\s](\d{1,2})/,r.convertFormat=function(e,t){e=(e||"").replace(r.regex.spaces," ").replace(r.regex.shortDateReplace,"/"),"mmddyyyy"===t?e=e.replace(r.regex.shortDateXXY,"$3/$1/$2"):"ddmmyyyy"===t?e=e.replace(r.regex.shortDateXXY,"$3/$2/$1"):"yyyymmdd"===t&&(e=e.replace(r.regex.shortDateYMD,"$1/$2/$3"));var a=new Date(e);return a instanceof Date&&isFinite(a)?a.getTime():""},r.addParser({id:"shortDate",is:function(e){return e=(e||"").replace(r.regex.spaces," ").replace(r.regex.shortDateReplace,"/"),r.regex.shortDateTest.test(e)},format:function(e,t,a,i){if(e){var s=t.config,o=s.$headerIndexed[i],n=o.length&&o.data("dateFormat")||r.getData(o,r.getColumnData(t,s.headers,i),"dateFormat")||s.dateFormat;return o.length&&o.data("dateFormat",n),r.convertFormat(e,n)||e}return e},type:"numeric"}),r.regex.timeTest=/^(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)$|^((?:[01]\d|[2][0-4]):[0-5]\d)$/i,r.regex.timeMatch=/(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)|((?:[01]\d|[2][0-4]):[0-5]\d)/i,r.addParser({id:"time",is:function(e){return r.regex.timeTest.test(e)},format:function(e,t){var a,i=(e||"").match(r.regex.timeMatch),s=new Date(e),o=e&&(null!==i?i[0]:"00:00 AM"),n=o?new Date("2000/01/01 "+o.replace(r.regex.dateReplace,"$1 $2")):o;return n instanceof Date&&isFinite(n)?(a=s instanceof Date&&isFinite(s)?s.getTime():0,a?parseFloat(n.getTime()+"."+s.getTime()):n.getTime()):e},type:"numeric"}),r.addParser({id:"metadata",is:function(){return!1},format:function(e,r,a){var i=r.config,s=i.parserMetadataName?i.parserMetadataName:"sortValue";return t(a).metadata()[s]},type:"numeric"}),r.addWidget({id:"zebra",priority:90,format:function(e,r,a){var i,s,o,n,l,c,d,f=new RegExp(r.cssChildRow,"i"),u=r.$tbodies.add(t(r.namespace+"_extra_table").children("tbody:not(."+r.cssInfoBlock+")"));for(l=0;l')}),a.cssIcon&&v.find("."+t.css.icon).removeClass(b?[p.icons,m].join(" "):"").addClass(C.icons||""),t.hasWidget(a.table,"filter")&&(o=function(){w.children("thead").children("."+t.css.filterRow).removeClass(b?p.filterRow||"":"").addClass(C.filterRow||"")},i.filter_initialized?o():w.one("filterInit",function(){o()}))),s=0;s1)))for(u=1;u=]/g,query:"(q|query)",wild01:/\?/g,wild0More:/\*/g,quote:/\"/g,isNeg1:/(>=?\s*-\d)/,isNeg2:/(<=?\s*\d)/},types:{or:function(a,i,s){if((r.orTest.test(i.iFilter)||r.orSplit.test(i.filter))&&!r.regex.test(i.filter)){var o,n,l,c,d=e.extend({},i),f=i.filter.split(r.orSplit),u=i.iFilter.split(r.orSplit),g=f.length;for(o=0;o=f:o>f:r.ltTest.test(s.iFilter)&&(n=r.lteTest.test(s.iFilter)?o<=f:o=0)))}return null},exact:function(a,i){if(r.exact.test(i.iFilter)){var s=i.iFilter.replace(r.exact,""),o=t.parseFilter(a,s,i)||"";return i.anyMatch?e.inArray(o,i.rowArray)>=0:o==i.iExact}return null},range:function(e,i){if(r.toTest.test(i.iFilter)){var s,o,n,l,c=e.table,d=i.index,f=i.parsed[d],u=i.iFilter.split(r.toSplit);return o=u[0].replace(a.regex.nondigit,"")||"",n=a.formatFloat(t.parseFilter(e,o,i),c),o=u[1].replace(a.regex.nondigit,"")||"",l=a.formatFloat(t.parseFilter(e,o,i),c),(f||"numeric"===e.parsers[d].type)&&(n=""===(s=e.parsers[d].format(""+u[0],c,e.$headers.eq(d),d))||isNaN(s)?n:s,l=""===(s=e.parsers[d].format(""+u[1],c,e.$headers.eq(d),d))||isNaN(s)?l:s),!f&&"numeric"!==e.parsers[d].type||isNaN(n)||isNaN(l)?(o=isNaN(i.iExact)?i.iExact.replace(a.regex.nondigit,""):i.iExact,s=a.formatFloat(o,c)):s=i.cache,n>l&&(o=n,n=l,l=o),s>=n&&s<=l||""===n||""===l}return null},wild:function(e,a){if(r.wildOrTest.test(a.iFilter)){var i=""+(t.parseFilter(e,a.iFilter,a)||"");!r.wildTest.test(i)&&a.nestedFilters&&(i=a.isMatch?i:"^("+i+")$");try{return new RegExp(i.replace(r.wild01,"\\S{1}").replace(r.wild0More,"\\S*"),e.widgetOptions.filter_ignoreCase?"i":"").test(a.exact)}catch(e){return null}}return null},fuzzy:function(e,a){if(r.fuzzyTest.test(a.iFilter)){var i,s=0,o=a.iExact.length,n=a.iFilter.slice(1),l=t.parseFilter(e,n,a)||"";for(i=0;i]=?/,gtTest:/>/,gteTest:/>=/,ltTest:/'+(c.data("placeholder")||c.attr("data-placeholder")||h.filter_placeholder.select||"")+"":"",f=n,l=n,n.indexOf(h.filter_selectSourceSeparator)>=0&&(l=(f=n.split(h.filter_selectSourceSeparator))[1],f=f[0]),o+="");p.$table.find("thead").find("select."+i.filter+'[data-column="'+d+'"]').append(o),(u="function"==typeof(l=h.filter_selectSource)||a.getColumnData(s,l,d))&&t.buildSelect(p.table,d,"",!0,c.hasClass(h.filter_onlyAvail))}t.buildDefault(s,!0),t.bindSearch(s,p.$table.find("."+i.filter),!0),h.filter_external&&t.bindSearch(s,h.filter_external),h.filter_hideFilters&&t.hideFilters(p),p.showProcessing&&(l="filterStart filterEnd ".split(" ").join(p.namespace+"filter "),p.$table.unbind(l.replace(a.regex.spaces," ")).bind(l,function(t,r){c=r?p.$table.find("."+i.header).filter("[data-column]").filter(function(){return""!==r[e(this).data("column")]}):"",a.isProcessing(s,"filterStart"===t.type,r?c:"")})),p.filteredRows=p.totalRows,l="tablesorter-initialized pagerBeforeInitialized ".split(" ").join(p.namespace+"filter "),p.$table.unbind(l.replace(a.regex.spaces," ")).bind(l,function(){t.completeInit(this)}),p.pager&&p.pager.initialized&&!h.filter_initialized?(p.$table.triggerHandler("filterFomatterUpdate"),setTimeout(function(){t.filterInitComplete(p)},100)):h.filter_initialized||t.completeInit(s)},completeInit:function(e){var r=e.config,i=r.widgetOptions,s=t.setDefaults(e,r,i)||[];s.length&&(r.delayInit&&""===s.join("")||a.setFilters(e,s,!0)),r.$table.triggerHandler("filterFomatterUpdate"),setTimeout(function(){i.filter_initialized||t.filterInitComplete(r)},100)},formatterUpdated:function(e,t){var r=e&&e.closest("table"),a=r.length&&r[0].config,i=a&&a.widgetOptions;i&&!i.filter_initialized&&(i.filter_formatterInit[t]=1)},filterInitComplete:function(r){var a,i,s=r.widgetOptions,o=0,n=function(){s.filter_initialized=!0,r.lastSearch=r.$table.data("lastSearch"),r.$table.triggerHandler("filterInit",r),t.findRows(r.table,r.lastSearch||[])};if(e.isEmptyObject(s.filter_formatter))n();else{for(i=s.filter_formatterInit.length,a=0;a';for(c=0;c1?'").appendTo(s.$table.children("thead").eq(0)).children("td"),c=0;c").appendTo(n):((p=a.getColumnData(r,o.filter_formatter,c))?(o.filter_formatterCount++,(w=p(n,c))&&0===w.length&&(w=n.children("input")),w&&(0===w.parent().length||w.parent().length&&w.parent()[0]!==n[0])&&n.append(w)):w=e('').appendTo(n),w&&(h=d.data("placeholder")||d.attr("data-placeholder")||o.filter_placeholder.search||"",w.attr("placeholder",h))),w&&(g=(e.isArray(o.filter_cssFilter)?void 0!==o.filter_cssFilter[c]?o.filter_cssFilter[c]||"":"":o.filter_cssFilter)||"",w.addClass(i.filter+" "+g).attr("data-column",n.attr("data-column")),u&&(w.attr("placeholder","").addClass(i.filterDisabled)[0].disabled=!0)))},bindSearch:function(r,i,o){if(r=e(r)[0],(i=e(i)).length){var n,l=r.config,c=l.widgetOptions,d=l.namespace+"filter",f=c.filter_$externalFilters;!0!==o&&(n=c.filter_anyColumnSelector+","+c.filter_multipleColumnSelector,c.filter_$anyMatch=i.filter(n),f&&f.length?c.filter_$externalFilters=c.filter_$externalFilters.add(i):c.filter_$externalFilters=i,a.setFilters(r,l.$table.data("lastSearch")||[],!1===o)),n="keypress keyup keydown search change input ".split(" ").join(d+" "),i.attr("data-lastSearchTime",(new Date).getTime()).unbind(n.replace(a.regex.spaces," ")).bind("keydown"+d,function(e){if(e.which===s.escape&&!r.config.widgetOptions.filter_resetOnEsc)return!1}).bind("keyup"+d,function(i){c=r.config.widgetOptions;var o=parseInt(e(this).attr("data-column"),10),n="boolean"==typeof c.filter_liveSearch?c.filter_liveSearch:a.getColumnData(r,c.filter_liveSearch,o);if(void 0===n&&(n=c.filter_liveSearch.fallback||!1),e(this).attr("data-lastSearchTime",(new Date).getTime()),i.which===s.escape)this.value=c.filter_resetOnEsc?"":l.lastSearch[o];else{if(""!==this.value&&("number"==typeof n&&this.value.length=s.left&&i.which<=s.down)))return;if(!1===n&&""!==this.value&&i.which!==s.enter)return}t.searching(r,!0,!0,o)}).bind("search change keypress input blur ".split(" ").join(d+" "),function(i){var o=parseInt(e(this).attr("data-column"),10),n=i.type,d="boolean"==typeof c.filter_liveSearch?c.filter_liveSearch:a.getColumnData(r,c.filter_liveSearch,o);!r.config.widgetOptions.filter_initialized||i.which!==s.enter&&"search"!==n&&"blur"!==n&&("change"!==n&&"input"!==n||!0!==d&&(!0===d||"INPUT"===i.target.nodeName)||this.value===l.lastSearch[o])||(i.preventDefault(),e(this).attr("data-lastSearchTime",(new Date).getTime()),t.searching(r,"keypress"!==n,!0,o))})}},searching:function(e,r,i,s){var o,n=e.config.widgetOptions;void 0===s?o=!1:void 0===(o="boolean"==typeof n.filter_liveSearch?n.filter_liveSearch:a.getColumnData(e,n.filter_liveSearch,s))&&(o=n.filter_liveSearch.fallback||!1),clearTimeout(n.filter_searchTimer),void 0===r||!0===r?n.filter_searchTimer=setTimeout(function(){t.checkFilters(e,r,i)},o?n.filter_searchDelay:10):t.checkFilters(e,r,i)},equalFilters:function(t,r,a){var i,s=[],o=[],n=t.columns+1;for(r=e.isArray(r)?r:[],a=e.isArray(a)?a:[],i=0;i1?e.trim(t).split(/\s/):[e.trim(t)],n=o.length-1,l=0,c=a;for(n<1&&s>1&&(o[1]=o[0]);i.test(c);)c=c.replace(i,o[l++]||""),i.test(c)&&l(n=parseInt(s[1],10)||e.columns-1)&&(a=o,o=n,n=a),n>=e.columns&&(n=e.columns-1);o<=n;o++)u[u.length]=o;t=t.replace(i[d],"")}if(!r&&/,/.test(t))for(f=(l=t.split(/\s*,\s*/)).length,c=0;c-1})},multipleColumns:function(r,a){var i=r.widgetOptions,s=i.filter_initialized||!a.filter(i.filter_anyColumnSelector).length,o=e.trim(t.getLatestSearch(a).attr("data-column")||"");return t.findRange(r,o,!s)},processTypes:function(r,a,i){var s,o=null,n=null;for(s in t.types)e.inArray(s,i.excludeMatch)<0&&null===n&&null!==(n=t.types[s](r,a,i))&&(o=n);return o},matchType:function(e,t){var r,a=e.widgetOptions,s=e.$headerIndexed[t];return s.hasClass("filter-exact")?r=!1:s.hasClass("filter-match")?r=!0:(a.filter_columnFilters?s=e.$filters.find("."+i.filter).add(a.filter_$externalFilters).filter('[data-column="'+t+'"]'):a.filter_$externalFilters&&(s=a.filter_$externalFilters.filter('[data-column="'+t+'"]')),r=!!s.length&&"match"===e.widgetOptions.filter_matchType[(s[0].nodeName||"").toLowerCase()]),r},processRow:function(i,s,o){var n,l,c,d,f,u=i.widgetOptions,g=!0,p=u.filter_$anyMatch&&u.filter_$anyMatch.length,h=u.filter_$anyMatch&&u.filter_$anyMatch.length?t.multipleColumns(i,u.filter_$anyMatch):[];if(s.$cells=s.$row.children(),s.anyMatchFlag&&h.length>1||s.anyMatchFilter&&!p){if(s.anyMatch=!0,s.isMatch=!0,s.rowArray=s.$cells.map(function(t){if(e.inArray(t,h)>-1||s.anyMatchFilter&&!p)return s.parsed[t]?f=s.cacheArray[t]:(f=s.rawArray[t],f=e.trim(u.filter_ignoreCase?f.toLowerCase():f),i.sortLocaleCompare&&(f=a.replaceAccents(f))),f}).get(),s.filter=s.anyMatchFilter,s.iFilter=s.iAnyMatchFilter,s.exact=s.rowArray.join(" "),s.iExact=u.filter_ignoreCase?s.exact.toLowerCase():s.exact,s.cache=s.cacheArray.slice(0,-1).join(" "),o.excludeMatch=o.noAnyMatch,null!==(l=t.processTypes(i,s,o)))g=l;else if(u.filter_startsWith)for(g=!1,h=Math.min(i.columns,s.rowArray.length);!g&&h>0;)h--,g=g||0===s.rowArray[h].indexOf(s.iFilter);else g=(s.iExact+s.childRowText).indexOf(s.iFilter)>=0;if(s.anyMatch=!1,s.filters.join("")===s.filter)return g}for(h=0;h=0:s.filter===s.exact:(f=(s.iExact+s.childRowText).indexOf(t.parseFilter(i,s.iFilter,s)),n=!u.filter_startsWith&&f>=0||u.filter_startsWith&&0===f):n=l,g=!!n&&g);return g},findRows:function(i,s,o){if(!t.equalFilters(i.config,i.config.lastSearch,o)&&i.config.widgetOptions.filter_initialized){var n,l,c,d,f,u,g,p,h,m,b,y,w,v,x,C,_,$,S,z,F,R,T,I=e.extend([],s),k=i.config,A=k.widgetOptions,D={anyMatch:!1,filters:s,filter_regexCache:[]},H={noAnyMatch:["range","operators"],functions:[],excludeFilter:[],defaultColFilter:[],defaultAnyFilter:a.getColumnData(i,A.filter_defaultFilter,k.columns,!0)||""};for(D.parsed=[],h=0;h1&&(isNaN(F[0])?e.each(k.headerContent,function(e,t){t.toLowerCase().indexOf(F[0])>-1&&(s[R=e]=F[1])}):R=parseInt(F[0],10)-1,R>=0&&R")>=0)return d;if(e.isArray(d))n=d;else if("object"===e.type(l)&&d&&null===(n=d(r,i,s)))return null}return!1===n&&(n=t.getOptions(r,i,s)),t.processOptions(r,i,n)},processOptions:function(t,r,i){if(!e.isArray(i))return!1;var s,o,n,l,c,d,f=(t=e(t)[0]).config,u=void 0!==r&&null!==r&&r>=0&&r'+(y.data("placeholder")||y.attr("data-placeholder")||b.filter_placeholder.select||"")+"",v=m.$table.find("thead").find("select."+i.filter+'[data-column="'+s+'"]').val();if(void 0!==o&&""!==o||null!==(o=t.getOptionSource(a,s,l))){if(e.isArray(o)){for(c=0;c"}else""+h!="[object Object]"&&(d=f=h=(""+h).replace(r.quote,"""),f.indexOf(b.filter_selectSourceSeparator)>=0&&(d=(u=f.split(b.filter_selectSourceSeparator))[0],f=u[1]),w+=""!==h?"":"");o=[]}g=(m.$filters?m.$filters:m.$table.children("thead")).find("."+i.filter),b.filter_$externalFilters&&(g=g&&g.length?g.add(b.filter_$externalFilters):b.filter_$externalFilters),(p=g.filter('select[data-column="'+s+'"]')).length&&(p[n?"html":"append"](w),e.isArray(o)||p.append(o).val(v),p.val(v))}}},buildDefault:function(e,r){var i,s,o,n=e.config,l=n.widgetOptions,c=n.columns;for(i=0;i1&&(c=c.slice(1)),n===u.columns&&(c=(d=c.filter(g.filter_anyColumnSelector)).length?d:c),c.val(s[n]).trigger("change"+u.namespace)):(f[n]=c.val()||"",n===u.columns?c.slice(1).filter('[data-column*="'+c.attr("data-column")+'"]').val(f[n]):c.slice(1).val(f[n])),n===u.columns&&c.length&&(g.filter_$anyMatch=c));return f},a.setFilters=function(r,i,s,o){var n=r?e(r)[0].config:"",l=a.getFilters(r,!0,i,o);return void 0===s&&(s=!0),n&&s&&(n.lastCombinedFilter=null,n.lastSearch=[],t.searching(n.table,i,o),n.$table.triggerHandler("filterFomatterUpdate")),0!==l.length}}(e),function(e,t){"use strict";function r(t,r){var a=isNaN(r.stickyHeaders_offset)?e(r.stickyHeaders_offset):[];return a.length?a.height()||0:parseInt(r.stickyHeaders_offset,10)||0}var a=e.tablesorter||{};e.extend(a.css,{sticky:"tablesorter-stickyHeader",stickyVis:"tablesorter-sticky-visible",stickyHide:"tablesorter-sticky-hidden",stickyWrap:"tablesorter-sticky-wrapper"}),a.addHeaderResizeEvent=function(t,r,a){if((t=e(t)[0]).config){var i={timer:250},s=e.extend({},i,a),o=t.config,n=o.widgetOptions,l=function(e){var t,r,a,i,s,l,c=o.$headers.length;for(n.resize_flag=!0,r=[],t=0;t=0&&!s.$table.hasClass("hasFilters"))){var n,l,c,d,f=s.$table,u=e(o.stickyHeaders_attachTo),g=s.namespace+"stickyheaders ",p=e(o.stickyHeaders_yScroll||o.stickyHeaders_attachTo||t),h=e(o.stickyHeaders_xScroll||o.stickyHeaders_attachTo||t),m=f.children("thead:first").children("tr").not(".sticky-false").children(),b=f.children("tfoot"),y=r(s,o),w=f.parent().closest("."+a.css.table).hasClass("hasStickyHeaders")?f.parent().closest("table.tablesorter")[0].config.widgetOptions.$sticky.parent():[],v=w.length?w.height():0,x=o.$sticky=f.clone().addClass("containsStickyHeaders "+a.css.sticky+" "+o.stickyHeaders+" "+s.namespace.slice(1)+"_extra_table").wrap('
'),C=x.parent().addClass(a.css.stickyHide).css({position:u.length?"absolute":"fixed",padding:parseInt(x.parent().parent().css("padding-left"),10),top:y+v,left:0,visibility:"hidden",zIndex:o.stickyHeaders_zIndex||2}),_=x.children("thead:first"),$="",S=function(e,r){var a,i,s,o,n,l=e.filter(":visible"),c=l.length;for(a=0;ai.top&&m=0&&s.$filters&&s.$filters.eq(i).find("a, select, input").filter(":visible").focus())}),a.filter.bindSearch(f,d.find("."+a.css.filter)),o.filter_hideFilters&&a.filter.hideFilters(s,x)),o.stickyHeaders_addResizeEvent&&f.bind("resize"+s.namespace+"stickyheaders",function(){z()}),F(!0),f.triggerHandler("stickyHeadersInit")}},remove:function(r,i,s){var o=i.namespace+"stickyheaders ";i.$table.removeClass("hasStickyHeaders").unbind("pagerComplete resize filterEnd stickyHeadersUpdate ".split(" ").join(o).replace(/\s+/g," ")).next("."+a.css.stickyWrap).remove(),s.$sticky&&s.$sticky.length&&s.$sticky.remove(),e(t).add(s.stickyHeaders_xScroll).add(s.stickyHeaders_yScroll).add(s.stickyHeaders_attachTo).unbind("scroll resize ".split(" ").join(o).replace(/\s+/g," ")),a.addHeaderResizeEvent(r,!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="";e("head").append(t)}),r.resizable={init:function(t,a){if(!t.$table.hasClass("hasResizable")){t.$table.addClass("hasResizable");var i,s,o,n,l=t.$table,c=l.parent(),d=parseInt(l.css("margin-top"),10),f=a.resizable_vars={useStorage:r.storage&&!1!==a.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=l.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(l,n,!0)),a.resizable_vars.storedSizes=o=(f.useStorage?r.storage(t.table,r.css.resizableStorage):[])||[],r.resizable.setWidths(t,a,o),r.resizable.updateStoredSizes(t,a),a.$resizable_container=e('
').css({top:d}).insertBefore(l),s=0;s').appendTo(a.$resizable_container).attr({"data-column":s,unselectable:"on"}).data("header",i).bind("selectstart",!1);r.resizable.bindings(t,a)}},updateStoredSizes:function(e,t){var r,a,i=e.columns,s=t.resizable_vars;for(s.storedSizes=[],r=0;r0){for(n.storedSizes[n.target]+=d,r.resizable.setWidth(n.$target,n.storedSizes[n.target],!0),s=0;s0?a.sortList=d:r.hasInitialized&&d&&d.length>0&&t.sortOn(a,d))},remove:function(e,r){r.$table.removeClass("hasSaveSort"),t.storage&&t.storage(e,"tablesorter-savesort","")}})}(e),e.tablesorter}); \ No newline at end of file +/*! tablesorter (FORK) - updated 07-17-2017 (v2.28.15)*/ +!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(t){"use strict";var r=t.tablesorter={version:"2.28.15",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(e,a){if(e&&e.tHead&&0!==e.tBodies.length&&!0!==e.hasInitialized){var i="",s=t(e),o=t.metadata;e.hasInitialized=!1,e.isProcessing=!0,e.config=a,t.data(e,"tablesorter",a),a.debug&&(console[console.group?"group":"log"]("Initializing tablesorter v"+r.version),t.data(e,"startoveralltimer",new Date)),a.supportsDataObject=function(e){return e[0]=parseInt(e[0],10),e[0]>1||1===e[0]&&parseInt(e[1],10)>=4}(t.fn.jquery.split(".")),a.emptyTo=a.emptyTo.toLowerCase(),a.stringTo=a.stringTo.toLowerCase(),a.last={sortList:[],clickedIndex:-1},/tablesorter\-/.test(s.attr("class"))||(i=""!==a.theme?" tablesorter-"+a.theme:""),a.namespace?a.namespace="."+a.namespace.replace(r.regex.nonWord,""):a.namespace=".tablesorter"+Math.random().toString(16).slice(2),a.table=e,a.$table=s.addClass(r.css.table+" "+a.tableClass+i+" "+a.namespace.slice(1)).attr("role","grid"),a.$headers=s.find(a.selectorHeaders),a.$table.children().children("tr").attr("role","row"),a.$tbodies=s.children("tbody:not(."+a.cssInfoBlock+")").attr({"aria-live":"polite","aria-relevant":"all"}),a.$table.children("caption").length&&((i=a.$table.children("caption")[0]).id||(i.id=a.namespace.slice(1)+"caption"),a.$table.attr("aria-labelledby",i.id)),a.widgetInit={},a.textExtraction=a.$table.attr("data-text-extraction")||a.textExtraction||"basic",r.buildHeaders(a),r.fixColumnWidth(e),r.addWidgetFromClass(e),r.applyWidgetOptions(e),r.setupParsers(a),a.totalRows=0,r.validateOptions(a),a.delayInit||r.buildCache(a),r.bindEvents(e,a.$headers,!0),r.bindMethods(a),a.supportsDataObject&&void 0!==s.data().sortlist?a.sortList=s.data().sortlist:o&&s.metadata()&&s.metadata().sortlist&&(a.sortList=s.metadata().sortlist),r.applyWidget(e,!0),a.sortList.length>0?r.sortOn(a,a.sortList,{},!a.initWidgets):(r.setHeadersCss(a),a.initWidgets&&r.applyWidget(e,!1)),a.showProcessing&&s.unbind("sortBegin"+a.namespace+" sortEnd"+a.namespace).bind("sortBegin"+a.namespace+" sortEnd"+a.namespace,function(t){clearTimeout(a.timerProcessing),r.isProcessing(e),"sortBegin"===t.type&&(a.timerProcessing=setTimeout(function(){r.isProcessing(e,!0)},500))}),e.hasInitialized=!0,e.isProcessing=!1,a.debug&&(console.log("Overall initialization time:"+r.benchmark(t.data(e,"startoveralltimer"))),a.debug&&console.groupEnd&&console.groupEnd()),s.triggerHandler("tablesorter-initialized",e),"function"==typeof a.initialized&&a.initialized(e)}else a.debug&&(e.hasInitialized?console.warn("Stopping initialization. Tablesorter has already been initialized"):console.error("Stopping initialization! No table, thead or tbody",e))},bindMethods:function(e){var a=e.$table,i=e.namespace,s="sortReset update updateRows updateAll updateHeaders addRows updateCell updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave ".split(" ").join(i+" ");a.unbind(s.replace(r.regex.spaces," ")).bind("sortReset"+i,function(e,t){e.stopPropagation(),r.sortReset(this.config,function(e){e.isApplyingWidgets?setTimeout(function(){r.applyWidget(e,"",t)},100):r.applyWidget(e,"",t)})}).bind("updateAll"+i,function(e,t,a){e.stopPropagation(),r.updateAll(this.config,t,a)}).bind("update"+i+" updateRows"+i,function(e,t,a){e.stopPropagation(),r.update(this.config,t,a)}).bind("updateHeaders"+i,function(e,t){e.stopPropagation(),r.updateHeaders(this.config,t)}).bind("updateCell"+i,function(e,t,a,i){e.stopPropagation(),r.updateCell(this.config,t,a,i)}).bind("addRows"+i,function(e,t,a,i){e.stopPropagation(),r.addRows(this.config,t,a,i)}).bind("updateComplete"+i,function(){this.isUpdating=!1}).bind("sorton"+i,function(e,t,a,i){e.stopPropagation(),r.sortOn(this.config,t,a,i)}).bind("appendCache"+i,function(e,a,i){e.stopPropagation(),r.appendCache(this.config,i),t.isFunction(a)&&a(this)}).bind("updateCache"+i,function(e,t,a){e.stopPropagation(),r.updateCache(this.config,t,a)}).bind("applyWidgetId"+i,function(e,t){e.stopPropagation(),r.applyWidgetId(this,t)}).bind("applyWidgets"+i,function(e,t){e.stopPropagation(),r.applyWidget(this,t)}).bind("refreshWidgets"+i,function(e,t,a){e.stopPropagation(),r.refreshWidgets(this,t,a)}).bind("removeWidget"+i,function(e,t,a){e.stopPropagation(),r.removeWidget(this,t,a)}).bind("destroy"+i,function(e,t,a){e.stopPropagation(),r.destroy(this,t,a)}).bind("resetToLoadState"+i,function(a){a.stopPropagation(),r.removeWidget(this,!0,!1);var i=t.extend(!0,{},e.originalSettings);(e=t.extend(!0,{},r.defaults,i)).originalSettings=i,this.hasInitialized=!1,r.setup(this,e)})},bindEvents:function(e,a,i){var s,o=(e=t(e)[0]).config,n=o.namespace,l=null;!0!==i&&(a.addClass(n.slice(1)+"_extra_headers"),(s=t.fn.closest?a.closest("table")[0]:a.parents("table")[0])&&"TABLE"===s.nodeName&&s!==e&&t(s).addClass(n.slice(1)+"_extra_table")),s=(o.pointerDown+" "+o.pointerUp+" "+o.pointerClick+" sort keyup ").replace(r.regex.spaces," ").split(" ").join(n+" "),a.find(o.selectorSort).add(a.filter(o.selectorSort)).unbind(s).bind(s,function(e,i){var s,n,d,c=t(e.target),f=" "+e.type+" ";if(!(1!==(e.which||e.button)&&!f.match(" "+o.pointerClick+" | sort | keyup ")||" keyup "===f&&e.which!==r.keyCodes.enter||f.match(" "+o.pointerClick+" ")&&void 0!==e.which||f.match(" "+o.pointerUp+" ")&&l!==e.target&&!0!==i)){if(f.match(" "+o.pointerDown+" "))return l=e.target,void("1"===(d=c.jquery.split("."))[0]&&d[1]<4&&e.preventDefault());if(l=null,r.regex.formElements.test(e.target.nodeName)||c.hasClass(o.cssNoSort)||c.parents("."+o.cssNoSort).length>0||c.parents("button").length>0)return!o.cancelSelection;o.delayInit&&r.isEmptyObject(o.cache)&&r.buildCache(o),s=t.fn.closest?t(this).closest("th, td"):/TH|TD/.test(this.nodeName)?t(this):t(this).parents("th, td"),d=a.index(s),o.last.clickedIndex=d<0?s.attr("data-column"):d,(n=o.$headers[o.last.clickedIndex])&&!n.sortDisabled&&r.initSort(o,n,e)}}),o.cancelSelection&&a.attr("unselectable","on").bind("selectstart",!1).css({"user-select":"none",MozUserSelect:"none"})},buildHeaders:function(e){var a,i,s,o;for(e.headerList=[],e.headerContent=[],e.sortVars=[],e.debug&&(s=new Date),e.columns=r.computeColumnIndex(e.$table.children("thead, tfoot").children("tr")),i=e.cssIcon?'':"",e.$headers=t(t.map(e.$table.find(e.selectorHeaders),function(a,s){var o,n,l,d,c,f=t(a);if(!f.parent().hasClass(e.cssIgnoreRow))return o=r.getColumnData(e.table,e.headers,s,!0),e.headerContent[s]=f.html(),""===e.headerTemplate||f.find("."+r.css.headerIn).length||(d=e.headerTemplate.replace(r.regex.templateContent,f.html()).replace(r.regex.templateIcon,f.find("."+r.css.icon).length?"":i),e.onRenderTemplate&&(n=e.onRenderTemplate.apply(f,[s,d]))&&"string"==typeof n&&(d=n),f.html('
'+d+"
")),e.onRenderHeader&&e.onRenderHeader.apply(f,[s,e,e.$table]),l=parseInt(f.attr("data-column"),10),a.column=l,c=r.getOrder(r.getData(f,o,"sortInitialOrder")||e.sortInitialOrder),e.sortVars[l]={count:-1,order:c?e.sortReset?[1,0,2]:[1,0]:e.sortReset?[0,1,2]:[0,1],lockedOrder:!1},void 0!==(c=r.getData(f,o,"lockedOrder")||!1)&&!1!==c&&(e.sortVars[l].lockedOrder=!0,e.sortVars[l].order=r.getOrder(c)?[1,1]:[0,0]),e.headerList[s]=a,f.addClass(r.css.header+" "+e.cssHeader).parent().addClass(r.css.headerRow+" "+e.cssHeaderRow).attr("role","row"),e.tabIndex&&f.attr("tabindex",0),a})),e.$headerIndexed=[],o=0;o0))for(n+=s,o+=s;s+1>0;)i.parsers[n-s]=u,i.extractors[n-s]=g,s--;n++}y+=i.parsers.length?m:1}e.debug&&(r.isEmptyObject(w)?console.warn(" No parsers detected!"):console[console.table?"table":"log"](w),console.log("Completed detecting parsers"+r.benchmark(p)),console.groupEnd&&console.groupEnd()),e.parsers=i.parsers,e.extractors=i.extractors},addParser:function(e){var t,a=r.parsers.length,i=!0;for(t=0;t=0;)if((o=r.parsers[d])&&"text"!==o.id&&o.is&&o.is(f,e.table,c,n))return o;return r.getParserById("text")},getElementText:function(e,a,i){if(!a)return"";var s,o=e.textExtraction||"",n=a.jquery?a:t(a);return"string"==typeof o?"basic"===o&&void 0!==(s=n.attr(e.textAttribute))?t.trim(s):t.trim(a.textContent||n.text()):"function"==typeof o?t.trim(o(n[0],e.table,i)):"function"==typeof(s=r.getColumnData(e.table,o,i))?t.trim(s(n[0],e.table,i)):t.trim(n[0].textContent||n.text())},getParsedText:function(e,t,a,i){void 0===i&&(i=r.getElementText(e,t,a));var s=""+i,o=e.parsers[a],n=e.extractors[a];return o&&(n&&"function"==typeof n.format&&(i=n.format(i,e.table,t,a)),s="no-parser"===o.id?"":o.format(""+i,e.table,t,a),e.ignoreCase&&"string"==typeof s&&(s=s.toLowerCase())),s},buildCache:function(e,a,i){var s,o,n,l,d,c,f,u,g,p,h,m,b,y,w,v,x,C,_,$,S,z,F=e.table,R=e.parsers;if(e.$tbodies=e.$table.children("tbody:not(."+e.cssInfoBlock+")"),f=void 0===i?e.$tbodies:i,e.cache={},e.totalRows=0,!R)return e.debug?console.warn("Warning: *Empty table!* Not building a cache"):"";for(e.debug&&(m=new Date),e.showProcessing&&r.isProcessing(F,!0),c=0;c0&&(C+=x,$+=x)),C++;else{for(y.$row=u,y.order=l,C=0,$=e.columns,d=0;d<$;++d){if((h=u[0].cells[d])&&C0)){for(z=0;z<=x;)n=e.duplicateSpan||0===z?o:"string"!=typeof e.textExtraction?r.getElementText(e,h,C+z)||"":"",y.raw[C+z]=n,g[C+z]=n,z++;C+=x,$+=x}C++}g[e.columns]=y,s.normalized[s.normalized.length]=g}s.colMax=v,e.totalRows+=s.normalized.length}if(e.showProcessing&&r.isProcessing(F),e.debug){for(S=Math.min(5,e.cache[0].normalized.length),console[console.group?"group":"log"]("Building cache for "+e.totalRows+" rows (showing "+S+" rows in log) and "+e.columns+" columns"+r.benchmark(m)),o={},d=0;d-1);return a}),(u=u.not(".sorter-false").filter('[data-column="'+s[a][0]+'"]'+(1===o?":last":""))).length)){for(i=0;i=0?s:o[1]%f.length}},updateAll:function(e,t,a){var i=e.table;i.isUpdating=!0,r.refreshWidgets(i,!0,!0),r.buildHeaders(e),r.bindEvents(i,e.$headers,!0),r.bindMethods(e),r.commonUpdate(e,t,a)},update:function(e,t,a){e.table.isUpdating=!0,r.updateHeader(e),r.commonUpdate(e,t,a)},updateHeaders:function(e,t){e.table.isUpdating=!0,r.buildHeaders(e),r.bindEvents(e.table,e.$headers,!0),r.resortComplete(e,t)},updateCell:function(e,a,i,s){if(t(a).closest("tr").hasClass(e.cssChildRow))console.warn('Tablesorter Warning! "updateCell" for child row content has been disabled, use "update" instead');else{if(r.isEmptyObject(e.cache))return r.updateHeader(e),void r.commonUpdate(e,i,s);e.table.isUpdating=!0,e.$table.find(e.selectorRemove).remove();var o,n,l,d,c,f,u=e.$tbodies,g=t(a),p=u.index(t.fn.closest?g.closest("tbody"):g.parents("tbody").filter(":first")),h=e.cache[p],m=t.fn.closest?g.closest("tr"):g.parents("tr").filter(":first");if(a=g[0],u.length&&p>=0){if(l=u.eq(p).find("tr").not("."+e.cssChildRow).index(m),c=h.normalized[l],(f=m[0].cells.length)!==e.columns)for(d=0,o=!1,n=0;n0&&(h+=w),h++;b[a.columns]=m,a.cache[d].normalized[p]=b}r.checkResort(a,s,o)}},updateCache:function(e,t,a){e.parsers&&e.parsers.length||r.setupParsers(e,a),r.buildCache(e,t,a)},appendCache:function(e,t){var a,i,s,o,n,l,d,c=e.table,f=e.widgetOptions,u=e.$tbodies,g=[],p=e.cache;if(r.isEmptyObject(p))return e.appender?e.appender(c,g):c.isUpdating?e.$table.triggerHandler("updateComplete",c):"";for(e.debug&&(d=new Date),l=0;l1))for(o=1;o=0)for(o=0;o1))for(o=1;oi)return 1}for(a=(e||"").replace(d.chunk,"\\0$1\\0").replace(d.chunks,"").split("\\0"),i=(t||"").replace(d.chunk,"\\0$1\\0").replace(d.chunks,"").split("\\0"),l=Math.max(a.length,i.length),n=0;no)return 1}return 0},sortNaturalAsc:function(e,t,a,i){if(e===t)return 0;var s=r.string[i.empties[a]||i.emptyTo];return""===e&&0!==s?"boolean"==typeof s?s?-1:1:-s||-1:""===t&&0!==s?"boolean"==typeof s?s?1:-1:s||1:r.sortNatural(e,t)},sortNaturalDesc:function(e,t,a,i){if(e===t)return 0;var s=r.string[i.empties[a]||i.emptyTo];return""===e&&0!==s?"boolean"==typeof s?s?-1:1:s||1:""===t&&0!==s?"boolean"==typeof s?s?1:-1:-s||-1:r.sortNatural(t,e)},sortText:function(e,t){return e>t?1:e=0&&!0!==i&&d.widgets.splice(n,1),o&&o.remove&&(d.debug&&console.log((i?"Refreshing":"Removing")+' "'+a[s]+'" widget'),o.remove(e,d,d.widgetOptions,i),d.widgetInit[a[s]]=!1);d.$table.triggerHandler("widgetRemoveEnd",e)},refreshWidgets:function(e,a,i){var s,o,n=(e=t(e)[0]).config.widgets,l=r.widgets,d=l.length,c=[],f=function(e){t(e).triggerHandler("refreshComplete")};for(s=0;s'),a=l.$table.width(),o=(s=l.$tbodies.find("tr:first").children(":visible")).length,n=0;n").css("width",i));l.$table.prepend(d)}},getData:function(e,r,a){var i,s,o="",n=t(e);return n.length?(i=!!t.metadata&&n.metadata(),s=" "+(n.attr("class")||""),void 0!==n.data(a)||void 0!==n.data(a.toLowerCase())?o+=n.data(a)||n.data(a.toLowerCase()):i&&void 0!==i[a]?o+=i[a]:r&&void 0!==r[a]?o+=r[a]:" "!==s&&s.match(" "+a+"-")&&(o=s.match(new RegExp("\\s"+a+"-([\\w-]+)"))[1]||""),t.trim(o)):""},getColumnData:function(e,r,a,i,s){if("object"!=typeof r||null===r)return r;var o,n=(e=t(e)[0]).config,l=s||n.$headers,d=n.$headerIndexed&&n.$headerIndexed[a]||l.filter('[data-column="'+a+'"]:last');if(void 0!==r[a])return i?r[a]:r[l.index(d)];for(o in r)if("string"==typeof o&&d.filter(o).add(d.find(o)).length)return r[o]},isProcessing:function(e,a,i){var s=(e=t(e))[0].config,o=i||e.find("."+r.css.header);a?(void 0!==i&&s.sortList.length>0&&(o=o.filter(function(){return!this.sortDisabled&&r.isValueInArray(parseFloat(t(this).attr("data-column")),s.sortList)>=0})),e.add(o).addClass(r.css.processing+" "+s.cssProcessing)):e.add(o).removeClass(r.css.processing+" "+s.cssProcessing)},processTbody:function(e,r,a){if(e=t(e)[0],a)return e.isProcessing=!0,r.before(''),t.fn.detach?r.detach():r.remove();var i=t(e).find("colgroup.tablesorter-savemyplace");r.insertAfter(i),i.remove(),e.isProcessing=!1},clearTableBody:function(e){t(e)[0].config.$tbodies.children().detach()},characterEquivalents:{a:"áàâãäąå",A:"ÁÀÂÃÄĄÅ",c:"çćč",C:"ÇĆČ",e:"éèêëěę",E:"ÉÈÊËĚĘ",i:"íìİîïı",I:"ÍÌİÎÏ",o:"óòôõöō",O:"ÓÒÔÕÖŌ",ss:"ß",SS:"ẞ",u:"úùûüů",U:"ÚÙÛÜŮ"},replaceAccents:function(e){var t,a="[",i=r.characterEquivalents;if(!r.characterRegex){r.characterRegexArray={};for(t in i)"string"==typeof t&&(a+=i[t],r.characterRegexArray[t]=new RegExp("["+i[t]+"]","g"));r.characterRegex=new RegExp(a+"]")}if(r.characterRegex.test(e))for(t in i)"string"==typeof t&&(e=e.replace(r.characterRegexArray[t],t));return e},validateOptions:function(e){var a,i,s,o,n="headers sortForce sortList sortAppend widgets".split(" "),l=e.originalSettings;if(l){e.debug&&(o=new Date);for(a in l)if("undefined"==(s=typeof r.defaults[a]))console.warn('Tablesorter Warning! "table.config.'+a+'" option not recognized');else if("object"===s)for(i in l[a])s=r.defaults[a]&&typeof r.defaults[a][i],t.inArray(a,n)<0&&"undefined"===s&&console.warn('Tablesorter Warning! "table.config.'+a+"."+i+'" option not recognized');e.debug&&console.log("validate options time:"+r.benchmark(o))}},restoreHeaders:function(e){var a,i,s=t(e)[0].config,o=s.$table.find(s.selectorHeaders),n=o.length;for(a=0;a tr").children("th, td");!1===a&&t.inArray("uitheme",n.widgets)>=0&&(o.triggerHandler("applyWidgetId",["uitheme"]),o.triggerHandler("applyWidgetId",["zebra"])),d.find("tr").not(c).remove(),s="sortReset update updateRows updateAll updateHeaders updateCell addRows updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets removeWidget destroy mouseup mouseleave "+"keypress sortBegin sortEnd resetToLoadState ".split(" ").join(n.namespace+" "),o.removeData("tablesorter").unbind(s.replace(r.regex.spaces," ")),n.$headers.add(f).removeClass([r.css.header,n.cssHeader,n.cssAsc,n.cssDesc,r.css.sortAsc,r.css.sortDesc,r.css.sortNone].join(" ")).removeAttr("data-column").removeAttr("aria-label").attr("aria-disabled","true"),c.find(n.selectorSort).unbind("mousedown mouseup keypress ".split(" ").join(n.namespace+" ").replace(r.regex.spaces," ")),r.restoreHeaders(e),o.toggleClass(r.css.table+" "+n.tableClass+" tablesorter-"+n.theme,!1===a),o.removeClass(n.namespace.slice(1)),e.hasInitialized=!1,delete e.config.cache,"function"==typeof i&&i(e),l&&console.log("tablesorter has been removed")}}};t.fn.tablesorter=function(e){return this.each(function(){var a=this,i=t.extend(!0,{},r.defaults,e,r.instanceMethods);i.originalSettings=e,!a.hasInitialized&&r.buildTable&&"TABLE"!==this.nodeName?r.buildTable(a,i):r.setup(a,i)})},window.console&&window.console.log||(r.logs=[],console={},console.log=console.warn=console.error=console.table=function(){var e=arguments.length>1?arguments:arguments[0];r.logs[r.logs.length]={date:Date.now(),log:e}}),r.addParser({id:"no-parser",is:function(){return!1},format:function(){return""},type:"text"}),r.addParser({id:"text",is:function(){return!0},format:function(e,a){var i=a.config;return e&&(e=t.trim(i.ignoreCase?e.toLocaleLowerCase():e),e=i.sortLocaleCompare?r.replaceAccents(e):e),e},type:"text"}),r.regex.nondigit=/[^\w,. \-()]/g,r.addParser({id:"digit",is:function(e){return r.isDigit(e)},format:function(e,a){var i=r.formatFloat((e||"").replace(r.regex.nondigit,""),a);return e&&"number"==typeof i?i:e?t.trim(e&&a.config.ignoreCase?e.toLocaleLowerCase():e):e},type:"numeric"}),r.regex.currencyReplace=/[+\-,. ]/g,r.regex.currencyTest=/^\(?\d+[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]|[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]\d+\)?$/,r.addParser({id:"currency",is:function(e){return e=(e||"").replace(r.regex.currencyReplace,""),r.regex.currencyTest.test(e)},format:function(e,a){var i=r.formatFloat((e||"").replace(r.regex.nondigit,""),a);return e&&"number"==typeof i?i:e?t.trim(e&&a.config.ignoreCase?e.toLocaleLowerCase():e):e},type:"numeric"}),r.regex.urlProtocolTest=/^(https?|ftp|file):\/\//,r.regex.urlProtocolReplace=/(https?|ftp|file):\/\/(www\.)?/,r.addParser({id:"url",is:function(e){return r.regex.urlProtocolTest.test(e)},format:function(e){return e?t.trim(e.replace(r.regex.urlProtocolReplace,"")):e},type:"text"}),r.regex.dash=/-/g,r.regex.isoDate=/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}/,r.addParser({id:"isoDate",is:function(e){return r.regex.isoDate.test(e)},format:function(e,t){var a=e?new Date(e.replace(r.regex.dash,"/")):e;return a instanceof Date&&isFinite(a)?a.getTime():e},type:"numeric"}),r.regex.percent=/%/g,r.regex.percentTest=/(\d\s*?%|%\s*?\d)/,r.addParser({id:"percent",is:function(e){return r.regex.percentTest.test(e)&&e.length<15},format:function(e,t){return e?r.formatFloat(e.replace(r.regex.percent,""),t):e},type:"numeric"}),r.addParser({id:"image",is:function(e,t,r,a){return a.find("img").length>0},format:function(e,r,a){return t(a).find("img").attr(r.config.imgAttr||"alt")||e},parsed:!0,type:"text"}),r.regex.dateReplace=/(\S)([AP]M)$/i,r.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,r.regex.usLongDateTest2=/^\d{1,2}\s+[A-Z]{3,10}\s+\d{4}/i,r.addParser({id:"usLongDate",is:function(e){return r.regex.usLongDateTest1.test(e)||r.regex.usLongDateTest2.test(e)},format:function(e,t){var a=e?new Date(e.replace(r.regex.dateReplace,"$1 $2")):e;return a instanceof Date&&isFinite(a)?a.getTime():e},type:"numeric"}),r.regex.shortDateTest=/(^\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4})|(^\d{4}[\/\s]\d{1,2}[\/\s]\d{1,2})/,r.regex.shortDateReplace=/[\-.,]/g,r.regex.shortDateXXY=/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/,r.regex.shortDateYMD=/(\d{4})[\/\s](\d{1,2})[\/\s](\d{1,2})/,r.convertFormat=function(e,t){e=(e||"").replace(r.regex.spaces," ").replace(r.regex.shortDateReplace,"/"),"mmddyyyy"===t?e=e.replace(r.regex.shortDateXXY,"$3/$1/$2"):"ddmmyyyy"===t?e=e.replace(r.regex.shortDateXXY,"$3/$2/$1"):"yyyymmdd"===t&&(e=e.replace(r.regex.shortDateYMD,"$1/$2/$3"));var a=new Date(e);return a instanceof Date&&isFinite(a)?a.getTime():""},r.addParser({id:"shortDate",is:function(e){return e=(e||"").replace(r.regex.spaces," ").replace(r.regex.shortDateReplace,"/"),r.regex.shortDateTest.test(e)},format:function(e,t,a,i){if(e){var s=t.config,o=s.$headerIndexed[i],n=o.length&&o.data("dateFormat")||r.getData(o,r.getColumnData(t,s.headers,i),"dateFormat")||s.dateFormat;return o.length&&o.data("dateFormat",n),r.convertFormat(e,n)||e}return e},type:"numeric"}),r.regex.timeTest=/^(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)$|^((?:[01]\d|[2][0-4]):[0-5]\d)$/i,r.regex.timeMatch=/(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)|((?:[01]\d|[2][0-4]):[0-5]\d)/i,r.addParser({id:"time",is:function(e){return r.regex.timeTest.test(e)},format:function(e,t){var a=(e||"").match(r.regex.timeMatch),i=new Date(e),s=e&&(null!==a?a[0]:"00:00 AM"),o=s?new Date("2000/01/01 "+s.replace(r.regex.dateReplace,"$1 $2")):s;return o instanceof Date&&isFinite(o)?(i instanceof Date&&isFinite(i)?i.getTime():0)?parseFloat(o.getTime()+"."+i.getTime()):o.getTime():e},type:"numeric"}),r.addParser({id:"metadata",is:function(){return!1},format:function(e,r,a){var i=r.config,s=i.parserMetadataName?i.parserMetadataName:"sortValue";return t(a).metadata()[s]},type:"numeric"}),r.addWidget({id:"zebra",priority:90,format:function(e,r,a){var i,s,o,n,l,d,c,f=new RegExp(r.cssChildRow,"i"),u=r.$tbodies.add(t(r.namespace+"_extra_table").children("tbody:not(."+r.cssInfoBlock+")"));for(l=0;l
')}),a.cssIcon&&v.find("."+t.css.icon).removeClass(b?[p.icons,m].join(" "):"").addClass(C.icons||""),t.hasWidget(a.table,"filter")&&(o=function(){w.children("thead").children("."+t.css.filterRow).removeClass(b?p.filterRow||"":"").addClass(C.filterRow||"")},i.filter_initialized?o():w.one("filterInit",function(){o()}))),s=0;s1)))for(u=1;u=]/g,query:"(q|query)",wild01:/\?/g,wild0More:/\*/g,quote:/\"/g,isNeg1:/(>=?\s*-\d)/,isNeg2:/(<=?\s*\d)/},types:{or:function(a,i,s){if((r.orTest.test(i.iFilter)||r.orSplit.test(i.filter))&&!r.regex.test(i.filter)){var o,n,l,d,c=e.extend({},i),f=i.filter.split(r.orSplit),u=i.iFilter.split(r.orSplit),g=f.length;for(o=0;o=f:o>f:r.ltTest.test(s.iFilter)&&(n=r.lteTest.test(s.iFilter)?o<=f:o=0)))}return null},exact:function(a,i){if(r.exact.test(i.iFilter)){var s=i.iFilter.replace(r.exact,""),o=t.parseFilter(a,s,i)||"";return i.anyMatch?e.inArray(o,i.rowArray)>=0:o==i.iExact}return null},range:function(e,i){if(r.toTest.test(i.iFilter)){var s,o,n,l,d=e.table,c=i.index,f=i.parsed[c],u=i.iFilter.split(r.toSplit);return o=u[0].replace(a.regex.nondigit,"")||"",n=a.formatFloat(t.parseFilter(e,o,i),d),o=u[1].replace(a.regex.nondigit,"")||"",l=a.formatFloat(t.parseFilter(e,o,i),d),(f||"numeric"===e.parsers[c].type)&&(n=""===(s=e.parsers[c].format(""+u[0],d,e.$headers.eq(c),c))||isNaN(s)?n:s,l=""===(s=e.parsers[c].format(""+u[1],d,e.$headers.eq(c),c))||isNaN(s)?l:s),!f&&"numeric"!==e.parsers[c].type||isNaN(n)||isNaN(l)?(o=isNaN(i.iExact)?i.iExact.replace(a.regex.nondigit,""):i.iExact,s=a.formatFloat(o,d)):s=i.cache,n>l&&(o=n,n=l,l=o),s>=n&&s<=l||""===n||""===l}return null},wild:function(e,a){if(r.wildOrTest.test(a.iFilter)){var i=""+(t.parseFilter(e,a.iFilter,a)||"");!r.wildTest.test(i)&&a.nestedFilters&&(i=a.isMatch?i:"^("+i+")$");try{return new RegExp(i.replace(r.wild01,"\\S{1}").replace(r.wild0More,"\\S*"),e.widgetOptions.filter_ignoreCase?"i":"").test(a.exact)}catch(e){return null}}return null},fuzzy:function(e,a){if(r.fuzzyTest.test(a.iFilter)){var i,s=0,o=a.iExact.length,n=a.iFilter.slice(1),l=t.parseFilter(e,n,a)||"";for(i=0;i]=?/,gtTest:/>/,gteTest:/>=/,ltTest:/'+(d.data("placeholder")||d.attr("data-placeholder")||h.filter_placeholder.select||"")+"":"",f=n,l=n,n.indexOf(h.filter_selectSourceSeparator)>=0&&(l=(f=n.split(h.filter_selectSourceSeparator))[1],f=f[0]),o+="");p.$table.find("thead").find("select."+i.filter+'[data-column="'+c+'"]').append(o),(u="function"==typeof(l=h.filter_selectSource)||a.getColumnData(s,l,c))&&t.buildSelect(p.table,c,"",!0,d.hasClass(h.filter_onlyAvail))}t.buildDefault(s,!0),t.bindSearch(s,p.$table.find("."+i.filter),!0),h.filter_external&&t.bindSearch(s,h.filter_external),h.filter_hideFilters&&t.hideFilters(p),p.showProcessing&&(l="filterStart filterEnd ".split(" ").join(p.namespace+"filter "),p.$table.unbind(l.replace(a.regex.spaces," ")).bind(l,function(t,r){d=r?p.$table.find("."+i.header).filter("[data-column]").filter(function(){return""!==r[e(this).data("column")]}):"",a.isProcessing(s,"filterStart"===t.type,r?d:"")})),p.filteredRows=p.totalRows,l="tablesorter-initialized pagerBeforeInitialized ".split(" ").join(p.namespace+"filter "),p.$table.unbind(l.replace(a.regex.spaces," ")).bind(l,function(){t.completeInit(this)}),p.pager&&p.pager.initialized&&!h.filter_initialized?(p.$table.triggerHandler("filterFomatterUpdate"),setTimeout(function(){t.filterInitComplete(p)},100)):h.filter_initialized||t.completeInit(s)},completeInit:function(e){var r=e.config,i=r.widgetOptions,s=t.setDefaults(e,r,i)||[];s.length&&(r.delayInit&&""===s.join("")||a.setFilters(e,s,!0)),r.$table.triggerHandler("filterFomatterUpdate"),setTimeout(function(){i.filter_initialized||t.filterInitComplete(r)},100)},formatterUpdated:function(e,t){var r=e&&e.closest("table"),a=r.length&&r[0].config,i=a&&a.widgetOptions;i&&!i.filter_initialized&&(i.filter_formatterInit[t]=1)},filterInitComplete:function(r){var a,i,s=r.widgetOptions,o=0,n=function(){s.filter_initialized=!0,r.lastSearch=r.$table.data("lastSearch"),r.$table.triggerHandler("filterInit",r),t.findRows(r.table,r.lastSearch||[])};if(e.isEmptyObject(s.filter_formatter))n();else{for(i=s.filter_formatterInit.length,a=0;a';for(d=0;d1?'").appendTo(s.$table.children("thead").eq(0)).children("td"),d=0;d").appendTo(n):((p=a.getColumnData(r,o.filter_formatter,d))?(o.filter_formatterCount++,(w=p(n,d))&&0===w.length&&(w=n.children("input")),w&&(0===w.parent().length||w.parent().length&&w.parent()[0]!==n[0])&&n.append(w)):w=e('').appendTo(n),w&&(h=c.data("placeholder")||c.attr("data-placeholder")||o.filter_placeholder.search||"",w.attr("placeholder",h))),w&&(g=(e.isArray(o.filter_cssFilter)?void 0!==o.filter_cssFilter[d]?o.filter_cssFilter[d]||"":"":o.filter_cssFilter)||"",w.addClass(i.filter+" "+g).attr("data-column",n.attr("data-column")),u&&(w.attr("placeholder","").addClass(i.filterDisabled)[0].disabled=!0)))},bindSearch:function(r,i,o){if(r=e(r)[0],(i=e(i)).length){var n,l=r.config,d=l.widgetOptions,c=l.namespace+"filter",f=d.filter_$externalFilters;!0!==o&&(n=d.filter_anyColumnSelector+","+d.filter_multipleColumnSelector,d.filter_$anyMatch=i.filter(n),f&&f.length?d.filter_$externalFilters=d.filter_$externalFilters.add(i):d.filter_$externalFilters=i,a.setFilters(r,l.$table.data("lastSearch")||[],!1===o)),n="keypress keyup keydown search change input ".split(" ").join(c+" "),i.attr("data-lastSearchTime",(new Date).getTime()).unbind(n.replace(a.regex.spaces," ")).bind("keydown"+c,function(e){if(e.which===s.escape&&!r.config.widgetOptions.filter_resetOnEsc)return!1}).bind("keyup"+c,function(i){d=r.config.widgetOptions;var o=parseInt(e(this).attr("data-column"),10),n="boolean"==typeof d.filter_liveSearch?d.filter_liveSearch:a.getColumnData(r,d.filter_liveSearch,o);if(void 0===n&&(n=d.filter_liveSearch.fallback||!1),e(this).attr("data-lastSearchTime",(new Date).getTime()),i.which===s.escape)this.value=d.filter_resetOnEsc?"":l.lastSearch[o];else{if(""!==this.value&&("number"==typeof n&&this.value.length=s.left&&i.which<=s.down)))return;if(!1===n&&""!==this.value&&i.which!==s.enter)return}t.searching(r,!0,!0,o)}).bind("search change keypress input blur ".split(" ").join(c+" "),function(i){var o=parseInt(e(this).attr("data-column"),10),n=i.type,c="boolean"==typeof d.filter_liveSearch?d.filter_liveSearch:a.getColumnData(r,d.filter_liveSearch,o);!r.config.widgetOptions.filter_initialized||i.which!==s.enter&&"search"!==n&&"blur"!==n&&("change"!==n&&"input"!==n||!0!==c&&(!0===c||"INPUT"===i.target.nodeName)||this.value===l.lastSearch[o])||(i.preventDefault(),e(this).attr("data-lastSearchTime",(new Date).getTime()),t.searching(r,"keypress"!==n,!0,o))})}},searching:function(e,r,i,s){var o,n=e.config.widgetOptions;void 0===s?o=!1:void 0===(o="boolean"==typeof n.filter_liveSearch?n.filter_liveSearch:a.getColumnData(e,n.filter_liveSearch,s))&&(o=n.filter_liveSearch.fallback||!1),clearTimeout(n.filter_searchTimer),void 0===r||!0===r?n.filter_searchTimer=setTimeout(function(){t.checkFilters(e,r,i)},o?n.filter_searchDelay:10):t.checkFilters(e,r,i)},equalFilters:function(t,r,a){var i,s=[],o=[],n=t.columns+1;for(r=e.isArray(r)?r:[],a=e.isArray(a)?a:[],i=0;i1?e.trim(t).split(/\s/):[e.trim(t)],n=o.length-1,l=0,d=a;for(n<1&&s>1&&(o[1]=o[0]);i.test(d);)d=d.replace(i,o[l++]||""),i.test(d)&&l(n=parseInt(s[1],10)||e.columns-1)&&(a=o,o=n,n=a),n>=e.columns&&(n=e.columns-1);o<=n;o++)u[u.length]=o;t=t.replace(i[c],"")}if(!r&&/,/.test(t))for(f=(l=t.split(/\s*,\s*/)).length,d=0;d-1})},multipleColumns:function(r,a){var i=r.widgetOptions,s=i.filter_initialized||!a.filter(i.filter_anyColumnSelector).length,o=e.trim(t.getLatestSearch(a).attr("data-column")||"");return t.findRange(r,o,!s)},processTypes:function(r,a,i){var s,o=null,n=null;for(s in t.types)e.inArray(s,i.excludeMatch)<0&&null===n&&null!==(n=t.types[s](r,a,i))&&(o=n);return o},matchType:function(e,t){var r,a=e.widgetOptions,s=e.$headerIndexed[t];return s.hasClass("filter-exact")?r=!1:s.hasClass("filter-match")?r=!0:(a.filter_columnFilters?s=e.$filters.find("."+i.filter).add(a.filter_$externalFilters).filter('[data-column="'+t+'"]'):a.filter_$externalFilters&&(s=a.filter_$externalFilters.filter('[data-column="'+t+'"]')),r=!!s.length&&"match"===e.widgetOptions.filter_matchType[(s[0].nodeName||"").toLowerCase()]),r},processRow:function(i,s,o){var n,l,d,c,f,u=i.widgetOptions,g=!0,p=u.filter_$anyMatch&&u.filter_$anyMatch.length,h=u.filter_$anyMatch&&u.filter_$anyMatch.length?t.multipleColumns(i,u.filter_$anyMatch):[];if(s.$cells=s.$row.children(),s.anyMatchFlag&&h.length>1||s.anyMatchFilter&&!p){if(s.anyMatch=!0,s.isMatch=!0,s.rowArray=s.$cells.map(function(t){if(e.inArray(t,h)>-1||s.anyMatchFilter&&!p)return s.parsed[t]?f=s.cacheArray[t]:(f=s.rawArray[t],f=e.trim(u.filter_ignoreCase?f.toLowerCase():f),i.sortLocaleCompare&&(f=a.replaceAccents(f))),f}).get(),s.filter=s.anyMatchFilter,s.iFilter=s.iAnyMatchFilter,s.exact=s.rowArray.join(" "),s.iExact=u.filter_ignoreCase?s.exact.toLowerCase():s.exact,s.cache=s.cacheArray.slice(0,-1).join(" "),o.excludeMatch=o.noAnyMatch,null!==(l=t.processTypes(i,s,o)))g=l;else if(u.filter_startsWith)for(g=!1,h=Math.min(i.columns,s.rowArray.length);!g&&h>0;)h--,g=g||0===s.rowArray[h].indexOf(s.iFilter);else g=(s.iExact+s.childRowText).indexOf(s.iFilter)>=0;if(s.anyMatch=!1,s.filters.join("")===s.filter)return g}for(h=0;h=0:s.filter===s.exact:(f=(s.iExact+s.childRowText).indexOf(t.parseFilter(i,s.iFilter,s)),n=!u.filter_startsWith&&f>=0||u.filter_startsWith&&0===f):n=l,g=!!n&&g);return g},findRows:function(i,s,o){if(!t.equalFilters(i.config,i.config.lastSearch,o)&&i.config.widgetOptions.filter_initialized){var n,l,d,c,f,u,g,p,h,m,b,y,w,v,x,C,_,$,S,z,F,R,T,I=e.extend([],s),k=i.config,A=k.widgetOptions,D={anyMatch:!1,filters:s,filter_regexCache:[]},H={noAnyMatch:["range","operators"],functions:[],excludeFilter:[],defaultColFilter:[],defaultAnyFilter:a.getColumnData(i,A.filter_defaultFilter,k.columns,!0)||""};for(D.parsed=[],h=0;h1&&(isNaN(F[0])?e.each(k.headerContent,function(e,t){t.toLowerCase().indexOf(F[0])>-1&&(s[R=e]=F[1])}):R=parseInt(F[0],10)-1,R>=0&&R")>=0)return c;if(e.isArray(c))n=c;else if("object"===e.type(l)&&c&&null===(n=c(r,i,s)))return null}return!1===n&&(n=t.getOptions(r,i,s)),t.processOptions(r,i,n)},processOptions:function(t,r,i){if(!e.isArray(i))return!1;var s,o,n,l,d,c,f=(t=e(t)[0]).config,u=void 0!==r&&null!==r&&r>=0&&r'+(y.data("placeholder")||y.attr("data-placeholder")||b.filter_placeholder.select||"")+"",v=m.$table.find("thead").find("select."+i.filter+'[data-column="'+s+'"]').val();if(void 0!==o&&""!==o||null!==(o=t.getOptionSource(a,s,l))){if(e.isArray(o)){for(d=0;d"}else""+h!="[object Object]"&&(c=f=h=(""+h).replace(r.quote,"""),f.indexOf(b.filter_selectSourceSeparator)>=0&&(c=(u=f.split(b.filter_selectSourceSeparator))[0],f=u[1]),w+=""!==h?"":"");o=[]}g=(m.$filters?m.$filters:m.$table.children("thead")).find("."+i.filter),b.filter_$externalFilters&&(g=g&&g.length?g.add(b.filter_$externalFilters):b.filter_$externalFilters),(p=g.filter('select[data-column="'+s+'"]')).length&&(p[n?"html":"append"](w),e.isArray(o)||p.append(o).val(v),p.val(v))}}},buildDefault:function(e,r){var i,s,o,n=e.config,l=n.widgetOptions,d=n.columns;for(i=0;i1&&(d=d.slice(1)),n===u.columns&&(d=(c=d.filter(g.filter_anyColumnSelector)).length?c:d),d.val(s[n]).trigger("change"+u.namespace)):(f[n]=d.val()||"",n===u.columns?d.slice(1).filter('[data-column*="'+d.attr("data-column")+'"]').val(f[n]):d.slice(1).val(f[n])),n===u.columns&&d.length&&(g.filter_$anyMatch=d));return f},a.setFilters=function(r,i,s,o){var n=r?e(r)[0].config:"",l=a.getFilters(r,!0,i,o);return void 0===s&&(s=!0),n&&s&&(n.lastCombinedFilter=null,n.lastSearch=[],t.searching(n.table,i,o),n.$table.triggerHandler("filterFomatterUpdate")),0!==l.length}}(e),function(e,t){"use strict";function r(t,r){var a=isNaN(r.stickyHeaders_offset)?e(r.stickyHeaders_offset):[];return a.length?a.height()||0:parseInt(r.stickyHeaders_offset,10)||0}var a=e.tablesorter||{};e.extend(a.css,{sticky:"tablesorter-stickyHeader",stickyVis:"tablesorter-sticky-visible",stickyHide:"tablesorter-sticky-hidden",stickyWrap:"tablesorter-sticky-wrapper"}),a.addHeaderResizeEvent=function(t,r,a){if((t=e(t)[0]).config){var i={timer:250},s=e.extend({},i,a),o=t.config,n=o.widgetOptions,l=function(e){var t,r,a,i,s,l,d=o.$headers.length;for(n.resize_flag=!0,r=[],t=0;t=0&&!s.$table.hasClass("hasFilters"))){var n,l,d,c,f=s.$table,u=e(o.stickyHeaders_attachTo),g=s.namespace+"stickyheaders ",p=e(o.stickyHeaders_yScroll||o.stickyHeaders_attachTo||t),h=e(o.stickyHeaders_xScroll||o.stickyHeaders_attachTo||t),m=f.children("thead:first").children("tr").not(".sticky-false").children(),b=f.children("tfoot"),y=r(0,o),w=f.parent().closest("."+a.css.table).hasClass("hasStickyHeaders")?f.parent().closest("table.tablesorter")[0].config.widgetOptions.$sticky.parent():[],v=w.length?w.height():0,x=o.$sticky=f.clone().addClass("containsStickyHeaders "+a.css.sticky+" "+o.stickyHeaders+" "+s.namespace.slice(1)+"_extra_table").wrap('
'),C=x.parent().addClass(a.css.stickyHide).css({position:u.length?"absolute":"fixed",padding:parseInt(x.parent().parent().css("padding-left"),10),top:y+v,left:0,visibility:"hidden",zIndex:o.stickyHeaders_zIndex||2}),_=x.children("thead:first"),$="",S=function(e,r){var a,i,s,o,n,l=e.filter(":visible"),d=l.length;for(a=0;ai.top&&g=0&&s.$filters&&s.$filters.eq(i).find("a, select, input").filter(":visible").focus())}),a.filter.bindSearch(f,c.find("."+a.css.filter)),o.filter_hideFilters&&a.filter.hideFilters(s,x)),o.stickyHeaders_addResizeEvent&&f.bind("resize"+s.namespace+"stickyheaders",function(){z()}),F(!0),f.triggerHandler("stickyHeadersInit")}},remove:function(r,i,s){var o=i.namespace+"stickyheaders ";i.$table.removeClass("hasStickyHeaders").unbind("pagerComplete resize filterEnd stickyHeadersUpdate ".split(" ").join(o).replace(/\s+/g," ")).next("."+a.css.stickyWrap).remove(),s.$sticky&&s.$sticky.length&&s.$sticky.remove(),e(t).add(s.stickyHeaders_xScroll).add(s.stickyHeaders_yScroll).add(s.stickyHeaders_attachTo).unbind("scroll resize ".split(" ").join(o).replace(/\s+/g," ")),a.addHeaderResizeEvent(r,!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="";e("head").append(t)}),r.resizable={init:function(t,a){if(!t.$table.hasClass("hasResizable")){t.$table.addClass("hasResizable");var i,s,o,n,l=t.$table,d=l.parent(),c=parseInt(l.css("margin-top"),10),f=a.resizable_vars={useStorage:r.storage&&!1!==a.resizable,$wrap:d,mouseXPosition:0,$target:null,$next:null,overflow:"auto"===d.css("overflow")||"scroll"===d.css("overflow")||"auto"===d.css("overflow-x")||"scroll"===d.css("overflow-x"),storedSizes:[]};for(r.resizableReset(t.table,!0),f.tableWidth=l.width(),f.fullWidth=Math.abs(d.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(l,n,!0)),a.resizable_vars.storedSizes=o=(f.useStorage?r.storage(t.table,r.css.resizableStorage):[])||[],r.resizable.setWidths(t,a,o),r.resizable.updateStoredSizes(t,a),a.$resizable_container=e('
').css({top:c}).insertBefore(l),s=0;s').appendTo(a.$resizable_container).attr({"data-column":s,unselectable:"on"}).data("header",i).bind("selectstart",!1);r.resizable.bindings(t,a)}},updateStoredSizes:function(e,t){var r,a,i=e.columns,s=t.resizable_vars;for(s.storedSizes=[],r=0;r0){for(n.storedSizes[n.target]+=c,r.resizable.setWidth(n.$target,n.storedSizes[n.target],!0),s=0;s0?a.sortList=c:r.hasInitialized&&c&&c.length>0&&t.sortOn(a,c))},remove:function(e,r){r.$table.removeClass("hasSaveSort"),t.storage&&t.storage(e,"tablesorter-savesort","")}})}(e),e.tablesorter}); \ No newline at end of file diff --git a/dist/js/jquery.tablesorter.js b/dist/js/jquery.tablesorter.js index d2e628f58..3fe5a8943 100644 --- a/dist/js/jquery.tablesorter.js +++ b/dist/js/jquery.tablesorter.js @@ -29,2848 +29,2849 @@ */ /*jshint browser:true, jquery:true, unused:false, expr: true */ ;( function( $ ) { - 'use strict'; - var ts = $.tablesorter = { - - version : '2.28.15', - - 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} = // 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 ( c.debug ) { - 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 ( c.debug ) { - 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; - 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 ) { - 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 ( c.debug ) { - console.log( 'Overall initialization time:' + ts.benchmark( $.data( table, 'startoveralltimer' ) ) ); - if ( c.debug && 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, init ) { - e.stopPropagation(); - // apply widgets - ts.applyWidget( this, init ); - }) - .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 = $.fn.closest ? $headers.closest( 'table' )[ 0 ] : $headers.parents( 'table' )[ 0 ]; - if ( tmp && tmp.nodeName === 'TABLE' && tmp !== table ) { - $( tmp ).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; - // 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 || - // elements within a button - $target.parents( 'button' ).length > 0 ) { - return !c.cancelSelection; - } - if ( c.delayInit && ts.isEmptyObject( c.cache ) ) { - ts.buildCache( c ); - } - // jQuery v1.2.6 doesn't have closest() - $cell = $.fn.closest ? $( this ).closest( 'th, td' ) : - /TH|TD/.test( this.nodeName ) ? $( this ) : $( this ).parents( 'th, td' ); - // reference original table headers and find the same cell - // don't use $headers or IE8 throws an error - see #987 - temp = $headers.index( $cell ); - c.last.clickedIndex = ( temp < 0 ) ? $cell.attr( 'data-column' ) : temp; - // use column index if $headers is undefined - cell = c.$headers[ c.last.clickedIndex ]; - 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 ( c.debug ) { - 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 ? - '' : - ''; - // 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 ( $elem.parent().hasClass( c.cssIgnoreRow ) ) { return; } - // 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( '
' + template + '
' ); // 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 - }; - 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; - // add to parent in case there are multiple rows - $elem - .addClass( ts.css.header + ' ' + c.cssHeader ) - .parent() - .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 ] = {}; - } - $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 ( c.debug ) { - 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 = {}; - // 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 c.debug ? console.warn( 'Warning: *Empty table!* Not building a parser cache' ) : ''; - } else if ( c.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 ( c.debug ) { - debug[ '(' + 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 ( c.debug ) { - if ( !ts.isEmptyObject( debug ) ) { - console[ console.table ? 'table' : 'log' ]( debug ); - } 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 */ - 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 = '', - 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 ( c.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; - // 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 c.debug ? console.warn( 'Warning: *Empty table!* Not building a cache' ) : ''; - } - if ( c.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 && c.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 ( c.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 ( c.debug ) { - 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' ], - // 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 + c.$headers[ i ].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 ) { - $sorted - .eq( column ) - .removeClass( none ) - .addClass( css[ list[ indx ][ 1 ] ] ) - .attr( 'aria-sort', aria[ list[ indx ][ 1 ] ] ) - .find( '.' + ts.css.icon ) - .removeClass( cssIcon[ 2 ] ) - .addClass( cssIcon[ list[ indx ][ 1 ] ] ); - } - } - // add sorted class to footer & extra headers, if they exist - if ( $extras.length ) { - $extras - .filter( '[data-column="' + list[ indx ][ 0 ] + '"]' ) - .removeClass( none ) - .addClass( css[ list[ indx ][ 1 ] ] ); - } - } - } - } - // add verbose aria labels - len = c.$headers.length; - for ( indx = 0; indx < len; indx++ ) { - ts.setColumnAriaLabel( c, c.$headers.eq( indx ) ); - } - }, - - // 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 ); - } - }, - - 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( $.fn.closest ? $cell.closest( 'tbody' ) : $cell.parents( 'tbody' ).filter( ':first' ) ), - tbcache = c.cache[ tbodyIndex ], - $row = $.fn.closest ? $cell.closest( 'tr' ) : $cell.parents( 'tr' ).filter( ':first' ); - 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 ( c.debug ) { - 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 && / 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, - wo = c.widgetOptions, - $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 ( c.debug ) { - 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 || !wo.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 ( c.debug ) { - 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, - // get current column index - col = parseInt( $( cell ).attr( 'data-column' ), 10 ), - order = c.sortVars[ col ].order; - - // 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 ) { - // 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 ]; - } - } - } - // add column to sort list - dir = order[ c.sortVars[ col ].count ]; - if ( dir < 2 ) { - c.sortList[ c.sortList.length ] = [ col, dir ]; - // add other columns if header spans across multiple - if ( cell.colSpan > 1 ) { - for ( indx = 1; indx < cell.colSpan; indx++ ) { - c.sortList[ c.sortList.length ] = [ col + indx, dir ]; - // update count on columns in colSpan - c.sortVars[ col + indx ].count = $.inArray( dir, order ); - } - } - } - // 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 - 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 ]; - if ( dir < 2 ) { - c.sortList[ c.sortList.length ] = [ col, dir ]; - // add other columns if header spans across multiple - if ( cell.colSpan > 1 ) { - for ( indx = 1; indx < cell.colSpan; indx++ ) { - c.sortList[ c.sortList.length ] = [ col + indx, dir ]; - // update count on columns in colSpan - c.sortVars[ col + indx ].count = $.inArray( dir, order ); - } - } - } - } - } - // 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 ]; - } - } - } - } - // 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 ( c.debug ) { 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 ( c.debug ) { - 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 table = c.table; - c.$table.triggerHandler( 'sortStart', table ); - // 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 = []; - ts.setHeadersCss( c ); - ts.multisort( c ); - ts.appendCache( c ); - var indx; - for (indx = 0; indx < c.columns; indx++) { - c.sortVars[ indx ].count = -1; - } - 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, - 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 ( c.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 ( c.debug ) { - console[ console.group ? 'group' : 'log' ]( 'Initializing ' + name + ' widget' ); - } - widget.init( table, widget, c, wo ); - } - } - if ( !init && typeof widget.format === 'function' ) { - applied = true; - if ( c.debug ) { - console[ console.group ? 'group' : 'log' ]( 'Updating ' + name + ' widget' ); - } - widget.format( table, c, wo, false ); - } - if ( c.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, - widgets = []; - // prevent numerous consecutive widget applications - if ( init !== false && table.hasInitialized && ( table.isApplyingWidgets || table.isUpdating ) ) { - return; - } - if ( c.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 ( c.debug ) { - console.warn( '"' + names[ indx ] + '" widget code does not exist!' ); - } - } - // 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 ( c.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 ( c.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 ( c.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 ( c.debug ) { - console.log( ( refreshing ? 'Refreshing' : 'Removing' ) + ' "' + name[ index ] + '" widget' ); - } - widget.remove( table, c, c.widgetOptions, refreshing ); - c.widgetInit[ name[ index ] ] = false; - } - } - }, - - 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 ); - }, - - // $.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 = $( '' ); - 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( $( '' ).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.filter( '[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( '' ); - 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 ( c.debug ) { - 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 ( c.debug ) { - 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, - debug = c.debug, - $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 ( debug ) { - 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, table ) { - 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, table ) { - 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, table ) { - // 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 - } - } - }); + 'use strict'; + var ts = $.tablesorter = { + + version : '2.28.15', + + 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} = // 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 ( c.debug ) { + 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 ( c.debug ) { + 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; + 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 ) { + 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 ( c.debug ) { + console.log( 'Overall initialization time:' + ts.benchmark( $.data( table, 'startoveralltimer' ) ) ); + if ( c.debug && 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, init ) { + e.stopPropagation(); + // apply widgets + ts.applyWidget( this, init ); + }) + .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 = $.fn.closest ? $headers.closest( 'table' )[ 0 ] : $headers.parents( 'table' )[ 0 ]; + if ( tmp && tmp.nodeName === 'TABLE' && tmp !== table ) { + $( tmp ).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; + // 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 || + // elements within a button + $target.parents( 'button' ).length > 0 ) { + return !c.cancelSelection; + } + if ( c.delayInit && ts.isEmptyObject( c.cache ) ) { + ts.buildCache( c ); + } + // jQuery v1.2.6 doesn't have closest() + $cell = $.fn.closest ? $( this ).closest( 'th, td' ) : + /TH|TD/.test( this.nodeName ) ? $( this ) : $( this ).parents( 'th, td' ); + // reference original table headers and find the same cell + // don't use $headers or IE8 throws an error - see #987 + temp = $headers.index( $cell ); + c.last.clickedIndex = ( temp < 0 ) ? $cell.attr( 'data-column' ) : temp; + // use column index if $headers is undefined + cell = c.$headers[ c.last.clickedIndex ]; + 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 ( c.debug ) { + 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 ? + '' : + ''; + // 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 ( $elem.parent().hasClass( c.cssIgnoreRow ) ) { return; } + // 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( '
' + template + '
' ); // 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 + }; + 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; + // add to parent in case there are multiple rows + $elem + .addClass( ts.css.header + ' ' + c.cssHeader ) + .parent() + .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 ] = {}; + } + $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 ( c.debug ) { + 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 = {}; + // 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 c.debug ? console.warn( 'Warning: *Empty table!* Not building a parser cache' ) : ''; + } else if ( c.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 ( c.debug ) { + debug[ '(' + 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 ( c.debug ) { + if ( !ts.isEmptyObject( debug ) ) { + console[ console.table ? 'table' : 'log' ]( debug ); + } 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 */ + 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 = '', + 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 ( c.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; + // 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 c.debug ? console.warn( 'Warning: *Empty table!* Not building a cache' ) : ''; + } + if ( c.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 && c.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 ( c.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 ( c.debug ) { + 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' ], + // 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 + c.$headers[ i ].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 ) { + $sorted + .eq( column ) + .removeClass( none ) + .addClass( css[ list[ indx ][ 1 ] ] ) + .attr( 'aria-sort', aria[ list[ indx ][ 1 ] ] ) + .find( '.' + ts.css.icon ) + .removeClass( cssIcon[ 2 ] ) + .addClass( cssIcon[ list[ indx ][ 1 ] ] ); + } + } + // add sorted class to footer & extra headers, if they exist + if ( $extras.length ) { + $extras + .filter( '[data-column="' + list[ indx ][ 0 ] + '"]' ) + .removeClass( none ) + .addClass( css[ list[ indx ][ 1 ] ] ); + } + } + } + } + // add verbose aria labels + len = c.$headers.length; + for ( indx = 0; indx < len; indx++ ) { + ts.setColumnAriaLabel( c, c.$headers.eq( indx ) ); + } + }, + + // 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 ); + } + }, + + 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( $.fn.closest ? $cell.closest( 'tbody' ) : $cell.parents( 'tbody' ).filter( ':first' ) ), + tbcache = c.cache[ tbodyIndex ], + $row = $.fn.closest ? $cell.closest( 'tr' ) : $cell.parents( 'tr' ).filter( ':first' ); + 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 ( c.debug ) { + 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 && / 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, + wo = c.widgetOptions, + $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 ( c.debug ) { + 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 || !wo.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 ( c.debug ) { + 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, + // get current column index + col = parseInt( $( cell ).attr( 'data-column' ), 10 ), + order = c.sortVars[ col ].order; + + // 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 ) { + // 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 ]; + } + } + } + // add column to sort list + dir = order[ c.sortVars[ col ].count ]; + if ( dir < 2 ) { + c.sortList[ c.sortList.length ] = [ col, dir ]; + // add other columns if header spans across multiple + if ( cell.colSpan > 1 ) { + for ( indx = 1; indx < cell.colSpan; indx++ ) { + c.sortList[ c.sortList.length ] = [ col + indx, dir ]; + // update count on columns in colSpan + c.sortVars[ col + indx ].count = $.inArray( dir, order ); + } + } + } + // 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 + 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 ]; + if ( dir < 2 ) { + c.sortList[ c.sortList.length ] = [ col, dir ]; + // add other columns if header spans across multiple + if ( cell.colSpan > 1 ) { + for ( indx = 1; indx < cell.colSpan; indx++ ) { + c.sortList[ c.sortList.length ] = [ col + indx, dir ]; + // update count on columns in colSpan + c.sortVars[ col + indx ].count = $.inArray( dir, order ); + } + } + } + } + } + // 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 ]; + } + } + } + } + // 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 ( c.debug ) { 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 ( c.debug ) { + 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 table = c.table; + c.$table.triggerHandler( 'sortStart', table ); + // 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 = []; + ts.setHeadersCss( c ); + ts.multisort( c ); + ts.appendCache( c ); + var indx; + for (indx = 0; indx < c.columns; indx++) { + c.sortVars[ indx ].count = -1; + } + 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, + 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 ( c.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 ( c.debug ) { + console[ console.group ? 'group' : 'log' ]( 'Initializing ' + name + ' widget' ); + } + widget.init( table, widget, c, wo ); + } + } + if ( !init && typeof widget.format === 'function' ) { + applied = true; + if ( c.debug ) { + console[ console.group ? 'group' : 'log' ]( 'Updating ' + name + ' widget' ); + } + widget.format( table, c, wo, false ); + } + if ( c.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, + widgets = []; + // prevent numerous consecutive widget applications + if ( init !== false && table.hasInitialized && ( table.isApplyingWidgets || table.isUpdating ) ) { + return; + } + if ( c.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 ( c.debug ) { + console.warn( '"' + names[ indx ] + '" widget code does not exist!' ); + } + } + // 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 ( c.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 ( c.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 ( c.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 ( c.debug ) { + 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 ); + }, + + // $.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 = $( '' ); + 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( $( '' ).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.filter( '[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( '' ); + 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 ( c.debug ) { + 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 ( c.debug ) { + 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, + debug = c.debug, + $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 ( debug ) { + 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, table ) { + 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, table ) { + 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, table ) { + // 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 ); diff --git a/dist/js/jquery.tablesorter.min.js b/dist/js/jquery.tablesorter.min.js index 3c9abe287..ff3909b5b 100644 --- a/dist/js/jquery.tablesorter.min.js +++ b/dist/js/jquery.tablesorter.min.js @@ -1 +1 @@ -!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(t){"use strict";var r=t.tablesorter={version:"2.28.15",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(e,s){if(e&&e.tHead&&0!==e.tBodies.length&&!0!==e.hasInitialized){var o="",a=t(e),n=t.metadata;e.hasInitialized=!1,e.isProcessing=!0,e.config=s,t.data(e,"tablesorter",s),s.debug&&(console[console.group?"group":"log"]("Initializing tablesorter v"+r.version),t.data(e,"startoveralltimer",new Date)),s.supportsDataObject=function(e){return e[0]=parseInt(e[0],10),e[0]>1||1===e[0]&&parseInt(e[1],10)>=4}(t.fn.jquery.split(".")),s.emptyTo=s.emptyTo.toLowerCase(),s.stringTo=s.stringTo.toLowerCase(),s.last={sortList:[],clickedIndex:-1},/tablesorter\-/.test(a.attr("class"))||(o=""!==s.theme?" tablesorter-"+s.theme:""),s.namespace?s.namespace="."+s.namespace.replace(r.regex.nonWord,""):s.namespace=".tablesorter"+Math.random().toString(16).slice(2),s.table=e,s.$table=a.addClass(r.css.table+" "+s.tableClass+o+" "+s.namespace.slice(1)).attr("role","grid"),s.$headers=a.find(s.selectorHeaders),s.$table.children().children("tr").attr("role","row"),s.$tbodies=a.children("tbody:not(."+s.cssInfoBlock+")").attr({"aria-live":"polite","aria-relevant":"all"}),s.$table.children("caption").length&&((o=s.$table.children("caption")[0]).id||(o.id=s.namespace.slice(1)+"caption"),s.$table.attr("aria-labelledby",o.id)),s.widgetInit={},s.textExtraction=s.$table.attr("data-text-extraction")||s.textExtraction||"basic",r.buildHeaders(s),r.fixColumnWidth(e),r.addWidgetFromClass(e),r.applyWidgetOptions(e),r.setupParsers(s),s.totalRows=0,r.validateOptions(s),s.delayInit||r.buildCache(s),r.bindEvents(e,s.$headers,!0),r.bindMethods(s),s.supportsDataObject&&void 0!==a.data().sortlist?s.sortList=a.data().sortlist:n&&a.metadata()&&a.metadata().sortlist&&(s.sortList=a.metadata().sortlist),r.applyWidget(e,!0),s.sortList.length>0?r.sortOn(s,s.sortList,{},!s.initWidgets):(r.setHeadersCss(s),s.initWidgets&&r.applyWidget(e,!1)),s.showProcessing&&a.unbind("sortBegin"+s.namespace+" sortEnd"+s.namespace).bind("sortBegin"+s.namespace+" sortEnd"+s.namespace,function(t){clearTimeout(s.timerProcessing),r.isProcessing(e),"sortBegin"===t.type&&(s.timerProcessing=setTimeout(function(){r.isProcessing(e,!0)},500))}),e.hasInitialized=!0,e.isProcessing=!1,s.debug&&(console.log("Overall initialization time:"+r.benchmark(t.data(e,"startoveralltimer"))),s.debug&&console.groupEnd&&console.groupEnd()),a.triggerHandler("tablesorter-initialized",e),"function"==typeof s.initialized&&s.initialized(e)}else s.debug&&(e.hasInitialized?console.warn("Stopping initialization. Tablesorter has already been initialized"):console.error("Stopping initialization! No table, thead or tbody",e))},bindMethods:function(e){var s=e.$table,o=e.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(r.regex.spaces," ")).bind("sortReset"+o,function(e,t){e.stopPropagation(),r.sortReset(this.config,function(e){e.isApplyingWidgets?setTimeout(function(){r.applyWidget(e,"",t)},100):r.applyWidget(e,"",t)})}).bind("updateAll"+o,function(e,t,s){e.stopPropagation(),r.updateAll(this.config,t,s)}).bind("update"+o+" updateRows"+o,function(e,t,s){e.stopPropagation(),r.update(this.config,t,s)}).bind("updateHeaders"+o,function(e,t){e.stopPropagation(),r.updateHeaders(this.config,t)}).bind("updateCell"+o,function(e,t,s,o){e.stopPropagation(),r.updateCell(this.config,t,s,o)}).bind("addRows"+o,function(e,t,s,o){e.stopPropagation(),r.addRows(this.config,t,s,o)}).bind("updateComplete"+o,function(){this.isUpdating=!1}).bind("sorton"+o,function(e,t,s,o){e.stopPropagation(),r.sortOn(this.config,t,s,o)}).bind("appendCache"+o,function(e,s,o){e.stopPropagation(),r.appendCache(this.config,o),t.isFunction(s)&&s(this)}).bind("updateCache"+o,function(e,t,s){e.stopPropagation(),r.updateCache(this.config,t,s)}).bind("applyWidgetId"+o,function(e,t){e.stopPropagation(),r.applyWidgetId(this,t)}).bind("applyWidgets"+o,function(e,t){e.stopPropagation(),r.applyWidget(this,t)}).bind("refreshWidgets"+o,function(e,t,s){e.stopPropagation(),r.refreshWidgets(this,t,s)}).bind("removeWidget"+o,function(e,t,s){e.stopPropagation(),r.removeWidget(this,t,s)}).bind("destroy"+o,function(e,t,s){e.stopPropagation(),r.destroy(this,t,s)}).bind("resetToLoadState"+o,function(s){s.stopPropagation(),r.removeWidget(this,!0,!1);var o=t.extend(!0,{},e.originalSettings);(e=t.extend(!0,{},r.defaults,o)).originalSettings=o,this.hasInitialized=!1,r.setup(this,e)})},bindEvents:function(e,s,o){var a,n=(e=t(e)[0]).config,i=n.namespace,l=null;!0!==o&&(s.addClass(i.slice(1)+"_extra_headers"),(a=t.fn.closest?s.closest("table")[0]:s.parents("table")[0])&&"TABLE"===a.nodeName&&a!==e&&t(a).addClass(i.slice(1)+"_extra_table")),a=(n.pointerDown+" "+n.pointerUp+" "+n.pointerClick+" sort keyup ").replace(r.regex.spaces," ").split(" ").join(i+" "),s.find(n.selectorSort).add(s.filter(n.selectorSort)).unbind(a).bind(a,function(e,o){var a,i,d,c=t(e.target),g=" "+e.type+" ";if(!(1!==(e.which||e.button)&&!g.match(" "+n.pointerClick+" | sort | keyup ")||" keyup "===g&&e.which!==r.keyCodes.enter||g.match(" "+n.pointerClick+" ")&&void 0!==e.which||g.match(" "+n.pointerUp+" ")&&l!==e.target&&!0!==o)){if(g.match(" "+n.pointerDown+" "))return l=e.target,void("1"===(d=c.jquery.split("."))[0]&&d[1]<4&&e.preventDefault());if(l=null,r.regex.formElements.test(e.target.nodeName)||c.hasClass(n.cssNoSort)||c.parents("."+n.cssNoSort).length>0||c.parents("button").length>0)return!n.cancelSelection;n.delayInit&&r.isEmptyObject(n.cache)&&r.buildCache(n),a=t.fn.closest?t(this).closest("th, td"):/TH|TD/.test(this.nodeName)?t(this):t(this).parents("th, td"),d=s.index(a),n.last.clickedIndex=d<0?a.attr("data-column"):d,(i=n.$headers[n.last.clickedIndex])&&!i.sortDisabled&&r.initSort(n,i,e)}}),n.cancelSelection&&s.attr("unselectable","on").bind("selectstart",!1).css({"user-select":"none",MozUserSelect:"none"})},buildHeaders:function(e){var s,o,a,n;for(e.headerList=[],e.headerContent=[],e.sortVars=[],e.debug&&(a=new Date),e.columns=r.computeColumnIndex(e.$table.children("thead, tfoot").children("tr")),o=e.cssIcon?'':"",e.$headers=t(t.map(e.$table.find(e.selectorHeaders),function(s,a){var n,i,l,d,c,g=t(s);if(!g.parent().hasClass(e.cssIgnoreRow))return n=r.getColumnData(e.table,e.headers,a,!0),e.headerContent[a]=g.html(),""===e.headerTemplate||g.find("."+r.css.headerIn).length||(d=e.headerTemplate.replace(r.regex.templateContent,g.html()).replace(r.regex.templateIcon,g.find("."+r.css.icon).length?"":o),e.onRenderTemplate&&(i=e.onRenderTemplate.apply(g,[a,d]))&&"string"==typeof i&&(d=i),g.html('
'+d+"
")),e.onRenderHeader&&e.onRenderHeader.apply(g,[a,e,e.$table]),l=parseInt(g.attr("data-column"),10),s.column=l,c=r.getOrder(r.getData(g,n,"sortInitialOrder")||e.sortInitialOrder),e.sortVars[l]={count:-1,order:c?e.sortReset?[1,0,2]:[1,0]:e.sortReset?[0,1,2]:[0,1],lockedOrder:!1},void 0!==(c=r.getData(g,n,"lockedOrder")||!1)&&!1!==c&&(e.sortVars[l].lockedOrder=!0,e.sortVars[l].order=r.getOrder(c)?[1,1]:[0,0]),e.headerList[a]=s,g.addClass(r.css.header+" "+e.cssHeader).parent().addClass(r.css.headerRow+" "+e.cssHeaderRow).attr("role","row"),e.tabIndex&&g.attr("tabindex",0),s})),e.$headerIndexed=[],n=0;n0))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}e.debug&&(r.isEmptyObject(w)?console.warn(" No parsers detected!"):console[console.table?"table":"log"](w),console.log("Completed detecting parsers"+r.benchmark(f)),console.groupEnd&&console.groupEnd()),e.parsers=o.parsers,e.extractors=o.extractors},addParser:function(e){var t,s=r.parsers.length,o=!0;for(t=0;t=0;)if((n=r.parsers[d])&&"text"!==n.id&&n.is&&n.is(g,e.table,c,i))return n;return r.getParserById("text")},getElementText:function(e,s,o){if(!s)return"";var a,n=e.textExtraction||"",i=s.jquery?s:t(s);return"string"==typeof n?"basic"===n&&void 0!==(a=i.attr(e.textAttribute))?t.trim(a):t.trim(s.textContent||i.text()):"function"==typeof n?t.trim(n(i[0],e.table,o)):"function"==typeof(a=r.getColumnData(e.table,n,o))?t.trim(a(i[0],e.table,o)):t.trim(i[0].textContent||i.text())},getParsedText:function(e,t,s,o){void 0===o&&(o=r.getElementText(e,t,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,t,s)),a="no-parser"===n.id?"":n.format(""+o,e.table,t,s),e.ignoreCase&&"string"==typeof a&&(a=a.toLowerCase())),a},buildCache:function(e,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=e.table,L=e.parsers;if(e.$tbodies=e.$table.children("tbody:not(."+e.cssInfoBlock+")"),g=void 0===o?e.$tbodies:o,e.cache={},e.totalRows=0,!L)return e.debug?console.warn("Warning: *Empty table!* Not building a cache"):"";for(e.debug&&(m=new Date),e.showProcessing&&r.isProcessing(T,!0),c=0;c0&&(C+=v,I+=v)),C++;else{for(y.$row=p,y.order=l,C=0,I=e.columns,d=0;d0)){for(R=0;R<=v;)i=e.duplicateSpan||0===R?n:"string"!=typeof e.textExtraction?r.getElementText(e,h,C+R)||"":"",y.raw[C+R]=i,u[C+R]=i,R++;C+=v,I+=v}C++}u[e.columns]=y,a.normalized[a.normalized.length]=u}a.colMax=x,e.totalRows+=a.normalized.length}if(e.showProcessing&&r.isProcessing(T),e.debug){for(D=Math.min(5,e.cache[0].normalized.length),console[console.group?"group":"log"]("Building cache for "+e.totalRows+" rows (showing "+D+" rows in log) and "+e.columns+" columns"+r.benchmark(m)),n={},d=0;d-1);return s}),(p=p.not(".sorter-false").filter('[data-column="'+a[s][0]+'"]'+(1===n?":last":""))).length)){for(o=0;o=0?a:n[1]%g.length}},updateAll:function(e,t,s){var o=e.table;o.isUpdating=!0,r.refreshWidgets(o,!0,!0),r.buildHeaders(e),r.bindEvents(o,e.$headers,!0),r.bindMethods(e),r.commonUpdate(e,t,s)},update:function(e,t,s){e.table.isUpdating=!0,r.updateHeader(e),r.commonUpdate(e,t,s)},updateHeaders:function(e,t){e.table.isUpdating=!0,r.buildHeaders(e),r.bindEvents(e.table,e.$headers,!0),r.resortComplete(e,t)},updateCell:function(e,s,o,a){if(t(s).closest("tr").hasClass(e.cssChildRow))console.warn('Tablesorter Warning! "updateCell" for child row content has been disabled, use "update" instead');else{if(r.isEmptyObject(e.cache))return r.updateHeader(e),void r.commonUpdate(e,o,a);e.table.isUpdating=!0,e.$table.find(e.selectorRemove).remove();var n,i,l,d,c,g,p=e.$tbodies,u=t(s),f=p.index(t.fn.closest?u.closest("tbody"):u.parents("tbody").filter(":first")),h=e.cache[f],m=t.fn.closest?u.closest("tr"):u.parents("tr").filter(":first");if(s=u[0],p.length&&f>=0){if(l=p.eq(f).find("tr").not("."+e.cssChildRow).index(m),c=h.normalized[l],(g=m[0].cells.length)!==e.columns)for(d=0,n=!1,i=0;i0&&(h+=w),h++;b[s.columns]=m,s.cache[d].normalized[f]=b}r.checkResort(s,a,n)}},updateCache:function(e,t,s){e.parsers&&e.parsers.length||r.setupParsers(e,s),r.buildCache(e,t,s)},appendCache:function(e,t){var s,o,a,n,i,l,d,c=e.table,g=e.widgetOptions,p=e.$tbodies,u=[],f=e.cache;if(r.isEmptyObject(f))return e.appender?e.appender(c,u):c.isUpdating?e.$table.triggerHandler("updateComplete",c):"";for(e.debug&&(d=new Date),l=0;l1))for(n=1;n=0)for(n=0;n1))for(n=1;no)return 1}for(s=(e||"").replace(d.chunk,"\\0$1\\0").replace(d.chunks,"").split("\\0"),o=(t||"").replace(d.chunk,"\\0$1\\0").replace(d.chunks,"").split("\\0"),l=Math.max(s.length,o.length),i=0;in)return 1}return 0},sortNaturalAsc:function(e,t,s,o){if(e===t)return 0;var a=r.string[o.empties[s]||o.emptyTo];return""===e&&0!==a?"boolean"==typeof a?a?-1:1:-a||-1:""===t&&0!==a?"boolean"==typeof a?a?1:-1:a||1:r.sortNatural(e,t)},sortNaturalDesc:function(e,t,s,o){if(e===t)return 0;var a=r.string[o.empties[s]||o.emptyTo];return""===e&&0!==a?"boolean"==typeof a?a?-1:1:a||1:""===t&&0!==a?"boolean"==typeof a?a?1:-1:-a||-1:r.sortNatural(t,e)},sortText:function(e,t){return e>t?1:e=0&&!0!==o&&d.widgets.splice(i,1),n&&n.remove&&(d.debug&&console.log((o?"Refreshing":"Removing")+' "'+s[a]+'" widget'),n.remove(e,d,d.widgetOptions,o),d.widgetInit[s[a]]=!1)},refreshWidgets:function(e,s,o){var a,n,i=(e=t(e)[0]).config.widgets,l=r.widgets,d=l.length,c=[],g=function(e){t(e).triggerHandler("refreshComplete")};for(a=0;a'),s=l.$table.width(),n=(a=l.$tbodies.find("tr:first").children(":visible")).length,i=0;i").css("width",o));l.$table.prepend(d)}},getData:function(e,r,s){var o,a,n="",i=t(e);return i.length?(o=!!t.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]||""),t.trim(n)):""},getColumnData:function(e,r,s,o,a){if("object"!=typeof r||null===r)return r;var n,i=(e=t(e)[0]).config,l=a||i.$headers,d=i.$headerIndexed&&i.$headerIndexed[s]||l.filter('[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(e,s,o){var a=(e=t(e))[0].config,n=o||e.find("."+r.css.header);s?(void 0!==o&&a.sortList.length>0&&(n=n.filter(function(){return!this.sortDisabled&&r.isValueInArray(parseFloat(t(this).attr("data-column")),a.sortList)>=0})),e.add(n).addClass(r.css.processing+" "+a.cssProcessing)):e.add(n).removeClass(r.css.processing+" "+a.cssProcessing)},processTbody:function(e,r,s){if(e=t(e)[0],s)return e.isProcessing=!0,r.before(''),t.fn.detach?r.detach():r.remove();var o=t(e).find("colgroup.tablesorter-savemyplace");r.insertAfter(o),o.remove(),e.isProcessing=!1},clearTableBody:function(e){t(e)[0].config.$tbodies.children().detach()},characterEquivalents:{a:"áàâãäąå",A:"ÁÀÂÃÄĄÅ",c:"çćč",C:"ÇĆČ",e:"éèêëěę",E:"ÉÈÊËĚĘ",i:"íìİîïı",I:"ÍÌİÎÏ",o:"óòôõöō",O:"ÓÒÔÕÖŌ",ss:"ß",SS:"ẞ",u:"úùûüů",U:"ÚÙÛÜŮ"},replaceAccents:function(e){var t,s="[",o=r.characterEquivalents;if(!r.characterRegex){r.characterRegexArray={};for(t in o)"string"==typeof t&&(s+=o[t],r.characterRegexArray[t]=new RegExp("["+o[t]+"]","g"));r.characterRegex=new RegExp(s+"]")}if(r.characterRegex.test(e))for(t in o)"string"==typeof t&&(e=e.replace(r.characterRegexArray[t],t));return e},validateOptions:function(e){var s,o,a,n,i="headers sortForce sortList sortAppend widgets".split(" "),l=e.originalSettings;if(l){e.debug&&(n=new Date);for(s in l)if("undefined"===(a=typeof r.defaults[s]))console.warn('Tablesorter Warning! "table.config.'+s+'" option not recognized');else if("object"===a)for(o in l[s])a=r.defaults[s]&&typeof r.defaults[s][o],t.inArray(s,i)<0&&"undefined"===a&&console.warn('Tablesorter Warning! "table.config.'+s+"."+o+'" option not recognized');e.debug&&console.log("validate options time:"+r.benchmark(n))}},restoreHeaders:function(e){var s,o,a=t(e)[0].config,n=a.$table.find(a.selectorHeaders),i=n.length;for(s=0;s tr").children("th, td");!1===s&&t.inArray("uitheme",i.widgets)>=0&&(n.triggerHandler("applyWidgetId",["uitheme"]),n.triggerHandler("applyWidgetId",["zebra"])),d.find("tr").not(c).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(r.regex.spaces," ")),i.$headers.add(g).removeClass([r.css.header,i.cssHeader,i.cssAsc,i.cssDesc,r.css.sortAsc,r.css.sortDesc,r.css.sortNone].join(" ")).removeAttr("data-column").removeAttr("aria-label").attr("aria-disabled","true"),c.find(i.selectorSort).unbind("mousedown mouseup keypress ".split(" ").join(i.namespace+" ").replace(r.regex.spaces," ")),r.restoreHeaders(e),n.toggleClass(r.css.table+" "+i.tableClass+" tablesorter-"+i.theme,!1===s),n.removeClass(i.namespace.slice(1)),e.hasInitialized=!1,delete e.config.cache,"function"==typeof o&&o(e),l&&console.log("tablesorter has been removed")}}};t.fn.tablesorter=function(e){return this.each(function(){var s=this,o=t.extend(!0,{},r.defaults,e,r.instanceMethods);o.originalSettings=e,!s.hasInitialized&&r.buildTable&&"TABLE"!==this.nodeName?r.buildTable(s,o):r.setup(s,o)})},window.console&&window.console.log||(r.logs=[],console={},console.log=console.warn=console.error=console.table=function(){var e=arguments.length>1?arguments:arguments[0];r.logs[r.logs.length]={date:Date.now(),log:e}}),r.addParser({id:"no-parser",is:function(){return!1},format:function(){return""},type:"text"}),r.addParser({id:"text",is:function(){return!0},format:function(e,s){var o=s.config;return e&&(e=t.trim(o.ignoreCase?e.toLocaleLowerCase():e),e=o.sortLocaleCompare?r.replaceAccents(e):e),e},type:"text"}),r.regex.nondigit=/[^\w,. \-()]/g,r.addParser({id:"digit",is:function(e){return r.isDigit(e)},format:function(e,s){var o=r.formatFloat((e||"").replace(r.regex.nondigit,""),s);return e&&"number"==typeof o?o:e?t.trim(e&&s.config.ignoreCase?e.toLocaleLowerCase():e):e},type:"numeric"}),r.regex.currencyReplace=/[+\-,. ]/g,r.regex.currencyTest=/^\(?\d+[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]|[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]\d+\)?$/,r.addParser({id:"currency",is:function(e){return e=(e||"").replace(r.regex.currencyReplace,""),r.regex.currencyTest.test(e)},format:function(e,s){var o=r.formatFloat((e||"").replace(r.regex.nondigit,""),s);return e&&"number"==typeof o?o:e?t.trim(e&&s.config.ignoreCase?e.toLocaleLowerCase():e):e},type:"numeric"}),r.regex.urlProtocolTest=/^(https?|ftp|file):\/\//,r.regex.urlProtocolReplace=/(https?|ftp|file):\/\/(www\.)?/,r.addParser({id:"url",is:function(e){return r.regex.urlProtocolTest.test(e)},format:function(e){return e?t.trim(e.replace(r.regex.urlProtocolReplace,"")):e},type:"text"}),r.regex.dash=/-/g,r.regex.isoDate=/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}/,r.addParser({id:"isoDate",is:function(e){return r.regex.isoDate.test(e)},format:function(e,t){var s=e?new Date(e.replace(r.regex.dash,"/")):e;return s instanceof Date&&isFinite(s)?s.getTime():e},type:"numeric"}),r.regex.percent=/%/g,r.regex.percentTest=/(\d\s*?%|%\s*?\d)/,r.addParser({id:"percent",is:function(e){return r.regex.percentTest.test(e)&&e.length<15},format:function(e,t){return e?r.formatFloat(e.replace(r.regex.percent,""),t):e},type:"numeric"}),r.addParser({id:"image",is:function(e,t,r,s){return s.find("img").length>0},format:function(e,r,s){return t(s).find("img").attr(r.config.imgAttr||"alt")||e},parsed:!0,type:"text"}),r.regex.dateReplace=/(\S)([AP]M)$/i,r.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,r.regex.usLongDateTest2=/^\d{1,2}\s+[A-Z]{3,10}\s+\d{4}/i,r.addParser({id:"usLongDate",is:function(e){return r.regex.usLongDateTest1.test(e)||r.regex.usLongDateTest2.test(e)},format:function(e,t){var s=e?new Date(e.replace(r.regex.dateReplace,"$1 $2")):e;return s instanceof Date&&isFinite(s)?s.getTime():e},type:"numeric"}),r.regex.shortDateTest=/(^\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4})|(^\d{4}[\/\s]\d{1,2}[\/\s]\d{1,2})/,r.regex.shortDateReplace=/[\-.,]/g,r.regex.shortDateXXY=/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/,r.regex.shortDateYMD=/(\d{4})[\/\s](\d{1,2})[\/\s](\d{1,2})/,r.convertFormat=function(e,t){e=(e||"").replace(r.regex.spaces," ").replace(r.regex.shortDateReplace,"/"),"mmddyyyy"===t?e=e.replace(r.regex.shortDateXXY,"$3/$1/$2"):"ddmmyyyy"===t?e=e.replace(r.regex.shortDateXXY,"$3/$2/$1"):"yyyymmdd"===t&&(e=e.replace(r.regex.shortDateYMD,"$1/$2/$3"));var s=new Date(e);return s instanceof Date&&isFinite(s)?s.getTime():""},r.addParser({id:"shortDate",is:function(e){return e=(e||"").replace(r.regex.spaces," ").replace(r.regex.shortDateReplace,"/"),r.regex.shortDateTest.test(e)},format:function(e,t,s,o){if(e){var a=t.config,n=a.$headerIndexed[o],i=n.length&&n.data("dateFormat")||r.getData(n,r.getColumnData(t,a.headers,o),"dateFormat")||a.dateFormat;return n.length&&n.data("dateFormat",i),r.convertFormat(e,i)||e}return e},type:"numeric"}),r.regex.timeTest=/^(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)$|^((?:[01]\d|[2][0-4]):[0-5]\d)$/i,r.regex.timeMatch=/(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)|((?:[01]\d|[2][0-4]):[0-5]\d)/i,r.addParser({id:"time",is:function(e){return r.regex.timeTest.test(e)},format:function(e,t){var s,o=(e||"").match(r.regex.timeMatch),a=new Date(e),n=e&&(null!==o?o[0]:"00:00 AM"),i=n?new Date("2000/01/01 "+n.replace(r.regex.dateReplace,"$1 $2")):n;return i instanceof Date&&isFinite(i)?(s=a instanceof Date&&isFinite(a)?a.getTime():0,s?parseFloat(i.getTime()+"."+a.getTime()):i.getTime()):e},type:"numeric"}),r.addParser({id:"metadata",is:function(){return!1},format:function(e,r,s){var o=r.config,a=o.parserMetadataName?o.parserMetadataName:"sortValue";return t(s).metadata()[a]},type:"numeric"}),r.addWidget({id:"zebra",priority:90,format:function(e,r,s){var o,a,n,i,l,d,c,g=new RegExp(r.cssChildRow,"i"),p=r.$tbodies.add(t(r.namespace+"_extra_table").children("tbody:not(."+r.cssInfoBlock+")"));for(l=0;l 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(e,s){if(e&&e.tHead&&0!==e.tBodies.length&&!0!==e.hasInitialized){var o="",a=t(e),n=t.metadata;e.hasInitialized=!1,e.isProcessing=!0,e.config=s,t.data(e,"tablesorter",s),s.debug&&(console[console.group?"group":"log"]("Initializing tablesorter v"+r.version),t.data(e,"startoveralltimer",new Date)),s.supportsDataObject=function(e){return e[0]=parseInt(e[0],10),e[0]>1||1===e[0]&&parseInt(e[1],10)>=4}(t.fn.jquery.split(".")),s.emptyTo=s.emptyTo.toLowerCase(),s.stringTo=s.stringTo.toLowerCase(),s.last={sortList:[],clickedIndex:-1},/tablesorter\-/.test(a.attr("class"))||(o=""!==s.theme?" tablesorter-"+s.theme:""),s.namespace?s.namespace="."+s.namespace.replace(r.regex.nonWord,""):s.namespace=".tablesorter"+Math.random().toString(16).slice(2),s.table=e,s.$table=a.addClass(r.css.table+" "+s.tableClass+o+" "+s.namespace.slice(1)).attr("role","grid"),s.$headers=a.find(s.selectorHeaders),s.$table.children().children("tr").attr("role","row"),s.$tbodies=a.children("tbody:not(."+s.cssInfoBlock+")").attr({"aria-live":"polite","aria-relevant":"all"}),s.$table.children("caption").length&&((o=s.$table.children("caption")[0]).id||(o.id=s.namespace.slice(1)+"caption"),s.$table.attr("aria-labelledby",o.id)),s.widgetInit={},s.textExtraction=s.$table.attr("data-text-extraction")||s.textExtraction||"basic",r.buildHeaders(s),r.fixColumnWidth(e),r.addWidgetFromClass(e),r.applyWidgetOptions(e),r.setupParsers(s),s.totalRows=0,r.validateOptions(s),s.delayInit||r.buildCache(s),r.bindEvents(e,s.$headers,!0),r.bindMethods(s),s.supportsDataObject&&void 0!==a.data().sortlist?s.sortList=a.data().sortlist:n&&a.metadata()&&a.metadata().sortlist&&(s.sortList=a.metadata().sortlist),r.applyWidget(e,!0),s.sortList.length>0?r.sortOn(s,s.sortList,{},!s.initWidgets):(r.setHeadersCss(s),s.initWidgets&&r.applyWidget(e,!1)),s.showProcessing&&a.unbind("sortBegin"+s.namespace+" sortEnd"+s.namespace).bind("sortBegin"+s.namespace+" sortEnd"+s.namespace,function(t){clearTimeout(s.timerProcessing),r.isProcessing(e),"sortBegin"===t.type&&(s.timerProcessing=setTimeout(function(){r.isProcessing(e,!0)},500))}),e.hasInitialized=!0,e.isProcessing=!1,s.debug&&(console.log("Overall initialization time:"+r.benchmark(t.data(e,"startoveralltimer"))),s.debug&&console.groupEnd&&console.groupEnd()),a.triggerHandler("tablesorter-initialized",e),"function"==typeof s.initialized&&s.initialized(e)}else s.debug&&(e.hasInitialized?console.warn("Stopping initialization. Tablesorter has already been initialized"):console.error("Stopping initialization! No table, thead or tbody",e))},bindMethods:function(e){var s=e.$table,o=e.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(r.regex.spaces," ")).bind("sortReset"+o,function(e,t){e.stopPropagation(),r.sortReset(this.config,function(e){e.isApplyingWidgets?setTimeout(function(){r.applyWidget(e,"",t)},100):r.applyWidget(e,"",t)})}).bind("updateAll"+o,function(e,t,s){e.stopPropagation(),r.updateAll(this.config,t,s)}).bind("update"+o+" updateRows"+o,function(e,t,s){e.stopPropagation(),r.update(this.config,t,s)}).bind("updateHeaders"+o,function(e,t){e.stopPropagation(),r.updateHeaders(this.config,t)}).bind("updateCell"+o,function(e,t,s,o){e.stopPropagation(),r.updateCell(this.config,t,s,o)}).bind("addRows"+o,function(e,t,s,o){e.stopPropagation(),r.addRows(this.config,t,s,o)}).bind("updateComplete"+o,function(){this.isUpdating=!1}).bind("sorton"+o,function(e,t,s,o){e.stopPropagation(),r.sortOn(this.config,t,s,o)}).bind("appendCache"+o,function(e,s,o){e.stopPropagation(),r.appendCache(this.config,o),t.isFunction(s)&&s(this)}).bind("updateCache"+o,function(e,t,s){e.stopPropagation(),r.updateCache(this.config,t,s)}).bind("applyWidgetId"+o,function(e,t){e.stopPropagation(),r.applyWidgetId(this,t)}).bind("applyWidgets"+o,function(e,t){e.stopPropagation(),r.applyWidget(this,t)}).bind("refreshWidgets"+o,function(e,t,s){e.stopPropagation(),r.refreshWidgets(this,t,s)}).bind("removeWidget"+o,function(e,t,s){e.stopPropagation(),r.removeWidget(this,t,s)}).bind("destroy"+o,function(e,t,s){e.stopPropagation(),r.destroy(this,t,s)}).bind("resetToLoadState"+o,function(s){s.stopPropagation(),r.removeWidget(this,!0,!1);var o=t.extend(!0,{},e.originalSettings);(e=t.extend(!0,{},r.defaults,o)).originalSettings=o,this.hasInitialized=!1,r.setup(this,e)})},bindEvents:function(e,s,o){var a,n=(e=t(e)[0]).config,i=n.namespace,l=null;!0!==o&&(s.addClass(i.slice(1)+"_extra_headers"),(a=t.fn.closest?s.closest("table")[0]:s.parents("table")[0])&&"TABLE"===a.nodeName&&a!==e&&t(a).addClass(i.slice(1)+"_extra_table")),a=(n.pointerDown+" "+n.pointerUp+" "+n.pointerClick+" sort keyup ").replace(r.regex.spaces," ").split(" ").join(i+" "),s.find(n.selectorSort).add(s.filter(n.selectorSort)).unbind(a).bind(a,function(e,o){var a,i,d,c=t(e.target),g=" "+e.type+" ";if(!(1!==(e.which||e.button)&&!g.match(" "+n.pointerClick+" | sort | keyup ")||" keyup "===g&&e.which!==r.keyCodes.enter||g.match(" "+n.pointerClick+" ")&&void 0!==e.which||g.match(" "+n.pointerUp+" ")&&l!==e.target&&!0!==o)){if(g.match(" "+n.pointerDown+" "))return l=e.target,void("1"===(d=c.jquery.split("."))[0]&&d[1]<4&&e.preventDefault());if(l=null,r.regex.formElements.test(e.target.nodeName)||c.hasClass(n.cssNoSort)||c.parents("."+n.cssNoSort).length>0||c.parents("button").length>0)return!n.cancelSelection;n.delayInit&&r.isEmptyObject(n.cache)&&r.buildCache(n),a=t.fn.closest?t(this).closest("th, td"):/TH|TD/.test(this.nodeName)?t(this):t(this).parents("th, td"),d=s.index(a),n.last.clickedIndex=d<0?a.attr("data-column"):d,(i=n.$headers[n.last.clickedIndex])&&!i.sortDisabled&&r.initSort(n,i,e)}}),n.cancelSelection&&s.attr("unselectable","on").bind("selectstart",!1).css({"user-select":"none",MozUserSelect:"none"})},buildHeaders:function(e){var s,o,a,n;for(e.headerList=[],e.headerContent=[],e.sortVars=[],e.debug&&(a=new Date),e.columns=r.computeColumnIndex(e.$table.children("thead, tfoot").children("tr")),o=e.cssIcon?'':"",e.$headers=t(t.map(e.$table.find(e.selectorHeaders),function(s,a){var n,i,l,d,c,g=t(s);if(!g.parent().hasClass(e.cssIgnoreRow))return n=r.getColumnData(e.table,e.headers,a,!0),e.headerContent[a]=g.html(),""===e.headerTemplate||g.find("."+r.css.headerIn).length||(d=e.headerTemplate.replace(r.regex.templateContent,g.html()).replace(r.regex.templateIcon,g.find("."+r.css.icon).length?"":o),e.onRenderTemplate&&(i=e.onRenderTemplate.apply(g,[a,d]))&&"string"==typeof i&&(d=i),g.html('
'+d+"
")),e.onRenderHeader&&e.onRenderHeader.apply(g,[a,e,e.$table]),l=parseInt(g.attr("data-column"),10),s.column=l,c=r.getOrder(r.getData(g,n,"sortInitialOrder")||e.sortInitialOrder),e.sortVars[l]={count:-1,order:c?e.sortReset?[1,0,2]:[1,0]:e.sortReset?[0,1,2]:[0,1],lockedOrder:!1},void 0!==(c=r.getData(g,n,"lockedOrder")||!1)&&!1!==c&&(e.sortVars[l].lockedOrder=!0,e.sortVars[l].order=r.getOrder(c)?[1,1]:[0,0]),e.headerList[a]=s,g.addClass(r.css.header+" "+e.cssHeader).parent().addClass(r.css.headerRow+" "+e.cssHeaderRow).attr("role","row"),e.tabIndex&&g.attr("tabindex",0),s})),e.$headerIndexed=[],n=0;n0))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}e.debug&&(r.isEmptyObject(w)?console.warn(" No parsers detected!"):console[console.table?"table":"log"](w),console.log("Completed detecting parsers"+r.benchmark(f)),console.groupEnd&&console.groupEnd()),e.parsers=o.parsers,e.extractors=o.extractors},addParser:function(e){var t,s=r.parsers.length,o=!0;for(t=0;t=0;)if((n=r.parsers[d])&&"text"!==n.id&&n.is&&n.is(g,e.table,c,i))return n;return r.getParserById("text")},getElementText:function(e,s,o){if(!s)return"";var a,n=e.textExtraction||"",i=s.jquery?s:t(s);return"string"==typeof n?"basic"===n&&void 0!==(a=i.attr(e.textAttribute))?t.trim(a):t.trim(s.textContent||i.text()):"function"==typeof n?t.trim(n(i[0],e.table,o)):"function"==typeof(a=r.getColumnData(e.table,n,o))?t.trim(a(i[0],e.table,o)):t.trim(i[0].textContent||i.text())},getParsedText:function(e,t,s,o){void 0===o&&(o=r.getElementText(e,t,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,t,s)),a="no-parser"===n.id?"":n.format(""+o,e.table,t,s),e.ignoreCase&&"string"==typeof a&&(a=a.toLowerCase())),a},buildCache:function(e,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=e.table,L=e.parsers;if(e.$tbodies=e.$table.children("tbody:not(."+e.cssInfoBlock+")"),g=void 0===o?e.$tbodies:o,e.cache={},e.totalRows=0,!L)return e.debug?console.warn("Warning: *Empty table!* Not building a cache"):"";for(e.debug&&(m=new Date),e.showProcessing&&r.isProcessing(T,!0),c=0;c0&&(C+=v,I+=v)),C++;else{for(y.$row=p,y.order=l,C=0,I=e.columns,d=0;d0)){for(R=0;R<=v;)i=e.duplicateSpan||0===R?n:"string"!=typeof e.textExtraction?r.getElementText(e,h,C+R)||"":"",y.raw[C+R]=i,u[C+R]=i,R++;C+=v,I+=v}C++}u[e.columns]=y,a.normalized[a.normalized.length]=u}a.colMax=x,e.totalRows+=a.normalized.length}if(e.showProcessing&&r.isProcessing(T),e.debug){for(D=Math.min(5,e.cache[0].normalized.length),console[console.group?"group":"log"]("Building cache for "+e.totalRows+" rows (showing "+D+" rows in log) and "+e.columns+" columns"+r.benchmark(m)),n={},d=0;d-1);return s}),(p=p.not(".sorter-false").filter('[data-column="'+a[s][0]+'"]'+(1===n?":last":""))).length)){for(o=0;o=0?a:n[1]%g.length}},updateAll:function(e,t,s){var o=e.table;o.isUpdating=!0,r.refreshWidgets(o,!0,!0),r.buildHeaders(e),r.bindEvents(o,e.$headers,!0),r.bindMethods(e),r.commonUpdate(e,t,s)},update:function(e,t,s){e.table.isUpdating=!0,r.updateHeader(e),r.commonUpdate(e,t,s)},updateHeaders:function(e,t){e.table.isUpdating=!0,r.buildHeaders(e),r.bindEvents(e.table,e.$headers,!0),r.resortComplete(e,t)},updateCell:function(e,s,o,a){if(t(s).closest("tr").hasClass(e.cssChildRow))console.warn('Tablesorter Warning! "updateCell" for child row content has been disabled, use "update" instead');else{if(r.isEmptyObject(e.cache))return r.updateHeader(e),void r.commonUpdate(e,o,a);e.table.isUpdating=!0,e.$table.find(e.selectorRemove).remove();var n,i,l,d,c,g,p=e.$tbodies,u=t(s),f=p.index(t.fn.closest?u.closest("tbody"):u.parents("tbody").filter(":first")),h=e.cache[f],m=t.fn.closest?u.closest("tr"):u.parents("tr").filter(":first");if(s=u[0],p.length&&f>=0){if(l=p.eq(f).find("tr").not("."+e.cssChildRow).index(m),c=h.normalized[l],(g=m[0].cells.length)!==e.columns)for(d=0,n=!1,i=0;i0&&(h+=w),h++;b[s.columns]=m,s.cache[d].normalized[f]=b}r.checkResort(s,a,n)}},updateCache:function(e,t,s){e.parsers&&e.parsers.length||r.setupParsers(e,s),r.buildCache(e,t,s)},appendCache:function(e,t){var s,o,a,n,i,l,d,c=e.table,g=e.widgetOptions,p=e.$tbodies,u=[],f=e.cache;if(r.isEmptyObject(f))return e.appender?e.appender(c,u):c.isUpdating?e.$table.triggerHandler("updateComplete",c):"";for(e.debug&&(d=new Date),l=0;l1))for(n=1;n=0)for(n=0;n1))for(n=1;no)return 1}for(s=(e||"").replace(d.chunk,"\\0$1\\0").replace(d.chunks,"").split("\\0"),o=(t||"").replace(d.chunk,"\\0$1\\0").replace(d.chunks,"").split("\\0"),l=Math.max(s.length,o.length),i=0;in)return 1}return 0},sortNaturalAsc:function(e,t,s,o){if(e===t)return 0;var a=r.string[o.empties[s]||o.emptyTo];return""===e&&0!==a?"boolean"==typeof a?a?-1:1:-a||-1:""===t&&0!==a?"boolean"==typeof a?a?1:-1:a||1:r.sortNatural(e,t)},sortNaturalDesc:function(e,t,s,o){if(e===t)return 0;var a=r.string[o.empties[s]||o.emptyTo];return""===e&&0!==a?"boolean"==typeof a?a?-1:1:a||1:""===t&&0!==a?"boolean"==typeof a?a?1:-1:-a||-1:r.sortNatural(t,e)},sortText:function(e,t){return e>t?1:e=0&&!0!==o&&d.widgets.splice(i,1),n&&n.remove&&(d.debug&&console.log((o?"Refreshing":"Removing")+' "'+s[a]+'" widget'),n.remove(e,d,d.widgetOptions,o),d.widgetInit[s[a]]=!1);d.$table.triggerHandler("widgetRemoveEnd",e)},refreshWidgets:function(e,s,o){var a,n,i=(e=t(e)[0]).config.widgets,l=r.widgets,d=l.length,c=[],g=function(e){t(e).triggerHandler("refreshComplete")};for(a=0;a'),s=l.$table.width(),n=(a=l.$tbodies.find("tr:first").children(":visible")).length,i=0;i").css("width",o));l.$table.prepend(d)}},getData:function(e,r,s){var o,a,n="",i=t(e);return i.length?(o=!!t.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]||""),t.trim(n)):""},getColumnData:function(e,r,s,o,a){if("object"!=typeof r||null===r)return r;var n,i=(e=t(e)[0]).config,l=a||i.$headers,d=i.$headerIndexed&&i.$headerIndexed[s]||l.filter('[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(e,s,o){var a=(e=t(e))[0].config,n=o||e.find("."+r.css.header);s?(void 0!==o&&a.sortList.length>0&&(n=n.filter(function(){return!this.sortDisabled&&r.isValueInArray(parseFloat(t(this).attr("data-column")),a.sortList)>=0})),e.add(n).addClass(r.css.processing+" "+a.cssProcessing)):e.add(n).removeClass(r.css.processing+" "+a.cssProcessing)},processTbody:function(e,r,s){if(e=t(e)[0],s)return e.isProcessing=!0,r.before(''),t.fn.detach?r.detach():r.remove();var o=t(e).find("colgroup.tablesorter-savemyplace");r.insertAfter(o),o.remove(),e.isProcessing=!1},clearTableBody:function(e){t(e)[0].config.$tbodies.children().detach()},characterEquivalents:{a:"áàâãäąå",A:"ÁÀÂÃÄĄÅ",c:"çćč",C:"ÇĆČ",e:"éèêëěę",E:"ÉÈÊËĚĘ",i:"íìİîïı",I:"ÍÌİÎÏ",o:"óòôõöō",O:"ÓÒÔÕÖŌ",ss:"ß",SS:"ẞ",u:"úùûüů",U:"ÚÙÛÜŮ"},replaceAccents:function(e){var t,s="[",o=r.characterEquivalents;if(!r.characterRegex){r.characterRegexArray={};for(t in o)"string"==typeof t&&(s+=o[t],r.characterRegexArray[t]=new RegExp("["+o[t]+"]","g"));r.characterRegex=new RegExp(s+"]")}if(r.characterRegex.test(e))for(t in o)"string"==typeof t&&(e=e.replace(r.characterRegexArray[t],t));return e},validateOptions:function(e){var s,o,a,n,i="headers sortForce sortList sortAppend widgets".split(" "),l=e.originalSettings;if(l){e.debug&&(n=new Date);for(s in l)if("undefined"==(a=typeof r.defaults[s]))console.warn('Tablesorter Warning! "table.config.'+s+'" option not recognized');else if("object"===a)for(o in l[s])a=r.defaults[s]&&typeof r.defaults[s][o],t.inArray(s,i)<0&&"undefined"===a&&console.warn('Tablesorter Warning! "table.config.'+s+"."+o+'" option not recognized');e.debug&&console.log("validate options time:"+r.benchmark(n))}},restoreHeaders:function(e){var s,o,a=t(e)[0].config,n=a.$table.find(a.selectorHeaders),i=n.length;for(s=0;s tr").children("th, td");!1===s&&t.inArray("uitheme",i.widgets)>=0&&(n.triggerHandler("applyWidgetId",["uitheme"]),n.triggerHandler("applyWidgetId",["zebra"])),d.find("tr").not(c).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(r.regex.spaces," ")),i.$headers.add(g).removeClass([r.css.header,i.cssHeader,i.cssAsc,i.cssDesc,r.css.sortAsc,r.css.sortDesc,r.css.sortNone].join(" ")).removeAttr("data-column").removeAttr("aria-label").attr("aria-disabled","true"),c.find(i.selectorSort).unbind("mousedown mouseup keypress ".split(" ").join(i.namespace+" ").replace(r.regex.spaces," ")),r.restoreHeaders(e),n.toggleClass(r.css.table+" "+i.tableClass+" tablesorter-"+i.theme,!1===s),n.removeClass(i.namespace.slice(1)),e.hasInitialized=!1,delete e.config.cache,"function"==typeof o&&o(e),l&&console.log("tablesorter has been removed")}}};t.fn.tablesorter=function(e){return this.each(function(){var s=this,o=t.extend(!0,{},r.defaults,e,r.instanceMethods);o.originalSettings=e,!s.hasInitialized&&r.buildTable&&"TABLE"!==this.nodeName?r.buildTable(s,o):r.setup(s,o)})},window.console&&window.console.log||(r.logs=[],console={},console.log=console.warn=console.error=console.table=function(){var e=arguments.length>1?arguments:arguments[0];r.logs[r.logs.length]={date:Date.now(),log:e}}),r.addParser({id:"no-parser",is:function(){return!1},format:function(){return""},type:"text"}),r.addParser({id:"text",is:function(){return!0},format:function(e,s){var o=s.config;return e&&(e=t.trim(o.ignoreCase?e.toLocaleLowerCase():e),e=o.sortLocaleCompare?r.replaceAccents(e):e),e},type:"text"}),r.regex.nondigit=/[^\w,. \-()]/g,r.addParser({id:"digit",is:function(e){return r.isDigit(e)},format:function(e,s){var o=r.formatFloat((e||"").replace(r.regex.nondigit,""),s);return e&&"number"==typeof o?o:e?t.trim(e&&s.config.ignoreCase?e.toLocaleLowerCase():e):e},type:"numeric"}),r.regex.currencyReplace=/[+\-,. ]/g,r.regex.currencyTest=/^\(?\d+[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]|[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]\d+\)?$/,r.addParser({id:"currency",is:function(e){return e=(e||"").replace(r.regex.currencyReplace,""),r.regex.currencyTest.test(e)},format:function(e,s){var o=r.formatFloat((e||"").replace(r.regex.nondigit,""),s);return e&&"number"==typeof o?o:e?t.trim(e&&s.config.ignoreCase?e.toLocaleLowerCase():e):e},type:"numeric"}),r.regex.urlProtocolTest=/^(https?|ftp|file):\/\//,r.regex.urlProtocolReplace=/(https?|ftp|file):\/\/(www\.)?/,r.addParser({id:"url",is:function(e){return r.regex.urlProtocolTest.test(e)},format:function(e){return e?t.trim(e.replace(r.regex.urlProtocolReplace,"")):e},type:"text"}),r.regex.dash=/-/g,r.regex.isoDate=/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}/,r.addParser({id:"isoDate",is:function(e){return r.regex.isoDate.test(e)},format:function(e,t){var s=e?new Date(e.replace(r.regex.dash,"/")):e;return s instanceof Date&&isFinite(s)?s.getTime():e},type:"numeric"}),r.regex.percent=/%/g,r.regex.percentTest=/(\d\s*?%|%\s*?\d)/,r.addParser({id:"percent",is:function(e){return r.regex.percentTest.test(e)&&e.length<15},format:function(e,t){return e?r.formatFloat(e.replace(r.regex.percent,""),t):e},type:"numeric"}),r.addParser({id:"image",is:function(e,t,r,s){return s.find("img").length>0},format:function(e,r,s){return t(s).find("img").attr(r.config.imgAttr||"alt")||e},parsed:!0,type:"text"}),r.regex.dateReplace=/(\S)([AP]M)$/i,r.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,r.regex.usLongDateTest2=/^\d{1,2}\s+[A-Z]{3,10}\s+\d{4}/i,r.addParser({id:"usLongDate",is:function(e){return r.regex.usLongDateTest1.test(e)||r.regex.usLongDateTest2.test(e)},format:function(e,t){var s=e?new Date(e.replace(r.regex.dateReplace,"$1 $2")):e;return s instanceof Date&&isFinite(s)?s.getTime():e},type:"numeric"}),r.regex.shortDateTest=/(^\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4})|(^\d{4}[\/\s]\d{1,2}[\/\s]\d{1,2})/,r.regex.shortDateReplace=/[\-.,]/g,r.regex.shortDateXXY=/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/,r.regex.shortDateYMD=/(\d{4})[\/\s](\d{1,2})[\/\s](\d{1,2})/,r.convertFormat=function(e,t){e=(e||"").replace(r.regex.spaces," ").replace(r.regex.shortDateReplace,"/"),"mmddyyyy"===t?e=e.replace(r.regex.shortDateXXY,"$3/$1/$2"):"ddmmyyyy"===t?e=e.replace(r.regex.shortDateXXY,"$3/$2/$1"):"yyyymmdd"===t&&(e=e.replace(r.regex.shortDateYMD,"$1/$2/$3"));var s=new Date(e);return s instanceof Date&&isFinite(s)?s.getTime():""},r.addParser({id:"shortDate",is:function(e){return e=(e||"").replace(r.regex.spaces," ").replace(r.regex.shortDateReplace,"/"),r.regex.shortDateTest.test(e)},format:function(e,t,s,o){if(e){var a=t.config,n=a.$headerIndexed[o],i=n.length&&n.data("dateFormat")||r.getData(n,r.getColumnData(t,a.headers,o),"dateFormat")||a.dateFormat;return n.length&&n.data("dateFormat",i),r.convertFormat(e,i)||e}return e},type:"numeric"}),r.regex.timeTest=/^(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)$|^((?:[01]\d|[2][0-4]):[0-5]\d)$/i,r.regex.timeMatch=/(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)|((?:[01]\d|[2][0-4]):[0-5]\d)/i,r.addParser({id:"time",is:function(e){return r.regex.timeTest.test(e)},format:function(e,t){var s=(e||"").match(r.regex.timeMatch),o=new Date(e),a=e&&(null!==s?s[0]:"00:00 AM"),n=a?new Date("2000/01/01 "+a.replace(r.regex.dateReplace,"$1 $2")):a;return n instanceof Date&&isFinite(n)?(o instanceof Date&&isFinite(o)?o.getTime():0)?parseFloat(n.getTime()+"."+o.getTime()):n.getTime():e},type:"numeric"}),r.addParser({id:"metadata",is:function(){return!1},format:function(e,r,s){var o=r.config,a=o.parserMetadataName?o.parserMetadataName:"sortValue";return t(s).metadata()[a]},type:"numeric"}),r.addWidget({id:"zebra",priority:90,format:function(e,r,s){var o,a,n,i,l,d,c,g=new RegExp(r.cssChildRow,"i"),p=r.$tbodies.add(t(r.namespace+"_extra_table").children("tbody:not(."+r.cssInfoBlock+")"));for(l=0;l
')}),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;l1)))for(h=1;h=]/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,d=e.extend({},a),f=a.filter.split(r.orSplit),h=a.iFilter.split(r.orSplit),u=f.length;for(s=0;s=f:s>f:r.ltTest.test(l.iFilter)&&(n=r.lteTest.test(l.iFilter)?s<=f:s=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]=?/,gtTest:/>/,gteTest:/>=/,ltTest:/'+(c.data("placeholder")||c.attr("data-placeholder")||g.filter_placeholder.select||"")+"":"",f=n,o=n,n.indexOf(g.filter_selectSourceSeparator)>=0&&(o=(f=n.split(g.filter_selectSourceSeparator))[1],f=f[0]),s+="");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 "),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 i,a,l=r.widgetOptions,s=0,n=function(){l.filter_initialized=!0,r.lastSearch=r.$table.data("lastSearch"),r.$table.triggerHandler("filterInit",r),t.findRows(r.table,r.lastSearch||[])};if(e.isEmptyObject(l.filter_formatter))n();else{for(a=l.filter_formatterInit.length,i=0;i';for(c=0;c1?'").appendTo(l.$table.children("thead").eq(0)).children("td"),c=0;c").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('').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).attr("data-column",n.attr("data-column")),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=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;a1?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=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-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))&&(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.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=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,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={anyMatch:!1,filters:l,filter_regexCache:[]},O={noAnyMatch:["range","operators"],functions:[],excludeFilter:[],defaultColFilter:[],defaultAnyFilter:i.getColumnData(a,A.filter_defaultFilter,H.columns,!0)||""};for(I.parsed=[],g=0;g1&&(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")>=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=void 0!==r&&null!==r&&r>=0&&r'+(y.data("placeholder")||y.attr("data-placeholder")||b.filter_placeholder.select||"")+"",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"}else""+g!="[object Object]"&&(d=f=g=(""+g).replace(r.quote,"""),f.indexOf(b.filter_selectSourceSeparator)>=0&&(d=(h=f.split(b.filter_selectSourceSeparator))[0],f=h[1]),_+=""!==g?"":"");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;a1&&(c=c.slice(1)),n===h.columns&&(c=(d=c.filter(u.filter_anyColumnSelector)).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";function r(t,r){var i=isNaN(r.stickyHeaders_offset)?e(r.stickyHeaders_offset):[];return i.length?i.height()||0:parseInt(r.stickyHeaders_offset,10)||0}var i=e.tablesorter||{};e.extend(i.css,{sticky:"tablesorter-stickyHeader",stickyVis:"tablesorter-sticky-visible",stickyHide:"tablesorter-sticky-hidden",stickyWrap:"tablesorter-sticky-wrapper"}),i.addHeaderResizeEvent=function(t,r,i){if((t=e(t)[0]).config){var a={timer:250},l=e.extend({},a,i),s=t.config,n=s.widgetOptions,o=function(e){var t,r,i,a,l,o,c=s.$headers.length;for(n.resize_flag=!0,r=[],t=0;t=0&&!l.$table.hasClass("hasFilters"))){var n,o,c,d,f=l.$table,h=e(s.stickyHeaders_attachTo),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=r(l,s),_=f.parent().closest("."+i.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 "+i.css.sticky+" "+s.stickyHeaders+" "+l.namespace.slice(1)+"_extra_table").wrap('
'),x=w.parent().addClass(i.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;ia.top&&m=0&&l.$filters&&l.$filters.eq(a).find("a, select, input").filter(":visible").focus())}),i.filter.bindSearch(f,d.find("."+i.css.filter)),s.filter_hideFilters&&i.filter.hideFilters(l,w)),s.stickyHeaders_addResizeEvent&&f.bind("resize"+l.namespace+"stickyheaders",function(){$()}),F(!0),f.triggerHandler("stickyHeadersInit")}},remove:function(r,a,l){var s=a.namespace+"stickyheaders ";a.$table.removeClass("hasStickyHeaders").unbind("pagerComplete resize filterEnd stickyHeadersUpdate ".split(" ").join(s).replace(/\s+/g," ")).next("."+i.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," ")),i.addHeaderResizeEvent(r,!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="";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('
').css({top:d}).insertBefore(o),l=0;l').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;r0){for(n.storedSizes[n.target]+=d,r.resizable.setWidth(n.$target,n.storedSizes[n.target],!0),l=0;l0?i.sortList=d:r.hasInitialized&&d&&d.length>0&&t.sortOn(i,d))},remove:function(e,r){r.$table.removeClass("hasSaveSort"),t.storage&&t.storage(e,"tablesorter-savesort","")}})}(e),e.tablesorter}); \ No newline at end of file +/*! tablesorter (FORK) - updated 07-17-2017 (v2.28.15)*/ +!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(i,a,l,s){var n,o,c,d=!1,f={},h=(i=e(i)[0]).config,u=h&&h.widgetOptions,p=(s&&s.storageType||u&&u.storage_storageType).toString().charAt(0).toLowerCase(),g=p?"":s&&s.useSessionStorage||u&&u.storage_useSessionStorage,m=e(i),b=s&&s.id||m.attr(s&&s.group||u&&u.storage_group||"data-table-group")||u&&u.storage_tableId||i.id||e(".tablesorter").index(m),y=s&&s.url||m.attr(s&&s.page||u&&u.storage_page||"data-table-page")||u&&u.storage_fixedUrl||h&&h.fixedUrl||t.location.pathname;if("c"!==p&&(p="s"===p||g?"sessionStorage":"localStorage")in t)try{t[p].setItem("_tmptest","temp"),d=!0,t[p].removeItem("_tmptest")}catch(e){h&&h.debug&&console.warn(p+" is not supported in this browser")}if(h.debug&&console.log("Storage widget using",d?p:"cookies"),e.parseJSON&&(d?f=e.parseJSON(t[p][a]||"null")||{}:(o=r.cookie.split(/[;\s|=]/),f=0!==(n=e.inArray(a,o)+1)?e.parseJSON(o[n]||"null")||{}:{})),void 0===l||!t.JSON||!JSON.hasOwnProperty("stringify"))return f&&f[y]?f[y][b]:"";f[y]||(f[y]={}),f[y][b]=l,d?t[p][a]=JSON.stringify(f):((c=new Date).setTime(c.getTime()+31536e6),r.cookie=a+"="+JSON.stringify(f).replace(/\"/g,'"')+"; expires="+c.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:"icon-chevron-up glyphicon glyphicon-chevron-up",iconSortDesc:"icon-chevron-down 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(" "));for(i.debug&&(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('
')}),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;l1)))for(h=1;h=]/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,d=e.extend({},a),f=a.filter.split(r.orSplit),h=a.iFilter.split(r.orSplit),u=f.length;for(s=0;s=f:s>f:r.ltTest.test(l.iFilter)&&(n=r.lteTest.test(l.iFilter)?s<=f:s=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]=?/,gtTest:/>/,gteTest:/>=/,ltTest:/'+(c.data("placeholder")||c.attr("data-placeholder")||g.filter_placeholder.select||"")+"":"",f=n,o=n,n.indexOf(g.filter_selectSourceSeparator)>=0&&(o=(f=n.split(g.filter_selectSourceSeparator))[1],f=f[0]),s+="");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 "),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 i,a,l=r.widgetOptions,s=0,n=function(){l.filter_initialized=!0,r.lastSearch=r.$table.data("lastSearch"),r.$table.triggerHandler("filterInit",r),t.findRows(r.table,r.lastSearch||[])};if(e.isEmptyObject(l.filter_formatter))n();else{for(a=l.filter_formatterInit.length,i=0;i';for(c=0;c1?'").appendTo(l.$table.children("thead").eq(0)).children("td"),c=0;c").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('').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).attr("data-column",n.attr("data-column")),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=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;a1?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=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-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))&&(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.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=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,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={anyMatch:!1,filters:l,filter_regexCache:[]},O={noAnyMatch:["range","operators"],functions:[],excludeFilter:[],defaultColFilter:[],defaultAnyFilter:i.getColumnData(a,A.filter_defaultFilter,H.columns,!0)||""};for(I.parsed=[],g=0;g1&&(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")>=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=void 0!==r&&null!==r&&r>=0&&r'+(y.data("placeholder")||y.attr("data-placeholder")||b.filter_placeholder.select||"")+"",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"}else""+g!="[object Object]"&&(d=f=g=(""+g).replace(r.quote,"""),f.indexOf(b.filter_selectSourceSeparator)>=0&&(d=(h=f.split(b.filter_selectSourceSeparator))[0],f=h[1]),_+=""!==g?"":"");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;a1&&(c=c.slice(1)),n===h.columns&&(c=(d=c.filter(u.filter_anyColumnSelector)).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";function r(t,r){var i=isNaN(r.stickyHeaders_offset)?e(r.stickyHeaders_offset):[];return i.length?i.height()||0:parseInt(r.stickyHeaders_offset,10)||0}var i=e.tablesorter||{};e.extend(i.css,{sticky:"tablesorter-stickyHeader",stickyVis:"tablesorter-sticky-visible",stickyHide:"tablesorter-sticky-hidden",stickyWrap:"tablesorter-sticky-wrapper"}),i.addHeaderResizeEvent=function(t,r,i){if((t=e(t)[0]).config){var a={timer:250},l=e.extend({},a,i),s=t.config,n=s.widgetOptions,o=function(e){var t,r,i,a,l,o,c=s.$headers.length;for(n.resize_flag=!0,r=[],t=0;t=0&&!l.$table.hasClass("hasFilters"))){var n,o,c,d,f=l.$table,h=e(s.stickyHeaders_attachTo),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=r(0,s),_=f.parent().closest("."+i.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 "+i.css.sticky+" "+s.stickyHeaders+" "+l.namespace.slice(1)+"_extra_table").wrap('
'),x=w.parent().addClass(i.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;ia.top&&u=0&&l.$filters&&l.$filters.eq(a).find("a, select, input").filter(":visible").focus())}),i.filter.bindSearch(f,d.find("."+i.css.filter)),s.filter_hideFilters&&i.filter.hideFilters(l,w)),s.stickyHeaders_addResizeEvent&&f.bind("resize"+l.namespace+"stickyheaders",function(){$()}),F(!0),f.triggerHandler("stickyHeadersInit")}},remove:function(r,a,l){var s=a.namespace+"stickyheaders ";a.$table.removeClass("hasStickyHeaders").unbind("pagerComplete resize filterEnd stickyHeadersUpdate ".split(" ").join(s).replace(/\s+/g," ")).next("."+i.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," ")),i.addHeaderResizeEvent(r,!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="";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('
').css({top:d}).insertBefore(o),l=0;l').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;r0){for(n.storedSizes[n.target]+=d,r.resizable.setWidth(n.$target,n.storedSizes[n.target],!0),l=0;l0?i.sortList=d:r.hasInitialized&&d&&d.length>0&&t.sortOn(i,d))},remove:function(e,r){r.$table.removeClass("hasSaveSort"),t.storage&&t.storage(e,"tablesorter-savesort","")}})}(e),e.tablesorter}); \ No newline at end of file diff --git a/dist/js/parsers/parser-date-extract.min.js b/dist/js/parsers/parser-date-extract.min.js index d3a7800ea..0eb13903c 100644 --- a/dist/js/parsers/parser-date-extract.min.js +++ b/dist/js/parsers/parser-date-extract.min.js @@ -1,6 +1,6 @@ /*! Parser: Extract out date - updated 10/26/2014 (v2.18.0) */ !function(e){"use strict";var t={usLong:/[A-Z]{3,10}\.?\s+\d{1,2},?\s+(?:\d{4})(?:\s+\d{1,2}:\d{2}(?::\d{2})?(?:\s+[AP]M)?)?/i,mdy:/(\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/i,dmy:/(\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/i,dmyreplace:/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/,ymd:/(\d{4}[\/\s]\d{1,2}[\/\s]\d{1,2}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/i,ymdreplace:/(\d{4})[\/\s](\d{1,2})[\/\s](\d{1,2})/};/*! extract US Long Date */ -e.tablesorter.addParser({id:"extractUSLongDate",is:function(){return!1},format:function(e){var r,a=e?e.match(t.usLong):e;return a?(r=new Date(a[0]),r instanceof Date&&isFinite(r)?r.getTime():e):e},type:"numeric"}),/*! extract MMDDYYYY */ -e.tablesorter.addParser({id:"extractMMDDYYYY",is:function(){return!1},format:function(e){var r,a=e?e.replace(/\s+/g," ").replace(/[\-.,]/g,"/").match(t.mdy):e;return a?(r=new Date(a[0]),r instanceof Date&&isFinite(r)?r.getTime():e):e},type:"numeric"}),/*! extract DDMMYYYY */ -e.tablesorter.addParser({id:"extractDDMMYYYY",is:function(){return!1},format:function(e){var r,a=e?e.replace(/\s+/g," ").replace(/[\-.,]/g,"/").match(t.dmy):e;return a?(r=new Date(a[0].replace(t.dmyreplace,"$2/$1/$3")),r instanceof Date&&isFinite(r)?r.getTime():e):e},type:"numeric"}),/*! extract YYYYMMDD */ -e.tablesorter.addParser({id:"extractYYYYMMDD",is:function(){return!1},format:function(e){var r,a=e?e.replace(/\s+/g," ").replace(/[\-.,]/g,"/").match(t.ymd):e;return a?(r=new Date(a[0].replace(t.ymdreplace,"$2/$3/$1")),r instanceof Date&&isFinite(r)?r.getTime():e):e},type:"numeric"})}(jQuery); \ No newline at end of file +e.tablesorter.addParser({id:"extractUSLongDate",is:function(){return!1},format:function(e){var r,a=e?e.match(t.usLong):e;return a&&(r=new Date(a[0]))instanceof Date&&isFinite(r)?r.getTime():e},type:"numeric"}),/*! extract MMDDYYYY */ +e.tablesorter.addParser({id:"extractMMDDYYYY",is:function(){return!1},format:function(e){var r,a=e?e.replace(/\s+/g," ").replace(/[\-.,]/g,"/").match(t.mdy):e;return a&&(r=new Date(a[0]))instanceof Date&&isFinite(r)?r.getTime():e},type:"numeric"}),/*! extract DDMMYYYY */ +e.tablesorter.addParser({id:"extractDDMMYYYY",is:function(){return!1},format:function(e){var r,a=e?e.replace(/\s+/g," ").replace(/[\-.,]/g,"/").match(t.dmy):e;return a&&(r=new Date(a[0].replace(t.dmyreplace,"$2/$1/$3")))instanceof Date&&isFinite(r)?r.getTime():e},type:"numeric"}),/*! extract YYYYMMDD */ +e.tablesorter.addParser({id:"extractYYYYMMDD",is:function(){return!1},format:function(e){var r,a=e?e.replace(/\s+/g," ").replace(/[\-.,]/g,"/").match(t.ymd):e;return a&&(r=new Date(a[0].replace(t.ymdreplace,"$2/$3/$1")))instanceof Date&&isFinite(r)?r.getTime():e},type:"numeric"})}(jQuery); \ No newline at end of file diff --git a/dist/js/parsers/parser-date-iso8601.min.js b/dist/js/parsers/parser-date-iso8601.min.js index 2bab3e6cf..332450032 100644 --- a/dist/js/parsers/parser-date-iso8601.min.js +++ b/dist/js/parsers/parser-date-iso8601.min.js @@ -1,2 +1,2 @@ /*! Parser: ISO-8601 date - updated 10/26/2014 (v2.18.0) */ -!function(e){"use strict";var t=/^([0-9]{4})(-([0-9]{2})(-([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?$/;e.tablesorter.addParser({id:"iso8601date",is:function(e){return!!e&&e.match(t)},format:function(e){var r=e?e.match(t):e;if(r){var s=new Date(r[1],0,1);return r[3]&&s.setMonth(r[3]-1),r[5]&&s.setDate(r[5]),r[7]&&s.setHours(r[7]),r[8]&&s.setMinutes(r[8]),r[10]&&s.setSeconds(r[10]),r[12]&&s.setMilliseconds(1e3*Number("0."+r[12])),s.getTime()}return e},type:"numeric"})}(jQuery); \ No newline at end of file +!function(e){"use strict";var t=/^([0-9]{4})(-([0-9]{2})(-([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?$/;jQuery.tablesorter.addParser({id:"iso8601date",is:function(e){return!!e&&e.match(t)},format:function(e){var r=e?e.match(t):e;if(r){var s=new Date(r[1],0,1);return r[3]&&s.setMonth(r[3]-1),r[5]&&s.setDate(r[5]),r[7]&&s.setHours(r[7]),r[8]&&s.setMinutes(r[8]),r[10]&&s.setSeconds(r[10]),r[12]&&s.setMilliseconds(1e3*Number("0."+r[12])),s.getTime()}return e},type:"numeric"})}(); \ No newline at end of file diff --git a/dist/js/parsers/parser-date-month.min.js b/dist/js/parsers/parser-date-month.min.js index 763133305..28733350b 100644 --- a/dist/js/parsers/parser-date-month.min.js +++ b/dist/js/parsers/parser-date-month.min.js @@ -1,2 +1,2 @@ /*! Parser: Month - updated 11/22/2015 (v2.24.6) */ -!function(e){"use strict";var t=e.tablesorter;t.dates||(t.dates={}),t.dates.months||(t.dates.months={}),t.dates.months.en={1:"Jan",2:"Feb",3:"Mar",4:"Apr",5:"May",6:"Jun",7:"Jul",8:"Aug",9:"Sep",10:"Oct",11:"Nov",12:"Dec"},t.addParser({id:"month",is:function(){return!1},format:function(e,n,a,r){if(e){var o,s,i=n.config,u=i.globalize&&(i.globalize[r]||i.globalize)||{},c=t.dates.months[u.lang||"en"];i.ignoreCase&&(e=e.toLowerCase());for(s in c)if("string"==typeof s&&(o=c[s],i.ignoreCase&&(o=o.toLowerCase()),e.match(o)))return parseInt(s,10)}return e},type:"numeric"})}(jQuery); \ No newline at end of file +!function(e){"use strict";var t=jQuery.tablesorter;t.dates||(t.dates={}),t.dates.months||(t.dates.months={}),t.dates.months.en={1:"Jan",2:"Feb",3:"Mar",4:"Apr",5:"May",6:"Jun",7:"Jul",8:"Aug",9:"Sep",10:"Oct",11:"Nov",12:"Dec"},t.addParser({id:"month",is:function(){return!1},format:function(e,n,a,r){if(e){var o,s,i=n.config,u=i.globalize&&(i.globalize[r]||i.globalize)||{},c=t.dates.months[u.lang||"en"];i.ignoreCase&&(e=e.toLowerCase());for(s in c)if("string"==typeof s&&(o=c[s],i.ignoreCase&&(o=o.toLowerCase()),e.match(o)))return parseInt(s,10)}return e},type:"numeric"})}(); \ No newline at end of file diff --git a/dist/js/parsers/parser-date-weekday.min.js b/dist/js/parsers/parser-date-weekday.min.js index 509dcd740..3a9950ef5 100644 --- a/dist/js/parsers/parser-date-weekday.min.js +++ b/dist/js/parsers/parser-date-weekday.min.js @@ -1,2 +1,2 @@ /*! Parser: weekday - updated 11/22/2015 (v2.24.6) */ -!function(e){"use strict";var t=e.tablesorter;t.dates||(t.dates={}),t.dates.weekdays||(t.dates.weekdays={}),t.dates.weekdays.en={sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"},t.dates.weekStartList={sun:"1995",mon:"1996",fri:"1999",sat:"2000"},t.dates.weekdaysXref=["sun","mon","tue","wed","thu","fri","sat"],t.addParser({id:"weekday",is:function(){return!1},format:function(a,r,n,s){if(a){var i,d,o,u=r.config,f=u.globalize&&(u.globalize[s]||u.globalize)||{},w=t.dates.weekdays[f.lang||"en"],y=t.dates.weekdaysXref;u.ignoreCase&&(a=a.toLowerCase());for(d in w)if("string"==typeof d&&(i=w[d],u.ignoreCase&&(i=i.toLowerCase()),a.match(i)))return o=e.inArray(d,y),o>-1?o:a}return a},type:"numeric"}),t.addParser({id:"weekday-index",is:function(){return!1},format:function(e,a){if(e){var r=a.config,n=new Date(e);if(n instanceof Date&&isFinite(n))return new Date("1/"+(n.getDay()+1)+"/"+t.dates.weekStartList[r.weekStarts||"sun"])}return e},type:"numeric"})}(jQuery); \ No newline at end of file +!function(e){"use strict";var t=e.tablesorter;t.dates||(t.dates={}),t.dates.weekdays||(t.dates.weekdays={}),t.dates.weekdays.en={sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"},t.dates.weekStartList={sun:"1995",mon:"1996",fri:"1999",sat:"2000"},t.dates.weekdaysXref=["sun","mon","tue","wed","thu","fri","sat"],t.addParser({id:"weekday",is:function(){return!1},format:function(a,r,n,s){if(a){var i,d,o,u=r.config,f=u.globalize&&(u.globalize[s]||u.globalize)||{},w=t.dates.weekdays[f.lang||"en"],y=t.dates.weekdaysXref;u.ignoreCase&&(a=a.toLowerCase());for(d in w)if("string"==typeof d&&(i=w[d],u.ignoreCase&&(i=i.toLowerCase()),a.match(i)))return(o=e.inArray(d,y))>-1?o:a}return a},type:"numeric"}),t.addParser({id:"weekday-index",is:function(){return!1},format:function(e,a){if(e){var r=a.config,n=new Date(e);if(n instanceof Date&&isFinite(n))return new Date("1/"+(n.getDay()+1)+"/"+t.dates.weekStartList[r.weekStarts||"sun"])}return e},type:"numeric"})}(jQuery); \ No newline at end of file diff --git a/dist/js/parsers/parser-globalize.min.js b/dist/js/parsers/parser-globalize.min.js index e42e5986a..8bc4d16cb 100644 --- a/dist/js/parsers/parser-globalize.min.js +++ b/dist/js/parsers/parser-globalize.min.js @@ -1,4 +1,4 @@ /*! Parser: jQuery Globalize - updated 11/2/2015 (v2.24.1) */ !function(e){"use strict";/*! jQuery Globalize date parser (https://github.com/jquery/globalize#date-module) */ -e.tablesorter.addParser({id:"globalize-date",is:function(){return!1},format:function(e,l,a,o){var r,i,t=l.config,n=t.globalize&&(t.globalize[o]||t.globalize)||{};return Globalize&&(r="object"==typeof n.Globalize?n.Globalize:Globalize(n.lang||"en"),n.Globalize||(n.Globalize=r)),i=r&&r.dateParser?r.dateParser(n)(e):e?new Date(e):e,i instanceof Date&&isFinite(i)?i.getTime():e},type:"numeric"}),/*! jQuery Globalize number parser (https://github.com/jquery/globalize#number-module) */ +e.tablesorter.addParser({id:"globalize-date",is:function(){return!1},format:function(e,l,a,o){var r,i,t=l.config,n=t.globalize&&(t.globalize[o]||t.globalize)||{};return Globalize&&(r="object"==typeof n.Globalize?n.Globalize:Globalize(n.lang||"en"),n.Globalize||(n.Globalize=r)),(i=r&&r.dateParser?r.dateParser(n)(e):e?new Date(e):e)instanceof Date&&isFinite(i)?i.getTime():e},type:"numeric"}),/*! jQuery Globalize number parser (https://github.com/jquery/globalize#number-module) */ e.tablesorter.addParser({id:"globalize-number",is:function(){return!1},format:function(l,a,o,r){var i,t,n=a.config,b=n.globalize&&(n.globalize[r]||n.globalize)||{};return Globalize&&(i="object"==typeof b.Globalize?b.Globalize:Globalize(b.lang||"en"),b.Globalize||(b.Globalize=i)),t=i&&i.numberParser?i.numberParser(b)(l):l?e.tablesorter.formatFloat((l||"").replace(/[^\w,. \-()]/g,""),a):l,l&&"number"==typeof t?t:l},type:"numeric"})}(jQuery); \ No newline at end of file diff --git a/dist/js/parsers/parser-huge-numbers.min.js b/dist/js/parsers/parser-huge-numbers.min.js index f570b1a81..be6580a33 100644 --- a/dist/js/parsers/parser-huge-numbers.min.js +++ b/dist/js/parsers/parser-huge-numbers.min.js @@ -1,2 +1,2 @@ /*! Parser: hugeNumbers - updated 3/1/2016 (v2.25.5) */ -!function(e){"use strict";e.tablesorter.addParser({id:"hugeNumbers",is:function(){return!1},format:function(e){return e.replace(/\B(?=(\d{12})+(?!\d))/g,",")},type:"text"})}(jQuery); \ No newline at end of file +!function(e){"use strict";jQuery.tablesorter.addParser({id:"hugeNumbers",is:function(){return!1},format:function(e){return e.replace(/\B(?=(\d{12})+(?!\d))/g,",")},type:"text"})}(); \ No newline at end of file diff --git a/dist/js/parsers/parser-ignore-articles.min.js b/dist/js/parsers/parser-ignore-articles.min.js index 1dba2ed36..e036000cf 100644 --- a/dist/js/parsers/parser-ignore-articles.min.js +++ b/dist/js/parsers/parser-ignore-articles.min.js @@ -1,2 +1,2 @@ /*! Parser: ignoreArticles - updated 9/15/2014 (v2.17.8) */ -!function(e){"use strict";var r=e.tablesorter;r.ignoreArticles={en:"the, a, an",de:"der, die, das, des, dem, den, ein, eine, einer, eines, einem, einen",nl:"de, het, de, een",es:"el, la, lo, los, las, un, una, unos, unas",pt:"o, a, os, as, um, uma, uns, umas",fr:"le, la, l'_, les, un, une, des",it:"il, lo, la, l'_, i, gli, le, un', uno, una, un",hu:"a, az, egy"},r.addParser({id:"ignoreArticles",is:function(){return!1},format:function(s,a,n,i){var t,l,d,o=a.config,g=s||"";return o.headers&&o.headers[i]&&o.headers[i].ignoreArticlesRegex||(o.headers||(o.headers={}),o.headers[i]||(o.headers[i]={}),d=r.getData(o.$headers.eq(i),r.getColumnData(a,o.headers,i),"ignoreArticles"),t=(r.ignoreArticles[d]||"the, a, an")+"",o.headers[i].ignoreArticlesRegex=new RegExp("^("+e.trim(t.split(/\s*\,\s*/).join("\\s|")+"\\s").replace("_\\s","")+")","i"),l=r.getData(o.$headers.eq(i),r.getColumnData(a,o.headers,i),"ignoreArticlesExcept"),o.headers[i].ignoreArticlesRegex2=""!==l?new RegExp("^("+l.replace(/\s/g,"\\s")+")","i"):""),t=o.headers[i].ignoreArticlesRegex,!t.test(g)||(l=o.headers[i].ignoreArticlesRegex2)&&l.test(g)?g:g.replace(t,"")},type:"text"})}(jQuery); \ No newline at end of file +!function(e){"use strict";var r=e.tablesorter;r.ignoreArticles={en:"the, a, an",de:"der, die, das, des, dem, den, ein, eine, einer, eines, einem, einen",nl:"de, het, de, een",es:"el, la, lo, los, las, un, una, unos, unas",pt:"o, a, os, as, um, uma, uns, umas",fr:"le, la, l'_, les, un, une, des",it:"il, lo, la, l'_, i, gli, le, un', uno, una, un",hu:"a, az, egy"},r.addParser({id:"ignoreArticles",is:function(){return!1},format:function(s,a,n,i){var t,l,d,o=a.config,g=s||"";return o.headers&&o.headers[i]&&o.headers[i].ignoreArticlesRegex||(o.headers||(o.headers={}),o.headers[i]||(o.headers[i]={}),d=r.getData(o.$headers.eq(i),r.getColumnData(a,o.headers,i),"ignoreArticles"),t=(r.ignoreArticles[d]||"the, a, an")+"",o.headers[i].ignoreArticlesRegex=new RegExp("^("+e.trim(t.split(/\s*\,\s*/).join("\\s|")+"\\s").replace("_\\s","")+")","i"),l=r.getData(o.$headers.eq(i),r.getColumnData(a,o.headers,i),"ignoreArticlesExcept"),o.headers[i].ignoreArticlesRegex2=""!==l?new RegExp("^("+l.replace(/\s/g,"\\s")+")","i"):""),!(t=o.headers[i].ignoreArticlesRegex).test(g)||(l=o.headers[i].ignoreArticlesRegex2)&&l.test(g)?g:g.replace(t,"")},type:"text"})}(jQuery); \ No newline at end of file diff --git a/dist/js/parsers/parser-input-select.min.js b/dist/js/parsers/parser-input-select.min.js index 8946bbc27..f2408fb6e 100644 --- a/dist/js/parsers/parser-input-select.min.js +++ b/dist/js/parsers/parser-input-select.min.js @@ -1,2 +1,2 @@ /*! Parser: input & select - updated 5/16/2017 (v2.28.10) */ -!function(e){"use strict";e.tablesorter.addParser({id:"inputs",is:function(){return!1},format:function(t,a,r){var n=e(r).find("input");return n.length?n.val():t},parsed:!0,type:"text"}),e.tablesorter.addParser({id:"inputs-numeric",is:function(){return!1},format:function(t,a,r){var n=e(r).find("input"),i=n.length?n.val():t,s=e.tablesorter.formatFloat((i||"").replace(/[^\w,. \-()]/g,""),a);return t&&"number"==typeof s?s:t?e.trim(t&&a.config.ignoreCase?t.toLocaleLowerCase():t):t},parsed:!0,type:"numeric"}),e.tablesorter.addParser({id:"checkbox",is:function(){return!1},format:function(t,a,r){var n=e(r),i=a.config.widgetOptions,s=i.group_checkbox?i.group_checkbox:["checked","unchecked"],o=n.find('input[type="checkbox"]'),c=o.length?o[0].checked:"";return o.length?s[c?0:1]:t},parsed:!0,type:"text"}),e.tablesorter.addParser({id:"select",is:function(){return!1},format:function(t,a,r){var n=e(r).find("select");return n.length?n.val():t},parsed:!0,type:"text"}),e.tablesorter.addParser({id:"select-text",is:function(){return!1},format:function(t,a,r){var n=e(r).find("select");return n.length?n.find("option:selected").text()||"":t},parsed:!0,type:"text"}),e.tablesorter.addParser({id:"textarea",is:function(){return!1},format:function(t,a,r){var n=e(r).find("textarea");return n.length?n.val():t},parsed:!0,type:"text"}),e.tablesorter.defaults.checkboxClass="",e.tablesorter.defaults.checkboxVisible="",e(function(){if(e.fn.on){var t=function(e,t,a,r){e.toggleClass(t+"-"+a,r),(e[0].className||"").match(t+"-")?e.addClass(t):e.removeClass(t)},a=function(e,t){if("INPUT"!==e[0].nodeName&&(e=e.find('input[type="checkbox"]')),e.length){var a=window.navigator.userAgent;"indeterminate"===t?(e.prop("checked",!(a.indexOf("Trident/")>-1||a.indexOf("Edge/")>-1)),e.prop("indeterminate",!0)):(e.prop("checked",t),e.prop("indeterminate",!1))}},r=function(t,r){var n=t.children("tbody").children(":visible"),i=n.length,s=t[0].config.widgetOptions.$sticky;t.children("thead").find('input[type="checkbox"]').each(function(){var t=e(this).closest("td, th").attr("data-column"),o=s.find('[data-column="'+t+'"]'),c=n.filter("."+r+"-"+t).length,l=c===i&&i>0;0===c||l?(a(e(this),l),o&&a(o,l)):(a(e(this),"indeterminate"),o&&a(o,"indeterminate"))})};e("table").on("tablesorter-initialized updateComplete",function(){this.tablesorterBusy=!1;var n=".parser-forms";e(this).addClass(this.config.namespace.slice(1)).children("tbody").off(n).on("mouseleave"+n,function(t){"TBODY"===t.target.nodeName&&e(":focus").blur()}).on("focus"+n,"select, input:not([type=checkbox]), textarea",function(t){var a=e(t.target).closest("tr"),r=a.closest("table")[0].config;!r||r&&r.ignoreChildRow&&a.hasClass(r.cssChildRow)||e(this).data("ts-original-value",this.value)}).on("blur"+n,"input:not([type=checkbox]), textarea",function(t){var a=e(t.target).closest("tr"),r=a.closest("table")[0].config;!r||r&&r.ignoreChildRow&&a.hasClass(r.cssChildRow)||(this.value=e(this).data("ts-original-value"))}).on("change keyup ".split(" ").join(n+" "),"select, input, textarea",function(a){var n=e(this).closest("tr"),i=n.closest("table")[0].config;if(i&&!(i&&i.ignoreChildRow&&n.hasClass(i.cssChildRow)))if(27!==a.which||"INPUT"===this.nodeName&&"checkbox"===this.type){if("change"===a.type||"keyup"===a.type&&13===a.which&&("INPUT"===a.target.nodeName||"TEXTAREA"===a.target.nodeName&&a.altKey)){var s,o=e(a.target),c="checkbox"===a.target.type,l=o.closest("td"),d=l[0].cellIndex,h=i.table.tablesorterBusy,u=i.$headerIndexed&&i.$headerIndexed[d]||[],f=c?a.target.checked:o.val();if(e.isEmptyObject(i)||!1!==h)return;if(c&&(s=i.checkboxClass||"checked",t(l.closest("tr"),s,d,f),r(i.$table,s)),u.length&&(u.hasClass("parser-false")||u.hasClass("sorter-false")&&u.hasClass("filter-false"))||"change"===a.type&&i.table.isUpdating)return;(i&&f!==o.data("ts-original-value")||c)&&(o.data("ts-original-value",f),i.table.tablesorterBusy=!0,e.tablesorter.updateCell(i,l,void 0,function(){i.$table,i.table.tablesorterBusy=!1}))}}else this.value=e(this).data("ts-original-value")}),e(this).children("thead").find('input[type="checkbox"]')&&e(this).off(n).on("tablesorter-ready"+n,function(){var t,a=e(this),n=a.length&&a[0].config;e.isEmptyObject(n)||(this.tablesorterBusy=!0,t=n&&n.checkboxClass||"checked",r(a,t),this.tablesorterBusy=!1)}).children("thead").add(this.config.widgetOptions.$sticky).off(n).on("click.parser-forms change"+n,'input[type="checkbox"]',function(n){var i,s,o,c,l,d,h=e(this),u=this.checked,f=h.closest("table"),p=f.length&&f[0].className.match(/(tablesorter\w+)_extra_table/);return p&&(p=p[1],f=e("."+p+":not(."+p+"_extra_table)")),i=f.length&&f[0].config,!(!f.length||!i||f[0].tablesorterBusy)&&(o=parseInt(h.closest("td, th").attr("data-column"),10),l="checkbox"===i.parsers[o].id,s=i.checkboxVisible,f[0].tablesorterBusy=!0,a(c=f.children("tbody").children("tr"+(void 0===s||!0===s?":visible":"")).children(":nth-child("+(o+1)+")"),u),d=i.checkboxClass||"checked",c.each(function(){t(e(this).closest("tr"),d,o,u)}),p?a(f.children("thead").find('[data-column="'+o+'"]'),u):i.widgetOptions.$sticky&&a(i.widgetOptions.$sticky.find("thead").find('[data-column="'+o+'"]'),u),r(f,d),l?e.tablesorter.update(i,void 0,function(){f[0].tablesorterBusy=!1}):f[0].tablesorterBusy=!1,!0)})})}})}(jQuery); \ No newline at end of file +!function(e){"use strict";var t=function(e,t,a){};e.tablesorter.addParser({id:"inputs",is:function(){return!1},format:function(t,a,r){var n=e(r).find("input");return n.length?n.val():t},parsed:!0,type:"text"}),e.tablesorter.addParser({id:"inputs-numeric",is:function(){return!1},format:function(t,a,r){var n=e(r).find("input"),i=n.length?n.val():t,s=e.tablesorter.formatFloat((i||"").replace(/[^\w,. \-()]/g,""),a);return t&&"number"==typeof s?s:t?e.trim(t&&a.config.ignoreCase?t.toLocaleLowerCase():t):t},parsed:!0,type:"numeric"}),e.tablesorter.addParser({id:"checkbox",is:function(){return!1},format:function(t,a,r){var n=e(r),i=a.config.widgetOptions,s=i.group_checkbox?i.group_checkbox:["checked","unchecked"],o=n.find('input[type="checkbox"]'),c=o.length?o[0].checked:"";return o.length?s[c?0:1]:t},parsed:!0,type:"text"}),e.tablesorter.addParser({id:"select",is:function(){return!1},format:function(t,a,r){var n=e(r).find("select");return n.length?n.val():t},parsed:!0,type:"text"}),e.tablesorter.addParser({id:"select-text",is:function(){return!1},format:function(t,a,r){var n=e(r).find("select");return n.length?n.find("option:selected").text()||"":t},parsed:!0,type:"text"}),e.tablesorter.addParser({id:"textarea",is:function(){return!1},format:function(t,a,r){var n=e(r).find("textarea");return n.length?n.val():t},parsed:!0,type:"text"}),e.tablesorter.defaults.checkboxClass="",e.tablesorter.defaults.checkboxVisible="",e(function(){if(e.fn.on){var a=function(e,t,a,r){e.toggleClass(t+"-"+a,r),(e[0].className||"").match(t+"-")?e.addClass(t):e.removeClass(t)},r=function(e,t){if("INPUT"!==e[0].nodeName&&(e=e.find('input[type="checkbox"]')),e.length){var a=window.navigator.userAgent;"indeterminate"===t?(e.prop("checked",!(a.indexOf("Trident/")>-1||a.indexOf("Edge/")>-1)),e.prop("indeterminate",!0)):(e.prop("checked",t),e.prop("indeterminate",!1))}},n=function(t,a){var n=t.children("tbody").children(":visible"),i=n.length,s=t[0].config.widgetOptions.$sticky;t.children("thead").find('input[type="checkbox"]').each(function(){var t=e(this).closest("td, th").attr("data-column"),o=s.find('[data-column="'+t+'"]'),c=n.filter("."+a+"-"+t).length,l=c===i&&i>0;0===c||l?(r(e(this),l),o&&r(o,l)):(r(e(this),"indeterminate"),o&&r(o,"indeterminate"))})};e("table").on("tablesorter-initialized updateComplete",function(){this.tablesorterBusy=!1;var i=".parser-forms";e(this).addClass(this.config.namespace.slice(1)).children("tbody").off(i).on("mouseleave"+i,function(t){"TBODY"===t.target.nodeName&&e(":focus").blur()}).on("focus"+i,"select, input:not([type=checkbox]), textarea",function(t){var a=e(t.target).closest("tr"),r=a.closest("table")[0].config;!r||r&&r.ignoreChildRow&&a.hasClass(r.cssChildRow)||e(this).data("ts-original-value",this.value)}).on("blur"+i,"input:not([type=checkbox]), textarea",function(t){var a=e(t.target).closest("tr"),r=a.closest("table")[0].config;!r||r&&r.ignoreChildRow&&a.hasClass(r.cssChildRow)||(this.value=e(this).data("ts-original-value"))}).on("change keyup ".split(" ").join(i+" "),"select, input, textarea",function(r){var i=e(this).closest("tr"),s=i.closest("table")[0].config;if(s&&!(s&&s.ignoreChildRow&&i.hasClass(s.cssChildRow)))if(27!==r.which||"INPUT"===this.nodeName&&"checkbox"===this.type){if("change"===r.type||"keyup"===r.type&&13===r.which&&("INPUT"===r.target.nodeName||"TEXTAREA"===r.target.nodeName&&r.altKey)){var o,c=e(r.target),l="checkbox"===r.target.type,d=c.closest("td"),h=d[0].cellIndex,u=s.table.tablesorterBusy,f=s.$headerIndexed&&s.$headerIndexed[h]||[],p=l?r.target.checked:c.val();if(e.isEmptyObject(s)||!1!==u)return;if(l&&(o=s.checkboxClass||"checked",a(d.closest("tr"),o,h,p),n(s.$table,o)),f.length&&(f.hasClass("parser-false")||f.hasClass("sorter-false")&&f.hasClass("filter-false"))||"change"===r.type&&s.table.isUpdating)return;(s&&p!==c.data("ts-original-value")||l)&&(c.data("ts-original-value",p),s.table.tablesorterBusy=!0,e.tablesorter.updateCell(s,d,void 0,function(){t(0,s.$table),s.table.tablesorterBusy=!1}))}}else this.value=e(this).data("ts-original-value")}),e(this).children("thead").find('input[type="checkbox"]')&&e(this).off(i).on("tablesorter-ready"+i,function(){var t,a=e(this),r=a.length&&a[0].config;e.isEmptyObject(r)||(this.tablesorterBusy=!0,t=r&&r.checkboxClass||"checked",n(a,t),this.tablesorterBusy=!1)}).children("thead").add(this.config.widgetOptions.$sticky).off(i).on("click.parser-forms change"+i,'input[type="checkbox"]',function(i){var s,o,c,l,d,h,u=e(this),f=this.checked,p=u.closest("table"),b=p.length&&p[0].className.match(/(tablesorter\w+)_extra_table/);return b&&(b=b[1],p=e("."+b+":not(."+b+"_extra_table)")),s=p.length&&p[0].config,!(!p.length||!s||p[0].tablesorterBusy)&&(c=parseInt(u.closest("td, th").attr("data-column"),10),d="checkbox"===s.parsers[c].id,o=s.checkboxVisible,p[0].tablesorterBusy=!0,r(l=p.children("tbody").children("tr"+(void 0===o||!0===o?":visible":"")).children(":nth-child("+(c+1)+")"),f),h=s.checkboxClass||"checked",l.each(function(){a(e(this).closest("tr"),h,c,f)}),b?r(p.children("thead").find('[data-column="'+c+'"]'),f):s.widgetOptions.$sticky&&r(s.widgetOptions.$sticky.find("thead").find('[data-column="'+c+'"]'),f),n(p,h),d?e.tablesorter.update(s,void 0,function(){t(),p[0].tablesorterBusy=!1}):(t(),p[0].tablesorterBusy=!1),!0)})})}})}(jQuery); \ No newline at end of file diff --git a/dist/js/parsers/parser-leading-zeros.min.js b/dist/js/parsers/parser-leading-zeros.min.js index 19cffcfa6..5aea5bc08 100644 --- a/dist/js/parsers/parser-leading-zeros.min.js +++ b/dist/js/parsers/parser-leading-zeros.min.js @@ -1,2 +1,2 @@ /*! Parser: leading zeros - updated 4/2/2017 (v2.28.6) */ -!function(e){"use strict";var t=e.tablesorter;t.addParser({id:"leadingZeros",is:function(){return!1},format:function(e,r){var n=(e||"").replace(t.regex.nondigit,""),a=t.formatFloat(n,r),i=a.toString();return isNaN(a)||a!=n||n.length===i.length||(a-=1e-10*(e.length-i.length)),a},type:"number"})}(jQuery); \ No newline at end of file +!function(e){"use strict";var t=jQuery.tablesorter;t.addParser({id:"leadingZeros",is:function(){return!1},format:function(e,r){var n=(e||"").replace(t.regex.nondigit,""),a=t.formatFloat(n,r),i=a.toString();return isNaN(a)||a!=n||n.length===i.length||(a-=1e-10*(e.length-i.length)),a},type:"number"})}(); \ No newline at end of file diff --git a/dist/js/parsers/parser-named-numbers.min.js b/dist/js/parsers/parser-named-numbers.min.js index 89c9baaf3..11853d2dd 100644 --- a/dist/js/parsers/parser-named-numbers.min.js +++ b/dist/js/parsers/parser-named-numbers.min.js @@ -1,2 +1,2 @@ /*! Parser: namedNumbers - updated 10/26/2014 (v2.18.0) */ -!function(e){"use strict";var i,n,t={negative:["negative","minus"],numbers:{zero:0,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,thirteen:13,fourteen:14,fifteen:15,sixteen:16,seventeen:17,eighteen:18,nineteen:19,twenty:20,thirty:30,forty:40,fourty:40,fifty:50,sixty:60,seventy:70,eighty:80,ninety:90},hundred:"hundred",powers:{thousand:1e3,million:1e6,billion:1e9,trillion:1e12,quadrillion:1e15,quintillion:1e18,sextillion:1e21,septillion:1e24,octillion:1e27,nonillion:1e30,decillion:1e33,undecillion:1e36,duodecillion:1e39,tredecillion:1e42,quattuordecillion:1e45,quindecillion:1e48,sexdecillion:1e51,septendecillion:1e54,octodecillion:1e57,novemdecillion:1e60,vigintillion:1e63,unvigintillion:1e66,duovigintillion:1e69,trevigintillion:1e72,quattuorvigintillion:1e75,quinvigintillion:1e78,sexvigintillion:1e81,septenvigintillion:1e84,octovigintillion:1e87,novemvigintillion:1e90,trigintillion:1e93,untrigintillion:1e96,duotrigintillion:1e99,googl:1e100}},l=new RegExp("("+t.negative.join("|")+")"),o=function(l,o){var r=l.replace(/[,."']/g,""),u=e.tablesorter.formatFloat(l||"",o),s=t.powers.hasOwnProperty(r)?t.powers[r]:null;null!==(u="number"==typeof u?u:t.numbers.hasOwnProperty(r)?t.numbers[r]:null)?n+=u:r===t.hundred?n*=100:null!==s&&(i+=n*s,n=0)};e.tablesorter.addParser({id:"namedNumbers",is:function(){return!1},format:function(r,u){i=0,n=0;var s,a=(r||"").split(/[\s-]+/),d=a.length;for(s=0;s"+o+"
").text().replace(/\{content\}/g,"").trim(),l=l.replace(i,"")),l=e.formatFloat(l.replace(/[^\w,. \-()]/g,""),a.table)||0,isNaN(l)?0:l},getRow:function(e,a,r){var i,l=e.widgetOptions,o=[],h=a.closest("tr"),s=h.hasClass(l.filter_filteredRow||"filtered");return r&&(h=h.filter(r)),!r&&s||(i=h.children().not("["+l.math_dataAttrib+"=ignore]"),l.math_ignore.length&&(i=i.filter(function(){return-1===t.inArray(n.getCellIndex(t(this)),l.math_ignore)})),o=i.not(a).map(function(){return n.processText(e,t(this))}).get()),o},getColumn:function(e,a,r,i){var l,o,h,s,d,u,c=e.widgetOptions,g=[],f=a.closest("tr"),m=c.math_dataAttrib,p="["+m+"=ignore]",_=c.filter_filteredRow||"filtered",b=n.getCellIndex(a),v=e.$table.children("tbody").children(),x=["["+m+"^=above]","["+m+"^=below]","["+m+"^=col]","["+m+"^=all]"];if("above"===r)for(l=s=v.index(f);l>=0;)u=(h=v.eq(l)).children().filter(x[0]).length,i&&(h=h.filter(i)),o=h.children().filter(function(){return n.getCellIndex(t(this))===b}),((i||!h.hasClass(_))&&h.not(p).length&&l!==s||u&&l!==s)&&(u?l=0:o.length&&(g[g.length]=n.processText(e,o))),l--;else if("below"===r)for(s=v.length,l=v.index(f)+1;l0;if(a>1?(a--,i=!0):a<1&&(a=1),r.children("[rowspan]").length>0)for(e=this.cells,n=0;n0?t.substring(0,w):"",y=C;if(n&&(y=/\{content\}/.test(n||"")?(n||"").replace(/\{content\}/g,C||""):(n||"")+C),b=t.split("").reverse().join(""),_=b.search(/[0-9\-\+#]/),p=x-_,p+="."===t.substring(p,p+1)?1:0,C=_>0?t.substring(p,x):"",v=C,a&&(v=/\{content\}/.test(a||"")?(a||"").replace(/\{content\}/g,C||""):C+(a||"")),t=t.substring(w,p),e="-"==t.charAt(0)?-e:+e,r=e<0?e=-e:0,i=t.match(/[^\d\-\+#]/g),l=i&&i[i.length-1]||".",o=i&&i[1]&&i[0]||",",t=t.split(l),e=e.toFixed(t[1]&&t[1].length),e=+e+"",s=t[1]&&t[1].lastIndexOf("0"),(!(u=e.split("."))[1]||u[1]&&u[1].length<=s)&&(e=(+e).toFixed(s+1)),c=t[0].split(o),t[0]=c.join(""),(h=t[0]&&t[0].indexOf("0"))>-1)for(;u[0].length1?(t.sort(function(t,e){return t-e}),a=Math.floor(r/2),r%2?t[a]:(t[a-1]+t[a])/2):n.invalid(e,"median",1)},mode:function(t){var e,n,a,r={},i=1,l=[t[0]];for(e=0;ei?(l=[n],i=a):a===i&&(l[l.length]=n,i=a);return l.sort(function(t,e){return t-e})},max:function(t){return Math.max.apply(Math,t)},min:function(t){return Math.min.apply(Math,t)},range:function(t){var e=t.sort(function(t,e){return t-e});return e[t.length-1]-e[0]},variance:function(t,a,r){for(var i,l=e.equations.mean(t),o=0,h=t.length;h--;)o+=Math.pow(t[h]-l,2);return 0===(i=t.length-(a?0:1))?n.invalid(r,"variance",0):o/=i},varp:function(t,n){return e.equations.variance(t,!0,n)},vars:function(t,n){return e.equations.variance(t,!1,n)},stdevs:function(t,n){var a=e.equations.variance(t,!1,n);return Math.sqrt(a)},stdevp:function(t,n){var a=e.equations.variance(t,!0,n);return Math.sqrt(a)}},e.addWidget({id:"math",priority:100,options:{math_data:"math",math_debug:!1,math_ignore:[],math_mask:"#,##0.00",math_complete:null,math_completed:function(t){},math_priority:["row","above","below","col"],math_prefix:"",math_suffix:"",math_none:"N/A",math_event:"recalculate",math_rowFilter:""},init:function(t,a,r,i){var l=(e.hasWidget(t,"filter")?"filterEnd":"updateComplete")+".tsmath";n.events+=(e.hasWidget(t,"pager")?"pagerComplete":"filterEnd")+".tsmath ",r.$table.off((n.events+"updateComplete.tsmath "+i.math_event).replace(/\s+/g," ")).on(n.events+i.math_event,function(t){if(this.hasInitialized){var e="tablesorter-initialized"===t.type;i.math_isUpdating&&!e||(/filter/.test(t.type)||e||n.setColumnIndexes(r),n.recalculate(r,i,e))}}).on(l,function(){setTimeout(function(){n.updateComplete(r)},40)}),i.math_isUpdating=!1,t.hasInitialized&&n.recalculate(r,i,!0)},remove:function(t,e,a,r){r||e.$table.off((n.events+" updateComplete.tsmath "+a.math_event).replace(/\s+/g," ")).children().children("tr").children("[data-"+a.math_data+"]").empty()}})}(jQuery); \ No newline at end of file +!function(t){"use strict";var e=t.tablesorter,n={error:{0:"Infinity result: Divide by zero",1:"Need more than one element to make this calculation",undef:"No elements found"},invalid:function(t,e,a){return console.warn(e,n.error[a]),t&&t.widgetOptions.math_none||""},events:"tablesorter-initialized update updateAll updateRows addRows updateCell filterReset ".split(" ").join(".tsmath "),processText:function(a,r){var i,l=e.getElementText(a,r,n.getCellIndex(r)),o=a.widgetOptions.math_prefix;return/"+o+"
").text().replace(/\{content\}/g,"").trim(),l=l.replace(i,"")),l=e.formatFloat(l.replace(/[^\w,. \-()]/g,""),a.table)||0,isNaN(l)?0:l},getRow:function(e,a,r){var i,l=e.widgetOptions,o=[],h=a.closest("tr"),s=h.hasClass(l.filter_filteredRow||"filtered");return r&&(h=h.filter(r)),!r&&s||(i=h.children().not("["+l.math_dataAttrib+"=ignore]"),l.math_ignore.length&&(i=i.filter(function(){return-1===t.inArray(n.getCellIndex(t(this)),l.math_ignore)})),o=i.not(a).map(function(){return n.processText(e,t(this))}).get()),o},getColumn:function(e,a,r,i){var l,o,h,s,d,u,c=e.widgetOptions,g=[],f=a.closest("tr"),m=c.math_dataAttrib,p="["+m+"=ignore]",_=c.filter_filteredRow||"filtered",b=n.getCellIndex(a),v=e.$table.children("tbody").children(),x=["["+m+"^=above]","["+m+"^=below]","["+m+"^=col]","["+m+"^=all]"];if("above"===r)for(l=s=v.index(f);l>=0;)u=(h=v.eq(l)).children().filter(x[0]).length,i&&(h=h.filter(i)),o=h.children().filter(function(){return n.getCellIndex(t(this))===b}),((i||!h.hasClass(_))&&h.not(p).length&&l!==s||u&&l!==s)&&(u?l=0:o.length&&(g[g.length]=n.processText(e,o))),l--;else if("below"===r)for(s=v.length,l=v.index(f)+1;l0;if(a>1?(a--,i=!0):a<1&&(a=1),r.children("[rowspan]").length>0)for(e=this.cells,n=0;n0?t.substring(0,w):"",y=C;if(n&&(y=/\{content\}/.test(n||"")?(n||"").replace(/\{content\}/g,C||""):(n||"")+C),b=t.split("").reverse().join(""),_=b.search(/[0-9\-\+#]/),p=x-_,p+="."===t.substring(p,p+1)?1:0,C=_>0?t.substring(p,x):"",v=C,a&&(v=/\{content\}/.test(a||"")?(a||"").replace(/\{content\}/g,C||""):C+(a||"")),t=t.substring(w,p),e="-"==t.charAt(0)?-e:+e,r=e<0?e=-e:0,i=t.match(/[^\d\-\+#]/g),l=i&&i[i.length-1]||".",o=i&&i[1]&&i[0]||",",t=t.split(l),e=e.toFixed(t[1]&&t[1].length),e=+e+"",s=t[1]&&t[1].lastIndexOf("0"),(!(u=e.split("."))[1]||u[1]&&u[1].length<=s)&&(e=(+e).toFixed(s+1)),c=t[0].split(o),t[0]=c.join(""),(h=t[0]&&t[0].indexOf("0"))>-1)for(;u[0].length1?(t.sort(function(t,e){return t-e}),a=Math.floor(r/2),r%2?t[a]:(t[a-1]+t[a])/2):n.invalid(e,"median",1)},mode:function(t){var e,n,a,r={},i=1,l=[t[0]];for(e=0;ei?(l=[n],i=a):a===i&&(l[l.length]=n,i=a);return l.sort(function(t,e){return t-e})},max:function(t){return Math.max.apply(Math,t)},min:function(t){return Math.min.apply(Math,t)},range:function(t){var e=t.sort(function(t,e){return t-e});return e[t.length-1]-e[0]},variance:function(t,a,r){for(var i,l=e.equations.mean(t),o=0,h=t.length;h--;)o+=Math.pow(t[h]-l,2);return 0==(i=t.length-(a?0:1))?n.invalid(r,"variance",0):o/=i},varp:function(t,n){return e.equations.variance(t,!0,n)},vars:function(t,n){return e.equations.variance(t,!1,n)},stdevs:function(t,n){var a=e.equations.variance(t,!1,n);return Math.sqrt(a)},stdevp:function(t,n){var a=e.equations.variance(t,!0,n);return Math.sqrt(a)}},e.addWidget({id:"math",priority:100,options:{math_data:"math",math_debug:!1,math_ignore:[],math_mask:"#,##0.00",math_complete:null,math_completed:function(t){},math_priority:["row","above","below","col"],math_prefix:"",math_suffix:"",math_none:"N/A",math_event:"recalculate",math_rowFilter:""},init:function(t,a,r,i){var l=(e.hasWidget(t,"filter")?"filterEnd":"updateComplete")+".tsmath";n.events+=(e.hasWidget(t,"pager")?"pagerComplete":"filterEnd")+".tsmath ",r.$table.off((n.events+"updateComplete.tsmath "+i.math_event).replace(/\s+/g," ")).on(n.events+i.math_event,function(t){if(this.hasInitialized){var e="tablesorter-initialized"===t.type;i.math_isUpdating&&!e||(/filter/.test(t.type)||e||n.setColumnIndexes(r),n.recalculate(r,i,e))}}).on(l,function(){setTimeout(function(){n.updateComplete(r)},40)}),i.math_isUpdating=!1,t.hasInitialized&&n.recalculate(r,i,!0)},remove:function(t,e,a,r){r||e.$table.off((n.events+" updateComplete.tsmath "+a.math_event).replace(/\s+/g," ")).children().children("tr").children("[data-"+a.math_data+"]").empty()}})}(jQuery); \ No newline at end of file diff --git a/dist/js/widgets/widget-pager.min.js b/dist/js/widgets/widget-pager.min.js index 80e66fd18..3900f56ca 100644 --- a/dist/js/widgets/widget-pager.min.js +++ b/dist/js/widgets/widget-pager.min.js @@ -1,2 +1,2 @@ /*! Widget: Pager - updated 5/24/2017 (v2.28.11) */ -!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[0,[],null]},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.isInitializing||(n.isInitializing=!0,s.debug&&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),e.debug&&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;r.$table.off(l).on("filterInit filterStart ".split(" ").join(l+" "),function(i,s){g.currentFilters=e.isArray(s)?s:r.$table.data("lastSearch");var o;if(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,a){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"],r.debug&&!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> 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})):r.debug&&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=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'):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'+n[l]+"";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&&(r.debug&&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(''))},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(' '),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){e.table;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=d&&u=d&&u0&&i[o].className.match(t.css.cssHasChild))for(;++o> 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(C)?(j=C[(f=isNaN(C[0])&&!isNaN(C[1]))?1:0],l.totalRows=isNaN(j)?l.totalRows||0:j,i.totalRows=i.filteredRows=l.filteredRows=l.totalRows,v=0===l.totalRows?[]:C[f?0:1]||[],R=C[2]):(l.ajaxData=C,i.totalRows=l.totalRows=C.total,i.filteredRows=l.filteredRows=void 0!==C.filteredRows?C.filteredRows:C.total,R=C.headers,v=C.rows||[]),m=v&&v.length,v instanceof jQuery)p.pager_processAjaxOnInit&&(i.$tbodies.eq(0).empty(),i.$tbodies.eq(0).append(v));else if(m){for(d=0;d",c=0;c"+v[d][c]+"";S+=""}p.pager_processAjaxOnInit&&i.$tbodies.eq(0).html(S)}if(p.pager_processAjaxOnInit=!0,R){for(w=(u=y.hasClass("hasStickyHeaders"))?p.$sticky.children("thead:first").children("tr:not(."+i.cssIgnoreRow+")").children():"",h=y.find("tfoot tr:first").children(),x=(P=i.$headers.filter("th")).length,c=0;c> 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&&(e.debug&&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=d?0:u,o=d?0:u,g=0;gu&&g<=f&&(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&&(e.debug&&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.totalPages,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),r.debug&&console.log("Pager: Disabled")),o=(s=n.$container.find(l.pager_selectors.pageSize+","+l.pager_selectors.gotoPage+",.ts-startRow, .ts-page")).length,i=0;ir&&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<=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),r.debug&&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:''+d+"").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); \ No newline at end of file +!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[0,[],null]},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.isInitializing||(n.isInitializing=!0,s.debug&&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),e.debug&&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;r.$table.off(l).on("filterInit filterStart ".split(" ").join(l+" "),function(i,s){g.currentFilters=e.isArray(s)?s:r.$table.data("lastSearch");var o;if(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,a){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"],r.debug&&!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> 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})):r.debug&&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=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'):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'+n[l]+"";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&&(r.debug&&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(''))},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(' '),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){e.table;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=d&&u=d&&u0&&i[o].className.match(t.css.cssHasChild))for(;++o> 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(C)?(j=C[(f=isNaN(C[0])&&!isNaN(C[1]))?1:0],l.totalRows=isNaN(j)?l.totalRows||0:j,i.totalRows=i.filteredRows=l.filteredRows=l.totalRows,v=0===l.totalRows?[]:C[f?0:1]||[],R=C[2]):(l.ajaxData=C,i.totalRows=l.totalRows=C.total,i.filteredRows=l.filteredRows=void 0!==C.filteredRows?C.filteredRows:C.total,R=C.headers,v=C.rows||[]),m=v&&v.length,v instanceof jQuery)p.pager_processAjaxOnInit&&(i.$tbodies.eq(0).empty(),i.$tbodies.eq(0).append(v));else if(m){for(d=0;d",c=0;c"+v[d][c]+"";S+=""}p.pager_processAjaxOnInit&&i.$tbodies.eq(0).html(S)}if(p.pager_processAjaxOnInit=!0,R){for(w=(u=y.hasClass("hasStickyHeaders"))?p.$sticky.children("thead:first").children("tr:not(."+i.cssIgnoreRow+")").children():"",h=y.find("tfoot tr:first").children(),x=(P=i.$headers.filter("th")).length,c=0;c> 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&&(e.debug&&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=d?0:u,o=d?0:u,g=0;gu&&g<=f&&(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&&(e.debug&&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.totalPages,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),r.debug&&console.log("Pager: Disabled")),o=(s=n.$container.find(l.pager_selectors.pageSize+","+l.pager_selectors.gotoPage+",.ts-startRow, .ts-page")).length,i=0;ir&&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),r.debug&&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:''+d+"").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); \ No newline at end of file diff --git a/dist/js/widgets/widget-sortTbodies.min.js b/dist/js/widgets/widget-sortTbodies.min.js index 76f6f74b6..ca1e5e63f 100644 --- a/dist/js/widgets/widget-sortTbodies.min.js +++ b/dist/js/widgets/widget-sortTbodies.min.js @@ -3,4 +3,4 @@ * by Rob Garrison * Contributors: Chris Rogers */ -!function(t){"use strict";var o=t.tablesorter;o.sortTbodies={init:function(r,e){var s,n,i,d,a,b=r.namespace+"sortTbody",l=r.$table.children("tbody"),c=l.length;for(e.sortTbody_original_serverSideSorting=r.serverSideSorting,e.sortTbody_original_cssInfoBlock=r.cssInfoBlock,r.cssInfoBlock=e.sortTbody_noSort,o.sortTbodies.setTbodies(r,e),s=0;s=i?i:b<0?0:b)!==e.eq(a).index()&&(c=!0,n=e.eq(a).detach(),b>=i?n.appendTo(l):0===b?n.prependTo(l):n.insertBefore(l.children("tbody:eq("+b+")")));y++}l.show()}},o.addWidget({id:"sortTbody",priority:40,options:{sortTbody_lockHead:!1,sortTbody_primaryRow:null,sortTbody_sortRows:!1,sortTbody_noSort:"tablesorter-no-sort-tbody"},init:function(t,r,e,s){o.sortTbodies.init(e,s)},remove:function(t,o,r,e){o.$table.unbind("sortBegin updateComplete ".split(" ").join(o.namespace+"sortTbody ")),o.serverSideSorting=r.sortTbody_original_serverSideSorting,o.cssInfoBlock=r.sortTbody_original_cssInfoBlock}})}(jQuery); \ No newline at end of file +!function(t){"use strict";var o=t.tablesorter;o.sortTbodies={init:function(r,e){var s,n,i,d,a,b=r.namespace+"sortTbody",l=r.$table.children("tbody"),c=l.length;for(e.sortTbody_original_serverSideSorting=r.serverSideSorting,e.sortTbody_original_cssInfoBlock=r.cssInfoBlock,r.cssInfoBlock=e.sortTbody_noSort,o.sortTbodies.setTbodies(r,e),s=0;s=i?i:b<0?0:b)!==e.eq(a).index()&&(c=!0,n=e.eq(a).detach(),b>=i?n.appendTo(l):0===b?n.prependTo(l):n.insertBefore(l.children("tbody:eq("+b+")")));y++}l.show()}},o.addWidget({id:"sortTbody",priority:40,options:{sortTbody_lockHead:!1,sortTbody_primaryRow:null,sortTbody_sortRows:!1,sortTbody_noSort:"tablesorter-no-sort-tbody"},init:function(t,r,e,s){o.sortTbodies.init(e,s)},remove:function(t,o,r,e){o.$table.unbind("sortBegin updateComplete ".split(" ").join(o.namespace+"sortTbody ")),o.serverSideSorting=r.sortTbody_original_serverSideSorting,o.cssInfoBlock=r.sortTbody_original_cssInfoBlock}})}(jQuery); \ No newline at end of file diff --git a/dist/js/widgets/widget-stickyHeaders.min.js b/dist/js/widgets/widget-stickyHeaders.min.js index 7aedad304..06ecab8b6 100644 --- a/dist/js/widgets/widget-stickyHeaders.min.js +++ b/dist/js/widgets/widget-stickyHeaders.min.js @@ -1,2 +1,2 @@ /*! Widget: stickyHeaders - updated 6/2/2017 (v2.28.13) */ -!function(e,s){"use strict";function t(s,t){var i=isNaN(t.stickyHeaders_offset)?e(t.stickyHeaders_offset):[];return i.length?i.height()||0:parseInt(t.stickyHeaders_offset,10)||0}var i=e.tablesorter||{};e.extend(i.css,{sticky:"tablesorter-stickyHeader",stickyVis:"tablesorter-sticky-visible",stickyHide:"tablesorter-sticky-hidden",stickyWrap:"tablesorter-sticky-wrapper"}),i.addHeaderResizeEvent=function(s,t,i){if((s=e(s)[0]).config){var r={timer:250},a=e.extend({},r,i),d=s.config,c=d.widgetOptions,l=function(e){var s,t,i,r,a,l,n=d.$headers.length;for(c.resize_flag=!0,t=[],s=0;s=0&&!a.$table.hasClass("hasFilters"))){var c,l,n,o,f=a.$table,p=e(d.stickyHeaders_attachTo),h=a.namespace+"stickyheaders ",y=e(d.stickyHeaders_yScroll||d.stickyHeaders_attachTo||s),k=e(d.stickyHeaders_xScroll||d.stickyHeaders_attachTo||s),g=f.children("thead:first").children("tr").not(".sticky-false").children(),H=f.children("tfoot"),b=t(a,d),u=f.parent().closest("."+i.css.table).hasClass("hasStickyHeaders")?f.parent().closest("table.tablesorter")[0].config.widgetOptions.$sticky.parent():[],_=u.length?u.height():0,v=d.$sticky=f.clone().addClass("containsStickyHeaders "+i.css.sticky+" "+d.stickyHeaders+" "+a.namespace.slice(1)+"_extra_table").wrap('
'),m=v.parent().addClass(i.css.stickyHide).css({position:p.length?"absolute":"fixed",padding:parseInt(v.parent().parent().css("padding-left"),10),top:b+_,left:0,visibility:"hidden",zIndex:d.stickyHeaders_zIndex||2}),z=v.children("thead:first"),C="",w=function(e,t){var i,r,a,d,c,l=e.filter(":visible"),n=l.length;for(i=0;ir.top&&g=0&&a.$filters&&a.$filters.eq(r).find("a, select, input").filter(":visible").focus())}),i.filter.bindSearch(f,o.find("."+i.css.filter)),d.filter_hideFilters&&i.filter.hideFilters(a,v)),d.stickyHeaders_addResizeEvent&&f.bind("resize"+a.namespace+"stickyheaders",function(){T()}),S(!0),f.triggerHandler("stickyHeadersInit")}},remove:function(t,r,a){var d=r.namespace+"stickyheaders ";r.$table.removeClass("hasStickyHeaders").unbind("pagerComplete resize filterEnd stickyHeadersUpdate ".split(" ").join(d).replace(/\s+/g," ")).next("."+i.css.stickyWrap).remove(),a.$sticky&&a.$sticky.length&&a.$sticky.remove(),e(s).add(a.stickyHeaders_xScroll).add(a.stickyHeaders_yScroll).add(a.stickyHeaders_attachTo).unbind("scroll resize ".split(" ").join(d).replace(/\s+/g," ")),i.addHeaderResizeEvent(t,!0)}})}(jQuery,window); \ No newline at end of file +!function(e,s){"use strict";function t(s,t){var i=isNaN(t.stickyHeaders_offset)?e(t.stickyHeaders_offset):[];return i.length?i.height()||0:parseInt(t.stickyHeaders_offset,10)||0}var i=e.tablesorter||{};e.extend(i.css,{sticky:"tablesorter-stickyHeader",stickyVis:"tablesorter-sticky-visible",stickyHide:"tablesorter-sticky-hidden",stickyWrap:"tablesorter-sticky-wrapper"}),i.addHeaderResizeEvent=function(s,t,i){if((s=e(s)[0]).config){var r={timer:250},a=e.extend({},r,i),d=s.config,c=d.widgetOptions,l=function(e){var s,t,i,r,a,l,n=d.$headers.length;for(c.resize_flag=!0,t=[],s=0;s=0&&!a.$table.hasClass("hasFilters"))){var c,l,n,o,f=a.$table,p=e(d.stickyHeaders_attachTo),h=a.namespace+"stickyheaders ",y=e(d.stickyHeaders_yScroll||d.stickyHeaders_attachTo||s),k=e(d.stickyHeaders_xScroll||d.stickyHeaders_attachTo||s),g=f.children("thead:first").children("tr").not(".sticky-false").children(),H=f.children("tfoot"),b=t(0,d),u=f.parent().closest("."+i.css.table).hasClass("hasStickyHeaders")?f.parent().closest("table.tablesorter")[0].config.widgetOptions.$sticky.parent():[],_=u.length?u.height():0,v=d.$sticky=f.clone().addClass("containsStickyHeaders "+i.css.sticky+" "+d.stickyHeaders+" "+a.namespace.slice(1)+"_extra_table").wrap('
'),m=v.parent().addClass(i.css.stickyHide).css({position:p.length?"absolute":"fixed",padding:parseInt(v.parent().parent().css("padding-left"),10),top:b+_,left:0,visibility:"hidden",zIndex:d.stickyHeaders_zIndex||2}),z=v.children("thead:first"),C="",w=function(e,t){var i,r,a,d,c,l=e.filter(":visible"),n=l.length;for(i=0;ir.top&&h=0&&a.$filters&&a.$filters.eq(r).find("a, select, input").filter(":visible").focus())}),i.filter.bindSearch(f,o.find("."+i.css.filter)),d.filter_hideFilters&&i.filter.hideFilters(a,v)),d.stickyHeaders_addResizeEvent&&f.bind("resize"+a.namespace+"stickyheaders",function(){T()}),S(!0),f.triggerHandler("stickyHeadersInit")}},remove:function(t,r,a){var d=r.namespace+"stickyheaders ";r.$table.removeClass("hasStickyHeaders").unbind("pagerComplete resize filterEnd stickyHeadersUpdate ".split(" ").join(d).replace(/\s+/g," ")).next("."+i.css.stickyWrap).remove(),a.$sticky&&a.$sticky.length&&a.$sticky.remove(),e(s).add(a.stickyHeaders_xScroll).add(a.stickyHeaders_yScroll).add(a.stickyHeaders_attachTo).unbind("scroll resize ".split(" ").join(d).replace(/\s+/g," ")),i.addHeaderResizeEvent(t,!0)}})}(jQuery,window); \ No newline at end of file diff --git a/dist/js/widgets/widget-toggle.min.js b/dist/js/widgets/widget-toggle.min.js index 0643899bb..56e58da6c 100644 --- a/dist/js/widgets/widget-toggle.min.js +++ b/dist/js/widgets/widget-toggle.min.js @@ -2,4 +2,4 @@ * Requires tablesorter v2.24.4+ & jQuery 1.7+ * by Rob Garrison */ -!function(e){"use strict";var l=e.tablesorter,t=l.toggleTS={init:function(e,l){l.toggleTS_isEnabled=!0,l.toggleTS_areDisabled={headers:[],filters:[]},e.$table.on("enable.toggleTS disable.toggleTS",function(e){t.toggle(this.config,this.config.widgetOptions,"enable"===e.type)})},toggle:function(e,t,i){if(t.toggleTS_isEnabled!==i){t.toggleTS_isEnabled=i;var s,o,g=e.$headers.length;for(s=0;s // 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 ( c.debug ) { - 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 ( c.debug ) { - 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; - 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 ) { - 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 ( c.debug ) { - console.log( 'Overall initialization time:' + ts.benchmark( $.data( table, 'startoveralltimer' ) ) ); - if ( c.debug && 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, init ) { - e.stopPropagation(); - // apply widgets - ts.applyWidget( this, init ); - }) - .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 = $.fn.closest ? $headers.closest( 'table' )[ 0 ] : $headers.parents( 'table' )[ 0 ]; - if ( tmp && tmp.nodeName === 'TABLE' && tmp !== table ) { - $( tmp ).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; - // 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 || - // elements within a button - $target.parents( 'button' ).length > 0 ) { - return !c.cancelSelection; - } - if ( c.delayInit && ts.isEmptyObject( c.cache ) ) { - ts.buildCache( c ); - } - // jQuery v1.2.6 doesn't have closest() - $cell = $.fn.closest ? $( this ).closest( 'th, td' ) : - /TH|TD/.test( this.nodeName ) ? $( this ) : $( this ).parents( 'th, td' ); - // reference original table headers and find the same cell - // don't use $headers or IE8 throws an error - see #987 - temp = $headers.index( $cell ); - c.last.clickedIndex = ( temp < 0 ) ? $cell.attr( 'data-column' ) : temp; - // use column index if $headers is undefined - cell = c.$headers[ c.last.clickedIndex ]; - 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 ( c.debug ) { - 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 ? - '' : - ''; - // 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 ( $elem.parent().hasClass( c.cssIgnoreRow ) ) { return; } - // 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( '
' + template + '
' ); // 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 - }; - 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; - // add to parent in case there are multiple rows - $elem - .addClass( ts.css.header + ' ' + c.cssHeader ) - .parent() - .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 ] = {}; - } - $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 ( c.debug ) { - 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 = {}; - // 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 c.debug ? console.warn( 'Warning: *Empty table!* Not building a parser cache' ) : ''; - } else if ( c.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 ( c.debug ) { - debug[ '(' + 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 ( c.debug ) { - if ( !ts.isEmptyObject( debug ) ) { - console[ console.table ? 'table' : 'log' ]( debug ); - } 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 */ - 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 = '', - 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 ( c.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; - // 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 c.debug ? console.warn( 'Warning: *Empty table!* Not building a cache' ) : ''; - } - if ( c.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 && c.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 ( c.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 ( c.debug ) { - 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' ], - // 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 + c.$headers[ i ].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 ) { - $sorted - .eq( column ) - .removeClass( none ) - .addClass( css[ list[ indx ][ 1 ] ] ) - .attr( 'aria-sort', aria[ list[ indx ][ 1 ] ] ) - .find( '.' + ts.css.icon ) - .removeClass( cssIcon[ 2 ] ) - .addClass( cssIcon[ list[ indx ][ 1 ] ] ); - } - } - // add sorted class to footer & extra headers, if they exist - if ( $extras.length ) { - $extras - .filter( '[data-column="' + list[ indx ][ 0 ] + '"]' ) - .removeClass( none ) - .addClass( css[ list[ indx ][ 1 ] ] ); - } - } - } - } - // add verbose aria labels - len = c.$headers.length; - for ( indx = 0; indx < len; indx++ ) { - ts.setColumnAriaLabel( c, c.$headers.eq( indx ) ); - } - }, - - // 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 ); - } - }, - - 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( $.fn.closest ? $cell.closest( 'tbody' ) : $cell.parents( 'tbody' ).filter( ':first' ) ), - tbcache = c.cache[ tbodyIndex ], - $row = $.fn.closest ? $cell.closest( 'tr' ) : $cell.parents( 'tr' ).filter( ':first' ); - 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 ( c.debug ) { - 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 && / 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, - wo = c.widgetOptions, - $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 ( c.debug ) { - 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 || !wo.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 ( c.debug ) { - 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, - // get current column index - col = parseInt( $( cell ).attr( 'data-column' ), 10 ), - order = c.sortVars[ col ].order; - - // 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 ) { - // 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 ]; - } - } - } - // add column to sort list - dir = order[ c.sortVars[ col ].count ]; - if ( dir < 2 ) { - c.sortList[ c.sortList.length ] = [ col, dir ]; - // add other columns if header spans across multiple - if ( cell.colSpan > 1 ) { - for ( indx = 1; indx < cell.colSpan; indx++ ) { - c.sortList[ c.sortList.length ] = [ col + indx, dir ]; - // update count on columns in colSpan - c.sortVars[ col + indx ].count = $.inArray( dir, order ); - } - } - } - // 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 - 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 ]; - if ( dir < 2 ) { - c.sortList[ c.sortList.length ] = [ col, dir ]; - // add other columns if header spans across multiple - if ( cell.colSpan > 1 ) { - for ( indx = 1; indx < cell.colSpan; indx++ ) { - c.sortList[ c.sortList.length ] = [ col + indx, dir ]; - // update count on columns in colSpan - c.sortVars[ col + indx ].count = $.inArray( dir, order ); - } - } - } - } - } - // 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 ]; - } - } - } - } - // 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 ( c.debug ) { 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 ( c.debug ) { - 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 table = c.table; - c.$table.triggerHandler( 'sortStart', table ); - // 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 = []; - ts.setHeadersCss( c ); - ts.multisort( c ); - ts.appendCache( c ); - var indx; - for (indx = 0; indx < c.columns; indx++) { - c.sortVars[ indx ].count = -1; - } - 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, - 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 ( c.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 ( c.debug ) { - console[ console.group ? 'group' : 'log' ]( 'Initializing ' + name + ' widget' ); - } - widget.init( table, widget, c, wo ); - } - } - if ( !init && typeof widget.format === 'function' ) { - applied = true; - if ( c.debug ) { - console[ console.group ? 'group' : 'log' ]( 'Updating ' + name + ' widget' ); - } - widget.format( table, c, wo, false ); - } - if ( c.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, - widgets = []; - // prevent numerous consecutive widget applications - if ( init !== false && table.hasInitialized && ( table.isApplyingWidgets || table.isUpdating ) ) { - return; - } - if ( c.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 ( c.debug ) { - console.warn( '"' + names[ indx ] + '" widget code does not exist!' ); - } - } - // 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 ( c.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 ( c.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 ( c.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 ( c.debug ) { - console.log( ( refreshing ? 'Refreshing' : 'Removing' ) + ' "' + name[ index ] + '" widget' ); - } - widget.remove( table, c, c.widgetOptions, refreshing ); - c.widgetInit[ name[ index ] ] = false; - } - } - }, - - 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 ); - }, - - // $.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 = $( '' ); - 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( $( '' ).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.filter( '[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( '' ); - 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 ( c.debug ) { - 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 ( c.debug ) { - 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, - debug = c.debug, - $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 ( debug ) { - 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, table ) { - 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, table ) { - 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, table ) { - // 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 - } - } - }); + 'use strict'; + var ts = $.tablesorter = { + + version : '2.28.15', + + 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} = // 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 ( c.debug ) { + 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 ( c.debug ) { + 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; + 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 ) { + 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 ( c.debug ) { + console.log( 'Overall initialization time:' + ts.benchmark( $.data( table, 'startoveralltimer' ) ) ); + if ( c.debug && 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, init ) { + e.stopPropagation(); + // apply widgets + ts.applyWidget( this, init ); + }) + .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 = $.fn.closest ? $headers.closest( 'table' )[ 0 ] : $headers.parents( 'table' )[ 0 ]; + if ( tmp && tmp.nodeName === 'TABLE' && tmp !== table ) { + $( tmp ).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; + // 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 || + // elements within a button + $target.parents( 'button' ).length > 0 ) { + return !c.cancelSelection; + } + if ( c.delayInit && ts.isEmptyObject( c.cache ) ) { + ts.buildCache( c ); + } + // jQuery v1.2.6 doesn't have closest() + $cell = $.fn.closest ? $( this ).closest( 'th, td' ) : + /TH|TD/.test( this.nodeName ) ? $( this ) : $( this ).parents( 'th, td' ); + // reference original table headers and find the same cell + // don't use $headers or IE8 throws an error - see #987 + temp = $headers.index( $cell ); + c.last.clickedIndex = ( temp < 0 ) ? $cell.attr( 'data-column' ) : temp; + // use column index if $headers is undefined + cell = c.$headers[ c.last.clickedIndex ]; + 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 ( c.debug ) { + 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 ? + '' : + ''; + // 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 ( $elem.parent().hasClass( c.cssIgnoreRow ) ) { return; } + // 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( '
' + template + '
' ); // 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 + }; + 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; + // add to parent in case there are multiple rows + $elem + .addClass( ts.css.header + ' ' + c.cssHeader ) + .parent() + .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 ] = {}; + } + $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 ( c.debug ) { + 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 = {}; + // 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 c.debug ? console.warn( 'Warning: *Empty table!* Not building a parser cache' ) : ''; + } else if ( c.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 ( c.debug ) { + debug[ '(' + 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 ( c.debug ) { + if ( !ts.isEmptyObject( debug ) ) { + console[ console.table ? 'table' : 'log' ]( debug ); + } 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 */ + 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 = '', + 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 ( c.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; + // 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 c.debug ? console.warn( 'Warning: *Empty table!* Not building a cache' ) : ''; + } + if ( c.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 && c.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 ( c.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 ( c.debug ) { + 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' ], + // 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 + c.$headers[ i ].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 ) { + $sorted + .eq( column ) + .removeClass( none ) + .addClass( css[ list[ indx ][ 1 ] ] ) + .attr( 'aria-sort', aria[ list[ indx ][ 1 ] ] ) + .find( '.' + ts.css.icon ) + .removeClass( cssIcon[ 2 ] ) + .addClass( cssIcon[ list[ indx ][ 1 ] ] ); + } + } + // add sorted class to footer & extra headers, if they exist + if ( $extras.length ) { + $extras + .filter( '[data-column="' + list[ indx ][ 0 ] + '"]' ) + .removeClass( none ) + .addClass( css[ list[ indx ][ 1 ] ] ); + } + } + } + } + // add verbose aria labels + len = c.$headers.length; + for ( indx = 0; indx < len; indx++ ) { + ts.setColumnAriaLabel( c, c.$headers.eq( indx ) ); + } + }, + + // 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 ); + } + }, + + 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( $.fn.closest ? $cell.closest( 'tbody' ) : $cell.parents( 'tbody' ).filter( ':first' ) ), + tbcache = c.cache[ tbodyIndex ], + $row = $.fn.closest ? $cell.closest( 'tr' ) : $cell.parents( 'tr' ).filter( ':first' ); + 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 ( c.debug ) { + 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 && / 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, + wo = c.widgetOptions, + $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 ( c.debug ) { + 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 || !wo.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 ( c.debug ) { + 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, + // get current column index + col = parseInt( $( cell ).attr( 'data-column' ), 10 ), + order = c.sortVars[ col ].order; + + // 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 ) { + // 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 ]; + } + } + } + // add column to sort list + dir = order[ c.sortVars[ col ].count ]; + if ( dir < 2 ) { + c.sortList[ c.sortList.length ] = [ col, dir ]; + // add other columns if header spans across multiple + if ( cell.colSpan > 1 ) { + for ( indx = 1; indx < cell.colSpan; indx++ ) { + c.sortList[ c.sortList.length ] = [ col + indx, dir ]; + // update count on columns in colSpan + c.sortVars[ col + indx ].count = $.inArray( dir, order ); + } + } + } + // 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 + 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 ]; + if ( dir < 2 ) { + c.sortList[ c.sortList.length ] = [ col, dir ]; + // add other columns if header spans across multiple + if ( cell.colSpan > 1 ) { + for ( indx = 1; indx < cell.colSpan; indx++ ) { + c.sortList[ c.sortList.length ] = [ col + indx, dir ]; + // update count on columns in colSpan + c.sortVars[ col + indx ].count = $.inArray( dir, order ); + } + } + } + } + } + // 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 ]; + } + } + } + } + // 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 ( c.debug ) { 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 ( c.debug ) { + 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 table = c.table; + c.$table.triggerHandler( 'sortStart', table ); + // 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 = []; + ts.setHeadersCss( c ); + ts.multisort( c ); + ts.appendCache( c ); + var indx; + for (indx = 0; indx < c.columns; indx++) { + c.sortVars[ indx ].count = -1; + } + 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, + 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 ( c.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 ( c.debug ) { + console[ console.group ? 'group' : 'log' ]( 'Initializing ' + name + ' widget' ); + } + widget.init( table, widget, c, wo ); + } + } + if ( !init && typeof widget.format === 'function' ) { + applied = true; + if ( c.debug ) { + console[ console.group ? 'group' : 'log' ]( 'Updating ' + name + ' widget' ); + } + widget.format( table, c, wo, false ); + } + if ( c.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, + widgets = []; + // prevent numerous consecutive widget applications + if ( init !== false && table.hasInitialized && ( table.isApplyingWidgets || table.isUpdating ) ) { + return; + } + if ( c.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 ( c.debug ) { + console.warn( '"' + names[ indx ] + '" widget code does not exist!' ); + } + } + // 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 ( c.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 ( c.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 ( c.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 ( c.debug ) { + 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 ); + }, + + // $.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 = $( '' ); + 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( $( '' ).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.filter( '[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( '' ); + 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 ( c.debug ) { + 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 ( c.debug ) { + 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, + debug = c.debug, + $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 ( debug ) { + 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, table ) { + 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, table ) { + 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, table ) { + // 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 ); diff --git a/js/jquery.tablesorter.widgets.js b/js/jquery.tablesorter.widgets.js index c2c84d9e2..64dfd49d9 100644 --- a/js/jquery.tablesorter.widgets.js +++ b/js/jquery.tablesorter.widgets.js @@ -4,7 +4,7 @@ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀██ █████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀ */ -/*! tablesorter (FORK) - updated 07-04-2017 (v2.28.15)*/ +/*! tablesorter (FORK) - updated 07-17-2017 (v2.28.15)*/ /* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */ (function(factory) { if (typeof define === 'function' && define.amd) {