diff --git a/js/photon-absorption/view/EmissionRateControlSliderNode.js b/js/photon-absorption/view/EmissionRateControlSliderNode.js index 4ed298d..62a3a21 100644 --- a/js/photon-absorption/view/EmissionRateControlSliderNode.js +++ b/js/photon-absorption/view/EmissionRateControlSliderNode.js @@ -26,7 +26,8 @@ define( function( require ) { var Range = require( 'DOT/Range' ); var Rectangle = require( 'SCENERY/nodes/Rectangle' ); var Shape = require( 'KITE/Shape' ); - // var StringUtils = require( 'PHETCOMMON/util/StringUtils' ); + var StringUtils = require( 'PHETCOMMON/util/StringUtils' ); + var utteranceQueue = require( 'SCENERY_PHET/accessibility/utteranceQueue' ); var WavelengthConstants = require( 'MOLECULES_AND_LIGHT/photon-absorption/model/WavelengthConstants' ); // constants @@ -86,16 +87,65 @@ define( function( require ) { var parentBounds = sliderThumb.localToParentBounds( sliderBounds ); this.emissionRateControlSlider.focusHighlight = new FocusHighlightPath( Shape.bounds( parentBounds ) ); - // a11y + // a11y// takes a given frequency and returns the proper string for its associated rate + function mapFrequencyToString( freq ) { + // debugger; + // can be moved to constants file + var sliderRangeMap = [ + { + range: { + contains: function ( val ) { + return val > 0 && val < 0.3; + } + }, + text: 'slow' + }, + { + range: { + contains: function( val ) { + return val >= 0.3 && val < 0.7; + } + }, + text: 'moderate' + }, + { + range: { + contains: function( val ) { + return val >= 0.7 && val <= 1; + } + }, + text: 'fast' + } + ]; + + for ( var i = sliderRangeMap.length - 1; i >= 0; i-- ) { + if ( sliderRangeMap[ i ].range.contains ( freq ) ) { + return sliderRangeMap[ i ].text; + } + } + } this.emissionRateControlSlider.addAccessibleInputListener( { focus: function() { sliderThumb.backgroundRectangle.visible = true; }, blur: function() { sliderThumb.backgroundRectangle.visible = false; + }, + keyup: function() { + var frequencyText = mapFrequencyToString( model.emissionFrequencyProperty.get() ); + var wavelengthText = WavelengthConstants.getLightSourceName( model.photonWavelengthProperty.get() ); + + utteranceQueue.addToBack( StringUtils.fillIn( + '{{wavelengthText}} photon rate, {{frequencyText}}', + { wavelengthText: wavelengthText, frequencyText: frequencyText } + ) ); } } ); + // a11y alerts for the slider + // model.emissionFrequencyProperty.lazyLink( function( frequency ) { + // } ); + // width of the background rectangle is larger than the slider to accentuate the thumb. var backgroundOffset = 4; this.backgroundRect = new Rectangle( diff --git a/js/photon-absorption/view/MoleculeNode.js b/js/photon-absorption/view/MoleculeNode.js index 5204859..e976ef0 100644 --- a/js/photon-absorption/view/MoleculeNode.js +++ b/js/photon-absorption/view/MoleculeNode.js @@ -17,7 +17,6 @@ define( function( require ) { var MoleculesAndLightA11yStrings = require( 'MOLECULES_AND_LIGHT/common/MoleculesAndLightA11yStrings' ); var Node = require( 'SCENERY/nodes/Node' ); var StringUtils = require( 'PHETCOMMON/util/StringUtils' ); - // var Utterance = require( 'SCENERY_PHET/accessibility/Utterance' ); var utteranceQueue = require( 'SCENERY_PHET/accessibility/utteranceQueue' ); var NO = require( 'MOLECULES_AND_LIGHT/photon-absorption/model/molecules/NO' ); var CO = require( 'MOLECULES_AND_LIGHT/photon-absorption/model/molecules/CO' );