mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-09 13:28:53 +08:00
truncate and display text in tooltip in custom repository fields
This commit is contained in:
parent
3df034ff21
commit
a195c9a5af
4 changed files with 23 additions and 4 deletions
|
@ -355,6 +355,13 @@ function initHeaderTooltip() {
|
||||||
offsetLeft -= 150;
|
offsetLeft -= 150;
|
||||||
}
|
}
|
||||||
var offsetTop = $tooltip.offset().top;
|
var offsetTop = $tooltip.offset().top;
|
||||||
|
var width = 200;
|
||||||
|
|
||||||
|
// set tooltip params in the table body
|
||||||
|
if ( $(this).parents('#repository-table').length ) {
|
||||||
|
offsetLeft -= 130;
|
||||||
|
width = $('#repository-table').width() - 200;
|
||||||
|
}
|
||||||
$('body').append($tooltip);
|
$('body').append($tooltip);
|
||||||
$tooltip.css('background-color', '#d2d2d2');
|
$tooltip.css('background-color', '#d2d2d2');
|
||||||
$tooltip.css('border-radius', '6px');
|
$tooltip.css('border-radius', '6px');
|
||||||
|
@ -366,7 +373,7 @@ function initHeaderTooltip() {
|
||||||
$tooltip.css('text-align', 'center');
|
$tooltip.css('text-align', 'center');
|
||||||
$tooltip.css('top', offsetTop + 'px');
|
$tooltip.css('top', offsetTop + 'px');
|
||||||
$tooltip.css('visibility', 'visible');
|
$tooltip.css('visibility', 'visible');
|
||||||
$tooltip.css('width', '200px');
|
$tooltip.css('width', width + 'px');
|
||||||
$tooltip.css('word-wrap', 'break-word');
|
$tooltip.css('word-wrap', 'break-word');
|
||||||
$(this).data('dropdown-tooltip', $tooltip);
|
$(this).data('dropdown-tooltip', $tooltip);
|
||||||
}, function() {
|
}, function() {
|
||||||
|
@ -431,12 +438,14 @@ function onClickAddRecord() {
|
||||||
viewAssigned = 'assigned';
|
viewAssigned = 'assigned';
|
||||||
table.ajax.reload(function() {
|
table.ajax.reload(function() {
|
||||||
initRowSelection();
|
initRowSelection();
|
||||||
|
initHeaderTooltip();
|
||||||
}, false);
|
}, false);
|
||||||
});
|
});
|
||||||
$('#all-repo-records').on('click', function() {
|
$('#all-repo-records').on('click', function() {
|
||||||
viewAssigned = 'all';
|
viewAssigned = 'all';
|
||||||
table.ajax.reload(function() {
|
table.ajax.reload(function() {
|
||||||
initRowSelection();
|
initRowSelection();
|
||||||
|
initHeaderTooltip();
|
||||||
}, false);
|
}, false);
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -1576,6 +1576,11 @@ table.dataTable {
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// don't display tooltip, it's handeled with js
|
||||||
|
.repository-table .modal-tooltip:hover .modal-tooltiptext {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
// Comments
|
// Comments
|
||||||
|
|
||||||
.comment-more {
|
.comment-more {
|
||||||
|
|
|
@ -118,9 +118,12 @@ class RepositoryDatatable < AjaxDatatablesRails::Base
|
||||||
# Add custom columns
|
# Add custom columns
|
||||||
record.repository_cells.each do |cell|
|
record.repository_cells.each do |cell|
|
||||||
row[@columns_mappings[cell.repository_column.id]] =
|
row[@columns_mappings[cell.repository_column.id]] =
|
||||||
custom_auto_link(cell.value.data,
|
custom_auto_link(
|
||||||
|
display_tooltip(cell.value.data,
|
||||||
|
Constants::TABLE_FIELDS_TRUNCATION_LENGTH),
|
||||||
simple_format: true,
|
simple_format: true,
|
||||||
team: @team)
|
team: @team
|
||||||
|
)
|
||||||
end
|
end
|
||||||
row
|
row
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,6 +11,8 @@ class Constants
|
||||||
NAME_TRUNCATION_LENGTH = 25
|
NAME_TRUNCATION_LENGTH = 25
|
||||||
# Max characters for short text fields, in dropdownList
|
# Max characters for short text fields, in dropdownList
|
||||||
NAME_TRUNCATION_LENGTH_DROPDOWN = 20
|
NAME_TRUNCATION_LENGTH_DROPDOWN = 20
|
||||||
|
# Max characters for datatables fields
|
||||||
|
TABLE_FIELDS_TRUNCATION_LENGTH = 250
|
||||||
# Max characters for long text fields
|
# Max characters for long text fields
|
||||||
TEXT_MAX_LENGTH = 10000
|
TEXT_MAX_LENGTH = 10000
|
||||||
# Max characters for rich text fields (in html format)
|
# Max characters for rich text fields (in html format)
|
||||||
|
|
Loading…
Add table
Reference in a new issue