From 39743a396a3874397ed67b3a8211ea045d6a8c7e Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Fri, 18 Mar 2016 13:16:23 +0000 Subject: [PATCH] SSDM-3357 : Tooltip on table cells. SVN: 35942 --- .../webapps/eln-lims/html/lib/grid/js/Grid.js | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/lib/grid/js/Grid.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/lib/grid/js/Grid.js index c33344f1a0a..34b9b0da48c 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/lib/grid/js/Grid.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/lib/grid/js/Grid.js @@ -335,21 +335,39 @@ $.extend(Grid.prototype, { renderData : function(dataList) { var thisGrid = this; var items = []; - var maxLineLength = 300; + var maxLineLength = 200; dataList.forEach(function(data) { var item = {}; thisGrid.getVisibleColumns().forEach(function(column) { + //1. Render var value = null; if (column.render) { value = column.render(data); } else { value = data[column.property]; - if(value && value.length > maxLineLength) { - value = value.substring(0, maxLineLength) + "..."; - } } - item[column.property] = FormUtil.sanitizeRichHTMLText(value); + + //2. Sanitize + var value = FormUtil.sanitizeRichHTMLText(value); + + //3. Shorten + var finalValue = null; + if(value && value.length > maxLineLength) { + finalValue = value.substring(0, maxLineLength) + "..."; + } else { + finalValue = value; + } + + //4. Tooltip + if(value !== finalValue) { + finalValue = $("<div>").append(finalValue); + finalValue.tooltipster({ + content: $(value) + }); + } + + item[column.property] = finalValue; }); items.push(item); }); -- GitLab