|
278 | 278 | } |
279 | 279 |
|
280 | 280 | return function (query) { |
281 | | - var t = query.term.toUpperCase(), filtered = {}; |
| 281 | + var t = query.term, filtered = {}; |
282 | 282 | if (t === "") { |
283 | 283 | query.callback({results: data}); |
284 | 284 | return; |
285 | 285 | } |
286 | 286 | filtered.results = $(data) |
287 | | - .filter(function () {return text(this).toUpperCase().indexOf(t) >= 0;}) |
| 287 | + .filter(function () {return query.matcher(t, text(this));}) |
288 | 288 | .get(); |
289 | 289 | query.callback(filtered); |
290 | 290 | }; |
|
301 | 301 | // if not a function we assume it to be an array |
302 | 302 |
|
303 | 303 | return function (query) { |
304 | | - var t = query.term.toUpperCase(), filtered = {results: []}; |
| 304 | + var t = query.term, filtered = {results: []}; |
305 | 305 | $(data).each(function () { |
306 | 306 | var isObject = this.text !== undefined, |
307 | 307 | text = isObject ? this.text : this; |
308 | | - if (t === "" || text.toUpperCase().indexOf(t) >= 0) { |
| 308 | + if (t === "" || query.matcher(t, text)) { |
309 | 309 | filtered.results.push(isObject ? this : {id: this, text: this}); |
310 | 310 | } |
311 | 311 | }); |
|
470 | 470 | formatInputTooShort: function (input, min) { return "Please enter " + (min - input.length) + " more characters"; }, |
471 | 471 | minimumResultsForSearch: 0, |
472 | 472 | minimumInputLength: 0, |
473 | | - id: function (e) { return e.id; } |
| 473 | + id: function (e) { return e.id; }, |
| 474 | + matcher: function(term, text) { |
| 475 | + return text.toUpperCase().indexOf(term.toUpperCase()) >= 0; |
| 476 | + } |
474 | 477 | }, opts); |
475 | 478 |
|
476 | 479 | if (typeof(opts.id) !== "function") { |
|
481 | 484 | if (select) { |
482 | 485 | opts.query = this.bind(function (query) { |
483 | 486 | var data = {results: [], more: false}, |
484 | | - term = query.term.toUpperCase(), |
| 487 | + term = query.term, |
485 | 488 | placeholder = this.getPlaceholder(); |
486 | 489 | element.find("option").each(function (i) { |
487 | 490 | var e = $(this), |
488 | 491 | text = e.text(); |
489 | 492 |
|
490 | 493 | if (i === 0 && placeholder !== undefined && text === "") return true; |
491 | 494 |
|
492 | | - if (text.toUpperCase().indexOf(term) >= 0) { |
| 495 | + if (query.matcher(term, text)) { |
493 | 496 | data.results.push({id: e.attr("value"), text: text}); |
494 | 497 | } |
495 | 498 | }); |
|
676 | 679 | term: this.search.val(), |
677 | 680 | page: page, |
678 | 681 | context: self.context, |
| 682 | + matcher: self.opts.matcher, |
679 | 683 | callback: this.bind(function (data) { |
680 | 684 | var parts = [], self = this; |
681 | 685 | $(data.results).each(function () { |
|
726 | 730 | term: search.val(), |
727 | 731 | page: this.resultsPage, |
728 | 732 | context: null, |
| 733 | + matcher: opts.matcher, |
729 | 734 | callback: this.bind(function (data) { |
730 | 735 | var parts = [], // html parts |
731 | 736 | def; // default choice |
|
0 commit comments