From 614a9fa1cc5d8bf6fc314e7e9c71b77e5367fb85 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Mon, 16 May 2022 19:30:18 +0300 Subject: [PATCH] [SSE] Add tooltips in search results --- .../main/app/controller/Search.js | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Search.js b/apps/spreadsheeteditor/main/app/controller/Search.js index 869993ac7..f0465d066 100644 --- a/apps/spreadsheeteditor/main/app/controller/Search.js +++ b/apps/spreadsheeteditor/main/app/controller/Search.js @@ -420,27 +420,47 @@ define([ data.forEach(function (item, ind) { var isSelected = ind === me._state.currentResult; var tr = '
' + - '
' + item[1] + '
' + - '
' + item[2] + '
' + - '
' + item[3] + '
' + - '
' + item[4] + '
' + - '
' + item[5] + '
' + + '
' + (item[1] ? item[1] : '') + '
' + + '
' + (item[2] ? item[2] : '') + '
' + + '
' + (item[3] ? item[3] : '') + '
' + + '
' + (item[4] ? item[4] : '') + '
' + + '
' + (item[5] ? item[5] : '') + '
' + '
'; var $item = $(tr).appendTo($innerResults); if (isSelected) { $item.addClass('selected'); } - var resultItem = {id: item[0], $el: $item, el: tr, selected: isSelected}; + var resultItem = {id: item[0], $el: $item, el: tr, selected: isSelected, data: data}; me.resultItems.push(resultItem); $item.on('click', _.bind(function (el) { var id = item[0]; me.api.asc_SelectSearchElement(id); }, me)); + me.addTooltips($item, item); }); this.view.$resultsContainer.show(); } }, + addTooltips: function (item, data) { + var cells = [item.find('.sheet'), item.find('.name'), item.find('.cell'), item.find('.value'), item.find('.formula')], + tips = [data[1], data[2], data[3], data[4], data[5]]; + cells.forEach(function (el, ind) { + var tip = tips[ind]; + if (tip) { + el.one('mouseenter', function () { + el.attr('data-toggle', 'tooltip'); + el.tooltip({ + title: tip, + placement: 'cursor', + zIndex: 1000 + }); + el.mouseenter(); + }); + } + }); + }, + hideResults: function () { if (this.view) { this.view.$resultsContainer.hide(); @@ -496,6 +516,7 @@ define([ $('#search-results').find('.item').removeClass('selected'); $(el.currentTarget).addClass('selected'); }); + me.addTooltips($item, item.data); }); this.scrollToSelectedResult(); }