Skip to content

Commit 1735fe2

Browse files
authored
Update for Firefox Mobile (#50)
* Update for Firefox Mobile * Fix Keyboard Shortcut Name * Cleanup
1 parent 7de544b commit 1735fe2

File tree

8 files changed

+83
-44
lines changed

8 files changed

+83
-44
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"suggested_key": {
2323
"default": "Alt+Shift+G"
2424
},
25-
"description": "Upload Files"
25+
"description": "Open Gallery"
2626
}
2727
},
2828
"permissions": [

src/css/options.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ video {
1616
}
1717

1818
.card {
19-
min-width: 400px;
19+
min-width: 360px;
2020
background: rgba(0 0 0 / 70%);
2121
}
2222

src/css/popup.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* CSS for popup.html */
22

33
body {
4-
width: 380px;
54
overflow-x: hidden;
65
}
76

src/html/options.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h1>Django Files Options</h1>
2929
<div class="clearfix"></div>
3030
<p class="text-center lead">v<span id="version"></span></p>
3131

32-
<table id="keyboard-shortcuts" class="table table-sm table-borderless table-hover">
32+
<table id="keyboard-shortcuts" class="table table-sm table-borderless table-hover d-none">
3333
<caption class="visually-hidden">Keyboard Shortcuts</caption>
3434
<thead class="visually-hidden"><tr><th>Description</th><th>Shortcut</th></tr></thead>
3535
<tbody>

src/html/popup.html

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<body>
1515

1616
<div class="container-fluid p-2">
17-
<div class="head mb-1">
17+
<div class="head mb-2">
1818
<div class="form-check form-switch float-start form-select-lg pb-0" style="padding-top: 1px;"
1919
data-bs-title="Disable/Enable Mouseover Preview." data-bs-placement="bottom" data-bs-toggle="tooltip" data-bs-trigger="hover">
2020
<input class="form-check-input" id="popupPreview" type="checkbox" role="switch">
@@ -25,9 +25,9 @@
2525
<a id="always-auth" class="d-none btn btn-sm btn-outline-warning float-end add-auth" role="button"
2626
data-bs-title="Update Authentication with Current Site." data-bs-placement="bottom" data-bs-toggle="tooltip" data-bs-trigger="hover">
2727
<i class="fa-solid fa-key"></i></a>
28-
<div class="d-flex align-items-center justify-content-center">
28+
<div class="d-flex align-items-center overflow-hidden text-nowrap">
2929
<a href=""><img src="../media/logo32.png" class="me-1" height="32" width="32" alt="Django Files"></a>
30-
<h3 class="my-0"><a class="link-body-emphasis text-decoration-none" href="">Django Files</a></h3>
30+
<h4 class="my-0"><a class="link-body-emphasis text-decoration-none" href="">Django Files</a></h4>
3131
</div>
3232
</div>
3333

@@ -90,31 +90,31 @@ <h3 class="my-0"><a class="link-body-emphasis text-decoration-none" href="">Djan
9090
</div>
9191

9292
<div class="toast align-items-center border-0 mb-3" role="alert" aria-live="assertive" aria-atomic="true" data-bs-delay="5000">
93-
<div class="toast-body text-break small"></div>
93+
<div class="toast-body text-break"></div>
9494
</div>
9595

9696
<input id="ctx-menu-row" type="hidden" value="">
9797

9898
<ul class="dropdown-menu py-1">
99-
<li class="small d-none "><a class="dropdown-item clip copy-link">
99+
<li class="d-none "><a class="dropdown-item clip copy-link">
100100
<i class="fa-solid fa-copy link-body-emphasis me-3"></i> Copy Share Link</a></li>
101-
<li class="small d-none "><a class="dropdown-item clip copy-raw">
101+
<li class="d-none "><a class="dropdown-item clip copy-raw">
102102
<i class="fa-regular fa-copy link-body-emphasis me-3"></i> Copy Raw Link</a></li>
103103
<li class="d-none "><hr class="dropdown-divider my-1"></li>
104-
<li class="small"><a class="dropdown-item clip raw" href="">
104+
<li class=""><a class="dropdown-item clip raw" href="">
105105
<i class="fa-solid fa-arrow-up-right-from-square link-body-emphasis me-3"></i> Open Raw File</a></li>
106-
<li class="small"><a class="dropdown-item" data-action="delete">
106+
<li class=""><a class="dropdown-item" data-action="delete">
107107
<i class="fa-regular fa-trash-can link-danger me-3"></i> Delete File</a></li>
108108
<li><hr class="dropdown-divider my-1"></li>
109-
<li class="dropdown-item-text text-center text-break small clip mouse-link py-0"></li>
109+
<li class="dropdown-item-text text-center text-break clip mouse-link py-0"></li>
110110
<li class="dropdown-item-text text-center file-icons">
111-
<span class="text-body-tertiary view-text">0</span>
112-
<i class="fa-solid fa-eye text-body-tertiary mx-1"></i>
113-
<a data-action="private"><i class="fa-solid fa-lock mx-1 text-body-tertiary"></i></a>
114-
<a class="pass-link" data-action="password"><i class="fa-solid fa-key mx-1 text-body-tertiary"></i></a>
111+
<span class="text-body-tertiary view-text me-1">0</span>
112+
<i class="fa-solid fa-eye text-body-tertiary me-2"></i>
113+
<a data-action="private"><i class="fa-solid fa-lock mx-2 text-body-tertiary"></i></a>
114+
<a class="pass-link" data-action="password"><i class="fa-solid fa-key mx-2 text-body-tertiary"></i></a>
115115
<a class="text-decoration-none link-body-emphasis" data-action="expire">
116-
<i class="fa-solid fa-hourglass-start mx-1 text-body-tertiary"></i>
117-
<span class="expr-text"></span></a>
116+
<i class="fa-solid fa-hourglass-start ms-2 text-body-tertiary"></i>
117+
<span class="expr-text ms-1"></span></a>
118118
</li>
119119
</ul>
120120
<i class="fa-solid fa-hourglass ms-1 d-none"></i>

src/js/options.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,9 @@ function setBackground(options) {
6868
document.body.style.mozBackgroundSize = 'cover'
6969
document.body.style.oBackgroundSize = 'cover'
7070
document.body.style.backgroundSize = 'cover'
71-
7271
document.querySelector('video').classList.add('d-none')
7372
} else if (options.radioBackground === 'bgVideo') {
7473
document.querySelector('video').classList.remove('d-none')
75-
7674
document.body.style.cssText = ''
7775
} else {
7876
document.body.style.cssText = ''
@@ -112,6 +110,7 @@ async function saveOptions(event) {
112110
event.target.value = options[event.target.id]
113111
// TODO: Add Error Handling
114112
// showToast(`Value ${number} Out of Range for ${event.target.id}`,'warning')
113+
return
115114
}
116115
} else if (event.target.type === 'radio') {
117116
key = event.target.name
@@ -184,7 +183,12 @@ function hideShowElement(selector, show, speed = 'fast') {
184183
* @param {String} selector
185184
*/
186185
async function setShortcuts(selector = '#keyboard-shortcuts') {
187-
const tbody = document.querySelector(selector).querySelector('tbody')
186+
if (!chrome.commands) {
187+
return console.debug('Skipping: chrome.commands')
188+
}
189+
const table = document.querySelector(selector)
190+
table.classList.remove('d-none')
191+
const tbody = table.querySelector('tbody')
188192
const source = tbody.querySelector('tr.d-none').cloneNode(true)
189193
source.classList.remove('d-none')
190194
const commands = await chrome.commands.getAll()

src/js/popup.js

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,33 @@ async function initPopup() {
7373
const { options } = await chrome.storage.sync.get(['options'])
7474
console.debug('options:', options)
7575
document.getElementById('popupPreview').checked = options.popupPreview
76-
document.body.style.width = `${options.popupWidth}px`
77-
78-
// Table Max Height
7976
const wrapper = document.getElementById('table-wrapper')
80-
if (options.popupLinks) {
81-
wrapper.style.maxHeight = '500px'
77+
const platform = await chrome.runtime.getPlatformInfo()
78+
if (platform.os !== 'android') {
79+
document.body.style.width = `${options.popupWidth}px`
80+
if (options.popupLinks) {
81+
wrapper.style.maxHeight = '500px'
82+
} else {
83+
wrapper.style.maxHeight = '540px'
84+
}
8285
} else {
83-
wrapper.style.maxHeight = '540px'
86+
if (options.popupLinks) {
87+
wrapper.style.maxHeight = '82vh'
88+
} else {
89+
wrapper.style.maxHeight = '88vh'
90+
}
91+
document.documentElement.style.fontSize = '1.3rem'
92+
document
93+
.querySelectorAll('.hover-menu > a')
94+
.forEach((el) => el.classList.add('px-1'))
8495
}
8596

8697
// Manifest
8798
const manifest = chrome.runtime.getManifest()
8899
const imgLink = document.querySelector('.head img').closest('a')
89100
imgLink.href = manifest.homepage_url
90101
imgLink.title = `v${manifest.version}`
91-
const titleLink = document.querySelector('.head h3 a')
102+
const titleLink = document.querySelector('.head h4 a')
92103
titleLink.href = manifest.homepage_url
93104

94105
// Title Link
@@ -377,6 +388,11 @@ function updateTable(data, options) {
377388
thumbURL.searchParams.append('token', options.authToken)
378389
}
379390

391+
// Set mouseOver data on row
392+
row.classList.add('mouse-link')
393+
row.dataset.thumb = thumbURL?.href || rawURL.href
394+
row.dataset.name = data[i].name
395+
380396
// File Link -> 1
381397
const link = document.createElement('a')
382398
link.text = data[i].name
@@ -387,8 +403,8 @@ function updateTable(data, options) {
387403
'link-underline',
388404
'link-underline-opacity-0',
389405
'link-underline-opacity-75-hover',
390-
'file-link',
391-
'mouse-link'
406+
'file-link'
407+
// 'mouse-link'
392408
)
393409
link.target = '_blank'
394410
link.dataset.name = data[i].name
@@ -609,7 +625,7 @@ async function ctxMenu(event) {
609625
}
610626

611627
async function togglePrivate() {
612-
console.debug('togglePrivate')
628+
console.debug(`togglePrivate: ${ctxMenuRow.value}`)
613629
// event.preventDefault()
614630
const file = fileData[ctxMenuRow.value]
615631
console.debug('file:', file)
@@ -641,7 +657,7 @@ async function togglePrivate() {
641657
* @param {SubmitEvent} event
642658
*/
643659
async function passwordForm(event) {
644-
console.debug('passwordForm:', event)
660+
console.debug(`passwordForm: ${ctxMenuRow.value}:`, event)
645661
event.preventDefault()
646662
const file = fileData[ctxMenuRow.value]
647663
console.debug('file:', file)
@@ -679,7 +695,7 @@ async function passwordForm(event) {
679695
* @param {SubmitEvent} event
680696
*/
681697
async function expireForm(event) {
682-
console.debug('expireForm:', event)
698+
console.debug(`expireForm: ${ctxMenuRow.value}:`, event)
683699
event.preventDefault()
684700
const file = fileData[ctxMenuRow.value]
685701
console.debug('file:', file)
@@ -717,7 +733,7 @@ async function expireForm(event) {
717733
* @param {MouseEvent} event
718734
*/
719735
async function deleteConfirm(event) {
720-
console.debug('deleteConfirm:', event)
736+
console.debug(`deleteConfirm: ${ctxMenuRow.value}:`, event)
721737
event.preventDefault()
722738
const file = fileData[ctxMenuRow.value]
723739
console.debug('file:', file)
@@ -842,6 +858,8 @@ function initPopupMouseover() {
842858
})
843859
}
844860

861+
let mouseRow
862+
845863
function onMouseOver(event) {
846864
// console.debug('onMouseOver:', event)
847865
mediaError.classList.add('d-none')
@@ -853,12 +871,19 @@ function onMouseOver(event) {
853871
mediaOuter.classList.remove('bottom-0')
854872
mediaOuter.classList.add('top-0')
855873
}
856-
const str = event.target.innerText
874+
const tr = event.target.closest('tr')
875+
if (tr.id === mouseRow) {
876+
// console.debug('onMouseOver: return')
877+
return
878+
}
879+
mouseRow = tr.id
880+
// console.debug('tr:', tr)
857881
const imageExtensions = /\.(gif|ico|jpeg|jpg|png|svg|webp)$/i
858-
if (str.match(imageExtensions)) {
882+
if (tr.dataset.name.match(imageExtensions)) {
883+
// console.log('onMouseOver: UPDATE SRC')
859884
mediaImage.src = loadingImage
860-
mediaImage.src = event.target.dataset.thumb
861-
// console.debug('dataset.thumb', event.target.dataset.thumb)
885+
mediaImage.src = tr.dataset.thumb
886+
// console.debug('dataset.thumb', tr.dataset.thumb)
862887
mediaOuter.classList.remove('d-none')
863888
} else {
864889
mediaOuter.classList.add('d-none')
@@ -869,8 +894,16 @@ function onMouseOver(event) {
869894
}
870895
}
871896

872-
function onMouseOut() {
873-
// console.debug('onMouseOut')
897+
function onMouseOut(event) {
898+
// console.debug('onMouseOut:', event)
899+
const tr = event.target.closest('tr')
900+
// console.debug('tr:', tr)
901+
// console.debug('mouseRow:', mouseRow)
902+
if (tr.id === mouseRow) {
903+
// console.debug('onMouseOut: return')
904+
return
905+
}
906+
// console.debug('onMouseOut: START TIMEOUT')
874907
timeoutID = setTimeout(function () {
875908
mediaOuter.classList.add('d-none')
876909
mediaImage.src = loadingImage

src/js/service-worker.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
chrome.runtime.onStartup.addListener(onStartup)
44
chrome.runtime.onInstalled.addListener(onInstalled)
5-
chrome.commands.onCommand.addListener(onCommand)
6-
chrome.contextMenus.onClicked.addListener(contextMenusClicked)
5+
chrome.commands?.onCommand.addListener(onCommand)
6+
chrome.contextMenus?.onClicked.addListener(contextMenusClicked)
77
chrome.notifications.onClicked.addListener(notificationsClicked)
88
chrome.storage.onChanged.addListener(onChanged)
99

@@ -38,7 +38,7 @@ async function onInstalled(details) {
3838
authToken: '',
3939
recentFiles: 14,
4040
popupWidth: 380,
41-
popupTimeout: 5,
41+
popupTimeout: 10,
4242
popupPreview: true,
4343
popupIcons: true,
4444
iconPrivate: true,
@@ -169,6 +169,9 @@ function onChanged(changes, namespace) {
169169
* @function createContextMenus
170170
*/
171171
function createContextMenus() {
172+
if (!chrome.contextMenus) {
173+
return console.debug('Skipping: chrome.contextMenus')
174+
}
172175
console.debug('createContextMenus')
173176
chrome.contextMenus.removeAll()
174177
const ctx = ['link', 'image', 'video', 'audio']

0 commit comments

Comments
 (0)