forked from nhsuk-archive/cervical-screening-interim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request nhsuk-archive#48 from nhsuk/CSSE-tool
Csse tool
- Loading branch information
Showing
17 changed files
with
2,177 additions
and
1,730 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
const createSuggestionDropdown = (data, elementId) => { | ||
function customSuggest(query, syncResults) { | ||
const results = data; | ||
syncResults( | ||
query | ||
? results.filter(function (result) { | ||
var codeContains = | ||
result.code.toLowerCase().indexOf(query.toLowerCase()) !== -1; | ||
var resultNameContains = | ||
result.name.toLowerCase().indexOf(query.toLowerCase()) !== -1; | ||
return codeContains || resultNameContains; | ||
}) | ||
: [] | ||
); | ||
} | ||
|
||
function inputValueTemplate(result) { | ||
return result && result.code; | ||
} | ||
|
||
function suggestionTemplate(result) { | ||
return result && `<div class="nhsuk-u-font-weight-bold autocomplete__option-code">${result.code}</div><div class="autocomplete__option-name">${result.name}</div>`; | ||
} | ||
|
||
const element = document.querySelector(`#${elementId}`); | ||
const id = `${elementId}-autocomplete`; | ||
accessibleAutocomplete({ | ||
element: element, | ||
id: id, | ||
name: elementId, | ||
displayMenu: 'overlay', | ||
source: customSuggest, | ||
templates: { | ||
inputValue: inputValueTemplate, | ||
suggestion: suggestionTemplate, | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.