~ubuntu-branches/ubuntu/precise/maas/precise-updates

« back to all changes in this revision

Viewing changes to debian/extras/jslibs/yui/autocomplete-highlighters-accentfold/autocomplete-highlighters-accentfold-debug.js

Tags: 1.2+bzr1373+dfsg-0ubuntu1~12.04.4
* SECURITY UPDATE: failure to authenticate downloaded content (LP: #1039513)
  - debian/patches/CVE-2013-1058.patch: Authenticate downloaded files with
    GnuPG and MD5SUM files. Thanks to Julian Edwards.
  - CVE-2013-1058
* SECURITY UPDATE: configuration options may be loaded from current working
  directory (LP: #1158425)
  - debian/patches/CVE-2013-1057-1-2.patch: Do not load configuration
    options from the current working directory. Thanks to Julian Edwards.
  - CVE-2013-1057

Show diffs side-by-side

added added

removed removed

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