mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
filter widget now uses search type inputs
This commit is contained in:
parent
9603723f64
commit
c1ec042b60
@ -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.
|
||||
|
@ -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)
|
||||
============================
|
||||
|
||||
|
4
js/jquery.tablesorter.min.js
vendored
4
js/jquery.tablesorter.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
||||
/* TableSorter 2.0 Widgets - updated 2/20/2012
|
||||
/* TableSorter 2.0 Widgets - updated 2/27/2012
|
||||
*
|
||||
* jQuery UI Theme
|
||||
* Column Styles
|
||||
@ -111,14 +111,14 @@ $.tablesorter.addWidget({
|
||||
time = new Date();
|
||||
}
|
||||
for (i=0; i < cols; i++){
|
||||
fr += '<td><input type="text" data-col="' + i + '" class="filter';
|
||||
fr += '<td><input type="search" data-col="' + i + '" class="filter';
|
||||
// use header option - headers: { 1: { filter: false } } OR add class="filter-false"
|
||||
fr += ((c.headers[i] && 'filter' in c.headers[i] && c.headers[i].filter === false) || $(c.headerList[i]).is('.filter-false') ) ? ' disabled" disabled' : '"';
|
||||
fr += ((c.headers[i] && c.headers[i].hasOwnProperty('filter') && c.headers[i].filter === false) || $(c.headerList[i]).is('.filter-false') ) ? ' disabled" disabled' : '"';
|
||||
fr += '></td>';
|
||||
}
|
||||
tbl
|
||||
.find('thead').append(fr += '</tr>')
|
||||
.find('.filter').bind('keyup', function(e){
|
||||
.find('.filter').bind('keyup search', function(e){
|
||||
v = tbl.find('.filter').map(function(){ return ($(this).val() || '').toLowerCase(); }).get();
|
||||
if (v.join('') === '') {
|
||||
tbl.find('tr').show();
|
||||
|
14
js/jquery.tablesorter.widgets.min.js
vendored
14
js/jquery.tablesorter.widgets.min.js
vendored
@ -1,10 +1,10 @@
|
||||
/* TableSorter 2.0 Widgets - updated 2/20/2012 */
|
||||
/* TableSorter 2.0 Widgets - updated 2/27/2012 */
|
||||
|
||||
(function(b){
|
||||
b.tablesorter.addWidget({id:"uitheme",format:function(e){var g,a,d,f,h,c=e.config,i=b(e),j=["ui-icon-arrowthick-2-n-s","ui-icon-arrowthick-1-s","ui-icon-arrowthick-1-n"];c.widgetUitheme&&c.widgetUitheme.hasOwnProperty("css")&&(j=c.widgetUitheme.css||j);d=j.join(" ");c.debug&&(g=new Date);i.is(".ui-theme")||(i.addClass("ui-widget ui-widget-content ui-corner-all ui-theme"),b.each(c.headerList,function(){b(this).addClass("ui-widget-header ui-corner-all").append('<span class="ui-icon"/>').wrapInner('<div class="inner"/>').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<i)for(a=1;a<i;a++)g.eq(c[a][0]).addClass(j[a]||j[d])});h.debug&&b.tablesorter.benchmark("Applying Columns widget", a)}});
|
||||
b.tablesorter.addWidget({id:"filter",format:function(e){if(!e.config.filtering){var g,a,d,f,h,c,i=e.config,j=i.headerList.length,k=b(e),e='<tr class="filters">',l;i.debug&&(l=new Date);for(g=0;g<j;g++)e+='<td><input type="text" data-col="'+g+'" class="filter',e+=i.headers[g]&&"filter"in i.headers[g]&&!1===i.headers[g].filter||b(i.headerList[g]).is(".filter-false")?' disabled" disabled':'"',e+="></td>";k.find("thead").append(e+="</tr>").find(".filter").bind("keyup",function(){a=k.find(".filter").map(function(){return(b(this).val()|| "").toLowerCase()}).get();""===a.join("")?k.find("tr").show():k.find("tbody").find("tr:not(.expand-child)").each(function(){d=!0;h=b(this).nextUntil("tr:not(.expand-child)");f=h.length&&("undefined"!==typeof i.widgetFilterChildRows?i.widgetFilterChildRows:1)?h.text():"";c=b(this).find("td");for(g=0;g<j;g++)""!==a[g]&&0<=(c.eq(g).text()+f).toLowerCase().indexOf(a[g])?d=d?!0:!1:""!==a[g]&&(d=!1);b(this)[d?"show":"hide"]();if(h.length)h[d?"show":"hide"]()});k.trigger("applyWidgets")});i.filtering=!0; i.debug&&b.tablesorter.benchmark("Applying Filter widget",l)}}});
|
||||
b.tablesorter.addWidget({id:"stickyHeaders",format:function(e){if(!b(e).hasClass("hasStickyHeaders")){var g=b(e).addClass("hasStickyHeaders"),a=b(window),d=b(e).find("thead"),f=d.find("tr").children(),h=f.eq(0),c=parseInt(f.eq(0).css("border-left-width"),10),i=d.find("tr:not(.filters)").clone().addClass("stickyHeader").css({width:d.outerWidth()+2*c,position:"fixed",left:h.offset().left,marginLeft:-c,top:0,visibility:"hidden",zIndex:10}), j=i.children(),k;g.bind("sortEnd",function(a,c){var d=b(c).find("thead tr"),e=d.filter(".stickyHeader").children();d.filter(":not(.stickyHeader)").children().each(function(a){e.eq(a).attr("class",b(this).attr("class"))})}).bind("pagerComplete",function(){a.resize()});f.each(function(a){var c=b(this);j.eq(a).width(c.width()).bind("click",function(a){c.trigger(a)}).bind("mousedown",function(){this.onselectstart=function(){return!1};return!1})});d.prepend(i);a.scroll(function(){var c=h.offset(),b=a.scrollTop(), b=b>c.top&&b<c.top+g.find("tbody").height()?"visible":"hidden";i.css({left:c.left-a.scrollLeft(),visibility:b});b!==k&&(a.resize(),k=b)}).resize(function(){i.css({left:h.offset().left-a.scrollLeft(),width:d.outerWidth()+2*c});j.each(function(a){b(this).width(f.eq(a).width())})})}}});
|
||||
b.tablesorter.addWidget({id:"resizable",format:function(e){if(!e.config.resizable){var g,a=e.config,d=a.headerList,f=d.length,h=function(){a.resizable_position=0;a.resizable_target=null;b(window).trigger("resize")};a.resizable_target= null;a.resizable_position=0;for(g=1;g<f;g++)b(d[g]).append('<div class="resizer" style="cursor:w-resize;position:absolute;height:100%;width:20px;left:-20px;top:0;z-index:1;"></div>').wrapInner('<div style="position:relative;height:100%;width:100%"></div>').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<f.length?c.sortList=f:e.hasInitialized&&f&&0<f.length&&b(e).trigger("sorton",[f])}}})
|
||||
b.tablesorter.addWidget({id:"uitheme",format:function(d){var g,a,e,f,h,c=d.config,i=b(d),j=["ui-icon-arrowthick-2-n-s","ui-icon-arrowthick-1-s","ui-icon-arrowthick-1-n"];c.widgetUitheme&&c.widgetUitheme.hasOwnProperty("css")&&(j=c.widgetUitheme.css||j);e=j.join(" ");c.debug&&(g=new Date);i.is(".ui-theme")||(i.addClass("ui-widget ui-widget-content ui-corner-all ui-theme"),b.each(c.headerList,function(){b(this).addClass("ui-widget-header ui-corner-all").append('<span class="ui-icon"/>').wrapInner('<div class="inner"/>').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<i)for(a=1;a<i;a++)g.eq(c[a][0]).addClass(j[a]||j[e])}):b("td",d.tBodies[0]).removeClass(f);h.debug&& b.tablesorter.benchmark("Applying Columns widget",a)}});
|
||||
b.tablesorter.addWidget({id:"filter",format:function(d){if(!d.config.filtering){var g,a,e,f,h,c,i=d.config,j=i.headerList.length,k=b(d),d='<tr class="filters">',l;i.debug&&(l=new Date);for(g=0;g<j;g++)d+='<td><input type="search" data-col="'+g+'" class="filter',d+=i.headers[g]&&i.headers[g].hasOwnProperty("filter")&&!1===i.headers[g].filter||b(i.headerList[g]).is(".filter-false")?' disabled" disabled':'"',d+="></td>";k.find("thead").append(d+= "</tr>").find(".filter").bind("keyup search",function(){a=k.find(".filter").map(function(){return(b(this).val()||"").toLowerCase()}).get();""===a.join("")?k.find("tr").show():k.find("tbody").find("tr:not(.expand-child)").each(function(){e=!0;h=b(this).nextUntil("tr:not(.expand-child)");f=h.length&&("undefined"!==typeof i.widgetFilterChildRows?i.widgetFilterChildRows:1)?h.text():"";c=b(this).find("td");for(g=0;g<j;g++)""!==a[g]&&0<=(c.eq(g).text()+f).toLowerCase().indexOf(a[g])?e=e?!0:!1:""!==a[g]&& (e=!1);b(this)[e?"show":"hide"]();if(h.length)h[e?"show":"hide"]()});k.trigger("applyWidgets")});i.filtering=!0;i.debug&&b.tablesorter.benchmark("Applying Filter widget",l)}}});
|
||||
b.tablesorter.addWidget({id:"stickyHeaders",format:function(d){if(!b(d).hasClass("hasStickyHeaders")){var g=b(d).addClass("hasStickyHeaders"),a=b(window),e=b(d).find("thead"),f=e.find("tr").children(),h=f.eq(0),c=parseInt(f.eq(0).css("border-left-width"),10),i=e.find("tr:not(.filters)").clone().addClass("stickyHeader").css({width:e.outerWidth()+ 2*c,position:"fixed",left:h.offset().left,marginLeft:-c,top:0,visibility:"hidden",zIndex:10}),j=i.children(),k;g.bind("sortEnd",function(a,c){var d=b(c).find("thead tr"),e=d.filter(".stickyHeader").children();d.filter(":not(.stickyHeader)").children().each(function(a){e.eq(a).attr("class",b(this).attr("class"))})}).bind("pagerComplete",function(){a.resize()});f.each(function(a){var c=b(this);j.eq(a).width(c.width()).bind("click",function(a){c.trigger(a)}).bind("mousedown",function(){this.onselectstart= function(){return!1};return!1})});e.prepend(i);a.scroll(function(){var c=h.offset(),b=a.scrollTop(),b=b>c.top&&b<c.top+g.find("tbody").height()?"visible":"hidden";i.css({left:c.left-a.scrollLeft(),visibility:b});b!==k&&(a.resize(),k=b)}).resize(function(){i.css({left:h.offset().left-a.scrollLeft(),width:e.outerWidth()+2*c});j.each(function(a){b(this).width(f.eq(a).width())})})}}});
|
||||
b.tablesorter.addWidget({id:"resizable",format:function(d){if(!d.config.resizable){var g,a=d.config,e=a.headerList,f= e.length,h=function(){a.resizable_position=0;a.resizable_target=null;b(window).trigger("resize")};a.resizable_target=null;a.resizable_position=0;for(g=1;g<f;g++)b(e[g]).append('<div class="resizer" style="cursor:w-resize;position:absolute;height:100%;width:20px;left:-20px;top:0;z-index:1;"></div>').wrapInner('<div style="position:relative;height:100%;width:100%"></div>').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<f.length?c.sortList=f:d.hasInitialized&&f&&0<f.length&& b(d).trigger("sorton",[f])}}})
|
||||
})(jQuery);
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tablesorter",
|
||||
"version": "2.0.30.1",
|
||||
"version": "2.0.31",
|
||||
"title": "tablesorter",
|
||||
"author": {
|
||||
"name": "Christian Bach",
|
||||
|
Loading…
Reference in New Issue
Block a user