From 9db9750565f294d0586ade17a1024d2c16405c99 Mon Sep 17 00:00:00 2001 From: Anmol Wassan Date: Tue, 10 Oct 2017 07:06:23 +0000 Subject: [PATCH 1/2] Update _popup.js to show the last element. --- src/js/_popup.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); } /** From 49d5c4ea86b2b0dd4b46ab6a9971c58074944062 Mon Sep 17 00:00:00 2001 From: Anmol Wassan Date: Sun, 22 Oct 2017 13:59:02 +0000 Subject: [PATCH 2/2] Update file using gulp --- dist/js/sth-select.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) 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 +});