/usr/share/javascript/yui3/autocomplete-highlighters/autocomplete-highlighters.js is in libjs-yui3-full 3.5.1-1ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | /*
YUI 3.5.1 (build 22)
Copyright 2012 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
YUI.add('autocomplete-highlighters', function(Y) {
/**
Provides pre-built result highlighters for AutoComplete.
@module autocomplete
@submodule autocomplete-highlighters
@class AutoCompleteHighlighters
@static
**/
var YArray = Y.Array,
Highlight = Y.Highlight,
Highlighters = Y.mix(Y.namespace('AutoCompleteHighlighters'), {
// -- Public Methods -------------------------------------------------------
/**
Highlights any individual query character that occurs anywhere in a result.
Case-insensitive.
@method charMatch
@param {String} query Query to match
@param {Array} results Results to highlight
@return {Array} Highlighted results
@static
**/
charMatch: function (query, results, caseSensitive) {
// The caseSensitive parameter is only intended for use by
// charMatchCase(). It's intentionally undocumented.
var queryChars = YArray.unique((caseSensitive ? query :
query.toLowerCase()).split(''));
return YArray.map(results, function (result) {
return Highlight.all(result.text, queryChars, {
caseSensitive: caseSensitive
});
});
},
/**
Case-sensitive version of `charMatch()`.
@method charMatchCase
@param {String} query Query to match
@param {Array} results Results to highlight
@return {Array} Highlighted results
@static
**/
charMatchCase: function (query, results) {
return Highlighters.charMatch(query, results, true);
},
/**
Highlights the complete query as a phrase anywhere within a result. Case-
insensitive.
@method phraseMatch
@param {String} query Query to match
@param {Array} results Results to highlight
@return {Array} Highlighted results
@static
**/
phraseMatch: function (query, results, caseSensitive) {
// The caseSensitive parameter is only intended for use by
// phraseMatchCase(). It's intentionally undocumented.
return YArray.map(results, function (result) {
return Highlight.all(result.text, [query], {
caseSensitive: caseSensitive
});
});
},
/**
Case-sensitive version of `phraseMatch()`.
@method phraseMatchCase
@param {String} query Query to match
@param {Array} results Results to highlight
@return {Array} Highlighted results
@static
**/
phraseMatchCase: function (query, results) {
return Highlighters.phraseMatch(query, results, true);
},
/**
Highlights the complete query as a phrase at the beginning of a result.
Case-insensitive.
@method startsWith
@param {String} query Query to match
@param {Array} results Results to highlight
@return {Array} Highlighted results
@static
**/
startsWith: function (query, results, caseSensitive) {
// The caseSensitive parameter is only intended for use by
// startsWithCase(). It's intentionally undocumented.
return YArray.map(results, function (result) {
return Highlight.all(result.text, [query], {
caseSensitive: caseSensitive,
startsWith : true
});
});
},
/**
Case-sensitive version of `startsWith()`.
@method startsWithCase
@param {String} query Query to match
@param {Array} results Results to highlight
@return {Array} Highlighted results
@static
**/
startsWithCase: function (query, results) {
return Highlighters.startsWith(query, results, true);
},
/**
Highlights portions of results in which words from the query match either
whole words or parts of words in the result. Non-word characters like
whitespace and certain punctuation are ignored. Case-insensitive.
@method subWordMatch
@param {String} query Query to match
@param {Array} results Results to highlight
@return {Array} Highlighted results
@static
**/
subWordMatch: function (query, results, caseSensitive) {
// The caseSensitive parameter is only intended for use by
// subWordMatchCase(). It's intentionally undocumented.
var queryWords = Y.Text.WordBreak.getUniqueWords(query, {
ignoreCase: !caseSensitive
});
return YArray.map(results, function (result) {
return Highlight.all(result.text, queryWords, {
caseSensitive: caseSensitive
});
});
},
/**
Case-sensitive version of `subWordMatch()`.
@method subWordMatchCase
@param {String} query Query to match
@param {Array} results Results to highlight
@return {Array} Highlighted results
@static
**/
subWordMatchCase: function (query, results) {
return Highlighters.subWordMatch(query, results, true);
},
/**
Highlights individual words in results that are also in the query. Non-word
characters like punctuation are ignored. Case-insensitive.
@method wordMatch
@param {String} query Query to match
@param {Array} results Results to highlight
@return {Array} Highlighted results
@static
**/
wordMatch: function (query, results, caseSensitive) {
// The caseSensitive parameter is only intended for use by
// wordMatchCase(). It's intentionally undocumented.
return YArray.map(results, function (result) {
return Highlight.words(result.text, query, {
caseSensitive: caseSensitive
});
});
},
/**
Case-sensitive version of `wordMatch()`.
@method wordMatchCase
@param {String} query Query to match
@param {Array} results Results to highlight
@return {Array} Highlighted results
@static
**/
wordMatchCase: function (query, results) {
return Highlighters.wordMatch(query, results, true);
}
});
}, '3.5.1' ,{requires:['array-extras', 'highlight-base']});
|