Remove buttons when previewing a matched cell

This commit is contained in:
Antonin Delpeuch 2019-02-19 16:56:07 +00:00
parent c509dd3847
commit 4344b2474c

View File

@ -108,7 +108,7 @@ DataTableCellUI.prototype._render = function() {
a.attr("href", encodeURI(service.view.url.replace("{{id}}", match.id))); a.attr("href", encodeURI(service.view.url.replace("{{id}}", match.id)));
} }
self._previewOnHover(service, match, a); self._previewOnHover(service, match, a, false);
$('<span> </span>').appendTo(divContent); $('<span> </span>').appendTo(divContent);
$('<a href="javascript:{}"></a>') $('<a href="javascript:{}"></a>')
@ -153,7 +153,7 @@ DataTableCellUI.prototype._render = function() {
a.attr("href", encodeURI(service.view.url.replace("{{id}}", candidate.id))); a.attr("href", encodeURI(service.view.url.replace("{{id}}", candidate.id)));
} }
self._previewOnHover(service, candidate, liSpan); self._previewOnHover(service, candidate, liSpan, true);
var score; var score;
if (candidate.score < 1) { if (candidate.score < 1) {
@ -418,15 +418,18 @@ DataTableCellUI.prototype._postProcessSeveralCells = function(command, params, b
); );
}; };
DataTableCellUI.prototype._previewCandidateTopic = function(candidate, elmt, preview) { DataTableCellUI.prototype._previewCandidateTopic = function(candidate, elmt, preview, showActions) {
var self = this; var self = this;
var id = candidate.id; var id = candidate.id;
var fakeMenu = $('<div></div>') var fakeMenu = $('<div></div>')
.addClass("menu-container"); .addClass("menu-container");
fakeMenu fakeMenu
.width(preview.width?preview.width:414) .width(preview.width?preview.width:414)
.addClass('data-table-topic-popup') .addClass('data-table-topic-popup');
if (showActions) {
fakeMenu
.html(DOM.loadHTML("core", "scripts/views/data-table/cell-recon-preview-popup-header.html")); .html(DOM.loadHTML("core", "scripts/views/data-table/cell-recon-preview-popup-header.html"));
}
if (preview && preview.url) { // Service has a preview URL associated with it if (preview && preview.url) { // Service has a preview URL associated with it
var url = encodeURI(preview.url.replace("{{id}}", id)); var url = encodeURI(preview.url.replace("{{id}}", id));
@ -447,6 +450,7 @@ DataTableCellUI.prototype._previewCandidateTopic = function(candidate, elmt, pre
fakeMenu.unbind(); fakeMenu.unbind();
}; };
if (showActions) {
var elmts = DOM.bind(fakeMenu); var elmts = DOM.bind(fakeMenu);
elmts.matchButton.html($.i18n('core-views/match-cell')); elmts.matchButton.html($.i18n('core-views/match-cell'));
@ -464,13 +468,14 @@ DataTableCellUI.prototype._previewCandidateTopic = function(candidate, elmt, pre
elmts.cancelButton.click(function() { elmts.cancelButton.click(function() {
dismissMenu(); dismissMenu();
}); });
}
return dismissMenu; return dismissMenu;
}; };
/** /**
* Sets up a preview widget to appear when hovering the given DOM element. * Sets up a preview widget to appear when hovering the given DOM element.
*/ */
DataTableCellUI.prototype._previewOnHover = function(service, candidate, element) { DataTableCellUI.prototype._previewOnHover = function(service, candidate, element, showActions) {
var self = this; var self = this;
var preview = null; var preview = null;
if ((service) && (service.preview)) { if ((service) && (service.preview)) {
@ -481,7 +486,7 @@ DataTableCellUI.prototype._previewOnHover = function(service, candidate, element
var dismissCallback = null; var dismissCallback = null;
element.hover(function(evt) { element.hover(function(evt) {
if (!evt.metaKey && !evt.ctrlKey) { if (!evt.metaKey && !evt.ctrlKey) {
dismissCallback = self._previewCandidateTopic(candidate, this, preview); dismissCallback = self._previewCandidateTopic(candidate, this, preview, showActions);
evt.preventDefault(); evt.preventDefault();
} }
}, function(evt) { }, function(evt) {