Skip to content

Commit 0e74d71

Browse files
Adding typeahead to other language
1 parent 2ba1242 commit 0e74d71

File tree

1 file changed

+368
-8
lines changed

1 file changed

+368
-8
lines changed

app/views/design/do-you-need-a-interpreter-language.html renamed to app/views/design/do-you-need-an-interpreter-language.html

Lines changed: 368 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,12 @@
173173
{% else %}
174174

175175
{% set languageHtml %}
176-
{{ input({
177-
id: "other",
178-
name: "other",
179-
classes: "nhsuk-u-width-two-thirds",
180-
label: {
181-
text: "Language"
182-
}
183-
}) }}
176+
<div class="nhsuk-form-group">
177+
<label class="nhsuk-label" for="country-container">
178+
Language
179+
</label>
180+
<div id="country-container" name="country-visited"></div>
181+
</div>
184182
{% endset %}
185183

186184
{{ radios({
@@ -322,6 +320,368 @@
322320
</div>
323321
</div>
324322

323+
324+
<style>
325+
.autocomplete__wrapper {
326+
position: relative;
327+
/*max-width: 35em;*/
328+
margin-bottom: 20px;
329+
text-transform: capitalize;
330+
}
331+
332+
@media (min-width: 40.0625em) {
333+
.autocomplete__wrapper {
334+
margin-bottom: 30px;
335+
}
336+
}
337+
338+
.autocomplete__hint, .autocomplete__input {
339+
-webkit-appearance: none;
340+
border: 2px solid rgb(76, 98, 114);
341+
border-radius: 0;
342+
box-sizing: border-box;
343+
-moz-box-sizing: border-box;
344+
-webkit-box-sizing: border-box;
345+
margin-bottom: 0;
346+
width: 100%;
347+
text-transform: capitalize;
348+
}
349+
350+
351+
352+
.autocomplete__input {
353+
background-color: white;
354+
position: relative;
355+
text-transform: capitalize;
356+
}
357+
358+
@media (min-width: 40.0625em) {
359+
.autocomplete__input {
360+
width: 66.66% !important;
361+
}
362+
}
363+
364+
.autocomplete__hint {
365+
color: #b1b4b6;
366+
position: absolute;
367+
}
368+
369+
.autocomplete__input--default {
370+
padding: 5px;
371+
line-height: 1.5;
372+
}
373+
374+
.autocomplete__input--focused {
375+
outline: 3px solid #fd0;
376+
outline-offset: 0;
377+
box-shadow: inset 0 0 0 2px;
378+
}
379+
380+
.autocomplete__input--show-all-values {
381+
padding: 5px 34px 5px 5px;
382+
cursor: pointer;
383+
}
384+
385+
.autocomplete__dropdown-arrow-down {
386+
z-index: -1;
387+
display: inline-block;
388+
position: absolute;
389+
right: 8px;
390+
width: 24px;
391+
height: 24px;
392+
top: 10px;
393+
}
394+
395+
.autocomplete__menu {
396+
background-color: #fff;
397+
border: 2px solid #0b0c0c;
398+
border-top: 0;
399+
color: #0b0c0c;
400+
margin: 0;
401+
max-height: 342px;
402+
overflow-x: hidden;
403+
padding: 0;
404+
width: 100%;
405+
width: calc(100% - 4px);
406+
}
407+
408+
.autocomplete__menu--visible {
409+
display: block;
410+
}
411+
412+
.autocomplete__menu--hidden {
413+
display: none;
414+
}
415+
416+
.autocomplete__menu--overlay {
417+
box-shadow: rgba(0, 0, 0, 0.256863) 0 2px 6px;
418+
left: 0;
419+
position: absolute;
420+
top: 100%;
421+
z-index: 100;
422+
}
423+
424+
.autocomplete__menu--inline {
425+
position: relative;
426+
}
427+
428+
.autocomplete__option {
429+
border-bottom: solid #b1b4b6;
430+
border-width: 1px 0;
431+
cursor: pointer;
432+
display: block;
433+
position: relative;
434+
}
435+
436+
.autocomplete__option > * {
437+
pointer-events: none;
438+
}
439+
440+
.autocomplete__option:first-of-type {
441+
border-top-width: 0;
442+
}
443+
444+
.autocomplete__option:last-of-type {
445+
border-bottom-width: 0;
446+
}
447+
448+
.autocomplete__option--odd {
449+
background-color: #fafafa;
450+
}
451+
452+
.autocomplete__option--focused, .autocomplete__option:hover {
453+
background-color: #1d70b8;
454+
border-color: #1d70b8;
455+
color: #fff;
456+
outline: 0;
457+
}
458+
459+
.autocomplete__option--no-results {
460+
background-color: #fafafa;
461+
color: #646b6f;
462+
cursor: not-allowed;
463+
}
464+
465+
.autocomplete__hint, .autocomplete__input, .autocomplete__option {
466+
font-size: 16px;
467+
/*line-height: 1.25;*/
468+
}
469+
470+
.autocomplete__hint, .autocomplete__option {
471+
padding: 5px;
472+
}
473+
474+
@media (min-width: 641px) {
475+
.autocomplete__hint, .autocomplete__input, .autocomplete__option {
476+
font-size: 19px;
477+
line-height: 1.31579;
478+
}
479+
}
480+
</style>
481+
<script type="text/javascript" src="/js/accessible-autocomplete.min.js"></script>
482+
<script>
483+
const countries = [
484+
"Afar",
485+
"Abkhazian",
486+
"Avestan",
487+
"Afrikaans",
488+
"Akan",
489+
"Amharic",
490+
"Aragonese",
491+
"Arabic",
492+
"Assamese",
493+
"Avaric",
494+
"Aymara",
495+
"Azerbaijani",
496+
"Bashkir",
497+
"Belarusian",
498+
"Bulgarian",
499+
"Bihari languages",
500+
"Bislama",
501+
"Bambara",
502+
"Bengali",
503+
"Tibetan",
504+
"Breton",
505+
"Bosnian",
506+
"Catalan; Valencian",
507+
"Chechen",
508+
"Chamorro",
509+
"Corsican",
510+
"Cree",
511+
"Czech",
512+
"Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic",
513+
"Chuvash",
514+
"Welsh",
515+
"Danish",
516+
"German",
517+
"Divehi; Dhivehi; Maldivian",
518+
"Dzongkha",
519+
"Ewe",
520+
"Greek, Modern (1453-)",
521+
"English",
522+
"Esperanto",
523+
"Spanish; Castilian",
524+
"Estonian",
525+
"Basque",
526+
"Persian",
527+
"Fulah",
528+
"Finnish",
529+
"Fijian",
530+
"Faroese",
531+
"French",
532+
"Western Frisian",
533+
"Irish",
534+
"Gaelic; Scottish Gaelic",
535+
"Galician",
536+
"Guarani",
537+
"Gujarati",
538+
"Manx",
539+
"Hausa",
540+
"Hebrew",
541+
"Hindi",
542+
"Hiri Motu",
543+
"Croatian",
544+
"Haitian; Haitian Creole",
545+
"Hungarian",
546+
"Armenian",
547+
"Herero",
548+
"Interlingua (International Auxiliary Language Association)",
549+
"Indonesian",
550+
"Interlingue; Occidental",
551+
"Igbo",
552+
"Sichuan Yi; Nuosu",
553+
"Inupiaq",
554+
"Ido",
555+
"Icelandic",
556+
"Italian",
557+
"Inuktitut",
558+
"Japanese",
559+
"Javanese",
560+
"Georgian",
561+
"Kongo",
562+
"Kikuyu; Gikuyu",
563+
"Kuanyama; Kwanyama",
564+
"Kazakh",
565+
"Kalaallisut; Greenlandic",
566+
"Central Khmer",
567+
"Kannada",
568+
"Korean",
569+
"Kanuri",
570+
"Kashmiri",
571+
"Kurdish",
572+
"Komi",
573+
"Cornish",
574+
"Kirghiz; Kyrgyz",
575+
"Latin",
576+
"Luxembourgish; Letzebuergesch",
577+
"Ganda",
578+
"Limburgan; Limburger; Limburgish",
579+
"Lingala",
580+
"Lao",
581+
"Lithuanian",
582+
"Luba-Katanga",
583+
"Latvian",
584+
"Malagasy",
585+
"Marshallese",
586+
"Maori",
587+
"Macedonian",
588+
"Malayalam",
589+
"Mongolian",
590+
"Marathi",
591+
"Malay",
592+
"Maltese",
593+
"Burmese",
594+
"Nauru",
595+
"Bokmål, Norwegian; Norwegian Bokmål",
596+
"Ndebele, North; North Ndebele",
597+
"Nepali",
598+
"Ndonga",
599+
"Dutch; Flemish",
600+
"Norwegian Nynorsk; Nynorsk, Norwegian",
601+
"Norwegian",
602+
"Ndebele, South; South Ndebele",
603+
"Navajo; Navaho",
604+
"Chichewa; Chewa; Nyanja",
605+
"Occitan (post 1500)",
606+
"Ojibwa",
607+
"Oromo",
608+
"Oriya",
609+
"Ossetian; Ossetic",
610+
"Panjabi; Punjabi",
611+
"Pali",
612+
"Polish",
613+
"Pushto; Pashto",
614+
"Portuguese",
615+
"Quechua",
616+
"Romansh",
617+
"Rundi",
618+
"Romanian; Moldavian; Moldovan",
619+
"Russian",
620+
"Kinyarwanda",
621+
"Sanskrit",
622+
"Sardinian",
623+
"Sindhi",
624+
"Northern Sami",
625+
"Sango",
626+
"Sinhala; Sinhalese",
627+
"Slovak",
628+
"Slovenian",
629+
"Samoan",
630+
"Shona",
631+
"Somali",
632+
"Albanian",
633+
"Serbian",
634+
"Swati",
635+
"Sotho, Southern",
636+
"Sundanese",
637+
"Swedish",
638+
"Swahili",
639+
"Tamil",
640+
"Telugu",
641+
"Tajik",
642+
"Thai",
643+
"Tigrinya",
644+
"Turkmen",
645+
"Tagalog",
646+
"Tswana",
647+
"Tonga (Tonga Islands)",
648+
"Turkish",
649+
"Tsonga",
650+
"Tatar",
651+
"Twi",
652+
"Tahitian",
653+
"Uighur; Uyghur",
654+
"Ukrainian",
655+
"Urdu",
656+
"Uzbek",
657+
"Venda",
658+
"Vietnamese",
659+
"Volapük",
660+
"Walloon",
661+
"Wolof",
662+
"Xhosa",
663+
"Yiddish",
664+
"Yoruba",
665+
"Zhuang; Chuang",
666+
"Chinese",
667+
"Zulu"
668+
]
669+
670+
accessibleAutocomplete({
671+
autoselect: false,
672+
element: document.querySelector('#country-container'),
673+
id: 'country-born',
674+
name: 'country-born',
675+
source: countries,
676+
defaultValue: "{{ data['country-born'] }}",
677+
displayMenu: 'overlay',
678+
minLength: 2,
679+
tNoResults: function() {
680+
return "Other"
681+
}
682+
});
683+
</script>
684+
325685
{% endblock %}
326686

327687
{% block footer %}

0 commit comments

Comments
 (0)