Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

The filter & stickyheader widgets cooperate

  • Loading branch information...
commit 9b6f38a830daf21f931ce329f03a09b5fe92735f 1 parent 16c2108
@Mottie authored
View
4 README.markdown
@@ -34,6 +34,10 @@ 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.23.5 (2011-12-6)
+
+* Updated the sticky header widget again to not interfere with the filter widget. Fix for [issue #10](https://github.com/Mottie/tablesorter/issues/10).
+
####Version 2.0.23.4 (2011-12-6)
* Updated the sticky header widget to reposition the sticky header when scrolling left. Fix for [issue #9](https://github.com/Mottie/tablesorter/issues/9).
View
5 changelog.txt
@@ -1,5 +1,10 @@
TableSorter Change Log
+Version 2.0.23.5 (2011-12-6)
+============================
+
+* Updated the sticky header widget again to not interfere with the filter widget. Fix for [issue #10](https://github.com/Mottie/tablesorter/issues/10).
+
Version 2.0.23.4 (2011-12-6)
============================
View
10 js/jquery.tablesorter.widgets.js
@@ -159,7 +159,7 @@ $.tablesorter.addWidget({
header = $(table).find('thead'),
hdrCells = header.find('tr').children(),
brdr = parseInt(hdrCells.eq(0).css('border-left-width'),10),
- sticky = header.find('tr').clone()
+ sticky = header.find('tr:not(.filters)').clone()
.addClass('stickyHeader')
.css({
width : header.outerWidth() + brdr * 2,
@@ -169,7 +169,8 @@ $.tablesorter.addWidget({
visibility : 'hidden',
zIndex : 10
}),
- stkyCells = sticky.children();
+ stkyCells = sticky.children(),
+ laststate;
// update sticky header class names to match real header
$table.bind('sortEnd', function(e,t){
var th = $(t).find('thead tr'),
@@ -205,6 +206,11 @@ $.tablesorter.addWidget({
left : offset.left - win.scrollLeft(),
visibility : vis
});
+ if (vis !== laststate) {
+ // trigger resize to make sure the column widths match
+ win.resize();
+ laststate = vis;
+ }
})
.resize(function(){
sticky.css({
View
2  js/jquery.tablesorter.widgets.min.js
@@ -4,6 +4,6 @@
a.tablesorter.addWidget({id:"uitheme",format:function(d){var c,b,g,f=d.config,e=["ui-icon-arrowthick-2-n-s","ui-icon-arrowthick-1-s","ui-icon-arrowthick-1-n"];f.widgetUitheme&&f.widgetUitheme.hasOwnProperty("css")&&(e=f.widgetUitheme.css||e);g=e.join(" ");f.debug&&(c=new Date);a(d).is(".ui-theme")||(a(d).addClass("ui-widget ui-widget-content ui-corner-all ui-theme"),a.each(f.headerList,function(){a(this).addClass("ui-widget-header ui-corner-all").append('<span class="ui-icon"/>').hover(function(){a(this).addClass("ui-state-hover")}, function(){a(this).removeClass("ui-state-hover")})}));a.each(f.headerList,function(c){f.headers[c]&&!1===f.headers[c].sorter?a(this).find("span.ui-icon").removeClass(g+" ui-icon"):(b=a(this).is("."+f.cssAsc)?e[1]:a(this).is("."+f.cssDesc)?e[2]:a(this).is("."+f.cssHeader)?e[0]:"",a(this)[b===e[0]?"removeClass":"addClass"]("ui-state-active").find("span.ui-icon").removeClass(g).addClass(b))});f.debug&&a.tablesorter.benchmark("Applying uitheme widget",c)}});
a.tablesorter.addWidget({id:"columns",format:function(d){var c, b,g,f,e=d.config,i=e.sortList,h=i.length,j=["primary","secondary","tertiary"];e.widgetColumns&&e.widgetColumns.hasOwnProperty("css")&&(j=e.widgetColumns.css||j);g=j.length-1;f=j.join(" ");e.debug&&(b=new Date);i&&i[0]&&a("tr:visible",d.tBodies[0]).each(function(b){c=a(this).children().removeClass(f);c.eq(i[0][0]).addClass(j[0]);if(1<h)for(b=1;b<h;b++)c.eq(i[b][0]).addClass(j[b]||j[g])});e.debug&&a.tablesorter.benchmark("Applying Columns widget",b)}});
a.tablesorter.addWidget({id:"filter",format:function(d){if(!d.config.filtering){var c, b,g,f,e,i,h=d.config,j=h.headerList.length,k=a(d),d='<tr class="filters">',l;h.debug&&(l=new Date);for(c=0;c<j;c++)d+='<td><input type="text" class="filter" data-col="'+c+'" style="',d+=h.headers[c]&&"filter"in h.headers[c]&&!1===h.headers[c].filter||a(h.headerList[c]).is(".filter-false")?"display:none":"",d+='"></td>';k.find("thead").append(d+="</tr>").find(".filter").bind("keyup",function(){b=k.find(".filter").map(function(){return(a(this).val()||"").toLowerCase()}).get();""===b.join("")?k.find("tr").show(): k.find("tbody").find("tr:not(.expand-child)").each(function(){g=!0;e=a(this).nextUntil("tr:not(.expand-child)");f=e.length&&("undefined"!==typeof h.widgetFilterChildRows?h.widgetFilterChildRows:1)?e.text():"";i=a(this).find("td");for(c=0;c<j;c++)""!==b[c]&&0<=(i.eq(c).text()+f).toLowerCase().indexOf(b[c])?g=g?!0:!1:""!==b[c]&&(g=!1);a(this)[g?"show":"hide"]();if(e.length)e[g?"show":"hide"]()});k.trigger("applyWidgets")});h.filtering=!0;h.debug&&a.tablesorter.benchmark("Applying Filter widget",l)}}});
-a.tablesorter.addWidget({id:"stickyHeaders",format:function(d){if(!a(d).find(".stickyHeader").length){var c=a(d),b=a(window),g=a(d).find("thead"),f=g.find("tr").children(),e=parseInt(f.eq(0).css("border-left-width"),10),i=g.find("tr").clone().addClass("stickyHeader").css({width:g.outerWidth()+2*e,position:"fixed",top:0,marginLeft:-e,visibility:"hidden",zIndex:10}),h=i.children();c.bind("sortEnd",function(b,c){var d=a(c).find("thead tr"),e=d.filter(".stickyHeader").children();d.filter(":not(.stickyHeader)").children().each(function(b){e.eq(b).attr("class", a(this).attr("class"))})});f.each(function(b){var c=a(this);h.eq(b).width(c.width()).bind("click",function(b){c.trigger(b)}).bind("mousedown",function(){this.onselectstart=function(){return!1};return!1})});g.prepend(i);b.scroll(function(){var a=c.offset(),d=b.scrollTop(),d=d>a.top&&d<a.top+c.find("tbody").height()?"visible":"hidden";i.css({left:a.left-b.scrollLeft(),visibility:d})}).resize(function(){i.css({left:a(d).offset().left-b.scrollLeft(),width:g.outerWidth()+2*e});h.each(function(b){a(this).width(f.eq(b).width())})})}}});
+a.tablesorter.addWidget({id:"stickyHeaders",format:function(d){if(!a(d).find(".stickyHeader").length){var c=a(d),b=a(window),g=a(d).find("thead"),f=g.find("tr").children(),e=parseInt(f.eq(0).css("border-left-width"),10),i=g.find("tr:not(.filters)").clone().addClass("stickyHeader").css({width:g.outerWidth()+2*e,position:"fixed",top:0,marginLeft:-e,visibility:"hidden",zIndex:10}),h=i.children(),j;c.bind("sortEnd",function(b,c){var d=a(c).find("thead tr"),e=d.filter(".stickyHeader").children();d.filter(":not(.stickyHeader)").children().each(function(b){e.eq(b).attr("class", a(this).attr("class"))})});f.each(function(b){var c=a(this);h.eq(b).width(c.width()).bind("click",function(b){c.trigger(b)}).bind("mousedown",function(){this.onselectstart=function(){return!1};return!1})});g.prepend(i);b.scroll(function(){var a=c.offset(),d=b.scrollTop(),d=d>a.top&&d<a.top+c.find("tbody").height()?"visible":"hidden";i.css({left:a.left-b.scrollLeft(),visibility:d});d!==j&&(b.resize(),j=d)}).resize(function(){i.css({left:a(d).offset().left-b.scrollLeft(),width:g.outerWidth()+2*e}); h.each(function(b){a(this).width(f.eq(b).width())})})}}});
a.tablesorter.addWidget({id:"resizable",format:function(d){if(!d.config.resizable){var c,b=d.config,g=b.headerList,f=g.length,e=function(){b.resizable_position=0;b.resizable_target=null;a(window).trigger("resize")};b.resizable_target=null;b.resizable_position=0;for(c=1;c<f;c++)a(g[c]).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){b.resizable_target=a(c.target).closest("th");b.resizable_position=c.pageX}).end().bind("mousemove",function(a){if(!(0===b.resizable_position||null===typeof b.resizable_target)){var c=a.pageX-b.resizable_position,d=b.resizable_target.closest("th").prev();if(!(b.resizable_target.width()<-c||d&&d.width()<=c))d.width(d.width()+c),b.resizable_position=a.pageX}}).bind("mouseup",function(){e();return!1});a(d).find("thead").bind("mouseup mouseleave",function(){e()});b.resizable=!0}}})
})(jQuery);
Please sign in to comment.
Something went wrong with that request. Please try again.