web/static/css/jq-css/demos/autocomplete/folding.html
changeset 61 cb1b83039bc1
parent 60 a8ad7ebf5902
parent 59 37a0235ff5fb
child 62 39b2dab4f939
equal deleted inserted replaced
60:a8ad7ebf5902 61:cb1b83039bc1
     1 <!DOCTYPE html>
       
     2 <html lang="en">
       
     3 <head>
       
     4 	<meta charset="UTF-8" />
       
     5 	<title>jQuery UI Autocomplete Accent Folding Demo</title>
       
     6 	<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
       
     7 	<script type="text/javascript" src="../../jquery-1.4.2.js"></script>
       
     8 	<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
       
     9 	<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
       
    10 	<script type="text/javascript" src="../../ui/jquery.ui.position.js"></script>
       
    11 	<script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script>
       
    12 	<link type="text/css" href="../demos.css" rel="stylesheet" />
       
    13 	<script type="text/javascript">
       
    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 <div class="demo-description">
       
    55 <p>
       
    56 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.
       
    57 </p>
       
    58 <p>
       
    59 Try typing "Jo" to see "John" and "Jörn", then type "Jö" to see only "Jörn".
       
    60 </p>
       
    61 </div><!-- End demo-description -->
       
    62 
       
    63 </body>
       
    64 </html>