Skip to content

Commit

Permalink
change verb tense for pass through alert, see #333
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Apr 21, 2021
1 parent c88fff2 commit 11839dd
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions js/moleculesandlight/view/ActiveMoleculeAlertManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const rotatesClockwiseString = moleculesAndLightStrings.a11y.rotatesClockwise;
const longBendingAlertString = moleculesAndLightStrings.a11y.longBendingAlert;
const rotatesCounterClockwise = moleculesAndLightStrings.a11y.rotatesCounterClockwise;
const pausedPassingPatternString = moleculesAndLightStrings.a11y.pausedPassingPattern;
const slowMotionPassingPatternString = moleculesAndLightStrings.a11y.slowMotionPassingPattern;
const shortRotatingAlertString = moleculesAndLightStrings.a11y.shortRotatingAlert;
const longRotatingAlertString = moleculesAndLightStrings.a11y.longRotatingAlert;
const shortGlowingAlertString = moleculesAndLightStrings.a11y.shortGlowingAlert;
Expand All @@ -45,6 +46,7 @@ const breakApartPhaseDescriptionPatternString = moleculesAndLightStrings.a11y.br
const stretchBackAndForthString = moleculesAndLightStrings.a11y.stretchBackAndForth;
const slowMotionAbsorbedShortPatternString = moleculesAndLightStrings.a11y.slowMotionAbsorbedShortPattern;
const photonPassesString = moleculesAndLightStrings.a11y.photonPasses;
const photonsPassingString = moleculesAndLightStrings.a11y.photonsPassing;

// constants
const PASS_THROUGH_COUNT_BEFORE_DESCRIPTION = MoleculesAndLightQueryParameters.passThroughCount;
Expand Down Expand Up @@ -551,10 +553,10 @@ class ActiveMoleculeAlertManager {
if ( strategy === null ) {
if ( this.passThroughCount >= PASS_THROUGH_COUNT_BEFORE_DESCRIPTION ) {
if ( this.photonAbsorptionModel.slowMotionProperty.get() ) {
alert = this.getDetailedPassThroughAlert( photon );
alert = this.getDetailedPassThroughAlert( photon, slowMotionPassingPatternString );
}
else {
alert = photonPassesString;
alert = photonsPassingString;
}
}
}
Expand All @@ -564,7 +566,7 @@ class ActiveMoleculeAlertManager {
alert = photonPassesString;
}
else {
alert = this.getDetailedPassThroughAlert( photon );
alert = this.getDetailedPassThroughAlert( photon, pausedPassingPatternString );
}
}

Expand All @@ -574,16 +576,23 @@ class ActiveMoleculeAlertManager {
/**
* Get a detailed alert that describes the photon passing through a molecule. This is pretty verbose so this
* is intended to describe pass through when we have lots of time for the screen reader to read this in full,
* such as during slow motion or step.
* such as during slow motion or step. Will return something like
*
* "Microwave photons passing through Methane molecule." or
* "Microwave photon passes through Methane molecule"
*
* depending on the context and provided patternString.
* @private
*
* @param {Photon} photon - the Photon passing through the photon target
* @param {string} patternString - A pattern string to be filled in with light source and molecular names, changing
* the verb tense depending on context.
*/
getDetailedPassThroughAlert( photon ) {
getDetailedPassThroughAlert( photon, patternString ) {
const lightSourceString = WavelengthConstants.getLightSourceName( photon.wavelength );
const molecularNameString = PhotonTarget.getMoleculeName( this.photonAbsorptionModel.photonTargetProperty.get() );

return StringUtils.fillIn( pausedPassingPatternString, {
return StringUtils.fillIn( patternString, {
lightSource: lightSourceString,
molecularName: molecularNameString
} );
Expand Down

0 comments on commit 11839dd

Please sign in to comment.