govuk_publishing_components 12.13.0 → 12.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/accessible-autocomplete.js +37 -0
  3. data/app/assets/javascripts/govuk_publishing_components/components/checkboxes.js +6 -5
  4. data/app/assets/javascripts/govuk_publishing_components/components/copy-to-clipboard.js +15 -15
  5. data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +2 -4
  6. data/app/assets/javascripts/govuk_publishing_components/components/initial-focus.js +8 -8
  7. data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +3 -3
  8. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_accessible-autocomplete.scss +16 -0
  10. data/app/views/govuk_publishing_components/components/_accessible_autocomplete.html.erb +24 -0
  11. data/app/views/govuk_publishing_components/components/docs/accessible_autocomplete.yml +42 -0
  12. data/config/initializers/assets.rb +1 -0
  13. data/lib/govuk_publishing_components/version.rb +1 -1
  14. data/node_modules/accessible-autocomplete/CHANGELOG.md +269 -0
  15. data/node_modules/accessible-autocomplete/CONTRIBUTING.md +150 -0
  16. data/node_modules/accessible-autocomplete/LICENSE.txt +20 -0
  17. data/node_modules/accessible-autocomplete/Procfile +1 -0
  18. data/node_modules/accessible-autocomplete/README.md +416 -0
  19. data/node_modules/accessible-autocomplete/accessibility-criteria.md +42 -0
  20. data/node_modules/accessible-autocomplete/app.json +15 -0
  21. data/node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.css +1 -0
  22. data/node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.js +2 -0
  23. data/node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.js.map +1 -0
  24. data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.preact.min.js +2 -0
  25. data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.preact.min.js.map +1 -0
  26. data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.react.min.js +2 -0
  27. data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.react.min.js.map +1 -0
  28. data/node_modules/accessible-autocomplete/examples/form.html +671 -0
  29. data/node_modules/accessible-autocomplete/examples/index.html +616 -0
  30. data/node_modules/accessible-autocomplete/examples/preact/index.html +346 -0
  31. data/node_modules/accessible-autocomplete/examples/react/index.html +347 -0
  32. data/node_modules/accessible-autocomplete/package.json +192 -0
  33. data/node_modules/accessible-autocomplete/preact.js +1 -0
  34. data/node_modules/accessible-autocomplete/react.js +1 -0
  35. data/node_modules/accessible-autocomplete/scripts/check-staged.js +14 -0
  36. data/node_modules/accessible-autocomplete/src/autocomplete.css +141 -0
  37. data/node_modules/accessible-autocomplete/src/autocomplete.js +524 -0
  38. data/node_modules/accessible-autocomplete/src/dropdown-arrow-down.js +11 -0
  39. data/node_modules/accessible-autocomplete/src/status.js +80 -0
  40. data/node_modules/accessible-autocomplete/src/wrapper.js +60 -0
  41. data/node_modules/accessible-autocomplete/test/functional/dropdown-arrow-down.js +44 -0
  42. data/node_modules/accessible-autocomplete/test/functional/index.js +485 -0
  43. data/node_modules/accessible-autocomplete/test/functional/wrapper.js +267 -0
  44. data/node_modules/accessible-autocomplete/test/integration/index.js +188 -0
  45. data/node_modules/accessible-autocomplete/test/karma.config.js +42 -0
  46. data/node_modules/accessible-autocomplete/test/wdio.config.js +80 -0
  47. data/node_modules/accessible-autocomplete/webpack.config.babel.js +193 -0
  48. data/node_modules/preact/LICENSE +21 -0
  49. data/node_modules/preact/README.md +580 -0
  50. data/node_modules/preact/debug.js +112 -0
  51. data/node_modules/preact/debug.js.map +1 -0
  52. data/node_modules/preact/debug/index.js +121 -0
  53. data/node_modules/preact/devtools.js +403 -0
  54. data/node_modules/preact/devtools.js.map +1 -0
  55. data/node_modules/preact/devtools/devtools.js +395 -0
  56. data/node_modules/preact/devtools/index.js +4 -0
  57. data/node_modules/preact/dist/preact.d.ts +891 -0
  58. data/node_modules/preact/dist/preact.dev.js +718 -0
  59. data/node_modules/preact/dist/preact.dev.js.map +1 -0
  60. data/node_modules/preact/dist/preact.js +408 -0
  61. data/node_modules/preact/dist/preact.js.flow +13 -0
  62. data/node_modules/preact/dist/preact.js.map +1 -0
  63. data/node_modules/preact/dist/preact.min.js +2 -0
  64. data/node_modules/preact/dist/preact.min.js.map +1 -0
  65. data/node_modules/preact/dist/preact.mjs +715 -0
  66. data/node_modules/preact/dist/preact.mjs.map +1 -0
  67. data/node_modules/preact/package.json +218 -0
  68. data/node_modules/preact/src/clone-element.js +18 -0
  69. data/node_modules/preact/src/component.js +90 -0
  70. data/node_modules/preact/src/constants.js +17 -0
  71. data/node_modules/preact/src/dom/index.js +138 -0
  72. data/node_modules/preact/src/h.js +86 -0
  73. data/node_modules/preact/src/options.js +22 -0
  74. data/node_modules/preact/src/preact.d.ts +891 -0
  75. data/node_modules/preact/src/preact.js +26 -0
  76. data/node_modules/preact/src/preact.js.flow +13 -0
  77. data/node_modules/preact/src/render-queue.js +28 -0
  78. data/node_modules/preact/src/render.js +22 -0
  79. data/node_modules/preact/src/util.js +19 -0
  80. data/node_modules/preact/src/vdom/component-recycler.js +48 -0
  81. data/node_modules/preact/src/vdom/component.js +296 -0
  82. data/node_modules/preact/src/vdom/diff.js +336 -0
  83. data/node_modules/preact/src/vdom/index.js +54 -0
  84. data/node_modules/preact/src/vnode.js +9 -0
  85. data/node_modules/preact/typings.json +5 -0
  86. metadata +78 -2
@@ -0,0 +1,616 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Accessible Autocomplete examples</title>
7
+ <style>
8
+ /* Example page specific styling. */
9
+ html {
10
+ color: #111;
11
+ background: #FFF;
12
+ font-family: -apple-system, BlinkMacSystemFont, 'avenir next', avenir, 'helvetica neue', helvetica, ubuntu, roboto, noto, 'segoe ui', arial, sans-serif;
13
+ font-size: 16px;
14
+ line-height: 1.5;
15
+ }
16
+
17
+ body {
18
+ padding-left: 1rem;
19
+ padding-right: 1rem;
20
+ }
21
+
22
+ h1, h2, h3, h4, h5, h6 {
23
+ line-height: normal;
24
+ }
25
+
26
+ label {
27
+ display: block;
28
+ margin-bottom: .5rem;
29
+ }
30
+
31
+ code {
32
+ padding-left: .5em;
33
+ padding-right: .5em;
34
+ background: #EFEFEF;
35
+ font-weight: normal;
36
+ font-family: monospace;
37
+ }
38
+
39
+ main {
40
+ max-width: 40em;
41
+ margin-left: auto;
42
+ margin-right: auto;
43
+ }
44
+
45
+ .autocomplete-wrapper {
46
+ max-width: 20em;
47
+ margin-bottom: 4rem;
48
+ }
49
+ </style>
50
+ <link rel="stylesheet" href="../dist/accessible-autocomplete.min.css">
51
+ </head>
52
+ <body>
53
+ <main>
54
+ <h1>Accessible Autocomplete examples</h1>
55
+
56
+ <p><a href="form.html">Example in a real HTML form that you can submit</a></p>
57
+
58
+ <h2>Options</h2>
59
+
60
+ <h3><code>{ element, id, source }</code></h3>
61
+ <p>This illustrates usage with only the required arguments.</p>
62
+ <label for="autocomplete-default">Select your country</label>
63
+ <div id="tt-default" class="autocomplete-wrapper"></div>
64
+
65
+ <h3><code>{ minLength: 2 }</code></h3>
66
+ <p>
67
+ This option will prevent displaying suggestions if less than 2 characters are
68
+ typed in.
69
+ </p>
70
+ <label for="autocomplete-minLength">Select your country</label>
71
+ <div id="tt-minLength" class="autocomplete-wrapper"></div>
72
+
73
+ <h3><code>{ displayMenu: 'overlay' }</code></h3>
74
+ <p>This option will display the menu as an absolutely positioned overlay.</p>
75
+ <label for="autocomplete-overlay">Select your country</label>
76
+ <div id="tt-overlay" class="autocomplete-wrapper"></div>
77
+
78
+ <h3><code>{ autoselect: true }</code></h3>
79
+ <p>This option will automatically select the first suggestion.</p>
80
+ <label for="autocomplete-autoselect">Select your country</label>
81
+ <div id="tt-autoselect" class="autocomplete-wrapper"></div>
82
+
83
+ <h3><code>{ defaultValue: 'Germany' }</code></h3>
84
+ <p>This option will prefill the input with a value.</p>
85
+ <label for="autocomplete-defaultValue">Select your country</label>
86
+ <div id="tt-defaultValue" class="autocomplete-wrapper"></div>
87
+
88
+ <h3><code>{ confirmOnBlur: false }</code></h3>
89
+ <p>
90
+ This option will toggle automatically confirming a selection on blur. In the other
91
+ examples, if you select an option using the arrow keys and then click out, it will
92
+ confirm the selection.
93
+ </p>
94
+ <label for="autocomplete-confirmOnBlur">Select your country</label>
95
+ <div id="tt-confirmOnBlur" class="autocomplete-wrapper"></div>
96
+
97
+ <h3><code>{ placeholder: 'Search for a country' }</code></h3>
98
+ <p>This option will populate the placeholder attribute on the input element.</p>
99
+ <label for="autocomplete-placeholder">Select your country</label>
100
+ <div id="tt-placeholder" class="autocomplete-wrapper"></div>
101
+
102
+ <h3><code>{ showNoOptionsFound: false }</code></h3>
103
+ <p>This option will toggle displaying the "No results found" message.</p>
104
+ <label for="autocomplete-showNoOptionsFound">Select your country</label>
105
+ <div id="tt-showNoOptionsFound" class="autocomplete-wrapper"></div>
106
+
107
+ <h3><code>{ showAllValues: true }</code></h3>
108
+ <p>
109
+ This option will toggle showing all values when the input is clicked, like a
110
+ default dropdown.
111
+ </p>
112
+ <label for="autocomplete-showAllValues">Select your country</label>
113
+ <div id="tt-showAllValues" class="autocomplete-wrapper"></div>
114
+
115
+ <h3><code>{ showAllValues: true, dropdownArrow: () => '' }</code></h3>
116
+ <p>
117
+ When <code>showAllValues</code> is <code>true</code> a dropdown arrow
118
+ will be displayed. It can be customized using a function that receives a
119
+ `{ className: string }` object and returns a string or (P)React component.
120
+ </p>
121
+ <label for="autocomplete-customDropdownArrow">Select your country</label>
122
+ <div id="tt-customDropdownArrow" class="autocomplete-wrapper"></div>
123
+
124
+ <h2>Advanced features</h2>
125
+
126
+ <h3>Progressive enhancement</h3>
127
+ <p>
128
+ This example demonstrates how to turn a server-rendered <code>&lt;select&gt;</code> element
129
+ into a autocomplete. Turn off JavaScript to see the <code>&lt;select&gt;</code> element.
130
+ </p>
131
+ <p>Uses <code>accessibleAutocomplete.enhanceSelectElement</code>.</p>
132
+ <label for="autocomplete-progressiveEnhancement">Select your country</label>
133
+ <div class="autocomplete-wrapper">
134
+ <select id="autocomplete-progressiveEnhancement">
135
+ <option value="fr">France</option>
136
+ <option value="de">Germany</option>
137
+ <option value="gb" selected>United Kingdom</option>
138
+ </select>
139
+ </div>
140
+
141
+ <h3>Custom results</h3>
142
+ <p>
143
+ This example demonstrates how to allow users to search for a country by either
144
+ its english name or its endonym. The suggestions are user-defined objects and
145
+ they are displayed using a user-defined template. Confirming a suggestion will
146
+ populate the input with the english country name.
147
+ </p>
148
+ <p>Uses the <code>{ templates: { inputValue, suggestion } }</code> options.</p>
149
+ <label for="autocomplete-customTemplates">Select your country</label>
150
+ <div id="tt-customTemplates" class="autocomplete-wrapper"></div>
151
+
152
+ <h3>Translating texts</h3>
153
+ <p>
154
+ This example demonstrates how to translate the texts emitted by the component.
155
+ </p>
156
+ <p>Uses the <code>{ tStatusQueryTooShort: (minQueryLength) => '',
157
+ tStatusNoResults: () => '',
158
+ tStatusSelectedOption: (selectedOption, length) => '',
159
+ tStatusResults: () => '' }</code> options.</p>
160
+ <label for="autocomplete-i18n">Select your country</label>
161
+ <div id="tt-i18n" class="autocomplete-wrapper"></div>
162
+ </main>
163
+
164
+ <script type="text/javascript" src="../dist/accessible-autocomplete.min.js"></script>
165
+ <script type="text/javascript">
166
+ var countries = [
167
+ 'Afghanistan',
168
+ 'Akrotiri',
169
+ 'Albania',
170
+ 'Algeria',
171
+ 'American Samoa',
172
+ 'Andorra',
173
+ 'Angola',
174
+ 'Anguilla',
175
+ 'Antarctica',
176
+ 'Antigua and Barbuda',
177
+ 'Argentina',
178
+ 'Armenia',
179
+ 'Aruba',
180
+ 'Ashmore and Cartier Islands',
181
+ 'Australia',
182
+ 'Austria',
183
+ 'Azerbaijan',
184
+ 'Bahamas, The',
185
+ 'Bahrain',
186
+ 'Bangladesh',
187
+ 'Barbados',
188
+ 'Bassas da India',
189
+ 'Belarus',
190
+ 'Belgium',
191
+ 'Belize',
192
+ 'Benin',
193
+ 'Bermuda',
194
+ 'Bhutan',
195
+ 'Bolivia',
196
+ 'Bosnia and Herzegovina',
197
+ 'Botswana',
198
+ 'Bouvet Island',
199
+ 'Brazil',
200
+ 'British Indian Ocean Territory',
201
+ 'British Virgin Islands',
202
+ 'Brunei',
203
+ 'Bulgaria',
204
+ 'Burkina Faso',
205
+ 'Burma',
206
+ 'Burundi',
207
+ 'Cambodia',
208
+ 'Cameroon',
209
+ 'Canada',
210
+ 'Cape Verde',
211
+ 'Cayman Islands',
212
+ 'Central African Republic',
213
+ 'Chad',
214
+ 'Chile',
215
+ 'China',
216
+ 'Christmas Island',
217
+ 'Clipperton Island',
218
+ 'Cocos (Keeling) Islands',
219
+ 'Colombia',
220
+ 'Comoros',
221
+ 'Congo',
222
+ 'Cook Islands',
223
+ 'Coral Sea Islands',
224
+ 'Costa Rica',
225
+ 'Cote d\'Ivoire',
226
+ 'Croatia',
227
+ 'Cuba',
228
+ 'Cyprus',
229
+ 'Czech Republic',
230
+ 'Denmark',
231
+ 'Dhekelia',
232
+ 'Djibouti',
233
+ 'Dominica',
234
+ 'Dominican Republic',
235
+ 'Ecuador',
236
+ 'Egypt',
237
+ 'El Salvador',
238
+ 'Equatorial Guinea',
239
+ 'Eritrea',
240
+ 'Estonia',
241
+ 'Ethiopia',
242
+ 'Europa Island',
243
+ 'Falkland Islands',
244
+ 'Faroe Islands',
245
+ 'Fiji',
246
+ 'Finland',
247
+ 'France',
248
+ 'French Guiana',
249
+ 'French Polynesia',
250
+ 'French Southern and Antarctic Lands',
251
+ 'Gabon',
252
+ 'Gambia,',
253
+ 'Gaza Strip',
254
+ 'Georgia',
255
+ 'Germany',
256
+ 'Ghana',
257
+ 'Gibraltar',
258
+ 'Glorioso Islands',
259
+ 'Greece',
260
+ 'Greenland',
261
+ 'Grenada',
262
+ 'Guadeloupe',
263
+ 'Guam',
264
+ 'Guatemala',
265
+ 'Guernsey',
266
+ 'Guinea',
267
+ 'Guinea-Bissau',
268
+ 'Guyana',
269
+ 'Haiti',
270
+ 'Heard Island and McDonald Islands',
271
+ 'Holy See (Vatican City)',
272
+ 'Honduras',
273
+ 'Hong Kong',
274
+ 'Hungary',
275
+ 'Iceland',
276
+ 'India',
277
+ 'Indonesia',
278
+ 'Iran',
279
+ 'Iraq',
280
+ 'Ireland',
281
+ 'Isle of Man',
282
+ 'Israel',
283
+ 'Italy',
284
+ 'Jamaica',
285
+ 'Jan Mayen',
286
+ 'Japan',
287
+ 'Jersey',
288
+ 'Jordan',
289
+ 'Juan de Nova Island',
290
+ 'Kazakhstan',
291
+ 'Kenya',
292
+ 'Kiribati',
293
+ 'Korea, North',
294
+ 'Korea, South',
295
+ 'Kuwait',
296
+ 'Kyrgyzstan',
297
+ 'Laos',
298
+ 'Latvia',
299
+ 'Lebanon',
300
+ 'Lesotho',
301
+ 'Liberia',
302
+ 'Libya',
303
+ 'Liechtenstein',
304
+ 'Lithuania',
305
+ 'Luxembourg',
306
+ 'Macau',
307
+ 'Macedonia',
308
+ 'Madagascar',
309
+ 'Malawi',
310
+ 'Malaysia',
311
+ 'Maldives',
312
+ 'Mali',
313
+ 'Malta',
314
+ 'Marshall Islands',
315
+ 'Martinique',
316
+ 'Mauritania',
317
+ 'Mauritius',
318
+ 'Mayotte',
319
+ 'Mexico',
320
+ 'Micronesia, Federated States of',
321
+ 'Moldova',
322
+ 'Monaco',
323
+ 'Mongolia',
324
+ 'Montserrat',
325
+ 'Morocco',
326
+ 'Mozambique',
327
+ 'Namibia',
328
+ 'Nauru',
329
+ 'Navassa Island',
330
+ 'Nepal',
331
+ 'Netherlands',
332
+ 'Netherlands Antilles',
333
+ 'New Caledonia',
334
+ 'New Zealand',
335
+ 'Nicaragua',
336
+ 'Niger',
337
+ 'Nigeria',
338
+ 'Niue',
339
+ 'Norfolk Island',
340
+ 'Northern Mariana Islands',
341
+ 'Norway',
342
+ 'Oman',
343
+ 'Pakistan',
344
+ 'Palau',
345
+ 'Panama',
346
+ 'Papua New Guinea',
347
+ 'Paracel Islands',
348
+ 'Paraguay',
349
+ 'Peru',
350
+ 'Philippines',
351
+ 'Pitcairn Islands',
352
+ 'Poland',
353
+ 'Portugal',
354
+ 'Puerto Rico',
355
+ 'Qatar',
356
+ 'Reunion',
357
+ 'Romania',
358
+ 'Russia',
359
+ 'Rwanda',
360
+ 'Saint Helena',
361
+ 'Saint Kitts and Nevis',
362
+ 'Saint Lucia',
363
+ 'Saint Pierre and Miquelon',
364
+ 'Saint Vincent and the Grenadines',
365
+ 'Samoa',
366
+ 'San Marino',
367
+ 'Sao Tome and Principe',
368
+ 'Saudi Arabia',
369
+ 'Senegal',
370
+ 'Serbia and Montenegro',
371
+ 'Seychelles',
372
+ 'Sierra Leone',
373
+ 'Singapore',
374
+ 'Slovakia',
375
+ 'Slovenia',
376
+ 'Solomon Islands',
377
+ 'Somalia',
378
+ 'South Africa',
379
+ 'South Georgia and the South Sandwich Islands',
380
+ 'Spain',
381
+ 'Spratly Islands',
382
+ 'Sri Lanka',
383
+ 'Sudan',
384
+ 'Suriname',
385
+ 'Svalbard',
386
+ 'Swaziland',
387
+ 'Sweden',
388
+ 'Switzerland',
389
+ 'Syria',
390
+ 'Taiwan',
391
+ 'Tajikistan',
392
+ 'Tanzania',
393
+ 'Thailand',
394
+ 'Timor-Leste',
395
+ 'Togo',
396
+ 'Tokelau',
397
+ 'Tonga',
398
+ 'Trinidad and Tobago',
399
+ 'Tromelin Island',
400
+ 'Tunisia',
401
+ 'Turkey',
402
+ 'Turkmenistan',
403
+ 'Turks and Caicos Islands',
404
+ 'Tuvalu',
405
+ 'Uganda',
406
+ 'Ukraine',
407
+ 'United Arab Emirates',
408
+ 'United Kingdom',
409
+ 'United States',
410
+ 'Uruguay',
411
+ 'Uzbekistan',
412
+ 'Vanuatu',
413
+ 'Venezuela',
414
+ 'Vietnam',
415
+ 'Virgin Islands',
416
+ 'Wake Island',
417
+ 'Wallis and Futuna',
418
+ 'West Bank',
419
+ 'Western Sahara',
420
+ 'Yemen',
421
+ 'Zambia',
422
+ 'Zimbabwe'
423
+ ]
424
+ </script>
425
+
426
+ <script type="text/javascript">
427
+ var element = document.querySelector('#tt-default')
428
+ var id = 'autocomplete-default'
429
+ accessibleAutocomplete({
430
+ element: element,
431
+ id: id,
432
+ source: countries
433
+ })
434
+ </script>
435
+
436
+ <script type="text/javascript">
437
+ element = document.querySelector('#tt-minLength')
438
+ id = 'autocomplete-minLength'
439
+ accessibleAutocomplete({
440
+ element: element,
441
+ id: id,
442
+ minLength: 2,
443
+ source: countries
444
+ })
445
+ </script>
446
+
447
+ <script type="text/javascript">
448
+ element = document.querySelector('#tt-autoselect')
449
+ id = 'autocomplete-autoselect'
450
+ accessibleAutocomplete({
451
+ autoselect: true,
452
+ element: element,
453
+ id: id,
454
+ source: countries
455
+ })
456
+ </script>
457
+
458
+ <script type="text/javascript">
459
+ element = document.querySelector('#tt-overlay')
460
+ id = 'autocomplete-overlay'
461
+ accessibleAutocomplete({
462
+ displayMenu: 'overlay',
463
+ element: element,
464
+ id: id,
465
+ source: countries
466
+ })
467
+ </script>
468
+
469
+ <script type="text/javascript">
470
+ element = document.querySelector('#tt-defaultValue')
471
+ id = 'autocomplete-defaultValue'
472
+ accessibleAutocomplete({
473
+ defaultValue: 'Germany',
474
+ element: element,
475
+ id: id,
476
+ source: countries
477
+ })
478
+ </script>
479
+
480
+ <script type="text/javascript">
481
+ element = document.querySelector('#autocomplete-progressiveEnhancement')
482
+ accessibleAutocomplete.enhanceSelectElement({
483
+ selectElement: element
484
+ })
485
+ </script>
486
+
487
+ <script type="text/javascript">
488
+ function customSuggest (query, syncResults) {
489
+ var results = [
490
+ { endonymLang: 'fr', endonym: 'République Française', name: 'France' },
491
+ { endonymLang: 'de', endonym: 'Deutschland', name: 'Germany' },
492
+ { endonymLang: 'en', endonym: 'Great Britain', name: 'United Kingdom' }
493
+ ]
494
+ syncResults(query
495
+ ? results.filter(function (result) {
496
+ var resultContains = result.name.toLowerCase().indexOf(query.toLowerCase()) !== -1
497
+ var endonymContains = result.endonym.toLowerCase().indexOf(query.toLowerCase()) !== -1
498
+ return resultContains || endonymContains
499
+ })
500
+ : []
501
+ )
502
+ }
503
+
504
+ function inputValueTemplate (result) {
505
+ return result && result.name
506
+ }
507
+
508
+ function suggestionTemplate (result) {
509
+ return result && '<strong>' + result.name + '</strong>' +
510
+ ' (<span lang=' + result.endonymLang + '>' + result.endonym + '</span>)'
511
+ }
512
+
513
+ element = document.querySelector('#tt-customTemplates')
514
+ id = 'autocomplete-customTemplates'
515
+ accessibleAutocomplete({
516
+ element: element,
517
+ id: id,
518
+ source: customSuggest,
519
+ templates: {
520
+ inputValue: inputValueTemplate,
521
+ suggestion: suggestionTemplate
522
+ }
523
+ })
524
+ </script>
525
+
526
+ <script type="text/javascript">
527
+ element = document.querySelector('#tt-confirmOnBlur')
528
+ id = 'autocomplete-confirmOnBlur'
529
+ accessibleAutocomplete({
530
+ element: element,
531
+ id: id,
532
+ confirmOnBlur: false,
533
+ source: countries
534
+ })
535
+ </script>
536
+
537
+ <script type="text/javascript">
538
+ element = document.querySelector('#tt-placeholder')
539
+ id = 'autocomplete-placeholder'
540
+ accessibleAutocomplete({
541
+ element: element,
542
+ id: id,
543
+ placeholder: 'Search for a country',
544
+ source: countries
545
+ })
546
+ </script>
547
+
548
+ <script type="text/javascript">
549
+ element = document.querySelector('#tt-showNoOptionsFound')
550
+ id = 'autocomplete-showNoOptionsFound'
551
+ accessibleAutocomplete({
552
+ element: element,
553
+ id: id,
554
+ showNoOptionsFound: false,
555
+ source: countries
556
+ })
557
+ </script>
558
+
559
+ <script type="text/javascript">
560
+ element = document.querySelector('#tt-showAllValues')
561
+ id = 'autocomplete-showAllValues'
562
+ accessibleAutocomplete({
563
+ element: element,
564
+ id: id,
565
+ showAllValues: true,
566
+ source: countries
567
+ })
568
+ </script>
569
+
570
+ <script type="text/javascript">
571
+ element = document.querySelector('#tt-i18n')
572
+ id = 'autocomplete-i18n'
573
+ accessibleAutocomplete({
574
+ element: element,
575
+ id: id,
576
+ showAllValues: false,
577
+ source: countries,
578
+ tStatusQueryTooShort: function (minQueryLength) {
579
+ return 'Tippe mindestens ' + minQueryLength + ' Zeichen ein für Resultate.'
580
+ },
581
+ tStatusNoResults: function () {
582
+ return 'Keine Resultate.'
583
+ },
584
+ tStatusSelectedOption: function (selectedOption, length) {
585
+ return selectedOption + ' (1 von ' + length + ') ist ausgewählt.'
586
+ },
587
+ tStatusResults: function (length, contentSelectedOption) {
588
+ var words = {
589
+ result: (length === 1) ? 'Resultat' : 'Resultate',
590
+ is: (length === 1) ? 'ist' : 'sind'
591
+ }
592
+
593
+ return length + ' ' + words.result + ' ' + words.is + ' verfügbar. ' + contentSelectedOption
594
+ },
595
+ tNoResults: function () {
596
+ return 'Keine Resultate'
597
+ }
598
+ })
599
+ </script>
600
+
601
+ <script type="text/javascript">
602
+ element = document.querySelector('#tt-customDropdownArrow')
603
+ id = 'autocomplete-customDropdownArrow'
604
+ accessibleAutocomplete({
605
+ element: element,
606
+ id: id,
607
+ showAllValues: true,
608
+ source: countries,
609
+ dropdownArrow: function (config) {
610
+ return '<svg class="' + config.className + '" style="top: 8px;" viewBox="0 0 512 512" ><path d="M256,298.3L256,298.3L256,298.3l174.2-167.2c4.3-4.2,11.4-4.1,15.8,0.2l30.6,29.9c4.4,4.3,4.5,11.3,0.2,15.5L264.1,380.9 c-2.2,2.2-5.2,3.2-8.1,3c-3,0.1-5.9-0.9-8.1-3L35.2,176.7c-4.3-4.2-4.2-11.2,0.2-15.5L66,131.3c4.4-4.3,11.5-4.4,15.8-0.2L256,298.3 z"/></svg>'
611
+ }
612
+ })
613
+ </script>
614
+
615
+ </body>
616
+ </html>