Skip to content

Commit

Permalink
Refactors class names
Browse files Browse the repository at this point in the history
- Normalized button and form id/class names using the specificity
principle.
- Removes unused classes from submit/reset buttons.
  • Loading branch information
anselmbradford committed Jul 29, 2014
1 parent 71b5085 commit e5b4b77
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 24 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/home/home-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ require(['util/geolocation/geolocate-action'],
// address is found.
function locateAction(address) {
document.getElementById('location').value = address;
document.getElementById('search-form').submit();
document.getElementById('form-search').submit();
}
// Parameters are: button ID, and callback function (see above).
geo.init('locate-btn', locateAction);
geo.init('button-geolocate', locateAction);
});
24 changes: 14 additions & 10 deletions app/assets/javascripts/search/search-filter-manager.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
// handles search filter functionality
define(['util/geolocation/geolocate-action', 'domReady!'],
function (geo) {
define([
'util/geolocation/geolocate-action',
'domReady!'
],
function (geo) {
'use strict';

var _searchForm; // the form to submit
// The form to submit.
var _searchForm;

// main module initialization
function init() {
// Set up geolocation button
geo.init('locate-btn', _geolocationClicked);
// Set up geolocation button.
geo.init('button-geolocate', _geolocationClicked);

// capture form submission
_searchForm = document.getElementById('search-form');
// Capture form submission.
_searchForm = document.getElementById('form-search');

// Hook reset button on the page and listen for a click event
var resetBtn = document.getElementById('reset-btn');
resetBtn.addEventListener('click', _resetClicked,false);
// Hook reset button on the page and listen for a click event.
var resetButton = document.getElementById('button-reset');
resetButton.addEventListener('click', _resetClicked,false);
}

// The geolocation button was clicked in the location filter.
Expand Down
8 changes: 4 additions & 4 deletions app/views/component/search/_aside.html.haml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
%aside#search-container
%section#search-box
= form_tag('/organizations', method: :get, id: 'search-form') do
= form_tag('/organizations', method: :get, id: 'form-search') do
%section#keyword-search-box
%div.input-search-small.clearable
= button_tag(type: 'submit', name: nil, id: 'find-btn', class: 'button-icon', title: 'Search') do
= button_tag(type: 'submit', name: nil, id: 'button-search', class: 'button-icon', title: 'Search') do
%i{ class: 'fa fa-search' }
= search_field_tag :keyword, params[:keyword], autocomplete: 'off', placeholder: t('placeholders.results_page_keyword_search')

Expand All @@ -13,10 +13,10 @@

%ul#search-controls
%li
= button_tag(type:'submit', name: nil, class: 'button-small update-btn') do
= button_tag(type:'submit', name: nil, class: 'button-small') do
%i{ class: 'fa fa-refresh' }
= t('buttons.update_search_results')
%li
= button_tag(type: 'reset', name: nil, id: 'reset-btn', class: 'button-small reset-btn') do
= button_tag(type: 'reset', name: nil, id: 'button-reset', class: 'button-small') do
%i{ class: 'fa fa-times-circle' }
= t('buttons.clear_search_fields')
4 changes: 2 additions & 2 deletions app/views/component/search/_box.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= form_tag('/organizations', method: :get, id: 'search-form') do
= form_tag('/organizations', method: :get, id: 'form-search') do
%section#search-box
%div
%div
Expand All @@ -7,7 +7,7 @@
%div.input-search-big
= search_field_tag :keyword, params[:keyword], autocomplete: 'off', placeholder: t('placeholders.homepage_keyword_search')

= button_tag(type: 'submit', name: nil, id: 'find-btn', class: 'button-icon', title: 'Search') do
= button_tag(type: 'submit', name: nil, id: 'button-search', class: 'button-icon', title: 'Search') do
%i{ class: 'fa fa-search' }
%span
= t('buttons.homepage_search')
Expand Down
2 changes: 1 addition & 1 deletion app/views/component/search/_geolocate.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%div#geolocate-box
= button_tag(type: 'submit', name: nil, id: 'locate-btn', class: "button-small #{context_class}", data: { wait_text: t('buttons.during_geolocation'), regular_text: t('buttons.services_near_me') }) do
= button_tag(type: 'submit', name: nil, id: 'button-geolocate', class: "button-small #{context_class}", data: { wait_text: t('buttons.during_geolocation'), regular_text: t('buttons.services_near_me') }) do
%i{ class: 'fa fa-globe' }
%span= t('buttons.services_near_me')
2 changes: 1 addition & 1 deletion spec/features/general/translate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
xit 'displays a Spanish-language contents' do
visit('/')
find_link('Español').click
find(:css, '#find-btn').click
find(:css, '#button-search').click
delay # give Google Translate a chance to translate page
expect(page).to have_content('Mostrando')
end
Expand Down
4 changes: 2 additions & 2 deletions spec/features/search/results_page_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@
context 'when clicking the reset button' do
xit 'clears out all the search input fields', :js do
search(keyword: 'clinic', location: '94403', org_name: 'samaritan')
find_by_id('reset-btn').click
find_by_id('button-reset').click

using_wait_time 5 do
expect(find_field('keyword').value).to eq ''
expect(find_field('location').value).to eq ''
expect(find_field('org_name').value).to eq ''
end

find('#find-btn').click
find('#button-search').click
expect(page).to have_content('Fair Oaks Adult Activity Center')
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/support/features/session_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ def search(options = {})
fill_in 'keyword', with: options[:keyword]
fill_in 'location', with: options[:location]
fill_in 'org_name', with: options[:org_name]
find('#find-btn').click
find('#button-search').click
end

# Search from homepage.
# @param options [Object] Hash containing keyword to search for.
def search_from_home(options = {})
visit('/')
fill_in 'keyword', with: options[:keyword]
find('#find-btn').click
find('#button-search').click
end

# Perform a search that returns 1 result
Expand Down

0 comments on commit e5b4b77

Please sign in to comment.