|
21 | 21 | allowMismatch: false, |
22 | 22 | allowMismatchBlank: true, // If "true" a user can backspace such that the value is nothing (even if no blank value was provided in the original criteria) |
23 | 23 | sortBy: 'score', // 'score' || 'name' |
| 24 | + blankSortBy: false, // 'initial' || 'score' || 'name' |
24 | 25 | preSelection: true, |
25 | 26 | hideDropdownOnEmptyInput: false, |
26 | 27 | selectedClass: "flexselect_selected", |
|
112 | 113 | self.hide(); |
113 | 114 | if (self.settings.allowMismatchBlank && $.trim($(this).val()) == '') |
114 | 115 | self.setValue(''); |
115 | | - if (!self.settings.allowMismatch && !self.picked) |
| 116 | + else if (!self.settings.allowMismatch && !self.picked) |
116 | 117 | self.reset(); |
117 | 118 | } |
118 | | - if (self.settings.hideDropdownOnEmptyInput) |
119 | | - self.dropdownList.show(); |
120 | 119 | }); |
121 | 120 |
|
122 | 121 | this.dropdownList.mouseover(function(event) { |
|
169 | 168 | self.filterResults(); |
170 | 169 | break; |
171 | 170 | } |
172 | | - if (self.settings.hideDropdownOnEmptyInput){ |
173 | | - if(self.input.val() == "") |
174 | | - self.dropdownList.hide(); |
175 | | - else |
176 | | - self.dropdownList.show(); |
177 | | - } |
178 | 171 | }); |
179 | 172 |
|
180 | 173 | this.input.keydown(function(event) { |
|
225 | 218 | if (this.score > 0.0) results.push(this); |
226 | 219 | }); |
227 | 220 | this.results = results; |
228 | | - |
229 | | - if (this.settings.sortBy == 'score') |
230 | | - this.sortResultsByScore(); |
231 | | - else if (this.settings.sortBy == 'name') |
232 | | - this.sortResultsByName(); |
| 221 | + |
| 222 | + if(this.settings.blankSortBy && $.trim(abbreviation) == ''){ |
| 223 | + if (this.settings.blankSortBy == 'score') |
| 224 | + this.sortResultsByScore(); |
| 225 | + else if (this.settings.blankSortBy == 'name') |
| 226 | + this.sortResultsByName(); |
| 227 | + } else { |
| 228 | + if (this.settings.sortBy == 'score') |
| 229 | + this.sortResultsByScore(); |
| 230 | + else if (this.settings.sortBy == 'name') |
| 231 | + this.sortResultsByName(); |
| 232 | + } |
233 | 233 |
|
234 | 234 | this.renderDropdown(); |
235 | 235 | this.markFirst(); |
236 | 236 | this.lastAbbreviation = abbreviation; |
237 | 237 | this.picked = false; |
238 | 238 | this.allowMouseMove = false; |
| 239 | + |
| 240 | + if (this.settings.hideDropdownOnEmptyInput){ |
| 241 | + if(this.input.val() == "") |
| 242 | + this.dropdown.hide(); |
| 243 | + else |
| 244 | + this.dropdown.show(); |
| 245 | + } |
239 | 246 | }, |
240 | 247 |
|
241 | 248 | sortResultsByScore: function() { |
|
0 commit comments