floatthead
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -0,4 +1,10 @@ | ||
### 2.1.1 | ||
I goofed, forgot to build dist last release. | ||
- Removed 'floatContainerOverflow' option, removed `overflow-y:hidden` css from scrollContainer. | ||
### 2.1.0 | ||
- #402 HUGE performance improvement if plugin used on multiple tables on the same page. Over **100x faster** startup time | ||
- #402 HUGE performance improvement if plugin used on multiple tables on the same page. Over **10x faster** startup time | ||
on a page with 39 tables. Big props to [@ineuwirth](https://github.com/ineuwirth) for finding this one! | ||
@@ -5,0 +11,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.1 - 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,3 +50,4 @@ $.floatThead = $.floatThead || {}; | ||
perfectScrollbar: true | ||
} | ||
}, | ||
floatContainerCss: {"overflow-x": "hidden"} // undocumented - css applied to the floatContainer | ||
}; | ||
@@ -139,3 +139,3 @@ | ||
var $window = $(window); | ||
var buggyMatchMedia = isFF && window.matchMedia; // TODO remove when fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=774398 | ||
@@ -334,3 +334,6 @@ | ||
var scrollbarOffset = {vertical: 0, horizontal: 0}; | ||
var scWidth = scrollbarWidth(); | ||
if(util.isFunction(scrollbarWidth)) { | ||
scrollbarWidth = scrollbarWidth(); | ||
} | ||
var lastColumnCount = 0; //used by columnNum() | ||
@@ -351,7 +354,7 @@ | ||
if (opts.position == 'auto') { | ||
if (opts.position === 'auto') { | ||
useAbsolutePositioning = null; | ||
} else if (opts.position == 'fixed') { | ||
} else if (opts.position === 'fixed') { | ||
useAbsolutePositioning = false; | ||
} else if (opts.position == 'absolute'){ | ||
} else if (opts.position === 'absolute'){ | ||
useAbsolutePositioning = true; | ||
@@ -396,3 +399,3 @@ } else if (opts.debug) { | ||
}); | ||
var $floatContainer = $('<div>').css('overflow', 'hidden').attr('aria-hidden', 'true'); | ||
var $floatContainer = $('<div>').css(opts.floatContainerCss).attr('aria-hidden', 'true'); | ||
var floatTableHidden = false; //this happens when the table is hidden and we do magic when making it visible | ||
@@ -432,3 +435,3 @@ var $newHeader = $("<thead/>"); | ||
} | ||
if(tableDisplayCss == 'none'){ | ||
if(tableDisplayCss === 'none'){ | ||
floatTableHidden = true; | ||
@@ -471,8 +474,8 @@ } | ||
$floatContainer.css({ | ||
position: useAbsolutePositioning ? 'absolute' : 'fixed', | ||
marginTop: 0, | ||
top: useAbsolutePositioning ? 0 : 'auto', | ||
zIndex: opts.zIndex, | ||
willChange: 'transform' | ||
}); | ||
position: useAbsolutePositioning ? 'absolute' : 'fixed', | ||
marginTop: 0, | ||
top: useAbsolutePositioning ? 0 : 'auto', | ||
zIndex: opts.zIndex, | ||
willChange: 'transform' | ||
}); | ||
$floatContainer.addClass(opts.floatContainerClass); | ||
@@ -540,3 +543,3 @@ updateScrollingOffsets(); | ||
} | ||
if(count != lastColumnCount){ | ||
if(count !== lastColumnCount){ | ||
lastColumnCount = count; | ||
@@ -893,14 +896,14 @@ var cells = [], cols = [], psuedo = [], content; | ||
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; | ||
} | ||
@@ -907,0 +910,0 @@ } |
@@ -1,2 +0,2 @@ | ||
/** @preserve jQuery.floatThead 2.0.3 - http://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2017 Misha Koryak **/ | ||
!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&>()},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}()); | ||
/** @preserve jQuery.floatThead 2.1.1 - http://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2018 Misha Koryak **/ | ||
!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},floatContainerCss:{"overflow-x":"hidden"}};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 n in t)e.has(t,n)&&o.push(n);return o};var n=0;return e.uniqueId=function(t){var e=++n+"";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 n,r,a,i,l;return function(){a=this,r=arguments,i=new Date;var s=function(){var d=new Date-i;d<e?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}(),o="undefined"!=typeof MutationObserver,n=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}(),r=/Gecko\//.test(navigator.userAgent),a=/WebKit\//.test(navigator.userAgent);n||r||a||(n=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=!r&&!n,s=t(window),d=r&&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(){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 b(t,e,o){var n=o?"outerWidth":"width";if(i&&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+=h(e.get(a));return r}return t[n]()}t.fn.floatThead=function(r){if(r=r||{},n<8)return this;var f=null;if(e.isFunction(i)&&(i=i()),e.isString(r)){var c=r,w=Array.prototype.slice.call(arguments,1),g=this;return this.filter("table").each(function(){var o=t(this),n=o.data("floatThead-lazy");n&&o.floatThead(n);var r=o.data("floatThead-attached");if(r&&e.isFunction(r[c])){var a=r[c].apply(this,w);void 0!==a&&(g=a)}}),g}var m=t.extend({},t.floatThead.defaults||{},r);if(t.each(r,function(o,n){o in t.floatThead.defaults||!m.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(", "))}),m.debug){var y=t.fn.jquery.split(".");1==parseInt(y[0],10)&&parseInt(y[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(."+m.floatTableClass+")").each(function(){var r=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=m.autoReflow&&o;var c=i.children("thead:first"),w=i.children("tbody:first");if(0==c.length||0==w.length)return m.debug&&(0==c.length?p("The thead element is missing."):p("The tbody element is missing.")),i.data("floatThead-lazy",m),void i.unbind("reflow").one("reflow",function(){i.floatThead(m)});i.data("floatThead-lazy")&&i.unbind("reflow"),i.data("floatThead-lazy",!1);var g,y,T=!0,C={vertical:0,horizontal:0};e.isFunction(v)&&(v=v());var x=0;!0===m.scrollContainer&&(m.scrollContainer=u);var j=m.scrollContainer(i)||t([]),S=j.length>0,z=S?t([]):m.responsiveContainer(i)||t([]),I=ct(),L=null;"auto"===m.position?L=null:"fixed"===m.position?L=!1:"absolute"===m.position?L=!0:m.debug&&p('Invalid value given to "position" option, valid is "fixed", "absolute" and "auto". You passed: ',m.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=n<=9&&!S&&L,D=t("<table/>"),F=t("<colgroup/>"),O=i.children("colgroup:first"),N=!0;0==O.length&&(O=t("<colgroup/>"),N=!1);var A=t("<fthtr>").css({display:"table-row","border-spacing":0,height:0,"border-collapse":"collapse"}),Q=t("<div>").css(m.floatContainerCss).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(O),l&&(R.append(A),i.append(R)),D.append(F),Q.append(D),m.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(m.floatTableClass).css({margin:0,"border-bottom-width":0}),L){var $=function(e,o){var n=e.css("position"),r=e;if(!("relative"==n||"absolute"==n)||o){var a={paddingLeft:e.css("paddingLeft"),paddingRight:e.css("paddingRight")};Q.css(a),r=e.data("floatThead-containerWrap")||e.wrap(t("<div>").addClass(m.floatWrapperClass).css({position:"relative",clear:"both"})).parent(),e.data("floatThead-containerWrap",r),M=!0}return r};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:m.zIndex,willChange:"transform"}),Q.addClass(m.floatContainerClass),nt();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-"+r+".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 nt(){g=(e.isFunction(m.top)?m.top(i):m.top)||0,y=(e.isFunction(m.bottom)?m.bottom(i):m.bottom)||0}function rt(){if(!T){if(T=!0,L){var t=b(i,B,!0);t>k.width()&&i.css("minWidth",t)}i.css(J),D.css(J),D.append(c),w.before(G),ot()}}function at(){T&&(T=!1,L&&i.width(_),G.detach(),i.prepend(c),i.css(Z),D.css(Z),i.css("minWidth",tt),i.css("minWidth",b(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(m.headerCellSelector);if(N?e=O.find("col").length:(e=0,o.each(function(){e+=parseInt(t(this).attr("colspan")||1,10)})),e!==x){x=e;for(var n,r=[],a=[],i=[],s=0;s<e;s++)n=o.eq(s).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(""),l&&(A.empty(),A.append(i),B=A.find("fthtd")),P.html(r),V=P.find("th"),N||O.html(a),X=O.find("col"),F.html(a),Y=F.find("col")}return e}();return function(){var t=Q.scrollLeft();X=O.find("col");var r,a,s,d,f=(r=i,a=X,s=B,d=n,l?s:d?m.getSizingRow(r,a,s):a);if(f.length==o&&o>0){if(!N)for(e=0;e<o;e++)X.eq(e).css("width","");at();var u=[];for(e=0;e<o;e++)u[e]=h(f.get(e));for(e=0;e<o;e++)Y.eq(e).width(u[e]),X.eq(e).width(u[e]);rt()}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,n=H?W.outerHeight(!0):0,r=q?n:-n,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+=n),f=ft("left"),c=ft("top"),o-=c}else t=d.top-g-l+y+C.horizontal;var p=s.scrollTop(),h=s.scrollLeft(),v=function(){return(ct()?z:j).scrollLeft()||0},b=v();return function(u){I=ct();var w=i[0].offsetWidth<=0&&i[0].offsetHeight<=0;if(!w&&U)return U=!1,setTimeout(function(){i.triggerHandler("reflow")},1),null;if(w&&(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+=n);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+r?m=T-l+r:d.top>=p+g?(m=0,at(),lt(!1)):(m=g+p-d.top+o+(q?n:0),rt(),lt(!0)),y=b):S&&!L?(o>e||e-o>T?(m=d.top-p,at(),lt(!1)):(m=d.top+e-p-o,rt(),lt(!0)),y=d.left+b-h):S||L||(p>t+T+r?m=T+g-p+t+r:d.top>p+g?(m=d.top-p,rt(),lt(!1)):(m=g,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(r,a,l){if(null!=r&&(t!=r.top||e!=r.left)){if(8===n)Q.css({top:r.top,left:r.left});else{var s="translateX("+r.left+"px) translateY("+r.top+"px)";Q.css({"-webkit-transform":s,"-moz-transform":s,"-ms-transform":s,"-o-transform":s,transform:s,top:0,left:0})}t=r.top,e=r.left}a&&function(){var t=b(i,B,!0),e=I?z:j,o=e.width()||t,n="hidden"!=e.css("overflow-y")?o-C.vertical:o;if(Q.width(n),S){var r=100*t/n;D.css("width",r+"%")}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(m.support&&m.support.perfectScrollbar&&j.data().perfectScrollbar)C={horizontal:0,vertical:0};else{if("scroll"==j.css("overflow-x"))C.horizontal=v;else{var t=j.width(),e=b(i,B),o=n<r?v:0;C.horizontal=t-o<e?v:0}if("scroll"==j.css("overflow-y"))C.vertical=v;else{var n=j.height(),r=i.height(),a=t<e?v:0;C.vertical=n-a<r?v: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&>()},yt=function(){wt(bt("containerScroll"),!1)},Tt=e.debounce(function(){i.is(":hidden")||(ht(),nt(),vt(),bt=ut(),wt(bt("reflow"),!0,!0))},1),Ct=function(){at()},xt=function(){rt()},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==n){var r=s.width(),a=e.debounce(function(){var t=s.width();r!=t&&(r=t,o())},1);s.on(t,a)}else s.on(t,e.debounce(o,1))}(et("resize"),function(){i.is(":hidden")||(nt(),ht(),vt(),bt=ut(),(wt=pt())(bt("resize"),!0,!0))}),i.on("reflow",Tt),m.support&&m.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),m.support&&m.support.bootstrap&&s.on(et("shown.bs.tab"),Tt),m.support&&m.support.jqueryUI&&s.on(et("tabsactivate"),Tt),o){var zt=null;e.isFunction(m.autoReflow)&&(zt=m.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-"+r;return at(),i.css(Z),O.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(m)}},reflow:function(){Tt()},setHeaderHeight:function(){ot()},getFloatContainer:function(){return Q},getRowGroups:function(){return T?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.1.0", | ||
"version": "2.1.1", | ||
"description": "fixed table header plugin that works", | ||
@@ -5,0 +5,0 @@ "main": "dist/jquery.floatThead.js", |
@@ -1,2 +0,2 @@ | ||
jquery.floatThead 2.1.0 | ||
jquery.floatThead [2.1.1](https://github.com/mkoryak/floatThead/releases) | ||
================= | ||
@@ -19,3 +19,3 @@ [![woot](http://giant.gfycat.com/AnyGloriousAlpaca.gif "or just click")](http://mkoryak.github.io/floatThead/) | ||
#### Download code | ||
[Latest Release (zip)](https://github.com/mkoryak/floatThead/archive/2.1.0.zip) | ||
[Latest Release (zip)](https://github.com/mkoryak/floatThead/archive/2.1.1.zip) | ||
@@ -22,0 +22,0 @@ #### Via CDN |
@@ -1,2 +0,2 @@ | ||
/** @preserve jQuery.floatThead 2.1.0 - http://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2018 Misha Koryak **/ | ||
/** @preserve jQuery.floatThead 2.1.1 - http://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2018 Misha Koryak **/ | ||
// @license MIT | ||
@@ -49,3 +49,3 @@ | ||
}, | ||
floatContainerOverflow: "hidden" // value for css 'overflow' attribute applied to the floatContainer - clips protruding elements by default | ||
floatContainerCss: {"overflow-x": "hidden"} // undocumented - css applied to the floatContainer | ||
}; | ||
@@ -350,7 +350,7 @@ | ||
if (opts.position == 'auto') { | ||
if (opts.position === 'auto') { | ||
useAbsolutePositioning = null; | ||
} else if (opts.position == 'fixed') { | ||
} else if (opts.position === 'fixed') { | ||
useAbsolutePositioning = false; | ||
} else if (opts.position == 'absolute'){ | ||
} else if (opts.position === 'absolute'){ | ||
useAbsolutePositioning = true; | ||
@@ -395,3 +395,3 @@ } else if (opts.debug) { | ||
}); | ||
var $floatContainer = $('<div>').css('overflow', opts.floatContainerOverflow).attr('aria-hidden', 'true'); | ||
var $floatContainer = $('<div>').css(opts.floatContainerCss).attr('aria-hidden', 'true'); | ||
var floatTableHidden = false; //this happens when the table is hidden and we do magic when making it visible | ||
@@ -431,3 +431,3 @@ var $newHeader = $("<thead/>"); | ||
} | ||
if(tableDisplayCss == 'none'){ | ||
if(tableDisplayCss === 'none'){ | ||
floatTableHidden = true; | ||
@@ -470,8 +470,8 @@ } | ||
$floatContainer.css({ | ||
position: useAbsolutePositioning ? 'absolute' : 'fixed', | ||
marginTop: 0, | ||
top: useAbsolutePositioning ? 0 : 'auto', | ||
zIndex: opts.zIndex, | ||
willChange: 'transform' | ||
}); | ||
position: useAbsolutePositioning ? 'absolute' : 'fixed', | ||
marginTop: 0, | ||
top: useAbsolutePositioning ? 0 : 'auto', | ||
zIndex: opts.zIndex, | ||
willChange: 'transform' | ||
}); | ||
$floatContainer.addClass(opts.floatContainerClass); | ||
@@ -539,3 +539,3 @@ updateScrollingOffsets(); | ||
} | ||
if(count != lastColumnCount){ | ||
if(count !== lastColumnCount){ | ||
lastColumnCount = count; | ||
@@ -542,0 +542,0 @@ var cells = [], cols = [], psuedo = [], content; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
120947
2069