Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

floatthead

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

floatthead - npm Package Compare versions

Comparing version 2.0.3 to 2.1.0

CODE_OF_CONDUCT.md

16

CHANGELOG.md

@@ -0,1 +1,17 @@

### 2.1.0
- #402 HUGE performance improvement if plugin used on multiple tables on the same page. Over **100x faster** startup time
on a page with 39 tables. Big props to [@ineuwirth](https://github.com/ineuwirth) for finding this one!
On a side note, the last release was exactly one year ago. I didn't do this on purpose :)
new features:
- #404 - Adding a 'floatContainerOverflow' option to govern floatContainer CSS
- #402 - performance improvement with many tables on the same page
bug fixes:
- #391 - Fix printing on firefox
- #399 - Set header size on reflow
- #361 - Works better on iPad Retina
### 2.0.2

@@ -2,0 +18,0 @@ - fix issue with horizontal scrollbars + reflow breaking header position #345, #355

16

dist/jquery.floatThead.js

@@ -52,3 +52,3 @@ /** @preserve jQuery.floatThead 2.0.3 - http://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2017 Misha Koryak **/

var util = window._ || (function underscoreShim(){
var util = (function underscoreShim(){
var that = {};

@@ -137,4 +137,6 @@ var hasOwnProperty = Object.prototype.hasOwnProperty, isThings = ['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'];

var $window = $(window);
var buggyMatchMedia = isFF && window.matchMedia; // TODO remove when fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=774398
if(!window.matchMedia) {
if(!window.matchMedia || buggyMatchMedia) {
var _beforePrint = window.onbeforeprint;

@@ -153,3 +155,3 @@ var _afterPrint = window.onafterprint;

/**
* @param debounceMs
* @param eventName
* @param cb

@@ -243,3 +245,3 @@ */

for(var i=0; i < $fthCells.length; i++){
w += $fthCells.get(i).offsetWidth;
w += getOffsetWidth($fthCells.get(i));
}

@@ -952,3 +954,3 @@ return w;

calculateFloatContainerPos = calculateFloatContainerPosFn();
repositionFloatContainer(calculateFloatContainerPos('reflow'), true);
repositionFloatContainer(calculateFloatContainerPos('reflow'), true, true);
}, 1);

@@ -972,4 +974,4 @@

var matchMediaPrint;
if(window.matchMedia && window.matchMedia('print').addListener){
var matchMediaPrint = null;
if(window.matchMedia && window.matchMedia('print').addListener && !buggyMatchMedia){
matchMediaPrint = window.matchMedia("print");

@@ -976,0 +978,0 @@ matchMediaPrint.addListener(printEvent);

/** @preserve jQuery.floatThead 2.0.3 - http://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2017 Misha Koryak **/
!function(t){function e(t,e){if(8==f){var o=v.width(),n=s.debounce(function(){var t=v.width();o!=t&&(o=t,e())},1);v.on(t,n)}else v.on(t,s.debounce(e,1))}function o(e){var o=e[0],n=o.parentElement;do{var r=window.getComputedStyle(n).getPropertyValue("overflow");if("visible"!=r)break}while(n=n.parentElement);return t(n==document.body?[]:n)}function n(t){window&&window.console&&window.console.error&&window.console.error("jQuery.floatThead: "+t)}function r(t){var e=t.getBoundingClientRect();return e.width||e.right-e.left}function a(){var t=document.createElement("scrolltester");t.style.cssText="width:100px;height:100px;overflow:scroll!important;position:absolute;top:-9999px;display:block",document.body.appendChild(t);var e=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),e}function i(t){if(t.dataTableSettings)for(var e=0;e<t.dataTableSettings.length;e++){var o=t.dataTableSettings[e].nTable;if(t[0]==o)return!0}return!1}function l(t,e,o){var n=o?"outerWidth":"width";if(p&&t.css("max-width")){var r=0;o&&(r+=parseInt(t.css("borderLeft"),10),r+=parseInt(t.css("borderRight"),10));for(var a=0;a<e.length;a++)r+=e.get(a).offsetWidth;return r}return t[n]()}t.floatThead=t.floatThead||{},t.floatThead.defaults={headerCellSelector:"tr:visible:first>*:visible",zIndex:1001,position:"auto",top:0,bottom:0,scrollContainer:function(){return t([])},responsiveContainer:function(){return t([])},getSizingRow:function(t){return t.find("tbody tr:visible:first>*:visible")},floatTableClass:"floatThead-table",floatWrapperClass:"floatThead-wrapper",floatContainerClass:"floatThead-container",copyTableClass:!0,autoReflow:!1,debug:!1,support:{bootstrap:!0,datatables:!0,jqueryUI:!0,perfectScrollbar:!0}};var s=window._||function(){var e={},o=Object.prototype.hasOwnProperty,n=["Arguments","Function","String","Number","Date","RegExp"];e.has=function(t,e){return o.call(t,e)},e.keys=Object.keys||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var o=[];for(var n in t)e.has(t,n)&&o.push(n);return o};var r=0;return e.uniqueId=function(t){var e=++r+"";return t?t+e:e},t.each(n,function(){var t=this;e["is"+t]=function(e){return Object.prototype.toString.call(e)=="[object "+t+"]"}}),e.debounce=function(t,e,o){var n,r,a,i,l;return function(){a=this,r=arguments,i=new Date;var s=function(){var d=new Date-i;e>d?n=setTimeout(s,e-d):(n=null,o||(l=t.apply(a,r)))},d=o&&!n;return n||(n=setTimeout(s,e)),d&&(l=t.apply(a,r)),l}},e}(),d="undefined"!=typeof MutationObserver,f=function(){for(var t=3,e=document.createElement("b"),o=e.all||[];t=1+t,e.innerHTML="<!--[if gt IE "+t+"]><i><![endif]-->",o[0];);return t>4?t:document.documentMode}(),c=/Gecko\//.test(navigator.userAgent),u=/WebKit\//.test(navigator.userAgent);f||c||u||(f=11);var p=function(){if(u){var e=t("<div>").css("width",0).append(t("<table>").css("max-width","100%").append(t("<tr>").append(t("<th>").append(t("<div>").css("min-width",100).text("X")))));t("body").append(e);var o=0==e.find("table").width();return e.remove(),o}return!1},h=!c&&!f,v=t(window);if(!window.matchMedia){var b=window.onbeforeprint,w=window.onafterprint;window.onbeforeprint=function(){b&&b(),v.triggerHandler("beforeprint")},window.onafterprint=function(){w&&w(),v.triggerHandler("afterprint")}}t.fn.floatThead=function(c){if(c=c||{},8>f)return this;var b=null;if(s.isFunction(p)&&(p=p()),s.isString(c)){var w=c,g=Array.prototype.slice.call(arguments,1),m=this;return this.filter("table").each(function(){var e=t(this),o=e.data("floatThead-lazy");o&&e.floatThead(o);var n=e.data("floatThead-attached");if(n&&s.isFunction(n[w])){var r=n[w].apply(this,g);void 0!==r&&(m=r)}}),m}var y=t.extend({},t.floatThead.defaults||{},c);if(t.each(c,function(e){e in t.floatThead.defaults||!y.debug||n("Used ["+e+"] key to init plugin, but that param is not an option for the plugin. Valid options are: "+s.keys(t.floatThead.defaults).join(", "))}),y.debug){var T=t.fn.jquery.split(".");1==parseInt(T[0],10)&&parseInt(T[1],10)<=7&&n("jQuery version "+t.fn.jquery+" detected! This plugin supports 1.8 or better, or 1.7.x with jQuery UI 1.8.24 -> http://jqueryui.com/resources/download/jquery-ui-1.8.24.zip")}return this.filter(":not(."+y.floatTableClass+")").each(function(){function c(t){return t+".fth-"+R+".floatTHead"}function p(){var e=0;if(k.children("tr:visible").each(function(){e+=t(this).outerHeight(!0)}),"collapse"==M.css("border-collapse")){var o=parseInt(M.css("border-top-width"),10),n=parseInt(M.find("thead tr:first").find(">*:first").css("border-top-width"),10);o>n&&(e-=o/2)}st.outerHeight(e),dt.outerHeight(e)}function w(){var t=l(M,ut,!0),e=V?P:U,o=e.width()||t,n="hidden"!=e.css("overflow-y")?o-N.vertical:o;if(at.width(n),G){var r=100*t/n;tt.css("width",r+"%")}else tt.outerWidth(t)}function g(){D=(s.isFunction(y.top)?y.top(M):y.top)||0,O=(s.isFunction(y.bottom)?y.bottom(M):y.bottom)||0}function m(){var e,o=k.find(y.headerCellSelector);if(nt?e=ot.find("col").length:(e=0,o.each(function(){e+=parseInt(t(this).attr("colspan")||1,10)})),e!=Q){Q=e;for(var n,r=[],a=[],i=[],l=0;e>l;l++)n=o.eq(l).text(),r.push('<th class="floatThead-col" aria-label="'+n+'"/>'),a.push("<col/>"),i.push(t("<fthtd>").css({display:"table-cell",height:0,width:"auto"}));a=a.join(""),r=r.join(""),h&&(rt.empty(),rt.append(i),ut=rt.find("fthtd")),st.html(r),dt=st.find("th"),nt||ot.html(a),ft=ot.find("col"),et.html(a),ct=et.find("col")}return e}function T(){if(!F){if(F=!0,X){var t=l(M,ut,!0),e=J.width();t>e&&M.css("minWidth",t)}M.css(vt),tt.css(vt),tt.append(k),E.before(lt),p()}}function C(){F&&(F=!1,X&&M.width(wt),lt.detach(),M.prepend(k),M.css(bt),tt.css(bt),M.css("minWidth",gt),M.css("minWidth",l(M,ut)))}function x(t){mt!=t&&(mt=t,M.triggerHandler("floatThead",[t,at]))}function j(t){X!=t&&(X=t,at.css({position:X?"absolute":"fixed"}))}function S(t,e,o,n){return h?o:n?y.getSizingRow(t,e,o):e}function z(){var t,e=m();return function(){var o=at.scrollLeft();ft=ot.find("col");var n=S(M,ft,ut,f);if(n.length==e&&e>0){if(!nt)for(t=0;e>t;t++)ft.eq(t).css("width","");C();var a=[];for(t=0;e>t;t++)a[t]=r(n.get(t));for(t=0;e>t;t++)ct.eq(t).width(a[t]),ft.eq(t).width(a[t]);T()}else tt.append(k),M.css(bt),tt.css(bt),p();at.scrollLeft(o),M.triggerHandler("reflowed",[at])}}function I(t){var e=U.css("border-"+t+"-width"),o=0;return e&&~e.indexOf("px")&&(o=parseInt(e,10)),o}function L(){return"auto"==P.css("overflow-x")}function W(){var t,e=U.scrollTop(),o=0,n=B?Y.outerHeight(!0):0,r=K?n:-n,a=at.height(),i=M.offset(),l=0,s=0;if(G){var d=U.offset();o=i.top-d.top+e,B&&K&&(o+=n),l=I("left"),s=I("top"),o-=s}else t=i.top-D-a+O+N.horizontal;var f=v.scrollTop(),c=v.scrollLeft(),p=function(){return(L()?P:U).scrollLeft()||0},h=p();return function(d){V=L();var b=M[0].offsetWidth<=0&&M[0].offsetHeight<=0;if(!b&&it)return it=!1,setTimeout(function(){M.triggerHandler("reflow")},1),null;if(b&&(it=!0,!X))return null;if("windowScroll"==d)f=v.scrollTop(),c=v.scrollLeft();else if("containerScroll"==d)if(P.length){if(!V)return;h=P.scrollLeft()}else e=U.scrollTop(),h=U.scrollLeft();else"init"!=d&&(f=v.scrollTop(),c=v.scrollLeft(),e=U.scrollTop(),h=p());if(!u||!(0>f||0>c)){if(Z)j("windowScrollDone"==d?!0:!1);else if("windowScrollDone"==d)return null;i=M.offset(),B&&K&&(i.top+=n);var w,g,m=M.outerHeight();if(G&&X){if(o>=e){var y=o-e+s;w=y>0?y:0,x(!1)}else w=_?s:e,x(!0);g=l}else!G&&X?(f>t+m+r?w=m-a+r:i.top>=f+D?(w=0,C(),x(!1)):(w=D+f-i.top+o+(K?n:0),T(),x(!0)),g=h):G&&!X?(o>e||e-o>m?(w=i.top-f,C(),x(!1)):(w=i.top+e-f-o,T(),x(!0)),g=i.left+h-c):G||X||(f>t+m+r?w=m+D-f+t+r:i.top>f+D?(w=i.top-f,T(),x(!1)):(w=D,x(!0)),g=i.left+h-c);return{top:Math.round(w),left:Math.round(g)}}}}function H(){var t=null,e=null,o=null;return function(n,r,a){if(null!=n&&(t!=n.top||e!=n.left)){if(8===f)at.css({top:n.top,left:n.left});else{var i="translateX("+n.left+"px) translateY("+n.top+"px)";at.css({"-webkit-transform":i,"-moz-transform":i,"-ms-transform":i,"-o-transform":i,transform:i,top:0,left:0})}t=n.top,e=n.left}r&&w(),a&&p();var l=(V?P:U).scrollLeft();X&&o==l||(at.scrollLeft(l),o=l)}}function q(){if(U.length)if(y.support&&y.support.perfectScrollbar&&U.data().perfectScrollbar)N={horizontal:0,vertical:0};else{if("scroll"==U.css("overflow-x"))N.horizontal=A;else{var t=U.width(),e=l(M,ut),o=r>n?A:0;N.horizontal=e>t-o?A:0}if("scroll"==U.css("overflow-y"))N.vertical=A;else{var n=U.height(),r=M.height(),a=e>t?A:0;N.vertical=r>n-a?A:0}}}var R=s.uniqueId(),M=t(this);if(M.data("floatThead-attached"))return!0;if(!M.is("table"))throw new Error('jQuery.floatThead must be run on a table element. ex: $("table").floatThead();');d=y.autoReflow&&d;var k=M.children("thead:first"),E=M.children("tbody:first");if(0==k.length||0==E.length)return y.debug&&n(0==k.length?"The thead element is missing.":"The tbody element is missing."),M.data("floatThead-lazy",y),void M.unbind("reflow").one("reflow",function(){M.floatThead(y)});M.data("floatThead-lazy")&&M.unbind("reflow"),M.data("floatThead-lazy",!1);var D,O,F=!0,N={vertical:0,horizontal:0},A=a(),Q=0;y.scrollContainer===!0&&(y.scrollContainer=o);var U=y.scrollContainer(M)||t([]),G=U.length>0,P=G?t([]):y.responsiveContainer(M)||t([]),V=L(),X=null;"auto"==y.position?X=null:"fixed"==y.position?X=!1:"absolute"==y.position?X=!0:y.debug&&n('Invalid value given to "position" option, valid is "fixed", "absolute" and "auto". You passed: ',y.position),null==X&&(X=G);var Y=M.find("caption"),B=1==Y.length;if(B)var K="top"===(Y.css("caption-side")||Y.attr("align")||"top");var $=t("<fthfoot>").css({display:"table-footer-group","border-spacing":0,height:0,"border-collapse":"collapse",visibility:"hidden"}),_=!1,J=t([]),Z=9>=f&&!G&&X,tt=t("<table/>"),et=t("<colgroup/>"),ot=M.children("colgroup:first"),nt=!0;0==ot.length&&(ot=t("<colgroup/>"),nt=!1);var rt=t("<fthtr>").css({display:"table-row","border-spacing":0,height:0,"border-collapse":"collapse"}),at=t("<div>").css("overflow","hidden").attr("aria-hidden","true"),it=!1,lt=t("<thead/>"),st=t('<tr class="size-row" aria-hidden="true"/>'),dt=t([]),ft=t([]),ct=t([]),ut=t([]);lt.append(st),M.prepend(ot),h&&($.append(rt),M.append($)),tt.append(et),at.append(tt),y.copyTableClass&&tt.attr("class",M.attr("class")),tt.attr({cellpadding:M.attr("cellpadding"),cellspacing:M.attr("cellspacing"),border:M.attr("border")});var pt=M.css("display");if(tt.css({borderCollapse:M.css("borderCollapse"),border:M.css("border"),display:pt}),G||tt.css("width","auto"),"none"==pt&&(it=!0),tt.addClass(y.floatTableClass).css({margin:0,"border-bottom-width":0}),X){var ht=function(e,o){var n=e.css("position"),r="relative"==n||"absolute"==n,a=e;if(!r||o){var i={paddingLeft:e.css("paddingLeft"),paddingRight:e.css("paddingRight")};at.css(i),a=e.data("floatThead-containerWrap")||e.wrap(t("<div>").addClass(y.floatWrapperClass).css({position:"relative",clear:"both"})).parent(),e.data("floatThead-containerWrap",a),_=!0}return a};G?(J=ht(U,!0),J.prepend(at)):(J=ht(M),M.before(at))}else M.before(at);at.css({position:X?"absolute":"fixed",marginTop:0,top:X?0:"auto",zIndex:y.zIndex,willChange:"transform"}),at.addClass(y.floatContainerClass),g();var vt={"table-layout":"fixed"},bt={"table-layout":M.css("tableLayout")||"auto"},wt=M[0].style.width||"",gt=M.css("minWidth")||"",mt=!1;q();var yt,Tt=function(){(yt=z())()};Tt();var Ct=W(),xt=H();xt(Ct("init"),!0);var jt,St=s.debounce(function(){xt(Ct("windowScrollDone"),!1)},1),zt=function(){xt(Ct("windowScroll"),!1),Z&&St()},It=function(){xt(Ct("containerScroll"),!1)},Lt=function(){M.is(":hidden")||(g(),q(),Tt(),Ct=W(),(xt=H())(Ct("resize"),!0,!0))},Wt=s.debounce(function(){M.is(":hidden")||(q(),g(),Tt(),Ct=W(),xt(Ct("reflow"),!0))},1),Ht=function(){C()},qt=function(){T()},Rt=function(t){t.matches?Ht():qt()};if(window.matchMedia&&window.matchMedia("print").addListener?(jt=window.matchMedia("print"),jt.addListener(Rt)):(v.on("beforeprint",Ht),v.on("afterprint",qt)),G?X?U.on(c("scroll"),It):(U.on(c("scroll"),It),v.on(c("scroll"),zt)):(P.on(c("scroll"),It),v.on(c("scroll"),zt)),v.on(c("load"),Wt),e(c("resize"),Lt),M.on("reflow",Wt),y.support&&y.support.datatables&&i(M)&&M.on("filter",Wt).on("sort",Wt).on("page",Wt),y.support&&y.support.bootstrap&&v.on(c("shown.bs.tab"),Wt),y.support&&y.support.jqueryUI&&v.on(c("tabsactivate"),Wt),d){var Mt=null;s.isFunction(y.autoReflow)&&(Mt=y.autoReflow(M,U)),Mt||(Mt=U.length?U[0]:M[0]),b=new MutationObserver(function(t){for(var e=function(t){return t&&t[0]&&("THEAD"==t[0].nodeName||"TD"==t[0].nodeName||"TH"==t[0].nodeName)},o=0;o<t.length;o++)if(!e(t[o].addedNodes)&&!e(t[o].removedNodes)){Wt();break}}),b.observe(Mt,{childList:!0,subtree:!0})}M.data("floatThead-attached",{destroy:function(){var t=".fth-"+R;return C(),M.css(bt),ot.remove(),h&&$.remove(),lt.parent().length&&lt.replaceWith(k),x(!1),d&&(b.disconnect(),b=null),M.off("reflow reflowed"),U.off(t),P.off(t),_&&(U.length?U.unwrap():M.unwrap()),G?U.data("floatThead-containerWrap",!1):M.data("floatThead-containerWrap",!1),M.css("minWidth",gt),at.remove(),M.data("floatThead-attached",!1),v.off(t),jt&&jt.removeListener(Rt),Ht=qt=function(){},function(){return M.floatThead(y)}},reflow:function(){Wt()},setHeaderHeight:function(){p()},getFloatContainer:function(){return at},getRowGroups:function(){return F?at.find(">table>thead").add(M.children("tbody,tfoot")):M.children("thead,tbody,tfoot")}})}),this}}(function(){var t=window.jQuery;return"undefined"!=typeof module&&module.exports&&!t&&(t=require("jquery")),t}());
!function(t){t.floatThead=t.floatThead||{},t.floatThead.defaults={headerCellSelector:"tr:visible:first>*:visible",zIndex:1001,position:"auto",top:0,bottom:0,scrollContainer:function(e){return t([])},responsiveContainer:function(e){return t([])},getSizingRow:function(t,e,o){return t.find("tbody tr:visible:first>*:visible")},floatTableClass:"floatThead-table",floatWrapperClass:"floatThead-wrapper",floatContainerClass:"floatThead-container",copyTableClass:!0,autoReflow:!1,debug:!1,support:{bootstrap:!0,datatables:!0,jqueryUI:!0,perfectScrollbar:!0}};var e=function(){var e={},o=Object.prototype.hasOwnProperty;e.has=function(t,e){return o.call(t,e)},e.keys=Object.keys||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var o=[];for(var r in t)e.has(t,r)&&o.push(r);return o};var r=0;return e.uniqueId=function(t){var e=++r+"";return t?t+e:e},t.each(["Arguments","Function","String","Number","Date","RegExp"],function(){var t=this;e["is"+t]=function(e){return Object.prototype.toString.call(e)=="[object "+t+"]"}}),e.debounce=function(t,e,o){var r,n,a,i,l;return function(){a=this,n=arguments,i=new Date;var s=function(){var d=new Date-i;d<e?r=setTimeout(s,e-d):(r=null,o||(l=t.apply(a,n)))},d=o&&!r;return r||(r=setTimeout(s,e)),d&&(l=t.apply(a,n)),l}},e}(),o="undefined"!=typeof MutationObserver,r=function(){for(var t=3,e=document.createElement("b"),o=e.all||[];t=1+t,e.innerHTML="\x3c!--[if gt IE "+t+"]><i><![endif]--\x3e",o[0];);return 4<t?t:document.documentMode}(),n=/Gecko\//.test(navigator.userAgent),a=/WebKit\//.test(navigator.userAgent);r||n||a||(r=11);var i=function(){if(a){var e=t("<div>").css("width",0).append(t("<table>").css("max-width","100%").append(t("<tr>").append(t("<th>").append(t("<div>").css("min-width",100).text("X")))));t("body").append(e);var o=0==e.find("table").width();return e.remove(),o}return!1},l=!n&&!r,s=t(window),d=n&&window.matchMedia;if(!window.matchMedia||d){var f=window.onbeforeprint,c=window.onafterprint;window.onbeforeprint=function(){f&&f(),s.triggerHandler("beforeprint")},window.onafterprint=function(){c&&c(),s.triggerHandler("afterprint")}}function u(e){var o=e[0].parentElement;do{if("visible"!=window.getComputedStyle(o).getPropertyValue("overflow"))break}while(o=o.parentElement);return o==document.body?t([]):t(o)}function p(t){window&&window.console&&window.console.error&&window.console.error("jQuery.floatThead: "+t)}function h(t){var e=t.getBoundingClientRect();return e.width||e.right-e.left}function v(t,e,o){var r=o?"outerWidth":"width";if(i&&t.css("max-width")){var n=0;o&&(n+=parseInt(t.css("borderLeft"),10),n+=parseInt(t.css("borderRight"),10));for(var a=0;a<e.length;a++)n+=h(e.get(a));return n}return t[r]()}t.fn.floatThead=function(n){if(n=n||{},r<8)return this;var f=null;if(e.isFunction(i)&&(i=i()),e.isString(n)){var c=n,b=Array.prototype.slice.call(arguments,1),w=this;return this.filter("table").each(function(){var o=t(this),r=o.data("floatThead-lazy");r&&o.floatThead(r);var n=o.data("floatThead-attached");if(n&&e.isFunction(n[c])){var a=n[c].apply(this,b);void 0!==a&&(w=a)}}),w}var g=t.extend({},t.floatThead.defaults||{},n);if(t.each(n,function(o,r){o in t.floatThead.defaults||!g.debug||p("Used ["+o+"] key to init plugin, but that param is not an option for the plugin. Valid options are: "+e.keys(t.floatThead.defaults).join(", "))}),g.debug){var m=t.fn.jquery.split(".");1==parseInt(m[0],10)&&parseInt(m[1],10)<=7&&p("jQuery version "+t.fn.jquery+" detected! This plugin supports 1.8 or better, or 1.7.x with jQuery UI 1.8.24 -> http://jqueryui.com/resources/download/jquery-ui-1.8.24.zip")}return this.filter(":not(."+g.floatTableClass+")").each(function(){var n=e.uniqueId(),i=t(this);if(i.data("floatThead-attached"))return!0;if(!i.is("table"))throw new Error('jQuery.floatThead must be run on a table element. ex: $("table").floatThead();');o=g.autoReflow&&o;var c=i.children("thead:first"),b=i.children("tbody:first");if(0==c.length||0==b.length)return g.debug&&(0==c.length?p("The thead element is missing."):p("The tbody element is missing.")),i.data("floatThead-lazy",g),void i.unbind("reflow").one("reflow",function(){i.floatThead(g)});i.data("floatThead-lazy")&&i.unbind("reflow"),i.data("floatThead-lazy",!1);var w,m,y=!0,T={vertical:0,horizontal:0},C=function(){var t=document.createElement("scrolltester");t.style.cssText="width:100px;height:100px;overflow:scroll!important;position:absolute;top:-9999px;display:block",document.body.appendChild(t);var e=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),e}(),x=0;!0===g.scrollContainer&&(g.scrollContainer=u);var j=g.scrollContainer(i)||t([]),S=j.length>0,z=S?t([]):g.responsiveContainer(i)||t([]),I=ct(),L=null;"auto"==g.position?L=null:"fixed"==g.position?L=!1:"absolute"==g.position?L=!0:g.debug&&p('Invalid value given to "position" option, valid is "fixed", "absolute" and "auto". You passed: ',g.position),null==L&&(L=S);var W=i.find("caption"),H=1==W.length;if(H)var q="top"===(W.css("caption-side")||W.attr("align")||"top");var R=t("<fthfoot>").css({display:"table-footer-group","border-spacing":0,height:0,"border-collapse":"collapse",visibility:"hidden"}),M=!1,k=t([]),E=r<=9&&!S&&L,D=t("<table/>"),O=t("<colgroup/>"),F=i.children("colgroup:first"),N=!0;0==F.length&&(F=t("<colgroup/>"),N=!1);var A=t("<fthtr>").css({display:"table-row","border-spacing":0,height:0,"border-collapse":"collapse"}),Q=t("<div>").css("overflow","hidden").attr("aria-hidden","true"),U=!1,G=t("<thead/>"),P=t('<tr class="size-row" aria-hidden="true"/>'),V=t([]),X=t([]),Y=t([]),B=t([]);G.append(P),i.prepend(F),l&&(R.append(A),i.append(R)),D.append(O),Q.append(D),g.copyTableClass&&D.attr("class",i.attr("class")),D.attr({cellpadding:i.attr("cellpadding"),cellspacing:i.attr("cellspacing"),border:i.attr("border")});var K=i.css("display");if(D.css({borderCollapse:i.css("borderCollapse"),border:i.css("border"),display:K}),S||D.css("width","auto"),"none"==K&&(U=!0),D.addClass(g.floatTableClass).css({margin:0,"border-bottom-width":0}),L){var $=function(e,o){var r=e.css("position"),n=e;if(!("relative"==r||"absolute"==r)||o){var a={paddingLeft:e.css("paddingLeft"),paddingRight:e.css("paddingRight")};Q.css(a),n=e.data("floatThead-containerWrap")||e.wrap(t("<div>").addClass(g.floatWrapperClass).css({position:"relative",clear:"both"})).parent(),e.data("floatThead-containerWrap",n),M=!0}return n};S?(k=$(j,!0)).prepend(Q):(k=$(i),i.before(Q))}else i.before(Q);Q.css({position:L?"absolute":"fixed",marginTop:0,top:L?0:"auto",zIndex:g.zIndex,willChange:"transform"}),Q.addClass(g.floatContainerClass),rt();var J={"table-layout":"fixed"},Z={"table-layout":i.css("tableLayout")||"auto"},_=i[0].style.width||"",tt=i.css("minWidth")||"";function et(t){return t+".fth-"+n+".floatTHead"}function ot(){var e=0;if(c.children("tr:visible").each(function(){e+=t(this).outerHeight(!0)}),"collapse"==i.css("border-collapse")){var o=parseInt(i.css("border-top-width"),10);o>parseInt(i.find("thead tr:first").find(">*:first").css("border-top-width"),10)&&(e-=o/2)}P.outerHeight(e),V.outerHeight(e)}function rt(){w=(e.isFunction(g.top)?g.top(i):g.top)||0,m=(e.isFunction(g.bottom)?g.bottom(i):g.bottom)||0}function nt(){if(!y){if(y=!0,L){var t=v(i,B,!0);t>k.width()&&i.css("minWidth",t)}i.css(J),D.css(J),D.append(c),b.before(G),ot()}}function at(){y&&(y=!1,L&&i.width(_),G.detach(),i.prepend(c),i.css(Z),D.css(Z),i.css("minWidth",tt),i.css("minWidth",v(i,B)))}var it=!1;function lt(t){it!=t&&(it=t,i.triggerHandler("floatThead",[t,Q]))}function st(t){L!=t&&(L=t,Q.css({position:L?"absolute":"fixed"}))}function dt(){var e,o=function(){var e,o=c.find(g.headerCellSelector);if(N?e=F.find("col").length:(e=0,o.each(function(){e+=parseInt(t(this).attr("colspan")||1,10)})),e!=x){x=e;for(var r,n=[],a=[],i=[],s=0;s<e;s++)r=o.eq(s).text(),n.push('<th class="floatThead-col" aria-label="'+r+'"/>'),a.push("<col/>"),i.push(t("<fthtd>").css({display:"table-cell",height:0,width:"auto"}));a=a.join(""),n=n.join(""),l&&(A.empty(),A.append(i),B=A.find("fthtd")),P.html(n),V=P.find("th"),N||F.html(a),X=F.find("col"),O.html(a),Y=O.find("col")}return e}();return function(){var t=Q.scrollLeft();X=F.find("col");var n,a,s,d=(n=i,a=X,s=B,l?s:r?g.getSizingRow(n,a,s):a);if(d.length==o&&o>0){if(!N)for(e=0;e<o;e++)X.eq(e).css("width","");at();var f=[];for(e=0;e<o;e++)f[e]=h(d.get(e));for(e=0;e<o;e++)Y.eq(e).width(f[e]),X.eq(e).width(f[e]);nt()}else D.append(c),i.css(Z),D.css(Z),ot();Q.scrollLeft(t),i.triggerHandler("reflowed",[Q])}}function ft(t){var e=j.css("border-"+t+"-width"),o=0;return e&&~e.indexOf("px")&&(o=parseInt(e,10)),o}function ct(){return"auto"==z.css("overflow-x")}function ut(){var t,e=j.scrollTop(),o=0,r=H?W.outerHeight(!0):0,n=q?r:-r,l=Q.height(),d=i.offset(),f=0,c=0;if(S){var u=j.offset();o=d.top-u.top+e,H&&q&&(o+=r),f=ft("left"),c=ft("top"),o-=c}else t=d.top-w-l+m+T.horizontal;var p=s.scrollTop(),h=s.scrollLeft(),v=function(){return(ct()?z:j).scrollLeft()||0},b=v();return function(u){I=ct();var g=i[0].offsetWidth<=0&&i[0].offsetHeight<=0;if(!g&&U)return U=!1,setTimeout(function(){i.triggerHandler("reflow")},1),null;if(g&&(U=!0,!L))return null;if("windowScroll"==u)p=s.scrollTop(),h=s.scrollLeft();else if("containerScroll"==u)if(z.length){if(!I)return;b=z.scrollLeft()}else e=j.scrollTop(),b=j.scrollLeft();else"init"!=u&&(p=s.scrollTop(),h=s.scrollLeft(),e=j.scrollTop(),b=v());if(!a||!(p<0||h<0)){if(E)st("windowScrollDone"==u);else if("windowScrollDone"==u)return null;var m,y;d=i.offset(),H&&q&&(d.top+=r);var T=i.outerHeight();if(S&&L){if(o>=e){var C=o-e+c;m=C>0?C:0,lt(!1)}else m=M?c:e,lt(!0);y=f}else!S&&L?(p>t+T+n?m=T-l+n:d.top>=p+w?(m=0,at(),lt(!1)):(m=w+p-d.top+o+(q?r:0),nt(),lt(!0)),y=b):S&&!L?(o>e||e-o>T?(m=d.top-p,at(),lt(!1)):(m=d.top+e-p-o,nt(),lt(!0)),y=d.left+b-h):S||L||(p>t+T+n?m=T+w-p+t+n:d.top>p+w?(m=d.top-p,nt(),lt(!1)):(m=w,lt(!0)),y=d.left+b-h);return{top:Math.round(m),left:Math.round(y)}}}}function pt(){var t=null,e=null,o=null;return function(n,a,l){if(null!=n&&(t!=n.top||e!=n.left)){if(8===r)Q.css({top:n.top,left:n.left});else{var s="translateX("+n.left+"px) translateY("+n.top+"px)";Q.css({"-webkit-transform":s,"-moz-transform":s,"-ms-transform":s,"-o-transform":s,transform:s,top:0,left:0})}t=n.top,e=n.left}a&&function(){var t=v(i,B,!0),e=I?z:j,o=e.width()||t,r="hidden"!=e.css("overflow-y")?o-T.vertical:o;if(Q.width(r),S){var n=100*t/r;D.css("width",n+"%")}else D.outerWidth(t)}(),l&&ot();var d=(I?z:j).scrollLeft();L&&o==d||(Q.scrollLeft(d),o=d)}}function ht(){if(j.length)if(g.support&&g.support.perfectScrollbar&&j.data().perfectScrollbar)T={horizontal:0,vertical:0};else{if("scroll"==j.css("overflow-x"))T.horizontal=C;else{var t=j.width(),e=v(i,B),o=r<n?C:0;T.horizontal=t-o<e?C:0}if("scroll"==j.css("overflow-y"))T.vertical=C;else{var r=j.height(),n=i.height(),a=t<e?C:0;T.vertical=r-a<n?C:0}}}ht();var vt=function(){dt()()};vt();var bt=ut(),wt=pt();wt(bt("init"),!0);var gt=e.debounce(function(){wt(bt("windowScrollDone"),!1)},1),mt=function(){wt(bt("windowScroll"),!1),E&&gt()},yt=function(){wt(bt("containerScroll"),!1)},Tt=e.debounce(function(){i.is(":hidden")||(ht(),rt(),vt(),bt=ut(),wt(bt("reflow"),!0,!0))},1),Ct=function(){at()},xt=function(){nt()},jt=function(t){t.matches?Ct():xt()},St=null;if(window.matchMedia&&window.matchMedia("print").addListener&&!d?(St=window.matchMedia("print")).addListener(jt):(s.on("beforeprint",Ct),s.on("afterprint",xt)),S?L?j.on(et("scroll"),yt):(j.on(et("scroll"),yt),s.on(et("scroll"),mt)):(z.on(et("scroll"),yt),s.on(et("scroll"),mt)),s.on(et("load"),Tt),function(t,o){if(8==r){var n=s.width(),a=e.debounce(function(){var t=s.width();n!=t&&(n=t,o())},1);s.on(t,a)}else s.on(t,e.debounce(o,1))}(et("resize"),function(){i.is(":hidden")||(rt(),ht(),vt(),bt=ut(),(wt=pt())(bt("resize"),!0,!0))}),i.on("reflow",Tt),g.support&&g.support.datatables&&function(t){if(t.dataTableSettings)for(var e=0;e<t.dataTableSettings.length;e++){var o=t.dataTableSettings[e].nTable;if(t[0]==o)return!0}return!1}(i)&&i.on("filter",Tt).on("sort",Tt).on("page",Tt),g.support&&g.support.bootstrap&&s.on(et("shown.bs.tab"),Tt),g.support&&g.support.jqueryUI&&s.on(et("tabsactivate"),Tt),o){var zt=null;e.isFunction(g.autoReflow)&&(zt=g.autoReflow(i,j)),zt||(zt=j.length?j[0]:i[0]),(f=new MutationObserver(function(t){for(var e=function(t){return t&&t[0]&&("THEAD"==t[0].nodeName||"TD"==t[0].nodeName||"TH"==t[0].nodeName)},o=0;o<t.length;o++)if(!e(t[o].addedNodes)&&!e(t[o].removedNodes)){Tt();break}})).observe(zt,{childList:!0,subtree:!0})}i.data("floatThead-attached",{destroy:function(){var t=".fth-"+n;return at(),i.css(Z),F.remove(),l&&R.remove(),G.parent().length&&G.replaceWith(c),lt(!1),o&&(f.disconnect(),f=null),i.off("reflow reflowed"),j.off(t),z.off(t),M&&(j.length?j.unwrap():i.unwrap()),S?j.data("floatThead-containerWrap",!1):i.data("floatThead-containerWrap",!1),i.css("minWidth",tt),Q.remove(),i.data("floatThead-attached",!1),s.off(t),St&&St.removeListener(jt),Ct=xt=function(){},function(){return i.floatThead(g)}},reflow:function(){Tt()},setHeaderHeight:function(){ot()},getFloatContainer:function(){return Q},getRowGroups:function(){return y?Q.find(">table>thead").add(i.children("tbody,tfoot")):i.children("thead,tbody,tfoot")}})}),this}}(function(){var t=window.jQuery;return"undefined"!=typeof module&&module.exports&&!t&&(t=require("jquery")),t}());
{
"name": "floatthead",
"version": "2.0.3",
"version": "2.1.0",
"description": "fixed table header plugin that works",

@@ -11,3 +11,3 @@ "main": "dist/jquery.floatThead.js",

"devDependencies": {
"uglifyjs": "2.7.5"
"uglify-js": "^3.3.8"
},

@@ -14,0 +14,0 @@ "repository": {

@@ -1,6 +0,6 @@

jquery.floatThead 2.0.3
jquery.floatThead 2.1.0
=================
[![woot](http://giant.gfycat.com/AnyGloriousAlpaca.gif "or just click")](http://mkoryak.github.io/floatThead/)
#Documentation & Examples: http://mkoryak.github.io/floatThead/
# Documentation & Examples: http://mkoryak.github.io/floatThead/

@@ -11,6 +11,2 @@ Float the table header on scroll. No changes to your HTML/CSS are required, it just works.

:heart_eyes_cat:**My cat loves it**:heart_eyes_cat:
### Install

@@ -24,8 +20,8 @@

#### Download code
[Latest Release (zip)](https://github.com/mkoryak/floatThead/archive/2.0.3.zip)
[Latest Release (zip)](https://github.com/mkoryak/floatThead/archive/2.1.0.zip)
#### Via CDN
[http://cdnjs.com/libraries/floatthead/](http://cdnjs.com/libraries/floatthead/)
[http://www.jsdelivr.com/#!jquery.floatthead](http://www.jsdelivr.com/#!jquery.floatthead)
[https://unpkg.com/floatthead](https://unpkg.com/floatthead)
[http://cdnjs.com/libraries/floatthead/](http://cdnjs.com/libraries/floatthead/) .
[http://www.jsdelivr.com/#!jquery.floatthead](http://www.jsdelivr.com/#!jquery.floatthead) .
[https://unpkg.com/floatthead](https://unpkg.com/floatthead) .

@@ -36,2 +32,3 @@ #### For java people

### Wrappers
[vuejs component](https://github.com/tmlee/vue-floatThead) by @tmlee

@@ -47,4 +44,5 @@ [angularjs directive](https://github.com/brandon-barker/angular-floatThead) by @brandon-barker

- Works with dynamically hidden/added/removed columns
- Doesn't clone the thead - so your events stay bound
- Doesn't mess with your styles, and doesnt require any css
- Does not clone the thead - so your events stay bound
- Does what `position:fixed` cannot do (and on browsers that do not support it)
- Does not mess with your styles, and doesnt require any css (see `fixed` vs `absolute` position modes)
- Works with border-collapse variants, weird margins, padding and borders

@@ -61,2 +59,3 @@ - Works with libs like [datatables](http://datatables.net), [perfect-scrollbar](http://mkoryak.github.io/floatThead/examples/perfect-scrollbar/), [bootstrap3](http://mkoryak.github.io/floatThead/examples/bootstrap3/), and many more

Common Pitfalls

@@ -88,8 +87,14 @@ ------

### [around 45K hits on guthub cod search](https://github.com/search?q=floatThead&ref=reposearch&type=Code&utf8=%E2%9C%93)
### [Around 96K hits on guthub cod search](https://github.com/search?q=floatThead&ref=reposearch&type=Code&utf8=%E2%9C%93)
### [http://kangax.github.io/compat-table/](http://kangax.github.io/compat-table/es6/)
### [Google](https://www.youtube.com/watch?v=dQw4w9WgXcQ)
- Internally, I happen to know...
### [staticsitegenerators.net](http://staticsitegenerators.net/)
### [Samsung](https://github.com/Samsung/iotjscode/blob/3d4de15ea32d27dce5885b2c8c9e3a783c846311/www/scripts/app/main.js#L234)
- For the internet of things!
### [compat-table](https://github.com/kangax/compat-table/)
- https://github.com/kangax/compat-table/blob/gh-pages/jquery.floatThead.min.js
- [online site](http://kangax.github.io/compat-table/es6/) (see floatThead in action here)
### [netdisco](http://netdisco.org)

@@ -101,4 +106,4 @@ - http://sourceforge.net/p/netdisco/netdisco-ng/ci/213352d54ee8e71cbca5ae2c1c75696800c4216b/

### [django-sql-explorer](https://github.com/epantry/django-sql-explorer)
- https://github.com/epantry/django-sql-explorer/commit/34ae345325a1e07ff952800fcd6dc5bddac5e3f2-
### [django-sql-explorer](https://github.com/groveco/django-sql-explorer)
- https://github.com/groveco/django-sql-explorer#dependencies

@@ -105,0 +110,0 @@

@@ -1,6 +0,6 @@

/** @preserve jQuery.floatThead 2.0.3 - http://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2017 Misha Koryak **/
/** @preserve jQuery.floatThead 2.1.0 - http://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2018 Misha Koryak **/
// @license MIT
/* @author Misha Koryak
* @projectDescription lock a table header in place while scrolling - without breaking styles or events bound to the header
* @projectDescription position:fixed on steroids. Lock a table header in place while scrolling.
*

@@ -13,3 +13,2 @@ * Dependencies:

* Tested on FF13+, Chrome 21+, IE8, IE9, IE10, IE11
*
*/

@@ -19,3 +18,3 @@ (function( $ ) {

* provides a default config object. You can modify this after including this script if you want to change the init defaults
* @type {Object}
* @type {!Object}
*/

@@ -51,6 +50,7 @@ $.floatThead = $.floatThead || {};

perfectScrollbar: true
}
},
floatContainerOverflow: "hidden" // value for css 'overflow' attribute applied to the floatContainer - clips protruding elements by default
};
var util = window._ || (function underscoreShim(){
var util = (function underscoreShim(){
var that = {};

@@ -140,3 +140,5 @@ var hasOwnProperty = Object.prototype.hasOwnProperty, isThings = ['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'];

if(!window.matchMedia) {
var buggyMatchMedia = isFF && window.matchMedia; // TODO remove when fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=774398
if(!window.matchMedia || buggyMatchMedia) {
var _beforePrint = window.onbeforeprint;

@@ -155,3 +157,3 @@ var _afterPrint = window.onafterprint;

/**
* @param debounceMs
* @param eventName
* @param cb

@@ -245,3 +247,3 @@ */

for(var i=0; i < $fthCells.length; i++){
w += $fthCells.get(i).offsetWidth;
w += getOffsetWidth($fthCells.get(i));
}

@@ -334,3 +336,6 @@ return w;

var scrollbarOffset = {vertical: 0, horizontal: 0};
var scWidth = scrollbarWidth();
if(util.isFunction(scrollbarWidth)) {
scrollbarWidth = scrollbarWidth();
}
var lastColumnCount = 0; //used by columnNum()

@@ -395,3 +400,3 @@

});
var $floatContainer = $('<div>').css('overflow', 'hidden').attr('aria-hidden', 'true');
var $floatContainer = $('<div>').css('overflow', opts.floatContainerOverflow).attr('aria-hidden', 'true');
var floatTableHidden = false; //this happens when the table is hidden and we do magic when making it visible

@@ -889,14 +894,14 @@ var $newHeader = $("<thead/>");

if($scrollContainer.css('overflow-x') == 'scroll'){
scrollbarOffset.horizontal = scWidth;
scrollbarOffset.horizontal = scrollbarWidth;
} else {
var sw = $scrollContainer.width(), tw = tableWidth($table, $fthCells);
var offsetv = sh < th ? scWidth : 0;
scrollbarOffset.horizontal = sw - offsetv < tw ? scWidth : 0;
var offsetv = sh < th ? scrollbarWidth : 0;
scrollbarOffset.horizontal = sw - offsetv < tw ? scrollbarWidth : 0;
}
if($scrollContainer.css('overflow-y') == 'scroll'){
scrollbarOffset.vertical = scWidth;
scrollbarOffset.vertical = scrollbarWidth;
} else {
var sh = $scrollContainer.height(), th = $table.height();
var offseth = sw < tw ? scWidth : 0;
scrollbarOffset.vertical = sh - offseth < th ? scWidth : 0;
var offseth = sw < tw ? scrollbarWidth : 0;
scrollbarOffset.vertical = sh - offseth < th ? scrollbarWidth : 0;
}

@@ -957,3 +962,3 @@ }

calculateFloatContainerPos = calculateFloatContainerPosFn();
repositionFloatContainer(calculateFloatContainerPos('reflow'), true);
repositionFloatContainer(calculateFloatContainerPos('reflow'), true, true);
}, 1);

@@ -977,4 +982,4 @@

var matchMediaPrint;
if(window.matchMedia && window.matchMedia('print').addListener){
var matchMediaPrint = null;
if(window.matchMedia && window.matchMedia('print').addListener && !buggyMatchMedia){
matchMediaPrint = window.matchMedia("print");

@@ -981,0 +986,0 @@ matchMediaPrint.addListener(printEvent);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc