~ubuntu-branches/ubuntu/utopic/moodle/utopic

« back to all changes in this revision

Viewing changes to lib/yuilib/3.9.1/build/autocomplete-highlighters-accentfold/autocomplete-highlighters-accentfold-debug.js

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-05-12 16:10:38 UTC
  • mfrom: (36.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140512161038-puyqf65k4e0s8ytz
Tags: 2.6.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* YUI 3.9.1 (build 5852) Copyright 2013 Yahoo! Inc. http://yuilibrary.com/license/ */
2
 
YUI.add('autocomplete-highlighters-accentfold', function (Y, NAME) {
3
 
 
4
 
/**
5
 
Provides pre-built accent-folding result highlighters for AutoComplete.
6
 
 
7
 
These highlighters are similar to the ones provided by the `autocomplete-
8
 
highlighters` module, but use accent-aware comparisons. For example, "resume"
9
 
and "résumé" will be considered equal when using the accent-folding
10
 
highlighters.
11
 
 
12
 
@module autocomplete
13
 
@submodule autocomplete-highlighters-accentfold
14
 
**/
15
 
 
16
 
/**
17
 
@class AutoCompleteHighlighters
18
 
@static
19
 
**/
20
 
 
21
 
var Highlight = Y.Highlight,
22
 
    YArray    = Y.Array;
23
 
 
24
 
Y.mix(Y.namespace('AutoCompleteHighlighters'), {
25
 
    /**
26
 
    Accent-folding version of `charMatch()`.
27
 
 
28
 
    @method charMatchFold
29
 
    @param {String} query Query to match
30
 
    @param {Array} results Results to highlight
31
 
    @return {Array} Highlighted results
32
 
    @static
33
 
    **/
34
 
    charMatchFold: function (query, results) {
35
 
        var queryChars = YArray.unique(query.split(''));
36
 
 
37
 
        return YArray.map(results, function (result) {
38
 
            return Highlight.allFold(result.text, queryChars);
39
 
        });
40
 
    },
41
 
 
42
 
    /**
43
 
    Accent-folding version of `phraseMatch()`.
44
 
 
45
 
    @method phraseMatchFold
46
 
    @param {String} query Query to match
47
 
    @param {Array} results Results to highlight
48
 
    @return {Array} Highlighted results
49
 
    @static
50
 
    **/
51
 
    phraseMatchFold: function (query, results) {
52
 
        return YArray.map(results, function (result) {
53
 
            return Highlight.allFold(result.text, [query]);
54
 
        });
55
 
    },
56
 
 
57
 
    /**
58
 
    Accent-folding version of `startsWith()`.
59
 
 
60
 
    @method startsWithFold
61
 
    @param {String} query Query to match
62
 
    @param {Array} results Results to highlight
63
 
    @return {Array} Highlighted results
64
 
    @static
65
 
    **/
66
 
    startsWithFold: function (query, results) {
67
 
        return YArray.map(results, function (result) {
68
 
            return Highlight.allFold(result.text, [query], {
69
 
                startsWith: true
70
 
            });
71
 
        });
72
 
    },
73
 
 
74
 
    /**
75
 
    Accent-folding version of `subWordMatch()`.
76
 
 
77
 
    @method subWordMatchFold
78
 
    @param {String} query Query to match
79
 
    @param {Array} results Results to highlight
80
 
    @return {Array} Highlighted results
81
 
    @static
82
 
    **/
83
 
    subWordMatchFold: function (query, results) {
84
 
        var queryWords = Y.Text.WordBreak.getUniqueWords(query);
85
 
 
86
 
        return YArray.map(results, function (result) {
87
 
            return Highlight.allFold(result.text, queryWords);
88
 
        });
89
 
    },
90
 
 
91
 
    /**
92
 
    Accent-folding version of `wordMatch()`.
93
 
 
94
 
    @method wordMatchFold
95
 
    @param {String} query Query to match
96
 
    @param {Array} results Results to highlight
97
 
    @return {Array} Highlighted results
98
 
    @static
99
 
    **/
100
 
    wordMatchFold: function (query, results) {
101
 
        return YArray.map(results, function (result) {
102
 
            return Highlight.wordsFold(result.text, query);
103
 
        });
104
 
    }
105
 
});
106
 
 
107
 
 
108
 
}, '3.9.1', {"requires": ["array-extras", "highlight-accentfold"]});