diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index 892399058..d1eac2761 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -1319,3 +1319,45 @@ export default class NoteTreeWidget extends TabAwareWidget { noteCreateService.duplicateNote(node.data.noteId, branch.parentNoteId); } } + +export function setupNoteTitleTooltip() { + // Source - https://gist.github.com/jtsternberg/c272d7de5b967cec2d3d + var is_colliding = function( $div1, $div2 ) { + // Div 1 data + var d1_offset = $div1.offset(); + var d1_height = $div1.outerHeight( true ); + var d1_width = $div1.outerWidth( true ); + var d1_distance_from_top = d1_offset.top + d1_height; + var d1_distance_from_left = d1_offset.left + d1_width; + + // Div 2 data + var d2_offset = $div2.offset(); + var d2_height = $div2.outerHeight( true ); + var d2_width = $div2.outerWidth( true ); + var d2_distance_from_top = d2_offset.top + d2_height; + var d2_distance_from_left = d2_offset.left + d2_width; + + var not_colliding = ( d1_distance_from_top < d2_offset.top + || d1_offset.top > d2_distance_from_top + || d1_distance_from_left < d2_offset.left + || d1_offset.left > d2_distance_from_left ); + + // Return whether it IS colliding + return ! not_colliding; + }; + + // Detects if there is a collision between the note-title and the + // center-pane element + let centerPane = document.getElementById("center-pane"); + $(document).on("mouseenter", "span", + function(e) { + if (e.currentTarget.className === 'fancytree-title') { + if(is_colliding($(centerPane), $(e.currentTarget))) { + e.currentTarget.title = e.currentTarget.innerText; + } else { + e.currentTarget.title = ""; + } + } + } + ); +} diff --git a/src/public/app/widgets/side_pane_toggles.js b/src/public/app/widgets/side_pane_toggles.js index df443ae13..a2819d510 100644 --- a/src/public/app/widgets/side_pane_toggles.js +++ b/src/public/app/widgets/side_pane_toggles.js @@ -1,6 +1,7 @@ import options from "../services/options.js"; import splitService from "../services/split.js"; import BasicWidget from "./basic_widget.js"; +import { setupNoteTitleTooltip } from './note_tree.js' const TPL = `
@@ -70,5 +71,7 @@ export default class SidePaneToggles extends BasicWidget { this.toggleSidebar('right', options.is('rightPaneVisible')); splitService.setupSplit(this.paneVisible.left, this.paneVisible.right); + + setupNoteTitleTooltip(); } }