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
|
YUI.add('searchbar-autocomplete', function (Y, NAME) {
"use strict";
(function () {
var searchbars = Y.all('.ues-searchbar');
searchbars.each(function (node, i) {
// input which has autocomplete plugin
var input;
// autocomplete boundingbox
var autoCompleteBox;
input = node.one('input[type="search"]');
if (!input) {
throw new Error('autocomplete is missing input');
}
// plug autocomplete
input.plug(Y.Plugin.AutoComplete, {
resultTextLocator: 'text',
resultHighlighter: 'phraseMatch',
tabSelect: true
});
// add ues classes
autoCompleteBox = input.ac.get('boundingBox');
autoCompleteBox.addClass('ues-autocomplete').addClass('ues-dropdown');
autoCompleteBox.one('ul').addClass('ues-dropdown-menu');
autoCompleteBox.setStyle('width', '100%');
// make ac control the visibility of the ues-dropdown
input.ac.before('visibleChange', function (e) {
autoCompleteBox.toggleClass('open', e.newVal);
});
});
})();
}, '0.1.0', {"requires": ["node", "autocomplete"]});
|