root/other-projects/tipple-android/i-greenstone-server-files/greenstone/webapps/greenstone3/interfaces/default/js/jquery-ui-1.8.15/demos/autocomplete/folding.html @ 26899

Revision 26899, 1.8 KB (checked in by davidb, 7 years ago)

Tipple reborn after Chris's Summer of Code 2013

Line 
1<!DOCTYPE html>
2<html lang="en">
3<head>
4    <meta charset="utf-8">
5    <title>jQuery UI Autocomplete - Accent folding</title>
6    <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
7    <script src="../../jquery-1.6.2.js"></script>
8    <script src="../../ui/jquery.ui.core.js"></script>
9    <script src="../../ui/jquery.ui.widget.js"></script>
10    <script src="../../ui/jquery.ui.position.js"></script>
11    <script src="../../ui/jquery.ui.autocomplete.js"></script>
12    <link rel="stylesheet" href="../demos.css">
13    <script>
14    $(function() {
15        var names = [ "Jörn Zaefferer", "Scott González", "John Resig" ];
16
17        var accentMap = {
18            "á": "a",
19            "ö": "o"
20        };
21        var normalize = function( term ) {
22            var ret = "";
23            for ( var i = 0; i < term.length; i++ ) {
24                ret += accentMap[ term.charAt(i) ] || term.charAt(i);
25            }
26            return ret;
27        };
28
29        $( "#developer" ).autocomplete({
30            source: function( request, response ) {
31                var matcher = new RegExp( $.ui.autocomplete.escapeRegex( request.term ), "i" );
32                response( $.grep( names, function( value ) {
33                    value = value.label || value.value || value;
34                    return matcher.test( value ) || matcher.test( normalize( value ) );
35                }) );
36            }
37        });
38    });
39    </script>
40</head>
41<body>
42
43<div class="demo">
44
45<div class="ui-widget">
46    <form>
47    <label for="developer">Developer: </label>
48    <input id="developer" />
49    </form>
50</div>
51
52</div><!-- End demo -->
53
54
55
56<div class="demo-description">
57<p>The autocomplete field uses a custom source option which will match results that have accented characters even when the text field doesn't contain accented characters. However if the you type in accented characters in the text field it is smart enough not to show results that aren't accented.</p>
58<p>Try typing "Jo" to see "John" and "Jörn", then type "Jö" to see only "Jörn".</p>
59</div><!-- End demo-description -->
60
61</body>
62</html>
Note: See TracBrowser for help on using the browser.