NOBUG: Fixed file access permissions
[moodle.git] / lib / yuilib / 3.13.0 / autocomplete-highlighters-accentfold / autocomplete-highlighters-accentfold-debug.js
blob25d17b8c28cafea82ce16d131d15d3e97c1aacff
1 /*
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/
6 */
8 YUI.add('autocomplete-highlighters-accentfold', function (Y, NAME) {
10 /**
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
16 highlighters.
18 @module autocomplete
19 @submodule autocomplete-highlighters-accentfold
20 **/
22 /**
23 @class AutoCompleteHighlighters
24 @static
25 **/
27 var Highlight = Y.Highlight,
28     YArray    = Y.Array;
30 Y.mix(Y.namespace('AutoCompleteHighlighters'), {
31     /**
32     Accent-folding version of `charMatch()`.
34     @method charMatchFold
35     @param {String} query Query to match
36     @param {Array} results Results to highlight
37     @return {Array} Highlighted results
38     @static
39     **/
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);
45         });
46     },
48     /**
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
55     @static
56     **/
57     phraseMatchFold: function (query, results) {
58         return YArray.map(results, function (result) {
59             return Highlight.allFold(result.text, [query]);
60         });
61     },
63     /**
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
70     @static
71     **/
72     startsWithFold: function (query, results) {
73         return YArray.map(results, function (result) {
74             return Highlight.allFold(result.text, [query], {
75                 startsWith: true
76             });
77         });
78     },
80     /**
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
87     @static
88     **/
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);
94         });
95     },
97     /**
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
104     @static
105     **/
106     wordMatchFold: function (query, results) {
107         return YArray.map(results, function (result) {
108             return Highlight.wordsFold(result.text, query);
109         });
110     }
114 }, '3.13.0', {"requires": ["array-extras", "highlight-accentfold"]});