Skip to content

Commit

Permalink
Add clear live-search
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWook authored Dec 4, 2017
1 parent 2862539 commit d7863d1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/nya-bs-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,28 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', '$compi
};
$document.on('click', outClick);

function reset_search() {
searchBox.children().eq(0)[0].value = "";
var options = dropdownMenu.children(),
length = options.length,
index,
option,
nyaBsOptionNode;
for(index = 0; index < length; index++) {
option = options.eq(index);
if(option.hasClass('nya-bs-option')) {
option.removeClass('not-match');
}
}
noSearchResult.removeClass('show');
nyaBsOptionNode = findFocus(true);

if(nyaBsOptionNode) {
options.removeClass('active');
jqLite(nyaBsOptionNode).addClass('active');
}
}

console.log(dropdownToggle[0]==$element.find('button').eq(0)[0]);

dropdownToggle.on('blur', function() {
Expand All @@ -356,6 +378,7 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', '$compi
calcMenuSize();
}
if($attrs.liveSearch === 'true' && $element.hasClass('open')) {
reset_search();
searchBox.children().eq(0)[0].focus();
nyaBsOptionNode = findFocus(true);
if(nyaBsOptionNode) {
Expand Down

0 comments on commit d7863d1

Please sign in to comment.