Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete: reorganize modules and update to v2.1.8 #3064

Merged
merged 30 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b7462a5
fix: expose show/hide for AC inputs.
crhallberg Aug 31, 2023
cd6abab
style: use trigger instead of deprecated focus().
crhallberg Sep 1, 2023
2fab02d
refactor: searchbox_controls creation and de-jQuery.
crhallberg Sep 7, 2023
ec015d1
Merge remote-tracking branch 'origin/dev' into fix-ac-open
crhallberg Sep 7, 2023
9396774
fix: missed file.
crhallberg Sep 7, 2023
33526d3
Merge remote-tracking branch 'origin/dev' into fix-ac-open
crhallberg Nov 14, 2023
ecc7cb4
style: global fix.
crhallberg Nov 14, 2023
a944fd3
style: rearrange functions for better scoping and readability.
crhallberg Nov 17, 2023
544638c
Merge remote-tracking branch 'origin/dev' into fix-ac-open
crhallberg Nov 21, 2023
b44c0c0
refactor: return extractClassParams to common.js
crhallberg Nov 29, 2023
2f7f21f
style: fix duplicate functions.
crhallberg Nov 29, 2023
71b1d08
style: reduce diffs.
crhallberg Nov 29, 2023
d2a1efb
stlye: reduce whitespace changes.
crhallberg Nov 29, 2023
093205c
refactor: remove redundant code.
crhallberg Dec 4, 2023
54af7e4
fix: use global variables in setup.
crhallberg Dec 4, 2023
1f5ecd3
style: code cleanup.
crhallberg Dec 5, 2023
5c94963
fix: onChange and input for virtual keyboard.
crhallberg Dec 5, 2023
3b29ec6
revert: config leak.
crhallberg Dec 5, 2023
8bd2e30
fix: simplify.
crhallberg Dec 5, 2023
17b5b01
feat: merge in align on resize (ThoWagen).
crhallberg Dec 11, 2023
06d5411
Merge remote-tracking branch 'origin/dev' into fix-ac-open
crhallberg Dec 12, 2023
e896d7d
fix: reset btn not clearing.
crhallberg Dec 12, 2023
0fd248c
style: syntax adjustments.
crhallberg Dec 12, 2023
36c609b
fix: caret no longer jumps to the end.
crhallberg Dec 12, 2023
d2c5edf
Merge remote-tracking branch 'origin/dev' into fix-ac-open
crhallberg Jan 10, 2024
426c1f3
revert: disable virtual keyboard.
crhallberg Jan 10, 2024
8eac13d
fix: move variable initialization.
crhallberg Jan 10, 2024
4a74a36
bump: autocomplete release minted.
crhallberg Jan 29, 2024
ce2bf60
Merge branch 'dev' into fix-ac-open
demiankatz Jan 29, 2024
67f8422
Update js file.
demiankatz Jan 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions themes/bootstrap3/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ $(function searchFormResetHandler() {
if (query !== '') {
resetButton.show();
queryInput.focus().val('').val(query);
queryInput[0].ac.hide();
}
queryInput.on('input', function onInput() {
if ($(this).val() === '') {
Expand All @@ -706,6 +707,7 @@ $(function searchFormResetHandler() {
});
resetButton.on('click', function onClick() {
queryInput.attr('value', '').focus();
queryInput[0].ac.hide(); // not sure why AC is using previous value
demiankatz marked this conversation as resolved.
Show resolved Hide resolved
resetButton.hide();
});
});
18 changes: 16 additions & 2 deletions themes/bootstrap3/js/vendor/autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* https://github.com/vufind-org/autocomplete.js (v2.1.7) (2023-06-21) */
/* https://github.com/vufind-org/autocomplete.js (v2.1.8) (2023-08-31) */
function Autocomplete(_settings) {
const _DEFAULTS = {
delay: 250,
Expand Down Expand Up @@ -73,6 +73,7 @@ function Autocomplete(_settings) {
list.classList.remove("open");
_currentIndex = -1;
lastInput = false;
lastCB = false;
demiankatz marked this conversation as resolved.
Show resolved Hide resolved
}

function _selectItem(item, input) {
Expand Down Expand Up @@ -252,6 +253,7 @@ function Autocomplete(_settings) {
if (!input) {
return false;
}

if (typeof handler === "undefined") {
throw new Error(
"Autocomplete needs handler to return items based on a query: function(query, callback) {}"
Expand Down Expand Up @@ -291,7 +293,14 @@ function Autocomplete(_settings) {
input.setAttribute("spellcheck", "false"); // ^

// Activation / De-activation
input.addEventListener("focus", (_) => _search(handler, input), false);
if (input.getAttribute("autofocus") !== null) {
// ignore the first autofocus
input.addEventListener("focus", () => {
input.addEventListener("focus", () => _search(handler, input));
}, { once: true });
} else {
input.addEventListener("focus", () => _search(handler, input));
}
input.addEventListener("blur", _hide, false);

// Input typing
Expand Down Expand Up @@ -323,6 +332,11 @@ function Autocomplete(_settings) {
false
);

input.ac = {
show: _show,
hide: _hide,
}

return input;
};
}
Expand Down