From 440f5549ad57665ab18c0e1280fae38514de63fc Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Wed, 27 Jul 2011 01:14:20 -0500 Subject: [PATCH] ui theme & pager update --- README.markdown | 23 +++ addons/pager/jquery.tablesorter.pager.js | 49 ++++- addons/pager/jquery.tablesorter.pager.min.js | 2 +- changelog.markdown | 23 +++ css/ui/style.css | 26 +++ docs/example-option-render-header.html | 4 +- docs/example-pager.html | 40 ++-- docs/example-ui-theme.html | 193 +++++++++++++++++++ docs/example-widgets.html | 2 +- docs/example-zebra.html | 2 +- docs/index.html | 12 +- index.html | 2 +- js/jquery.tablesorter.js | 6 +- js/jquery.tablesorter.min.js | 4 +- 14 files changed, 355 insertions(+), 33 deletions(-) create mode 100644 css/ui/style.css create mode 100644 docs/example-ui-theme.html diff --git a/README.markdown b/README.markdown index ba3bd89e..b650f6b6 100644 --- a/README.markdown +++ b/README.markdown @@ -28,6 +28,29 @@ Included all original [document pages](http://mottie.github.com/tablesorter/docs View the [complete listing here](changelog.markdown). +#### Version 2.0.9 (2011-07-27) + +* Added a jQuery UI theme and widget example. To apply the jQuery UI theme: + * Include any jQuery UI theme on your page. + * Add the base tablesorter ui theme (located in css/ui directory) + * Add the jQuery UI theme widget code found on [this example page](docs/example-option-ui-theme.html). This demo page includes the UI theme switcher. +* Added a header index to the `onRenderHeader` function to make it easier to target specific header cells for modification. See the [render header example](docs/example-option-render-header.html) for an example. +* Pager plugin updates: + * Removed the `separator` option and added an `output` option which allows you to completely customize the output string. + * In the `output` string, include any of the following variables: + * `{page}` is replaced with the current page number. + * `{totalPages}` is replaced with the total number of pages. + * `{startRow}` is replaced with the number of the visible start row of the pager. + * `{endRow}` is replaced with the number of the visible end row of the pager. + * `{totalRows}` is replaced with the total number of rows. + * The `cssPageDisplay` option can now target any element; in previous versions, this element was an input of type text. + * Added a `pagerArrows` and `cssDisabled` options: + * When `pagerArrows` is true, the first and previous pager arrows have the css class name contained in the `cssDisabled` option applied when the first row is visible. + * The next and last pager arrows will be have the `cssDisabled` class applied when the last row is visible. + * Additionally, if the number of table rows is less than the pager size, the pager will get the `cssDisabled` class name applied. + * If false (the default setting), the pager arrows class names will not change. + * Please see the updated [pager demo](docs/example-pager.html) to see this working. + #### Version 2.0.8 (2011-07-21) * Fixed parsers for currency and digits to work with number values separated by commas. Thanks to Josh Renaud for the information! diff --git a/addons/pager/jquery.tablesorter.pager.js b/addons/pager/jquery.tablesorter.pager.js index 81d21e49..1dffec02 100644 --- a/addons/pager/jquery.tablesorter.pager.js +++ b/addons/pager/jquery.tablesorter.pager.js @@ -1,8 +1,30 @@ +/* + * tablesorter pager plugin + * updated 7/27/2011 + */ + (function($) { $.extend({tablesorterPager: new function() { var updatePageDisplay = function(table,c) { - var s = $(c.cssPageDisplay,c.container).val((c.page+1) + c.seperator + c.totalPages); + c.startRow = c.size * (c.page) + 1; + c.endRow = Math.min(c.totalRows, c.size * (c.page+1)); + var out = $(c.cssPageDisplay, c.container), + // form the output string + s = c.output.replace(/\{(page|totalPages|startRow|endRow|totalRows)\}/gi, function(m){ + return { + '{page}' : c.page + 1, + '{totalPages}' : c.totalPages, + '{startRow}' : c.startRow, + '{endRow}' : c.endRow, + '{totalRows}' : c.totalRows + }[m]; + }); + if (out[0].tagName === 'INPUT') { + out.val(s); + } else { + out.html(s); + } $(table).trigger('pagerComplete', c); }, @@ -49,11 +71,29 @@ updatePageDisplay(table,c); }, + // hide arrows at extremes + pagerArrows = function(c) { + if (c.updateArrows) { + c.container.removeClass(c.cssDisabled); + $(c.cssFirst + ',' + c.cssPrev + ',' + c.cssNext + ',' + c.cssLast, c.container).removeClass(c.cssDisabled); + if (c.page === 0) { + $(c.cssFirst + ',' + c.cssPrev, c.container).addClass(c.cssDisabled); + } else if (c.page === c.totalPages - 1) { + $(c.cssNext + ',' + c.cssLast, c.container).addClass(c.cssDisabled); + } + // if the total # of pages is less than the selected number of visible rows, then hide the pager + if (c.totalRows < c.size) { + c.container.addClass(c.cssDisabled); + } + } + }, + moveToPage = function(table) { var c = table.config; - if(c.page < 0 || c.page > (c.totalPages-1)) { + if (c.page < 0 || c.page > (c.totalPages-1)) { c.page = 0; } + pagerArrows(c); renderTable(table,c.rowsCopy); }, @@ -117,7 +157,9 @@ cssLast: '.last', cssPageDisplay: '.pagedisplay', cssPageSize: '.pagesize', - seperator: "/", + cssDisabled: 'disabled', + output: '{page}/{totalPages}', // '{startRow} to {endRow} of {totalRows} rows', + updateArrows: false, positionFixed: true, appender: this.appender }; @@ -130,6 +172,7 @@ $(this).trigger("appendCache"); config.size = parseInt($(".pagesize",pager).val(), 10); + pagerArrows(config); $(config.cssFirst,pager).click(function() { moveToFirstPage(table); diff --git a/addons/pager/jquery.tablesorter.pager.min.js b/addons/pager/jquery.tablesorter.pager.min.js index 401979db..37b89f89 100644 --- a/addons/pager/jquery.tablesorter.pager.min.js +++ b/addons/pager/jquery.tablesorter.pager.min.js @@ -1,2 +1,2 @@ /* tablesorter pager plugin */ -(function(d){d.extend({tablesorterPager:new function(){var k=function(b){var a=b.config,b=d(b);if(!a.pagerPositionSet&&a.positionFixed)b.offset&&a.container.css({top:b.offset().top+b.height()+"px",position:"absolute"}),a.pagerPositionSet=!0},m=function(b,a){var c,f,h,i,e=b.config,g=a.length;c=e.page*e.size;var j=c+e.size;d(b).trigger("pagerChange",e);if(j>a.length)j=a.length;i=d(b.tBodies[0]);for(d.tablesorter.clearTableBody(b);c=e.totalPages&&l(b);d(e.cssPageDisplay,e.container).val(e.page+1+e.seperator+e.totalPages);d(b).trigger("pagerComplete",e)},g=function(b){var a=b.config;if(a.page<0||a.page>a.totalPages-1)a.page=0;m(b,a.rowsCopy)},l=function(b){var a=b.config;a.page=a.totalPages-1;g(b)};this.appender=function(b,a){var c=b.config;c.rowsCopy=a;c.totalRows=a.length;c.totalPages=Math.ceil(c.totalRows/c.size);m(b,a)};this.defaults={size:10,offset:0,page:0,totalRows:0,totalPages:0, container:null,cssNext:".next",cssPrev:".prev",cssFirst:".first",cssLast:".last",cssPageDisplay:".pagedisplay",cssPageSize:".pagesize",seperator:"/",positionFixed:!0,appender:this.appender};this.construct=function(b){return this.each(function(){var a=d.extend(this.config,d.tablesorterPager.defaults,b),c=this,f=a.container;d(this).trigger("appendCache");a.size=parseInt(d(".pagesize",f).val(),10);d(a.cssFirst,f).click(function(){c.config.page=0;g(c);return!1});d(a.cssNext,f).click(function(){var a= c.config;a.page++;if(a.page>=a.totalPages-1)a.page=a.totalPages-1;g(c);return!1});d(a.cssPrev,f).click(function(){var a=c.config;a.page--;if(a.page<=0)a.page=0;g(c);return!1});d(a.cssLast,f).click(function(){l(c);return!1});d(a.cssPageSize,f).change(function(){var a=parseInt(d(this).val(),10),b=c.config;b.size=a;b.totalPages=Math.ceil(b.totalRows/b.size);b.pagerPositionSet=!1;g(c);k(c);return!1})})}}});d.fn.extend({tablesorterPager:d.tablesorterPager.construct})})(jQuery); \ No newline at end of file +(function(d){d.extend({tablesorterPager:new function(){var o=function(a,b){b.startRow=b.size*b.page+1;b.endRow=Math.min(b.totalRows,b.size*(b.page+1));var c=d(b.cssPageDisplay,b.container),e=b.output.replace(/\{(page|totalPages|startRow|endRow|totalRows)\}/gi,function(a){return{"{page}":b.page+1,"{totalPages}":b.totalPages,"{startRow}":b.startRow,"{endRow}":b.endRow,"{totalRows}":b.totalRows}[a]});c[0].tagName==="INPUT"?c.val(e):c.html(e);d(a).trigger("pagerComplete",b)},k=function(a){var b=a.config, a=d(a);if(!b.pagerPositionSet&&b.positionFixed)a.offset&&b.container.css({top:a.offset().top+a.height()+"px",position:"absolute"}),b.pagerPositionSet=!0},m=function(a,b){var c,e,h,i,g=a.config,f=b.length;c=g.page*g.size;var j=c+g.size;d(a).trigger("pagerChange",g);if(j>b.length)j=b.length;i=d(a.tBodies[0]);for(d.tablesorter.clearTableBody(a);c=g.totalPages&&l(a);o(a,g)},n=function(a){a.updateArrows&& (a.container.removeClass(a.cssDisabled),d(a.cssFirst+","+a.cssPrev+","+a.cssNext+","+a.cssLast,a.container).removeClass(a.cssDisabled),a.page===0?d(a.cssFirst+","+a.cssPrev,a.container).addClass(a.cssDisabled):a.page===a.totalPages-1&&d(a.cssNext+","+a.cssLast,a.container).addClass(a.cssDisabled),a.totalRowsb.totalPages-1)b.page=0;n(b);m(a,b.rowsCopy)},l=function(a){var b=a.config;b.page=b.totalPages-1; f(a)};this.appender=function(a,b){var c=a.config;c.rowsCopy=b;c.totalRows=b.length;c.totalPages=Math.ceil(c.totalRows/c.size);m(a,b)};this.defaults={size:10,offset:0,page:0,totalRows:0,totalPages:0,container:null,cssNext:".next",cssPrev:".prev",cssFirst:".first",cssLast:".last",cssPageDisplay:".pagedisplay",cssPageSize:".pagesize",cssDisabled:"disabled",output:"{page}/{totalPages}",updateArrows:!1,positionFixed:!0,appender:this.appender};this.construct=function(a){return this.each(function(){var b= d.extend(this.config,d.tablesorterPager.defaults,a),c=this,e=b.container;d(this).trigger("appendCache");b.size=parseInt(d(".pagesize",e).val(),10);n(b);d(b.cssFirst,e).click(function(){c.config.page=0;f(c);return!1});d(b.cssNext,e).click(function(){var a=c.config;a.page++;if(a.page>=a.totalPages-1)a.page=a.totalPages-1;f(c);return!1});d(b.cssPrev,e).click(function(){var a=c.config;a.page--;if(a.page<=0)a.page=0;f(c);return!1});d(b.cssLast,e).click(function(){l(c);return!1});d(b.cssPageSize,e).change(function(){var a= parseInt(d(this).val(),10),b=c.config;b.size=a;b.totalPages=Math.ceil(b.totalRows/b.size);b.pagerPositionSet=!1;f(c);k(c);return!1})})}}});d.fn.extend({tablesorterPager:d.tablesorterPager.construct})})(jQuery); \ No newline at end of file diff --git a/changelog.markdown b/changelog.markdown index f3e83210..cacaac97 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,5 +1,28 @@ ###TableSorter Change Log +#### Version 2.0.9 (2011-07-27) + +* Added a jQuery UI theme and widget example. To apply the jQuery UI theme: + * Include any jQuery UI theme on your page. + * Add the base tablesorter ui theme (located in css/ui directory) + * Add the jQuery UI theme widget code found on [this example page](docs/example-option-ui-theme.html). This demo page includes the UI theme switcher. +* Added a header index to the `onRenderHeader` function to make it easier to target specific header cells for modification. See the [render header example](docs/example-option-render-header.html) for an example. +* Pager plugin updates: + * Removed the `separator` option and added an `output` option which allows you to completely customize the output string. + * In the `output` string, include any of the following variables: + * `{page}` is replaced with the current page number. + * `{totalPages}` is replaced with the total number of pages. + * `{startRow}` is replaced with the number of the visible start row of the pager. + * `{endRow}` is replaced with the number of the visible end row of the pager. + * `{totalRows}` is replaced with the total number of rows. + * The `cssPageDisplay` option can now target any element; in previous versions, this element was an input of type text. + * Added a `pagerArrows` and `cssDisabled` options: + * When `pagerArrows` is true, the first and previous pager arrows have the css class name contained in the `cssDisabled` option applied when the first row is visible. + * The next and last pager arrows will be have the `cssDisabled` class applied when the last row is visible. + * Additionally, if the number of table rows is less than the pager size, the pager will get the `cssDisabled` class name applied. + * If false (the default setting), the pager arrows class names will not change. + * Please see the updated [pager demo](docs/example-pager.html) to see this working. + #### Version 2.0.8 (2011-07-21) * Fixed parsers for currency and digits to work with number values separated by commas. Thanks to Josh Renaud for the information! diff --git a/css/ui/style.css b/css/ui/style.css new file mode 100644 index 00000000..9995dcab --- /dev/null +++ b/css/ui/style.css @@ -0,0 +1,26 @@ +/* jQuery UI Theme */ +table.tablesorter { + font-family: arial; + margin: 10px 0pt 15px; + font-size: 8pt; + width: 100%; + text-align: left; +} +table.tablesorter thead tr th, table.tablesorter tfoot tr th { + border-collapse: collapse; + font-size: 8pt; + padding: 4px; +} +table.tablesorter thead tr .header { + background-repeat: no-repeat; + background-position: center right; + cursor: pointer; +} +table.tablesorter tbody td { + padding: 4px; + vertical-align: top; +} +table.tablesorter .header .ui-theme { + display: block; + float: right; +} \ No newline at end of file diff --git a/docs/example-option-render-header.html b/docs/example-option-render-header.html index 968fd6a3..12b98f35 100644 --- a/docs/example-option-render-header.html +++ b/docs/example-option-render-header.html @@ -35,9 +35,9 @@ diff --git a/docs/example-pager.html b/docs/example-pager.html index 0b860e92..4a7fddd9 100644 --- a/docs/example-pager.html +++ b/docs/example-pager.html @@ -18,7 +18,19 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +

Demo

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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
+ +

Javascript

+
+

+	
+ + +

CSS

+
+
/* jQuery UI Theme required css; as seen in css/ui/style.css file */
+table.tablesorter {
+	font-family: arial;
+	margin: 10px 0pt 15px;
+	font-size: 8pt;
+	width: 100%;
+	text-align: left;
+}
+table.tablesorter thead tr th, table.tablesorter tfoot tr th {
+	border-collapse: collapse;
+	font-size: 8pt;
+	padding: 4px;
+}
+table.tablesorter thead tr .header {
+	background-repeat: no-repeat;
+	background-position: center right;
+	cursor: pointer;
+}
+table.tablesorter tbody td {
+	padding: 4px;
+	vertical-align: top;
+}
+table.tablesorter .header .ui-theme {
+	display: block;
+	float: right;
+}
+
+ + +

HTML

+
+

+	
+ + + +
+ + + + diff --git a/docs/example-widgets.html b/docs/example-widgets.html index 8a3b5c41..0ef35eda 100644 --- a/docs/example-widgets.html +++ b/docs/example-widgets.html @@ -321,7 +321,7 @@ diff --git a/docs/example-zebra.html b/docs/example-zebra.html index e95c3190..08b8340d 100644 --- a/docs/example-zebra.html +++ b/docs/example-zebra.html @@ -123,7 +123,7 @@ table.tablesorter tbody tr.alt-row td { diff --git a/docs/index.html b/docs/index.html index ac2fa2a9..dfdbc4f5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -36,7 +36,7 @@

Author: Christian Bach
- Version: 2.0.8 (changelog)
+ Version: 2.0.9 (changelog)
Licence: Dual licensed under MIT or GPL licenses. @@ -298,6 +298,7 @@

  • Direction of initial sort
  • Applying widgets
  • Applying the zebra stripe widget
  • +
  • Applying the jQuery UI theme widget New! v2.0.9
  • Disable sort using headers options
  • Lock sort order using header options
  • Set initial sort order using header options
  • @@ -644,7 +645,7 @@ "asc" When clicking the header for the first time, the direction it sorts. Valid arguments are "asc" for Ascending or "desc" for Descending.
    - New! in 2.0.8: This order can also be set by desired column using the headers option. + New! in v2.0.8: This order can also be set by desired column using the headers option. Ex:1 2 @@ -932,7 +933,7 @@ $(table) pagerChange - This event fires when the pager plugin begins to render the table on the currently selected page. New! in version 2.0.7. + This event fires when the pager plugin begins to render the table on the currently selected page. New! in v2.0.7.
    $(function(){
     
    @@ -958,7 +959,7 @@ $(table)
     
     			
     				pagerComplete
    -				This event fires when the pager plugin has completed its render of the table on the currently selected page. New! in version 2.0.7.
    +				This event fires when the pager plugin has completed its render of the table on the currently selected page. New! in v2.0.7.
     					
    $(function(){
     
    @@ -1021,6 +1022,7 @@ $(table)
     	
    • Green Skin - Images and CSS styles for green themed headers
    • Blue Skin - Images and CSS styles for blue themed headers (as seen in the examples)
    • +
    • jQuery UI Theme - Apply any jQuery UI theme to the table using the "uitheme" widget code. New! in v2.0.9!
    @@ -1054,7 +1056,7 @@ $(table)

    Documentation written by Brian Ghidinelli, based on Mike Alsup's great documention.
    - Missing documentation and alphanumeric sort added by Mottie. + Missing documentation, alphanumeric sort and other changes added by Mottie.

    John Resig for the fantastic jQuery diff --git a/index.html b/index.html index 02d1d87b..f3741ed2 100644 --- a/index.html +++ b/index.html @@ -23,7 +23,7 @@

    -

    TableSorter v2.0.7

    +

    TableSorter

    By Christian Bach; github updates by Rob G
    Complete docs included (updated with missing docs from this blog post)

    diff --git a/js/jquery.tablesorter.js b/js/jquery.tablesorter.js index 0ccff732..5fc37e67 100644 --- a/js/jquery.tablesorter.js +++ b/js/jquery.tablesorter.js @@ -1,6 +1,6 @@ /* * TableSorter 2.0 - Client-side table sorting with ease! -* Version 2.0.8 +* Version 2.0.9 * @requires jQuery v1.2.3 * * Copyright (c) 2007 Christian Bach @@ -100,7 +100,6 @@ sortList: [], headerList: [], dateFormat: "us", - decimal: /\.|\,/g, // not used onRenderHeader: null, selectorHeaders: 'thead th', tableClass : 'tablesorter', @@ -401,7 +400,7 @@ if (typeof(lock) !== 'undefined' && lock !== false) { this.order = this.lockedOrder = formatSortingOrder(lock); } if (!this.sortDisabled) { $th = $(this).addClass(table.config.cssHeader); - if (table.config.onRenderHeader) { table.config.onRenderHeader.apply($th); } + if (table.config.onRenderHeader) { table.config.onRenderHeader.apply($th, [index]); } } // add cell to headerList table.config.headerList[index] = this; @@ -410,7 +409,6 @@ benchmark("Built headers:", time); log($tableHeaders); } - console.debug($tableHeaders); return $tableHeaders; } diff --git a/js/jquery.tablesorter.min.js b/js/jquery.tablesorter.min.js index 0ae4402f..c3a3ae17 100644 --- a/js/jquery.tablesorter.min.js +++ b/js/jquery.tablesorter.min.js @@ -1,7 +1,7 @@ /* * TableSorter 2.0 - Client-side table sorting with ease! -* Version 2.0.8 +* Version 2.0.9 * Copyright (c) 2007 Christian Bach */ -(function($){$.extend({tablesorter:new function(){var parsers=[],widgets=[],tbl;this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",cssChildRow:"expand-child",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,sortLocaleCompare:false,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"us",decimal:/\.|\,/g,onRenderHeader:null, selectorHeaders:"thead th",tableClass:"tablesorter",debug:false};function log(s){if(typeof console!=="undefined"&&typeof console.debug!=="undefined")console.log(s);else alert(s)}function benchmark(s,d){log(s+","+((new Date).getTime()-d.getTime())+"ms")}this.benchmark=benchmark;function getElementText(config,node){var text="";if(!node)return"";if(!config.supportsTextContent)config.supportsTextContent=node.textContent||false;if(config.textExtraction==="simple")if(config.supportsTextContent)text=node.textContent; else if(node.childNodes[0]&&node.childNodes[0].hasChildNodes())text=node.childNodes[0].innerHTML;else text=node.innerHTML;else if(typeof config.textExtraction==="function")text=config.textExtraction(node);else text=$(node).text();return text}function getParserById(name){var i,l=parsers.length;for(i=0;i").each(function(index){this.column=header_index[this.parentNode.rowIndex+"-"+this.cellIndex];this.order=formatSortingOrder(checkHeaderOrder(table,index));this.count=this.order;if(checkHeaderMetadata(this)||checkHeaderOptions(table, index))this.sortDisabled=true;this.lockedOrder=false;lock=checkHeaderLocked(table,index);if(typeof lock!=="undefined"&&lock!==false)this.order=this.lockedOrder=formatSortingOrder(lock);if(!this.sortDisabled){$th=$(this).addClass(table.config.cssHeader);if(table.config.onRenderHeader)table.config.onRenderHeader.apply($th)}table.config.headerList[index]=this});if(table.config.debug){benchmark("Built headers:",time);log($tableHeaders)}console.debug($tableHeaders);return $tableHeaders}function checkCellColSpan(table, rows,row){var i,cell,arr=[],r=table.tHead.rows,c=r[row].cells;for(i=0;i1)arr=arr.concat(checkCellColSpan(table,rows,row++));else if(table.tHead.length===1||cell.rowSpan>1||!r[row+1])arr.push(cell)}return arr}function isValueInArray(v,a){var i,l=a.length;for(i=0;i");$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($("").css("width",$(this).width()))});$(table).prepend(colgroup)}}function updateHeaderSortCount(table,sortList){var i,s,o,c=table.config,l=sortList.length;for(i=0;ib?1:-1}catch(er){return 0}}function sortTextDesc(a, b){if($.data(tbl[0],"tablesorter").sortLocaleCompare)return b.localeCompare(a);return-sortText(a,b)}function sortNumeric(a,b){return a-b}function sortNumericDesc(a,b){return b-a}this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder,sortCSS,totalRows,$cell,i,j,a,s,o;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);tbl=$this=$(this).addClass(this.config.tableClass); $.data(this,"tablesorter",config);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){totalRows=$this[0].tBodies[0]&&$this[0].tBodies[0].rows.length||0;if(!this.sortDisabled&&totalRows>0){$this.trigger("sortStart",tbl[0]);$cell=$(this);i=this.column;this.order=this.count++%2;if(typeof this.lockedOrder!=="undefined"&&this.lockedOrder!==false)this.order=this.lockedOrder; if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!==null){a=config.sortForce;for(j=0;j0)$this.trigger("sorton",[config.sortList]);applyWidget(this)})};this.addParser=function(parser){var i,l=parsers.length,a=true;for(i=0;i").each(function(index){this.column=header_index[this.parentNode.rowIndex+"-"+this.cellIndex];this.order=formatSortingOrder(checkHeaderOrder(table,index));this.count=this.order;if(checkHeaderMetadata(this)||checkHeaderOptions(table, index))this.sortDisabled=true;this.lockedOrder=false;lock=checkHeaderLocked(table,index);if(typeof lock!=="undefined"&&lock!==false)this.order=this.lockedOrder=formatSortingOrder(lock);if(!this.sortDisabled){$th=$(this).addClass(table.config.cssHeader);if(table.config.onRenderHeader)table.config.onRenderHeader.apply($th,[index])}table.config.headerList[index]=this});if(table.config.debug){benchmark("Built headers:",time);log($tableHeaders)}return $tableHeaders}function checkCellColSpan(table,rows, row){var i,cell,arr=[],r=table.tHead.rows,c=r[row].cells;for(i=0;i1)arr=arr.concat(checkCellColSpan(table,rows,row++));else if(table.tHead.length===1||cell.rowSpan>1||!r[row+1])arr.push(cell)}return arr}function isValueInArray(v,a){var i,l=a.length;for(i=0;i");$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($("").css("width",$(this).width()))});$(table).prepend(colgroup)}}function updateHeaderSortCount(table,sortList){var i,s,o,c=table.config,l=sortList.length;for(i=0;ib?1:-1}catch(er){return 0}}function sortTextDesc(a, b){if($.data(tbl[0],"tablesorter").sortLocaleCompare)return b.localeCompare(a);return-sortText(a,b)}function sortNumeric(a,b){return a-b}function sortNumericDesc(a,b){return b-a}this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder,sortCSS,totalRows,$cell,i,j,a,s,o;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);tbl=$this=$(this).addClass(this.config.tableClass); $.data(this,"tablesorter",config);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){totalRows=$this[0].tBodies[0]&&$this[0].tBodies[0].rows.length||0;if(!this.sortDisabled&&totalRows>0){$this.trigger("sortStart",tbl[0]);$cell=$(this);i=this.column;this.order=this.count++%2;if(typeof this.lockedOrder!=="undefined"&&this.lockedOrder!==false)this.order=this.lockedOrder; if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!==null){a=config.sortForce;for(j=0;j0)$this.trigger("sorton",[config.sortList]);applyWidget(this)})};this.addParser=function(parser){var i,l=parsers.length,a=true;for(i=0;i