Skip to content

Commit 29f22ce

Browse files
committed
refactor(bootstrap): bump to 5
drop JQuery properly
1 parent 03dcc04 commit 29f22ce

File tree

7 files changed

+287
-245
lines changed

7 files changed

+287
-245
lines changed

gulpfile.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ const paths = {
2929
vendor: {
3030
scripts: [
3131
"src/main/xar-resources/resources/scripts/*",
32-
"node_modules/bootstrap/dist/js/bootstrap.min.*",
33-
"node_modules/jquery/dist/jquery.min.*",
32+
"node_modules/bootstrap/dist/js/bootstrap.min.*",
33+
"node_modules/@popperjs/core/dist/umd/popper.min.*",
3434
"node_modules/@highlightjs/cdn-assets/highlight.min.js",
3535
"node_modules/@highlightjs/cdn-assets/languages/xquery.min.js",
3636
"node_modules/zero-md/dist/index.min.js"
@@ -40,7 +40,7 @@ const paths = {
4040
"node_modules/bootstrap/dist/css/bootstrap.min.*",
4141
"node_modules/@highlightjs/cdn-assets/styles/atom-one-dark.min.css"
4242
],
43-
fonts: ["node_modules/bootstrap/dist/fonts/*"],
43+
fonts: ["node_modules/@neos21/bootstrap3-glyphicons/dist/fonts/*"],
4444
},
4545
};
4646

package-lock.json

Lines changed: 36 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
"homepage": "https://github.com/eXist-db/function-documentation#readme",
2727
"dependencies": {
2828
"@highlightjs/cdn-assets": "^11.11.1",
29-
"bootstrap": "^3.4.1",
30-
"jquery": "^1.12.4",
29+
"@neos21/bootstrap3-glyphicons": "^1.0.7",
30+
"@popperjs/core": "^2.11.8",
31+
"bootstrap": "^5.3.3",
3132
"zero-md": "^3.1.6"
3233
},
3334
"devDependencies": {

src/main/xar-resources/modules/app.xql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,5 +386,5 @@ function app:view($node as node(), $model as map(*), $uri as xs:string, $locati
386386
return
387387
app:print-function($xqdocfunction, exists($function))
388388
else
389-
app:print-module($module, $module//xqdoc:function, $details)
389+
app:print-module($module, $module//xqdoc:function, $details cast as xs:boolean)
390390
};

src/main/xar-resources/resources/scripts/query.js

Lines changed: 65 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
document.addEventListener("DOMContentLoaded", function () {
2-
const markedOptions = { gfm: true };
3-
const loginDialog = document.getElementById("loginDialog");
42
let timeout = 0;
53

64
// Modal handling
75
function showModal(element) {
8-
element.style.display = "block";
6+
if (element) element.style.display = "block";
97
}
108

119
function hideModal(element) {
12-
element.style.display = "none";
10+
if (element) element.style.display = "none";
1311
}
1412

15-
hideModal(loginDialog);
13+
const loginDialog = document.getElementById("loginDialog");
14+
if (loginDialog) hideModal(loginDialog);
1615

1716
function search() {
18-
const formData = new FormData(document.getElementById("fun-query-form"));
17+
const form = document.getElementById("fun-query-form");
18+
if (!form) return;
19+
const formData = new FormData(form);
1920
formData.append("action", "search");
2021

2122
fetch("ajax.html", {
@@ -25,9 +26,11 @@ document.addEventListener("DOMContentLoaded", function () {
2526
.then((response) => response.text())
2627
.then((data) => {
2728
const results = document.getElementById("results");
28-
results.style.display = "none";
29-
results.innerHTML = data;
30-
results.style.display = "block";
29+
if (results) {
30+
results.style.display = "none";
31+
results.innerHTML = data;
32+
results.style.display = "block";
33+
}
3134
timeout = null;
3235
});
3336
}
@@ -47,59 +50,78 @@ document.addEventListener("DOMContentLoaded", function () {
4750
function reindex() {
4851
const messages = document.getElementById("messages");
4952
const loadIndicator = document.getElementById("f-load-indicator");
50-
messages.innerHTML = "";
51-
loadIndicator.style.display = "block";
53+
if (messages) messages.innerHTML = "";
54+
if (loadIndicator) loadIndicator.style.display = "block";
5255

5356
fetch("modules/reindex.xql", {
5457
method: "POST",
5558
headers: { Accept: "application/json" },
5659
})
5760
.then((response) => response.json())
5861
.then((data) => {
59-
loadIndicator.style.display = "none";
62+
if (loadIndicator) loadIndicator.style.display = "none";
6063
if (data.status === "failed") {
61-
messages.textContent = data.message;
64+
if (messages) messages.textContent = data.message;
6265
} else {
6366
window.location.reload();
6467
}
6568
});
6669
}
6770

68-
loginDialog.querySelector("form").addEventListener("submit", function (event) {
69-
event.preventDefault();
70-
const formData = new FormData(this);
71+
if (loginDialog) {
72+
const form = loginDialog.querySelector("form");
73+
if (form) {
74+
form.addEventListener("submit", function (event) {
75+
event.preventDefault();
76+
const formData = new FormData(this);
7177

72-
fetch("login", {
73-
method: "POST",
74-
body: new URLSearchParams(formData),
75-
headers: { Accept: "application/json" },
76-
})
77-
.then((response) => {
78-
if (!response.ok) throw new Error();
79-
return response.json();
80-
})
81-
.then(() => {
82-
hideModal(loginDialog);
83-
reindex();
84-
})
85-
.catch(() => {
86-
loginDialog.querySelector(".login-message").style.display = "block";
87-
loginDialog.querySelector(".login-message").textContent = "Login failed!";
78+
fetch("login", {
79+
method: "POST",
80+
body: new URLSearchParams(formData),
81+
headers: { Accept: "application/json" },
82+
})
83+
.then((response) => {
84+
if (!response.ok) throw new Error();
85+
return response.json();
86+
})
87+
.then(() => {
88+
hideModal(loginDialog);
89+
reindex();
90+
})
91+
.catch(() => {
92+
const loginMessage = loginDialog.querySelector(".login-message");
93+
if (loginMessage) {
94+
loginMessage.style.display = "block";
95+
loginMessage.textContent = "Login failed!";
96+
}
97+
});
8898
});
89-
});
99+
}
100+
}
90101

91-
document.getElementById("f-load-indicator").style.display = "none";
102+
const loadIndicator = document.getElementById("f-load-indicator");
103+
if (loadIndicator) loadIndicator.style.display = "none";
92104

93-
document.getElementById("query-field").addEventListener("keyup", function () {
94-
const val = this.value;
95-
if (val.length > 3) {
96-
if (timeout) clearTimeout(timeout);
97-
timeout = setTimeout(search, 300);
98-
}
99-
});
105+
const queryField = document.getElementById("query-field");
106+
if (queryField) {
107+
queryField.addEventListener("keyup", function () {
108+
const val = this.value;
109+
if (val.length > 3) {
110+
if (timeout) clearTimeout(timeout);
111+
timeout = setTimeout(search, 300);
112+
}
113+
});
114+
}
100115

101-
document.getElementById("f-btn-reindex").addEventListener("click", reindexIfLoggedIn);
102-
document.getElementById("f-btn-reindex-regen").addEventListener("click", reindexIfLoggedIn);
116+
const btnReindex = document.getElementById("f-btn-reindex");
117+
if (btnReindex) {
118+
btnReindex.addEventListener("click", reindexIfLoggedIn);
119+
}
120+
121+
const btnReindexRegen = document.getElementById("f-btn-reindex-regen");
122+
if (btnReindexRegen) {
123+
btnReindexRegen.addEventListener("click", reindexIfLoggedIn);
124+
}
103125

104126
const tooltips = document.querySelectorAll("#fun-query-form [data-toggle='tooltip']");
105127
tooltips.forEach((tooltip) => {

0 commit comments

Comments
 (0)