diff --git a/dist/js/sth-select.js b/dist/js/sth-select.js index 5c86579..6cc6aed 100644 --- a/dist/js/sth-select.js +++ b/dist/js/sth-select.js @@ -200,31 +200,33 @@ /** * Renders all elements in the list of options. */ - function _renderList(caseSensitive) { + function _renderList() { _clear(); var rerenderOnEachItem = false; var $listItems = $([]); - var textFilter = _formatText(caseSensitive, _$filter.val()); + var textFilter = _$filter.val().toLowerCase(); - _items.forEach(function (item) { - var text = _formatText(caseSensitive, item.text); - if (text.indexOf(textFilter) != -1) { + _items.map(function (item) { + if (item.text.toLowerCase().indexOf(textFilter) != -1) { var $listItem = _addItem(item, rerenderOnEachItem); + $listItem.click(function () { + _onSelectCallback(item); + hide(); + }); + $listItems = $listItems.add($listItem); } }); _$content.append($listItems); - _$content.one('click', function (event) { - var item = $(event.target).data('item'); - _properties.onSelect(item, event); - _onSelectCallback(item); - hide(event); - }); + var popupHeight = _calculatePopupHeight(); var titleHeight = _$title.outerHeight(); - _$content.outerHeight(popupHeight - titleHeight); + var filterHeight = _$filter.outerHeight(); + var contentHeight = popupHeight - titleHeight; + if (_properties.hasFilter) contentHeight = contentHeight - filterHeight; + _$content.outerHeight(contentHeight); } /** @@ -414,4 +416,4 @@ $(document).ready(function loadFromHtmlAPI() { function boolFromString(string) { return string == "true"; } -}); \ No newline at end of file +}); diff --git a/src/js/_popup.js b/src/js/_popup.js index c39ffd2..03235bf 100644 --- a/src/js/_popup.js +++ b/src/js/_popup.js @@ -175,7 +175,11 @@ }); let popupHeight = _calculatePopupHeight(); let titleHeight = _$title.outerHeight(); - _$content.outerHeight( (popupHeight - titleHeight) ); + let filterHeight = _$filter.outerHeight(); + let contentHeight = (popupHeight - titleHeight); + if(_properties.hasFilter) + contentHeight = contentHeight - filterHeight; + _$content.outerHeight(contentHeight); } /**