tablesorter/dist/js/widgets/widget-cssStickyHeaders.min.js
Mottie 263aa97e66 Build: add combined file with selected widgets & parsers. See #855
NOTE: the core js/jquery.tablesorter.js file is no longer UMD wrapped!; this is done by the build process now

Updated various parser & widget comments
2015-03-28 15:03:50 -05:00

2 lines
2.4 KiB
JavaScript

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