From 774b3377b663b180a9fb2c4f2a09f4d69c00d8ee Mon Sep 17 00:00:00 2001 From: Michael Barlow Date: Wed, 31 Oct 2018 14:19:42 -0600 Subject: [PATCH] proper string handling, todos addressed, static text getter functions added, see phetsims/gravity-force-lab#109 --- js/ISLCA11yStrings.js | 9 +++++++++ js/view/ISLCCheckboxItem.js | 1 - js/view/ISLCObjectControlPanel.js | 1 - js/view/ISLCObjectNode.js | 4 ++-- js/view/ISLCStringManager.js | 12 ++++++++++-- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/js/ISLCA11yStrings.js b/js/ISLCA11yStrings.js index 9ed6024..a9e94bf 100644 --- a/js/ISLCA11yStrings.js +++ b/js/ISLCA11yStrings.js @@ -48,6 +48,15 @@ define( require => { forceAndVectorPattern: { value: 'Force on {{thisObject}} by {{otherObject}} is {{size}}, and vector points directly at {{otherObject}}.' }, + positionMeterMarkPattern: { + value: '{{position}} meter mark' + }, + valueKilogramsPattern: { + value: '{{value}} kilograms' + }, + objectLabelPositionPattern: { + value: '{{label}} position' + }, /********************** * Qualitative Values * diff --git a/js/view/ISLCCheckboxItem.js b/js/view/ISLCCheckboxItem.js index df3f1c0..c2ea73c 100644 --- a/js/view/ISLCCheckboxItem.js +++ b/js/view/ISLCCheckboxItem.js @@ -58,7 +58,6 @@ define( function( require ) { } ); // a11y - // TODO: review a11y implemntation ('accessibility' key in array) Checkbox.call( this, content, property, _.pick( options, [ 'boxWidth', 'tandem', 'accessibleName' ] ) ); } diff --git a/js/view/ISLCObjectControlPanel.js b/js/view/ISLCObjectControlPanel.js index d879b8a..fbe9742 100644 --- a/js/view/ISLCObjectControlPanel.js +++ b/js/view/ISLCObjectControlPanel.js @@ -50,7 +50,6 @@ define( function( require ) { align: 'right', // a11y - // TODO: REVIEW this tagName: 'li', numberControlOptions: {}, diff --git a/js/view/ISLCObjectNode.js b/js/view/ISLCObjectNode.js index 54a856a..418b591 100644 --- a/js/view/ISLCObjectNode.js +++ b/js/view/ISLCObjectNode.js @@ -20,6 +20,7 @@ define( function( require ) { var inverseSquareLawCommon = require( 'INVERSE_SQUARE_LAW_COMMON/inverseSquareLawCommon' ); var ISLCForceArrowNode = require( 'INVERSE_SQUARE_LAW_COMMON/view/ISLCForceArrowNode' ); var ISLCPullerNode = require( 'INVERSE_SQUARE_LAW_COMMON/view/ISLCPullerNode' ); + var ISLCStringManager = require( 'INVERSE_SQUARE_LAW_COMMON/view/ISLCStringManager' ); var Node = require( 'SCENERY/nodes/Node' ); var Path = require( 'SCENERY/nodes/Path' ); var PhetFont = require( 'SCENERY_PHET/PhetFont' ); @@ -124,9 +125,8 @@ define( function( require ) { } ); // A11Y DRAFT - // TODO: refactor assert && assert( options.createAriaValueText, 'ISLCObjectNode subtypes must define an aria-valuetext creation function' ); - this.accessibleName = `${options.label} position`; + this.accessibleName = ISLCStringManager.getObjectLabelPositionText( options.label ); // @protected this.layoutBounds = layoutBounds; diff --git a/js/view/ISLCStringManager.js b/js/view/ISLCStringManager.js index bf0dd93..326ddcd 100644 --- a/js/view/ISLCStringManager.js +++ b/js/view/ISLCStringManager.js @@ -27,6 +27,8 @@ define( require => { // const spherePositionHelpTextString = ISLCA11yStrings.spherePositionHelpText.value; const forceVectorMagnitudePatternString = ISLCA11yStrings.forceVectorMagnitudePattern.value; const forceAndVectorPatternString = ISLCA11yStrings.forceAndVectorPattern.value; + const positionMeterMarkPatternString = ISLCA11yStrings.positionMeterMarkPattern.value; + const objectLabelPositionPatternString = ISLCA11yStrings.objectLabelPositionPattern.value; const tinyString = ISLCA11yStrings.tiny.value; const verySmallString = ISLCA11yStrings.verySmall.value; @@ -36,7 +38,6 @@ define( require => { const veryLargeString = ISLCA11yStrings.veryLarge.value; const hugeString = ISLCA11yStrings.huge.value; - const extremelyFarFromString = ISLCA11yStrings.extremelyFarFrom.value; const veryFarFromString = ISLCA11yStrings.veryFarFrom.value; const notSoFarFromString = ISLCA11yStrings.notSoFarFrom.value; @@ -54,7 +55,6 @@ define( require => { const aLittleString = ISLCA11yStrings.aLittle.value; const aTinyBitString = ISLCA11yStrings.aTinyBit.value; - // TODO: create type to handle string arrays mapped from a given value const SIZE_STRINGS = [ tinyString, verySmallString, @@ -192,6 +192,14 @@ define( require => { return StringUtils.fillIn( pattern, fillObject ); } + static getPositionMeterMarkText( position ) { + return StringUtils.fillIn( positionMeterMarkPatternString, { position } ); + } + + static getObjectLabelPositionText( label ) { + return StringUtils.fillIn( objectLabelPositionPatternString, { label } ); + } + getSizeFromIndex( index ) { return SIZE_STRINGS[ index ]; }