From f26934431e391852e75317cec63a6a60669a941a Mon Sep 17 00:00:00 2001 From: Tyler Crammond Date: Wed, 22 May 2019 12:10:19 +0100 Subject: [PATCH] fix(rememberthemilk): Fix errors and conform to styleguide in RememberTheMilk --- src/scripts/content/rememberthemilk.js | 19 +++++++++---------- src/styles/style.css | 7 +++++++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/scripts/content/rememberthemilk.js b/src/scripts/content/rememberthemilk.js index a48ffef5f..2a4fd65f2 100644 --- a/src/scripts/content/rememberthemilk.js +++ b/src/scripts/content/rememberthemilk.js @@ -22,21 +22,20 @@ togglbutton.render( return p.textContent; }; - // Create and return toggl button's instance. - const createTogglButton = function () { - return togglbutton.createTimerLink({ + const task = elem + .querySelector( + "div[role='listbox'] [role='option'] span[style*='user-select: text']" + ); + + if (task) { + const link = togglbutton.createTimerLink({ className: 'rememberthemilk', description: getDescription, projectName: getProject, buttonType: 'minimal' }); - }; - // Inject toggl button to each task. - elem - .querySelector( - "div[role='listbox'] [role='option'] span[style*='user-select: text']" - ) - .parentElement.appendChild(createTogglButton()); + task.parentElement.appendChild(link); + } } ); diff --git a/src/styles/style.css b/src/styles/style.css index 789f3fe9b..af94cbcc5 100644 --- a/src/styles/style.css +++ b/src/styles/style.css @@ -886,6 +886,13 @@ li > .toggl-button.phabricator { margin-left: 5px; position: absolute; } +.toggl-button.rememberthemilk:not(.active) { + display: none !important; +} + +*:hover > .toggl-button.rememberthemilk { + display: inline-block !important; +} /********* FRESHDESK *********/ .toggl-button.freshdesk {