2 YUI 3.13.0 (build 508226d)
3 Copyright 2013 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
8 YUI.add('autocomplete-highlighters-accentfold', function (Y, NAME) {
11 Provides pre-built accent-folding result highlighters for AutoComplete.
13 These highlighters are similar to the ones provided by the `autocomplete-
14 highlighters` module, but use accent-aware comparisons. For example, "resume"
15 and "résumé" will be considered equal when using the accent-folding
19 @submodule autocomplete-highlighters-accentfold
23 @class AutoCompleteHighlighters
27 var Highlight = Y.Highlight,
30 Y.mix(Y.namespace('AutoCompleteHighlighters'), {
32 Accent-folding version of `charMatch()`.
35 @param {String} query Query to match
36 @param {Array} results Results to highlight
37 @return {Array} Highlighted results
40 charMatchFold: function (query, results) {
41 var queryChars = YArray.unique(query.split(''));
43 return YArray.map(results, function (result) {
44 return Highlight.allFold(result.text, queryChars);
49 Accent-folding version of `phraseMatch()`.
51 @method phraseMatchFold
52 @param {String} query Query to match
53 @param {Array} results Results to highlight
54 @return {Array} Highlighted results
57 phraseMatchFold: function (query, results) {
58 return YArray.map(results, function (result) {
59 return Highlight.allFold(result.text, [query]);
64 Accent-folding version of `startsWith()`.
66 @method startsWithFold
67 @param {String} query Query to match
68 @param {Array} results Results to highlight
69 @return {Array} Highlighted results
72 startsWithFold: function (query, results) {
73 return YArray.map(results, function (result) {
74 return Highlight.allFold(result.text, [query], {
81 Accent-folding version of `subWordMatch()`.
83 @method subWordMatchFold
84 @param {String} query Query to match
85 @param {Array} results Results to highlight
86 @return {Array} Highlighted results
89 subWordMatchFold: function (query, results) {
90 var queryWords = Y.Text.WordBreak.getUniqueWords(query);
92 return YArray.map(results, function (result) {
93 return Highlight.allFold(result.text, queryWords);
98 Accent-folding version of `wordMatch()`.
100 @method wordMatchFold
101 @param {String} query Query to match
102 @param {Array} results Results to highlight
103 @return {Array} Highlighted results
106 wordMatchFold: function (query, results) {
107 return YArray.map(results, function (result) {
108 return Highlight.wordsFold(result.text, query);
114 }, '3.13.0', {"requires": ["array-extras", "highlight-accentfold"]});