-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #495 - Adds input clear button
- Adds search input manager for handling input clear button—little (x). - Disables autocomplete because field highlight color can’t be overridden. - Removes unused data-list attributes. - Adds tests for clearing the input fields.
- Loading branch information
1 parent
ffbcaa4
commit 6c23d00
Showing
12 changed files
with
626 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Handles functionality of search inputs, such as how the inputs are cleared. | ||
define( | ||
function () { | ||
'use strict'; | ||
|
||
function init() { | ||
|
||
var inputs = document.querySelectorAll('.clearable'); | ||
|
||
for (var i = 0, len = inputs.length; i < len; i++) { | ||
_initCloseButton(inputs[i]) | ||
} | ||
} | ||
|
||
function _initCloseButton(inputContainer) { | ||
|
||
// Retrieve first and only input element. | ||
var input = inputContainer.getElementsByTagName('input')[0]; | ||
var buttonClose = document.createElement('button'); | ||
buttonClose.className = 'button-close'; | ||
if (input.value === '') | ||
buttonClose.className += ' hide'; | ||
inputContainer.appendChild(buttonClose); | ||
|
||
//var buttonClose = input.querySelector('.close'); | ||
buttonClose.addEventListener('click', function (evt) { | ||
evt.preventDefault(); | ||
input.value = ''; | ||
buttonClose.classList.add('hide'); | ||
input.focus(); | ||
}) | ||
|
||
input.addEventListener('keyup', function (evt) { | ||
_checkCloseButtonVisibility(input, buttonClose); | ||
}) | ||
|
||
input.addEventListener('change', function (evt) { | ||
_checkCloseButtonVisibility(input, buttonClose); | ||
}) | ||
} | ||
|
||
function _checkCloseButtonVisibility(input, buttonClose) { | ||
if (input.value === '') | ||
buttonClose.classList.add('hide'); | ||
else | ||
buttonClose.classList.remove('hide'); | ||
} | ||
|
||
return { | ||
init:init | ||
}; | ||
}); |
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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
// manages search initialization | ||
require(['search/search-filter-manager'], | ||
function (filter) { | ||
// Manages search initialization. | ||
require([ | ||
'search/search-filter-manager', | ||
'search/input-manager' | ||
], | ||
function (filter, input) { | ||
'use strict'; | ||
|
||
filter.init(); | ||
input.init(); | ||
}); |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
= field_set_tag nil, id: 'org-name-options', class: 'input-search-filter' do | ||
= label_tag 'org_name', t('labels.agency_search') | ||
= content_tag :div, '', class: 'filter-input-group' do | ||
= button_tag(type: 'submit', name: nil) do | ||
= content_tag :div, '', class: 'filter-input-group clearable' do | ||
= button_tag(type: 'submit', name: nil, class: 'button-icon') do | ||
= content_tag :i, '', class: 'fa fa-institution' | ||
= search_field_tag :org_name, params[:org_name], placeholder: t('placeholders.agency_search'), list: 'search-agency' | ||
= search_field_tag :org_name, params[:org_name], autocomplete: 'off', placeholder: t('placeholders.agency_search') |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
= field_set_tag nil, id: 'location-options', class: 'input-search-filter input-search-filter-option' do | ||
= label_tag 'location', t('labels.address_search') | ||
= content_tag :div, '', class: 'filter-input-group' do | ||
= button_tag(type: 'submit', name: nil) do | ||
= content_tag :div, '', class: 'filter-input-group clearable' do | ||
= button_tag(type: 'submit', name: nil, class: 'button-icon') do | ||
= content_tag :i, '', class: 'fa fa-map-marker' | ||
= search_field_tag :location, params[:location], placeholder: t('placeholders.address_search'), list: 'search-location' | ||
= search_field_tag :location, params[:location], autocomplete: 'off', placeholder: t('placeholders.address_search') | ||
= render 'component/search/geolocate', context_class: 'input-search-filter-option' |
162 changes: 162 additions & 0 deletions
162
...e/when_clicking_the_clear_button_for_agency/clears_the_contents_of_the_location_field.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.