From c1ec042b60b7f09c568d1871116ef3e0630bab68 Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Mon, 27 Feb 2012 08:58:46 -0600 Subject: [PATCH] filter widget now uses search type inputs --- README.markdown | 15 +++++++++++++++ changelog.txt | 16 ++++++++++++++++ js/jquery.tablesorter.min.js | 4 ++-- js/jquery.tablesorter.widgets.js | 8 ++++---- js/jquery.tablesorter.widgets.min.js | 14 +++++++------- package.json | 2 +- 6 files changed, 45 insertions(+), 14 deletions(-) diff --git a/README.markdown b/README.markdown index a4b90979..4077cb4f 100644 --- a/README.markdown +++ b/README.markdown @@ -34,6 +34,21 @@ Included all original [document pages](http://mottie.github.com/tablesorter/docs View the [complete listing here](http://mottie.github.com/tablesorter/changelog.txt). +#### Version 2.0.31 (2012-2-27) + +* Added `sortRestart` option: + * When `true`, this option resets the sort direction so that clicking on an unsorted column will now sort in the `sortInitialOrder` direction. + * Clicking on a single column to cancel a multi-sorted table may not initially sort as expected. + * Requested by severa in [issue #30](https://github.com/Mottie/tablesorter/issues/29). Thanks! +* Made some `sortReset` fixes: + * Columns widget will now clear it's styling when the sort has reset. + * Added a [demo](http://mottie.github.com/tablesorter/). +* Changed the filter widget inputs to be of a search type: + * Currently only supported by webkit. + * Requested by cr125rider in [issue #29](https://github.com/Mottie/tablesorter/issues/29). Thanks! +* Updated `sortLocaleCompare` documentation since it was explained incorrectly. +* Did some general code cleanup and some optimization. + #### Version 2.0.30.1 (2012-2-20) * Modified the "filter" widget to disable the input window instead of setting it with display none. Now the input is disabled and a "disabled" class is applied to allow for further styling. diff --git a/changelog.txt b/changelog.txt index c1dd4214..03fb9c17 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,21 @@ TableSorter Change Log +Version 2.0.31 (2012-2-27) +============================ + +* Added `sortRestart` option: + * When `true`, this option resets the sort direction so that clicking on an unsorted column will now sort in the `sortInitialOrder` direction. + * Clicking on a single column to cancel a multi-sorted table may not initially sort as expected. + * Requested by severa in [issue #30](https://github.com/Mottie/tablesorter/issues/29). Thanks! +* Made some `sortReset` fixes: + * Columns widget will now clear it's styling when the sort has reset. + * Added a [demo](http://mottie.github.com/tablesorter/). +* Changed the filter widget inputs to be of a search type: + * Currently only supported by webkit. + * Requested by cr125rider in [issue #29](https://github.com/Mottie/tablesorter/issues/29). Thanks! +* Updated `sortLocaleCompare` documentation since it was explained incorrectly. +* Did some general code cleanup and some optimization. + Version 2.0.30.1 (2012-2-20) ============================ diff --git a/js/jquery.tablesorter.min.js b/js/jquery.tablesorter.min.js index aa7d5192..9de202b2 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.30 Minified using http://dean.edwards.name/packer/ +* Version 2.0.31 Minified using http://dean.edwards.name/packer/ * Copyright (c) 2007 Christian Bach */ -!(function($){$.extend({tablesorter:new function(){var g=[],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:"mmddyyyy",onRenderHeader:null,selectorHeaders:'thead th',tableClass:'tablesorter',debug:false};function log(s){if(typeof console!=="undefined"&&typeof console.log!=="undefined"){console.log(s)}else{alert(s)}}function benchmark(s,d){log(s+" ("+(new Date().getTime()-d.getTime())+"ms)")}this.benchmark=benchmark;this.hasInitialized=false;function getElementText(a,b,c){var d="",te=a.textExtraction;if(!b){return""}if(!a.supportsTextContent){a.supportsTextContent=b.textContent||false}if(te==="simple"){if(a.supportsTextContent){d=b.textContent}else{if(b.childNodes[0]&&b.childNodes[0].hasChildNodes()){d=b.childNodes[0].innerHTML}else{d=b.innerHTML}}}else{if(typeof(te)==="function"){d=te(b)}else if(typeof(te)==="object"&&te.hasOwnProperty(c)){d=te[c](b)}else{d=$(b).text()}}return d}function getParserById(a){var i,l=g.length;for(i=0;i").each(function(a){this.column=header_index[this.parentNode.rowIndex+"-"+this.cellIndex];this.order=formatSortingOrder(checkHeaderOrder(b,a));this.count=this.order;if(checkHeaderMetadata(this)||checkHeaderOptions(b,a)||$(this).is('.sorter-false')){this.sortDisabled=true}this.lockedOrder=false;lock=checkHeaderLocked(b,a);if(typeof(lock)!=='undefined'&&lock!==false){this.order=this.lockedOrder=formatSortingOrder(lock)}if(!this.sortDisabled){$th=$(this).addClass(c.cssHeader);if(c.onRenderHeader){c.onRenderHeader.apply($th,[a])}}c.headerList[a]=this});if(c.debug){benchmark("Built headers",time);log($tableHeaders)}return $tableHeaders}function checkCellColSpan(a,b,d){var i,cell,arr=[],r=a.tHead.rows,c=r[d].cells;for(i=0;i1){arr=arr.concat(checkCellColSpan(a,b,d++))}else{if(a.tHead.length===1||(cell.rowSpan>1||!r[d+1])){arr.push(cell)}}}return arr}function isValueInArray(v,a){var i,l=a.length;for(i=0;i');$("tr:first td",a.tBodies[0]).each(function(){c.append($('').css('width',$(this).width()))});$(a).prepend(c)}}function updateHeaderSortCount(a,b){var i,s,o,c=a.config,l=b.length;for(i=0;ib)?1:-1}catch(er){return 0}}function sortTextDesc(a,b){if(a===''){return 1}if(b===''){return-1}if(a===b){return 0}if($.data(tbl[0],"tablesorter").sortLocaleCompare){return b.localeCompare(a)}return-sortText(a,b)}function getTextValue(a,b,d){if(b){var i,l=a.length,n=b+d;for(i=0;i=2){config.sortList.splice(j,1);o.count=0}}}}else{if(this.order<2){config.sortList.push([i,this.order])}}}if(config.sortAppend!==null){a=config.sortAppend;for(j=0;j0){c.trigger("sorton",[config.sortList])}else{applyWidget(this)}this.hasInitialized=true})};this.addParser=function(b){var i,l=g.length,a=true;for(i=0;i").each(function(a){this.column=header_index[this.parentNode.rowIndex+"-"+this.cellIndex];this.order=formatSortingOrder(checkHeaderOrder(b,a));this.count=this.order;if(checkHeaderMetadata(this)||checkHeaderOptions(b,a)||$(this).is('.sorter-false')){this.sortDisabled=true}this.lockedOrder=false;lock=checkHeaderLocked(b,a);if(typeof(lock)!=='undefined'&&lock!==false){this.order=this.lockedOrder=formatSortingOrder(lock)}if(!this.sortDisabled){$th=$(this).addClass(c.cssHeader);if(c.onRenderHeader){c.onRenderHeader.apply($th,[a])}}c.headerList[a]=this});if(c.debug){benchmark("Built headers",time);log($tableHeaders)}return $tableHeaders}function checkCellColSpan(a,b,d){var i,cell,arr=[],r=a.tHead.rows,c=r[d].cells;for(i=0;i1){arr=arr.concat(checkCellColSpan(a,b,d++))}else{if(a.tHead.length===1||(cell.rowSpan>1||!r[d+1])){arr.push(cell)}}}return arr}function isValueInArray(v,a){var i,l=a.length;for(i=0;i');$("tr:first td",a.tBodies[0]).each(function(){c.append($('').css('width',$(this).width()))});$(a).prepend(c)}}function updateHeaderSortCount(a,b){var i,s,o,c=a.config,l=b.length;for(i=0;ib)?1:-1}catch(er){return 0}}function sortTextDesc(a,b){if(a===''){return 1}if(b===''){return-1}if(a===b){return 0}if($.data(tbl[0],"tablesorter").sortLocaleCompare){return b.localeCompare(a)}return-sortText(a,b)}function getTextValue(a,b,d){if(b){var i,l=a.length,n=b+d;for(i=0;i=2){c.sortList.splice(j,1);o.count=0}}}}else{if(this.order<2){c.sortList.push([i,this.order])}}}if(c.sortAppend!==null){a=c.sortAppend;for(j=0;j0){d.trigger("sorton",[c.sortList])}else{applyWidget(this)}this.hasInitialized=true})};this.addParser=function(b){var i,l=g.length,a=true;for(i=0;i').wrapInner('
').hover(function(){b(this).addClass("ui-state-hover")}, function(){b(this).removeClass("ui-state-hover")})}));b.each(c.headerList,function(e){f=b(this);this.sortDisabled?f.find("span.ui-icon").removeClass(d+" ui-icon"):(a=f.hasClass(c.cssAsc)?j[1]:f.hasClass(c.cssDesc)?j[2]:f.hasClass(c.cssHeader)?j[0]:"",h=i.hasClass("hasStickyHeaders")?i.find("tr.stickyHeader").find("th").eq(e).add(f):f,h[a===j[0]?"removeClass":"addClass"]("ui-state-active").find("span.ui-icon").removeClass(d).addClass(a))});c.debug&&b.tablesorter.benchmark("Applying uitheme widget", g)}}); -b.tablesorter.addWidget({id:"columns",format:function(e){var g,a,d,f,h=e.config,c=h.sortList,i=c.length,j=["primary","secondary","tertiary"];h.widgetColumns&&h.widgetColumns.hasOwnProperty("css")&&(j=h.widgetColumns.css||j);d=j.length-1;f=j.join(" ");h.debug&&(a=new Date);c&&c[0]&&b("tr:visible",e.tBodies[0]).each(function(a){g=b(this).children().removeClass(f);g.eq(c[0][0]).addClass(j[0]);if(1',l;i.debug&&(l=new Date);for(g=0;gc.top&&b
').wrapInner('
').find(".resizer").bind("mousedown",function(c){a.resizable_target=b(c.target).closest("th");a.resizable_position=c.pageX}).end().bind("mousemove",function(c){if(!(0===a.resizable_position||null===typeof a.resizable_target)){var b=c.pageX-a.resizable_position, d=a.resizable_target.closest("th").prev();a.resizable_target.width()<-b||d&&d.width()<=b||(d.width(d.width()+b),a.resizable_position=c.pageX)}}).bind("mouseup",function(){h();return!1});b(e).find("thead").bind("mouseup mouseleave",function(){h()});a.resizable=!0}}}); -b.tablesorter.addWidget({id:"saveSort",init:function(b,g,a){a.format(b,!0)},format:function(e,g){var a,d,f,h,c=e.config;f='{"sortList":'+JSON.stringify(c.sortList)+"}";c.debug&&(h=new Date);if(c.widgetsavesort)e.hasInitialized&&(a="tablesorter"+ (c.tableIndex||0)+e.id,c.hasLocalStorage?localStorage[a]=f:(d=new Date,d.setTime(d.getTime()+31536E6),document.cookie=a+"="+f+"; expires="+d.toGMTString()+"; path=/"),c.debug&&b.tablesorter.benchmark('saveSort: Saving sort to "'+a+'" in '+(c.hasLocalStorage?"local storage":"a cookie"),h));else{c.widgetsavesort=!0;c.hasLocalStorage=!1;try{localStorage.getItem&&(c.hasLocalStorage=!0)}catch(i){}c.tableIndex=b(".tablesorter").index(b(e));a="tablesorter"+(c.tableIndex||0)+e.id;c.hasLocalStorage?d=localStorage[a]: (f=document.cookie.split(/[;\s|=]/),d=b.inArray(a,f)+1,d=0!==d?f[d]:"");try{d=b.parseJSON(d)}catch(j){d=""}f=d&&d.hasOwnProperty("sortList")&&b.isArray(d.sortList)?d.sortList:"";c.debug&&b.tablesorter.benchmark('saveSort: Last sort for "'+a+'" obtained from '+(c.hasLocalStorage?"local storage":"a cookie"),h);g&&f&&0').wrapInner('
').hover(function(){b(this).addClass("ui-state-hover")}, function(){b(this).removeClass("ui-state-hover")})}));b.each(c.headerList,function(d){f=b(this);this.sortDisabled?f.find("span.ui-icon").removeClass(e+" ui-icon"):(a=f.hasClass(c.cssAsc)?j[1]:f.hasClass(c.cssDesc)?j[2]:f.hasClass(c.cssHeader)?j[0]:"",h=i.hasClass("hasStickyHeaders")?i.find("tr.stickyHeader").find("th").eq(d).add(f):f,h[a===j[0]?"removeClass":"addClass"]("ui-state-active").find("span.ui-icon").removeClass(e).addClass(a))});c.debug&&b.tablesorter.benchmark("Applying uitheme widget", g)}}); +b.tablesorter.addWidget({id:"columns",format:function(d){var g,a,e,f,h=d.config,c=h.sortList,i=c.length,j=["primary","secondary","tertiary"];h.widgetColumns&&h.widgetColumns.hasOwnProperty("css")&&(j=h.widgetColumns.css||j);e=j.length-1;f=j.join(" ");h.debug&&(a=new Date);c&&c[0]?b("tr:visible",d.tBodies[0]).each(function(a){g=b(this).children().removeClass(f);g.eq(c[0][0]).addClass(j[0]);if(1',l;i.debug&&(l=new Date);for(g=0;gc.top&&b
').wrapInner('
').find(".resizer").bind("mousedown",function(c){a.resizable_target=b(c.target).closest("th");a.resizable_position=c.pageX}).end().bind("mousemove", function(c){if(!(0===a.resizable_position||null===typeof a.resizable_target)){var b=c.pageX-a.resizable_position,d=a.resizable_target.closest("th").prev();a.resizable_target.width()<-b||d&&d.width()<=b||(d.width(d.width()+b),a.resizable_position=c.pageX)}}).bind("mouseup",function(){h();return!1});b(d).find("thead").bind("mouseup mouseleave",function(){h()});a.resizable=!0}}}); +b.tablesorter.addWidget({id:"saveSort",init:function(b,g,a){a.format(b,!0)},format:function(d,g){var a,e,f,h,c=d.config;f= '{"sortList":'+JSON.stringify(c.sortList)+"}";c.debug&&(h=new Date);if(c.widgetsavesort)d.hasInitialized&&(a="tablesorter"+(c.tableIndex||0)+d.id,c.hasLocalStorage?localStorage[a]=f:(e=new Date,e.setTime(e.getTime()+31536E6),document.cookie=a+"="+f+"; expires="+e.toGMTString()+"; path=/"),c.debug&&b.tablesorter.benchmark('saveSort: Saving sort to "'+a+'" in '+(c.hasLocalStorage?"local storage":"a cookie"),h));else{c.widgetsavesort=!0;c.hasLocalStorage=!1;try{localStorage.getItem&&(c.hasLocalStorage= !0)}catch(i){}c.tableIndex=b(".tablesorter").index(b(d));a="tablesorter"+(c.tableIndex||0)+d.id;c.hasLocalStorage?e=localStorage[a]:(f=document.cookie.split(/[;\s|=]/),e=b.inArray(a,f)+1,e=0!==e?f[e]:"");try{e=b.parseJSON(e)}catch(j){e=""}f=e&&e.hasOwnProperty("sortList")&&b.isArray(e.sortList)?e.sortList:"";c.debug&&b.tablesorter.benchmark('saveSort: Last sort for "'+a+'" obtained from '+(c.hasLocalStorage?"local storage":"a cookie"),h);g&&f&&0