/
autosuggest.html
173 lines (146 loc) · 4.06 KB
/
autosuggest.html
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>Autosuggest.js</title>
<style type="text/css">
html body {
font-family:"Open Sans",Helvetica,"Lucida Grande","charcoal cy",arial,sans-serif;
}
h1 {color: #393}
h2 {color: #999}
pre, code {
padding: 5px 10px;
margin-bottom: 20px;
overflow: auto;
font-family: courier;
background: ghostwhite;
border: 1px solid #ddd;
}
code {
padding: 2px 5px;
}
pre code {
padding: 0;
margin-bottom: 0;
border: 0;
}
pre:before,
pre:after {
content: '';
display: none;
width: 100%;
position: absolute;
left: 0;
}
pre:before {
border-top: 1px solid hsla( 0, 0%, 100%, 1 );
top: 0;
}
pre:after {
border-top: 1px solid hsla( 0, 0%, 0%, 0.05 );
bottom: 0px;
}
input {
padding: 10px 11px;
color: #999;
width: 300px;
border: 1px solid #ddd;
font-size: 22px;
transition: box-shadow 0.15s linear 0s, color 0.15s linear 0s;
-webkit-transition: box-shadow 0.25s linear 0s, color 0.15s linear 0s;
-moz-transition: box-shadow 0.25s linear 0s, color 0.15s linear 0s;
-o-transition: box-shadow 0.25s linear 0s, color 0.15s linear 0s;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) inset;
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) inset;
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) inset;
font-family: Optima, Segoe, "Segoe UI", Candara, Calibri, Arial, sans-serif;
}
input:focus {
color: #767676;
border-color: #c5d7ee;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) inset, 0 0 8px rgba(170, 200, 240, 0.9);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) inset, 0 0 8px rgba(170, 200, 240, 0.9);
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) inset, 0 0 8px rgba(170, 200, 240, 0.9);
}
</style>
</head>
<body>
<h1>Autosuggest.js</h1>
<p class="description">The autosuggest widget provides suggestions while you type into the field. The datasource is a simple JS array, provided to the widget using the second @param `suggestions`.</p>
<h2>Syntax:</h2>
<h3> cuba.UI.autosuggest ( elem, suggestions )</h3>
<table>
<tr><td><label for="tags">Select a programming language</label></td><td><input type="text" id="tags" /></td></tr>
<tr><td><label for="input">JS frameworks</label></td><td><input type="text" id="frameworks" /></td></tr>
</table>
<script type="text/javascript" src="src/cuba.js"></script>
<script type="text/javascript">
var $ = function( id ) {return document.getElementById( id ) }
var suggestions = ["jquery","mootools","dojo","nodejs","angular","yui3","yui2"]
var newS = suggestions.concat(["express"])
var suggest = cuba.UI.autosuggest($('frameworks'), newS)
suggest.set(newS.concat(["prototype.js"]))
$('frameworks').focus()
if( window.console ) console.log(suggest.get())
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"];
var suggest2 = cuba.UI.autosuggest($('tags'), availableTags)
if( window.console ) console.log(suggest2.get())
</script>
<pre><code>
var $ = function( id ) {return document.getElementById( id ) }
var suggestions = ["jquery","mootools","dojo","nodejs","angular","yui3","yui2"]
var newS = suggestions.concat(["express"])
var suggest = cuba.UI.autosuggest($('input'), newS)
suggest.set(newS.concat(["prototype.js"]))
$('input').focus()
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"];
var suggest2 = cuba.UI.autosuggest($('tags'), availableTags)
if( window.console ) console.log(suggest2.get())
</code></pre>
</body>
</html>