Skip to content

Commit

Permalink
implement proper string usage, remove comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarlow12 committed Dec 11, 2018
1 parent 73a4268 commit cee14db
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
12 changes: 12 additions & 0 deletions js/gravity-force-lab-basics/GFLBA11yStrings.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ define( function( require ) {
},
massBillionsPattern: {
value: '{{mass}} billion'
},
positionKilometerPattern: {
value: '{{position}} kilometer'
},
mass1Mass2QualitativeDistancePattern: {
value: '{{mass1}} and {{mass2}} are {{qualitativeDistance}} each other.'
},
distanceArrowVisible: {
value: 'Distance arrow visible.'
},
distanceArrowRemoved: {
value: 'Distance arrow removed.'
}
};

Expand Down
19 changes: 5 additions & 14 deletions js/gravity-force-lab-basics/view/GFLBStringManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ define( require => {
const massesDistanceApartPatternString = GFLBA11yStrings.massesDistanceApartPattern.value;
const unitsNewtonsString = require( 'string!INVERSE_SQUARE_LAW_COMMON/units.newtons' );
const massBillionsPatternString = GFLBA11yStrings.massBillionsPattern.value;
const positionKilometerPatternString = GFLBA11yStrings.positionKilometerPattern.value;
const mass1Mass2QualitativeDistancePatternString = GFLBA11yStrings.mass1Mass2QualitativeDistancePattern.value;

class GFLBStringManager extends GravityForceLabStringManager {

Expand All @@ -34,10 +36,9 @@ define( require => {
formatMassValue: mass => {
mass = mass / 1e9;
return StringUtils.fillIn( massBillionsPatternString, { mass } );
}, // TODO: convert to proper string usage
},
formatPositionUnitMark: position => {
// position = Util.toFixedNumber( position / 1e3, 1 );
return StringUtils.fillIn( '{{position}} kilometer', { position } );
return StringUtils.fillIn( positionKilometerPatternString, { position } );
}
} );
}
Expand All @@ -46,18 +47,8 @@ define( require => {
return StringUtils.fillIn( massesDistanceApartPatternString, { distance } );
}

// getSpherePositionAriaValueText( newPosition, objectEnum ) {
// return super.getSpherePositionAriaValueText( Util.toFixedNumber( newPosition + 4.8, 1 ), objectEnum );
// }
//
// getSpherePositionAndRegionText( position, objectEnum ) {
// position = Util.toFixedNumber( position + 4.8, 1 );
// return super.getSpherePositionAndRegionText( position, objectEnum );
// }

// TODO: proper string usage
getOnlyQualitativeObjectDistanceSummary() {
const pattern = '{{mass1}} and {{mass2}} are {{qualitativeDistance}} each other.';
const pattern = mass1Mass2QualitativeDistancePatternString;
return StringUtils.fillIn( pattern, { mass1: this.object1Label, mass2: this.object2Label, qualitativeDistance: this.getQualitativeDistance() } );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ define( require => {
// modules
const gravityForceLabBasics = require( 'GRAVITY_FORCE_LAB_BASICS/gravityForceLabBasics' );
const GravityForceLabA11yStrings = require( 'GRAVITY_FORCE_LAB/gravity-force-lab/GravityForceLabA11yStrings' );
// const ISLCA11yStrings = require( 'INVERSE_SQUARE_LAW_COMMON/ISLCA11yStrings' );
const GFLBA11yStrings = require( 'GRAVITY_FORCE_LAB_BASICS/gravity-force-lab-basics/GFLBA11yStrings' );
const ISLCAlertManager = require( 'INVERSE_SQUARE_LAW_COMMON/view/ISLCAlertManager' );
const Utterance = require( 'SCENERY_PHET/accessibility/Utterance' );
const utteranceQueue = require( 'SCENERY_PHET/accessibility/utteranceQueue' );

// strings
const constantRadiusThinkDensityString = GravityForceLabA11yStrings.constantRadiusThinkDensity.value;
const distanceArrowVisibleString = GFLBA11yStrings.distanceArrowVisible.value;
const distanceArrowRemovedString = GFLBA11yStrings.distanceArrowRemoved.value;

class GravityForceLabBasicsAlertManager extends ISLCAlertManager {
constructor( model, stringManager ) {
Expand Down Expand Up @@ -46,9 +48,9 @@ define( require => {
const utterance = new Utterance( { alert, uniqueGroupId: 'constantRadius' } );
utteranceQueue.addToBack( utterance );
}
// TODO: proper string usage - wait until content is finalized

alertDistanceVisible( showDistance ) {
const alert = showDistance ? 'Distance arrow visible.' : 'Distance arrow removed.';
const alert = showDistance ? distanceArrowVisibleString : distanceArrowRemovedString;
const utterance = new Utterance( { alert, uniqueGroupId: 'distanceVisible' } );
utteranceQueue.addToBack( utterance );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ define( function( require ) {
tandem: Tandem.required,

// a11y
// TODO: proper string usage
createAriaValueText: function( formattedValue, previousValue ) {
// formattedValue = Util.toFixedNumber( ( formattedValue + 4800 ) / 1e3, 1 );
return stringManager.getSpherePositionAriaValueText( formattedValue, self );
// return GFLBStringManager.getPositionMeterMarkText( `${formattedValue} kilometer` );
}
}, options );

Expand Down

0 comments on commit cee14db

Please sign in to comment.