From 973cb0fdece43b197b225347ef36c34803c65a13 Mon Sep 17 00:00:00 2001 From: Tim Krehan Date: Tue, 21 May 2019 16:47:14 +0200 Subject: [PATCH] fixed autocomplete --- bin/autocomplete.js | 10 +++++++++- bin/bootstrap.autocomplete.js | 1 - bin/manageRecipe.js | 8 +++++--- cont/manageRecipe.php | 4 ++-- 4 files changed, 16 insertions(+), 7 deletions(-) delete mode 100644 bin/bootstrap.autocomplete.js diff --git a/bin/autocomplete.js b/bin/autocomplete.js index c211afa..e6fc4a0 100644 --- a/bin/autocomplete.js +++ b/bin/autocomplete.js @@ -8,7 +8,9 @@ function autocomplete() { data: { q: search }, - success: function (data) { createAutocompleteDropdown(elem, JSON.parse(data)); } + success: function (data) { + createAutocompleteDropdown(elem, JSON.parse(data)); + } }); } } @@ -17,6 +19,10 @@ function createAutocompleteDropdown(elem, values) { var dropdownItems = dropdownmenue.find(".dropdown-item"); dropdownItems.remove(); + if (!(dropdownmenue.hasClass("show"))){ + elem.click(); + } + for (index = 0; index < values.length; index++) { var value = values[index]; var regex = new RegExp((elem).val(), "ig"); @@ -31,4 +37,6 @@ function createAutocompleteDropdown(elem, values) { function dropdownButtonClick() { var string = $(this).data("val"); $('#' + $(this).attr("aria-textfield")).val(string); + $('[aria-labelledby=' + $('#' + $(this).attr("aria-textfield")).attr("id") + ']').find(".dropdown-item").remove(); + $('[aria-labelledby=' + $('#' + $(this).attr("aria-textfield")).attr("id") + ']').append(''); } \ No newline at end of file diff --git a/bin/bootstrap.autocomplete.js b/bin/bootstrap.autocomplete.js deleted file mode 100644 index 2f87664..0000000 --- a/bin/bootstrap.autocomplete.js +++ /dev/null @@ -1 +0,0 @@ -!function(n){var i={};function s(e){if(i[e])return i[e].exports;var t=i[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,s),t.l=!0,t.exports}s.m=n,s.c=i,s.d=function(e,t,n){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)s.d(n,i,function(e){return t[e]}.bind(null,i));return n},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s="./src/main.ts")}({"./src/dropdown.ts":function(module,__webpack_exports__,__webpack_require__){"use strict";eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"Dropdown\", function() { return Dropdown; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"DropdownV4\", function() { return DropdownV4; });\n/*\n *\tDropdown class. Manages the dropdown drawing\n */\nvar Dropdown = /** @class */ (function () {\n function Dropdown(e, formatItemCbk, autoSelect, noResultsText) {\n this.initialized = false;\n this.shown = false;\n this.items = [];\n this._$el = e;\n this.formatItem = formatItemCbk;\n this.autoSelect = autoSelect;\n this.noResultsText = noResultsText;\n // initialize it in lazy mode to deal with glitches like modals\n // this.init();\n }\n Dropdown.prototype.init = function () {\n var _this = this;\n // Initialize dropdown\n var pos = $.extend({}, this._$el.position(), {\n height: this._$el[0].offsetHeight\n });\n // create element\n this._dd = $('