mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
2 lines
2.6 KiB
JavaScript
2 lines
2.6 KiB
JavaScript
/*! Widget: cssStickyHeaders - updated 6/16/2018 (v2.30.6) */
|
|
!function(e,t){"use strict";function s(a,d){var o,c,n=a.$table,r=e(d.cssStickyHeaders_attachTo),l="ActiveXObject"in t||t.navigator.userAgent.indexOf("Edge")>-1,p=a.namespace+"cssstickyheader ",h=n.children("thead"),f=n.children("caption"),g=r.length?r:e(t),k=n.parent().closest("table."+i.css.table),y=k.length&&i.hasWidget(k[0],"cssStickyHeaders")?k.children("thead"):[],H=parseInt(n.css("border-top-width"),10)||0,u=n.height(),S=d.cssStickyHeaders_addCaption,b=!1,m=!1,_=function(e,t){var s=0===t?"":"translate(0px,"+t+"px)";e.css({transform:s,"-ms-transform":s,"-webkit-transform":s})};f.length&&(f.hide(),m=n.height()===u,f.show(),o=n.offset().top,_(f,20),b=n.offset().top!==o,_(f,0)),g.unbind("scroll resize ".split(" ").join(p).replace(/\s+/g," ")).bind("scroll resize ".split(" ").join(p),function(){d=a.widgetOptions,b&&(_(f,0),c=n.offset().top),g.scrollTop()<f.outerHeight(!0)&&(u=n.height());var e=r.length?r.offset().top:g.scrollTop(),t=(f.outerHeight(!0)||0)+(parseInt(n.css("padding-top"),10)||0)+(parseInt(n.css("border-spacing"),10)||0),s=u+(m&&d.cssStickyHeaders_addCaption?t:0)-h.height()-(n.children("tfoot").height()||0)-(d.cssStickyHeaders_addCaption?t:m?0:t),i=y.length?y.height():0,o=y.length?l?k.data("cssStickyHeaderBottom")+i:y.offset().top+i-g.scrollTop():0,p=b?c:n.offset().top,C=e-(m?p-(d.cssStickyHeaders_addCaption?t:0):p)+o+H+(d.cssStickyHeaders_offset||0)-(d.cssStickyHeaders_addCaption?m?t:0:t),T=C>0&&C<=s?C:0,v=l?h.children().children():h;l&&a.$table.data("cssStickyHeaderBottom",(y.length?i:0)-(d.cssStickyHeaders_addCaption?t:0)),d.cssStickyHeaders_addCaption&&(v=v.add(f)),S!==d.cssStickyHeaders_addCaption&&((S=d.cssStickyHeaders_addCaption)||_(f,0)),_(v,T)}),n.unbind("filterEnd updateComplete ".split(" ").join(p).replace(/\s+/g," ")).bind("filterEnd"+p,function(){d.cssStickyHeaders_filteredToTop&&t.scrollTo(0,n.position().top)}).bind("updateComplete"+p,function(){s(a,a.widgetOptions)})}var i=e.tablesorter;i.addWidget({id:"cssStickyHeaders",priority:10,options:{cssStickyHeaders_offset:0,cssStickyHeaders_addCaption:!1,cssStickyHeaders_attachTo:null,cssStickyHeaders_filteredToTop:!0},init:function(e,t,i,a){s(i,a)},remove:function(s,i,a,d){if(!d){var o=i.namespace+"cssstickyheader ";e(t).unbind("scroll resize ".split(" ").join(o).replace(/\s+/g," ")),i.$table.unbind("filterEnd scroll resize updateComplete ".split(" ").join(o).replace(/\s+/g," ")).add(i.$table.children("thead").children().children()).children("thead, caption").css({transform:"","-ms-transform":"","-webkit-transform":""})}}})}(jQuery,window); |