diff --git a/public/js/app.js b/public/js/app.js index 5e880698..76f01756 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -4120,20 +4120,20 @@ $.when($.ready).then(function () { var width = $input.outerWidth(); var $autocomplete = $('
'); suggestions.forEach(function (suggestion) { - var $item = $('').text(suggestion).on('click', function () { + var $item = $('').text(suggestion).on("click", function () { $input.val(suggestion); hideAutocomplete(); - $input.closest('form').submit(); + $input.closest("form").submit(); }); $autocomplete.append($item); }); $autocomplete.css({ - position: 'absolute', - top: position.top + $input.outerHeight() + 'px', - left: position.left + 'px', - width: width + 'px' + position: "absolute", + top: "".concat(position.top + $input.outerHeight(), "px"), + left: "".concat(position.left, "px"), + width: "".concat(width, "px") }); - $input.closest('#search-container').append($autocomplete); + $input.closest("#search-container").append($autocomplete); } function fetchAutocomplete(query, provider) { // Cancel previous request if any @@ -4145,8 +4145,8 @@ $.when($.ready).then(function () { return; } currentAutocompleteRequest = $.ajax({ - url: base + 'search/autocomplete', - method: 'GET', + url: "".concat(base, "search/autocomplete"), + method: "GET", data: { q: query, provider: provider @@ -4209,15 +4209,15 @@ $.when($.ready).then(function () { }); // Hide autocomplete when clicking outside - $(document).on('click', function (e) { - if (!$(e.target).closest('#search-container').length) { + $(document).on("click", function (e) { + if (!$(e.target).closest("#search-container").length) { hideAutocomplete(); } }); // Hide autocomplete on Escape key - $(document).on('keydown', function (e) { - if (e.key === 'Escape') { + $(document).on("keydown", function (e) { + if (e.key === "Escape") { hideAutocomplete(); } }); diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 077b08a3..a8bc3a49 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -1,4 +1,4 @@ { "/css/app.css": "/css/app.css?id=18678c7bd2dc9b9f1d75e1aff3b7ea8e", - "/js/app.js": "/js/app.js?id=43116113f2c9194304ab84d8205fc7f9" + "/js/app.js": "/js/app.js?id=427b8a731c1bc78d363961ff85a33ee3" } diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index ab8b2cae..c8bb53dc 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -118,7 +118,7 @@ $.when($.ready).then(() => { function showAutocomplete(suggestions, inputElement) { hideAutocomplete(); - + if (!suggestions || suggestions.length === 0) { return; } @@ -128,26 +128,26 @@ $.when($.ready).then(() => { const width = $input.outerWidth(); const $autocomplete = $(''); - + suggestions.forEach((suggestion) => { const $item = $('') .text(suggestion) - .on('click', function() { + .on("click", () => { $input.val(suggestion); hideAutocomplete(); - $input.closest('form').submit(); + $input.closest("form").submit(); }); $autocomplete.append($item); }); $autocomplete.css({ - position: 'absolute', - top: position.top + $input.outerHeight() + 'px', - left: position.left + 'px', - width: width + 'px' + position: "absolute", + top: `${position.top + $input.outerHeight()}px`, + left: `${position.left}px`, + width: `${width}px`, }); - $input.closest('#search-container').append($autocomplete); + $input.closest("#search-container").append($autocomplete); } function fetchAutocomplete(query, provider) { @@ -162,22 +162,22 @@ $.when($.ready).then(() => { } currentAutocompleteRequest = $.ajax({ - url: base + 'search/autocomplete', - method: 'GET', + url: `${base}search/autocomplete`, + method: "GET", data: { q: query, - provider: provider + provider, }, - success: function(data) { + success(data) { const inputElement = $("#search-container input[name=q]")[0]; showAutocomplete(data, inputElement); }, - error: function() { + error() { hideAutocomplete(); }, - complete: function() { + complete() { currentAutocompleteRequest = null; - } + }, }); } @@ -186,7 +186,7 @@ $.when($.ready).then(() => { const search = this.value; const items = $("#sortable").find(".item-container"); const provider = $("#search-container select[name=provider]").val(); - + if (provider === "tiles") { hideAutocomplete(); if (search.length > 0) { @@ -202,7 +202,7 @@ $.when($.ready).then(() => { } } else { items.show(); - + // Debounce autocomplete requests clearTimeout(autocompleteTimeout); autocompleteTimeout = setTimeout(() => { @@ -234,15 +234,15 @@ $.when($.ready).then(() => { }); // Hide autocomplete when clicking outside - $(document).on('click', function(e) { - if (!$(e.target).closest('#search-container').length) { + $(document).on("click", (e) => { + if (!$(e.target).closest("#search-container").length) { hideAutocomplete(); } }); // Hide autocomplete on Escape key - $(document).on('keydown', function(e) { - if (e.key === 'Escape') { + $(document).on("keydown", (e) => { + if (e.key === "Escape") { hideAutocomplete(); } });