diff --git a/tablesorter b/tablesorter index 6d8fe95..351e3ad 160000 --- a/tablesorter +++ b/tablesorter @@ -1 +1 @@ -Subproject commit 6d8fe95da872d38c2e3ae2c43af11bda7ebb622e +Subproject commit 351e3ad699ed1d9ad0934f57e0b02d1f52939790 diff --git a/vendor/assets/images/jquery-tablesorter/black-asc.gif b/vendor/assets/images/jquery-tablesorter/black-asc.gif index 4c3b610..730533f 100644 Binary files a/vendor/assets/images/jquery-tablesorter/black-asc.gif and b/vendor/assets/images/jquery-tablesorter/black-asc.gif differ diff --git a/vendor/assets/images/jquery-tablesorter/black-desc.gif b/vendor/assets/images/jquery-tablesorter/black-desc.gif index 730533f..4c3b610 100644 Binary files a/vendor/assets/images/jquery-tablesorter/black-desc.gif and b/vendor/assets/images/jquery-tablesorter/black-desc.gif differ diff --git a/vendor/assets/images/jquery-tablesorter/dropbox-asc-hovered.png b/vendor/assets/images/jquery-tablesorter/dropbox-asc-hovered.png new file mode 100644 index 0000000..bc45223 Binary files /dev/null and b/vendor/assets/images/jquery-tablesorter/dropbox-asc-hovered.png differ diff --git a/vendor/assets/images/jquery-tablesorter/dropbox-asc.png b/vendor/assets/images/jquery-tablesorter/dropbox-asc.png new file mode 100644 index 0000000..0d6ee15 Binary files /dev/null and b/vendor/assets/images/jquery-tablesorter/dropbox-asc.png differ diff --git a/vendor/assets/images/jquery-tablesorter/dropbox-desc-hovered.png b/vendor/assets/images/jquery-tablesorter/dropbox-desc-hovered.png new file mode 100644 index 0000000..4930942 Binary files /dev/null and b/vendor/assets/images/jquery-tablesorter/dropbox-desc-hovered.png differ diff --git a/vendor/assets/images/jquery-tablesorter/dropbox-desc.png b/vendor/assets/images/jquery-tablesorter/dropbox-desc.png new file mode 100644 index 0000000..0bce65a Binary files /dev/null and b/vendor/assets/images/jquery-tablesorter/dropbox-desc.png differ diff --git a/vendor/assets/images/jquery-tablesorter/green-asc.gif b/vendor/assets/images/jquery-tablesorter/green-asc.gif new file mode 100644 index 0000000..4cfba09 Binary files /dev/null and b/vendor/assets/images/jquery-tablesorter/green-asc.gif differ diff --git a/vendor/assets/images/jquery-tablesorter/green-desc.gif b/vendor/assets/images/jquery-tablesorter/green-desc.gif new file mode 100644 index 0000000..4f88176 Binary files /dev/null and b/vendor/assets/images/jquery-tablesorter/green-desc.gif differ diff --git a/vendor/assets/images/jquery-tablesorter/green-header.gif b/vendor/assets/images/jquery-tablesorter/green-header.gif new file mode 100644 index 0000000..cc746b7 Binary files /dev/null and b/vendor/assets/images/jquery-tablesorter/green-header.gif differ diff --git a/vendor/assets/images/jquery-tablesorter/green-unsorted.gif b/vendor/assets/images/jquery-tablesorter/green-unsorted.gif new file mode 100644 index 0000000..0afe2c0 Binary files /dev/null and b/vendor/assets/images/jquery-tablesorter/green-unsorted.gif differ diff --git a/vendor/assets/images/jquery-tablesorter/ice-asc.gif b/vendor/assets/images/jquery-tablesorter/ice-asc.gif index 2b6a875..0961d9a 100644 Binary files a/vendor/assets/images/jquery-tablesorter/ice-asc.gif and b/vendor/assets/images/jquery-tablesorter/ice-asc.gif differ diff --git a/vendor/assets/images/jquery-tablesorter/ice-desc.gif b/vendor/assets/images/jquery-tablesorter/ice-desc.gif index 4544e9c..0330fcc 100644 Binary files a/vendor/assets/images/jquery-tablesorter/ice-desc.gif and b/vendor/assets/images/jquery-tablesorter/ice-desc.gif differ diff --git a/vendor/assets/images/jquery-tablesorter/ice-unsorted.gif b/vendor/assets/images/jquery-tablesorter/ice-unsorted.gif index d55322c..c1afde5 100644 Binary files a/vendor/assets/images/jquery-tablesorter/ice-unsorted.gif and b/vendor/assets/images/jquery-tablesorter/ice-unsorted.gif differ diff --git a/vendor/assets/images/jquery-tablesorter/white-asc.gif b/vendor/assets/images/jquery-tablesorter/white-asc.gif index 7109c3e..2173b0a 100644 Binary files a/vendor/assets/images/jquery-tablesorter/white-asc.gif and b/vendor/assets/images/jquery-tablesorter/white-asc.gif differ diff --git a/vendor/assets/images/jquery-tablesorter/white-desc.gif b/vendor/assets/images/jquery-tablesorter/white-desc.gif index 2173b0a..7109c3e 100644 Binary files a/vendor/assets/images/jquery-tablesorter/white-desc.gif and b/vendor/assets/images/jquery-tablesorter/white-desc.gif differ diff --git a/vendor/assets/javascripts/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.js b/vendor/assets/javascripts/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.js index ecc5bb2..6b1e193 100644 --- a/vendor/assets/javascripts/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.js +++ b/vendor/assets/javascripts/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.js @@ -1,508 +1,508 @@ -/*! - * tablesorter pager plugin - * updated 10/25/2012 - */ -/*jshint browser:true, jquery:true */ -;(function($) { - "use strict"; - $.extend({tablesorterPager: new function() { - - this.defaults = { - // target the pager markup - container: null, - - // use this format: "http://mydatabase.com?page={page}&size={size}&{sortList:col}" - // where {page} is replaced by the page number and {size} is replaced by the number of records to show - // {sortList:col} adds the sortList to the url into a "col" array. - // So a sortList = [[2,0],[3,0]] becomes "&col[2]=0&col[3]=0" in the url - ajaxUrl: null, - - // process ajax so that the following information is returned: - // [ total_rows (number), rows (array of arrays), headers (array; optional) ] - // example: - // [ - // 100, // total rows - // [ - // [ "row1cell1", "row1cell2", ... "row1cellN" ], - // [ "row2cell1", "row2cell2", ... "row2cellN" ], - // ... - // [ "rowNcell1", "rowNcell2", ... "rowNcellN" ] - // ], - // [ "header1", "header2", ... "headerN" ] // optional - // ] - ajaxProcessing: function(ajax){ return [ 0, [], null ]; }, - - // output default: '{page}/{totalPages}' - // possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows} - output: '{startRow} to {endRow} of {totalRows} rows', // '{page}/{totalPages}' - - // apply disabled classname to the pager arrows when the rows at either extreme is visible - updateArrows: true, - - // starting page of the pager (zero based index) - page: 0, - - // Number of visible rows - size: 10, - - // if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty - // table row set to a height to compensate; default is false - fixedHeight: false, - - // remove rows from the table to speed up the sort of large tables. - // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled. - removeRows: false, // removing rows in larger tables speeds up the sort - - // css class names of pager arrows - cssFirst: '.first', // go to first page arrow - cssPrev: '.prev', // previous page arrow - cssNext: '.next', // next page arrow - cssLast: '.last', // go to last page arrow - cssGoto: '.gotoPage', // go to page selector - select dropdown that sets the current page - cssPageDisplay: '.pagedisplay', // location of where the "output" is displayed - cssPageSize: '.pagesize', // page size selector - select dropdown that sets the "size" option - - // class added to arrows when at the extremes (i.e. prev/first arrows are "disabled" when on the first page) - cssDisabled: 'disabled', // Note there is no period "." in front of this class name - - // stuff not set by the user - totalRows: 0, - totalPages: 0, - filteredRows: 0, - filteredPages: 0 - - }; - - var $this = this, - - // hide arrows at extremes - pagerArrows = function(c, disable) { - var a = 'addClass', - r = 'removeClass', - d = c.cssDisabled, - dis = !!disable, - // tr = Math.min( c.totalRows, c.filteredRows ), - tp = Math.min( c.totalPages, c.filteredPages ); - if ( c.updateArrows ) { - $(c.cssFirst + ',' + c.cssPrev, c.container)[ ( dis || c.page === 0 ) ? a : r ](d); - $(c.cssNext + ',' + c.cssLast, c.container)[ ( dis || c.page === tp - 1 ) ? a : r ](d); - } - }, - - updatePageDisplay = function(table, c) { - var i, p, s, t, out, f = $(table).hasClass('hasFilters'); - c.filteredRows = (f) ? $(table).find('tbody tr:not(.filtered)').length : c.totalRows; - c.filteredPages = (f) ? Math.ceil( c.filteredRows / c.size ) : c.totalPages; - if ( Math.min( c.totalPages, c.filteredPages ) > 0 ) { - t = (c.size * c.page > c.filteredRows); - c.startRow = (t) ? 1 : ( c.size * c.page ) + 1; - c.page = (t) ? 0 : c.page; - c.endRow = Math.min( c.filteredRows, c.totalRows, c.size * ( c.page + 1 ) ); - out = $(c.cssPageDisplay, c.container); - // form the output string - s = c.output.replace(/\{(page|filteredRows|filteredPages|totalPages|startRow|endRow|totalRows)\}/gi, function(m){ - return { - '{page}' : c.page + 1, - '{filteredRows}' : c.filteredRows, - '{filteredPages}' : c.filteredPages, - '{totalPages}' : c.totalPages, - '{startRow}' : c.startRow, - '{endRow}' : c.endRow, - '{totalRows}' : c.totalRows - }[m]; - }); - if (out[0]) { - out[ (out[0].tagName === 'INPUT') ? 'val' : 'html' ](s); - if ( $(c.cssGoto, c.container).length ) { - t = ''; - p = Math.min( c.totalPages, c.filteredPages ); - for ( i = 1; i <= p; i++ ) { - t += ''; - } - $(c.cssGoto, c.container).html(t).val(c.page + 1); - } - } - } - pagerArrows(c); - if (c.initialized) { $(table).trigger('pagerComplete', c); } - }, - - fixHeight = function(table, c) { - var d, h, $b = $(table.tBodies[0]); - if (c.fixedHeight) { - $b.find('tr.pagerSavedHeightSpacer').remove(); - h = $.data(table, 'pagerSavedHeight'); - if (h) { - d = h - $b.height(); - if ( d > 5 && $.data(table, 'pagerLastSize') === c.size && $b.find('tr:visible').length < c.size ) { - $b.append(''); - } - } - } - }, - - changeHeight = function(table, c) { - var $b = $(table.tBodies[0]); - $b.find('tr.pagerSavedHeightSpacer').remove(); - $.data(table, 'pagerSavedHeight', $b.height()); - fixHeight(table, c); - $.data(table, 'pagerLastSize', c.size); - }, - - hideRows = function(table, c){ - if (!c.ajaxUrl) { - var i, - rows = $('tr:not(.' + table.config.cssChildRow + ')', table.tBodies), - l = rows.length, - s = ( c.page * c.size ), - e = s + c.size, - j = 0; // size counter - for ( i = 0; i < l; i++ ){ - if (!/filtered/.test(rows[i].className)) { - rows[i].style.display = ( j >= s && j < e ) ? '' : 'none'; - j++; - } - } - } - }, - - hideRowsSetup = function(table, c){ - c.size = parseInt( $(c.cssPageSize, c.container).find('option[selected]').val(), 10 ) || c.size; - $.data(table, 'pagerLastSize', c.size); - pagerArrows(c); - if ( !c.removeRows ) { - hideRows(table, c); - $(table).bind('sortEnd.pager filterEnd.pager', function(){ - hideRows(table, c); - }); - } - }, - - renderAjax = function(data, table, c, exception){ - // process data - if ( typeof(c.ajaxProcessing) === "function" ) { - // ajaxProcessing result: [ total, rows, headers ] - var i, j, hsh, $f, $sh, - $t = $(table), - tc = table.config, - $b = $(table.tBodies).filter(':not(.' + tc.cssInfoBlock + ')'), - hl = $t.find('thead th').length, tds = '', - err = '' + - (exception ? exception.message + ' (' + exception.name + ')' : 'No rows found') + '', - result = c.ajaxProcessing(data) || [ 0, [] ], - d = result[1] || [], - l = d.length, - th = result[2]; - if ( l > 0 ) { - for ( i = 0; i < l; i++ ) { - tds += ''; - for ( j = 0; j < d[i].length; j++ ) { - // build tbody cells - tds += '' + d[i][j] + ''; - } - tds += ''; - } - } - // only add new header text if the length matches - if ( th && th.length === hl ) { - hsh = $t.hasClass('hasStickyHeaders'); - $sh = $t.find('.' + ((tc.widgetOptions && tc.widgetOptions.stickyHeaders) || 'tablesorter-stickyheader')); - $f = $t.find('tfoot tr:first').children(); - $t.find('th.' + tc.cssHeader).each(function(j){ - var $t = $(this), icn; - // add new test within the first span it finds, or just in the header - if ( $t.find('.' + tc.cssIcon).length ) { - icn = $t.find('.' + tc.cssIcon).clone(true); - $t.find('.tablesorter-header-inner').html( th[j] ).append(icn); - if ( hsh && $sh.length ) { - icn = $sh.find('th').eq(j).find('.' + tc.cssIcon).clone(true); - $sh.find('th').eq(j).find('.tablesorter-header-inner').html( th[j] ).append(icn); - } - } else { - $t.find('.tablesorter-header-inner').html( th[j] ); - $sh.find('th').eq(j).find('.tablesorter-header-inner').html( th[j] ); - } - $f.eq(j).html( th[j] ); - }); - } - if ( exception ) { - // add error row to thead instead of tbody, or clicking on the header will result in a parser error - $t.find('thead').append(err); - } else { - $b.html( tds ); // add tbody - } - c.temp.remove(); // remove loading icon - $t.trigger('update'); - c.totalRows = result[0] || 0; - c.totalPages = Math.ceil( c.totalRows / c.size ); - updatePageDisplay(table, c); - fixHeight(table, c); - if (c.initialized) { $t.trigger('pagerChange', c); } - } - if (!c.initialized) { - c.initialized = true; - $(table).trigger('pagerInitialized', c); - } - }, - - getAjax = function(table, c){ - var $t = $(table), - url = (c.ajaxUrl) ? c.ajaxUrl.replace(/\{page\}/g, c.page).replace(/\{size\}/g, c.size) : '', - arry = [], - sl = table.config.sortList, - col = url.match(/\{sortList[\s+]?:[\s+]?(.*)\}/); - if (col) { - col = col[1]; - $.each(sl, function(i,v){ - arry.push(col + '[' + v[0] + ']=' + v[1]); - }); - // if the arry is empty, just add the col parameter... "&{sortList:col}" becomes "&col" - url = url.replace(/\{sortList[\s+]?:[\s+]?(.*)\}/g, arry.length ? arry.join('&') : col ); - } - if ( url !== '' ) { - // loading icon - c.temp = $('
', { - 'class' : 'tablesorter-processing', - width : $t.outerWidth(true), - height: $t.outerHeight(true) - }); - $t.before( c.temp ); - $(document).ajaxError(function(e, xhr, settings, exception) { - renderAjax(null, table, c, exception); - }); - $.getJSON(url, function(data) { - renderAjax(data, table, c); - }); - } - }, - - renderTable = function(table, rows, c) { - var i, j, o, - f = document.createDocumentFragment(), - l = rows.length, - s = ( c.page * c.size ), - e = ( s + c.size ); - if ( l < 1 ) { return; } // empty table, abort! - if (c.initialized) { $(table).trigger('pagerChange', c); } - if ( !c.removeRows ) { - hideRows(table, c); - } else { - if ( e > rows.length ) { - e = rows.length; - } - $(table.tBodies[0]).addClass('tablesorter-hidden'); - $.tablesorter.clearTableBody(table); - for ( i = s; i < e; i++ ) { - o = rows[i]; - l = o.length; - for ( j = 0; j < l; j++ ) { - f.appendChild(o[j]); - } - } - table.tBodies[0].appendChild(f); - $(table.tBodies[0]).removeClass('tablesorter-hidden'); - } - if ( c.page >= c.totalPages ) { - moveToLastPage(table, c); - } - updatePageDisplay(table, c); - if ( !c.isDisabled ) { fixHeight(table, c); } - $(table).trigger('applyWidgets'); - }, - - showAllRows = function(table, c){ - if ( c.ajax ) { - pagerArrows(c, true); - } else { - c.isDisabled = true; - $.data(table, 'pagerLastPage', c.page); - $.data(table, 'pagerLastSize', c.size); - c.page = 0; - c.size = c.totalRows; - c.totalPages = 1; - $('tr.pagerSavedHeightSpacer', table.tBodies[0]).remove(); - renderTable(table, table.config.rowsCopy, c); - } - // disable size selector - $(c.container).find(c.cssPageSize + ',' + c.cssGoto).each(function(){ - $(this).addClass(c.cssDisabled)[0].disabled = true; - }); - }, - - moveToPage = function(table, c) { - if ( c.isDisabled ) { return; } - var p = Math.min( c.totalPages, c.filteredPages ); - if ( c.page < 0 || c.page > ( p - 1 ) ) { - c.page = 0; - } - $.data(table, 'pagerLastPage', c.page); - if ( c.ajax ) { - getAjax(table, c); - } else { - renderTable(table, table.config.rowsCopy, c); - } - if (c.initialized) { $(table).trigger('pageMoved', c); } - }, - - setPageSize = function(table, size, c) { - c.size = size; - $.data(table, 'pagerLastPage', c.page); - $.data(table, 'pagerLastSize', c.size); - c.totalPages = Math.ceil( c.totalRows / c.size ); - moveToPage(table, c); - }, - - moveToFirstPage = function(table, c) { - c.page = 0; - moveToPage(table, c); - }, - - moveToLastPage = function(table, c) { - c.page = ( Math.min( c.totalPages, c.filteredPages ) - 1 ); - moveToPage(table, c); - }, - - moveToNextPage = function(table, c) { - c.page++; - if ( c.page >= ( Math.min( c.totalPages, c.filteredPages ) - 1 ) ) { - c.page = ( Math.min( c.totalPages, c.filteredPages ) - 1 ); - } - moveToPage(table, c); - }, - - moveToPrevPage = function(table, c) { - c.page--; - if ( c.page <= 0 ) { - c.page = 0; - } - moveToPage(table, c); - }, - - destroyPager = function(table, c){ - showAllRows(table, c); - $(c.container).hide(); // hide pager - table.config.appender = null; // remove pager appender function - $(table).unbind('destroy.pager sortEnd.pager filterEnd.pager enable.pager disable.pager'); - }, - - enablePager = function(table, c, triggered){ - var p = $(c.cssPageSize, c.container).removeClass(c.cssDisabled).removeAttr('disabled'); - c.isDisabled = false; - c.page = $.data(table, 'pagerLastPage') || c.page || 0; - c.size = $.data(table, 'pagerLastSize') || parseInt(p.find('option[selected]').val(), 10) || c.size; - p.val(c.size); // set page size - c.totalPages = Math.ceil( Math.min( c.totalPages, c.filteredPages ) / c.size); - if ( triggered ) { - $(table).trigger('update'); - setPageSize(table, c.size, c); - hideRowsSetup(table, c); - fixHeight(table, c); - } - }; - - $this.appender = function(table, rows) { - var c = table.config.pager; - if ( !c.ajax ) { - table.config.rowsCopy = rows; - c.totalRows = rows.length; - c.size = $.data(table, 'pagerLastSize') || c.size; - c.totalPages = Math.ceil(c.totalRows / c.size); - renderTable(table, rows, c); - } - }; - - $this.construct = function(settings) { - return this.each(function() { - var config = this.config, - c = config.pager = $.extend( {}, $.tablesorterPager.defaults, settings ), - table = this, - $t = $(table), - pager = $(c.container).addClass('tablesorter-pager').show(); // added in case the pager is reinitialized after being destroyed. - config.appender = $this.appender; - // clear initialized flag - c.initialized = false; - enablePager(table, c, false); - if ( typeof(c.ajaxUrl) === 'string' ) { - // ajax pager; interact with database - c.ajax = true; - getAjax(table, c); - } else { - c.ajax = false; - // Regular pager; all rows stored in memory - $(this).trigger("appendCache", true); - hideRowsSetup(table, c); - } - - // update pager after filter widget completes - $(table) - .unbind('filterEnd.pager updateComplete.pager ') - .bind('filterEnd.pager updateComplete.pager', function() { - c.page = 0; - updatePageDisplay(table, c); - moveToPage(table, c); - changeHeight(table, c); - }); - - if ( $(c.cssGoto, pager).length ) { - $(c.cssGoto, pager).bind('change', function(){ - c.page = $(this).val() - 1; - moveToPage(table, c); - }); - updatePageDisplay(table, c); - } - $(c.cssFirst,pager).unbind('click.pager').bind('click.pager', function() { - if ( !$(this).hasClass(c.cssDisabled) ) { moveToFirstPage(table, c); } - return false; - }); - $(c.cssNext,pager).unbind('click.pager').bind('click.pager', function() { - if ( !$(this).hasClass(c.cssDisabled) ) { moveToNextPage(table, c); } - return false; - }); - $(c.cssPrev,pager).unbind('click.pager').bind('click.pager', function() { - if ( !$(this).hasClass(c.cssDisabled) ) { moveToPrevPage(table, c); } - return false; - }); - $(c.cssLast,pager).unbind('click.pager').bind('click.pager', function() { - if ( !$(this).hasClass(c.cssDisabled) ) { moveToLastPage(table, c); } - return false; - }); - $(c.cssPageSize,pager).unbind('change.pager').bind('change.pager', function() { - $(c.cssPageSize,pager).val( $(this).val() ); // in case there are more than one pagers - if ( !$(this).hasClass(c.cssDisabled) ) { - setPageSize(table, parseInt( $(this).val(), 10 ), c); - changeHeight(table, c); - } - return false; - }); - - $t - .unbind('disable.pager enable.pager destroy.pager update.pager') - .bind('disable.pager', function(){ - showAllRows(table, c); - }) - .bind('enable.pager', function(){ - enablePager(table, c, true); - }) - .bind('destroy.pager', function(){ - destroyPager(table, c); - }) - .bind('update.pager', function(){ - hideRows(table, c); - }); - - // pager initialized - if (!c.ajax) { - c.initialized = true; - $(table).trigger('pagerInitialized', c); - } - }); - }; - - }() -}); -// extend plugin scope -$.fn.extend({ - tablesorterPager: $.tablesorterPager.construct -}); - +/*! + * tablesorter pager plugin + * updated 11/27/2012 + */ +/*jshint browser:true, jquery:true, unused:false */ +;(function($) { + "use strict"; + $.extend({tablesorterPager: new function() { + + this.defaults = { + // target the pager markup + container: null, + + // use this format: "http://mydatabase.com?page={page}&size={size}&{sortList:col}" + // where {page} is replaced by the page number and {size} is replaced by the number of records to show + // {sortList:col} adds the sortList to the url into a "col" array. + // So a sortList = [[2,0],[3,0]] becomes "&col[2]=0&col[3]=0" in the url + ajaxUrl: null, + + // process ajax so that the following information is returned: + // [ total_rows (number), rows (array of arrays), headers (array; optional) ] + // example: + // [ + // 100, // total rows + // [ + // [ "row1cell1", "row1cell2", ... "row1cellN" ], + // [ "row2cell1", "row2cell2", ... "row2cellN" ], + // ... + // [ "rowNcell1", "rowNcell2", ... "rowNcellN" ] + // ], + // [ "header1", "header2", ... "headerN" ] // optional + // ] + ajaxProcessing: function(ajax){ return [ 0, [], null ]; }, + + // output default: '{page}/{totalPages}' + // possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows} + output: '{startRow} to {endRow} of {totalRows} rows', // '{page}/{totalPages}' + + // apply disabled classname to the pager arrows when the rows at either extreme is visible + updateArrows: true, + + // starting page of the pager (zero based index) + page: 0, + + // Number of visible rows + size: 10, + + // if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty + // table row set to a height to compensate; default is false + fixedHeight: false, + + // remove rows from the table to speed up the sort of large tables. + // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled. + removeRows: false, // removing rows in larger tables speeds up the sort + + // css class names of pager arrows + cssFirst: '.first', // go to first page arrow + cssPrev: '.prev', // previous page arrow + cssNext: '.next', // next page arrow + cssLast: '.last', // go to last page arrow + cssGoto: '.gotoPage', // go to page selector - select dropdown that sets the current page + cssPageDisplay: '.pagedisplay', // location of where the "output" is displayed + cssPageSize: '.pagesize', // page size selector - select dropdown that sets the "size" option + + // class added to arrows when at the extremes (i.e. prev/first arrows are "disabled" when on the first page) + cssDisabled: 'disabled', // Note there is no period "." in front of this class name + + // stuff not set by the user + totalRows: 0, + totalPages: 0, + filteredRows: 0, + filteredPages: 0 + + }; + + var $this = this, + + // hide arrows at extremes + pagerArrows = function(c, disable) { + var a = 'addClass', + r = 'removeClass', + d = c.cssDisabled, + dis = !!disable, + // tr = Math.min( c.totalRows, c.filteredRows ), + tp = Math.min( c.totalPages, c.filteredPages ); + if ( c.updateArrows ) { + $(c.cssFirst + ',' + c.cssPrev, c.container)[ ( dis || c.page === 0 ) ? a : r ](d); + $(c.cssNext + ',' + c.cssLast, c.container)[ ( dis || c.page === tp - 1 ) ? a : r ](d); + } + }, + + updatePageDisplay = function(table, c) { + var i, p, s, t, out, f = $(table).hasClass('hasFilters'); + c.filteredRows = (f) ? $(table).find('tbody tr:not(.filtered)').length : c.totalRows; + c.filteredPages = (f) ? Math.ceil( c.filteredRows / c.size ) : c.totalPages; + if ( Math.min( c.totalPages, c.filteredPages ) > 0 ) { + t = (c.size * c.page > c.filteredRows); + c.startRow = (t) ? 1 : ( c.size * c.page ) + 1; + c.page = (t) ? 0 : c.page; + c.endRow = Math.min( c.filteredRows, c.totalRows, c.size * ( c.page + 1 ) ); + out = $(c.cssPageDisplay, c.container); + // form the output string + s = c.output.replace(/\{(page|filteredRows|filteredPages|totalPages|startRow|endRow|totalRows)\}/gi, function(m){ + return { + '{page}' : c.page + 1, + '{filteredRows}' : c.filteredRows, + '{filteredPages}' : c.filteredPages, + '{totalPages}' : c.totalPages, + '{startRow}' : c.startRow, + '{endRow}' : c.endRow, + '{totalRows}' : c.totalRows + }[m]; + }); + if (out[0]) { + out[ (out[0].tagName === 'INPUT') ? 'val' : 'html' ](s); + if ( $(c.cssGoto, c.container).length ) { + t = ''; + p = Math.min( c.totalPages, c.filteredPages ); + for ( i = 1; i <= p; i++ ) { + t += ''; + } + $(c.cssGoto, c.container).html(t).val(c.page + 1); + } + } + } + pagerArrows(c); + if (c.initialized) { $(table).trigger('pagerComplete', c); } + }, + + fixHeight = function(table, c) { + var d, h, $b = $(table.tBodies[0]); + if (c.fixedHeight) { + $b.find('tr.pagerSavedHeightSpacer').remove(); + h = $.data(table, 'pagerSavedHeight'); + if (h) { + d = h - $b.height(); + if ( d > 5 && $.data(table, 'pagerLastSize') === c.size && $b.find('tr:visible').length < c.size ) { + $b.append(''); + } + } + } + }, + + changeHeight = function(table, c) { + var $b = $(table.tBodies[0]); + $b.find('tr.pagerSavedHeightSpacer').remove(); + $.data(table, 'pagerSavedHeight', $b.height()); + fixHeight(table, c); + $.data(table, 'pagerLastSize', c.size); + }, + + hideRows = function(table, c){ + if (!c.ajaxUrl) { + var i, + rows = $('tr:not(.' + table.config.cssChildRow + ')', table.tBodies), + l = rows.length, + s = ( c.page * c.size ), + e = s + c.size, + j = 0; // size counter + for ( i = 0; i < l; i++ ){ + if (!/filtered/.test(rows[i].className)) { + rows[i].style.display = ( j >= s && j < e ) ? '' : 'none'; + j++; + } + } + } + }, + + hideRowsSetup = function(table, c){ + c.size = parseInt( $(c.cssPageSize, c.container).find('option[selected]').val(), 10 ) || c.size; + $.data(table, 'pagerLastSize', c.size); + pagerArrows(c); + if ( !c.removeRows ) { + hideRows(table, c); + $(table).bind('sortEnd.pager filterEnd.pager', function(){ + hideRows(table, c); + }); + } + }, + + renderAjax = function(data, table, c, exception){ + // process data + if ( typeof(c.ajaxProcessing) === "function" ) { + // ajaxProcessing result: [ total, rows, headers ] + var i, j, hsh, $f, $sh, + $t = $(table), + tc = table.config, + $b = $(table.tBodies).filter(':not(.' + tc.cssInfoBlock + ')'), + hl = $t.find('thead th').length, tds = '', + err = '' + + (exception ? exception.message + ' (' + exception.name + ')' : 'No rows found') + '', + result = c.ajaxProcessing(data) || [ 0, [] ], + d = result[1] || [], + l = d.length, + th = result[2]; + if ( l > 0 ) { + for ( i = 0; i < l; i++ ) { + tds += ''; + for ( j = 0; j < d[i].length; j++ ) { + // build tbody cells + tds += '' + d[i][j] + ''; + } + tds += ''; + } + } + // only add new header text if the length matches + if ( th && th.length === hl ) { + hsh = $t.hasClass('hasStickyHeaders'); + $sh = $t.find('.' + ((tc.widgetOptions && tc.widgetOptions.stickyHeaders) || 'tablesorter-stickyheader')); + $f = $t.find('tfoot tr:first').children(); + $t.find('th.' + tc.cssHeader).each(function(j){ + var $t = $(this), icn; + // add new test within the first span it finds, or just in the header + if ( $t.find('.' + tc.cssIcon).length ) { + icn = $t.find('.' + tc.cssIcon).clone(true); + $t.find('.tablesorter-header-inner').html( th[j] ).append(icn); + if ( hsh && $sh.length ) { + icn = $sh.find('th').eq(j).find('.' + tc.cssIcon).clone(true); + $sh.find('th').eq(j).find('.tablesorter-header-inner').html( th[j] ).append(icn); + } + } else { + $t.find('.tablesorter-header-inner').html( th[j] ); + $sh.find('th').eq(j).find('.tablesorter-header-inner').html( th[j] ); + } + $f.eq(j).html( th[j] ); + }); + } + if ( exception ) { + // add error row to thead instead of tbody, or clicking on the header will result in a parser error + $t.find('thead').append(err); + } else { + $b.html( tds ); // add tbody + } + $.tablesorter.isProcessing(table); // remove loading icon + $t.trigger('update'); + c.totalRows = result[0] || 0; + c.totalPages = Math.ceil( c.totalRows / c.size ); + updatePageDisplay(table, c); + fixHeight(table, c); + if (c.initialized) { $t.trigger('pagerChange', c); } + } + if (!c.initialized) { + c.initialized = true; + $(table).trigger('pagerInitialized', c); + } + }, + + getAjax = function(table, c){ + var url = (c.ajaxUrl) ? c.ajaxUrl.replace(/\{page\}/g, c.page).replace(/\{size\}/g, c.size) : '', + arry = [], + sl = table.config.sortList, + col = url.match(/\{sortList[\s+]?:[\s+]?(.*)\}/); + if (col) { + col = col[1]; + $.each(sl, function(i,v){ + arry.push(col + '[' + v[0] + ']=' + v[1]); + }); + // if the arry is empty, just add the col parameter... "&{sortList:col}" becomes "&col" + url = url.replace(/\{sortList[\s+]?:[\s+]?(.*)\}/g, arry.length ? arry.join('&') : col ); + } + if ( url !== '' ) { + // loading icon + $.tablesorter.isProcessing(table, true); + $(document).ajaxError(function(e, xhr, settings, exception) { + renderAjax(null, table, c, exception); + }); + $.getJSON(url, function(data) { + renderAjax(data, table, c); + }); + } + }, + + renderTable = function(table, rows, c) { + var i, j, o, + f = document.createDocumentFragment(), + l = rows.length, + s = ( c.page * c.size ), + e = ( s + c.size ); + if ( l < 1 ) { return; } // empty table, abort! + if (c.initialized) { $(table).trigger('pagerChange', c); } + if ( !c.removeRows ) { + hideRows(table, c); + } else { + if ( e > rows.length ) { + e = rows.length; + } + $(table.tBodies[0]).addClass('tablesorter-hidden'); + $.tablesorter.clearTableBody(table); + for ( i = s; i < e; i++ ) { + o = rows[i]; + l = o.length; + for ( j = 0; j < l; j++ ) { + f.appendChild(o[j]); + } + } + table.tBodies[0].appendChild(f); + $(table.tBodies[0]).removeClass('tablesorter-hidden'); + } + if ( c.page >= c.totalPages ) { + moveToLastPage(table, c); + } + updatePageDisplay(table, c); + if ( !c.isDisabled ) { fixHeight(table, c); } + $(table).trigger('applyWidgets'); + }, + + showAllRows = function(table, c){ + if ( c.ajax ) { + pagerArrows(c, true); + } else { + c.isDisabled = true; + $.data(table, 'pagerLastPage', c.page); + $.data(table, 'pagerLastSize', c.size); + c.page = 0; + c.size = c.totalRows; + c.totalPages = 1; + $('tr.pagerSavedHeightSpacer', table.tBodies[0]).remove(); + renderTable(table, table.config.rowsCopy, c); + } + // disable size selector + $(c.container).find(c.cssPageSize + ',' + c.cssGoto).each(function(){ + $(this).addClass(c.cssDisabled)[0].disabled = true; + }); + }, + + moveToPage = function(table, c) { + if ( c.isDisabled ) { return; } + var p = Math.min( c.totalPages, c.filteredPages ); + if ( c.page < 0 || c.page > ( p - 1 ) ) { + c.page = 0; + } + // change if page changed - fixes #182 + if (c.ajax && $.data(table, 'pagerLastPage') !== c.page) { + getAjax(table, c); + } else if (!c.ajax) { + renderTable(table, table.config.rowsCopy, c); + } + $.data(table, 'pagerLastPage', c.page); + if (c.initialized) { $(table).trigger('pageMoved', c); } + }, + + setPageSize = function(table, size, c) { + c.size = size; + $.data(table, 'pagerLastPage', c.page); + $.data(table, 'pagerLastSize', c.size); + c.totalPages = Math.ceil( c.totalRows / c.size ); + moveToPage(table, c); + }, + + moveToFirstPage = function(table, c) { + c.page = 0; + moveToPage(table, c); + }, + + moveToLastPage = function(table, c) { + c.page = ( Math.min( c.totalPages, c.filteredPages ) - 1 ); + moveToPage(table, c); + }, + + moveToNextPage = function(table, c) { + c.page++; + if ( c.page >= ( Math.min( c.totalPages, c.filteredPages ) - 1 ) ) { + c.page = ( Math.min( c.totalPages, c.filteredPages ) - 1 ); + } + moveToPage(table, c); + }, + + moveToPrevPage = function(table, c) { + c.page--; + if ( c.page <= 0 ) { + c.page = 0; + } + moveToPage(table, c); + }, + + destroyPager = function(table, c){ + showAllRows(table, c); + $(c.container).hide(); // hide pager + table.config.appender = null; // remove pager appender function + $(table).unbind('destroy.pager sortEnd.pager filterEnd.pager enable.pager disable.pager'); + }, + + enablePager = function(table, c, triggered){ + var p = $(c.cssPageSize, c.container).removeClass(c.cssDisabled).removeAttr('disabled'); + $(c.container).find(c.cssGoto).removeClass(c.cssDisabled).removeAttr('disabled'); + c.isDisabled = false; + c.page = $.data(table, 'pagerLastPage') || c.page || 0; + c.size = $.data(table, 'pagerLastSize') || parseInt(p.find('option[selected]').val(), 10) || c.size; + p.val(c.size); // set page size + c.totalPages = Math.ceil( Math.min( c.totalPages, c.filteredPages ) / c.size); + if ( triggered ) { + $(table).trigger('update'); + setPageSize(table, c.size, c); + hideRowsSetup(table, c); + fixHeight(table, c); + } + }; + + $this.appender = function(table, rows) { + var c = table.config.pager; + if ( !c.ajax ) { + table.config.rowsCopy = rows; + c.totalRows = rows.length; + c.size = $.data(table, 'pagerLastSize') || c.size; + c.totalPages = Math.ceil(c.totalRows / c.size); + renderTable(table, rows, c); + } + }; + + $this.construct = function(settings) { + return this.each(function() { + // check if tablesorter has initialized + if (!(this.config && this.hasInitialized)) { return; } + var config = this.config, + c = config.pager = $.extend( {}, $.tablesorterPager.defaults, settings ), + table = this, + $t = $(table), + pager = $(c.container).addClass('tablesorter-pager').show(); // added in case the pager is reinitialized after being destroyed. + config.appender = $this.appender; + // clear initialized flag + c.initialized = false; + enablePager(table, c, false); + if ( typeof(c.ajaxUrl) === 'string' ) { + // ajax pager; interact with database + c.ajax = true; + getAjax(table, c); + } else { + c.ajax = false; + // Regular pager; all rows stored in memory + $(this).trigger("appendCache", true); + hideRowsSetup(table, c); + } + + // update pager after filter widget completes + $(table) + .unbind('filterEnd.pager updateComplete.pager ') + .bind('filterEnd.pager updateComplete.pager', function() { + if ($(this).hasClass('hasFilters')) { + c.page = 0; + updatePageDisplay(table, c); + moveToPage(table, c); + changeHeight(table, c); + } + }); + + if ( $(c.cssGoto, pager).length ) { + $(c.cssGoto, pager).bind('change', function(){ + c.page = $(this).val() - 1; + moveToPage(table, c); + }); + updatePageDisplay(table, c); + } + $(c.cssFirst,pager).unbind('click.pager').bind('click.pager', function() { + if ( !$(this).hasClass(c.cssDisabled) ) { moveToFirstPage(table, c); } + return false; + }); + $(c.cssNext,pager).unbind('click.pager').bind('click.pager', function() { + if ( !$(this).hasClass(c.cssDisabled) ) { moveToNextPage(table, c); } + return false; + }); + $(c.cssPrev,pager).unbind('click.pager').bind('click.pager', function() { + if ( !$(this).hasClass(c.cssDisabled) ) { moveToPrevPage(table, c); } + return false; + }); + $(c.cssLast,pager).unbind('click.pager').bind('click.pager', function() { + if ( !$(this).hasClass(c.cssDisabled) ) { moveToLastPage(table, c); } + return false; + }); + $(c.cssPageSize,pager).unbind('change.pager').bind('change.pager', function() { + $(c.cssPageSize,pager).val( $(this).val() ); // in case there are more than one pagers + if ( !$(this).hasClass(c.cssDisabled) ) { + setPageSize(table, parseInt( $(this).val(), 10 ), c); + changeHeight(table, c); + } + return false; + }); + + $t + .unbind('disable.pager enable.pager destroy.pager update.pager') + .bind('disable.pager', function(){ + showAllRows(table, c); + }) + .bind('enable.pager', function(){ + enablePager(table, c, true); + }) + .bind('destroy.pager', function(){ + destroyPager(table, c); + }) + .bind('update.pager', function(){ + hideRows(table, c); + }); + + // pager initialized + if (!c.ajax) { + c.initialized = true; + $(table).trigger('pagerInitialized', c); + } + }); + }; + + }() +}); +// extend plugin scope +$.fn.extend({ + tablesorterPager: $.tablesorterPager.construct +}); + })(jQuery); \ No newline at end of file diff --git a/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.js b/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.js index 412f03d..3c6c290 100644 --- a/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.js +++ b/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.js @@ -1,5 +1,5 @@ -/*! -* TableSorter 2.4.6 - Client-side table sorting with ease! +/*! +* TableSorter 2.5.2 - Client-side table sorting with ease! * @requires jQuery v1.2.6+ * * Copyright (c) 2007 Christian Bach @@ -14,7 +14,7 @@ * @author Christian Bach/christian.bach@polyester.se * @contributor Rob Garrison/https://github.com/Mottie/tablesorter */ -/*jshint evil:true, browser:true, jquery:true, unused:false */ +/*jshint browser:true, jquery:true, unused:false */ /*global console:false, alert:false */ !(function($) { "use strict"; @@ -23,7 +23,7 @@ var ts = this; - ts.version = "2.4.5"; + ts.version = "2.5.2"; ts.parsers = []; ts.widgets = []; @@ -71,9 +71,9 @@ // css class names tableClass : 'tablesorter', - cssAsc : 'tablesorter-headerSortUp', + cssAsc : 'tablesorter-headerAsc', cssChildRow : 'tablesorter-childRow', // previously "expand-child" - cssDesc : 'tablesorter-headerSortDown', + cssDesc : 'tablesorter-headerDesc', cssHeader : 'tablesorter-header', cssHeaderRow : 'tablesorter-headerRow', cssIcon : 'tablesorter-icon', // if this class exists, a will be added to the header automatically @@ -162,7 +162,7 @@ return ts.parsers[0]; } - function buildParserCache(table, $headers) { + function buildParserCache(table) { var c = table.config, tb = $(table.tBodies).filter(':not(.' + c.cssInfoBlock + ')'), rows, list, l, i, h, ch, p, parsersDebug = ""; @@ -173,7 +173,10 @@ l = rows[0].cells.length; for (i = 0; i < l; i++) { // tons of thanks to AnthonyM1229 for working out the following selector (issue #74) to make this work in IE8! - h = $headers.filter(':not([colspan])[data-column="' + i + '"]:last,[colspan="1"][data-column="' + i + '"]:last'); + // More fixes to this selector to work properly in iOS and jQuery 1.8+ (issue #132 & #174) + h = c.$headers.filter(':not([colspan])'); + h = h.add( c.$headers.filter('[colspan="1"]') ) // ie8 fix + .filter('[data-column="' + i + '"]:last'); ch = c.headers[i]; // get column parser p = ts.getParserById( ts.getData(h, ch, 'sorter') ); @@ -203,7 +206,7 @@ totalRows, totalCells, parsers = tc.parsers, - t, i, j, k, c, cols, cacheTime; + t, v, i, j, k, c, cols, cacheTime, colMax = []; tc.cache = {}; if (tc.debug) { cacheTime = new Date(); @@ -233,11 +236,16 @@ t = getElementText(table, c[0].cells[j], j); // 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 - cols.push( parsers[j].format(t, table, c[0].cells[j], j) ); + v = parsers[j].format(t, table, c[0].cells[j], j); + cols.push(v); + if ((parsers[j].type || '').toLowerCase() === "numeric") { + colMax[j] = Math.max(Math.abs(v), colMax[j] || 0); // determine column max value (ignore sign) + } } cols.push(tc.cache[k].normalized.length); // add position for rowCache tc.cache[k].normalized.push(cols); } + tc.cache[k].colMax = colMax; } } if (tc.showProcessing) { @@ -370,7 +378,7 @@ if (typeof(lock) !== 'undefined' && lock !== false) { this.order = this.lockedOrder = formatSortingOrder(lock) ? [1,1,1] : [0,0,0]; } - $t.addClass( this.sortDisabled ? 'sorter-false' : c.cssHeader ); + $t.addClass( (this.sortDisabled ? 'sorter-false ' : ' ') + c.cssHeader ); // add cell to headerList c.headerList[index] = this; // add to parent in case there are multiple rows @@ -383,28 +391,28 @@ return $tableHeaders; } - function setHeadersCss(table, $headers) { + function setHeadersCss(table) { var f, i, j, l, c = table.config, list = c.sortList, - css = [c.cssDesc, c.cssAsc], + css = [c.cssAsc, c.cssDesc], // find the footer $t = $(table).find('tfoot tr').children().removeClass(css.join(' ')); // remove all header information - $headers.removeClass(css.join(' ')); + c.$headers.removeClass(css.join(' ')); l = list.length; for (i = 0; i < l; i++) { // direction = 2 means reset! if (list[i][1] !== 2) { // multicolumn sorting updating - choose the :last in case there are nested columns - f = $headers.not('.sorter-false').filter('[data-column="' + list[i][0] + '"]' + (l === 1 ? ':last' : '') ); + f = c.$headers.not('.sorter-false').filter('[data-column="' + list[i][0] + '"]' + (l === 1 ? ':last' : '') ); if (f.length) { for (j = 0; j < f.length; j++) { if (!f[j].sortDisabled) { f.eq(j).addClass(css[list[i][1]]); // add sorted class to footer, if it exists if ($t.length) { - $t.filter('[data-column="' + list[i][0] + '"]').eq(j).addClass(css[list[i][1]]); + $t.filter('[data-column="' + list[i][0] + '"]').eq(j).addClass(css[list[i][1]]); } } } @@ -446,48 +454,38 @@ } // sort multiple columns - function multisort(table) { +/* */ + function multisort(table) { /*jshint loopfunc:true */ var dynamicExp, sortWrapper, col, mx = 0, dir = 0, tc = table.config, sortList = tc.sortList, l = sortList.length, bl = table.tBodies.length, - sortTime, i, j, k, c, cache, lc, s, e, order, orgOrderCol; + sortTime, i, j, k, c, colMax, cache, lc, s, e, order, orgOrderCol; if (tc.debug) { sortTime = new Date(); } for (k = 0; k < bl; k++) { - dynamicExp = "sortWrapper = function(a,b) {"; - cache = tc.cache[k]; - lc = cache.normalized.length; - for (i = 0; i < l; i++) { - c = sortList[i][0]; - order = sortList[i][1]; - // fallback to natural sort since it is more robust - s = /n/i.test(getCachedSortType(tc.parsers, c)) ? "Numeric" : "Text"; - s += order === 0 ? "" : "Desc"; - e = "e" + i; - // get max column value (ignore sign) - if (/Numeric/.test(s) && tc.strings[c]) { - for (j = 0; j < lc; j++) { - col = Math.abs(parseFloat(cache.normalized[j][c])); - mx = Math.max( mx, isNaN(col) ? 0 : col ); - } - // sort strings in numerical columns - if (typeof(tc.string[tc.strings[c]]) === 'boolean') { - dir = (order === 0 ? 1 : -1) * (tc.string[tc.strings[c]] ? -1 : 1); - } else { - dir = (tc.strings[c]) ? tc.string[tc.strings[c]] || 0 : 0; + colMax = tc.cache[k].colMax; + cache = tc.cache[k].normalized; + lc = cache.length; + orgOrderCol = (cache && cache[0]) ? cache[0].length - 1 : 0; + cache.sort(function(a, b) { + // cache is undefined here in IE, so don't use it! + for (i = 0; i < l; i++) { + c = sortList[i][0]; + order = sortList[i][1]; + // fallback to natural sort since it is more robust + s = /n/i.test(getCachedSortType(tc.parsers, c)) ? "Numeric" : "Text"; + s += order === 0 ? "" : "Desc"; + if (/Numeric/.test(s) && tc.strings[c]) { + // sort strings in numerical columns + if (typeof (tc.string[tc.strings[c]]) === 'boolean') { + dir = (order === 0 ? 1 : -1) * (tc.string[tc.strings[c]] ? -1 : 1); + } else { + dir = (tc.strings[c]) ? tc.string[tc.strings[c]] || 0 : 0; + } } + var sort = $.tablesorter["sort" + s](table, a[c], b[c], c, colMax[c], dir); + if (sort) { return sort; } } - dynamicExp += "var " + e + " = $.tablesorter.sort" + s + "(table,a[" + c + "],b[" + c + "]," + c + "," + mx + "," + dir + "); "; - dynamicExp += "if (" + e + ") { return " + e + "; } "; - dynamicExp += "else { "; - } - // if value is the same keep orignal order - orgOrderCol = (cache.normalized && cache.normalized[0]) ? cache.normalized[0].length - 1 : 0; - dynamicExp += "return a[" + orgOrderCol + "]-b[" + orgOrderCol + "];"; - for (i=0; i < l; i++) { - dynamicExp += "}; "; - } - dynamicExp += "return 0; "; - dynamicExp += "}; "; - cache.normalized.sort(eval(dynamicExp)); // sort using eval expression + return a[orgOrderCol] - b[orgOrderCol]; + }); } if (tc.debug) { benchmark("Sorting on " + sortList.toString() + " and dir " + order + " time", sortTime); } } @@ -515,7 +513,7 @@ // if no thead or tbody, or tablesorter is already present, quit if (!this.tHead || this.tBodies.length === 0 || this.hasInitialized === true) { return; } // declare - var $headers, $cell, $this = $(this), + var $cell, $this = $(this), c, i, j, k = '', a, s, o, downTime, m = $.metadata; // initialization flag @@ -538,15 +536,15 @@ } $this.addClass(c.tableClass + k); // build headers - $headers = buildHeaders(this); + c.$headers = buildHeaders(this); // try to auto detect column type, and store in tables config - c.parsers = buildParserCache(this, $headers); + c.parsers = buildParserCache(this); // build the cache for the tbody cells // delayInit will delay building the cache until the user starts a sort if (!c.delayInit) { buildCache(this); } // apply event handling to headers // this is to big, perhaps break it out? - $headers + c.$headers // http://stackoverflow.com/questions/5312849/jquery-find-self .find('*').andSelf().filter(c.selectorSort) .unbind('mousedown.tablesorter mouseup.tablesorter') @@ -574,7 +572,7 @@ // reset all sorts on non-current column - issue #30 if (c.sortRestart) { i = cell; - $headers.each(function() { + c.$headers.each(function() { // only reset counts on columns that weren't just clicked on and if not included in a multisort if (this !== i && (k || !$(this).is('.' + c.cssDesc + ',.' + c.cssAsc))) { this.count = -1; @@ -655,7 +653,7 @@ // setTimeout needed so the processing icon shows up setTimeout(function(){ // set css for headers - setHeadersCss($this[0], $headers); + setHeadersCss($this[0]); multisort($this[0]); appendToTable($this[0]); }, 1); @@ -663,7 +661,7 @@ }); if (c.cancelSelection) { // cancel selection - $headers.each(function() { + c.$headers.each(function() { this.onselectstart = function() { return false; }; @@ -671,12 +669,18 @@ } // apply easy methods that trigger binded events $this - .unbind('update updateCell addRows sorton appendCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave') + .unbind('sortReset update updateCell addRows sorton appendCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave') + .bind("sortReset", function(){ + c.sortList = []; + setHeadersCss(this); + multisort(this); + appendToTable(this); + }) .bind("update", function(e, resort, callback) { // remove rows/elements before update $(c.selectorRemove, this).remove(); // rebuild parsers - c.parsers = buildParserCache(this, $headers); + c.parsers = buildParserCache(this); // rebuild the cache map buildCache(this); checkResort($this, resort, callback); @@ -703,6 +707,10 @@ var i, rows = $row.filter('tr').length, dat = [], l = $row[0].cells.length, t = this, tbdy = $(this).find('tbody').index( $row.closest('tbody') ); + // fixes adding rows to an empty table - see issue #179 + if (!c.parsers) { + c.parsers = buildParserCache(t); + } // add each row for (i = 0; i < rows; i++) { // add each cell @@ -724,7 +732,7 @@ // update header count index updateHeaderSortCount(this, list); // set css for headers - setHeadersCss(this, $headers); + setHeadersCss(this); // sort the table and append it to the dom multisort(this); appendToTable(this, init); @@ -844,7 +852,7 @@ // disable tablesorter $t .removeData('tablesorter') - .unbind('update updateCell addRows sorton appendCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave') + .unbind('sortReset update updateCell addRows sorton appendCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave') .find('.' + c.cssHeader) .unbind('click mousedown mousemove mouseup') .removeClass(c.cssHeader + ' ' + c.cssAsc + ' ' + c.cssDesc) @@ -1304,6 +1312,7 @@ row = 0; $tv = $tb.children('tr:visible'); // revered back to using jQuery each - strangely it's the fastest method + /*jshint loopfunc:true */ $tv.each(function(){ $tr = $(this); // style children rows the same way the parent row was styled diff --git a/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.min.js b/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.min.js index e6ba42c..1f3601e 100644 --- a/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.min.js +++ b/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.min.js @@ -1,6 +1,5 @@ /*! -* TableSorter 2.4.6 - Client-side table sorting with ease! -* Minified using UglifyJS (http://jscompress.com/) +* TableSorter 2.5.2 min - Client-side table sorting with ease! * Copyright (c) 2007 Christian Bach */ -!function($){"use strict";$.extend({tablesorter:new function(){function log(a){if(typeof console!=="undefined"&&typeof console.log!=="undefined"){console.log(a)}else{alert(a)}}function benchmark(a,b){log(a+" ("+((new Date).getTime()-b.getTime())+"ms)")}function getElementText(a,b,c){if(!b){return""}var d=a.config,e=d.textExtraction,f="";if(e==="simple"){if(d.supportsTextContent){f=b.textContent}else{f=$(b).text()}}else{if(typeof e==="function"){f=e(b,a,c)}else if(typeof e==="object"&&e.hasOwnProperty(c)){f=e[c](b,a,c)}else{f=d.supportsTextContent?b.textContent:$(b).text()}}return $.trim(f)}function detectParserForColumn(a,b,c,d){var e,f=ts.parsers.length,g=false,h="",i=true;while(h===""&&i){c++;if(b[c]){g=b[c].cells[d];h=getElementText(a,g,d);if(a.config.debug){log("Checking if value was empty on row "+c+", column: "+d+": "+h)}}else{i=false}}for(e=1;e':"";this.innerHTML='
'+this.innerHTML+e+"
";if(i.onRenderHeader){i.onRenderHeader.apply(d,[a])}this.column=b[this.parentNode.rowIndex+"-"+this.cellIndex];this.order=formatSortingOrder(ts.getData(d,c,"sortInitialOrder")||i.sortInitialOrder)?[1,0,2]:[0,1,2];this.count=-1;if(ts.getData(d,c,"sorter")==="false"){this.sortDisabled=true;d.addClass("sorter-false")}else{d.removeClass("sorter-false")}this.lockedOrder=false;f=ts.getData(d,c,"lockedOrder")||false;if(typeof f!=="undefined"&&f!==false){this.order=this.lockedOrder=formatSortingOrder(f)?[1,1,1]:[0,0,0]}d.addClass(this.sortDisabled?"sorter-false":i.cssHeader);i.headerList[a]=this;d.parent().addClass(i.cssHeaderRow)});if(a.config.debug){benchmark("Built headers:",g);log(h)}return h}function setHeadersCss(a,b){var c,d,e,f,g=a.config,h=g.sortList,i=[g.cssDesc,g.cssAsc],j=$(a).find("tfoot tr").children().removeClass(i.join(" "));b.removeClass(i.join(" "));f=h.length;for(d=0;d"),c=$(a).width();$("tr:first td",a.tBodies[0]).each(function(){b.append($("").css("width",parseInt($(this).width()/c*1e3,10)/10+"%"))});$(a).prepend(b)}}function updateHeaderSortCount(a,b){var c,d,e=a.config,f=e.headerList.length,g=b||e.sortList;e.sortList=[];$.each(g,function(a,b){c=[parseInt(b[0],10),parseInt(b[1],10)];d=e.headerList[c[0]];if(d){e.sortList.push(c);d.count=c[1]%(e.sortReset?3:2)}})}function getCachedSortType(a,b){return a&&a[b]?a[b].type||"":""}function multisort(table){var dynamicExp,sortWrapper,col,mx=0,dir=0,tc=table.config,sortList=tc.sortList,l=sortList.length,bl=table.tBodies.length,sortTime,i,j,k,c,cache,lc,s,e,order,orgOrderCol;if(tc.debug){sortTime=new Date}for(k=0;k thead th, > thead td",selectorSort:"th, td",selectorRemove:".remove-me",debug:false,headerList:[],empties:{},strings:{},parsers:[]};ts.benchmark=benchmark;ts.construct=function(a){return this.each(function(){if(!this.tHead||this.tBodies.length===0||this.hasInitialized===true){return}var b,c,d=$(this),e,f,g,h="",i,j,k,l,m=$.metadata;this.hasInitialized=false;this.config={};e=$.extend(true,this.config,ts.defaults,a);$.data(this,"tablesorter",e);if(e.debug){$.data(this,"startoveralltimer",new Date)}e.supportsTextContent=$("x")[0].textContent==="x";e.supportsDataObject=parseFloat($.fn.jquery)>=1.4;e.string={max:1,min:-1,"max+":1,"max-":-1,zero:0,none:0,"null":0,top:true,bottom:false};if(!/tablesorter\-/.test(d.attr("class"))){h=e.theme!==""?" tablesorter-"+e.theme:""}d.addClass(e.tableClass+h);b=buildHeaders(this);e.parsers=buildParserCache(this,b);if(!e.delayInit){buildCache(this)}b.find("*").andSelf().filter(e.selectorSort).unbind("mousedown.tablesorter mouseup.tablesorter").bind("mousedown.tablesorter mouseup.tablesorter",function(a,c){var m=this.tagName.match("TH|TD")?$(this):$(this).parents("th, td").filter(":last"),n=m[0];if((a.which||a.button)!==1){return false}if(a.type==="mousedown"){l=(new Date).getTime();return a.target.tagName==="INPUT"?"":!e.cancelSelection}if(c!==true&&(new Date).getTime()-l>250){return false}if(e.delayInit&&!e.cache){buildCache(d[0])}if(!n.sortDisabled){d.trigger("sortStart",d[0]);h=!a[e.sortMultiSortKey];n.count=(n.count+1)%(e.sortReset?3:2);if(e.sortRestart){f=n;b.each(function(){if(this!==f&&(h||!$(this).is("."+e.cssDesc+",."+e.cssAsc))){this.count=-1}})}f=n.column;if(h){e.sortList=[];if(e.sortForce!==null){i=e.sortForce;for(g=0;g1){for(g=1;g1){if(ts.isValueInArray(e.sortAppend[0][0],e.sortList)){e.sortList.pop()}}if(ts.isValueInArray(f,e.sortList)){for(g=0;g1){for(g=1;g=0){h=k.eq(l).find("tr").index(m);i=b.cellIndex;g=j.config.cache[l].normalized[h].length-1;j.config.cache[l].row[j.config.cache[l].normalized[h][g]]=m;j.config.cache[l].normalized[h][i]=e.parsers[i].format(getElementText(j,b,i),j,b,i);checkResort(d,c,f)}}).bind("addRows",function(a,b,c,f){var h,i=b.filter("tr").length,j=[],k=b[0].cells.length,l=this,m=$(this).find("tbody").index(b.closest("tbody"));for(h=0;h0){d.trigger("sorton",[e.sortList,{},!e.initWidgets])}else if(e.initWidgets){ts.applyWidget(this)}fixColumnWidth(this);if(e.showProcessing){d.unbind("sortBegin sortEnd").bind("sortBegin sortEnd",function(a){ts.isProcessing(d[0],a.type==="sortBegin")})}this.hasInitialized=true;if(e.debug){ts.benchmark("Overall initialization time",$.data(this,"startoveralltimer"))}d.trigger("tablesorter-initialized",this);if(typeof e.initialized==="function"){e.initialized(this)}})};ts.isProcessing=function(a,b,c){var d=a.config,e=c||$(a).find("."+d.cssHeader);if(b){if(d.sortList.length>0){e=e.filter(function(){return this.sortDisabled?false:ts.isValueInArray(parseFloat($(this).attr("data-column")),d.sortList)})}e.addClass(d.cssProcessing)}else{e.removeClass(d.cssProcessing)}};ts.processTbody=function(a,b,c){var d,e;if(c){b.before('');e=$.fn.detach?b.detach():b.remove();return e}e=$(a).find("span.tablesorter-savemyplace");b.insertAfter(e);e.remove()};ts.clearTableBody=function(a){$(a.tBodies).filter(":not(."+a.config.cssInfoBlock+")").empty()};ts.destroy=function(a,b,c){var d=$(a),e=a.config,f=d.find("thead:first");a.hasInitialized=false;f.find("tr:not(."+e.cssHeaderRow+")").remove();f.find(".tablesorter-resizer").remove();ts.refreshWidgets(a,true,true);d.removeData("tablesorter").unbind("update updateCell addRows sorton appendCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave").find("."+e.cssHeader).unbind("click mousedown mousemove mouseup").removeClass(e.cssHeader+" "+e.cssAsc+" "+e.cssDesc).find(".tablesorter-header-inner").each(function(){if(e.cssIcon!==""){$(this).find("."+e.cssIcon).remove()}$(this).replaceWith($(this).contents())});if(b!==false){d.removeClass(e.tableClass)}if(typeof c==="function"){c(a)}};ts.regex=[/(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,/^0x[0-9a-f]+$/i];ts.sortText=function(a,b,c,d){if(b===c){return 0}var e=a.config,f=e.string[e.empties[d]||e.emptyTo],g=ts.regex,h,i,j,k,l,m,n,o;if(b===""&&f!==0){return typeof f==="boolean"?f?-1:1:-f||-1}if(c===""&&f!==0){return typeof f==="boolean"?f?1:-1:f||1}if(typeof e.textSorter==="function"){return e.textSorter(b,c,a,d)}h=b.replace(g[0],"\\0$1\\0").replace(/\\0$/,"").replace(/^\\0/,"").split("\\0");j=c.replace(g[0],"\\0$1\\0").replace(/\\0$/,"").replace(/^\\0/,"").split("\\0");i=parseInt(b.match(g[2]),16)||h.length!==1&&b.match(g[1])&&Date.parse(b);k=parseInt(c.match(g[2]),16)||i&&c.match(g[1])&&Date.parse(c)||null;if(k){if(ik){return 1}}o=Math.max(h.length,j.length);for(n=0;nm){return 1}}return 0};ts.sortTextDesc=function(a,b,c,d){if(b===c){return 0}var e=a.config,f=e.string[e.empties[d]||e.emptyTo];if(b===""&&f!==0){return typeof f==="boolean"?f?-1:1:f||1}if(c===""&&f!==0){return typeof f==="boolean"?f?1:-1:-f||-1}if(typeof e.textSorter==="function"){return e.textSorter(c,b,a,d)}return ts.sortText(a,c,b)};ts.getTextValue=function(a,b,c){if(b){var d,e=a.length,f=b+c;for(d=0;d=0){c.widgets.splice(g,1);c.widgets.push("zebra")}if(c.debug){f=new Date}for(g=0;g1){g=0;e=d.children("tr:visible");e.each(function(){f=$(this);if(!l.test(this.className)){g++}h=g%2===0;f.removeClass(c.zebra[h?1:0]).addClass(c.zebra[h?0:1])})}}if(b.debug){ts.benchmark("Applying Zebra widget",i)}},remove:function(a,b,c){var d,e,f=$(a).children("tbody:not(."+b.cssInfoBlock+")"),g=(b.widgetOptions.zebra||["even","odd"]).join(" ");for(d=0;d thead th, > thead td",selectorSort:"th, td",selectorRemove:".remove-me",debug:!1,headerList:[],empties:{},strings:{},parsers:[]};e.benchmark=u;e.construct= function(c){return this.each(function(){if(this.tHead&&!(0===this.tBodies.length||!0===this.hasInitialized)){var b=f(this),a,g,h,s="",j,l,k,m,C=f.metadata;this.hasInitialized=!1;this.config={};a=f.extend(!0,this.config,e.defaults,c);f.data(this,"tablesorter",a);a.debug&&f.data(this,"startoveralltimer",new Date);a.supportsTextContent="x"===f("x")[0].textContent;a.supportsDataObject=1.4<=parseFloat(f.fn.jquery);a.string={max:1,min:-1,"max+":1,"max-":-1,zero:0,none:0,"null":0,top:!0,bottom:!1}; /tablesorter\-/.test(b.attr("class"))||(s=""!==a.theme?" tablesorter-"+a.theme:"");b.addClass(a.tableClass+s);var q=[],M={},x=f(this).find("thead:eq(0) tr, tfoot tr"),H,I,v,y,L,A,J,N,O,F;for(H=0;H':"";this.innerHTML='
'+this.innerHTML+P+"
";w.onRenderHeader&&w.onRenderHeader.apply(z,[a]);this.column=M[this.parentNode.rowIndex+"-"+this.cellIndex];var b=e.getData(z,K,"sortInitialOrder")||w.sortInitialOrder;this.order= /^d/i.test(b)||1===b?[1,0,2]:[0,1,2];this.count=-1;"false"===e.getData(z,K,"sorter")?(this.sortDisabled=!0,z.addClass("sorter-false")):z.removeClass("sorter-false");this.lockedOrder=!1;G=e.getData(z,K,"lockedOrder")||!1;"undefined"!==typeof G&&!1!==G&&(this.order=this.lockedOrder=/^d/i.test(G)||1===G?[1,1,1]:[0,0,0]);z.addClass((this.sortDisabled?"sorter-false ":" ")+w.cssHeader);w.headerList[a]=this;z.parent().addClass(w.cssHeaderRow)});this.config.debug&&(u("Built headers:",Q),d(q));a.$headers= q;a.parsers=i(this);a.delayInit||p(this);a.$headers.find("*").andSelf().filter(a.selectorSort).unbind("mousedown.tablesorter mouseup.tablesorter").bind("mousedown.tablesorter mouseup.tablesorter",function(c,d){var i=(this.tagName.match("TH|TD")?f(this):f(this).parents("th, td").filter(":last"))[0];if(1!==(c.which||c.button))return!1;if("mousedown"===c.type)return m=(new Date).getTime(),"INPUT"===c.target.tagName?"":!a.cancelSelection;if(!0!==d&&250<(new Date).getTime()-m)return!1;a.delayInit&&!a.cache&& p(b[0]);if(!i.sortDisabled){b.trigger("sortStart",b[0]);s=!c[a.sortMultiSortKey];i.count=(i.count+1)%(a.sortReset?3:2);a.sortRestart&&(g=i,a.$headers.each(function(){if(this!==g&&(s||!f(this).is("."+a.cssDesc+",."+a.cssAsc)))this.count=-1}));g=i.column;if(s){a.sortList=[];if(null!==a.sortForce){j=a.sortForce;for(h=0;hk&&(a.sortList.push([g,k]),1k&&(a.sortList.push([g,k]),1"),S=f(this).width();f("tr:first td",this.tBodies[0]).each(function(){R.append(f("").css("width",parseInt(1E3*(f(this).width()/S),10)/10+"%"))});f(this).prepend(R)}a.showProcessing&&b.unbind("sortBegin sortEnd").bind("sortBegin sortEnd",function(a){e.isProcessing(b[0], "sortBegin"===a.type)});this.hasInitialized=!0;a.debug&&e.benchmark("Overall initialization time",f.data(this,"startoveralltimer"));b.trigger("tablesorter-initialized",this);"function"===typeof a.initialized&&a.initialized(this)}})};e.isProcessing=function(c,b,a){var g=c.config,c=a||f(c).find("."+g.cssHeader);b?(0'),c=f.fn.detach?b.detach():b.remove();c=f(c).find("span.tablesorter-savemyplace");b.insertAfter(c);c.remove()};e.clearTableBody=function(c){f(c.tBodies).filter(":not(."+c.config.cssInfoBlock+")").empty()};e.destroy=function(c,b,a){var g=f(c),h=c.config,d=g.find("thead:first");c.hasInitialized=!1;d.find("tr:not(."+h.cssHeaderRow+")").remove();d.find(".tablesorter-resizer").remove();e.refreshWidgets(c,!0,!0); g.removeData("tablesorter").unbind("sortReset update updateCell addRows sorton appendCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave").find("."+h.cssHeader).unbind("click mousedown mousemove mouseup").removeClass(h.cssHeader+" "+h.cssAsc+" "+h.cssDesc).find(".tablesorter-header-inner").each(function(){""!==h.cssIcon&&f(this).find("."+h.cssIcon).remove();f(this).replaceWith(f(this).contents())});!1!==b&&g.removeClass(h.tableClass);"function"===typeof a&&a(c)};e.regex=[/(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi, /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,/^0x[0-9a-f]+$/i];e.sortText=function(c,b,a,g){if(b===a)return 0;var h=c.config,d=h.string[h.empties[g]||h.emptyTo],j=e.regex;if(""===b&&0!==d)return"boolean"===typeof d?d?-1:1:-d||-1;if(""===a&&0!==d)return"boolean"===typeof d?d?1:-1:d||1;if("function"===typeof h.textSorter)return h.textSorter(b,a,c,g);c=b.replace(j[0],"\\0$1\\0").replace(/\\0$/,"").replace(/^\\0/,"").split("\\0");g=a.replace(j[0], "\\0$1\\0").replace(/\\0$/,"").replace(/^\\0/,"").split("\\0");b=parseInt(b.match(j[2]),16)||1!==c.length&&b.match(j[1])&&Date.parse(b);if(a=parseInt(a.match(j[2]),16)||b&&a.match(j[1])&&Date.parse(a)||null){if(ba)return 1}h=Math.max(c.length,g.length);for(b=0;bj)return 1}return 0};e.sortTextDesc= function(c,b,a,g){if(b===a)return 0;var d=c.config,f=d.string[d.empties[g]||d.emptyTo];return""===b&&0!==f?"boolean"===typeof f?f?-1:1:f||1:""===a&&0!==f?"boolean"===typeof f?f?1:-1:-f||-1:"function"===typeof d.textSorter?d.textSorter(a,b,c,g):e.sortText(c,a,b)};e.getTextValue=function(c,b,a){if(b){for(var g=c.length,d=b+a,b=0;bf.inArray(j[g].id,i)))h.debug&&d("removing "+j[g].id),j[g].hasOwnProperty("remove")&&j[g].remove(c,h,h.widgetOptions);!0!==a&&e.applyWidget(c,b)};e.getData=function(c,b,a){var d="",c=f(c),e,i;if(!c.length)return""; e=f.metadata?c.metadata():!1;i=" "+(c.attr("class")||"");"undefined"!==typeof c.data(a)||"undefined"!==typeof c.data(a.toLowerCase())?d+=c.data(a)||c.data(a.toLowerCase()):e&&"undefined"!==typeof e[a]?d+=e[a]:b&&"undefined"!==typeof b[a]?d+=b[a]:" "!==i&&i.match(" "+a+"-")&&(d=i.match(RegExp(" "+a+"-(\\w+)"))[1]||"");return f.trim(d)};e.formatFloat=function(c,b){if("string"!==typeof c||""===c)return c;c=!1!==b.config.usNumberFormat?c.replace(/,/g,""):c.replace(/[\s|\.]/g,"").replace(/,/g,".");/^\s*\([.\d]+\)/.test(c)&& (c=c.replace(/^\s*\(/,"-").replace(/\)/,""));var a=parseFloat(c);return isNaN(a)?f.trim(c):a};e.isDigit=function(c){return isNaN(c)?/^[\-+(]?\d+[)]?$/.test(c.toString().replace(/[,.'\s]/g,"")):!0}}});var i=f.tablesorter;f.fn.extend({tablesorter:i.construct});i.addParser({id:"text",is:function(){return!0},format:function(d,u){var n=u.config,d=f.trim(n.ignoreCase?d.toLocaleLowerCase():d);return n.sortLocaleCompare?i.replaceAccents(d):d},type:"text"});i.addParser({id:"currency",is:function(d){return/^\(?[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]\d+/.test(d)}, format:function(d,f){return i.formatFloat(d.replace(/[^\w,. \-()]/g,""),f)},type:"numeric"});i.addParser({id:"ipAddress",is:function(d){return/^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$/.test(d)},format:function(d,f){var n,t=d.split("."),p="",r=t.length;for(n=0;n offset.top) && (sTop < offset.top + tableHt) ? 'visible' : 'hidden'; stkyHdr .css({ diff --git a/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets.min.js b/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets.min.js index 5b8fe75..54f558e 100644 --- a/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets.min.js +++ b/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets.min.js @@ -1,12 +1,12 @@ -/*! tableSorter 2.4+ widgets - updated 10/17/2012 */ +/*! tableSorter 2.4+ widgets - updated 11/22/2012 */ ;(function(a){ a.tablesorter=a.tablesorter||{}; a.tablesorter.themes={bootstrap:{table:"table table-bordered table-striped",header:"bootstrap-header",icons:"",sortNone:"bootstrap-icon-unsorted",sortAsc:"icon-chevron-up",sortDesc:"icon-chevron-down",active:"",hover:"",filterRow:"",even:"",odd:""},jui:{table:"ui-widget ui-widget-content ui-corner-all",header:"ui-widget-header ui-corner-all ui-state-default",icons:"ui-icon",sortNone:"ui-icon-carat-2-n-s",sortAsc:"ui-icon-carat-1-n",sortDesc:"ui-icon-carat-1-s", active:"ui-state-active",hover:"ui-state-hover",filterRow:"",even:"ui-widget-content",odd:"ui-state-default"}}; -a.tablesorter.storage=function(e,b,c){var d,i=!1;d={};var f=e.id||a(".tablesorter").index(a(e)),g=window.location.pathname;try{i=!!localStorage.getItem}catch(m){}a.parseJSON&&(i?d=a.parseJSON(localStorage[b])||{}:(d=document.cookie.split(/[;\s|=]/),e=a.inArray(b,d)+1,d=0!==e?a.parseJSON(d[e])||{}:{}));if(c&&JSON&&JSON.hasOwnProperty("stringify")){if(!d[g]||!d[g][f])d[g]||(d[g]={});d[g][f]= c;i?localStorage[b]=JSON.stringify(d):(e=new Date,e.setTime(e.getTime()+31536E6),document.cookie=b+"="+JSON.stringify(d).replace(/\"/g,'"')+"; expires="+e.toGMTString()+"; path=/")}else return d&&d.hasOwnProperty(g)&&d[g].hasOwnProperty(f)?d[g][f]:{}}; -a.tablesorter.addWidget({id:"uitheme",format:function(e){var b,c,d,i,f=a(e),g=e.config,m=g.widgetOptions,n="object"===typeof m.uitheme?"jui":m.uitheme||"jui",h="object"===typeof m.uitheme&&!Object.prototype.toString.call(m.uitheme).test("Array")?m.uitheme: a.tablesorter.themes[a.tablesorter.themes.hasOwnProperty(n)?n:"jui"],l=a(g.headerList),p="tr."+(m.stickyHeaders||"tablesorter-stickyHeader"),q=h.sortNone+" "+h.sortDesc+" "+h.sortAsc;g.debug&&(b=new Date);if(!f.hasClass("tablesorter-"+n)||g.theme===n||!e.hasInitialized)""!==h.even&&(m.zebra[0]+=" "+h.even),""!==h.odd&&(m.zebra[1]+=" "+h.odd),f.removeClass(""===g.theme?"":"tablesorter-"+g.theme).addClass("tablesorter-"+n+" "+h.table),g.theme="",l.addClass(h.header).filter(":not(.sorter-false)").hover(function(){a(this).addClass(h.hover)}, function(){a(this).removeClass(h.hover)}),l.find(".tablesorter-wrapper").length||l.wrapInner('
'),g.cssIcon&&l.find("."+g.cssIcon).addClass(h.icons),f.hasClass("hasFilters")&&l.find(".tablesorter-filter-row").addClass(h.filterRow);a.each(l,function(b){d=a(this);i=g.cssIcon?d.find("."+g.cssIcon):d;this.sortDisabled?(d.removeClass(q),i.removeClass(q+" tablesorter-icon "+h.icons)):(f.hasClass("hasStickyHeaders")&& f.find(p).find("th").eq(b).add(d),c=d.hasClass(g.cssAsc)?h.sortDesc:d.hasClass(g.cssDesc)?h.sortAsc:d.hasClass(g.cssHeader)?h.sortNone:"",d[c===h.sortNone?"removeClass":"addClass"](h.active),i.removeClass(q).addClass(c))});g.debug&&a.tablesorter.benchmark("Applying "+n+" theme",b)},remove:function(e,b,c){var e=a(e),d="object"===typeof c.uitheme?"jui":c.uitheme||"jui",c="object"===typeof c.uitheme?c.uitheme:a.tablesorter.themes[a.tablesorter.themes.hasOwnProperty(d)?d:"jui"],i=e.children("thead").children(), f=c.sortNone+" "+c.sortDesc+" "+c.sortAsc;e.removeClass("tablesorter-"+d+" "+c.table).find(b.cssHeader).removeClass(c.header);i.unbind("mouseenter mouseleave").removeClass(c.hover+" "+f+" "+c.active).find(".tablesorter-filter-row").removeClass(c.filterRow);i.find(".tablesorter-icon").removeClass(c.icons)}}); -a.tablesorter.addWidget({id:"columns",format:function(e){var b,c,d,i,f,g,m,n,h,l=a(e),p=e.config,q=p.widgetOptions,s=l.children("tbody:not(."+p.cssInfoBlock+")"),u=p.sortList,v=u.length,k=["primary", "secondary","tertiary"],k=p.widgetColumns&&p.widgetColumns.hasOwnProperty("css")?p.widgetColumns.css||k:q&&q.hasOwnProperty("columns")?q.columns||k:k;g=k.length-1;m=k.join(" ");p.debug&&(f=new Date);for(h=0;h=]/g],L=A.map(function(b){return z.getData?"parsed"===z.getData(A.filter('[data-column="'+b+'"]:last'),r.headers[b],"filter"):a(this).hasClass("filter-parsed")}).get(),G,H,C=function(b){var d=a.isArray(b),e=t.find("thead").eq(0).children("tr").find("select."+y+", input."+y),c=d?b:e.map(function(){return a(this).val()||""}).get(),f=(c|| []).join("");d&&e.each(function(c,d){a(d).val(b[c]||"")});!0===j.filter_hideFilters&&t.find(".tablesorter-filter-row").trigger(""===f?"mouseleave":"mouseenter");if(!(F===f&&!1!==b))if(t.trigger("filterStart",[c]),r.showProcessing)setTimeout(function(){I(b,c,f);return!1},30);else return I(b,c,f),!1},I=function(g,i,h){var l,p,s,q,x,w,y;r.debug&&(y=new Date);for(d=0;d]=?/.test(f)?(u=isNaN(n)?a.tablesorter.formatFloat(n.replace(B[5],""),e):a.tablesorter.formatFloat(n,e),v=a.tablesorter.formatFloat(f.replace(B[5],"").replace(B[6],""),e),/>/.test(f)&&(w=/>=/.test(f)?u>=v:u>v),/'+(A.filter('[data-column="'+b+'"]:last').attr("data-placeholder")||"")+"";for(d=0;d'+h[d]+"";t.find("thead").find("select."+y+'[data-column="'+b+'"]')[f?"html":"append"](g)},K=function(a){for(b=0;b';for(b=0;b":">")+"";t.find("thead").eq(0).append(k+= "")}t.bind(["addRows","updateCell","update","appendCache","search"].join(".tsfilter "),function(a,b){"search"!==a.type&&K(!0);C("search"===a.type?b:"");return!1}).find("input."+y).bind("keyup search",function(a,b){if(!(32>a.which&&8!==a.which||37<=a.which&&40>=a.which)){if("undefined"!==typeof b)return C(b),!1;clearTimeout(H);H=setTimeout(function(){C()},j.filter_searchDelay||300)}});j.filter_reset&&a(j.filter_reset).length&&a(j.filter_reset).bind("click",function(){t.find("."+y).val("");C(); return!1});if(j.filter_functions)for(x in j.filter_functions)if(j.filter_functions.hasOwnProperty(x)&&"string"===typeof x)if(k=A.filter('[data-column="'+x+'"]:last'),g="",!0===j.filter_functions[x]&&!k.hasClass("filter-false"))J(x);else if("string"===typeof x&&!k.hasClass("filter-false")){for(l in j.filter_functions[x])"string"===typeof l&&(g+=""===g?'":"",g+='");t.find("thead").find("select."+y+'[data-column="'+ x+'"]').append(g)}K();t.find("select."+y).bind("change search",function(){C()});!0===j.filter_hideFilters&&t.find(".tablesorter-filter-row").addClass("hideme").bind("mouseenter mouseleave",function(b){var c;p=a(this);clearTimeout(h);h=setTimeout(function(){/enter|over/.test(b.type)?p.removeClass("hideme"):a(document.activeElement).closest("tr")[0]!==p[0]&&(c=t.find("."+(j.filter_cssFilter||"tablesorter-filter")).map(function(){return a(this).val()||""}).get().join(""),""===c&&p.addClass("hideme"))}, 200)}).find("input, select").bind("focus blur",function(b){q=a(this).closest("tr");clearTimeout(h);h=setTimeout(function(){if(""===t.find("."+(j.filter_cssFilter||"tablesorter-filter")).map(function(){return a(this).val()||""}).get().join(""))q["focus"===b.type?"removeClass":"addClass"]("hideme")},200)});r.showProcessing&&t.bind("filterStart filterEnd",function(b,c){var d=c?t.find("."+r.cssHeader).filter("[data-column]").filter(function(){return""!==c[a(this).data("column")]}):"";z.isProcessing(t[0], "filterStart"===b.type,c?d:"")});r.debug&&z.benchmark("Applying Filter widget",G);t.trigger("filterInit")}},remove:function(e,b,c){var d,i;d=a(e);b=d.children("tbody:not(."+b.cssInfoBlock+")");d.removeClass("hasFilters").unbind(["addRows","updateCell","update","appendCache","search"].join(".tsfilter")).find(".tablesorter-filter-row").remove();for(d=0;da.top&&c
');i=i.slice(0,-1);f=f?f.add(i):i});f.each(function(){b=a(this);c=parseInt(b.css("padding-right"),10)+8;b.find(".tablesorter-wrapper").append('
')}).bind("mousemove.tsresize",function(a){if(0!==h&&l){var b=a.pageX-h;l.width(l.width()+b);p.width(p.width()-b);h=a.pageX}}).bind("mouseup.tsresize", function(){a.tablesorter.storage&&l&&(d[l.index()]=l.width(),d[p.index()]=p.width(),!1!==n.resizable&&a.tablesorter.storage(e,"tablesorter-resizable",d));q()}).find(".tablesorter-resizer").bind("mousedown",function(b){l=a(b.target).parents("th:last");p=l.next();h=b.pageX});g.find("thead:first").bind("mouseup.tsresize mouseleave.tsresize",function(){q()}).bind("contextmenu.tsresize",function(){a.tablesorter.resizableReset(e);var b=a.isEmptyObject?a.isEmptyObject(d):d==={};d={};return b})}},remove:function(e){a(e).removeClass("hasResizable").find("thead").unbind("mouseup.tsresize mouseleave.tsresize contextmenu.tsresize").find("tr").children().unbind("mousemove.tsresize mouseup.tsresize").find(".tablesorter-wrapper").each(function(){a(this).find(".tablesorter-resizer").remove(); a(this).replaceWith(a(this).contents())});a.tablesorter.resizableReset(e)}});a.tablesorter.resizableReset=function(e){a(e.config.headerList).width("auto");a.tablesorter.storage(e,"tablesorter-resizable",{})}; -a.tablesorter.addWidget({id:"saveSort",init:function(a,b){b.format(a,!0)},format:function(e,b){var c,d,i=e.config;c=!1!==i.widgetOptions.saveSort;var f={sortList:i.sortList};i.debug&&(d=new Date);a(e).hasClass("hasSaveSort")?c&&(e.hasInitialized&&a.tablesorter.storage)&&(a.tablesorter.storage(e, "tablesorter-savesort",f),i.debug&&a.tablesorter.benchmark("saveSort widget: Saving last sort: "+i.sortList,d)):(a(e).addClass("hasSaveSort"),f="",a.tablesorter.storage&&(f=(c=a.tablesorter.storage(e,"tablesorter-savesort"))&&c.hasOwnProperty("sortList")&&a.isArray(c.sortList)?c.sortList:"",i.debug&&a.tablesorter.benchmark('saveSort: Last sort loaded: "'+f+'"',d)),b&&f&&0'),g.cssIcon&&l.find("."+g.cssIcon).addClass(h.icons),f.hasClass("hasFilters")&&l.find(".tablesorter-filter-row").addClass(h.filterRow);a.each(l,function(c){b=a(this);i=g.cssIcon?b.find("."+g.cssIcon):b;this.sortDisabled?(b.removeClass(p),i.removeClass(p+" tablesorter-icon "+h.icons)):(f.hasClass("hasStickyHeaders")&& f.find(q).find("th").eq(c).add(b),d=b.hasClass(g.cssAsc)?h.sortAsc:b.hasClass(g.cssDesc)?h.sortDesc:b.hasClass(g.cssHeader)?h.sortNone:"",b[d===h.sortNone?"removeClass":"addClass"](h.active),i.removeClass(p).addClass(d))});g.debug&&a.tablesorter.benchmark("Applying "+m+" theme",c)},remove:function(e,c,d){var e=a(e),b="object"===typeof d.uitheme?"jui":d.uitheme||"jui",d="object"===typeof d.uitheme?d.uitheme:a.tablesorter.themes[a.tablesorter.themes.hasOwnProperty(b)?b:"jui"],i=e.children("thead").children(), f=d.sortNone+" "+d.sortDesc+" "+d.sortAsc;e.removeClass("tablesorter-"+b+" "+d.table).find(c.cssHeader).removeClass(d.header);i.unbind("mouseenter mouseleave").removeClass(d.hover+" "+f+" "+d.active).find(".tablesorter-filter-row").removeClass(d.filterRow);i.find(".tablesorter-icon").removeClass(d.icons)}}); +a.tablesorter.addWidget({id:"columns",format:function(e){var c,d,b,i,f,g,n,m,h,l=a(e),q=e.config,p=q.widgetOptions,s=l.children("tbody:not(."+q.cssInfoBlock+")"),u=q.sortList,v=u.length,k=["primary", "secondary","tertiary"],k=q.widgetColumns&&q.widgetColumns.hasOwnProperty("css")?q.widgetColumns.css||k:p&&p.hasOwnProperty("columns")?p.columns||k:k;g=k.length-1;n=k.join(" ");q.debug&&(f=new Date);for(h=0;h=]/g],L=A.map(function(b){return z.getData?"parsed"===z.getData(A.filter('[data-column="'+b+'"]:last'),r.headers[b],"filter"):a(this).hasClass("filter-parsed")}).get(),G,H,C=function(b){var c=a.isArray(b),e=t.find("thead").eq(0).children("tr").find("select."+y+", input."+y),d=c?b:e.map(function(){return a(this).val()||""}).get(),f=(d|| []).join("");c&&e.each(function(c,d){a(d).val(b[c]||"")});!0===j.filter_hideFilters&&t.find(".tablesorter-filter-row").trigger(""===f?"mouseleave":"mouseenter");if(!(F===f&&!1!==b))if(t.trigger("filterStart",[d]),r.showProcessing)setTimeout(function(){I(b,d,f);return!1},30);else return I(b,d,f),!1},I=function(g,i,h){var l,q,s,p,x,w,y;r.debug&&(y=new Date);for(b=0;b]=?/.test(f)?(u=isNaN(m)?a.tablesorter.formatFloat(m.replace(B[5],""),e):a.tablesorter.formatFloat(m,e),v=a.tablesorter.formatFloat(f.replace(B[5],"").replace(B[6],""),e),/>/.test(f)&&(w=/>=/.test(f)?u>=v:u>v),/'+(A.filter('[data-column="'+c+'"]:last').attr("data-placeholder")||"")+"";for(b=0;b'+h[b]+"";t.find("thead").find("select."+y+'[data-column="'+c+'"]')[f?"html":"append"](g)},K=function(a){for(c=0;c';for(c=0;c":">")+ "";t.find("thead").eq(0).append(k+="")}t.bind(["addRows","updateCell","update","appendCache","search"].join(".tsfilter "),function(a,b){"search"!==a.type&&K(!0);C("search"===a.type?b:"");return!1}).find("input."+y).bind("keyup search",function(a,b){if(!(32>a.which&&8!==a.which||37<=a.which&&40>=a.which)){if("undefined"!==typeof b)return C(b),!1;clearTimeout(H);H=setTimeout(function(){C()},j.filter_searchDelay||300)}});j.filter_reset&&a(j.filter_reset).length&&a(j.filter_reset).bind("click", function(){t.find("."+y).val("");C();return!1});if(j.filter_functions)for(x in j.filter_functions)if(j.filter_functions.hasOwnProperty(x)&&"string"===typeof x)if(k=A.filter('[data-column="'+x+'"]:last'),g="",!0===j.filter_functions[x]&&!k.hasClass("filter-false"))J(x);else if("string"===typeof x&&!k.hasClass("filter-false")){for(l in j.filter_functions[x])"string"===typeof l&&(g+=""===g?'":"",g+='"); t.find("thead").find("select."+y+'[data-column="'+x+'"]').append(g)}K();t.find("select."+y).bind("change search",function(){C()});!0===j.filter_hideFilters&&t.find(".tablesorter-filter-row").addClass("hideme").bind("mouseenter mouseleave",function(b){var c;q=a(this);clearTimeout(h);h=setTimeout(function(){/enter|over/.test(b.type)?q.removeClass("hideme"):a(document.activeElement).closest("tr")[0]!==q[0]&&(c=t.find("."+(j.filter_cssFilter||"tablesorter-filter")).map(function(){return a(this).val()|| ""}).get().join(""),""===c&&q.addClass("hideme"))},200)}).find("input, select").bind("focus blur",function(b){p=a(this).closest("tr");clearTimeout(h);h=setTimeout(function(){if(""===t.find("."+(j.filter_cssFilter||"tablesorter-filter")).map(function(){return a(this).val()||""}).get().join(""))p["focus"===b.type?"removeClass":"addClass"]("hideme")},200)});r.showProcessing&&t.bind("filterStart filterEnd",function(b,c){var d=c?t.find("."+r.cssHeader).filter("[data-column]").filter(function(){return""!== c[a(this).data("column")]}):"";z.isProcessing(t[0],"filterStart"===b.type,c?d:"")});r.debug&&z.benchmark("Applying Filter widget",G);t.trigger("filterInit")}},remove:function(e,c,d){var b,i;b=a(e);c=b.children("tbody:not(."+c.cssInfoBlock+")");b.removeClass("hasFilters").unbind(["addRows","updateCell","update","appendCache","search"].join(".tsfilter")).find(".tablesorter-filter-row").remove();for(b=0;ba.top&&b');i=i.slice(0,-1);f=f?f.add(i):i});f.each(function(){c=a(this);d=parseInt(c.css("padding-right"),10)+8;c.find(".tablesorter-wrapper").append('
')}).bind("mousemove.tsresize",function(a){if(0!==h&&l){var b=a.pageX-h;l.width(l.width()+b);q.width(q.width()-b);h=a.pageX}}).bind("mouseup.tsresize",function(){a.tablesorter.storage&&l&&(b[l.index()]=l.width(),b[q.index()]=q.width(),!1!==m.resizable&&a.tablesorter.storage(e,"tablesorter-resizable",b));p()}).find(".tablesorter-resizer").bind("mousedown",function(b){l=a(b.target).parents("th:last");q=l.next();h=b.pageX});g.find("thead:first").bind("mouseup.tsresize mouseleave.tsresize", function(){p()}).bind("contextmenu.tsresize",function(){a.tablesorter.resizableReset(e);var c=a.isEmptyObject?a.isEmptyObject(b):b==={};b={};return c})}},remove:function(e){a(e).removeClass("hasResizable").find("thead").unbind("mouseup.tsresize mouseleave.tsresize contextmenu.tsresize").find("tr").children().unbind("mousemove.tsresize mouseup.tsresize").find(".tablesorter-wrapper").each(function(){a(this).find(".tablesorter-resizer").remove();a(this).replaceWith(a(this).contents())});a.tablesorter.resizableReset(e)}}); a.tablesorter.resizableReset=function(e){a(e.config.headerList).width("auto");a.tablesorter.storage(e,"tablesorter-resizable",{})}; +a.tablesorter.addWidget({id:"saveSort",init:function(a,c){c.format(a,!0)},format:function(e,c){var d,b,i=e.config;d=!1!==i.widgetOptions.saveSort;var f={sortList:i.sortList};i.debug&&(b=new Date);a(e).hasClass("hasSaveSort")?d&&(e.hasInitialized&&a.tablesorter.storage)&&(a.tablesorter.storage(e,"tablesorter-savesort",f),i.debug&&a.tablesorter.benchmark("saveSort widget: Saving last sort: "+ i.sortList,b)):(a(e).addClass("hasSaveSort"),f="",a.tablesorter.storage&&(f=(d=a.tablesorter.storage(e,"tablesorter-savesort"))&&d.hasOwnProperty("sortList")&&a.isArray(d.sortList)?d.sortList:"",i.debug&&a.tablesorter.benchmark('saveSort: Last sort loaded: "'+f+'"',b)),c&&f&&0 tr:hover td { + opacity: 0.7; + filter: alpha(opacity=70); +} + /* table processing indicator */ .tablesorter-jui .tablesorter-processing .tablesorter-header-inner { background-position: center center !important;