|
@ -687,15 +687,14 @@ $.fn.dropdown = function(parameters) { |
|
|
searchTerm = (query !== undefined) |
|
|
searchTerm = (query !== undefined) |
|
|
? query |
|
|
? query |
|
|
: module.get.query(), |
|
|
: module.get.query(), |
|
|
$results = $(), |
|
|
|
|
|
|
|
|
results = null, |
|
|
escapedTerm = module.escape.regExp(searchTerm), |
|
|
escapedTerm = module.escape.regExp(searchTerm), |
|
|
beginsWithRegExp = new RegExp('^' + escapedTerm, 'igm') |
|
|
beginsWithRegExp = new RegExp('^' + escapedTerm, 'igm') |
|
|
; |
|
|
; |
|
|
// avoid loop if we're matching nothing
|
|
|
// avoid loop if we're matching nothing
|
|
|
if( !module.has.query() ) { |
|
|
|
|
|
$results = $item; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
|
|
|
if( module.has.query() ) { |
|
|
|
|
|
results = []; |
|
|
|
|
|
|
|
|
module.verbose('Searching for matching values', searchTerm); |
|
|
module.verbose('Searching for matching values', searchTerm); |
|
|
$item |
|
|
$item |
|
|
.each(function(){ |
|
|
.each(function(){ |
|
@ -707,11 +706,11 @@ $.fn.dropdown = function(parameters) { |
|
|
if(settings.match == 'both' || settings.match == 'text') { |
|
|
if(settings.match == 'both' || settings.match == 'text') { |
|
|
text = String(module.get.choiceText($choice, false)); |
|
|
text = String(module.get.choiceText($choice, false)); |
|
|
if(text.search(beginsWithRegExp) !== -1) { |
|
|
if(text.search(beginsWithRegExp) !== -1) { |
|
|
$results = $results.add($choice); |
|
|
|
|
|
|
|
|
results.push(this); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
else if(settings.fullTextSearch && module.fuzzySearch(searchTerm, text)) { |
|
|
else if(settings.fullTextSearch && module.fuzzySearch(searchTerm, text)) { |
|
|
$results = $results.add($choice); |
|
|
|
|
|
|
|
|
results.push(this); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -719,11 +718,11 @@ $.fn.dropdown = function(parameters) { |
|
|
value = String(module.get.choiceValue($choice, text)); |
|
|
value = String(module.get.choiceValue($choice, text)); |
|
|
|
|
|
|
|
|
if(value.search(beginsWithRegExp) !== -1) { |
|
|
if(value.search(beginsWithRegExp) !== -1) { |
|
|
$results = $results.add($choice); |
|
|
|
|
|
|
|
|
results.push(this); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
else if(settings.fullTextSearch && module.fuzzySearch(searchTerm, value)) { |
|
|
else if(settings.fullTextSearch && module.fuzzySearch(searchTerm, value)) { |
|
|
$results = $results.add($choice); |
|
|
|
|
|
|
|
|
results.push(this); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -732,10 +731,12 @@ $.fn.dropdown = function(parameters) { |
|
|
} |
|
|
} |
|
|
module.debug('Showing only matched items', searchTerm); |
|
|
module.debug('Showing only matched items', searchTerm); |
|
|
module.remove.filteredItem(); |
|
|
module.remove.filteredItem(); |
|
|
$item |
|
|
|
|
|
.not($results) |
|
|
|
|
|
.addClass(className.filtered) |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
if(results){ |
|
|
|
|
|
$item |
|
|
|
|
|
.not(results) |
|
|
|
|
|
.addClass(className.filtered) |
|
|
|
|
|
; |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
fuzzySearch: function(query, term) { |
|
|
fuzzySearch: function(query, term) { |
|
|