Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions source/github-notifications-preview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ function createNotificationsDropdown() {
);

indicator.addEventListener('mouseenter', openDropdown);
if (options.closeOnMouseleave) {
let timer;
select('.NPG-dropdown').addEventListener('mouseleave', () => {
timer = setTimeout(closeDropdown, 1000);
});
select('.NPG-dropdown').addEventListener('mouseenter', () => {
clearTimeout(timer);
});
}

indicator.addEventListener('click', visitNotificationsPage);
}
}
Expand Down Expand Up @@ -169,6 +179,10 @@ async function openDropdown({currentTarget: indicator}) {
}
}

function closeDropdown() {
select('.NPG-container[open]').removeAttribute('open');
}

// When the dropdown is open, GitHub's modal blocks all links outside the dropdown.
// This handler lets the user visit /notifications while retaining any cmd/ctrl click modifier
function visitNotificationsPage(event) {
Expand Down
3 changes: 2 additions & 1 deletion source/options-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ window.optionsStorage = new OptionsSync({
defaults: {
previewCount: true,
dropdown: 'compact',
participating: false
participating: false,
closeOnMouseleave: false
}
});
6 changes: 6 additions & 0 deletions source/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
Show only participating notifications
</label>
</p>
<p>
<label>
<input type="checkbox" name="closeOnMouseleave">
Automatically close the popup when mouse is moved away
</label>
</p>
<p>
Show notifications list on hover: <br>
<label><input type="radio" name="dropdown" value="yes"> Yes</label><br>
Expand Down