Ensure search loads in iframe

Former-commit-id: b56148d1ed455e1a56c0229629049f49ef8a8ed4 [formerly 1698ef45358974fceb3698944ab6eea06bb89945 [formerly d99494112e21b611e65e0d61f9e58a9d971e6e5b]]
Former-commit-id: b793705f36f894ad0017b3d9d40ef7c3d7a618eb
Former-commit-id: 69b4bb2eeaace330794b09ef69be976e57de722e
This commit is contained in:
Jaifroid 2021-05-10 21:33:40 +01:00
parent 62ed795705
commit c5b124dc43
2 changed files with 4 additions and 6 deletions

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html style="background-color: black;">
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Security-Policy" content="default-src http: https: file: data: blob: chrome-extension: ms-appx-web: 'unsafe-inline' 'unsafe-eval';">

View File

@ -134,8 +134,6 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
$("#welcomeText").hide();
$('.alert').hide();
$("#searchingArticles").show();
// Ensure selected search item is displayed in the iframe, not a new window or tab
appstate.target = 'iframe';
pushBrowserHistoryState(null, prefix);
// Initiate the search
searchDirEntriesFromPrefix(prefix);
@ -2879,7 +2877,6 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
return false;
}
/**
* Creates an instance of DirEntry from given dirEntryId (including resolving redirects),
* and call the function to read the corresponding article
@ -2890,6 +2887,8 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
var dirEntry = appstate.selectedArchive.parseDirEntryId(dirEntryId);
// Remove focus from search field to hide keyboard and to allow navigation keys to be used
document.getElementById('articleContent').contentWindow.focus();
// Ensure selected search item is displayed in the iframe, not a new window or tab
appstate.target = 'iframe';
$("#searchingArticles").show();
if (dirEntry.isRedirect()) {
appstate.selectedArchive.resolveRedirect(dirEntry, readArticle);
@ -3725,6 +3724,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
if (appstate.target === 'iframe') {
// Tell jQuery we're removing the iframe document: clears jQuery cache and prevents memory leaks [kiwix-js #361]
$('#articleContent').contents().remove();
articleContainer = document.getElementById('articleContent');
articleWindow = articleContainer.contentWindow;
}
@ -3771,8 +3771,6 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
// articleWindow.document.close();
if (appstate.target === 'iframe') {
// Tell jQuery we're removing the iframe document: clears jQuery cache and prevents memory leaks [kiwix-js #361]
$('#articleContent').contents().remove();
// Store the frame article's target in the top-level window, so that when we retrieve the window with
// history manipulation, we'll know where to place the iframe contentWindow
window.kiwixType = appstate.target;