~ubuntuone-hackers/online-services-common-js/trunk

« back to all changes in this revision

Viewing changes to build/searchbar-autocomplete/searchbar-autocomplete-debug.js

  • Committer: jonas-drange
  • Date: 2014-05-14 09:49:12 UTC
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: jonas.drange@canonical.com-20140514094912-g2fjwnydr2ou5gnt
addressing comments

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
var searchbars = Y.all('.ues-searchbar');
7
7
 
8
 
if (searchbars.size()) {
9
 
    searchbars.each(function(node, i) {
10
 
 
11
 
        // input which has autocomplete plugin
12
 
        var input;
13
 
        // autocomplete boundingbox
14
 
        var autoCompleteBox;
15
 
 
16
 
        input = node.one('input[type="search"]');
17
 
        if(!input) {
18
 
            throw new Error('autocomplete is missing input');
19
 
        }
20
 
 
21
 
        // plug autocomplete
22
 
        input.plug(Y.Plugin.AutoComplete, {
23
 
            resultTextLocator: 'text',
24
 
            resultHighlighter: 'phraseMatch',
25
 
            tabSelect: true
26
 
        });
27
 
 
28
 
        // add ues classes
29
 
        autoCompleteBox = input.ac.get('boundingBox');
30
 
        autoCompleteBox.addClass('ues-autocomplete').addClass('ues-dropdown');
31
 
        autoCompleteBox.one('ul').addClass('ues-dropdown-menu');
32
 
        autoCompleteBox.setStyle('width', '100%');
33
 
 
34
 
        // make ac control the visibility of the ues-dropdown
35
 
        input.ac.before('visibleChange', function (e) {
36
 
            autoCompleteBox.toggleClass('open', e.newVal);
37
 
        });
38
 
 
39
 
    });
40
 
}
 
8
searchbars.each(function (node, i) {
 
9
 
 
10
    // input which has autocomplete plugin
 
11
    var input;
 
12
    // autocomplete boundingbox
 
13
    var autoCompleteBox;
 
14
 
 
15
    input = node.one('input[type="search"]');
 
16
    if (!input) {
 
17
        throw new Error('autocomplete is missing input');
 
18
    }
 
19
 
 
20
    // plug autocomplete
 
21
    input.plug(Y.Plugin.AutoComplete, {
 
22
        resultTextLocator: 'text',
 
23
        resultHighlighter: 'phraseMatch',
 
24
        tabSelect: true
 
25
    });
 
26
 
 
27
    // add ues classes
 
28
    autoCompleteBox = input.ac.get('boundingBox');
 
29
    autoCompleteBox.addClass('ues-autocomplete').addClass('ues-dropdown');
 
30
    autoCompleteBox.one('ul').addClass('ues-dropdown-menu');
 
31
    autoCompleteBox.setStyle('width', '100%');
 
32
 
 
33
    // make ac control the visibility of the ues-dropdown
 
34
    input.ac.before('visibleChange', function (e) {
 
35
        autoCompleteBox.toggleClass('open', e.newVal);
 
36
    });
 
37
 
 
38
});
41
39
 
42
40
})();
43
41