From b7454cdd065434f09e340d9b2c0b64f55bf5d4d8 Mon Sep 17 00:00:00 2001 From: Mottie Date: Sun, 26 Jul 2015 12:03:41 -0500 Subject: [PATCH] Scroller: include sortEnd in fixed column updates - see #977 --- dist/js/widgets/widget-scroller.min.js | 2 +- js/widgets/widget-scroller.js | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/dist/js/widgets/widget-scroller.min.js b/dist/js/widgets/widget-scroller.min.js index 575219f2..448c3c09 100644 --- a/dist/js/widgets/widget-scroller.min.js +++ b/dist/js/widgets/widget-scroller.min.js @@ -1,2 +1,2 @@ /*! Widget: scroller - updated 5/17/2015 (v2.22.0) */ -!function(a,b){"use strict";var c=a.tablesorter,d=c.css;a.extend(c.css,{scrollerWrap:"tablesorter-scroller",scrollerHeader:"tablesorter-scroller-header",scrollerTable:"tablesorter-scroller-table",scrollerFooter:"tablesorter-scroller-footer",scrollerFixed:"tablesorter-scroller-fixed",scrollerFixedPanel:"tablesorter-scroller-fixed-panel",scrollerHasFix:"tablesorter-scroller-has-fixed-columns",scrollerHideColumn:"tablesorter-scroller-hidden-column",scrollerHideElement:"tablesorter-scroller-hidden",scrollerSpacerRow:"tablesorter-scroller-spacer",scrollerBarSpacer:"tablesorter-scroller-bar-spacer",scrollerAddedHeight:"tablesorter-scroller-added-height",scrollerHack:"tablesorter-scroller-scrollbar-hack",scrollerRtl:"ts-scroller-rtl"}),c.addWidget({id:"scroller",priority:60,options:{scroller_height:300,scroller_jumpToHeader:!0,scroller_upAfterSort:!0,scroller_fixedColumns:0,scroller_rowHighlight:"hover",scroller_addFixedOverlay:!1,scroller_barWidth:null},format:function(a,b,d){b.isScrolling||c.scroller.setup(b,d)},remove:function(a,b,d){c.scroller.remove(b,d)}}),c.window_resize=function(){c.timer_resize&&clearTimeout(c.timer_resize),c.timer_resize=setTimeout(function(){a(b).trigger("resizeEnd")},250)},a(function(){var b="";a(b).appendTo("body")}),c.scroller={isFirefox:navigator.userAgent.toLowerCase().indexOf("firefox")>-1,isOldIE:document.all&&!b.atob,isIE:document.all&&!b.atob||navigator.appVersion.indexOf("Trident/")>0,isSafari:navigator.userAgent.toLowerCase().indexOf("safari")>-1&&-1===navigator.userAgent.toLowerCase().indexOf("chrome"),hasScrollBar:function(a,b){return b?a.get(0).scrollWidth>a.width():a.get(0).scrollHeight>a.height()},setWidth:function(a,b){a.css({width:b,"min-width":b,"max-width":b})},getBarWidth:function(){var b=a("
").css({position:"absolute",top:"-9999px",left:0,width:"100px",height:"100px",overflow:"scroll",visibility:"hidden"}).appendTo("body"),c=b[0],d=c.offsetWidth-c.clientWidth;return b.remove(),d},setup:function(e,f){var g,h,i,j,k,l,m,n,o=a(b),p=c.scroller,q=e.namespace+"tsscroller",r=a(),s=e.namespace.slice(1)+"tsscroller",t=e.$table;e.widthFixed=!0,f.scroller_calcWidths=[],f.scroller_saved=[0,0],f.scroller_isBusy=!0,f.scroller_barSetWidth=null!==f.scroller_barWidth?f.scroller_barWidth:p.getBarWidth()||15,g=f.scroller_height||300,i=a(''+t.children("thead")[0].outerHTML+"
"),f.scroller_$header=i.addClass(e.namespace.slice(1)+"_extra_table"),j=t.children("tfoot"),j.length&&(r=a('
').addClass(e.namespace.slice(1)+"_extra_table").append(j.clone(!0)).wrap('
'),l=r.children("tfoot").eq(0).children("tr").children()),f.scroller_$footer=r,t.wrap('
').before(i).find("."+d.filterRow).addClass(d.filterRowHide),f.scroller_$container=t.parent(),r.length&&t.after(r.parent()),k=i.wrap('
').find("."+d.header),t.wrap('
'),m=t.parent(),c.bindEvents(e.table,k),t.hasClass("hasFilters")&&c.filter.bindSearch(t,i.find("."+d.filter)),t.find("thead").addClass(d.scrollerHideElement),h=m.parent().height(),m.off("scroll"+q).on("scroll"+q,function(){if(f.scroller_jumpToHeader){var b=o.scrollTop()-i.offset().top;0!==a(this).scrollTop()&&h>b&&b>0&&o.scrollTop(i.offset().top)}i.parent().add(r.parent()).scrollLeft(a(this).scrollLeft())}),n=((c.hasWidget(e.table,"filter")?"filterEnd":"tablesorter-initialized")+" updateComplete pagerComplete columnUpdate ").split(" ").join(q+" "),t.off(q).on("sortEnd filterEnd".split(" ").join(q+" "),function(a){"sortEnd"===a.type&&f.scroller_upAfterSort?m.animate({scrollTop:0},"fast"):f.scroller_fixedColumns&&setTimeout(function(){m.scrollTop(f.scroller_saved[1]).scrollLeft(f.scroller_saved[0]),p.updateFixed(e,f,!1)},0)}).on("setFixedColumnSize"+q,function(a,b){var c=f.scroller_$container;"undefined"==typeof b||isNaN(b)||(f.scroller_fixedColumns=parseInt(b,10)),p.removeFixed(e,f),b=f.scroller_fixedColumns,b>0&&b0&&p.updateFixed(e,f,!1),p.resize(e,f))}),o.off("resize resizeEnd ".split(" ").join(q+" ")).on("resize"+q,c.window_resize).on("resizeEnd"+q,function(){o.off("resize"+q,c.window_resize),p.resize(e,f),o.on("resize"+q,c.window_resize),m.trigger("scroll"+q)}),e.isScrolling=!0,p.updateFixed(e,f),e.table.hasInitialized&&e.isScrolling&&setTimeout(function(){c.scroller.resize(e,f)},50)},resize:function(e,f){if(!f.scroller_isBusy){var g,h,i,j,k,l,m=c.scroller,n=f.scroller_$container,o=e.$table,p=o.parent(),q=f.scroller_$header,r=f.scroller_$footer,s=e.namespace.slice(1)+"tsscroller",t=a("div."+d.scrollerWrap+'[id!="'+s+'"]').addClass(d.scrollerHideElement),u='';for(f.scroller_calcWidths=[],m.removeFixed(e,f),n.find("."+d.scrollerSpacerRow).remove(),n.find("."+c.css.colgroup).remove(),o.find("."+d.scrollerHideElement).removeClass(d.scrollerHideElement),h=parseInt(o.css("border-left-width"),10),j=e.$headerIndexed,g=0;g',f.scroller_calcWidths[g]=i;u+="",e.$tbodies.eq(0).prepend(u),q.children("thead").append(u),r.children("tfoot").append(u),c.fixColumnWidth(e.table),u=e.$table.children("colgroup")[0].outerHTML,q.prepend(u),r.prepend(u),l=p.parent().innerWidth()-(m.hasScrollBar(p)?f.scroller_barSetWidth:0),p.width(l),l=(m.hasScrollBar(p)?f.scroller_barSetWidth:0)+h,i=p.innerWidth()-l,q.parent().add(r.parent()).width(i),p.width(i+l),o.children("thead").addClass(d.scrollerHideElement),m.updateFixed(e,f),t.removeClass(d.scrollerHideElement),p.scrollTop(f.scroller_saved[1]),f.scroller_$container.find("."+d.scrollerFixed).find("."+d.scrollerTable).scrollTop(f.scroller_saved[1]),setTimeout(function(){e.$table.trigger("resizableUpdate")},100)}},setupFixed:function(a,b){var e,f,g,h,i,j,k,l=a.$table,m=b.scroller_$container,n=b.scroller_fixedColumns;for(j=m.addClass(d.scrollerHasFix).clone().addClass(d.scrollerFixed).removeClass(d.scrollerWrap).attr("id",""),b.scroller_addFixedOverlay&&j.append('
'),k=j.find("."+d.scrollerTable),k.children("table").addClass(a.namespace.slice(1)+"_extra_table").attr("id","").children("thead, tfoot").remove(),b.scroller_$fixedColumns=j,l.hasClass(d.scrollerRtl)&&j.addClass(d.scrollerRtl),g=j.find("tr"),h=g.length,e=0;h>e;e++)g.eq(e).children(":gt("+(n-1)+")").remove();if(j.addClass(d.scrollerHideElement).prependTo(m),a.$table.hasClass("hasFilters"))for(g=j.find("."+d.filter).not("."+d.filterDisabled).prop("disabled",!1),c.filter.bindSearch(l,j.find("."+d.filter)),g=m.children("."+d.scrollerHeader).find("."+d.filter),h=g.length,e=0;h>e;e++)g.eq(e).hasClass(d.filterDisabled||"disabled")||g.eq(e).prop("disabled",n>e);for(a.$table.add("."+d.scrollerFooter+" table").children("thead").children("tr."+d.headerRow).children().attr("tabindex",-1),g=b.scroller_$header.add(j.find("."+d.scrollerTable+" table")).children("thead").children("tr."+d.headerRow),h=g.length,e=0;h>e;e++)for(i=g.eq(e).children(),f=0;ff?-1:0);c.bindEvents(a.table,j.find("."+d.header)),c.scroller.bindFixedColumnEvents(a,b),(c.scroller.isFirefox||c.scroller.isOldIE)&&k.wrap('
')},bindFixedColumnEvents:function(b,e){var f=c.scroller,g=b.namespace+"tsscrollerFixed",h="scroll"+g,i=e.scroller_$fixedColumns.find("."+d.scrollerTable),j=!0,k=!0;b.$table.parent().off(h).on(h,function(){if(!e.scroller_isBusy&&!e.scroller_isBusy&&(j||!f.isFirefox&&!f.isIE)){k=!1;var b=a(this);i[0].scrollTop=e.scroller_saved[1]=b.scrollTop(),e.scroller_saved[0]=b.scrollLeft(),setTimeout(function(){k=!0},20)}}),i.off(h).on(h,function(){if(!e.scroller_isBusy&&(k||!f.isFirefox&&!f.isIE)){j=!1;var c=a(this);b.$table.parent()[0].scrollTop=e.scroller_saved[1]=c.scrollTop(),setTimeout(function(){j=!0},20)}}).scroll(),""!==e.scroller_rowHighlight&&(h="mouseover mouseleave ".split(" ").join(g+" "),b.$table.off(h,"tbody > tr").on(h,"tbody > tr",function(a){var c=b.$table.children("tbody").children("tr").index(this);i.children("table").children("tbody").children("tr").eq(c).add(this).toggleClass(e.scroller_rowHighlight,"mouseover"===a.type)}),i.find("table").off(h,"tbody > tr").on(h,"tbody > tr",function(a){var c=i.children("table").children("tbody").children("tr"),d=c.index(this);b.$table.children("tbody").children("tr").eq(d).add(this).toggleClass(e.scroller_rowHighlight,"mouseover"===a.type)}))},adjustWidth:function(a,b,e,f,g){var h=b.scroller_$container;h.children("."+d.scrollerTable).css(g?"right":"left",e),h.children("."+d.scrollerHeader+", ."+d.scrollerFooter).css(g?"right":"left",e+(g&&c.scroller.isSafari?f:0))},updateFixed:function(b,e){var f,g,h=e.scroller_$container,i=e.scroller_$header,j=e.scroller_$footer,k=b.$table,l=k.parent(),m=e.scroller_barSetWidth,n=k.hasClass(d.scrollerRtl);if(0===e.scroller_fixedColumns)return e.scroller_isBusy=!1,c.scroller.removeFixed(b,e),f=h.width(),l.width(f),g=c.scroller.hasScrollBar(l)?m:0,void i.parent().add(j.parent()).width(f-g);if(b.isScrolling){e.scroller_isBusy=!0,h.find("."+d.scrollerFixed).length||c.scroller.setupFixed(b,e);var o,p,q,r,s,t,u,v=e.scroller_$container.children("."+d.scrollerTable).children("table").children("tbody"),w=e.scroller_$header.children("thead").children("."+d.headerRow),x=e.scroller_$fixedColumns.addClass(d.scrollerHideElement),y=x.find("."+d.scrollerTable).children("table"),z=y.children("tbody"),A=c.scroller,B=e.scroller_fixedColumns,C=k.find("tbody td"),D=parseInt(C.css("border-right-width"),10)||1,E=parseInt((C.css("border-spacing")||"").split(/\s/)[0],10)/2||0,F=parseInt(k.css("padding-left"),10)+parseInt(k.css("padding-right"),10)-D,G=e.scroller_calcWidths;for(c.scroller.removeFixed(b,e,!1),o=0;B>o;o++)F+=G[o]+E;for(F=F+2*D-E,A.setWidth(x.add(x.children()),F),A.setWidth(x.children().children("table"),F),p=0;pq;q++)s=a(w[q].outerHTML),s.children("td, th").slice(B).remove(),t.append(s);c.processTbody(y,t,!1)}for(g=c.scroller.hasScrollBar(l)?m:0,(A.isFirefox||A.isOldIE)&&y.css("width",F).parent().css("width",F+g),x.removeClass(d.scrollerHideElement),o=0;B>o;o++)h.children("div").children("table").find("th:nth-child("+(o+1)+"), td:nth-child("+(o+1)+")").addClass(d.scrollerHideColumn);F-=D,f=l.parent().innerWidth()-F,l.width(f),h.children("."+d.scrollerTable).css(n?"right":"left",F),h.children("."+d.scrollerHeader+", ."+d.scrollerFooter).css(n?"right":"left",F+(n&&c.scroller.isSafari?g:0)),i.parent().add(j.parent()).width(f-g),f=c.scroller.hasScrollBar(l,!0),g=f?m:0,!x.find("."+d.scrollerBarSpacer).length&&f?(C=a('
').css("height",g+"px"),x.find("."+d.scrollerTable).append(C)):f||x.find("."+d.scrollerBarSpacer).remove(),c.scroller.updateRowHeight(b,e),x.height(h.height()),x.removeClass(d.scrollerHideElement),e.scroller_isBusy=!1}},fixHeight:function(a,b){var c,e,f,g,h,i=a.length;for(c=0;i>c;c++)g=a.eq(c),h=b.eq(c),e=g.height(),f=h.height(),e>f?h.addClass(d.scrollerAddedHeight).height(e):f>e&&g.addClass(d.scrollerAddedHeight).height(f)},updateRowHeight:function(a,b){var e,f,g=b.scroller_$fixedColumns;b.scroller_$container.find("."+d.scrollerAddedHeight).removeClass(d.scrollerAddedHeight).height(""),e=b.scroller_$header.children("thead").children("tr"),f=g.children("."+d.scrollerHeader).children("table").children("thead").children("tr"),c.scroller.fixHeight(e,f),e=b.scroller_$footer.children("tfoot").children("tr"),f=g.children("."+d.scrollerFooter).children("table").children("tfoot").children("tr"),c.scroller.fixHeight(e,f),(c.scroller.isFirefox||c.scroller.isOldIE)&&(g=g.find("."+d.scrollerHack)),e=a.$table.children("tbody").children("tr"),f=g.children("."+d.scrollerTable).children("table").children("tbody").children("tr"),c.scroller.fixHeight(e,f)},removeFixed:function(a,b,c){var e=a.$table,f=b.scroller_$container,g=e.hasClass(d.scrollerRtl);(c||"undefined"==typeof c)&&f.find("."+d.scrollerFixed).remove(),f.find("."+d.scrollerHideColumn).removeClass(d.scrollerHideColumn),f.children(":not(."+d.scrollerFixed+")").css(g?"right":"left",0)},remove:function(c,e){var f=e.scroller_$container,g=c.namespace+"tsscroller";c.$table.off(g),a(b).off(g),f&&(c.$table.insertBefore(f).find("thead").removeClass(d.scrollerHideElement).children("tr."+d.headerRow).children().attr("tabindex",0).end().find("."+d.filterRow).removeClass(d.scrollerHideElement+" "+d.filterRowHide),c.$table.find("."+d.filter).not("."+d.filterDisabled).prop("disabled",!1),f.remove(),c.isScrolling=!1)}}}(jQuery,window); \ No newline at end of file +!function(a,b){"use strict";var c=a.tablesorter,d=c.css;a.extend(c.css,{scrollerWrap:"tablesorter-scroller",scrollerHeader:"tablesorter-scroller-header",scrollerTable:"tablesorter-scroller-table",scrollerFooter:"tablesorter-scroller-footer",scrollerFixed:"tablesorter-scroller-fixed",scrollerFixedPanel:"tablesorter-scroller-fixed-panel",scrollerHasFix:"tablesorter-scroller-has-fixed-columns",scrollerHideColumn:"tablesorter-scroller-hidden-column",scrollerHideElement:"tablesorter-scroller-hidden",scrollerSpacerRow:"tablesorter-scroller-spacer",scrollerBarSpacer:"tablesorter-scroller-bar-spacer",scrollerAddedHeight:"tablesorter-scroller-added-height",scrollerHack:"tablesorter-scroller-scrollbar-hack",scrollerRtl:"ts-scroller-rtl"}),c.addWidget({id:"scroller",priority:60,options:{scroller_height:300,scroller_jumpToHeader:!0,scroller_upAfterSort:!0,scroller_fixedColumns:0,scroller_rowHighlight:"hover",scroller_addFixedOverlay:!1,scroller_barWidth:null},format:function(a,b,d){b.isScrolling||c.scroller.setup(b,d)},remove:function(a,b,d){c.scroller.remove(b,d)}}),c.window_resize=function(){c.timer_resize&&clearTimeout(c.timer_resize),c.timer_resize=setTimeout(function(){a(b).trigger("resizeEnd")},250)},a(function(){var b="";a(b).appendTo("body")}),c.scroller={isFirefox:navigator.userAgent.toLowerCase().indexOf("firefox")>-1,isOldIE:document.all&&!b.atob,isIE:document.all&&!b.atob||navigator.appVersion.indexOf("Trident/")>0,isSafari:navigator.userAgent.toLowerCase().indexOf("safari")>-1&&-1===navigator.userAgent.toLowerCase().indexOf("chrome"),hasScrollBar:function(a,b){return b?a.get(0).scrollWidth>a.width():a.get(0).scrollHeight>a.height()},setWidth:function(a,b){a.css({width:b,"min-width":b,"max-width":b})},getBarWidth:function(){var b=a("
").css({position:"absolute",top:"-9999px",left:0,width:"100px",height:"100px",overflow:"scroll",visibility:"hidden"}).appendTo("body"),c=b[0],d=c.offsetWidth-c.clientWidth;return b.remove(),d},setup:function(e,f){var g,h,i,j,k,l,m,n,o=a(b),p=c.scroller,q=e.namespace+"tsscroller",r=a(),s=e.namespace.slice(1)+"tsscroller",t=e.$table;e.widthFixed=!0,f.scroller_calcWidths=[],f.scroller_saved=[0,0],f.scroller_isBusy=!0,f.scroller_barSetWidth=null!==f.scroller_barWidth?f.scroller_barWidth:p.getBarWidth()||15,g=f.scroller_height||300,i=a(''+t.children("thead")[0].outerHTML+"
"),f.scroller_$header=i.addClass(e.namespace.slice(1)+"_extra_table"),j=t.children("tfoot"),j.length&&(r=a('
').addClass(e.namespace.slice(1)+"_extra_table").append(j.clone(!0)).wrap('
'),l=r.children("tfoot").eq(0).children("tr").children()),f.scroller_$footer=r,t.wrap('
').before(i).find("."+d.filterRow).addClass(d.filterRowHide),f.scroller_$container=t.parent(),r.length&&t.after(r.parent()),k=i.wrap('
').find("."+d.header),t.wrap('
'),m=t.parent(),c.bindEvents(e.table,k),t.hasClass("hasFilters")&&c.filter.bindSearch(t,i.find("."+d.filter)),t.find("thead").addClass(d.scrollerHideElement),h=m.parent().height(),m.off("scroll"+q).on("scroll"+q,function(){if(f.scroller_jumpToHeader){var b=o.scrollTop()-i.offset().top;0!==a(this).scrollTop()&&h>b&&b>0&&o.scrollTop(i.offset().top)}i.parent().add(r.parent()).scrollLeft(a(this).scrollLeft())}),n=((c.hasWidget(e.table,"filter")?"filterEnd":"tablesorter-initialized updateComplete")+" sortEnd pagerComplete columnUpdate ").split(" ").join(q+" "),t.off(q).on("sortEnd filterEnd".split(" ").join(q+" "),function(a){"sortEnd"===a.type&&f.scroller_upAfterSort?m.animate({scrollTop:0},"fast"):f.scroller_fixedColumns&&setTimeout(function(){m.scrollTop(f.scroller_saved[1]).scrollLeft(f.scroller_saved[0]),p.updateFixed(e,f)},0)}).on("setFixedColumnSize"+q,function(a,b){var c=f.scroller_$container;"undefined"==typeof b||isNaN(b)||(f.scroller_fixedColumns=parseInt(b,10)),p.removeFixed(e,f),b=f.scroller_fixedColumns,b>0&&b0&&p.updateFixed(e,f),p.resize(e,f))}),o.off("resize resizeEnd ".split(" ").join(q+" ")).on("resize"+q,c.window_resize).on("resizeEnd"+q,function(){o.off("resize"+q,c.window_resize),p.resize(e,f),o.on("resize"+q,c.window_resize),m.trigger("scroll"+q)}),e.isScrolling=!0,p.updateFixed(e,f),e.table.hasInitialized&&e.isScrolling&&setTimeout(function(){c.scroller.resize(e,f)},50)},resize:function(e,f){if(!f.scroller_isBusy){var g,h,i,j,k,l,m=c.scroller,n=f.scroller_$container,o=e.$table,p=o.parent(),q=f.scroller_$header,r=f.scroller_$footer,s=e.namespace.slice(1)+"tsscroller",t=a("div."+d.scrollerWrap+'[id!="'+s+'"]').addClass(d.scrollerHideElement),u='';for(f.scroller_calcWidths=[],m.removeFixed(e,f),n.find("."+d.scrollerSpacerRow).remove(),n.find("."+c.css.colgroup).remove(),o.find("."+d.scrollerHideElement).removeClass(d.scrollerHideElement),h=parseInt(o.css("border-left-width"),10),j=e.$headerIndexed,g=0;g',f.scroller_calcWidths[g]=i;u+="",e.$tbodies.eq(0).prepend(u),q.children("thead").append(u),r.children("tfoot").append(u),c.fixColumnWidth(e.table),u=e.$table.children("colgroup")[0].outerHTML,q.prepend(u),r.prepend(u),l=p.parent().innerWidth()-(m.hasScrollBar(p)?f.scroller_barSetWidth:0),p.width(l),l=(m.hasScrollBar(p)?f.scroller_barSetWidth:0)+h,i=p.innerWidth()-l,q.parent().add(r.parent()).width(i),p.width(i+l),o.children("thead").addClass(d.scrollerHideElement),m.updateFixed(e,f),t.removeClass(d.scrollerHideElement),p.scrollTop(f.scroller_saved[1]),f.scroller_$container.find("."+d.scrollerFixed).find("."+d.scrollerTable).scrollTop(f.scroller_saved[1]),setTimeout(function(){e.$table.trigger("resizableUpdate")},100)}},setupFixed:function(a,b){var e,f,g,h,i,j,k,l=a.$table,m=b.scroller_$container,n=b.scroller_fixedColumns;for(j=m.addClass(d.scrollerHasFix).clone().addClass(d.scrollerFixed).removeClass(d.scrollerWrap).attr("id",""),b.scroller_addFixedOverlay&&j.append('
'),k=j.find("."+d.scrollerTable),k.children("table").addClass(a.namespace.slice(1)+"_extra_table").attr("id","").children("thead, tfoot").remove(),b.scroller_$fixedColumns=j,l.hasClass(d.scrollerRtl)&&j.addClass(d.scrollerRtl),g=j.find("tr"),h=g.length,e=0;h>e;e++)g.eq(e).children(":gt("+(n-1)+")").remove();if(j.addClass(d.scrollerHideElement).prependTo(m),a.$table.hasClass("hasFilters"))for(g=j.find("."+d.filter).not("."+d.filterDisabled).prop("disabled",!1),c.filter.bindSearch(l,j.find("."+d.filter)),g=m.children("."+d.scrollerHeader).find("."+d.filter),h=g.length,e=0;h>e;e++)g.eq(e).hasClass(d.filterDisabled||"disabled")||g.eq(e).prop("disabled",n>e);for(a.$table.add("."+d.scrollerFooter+" table").children("thead").children("tr."+d.headerRow).children().attr("tabindex",-1),g=b.scroller_$header.add(j.find("."+d.scrollerTable+" table")).children("thead").children("tr."+d.headerRow),h=g.length,e=0;h>e;e++)for(i=g.eq(e).children(),f=0;ff?-1:0);c.bindEvents(a.table,j.find("."+d.header)),c.scroller.bindFixedColumnEvents(a,b),(c.scroller.isFirefox||c.scroller.isOldIE)&&k.wrap('
')},bindFixedColumnEvents:function(b,e){var f=c.scroller,g=b.namespace+"tsscrollerFixed",h="scroll"+g,i=e.scroller_$fixedColumns.find("."+d.scrollerTable),j=!0,k=!0;b.$table.parent().off(h).on(h,function(){if(!e.scroller_isBusy&&!e.scroller_isBusy&&(j||!f.isFirefox&&!f.isIE)){k=!1;var b=a(this);i[0].scrollTop=e.scroller_saved[1]=b.scrollTop(),e.scroller_saved[0]=b.scrollLeft(),setTimeout(function(){k=!0},20)}}),i.off(h).on(h,function(){if(!e.scroller_isBusy&&(k||!f.isFirefox&&!f.isIE)){j=!1;var c=a(this);b.$table.parent()[0].scrollTop=e.scroller_saved[1]=c.scrollTop(),setTimeout(function(){j=!0},20)}}).scroll(),""!==e.scroller_rowHighlight&&(h="mouseover mouseleave ".split(" ").join(g+" "),b.$table.off(h,"tbody > tr").on(h,"tbody > tr",function(a){var c=b.$table.children("tbody").children("tr").index(this);i.children("table").children("tbody").children("tr").eq(c).add(this).toggleClass(e.scroller_rowHighlight,"mouseover"===a.type)}),i.find("table").off(h,"tbody > tr").on(h,"tbody > tr",function(a){var c=i.children("table").children("tbody").children("tr"),d=c.index(this);b.$table.children("tbody").children("tr").eq(d).add(this).toggleClass(e.scroller_rowHighlight,"mouseover"===a.type)}))},adjustWidth:function(a,b,e,f,g){var h=b.scroller_$container;h.children("."+d.scrollerTable).css(g?"right":"left",e),h.children("."+d.scrollerHeader+", ."+d.scrollerFooter).css(g?"right":"left",e+(g&&c.scroller.isSafari?f:0))},updateFixed:function(b,e){var f,g,h=e.scroller_$container,i=e.scroller_$header,j=e.scroller_$footer,k=b.$table,l=k.parent(),m=e.scroller_barSetWidth,n=k.hasClass(d.scrollerRtl);if(0===e.scroller_fixedColumns)return e.scroller_isBusy=!1,c.scroller.removeFixed(b,e),f=h.width(),l.width(f),g=c.scroller.hasScrollBar(l)?m:0,void i.parent().add(j.parent()).width(f-g);if(b.isScrolling){e.scroller_isBusy=!0,h.find("."+d.scrollerFixed).length||c.scroller.setupFixed(b,e);var o,p,q,r,s,t,u,v=e.scroller_$container.children("."+d.scrollerTable).children("table").children("tbody"),w=e.scroller_$header.children("thead").children("."+d.headerRow),x=e.scroller_$fixedColumns.addClass(d.scrollerHideElement),y=x.find("."+d.scrollerTable).children("table"),z=y.children("tbody"),A=c.scroller,B=e.scroller_fixedColumns,C=k.find("tbody td"),D=parseInt(C.css("border-right-width"),10)||1,E=parseInt((C.css("border-spacing")||"").split(/\s/)[0],10)/2||0,F=parseInt(k.css("padding-left"),10)+parseInt(k.css("padding-right"),10)-D,G=e.scroller_calcWidths;for(c.scroller.removeFixed(b,e,!1),o=0;B>o;o++)F+=G[o]+E;for(F=F+2*D-E,A.setWidth(x.add(x.children()),F),A.setWidth(x.children().children("table"),F),p=0;pq;q++)s=a(w[q].outerHTML),s.children("td, th").slice(B).remove(),t.append(s);c.processTbody(y,t,!1)}for(g=c.scroller.hasScrollBar(l)?m:0,(A.isFirefox||A.isOldIE)&&y.css("width",F).parent().css("width",F+g),x.removeClass(d.scrollerHideElement),o=0;B>o;o++)h.children("div").children("table").find("th:nth-child("+(o+1)+"), td:nth-child("+(o+1)+")").addClass(d.scrollerHideColumn);F-=D,f=l.parent().innerWidth()-F,l.width(f),h.children("."+d.scrollerTable).css(n?"right":"left",F),h.children("."+d.scrollerHeader+", ."+d.scrollerFooter).css(n?"right":"left",F+(n&&c.scroller.isSafari?g:0)),i.parent().add(j.parent()).width(f-g),f=c.scroller.hasScrollBar(l,!0),g=f?m:0,!x.find("."+d.scrollerBarSpacer).length&&f?(C=a('
').css("height",g+"px"),x.find("."+d.scrollerTable).append(C)):f||x.find("."+d.scrollerBarSpacer).remove(),c.scroller.updateRowHeight(b,e),x.height(h.height()),x.removeClass(d.scrollerHideElement),e.scroller_isBusy=!1}},fixHeight:function(a,b){var c,e,f,g,h,i=d.scrollerAddedHeight,j=a.length;for(c=0;j>c;c++)g=a.eq(c),h=b.eq(c),e=g.height(),f=h.height(),e>f?h.addClass(i).height(e):f>e&&g.addClass(i).height(f)},updateRowHeight:function(a,b){var e,f,g=b.scroller_$fixedColumns;b.scroller_$container.find("."+d.scrollerAddedHeight).removeClass(d.scrollerAddedHeight).height(""),e=b.scroller_$header.children("thead").children("tr"),f=g.children("."+d.scrollerHeader).children("table").children("thead").children("tr"),c.scroller.fixHeight(e,f),e=b.scroller_$footer.children("tfoot").children("tr"),f=g.children("."+d.scrollerFooter).children("table").children("tfoot").children("tr"),c.scroller.fixHeight(e,f),(c.scroller.isFirefox||c.scroller.isOldIE)&&(g=g.find("."+d.scrollerHack)),e=a.$table.children("tbody").children("tr"),f=g.children("."+d.scrollerTable).children("table").children("tbody").children("tr"),c.scroller.fixHeight(e,f)},removeFixed:function(a,b,c){var e=a.$table,f=b.scroller_$container,g=e.hasClass(d.scrollerRtl);(c||"undefined"==typeof c)&&f.find("."+d.scrollerFixed).remove(),f.find("."+d.scrollerHideColumn).removeClass(d.scrollerHideColumn),f.children(":not(."+d.scrollerFixed+")").css(g?"right":"left",0)},remove:function(c,e){var f=e.scroller_$container,g=c.namespace+"tsscroller";c.$table.off(g),a(b).off(g),f&&(c.$table.insertBefore(f).find("thead").removeClass(d.scrollerHideElement).children("tr."+d.headerRow).children().attr("tabindex",0).end().find("."+d.filterRow).removeClass(d.scrollerHideElement+" "+d.filterRowHide),c.$table.find("."+d.filter).not("."+d.filterDisabled).prop("disabled",!1),f.remove(),c.isScrolling=!1)}}}(jQuery,window); \ No newline at end of file diff --git a/js/widgets/widget-scroller.js b/js/widgets/widget-scroller.js index f43ea8d3..e0dc84c7 100644 --- a/js/widgets/widget-scroller.js +++ b/js/widgets/widget-scroller.js @@ -277,9 +277,9 @@ .scrollLeft( $( this ).scrollLeft() ); }); - // resize/update events - events = ( ( ts.hasWidget( c.table, 'filter' ) ? 'filterEnd' : 'tablesorter-initialized' ) + - ' updateComplete pagerComplete columnUpdate ' ).split( ' ' ).join( namespace + ' ' ); + // resize/update events - filterEnd fires after "tablesorter-initialized" and "updateComplete" + events = ( ( ts.hasWidget( c.table, 'filter' ) ? 'filterEnd' : 'tablesorter-initialized updateComplete' ) + + ' sortEnd pagerComplete columnUpdate ' ).split( ' ' ).join( namespace + ' ' ); $table .off( namespace ) @@ -295,7 +295,7 @@ $tableWrap .scrollTop( wo.scroller_saved[1] ) .scrollLeft( wo.scroller_saved[0] ); - tsScroller.updateFixed( c, wo, false ); + tsScroller.updateFixed( c, wo ); }, 0 ); } }) @@ -321,7 +321,7 @@ return; } if ( wo.scroller_fixedColumns > 0 ) { - tsScroller.updateFixed( c, wo, false ); + tsScroller.updateFixed( c, wo ); } // adjust column sizes after an update tsScroller.resize( c, wo ); @@ -807,6 +807,7 @@ fixHeight : function( $rows, $fixedRows ) { var index, heightRow, heightFixed, $r, $f, + addedHt = tscss.scrollerAddedHeight, len = $rows.length; for ( index = 0; index < len; index++ ) { $r = $rows.eq( index ); @@ -814,9 +815,9 @@ heightRow = $r.height(); heightFixed = $f.height(); if ( heightRow > heightFixed ) { - $f.addClass( tscss.scrollerAddedHeight ).height( heightRow ); + $f.addClass( addedHt ).height( heightRow ); } else if ( heightRow < heightFixed ) { - $r.addClass( tscss.scrollerAddedHeight ).height( heightFixed ); + $r.addClass( addedHt ).height( heightFixed ); } } },