mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-04 03:36:44 +08:00
Merge pull request #689 from mlorb/ml_sci_1354
Truncate and display text in tooltip in custom repository fields [SCI-1354]
This commit is contained in:
commit
14429a270c
4 changed files with 23 additions and 5 deletions
|
@ -118,6 +118,7 @@ function dataTableInit() {
|
|||
rowsSelected.length +
|
||||
' entries selected)');
|
||||
initRowSelection();
|
||||
initHeaderTooltip();
|
||||
},
|
||||
preDrawCallback: function() {
|
||||
animateSpinner(this);
|
||||
|
@ -352,6 +353,13 @@ function initHeaderTooltip() {
|
|||
offsetLeft -= 150;
|
||||
}
|
||||
var offsetTop = $tooltip.offset().top;
|
||||
var width = 200;
|
||||
|
||||
// set tooltip params in the table body
|
||||
if ( $(this).parents('#repository-table').length ) {
|
||||
offsetLeft = $('#repository-table').offset().left + 100;
|
||||
width = $('#repository-table').width() - 200;
|
||||
}
|
||||
$('body').append($tooltip);
|
||||
$tooltip.css('background-color', '#d2d2d2');
|
||||
$tooltip.css('border-radius', '6px');
|
||||
|
@ -363,8 +371,9 @@ function initHeaderTooltip() {
|
|||
$tooltip.css('text-align', 'center');
|
||||
$tooltip.css('top', offsetTop + 'px');
|
||||
$tooltip.css('visibility', 'visible');
|
||||
$tooltip.css('width', '200px');
|
||||
$tooltip.css('width', width + 'px');
|
||||
$tooltip.css('word-wrap', 'break-word');
|
||||
$tooltip.css('z-index', '4');
|
||||
$(this).data('dropdown-tooltip', $tooltip);
|
||||
}, function() {
|
||||
$(this).append($(this).data('dropdown-tooltip'));
|
||||
|
@ -832,6 +841,7 @@ function changeToEditMode() {
|
|||
currentMode = 'editMode';
|
||||
// Table specific stuff
|
||||
table.button(0).enable(false);
|
||||
initHeaderTooltip();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1576,6 +1576,11 @@ table.dataTable {
|
|||
visibility: visible;
|
||||
}
|
||||
|
||||
// don't display tooltip, it's handeled with js
|
||||
.repository-table .modal-tooltip:hover .modal-tooltiptext {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
// Comments
|
||||
|
||||
.comment-more {
|
||||
|
|
|
@ -118,9 +118,12 @@ class RepositoryDatatable < AjaxDatatablesRails::Base
|
|||
# Add custom columns
|
||||
record.repository_cells.each do |cell|
|
||||
row[@columns_mappings[cell.repository_column.id]] =
|
||||
custom_auto_link(cell.value.data,
|
||||
custom_auto_link(
|
||||
display_tooltip(cell.value.data,
|
||||
Constants::NAME_MAX_LENGTH),
|
||||
simple_format: true,
|
||||
team: @team)
|
||||
team: @team
|
||||
)
|
||||
end
|
||||
row
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def display_tooltip(message, len = Constants::NAME_TRUNCATION_LENGTH)
|
||||
if message.strip.length > Constants::NAME_TRUNCATION_LENGTH
|
||||
if message.strip.length > len
|
||||
sanitize_input("<div class='modal-tooltip'> \
|
||||
#{truncate(message.strip, length: len)} \
|
||||
<span class='modal-tooltiptext'> \
|
||||
|
|
Loading…
Reference in a new issue