From 5c538e70f27b8e64c345be56a28034f79a78e3cc Mon Sep 17 00:00:00 2001 From: jlukic Date: Wed, 8 Apr 2015 12:47:06 -0400 Subject: [PATCH] Adds #2083, search can specify whether to match on text, value or both --- src/definitions/modules/dropdown.js | 31 +++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index c350732c6..95d4e6109 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -454,15 +454,32 @@ $.fn.dropdown = function(parameters) { .each(function(){ var $choice = $(this), - text = String(module.get.choiceText($choice, false)), - value = String(module.get.choiceValue($choice, text)) + text, + value ; - if( text.match(exactRegExp) || value.match(exactRegExp) ) { - $results = $results.add($choice); + if(settings.match == 'both' || settings.match == 'text') { + text = String(module.get.choiceText($choice, false)); + + if(text.match(exactRegExp)) { + $results = $results.add($choice); + return true; + } + else if(settings.fullTextSearch && text.match(fullTextRegExp)) { + $results = $results.add($choice); + return true; + } } - else if(settings.fullTextSearch) { - if( text.match(fullTextRegExp) || value.match(fullTextRegExp) ) { + if(settings.match == 'both' || settings.match == 'value') { + console.log('here'); + value = String(module.get.choiceValue($choice, text)); + + if(value.match(exactRegExp)) { + $results = $results.add($choice); + return true; + } + else if(settings.fullTextSearch && value.match(fullTextRegExp)) { $results = $results.add($choice); + return true; } } }) @@ -2088,6 +2105,8 @@ $.fn.dropdown.settings = { variation : false }, + match: 'both', + allowCategorySelection : false, delay : {