From eff21abbca6b93f901d819d3cdf0bfe0160bf272 Mon Sep 17 00:00:00 2001 From: mkoryak Date: Thu, 28 May 2020 11:51:50 -0400 Subject: [PATCH] prepare to release 2.2.0 --- .gitignore | 1 + CHANGELOG.md | 10 ++++++++++ dist/jquery.floatThead.js | 7 +++---- dist/jquery.floatThead.min.js | 2 +- package.json | 5 +++-- {dist => src}/jquery.floatThead.d.ts | 0 src/jquery.floatThead.js | 6 +++--- 7 files changed, 21 insertions(+), 10 deletions(-) rename {dist => src}/jquery.floatThead.d.ts (100%) diff --git a/.gitignore b/.gitignore index 050bcf7..64d3f4d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ build/ compiled-docs/ license.txt +.DS_Store node_modules/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 640c1a3..59811bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +### 2.2.0 +The Covid Release + +bug fixes: +- #454 - Fix destroy function when using autoReflow with multiple tables + +new features: +- #445 - Support hidden columns in tables that have an existing colgroup +- #458 - TypeScript definitions + ### 2.1.4 This release is dedicated to my cat. May he rest in catnip and meats. diff --git a/dist/jquery.floatThead.js b/dist/jquery.floatThead.js index aa3cc08..a6a0270 100644 --- a/dist/jquery.floatThead.js +++ b/dist/jquery.floatThead.js @@ -104,7 +104,7 @@ return that; })(); - var canObserveMutations = typeof MutationObserver !== 'undefined'; + var globalCanObserveMutations = typeof MutationObserver !== 'undefined'; //browser stuff @@ -260,8 +260,6 @@ return this; //no more crappy browser support. } - var mObs = null; //mutation observer lives in here if we can use it / make it - if(util.isFunction(isTableWidthBug)) { isTableWidthBug = isTableWidthBug(); } @@ -309,7 +307,8 @@ if(!$table.is('table')){ throw new Error('jQuery.floatThead must be run on a table element. ex: $("table").floatThead();'); } - canObserveMutations = opts.autoReflow && canObserveMutations; //option defaults to false! + var canObserveMutations = opts.autoReflow && globalCanObserveMutations; //option defaults to false! + var mObs = null; //mutation observer lives in here if we can use it / make it var $header = $table.children('thead:first'); var $tbody = $table.children('tbody:first'); if($header.length === 0 || $tbody.length === 0){ diff --git a/dist/jquery.floatThead.min.js b/dist/jquery.floatThead.min.js index b9063e9..6029bbb 100644 --- a/dist/jquery.floatThead.min.js +++ b/dist/jquery.floatThead.min.js @@ -1,2 +1,2 @@ /** @preserve jQuery.floatThead 2.2.0 - https://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2019 Misha Koryak **/ -!function(vt){vt.floatThead=vt.floatThead||{},vt.floatThead.defaults={headerCellSelector:"tr:visible:first>*:visible",zIndex:1001,position:"auto",top:0,bottom:0,scrollContainer:function(t){return vt([])},responsiveContainer:function(t){return vt([])},getSizingRow:function(t,e,o){return t.find("tbody tr:visible:first>*:visible")},ariaLabel:function(t,e,o){return e.text()},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 bt=function(){var n={},o=Object.prototype.hasOwnProperty;n.has=function(t,e){return o.call(t,e)},n.keys=Object.keys||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var e=[];for(var o in t)n.has(t,o)&&e.push(o);return e};var r=0;return n.uniqueId=function(t){var e=++r+"";return t?t+e:e},vt.each(["Arguments","Function","String","Number","Date","RegExp"],function(){var e=this;n["is"+e]=function(t){return Object.prototype.toString.call(t)==="[object "+e+"]"}}),n.debounce=function(o,n,r){var a,i,l,s,d;return function(){l=this,i=arguments,s=new Date;var e=function(){var t=new Date-s;t").css("width",0).append(vt("").css("max-width","100%").append(vt("").append(vt("
").append(vt("
").css("min-width",100).text("X")))));vt("body").append(t);var e=0===t.find("table").width();return t.remove(),e}return!1},Tt=!t&&!gt,Ct=vt(window),xt=t&&window.matchMedia;if(!window.matchMedia||xt){var e=window.onbeforeprint,o=window.onafterprint;window.onbeforeprint=function(){e&&e(),Ct.triggerHandler("fth-beforeprint")},window.onafterprint=function(){o&&o(),Ct.triggerHandler("fth-afterprint")}}function Lt(t){var e=t[0].parentElement;do{if("visible"!==window.getComputedStyle(e).getPropertyValue("overflow"))break}while(e=e.parentElement);return e===document.body?vt([]):vt(e)}function St(t){window&&window.console&&window.console.error&&window.console.error("jQuery.floatThead: "+t)}function jt(t){var e=t.getBoundingClientRect();return e.width||e.right-e.left}function zt(){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 It(t,e,o){var n=o?"outerWidth":"width";if(l&&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 http://jqueryui.com/resources/download/jquery-ui-1.8.24.zip")}return this.filter(":not(."+ht.floatTableClass+")").each(function(){var e=bt.uniqueId(),m=vt(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();');wt=ht.autoReflow&&wt;var d=m.children("thead:first"),o=m.children("tbody:first");if(0===d.length||0===o.length)return ht.debug&&(0===d.length?St("The thead element is missing."):St("The tbody element is missing.")),m.data("floatThead-lazy",ht),void m.unbind("reflow").one("reflow",function(){m.floatThead(ht)});m.data("floatThead-lazy")&&m.unbind("reflow"),m.data("floatThead-lazy",!1);var y,T,n=!0,C={vertical:0,horizontal:0};bt.isFunction(zt)&&(zt=zt());var i=0;!0===ht.scrollContainer&&(ht.scrollContainer=Lt);var x=ht.scrollContainer(m)||vt([]),L=0").css({display:"table-footer-group","border-spacing":0,height:0,"border-collapse":"collapse",visibility:"hidden"}),W=!1,l=vt([]),q=gt<=9&&!L&&z,f=vt(""),c=vt(""),u=m.children("colgroup:first"),p=!0;0===u.length&&(u=vt(""),p=!1);var h=p?"col:visible":"col",v=vt("").css({display:"table-row","border-spacing":0,height:0,"border-collapse":"collapse"}),R=vt("
").css(ht.floatContainerCss).attr("aria-hidden","true"),E=!1,s=vt("
"),b=vt(''),w=vt([]),g=vt([]),M=vt([]),k=vt([]);s.append(b),m.prepend(u),Tt&&(a.append(v),m.append(a)),f.append(c),R.append(f),ht.copyTableClass&&f.attr("class",m.attr("class")),f.attr({cellpadding:m.attr("cellpadding"),cellspacing:m.attr("cellspacing"),border:m.attr("border")});var t=m.css("display");if(f.css({borderCollapse:m.css("borderCollapse"),border:m.css("border"),display:t}),L||f.css("width","auto"),"none"===t&&(E=!0),f.addClass(ht.floatTableClass).css({margin:0,"border-bottom-width":0}),z){var D=function(t,e){var o=t.css("position"),n=t;if(!("relative"===o||"absolute"===o)||e){var r={paddingLeft:t.css("paddingLeft"),paddingRight:t.css("paddingRight")};R.css(r),n=t.data("floatThead-containerWrap")||t.wrap(vt("
").addClass(ht.floatWrapperClass).css({position:"relative",clear:"both"})).parent(),t.data("floatThead-containerWrap",n),W=!0}return n};L?(l=D(x,!0)).prepend(R):(l=D(m),m.before(R))}else m.before(R);R.css({position:z?"absolute":"fixed",marginTop:0,top:z?0:"auto",zIndex:ht.zIndex,willChange:"transform"}),R.addClass(ht.floatContainerClass),G();var F={"table-layout":"fixed"},O={"table-layout":m.css("tableLayout")||"auto"},N=m[0].style.width||"",A=m.css("minWidth")||"";function Q(t){return t+".fth-"+e+".floatTHead"}function U(){var t=0;if(d.children("tr:visible").each(function(){t+=vt(this).outerHeight(!0)}),"collapse"===m.css("border-collapse")){var e=parseInt(m.css("border-top-width"),10);parseInt(m.find("thead tr:first").find(">*:first").css("border-top-width"),10)"),n.push(vt("").css({display:"table-cell",height:0,width:"auto"}))}o=p?u.html():o.join(""),Tt&&(v.empty(),v.append(n),k=v.find("fthtd")),w=b.find("th"),p||u.html(o),g=u.find(h),c.html(o),M=c.find(h)}return t}();return function(){var t=R.scrollLeft();g=u.find(h);var e,o,n,r,a=(e=m,o=g,n=k,r=gt,Tt?n:r?ht.getSizingRow(e,o,n):o);if(a.length===s&&0=v+y?(o=0,V(),Y(!1)):(o=y+v-u.top+s+(H?d:0),P(),Y(!0)),n=g):L&&!z?(lv+y?(o=u.top-v,P(),Y(!1)):(o=y,Y(!0)),n=u.left+g-b);return{top:Math.round(o),left:Math.round(n)}}}}function _(){var i=null,l=null,s=null;return function(t,e,o){if(null!=t&&(i!==t.top||l!==t.left)){if(8===gt)R.css({top:t.top,left:t.left});else{var n="translateX("+t.left+"px) translateY("+t.top+"px)",r={"-webkit-transform":n,"-moz-transform":n,"-ms-transform":n,"-o-transform":n,transform:n,top:0,left:0};R.css(r)}i=t.top,l=t.left}e&&function(){var t=It(m,k,!0),e=j?S:x,o=e.length?jt(e[0]):t,n="hidden"!==e.css("overflow-y")?o-C.vertical:o;if(R.width(n),L){var r=100*t/n;f.css("width",r+"%")}else f.css("width",t+"px")}(),o&&U();var a=(j?S:x).scrollLeft();z&&s===a||(R.scrollLeft(a),s=a)}}function tt(){if(x.length)if(ht.support&&ht.support.perfectScrollbar&&x.data().perfectScrollbar)C={horizontal:0,vertical:0};else{if("scroll"===x.css("overflow-x"))C.horizontal=zt;else{var t=x.width(),e=It(m,k),o=ntable>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(bt){bt.floatThead=bt.floatThead||{},bt.floatThead.defaults={headerCellSelector:"tr:visible:first>*:visible",zIndex:1001,position:"auto",top:0,bottom:0,scrollContainer:function(t){return bt([])},responsiveContainer:function(t){return bt([])},getSizingRow:function(t,e,o){return t.find("tbody tr:visible:first>*:visible")},ariaLabel:function(t,e,o){return e.text()},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 wt=function(){var n={},o=Object.prototype.hasOwnProperty;n.has=function(t,e){return o.call(t,e)},n.keys=Object.keys||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var e=[];for(var o in t)n.has(t,o)&&e.push(o);return e};var r=0;return n.uniqueId=function(t){var e=++r+"";return t?t+e:e},bt.each(["Arguments","Function","String","Number","Date","RegExp"],function(){var e=this;n["is"+e]=function(t){return Object.prototype.toString.call(t)==="[object "+e+"]"}}),n.debounce=function(o,n,r){var a,i,l,s,d;return function(){l=this,i=arguments,s=new Date;var e=function(){var t=new Date-s;t").css("width",0).append(bt("
").css("max-width","100%").append(bt("").append(bt("
").append(bt("
").css("min-width",100).text("X")))));bt("body").append(t);var e=0===t.find("table").width();return t.remove(),e}return!1},Ct=!t&&!mt,xt=bt(window),Lt=t&&window.matchMedia;if(!window.matchMedia||Lt){var e=window.onbeforeprint,o=window.onafterprint;window.onbeforeprint=function(){e&&e(),xt.triggerHandler("fth-beforeprint")},window.onafterprint=function(){o&&o(),xt.triggerHandler("fth-afterprint")}}function St(t){var e=t[0].parentElement;do{if("visible"!==window.getComputedStyle(e).getPropertyValue("overflow"))break}while(e=e.parentElement);return e===document.body?bt([]):bt(e)}function jt(t){window&&window.console&&window.console.error&&window.console.error("jQuery.floatThead: "+t)}function zt(t){var e=t.getBoundingClientRect();return e.width||e.right-e.left}function It(){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 Ht(t,e,o){var n=o?"outerWidth":"width";if(l&&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 http://jqueryui.com/resources/download/jquery-ui-1.8.24.zip")}return this.filter(":not(."+vt.floatTableClass+")").each(function(){var e=wt.uniqueId(),m=bt(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();');var o=vt.autoReflow&>,n=null,d=m.children("thead:first"),r=m.children("tbody:first");if(0===d.length||0===r.length)return vt.debug&&(0===d.length?jt("The thead element is missing."):jt("The tbody element is missing.")),m.data("floatThead-lazy",vt),void m.unbind("reflow").one("reflow",function(){m.floatThead(vt)});m.data("floatThead-lazy")&&m.unbind("reflow"),m.data("floatThead-lazy",!1);var y,T,a=!0,C={vertical:0,horizontal:0};wt.isFunction(It)&&(It=It());var i=0;!0===vt.scrollContainer&&(vt.scrollContainer=St);var x=vt.scrollContainer(m)||bt([]),L=0").css({display:"table-footer-group","border-spacing":0,height:0,"border-collapse":"collapse",visibility:"hidden"}),q=!1,s=bt([]),R=mt<=9&&!L&&z,f=bt(""),c=bt(""),u=m.children("colgroup:first"),p=!0;0===u.length&&(u=bt(""),p=!1);var h=p?"col:visible":"col",v=bt("").css({display:"table-row","border-spacing":0,height:0,"border-collapse":"collapse"}),E=bt("
").css(vt.floatContainerCss).attr("aria-hidden","true"),M=!1,b=bt("
"),w=bt(''),g=bt([]),k=bt([]),D=bt([]),F=bt([]);b.append(w),m.prepend(u),Ct&&(l.append(v),m.append(l)),f.append(c),E.append(f),vt.copyTableClass&&f.attr("class",m.attr("class")),f.attr({cellpadding:m.attr("cellpadding"),cellspacing:m.attr("cellspacing"),border:m.attr("border")});var t=m.css("display");if(f.css({borderCollapse:m.css("borderCollapse"),border:m.css("border"),display:t}),L||f.css("width","auto"),"none"===t&&(M=!0),f.addClass(vt.floatTableClass).css({margin:0,"border-bottom-width":0}),z){var O=function(t,e){var o=t.css("position"),n=t;if(!("relative"===o||"absolute"===o)||e){var r={paddingLeft:t.css("paddingLeft"),paddingRight:t.css("paddingRight")};E.css(r),n=t.data("floatThead-containerWrap")||t.wrap(bt("
").addClass(vt.floatWrapperClass).css({position:"relative",clear:"both"})).parent(),t.data("floatThead-containerWrap",n),q=!0}return n};L?(s=O(x,!0)).prepend(E):(s=O(m),m.before(E))}else m.before(E);E.css({position:z?"absolute":"fixed",marginTop:0,top:z?0:"auto",zIndex:vt.zIndex,willChange:"transform"}),E.addClass(vt.floatContainerClass),V();var N={"table-layout":"fixed"},A={"table-layout":m.css("tableLayout")||"auto"},Q=m[0].style.width||"",U=m.css("minWidth")||"";function G(t){return t+".fth-"+e+".floatTHead"}function P(){var t=0;if(d.children("tr:visible").each(function(){t+=bt(this).outerHeight(!0)}),"collapse"===m.css("border-collapse")){var e=parseInt(m.css("border-top-width"),10);parseInt(m.find("thead tr:first").find(">*:first").css("border-top-width"),10)"),n.push(bt("").css({display:"table-cell",height:0,width:"auto"}))}o=p?u.html():o.join(""),Ct&&(v.empty(),v.append(n),F=v.find("fthtd")),g=w.find("th"),p||u.html(o),k=u.find(h),c.html(o),D=c.find(h)}return t}();return function(){var t=E.scrollLeft();k=u.find(h);var e,o,n,r,a=(e=m,o=k,n=F,r=mt,Ct?n:r?vt.getSizingRow(e,o,n):o);if(a.length===s&&0=v+y?(o=0,Y(),K(!1)):(o=y+v-u.top+s+(W?d:0),X(),K(!0)),n=g):L&&!z?(lv+y?(o=u.top-v,X(),K(!1)):(o=y,K(!0)),n=u.left+g-b);return{top:Math.round(o),left:Math.round(n)}}}}function et(){var i=null,l=null,s=null;return function(t,e,o){if(null!=t&&(i!==t.top||l!==t.left)){if(8===mt)E.css({top:t.top,left:t.left});else{var n="translateX("+t.left+"px) translateY("+t.top+"px)",r={"-webkit-transform":n,"-moz-transform":n,"-ms-transform":n,"-o-transform":n,transform:n,top:0,left:0};E.css(r)}i=t.top,l=t.left}e&&function(){var t=Ht(m,F,!0),e=j?S:x,o=e.length?zt(e[0]):t,n="hidden"!==e.css("overflow-y")?o-C.vertical:o;if(E.width(n),L){var r=100*t/n;f.css("width",r+"%")}else f.css("width",t+"px")}(),o&&P();var a=(j?S:x).scrollLeft();z&&s===a||(E.scrollLeft(a),s=a)}}function ot(){if(x.length)if(vt.support&&vt.support.perfectScrollbar&&x.data().perfectScrollbar)C={horizontal:0,vertical:0};else{if("scroll"===x.css("overflow-x"))C.horizontal=It;else{var t=x.width(),e=Ht(m,F),o=ntable>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}()); \ No newline at end of file diff --git a/package.json b/package.json index eabc52c..5714998 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "floatthead", - "version": "2.1.4", + "version": "2.2.0", "description": "fixed table header plugin that works", "main": "dist/jquery.floatThead.min.js", "type": "dist/jquery.floatThead.d.ts", "scripts": { - "build": "cp src/jquery.floatThead.js dist/jquery.floatThead.js && uglifyjs dist/jquery.floatThead.js --compress --mangle --comments -o dist/jquery.floatThead.min.js" + "build": "cp src/* dist/ && uglifyjs dist/jquery.floatThead.js --compress --mangle --comments -o dist/jquery.floatThead.min.js" }, "dependencies": {}, "devDependencies": { @@ -22,6 +22,7 @@ "fixed table header", "table", "thead", + "fixed position", "the cat is cute", "floatThead", "scrolling table", diff --git a/dist/jquery.floatThead.d.ts b/src/jquery.floatThead.d.ts similarity index 100% rename from dist/jquery.floatThead.d.ts rename to src/jquery.floatThead.d.ts diff --git a/src/jquery.floatThead.js b/src/jquery.floatThead.js index a6a0270..9988200 100644 --- a/src/jquery.floatThead.js +++ b/src/jquery.floatThead.js @@ -1,15 +1,15 @@ -/** @preserve jQuery.floatThead 2.2.0 - https://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2019 Misha Koryak **/ +/** @preserve jQuery.floatThead 2.2.0 - https://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2020 Misha Koryak **/ // @license MIT /* @author Misha Koryak * @projectDescription position:fixed on steroids. Lock a table header in place while scrolling. * * Dependencies: - * jquery 1.9.0 + [required] OR jquery 1.7.0 + jquery UI core + * jquery 1.9.0+ [required] OR jquery 1.7.0+ jquery UI core * * https://mkoryak.github.io/floatThead/ * - * Tested on FF13+, Chrome 21+, IE8, IE9, IE10, IE11 + * Tested on FF13+, Chrome 21+, IE9, IE10, IE11, EDGE */ (function( $ ) { /**