-
Notifications
You must be signed in to change notification settings - Fork 23
/
index.html
executable file
·294 lines (262 loc) · 8.36 KB
/
index.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>AutoSuggest Examples</title>
<style type="text/css" title="text/css" media="screen">
.swatch {
width: 10px;
height: 10px;
margin: 0 2px;
float: left;
border: 1px solid #000;
}
</style>
<!-- assumes gloader project folder is next to glow project folder -->
<script type="text/javascript" src="../../../../gloader/src/gloader.js">
gloader.use(
"glow",
{
$map: "../../../srcloader/map.js",
$base: "../../../src/"
}
);
</script>
<script type="text/javascript">
gloader.load(
['glow', '@VERSION@', 'glow.widgets.AutoSuggest', 'glow.widgets.AutoComplete']
);
</script>
</head>
<body>
<h1>glow.widgets.AutoSuggest examples</h1>
<div class="example">
<h2>Autosuggest with minimum input length, and completion</h2>
<p>no description</p>
<script type="text/javascript" class="showSrc">
// <![CDATA[
glow.ready(function() {
new glow.widgets.AutoSuggest(
"#colornames1",
"colornames.js",
{
onInputChange: function(event) {
// only hit the server when we have more than 2 chars
if (event.value.length < 3) {
event.preventDefault();
this.hide();
}
},
complete: true,
activeOnShow: false,
delim: " "
}
)
.loadData();
});
// ]]>
</script>
<div class="sandbox">
<form action="#" onsubmit="alert('submit: '+this.colornames1.value); return false;">
<p>Try it: <input type="text" id="colornames1" autocomplete="false" /> (type the name of a web-safe colour delimited with spaces)</p>
</form>
</div>
</div>
<div class="example">
<h2>Autosuggest with formatItem, no completion</h2>
<p>Making the suggstion list look fancy.</p>
<script type="text/javascript" class="showSrc">
// <![CDATA[
glow.ready(function() {
new glow.widgets.AutoSuggest(
"#colornames2",
"colornames.js",
{
onItemSelect: function(e){
this.setValue(e.selectedItem.name);
},
formatItem: function(item) {
var html = '<div style="clear: both; padding: 2px},"><div ';
html += 'class="swatch" style="background-color:#'+item.hex+'">';
html += '<'+'/div><'+'/div>';
html += item.name;
return html;
}
}
).loadData();
});
// ]]>
</script>
<div class="sandbox">
<form action="#" onsubmit="alert('submit: '+this.colornames2.value); return false;">
<p>Try it: <input type="text" id="colornames2" value="" autocomplete="false" /> (type the name of a web-safe colour)</p>
</form>
</div>
</div>
<div class="example">
<h2>Autosuggest with isMatch, and formatItem</h2>
<p>
Here we are not matching on the beginning of the index. Note that completion isn't sane in such a case.
</p>
<script type="text/javascript" class="showSrc">
// <![CDATA[
glow.ready(function() {
new glow.widgets.AutoSuggest(
"#colornames3",
"colornames.js",
{
onItemSelect: function(e){
this.setValue(e.selectedItem.name);
},
isMatch: function(indexedWord, inputWord) {
return (
inputWord.length > 1 && indexedWord.indexOf(inputWord) > -1
);
},
formatItem: function(item) {
var pat = new RegExp(glow.lang.trim(this.getValue()), 'i');
return item.name.replace(pat, "<u>$&<"+"/u>");
},
delim: ","
// complete: this option makes no sense here!
}
).loadData();
});
// ]]>
</script>
<div class="sandbox">
<form action="#" onsubmit="alert('submit: '+this.colornames3.value); return false;">
<p>Try it: <input type="text" id="colornames3" /> (type the name of a web-safe colour delimited with commas)</p>
</form>
</div>
</div>
<div class="example">
<h2>Autosuggest with caseSensitive, maxListLength, onItemSelect, and completion</h2>
<p>You must type a word that matches the start of an index exactly, even case-wise.</p>
<p>Note that this results in a value that is not identical to the displayed suggestion.</p>
<script type="text/javascript" class="showSrc">
// <![CDATA[
glow.ready(function() {
new glow.widgets.AutoSuggest(
"#colornames4",
"colornames.js",
{
onItemSelect: function(e){
this.setValue("#"+e.selectedItem.hex);
},
caseSensitive: true,
maxListLength: 10,
complete: true,
delim: ","
}
).loadData();
});
// ]]>
</script>
<div class="sandbox">
<form action="#" onsubmit="alert('submit: '+this.colornames4.value); return false;">
<p>Try it: <input type="text" id="colornames4" /> (type the name of a web-safe colour)</p>
</form>
</div>
</div>
<div class="example">
<h2>Autosuggest with appearance options</h2>
<p>Using the non-default theme of "dark" and changing the dimensions of the suggestion list.</p>
<script type="text/javascript" class="showSrc">
// <![CDATA[
glow.ready(function() {
new glow.widgets.AutoSuggest(
"#colornames5",
"colornames.js",
{
onItemSelect: function(e){
this.setValue(e.selectedItem.name);
},
width: 600,
height: 100,
theme: "dark"
}
).loadData();
});
// ]]>
</script>
<div class="sandbox">
<form action="#" onsubmit="alert('submit: '+this.colornames5.value); return false;">
<p>Try it: <input type="text" id="colornames5" /> (type the name of a web-safe colour)</p>
</form>
</div>
</div>
<h1>glow.widgets.AutoComplete examples</h1>
<div class="example">
<h2>Single-value glow.widgets.AutoComplete</h2>
<p>Using autocomplete directly in this way is now deprecated.</p>
<script type="text/javascript" class="showSrc">
// <![CDATA[
glow.ready(function() {
new glow.widgets.AutoComplete(
"#complete1",
"tags.js"
).autosuggest.loadData();
});
// ]]>
</script>
<div class="sandbox">
<form action="#" onsubmit="alert('submit: '+this.complete1.value); return false;">
<p>Try it: <input type="text" id="complete1" /> (type a tag name)</p>
</form>
</div>
</div>
<div class="example">
<h2>Multi-value glow.widgets.AutoComplete</h2>
<p>Using autocomplete directly in this way is now deprecated.</p>
<script type="text/javascript" class="showSrc">
// <![CDATA[
glow.ready(function() {
new glow.widgets.AutoComplete(
"#complete2",
"tags.js",
{
delim: ","
}
).autosuggest.loadData();
});
// ]]>
</script>
<div class="sandbox">
<form action="#" onsubmit="alert('submit: '+this.complete2.value); return false;">
<p>Try it: <input type="text" id="complete2" /> (type tag names separated by a comma)</p>
</form>
</div>
</div>
<div class="example">
<h2>Same with glow.widgets.AutoSuggest (using array of strings as dataSource)</h2>
<p>This is the preferred way to do autocomplete.</p>
<script type="text/javascript" class="showSrc">
// <![CDATA[
glow.ready(function() {
new glow.widgets.AutoSuggest(
"#complete3",
"tags.js",
{
complete: true,
delim: ","
}
).loadData();
});
// ]]>
</script>
<div class="sandbox">
<form action="#" onsubmit="alert('submit: '+this.complete3.value); return false;">
<p>Try it: <input type="text" id="complete3" /> (type tag names separated by a comma)</p>
</form>
<p>
Lorem ipsum clee chea saeff a. Enfreep gleepi whop heeth zogh, kucka thee shoogh ne gead ca. Hegh en, vee, fu dreati whim breest taeth ste faeck blea blea dro, plan, rae ha su koo, jooff wreap ho I gla trag ir slae ripi enmaev logher moo pog queeth I slaeing whooth bean draem, ir paers. Gu perki, ghee plae kae. Za beeing hews, bae posting ri blorling ceack wrirl, unjaeh musher fri. A, sla frashe hi; Rae bla ro I whad. Stushe I dust whea droo lae, I infrap truroer bloos troshen pi, troo cae tis, lurth gleth, precuth sea so, wu queaing see quu wha cli pla jockal cresh se la. Doopi, ches shoorl grae vaell hi jeah, op gle prega cloo, quath ke inlockall dreaw. Rea wreela, de, op, droo frae vi, furd stae du drist purth ne draing pij quoo.
</p>
<p>
Tord hea op, wra en, zash treeb; The perbrala cheath quee taed quaen, ghor sod; Blea bu a preree, glurl unseashew neeti chee fri bree la, bagh! Gi, concroshegher cuh unsheerd bloing, stohus, ju zem. Ruv faert, ungrupi, tesum. En degleed po ir stea. Conplerth a brogs, do.
</p>
</div>
</div>
<script type="text/javascript" src="../../includes/js/showsrc.js"></script>
</body>
</html>