Skip to content

Commit a0e2578

Browse files
committed
fix ff contextmenu colours + keybindings in the popup
1 parent 173323b commit a0e2578

File tree

7 files changed

+42
-15
lines changed

7 files changed

+42
-15
lines changed

html/settings.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,14 @@ <h4>Snoozz tabs using the right-click (context) menu</h4>
226226
</div>
227227
<div class="input-container flex" id="shortcut">
228228
<div>
229-
<h4>Keyboard shortcuts</h4>
230-
<p>Set up shortcuts to snooze a tab without any clicks.</p>
229+
<h4>Custom Keyboard Shortcuts</h4>
230+
<p>Set up your own shortcuts to snooze a tab without any clicks.</p>
231231
</div>
232232
<div tabindex="0" class="btn"><div></div></div>
233233
<div class="mini firefox-info">
234234
<strong>Instructions</strong>
235235
<ol>
236-
<li>Open the Firefox Add-Ons page in a new tab: <code>about:addons</code>.</li>
236+
<li>Open the Firefox Add-Ons page in a new tab: <u><code>about:addons</code></u>.</li>
237237
<li>Click on the <a tabindex="0" target="_blank" href="https://bug1303384.bmoattachments.org/attachment.cgi?id=9051647">gear icon</a> in the top right and select <strong>Manage Extension Shortcuts</strong>.</li>
238238
<li>Configure snooze time shortcuts using your own key bindings.</li>
239239
</ol>
@@ -244,7 +244,7 @@ <h4>Keyboard shortcuts</h4>
244244
</div>
245245
<div class="mini safari-info">
246246
<strong>Uh Oh</strong>
247-
<div>Keyboard Shortcuts cannot be configured for extensions in Safari.</div>
247+
<div>Shortcuts cannot be configured for extensions in Safari. You can blame Steve Jobs for this.</div>
248248
</div>
249249
<div class="mini shortcuts">
250250
<strong>Currently active shortcuts</strong>

scripts/flatpickr.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/nap_room.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ function buildTabActions(t, tabDiv) {
249249
}
250250
tabDiv.querySelector('.wakeup-label').innerText = t.deleted ? 'Deleted on' : (t.opened ? `Woke up ${t.opened < t.wakeUpTime ? 'manually' : 'automatically'} on` : 'Waking up')
251251
tabDiv.querySelector('.wakeup-time').innerText = t.opened ? dayjs(t.opened).format('dddd, D MMM') : formatSnoozedUntil(t)
252-
tabDiv.querySelector('.wakeup-time').title = dayjs(t.opened ? t.opened : t.wakeUpTime).format(`${getHourFormat()} [on] ddd, D MMMM YYYY`);
252+
tabDiv.querySelector('.wakeup-time').title = dayjs(t.opened ? t.opened : t.wakeUpTime).format(`${getHourFormat(true)} [on] ddd, D MMMM YYYY`);
253253
return tabDiv;
254254
}
255255

scripts/popup.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,23 @@ async function init() {
3535
}
3636

3737
document.addEventListener('keyup', e => {
38-
if (e.which >= 48 && e.which <= 56 && !document.querySelector('.form-overlay').classList.contains('show')) {
38+
if (e.which >= 49 && e.which <= 58 && !document.querySelector('.form-overlay').classList.contains('show')) {
3939
var choices = document.querySelectorAll('.choice');
4040
var selectedChoice = choices && choices.length > 0 ? choices[e.which - 48 - 1] : false;
4141
if (!selectedChoice || selectedChoice.classList.contains('disabled')) return;
4242
choices.forEach(c => c.classList.remove('focused'));
4343
selectedChoice.focus();
4444
}
45+
if (e.which === 48) {
46+
document.querySelectorAll('.choice').forEach(c => c.classList.remove('focused'))
47+
document.querySelector('.choice:last-of-type').focus();
48+
}
4549
if (e.which === 13 && !document.querySelector('.form-overlay').classList.contains('show')) {
4650
var selectedChoice = document.querySelector('.choice.focused');
4751
if (!selectedChoice) return;
4852
snooze(o.time, c)
4953
}
54+
if (e.which === 67) document.querySelector('.custom-choice').click();
5055
if (e.which === 84) document.getElementById('tab').click();
5156
if (e.which === 87) document.getElementById('window').click();
5257
if (e.which === 83) document.getElementById('selection').click();
@@ -151,6 +156,7 @@ async function buildChoices() {
151156
var now = Object.assign(document.createElement('option'), {value: 'now', innerText: 'Current Time', selected: s === 'now'});
152157

153158
var select = document.createElement('select');
159+
select.tabIndex = -1;
154160
select.addEventListener('change', async e => {
155161
await savePopupOptions();
156162
// change time
@@ -179,7 +185,15 @@ async function buildChoices() {
179185
tabIndex: o.disabled ? -1 : 0,
180186
}, wrapInDiv('', icon, label), o.startUp ? wrapInDiv() : wrapInDiv('', date, time));
181187
c.addEventListener('mouseover', _ => c.classList.add('focused'))
182-
c.addEventListener('mouseout', _ => c.classList.remove('focused'))
188+
c.addEventListener('mouseout', _ => c.classList.remove('focused'));
189+
if (['weekend', 'monday', 'week', 'month'].includes(name)) c.addEventListener('keydown', e => {
190+
if (!e || e.which !== 38 && e.which !== 40) return;
191+
var options = select.querySelectorAll('option');
192+
var current = Array.from(options).findIndex(o => o.selected);
193+
if (e.which === 38 && current > 0) options[current - 1].selected = true;
194+
if (e.which === 40 && current < options.length - 1) options[current + 1].selected = true;
195+
select.dispatchEvent(new Event('change'));
196+
})
183197
c.onclick = e => {if (!['OPTION', 'SELECT'].includes(e.target.nodeName)) snooze(o.startUp ? 'startup' : o.time, c)}
184198
c.onkeyup = e => {if (e.which === 13) snooze(o.startUp ? 'startup' : o.time, c)}
185199
return c
@@ -248,7 +262,12 @@ async function buildCustomChoice() {
248262
onclick: _ => {
249263
customChoice.classList.add('focused');
250264
document.querySelectorAll('.choice').forEach(c => {c.classList.add('disabled');c.setAttribute('tabindex','-1')});
251-
// document.querySelector('.popup-checkbox input').setAttribute('tabindex', '-1');
265+
document.querySelector('.form-overlay').classList.add('show')
266+
},
267+
onkeydown: e => {
268+
if (!e || e.which !== 13 && e.which !== 32) return;
269+
customChoice.classList.add('focused');
270+
document.querySelectorAll('.choice').forEach(c => {c.classList.add('disabled');c.setAttribute('tabindex','-1')});
252271
document.querySelector('.form-overlay').classList.add('show')
253272
}
254273
}, wrapInDiv('', icon, label), wrapInDiv('custom-info', wrapInDiv('display', wrapInDiv('date-display'), wrapInDiv('time-display')), submitButton));

scripts/rise.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function populate(found) {
3030
document.querySelector('#when span').innerText = dayjs(found.timeCreated).format(`${getHourFormat(true)} on dddd, DD MMM YYYY`)
3131
var till = document.querySelector('#till span');
3232
till.innerText = found.startUp ? 'the next time you opened ' + capitalize(getBrowser()) : dayjs(found.timeCreated).to(dayjs(found.wakeUpTime),true) + ' later'
33-
till.setAttribute('title', dayjs(found.wakeUpTime).format(`${getHourFormat()} on dddd, DD MMM YYYY`))
33+
till.setAttribute('title', dayjs(found.wakeUpTime).format(`${getHourFormat(true)} on dddd, DD MMM YYYY`))
3434
var tabList = document.querySelector('.tab-list');
3535
found.tabs.forEach((t, i) => {
3636
var iconImg = Object.assign(document.createElement('img'), {src: getFaviconUrl(t.url)});

styles/popup.css

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,14 @@ h3 {
273273
position: relative;
274274
}
275275

276-
.choice.focused select {
276+
.choice.focused select, select:focus:hover, .choice:focus-visible select {
277277
background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z' fill='white'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
278278
}
279279

280280
body.dark .choice .date {
281281
color: #AAA;
282282
}
283-
.choice:hover *, .choice.focused *, .choice:hover .date, .custom-choice:hover *, .custom-choice.focused *, .custom-choice.really-focused {
283+
.choice:hover *, .choice.focused *, .choice:hover .date, .custom-choice:hover *, .custom-choice.focused *, .custom-choice.really-focused, .choice:focus-visible *, .custom-choice:focus-visible * {
284284
color: #FFF !important;
285285
}
286286

@@ -332,13 +332,17 @@ body.dark .choice .date {
332332
opacity: 0.2;
333333
}
334334

335-
.choice.focused, .custom-choice.focused, .custom-choice.really-focused {
335+
.choice.focused, .choice:focus-visible, .choice:focus-within:hover, .custom-choice.focused, .custom-choice:focus-visible, .custom-choice.really-focused {
336336
background-color: var(--bg) !important;
337337
}
338338
.choice.focused, .custom-choice.focused {
339339
transition: background-color 0s linear;
340340
cursor: default;
341341
}
342+
.choice select:focus:hover {
343+
color: var(--color);
344+
background-color: rgba(0,0,0,.5);
345+
}
342346

343347
body.dark #preview, body.dark .choice, body.dark .custom-choice, body.dark .form-overlay {
344348
background-color: #444

styles/settings.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ option {
6969
color: var(--color);
7070
background-color: var(--bg-color);
7171
}
72+
select:focus:hover {
73+
color: var(--color);
74+
background-color: rgba(0,0,0,.5);
75+
}
7276
.select-wrapper, .btn {
7377
position: relative;
7478
cursor: pointer;
@@ -132,7 +136,7 @@ span.am-pm {
132136
font-size: .8em;
133137
margin-left: .5rem;
134138
}
135-
body.dark select {
139+
body.dark select, select:focus:hover, select:focus-visible {
136140
background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'><path fill='white' d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
137141
}
138142
#right-click .btn div:before {
@@ -229,7 +233,7 @@ kbd {
229233
code {
230234
cursor: pointer;
231235
font-size: 1.2em;
232-
background-color: #999;
236+
background-color: rgba(0, 0, 0, .3);
233237
border-radius: .25em;
234238
padding: .1em .2em;
235239
user-select: none;

0 commit comments

Comments
 (0)