mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-15 15:27:11 -04:00
Remove some more jQuery
Former-commit-id: c98368624adabd1a4a46d4bf1becde3a5341a08e [formerly be192ff3a8134c547e2ce5d4254e6eef2ecddd36] Former-commit-id: f66e53ce21ff7aeeb653347367a8c136516ef005
This commit is contained in:
parent
c35f170cfb
commit
6e8322e836
109
www/js/app.js
109
www/js/app.js
@ -107,7 +107,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Define behavior of HTML elements
|
// Define behavior of HTML elements
|
||||||
$('#searchArticles').on('click', function (e) {
|
document.getElementById('searchArticles').addEventListener('click', function () {
|
||||||
pushBrowserHistoryState(null, $('#prefix').val());
|
pushBrowserHistoryState(null, $('#prefix').val());
|
||||||
searchDirEntriesFromPrefix($('#prefix').val());
|
searchDirEntriesFromPrefix($('#prefix').val());
|
||||||
$("#welcomeText").hide();
|
$("#welcomeText").hide();
|
||||||
@ -123,11 +123,10 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
$('#navbarToggle').click();
|
$('#navbarToggle').click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('#formArticleSearch').on('submit', function (e) {
|
document.getElementById('formArticleSearch').addEventListener('submit', function () {
|
||||||
document.getElementById("searchArticles").click();
|
document.getElementById("searchArticles").click();
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
$('#prefix').on('keyup', function (e) {
|
document.getElementById('prefix').addEventListener('keyup', function (e) {
|
||||||
if (selectedArchive !== null && selectedArchive.isReady()) {
|
if (selectedArchive !== null && selectedArchive.isReady()) {
|
||||||
if (e.which == 40) {
|
if (e.which == 40) {
|
||||||
var articleResults = document.querySelectorAll('.list-group-item');
|
var articleResults = document.querySelectorAll('.list-group-item');
|
||||||
@ -140,12 +139,11 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
});
|
});
|
||||||
|
|
||||||
//Add keyboard shortcuts
|
//Add keyboard shortcuts
|
||||||
$(window).on('keyup', function (e) {
|
window.addEventListener('keyup', function (e) {
|
||||||
var e = e || window.event;
|
var e = e || window.event;
|
||||||
//Alt-F for search in article, also patches Ctrl-F for apps that do not have access to browser search
|
//Alt-F for search in article, also patches Ctrl-F for apps that do not have access to browser search
|
||||||
if ((e.ctrlKey || e.altKey) && e.which == 70) {
|
if ((e.ctrlKey || e.altKey) && e.which == 70) {
|
||||||
$('#findText').click();
|
document.getElementById('findText').click();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -155,7 +153,6 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
printIntercept();
|
printIntercept();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
@ -291,7 +288,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
document.getElementById('findText').classList.remove("active");
|
document.getElementById('findText').classList.remove("active");
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#findText').on('click', function (e) {
|
document.getElementById('findText').addEventListener('click', function () {
|
||||||
var searchDiv = document.getElementById('row2');
|
var searchDiv = document.getElementById('row2');
|
||||||
if (searchDiv.style.display != "none") {
|
if (searchDiv.style.display != "none") {
|
||||||
setTab();
|
setTab();
|
||||||
@ -313,15 +310,15 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
//Ensure timeout doesn't occur if another key has been pressed within time window
|
//Ensure timeout doesn't occur if another key has been pressed within time window
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
//If user pressed Alt-F or Ctrl-F, exit
|
//If user pressed Alt-F or Ctrl-F, exit
|
||||||
if ((e.altKey || e.ctrlKey) && e.which == 70) return false;
|
if ((e.altKey || e.ctrlKey) && e.which == 70) return;
|
||||||
var val = this.value;
|
var val = this.value;
|
||||||
//If user pressed enter / return key
|
//If user pressed enter / return key
|
||||||
if (val && e.which == 13) {
|
if (val && e.which == 13) {
|
||||||
localSearch.scrollFrom = localSearch.scrollToFullMatch(val, localSearch.scrollFrom);
|
localSearch.scrollFrom = localSearch.scrollToFullMatch(val, localSearch.scrollFrom);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
//If value hasn't changed, exit
|
//If value hasn't changed, exit
|
||||||
if (val == localSearch.lastScrollValue) return false;
|
if (val == localSearch.lastScrollValue) return;
|
||||||
//Ensure nothing happens if only one value has been entered (not specific enough), but ensure timeout is set
|
//Ensure nothing happens if only one value has been entered (not specific enough), but ensure timeout is set
|
||||||
//if no value has been entered (clears highlighting if user deletes all values in search field)
|
//if no value has been entered (clears highlighting if user deletes all values in search field)
|
||||||
if (~(val.length - 2)) {
|
if (~(val.length - 2)) {
|
||||||
@ -346,10 +343,10 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
}, false);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#btnRandomArticle").on("click", function (e) {
|
document.getElementById('btnRandomArticle').addEventListener('click', function () {
|
||||||
setTab('btnRandomArticle');
|
setTab('btnRandomArticle');
|
||||||
//Re-enable top-level scrolling
|
//Re-enable top-level scrolling
|
||||||
document.getElementById('top').style.position = "relative";
|
document.getElementById('top').style.position = "relative";
|
||||||
@ -359,7 +356,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
goToRandomArticle();
|
goToRandomArticle();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#btnRescanDeviceStorage').on("click", function (e) {
|
document.getElementById('btnRescanDeviceStorage').addEventListener("click", function () {
|
||||||
var returnDivs = document.getElementsByClassName("returntoArticle");
|
var returnDivs = document.getElementsByClassName("returntoArticle");
|
||||||
for (var i = 0; i < returnDivs.length; i++) {
|
for (var i = 0; i < returnDivs.length; i++) {
|
||||||
returnDivs[i].innerHTML = "";
|
returnDivs[i].innerHTML = "";
|
||||||
@ -379,22 +376,21 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
// Bottom bar :
|
// Bottom bar :
|
||||||
// @TODO Since bottom bar now hidden in Settings and About the returntoArticle code cannot be accessed;
|
// @TODO Since bottom bar now hidden in Settings and About the returntoArticle code cannot be accessed;
|
||||||
// consider adding it to top home button instead
|
// consider adding it to top home button instead
|
||||||
$('#btnBack').on('click', function (e) {
|
document.getElementById('btnBack').addEventListener('click', function () {
|
||||||
if (document.getElementById('articleContent').style.display == "none") {
|
if (document.getElementById('articleContent').style.display == "none") {
|
||||||
$('#returntoArticle').click();
|
document.getElementById('returntoArticle').click();
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
clearFindInArticle();
|
clearFindInArticle();
|
||||||
history.back();
|
history.back();
|
||||||
return false;
|
return;
|
||||||
});
|
});
|
||||||
$('#btnForward').on('click', function (e) {
|
document.getElementById('btnForward').addEventListener('click', function () {
|
||||||
clearFindInArticle();
|
clearFindInArticle();
|
||||||
history.forward();
|
history.forward();
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
document.getElementById('articleContent').contentDocument.body.style.fontSize = params.relativeFontSize + "%";
|
document.getElementById('articleContent').contentDocument.body.style.fontSize = params.relativeFontSize + "%";
|
||||||
$('#btnZoomin').on('click', function (e) {
|
document.getElementById('btnZoomin').addEventListener('click', function () {
|
||||||
params.relativeFontSize += 5;
|
params.relativeFontSize += 5;
|
||||||
var doc = document.getElementById('articleContent').contentDocument;
|
var doc = document.getElementById('articleContent').contentDocument;
|
||||||
doc.body.style.fontSize = /-\/static\/main\.css/.test(doc.head.innerHTML) ? params.relativeFontSize * 1.5 + "%" : params.relativeFontSize + "%";
|
doc.body.style.fontSize = /-\/static\/main\.css/.test(doc.head.innerHTML) ? params.relativeFontSize * 1.5 + "%" : params.relativeFontSize + "%";
|
||||||
@ -404,9 +400,8 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
document.getElementById('lblZoom').innerHTML = "";
|
document.getElementById('lblZoom').innerHTML = "";
|
||||||
}, 1000);
|
}, 1000);
|
||||||
cookies.setItem('relativeFontSize', params.relativeFontSize, Infinity);
|
cookies.setItem('relativeFontSize', params.relativeFontSize, Infinity);
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
$('#btnZoomout').on('click', function (e) {
|
document.getElementById('btnZoomout').addEventListener('click', function () {
|
||||||
params.relativeFontSize -= 5;
|
params.relativeFontSize -= 5;
|
||||||
var doc = document.getElementById('articleContent').contentDocument;
|
var doc = document.getElementById('articleContent').contentDocument;
|
||||||
doc.body.style.fontSize = /-\/static\/main\.css/.test(doc.head.innerHTML) ? params.relativeFontSize * 1.5 + "%" : params.relativeFontSize + "%";
|
doc.body.style.fontSize = /-\/static\/main\.css/.test(doc.head.innerHTML) ? params.relativeFontSize * 1.5 + "%" : params.relativeFontSize + "%";
|
||||||
@ -416,7 +411,6 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
document.getElementById('lblZoom').innerHTML = "";
|
document.getElementById('lblZoom').innerHTML = "";
|
||||||
}, 1000);
|
}, 1000);
|
||||||
cookies.setItem('relativeFontSize', params.relativeFontSize, Infinity);
|
cookies.setItem('relativeFontSize', params.relativeFontSize, Infinity);
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
setRelativeUIFontSize(params.relativeUIFontSize);
|
setRelativeUIFontSize(params.relativeUIFontSize);
|
||||||
document.getElementById('relativeUIFontSizeSlider').addEventListener('change', function () {
|
document.getElementById('relativeUIFontSizeSlider').addEventListener('change', function () {
|
||||||
@ -451,11 +445,10 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#btnHomeBottom').on('click', function (e) {
|
document.getElementById('btnHomeBottom').addEventListener('click', function () {
|
||||||
$('#btnHome').click();
|
document.getElementById('btnHome').click();
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
$('#btnTop').on('click', function (e) {
|
document.getElementById('btnTop').addEventListener('click', function () {
|
||||||
//Ensures toolbar is shown after hidden
|
//Ensures toolbar is shown after hidden
|
||||||
var thisdoc = document.getElementById('top');
|
var thisdoc = document.getElementById('top');
|
||||||
if (params.hideToolbar && thisdoc.style.zIndex == "0") {
|
if (params.hideToolbar && thisdoc.style.zIndex == "0") {
|
||||||
@ -464,14 +457,11 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
params.hideToolbar = true;
|
params.hideToolbar = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//document.getElementById('article').style.marginTop = "46px";
|
|
||||||
$("#articleContent").contents().scrollTop(0);
|
$("#articleContent").contents().scrollTop(0);
|
||||||
$("#search-article").scrollTop(0);
|
$("#search-article").scrollTop(0);
|
||||||
// We return true, so that the link to #top is still triggered (useful in the About section)
|
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
// Top menu :
|
// Top menu :
|
||||||
$('#btnHome').on('click', function (e) {
|
document.getElementById('btnHome').addEventListener('click', function () {
|
||||||
setTab('btnHome');
|
setTab('btnHome');
|
||||||
// Give the focus to the search field, and clean up the page contents
|
// Give the focus to the search field, and clean up the page contents
|
||||||
if (!firstRun) {
|
if (!firstRun) {
|
||||||
@ -487,7 +477,6 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
$('#welcomeText').hide();
|
$('#welcomeText').hide();
|
||||||
goToMainArticle();
|
goToMainArticle();
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function setTab(activeBtn) {
|
function setTab(activeBtn) {
|
||||||
@ -557,7 +546,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#btnConfigure').on('click', function (e) {
|
document.getElementById('btnConfigure').addEventListener('click', function () {
|
||||||
var searchDiv = document.getElementById('configuration');
|
var searchDiv = document.getElementById('configuration');
|
||||||
if (searchDiv.style.display != 'none') {
|
if (searchDiv.style.display != 'none') {
|
||||||
setTab();
|
setTab();
|
||||||
@ -608,11 +597,10 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
document.getElementById('chooseArchiveFromLocalStorage').style.display = "block";
|
document.getElementById('chooseArchiveFromLocalStorage').style.display = "block";
|
||||||
document.getElementById('instructions').style.display = "block";
|
document.getElementById('instructions').style.display = "block";
|
||||||
document.getElementById('archiveFilesLegacy').style.display = "inline";
|
document.getElementById('archiveFilesLegacy').style.display = "inline";
|
||||||
$('#archiveFilesLegacy').on('change', setLocalArchiveFromFileSelect);
|
document.getElementById('archiveFilesLegacy').addEventListener('change', setLocalArchiveFromFileSelect);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
$('#btnAbout').on('click', function (e) {
|
document.getElementById('btnAbout').addEventListener('click', function () {
|
||||||
var btnAboutElement = document.getElementById('btnAbout');
|
var btnAboutElement = document.getElementById('btnAbout');
|
||||||
if (/glyphicon-print/.test(btnAboutElement.innerHTML)) {
|
if (/glyphicon-print/.test(btnAboutElement.innerHTML)) {
|
||||||
printIntercept();
|
printIntercept();
|
||||||
@ -642,16 +630,15 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
document.getElementById('scrollbox').style.position = "fixed";
|
document.getElementById('scrollbox').style.position = "fixed";
|
||||||
document.getElementById('scrollbox').style.height = document.documentElement.clientHeight + "px";
|
document.getElementById('scrollbox').style.height = document.documentElement.clientHeight + "px";
|
||||||
document.getElementById('search-article').style.overflowY = "auto";
|
document.getElementById('search-article').style.overflowY = "auto";
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
// TODO: I've set up two event listeners below because the archive list doesn't "change" if there is only one element in it
|
// TODO: I've set up two event listeners below because the archive list doesn't "change" if there is only one element in it
|
||||||
// See if this can be simplified.... (but note that keyboard users might not click)
|
// See if this can be simplified.... (but note that keyboard users might not click)
|
||||||
$('#archiveList').on('change', function () {
|
document.getElementById('archiveList').addEventListener('change', function () {
|
||||||
console.log("***Archive List change event fired");
|
console.log("***Archive List change event fired");
|
||||||
$('#openLocalFiles').hide();
|
$('#openLocalFiles').hide();
|
||||||
setLocalArchiveFromArchiveList();
|
setLocalArchiveFromArchiveList();
|
||||||
});
|
});
|
||||||
$('#archiveList').on('click', function () {
|
document.getElementById('archiveList').addEventListener('click', function () {
|
||||||
console.log("***Archive List click event fired: ***WHY***??? checking length of options list...");
|
console.log("***Archive List click event fired: ***WHY***??? checking length of options list...");
|
||||||
//Doh, why are you testing for this? Surely you want to jump to the file if it's been clicked on? There was a reason @REMIND_ME....
|
//Doh, why are you testing for this? Surely you want to jump to the file if it's been clicked on? There was a reason @REMIND_ME....
|
||||||
//var comboArchiveList = document.getElementById('archiveList');
|
//var comboArchiveList = document.getElementById('archiveList');
|
||||||
@ -662,7 +649,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
//}
|
//}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#archiveFile').on('click', function () {
|
document.getElementById('archiveFile').addEventListener('click', function () {
|
||||||
if (typeof Windows !== 'undefined' && typeof Windows.Storage !== 'undefined') {
|
if (typeof Windows !== 'undefined' && typeof Windows.Storage !== 'undefined') {
|
||||||
//UWP FilePicker [kiwix-js-windows #3]
|
//UWP FilePicker [kiwix-js-windows #3]
|
||||||
pickFileUWP();
|
pickFileUWP();
|
||||||
@ -670,7 +657,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
//@TODO enable and provide classic filepicker
|
//@TODO enable and provide classic filepicker
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('#archiveFiles').on('click', function () {
|
document.getElementById('archiveFiles').addEventListener('click', function () {
|
||||||
if (typeof Windows !== 'undefined' && typeof Windows.Storage !== 'undefined') {
|
if (typeof Windows !== 'undefined' && typeof Windows.Storage !== 'undefined') {
|
||||||
//UWP FolderPicker
|
//UWP FolderPicker
|
||||||
pickFolderUWP();
|
pickFolderUWP();
|
||||||
@ -823,7 +810,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
cookies.setItem('cssSource', params.cssSource, Infinity);
|
cookies.setItem('cssSource', params.cssSource, Infinity);
|
||||||
params.themeChanged = true;
|
params.themeChanged = true;
|
||||||
});
|
});
|
||||||
$('#removePageMaxWidthCheck').on('click', function (e) {
|
document.getElementById('removePageMaxWidthCheck').addEventListener('click', function () {
|
||||||
//This code implements a tri-state checkbox
|
//This code implements a tri-state checkbox
|
||||||
if (this.readOnly) this.checked = this.readOnly = false;
|
if (this.readOnly) this.checked = this.readOnly = false;
|
||||||
else if (!this.checked) this.readOnly = this.indeterminate = true;
|
else if (!this.checked) this.readOnly = this.indeterminate = true;
|
||||||
@ -1157,7 +1144,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
// Archive files are already selected,
|
// Archive files are already selected,
|
||||||
setLocalArchiveFromFileSelect();
|
setLocalArchiveFromFileSelect();
|
||||||
} else {
|
} else {
|
||||||
$("#btnConfigure").click();
|
document.getElementById('btnConfigure').click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1165,7 +1152,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
|
|
||||||
function searchForArchivesInStorage() {
|
function searchForArchivesInStorage() {
|
||||||
// If DeviceStorage is available, we look for archives in it
|
// If DeviceStorage is available, we look for archives in it
|
||||||
$("#btnConfigure").click();
|
document.getElementById('btnConfigure').click();
|
||||||
$('#scanningForArchives').show();
|
$('#scanningForArchives').show();
|
||||||
if (params.localStorage && typeof Windows !== 'undefined' && typeof Windows.Storage !== 'undefined') {
|
if (params.localStorage && typeof Windows !== 'undefined' && typeof Windows.Storage !== 'undefined') {
|
||||||
scanUWPFolderforArchives(params.localStorage);
|
scanUWPFolderforArchives(params.localStorage);
|
||||||
@ -1197,7 +1184,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
// Archive files are already selected,
|
// Archive files are already selected,
|
||||||
setLocalArchiveFromFileSelect();
|
setLocalArchiveFromFileSelect();
|
||||||
} else {
|
} else {
|
||||||
$("#btnConfigure").click();
|
document.getElementById('btnConfigure').click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1353,7 +1340,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
populateDropDownListOfArchives(archiveList);
|
populateDropDownListOfArchives(archiveList);
|
||||||
$('#btnConfigure').click();
|
document.getElementById('btnConfigure').click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -1372,7 +1359,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
if (params.localStorage) {
|
if (params.localStorage) {
|
||||||
scanUWPFolderforArchives(params.localStorage);
|
scanUWPFolderforArchives(params.localStorage);
|
||||||
} else {
|
} else {
|
||||||
$('#btnConfigure').click();
|
document.getElementById('btnConfigure').click();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1387,11 +1374,11 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
cookies.setItem("lastSelectedArchive", archiveDirectory, Infinity);
|
cookies.setItem("lastSelectedArchive", archiveDirectory, Infinity);
|
||||||
// The archive is set : go back to home page to start searching
|
// The archive is set : go back to home page to start searching
|
||||||
if (params.rescan) {
|
if (params.rescan) {
|
||||||
$('#btnConfigure').click();
|
document.getElementById('btnConfigure').click();
|
||||||
params.rescan = false;
|
params.rescan = false;
|
||||||
} else {
|
} else {
|
||||||
$('#openLocalFiles').hide();
|
$('#openLocalFiles').hide();
|
||||||
$('#btnHome').click();
|
document.getElementById('btnHome').click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1517,8 +1504,8 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
//This ensures the correct icon is set for the newly loaded archive
|
//This ensures the correct icon is set for the newly loaded archive
|
||||||
cssUIThemeSet(params.cssUITheme);
|
cssUIThemeSet(params.cssUITheme);
|
||||||
if (params.rescan) {
|
if (params.rescan) {
|
||||||
$('#btnConfigure').click();
|
document.getElementById('btnConfigure').click();
|
||||||
$('#btnConfigure').click();
|
document.getElementById('btnConfigure').click();
|
||||||
params.rescan = false;
|
params.rescan = false;
|
||||||
} else {
|
} else {
|
||||||
$('#openLocalFiles').hide();
|
$('#openLocalFiles').hide();
|
||||||
@ -1526,7 +1513,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
var lastPage = decodeURIComponent(params.lastPageVisit.replace(/@kiwixKey@.+/, ""));
|
var lastPage = decodeURIComponent(params.lastPageVisit.replace(/@kiwixKey@.+/, ""));
|
||||||
goToArticle(lastPage);
|
goToArticle(lastPage);
|
||||||
} else {
|
} else {
|
||||||
$('#btnHome').click();
|
document.getElementById('btnHome').click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1606,7 +1593,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
window.timeoutKeyUpPrefix = window.setTimeout(function () {
|
window.timeoutKeyUpPrefix = window.setTimeout(function () {
|
||||||
var prefix = $("#prefix").val();
|
var prefix = $("#prefix").val();
|
||||||
if (prefix && prefix.length > 0) {
|
if (prefix && prefix.length > 0) {
|
||||||
$('#searchArticles').click();
|
document.getElementById('searchArticles').click();
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
@ -1629,7 +1616,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
// so that the keyboard does not stay above the message
|
// so that the keyboard does not stay above the message
|
||||||
$('#searchArticles').focus();
|
$('#searchArticles').focus();
|
||||||
alert("Archive not set : please select an archive");
|
alert("Archive not set : please select an archive");
|
||||||
$('#btnConfigure').click();
|
document.getElementById('btnConfigure').click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1668,7 +1655,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
"' class='list-group-item'>" + dirEntry.title + "</a>";
|
"' class='list-group-item'>" + dirEntry.title + "</a>";
|
||||||
}
|
}
|
||||||
articleListDiv.html(articleListDivHtml);
|
articleListDiv.html(articleListDivHtml);
|
||||||
$("#articleList a").on("click", handleTitleClick);
|
document.getElementById('articleList a').addEventListener("click", handleTitleClick);
|
||||||
$('#searchingForArticles').hide();
|
$('#searchingForArticles').hide();
|
||||||
$('#articleList').show();
|
$('#articleList').show();
|
||||||
$('#articleListHeaderMessage').show();
|
$('#articleListHeaderMessage').show();
|
||||||
@ -1679,14 +1666,13 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
* @param {Event} event
|
* @param {Event} event
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
function handleTitleClick(event) {
|
function handleTitleClick() {
|
||||||
var dirEntryId = event.target.getAttribute("dirEntryId");
|
var dirEntryId = event.target.getAttribute("dirEntryId");
|
||||||
$("#articleList").empty();
|
$("#articleList").empty();
|
||||||
$('#articleListHeaderMessage').empty();
|
$('#articleListHeaderMessage').empty();
|
||||||
$("#prefix").val("");
|
$("#prefix").val("");
|
||||||
findDirEntryFromDirEntryIdAndLaunchArticleRead(dirEntryId);
|
findDirEntryFromDirEntryIdAndLaunchArticleRead(dirEntryId);
|
||||||
var dirEntry = selectedArchive.parseDirEntryId(dirEntryId);
|
var dirEntry = selectedArchive.parseDirEntryId(dirEntryId);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2228,8 +2214,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
document.getElementById('articleContent').contentWindow.addEventListener('keyup', function (e) {
|
document.getElementById('articleContent').contentWindow.addEventListener('keyup', function (e) {
|
||||||
//Alt-F for search in article, also patches Ctrl-F for apps that do not have access to browser search
|
//Alt-F for search in article, also patches Ctrl-F for apps that do not have access to browser search
|
||||||
if ((e.ctrlKey || e.altKey) && e.which == 70) {
|
if ((e.ctrlKey || e.altKey) && e.which == 70) {
|
||||||
$('#findText').click();
|
document.getElementById('findText').click();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2239,7 +2224,6 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
printIntercept();
|
printIntercept();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
@ -2287,7 +2271,6 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var decodedURL = decodeURIComponent(zimUrl);
|
var decodedURL = decodeURIComponent(zimUrl);
|
||||||
goToArticle(decodedURL);
|
goToArticle(decodedURL);
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user