|
1 |
| -<!DOCTYPE html> |
2 |
| -<html lang="en"> |
3 |
| -<head> |
4 |
| - <meta charset="UTF-8" /> |
5 |
| - <title>jQuery UI Autocomplete Custom Data 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 |
| - <style type="text/css"> |
14 |
| - .ui-autocomplete-category { |
15 |
| - font-weight:bold; |
16 |
| - padding:.2em .4em; |
17 |
| - margin:.8em 0 .2em; |
18 |
| - line-height:1.5; |
19 |
| - } |
20 |
| - </style> |
21 |
| - <script type="text/javascript"> |
22 |
| - $.extend( $.ui.menu.prototype, { |
23 |
| - next: function() { |
24 |
| - this.move("next", ".ui-menu-item:first"); |
25 |
| - }, |
26 |
| - |
27 |
| - previous: function() { |
28 |
| - this.move("prev", ".ui-menu-item:last"); |
29 |
| - }, |
30 |
| - |
31 |
| - move: function(direction, edge) { |
32 |
| - if (!this.active) { |
33 |
| - this.activate(this.element.children(edge)); |
34 |
| - return; |
35 |
| - } |
36 |
| - var next = this.active[direction + "All"]('.ui-menu-item').eq( 0 ); |
37 |
| - if (next.length) { |
38 |
| - this.activate(next); |
39 |
| - } else { |
40 |
| - this.activate(this.element.children(edge)); |
41 |
| - } |
42 |
| - } |
43 |
| - }); |
44 |
| - |
45 |
| - $.widget("custom.catcomplete", $.ui.autocomplete, { |
46 |
| - _renderMenu: function( ul, items ) { |
47 |
| - var self = this, |
48 |
| - currentCategory = ""; |
49 |
| - $.each( items, function( index, item ) { |
50 |
| - if ( item.category != currentCategory ) { |
51 |
| - ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" ); |
52 |
| - currentCategory = item.category; |
53 |
| - } |
54 |
| - self._renderItem( ul, item ); |
55 |
| - }); |
56 |
| - } |
57 |
| - }); |
58 |
| - </script> |
59 |
| - <script type="text/javascript"> |
60 |
| - $(function() { |
61 |
| - var data = [ |
62 |
| - { label: "anders", category: "" }, |
63 |
| - { label: "andreas", category: "" }, |
64 |
| - { label: "antal", category: "" }, |
65 |
| - { label: "annhhx10", category: "Products" }, |
66 |
| - { label: "annk K12", category: "Products" }, |
67 |
| - { label: "annttop C13", category: "Products" }, |
68 |
| - { label: "anders andersson", category: "People" }, |
69 |
| - { label: "andreas andersson", category: "People" }, |
70 |
| - { label: "andreas johnson", category: "People" } |
71 |
| - ]; |
72 |
| - |
73 |
| - $('#search').catcomplete({ |
74 |
| - delay: 0, |
75 |
| - source: data |
76 |
| - }); |
77 |
| - }); |
78 |
| - </script> |
79 |
| -</head> |
80 |
| -<body> |
81 |
| - |
82 |
| -<div class="demo"> |
83 |
| - <label for="search">Search: </label> |
84 |
| - <input id="search" /> |
85 |
| -</div><!-- End demo --> |
86 |
| - |
87 |
| -<div class="demo-description"> |
88 |
| -<p> |
89 |
| - A categorized search result. Try typing "a" or "n". |
90 |
| -</p> |
91 |
| -</div><!-- End demo-description --> |
92 |
| - |
93 |
| -</body> |
94 |
| -</html> |
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8" /> |
| 5 | + <title>jQuery UI Autocomplete Custom Data 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 | + <style type="text/css"> |
| 14 | + .ui-autocomplete-category { |
| 15 | + font-weight:bold; |
| 16 | + padding:.2em .4em; |
| 17 | + margin:.8em 0 .2em; |
| 18 | + line-height:1.5; |
| 19 | + } |
| 20 | + </style> |
| 21 | + <script type="text/javascript"> |
| 22 | + $.extend( $.ui.menu.prototype, { |
| 23 | + next: function() { |
| 24 | + this.move("next", ".ui-menu-item:first"); |
| 25 | + }, |
| 26 | + |
| 27 | + previous: function() { |
| 28 | + this.move("prev", ".ui-menu-item:last"); |
| 29 | + }, |
| 30 | + |
| 31 | + move: function(direction, edge) { |
| 32 | + if (!this.active) { |
| 33 | + this.activate(this.element.children(edge)); |
| 34 | + return; |
| 35 | + } |
| 36 | + var next = this.active[direction + "All"]('.ui-menu-item').eq( 0 ); |
| 37 | + if (next.length) { |
| 38 | + this.activate(next); |
| 39 | + } else { |
| 40 | + this.activate(this.element.children(edge)); |
| 41 | + } |
| 42 | + } |
| 43 | + }); |
| 44 | + |
| 45 | + $.widget("custom.catcomplete", $.ui.autocomplete, { |
| 46 | + _renderMenu: function( ul, items ) { |
| 47 | + var self = this, |
| 48 | + currentCategory = ""; |
| 49 | + $.each( items, function( index, item ) { |
| 50 | + if ( item.category != currentCategory ) { |
| 51 | + ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" ); |
| 52 | + currentCategory = item.category; |
| 53 | + } |
| 54 | + self._renderItem( ul, item ); |
| 55 | + }); |
| 56 | + } |
| 57 | + }); |
| 58 | + </script> |
| 59 | + <script type="text/javascript"> |
| 60 | + $(function() { |
| 61 | + var data = [ |
| 62 | + { label: "anders", category: "" }, |
| 63 | + { label: "andreas", category: "" }, |
| 64 | + { label: "antal", category: "" }, |
| 65 | + { label: "annhhx10", category: "Products" }, |
| 66 | + { label: "annk K12", category: "Products" }, |
| 67 | + { label: "annttop C13", category: "Products" }, |
| 68 | + { label: "anders andersson", category: "People" }, |
| 69 | + { label: "andreas andersson", category: "People" }, |
| 70 | + { label: "andreas johnson", category: "People" } |
| 71 | + ]; |
| 72 | + |
| 73 | + $('#search').catcomplete({ |
| 74 | + delay: 0, |
| 75 | + source: data |
| 76 | + }); |
| 77 | + }); |
| 78 | + </script> |
| 79 | +</head> |
| 80 | +<body> |
| 81 | + |
| 82 | +<div class="demo"> |
| 83 | + <label for="search">Search: </label> |
| 84 | + <input id="search" /> |
| 85 | +</div><!-- End demo --> |
| 86 | + |
| 87 | +<div class="demo-description"> |
| 88 | +<p> |
| 89 | + A categorized search result. Try typing "a" or "n". |
| 90 | +</p> |
| 91 | +</div><!-- End demo-description --> |
| 92 | + |
| 93 | +</body> |
| 94 | +</html> |
0 commit comments