From 9847837ae9aed1acd52ccc4730b6c6ddc72b3d5e Mon Sep 17 00:00:00 2001 From: Tom Hill Date: Tue, 27 Mar 2018 12:30:39 +1100 Subject: [PATCH] Adds @pxgamer's changes and closes #7. New todos for release. --- main.js | 14 +++++++++++++- todo.md | 10 +++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/main.js b/main.js index bfcb3de..6f822cc 100644 --- a/main.js +++ b/main.js @@ -87,6 +87,7 @@ function createTooltip (content, isMarked = false) { } } +// removes the tooltip, arrow and content function removeTooltip () { if (tooltip != null) { tooltip.parentNode.removeChild(tooltip) @@ -97,7 +98,17 @@ function removeTooltip () { } } -window.onmousedown = removeTooltip +// Ensures the tldr tooltip does not close if clicked on +window.onmousedown = (mouseDownEvent) => { + let isPopup = false + mouseDownEvent.path.forEach((elementInPath) => { + if (elementInPath.id === 'tldr-chrome') isPopup = true + }) + + if (!isPopup) { + removeTooltip() + } +} let commandList = [] @@ -136,6 +147,7 @@ function checkCode () { }) } +// Deletes the tooltip and resizes when window is resized. window.onresize = event => { let oldContent if (tooltip) { diff --git a/todo.md b/todo.md index f604377..9146eb9 100644 --- a/todo.md +++ b/todo.md @@ -15,12 +15,11 @@ - [x] Better fonts - [x] Remove styles inherited from document (thanks @pxgamer) -## v0.3.0 +## ~~v0.3.0~~ -- [ ] comment / document current codebase -- [ ] flip tooltip position based on where the element is on the page +- [x] comment / document current codebase - [x] Convert to `fetch` rather than `XMLHttpRequest` (see #4) -- [ ] Ensure the tooltip does not disappear when clicking within the tooltip itself but is removed when user clicks outside of the tooltip +- [x] Ensure the tooltip does not disappear when clicking within the tooltip itself but is removed when user clicks outside of the tooltip ## v1.0.0 :raised_hands: (release) - [x] Icon for right-click menu bar @@ -28,7 +27,6 @@ - [ ] Screenshots - [ ] Description - [ ] Better README -- [ ] Contribution Guidelines ## Other features - [ ] search for keywords in pre and code tags @@ -38,5 +36,7 @@ - [ ] keyboard shortcut - [ ] light theme - [ ] compose button +- [ ] flip tooltip position based on where the element is on the page +- [ ] copy to clipboard (To request a feature you can create an issue *or*, better yet, submit a pull request with the feature implemented :wink:)