Skip to content

Commit

Permalink
keyboard nav strings moved to GFL, GFLB keyboard nav dialog deleted, …
Browse files Browse the repository at this point in the history
…proper string handling and address todos, see phetsims/gravity-force-lab#109
  • Loading branch information
mbarlow12 committed Oct 31, 2018
1 parent eeba9e2 commit f85c979
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 224 deletions.
33 changes: 0 additions & 33 deletions gravity-force-lab-basics-strings_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,6 @@
"billionKg": {
"value": "billion kg"
},
"moveSpheresHeading": {
"value": "Move Spheres"
},
"moveSphereLabel": {
"value": "Move sphere"
},
"moveInLargerSteps": {
"value": "Move in larger steps"
},
"jumpToLeft": {
"value": "Jump to left"
},
"jumpToRight": {
"value": "Jump to right"
},
"changeMassHeading": {
"value": "Change Mass"
},
"increaseMass": {
"value": "Increase mass"
},
"decreaseMass": {
"value": "Decrease mass"
},
"changeMassInLargerSteps": {
"value": "Change mass in larger steps"
},
"jumpToMaximumMass": {
"value": "Jump to maximum mass"
},
"jumpToMinimumMass": {
"value": "Jump to minimum mass"
},
"mass1ControlLabel": {
"value": "Mass 1"
},
Expand Down
4 changes: 2 additions & 2 deletions js/gravity-force-lab-basics-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ define( function( require ) {
'use strict';

// modules
var GravityForceLabBasicsKeyboardHelpContent = require( 'GRAVITY_FORCE_LAB_BASICS/gravity-force-lab-basics/view/GravityForceLabBasicsKeyboardHelpContent' );
var GravityForceLabKeyboardHelpContent = require( 'GRAVITY_FORCE_LAB/gravity-force-lab/view/GravityForceLabKeyboardHelpContent' );
var GravityForceLabBasicsModel = require( 'GRAVITY_FORCE_LAB_BASICS/gravity-force-lab-basics/model/GravityForceLabBasicsModel' );
var GravityForceLabBasicsScreenView = require( 'GRAVITY_FORCE_LAB_BASICS/gravity-force-lab-basics/view/GravityForceLabBasicsScreenView' );
var Property = require( 'AXON/Property' );
Expand All @@ -24,7 +24,7 @@ define( function( require ) {
// strings
var gravityForceLabBasicsTitleString = require( 'string!GRAVITY_FORCE_LAB_BASICS/gravity-force-lab-basics.title' );

var keyboardHelpContent = new GravityForceLabBasicsKeyboardHelpContent( Tandem.rootTandem.createTandem( 'keyboardHelpContent' ) );
var keyboardHelpContent = new GravityForceLabKeyboardHelpContent( Tandem.rootTandem.createTandem( 'keyboardHelpContent' ) );

var simOptions = {
credits: {
Expand Down
28 changes: 2 additions & 26 deletions js/gravity-force-lab-basics/GravityForceLabBasicsA11yStrings.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,8 @@ define( function( require ) {
massReadoutPattern: {
value: '{{value}} billion kg'
},
moveSphereDescription: {
value: 'Move sphere left and right with the Left and Right Arrow keys.'
},
moveInLargerStepsDescription: {
value: 'Move in larger steps with Page Up and Page Down keys.'
},
jumpToLeftDescription: {
value: 'Jump to left with Home key.'
},
jumpToRightDescription: {
value: 'Jump to right with End key.'
},
increaseMassDescription: {
value: 'Increase mass with Up or Right Arrow key.'
},
decreaseMassDescription: {
value: 'Decrease mass with Down or Left Arrow key.'
},
changeMassInLargerStepsDescription: {
value: 'Change mass in larger steps with Page Up and Page Down keys.'
},
jumpToMaximumMassDescription: {
value: 'Jump to maximum mass with End key.'
},
jumpToMinimumMassDescription: {
value: 'Jump to minimum mass with Home key.'
massesDistanceApartPattern: {
value: 'masses are {{distance}} km apart;'
}
};

Expand Down
9 changes: 9 additions & 0 deletions js/gravity-force-lab-basics/view/GFLBStringManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,31 @@ define( require => {

// modules
const gravityForceLabBasics = require( 'GRAVITY_FORCE_LAB_BASICS/gravityForceLabBasics' );
const GravityForceLabBasicsA11yStrings = require( 'GRAVITY_FORCE_LAB_BASICS/gravity-force-lab-basics/GravityForceLabBasicsA11yStrings' );
const GravityForceLabBasicsConstants = require( 'GRAVITY_FORCE_LAB_BASICS/gravity-force-lab-basics/GravityForceLabBasicsConstants' );
const GravityForceLabStringManager = require( 'GRAVITY_FORCE_LAB/gravity-force-lab/view/GravityForceLabStringManager' );
const LinearFunction = require( 'DOT/LinearFunction' );
const StringUtils = require( 'PHETCOMMON/util/StringUtils' );
const Util = require( 'DOT/Util' );

const { MASS_RANGE, PULL_FORCE_RANGE } = GravityForceLabBasicsConstants;
const massToIndex = new LinearFunction( MASS_RANGE.min, MASS_RANGE.max, 0, 6 );
const forceToIndex = new LinearFunction( PULL_FORCE_RANGE.min, PULL_FORCE_RANGE.max * 0.6, 0, 6, true );
const forceToPullIndex = new LinearFunction( PULL_FORCE_RANGE.min, PULL_FORCE_RANGE.max, 6, 0, true );

const massesDistanceApartPatternString = GravityForceLabBasicsA11yStrings.massesDistanceApartPattern.value;


class GFLBStringManager extends GravityForceLabStringManager {

constructor( model, object1Label, object2Label ) {
super( model, object1Label, object2Label, {} );
}

static getMassesDistanceApart( distance ) {
return StringUtils.fillIn( massesDistanceApartPatternString, { distance } );
}

// @override
getDistanceIndex( distance ) {
distance /= 1000;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ define( function( require ) {
var gravityForceLabBasics = require( 'GRAVITY_FORCE_LAB_BASICS/gravityForceLabBasics' );
var inherit = require( 'PHET_CORE/inherit' );
var GravityForceLabBasicsConstants = require( 'GRAVITY_FORCE_LAB_BASICS/gravity-force-lab-basics/GravityForceLabBasicsConstants' );
var GFLBStringManager = require( 'GRAVITY_FORCE_LAB_BASICS/gravity-force-lab-basics/view/GFLBStringManager' );
var ISLCObjectNode = require( 'INVERSE_SQUARE_LAW_COMMON/view/ISLCObjectNode' );
var PhetFont = require( 'SCENERY_PHET/PhetFont' );
var RadialGradient = require( 'SCENERY/util/RadialGradient' );
Expand Down Expand Up @@ -47,10 +48,9 @@ define( function( require ) {
tandem: Tandem.required,

// a11y
// TODO: refactor into proper string usage
createAriaValueText: function( formattedValue, previousValue ) {
formattedValue += 4800;
return `${formattedValue} meter mark`;
return GFLBStringManager.getPositionMeterMarkText( formattedValue );
}
}, options );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ define( function( require ) {
var ISLCQueryParameters = require( 'INVERSE_SQUARE_LAW_COMMON/ISLCQueryParameters' );
var MassControl = require( 'GRAVITY_FORCE_LAB_BASICS/gravity-force-lab-basics/view/MassControl' );
var MassPDOMNode = require( 'GRAVITY_FORCE_LAB/gravity-force-lab/view/MassPDOMNode' );
var GravityForceLabA11yStrings = require( 'GRAVITY_FORCE_LAB/gravity-force-lab/GravityForceLabA11yStrings' );
var GravityForceLabScreenSummaryNode = require( 'GRAVITY_FORCE_LAB/gravity-force-lab/view/GravityForceLabScreenSummaryNode' );
var GFLBStringManager = require( 'GRAVITY_FORCE_LAB_BASICS/gravity-force-lab-basics/view/GFLBStringManager' );
var ModelViewTransform2 = require( 'PHETCOMMON/view/ModelViewTransform2' );
Expand Down Expand Up @@ -60,6 +61,7 @@ define( function( require ) {
var mass2ControlLabelString = require( 'string!GRAVITY_FORCE_LAB_BASICS/mass2ControlLabel' );
var spherePositionsString = ISLCA11yStrings.spherePositions.value;
var spherePositionHelpTextString = ISLCA11yStrings.spherePositionHelpText.value;
var massControlsLabelString = GravityForceLabA11yStrings.massControlsLabel.value;

/**
* @param {GravityForceLabBasicsModel} model
Expand Down Expand Up @@ -139,10 +141,9 @@ define( function( require ) {
color: new Color( 255, 0, 0 )
} );

// TODO: implement proper string usage
var massControlsNode = new Node( {
labelTagName: 'h3',
labelContent: 'Mass Controls',
labelContent: massControlsLabelString,
tagName: 'ul'
} );
playAreaNode.addChild( massControlsNode );
Expand Down Expand Up @@ -177,15 +178,14 @@ define( function( require ) {
controlAreaNode.addChild( parameterControlPanel );

// arrow that shows distance between the two masses
// TODO: review accessible implementation and string usage
var distanceArrowNode = new DistanceArrowNode( model, modelViewTransform, {
tandem: tandem.createTandem( 'distanceArrowNode' ),
y: 145,
tagName: 'li'
tagName: 'p'
} );
model.showDistanceProperty.linkAttribute( distanceArrowNode, 'visible' );
model.distanceProperty.link( function( distance ) {
distanceArrowNode.innerContent = `masses are ${distance} km apart`;
distanceArrowNode.innerContent = GFLBStringManager.getMassesDistanceApart( distance );
} );
massPositionsNode.addChild( distanceArrowNode );

Expand Down
2 changes: 1 addition & 1 deletion js/gravity-force-lab-basics/view/MassControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ define( function( require ) {
align: 'center',
tandem: tandem,

// TODO: review
// a11y
tagName: 'li'
} );
}
Expand Down

0 comments on commit f85c979

Please sign in to comment.