Polish DocumentToggle.js
* Declare duplicate jQuery selectors as variables * Remove extra semicolons after function declarations * Remove leftover jquery.js from Java/XML toggle implementation When the Java/XML toggle implementation was introduced, jquery-3.2.1.min.js replaced the old jquery script in toggle.adoc and the old jquery script was accidentally leftover as a result.
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
0f9b2e800e
commit
53ec8f6084
@@ -1,5 +1,15 @@
|
||||
$(document).ready(function(){
|
||||
|
||||
var $xmlButton = $("#xmlButton");
|
||||
var $javaButton = $("#javaButton");
|
||||
var $bothButton = $("#bothButton");
|
||||
|
||||
var $xmlContent = $("*.xmlContent");
|
||||
var $xmlContentAll = $("*.xmlContent > *");
|
||||
|
||||
var $javaContent = $("*.javaContent");
|
||||
var $javaContentAll = $("*.javaContent > *");
|
||||
|
||||
setJava();
|
||||
|
||||
// Initial cookie handler. This part remembers the reader's choice and sets the toggle
|
||||
@@ -7,58 +17,58 @@ $(document).ready(function(){
|
||||
var docToggleCookieString = Cookies.get("docToggle");
|
||||
if (docToggleCookieString != null) {
|
||||
if (docToggleCookieString === "xml") {
|
||||
$("#xmlButton").prop("checked", true);
|
||||
$xmlButton.prop("checked", true);
|
||||
setXml();
|
||||
} else if (docToggleCookieString === "java") {
|
||||
$("#javaButton").prop("checked", true);
|
||||
$javaButton.prop("checked", true);
|
||||
setJava();
|
||||
} else if (docToggleCookieString === "both") {
|
||||
$("#bothButton").prop("checked", true);
|
||||
$bothButton.prop("checked", true);
|
||||
setBoth();
|
||||
}
|
||||
}
|
||||
|
||||
// Click handlers
|
||||
$("#xmlButton").on("click", function() {
|
||||
$xmlButton.on("click", function() {
|
||||
setXml();
|
||||
});
|
||||
$("#javaButton").on("click", function() {
|
||||
$javaButton.on("click", function() {
|
||||
setJava();
|
||||
});
|
||||
$("#bothButton").on("click", function() {
|
||||
$bothButton.on("click", function() {
|
||||
setBoth();
|
||||
});
|
||||
|
||||
// Functions to do the work of handling the reader's choice, whether through a click
|
||||
// or through a cookie. 3652 days is 10 years, give or take a leap day.
|
||||
function setXml() {
|
||||
$("*.xmlContent").show();
|
||||
$("*.javaContent").hide();
|
||||
$("*.javaContent > *").addClass("js-toc-ignore");
|
||||
$("*.xmlContent > *").removeClass("js-toc-ignore");
|
||||
$xmlContent.show();
|
||||
$javaContent.hide();
|
||||
$javaContentAll.addClass("js-toc-ignore");
|
||||
$xmlContentAll.removeClass("js-toc-ignore");
|
||||
window.dispatchEvent(new Event("tocRefresh"));
|
||||
tocbot.refresh();
|
||||
Cookies.set('docToggle', 'xml', { expires: 3652 });
|
||||
};
|
||||
}
|
||||
|
||||
function setJava() {
|
||||
$("*.javaContent").show();
|
||||
$("*.xmlContent").hide();
|
||||
$("*.xmlContent > *").addClass("js-toc-ignore");
|
||||
$("*.javaContent > *").removeClass("js-toc-ignore");
|
||||
$javaContent.show();
|
||||
$xmlContent.hide();
|
||||
$xmlContentAll.addClass("js-toc-ignore");
|
||||
$javaContentAll.removeClass("js-toc-ignore");
|
||||
window.dispatchEvent(new Event("tocRefresh"));
|
||||
tocbot.refresh();
|
||||
Cookies.set('docToggle', 'java', { expires: 3652 });
|
||||
};
|
||||
}
|
||||
|
||||
function setBoth() {
|
||||
$("*.javaContent").show();
|
||||
$("*.xmlContent").show();
|
||||
$("*.javaContent > *").removeClass("js-toc-ignore");
|
||||
$("*.xmlContent > *").removeClass("js-toc-ignore");
|
||||
$javaContent.show();
|
||||
$xmlContent.show();
|
||||
$javaContentAll.removeClass("js-toc-ignore");
|
||||
$xmlContentAll.removeClass("js-toc-ignore");
|
||||
window.dispatchEvent(new Event("tocRefresh"));
|
||||
tocbot.refresh();
|
||||
Cookies.set('docToggle', 'both', { expires: 3652 });
|
||||
};
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
9807
spring-batch-docs/asciidoc/js/jquery.js
vendored
9807
spring-batch-docs/asciidoc/js/jquery.js
vendored
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user