|
@ -485,7 +485,6 @@ $.fn.dropdown = function(parameters) { |
|
|
$results = $(), |
|
|
$results = $(), |
|
|
escapedTerm = module.escape.regExp(searchTerm), |
|
|
escapedTerm = module.escape.regExp(searchTerm), |
|
|
exactRegExp = new RegExp('^' + escapedTerm, 'igm'), |
|
|
exactRegExp = new RegExp('^' + escapedTerm, 'igm'), |
|
|
fullTextRegExp = new RegExp(escapedTerm, 'ig'), |
|
|
|
|
|
allItemsFiltered |
|
|
allItemsFiltered |
|
|
; |
|
|
; |
|
|
module.verbose('Searching for matching values'); |
|
|
module.verbose('Searching for matching values'); |
|
@ -503,7 +502,7 @@ $.fn.dropdown = function(parameters) { |
|
|
$results = $results.add($choice); |
|
|
$results = $results.add($choice); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
else if(settings.fullTextSearch && text.match(fullTextRegExp)) { |
|
|
|
|
|
|
|
|
else if(settings.fullTextSearch && module.fuzzySearch(searchTerm, text)) { |
|
|
$results = $results.add($choice); |
|
|
$results = $results.add($choice); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
@ -515,7 +514,7 @@ $.fn.dropdown = function(parameters) { |
|
|
$results = $results.add($choice); |
|
|
$results = $results.add($choice); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
else if(settings.fullTextSearch && value.match(fullTextRegExp)) { |
|
|
|
|
|
|
|
|
else if(settings.fullTextSearch && module.fuzzySearch(searchTerm, value)) { |
|
|
$results = $results.add($choice); |
|
|
$results = $results.add($choice); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
@ -543,6 +542,33 @@ $.fn.dropdown = function(parameters) { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
fuzzySearch: function(query, term) { |
|
|
|
|
|
var |
|
|
|
|
|
termLength = term.length, |
|
|
|
|
|
queryLength = query.length |
|
|
|
|
|
; |
|
|
|
|
|
query = query.toLowerCase(); |
|
|
|
|
|
term = term.toLowerCase(); |
|
|
|
|
|
if(queryLength > termLength) { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
if(queryLength === termLength) { |
|
|
|
|
|
return (query === term); |
|
|
|
|
|
} |
|
|
|
|
|
search: for (var characterIndex = 0, nextCharacterIndex = 0; characterIndex < queryLength; characterIndex++) { |
|
|
|
|
|
var |
|
|
|
|
|
queryCharacter = query.charCodeAt(characterIndex) |
|
|
|
|
|
; |
|
|
|
|
|
while(nextCharacterIndex < termLength) { |
|
|
|
|
|
if(term.charCodeAt(nextCharacterIndex++) === queryCharacter) { |
|
|
|
|
|
continue search; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
filterActive: function() { |
|
|
filterActive: function() { |
|
|
if(settings.hideSelections) { |
|
|
if(settings.hideSelections) { |
|
|
$item.filter('.' + className.active) |
|
|
$item.filter('.' + className.active) |
|
|