Skip to content

Commit

Permalink
Merge pull request #169 from devgeniem/TMS-942
Browse files Browse the repository at this point in the history
TMS-942: Program- & site-search, contact and fly-out-menu accessibility fixes
  • Loading branch information
eebbi authored Dec 4, 2023
2 parents fdb34a3 + 4d2b201 commit f2bd8a2
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- TMS-940:
- Change mobile menu dropdown links to a single button-element
- Hide current language on mobile header if only 2 languages in use
- TMS-942:
- Check / uncheck search filter checkboxes depending on choices
- Trim contact phone number in href
- Increase fly-out-nav z-index to prevent chatbot from overlapping elements
- Add margin for program text-search suggestions
- TMS-995: Show project-listing component images in projects-page

## [1.8.7] - 2023-11-21
Expand Down
47 changes: 47 additions & 0 deletions assets/scripts/search-filters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2023. Hion Digital
*/

// Use jQuery as $ within this file scope.
const $ = jQuery; // eslint-disable-line no-unused-vars

/**
* Export the class reference.
*/
export default class SearchFilters {

/**
* Check or uncheck checkboxes depending on selections
*
* @param {Object} event Change event
*/
SearchFilters( event ) {
const $checkBoxContainer = $( '.search-filters' );
const $checkBoxes = $checkBoxContainer.find( 'input[type=checkbox]' );
const $clickedCheckbox = event.target;

if ( $( $clickedCheckbox ).is( ':checked' ) ) {
// Uncheck "All"-checkbox when others are checked
if ( $( $clickedCheckbox ).prop( 'id' ) !== 'cpt-all' ) {
$( '#cpt-all' ).prop( 'checked', false );
}
// Uncheck other checkboxes when "All" is selected
else {
$checkBoxes.each( function() {
if ( $( this ).prop( 'id' ) !== 'cpt-all' ) {
$( this ).prop( 'checked', false );
}
} );
}
}
}

/**
* Run when the document is ready.
*
* @return {void}
*/
docReady() {
$( '.search-filters input[type=checkbox]' ).on( 'change', this.SearchFilters.bind( this ) );
}
}
2 changes: 2 additions & 0 deletions assets/scripts/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import GravityFormsPatch from './gravity-forms-patch';
import Countdown from './countdown';
import ProgramSearch from './program-search';
import LoadMore from './load-more';
import SearchFilters from './search-filters';
import FocusOnSearch from './focus-on-search';

const globalControllers = {
Expand Down Expand Up @@ -56,6 +57,7 @@ const globalControllers = {
Countdown,
ProgramSearch,
LoadMore,
SearchFilters,
FocusOnSearch,
};

Expand Down
4 changes: 4 additions & 0 deletions assets/styles/blocks/custom/_contacts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
$contacts-gap: .75rem;

.contacts {
&__name {
overflow: hidden !important; // sass-lint:disable no-important
}

&__item {
flex: 1 0 auto;
max-width: calc(100% - $contacts-gap);
Expand Down
3 changes: 2 additions & 1 deletion assets/styles/ui-components/header/_fly-out-nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ $fly-out-nav-secondary-link-hover: $primary-invert !default;
$fly-out-nav-search-button-icon: $primary !default;

.fly-out-nav {
z-index: 50;
// z-index unbelievable high to prevent embedded chat overlapping elements
z-index: 9999999999;
display: none;


Expand Down
10 changes: 7 additions & 3 deletions assets/styles/views/_page-program.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@
}

ul.ui-menu {
.ui-menu-item-wrapper {
&.ui-state-active {
background-color: $color-grey;
.ui-menu-item {
margin-bottom: .5rem;

.ui-menu-item-wrapper {
&.ui-state-active {
background-color: $color-grey;
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions lib/Formatters/ContactFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ public function map_keys( array $posts, array $field_keys, $default_image = null
$fields['phone_repeater'] = array_filter( $fields['phone_repeater'], function ( $item ) {
return ! empty( $item['phone_text'] ) || ! empty( $item['phone_number'] );
} );

// Remove whitespaces from phone_number to use on the href
foreach ( $fields['phone_repeater'] as $i => $single_phone ) {
$fields['phone_repeater'][ $i ]['trimmed_number'] = str_replace( ' ', '', $single_phone['phone_number'] );
}
}

return $fields;
Expand Down
2 changes: 1 addition & 1 deletion partials/shared/contact-item.dust
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div>
<span>{phone_text|html}</span>
<div>
<a href="tel:{phone_number|html}"
<a href="tel:{?trimmed_number}{trimmed_number|html}{:else}{phone_number|html}{/trimmed_number}"
class="has-text-paragraph hyphenate">
{phone_number|html}
</a>
Expand Down

0 comments on commit f2bd8a2

Please sign in to comment.