From: Bill Erickson Date: Thu, 23 Aug 2018 17:52:38 +0000 (-0400) Subject: LP#1740412 Grid cell tooltips limited to long content X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1e9c0ab388a0697a1f099970240f2da21bfb5e1f;p=evergreen%2Fpines.git LP#1740412 Grid cell tooltips limited to long content Only display grid cell tooltips when the content of the cell overflows its container. Signed-off-by: Bill Erickson Signed-off-by: Michele Morgan Signed-off-by: Kathy Lussier --- diff --git a/Open-ILS/src/templates/staff/share/t_autogrid.tt2 b/Open-ILS/src/templates/staff/share/t_autogrid.tt2 index a7722f6e47..e77fa586af 100644 --- a/Open-ILS/src/templates/staff/share/t_autogrid.tt2 +++ b/Open-ILS/src/templates/staff/share/t_autogrid.tt2 @@ -328,9 +328,11 @@ - + @@ -342,8 +344,9 @@ {{text_value}} diff --git a/Open-ILS/web/js/ui/default/staff/services/grid.js b/Open-ILS/web/js/ui/default/staff/services/grid.js index f2b577c2de..62a4719b99 100644 --- a/Open-ILS/web/js/ui/default/staff/services/grid.js +++ b/Open-ILS/web/js/ui/default/staff/services/grid.js @@ -859,6 +859,32 @@ angular.module('egGridMod', return grid.modifyColumnPos(col, diff); } + // Returns true of the contents of the cell overflow its container. + // parentDepth tells the code how far up the DOM tree to traverse + // via parentNode before stopping to inspect the value. + // There's no way to pass a reference to a DOM node directly via + // a scope function (except ng-click, etc.) so pass the + // DOM id instead and get the node from there. + $scope.cellOverflowed = function(id, parentDepth) { + var node = document.getElementById(id); + if (!node) return; + for (var i = 0; i < parentDepth; i++) { + node = node.parentNode; + } + return node.scrollHeight > node.clientHeight + || node.scrollWidth > node.clientWidth; + } + + // Generates a unique identifier per cell per grid. + $scope.cellId = function(col, item) { + if (!col || !item) return ''; + return 'grid-cell-span-' + // differentiate grids + + ($scope.persistKey || $scope.idlClass || $scope.grid_element.id) + // differentiate rows and columns. + + '-' + col.name + '-' + $scope.indexValue(item); + + } // handles click, control-click, and shift-click $scope.handleRowClick = function($event, item) {