Skip to content

Commit 2fe81ce

Browse files
committed
Fix regression in CSS styles and JS toggle
Resolves #4437
1 parent 9365635 commit 2fe81ce

File tree

3 files changed

+40
-118
lines changed

3 files changed

+40
-118
lines changed

build.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -726,16 +726,13 @@ asciidoctor {
726726
options doctype: 'book', eruby: 'erubis'
727727
logDocuments = true
728728
attributes 'docinfo': 'shared',
729+
'backend-html5': true,
729730
// use provided stylesheet
730731
stylesdir: "css/",
731732
stylesheet: 'spring.css',
732733
'linkcss': true,
733734
'icons': 'font',
734-
'sectanchors': '',
735-
// use provided highlighter
736-
'source-highlighter': 'highlight.js',
737-
'highlightjsdir': 'js/highlight',
738-
'highlightjs-theme': 'github',
735+
'sectanchors': '',
739736
'idprefix': '',
740737
'idseparator': '-',
741738
'spring-version': project.version,
@@ -832,8 +829,12 @@ task docsZip(type: Zip) {
832829
from (asciidoctor) {
833830
include "*.html"
834831
include "css/**"
832+
include "fonts/**"
833+
include "footer/**"
834+
include "header/**"
835835
include "js/**"
836836
include "images/**"
837+
include "img/**"
837838
into 'reference/html'
838839
}
839840
}
Lines changed: 34 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,62 @@
11
$(document).ready(function(){
22

3-
var BATCH_LANGUAGES = ["java", "xml", "both"];
4-
var $xmlButton = $("#xmlButton");
5-
var $javaButton = $("#javaButton");
6-
var $bothButton = $("#bothButton");
7-
8-
var $xmlContent = $("*.xmlContent");
9-
var $xmlContentAll = $("*.xmlContent > *");
10-
11-
var $javaContent = $("*.javaContent");
12-
var $javaContentAll = $("*.javaContent > *");
13-
14-
// Initial cookie handler. This part remembers the
15-
// reader's choice and sets the toggle accordingly.
16-
var lang = window.localStorage.getItem("docToggle");
17-
if (BATCH_LANGUAGES.indexOf(lang) === -1) {
18-
lang = "java";
19-
$javaButton.prop("checked", true);
20-
setJava();
21-
} else {
22-
if (lang === "xml") {
23-
$xmlButton.prop("checked", true);
3+
// Make Java the default
4+
setJava();
5+
6+
// Initial cookie handler. This part remembers the reader's choice and sets the toggle
7+
// accordingly.
8+
var docToggleCookieString = Cookies.get("docToggle");
9+
if (docToggleCookieString != null) {
10+
if (docToggleCookieString === "xml") {
11+
$("#xmlButton").prop("checked", true);
2412
setXml();
25-
}
26-
if (lang === "java") {
27-
$javaButton.prop("checked", true);
13+
} else if (docToggleCookieString === "java") {
14+
$("#javaButton").prop("checked", true);
2815
setJava();
29-
}
30-
if (lang === "both") {
31-
$javaButton.prop("checked", true);
16+
} else if (docToggleCookieString === "both") {
17+
$("#bothButton").prop("checked", true);
3218
setBoth();
3319
}
3420
}
3521

3622
// Click handlers
37-
$xmlButton.on("click", function() {
23+
$("#xmlButton").on("click", function() {
3824
setXml();
3925
});
40-
$javaButton.on("click", function() {
26+
$("#javaButton").on("click", function() {
4127
setJava();
4228
});
43-
$bothButton.on("click", function() {
29+
$("#bothButton").on("click", function() {
4430
setBoth();
4531
});
4632

4733
// Functions to do the work of handling the reader's choice, whether through a click
4834
// or through a cookie. 3652 days is 10 years, give or take a leap day.
4935
function setXml() {
50-
$xmlContent.show();
51-
$javaContent.hide();
52-
$javaContentAll.addClass("js-toc-ignore");
53-
$xmlContentAll.removeClass("js-toc-ignore");
36+
$("*.xmlContent").show();
37+
$("*.javaContent").hide();
38+
$("*.javaContent > *").addClass("js-toc-ignore");
39+
$("*.xmlContent > *").removeClass("js-toc-ignore");
5440
window.dispatchEvent(new Event("tocRefresh"));
55-
tocbot.refresh();
56-
window.localStorage.setItem('docToggle', 'xml');
57-
}
41+
Cookies.set('docToggle', 'xml', { expires: 3652 });
42+
};
5843

5944
function setJava() {
60-
$javaContent.show();
61-
$xmlContent.hide();
62-
$xmlContentAll.addClass("js-toc-ignore");
63-
$javaContentAll.removeClass("js-toc-ignore");
45+
$("*.javaContent").show();
46+
$("*.xmlContent").hide();
47+
$("*.xmlContent > *").addClass("js-toc-ignore");
48+
$("*.javaContent > *").removeClass("js-toc-ignore");
6449
window.dispatchEvent(new Event("tocRefresh"));
65-
tocbot.refresh();
66-
window.localStorage.setItem('docToggle', 'java');
67-
}
50+
Cookies.set('docToggle', 'java', { expires: 3652 });
51+
};
6852

6953
function setBoth() {
70-
$javaContent.show();
71-
$xmlContent.show();
72-
$javaContentAll.removeClass("js-toc-ignore");
73-
$xmlContentAll.removeClass("js-toc-ignore");
54+
$("*.javaContent").show();
55+
$("*.xmlContent").show();
56+
$("*.javaContent > *").removeClass("js-toc-ignore");
57+
$("*.xmlContent > *").removeClass("js-toc-ignore");
7458
window.dispatchEvent(new Event("tocRefresh"));
75-
tocbot.refresh();
76-
window.localStorage.setItem('docToggle', 'both');
77-
}
59+
Cookies.set('docToggle', 'both', { expires: 3652 });
60+
};
7861

7962
});

spring-batch-docs/asciidoc/jsfiles/DocumentToggle.js

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)