From 0138c64cb9366ab370eebf4f32ad92125c94b33c Mon Sep 17 00:00:00 2001 From: Michael Barlow Date: Mon, 10 Dec 2018 18:33:24 -0700 Subject: [PATCH] remove comments, implement proper string usage --- .../GravityForceLabA11yStrings.js | 6 ++++++ .../view/GravityForceLabStringManager.js | 17 +++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/js/gravity-force-lab/GravityForceLabA11yStrings.js b/js/gravity-force-lab/GravityForceLabA11yStrings.js index 9b7b8ca5..40fff699 100644 --- a/js/gravity-force-lab/GravityForceLabA11yStrings.js +++ b/js/gravity-force-lab/GravityForceLabA11yStrings.js @@ -36,6 +36,12 @@ define( require => { mass2RedSphere: { value: 'm2, Red Sphere' }, + valueUnitstPattern: { + value: '{{value}} {{units}}' + }, + positionMeterPattern: { + value: '{{position}} meter' + }, //////////////////////// diff --git a/js/gravity-force-lab/view/GravityForceLabStringManager.js b/js/gravity-force-lab/view/GravityForceLabStringManager.js index e215a30b..ee6d4bd3 100644 --- a/js/gravity-force-lab/view/GravityForceLabStringManager.js +++ b/js/gravity-force-lab/view/GravityForceLabStringManager.js @@ -24,12 +24,12 @@ define( require => { // strings const micronewtonsString = GravityForceLabA11yStrings.micronewtons.value; - // const mass1AbbreviatedString = require( 'string!GRAVITY_FORCE_LAB/mass1Abbreviated' ); - // const mass2AbbreviatedString = require( 'string!GRAVITY_FORCE_LAB/mass2Abbreviated' ); + const unitsNewtonsString = require( 'string!INVERSE_SQUARE_LAW_COMMON/units.newtons' ); const massValuesAndComparisonSummaryPatternString = GravityForceLabA11yStrings.massValuesAndComparisonSummaryPattern.value; - // TODO: proper string usage const sizeAndPositionPatternString = GravityForceLabA11yStrings.sizeAndPositionPattern.value; + const valueUnitsPatternString = GravityForceLabA11yStrings.valueUnitstPattern.value; + const positionMeterPatternString = GravityForceLabA11yStrings.positionMeterPattern.value; const muchMuchSmallerThanString = GravityForceLabA11yStrings.muchMuchSmallerThan.value; const muchSmallerThanString = GravityForceLabA11yStrings.muchSmallerThan.value; @@ -54,20 +54,19 @@ define( require => { class GravityForceLabStringManager extends ISLCStringManager { constructor( model, object1Label, object2Label, options ) { - // TODO: proper string handling const convertForceValue = forceValue => { let units; let value; if ( model.scientificNotationProperty.get() ) { - units = 'newtons'; + units = unitsNewtonsString; value = ISLCStringManager.getForceInScientificNotation( forceValue, 2 ); } else { - units = 'micronewtons'; + units = micronewtonsString; value = Util.toFixedNumber( forceValue * MICRO_CONVERSION_FACTOR, 6 ); } - return `${value} ${units}`; + return StringUtils.fillIn( valueUnitsPatternString, { value, units } ); }; options = _.extend( { @@ -77,7 +76,7 @@ define( require => { convertDistanceMetric: distance => Util.toFixedNumber( distance, 1 ), formatPositionUnitMark: position => { position = Util.toFixedNumber( position, 1 ); - return StringUtils.fillIn( '{{position}} meter', { position } ); + return StringUtils.fillIn( positionMeterPatternString, { position } ); }, formatMassValue: mass => mass }, options ); @@ -97,8 +96,6 @@ define( require => { [ model.object1.radiusProperty, model.object2.radiusProperty ], ( r1, r2 ) => { this._radiusDifference = r1 - r2; - // max diff -1.0507898924466623 - // min diff 0 } );