tablesorter/dist/js/widgets/widget-cssStickyHeaders.min.js
Rob Garrison e3227a7af0 v2.28.11
2017-05-24 18:53:44 -05:00

2 lines
2.4 KiB
JavaScript

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