Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport popover code from Kiwix PWA #1252

Merged
merged 70 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
071b947
Add and remove popovers with mouseover
Jaifroid May 19, 2024
d5bafbc
Refactor
Jaifroid May 19, 2024
511395d
Make generic event handler
Jaifroid May 19, 2024
210a36d
Add missing files to precache
Jaifroid May 19, 2024
28f075b
Merge branch 'main' into Backport-popover-code-from-Kiwix-PWA
Jaifroid May 20, 2024
10c7ff0
Fix items from self review
Jaifroid May 20, 2024
a00f38d
Support dark mode
Jaifroid May 20, 2024
b248e3f
Add comment explaining inline styles
Jaifroid May 20, 2024
5fe97eb
Make feature conditional on css matches support
Jaifroid May 20, 2024
1642acd
Enable for restricted mode
Jaifroid May 20, 2024
3b8644e
Clearer event naming
Jaifroid May 20, 2024
e7e1cf9
Ad e2e test for popovers on Ray Charles
Jaifroid May 20, 2024
ac7b6de
Increase wait for popover
Jaifroid May 20, 2024
d9bdb7e
Work around unsupported sendKeys in older Chrome
Jaifroid May 20, 2024
8b6f9b2
Avoid buggy sendKeys
Jaifroid May 20, 2024
21c15e0
Work around Safari failure?
Jaifroid May 20, 2024
5ed4812
Use JS methods to select the popover
Jaifroid May 20, 2024
9b56c5e
Try again and check for text content
Jaifroid May 20, 2024
3bf2cf0
Fix opening new tab
Jaifroid May 20, 2024
926f5ae
Fix issues from self review
Jaifroid May 20, 2024
b31f615
Add UI option to disable
Jaifroid May 20, 2024
4719f8b
Added touch support
Jaifroid May 20, 2024
197dae9
Fix clicking on links inside balloon div
Jaifroid May 21, 2024
005dfd5
Make separate attachPopoverTirggerEvents fn
Jaifroid May 21, 2024
2899be9
Cosmetic from self-review
Jaifroid May 21, 2024
d2cb7b7
Try adding pointerdown support
Jaifroid May 21, 2024
53cd00d
Attempt to support Safari on iOS
Jaifroid May 21, 2024
149685a
Prevent accidental selection of link during long-press
Jaifroid May 21, 2024
2af63fd
Remove user-select none for all except webkit
Jaifroid May 21, 2024
7ba937f
Block popup from showing if user navigated
Jaifroid May 21, 2024
29611b6
Comment out some debug
Jaifroid May 21, 2024
81f441a
Add articleisloading block in Safe Mode
Jaifroid May 21, 2024
c12c192
Make attachKiwixPopoverDiv properly return a Promise
Jaifroid May 21, 2024
a3b9399
Try to prevent selection
Jaifroid May 21, 2024
2bd4b99
Revert "Try to prevent selection"
Jaifroid May 21, 2024
2e7d8ef
Finesse touch detection for Firefox
Jaifroid May 22, 2024
371abee
More finessing for iPad and Edge Legacy
Jaifroid May 22, 2024
de9d86d
Better handle context menu suppression
Jaifroid May 22, 2024
5dd13c0
Try again with edge legacy
Jaifroid May 22, 2024
333756d
Refactor for clarity
Jaifroid May 22, 2024
1d385ea
Fix issues from self review
Jaifroid May 22, 2024
f339108
More accurate function names
Jaifroid May 22, 2024
af76b68
Remove debug and add more comments
Jaifroid May 23, 2024
bd94143
Typos
Jaifroid May 23, 2024
dcc2279
Stupid typo
Jaifroid May 23, 2024
c3747f7
Revert appstate to global variable in app.js only
Jaifroid May 24, 2024
17e3402
Do not use global for popoverThrottle
Jaifroid May 24, 2024
d12c923
Missed baseUrl variable
Jaifroid May 24, 2024
8e2816b
Refactor to simplify
Jaifroid May 24, 2024
c44607d
Refactor for legibility
Jaifroid May 24, 2024
cd574f9
Use Array.from and remove console.debug
Jaifroid May 24, 2024
dd2aed8
Use Array.some() for more concision
Jaifroid May 24, 2024
e0cae4f
Clarify comment
Jaifroid May 24, 2024
0460851
Clarify further comment
Jaifroid May 24, 2024
0b578f0
And again
Jaifroid May 24, 2024
a420012
Correct comment
Jaifroid May 24, 2024
c602e25
Explain cleanup routine
Jaifroid May 24, 2024
9c5289c
Final comment clarification for app.js
Jaifroid May 24, 2024
1ea0908
Merge branch 'Backport-popover-code-from-Kiwix-PWA' of https://github…
Jaifroid May 24, 2024
5634bef
Refactor to separate popovers to new module
Jaifroid May 24, 2024
85f41aa
Add explanatory comment about timeout
Jaifroid May 24, 2024
2713a71
Fix new file missing from SW precache
Jaifroid May 24, 2024
6661fba
First attempt (working) to refactor getArticleLede
Jaifroid May 25, 2024
e9f5373
Further simplification
Jaifroid May 25, 2024
8bd5a23
Break out removeAllStyleElements
Jaifroid May 25, 2024
9bd4f08
Add helper functions
Jaifroid May 25, 2024
93cdb4a
Remove misleading and useless Promise syntax
Jaifroid May 25, 2024
a47ce7a
Deal better with dark theme
Jaifroid May 25, 2024
62e7287
Make border colour variable
Jaifroid May 25, 2024
99363d9
Better border styling and use computedStyles
Jaifroid May 25, 2024
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
7 changes: 4 additions & 3 deletions i18n/en.jsonp.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions i18n/es.jsonp.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions i18n/fr.jsonp.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ const precacheFiles = [
'www/img/icons/kiwix-256.png',
'www/img/icons/kiwix-32.png',
'www/img/icons/kiwix-60.png',
'www/img/icons/new_window_black.svg',
'www/img/icons/new_window_white.svg',
'www/img/spinner.gif',
'www/img/Icon_External_Link.png',
'www/index.html',
Expand All @@ -135,6 +137,7 @@ const precacheFiles = [
'www/js/lib/arrayFromPolyfill.js',
'www/js/lib/filecache.js',
'www/js/lib/cache.js',
'www/js/lib/popovers.js',
'www/js/lib/promisePolyfill.js',
'www/js/lib/settingsStore.js',
'www/js/lib/translateUI.js',
Expand Down
32 changes: 29 additions & 3 deletions tests/e2e/spec/legacy-ray_charles.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function runTests (driver, modes) {
it('Load legacy Ray Charles and check index contains specified article', async function () {
if (!serviceWorkerAPI) {
console.log('\x1b[33m%s\x1b[0m', ' - Following test skipped:');
return;
this.skip();
}
const archiveFiles = await driver.findElement(By.id('archiveFiles'));
// Unhide the element using JavaScript in case it is hidden
Expand Down Expand Up @@ -234,7 +234,7 @@ function runTests (driver, modes) {
it('Navigate to "This Little Girl of Mine"', async function () {
if (!serviceWorkerAPI) {
console.log('\x1b[33m%s\x1b[0m', ' - Following test skipped:');
return;
this.skip();
}

// console.log('FilesLength outer: ' + filesLength);
Expand Down Expand Up @@ -274,12 +274,38 @@ function runTests (driver, modes) {
// console.log('Element text: ' + elementText);
// Check that the article title is correct
assert.equal('Instrumentation by the Ray Charles Orchestra', elementText);
await driver.switchTo().defaultContent();
});

it('Check for popover functionality when focusing link', async function () {
// Check if the browser supports 'matches' in Element.prototype
const matchesSupported = await driver.executeScript('return typeof Element.prototype.matches === "function";');
if (!matchesSupported) {
console.log('\x1b[33m%s\x1b[0m', ' - Following test skipped because browser does not support css matches:');
this.skip();
}
// Switch to iframe
await driver.switchTo().frame('articleContent');
// Focus on the link "Hallelujah" with id="mwVw"
let link = await driver.findElement(By.id('mwVw'));
await driver.executeScript('arguments[0].focus();', link);
await driver.sleep(2000);
// Focus on the next link "A Fool for You" with id="mwWw"
await driver.executeScript('document.getElementById("mwWw").focus();');
// Wait for the popover to appear
await driver.sleep(2500); // DEV: Adjust this delay if failing on older, slower browsers
// Use standard JavaScript methods to find the popover element because Safari 14 fails when using WebDriver methods
let popover = await driver.executeScript('return document.querySelector(".kiwixtooltip").outerHTML;');
// The popover should contain the word "bluesy" (description of style of song)
let popoverContainsText = /bluesy/.test(popover);
Jaifroid marked this conversation as resolved.
Show resolved Hide resolved
assert.ok(popoverContainsText, 'Popover div with class ".kiwixtooltip" did not have expected text "bluesy"');
await driver.switchTo().defaultContent();
});

it('Search for Ray Charles in title index and go to article', async function () {
if (!serviceWorkerAPI) {
console.log('\x1b[33m%s\x1b[0m', ' - Following test skipped:');
return;
this.skip();
}
await driver.switchTo().defaultContent();
const prefix = await driver.findElement(By.id('prefix'));
Expand Down
8 changes: 8 additions & 0 deletions www/img/icons/new_window_black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions www/img/icons/new_window_white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 14 additions & 3 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,9 @@ <h3 data-i18n="configure-display-settings-title">Display settings</h3>
</div>
</div>
<div class="container">
<h3 data-i18n="configure-performance-settings-title">Performance settings</h3>
<h3 data-i18n="configure-performance-settings-title">Performance / compatibility</h3>
<div class="card card-warning" id="performanceSettingsDiv">
<div data-i18n="configure-performance-panel-header" class="card-header">Speed up archive access</div>
<div data-i18n="configure-performance-panel-header" class="card-header">Caching and preview settings</div>
<div class="card-body">
<div class="row">
<div class="col-sm-6">
Expand Down Expand Up @@ -628,11 +628,22 @@ <h3 data-i18n="configure-performance-settings-title">Performance settings</h3>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="checkbox">
<label data-i18n-tip="configure-previews-tip" title="Shows a small popup preview of Wikipedia and Wikivoyage articles when the pointer is hovered over an article link. Turn this off if it is too slow or interferes wtih display of articles on small-screen devices.">
<input type="checkbox" name="showPopoverPreviews" id="showPopoverPreviewsCheck" checked>
<span data-i18n="configure-previews">
<b>Show a popover preview of <i>Wikipedia / Wkivoyage</i> articles</b> when hovering over links (<i>limited functionality in Safe Mode</i>)
</span>
</label>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<h3 data-i18n="configure-compatibility-settings-title">Compatibility settings</h3>
<div class="card card-warning" id="contentInjectionModeDiv">
<div data-i18n="configure-compatibility-panel-header" class="card-header">Content injection mode</div>
<div class="card-body">
Expand Down
Loading
Loading