mirror of
https://github.com/cotes2020/jekyll-theme-chirpy.git
synced 2025-12-18 05:41:31 +00:00
Adapt the search input to Bootstrap 4.6
This commit is contained in:
@@ -3,12 +3,9 @@
|
||||
*/
|
||||
|
||||
$(function() {
|
||||
|
||||
const btnSbTrigger = $("#sidebar-trigger");
|
||||
const btnSearchTrigger = $("#search-trigger");
|
||||
const btnCancel = $("#search-cancel");
|
||||
const btnClear = $("#search-cleaner");
|
||||
|
||||
const main = $("#main");
|
||||
const topbarTitle = $("#topbar-title");
|
||||
const searchWrapper = $("#search-wrapper");
|
||||
@@ -33,8 +30,7 @@ $(function() {
|
||||
};
|
||||
}());
|
||||
|
||||
|
||||
/*--- Actions in small screens (Sidebar unloaded) ---*/
|
||||
/*--- Actions in mobile screens (Sidebar hidden) ---*/
|
||||
|
||||
const mobileSearchBar = (function () {
|
||||
return {
|
||||
@@ -75,7 +71,6 @@ $(function() {
|
||||
hints.removeClass("unloaded");
|
||||
}
|
||||
resultWrapper.addClass("unloaded");
|
||||
btnClear.removeClass("visible");
|
||||
main.removeClass("unloaded");
|
||||
|
||||
// now the release method must be called after $(#main) display
|
||||
@@ -92,7 +87,6 @@ $(function() {
|
||||
|
||||
}());
|
||||
|
||||
|
||||
function isMobileView() {
|
||||
return btnCancel.hasClass("loaded");
|
||||
}
|
||||
@@ -116,38 +110,20 @@ $(function() {
|
||||
searchWrapper.removeClass("input-focus");
|
||||
});
|
||||
|
||||
input.on("keyup", function(e) {
|
||||
if (e.keyCode === 8 && input.val() === "") {
|
||||
if (!isMobileView()) {
|
||||
resultSwitch.off();
|
||||
} else {
|
||||
input.on("input", () => {
|
||||
if (input.val() === "") {
|
||||
if (isMobileView()) {
|
||||
hints.removeClass("unloaded");
|
||||
} else {
|
||||
resultSwitch.off();
|
||||
}
|
||||
|
||||
} else {
|
||||
if (input.val() !== "") {
|
||||
resultSwitch.on();
|
||||
|
||||
if (!btnClear.hasClass("visible")) {
|
||||
btnClear.addClass("visible");
|
||||
}
|
||||
|
||||
if (isMobileView()) {
|
||||
hints.addClass("unloaded");
|
||||
}
|
||||
resultSwitch.on();
|
||||
if (isMobileView()) {
|
||||
hints.addClass("unloaded");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
btnClear.on("click", function() {
|
||||
input.val("");
|
||||
if (isMobileView()) {
|
||||
hints.removeClass("unloaded");
|
||||
results.empty();
|
||||
} else {
|
||||
resultSwitch.off();
|
||||
}
|
||||
input.focus();
|
||||
btnClear.removeClass("visible");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user