From 28c745c19c6ece4a7ebaa1e73580b92f8bb637ab Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Fri, 2 Oct 2020 00:22:19 -0700 Subject: [PATCH] Patch DataTables ColVis to fix dropdown extending past bottom of page --- data/interfaces/default/css/dataTables.colVis.css | 2 +- data/interfaces/default/js/dataTables.colVis.js | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/data/interfaces/default/css/dataTables.colVis.css b/data/interfaces/default/css/dataTables.colVis.css index 94bcdd39..dcbfa76f 100644 --- a/data/interfaces/default/css/dataTables.colVis.css +++ b/data/interfaces/default/css/dataTables.colVis.css @@ -71,7 +71,7 @@ ul.ColVis_collection { list-style: none; width: 150px; padding: 8px 8px 4px 8px; - margin: 10px 0px 0px 0px; + margin: 10px 0px 10px 0px; background-color: #444; overflow: hidden; z-index: 2002; diff --git a/data/interfaces/default/js/dataTables.colVis.js b/data/interfaces/default/js/dataTables.colVis.js index cc13cd8c..1a2df816 100644 --- a/data/interfaces/default/js/dataTables.colVis.js +++ b/data/interfaces/default/js/dataTables.colVis.js @@ -790,6 +790,9 @@ ColVis.prototype = { oStyle.top = oPos.top+"px"; oStyle.left = iDivX+"px"; + var iDocWidth = $(document).width(); + var iDocHeight = $(document).height(); + document.body.appendChild( nBackground ); document.body.appendChild( nHidden ); document.body.appendChild( this.dom.catcher ); @@ -819,12 +822,17 @@ ColVis.prototype = { var iDivWidth = $(nHidden).outerWidth(); var iDivHeight = $(nHidden).outerHeight(); - var iDocWidth = $(document).width(); + var iDivMarginTop = parseInt($(nHidden).css("marginTop"), 10); + var iDivMarginBottom = parseInt($(nHidden).css("marginBottom"), 10); if ( iLeft + iDivWidth > iDocWidth ) { nHidden.style.left = (iDocWidth-iDivWidth)+"px"; } + if ( iDivY + iDivHeight > iDocHeight ) + { + nHidden.style.top = (oPos.top - iDivHeight - iDivMarginTop - iDivMarginBottom)+"px"; + } } this.s.hidden = false; @@ -846,7 +854,8 @@ ColVis.prototype = { this.s.hidden = true; $(this.dom.collection).animate({"opacity": 0}, that.s.iOverlayFade, function (e) { - this.style.display = "none"; + // this.style.display = "none"; + document.body.removeChild( this ); } ); $(this.dom.background).animate({"opacity": 0}, that.s.iOverlayFade, function (e) {