From a8971b4e204ef5d9348fda25b52582886b393cb1 Mon Sep 17 00:00:00 2001 From: zmagod Date: Mon, 11 Jun 2018 15:22:56 +0200 Subject: [PATCH] enables tooltip on long column names [fixes SCI-2427] --- .../repositories/repository_datatable.js.erb | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/app/assets/javascripts/repositories/repository_datatable.js.erb b/app/assets/javascripts/repositories/repository_datatable.js.erb index 3075232a8..81f35bb6c 100644 --- a/app/assets/javascripts/repositories/repository_datatable.js.erb +++ b/app/assets/javascripts/repositories/repository_datatable.js.erb @@ -214,6 +214,7 @@ var RepositoryDatatable = (function(global) { bindExportActions(); disableCheckboxToggleOnAssetDownload(); initPreviewModal(); + initHeaderTooltip(); } }); @@ -1093,6 +1094,34 @@ var RepositoryDatatable = (function(global) { TABLE.button(0).enable(false); } + function initHeaderTooltip() { + // Fix compatibility of fixed table header and column names modal-tooltip + $('.modal-tooltip').off(); + $('.modal-tooltip').hover(function() { + var $tooltip = $(this).find('.modal-tooltiptext'); + var offsetLeft = $tooltip.offset().left; + (offsetLeft + 200) > $(window).width() ? offsetLeft -= 150 : offsetLeft; + var offsetTop = $tooltip.offset().top; + $('body').append($tooltip); + $tooltip.css('background-color', '#d2d2d2'); + $tooltip.css('border-radius', '6px'); + $tooltip.css('color', '#333'); + $tooltip.css('display', 'block'); + $tooltip.css('left', offsetLeft + 'px'); + $tooltip.css('padding', '5px'); + $tooltip.css('position', 'absolute'); + $tooltip.css('text-align', 'center'); + $tooltip.css('top', offsetTop + 'px'); + $tooltip.css('visibility', 'visible'); + $tooltip.css('width', '200px'); + $tooltip.css('word-wrap', 'break-word'); + $(this).data('dropdown-tooltip', $tooltip); + }, function() { + $(this).append($(this).data('dropdown-tooltip')); + $(this).data('dropdown-tooltip').removeAttr('style'); + }); + } + /* * Repository columns dropdown */