trilium/src/public/javascripts/services/tooltip.js
2018-03-26 23:48:45 -04:00

32 lines
No EOL
953 B
JavaScript

import noteDetailService from "./note_detail.js";
import treeUtils from "./tree_utils.js";
import linkService from "./link.js";
function setupTooltip() {
$(document).tooltip({
items: "#note-detail-text a",
content: function (callback) {
const notePath = linkService.getNotePathFromLink($(this).attr("href"));
if (notePath !== null) {
const noteId = treeUtils.getNoteIdFromNotePath(notePath);
noteDetailService.loadNote(noteId).then(note => callback(note.content));
}
},
close: function (event, ui) {
ui.tooltip.hover(function () {
$(this).stop(true).fadeTo(400, 1);
},
function () {
$(this).fadeOut('400', function () {
$(this).remove();
});
});
}
});
}
export default {
setupTooltip
}