diff --git a/js/balloons-and-static-electricity-main.js b/js/balloons-and-static-electricity-main.js
index 8847c075..efa7f74f 100644
--- a/js/balloons-and-static-electricity-main.js
+++ b/js/balloons-and-static-electricity-main.js
@@ -27,9 +27,9 @@ define( require => {
SimLauncher.launch( function() {
- var tandem = Tandem.rootTandem;
+ const tandem = Tandem.rootTandem;
- var simOptions = {
+ const simOptions = {
credits: {
leadDesign: 'Noah Podolefsky & Sam Reid',
softwareDevelopment: 'Sam Reid, John Blanco',
@@ -43,7 +43,7 @@ define( require => {
keyboardHelpNode: new BASEKeyboardHelpContent()
};
- var balloonsAndStaticElectricityScreenTandem = tandem.createTandem( 'balloonsAndStaticElectricityScreen' );
+ const balloonsAndStaticElectricityScreenTandem = tandem.createTandem( 'balloonsAndStaticElectricityScreen' );
//Create and start the sim
new Sim( balloonsAndStaticElectricityTitleString, [
diff --git a/js/balloons-and-static-electricity/BASEA11yStrings.js b/js/balloons-and-static-electricity/BASEA11yStrings.js
index 8ab4497c..0bad00ff 100644
--- a/js/balloons-and-static-electricity/BASEA11yStrings.js
+++ b/js/balloons-and-static-electricity/BASEA11yStrings.js
@@ -12,7 +12,7 @@ define( require => {
const balloonsAndStaticElectricity = require( 'BALLOONS_AND_STATIC_ELECTRICITY/balloonsAndStaticElectricity' );
- var BASEA11yStrings = {
+ const BASEA11yStrings = {
//------------------------------------------------------------------------
// General utility strings
@@ -872,7 +872,7 @@ define( require => {
};
if ( phet.chipper.queryParameters.stringTest === 'xss' ) {
- for ( var key in BASEA11yStrings ) {
+ for ( const key in BASEA11yStrings ) {
BASEA11yStrings[ key ].value += '';
}
}
diff --git a/js/balloons-and-static-electricity/BASEConstants.js b/js/balloons-and-static-electricity/BASEConstants.js
index a908dfa3..e13fcf58 100644
--- a/js/balloons-and-static-electricity/BASEConstants.js
+++ b/js/balloons-and-static-electricity/BASEConstants.js
@@ -12,7 +12,7 @@ define( require => {
const balloonsAndStaticElectricity = require( 'BALLOONS_AND_STATIC_ELECTRICITY/balloonsAndStaticElectricity' );
const Property = require( 'AXON/Property' );
- var BASEConstants = {
+ const BASEConstants = {
backgroundColorProperty: new Property( 'rgb( 151, 208, 255 )' ),
msScaleFactor: 1000, // to convert seconds to miliseconds, used throughout the view
MAX_BALLOON_CHARGE: 57, // max number of charges the balloon can have
diff --git a/js/balloons-and-static-electricity/BASEQueryParameters.js b/js/balloons-and-static-electricity/BASEQueryParameters.js
index 542c5e57..0caed62e 100644
--- a/js/balloons-and-static-electricity/BASEQueryParameters.js
+++ b/js/balloons-and-static-electricity/BASEQueryParameters.js
@@ -12,7 +12,7 @@ define( require => {
// modules
const balloonsAndStaticElectricity = require( 'BALLOONS_AND_STATIC_ELECTRICITY/balloonsAndStaticElectricity' );
- var BASEQueryParameters = QueryStringMachine.getAll( {
+ const BASEQueryParameters = QueryStringMachine.getAll( {
// keyData - must be used with reader, shows key information instead of reader output, useful for debugging
keyData: { type: 'flag' },
diff --git a/js/balloons-and-static-electricity/model/BASEModel.js b/js/balloons-and-static-electricity/model/BASEModel.js
index 1d208ded..c6641ff4 100644
--- a/js/balloons-and-static-electricity/model/BASEModel.js
+++ b/js/balloons-and-static-electricity/model/BASEModel.js
@@ -62,11 +62,11 @@ define( require => {
this.wall = new WallModel( width - this.wallWidth, this.wallWidth, height, this.yellowBalloon, this.greenBalloon, tandem.createTandem( 'wall' ) );
// when the wall changes visibility, the balloons could start moving if they have charge and are near the wall
- var self = this;
+ const self = this;
this.wall.isVisibleProperty.link( function( isVisible ) {
// update the model bounds
- var newWidth = isVisible ? width - self.wallWidth : width;
+ const newWidth = isVisible ? width - self.wallWidth : width;
self.playAreaBounds.setMaxX( newWidth );
} );
@@ -116,7 +116,7 @@ define( require => {
// Called by the animation loop
step: function( dt ) {
- var self = this;
+ const self = this;
this.balloons.forEach( function( balloon ) {
if ( balloon.isVisibleProperty.get() ) {
@@ -156,7 +156,7 @@ define( require => {
* @returns {boolean}
*/
getBalloonsAdjacent: function() {
- var balloonsAdjacent = ( this.yellowBalloon.getCenter().minus( this.greenBalloon.getCenter() ).magnitude ) < BalloonModel.BALLOON_WIDTH;
+ const balloonsAdjacent = ( this.yellowBalloon.getCenter().minus( this.greenBalloon.getCenter() ).magnitude ) < BalloonModel.BALLOON_WIDTH;
return balloonsAdjacent && this.bothBalloonsVisible();
},
@@ -172,10 +172,10 @@ define( require => {
checkBalloonRestrictions: function( position, objWidth, objHeight ) {
//flag to check if we outside borders
- var isOutBounds = false;
+ let isOutBounds = false;
// if wall visible, right bound will be smaller by width of wall
- var rightBound = this.playAreaBounds.width;
+ const rightBound = this.playAreaBounds.width;
//if more than maxRight position - set maxRight position
if ( position.x + objWidth > rightBound ) {
diff --git a/js/balloons-and-static-electricity/model/BalloonModel.js b/js/balloons-and-static-electricity/model/BalloonModel.js
index c0aff707..05dbd793 100644
--- a/js/balloons-and-static-electricity/model/BalloonModel.js
+++ b/js/balloons-and-static-electricity/model/BalloonModel.js
@@ -30,16 +30,16 @@ define( require => {
const Vector2Property = require( 'DOT/Vector2Property' );
// constants, most if not all of which were empirically determined to elicit the desired appearance and behavior
- var VELOCITY_ARRAY_LENGTH = 5;
- var THRESHOLD_SPEED = 0.0125;
- var BALLOON_WIDTH = 134;
- var BALLOON_HEIGHT = 222;
+ const VELOCITY_ARRAY_LENGTH = 5;
+ const THRESHOLD_SPEED = 0.0125;
+ const BALLOON_WIDTH = 134;
+ const BALLOON_HEIGHT = 222;
// threshold for diagonal movement is +/- 15 degrees from diagonals
- var DIAGONAL_MOVEMENT_THRESHOLD = 15 * Math.PI / 180;
+ const DIAGONAL_MOVEMENT_THRESHOLD = 15 * Math.PI / 180;
// map that determines if the balloon is moving up, down, horizontally or along a diagonal between two points
- var DIRECTION_MAP = {
+ const DIRECTION_MAP = {
UP: new Range( -3 * Math.PI / 4 + DIAGONAL_MOVEMENT_THRESHOLD, -Math.PI / 4 - DIAGONAL_MOVEMENT_THRESHOLD ),
DOWN: new Range( Math.PI / 4 + DIAGONAL_MOVEMENT_THRESHOLD, 3 * Math.PI / 4 - DIAGONAL_MOVEMENT_THRESHOLD ),
RIGHT: new Range( -Math.PI / 4 + DIAGONAL_MOVEMENT_THRESHOLD, Math.PI / 4 - DIAGONAL_MOVEMENT_THRESHOLD ),
@@ -52,12 +52,12 @@ define( require => {
UP_RIGHT: new Range( -Math.PI / 4 - DIAGONAL_MOVEMENT_THRESHOLD, -Math.PI / 4 + DIAGONAL_MOVEMENT_THRESHOLD ),
DOWN_RIGHT: new Range( Math.PI / 4 - DIAGONAL_MOVEMENT_THRESHOLD, Math.PI / 4 + DIAGONAL_MOVEMENT_THRESHOLD )
};
- var DIRECTION_MAP_KEYS = Object.keys( DIRECTION_MAP );
+ const DIRECTION_MAP_KEYS = Object.keys( DIRECTION_MAP );
// collection of charge positions on the balloon, relative to the top left corners
// charges will appear in these positions as the balloon collects electrons
- var POSITIONS = [
+ const POSITIONS = [
[ 14, 70 ],
[ 18, 60 ],
[ 14, 90 ],
@@ -120,11 +120,11 @@ define( require => {
// determine average Y position for the charges in the balloon, used to calculate the average vertical location of
// the visual charge center
- var positionYSum = 0;
- for ( var i = 0; i < POSITIONS.length; i++ ) {
+ let positionYSum = 0;
+ for ( let i = 0; i < POSITIONS.length; i++ ) {
positionYSum += POSITIONS[ i ][ 1 ]; // y coordinate is second value
}
- var AVERAGE_CHARGE_Y = ( positionYSum / POSITIONS.length );
+ const AVERAGE_CHARGE_Y = ( positionYSum / POSITIONS.length );
/**
* Constructor
@@ -137,7 +137,7 @@ define( require => {
*/
function BalloonModel( x, y, balloonsAndStaticElectricityModel, defaultVisibility, tandem ) {
- var self = this;
+ const self = this;
//------------------------------------------------
// Properties
@@ -257,15 +257,15 @@ define( require => {
this.balloonsAndStaticElectricityModel = balloonsAndStaticElectricityModel;
// neutral pair of charges
- var plusChargesTandemGroup = tandem.createGroupTandem( 'plusCharges' );
- var minusChargesTandemGroup = tandem.createGroupTandem( 'minusCharges' );
+ const plusChargesTandemGroup = tandem.createGroupTandem( 'plusCharges' );
+ const minusChargesTandemGroup = tandem.createGroupTandem( 'minusCharges' );
this.positionsOfStartCharges.forEach( function( entry ) {
- var plusCharge = new PointChargeModel( entry[ 0 ], entry[ 1 ], plusChargesTandemGroup.createNextTandem(), false );
+ const plusCharge = new PointChargeModel( entry[ 0 ], entry[ 1 ], plusChargesTandemGroup.createNextTandem(), false );
self.plusCharges.push( plusCharge );
// minus charges at same location of positive charge, shifted down and to the right by charge radius
- var minusCharge = new PointChargeModel(
+ const minusCharge = new PointChargeModel(
entry[ 0 ] + PointChargeModel.RADIUS,
entry[ 1 ] + PointChargeModel.RADIUS,
minusChargesTandemGroup.createNextTandem(),
@@ -276,7 +276,7 @@ define( require => {
// charges that we can get from sweater, only negative charges
POSITIONS.forEach( function( entry ) {
- var minusCharge = new PointChargeModel( entry[ 0 ], entry[ 1 ], minusChargesTandemGroup.createNextTandem(), true );
+ const minusCharge = new PointChargeModel( entry[ 0 ], entry[ 1 ], minusChargesTandemGroup.createNextTandem(), true );
self.minusCharges.push( minusCharge );
} );
@@ -340,7 +340,7 @@ define( require => {
* @returns {boolean}
*/
onSweater: function() {
- var sweaterBounds = this.balloonsAndStaticElectricityModel.sweater.bounds;
+ const sweaterBounds = this.balloonsAndStaticElectricityModel.sweater.bounds;
if ( sweaterBounds.intersectsBounds( this.bounds ) ) {
return true;
}
@@ -421,7 +421,7 @@ define( require => {
* @returns {string}
*/
veryCloseToObject: function() {
- var centerX = this.getCenterX();
+ const centerX = this.getCenterX();
return PlayAreaMap.LANDMARK_RANGES.AT_VERY_CLOSE_TO_SWEATER.contains( centerX ) ||
PlayAreaMap.LANDMARK_RANGES.AT_VERY_CLOSE_TO_WALL.contains( centerX ) ||
PlayAreaMap.LANDMARK_RANGES.AT_VERY_CLOSE_TO_RIGHT_EDGE.contains( centerX );
@@ -433,8 +433,8 @@ define( require => {
* @returns {boolean}
*/
touchingWall: function() {
- var atWall = this.getCenterX() === PlayAreaMap.X_LOCATIONS.AT_WALL;
- var wallVisible = this.balloonsAndStaticElectricityModel.wall.isVisibleProperty.get();
+ const atWall = this.getCenterX() === PlayAreaMap.X_LOCATIONS.AT_WALL;
+ const wallVisible = this.balloonsAndStaticElectricityModel.wall.isVisibleProperty.get();
return ( atWall && wallVisible );
},
@@ -444,7 +444,7 @@ define( require => {
* @returns {string} - "LEFT"|"RIGHT"
*/
movingHorizontally: function() {
- var direction = this.directionProperty.get();
+ const direction = this.directionProperty.get();
return direction === BalloonDirectionEnum.LEFT || direction === BalloonDirectionEnum.RIGHT;
},
@@ -454,7 +454,7 @@ define( require => {
* @returns {string} - "UP"|"DOWN"
*/
movingVertically: function() {
- var direction = this.directionProperty.get();
+ const direction = this.directionProperty.get();
return direction === BalloonDirectionEnum.UP || direction === BalloonDirectionEnum.DOWN;
},
@@ -464,7 +464,7 @@ define( require => {
* @returns {string} - "UP_LEFT"|"UP_RIGHT"|"DOWN_LEFT"|"DOWN_RIGHT"
*/
movingDiagonally: function() {
- var direction = this.directionProperty.get();
+ const direction = this.directionProperty.get();
return direction === BalloonDirectionEnum.UP_LEFT ||
direction === BalloonDirectionEnum.UP_RIGHT ||
direction === BalloonDirectionEnum.DOWN_LEFT ||
@@ -477,7 +477,7 @@ define( require => {
* @returns {boolean}
*/
movingRight: function() {
- var direction = this.directionProperty.get();
+ const direction = this.directionProperty.get();
return direction === BalloonDirectionEnum.RIGHT ||
direction === BalloonDirectionEnum.UP_RIGHT ||
direction === BalloonDirectionEnum.DOWN_RIGHT;
@@ -489,7 +489,7 @@ define( require => {
* @returns {boolean}
*/
movingLeft: function() {
- var direction = this.directionProperty.get();
+ const direction = this.directionProperty.get();
return direction === BalloonDirectionEnum.LEFT ||
direction === BalloonDirectionEnum.UP_LEFT ||
direction === BalloonDirectionEnum.DOWN_LEFT;
@@ -505,8 +505,8 @@ define( require => {
*/
getProgressThroughRegion: function() {
- var range;
- var difference;
+ let range;
+ let difference;
if ( this.movingHorizontally() || this.movingDiagonally() ) {
range = PlayAreaMap.COLUMN_RANGES[ this.playAreaColumnProperty.get() ];
difference = this.getCenter().x - range.min;
@@ -517,10 +517,10 @@ define( require => {
}
// determine how far we are through the region
- var progress = difference / range.getLength();
+ let progress = difference / range.getLength();
// progress is the difference of the calculated proportion if moving to the left or up
- var direction = this.directionProperty.get();
+ const direction = this.directionProperty.get();
if ( direction === BalloonDirectionEnum.LEFT || direction === BalloonDirectionEnum.UP ) {
progress = 1 - progress;
}
@@ -586,8 +586,8 @@ define( require => {
* @returns {Vector2}
*/
getChargeCenter: function() {
- var centerX = this.getCenter().x;
- var centerY = this.locationProperty.get().y + AVERAGE_CHARGE_Y;
+ const centerX = this.getCenter().x;
+ const centerY = this.locationProperty.get().y + AVERAGE_CHARGE_Y;
return new Vector2( centerX, centerY );
},
@@ -598,8 +598,8 @@ define( require => {
* @returns {Vector2}
*/
getSweaterTouchingCenter: function() {
- var sweater = this.balloonsAndStaticElectricityModel.sweater;
- var sweaterRight = sweater.x + sweater.width;
+ const sweater = this.balloonsAndStaticElectricityModel.sweater;
+ const sweaterRight = sweater.x + sweater.width;
if ( this.getCenter().x > sweaterRight ) {
var centerX = this.locationProperty.get().x;
@@ -645,8 +645,8 @@ define( require => {
}
// otherwise, wall and balloon must be visible, and force must be large enough
- var balloonForce = BalloonModel.getForceToClosestWallCharge( this );
- var forceLargeEnough = this.balloonsAndStaticElectricityModel.wall.forceIndicatesInducedCharge( balloonForce );
+ const balloonForce = BalloonModel.getForceToClosestWallCharge( this );
+ const forceLargeEnough = this.balloonsAndStaticElectricityModel.wall.forceIndicatesInducedCharge( balloonForce );
return wallVisible && this.isVisibleProperty.get() && forceLargeEnough;
},
@@ -687,7 +687,7 @@ define( require => {
// seconds to milliseconds - really, the model is fairly 'unitless' but multiplying the
// time step by 1000 makes the sim look and feel like the Java version
- var dt = dtSeconds * 1000;
+ let dt = dtSeconds * 1000;
// limit large values of dt - they probably mean that the sim just regained focus
if ( dt > 500 ) {
@@ -722,8 +722,8 @@ define( require => {
if ( !this.oldLocation ) {
return;
}
- var vx = ( this.locationProperty.get().x - this.oldLocation.x ) / dt;
- var vy = ( this.locationProperty.get().y - this.oldLocation.y ) / dt;
+ const vx = ( this.locationProperty.get().x - this.oldLocation.x ) / dt;
+ const vy = ( this.locationProperty.get().y - this.oldLocation.y ) / dt;
// calculate average velocity
this.xVelocityArray[ this.xVelocityArray.counter++ ] = vx * vx;
@@ -731,9 +731,9 @@ define( require => {
this.yVelocityArray[ this.yVelocityArray.counter++ ] = vy * vy;
this.yVelocityArray.counter %= VELOCITY_ARRAY_LENGTH;
- var averageX = 0;
- var averageY = 0;
- for ( var i = 0; i < VELOCITY_ARRAY_LENGTH; i++ ) {
+ let averageX = 0;
+ let averageY = 0;
+ for ( let i = 0; i < VELOCITY_ARRAY_LENGTH; i++ ) {
averageX += this.xVelocityArray[ i ];
averageY += this.yVelocityArray[ i ];
}
@@ -741,11 +741,11 @@ define( require => {
averageY /= VELOCITY_ARRAY_LENGTH;
// if average speed larger than threshold speed we try to move minus charges from sweater to balloon
- var speed = Math.sqrt( averageX * averageX + averageY * averageY );
+ const speed = Math.sqrt( averageX * averageX + averageY * averageY );
this.dragVelocityProperty.set( new Vector2( vx, vy ) );
- var chargeFound = false;
+ let chargeFound = false;
if ( speed >= THRESHOLD_SPEED ) {
chargeFound = model.sweater.checkAndTransferCharges( this );
}
@@ -785,7 +785,7 @@ define( require => {
* @returns {boolean}
*/
isTouchingRightBoundary: function() {
- var balloonX = this.getCenter().x;
+ const balloonX = this.getCenter().x;
if ( this.balloonsAndStaticElectricityModel.wall.isVisibleProperty.get() ) {
return PlayAreaMap.X_LOCATIONS.AT_WALL === balloonX;
}
@@ -801,7 +801,7 @@ define( require => {
* @returns {boolean}
*/
isTouchingRightEdge: function() {
- var balloonX = this.getCenterX();
+ const balloonX = this.getCenterX();
return PlayAreaMap.X_BOUNDARY_LOCATIONS.AT_RIGHT_EDGE === balloonX;
},
@@ -835,13 +835,13 @@ define( require => {
applyForce: function( dt ) {
// only move if this balloon is not over the sweater
- var model = this.balloonsAndStaticElectricityModel;
+ const model = this.balloonsAndStaticElectricityModel;
if ( !this.centerInSweaterChargedArea() ) {
- var rightBound = model.playAreaBounds.maxX;
- var force = this.getTotalForce();
- var newVelocity = this.velocityProperty.get().plus( force.timesScalar( dt ) );
- var newLocation = this.locationProperty.get().plus( this.velocityProperty.get().timesScalar( dt ) );
+ const rightBound = model.playAreaBounds.maxX;
+ const force = this.getTotalForce();
+ const newVelocity = this.velocityProperty.get().plus( force.timesScalar( dt ) );
+ const newLocation = this.locationProperty.get().plus( this.velocityProperty.get().timesScalar( dt ) );
if ( newLocation.x + this.width >= rightBound ) {
@@ -890,27 +890,27 @@ define( require => {
* @returns {Vector2}
*/
getTotalForce: function() {
- var model = this.balloonsAndStaticElectricityModel;
+ const model = this.balloonsAndStaticElectricityModel;
if ( model.wall.isVisibleProperty.get() ) {
- var distFromWall = model.wall.x - this.locationProperty.get().x;
+ const distFromWall = model.wall.x - this.locationProperty.get().x;
// if the balloon has enough charge and is close enough to the wall, the wall attracts it more than the sweater
if ( this.chargeProperty.get() < -5 ) {
- var relDist = distFromWall - this.width;
- var fright = 0.003;
+ const relDist = distFromWall - this.width;
+ const fright = 0.003;
if ( relDist <= 40 + this.chargeProperty.get() / 8 ) {
return new Vector2( -fright * this.chargeProperty.get() / 20.0, 0 );
}
}
}
- var force = this.getSweaterForce( model.sweater );
- var other = this.getOtherBalloonForce();
- var sumOfForces = force.plus( other );
+ const force = this.getSweaterForce( model.sweater );
+ const other = this.getOtherBalloonForce();
+ const sumOfForces = force.plus( other );
// Don't allow the force to be too high or the balloon can jump across the screen in 1 step, see #67
- var mag = sumOfForces.magnitude;
- var max = 1E-2;
+ const mag = sumOfForces.magnitude;
+ const max = 1E-2;
if ( mag > max ) {
sumOfForces.normalize();
sumOfForces.multiplyScalar( max );
@@ -929,7 +929,7 @@ define( require => {
if ( this.isDraggedProperty.get() || !this.isVisibleProperty.get() || !this.other.isVisibleProperty.get() ) {
return new Vector2( 0, 0 );
}
- var kqq = BalloonModel.FORCE_CONSTANT * this.chargeProperty.get() * this.other.chargeProperty.get();
+ const kqq = BalloonModel.FORCE_CONSTANT * this.chargeProperty.get() * this.other.chargeProperty.get();
return BalloonModel.getForce( this.getCenter(), this.other.getCenter(), kqq );
}
}, {
@@ -954,8 +954,8 @@ define( require => {
power = power || 2;
// calculate a vector from one point to the other
- var difference = p1.minus( p2 );
- var r = difference.magnitude;
+ const difference = p1.minus( p2 );
+ const r = difference.magnitude;
// if the points are right on top of one another, return an attraction value of zero
if ( r === 0 ) {
@@ -995,11 +995,11 @@ define( require => {
* @static
*/
getDirection: function( pointA, pointB ) {
- var direction;
+ let direction;
- var dx = pointA.x - pointB.x;
- var dy = pointA.y - pointB.y;
- var angle = Math.atan2( dy, dx );
+ const dx = pointA.x - pointB.x;
+ const dy = pointA.y - pointB.y;
+ const angle = Math.atan2( dy, dx );
// atan2 wraps around Math.PI, so special check for moving left from absolute value
if ( DIRECTION_MAP.LEFT.contains( Math.abs( angle ) ) ) {
@@ -1007,8 +1007,8 @@ define( require => {
}
// otherwise, angle will be in one of the ranges in DIRECTION_MAP
- for ( var i = 0; i < DIRECTION_MAP_KEYS.length; i++ ) {
- var entry = DIRECTION_MAP[ DIRECTION_MAP_KEYS[ i ] ];
+ for ( let i = 0; i < DIRECTION_MAP_KEYS.length; i++ ) {
+ const entry = DIRECTION_MAP[ DIRECTION_MAP_KEYS[ i ] ];
if ( entry.contains( angle ) ) {
direction = BalloonDirectionEnum[ DIRECTION_MAP_KEYS[ i ] ];
break;
diff --git a/js/balloons-and-static-electricity/model/MovablePointChargeModel.js b/js/balloons-and-static-electricity/model/MovablePointChargeModel.js
index ed2a180f..90494af3 100644
--- a/js/balloons-and-static-electricity/model/MovablePointChargeModel.js
+++ b/js/balloons-and-static-electricity/model/MovablePointChargeModel.js
@@ -57,8 +57,8 @@ define( require => {
* @returns {Vector2}
*/
getDisplacement: function() {
- var initialPosition = this.locationProperty.initialValue;
- var displacement = this.locationProperty.get().distance( initialPosition );
+ const initialPosition = this.locationProperty.initialValue;
+ const displacement = this.locationProperty.get().distance( initialPosition );
return displacement;
},
diff --git a/js/balloons-and-static-electricity/model/PlayAreaMap.js b/js/balloons-and-static-electricity/model/PlayAreaMap.js
index 4d03bc23..ceffa037 100644
--- a/js/balloons-and-static-electricity/model/PlayAreaMap.js
+++ b/js/balloons-and-static-electricity/model/PlayAreaMap.js
@@ -23,11 +23,11 @@ define( require => {
// constants
// when within this width of an X_LOCATION, balloon is considered in a landmark
- var LANDMARK_WIDTH = 20;
- var HALF_LANDMARK_WIDTH = LANDMARK_WIDTH / 2;
+ const LANDMARK_WIDTH = 20;
+ const HALF_LANDMARK_WIDTH = LANDMARK_WIDTH / 2;
// critical x locations for the balloon (relative to the balloon's center)
- var X_LOCATIONS = {
+ const X_LOCATIONS = {
AT_NEAR_SWEATER: 393,
AT_CENTER_PLAY_AREA: 507,
AT_NEAR_WALL: 596,
@@ -36,42 +36,42 @@ define( require => {
};
// critical y locations for the balloon (relative to the balloon's center)
- var Y_LOCATIONS = {
+ const Y_LOCATIONS = {
AT_BOTTOM: 393,
AT_CENTER_PLAY_AREA: 249
};
// horizontal boundary locations, the left and right edges
- var X_BOUNDARY_LOCATIONS = {
+ const X_BOUNDARY_LOCATIONS = {
AT_LEFT_EDGE: 67,
AT_RIGHT_EDGE: 701
};
// vertical boundary locations, the top and bottom edges
- var Y_BOUNDARY_LOCATIONS = {
+ const Y_BOUNDARY_LOCATIONS = {
AT_TOP: 111,
AT_BOTTOM: 393
};
// landmark ranges that surround critical x locations, but more are added below that depend on these ranges
- var atNearSweaterRange = createLandmarkRange( X_LOCATIONS.AT_NEAR_SWEATER );
- var atCenterPlayAreaRange = createLandmarkRange( X_LOCATIONS.AT_CENTER_PLAY_AREA );
- var atNearWallRange = createLandmarkRange( X_LOCATIONS.AT_NEAR_WALL );
- var atNearRightEdgeRange = createLandmarkRange( X_LOCATIONS.AT_NEAR_RIGHT_EDGE );
+ const atNearSweaterRange = createLandmarkRange( X_LOCATIONS.AT_NEAR_SWEATER );
+ const atCenterPlayAreaRange = createLandmarkRange( X_LOCATIONS.AT_CENTER_PLAY_AREA );
+ const atNearWallRange = createLandmarkRange( X_LOCATIONS.AT_NEAR_WALL );
+ const atNearRightEdgeRange = createLandmarkRange( X_LOCATIONS.AT_NEAR_RIGHT_EDGE );
// special ranges with slightly different widths, but that behave just like a landmark in the play area
// at 'very close to sweater' landmark which extends to the left off the 'near sweater' landmark until we hit the
// sweater
- var atVeryCloseToSweaterRange = new Range( atNearSweaterRange.min - LANDMARK_WIDTH, atNearSweaterRange.min );
+ const atVeryCloseToSweaterRange = new Range( atNearSweaterRange.min - LANDMARK_WIDTH, atNearSweaterRange.min );
// at 'very close to wall' landmark which extends to the right off the 'near wall' landmark until just before we hit
// the wall
- var atVeryCloseToWallRange = new Range( atNearWallRange.max, X_LOCATIONS.AT_WALL - 1 );
+ const atVeryCloseToWallRange = new Range( atNearWallRange.max, X_LOCATIONS.AT_WALL - 1 );
// at 'very close to right edge' landmark, which extends to right of the 'near right edge' landmark until just before
// we hit the right edge
- var atVeryCloseToRightEdgeRange = new Range( atNearRightEdgeRange.max, X_BOUNDARY_LOCATIONS.AT_RIGHT_EDGE - 1 );
- var LANDMARK_RANGES = {
+ const atVeryCloseToRightEdgeRange = new Range( atNearRightEdgeRange.max, X_BOUNDARY_LOCATIONS.AT_RIGHT_EDGE - 1 );
+ const LANDMARK_RANGES = {
AT_NEAR_SWEATER: atNearSweaterRange,
AT_CENTER_PLAY_AREA: atCenterPlayAreaRange,
AT_NEAR_WALL: atNearWallRange,
@@ -82,15 +82,15 @@ define( require => {
};
// ranges that define columns in the play area, exact widths chosen by inspection to match mockup provided in #222
- var leftArmRange = createNextRange( 138 );
- var leftSideOfSweaterRange = createNextRange( 65, leftArmRange );
- var rightSideOfSweaterRange = createNextRange( 67, leftSideOfSweaterRange );
- var rightArmRange = createNextRange( 65, rightSideOfSweaterRange );
- var leftPlayAreaRange = createNextRange( 132, rightArmRange );
- var centerPlayAreaRange = createNextRange( 77, leftPlayAreaRange );
- var rightPlayAreaRange = createNextRange( 132, centerPlayAreaRange );
- var rightEdgeRange = createNextRange( 500, rightPlayAreaRange ); // extends far beyond the play area bounds
- var COLUMN_RANGES = {
+ const leftArmRange = createNextRange( 138 );
+ const leftSideOfSweaterRange = createNextRange( 65, leftArmRange );
+ const rightSideOfSweaterRange = createNextRange( 67, leftSideOfSweaterRange );
+ const rightArmRange = createNextRange( 65, rightSideOfSweaterRange );
+ const leftPlayAreaRange = createNextRange( 132, rightArmRange );
+ const centerPlayAreaRange = createNextRange( 77, leftPlayAreaRange );
+ const rightPlayAreaRange = createNextRange( 132, centerPlayAreaRange );
+ const rightEdgeRange = createNextRange( 500, rightPlayAreaRange ); // extends far beyond the play area bounds
+ const COLUMN_RANGES = {
LEFT_ARM: leftArmRange,
LEFT_SIDE_OF_SWEATER: leftSideOfSweaterRange,
RIGHT_SIDE_OF_SWEATER: rightSideOfSweaterRange,
@@ -102,10 +102,10 @@ define( require => {
};
// ranges that define the rows of the play area, exact heights chosen by inspection to match mockup in #222
- var upperPlayAreaRange = createNextRange( 172 );
- var centerPlayAreaRowRange = createNextRange( 154, upperPlayAreaRange );
- var lowerPlayAreaRange = createNextRange( 500, centerPlayAreaRowRange );
- var ROW_RANGES = {
+ const upperPlayAreaRange = createNextRange( 172 );
+ const centerPlayAreaRowRange = createNextRange( 154, upperPlayAreaRange );
+ const lowerPlayAreaRange = createNextRange( 500, centerPlayAreaRowRange );
+ const ROW_RANGES = {
UPPER_PLAY_AREA: upperPlayAreaRange,
CENTER_PLAY_AREA: centerPlayAreaRowRange,
LOWER_PLAY_AREA: lowerPlayAreaRange
@@ -129,14 +129,14 @@ define( require => {
* @returns {string}
*/
getPlayAreaColumn: function( location, wallVisible ) {
- var columns = COLUMN_RANGES;
+ const columns = COLUMN_RANGES;
// loop through keys manually to prevent a many closures from being created during object iteration in 'for in'
// loops
- var columnsKeys = Object.keys( columns );
+ const columnsKeys = Object.keys( columns );
- var column;
- for ( var i = 0; i < columnsKeys.length; i++ ) {
+ let column;
+ for ( let i = 0; i < columnsKeys.length; i++ ) {
if ( columns[ columnsKeys[ i ] ].contains( location.x ) ) {
column = columnsKeys[ i ];
}
@@ -158,14 +158,14 @@ define( require => {
* @returns {string}
*/
getPlayAreaLandmark: function( location, wallVisible ) {
- var landmarks = LANDMARK_RANGES;
+ const landmarks = LANDMARK_RANGES;
// loop through keys manually to prevent a many closures from being created during object iteration in 'for in'
// loops
- var landmarksKeys = Object.keys( landmarks );
+ const landmarksKeys = Object.keys( landmarks );
- var landmark = null;
- for ( var i = 0; i < landmarksKeys.length; i++ ) {
+ let landmark = null;
+ for ( let i = 0; i < landmarksKeys.length; i++ ) {
if ( landmarks[ landmarksKeys[ i ] ].contains( location.x ) ) {
landmark = landmarksKeys[ i ];
}
@@ -186,13 +186,13 @@ define( require => {
* @returns {strint}
*/
getPlayAreaRow: function( location ) {
- var rows = PlayAreaMap.ROW_RANGES;
+ const rows = PlayAreaMap.ROW_RANGES;
// loop through keys manually to prevent a many closures from being created during object iteration in 'for in' loops
- var rowKeys = Object.keys( rows );
+ const rowKeys = Object.keys( rows );
- var row;
- var i;
+ let row;
+ let i;
for ( i = 0; i < rowKeys.length; i++ ) {
if ( rows[ rowKeys[ i ] ].contains( location.y ) ) {
row = rowKeys[ i ];
@@ -211,12 +211,12 @@ define( require => {
* @returns {boolean}
*/
inLandmarkColumn: function( location ) {
- var landmarks = PlayAreaMap.LANDMARK_RANGES;
+ const landmarks = PlayAreaMap.LANDMARK_RANGES;
// loop through keys manually to prevent many closures from being created during object iteration in for loops
- var landmarkKeys = Object.keys( landmarks );
- var inLandmarkColumn = false;
- for( var i = 0; i < landmarkKeys.length; i++ ) {
+ const landmarkKeys = Object.keys( landmarks );
+ let inLandmarkColumn = false;
+ for( let i = 0; i < landmarkKeys.length; i++ ) {
if ( landmarks[ landmarkKeys[ i ] ].contains( location.x ) ) {
inLandmarkColumn = true;
break;
@@ -239,7 +239,7 @@ define( require => {
* @returns {Range}
*/
function createNextRange( width, previousRange ) {
- var min = previousRange ? previousRange.max : 0;
+ const min = previousRange ? previousRange.max : 0;
return new Range( min, min + width );
}
diff --git a/js/balloons-and-static-electricity/model/PointChargeModel.js b/js/balloons-and-static-electricity/model/PointChargeModel.js
index d7b0a7ec..660ce42b 100644
--- a/js/balloons-and-static-electricity/model/PointChargeModel.js
+++ b/js/balloons-and-static-electricity/model/PointChargeModel.js
@@ -19,10 +19,10 @@ define( require => {
const Vector2 = require( 'DOT/Vector2' );
// constants
- var RADIUS = 8;
+ const RADIUS = 8;
//1,754 = 100/57 - to get relevant to original java model, where we have 100 sweater's charges (in this model only 57 )
- var CHARGE = -1.754;
+ const CHARGE = -1.754;
/**
* @constructor
diff --git a/js/balloons-and-static-electricity/model/SweaterModel.js b/js/balloons-and-static-electricity/model/SweaterModel.js
index 4e500e8c..b9f92fa5 100644
--- a/js/balloons-and-static-electricity/model/SweaterModel.js
+++ b/js/balloons-and-static-electricity/model/SweaterModel.js
@@ -19,7 +19,7 @@ define( require => {
const Vector2 = require( 'DOT/Vector2' );
// positions of the charge pairs, in absolute model coordinates (i.e. not relative to the sweater position)
- var CHARGE_PAIR_POSITIONS = [
+ const CHARGE_PAIR_POSITIONS = [
new Vector2( 104, 64 ),
new Vector2( 94, 90 ),
new Vector2( 85, 121 ),
@@ -99,7 +99,7 @@ define( require => {
phetioReadOnly: true
} );
- var self = this;
+ const self = this;
// @public
this.x = x;
@@ -119,14 +119,14 @@ define( require => {
// https://github.com/phetsims/balloons-and-static-electricity/issues/240. This algorithm works by dividing the
// unit circle into a set of slices and finding the charge location that is furthest from the center in that
// slice, then building a shape from that set of points.
- var numSlices = 9; // this number can be adjusted to get a more refined shape to enclose the charges
- var shapeDefiningPoints = [];
- var sliceWidth = ( 2 * Math.PI ) / numSlices; // in radians
+ const numSlices = 9; // this number can be adjusted to get a more refined shape to enclose the charges
+ const shapeDefiningPoints = [];
+ const sliceWidth = ( 2 * Math.PI ) / numSlices; // in radians
_.times( numSlices ).forEach( function( sliceNumber ) {
shapeDefiningPoints.push( self.center.copy() );
- var slice = new Range( sliceNumber * sliceWidth, ( sliceNumber + 1 ) * sliceWidth );
+ const slice = new Range( sliceNumber * sliceWidth, ( sliceNumber + 1 ) * sliceWidth );
CHARGE_PAIR_POSITIONS.forEach( function( chargePairPosition ) {
- var angle = chargePairPosition.minus( self.center ).angle;
+ let angle = chargePairPosition.minus( self.center ).angle;
// convert negative angles
if ( angle < 0 ) {
@@ -146,7 +146,7 @@ define( require => {
// @public {Shape} - area on the sweater where charges exist
this.chargedArea = new Shape().moveToPoint( shapeDefiningPoints[ 0 ] );
- for ( var i = 1; i < shapeDefiningPoints.length; i++ ) {
+ for ( let i = 1; i < shapeDefiningPoints.length; i++ ) {
this.chargedArea.lineToPoint( shapeDefiningPoints[ i ] );
}
this.chargedArea.close();
@@ -155,10 +155,10 @@ define( require => {
this.plusCharges = [];
this.minusCharges = [];
- var plusChargesGroupTandem = tandem.createGroupTandem( 'plusCharges' );
- var minusChargesGroupTandem = tandem.createGroupTandem( 'minusCharges' );
+ const plusChargesGroupTandem = tandem.createGroupTandem( 'plusCharges' );
+ const minusChargesGroupTandem = tandem.createGroupTandem( 'minusCharges' );
CHARGE_PAIR_POSITIONS.forEach( function( chargePairPosition ) {
- var plusCharge = new PointChargeModel(
+ const plusCharge = new PointChargeModel(
chargePairPosition.x,
chargePairPosition.y,
plusChargesGroupTandem.createNextTandem(),
@@ -167,7 +167,7 @@ define( require => {
self.plusCharges.push( plusCharge );
//minus
- var minusCharge = new PointChargeModel(
+ const minusCharge = new PointChargeModel(
chargePairPosition.x + PointChargeModel.RADIUS,
chargePairPosition.y + PointChargeModel.RADIUS,
minusChargesGroupTandem.createNextTandem(),
@@ -192,10 +192,10 @@ define( require => {
* @returns {boolean} chargeMoved - was a charge moved to the balloon?
*/
checkAndTransferCharges: function( balloon ) {
- var self = this;
+ const self = this;
// track whether or not at least once charge was moved
- var chargeMoved = false;
+ let chargeMoved = false;
// check each minus charge to see whether it should be moved to the balloon
this.minusCharges.forEach( function( minusCharge ) {
diff --git a/js/balloons-and-static-electricity/model/WallModel.js b/js/balloons-and-static-electricity/model/WallModel.js
index 9272cb31..9390bdb7 100644
--- a/js/balloons-and-static-electricity/model/WallModel.js
+++ b/js/balloons-and-static-electricity/model/WallModel.js
@@ -20,7 +20,7 @@ define( require => {
// constants
// when charge displacement is larger than this, there is an appreciable induced charge
- var FORCE_MAGNITUDE_THRESHOLD = 2;
+ const FORCE_MAGNITUDE_THRESHOLD = 2;
/**
* @constructor
@@ -52,22 +52,22 @@ define( require => {
// @private {array.}
this.plusCharges = [];
- var plusChargesTandemGroup = tandem.createGroupTandem( 'plusCharges' );
+ const plusChargesTandemGroup = tandem.createGroupTandem( 'plusCharges' );
// @private {array.}
this.minusCharges = [];
- var minusChargesTandemGroup = tandem.createGroupTandem( 'minusCharges' );
+ const minusChargesTandemGroup = tandem.createGroupTandem( 'minusCharges' );
- for ( var i = 0; i < this.numX; i++ ) {
- for ( var k = 0; k < this.numY; k++ ) {
+ for ( let i = 0; i < this.numX; i++ ) {
+ for ( let k = 0; k < this.numY; k++ ) {
//plus
- var position = this.calculatePosition( i, k );
- var plusCharge = new PointChargeModel( x + position[ 0 ], position[ 1 ], plusChargesTandemGroup.createNextTandem(), false );
+ const position = this.calculatePosition( i, k );
+ const plusCharge = new PointChargeModel( x + position[ 0 ], position[ 1 ], plusChargesTandemGroup.createNextTandem(), false );
this.plusCharges.push( plusCharge );
//minus
- var minusCharge = new MovablePointChargeModel(
+ const minusCharge = new MovablePointChargeModel(
x + position[ 0 ] - PointChargeModel.RADIUS,
position[ 1 ] - PointChargeModel.RADIUS,
minusChargesTandemGroup.createNextTandem(),
@@ -77,20 +77,20 @@ define( require => {
}
}
- var self = this;
- var updateChargePositions = function() {
+ const self = this;
+ const updateChargePositions = function() {
// value for k for calculating forces, chosen so that motion of the balloon looks like Java version
- var k = 10000;
+ const k = 10000;
// calculate force from Balloon to each charge in the wall, we subtract by the PointChargeModel radius
// to make the force look correct because each charge is minus charge is shifted down by that much initially
self.minusCharges.forEach( function( entry ) {
- var ch = entry;
- var dv1 = new Vector2( 0, 0 );
- var dv2 = new Vector2( 0, 0 );
+ const ch = entry;
+ let dv1 = new Vector2( 0, 0 );
+ let dv2 = new Vector2( 0, 0 );
- var defaultLocation = ch.locationProperty.initialValue;
+ const defaultLocation = ch.locationProperty.initialValue;
if ( yellowBalloon.isVisibleProperty.get() ) {
dv1 = BalloonModel.getForce(
defaultLocation,
@@ -121,11 +121,11 @@ define( require => {
// if a balloon was stuck to the wall and visible when the wall becomes invisible, we need to
// notify that the balloon was released by reseting the timer
- var balloons = [ yellowBalloon, greenBalloon ];
+ const balloons = [ yellowBalloon, greenBalloon ];
this.isVisibleProperty.link( function( isVisible ) {
if ( !isVisible ) {
- for ( var i = 0; i < balloons.length; i++ ) {
- var balloon = balloons[ i ];
+ for ( let i = 0; i < balloons.length; i++ ) {
+ const balloon = balloons[ i ];
if ( balloon.isVisibleProperty.get() && balloon.rightAtWallLocation() && balloon.isCharged() ) {
balloon.timeSinceRelease = 0;
}
@@ -157,7 +157,7 @@ define( require => {
* @returns {Array.} - an array containing the x and y values for the charge
*/
calculatePosition: function( i, k ) {
- var y0 = i % 2 === 0 ? this.dy / 2 : 1;
+ const y0 = i % 2 === 0 ? this.dy / 2 : 1;
return [ i * this.dx + PointChargeModel.RADIUS + 1, k * this.dy + y0 ];
},
@@ -168,16 +168,16 @@ define( require => {
* @returns {MovablePointChargeModel}
*/
getClosestChargeToBalloon: function( balloon ) {
- var minusCharges = this.minusCharges;
+ const minusCharges = this.minusCharges;
// get the minus charge that is closest to the balloon
- var closestCharge = null;
- var chargeDistance = Number.POSITIVE_INFINITY;
- var balloonChargeCenter = balloon.getChargeCenter();
+ let closestCharge = null;
+ let chargeDistance = Number.POSITIVE_INFINITY;
+ const balloonChargeCenter = balloon.getChargeCenter();
- for ( var i = 0; i < minusCharges.length; i++ ) {
+ for ( let i = 0; i < minusCharges.length; i++ ) {
var charge = minusCharges[ i ];
- var newChargeDistance = charge.locationProperty.initialValue.distance( balloonChargeCenter );
+ const newChargeDistance = charge.locationProperty.initialValue.distance( balloonChargeCenter );
if ( newChargeDistance < chargeDistance ) {
chargeDistance = newChargeDistance;
diff --git a/js/balloons-and-static-electricity/view/BASESummaryNode.js b/js/balloons-and-static-electricity/view/BASESummaryNode.js
index b609a979..cc35b41e 100644
--- a/js/balloons-and-static-electricity/view/BASESummaryNode.js
+++ b/js/balloons-and-static-electricity/view/BASESummaryNode.js
@@ -24,30 +24,30 @@ define( require => {
const WallDescriber = require( 'BALLOONS_AND_STATIC_ELECTRICITY/balloons-and-static-electricity/view/describers/WallDescriber' );
// a11y strings
- var grabBalloonToPlayString = BASEA11yStrings.grabBalloonToPlay.value;
- var andARemovableWallString = BASEA11yStrings.andARemovableWall.value;
- var aSweaterString = BASEA11yStrings.aSweater.value;
- var andASweaterString = BASEA11yStrings.andASweater.value;
- var roomObjectsPatternString = BASEA11yStrings.roomObjectsPattern.value;
- var aYellowBalloonString = BASEA11yStrings.aYellowBalloon.value;
- var aGreenBalloonString = BASEA11yStrings.aGreenBalloon.value;
- var summaryBalloonChargePatternString = BASEA11yStrings.summaryBalloonChargePattern.value;
- var summaryEachBalloonChargePatternString = BASEA11yStrings.summaryEachBalloonChargePattern.value;
- var zeroString = BASEA11yStrings.zero.value;
- var summaryObjectsHaveChargePatternString = BASEA11yStrings.summaryObjectsHaveChargePattern.value;
- var summarySweaterAndWallString = BASEA11yStrings.summarySweaterAndWall.value;
- var summarySweaterWallPatternString = BASEA11yStrings.summarySweaterWallPattern.value;
- var summarySecondBalloonInducingChargePatternString = BASEA11yStrings.summarySecondBalloonInducingChargePattern.value;
- var summaryBothBalloonsPatternString = BASEA11yStrings.summaryBothBalloonsPattern.value;
- var summaryObjectEachHasPatternString = BASEA11yStrings.summaryObjectEachHasPattern.value;
- var summaryObjectEachPatternString = BASEA11yStrings.summaryObjectEachPattern.value;
- var singleStatementPatternString = BASEA11yStrings.singleStatementPattern.value;
- var summaryYellowGreenSweaterWallPatternString = BASEA11yStrings.summaryYellowGreenSweaterWallPattern.value;
- var summaryYellowGreenSweaterPatternString = BASEA11yStrings.summaryYellowGreenSweaterPattern.value;
- var summaryYellowSweaterWallPatternString = BASEA11yStrings.summaryYellowSweaterWallPattern.value;
- var summaryYellowSweaterPatternString = BASEA11yStrings.summaryYellowSweaterPattern.value;
- var initialObjectLocationsString = BASEA11yStrings.initialObjectLocations.value;
- var simOpeningString = BASEA11yStrings.simOpening.value;
+ const grabBalloonToPlayString = BASEA11yStrings.grabBalloonToPlay.value;
+ const andARemovableWallString = BASEA11yStrings.andARemovableWall.value;
+ const aSweaterString = BASEA11yStrings.aSweater.value;
+ const andASweaterString = BASEA11yStrings.andASweater.value;
+ const roomObjectsPatternString = BASEA11yStrings.roomObjectsPattern.value;
+ const aYellowBalloonString = BASEA11yStrings.aYellowBalloon.value;
+ const aGreenBalloonString = BASEA11yStrings.aGreenBalloon.value;
+ const summaryBalloonChargePatternString = BASEA11yStrings.summaryBalloonChargePattern.value;
+ const summaryEachBalloonChargePatternString = BASEA11yStrings.summaryEachBalloonChargePattern.value;
+ const zeroString = BASEA11yStrings.zero.value;
+ const summaryObjectsHaveChargePatternString = BASEA11yStrings.summaryObjectsHaveChargePattern.value;
+ const summarySweaterAndWallString = BASEA11yStrings.summarySweaterAndWall.value;
+ const summarySweaterWallPatternString = BASEA11yStrings.summarySweaterWallPattern.value;
+ const summarySecondBalloonInducingChargePatternString = BASEA11yStrings.summarySecondBalloonInducingChargePattern.value;
+ const summaryBothBalloonsPatternString = BASEA11yStrings.summaryBothBalloonsPattern.value;
+ const summaryObjectEachHasPatternString = BASEA11yStrings.summaryObjectEachHasPattern.value;
+ const summaryObjectEachPatternString = BASEA11yStrings.summaryObjectEachPattern.value;
+ const singleStatementPatternString = BASEA11yStrings.singleStatementPattern.value;
+ const summaryYellowGreenSweaterWallPatternString = BASEA11yStrings.summaryYellowGreenSweaterWallPattern.value;
+ const summaryYellowGreenSweaterPatternString = BASEA11yStrings.summaryYellowGreenSweaterPattern.value;
+ const summaryYellowSweaterWallPatternString = BASEA11yStrings.summaryYellowSweaterWallPattern.value;
+ const summaryYellowSweaterPatternString = BASEA11yStrings.summaryYellowSweaterPattern.value;
+ const initialObjectLocationsString = BASEA11yStrings.initialObjectLocations.value;
+ const simOpeningString = BASEA11yStrings.simOpening.value;
/**
* @constructor
@@ -59,7 +59,7 @@ define( require => {
*/
function BASESummaryNode( model, yellowBalloonNode, greenBalloonNode, wallNode, tandem ) {
- var self = this;
+ const self = this;
Node.call( this, {
tandem: tandem
@@ -77,16 +77,16 @@ define( require => {
this.wall = model.wall;
// opening paragraph for the simulation
- var openingSummaryNode = new Node( { tagName: 'p', innerContent: simOpeningString } );
+ const openingSummaryNode = new Node( { tagName: 'p', innerContent: simOpeningString } );
this.addChild( openingSummaryNode );
// list of dynamic description content that will update with the state of the simulation
- var listNode = new Node( { tagName: 'ul' } );
- var roomObjectsNode = new Node( { tagName: 'li' } );
- var objectLocationsNode = new Node( { tagName: 'li', innerContent: initialObjectLocationsString } );
- var balloonChargeNode = new Node( { tagName: 'li' } );
- var sweaterWallChargeNode = new Node( { tagName: 'li' } );
- var inducedChargeNode = new Node( { tagName: 'li' } );
+ const listNode = new Node( { tagName: 'ul' } );
+ const roomObjectsNode = new Node( { tagName: 'li' } );
+ const objectLocationsNode = new Node( { tagName: 'li', innerContent: initialObjectLocationsString } );
+ const balloonChargeNode = new Node( { tagName: 'li' } );
+ const sweaterWallChargeNode = new Node( { tagName: 'li' } );
+ const inducedChargeNode = new Node( { tagName: 'li' } );
// structure the accessible content
this.addChild( listNode );
@@ -102,9 +102,9 @@ define( require => {
roomObjectsNode.innerContent = BASESummaryNode.getVisibleObjectsDescription( balloonVisible, wallVisible );
} );
- var chargeProperties = [ this.yellowBalloon.chargeProperty, this.greenBalloon.chargeProperty, this.greenBalloon.isVisibleProperty, model.showChargesProperty, model.wall.isVisibleProperty ];
+ const chargeProperties = [ this.yellowBalloon.chargeProperty, this.greenBalloon.chargeProperty, this.greenBalloon.isVisibleProperty, model.showChargesProperty, model.wall.isVisibleProperty ];
Property.multilink( chargeProperties, function( yellowBalloonCharge, greenBalloonCharge, greenBalloonVisible, showCharges, wallVisible ) {
- var chargesVisible = showCharges !== 'none';
+ const chargesVisible = showCharges !== 'none';
balloonChargeNode.accessibleVisible = chargesVisible;
sweaterWallChargeNode.accessibleVisible = chargesVisible;
@@ -115,12 +115,12 @@ define( require => {
}
} );
- var inducedChargeProperties = [ this.yellowBalloon.locationProperty, this.greenBalloon.locationProperty, this.greenBalloon.isVisibleProperty, model.showChargesProperty, model.wall.isVisibleProperty ];
+ const inducedChargeProperties = [ this.yellowBalloon.locationProperty, this.greenBalloon.locationProperty, this.greenBalloon.isVisibleProperty, model.showChargesProperty, model.wall.isVisibleProperty ];
Property.multilink( inducedChargeProperties, function( yellowLocation, greenLocation, greenVisible, showCharges, wallVisible ) {
// the induced charge item is only available if one balloon is visible, inducing charge, and showCharges setting is set to 'all'
- var inducingCharge = self.yellowBalloon.inducingChargeAndVisible() || self.greenBalloon.inducingChargeAndVisible();
- var showInducingItem = inducingCharge && wallVisible && showCharges === 'all';
+ const inducingCharge = self.yellowBalloon.inducingChargeAndVisible() || self.greenBalloon.inducingChargeAndVisible();
+ const showInducingItem = inducingCharge && wallVisible && showCharges === 'all';
inducedChargeNode.accessibleVisible = showInducingItem;
if ( showInducingItem ) {
@@ -136,7 +136,7 @@ define( require => {
self.greenBalloon.isVisibleProperty,
model.wall.isVisibleProperty
], function( yellowLocation, greenLocation, greenVisible, wallVisible ) {
- var initialValues = self.yellowBalloon.locationProperty.initialValue === yellowLocation &&
+ const initialValues = self.yellowBalloon.locationProperty.initialValue === yellowLocation &&
self.greenBalloon.locationProperty.initialValue === greenLocation &&
self.greenBalloon.isVisibleProperty.initialValue === greenVisible &&
model.wall.isVisibleProperty.initialValue === wallVisible;
@@ -163,21 +163,21 @@ define( require => {
* @returns {string}
*/
getSweaterAndWallChargeDescription: function() {
- var description;
+ let description;
- var chargesShown = this.model.showChargesProperty.get();
- var wallVisible = this.model.wall.isVisibleProperty.get();
- var numberOfWallCharges = this.model.wall.numX * this.model.wall.numY;
- var wallChargeString = BASEDescriber.getNeutralChargesShownDescription( chargesShown, numberOfWallCharges );
+ const chargesShown = this.model.showChargesProperty.get();
+ const wallVisible = this.model.wall.isVisibleProperty.get();
+ const numberOfWallCharges = this.model.wall.numX * this.model.wall.numY;
+ const wallChargeString = BASEDescriber.getNeutralChargesShownDescription( chargesShown, numberOfWallCharges );
// if sweater has neutral charge, describe the sweater and wall together
if ( this.model.sweater.chargeProperty.get() === 0 && wallVisible ) {
- var chargedObjectsString = StringUtils.fillIn( summaryObjectsHaveChargePatternString, {
+ const chargedObjectsString = StringUtils.fillIn( summaryObjectsHaveChargePatternString, {
objects: summarySweaterAndWallString,
charge: zeroString
} );
- var patternString = chargesShown === 'all' ? summaryObjectEachHasPatternString : summaryObjectEachPatternString;
+ const patternString = chargesShown === 'all' ? summaryObjectEachHasPatternString : summaryObjectEachPatternString;
// both have same described charge, can be described with wallChargeString
description = StringUtils.fillIn( patternString, {
@@ -186,11 +186,11 @@ define( require => {
} );
}
else {
- var sweaterSummaryString = SweaterDescriber.getSummaryChargeDescription( chargesShown, this.model.sweater.chargeProperty.get() );
+ const sweaterSummaryString = SweaterDescriber.getSummaryChargeDescription( chargesShown, this.model.sweater.chargeProperty.get() );
// if the wall is visible, it also gets its own description
if ( wallVisible ) {
- var wallSummaryString = WallDescriber.getSummaryChargeDescription( chargesShown, numberOfWallCharges );
+ const wallSummaryString = WallDescriber.getSummaryChargeDescription( chargesShown, numberOfWallCharges );
description = StringUtils.fillIn( summarySweaterWallPatternString, {
sweater: sweaterSummaryString,
wall: wallSummaryString
@@ -214,13 +214,13 @@ define( require => {
* @returns {string}
*/
getBalloonChargeDescription: function() {
- var description;
+ let description;
- var yellowChargeRange = BASEDescriber.getDescribedChargeRange( this.yellowBalloon.chargeProperty.get() );
- var greenChargeRange = BASEDescriber.getDescribedChargeRange( this.greenBalloon.chargeProperty.get() );
+ const yellowChargeRange = BASEDescriber.getDescribedChargeRange( this.yellowBalloon.chargeProperty.get() );
+ const greenChargeRange = BASEDescriber.getDescribedChargeRange( this.greenBalloon.chargeProperty.get() );
- var yellowRelativeCharge = this.yellowBalloonDescriber.chargeDescriber.getSummaryRelativeChargeDescription();
- var yellowNetCharge = this.yellowBalloonDescriber.chargeDescriber.getNetChargeDescriptionWithLabel();
+ const yellowRelativeCharge = this.yellowBalloonDescriber.chargeDescriber.getSummaryRelativeChargeDescription();
+ const yellowNetCharge = this.yellowBalloonDescriber.chargeDescriber.getNetChargeDescriptionWithLabel();
if ( !this.greenBalloon.isVisibleProperty.get() ) {
description = StringUtils.fillIn( summaryBalloonChargePatternString, {
@@ -231,7 +231,7 @@ define( require => {
else if ( this.greenBalloon.isVisibleProperty.get() && yellowChargeRange.equals( greenChargeRange ) ) {
// both balloons visible have the same charge, describe charge together
- var eachNetCharge = BASEDescriber.getNetChargeDescriptionWithLabel( this.yellowBalloon.chargeProperty.get() );
+ const eachNetCharge = BASEDescriber.getNetChargeDescriptionWithLabel( this.yellowBalloon.chargeProperty.get() );
description = StringUtils.fillIn( summaryBalloonChargePatternString, {
balloonCharge: eachNetCharge,
@@ -241,14 +241,14 @@ define( require => {
else {
// both balloons visible with different amounts of relative charge
- var greenRelativeCharge = this.greenBalloonDescriber.chargeDescriber.getSummaryRelativeChargeDescription();
- var greenNetCharge = this.greenBalloonDescriber.chargeDescriber.getNetChargeDescriptionWithLabel();
+ const greenRelativeCharge = this.greenBalloonDescriber.chargeDescriber.getSummaryRelativeChargeDescription();
+ const greenNetCharge = this.greenBalloonDescriber.chargeDescriber.getNetChargeDescriptionWithLabel();
- var yellowBalloonDescription = StringUtils.fillIn( summaryBalloonChargePatternString, {
+ const yellowBalloonDescription = StringUtils.fillIn( summaryBalloonChargePatternString, {
balloonCharge: yellowNetCharge,
showingCharge: yellowRelativeCharge
} );
- var greenBalloonDescription = StringUtils.fillIn( summaryBalloonChargePatternString, {
+ const greenBalloonDescription = StringUtils.fillIn( summaryBalloonChargePatternString, {
balloonCharge: greenNetCharge,
showingCharge: greenRelativeCharge
} );
@@ -272,21 +272,21 @@ define( require => {
* @returns {string}
*/
getInducedChargeDescription: function() {
- var description;
+ let description;
- var yellowBalloon = this.yellowBalloon;
- var yellowBalloonDescriber = this.yellowBalloonDescriber;
- var yellowBalloonLabel = yellowBalloonDescriber.accessibleName;
+ const yellowBalloon = this.yellowBalloon;
+ const yellowBalloonDescriber = this.yellowBalloonDescriber;
+ const yellowBalloonLabel = yellowBalloonDescriber.accessibleName;
- var greenBalloon = this.greenBalloon;
- var greenBalloonDescriber = this.greenBalloonDescriber;
- var greenBalloonLabel = greenBalloonDescriber.accessibleName;
+ const greenBalloon = this.greenBalloon;
+ const greenBalloonDescriber = this.greenBalloonDescriber;
+ const greenBalloonLabel = greenBalloonDescriber.accessibleName;
- var greenInducingChargeAndVisilbe = greenBalloon.inducingChargeAndVisible();
- var yellowInducingChargeAndVisible = yellowBalloon.inducingChargeAndVisible();
+ const greenInducingChargeAndVisilbe = greenBalloon.inducingChargeAndVisible();
+ const yellowInducingChargeAndVisible = yellowBalloon.inducingChargeAndVisible();
assert && assert( greenInducingChargeAndVisilbe || yellowInducingChargeAndVisible );
- var wallVisible = this.model.wall.isVisibleProperty.get();
+ const wallVisible = this.model.wall.isVisibleProperty.get();
if ( greenInducingChargeAndVisilbe && yellowInducingChargeAndVisible ) {
@@ -303,14 +303,14 @@ define( require => {
else {
// full description for yellow balloon
- var yellowBalloonDescription = WallDescriber.getInducedChargeDescription( yellowBalloon, yellowBalloonLabel, wallVisible, {
+ const yellowBalloonDescription = WallDescriber.getInducedChargeDescription( yellowBalloon, yellowBalloonLabel, wallVisible, {
includeWallLocation: false,
includePositiveChargeInfo: false
} );
// short summary for green balloon
- var inducedChargeAmount = WallDescriber.getInducedChargeAmountDescription( greenBalloon );
- var greenBalloonDescription = StringUtils.fillIn( summarySecondBalloonInducingChargePatternString, {
+ const inducedChargeAmount = WallDescriber.getInducedChargeAmountDescription( greenBalloon );
+ const greenBalloonDescription = StringUtils.fillIn( summarySecondBalloonInducingChargePatternString, {
amount: inducedChargeAmount
} );
@@ -351,7 +351,7 @@ define( require => {
* @returns {string}
*/
getVisibleObjectsDescription: function( balloonVisible, wallVisible ) {
- var patternString;
+ let patternString;
if ( wallVisible ) {
patternString = balloonVisible ? summaryYellowGreenSweaterWallPatternString : summaryYellowSweaterWallPatternString;
}
@@ -359,8 +359,8 @@ define( require => {
patternString = balloonVisible ? summaryYellowGreenSweaterPatternString : summaryYellowSweaterPatternString;
}
- var sweaterString = wallVisible ? aSweaterString : andASweaterString;
- var descriptionString = StringUtils.fillIn( patternString, {
+ const sweaterString = wallVisible ? aSweaterString : andASweaterString;
+ const descriptionString = StringUtils.fillIn( patternString, {
yellowBalloon: aYellowBalloonString,
greenBalloon: aGreenBalloonString,
sweater: sweaterString,
diff --git a/js/balloons-and-static-electricity/view/BASESummaryNodeTests.js b/js/balloons-and-static-electricity/view/BASESummaryNodeTests.js
index ba75b3d1..a1f3e532 100644
--- a/js/balloons-and-static-electricity/view/BASESummaryNodeTests.js
+++ b/js/balloons-and-static-electricity/view/BASESummaryNodeTests.js
@@ -21,21 +21,21 @@ define( require => {
QUnit.module( 'BASESummaryNode' );
// create model and view for testing
- var model = new BASEModel( 768, 504, Tandem.rootTandem.createTandem( 'model' ) );
- var view = new BASEView( model, Tandem.rootTandem.createTandem( 'view' ) );
+ const model = new BASEModel( 768, 504, Tandem.rootTandem.createTandem( 'model' ) );
+ const view = new BASEView( model, Tandem.rootTandem.createTandem( 'view' ) );
// create a wallNode for testing
- var wallNode = new WallNode( model, view.layoutBounds, Tandem.rootTandem.createTandem( 'wallNode' ) );
+ const wallNode = new WallNode( model, view.layoutBounds, Tandem.rootTandem.createTandem( 'wallNode' ) );
QUnit.test( 'Summary tests', function( assert ) {
- var summaryNode = new BASESummaryNode( model, view.yellowBalloonNode, view.greenBalloonNode, wallNode, Tandem.rootTandem.createTandem( 'summaryNode' ) );
+ const summaryNode = new BASESummaryNode( model, view.yellowBalloonNode, view.greenBalloonNode, wallNode, Tandem.rootTandem.createTandem( 'summaryNode' ) );
// verify first item in summary, description of items in the room
model.reset();
// on load, yellow balloon, sweater, and removable wall
- var expectedFirstItem = 'Currently, room has a yellow balloon, a sweater, and a removable wall.';
- var actualFirstItem = BASESummaryNode.getVisibleObjectsDescription( model.greenBalloon.isVisibleProperty.get(), model.wall.isVisibleProperty.get() );
+ let expectedFirstItem = 'Currently, room has a yellow balloon, a sweater, and a removable wall.';
+ let actualFirstItem = BASESummaryNode.getVisibleObjectsDescription( model.greenBalloon.isVisibleProperty.get(), model.wall.isVisibleProperty.get() );
assert.equal( actualFirstItem, expectedFirstItem, 'first summary item incorrect on load' );
// yellow balloon and sweater
@@ -61,8 +61,8 @@ define( require => {
model.reset();
// on load
- var expectedSecondItem = 'Yellow Balloon has zero net charge, a few pairs of negative and positive charges.';
- var actualSecondItem = summaryNode.getBalloonChargeDescription();
+ let expectedSecondItem = 'Yellow Balloon has zero net charge, a few pairs of negative and positive charges.';
+ let actualSecondItem = summaryNode.getBalloonChargeDescription();
assert.equal( actualSecondItem, expectedSecondItem );
// when both balloons are visible
@@ -111,8 +111,8 @@ define( require => {
model.reset();
// on load
- var expectedThirdItem = 'Sweater and wall have zero net charge, each has many pairs of negative and positive charges.';
- var actualThirdItem = summaryNode.getSweaterAndWallChargeDescription();
+ let expectedThirdItem = 'Sweater and wall have zero net charge, each has many pairs of negative and positive charges.';
+ let actualThirdItem = summaryNode.getSweaterAndWallChargeDescription();
assert.equal( actualThirdItem, expectedThirdItem );
// when wall is invisible
@@ -147,8 +147,8 @@ define( require => {
model.reset();
model.yellowBalloon.chargeProperty.set( -20 );
model.yellowBalloon.setCenter( new Vector2( PlayAreaMap.X_LOCATIONS.AT_WALL, model.yellowBalloon.getCenter().y ) );
- var expectedFourthItem = 'Negative charges in wall move away from Yellow Balloon a lot. Positive charges do not move.';
- var actualFourthItem = summaryNode.getInducedChargeDescription();
+ let expectedFourthItem = 'Negative charges in wall move away from Yellow Balloon a lot. Positive charges do not move.';
+ let actualFourthItem = summaryNode.getInducedChargeDescription();
assert.equal( actualFourthItem, expectedFourthItem );
// test both balloons when they are adjacent
diff --git a/js/balloons-and-static-electricity/view/BASEView.js b/js/balloons-and-static-electricity/view/BASEView.js
index 6a3183cc..10a34cc1 100644
--- a/js/balloons-and-static-electricity/view/BASEView.js
+++ b/js/balloons-and-static-electricity/view/BASEView.js
@@ -29,15 +29,15 @@ define( require => {
const WallNode = require( 'BALLOONS_AND_STATIC_ELECTRICITY/balloons-and-static-electricity/view/WallNode' );
// a11y strings
- var greenBalloonLabelString = BASEA11yStrings.greenBalloonLabel.value;
- var yellowBalloonLabelString = BASEA11yStrings.yellowBalloonLabel.value;
+ const greenBalloonLabelString = BASEA11yStrings.greenBalloonLabel.value;
+ const yellowBalloonLabelString = BASEA11yStrings.yellowBalloonLabel.value;
// images
const balloonGreen = require( 'image!BALLOONS_AND_STATIC_ELECTRICITY/balloon-green.png' );
const balloonYellow = require( 'image!BALLOONS_AND_STATIC_ELECTRICITY/balloon-yellow.png' );
// constants
- var BALLOON_TIE_POINT_HEIGHT = 14; // empirically determined
+ const BALLOON_TIE_POINT_HEIGHT = 14; // empirically determined
/**
* @constructor
@@ -46,15 +46,15 @@ define( require => {
*/
function BASEView( model, tandem ) {
- var self = this;
+ const self = this;
ScreenView.call( this, {
layoutBounds: new Bounds2( 0, 0, 768, 504 ),
tandem: tandem
} );
- var sweaterNode = new SweaterNode( model, tandem.createTandem( 'sweaterNode' ) );
- var wallNode = new WallNode( model, this.layoutBounds.height, tandem.createTandem( 'wall' ) );
+ const sweaterNode = new SweaterNode( model, tandem.createTandem( 'sweaterNode' ) );
+ const wallNode = new WallNode( model, this.layoutBounds.height, tandem.createTandem( 'wall' ) );
this.playAreaNode.addChild( sweaterNode );
this.playAreaNode.addChild( wallNode );
@@ -69,7 +69,7 @@ define( require => {
) );
//Add black to the left of the screen to match the black region to the right of the wall
- var maxX = this.layoutBounds.maxX - model.wall.x - wallNode.wallNode.width;
+ const maxX = this.layoutBounds.maxX - model.wall.x - wallNode.wallNode.width;
this.addChild( new Rectangle(
maxX - 1000,
0,
@@ -78,12 +78,12 @@ define( require => {
{ fill: 'black', tandem: tandem.createTandem( 'spaceToLeftOfWall' ) }
) );
- var controlPanel = new ControlPanel( model, this.layoutBounds, tandem.createTandem( 'controlPanel' ) );
+ const controlPanel = new ControlPanel( model, this.layoutBounds, tandem.createTandem( 'controlPanel' ) );
this.yellowBalloonNode = new BalloonNode( model.yellowBalloon, balloonYellow, model, yellowBalloonLabelString, greenBalloonLabelString, this.layoutBounds, tandem.createTandem( 'yellowBalloonNode' ), {
labelContent: yellowBalloonLabelString
} );
- var tetherAnchorPoint = new Vector2(
+ const tetherAnchorPoint = new Vector2(
model.yellowBalloon.locationProperty.get().x + 30, // a bit to the side of directly below the starting position
this.layoutBounds.height
);
@@ -104,12 +104,12 @@ define( require => {
);
// created after all other view objects so we can access each describer
- var screenSummaryNode = new BASESummaryNode( model, this.yellowBalloonNode, this.greenBalloonNode, wallNode, tandem.createTandem( 'screenSummaryNode' ) );
+ const screenSummaryNode = new BASESummaryNode( model, this.yellowBalloonNode, this.greenBalloonNode, wallNode, tandem.createTandem( 'screenSummaryNode' ) );
this.setScreenSummaryContent( screenSummaryNode );
// combine the balloon content into single nodes so that they are easily layerable
- var greenBalloonLayerNode = new Node( { children: [ this.greenBalloonTetherNode, this.greenBalloonNode ] } );
- var yellowBalloonLayerNode = new Node( { children: [ this.yellowBalloonTetherNode, this.yellowBalloonNode ] } );
+ const greenBalloonLayerNode = new Node( { children: [ this.greenBalloonTetherNode, this.greenBalloonNode ] } );
+ const yellowBalloonLayerNode = new Node( { children: [ this.yellowBalloonTetherNode, this.yellowBalloonNode ] } );
this.playAreaNode.addChild( yellowBalloonLayerNode );
this.playAreaNode.addChild( greenBalloonLayerNode );
@@ -172,11 +172,11 @@ define( require => {
layout: function( width, height ) {
this.resetTransform();
- var scale = this.getLayoutScale( width, height );
+ const scale = this.getLayoutScale( width, height );
this.setScaleMagnitude( scale );
- var dx = 0;
- var offsetY = 0;
+ let dx = 0;
+ let offsetY = 0;
// Move to bottom vertically (custom for this sim)
if ( scale === width / this.layoutBounds.width ) {
diff --git a/js/balloons-and-static-electricity/view/BalloonInteractionCueNode.js b/js/balloons-and-static-electricity/view/BalloonInteractionCueNode.js
index ec2e2ee4..09749ce4 100644
--- a/js/balloons-and-static-electricity/view/BalloonInteractionCueNode.js
+++ b/js/balloons-and-static-electricity/view/BalloonInteractionCueNode.js
@@ -23,16 +23,16 @@ define( require => {
const VBox = require( 'SCENERY/nodes/VBox' );
// constants
- var ARROW_HEIGHT = 15; // dimensions for the arrow icons
- var KEY_HEIGHT = 24; // height of the arrow key, larger than default KeyNode height
- var ARROW_WIDTH = 1 / 2 * Math.sqrt( 3 ) * ARROW_HEIGHT; // for equilateral triangle
- var TEXT_KEY_OPTIONS = { font: new PhetFont( 14 ), forceSquareKey: true, keyHeight: KEY_HEIGHT };
- var KEY_ARROW_SPACING = 2;
- var BALLOON_KEY_SPACING = 8;
- var SHADOW_WIDTH = 2;
+ const ARROW_HEIGHT = 15; // dimensions for the arrow icons
+ const KEY_HEIGHT = 24; // height of the arrow key, larger than default KeyNode height
+ const ARROW_WIDTH = 1 / 2 * Math.sqrt( 3 ) * ARROW_HEIGHT; // for equilateral triangle
+ const TEXT_KEY_OPTIONS = { font: new PhetFont( 14 ), forceSquareKey: true, keyHeight: KEY_HEIGHT };
+ const KEY_ARROW_SPACING = 2;
+ const BALLOON_KEY_SPACING = 8;
+ const SHADOW_WIDTH = 2;
// possible directions or the directional cues
- var DIRECTION_ANGLES = {
+ const DIRECTION_ANGLES = {
up: 0,
down: Math.PI,
left: -Math.PI / 2,
@@ -51,13 +51,13 @@ define( require => {
Node.call( this );
// create the help node for the WASD and arrow keys, invisible except for on the initial balloon pick up
- var directionKeysParent = new Node();
+ const directionKeysParent = new Node();
this.addChild( directionKeysParent );
- var wNode = this.createMovementKeyNode( 'up' );
- var aNode = this.createMovementKeyNode( 'left' );
- var sNode = this.createMovementKeyNode( 'down' );
- var dNode = this.createMovementKeyNode( 'right' );
+ const wNode = this.createMovementKeyNode( 'up' );
+ const aNode = this.createMovementKeyNode( 'left' );
+ const sNode = this.createMovementKeyNode( 'down' );
+ const dNode = this.createMovementKeyNode( 'right' );
directionKeysParent.addChild( wNode );
directionKeysParent.addChild( aNode );
@@ -69,7 +69,7 @@ define( require => {
Property.multilink( [ balloonModel.locationProperty, model.wall.isVisibleProperty ], function( location, visible ) {
// get the max x locations depending on if the wall is visible
- var centerXRightBoundary;
+ let centerXRightBoundary;
if ( visible ) {
centerXRightBoundary = PlayAreaMap.X_LOCATIONS.AT_WALL;
}
@@ -77,7 +77,7 @@ define( require => {
centerXRightBoundary = PlayAreaMap.X_BOUNDARY_LOCATIONS.AT_RIGHT_EDGE;
}
- var balloonCenter = balloonModel.getCenter();
+ const balloonCenter = balloonModel.getCenter();
aNode.visible = balloonCenter.x !== PlayAreaMap.X_BOUNDARY_LOCATIONS.AT_LEFT_EDGE;
sNode.visible = balloonCenter.y !== PlayAreaMap.Y_BOUNDARY_LOCATIONS.AT_BOTTOM;
dNode.visible = balloonCenter.x !== centerXRightBoundary;
@@ -85,7 +85,7 @@ define( require => {
} );
// place the direction cues relative to the balloon bounds
- var balloonBounds = balloonModel.bounds;
+ const balloonBounds = balloonModel.bounds;
wNode.centerBottom = balloonBounds.getCenterTop().plusXY( 0, -BALLOON_KEY_SPACING );
aNode.rightCenter = balloonBounds.getLeftCenter().plusXY( -BALLOON_KEY_SPACING, 0 );
sNode.centerTop = balloonBounds.getCenterBottom().plusXY( 0, BALLOON_KEY_SPACING + SHADOW_WIDTH );
@@ -106,9 +106,9 @@ define( require => {
createMovementKeyNode: function( direction ) {
// create the arrow icon
- var arrowShape = new Shape();
+ const arrowShape = new Shape();
arrowShape.moveTo( ARROW_HEIGHT / 2, 0 ).lineTo( ARROW_HEIGHT, ARROW_WIDTH ).lineTo( 0, ARROW_WIDTH ).close();
- var arrowIcon = new Path( arrowShape, {
+ const arrowIcon = new Path( arrowShape, {
fill: 'white',
stroke: 'black',
lineJoin: 'bevel',
@@ -118,8 +118,8 @@ define( require => {
} );
// create the letter key nodes and place in the correct layout box
- var keyIcon;
- var box;
+ let keyIcon;
+ let box;
if ( direction === 'up' ) {
keyIcon = new LetterKeyNode( 'W', TEXT_KEY_OPTIONS );
box = new VBox( { children: [ arrowIcon, keyIcon ], spacing: KEY_ARROW_SPACING } );
diff --git a/js/balloons-and-static-electricity/view/BalloonNode.js b/js/balloons-and-static-electricity/view/BalloonNode.js
index 5aa454dd..6b38af40 100644
--- a/js/balloons-and-static-electricity/view/BalloonNode.js
+++ b/js/balloons-and-static-electricity/view/BalloonNode.js
@@ -40,10 +40,10 @@ define( require => {
const Vector2 = require( 'DOT/Vector2' );
// a11y - critical x locations for the balloon
- var X_LOCATIONS = PlayAreaMap.X_LOCATIONS;
+ const X_LOCATIONS = PlayAreaMap.X_LOCATIONS;
// a11y strings
- var grabBalloonHelpString = BASEA11yStrings.grabBalloonHelp.value;
+ const grabBalloonHelpString = BASEA11yStrings.grabBalloonHelp.value;
/**
* Constructor for the balloon
@@ -60,7 +60,7 @@ define( require => {
* @constructor
*/
function BalloonNode( model, imgsrc, globalModel, accessibleLabelString, otherAccessibleLabelString, layoutBounds, tandem, options ) {
- var self = this;
+ const self = this;
options = _.extend( {
cursor: 'pointer',
@@ -89,13 +89,13 @@ define( require => {
// @private - the utterance to be sent to the utteranceQueue when a jumping action occurs
this.jumpingUtterance = new Utterance();
- var originalChargesNode = new Node( {
+ const originalChargesNode = new Node( {
pickable: false,
tandem: tandem.createTandem( 'originalChargesNode' )
} );
- var addedChargesNode = new Node( { pickable: false, tandem: tandem.createTandem( 'addedChargesNode' ) } );
+ const addedChargesNode = new Node( { pickable: false, tandem: tandem.createTandem( 'addedChargesNode' ) } );
- var property = {
+ const property = {
//Set only to the legal positions in the frame
set: function( location ) { model.locationProperty.set( globalModel.checkBalloonRestrictions( location, model.width, model.height ) ); },
@@ -108,14 +108,14 @@ define( require => {
* Finish a drag interaction by updating the Property tracking that the balloon is dragged and resetting
* velocities.
*/
- var endDragListener = function() {
+ const endDragListener = function() {
model.isDraggedProperty.set( false );
model.velocityProperty.set( new Vector2( 0, 0 ) );
model.dragVelocityProperty.set( new Vector2( 0, 0 ) );
};
//When dragging, move the balloon
- var dragHandler = new MovableDragHandler( property, {
+ const dragHandler = new MovableDragHandler( property, {
//When dragging across it in a mobile device, pick it up
allowTouchSnag: true,
@@ -135,7 +135,7 @@ define( require => {
this.addInputListener( dragHandler );
- var balloonImageNode = new Image( imgsrc, {
+ const balloonImageNode = new Image( imgsrc, {
tandem: tandem.createTandem( 'balloonImageNode' ),
pickable: false // custom touch areas applied to parent
} );
@@ -148,16 +148,16 @@ define( require => {
this.touchArea = this.mouseArea;
// static charges
- var plusChargeNodesTandemGroup = tandem.createGroupTandem( 'plusChargeNodes' );
- var minusChargeNodesTandemGroup = tandem.createGroupTandem( 'minusChargeNodes' );
+ const plusChargeNodesTandemGroup = tandem.createGroupTandem( 'plusChargeNodes' );
+ const minusChargeNodesTandemGroup = tandem.createGroupTandem( 'minusChargeNodes' );
for ( var i = 0; i < model.plusCharges.length; i++ ) {
- var plusChargeNode = new PlusChargeNode(
+ const plusChargeNode = new PlusChargeNode(
model.plusCharges[ i ].location,
plusChargeNodesTandemGroup.createNextTandem()
);
originalChargesNode.addChild( plusChargeNode );
- var minusChargeNode = new MinusChargeNode(
+ const minusChargeNode = new MinusChargeNode(
model.minusCharges[ i ].location,
minusChargeNodesTandemGroup.createNextTandem()
);
@@ -165,10 +165,10 @@ define( require => {
}
//possible charges
- var addedNodes = []; // track in a local array to update visibility with charge
- var addedChargeNodesTandemGroup = tandem.createGroupTandem( 'addedChargeNodes' );
+ const addedNodes = []; // track in a local array to update visibility with charge
+ const addedChargeNodesTandemGroup = tandem.createGroupTandem( 'addedChargeNodes' );
for ( i = model.plusCharges.length; i < model.minusCharges.length; i++ ) {
- var addedMinusChargeNode = new MinusChargeNode(
+ const addedMinusChargeNode = new MinusChargeNode(
model.minusCharges[ i ].location,
addedChargeNodesTandemGroup.createNextTandem()
);
@@ -182,9 +182,9 @@ define( require => {
//if change charge, show more minus charges
model.chargeProperty.link( function updateCharge( chargeVal ) {
- var numVisibleMinusCharges = Math.abs( chargeVal );
+ const numVisibleMinusCharges = Math.abs( chargeVal );
- for ( var i = 0; i < addedNodes.length; i++ ) {
+ for ( let i = 0; i < addedNodes.length; i++ ) {
addedNodes[ i ].visible = i < numVisibleMinusCharges;
}
} );
@@ -201,7 +201,7 @@ define( require => {
addedChargesNode.visible = true;
}
else {
- var visiblity = ( value === 'all' );
+ const visiblity = ( value === 'all' );
originalChargesNode.visible = visiblity;
addedChargesNode.visible = visiblity;
}
@@ -212,7 +212,7 @@ define( require => {
// a11y - when the balloon charge, location, or model.showChargesProperty changes, the balloon needs a new
// description for assistive technology
- var updateAccessibleDescription = function() {
+ const updateAccessibleDescription = function() {
self.descriptionContent = self.describer.getBalloonDescription( model );
};
model.locationProperty.link( updateAccessibleDescription );
@@ -244,12 +244,12 @@ define( require => {
// made visible when the balloon is picked up with a keyboard for the first time to show how a user can drag with
// a keyboard
- var interactionCueNode = new BalloonInteractionCueNode( globalModel, model, this, layoutBounds );
+ const interactionCueNode = new BalloonInteractionCueNode( globalModel, model, this, layoutBounds );
interactionCueNode.center = balloonImageNode.center;
// attach the GrabDragInteraction to the image node, which is a child of this node so that the accessible
// content for the interaction is underneath this node
- var grabDragInteraction = new GrabDragInteraction( balloonImageNode, {
+ const grabDragInteraction = new GrabDragInteraction( balloonImageNode, {
objectToGrabString: accessibleLabelString,
dragCueNode: interactionCueNode,
@@ -320,7 +320,7 @@ define( require => {
} );
if ( BASEQueryParameters.showBalloonChargeCenter ) {
- var parentToLocalChargeCenter = this.parentToLocalPoint( model.getChargeCenter() );
+ const parentToLocalChargeCenter = this.parentToLocalPoint( model.getChargeCenter() );
this.addChild( new Rectangle( 0, 0, 5, 5, { fill: 'green', center: parentToLocalChargeCenter } ) );
this.addChild( new Line( -500, parentToLocalChargeCenter.y, 500, parentToLocalChargeCenter.y, { stroke: 'green' } ) );
}
@@ -378,7 +378,7 @@ define( require => {
},
getAttemptedMovementDirection: function( keyCode ) {
- var direction;
+ let direction;
if ( KeyboardDragListener.isLeftMovementKey( keyCode ) ) {
direction = BalloonDirectionEnum.LEFT;
}
@@ -397,9 +397,9 @@ define( require => {
},
getDragBounds: function() {
- var modelBounds = this.globalModel.playAreaBounds;
- var balloonWidth = this.model.width;
- var balloonHeight = this.model.height;
+ const modelBounds = this.globalModel.playAreaBounds;
+ const balloonWidth = this.model.width;
+ const balloonHeight = this.model.height;
return new Bounds2( modelBounds.minX, modelBounds.minY, modelBounds.maxX - balloonWidth, modelBounds.maxY - balloonHeight );
}
} );
diff --git a/js/balloons-and-static-electricity/view/ControlPanel.js b/js/balloons-and-static-electricity/view/ControlPanel.js
index 3baf228d..92afed0b 100644
--- a/js/balloons-and-static-electricity/view/ControlPanel.js
+++ b/js/balloons-and-static-electricity/view/ControlPanel.js
@@ -46,26 +46,26 @@ define( require => {
const resetBalloonString = require( 'string!BALLOONS_AND_STATIC_ELECTRICITY/resetBalloon' );
// a11y strings
- var twoBalloonExperimentLabelString = BASEA11yStrings.twoBalloonExperimentLabel.value;
- var chargeSettingsLabelString = BASEA11yStrings.chargeSettingsLabel.value;
- var chargeSettingsDescriptionString = BASEA11yStrings.chargeSettingsDescription.value;
- var showAllChargesAlertString = BASEA11yStrings.showAllChargesAlert.value;
- var shoNoChargesAlertString = BASEA11yStrings.shoNoChargesAlert.value;
- var showChargeDifferencesAlertString = BASEA11yStrings.showChargeDifferencesAlert.value;
- var removeWallDescriptionString = BASEA11yStrings.removeWallDescription.value;
- var twoBalloonExperimentDescriptionString = BASEA11yStrings.twoBalloonExperimentDescription.value;
- var resetBalloonsAlertPatternString = BASEA11yStrings.resetBalloonsAlertPattern.value;
- var balloonString = BASEA11yStrings.balloon.value;
- var balloonsString = BASEA11yStrings.balloons.value;
- var wallAddedString = BASEA11yStrings.wallAdded.value;
- var wallRemovedString = BASEA11yStrings.wallRemoved.value;
- var positionsString = BASEA11yStrings.positions.value;
- var positionString = BASEA11yStrings.position.value;
- var resetBalloonsDescriptionPatternString = BASEA11yStrings.resetBalloonsDescriptionPattern.value;
+ const twoBalloonExperimentLabelString = BASEA11yStrings.twoBalloonExperimentLabel.value;
+ const chargeSettingsLabelString = BASEA11yStrings.chargeSettingsLabel.value;
+ const chargeSettingsDescriptionString = BASEA11yStrings.chargeSettingsDescription.value;
+ const showAllChargesAlertString = BASEA11yStrings.showAllChargesAlert.value;
+ const shoNoChargesAlertString = BASEA11yStrings.shoNoChargesAlert.value;
+ const showChargeDifferencesAlertString = BASEA11yStrings.showChargeDifferencesAlert.value;
+ const removeWallDescriptionString = BASEA11yStrings.removeWallDescription.value;
+ const twoBalloonExperimentDescriptionString = BASEA11yStrings.twoBalloonExperimentDescription.value;
+ const resetBalloonsAlertPatternString = BASEA11yStrings.resetBalloonsAlertPattern.value;
+ const balloonString = BASEA11yStrings.balloon.value;
+ const balloonsString = BASEA11yStrings.balloons.value;
+ const wallAddedString = BASEA11yStrings.wallAdded.value;
+ const wallRemovedString = BASEA11yStrings.wallRemoved.value;
+ const positionsString = BASEA11yStrings.positions.value;
+ const positionString = BASEA11yStrings.position.value;
+ const resetBalloonsDescriptionPatternString = BASEA11yStrings.resetBalloonsDescriptionPattern.value;
// constants
- var BOTTOM_CONTROL_SPACING = 10;
- var CONTROLS_FONT = new PhetFont( 15 );
+ const BOTTOM_CONTROL_SPACING = 10;
+ const CONTROLS_FONT = new PhetFont( 15 );
/**
* @constructor
@@ -77,14 +77,14 @@ define( require => {
// super constructor
Node.call( this );
- var self = this;
+ const self = this;
// content for Add/Remove wall button.
- var addWallText = new MultiLineText( addWallString, {
+ const addWallText = new MultiLineText( addWallString, {
font: CONTROLS_FONT,
tandem: tandem.createTandem( 'addWallText' )
} );
- var removeWallText = new MultiLineText( removeWallString, {
+ const removeWallText = new MultiLineText( removeWallString, {
font: CONTROLS_FONT,
center: addWallText.center,
tandem: tandem.createTandem( 'removeWallText' )
@@ -108,16 +108,16 @@ define( require => {
model.wall.isVisibleProperty.lazyLink( function( wallVisible ) {
self.wallButton.innerContent = model.wall.isVisibleProperty.get() ? removeWallString : addWallString;
- var alertDescription = wallVisible ? wallAddedString : wallRemovedString;
+ const alertDescription = wallVisible ? wallAddedString : wallRemovedString;
utteranceQueue.addToBack( alertDescription );
} );
// Radio buttons related to charges
- var RADIO_BUTTON_TEXT_OPTIONS = {
+ const RADIO_BUTTON_TEXT_OPTIONS = {
font: CONTROLS_FONT,
maxWidth: 200
};
- var showChargesRadioButtonGroup = new VerticalAquaRadioButtonGroup( model.showChargesProperty, [ {
+ const showChargesRadioButtonGroup = new VerticalAquaRadioButtonGroup( model.showChargesProperty, [ {
node: new Text(
balloonAppletShowAllChargesString,
_.extend( { tandem: tandem.createTandem( 'allCharges' ) }, RADIO_BUTTON_TEXT_OPTIONS )
@@ -155,7 +155,7 @@ define( require => {
// a11y - announce an alert that describes the state of charge visibility, linked lazily
// so that we don't get any alerts on sim startup
model.showChargesProperty.lazyLink( function( value ) {
- var alertString;
+ let alertString;
if ( value === 'all' ) {
alertString = showAllChargesAlertString;
}
@@ -171,10 +171,10 @@ define( require => {
} );
// Radio buttons for selecting 1 vs 2 balloons
- var scale = 0.14;
- var yellowBalloonImage = new Image( balloonYellow, { tandem: tandem.createTandem( 'yellowBalloonImage' ) } );
- var twoBalloonIconTandem = tandem.createTandem( 'twoBalloonIcon' );
- var twoBalloonIcon = new Node( {
+ const scale = 0.14;
+ const yellowBalloonImage = new Image( balloonYellow, { tandem: tandem.createTandem( 'yellowBalloonImage' ) } );
+ const twoBalloonIconTandem = tandem.createTandem( 'twoBalloonIcon' );
+ const twoBalloonIcon = new Node( {
children: [
new Image( balloonGreen, { x: 160, tandem: twoBalloonIconTandem.createTandem( 'greenBalloonImage' ) } ),
yellowBalloonImage
@@ -183,8 +183,8 @@ define( require => {
tandem: twoBalloonIconTandem
} );
- var oneBalloonIconTandem = tandem.createTandem( 'oneBalloonIcon' );
- var oneBalloonIcon = new Node( {
+ const oneBalloonIconTandem = tandem.createTandem( 'oneBalloonIcon' );
+ const oneBalloonIcon = new Node( {
children: [
new Image( balloonYellow, {
x: twoBalloonIcon.width / scale / 2 - yellowBalloonImage.width / 2,
@@ -195,7 +195,7 @@ define( require => {
tandem: oneBalloonIconTandem
} );
- var showSecondBalloonSelector = new TwoSceneSelectionNode(
+ const showSecondBalloonSelector = new TwoSceneSelectionNode(
model.greenBalloon.isVisibleProperty,
false,
true,
@@ -212,7 +212,7 @@ define( require => {
);
// 'Reset Balloons' button
- var resetBalloonToggleNode = new BooleanToggleNode(
+ const resetBalloonToggleNode = new BooleanToggleNode(
new Text( resetBalloonsString, {
font: CONTROLS_FONT,
tandem: tandem.createTandem( 'resetBalloonsText' )
@@ -224,7 +224,7 @@ define( require => {
model.greenBalloon.isVisibleProperty,
{ maxWidth: 140, tandem: tandem.createTandem( 'resetBalloonToggleNode' ) }
);
- var resetBalloonButtonListener = function() {
+ const resetBalloonButtonListener = function() {
// disable other alerts until after we are finished resetting the balloons
utteranceQueue.enabled = false;
@@ -241,7 +241,7 @@ define( require => {
balloons: model.greenBalloon.isVisibleProperty.get() ? balloonsString : balloonString
} ) );
};
- var resetBalloonButton = new RectangularPushButton( {
+ const resetBalloonButton = new RectangularPushButton( {
content: resetBalloonToggleNode,
baseColor: 'rgb( 255, 200, 0 )',
listener: resetBalloonButtonListener,
@@ -253,9 +253,9 @@ define( require => {
} );
// create the accessible description for the reset balloon button
- var generateDescriptionString = function( balloonVisible ) {
- var balloonDescriptionString = balloonVisible ? balloonsString : balloonString;
- var positionDescriptionString = balloonVisible ? positionsString : positionString;
+ const generateDescriptionString = function( balloonVisible ) {
+ const balloonDescriptionString = balloonVisible ? balloonsString : balloonString;
+ const positionDescriptionString = balloonVisible ? positionsString : positionString;
return StringUtils.fillIn( resetBalloonsDescriptionPatternString, {
balloons: balloonDescriptionString,
positions: positionDescriptionString
@@ -268,7 +268,7 @@ define( require => {
resetBalloonButton.innerContent = isVisible ? resetBalloonsString : resetBalloonString;
} );
- var balloonsPanel = new VBox( {
+ const balloonsPanel = new VBox( {
spacing: 2,
children: [ showSecondBalloonSelector, resetBalloonButton ],
@@ -279,13 +279,13 @@ define( require => {
} );
//Add the controls at the right, with the reset all button and the wall button
- var resetAllButton = new ResetAllButton( {
+ const resetAllButton = new ResetAllButton( {
listener: model.reset.bind( model ),
scale: 0.96,
tandem: tandem.createTandem( 'resetAllButton' )
} );
- var controls = new HBox( {
+ const controls = new HBox( {
spacing: 14,
align: 'bottom',
children: [ resetAllButton, this.wallButton ]
@@ -295,8 +295,8 @@ define( require => {
controls.bottom = layoutBounds.maxY - BOTTOM_CONTROL_SPACING;
controls.right = layoutBounds.maxX - 4.5;// so "Remove Wall" button looks centered with wall
- var visibilityControls;
- var controlsLeft;
+ let visibilityControls;
+ let controlsLeft;
if ( BASEQueryParameters.hideChargeControls ) {
visibilityControls = [ balloonsPanel ];
controlsLeft = layoutBounds.width / 2 - balloonsPanel.width / 2;
diff --git a/js/balloons-and-static-electricity/view/MinusChargeNode.js b/js/balloons-and-static-electricity/view/MinusChargeNode.js
index c0aef445..5c272d17 100644
--- a/js/balloons-and-static-electricity/view/MinusChargeNode.js
+++ b/js/balloons-and-static-electricity/view/MinusChargeNode.js
@@ -18,7 +18,7 @@ define( require => {
const RadialGradient = require( 'SCENERY/util/RadialGradient' );
const Rectangle = require( 'SCENERY/nodes/Rectangle' );
- var RADIUS = PointChargeModel.RADIUS;
+ const RADIUS = PointChargeModel.RADIUS;
const icon = new Node( {
children: [
@@ -37,7 +37,7 @@ define( require => {
} )
]
} );
- var sharedMinusChargeNode = icon.rasterized( { resolution: BASEConstants.IMAGE_SCALE } );
+ const sharedMinusChargeNode = icon.rasterized( { resolution: BASEConstants.IMAGE_SCALE } );
/**
* @constructor
diff --git a/js/balloons-and-static-electricity/view/MinusChargesCanvasNode.js b/js/balloons-and-static-electricity/view/MinusChargesCanvasNode.js
index 68d57972..84cf2581 100644
--- a/js/balloons-and-static-electricity/view/MinusChargesCanvasNode.js
+++ b/js/balloons-and-static-electricity/view/MinusChargesCanvasNode.js
@@ -20,12 +20,12 @@ define( require => {
// Node converted to image to be drawn in canvas - scale up the node, then back down when converting to image so it
// doesn't look fuzzy
- var scale = 3.0;
- var chargeNode = null;
+ const scale = 3.0;
+ let chargeNode = null;
// This is to prevent an instrumented phet-io instance from being created outside of a constructor,
// see https://github.com/phetsims/phet-io-wrappers/issues/97
- var getChargeNode = function() {
+ const getChargeNode = function() {
if ( !chargeNode ) {
chargeNode = new MinusChargeNode( new Vector2( 0, 0 ), Tandem.globalTandem.createTandem( 'chargeNode' ), {
scale: scale
@@ -76,12 +76,12 @@ define( require => {
context.scale( 1 / scale, 1 / scale );
// draw all of the charges
- for ( var i = 0; i < this.charges.length; i++ ) {
- var charge = this.charges[ i ];
- var chargePosition = charge.locationProperty.get();
+ for ( let i = 0; i < this.charges.length; i++ ) {
+ const charge = this.charges[ i ];
+ const chargePosition = charge.locationProperty.get();
- var xPosition = ( ( chargePosition.x - this.wallX + PointChargeModel.RADIUS - BASEConstants.IMAGE_PADDING ) * scale );
- var yPosition = ( chargePosition.y + PointChargeModel.RADIUS - BASEConstants.IMAGE_PADDING ) * scale;
+ const xPosition = ( ( chargePosition.x - this.wallX + PointChargeModel.RADIUS - BASEConstants.IMAGE_PADDING ) * scale );
+ const yPosition = ( chargePosition.y + PointChargeModel.RADIUS - BASEConstants.IMAGE_PADDING ) * scale;
// render particle
context.drawImage( this.chargeImageNode.image, xPosition, yPosition );
diff --git a/js/balloons-and-static-electricity/view/PlayAreaGridNode.js b/js/balloons-and-static-electricity/view/PlayAreaGridNode.js
index bf3fa07a..1a1ac71e 100644
--- a/js/balloons-and-static-electricity/view/PlayAreaGridNode.js
+++ b/js/balloons-and-static-electricity/view/PlayAreaGridNode.js
@@ -28,26 +28,26 @@ define( require => {
function PlayAreaGridNode( layoutBounds, tandem ) {
Node.call( this, { pickable: false } );
- var blueOptions = { fill: 'rgba(0,0,255,0.5)' };
- var greyOptions = { fill: 'rgba(200,200,200,0.5)' };
- var redOptions = { fill: 'rgba(250,0,50,0.45)' };
+ const blueOptions = { fill: 'rgba(0,0,255,0.5)' };
+ const greyOptions = { fill: 'rgba(200,200,200,0.5)' };
+ const redOptions = { fill: 'rgba(250,0,50,0.45)' };
- var columns = PlayAreaMap.COLUMN_RANGES;
- var rows = PlayAreaMap.ROW_RANGES;
- var landmarks = PlayAreaMap.LANDMARK_RANGES;
+ const columns = PlayAreaMap.COLUMN_RANGES;
+ const rows = PlayAreaMap.ROW_RANGES;
+ const landmarks = PlayAreaMap.LANDMARK_RANGES;
// draw each column
- var self = this;
- var i = 0;
- var range;
- var minValue;
- var maxValue;
+ const self = this;
+ let i = 0;
+ let range;
+ let minValue;
+ let maxValue;
for ( range in columns ) {
if ( columns.hasOwnProperty( range ) ) {
if ( i % 2 === 0 ) {
minValue = Math.max( layoutBounds.minX, columns[ range ].min );
maxValue = Math.min( layoutBounds.maxX, columns[ range ].max );
- var width = maxValue - minValue;
+ const width = maxValue - minValue;
self.addChild( new Rectangle( minValue, 0, width, PlayAreaMap.HEIGHT, blueOptions ) );
}
i++;
@@ -60,7 +60,7 @@ define( require => {
if ( i % 2 === 0 ) {
minValue = Math.max( layoutBounds.minY, rows[ range ].min );
maxValue = Math.min( layoutBounds.maxY, rows[ range ].max );
- var height = maxValue - minValue;
+ const height = maxValue - minValue;
self.addChild( new Rectangle( 0, minValue, PlayAreaMap.WIDTH, height, greyOptions ) );
}
i++;
@@ -72,16 +72,16 @@ define( require => {
if ( landmarks.hasOwnProperty( range ) ) {
minValue = Math.max( layoutBounds.minX, landmarks[ range ].min );
maxValue = Math.min( layoutBounds.maxX, landmarks[ range ].max );
- var landmarkWidth = maxValue - minValue;
+ const landmarkWidth = maxValue - minValue;
self.addChild( new Rectangle( minValue, 0, landmarkWidth, PlayAreaMap.HEIGHT, redOptions ) );
}
}
// draw the lines to along critical balloon locations along both x and y
- var lineOptions = { stroke: 'rgba(0, 0, 0,0.4)', lineWidth: 2, lineDash: [ 2, 4 ] };
- var xLocations = PlayAreaMap.X_LOCATIONS;
- var yLocations = PlayAreaMap.Y_LOCATIONS;
- var location;
+ const lineOptions = { stroke: 'rgba(0, 0, 0,0.4)', lineWidth: 2, lineDash: [ 2, 4 ] };
+ const xLocations = PlayAreaMap.X_LOCATIONS;
+ const yLocations = PlayAreaMap.Y_LOCATIONS;
+ let location;
for ( location in xLocations ) {
if ( xLocations.hasOwnProperty( location ) ) {
self.addChild( new Line( xLocations[ location ], 0, xLocations[ location ], PlayAreaMap.HEIGHT, lineOptions ) );
diff --git a/js/balloons-and-static-electricity/view/PlusChargeNode.js b/js/balloons-and-static-electricity/view/PlusChargeNode.js
index 1189322a..d5959843 100644
--- a/js/balloons-and-static-electricity/view/PlusChargeNode.js
+++ b/js/balloons-and-static-electricity/view/PlusChargeNode.js
@@ -18,7 +18,7 @@ define( require => {
const RadialGradient = require( 'SCENERY/util/RadialGradient' );
const Rectangle = require( 'SCENERY/nodes/Rectangle' );
- var RADIUS = PointChargeModel.RADIUS;
+ const RADIUS = PointChargeModel.RADIUS;
const icon = new Node( {
children: [
@@ -43,7 +43,7 @@ define( require => {
} )
]
} );
- var sharedPlusChargeNode = icon.rasterized( { resolution: BASEConstants.IMAGE_SCALE } );
+ const sharedPlusChargeNode = icon.rasterized( { resolution: BASEConstants.IMAGE_SCALE } );
/**
* @constructor
diff --git a/js/balloons-and-static-electricity/view/SweaterNode.js b/js/balloons-and-static-electricity/view/SweaterNode.js
index 52d6c810..dc0eed88 100644
--- a/js/balloons-and-static-electricity/view/SweaterNode.js
+++ b/js/balloons-and-static-electricity/view/SweaterNode.js
@@ -23,7 +23,7 @@ define( require => {
const SweaterDescriber = require( 'BALLOONS_AND_STATIC_ELECTRICITY/balloons-and-static-electricity/view/describers/SweaterDescriber' );
// a11y strings
- var sweaterLabelString = BASEA11yStrings.sweaterLabel.value;
+ const sweaterLabelString = BASEA11yStrings.sweaterLabel.value;
// images
const sweater = require( 'image!BALLOONS_AND_STATIC_ELECTRICITY/sweater.png' );
@@ -34,7 +34,7 @@ define( require => {
* @param {Tandem} tandem
*/
function SweaterNode( model, tandem ) {
- var self = this;
+ const self = this;
Node.call( this, {
pickable: false,
@@ -53,7 +53,7 @@ define( require => {
this.sweaterModel = model.sweater;
// create the sweater image
- var sweaterImageNode = new Image( sweater, { tandem: tandem.createTandem( 'sweater' ) } );
+ const sweaterImageNode = new Image( sweater, { tandem: tandem.createTandem( 'sweater' ) } );
// scale image to match model, then set position
sweaterImageNode.scale(
@@ -75,14 +75,14 @@ define( require => {
}
// draw plus and minus charges
- var plusChargeNodesTandemGroup = tandem.createGroupTandem( 'plusChargeNodes' );
- var minusChargeNodesTandemGroup = tandem.createGroupTandem( 'minusChargeNodes' );
+ const plusChargeNodesTandemGroup = tandem.createGroupTandem( 'plusChargeNodes' );
+ const minusChargeNodesTandemGroup = tandem.createGroupTandem( 'minusChargeNodes' );
this.sweaterModel.plusCharges.forEach( function( plusCharge ) {
- var plusChargeNode = new PlusChargeNode( plusCharge.location, plusChargeNodesTandemGroup.createNextTandem() );
+ const plusChargeNode = new PlusChargeNode( plusCharge.location, plusChargeNodesTandemGroup.createNextTandem() );
self.plusChargesNode.addChild( plusChargeNode );
} );
this.sweaterModel.minusCharges.forEach( function( minusCharge ) {
- var minusChargeNode = new MinusChargeNode( minusCharge.location, minusChargeNodesTandemGroup.createNextTandem() );
+ const minusChargeNode = new MinusChargeNode( minusCharge.location, minusChargeNodesTandemGroup.createNextTandem() );
self.minusChargesNode.addChild( minusChargeNode );
} );
@@ -90,7 +90,7 @@ define( require => {
this.addChild( this.minusChargesNode );
// show all, none or charge difference
- var updateChargesVisibilityOnSweater = function( value ) {
+ const updateChargesVisibilityOnSweater = function( value ) {
if ( model.showChargesProperty.get() === 'none' ) {
self.plusChargesNode.visible = false;
self.minusChargesNode.visible = false;
@@ -99,10 +99,10 @@ define( require => {
self.plusChargesNode.visible = true;
self.minusChargesNode.visible = true;
- var showAll = ( model.showChargesProperty.get() === 'all');
- for ( var i = 0; i < self.sweaterModel.minusCharges.length; i++ ) {
- var plusChargeNodes = self.plusChargesNode.children;
- var minusChargeNodes = self.minusChargesNode.children;
+ const showAll = ( model.showChargesProperty.get() === 'all');
+ for ( let i = 0; i < self.sweaterModel.minusCharges.length; i++ ) {
+ const plusChargeNodes = self.plusChargesNode.children;
+ const minusChargeNodes = self.minusChargesNode.children;
plusChargeNodes[ i ].visible = showAll ||
self.sweaterModel.minusCharges[ i ].movedProperty.get();
minusChargeNodes[ i ].visible = showAll && !self.sweaterModel.minusCharges[ i ].movedProperty.get();
@@ -111,7 +111,7 @@ define( require => {
};
// a11y - construct a type that manages descriptions depending on the state of the model
- var sweaterDescriber = new SweaterDescriber( model, this.sweaterModel );
+ const sweaterDescriber = new SweaterDescriber( model, this.sweaterModel );
Property.multilink( [ model.showChargesProperty, this.sweaterModel.chargeProperty ], function( showCharges, charge ) {
updateChargesVisibilityOnSweater( charge );
diff --git a/js/balloons-and-static-electricity/view/TetherNode.js b/js/balloons-and-static-electricity/view/TetherNode.js
index e0ce2ca2..29e30fd7 100644
--- a/js/balloons-and-static-electricity/view/TetherNode.js
+++ b/js/balloons-and-static-electricity/view/TetherNode.js
@@ -23,7 +23,7 @@ define( require => {
* @constructor
*/
function TetherNode( balloonModel, anchorPoint, tetherPointOffset, tandem ) {
- var self = this;
+ const self = this;
Path.call( this, null, {
stroke: '#000000',
@@ -32,10 +32,10 @@ define( require => {
tandem: tandem
} );
- var anchorPointCopy = anchorPoint.copy();
+ const anchorPointCopy = anchorPoint.copy();
balloonModel.locationProperty.link( function( location ) {
- var attachmentPoint = location.plus( tetherPointOffset );
+ const attachmentPoint = location.plus( tetherPointOffset );
self.shape = new Shape()
.moveToPoint( anchorPointCopy )
.quadraticCurveTo(
diff --git a/js/balloons-and-static-electricity/view/TwoSceneSelectionNode.js b/js/balloons-and-static-electricity/view/TwoSceneSelectionNode.js
index 6e35f5ce..e252a3dc 100644
--- a/js/balloons-and-static-electricity/view/TwoSceneSelectionNode.js
+++ b/js/balloons-and-static-electricity/view/TwoSceneSelectionNode.js
@@ -39,7 +39,7 @@ define( require => {
const Tandem = require( 'TANDEM/Tandem' );
// constants
- var DEFAULT_FILL = new Color( 'white' );
+ const DEFAULT_FILL = new Color( 'white' );
/**
* @constructor
@@ -115,20 +115,20 @@ define( require => {
this.enabledProperty = options.enabledProperty;
// place the nodes in an align group so that the two buttons will have identical sizing
- var buttonAlignGroup = new AlignGroup();
- var aBox = buttonAlignGroup.createBox( nodeA );
- var bBox = buttonAlignGroup.createBox( nodeB );
+ const buttonAlignGroup = new AlignGroup();
+ const aBox = buttonAlignGroup.createBox( nodeA );
+ const bBox = buttonAlignGroup.createBox( nodeB );
// use a path so that the line width can be updated
- var xMargin = options.buttonContentXMargin;
- var yMargin = options.buttonContentYMargin;
- var cornerRadius = options.cornerRadius;
+ const xMargin = options.buttonContentXMargin;
+ const yMargin = options.buttonContentYMargin;
+ const cornerRadius = options.cornerRadius;
- var aButton = new Node();
- var bButton = new Node();
+ const aButton = new Node();
+ const bButton = new Node();
// aBox.bounds === bBox.bounds since we are using AlignGroup
- var rectShape = Shape.roundRect(
+ const rectShape = Shape.roundRect(
-xMargin,
-yMargin,
aBox.width + 2 * xMargin,
@@ -136,8 +136,8 @@ define( require => {
cornerRadius,
cornerRadius
);
- var aButtonPath = new Path( rectShape );
- var bButtonPath = new Path( rectShape );
+ const aButtonPath = new Path( rectShape );
+ const bButtonPath = new Path( rectShape );
// if there should be a mask, add before the buttons
if ( options.maskFill ) {
@@ -152,7 +152,7 @@ define( require => {
aButtonPath.addChild( aBox );
bButtonPath.addChild( bBox );
- var buttonBox = new LayoutBox( {
+ const buttonBox = new LayoutBox( {
spacing: options.spacing,
orientation: options.orientation,
align: options.align,
@@ -163,13 +163,13 @@ define( require => {
// sets the styles of the buttons after an interaction, including the stroke, opacity, lineWidth, and fill,
// depending on whether or not the button is enabled
- var self = this;
- var setStyles = function( enabled ) {
+ const self = this;
+ const setStyles = function( enabled ) {
- var selectedButton;
- var deselectedButton;
- var selectedContent;
- var deselectedContent;
+ let selectedButton;
+ let deselectedButton;
+ let selectedContent;
+ let deselectedContent;
if ( property.get() === valueA ) {
selectedButton = aButtonPath;
@@ -213,48 +213,48 @@ define( require => {
setStyles( self.enabledProperty.get() );
} );
- var upFunction = function() {
- var newValue = property.get() === valueA ? valueB : valueA;
+ const upFunction = function() {
+ const newValue = property.get() === valueA ? valueB : valueA;
property.set( newValue );
setStyles( self.enabledProperty.get() );
};
// Internal emitter for the PhET-iO data stream, see https://github.com/phetsims/sun/issues/396
- var firedEmitter = new Emitter( {
+ const firedEmitter = new Emitter( {
tandem: options.tandem.createTandem( 'firedEmitter' ),
phetioEventType: EventType.USER
} );
firedEmitter.addListener( upFunction );
- var downUpListener = new DownUpListener( {
+ const downUpListener = new DownUpListener( {
up: function() {
firedEmitter.emit();
},
down: function() {
- var otherButton = property.get() === valueA ? bButtonPath : aButtonPath;
+ const otherButton = property.get() === valueA ? bButtonPath : aButtonPath;
otherButton.fill = options.pressedColor;
}
} );
// considered "checked" for accessibility when node B is selected
- var propertyListener = function( value ) {
+ const propertyListener = function( value ) {
self.setAccessibleChecked( value === valueB );
};
// listener that highlights the unselected button when mouse is over local bounds
- var highlightListener = new HighlightListener( function( target, highlight ) {
- var otherButton = property.get() === valueA ? bButtonPath : aButtonPath;
- var otherContent = property.get() === valueA ? nodeB : nodeA;
+ const highlightListener = new HighlightListener( function( target, highlight ) {
+ const otherButton = property.get() === valueA ? bButtonPath : aButtonPath;
+ const otherContent = property.get() === valueA ? nodeB : nodeA;
- var buttonOpacity = highlight ? options.overButtonOpacity : options.deselectedButtonOpacity;
- var contentOpacity = highlight ? options.overContentOpacity : options.deselectedContentOpacity;
+ const buttonOpacity = highlight ? options.overButtonOpacity : options.deselectedButtonOpacity;
+ const contentOpacity = highlight ? options.overContentOpacity : options.deselectedContentOpacity;
otherButton.opacity = buttonOpacity;
otherContent.opacity = contentOpacity;
} );
// listener that is called when the button is pressed with 'enter' or 'spacebar'
- var clickListener = { click: upFunction };
+ const clickListener = { click: upFunction };
// add listeners, to be disposed
this.addInputListener( downUpListener );
diff --git a/js/balloons-and-static-electricity/view/WallNode.js b/js/balloons-and-static-electricity/view/WallNode.js
index 0245a6a5..9b4fa954 100644
--- a/js/balloons-and-static-electricity/view/WallNode.js
+++ b/js/balloons-and-static-electricity/view/WallNode.js
@@ -23,7 +23,7 @@ define( require => {
const wallImage = require( 'image!BALLOONS_AND_STATIC_ELECTRICITY/wall.png' );
// a11y strings
- var wallLabelString = BASEA11yStrings.wallLabel.value;
+ const wallLabelString = BASEA11yStrings.wallLabel.value;
/**
* @constructor
@@ -31,11 +31,11 @@ define( require => {
* @param {Tandem} tandem
*/
function WallNode( model, layoutHeight, tandem ) {
- var self = this;
+ const self = this;
// @private
this.model = model;
- var wallModel = model.wall;
+ const wallModel = model.wall;
// manages a11y descriptions for the wall
this.wallDescriber = new WallDescriber( model );
@@ -56,21 +56,21 @@ define( require => {
this.addChild( this.wallNode );
- var plusChargesNode = new Node( { tandem: tandem.createTandem( 'plusChargesNode' ) } );
+ const plusChargesNode = new Node( { tandem: tandem.createTandem( 'plusChargesNode' ) } );
plusChargesNode.translate( -wallModel.x, 0 );
//draw plusCharges on the wall
- var plusChargeNodesTandemGroup = tandem.createGroupTandem( 'plusChargeNodes' );
+ const plusChargeNodesTandemGroup = tandem.createGroupTandem( 'plusChargeNodes' );
wallModel.plusCharges.forEach( function( entry ) {
- var plusChargeNode = new PlusChargeNode( entry.location, plusChargeNodesTandemGroup.createNextTandem() );
+ const plusChargeNode = new PlusChargeNode( entry.location, plusChargeNodesTandemGroup.createNextTandem() );
plusChargesNode.addChild( plusChargeNode );
} );
this.addChild( plusChargesNode );
// the minus charges on the wall - with Canvas for performance, bounds widened so that charges are fully
// visible in wider layouts, see #409
- var wallBounds = new Bounds2( 0, 0, wallModel.width + 20, wallModel.height );
- var minusChargesNode = new MinusChargesCanvasNode( wallModel.x, wallBounds, wallModel.minusCharges );
+ const wallBounds = new Bounds2( 0, 0, wallModel.width + 20, wallModel.height );
+ const minusChargesNode = new MinusChargesCanvasNode( wallModel.x, wallBounds, wallModel.minusCharges );
this.addChild( minusChargesNode );
wallModel.isVisibleProperty.link( function updateWallVisibility( isVisible ) {
@@ -84,7 +84,7 @@ define( require => {
} );
// a11y - when the balloons change location, update the description of the induced charge in the wall
- var updateWallDescription = function() {
+ const updateWallDescription = function() {
self.setDescriptionContent( self.wallDescriber.getWallDescription( model.yellowBalloon, model.greenBalloon, model.getBalloonsAdjacent() ) );
};
diff --git a/js/balloons-and-static-electricity/view/describers/BASEDescriber.js b/js/balloons-and-static-electricity/view/describers/BASEDescriber.js
index c95432eb..7d8d0f50 100644
--- a/js/balloons-and-static-electricity/view/describers/BASEDescriber.js
+++ b/js/balloons-and-static-electricity/view/describers/BASEDescriber.js
@@ -20,80 +20,80 @@ define( require => {
// a11y strings
// play area grid strings
- var leftShoulderOfSweaterString = BASEA11yStrings.leftShoulderOfSweater.value;
- var leftArmOfSweaterString = BASEA11yStrings.leftArmOfSweater.value;
- var bottomLeftEdgeOfSweaterString = BASEA11yStrings.bottomLeftEdgeOfSweater.value;
+ const leftShoulderOfSweaterString = BASEA11yStrings.leftShoulderOfSweater.value;
+ const leftArmOfSweaterString = BASEA11yStrings.leftArmOfSweater.value;
+ const bottomLeftEdgeOfSweaterString = BASEA11yStrings.bottomLeftEdgeOfSweater.value;
- var upperLeftSideOfSweaterString = BASEA11yStrings.upperLeftSideOfSweater.value;
- var leftSideOfSweaterString = BASEA11yStrings.leftSideOfSweater.value;
- var lowerLeftSideOfSweaterString = BASEA11yStrings.lowerLeftSideOfSweater.value;
+ const upperLeftSideOfSweaterString = BASEA11yStrings.upperLeftSideOfSweater.value;
+ const leftSideOfSweaterString = BASEA11yStrings.leftSideOfSweater.value;
+ const lowerLeftSideOfSweaterString = BASEA11yStrings.lowerLeftSideOfSweater.value;
- var upperRightSideOfSweaterString = BASEA11yStrings.upperRightSideOfSweater.value;
- var rightSideOfSweaterString = BASEA11yStrings.rightSideOfSweater.value;
- var lowerRightSideOfSweater = BASEA11yStrings.lowerRightSideOfSweater.value;
+ const upperRightSideOfSweaterString = BASEA11yStrings.upperRightSideOfSweater.value;
+ const rightSideOfSweaterString = BASEA11yStrings.rightSideOfSweater.value;
+ const lowerRightSideOfSweater = BASEA11yStrings.lowerRightSideOfSweater.value;
- var rightShoulderOfSweaterString = BASEA11yStrings.rightShoulderOfSweater.value;
- var rightArmOfSweaterString = BASEA11yStrings.rightArmOfSweater.value;
- var lowerRightArmOfSweaterString = BASEA11yStrings.lowerRightArmOfSweater.value;
+ const rightShoulderOfSweaterString = BASEA11yStrings.rightShoulderOfSweater.value;
+ const rightArmOfSweaterString = BASEA11yStrings.rightArmOfSweater.value;
+ const lowerRightArmOfSweaterString = BASEA11yStrings.lowerRightArmOfSweater.value;
- var upperLeftSideOfPlayAreaString = BASEA11yStrings.upperLeftSideOfPlayArea.value;
- var leftSideOfPlayAreaString = BASEA11yStrings.leftSideOfPlayArea.value;
- var lowerLeftSideOfPlayAreaString = BASEA11yStrings.lowerLeftSideOfPlayArea.value;
+ const upperLeftSideOfPlayAreaString = BASEA11yStrings.upperLeftSideOfPlayArea.value;
+ const leftSideOfPlayAreaString = BASEA11yStrings.leftSideOfPlayArea.value;
+ const lowerLeftSideOfPlayAreaString = BASEA11yStrings.lowerLeftSideOfPlayArea.value;
- var upperCenterOfPlayAreaString = BASEA11yStrings.upperCenterOfPlayArea.value;
- var centerOfPlayAreaString = BASEA11yStrings.centerOfPlayArea.value;
- var lowerCenterOfPlayAreaString = BASEA11yStrings.lowerCenterOfPlayArea.value;
+ const upperCenterOfPlayAreaString = BASEA11yStrings.upperCenterOfPlayArea.value;
+ const centerOfPlayAreaString = BASEA11yStrings.centerOfPlayArea.value;
+ const lowerCenterOfPlayAreaString = BASEA11yStrings.lowerCenterOfPlayArea.value;
- var upperRightSideOfPlayAreaString = BASEA11yStrings.upperRightSideOfPlayArea.value;
- var rightSideOfPlayAreaString = BASEA11yStrings.rightSideOfPlayArea.value;
- var lowerRightSideOfPlayAreaString = BASEA11yStrings.lowerRightSideOfPlayArea.value;
+ const upperRightSideOfPlayAreaString = BASEA11yStrings.upperRightSideOfPlayArea.value;
+ const rightSideOfPlayAreaString = BASEA11yStrings.rightSideOfPlayArea.value;
+ const lowerRightSideOfPlayAreaString = BASEA11yStrings.lowerRightSideOfPlayArea.value;
- var upperWallString = BASEA11yStrings.upperWall.value;
- var wallString = BASEA11yStrings.wall.value;
- var lowerWallString = BASEA11yStrings.lowerWall.value;
+ const upperWallString = BASEA11yStrings.upperWall.value;
+ const wallString = BASEA11yStrings.wall.value;
+ const lowerWallString = BASEA11yStrings.lowerWall.value;
- var upperRightEdgeOfPlayAreaString = BASEA11yStrings.upperRightEdgeOfPlayArea.value;
- var rightEdgeOfPlayAreaString = BASEA11yStrings.rightEdgeOfPlayArea.value;
- var lowerRightEdgeOfPlayAreaString = BASEA11yStrings.lowerRightEdgeOfPlayArea.value;
+ const upperRightEdgeOfPlayAreaString = BASEA11yStrings.upperRightEdgeOfPlayArea.value;
+ const rightEdgeOfPlayAreaString = BASEA11yStrings.rightEdgeOfPlayArea.value;
+ const lowerRightEdgeOfPlayAreaString = BASEA11yStrings.lowerRightEdgeOfPlayArea.value;
// charge strings
- var noString = BASEA11yStrings.no.value;
- var zeroString = BASEA11yStrings.zero.value;
- var aFewString = BASEA11yStrings.aFew.value;
- var severalString = BASEA11yStrings.several.value;
- var manyString = BASEA11yStrings.many.value;
- var negativeString = BASEA11yStrings.negative.value;
-
- var eachBalloonString = BASEA11yStrings.eachBalloon.value;
- var balloonNetChargePatternStringWithLabel = BASEA11yStrings.balloonNetChargePatternStringWithLabel.value;
-
- var landmarkNearSweaterString = BASEA11yStrings.landmarkNearSweater.value;
- var landmarkLeftEdgeString = BASEA11yStrings.landmarkLeftEdge.value;
- var landmarkNearUpperWallString = BASEA11yStrings.landmarkNearUpperWall.value;
- var landmarkNearWallString = BASEA11yStrings.landmarkNearWall.value;
- var landmarkNearLowerWallString = BASEA11yStrings.landmarkNearLowerWall.value;
- var landmarkNearUpperRightEdgeString = BASEA11yStrings.landmarkNearUpperRightEdge.value;
- var landmarkNearRightEdgeString = BASEA11yStrings.landmarkNearRightEdge.value;
- var landmarkNearLowerRightEdgeString = BASEA11yStrings.landmarkNearLowerRightEdge.value;
- var landmarkAtCenterPlayAreaString = BASEA11yStrings.landmarkAtCenterPlayArea.value;
- var landmarkAtUpperCenterPlayAreaString = BASEA11yStrings.landmarkAtUpperCenterPlayArea.value;
- var landmarkAtLowerCenterPlayAreaString = BASEA11yStrings.landmarkAtLowerCenterPlayArea.value;
-
- var upString = BASEA11yStrings.up.value;
- var leftString = BASEA11yStrings.left.value;
- var downString = BASEA11yStrings.down.value;
- var rightString = BASEA11yStrings.right.value;
- var upAndToTheRightString = BASEA11yStrings.upAndToTheRight.value;
- var upAndToTheLeftString = BASEA11yStrings.upAndToTheLeft.value;
- var downAndToTheRightString = BASEA11yStrings.downAndToTheRight.value;
- var downAndToTheLeftString = BASEA11yStrings.downAndToTheLeft.value;
+ const noString = BASEA11yStrings.no.value;
+ const zeroString = BASEA11yStrings.zero.value;
+ const aFewString = BASEA11yStrings.aFew.value;
+ const severalString = BASEA11yStrings.several.value;
+ const manyString = BASEA11yStrings.many.value;
+ const negativeString = BASEA11yStrings.negative.value;
+
+ const eachBalloonString = BASEA11yStrings.eachBalloon.value;
+ const balloonNetChargePatternStringWithLabel = BASEA11yStrings.balloonNetChargePatternStringWithLabel.value;
+
+ const landmarkNearSweaterString = BASEA11yStrings.landmarkNearSweater.value;
+ const landmarkLeftEdgeString = BASEA11yStrings.landmarkLeftEdge.value;
+ const landmarkNearUpperWallString = BASEA11yStrings.landmarkNearUpperWall.value;
+ const landmarkNearWallString = BASEA11yStrings.landmarkNearWall.value;
+ const landmarkNearLowerWallString = BASEA11yStrings.landmarkNearLowerWall.value;
+ const landmarkNearUpperRightEdgeString = BASEA11yStrings.landmarkNearUpperRightEdge.value;
+ const landmarkNearRightEdgeString = BASEA11yStrings.landmarkNearRightEdge.value;
+ const landmarkNearLowerRightEdgeString = BASEA11yStrings.landmarkNearLowerRightEdge.value;
+ const landmarkAtCenterPlayAreaString = BASEA11yStrings.landmarkAtCenterPlayArea.value;
+ const landmarkAtUpperCenterPlayAreaString = BASEA11yStrings.landmarkAtUpperCenterPlayArea.value;
+ const landmarkAtLowerCenterPlayAreaString = BASEA11yStrings.landmarkAtLowerCenterPlayArea.value;
+
+ const upString = BASEA11yStrings.up.value;
+ const leftString = BASEA11yStrings.left.value;
+ const downString = BASEA11yStrings.down.value;
+ const rightString = BASEA11yStrings.right.value;
+ const upAndToTheRightString = BASEA11yStrings.upAndToTheRight.value;
+ const upAndToTheLeftString = BASEA11yStrings.upAndToTheLeft.value;
+ const downAndToTheRightString = BASEA11yStrings.downAndToTheRight.value;
+ const downAndToTheLeftString = BASEA11yStrings.downAndToTheLeft.value;
// charge strings
- var summaryNeutralChargesPatternString = BASEA11yStrings.summaryNeutralChargesPattern.value;
- var showingNoChargesString = BASEA11yStrings.showingNoCharges.value;
+ const summaryNeutralChargesPatternString = BASEA11yStrings.summaryNeutralChargesPattern.value;
+ const showingNoChargesString = BASEA11yStrings.showingNoCharges.value;
// constants
- var LOCATION_DESCRIPTION_MAP = {
+ const LOCATION_DESCRIPTION_MAP = {
AT_LEFT_EDGE: {
UPPER_PLAY_AREA: landmarkLeftEdgeString,
CENTER_PLAY_AREA: landmarkLeftEdgeString,
@@ -202,14 +202,14 @@ define( require => {
*
* @returns {Object}
*/
- var generateDescriptionMapWithEntries = function( descriptionArray, valueRange, entries ) {
+ const generateDescriptionMapWithEntries = function( descriptionArray, valueRange, entries ) {
entries = entries || [];
- var map = {};
+ const map = {};
- var minValue = valueRange.min;
- for ( var i = 0; i < descriptionArray.length; i++ ) {
+ let minValue = valueRange.min;
+ for ( let i = 0; i < descriptionArray.length; i++ ) {
- var nextMin = minValue + valueRange.getLength() / descriptionArray.length;
+ const nextMin = minValue + valueRange.getLength() / descriptionArray.length;
map[ i ] = {};
map[ i ].description = descriptionArray[ i ];
@@ -224,7 +224,7 @@ define( require => {
}
if ( entries.length > 0 ) {
- for ( var j = 0; j < entries.length; j++ ) {
+ for ( let j = 0; j < entries.length; j++ ) {
map[ descriptionArray.length + j ] = entries[ j ];
}
}
@@ -232,14 +232,14 @@ define( require => {
return map;
};
- var relativeChargeStrings = [ aFewString, severalString, manyString ];
- var RELATIVE_CHARGE_DESCRIPTION_MAP = generateDescriptionMapWithEntries( relativeChargeStrings, new Range( 1, BASEConstants.MAX_BALLOON_CHARGE ), [ {
+ const relativeChargeStrings = [ aFewString, severalString, manyString ];
+ const RELATIVE_CHARGE_DESCRIPTION_MAP = generateDescriptionMapWithEntries( relativeChargeStrings, new Range( 1, BASEConstants.MAX_BALLOON_CHARGE ), [ {
range: new Range( 0, 0 ),
description: noString
} ] );
// maps direction to a description string
- var DIRECTION_MAP = {
+ const DIRECTION_MAP = {
UP: upString,
DOWN: downString,
LEFT: leftString,
@@ -261,23 +261,23 @@ define( require => {
*/
getLocationDescription: function( location, wallVisible ) {
- var landmarks = PlayAreaMap.LANDMARK_RANGES;
- var columns = PlayAreaMap.COLUMN_RANGES;
- var locations = PlayAreaMap.X_LOCATIONS;
- var rows = PlayAreaMap.ROW_RANGES;
+ const landmarks = PlayAreaMap.LANDMARK_RANGES;
+ const columns = PlayAreaMap.COLUMN_RANGES;
+ const locations = PlayAreaMap.X_LOCATIONS;
+ const rows = PlayAreaMap.ROW_RANGES;
// loop through keys manually to prevent a many closures from being created during object iteration in 'for in'
// loops
- var columnsKeys = Object.keys( columns );
- var rowKeys = Object.keys( rows );
- var landmarkKeys = Object.keys( landmarks );
- var locationKeys = Object.keys( locations );
+ const columnsKeys = Object.keys( columns );
+ const rowKeys = Object.keys( rows );
+ const landmarkKeys = Object.keys( landmarks );
+ const locationKeys = Object.keys( locations );
- var i;
- var currentLocation;
- var currentLandmark;
- var currentColumn;
- var currentRow;
+ let i;
+ let currentLocation;
+ let currentLandmark;
+ let currentColumn;
+ let currentRow;
// critical x locations take priority, start there
for ( i = 0; i < locationKeys.length; i++ ) {
@@ -342,13 +342,13 @@ define( require => {
getRelativeChargeDescription: function( charge ) {
// the description is mapped to the absolute value of charge
- var absCharge = Math.abs( charge );
+ const absCharge = Math.abs( charge );
- var keys = Object.keys( RELATIVE_CHARGE_DESCRIPTION_MAP );
- var description;
+ const keys = Object.keys( RELATIVE_CHARGE_DESCRIPTION_MAP );
+ let description;
- for ( var i = 0; i < keys.length; i++ ) {
- var value = RELATIVE_CHARGE_DESCRIPTION_MAP[ keys[ i ] ];
+ for ( let i = 0; i < keys.length; i++ ) {
+ const value = RELATIVE_CHARGE_DESCRIPTION_MAP[ keys[ i ] ];
if ( value.range.contains( absCharge ) ) {
description = value.description;
break;
@@ -368,12 +368,12 @@ define( require => {
*/
getDescribedChargeRange: function( charge ) {
- var describedCharge = Math.abs( charge );
- var keys = Object.keys( RELATIVE_CHARGE_DESCRIPTION_MAP );
+ const describedCharge = Math.abs( charge );
+ const keys = Object.keys( RELATIVE_CHARGE_DESCRIPTION_MAP );
- var range;
- for ( var i = 0; i < keys.length; i++ ) {
- var value = RELATIVE_CHARGE_DESCRIPTION_MAP[ keys[ i ] ];
+ let range;
+ for ( let i = 0; i < keys.length; i++ ) {
+ const value = RELATIVE_CHARGE_DESCRIPTION_MAP[ keys[ i ] ];
if ( value.range.contains( describedCharge ) ) {
range = value.range;
break;
@@ -393,11 +393,11 @@ define( require => {
* @returns {[type]} [description]
*/
getBalloonsVisibleWithSameChargeRange: function( balloonA, balloonB ) {
- var rangeA = BASEDescriber.getDescribedChargeRange( balloonA.chargeProperty.get() );
- var rangeB = BASEDescriber.getDescribedChargeRange( balloonB.chargeProperty.get() );
+ const rangeA = BASEDescriber.getDescribedChargeRange( balloonA.chargeProperty.get() );
+ const rangeB = BASEDescriber.getDescribedChargeRange( balloonB.chargeProperty.get() );
- var visibleA = balloonA.isVisibleProperty.get();
- var visibleB = balloonB.isVisibleProperty.get();
+ const visibleA = balloonA.isVisibleProperty.get();
+ const visibleB = balloonB.isVisibleProperty.get();
return rangeA.equals( rangeB ) && ( visibleA && visibleB );
},
@@ -422,7 +422,7 @@ define( require => {
* @returns {string}
*/
getNetChargeDescriptionWithLabel: function( charge ) {
- var chargeAmountString = charge < 0 ? negativeString : zeroString;
+ const chargeAmountString = charge < 0 ? negativeString : zeroString;
return StringUtils.fillIn( balloonNetChargePatternStringWithLabel, {
chargeAmount: chargeAmountString,
balloon: eachBalloonString
@@ -441,9 +441,9 @@ define( require => {
* @returns {string}
*/
getNeutralChargesShownDescription: function( chargesShown, numberOfCharges ) {
- var description;
+ let description;
- var relativeCharge = BASEDescriber.getRelativeChargeDescription( numberOfCharges );
+ const relativeCharge = BASEDescriber.getRelativeChargeDescription( numberOfCharges );
if ( chargesShown === 'all' ) {
description = StringUtils.fillIn( summaryNeutralChargesPatternString, {
amount: relativeCharge
diff --git a/js/balloons-and-static-electricity/view/describers/BalloonChargeDescriber.js b/js/balloons-and-static-electricity/view/describers/BalloonChargeDescriber.js
index 2fcd6404..663a5a80 100644
--- a/js/balloons-and-static-electricity/view/describers/BalloonChargeDescriber.js
+++ b/js/balloons-and-static-electricity/view/describers/BalloonChargeDescriber.js
@@ -23,29 +23,29 @@ define( require => {
const WallDescriber = require( 'BALLOONS_AND_STATIC_ELECTRICITY/balloons-and-static-electricity/view/describers/WallDescriber' );
// a11y strings
- var summaryBalloonNeutralChargeString = BASEA11yStrings.summaryBalloonNeutralCharge.value;
- var balloonNetChargePatternString = BASEA11yStrings.balloonNetChargePattern.value;
- var balloonZeroString = BASEA11yStrings.balloonZero.value;
- var balloonNegativeString = BASEA11yStrings.balloonNegative.value;
- var balloonRelativeChargePatternString = BASEA11yStrings.balloonRelativeChargePattern.value;
- var balloonChargeDifferencesPatternString = BASEA11yStrings.balloonChargeDifferencesPattern.value;
- var moreInducedChargePatternString = BASEA11yStrings.moreInducedChargePattern.value;
- var lessInducedChargePatternString = BASEA11yStrings.lessInducedChargePattern.value;
- var balloonRelativeChargeAllPatternString = BASEA11yStrings.balloonRelativeChargeAllPattern.value;
- var combinedChargePatternString = BASEA11yStrings.combinedChargePattern.value;
- var wallInducedChargeWithManyPairsPatternString = BASEA11yStrings.wallInducedChargeWithManyPairsPattern.value;
- var eachBalloonString = BASEA11yStrings.eachBalloon.value;
- var singleStatementPatternString = BASEA11yStrings.singleStatementPattern.value;
- var wallHasManyChargesString = BASEA11yStrings.wallHasManyCharges.value;
- var balloonHasRelativeChargePatternString = BASEA11yStrings.balloonHasRelativeChargePattern.value;
- var showingNoChargesString = BASEA11yStrings.showingNoCharges.value;
- var balloonHasNetChargePatternString = BASEA11yStrings.balloonHasNetChargePattern.value;
- var balloonNetChargePatternStringWithLabel = BASEA11yStrings.balloonNetChargePatternStringWithLabel.value;
- var moveAwayALittleMoreString = BASEA11yStrings.moveAwayALittleMore.value;
- var beginToReturnString = BASEA11yStrings.beginToReturn.value;
- var returnALittleMoreString = BASEA11yStrings.returnALittleMore.value;
- var balloonHasChargePatternString = BASEA11yStrings.balloonHasChargePattern.value;
- var balloonHasChargeShowingPatternString = BASEA11yStrings.balloonHasChargeShowingPattern.value;
+ const summaryBalloonNeutralChargeString = BASEA11yStrings.summaryBalloonNeutralCharge.value;
+ const balloonNetChargePatternString = BASEA11yStrings.balloonNetChargePattern.value;
+ const balloonZeroString = BASEA11yStrings.balloonZero.value;
+ const balloonNegativeString = BASEA11yStrings.balloonNegative.value;
+ const balloonRelativeChargePatternString = BASEA11yStrings.balloonRelativeChargePattern.value;
+ const balloonChargeDifferencesPatternString = BASEA11yStrings.balloonChargeDifferencesPattern.value;
+ const moreInducedChargePatternString = BASEA11yStrings.moreInducedChargePattern.value;
+ const lessInducedChargePatternString = BASEA11yStrings.lessInducedChargePattern.value;
+ const balloonRelativeChargeAllPatternString = BASEA11yStrings.balloonRelativeChargeAllPattern.value;
+ const combinedChargePatternString = BASEA11yStrings.combinedChargePattern.value;
+ const wallInducedChargeWithManyPairsPatternString = BASEA11yStrings.wallInducedChargeWithManyPairsPattern.value;
+ const eachBalloonString = BASEA11yStrings.eachBalloon.value;
+ const singleStatementPatternString = BASEA11yStrings.singleStatementPattern.value;
+ const wallHasManyChargesString = BASEA11yStrings.wallHasManyCharges.value;
+ const balloonHasRelativeChargePatternString = BASEA11yStrings.balloonHasRelativeChargePattern.value;
+ const showingNoChargesString = BASEA11yStrings.showingNoCharges.value;
+ const balloonHasNetChargePatternString = BASEA11yStrings.balloonHasNetChargePattern.value;
+ const balloonNetChargePatternStringWithLabel = BASEA11yStrings.balloonNetChargePatternStringWithLabel.value;
+ const moveAwayALittleMoreString = BASEA11yStrings.moveAwayALittleMore.value;
+ const beginToReturnString = BASEA11yStrings.beginToReturn.value;
+ const returnALittleMoreString = BASEA11yStrings.returnALittleMore.value;
+ const balloonHasChargePatternString = BASEA11yStrings.balloonHasChargePattern.value;
+ const balloonHasChargeShowingPatternString = BASEA11yStrings.balloonHasChargeShowingPattern.value;
/**
* @constructor
@@ -55,7 +55,7 @@ define( require => {
* @param {string} otherAccessibleName - the accessible name for the other balloon in this sim
*/
function BalloonChargeDescriber( model, balloonModel, accessibleName, otherAccessibleName ) {
- var self = this;
+ const self = this;
// @private
this.model = model;
@@ -107,7 +107,7 @@ define( require => {
* @returns {string}
*/
getNetChargeDescription: function() {
- var chargeAmountString = this.balloonModel.chargeProperty.get() < 0 ? balloonNegativeString : balloonZeroString;
+ const chargeAmountString = this.balloonModel.chargeProperty.get() < 0 ? balloonNegativeString : balloonZeroString;
return StringUtils.fillIn( balloonNetChargePatternString, {
chargeAmount: chargeAmountString
} );
@@ -121,7 +121,7 @@ define( require => {
* @returns {string}
*/
getNetChargeDescriptionWithLabel: function() {
- var chargeAmountString = this.balloonModel.chargeProperty.get() < 0 ? balloonNegativeString : balloonZeroString;
+ const chargeAmountString = this.balloonModel.chargeProperty.get() < 0 ? balloonNegativeString : balloonZeroString;
return StringUtils.fillIn( balloonNetChargePatternStringWithLabel, {
chargeAmount: chargeAmountString,
balloon: this.accessibleName
@@ -142,22 +142,22 @@ define( require => {
*/
getCombinedRelativeChargeDescription: function() {
assert && assert( this.balloonModel.isDraggedProperty.get(), 'alert should only be generated if balloon is grabbed' );
- var description;
+ let description;
// the relative charge, used in all cases
- var sameChargeRange = BASEDescriber.getBalloonsVisibleWithSameChargeRange( this.balloonModel, this.balloonModel.other );
+ const sameChargeRange = BASEDescriber.getBalloonsVisibleWithSameChargeRange( this.balloonModel, this.balloonModel.other );
- var chargesShown = this.showChargesProperty.get();
+ const chargesShown = this.showChargesProperty.get();
// if both balloons have the same charge range, describe togethehr
if ( sameChargeRange ) {
description = BalloonChargeDescriber.getRelativeChargeDescriptionWithLabel( this.balloonModel, chargesShown, eachBalloonString );
}
else {
- var grabbedBalloonDescription = BalloonChargeDescriber.getRelativeChargeDescriptionWithLabel( this.balloonModel, chargesShown, this.accessibleName );
+ const grabbedBalloonDescription = BalloonChargeDescriber.getRelativeChargeDescriptionWithLabel( this.balloonModel, chargesShown, this.accessibleName );
if ( this.model.bothBalloonsVisible() ) {
- var otherBalloonDescription = BalloonChargeDescriber.getRelativeChargeDescriptionWithLabel( this.balloonModel.other, chargesShown, this.otherAccessibleName );
+ const otherBalloonDescription = BalloonChargeDescriber.getRelativeChargeDescriptionWithLabel( this.balloonModel.other, chargesShown, this.otherAccessibleName );
description = StringUtils.fillIn( combinedChargePatternString, {
grabbedBalloon: grabbedBalloonDescription,
@@ -183,21 +183,21 @@ define( require => {
* @returns {string}
*/
getOtherObjectChargeDescription: function() {
- var inducingChargeOrTouchingWall = this.balloonModel.inducingChargeProperty.get() || this.balloonModel.touchingWall();
- var onSweater = this.balloonModel.onSweater();
+ const inducingChargeOrTouchingWall = this.balloonModel.inducingChargeProperty.get() || this.balloonModel.touchingWall();
+ const onSweater = this.balloonModel.onSweater();
assert && assert( onSweater || inducingChargeOrTouchingWall, 'only include this phrase when balloon is inducing charge or on sweater' );
- var description;
+ let description;
- var chargesShown = this.showChargesProperty.get();
+ const chargesShown = this.showChargesProperty.get();
// if balloon is inducing charge, describe that object
if ( inducingChargeOrTouchingWall ) {
- var wallVisible = this.model.wall.isVisibleProperty.get();
+ const wallVisible = this.model.wall.isVisibleProperty.get();
if ( chargesShown === 'diff' ) {
// if showing charge differences, no charges are shown, so include that information
- var balloonsAdjacent = this.model.getBalloonsAdjacent();
+ const balloonsAdjacent = this.model.getBalloonsAdjacent();
description = WallDescriber.getWallChargeDescriptionWithLabel( this.model.yellowBalloon, this.model.greenBalloon, balloonsAdjacent, wallVisible, chargesShown );
description = StringUtils.fillIn( singleStatementPatternString, { statement: description } );
}
@@ -217,7 +217,7 @@ define( require => {
else {
// touching wall, not inducing charge, wrap with punctuation for this context
- var balloonCenter = this.balloonModel.getCenter();
+ const balloonCenter = this.balloonModel.getCenter();
description = WallDescriber.getNoChangeInChargesDescription( BASEDescriber.getLocationDescription( balloonCenter, wallVisible ) );
description = StringUtils.fillIn( singleStatementPatternString, {
statement: description
@@ -252,30 +252,30 @@ define( require => {
* @returns {string}
*/
getInducedChargeChangeDescription: function() {
- var descriptionString;
+ let descriptionString;
- var wallVisible = this.model.wall.isVisibleProperty.get();
+ const wallVisible = this.model.wall.isVisibleProperty.get();
// the force between the balloon and the closest charge to the balloon in the wall
- var balloonForce = BalloonModel.getForceToClosestWallCharge( this.balloonModel );
- var forceMagnitude = balloonForce.magnitude;
+ const balloonForce = BalloonModel.getForceToClosestWallCharge( this.balloonModel );
+ const forceMagnitude = balloonForce.magnitude;
// change in force magnitude on charges in the wall - sign determines if balloon is inducing more or less
// charge in the wall, but there must be some change since the last description
- var forceDelta = forceMagnitude - this.previousForceMagnitude;
+ const forceDelta = forceMagnitude - this.previousForceMagnitude;
assert && assert( forceDelta !== 0, 'induced charge did not change since last description' );
// if the sign of the change in force hasn't changed, then the balloon has continued to apply force on
// wall charges in the same direction since the last time this change was described
- var forceDeltaNormalized = forceDelta / Math.abs( forceDelta );
- var continuedDirection = forceDeltaNormalized === this.previousForceMagnitudeNormalized;
+ const forceDeltaNormalized = forceDelta / Math.abs( forceDelta );
+ const continuedDirection = forceDeltaNormalized === this.previousForceMagnitudeNormalized;
// describes the location of induced charge in the wall
- var balloonY = this.balloonModel.getCenterY();
- var chargeLocation = new Vector2( PlayAreaMap.X_LOCATIONS.AT_WALL, balloonY );
- var chargeLocationString = BASEDescriber.getLocationDescription( chargeLocation, wallVisible );
+ const balloonY = this.balloonModel.getCenterY();
+ const chargeLocation = new Vector2( PlayAreaMap.X_LOCATIONS.AT_WALL, balloonY );
+ const chargeLocationString = BASEDescriber.getLocationDescription( chargeLocation, wallVisible );
- var movementString;
+ let movementString;
if ( forceDelta > 0 ) {
if ( continuedDirection ) {
@@ -327,9 +327,9 @@ define( require => {
* @returns {string}
*/
describeInducedChargeChange: function() {
- var chargesShown = this.showChargesProperty.get();
- var wallVisible = this.wall.isVisibleProperty.get();
- var jumping = this.balloonModel.jumping;
+ const chargesShown = this.showChargesProperty.get();
+ const wallVisible = this.wall.isVisibleProperty.get();
+ const jumping = this.balloonModel.jumping;
return !jumping &&
!this.balloonModel.touchingWall() &&
wallVisible &&
@@ -343,7 +343,7 @@ define( require => {
* @returns {string}
*/
getSummaryRelativeChargeDescription: function() {
- var chargesShown = this.showChargesProperty.get();
+ const chargesShown = this.showChargesProperty.get();
if ( this.balloonModel.chargeProperty.get() === 0 && chargesShown === 'all' ) {
return summaryBalloonNeutralChargeString;
@@ -362,9 +362,9 @@ define( require => {
* @returns {string}
*/
getHasRelativeChargeDescription: function() {
- var balloonCharge = this.balloonModel.chargeProperty.get();
- var chargesShown = this.showChargesProperty.get();
- var chargeDescription = BalloonChargeDescriber.getRelativeChargeDescription( this.balloonModel, chargesShown );
+ const balloonCharge = this.balloonModel.chargeProperty.get();
+ const chargesShown = this.showChargesProperty.get();
+ let chargeDescription = BalloonChargeDescriber.getRelativeChargeDescription( this.balloonModel, chargesShown );
if ( chargesShown === 'all' ) {
chargeDescription = StringUtils.fillIn( balloonHasChargePatternString, {
@@ -372,7 +372,7 @@ define( require => {
} );
}
else if ( chargesShown === 'diff' ) {
- var chargeString = ( balloonCharge < 0 ) ? balloonNegativeString : balloonZeroString;
+ const chargeString = ( balloonCharge < 0 ) ? balloonNegativeString : balloonZeroString;
chargeDescription = StringUtils.fillIn( balloonHasChargeShowingPatternString, {
charge: chargeString,
showing: chargeDescription
@@ -408,8 +408,8 @@ define( require => {
* @returns {string}
*/
getRelativeChargeDescription: function( balloonModel, showCharges ) {
- var description;
- var chargeValue = Math.abs( balloonModel.chargeProperty.get() );
+ let description;
+ const chargeValue = Math.abs( balloonModel.chargeProperty.get() );
// if charge view is 'diff' and there are no charges, we simply say that there are no
// charges shown
@@ -417,8 +417,8 @@ define( require => {
description = showingNoChargesString;
}
else {
- var relativeChargesString = BASEDescriber.getRelativeChargeDescription( chargeValue );
- var stringPattern;
+ const relativeChargesString = BASEDescriber.getRelativeChargeDescription( chargeValue );
+ let stringPattern;
if ( showCharges === 'all' ) {
stringPattern = balloonRelativeChargePatternString;
}
@@ -446,8 +446,8 @@ define( require => {
* @returns {string}
*/
getRelativeChargeDescriptionWithLabel: function( balloonModel, showCharges, label ) {
- var description;
- var relativeCharge = BalloonChargeDescriber.getRelativeChargeDescription( balloonModel, showCharges );
+ let description;
+ const relativeCharge = BalloonChargeDescriber.getRelativeChargeDescription( balloonModel, showCharges );
assert && assert( showCharges !== 'none', 'relative description with label should never be read when no charges are shown' );
if ( showCharges === 'all' ) {
@@ -457,8 +457,8 @@ define( require => {
} );
}
else if ( showCharges === 'diff' ) {
- var balloonCharge = balloonModel.chargeProperty.get();
- var chargeString = ( balloonCharge < 0 ) ? balloonNegativeString : balloonZeroString;
+ const balloonCharge = balloonModel.chargeProperty.get();
+ const chargeString = ( balloonCharge < 0 ) ? balloonNegativeString : balloonZeroString;
description = StringUtils.fillIn( balloonHasNetChargePatternString, {
balloon: label,
diff --git a/js/balloons-and-static-electricity/view/describers/BalloonDescriber.js b/js/balloons-and-static-electricity/view/describers/BalloonDescriber.js
index d13e3391..22a28165 100644
--- a/js/balloons-and-static-electricity/view/describers/BalloonDescriber.js
+++ b/js/balloons-and-static-electricity/view/describers/BalloonDescriber.js
@@ -39,38 +39,38 @@ define( require => {
const WallDescriber = require( 'BALLOONS_AND_STATIC_ELECTRICITY/balloons-and-static-electricity/view/describers/WallDescriber' );
// a11y strings
- var balloonShowAllChargesPatternString = BASEA11yStrings.balloonShowAllChargesPattern.value;
- var balloonAtLocationPatternString = BASEA11yStrings.balloonAtLocationPattern.value;
- var singleStatementPatternString = BASEA11yStrings.singleStatementPattern.value;
- var balloonPicksUpChargesPatternString = BASEA11yStrings.balloonPicksUpChargesPattern.value;
- var balloonPicksUpMoreChargesPatternString = BASEA11yStrings.balloonPicksUpMoreChargesPattern.value;
- var balloonPicksUpChargesDiffPatternString = BASEA11yStrings.balloonPicksUpChargesDiffPattern.value;
- var balloonPicksUpMoreChargesDiffPatternString = BASEA11yStrings.balloonPicksUpMoreChargesDiffPattern.value;
- var balloonSweaterRelativeChargesPatternString = BASEA11yStrings.balloonSweaterRelativeChargesPattern.value;
- var lastChargePickedUpPatternString = BASEA11yStrings.lastChargePickedUpPattern.value;
- var noChargePickupPatternString = BASEA11yStrings.noChargePickupPattern.value;
- var noChangeInChargesString = BASEA11yStrings.noChangeInCharges.value;
- var noChangeInNetChargeString = BASEA11yStrings.noChangeInNetCharge.value;
- var noChargePickupHintPatternString = BASEA11yStrings.noChargePickupHintPattern.value;
- var nochargePickupWithObjectChargeAndHint = BASEA11yStrings.nochargePickupWithObjectChargeAndHint.value;
- var releaseHintString = BASEA11yStrings.releaseHint.value;
- var balloonAddedPatternString = BASEA11yStrings.balloonAddedPattern.value;
- var balloonRemovedPatternString = BASEA11yStrings.balloonRemovedPattern.value;
- var balloonAddedWithLocationPatternString = BASEA11yStrings.balloonAddedWithLocationPattern.value;
- var wallRubbingWithPairsPattern = BASEA11yStrings.wallRubbingWithPairsPattern.value;
- var wallRubPatternString = BASEA11yStrings.wallRubPattern.value;
- var wallRubAllPatternString = BASEA11yStrings.wallRubAllPattern.value;
- var wallRubDiffPatternString = BASEA11yStrings.wallRubDiffPattern.value;
+ const balloonShowAllChargesPatternString = BASEA11yStrings.balloonShowAllChargesPattern.value;
+ const balloonAtLocationPatternString = BASEA11yStrings.balloonAtLocationPattern.value;
+ const singleStatementPatternString = BASEA11yStrings.singleStatementPattern.value;
+ const balloonPicksUpChargesPatternString = BASEA11yStrings.balloonPicksUpChargesPattern.value;
+ const balloonPicksUpMoreChargesPatternString = BASEA11yStrings.balloonPicksUpMoreChargesPattern.value;
+ const balloonPicksUpChargesDiffPatternString = BASEA11yStrings.balloonPicksUpChargesDiffPattern.value;
+ const balloonPicksUpMoreChargesDiffPatternString = BASEA11yStrings.balloonPicksUpMoreChargesDiffPattern.value;
+ const balloonSweaterRelativeChargesPatternString = BASEA11yStrings.balloonSweaterRelativeChargesPattern.value;
+ const lastChargePickedUpPatternString = BASEA11yStrings.lastChargePickedUpPattern.value;
+ const noChargePickupPatternString = BASEA11yStrings.noChargePickupPattern.value;
+ const noChangeInChargesString = BASEA11yStrings.noChangeInCharges.value;
+ const noChangeInNetChargeString = BASEA11yStrings.noChangeInNetCharge.value;
+ const noChargePickupHintPatternString = BASEA11yStrings.noChargePickupHintPattern.value;
+ const nochargePickupWithObjectChargeAndHint = BASEA11yStrings.nochargePickupWithObjectChargeAndHint.value;
+ const releaseHintString = BASEA11yStrings.releaseHint.value;
+ const balloonAddedPatternString = BASEA11yStrings.balloonAddedPattern.value;
+ const balloonRemovedPatternString = BASEA11yStrings.balloonRemovedPattern.value;
+ const balloonAddedWithLocationPatternString = BASEA11yStrings.balloonAddedWithLocationPattern.value;
+ const wallRubbingWithPairsPattern = BASEA11yStrings.wallRubbingWithPairsPattern.value;
+ const wallRubPatternString = BASEA11yStrings.wallRubPattern.value;
+ const wallRubAllPatternString = BASEA11yStrings.wallRubAllPattern.value;
+ const wallRubDiffPatternString = BASEA11yStrings.wallRubDiffPattern.value;
// constants
// in ms, delay before announcing an alert that describes independent movement, to give the model time to respond
- var RELEASE_DESCRIPTION_TIME_DELAY = 25;
+ const RELEASE_DESCRIPTION_TIME_DELAY = 25;
// in ms, limits frequency of charge pickup alerts
- var CHARGE_DESCRIPTION_REFRESH_RATE = 2000;
+ const CHARGE_DESCRIPTION_REFRESH_RATE = 2000;
// in ms, time between alerts that tell user balloon continues to move due to force
- var RELEASE_DESCRIPTION_REFRESH_RATE = 5000;
+ const RELEASE_DESCRIPTION_REFRESH_RATE = 5000;
/**
* @param {BASEModel} model
@@ -81,7 +81,7 @@ define( require => {
* @constructor
*/
function BalloonDescriber( model, wall, balloon, accessibleLabel, otherAccessibleLabel ) {
- var self = this;
+ const self = this;
// @private
this.model = model;
@@ -169,7 +169,7 @@ define( require => {
// announce alerts related to charge change
balloon.chargeProperty.link( function updateCharge( chargeVal ) {
- var alert;
+ let alert;
// the first charge pickup and subsequent pickups (behind a refresh rate) should be announced
if ( self.alertNextPickup || self.alertFirstPickup ) {
@@ -277,10 +277,10 @@ define( require => {
* @returns {string}
*/
getBalloonDescription: function() {
- var description;
- var showCharges = this.showChargesProperty.get();
+ let description;
+ const showCharges = this.showChargesProperty.get();
- var attractiveStateAndLocationString = this.movementDescriber.getAttractiveStateAndLocationDescription();
+ let attractiveStateAndLocationString = this.movementDescriber.getAttractiveStateAndLocationDescription();
attractiveStateAndLocationString = StringUtils.fillIn( singleStatementPatternString, {
statement: attractiveStateAndLocationString
} );
@@ -291,10 +291,10 @@ define( require => {
else {
// balloon net charge description
- var netChargeDescriptionString = this.chargeDescriber.getNetChargeDescription();
+ const netChargeDescriptionString = this.chargeDescriber.getNetChargeDescription();
// balloon relative charge string, dependent on charge visibility
- var relativeChargesString = BalloonChargeDescriber.getRelativeChargeDescription( this.balloonModel, showCharges );
+ const relativeChargesString = BalloonChargeDescriber.getRelativeChargeDescription( this.balloonModel, showCharges );
description = StringUtils.fillIn( balloonShowAllChargesPatternString, {
stateAndLocation: attractiveStateAndLocationString,
@@ -315,11 +315,11 @@ define( require => {
* @returns {string}
*/
getChargePickupDescription: function( firstPickup ) {
- var description;
- var shownCharges = this.showChargesProperty.get();
+ let description;
+ const shownCharges = this.showChargesProperty.get();
- var newCharge = this.balloonModel.chargeProperty.get();
- var newRange = BASEDescriber.getDescribedChargeRange( newCharge );
+ const newCharge = this.balloonModel.chargeProperty.get();
+ const newRange = BASEDescriber.getDescribedChargeRange( newCharge );
if ( shownCharges === 'none' ) {
description = this.movementDescriber.getAttractiveStateAndLocationDescription();
@@ -335,14 +335,14 @@ define( require => {
// if we have entered a new described range since the previous charge alert,
// we will generate a special description that mentions the relative charges
- var sweaterCharge = this.model.sweater.chargeProperty.get();
+ const sweaterCharge = this.model.sweater.chargeProperty.get();
// relative charge of balloon, as a sentance
- var relativeBalloonCharge = BalloonChargeDescriber.getRelativeChargeDescriptionWithLabel( this.balloonModel, shownCharges, this.accessibleName );
+ let relativeBalloonCharge = BalloonChargeDescriber.getRelativeChargeDescriptionWithLabel( this.balloonModel, shownCharges, this.accessibleName );
relativeBalloonCharge = StringUtils.fillIn( singleStatementPatternString, {
statement: relativeBalloonCharge
} );
- var relativeSweaterCharge = SweaterDescriber.getRelativeChargeDescriptionWithLabel( sweaterCharge, shownCharges );
+ const relativeSweaterCharge = SweaterDescriber.getRelativeChargeDescriptionWithLabel( sweaterCharge, shownCharges );
description = StringUtils.fillIn( balloonSweaterRelativeChargesPatternString, {
balloon: relativeBalloonCharge,
@@ -354,7 +354,7 @@ define( require => {
else {
// in same described range of charges, describe how balloon picks up more charges
- var picksUpCharges = StringUtils.fillIn( balloonPicksUpMoreChargesPatternString, {
+ const picksUpCharges = StringUtils.fillIn( balloonPicksUpMoreChargesPatternString, {
balloon: this.accessibleName
} );
@@ -384,10 +384,10 @@ define( require => {
* @returns {string}
*/
getInitialChargePickupDescription: function() {
- var description;
- var shownCharges = this.showChargesProperty.get();
+ let description;
+ const shownCharges = this.showChargesProperty.get();
- var picksUpCharges = StringUtils.fillIn( balloonPicksUpChargesPatternString, {
+ const picksUpCharges = StringUtils.fillIn( balloonPicksUpChargesPatternString, {
balloon: this.accessibleName
} );
@@ -418,11 +418,11 @@ define( require => {
* @returns {string}
*/
getNoChargePickupDescription: function() {
- var alert;
- var chargesShown = this.showChargesProperty.get();
+ let alert;
+ const chargesShown = this.showChargesProperty.get();
- var balloonLocationString = this.movementDescriber.getAttractiveStateAndLocationDescription();
- var sweaterCharge = this.model.sweater.chargeProperty.get();
+ const balloonLocationString = this.movementDescriber.getAttractiveStateAndLocationDescription();
+ const sweaterCharge = this.model.sweater.chargeProperty.get();
if ( chargesShown === 'none' ) {
@@ -434,8 +434,8 @@ define( require => {
else if ( sweaterCharge < BASEConstants.MAX_BALLOON_CHARGE ) {
// there are still charges on the sweater
- var sweaterCharges = this.model.sweater.minusCharges;
- var moreChargesString = SweaterDescriber.getMoreChargesDescription( this.balloonModel, sweaterCharge, sweaterCharges, chargesShown );
+ const sweaterCharges = this.model.sweater.minusCharges;
+ const moreChargesString = SweaterDescriber.getMoreChargesDescription( this.balloonModel, sweaterCharge, sweaterCharges, chargesShown );
if ( chargesShown === 'all' ) {
alert = StringUtils.fillIn( noChargePickupPatternString, {
noChange: noChangeInChargesString,
@@ -455,8 +455,8 @@ define( require => {
// there are no more charges remaining on the sweater
if ( chargesShown === 'all' ) {
- var relativeSweaterCharge = SweaterDescriber.getNetChargeDescription( sweaterCharge );
- var relativeBalloonCharge = this.chargeDescriber.getNetChargeDescriptionWithLabel();
+ const relativeSweaterCharge = SweaterDescriber.getNetChargeDescription( sweaterCharge );
+ let relativeBalloonCharge = this.chargeDescriber.getNetChargeDescriptionWithLabel();
relativeBalloonCharge = StringUtils.fillIn( singleStatementPatternString, { statement: relativeBalloonCharge } );
alert = StringUtils.fillIn( nochargePickupWithObjectChargeAndHint, {
@@ -492,32 +492,32 @@ define( require => {
* @returns {string}
*/
getWallRubbingDescription: function() {
- var descriptionString;
- var chargeString;
+ let descriptionString;
+ let chargeString;
// the location string is used for all charge views, used as a single sentence
- var locationString = this.movementDescriber.getBalloonLocationDescription();
- var atLocationString = StringUtils.fillIn( balloonAtLocationPatternString, {
+ const locationString = this.movementDescriber.getBalloonLocationDescription();
+ let atLocationString = StringUtils.fillIn( balloonAtLocationPatternString, {
location: locationString
} );
atLocationString = StringUtils.fillIn( singleStatementPatternString, {
statement: atLocationString
} );
- var shownCharges = this.showChargesProperty.get();
- var wallVisible = this.wall.isVisibleProperty.get();
+ const shownCharges = this.showChargesProperty.get();
+ const wallVisible = this.wall.isVisibleProperty.get();
if ( shownCharges === 'none' ) {
descriptionString = atLocationString;
}
else {
if ( shownCharges === 'all' ) {
- var inducedChargeString;
+ let inducedChargeString;
// if balloons are adjacent, the resultant induced charge description is modified
if ( this.model.getBalloonsAdjacent() ) {
- var thisInducingAndVisible = this.balloonModel.inducingChargeAndVisible();
- var otherInducingAndVisible = this.balloonModel.other.inducingChargeAndVisible();
+ const thisInducingAndVisible = this.balloonModel.inducingChargeAndVisible();
+ const otherInducingAndVisible = this.balloonModel.other.inducingChargeAndVisible();
if ( thisInducingAndVisible && otherInducingAndVisible ) {
@@ -533,8 +533,8 @@ define( require => {
assert && assert( this.balloonModel.inducingChargeAndVisible() !== this.balloonModel.other.inducingChargeAndVisible() );
// only one balloon is inducing charge, describe whichever one is currently inducing charge
- var inducingBalloon;
- var balloonLabel;
+ let inducingBalloon;
+ let balloonLabel;
if ( this.balloonModel.inducingChargeAndVisible() ) {
inducingBalloon = this.balloonModel;
balloonLabel = this.accessibleName;
@@ -559,8 +559,8 @@ define( require => {
} );
}
else {
- var wallChargeString = WallDescriber.getWallChargeDescriptionWithLabel( this.model.yellowBalloon, this.model.greenBalloon, this.model.getBalloonsAdjacent(), wallVisible, shownCharges );
- var balloonChargeString = BalloonChargeDescriber.getRelativeChargeDescriptionWithLabel( this.balloonModel, shownCharges, this.accessibleName );
+ let wallChargeString = WallDescriber.getWallChargeDescriptionWithLabel( this.model.yellowBalloon, this.model.greenBalloon, this.model.getBalloonsAdjacent(), wallVisible, shownCharges );
+ let balloonChargeString = BalloonChargeDescriber.getRelativeChargeDescriptionWithLabel( this.balloonModel, shownCharges, this.accessibleName );
// balloon charge doesn't include punctuation
balloonChargeString = StringUtils.fillIn( singleStatementPatternString, {
@@ -620,11 +620,11 @@ define( require => {
* @returns {string}
*/
getLastChargePickupDescription: function() {
- var shownCharges = this.showChargesProperty.get();
- var charge = this.balloonModel.chargeProperty.get();
+ const shownCharges = this.showChargesProperty.get();
+ const charge = this.balloonModel.chargeProperty.get();
- var sweaterChargeString = SweaterDescriber.getNoMoreChargesAlert( charge, shownCharges );
- var balloonChargeString = BalloonChargeDescriber.getRelativeChargeDescriptionWithLabel( this.balloonModel, shownCharges, this.accessibleName );
+ const sweaterChargeString = SweaterDescriber.getNoMoreChargesAlert( charge, shownCharges );
+ const balloonChargeString = BalloonChargeDescriber.getRelativeChargeDescriptionWithLabel( this.balloonModel, shownCharges, this.accessibleName );
return StringUtils.fillIn( lastChargePickedUpPatternString, {
sweater: sweaterChargeString,
@@ -642,9 +642,9 @@ define( require => {
* @returns {string}
*/
getVisibilityChangedDescription: function() {
- var description;
- var locationProperty = this.balloonModel.locationProperty;
- var visible = this.balloonModel.isVisibleProperty.get();
+ let description;
+ const locationProperty = this.balloonModel.locationProperty;
+ const visible = this.balloonModel.isVisibleProperty.get();
if ( !visible ) {
@@ -690,17 +690,17 @@ define( require => {
step: function( dt ) {
// for readability
- var utterance = '';
- var model = this.balloonModel;
+ let utterance = '';
+ const model = this.balloonModel;
// grab next values to describe
- var nextVelocity = model.velocityProperty.get();
- var nextDragVelocity = model.dragVelocityProperty.get();
- var nextLocation = model.locationProperty.get();
- var nextVisible = model.isVisibleProperty.get();
- var nextTouchingWall = model.touchingWallProperty.get();
- var nextIsDragged = model.isDraggedProperty.get();
- var nextWallVisible = this.wall.isVisibleProperty.get();
+ const nextVelocity = model.velocityProperty.get();
+ const nextDragVelocity = model.dragVelocityProperty.get();
+ const nextLocation = model.locationProperty.get();
+ const nextVisible = model.isVisibleProperty.get();
+ const nextTouchingWall = model.touchingWallProperty.get();
+ const nextIsDragged = model.isDraggedProperty.get();
+ const nextWallVisible = this.wall.isVisibleProperty.get();
// update timers that determine the next time certain alerts should be announced
this.timeSinceChargeAlert += dt * 1000;
@@ -752,16 +752,16 @@ define( require => {
if ( !model.jumping ) {
// how much balloon has moved in a single drag
- var dragDelta = nextLocation.minus( this.oldDragLocation );
+ const dragDelta = nextLocation.minus( this.oldDragLocation );
// when we complete a keyboard drag, set timer to refresh rate so that we trigger a new description next
// time we move the balloon
this.timeSinceChargeAlert = CHARGE_DESCRIPTION_REFRESH_RATE;
// if in the play area, information about movement through the play area
- var inLandmark = PlayAreaMap.inLandmarkColumn( model.getCenter() );
- var onSweater = model.onSweater();
- var touchingWall = model.touchingWall();
+ const inLandmark = PlayAreaMap.inLandmarkColumn( model.getCenter() );
+ const onSweater = model.onSweater();
+ const touchingWall = model.touchingWall();
if ( !inLandmark && !onSweater && !touchingWall ) {
utterance = this.movementDescriber.getKeyboardMovementAlert();
}
@@ -784,7 +784,7 @@ define( require => {
// describe the change in induced charge due to balloon dragging
if ( this.chargeDescriber.describeInducedChargeChange() ) {
utterance = '';
- var wallVisible = this.wall.isVisibleProperty.get();
+ const wallVisible = this.wall.isVisibleProperty.get();
// if there is purely vertical motion, do not include information about amount of charge displacement
if ( dragDelta.x === 0 ) {
diff --git a/js/balloons-and-static-electricity/view/describers/BalloonDescriberTests.js b/js/balloons-and-static-electricity/view/describers/BalloonDescriberTests.js
index e3d14f60..9f6ac8f5 100644
--- a/js/balloons-and-static-electricity/view/describers/BalloonDescriberTests.js
+++ b/js/balloons-and-static-electricity/view/describers/BalloonDescriberTests.js
@@ -23,11 +23,11 @@ define( require => {
QUnit.module( 'BalloonDescriberTests' );
// create model and view for testing
- var layoutBounds = new Bounds2( 0, 0, 768, 504 );
- var model = new BASEModel( layoutBounds.width, layoutBounds.height, Tandem.rootTandem.createTandem( 'model' ) );
+ const layoutBounds = new Bounds2( 0, 0, 768, 504 );
+ const model = new BASEModel( layoutBounds.width, layoutBounds.height, Tandem.rootTandem.createTandem( 'model' ) );
// create a wallNode for testing
- var balloonNode = new BalloonNode( model.yellowBalloon, balloonYellow, model, 'Yellow Balloon', 'Green Balloon', layoutBounds, Tandem.rootTandem.createTandem( 'balloonNode' ), {
+ const balloonNode = new BalloonNode( model.yellowBalloon, balloonYellow, model, 'Yellow Balloon', 'Green Balloon', layoutBounds, Tandem.rootTandem.createTandem( 'balloonNode' ), {
labelContent: 'Yellow Balloon'
} );
@@ -35,8 +35,8 @@ define( require => {
model.reset();
// on load
- var actualDescription = balloonNode.descriptionContent;
- var expectedDescription = 'At center of Play Area. Has zero net charge, no more negative charges than positive charges.';
+ let actualDescription = balloonNode.descriptionContent;
+ let expectedDescription = 'At center of Play Area. Has zero net charge, no more negative charges than positive charges.';
assert.equal( actualDescription, expectedDescription );
// balloon at upper wall with several more negative charges than positive, all charges shown
@@ -83,8 +83,8 @@ define( require => {
model.reset();
// initial grab on load
- var actualDescription = balloonNode.describer.movementDescriber.getGrabbedAlert();
- var expectedDescription = 'Grabbed. At center of Play Area. Has no more negative charges than positive charges. Press W, A, S, or D key to move balloon. Space to release.';
+ let actualDescription = balloonNode.describer.movementDescriber.getGrabbedAlert();
+ let expectedDescription = 'Grabbed. At center of Play Area. Has no more negative charges than positive charges. Press W, A, S, or D key to move balloon. Space to release.';
assert.equal( actualDescription, expectedDescription, 'grab alert test 1' );
// Second grab, no longer have interaction hint
@@ -283,7 +283,7 @@ define( require => {
model.reset();
model.greenBalloon.isVisibleProperty.set( true );
- var rightSweater = new Vector2( PlayAreaMap.COLUMN_RANGES.RIGHT_SIDE_OF_SWEATER.getCenter(), PlayAreaMap.Y_BOUNDARY_LOCATIONS.AT_TOP );
+ const rightSweater = new Vector2( PlayAreaMap.COLUMN_RANGES.RIGHT_SIDE_OF_SWEATER.getCenter(), PlayAreaMap.Y_BOUNDARY_LOCATIONS.AT_TOP );
//--------------------------------------------------------------------------
// All charges shown
@@ -296,8 +296,8 @@ define( require => {
model.yellowBalloon.setCenter( rightSweater );
model.greenBalloon.setCenter( rightSweater );
model.yellowBalloon.isDraggedProperty.set( true );
- var actualDescription = balloonNode.describer.movementDescriber.getGrabbedAlert();
- var expectedDescription = 'Grabbed. On upper-right side of sweater, next to Green Balloon. ' +
+ let actualDescription = balloonNode.describer.movementDescriber.getGrabbedAlert();
+ let expectedDescription = 'Grabbed. On upper-right side of sweater, next to Green Balloon. ' +
'Each balloon has a few more negative charges than positive charges. ' +
'Sweater has several more positive charges than negative charges. ' +
'Press W, A, S, or D key to move balloon. Space to release.';
@@ -347,8 +347,8 @@ define( require => {
// first time balloon hits sweater and picks up negative charges
model.yellowBalloon.chargeProperty.set( -1 );
model.sweater.chargeProperty.set( 1 );
- var actualAlert = balloonNode.describer.getChargePickupDescription( true );
- var expectedAlert = 'Yellow Balloon picks up negative charges from sweater.';
+ let actualAlert = balloonNode.describer.getChargePickupDescription( true );
+ let expectedAlert = 'Yellow Balloon picks up negative charges from sweater.';
assert.equal( actualAlert, expectedAlert, 'charge pick up 1' );
// first time balloon hits sweater and picks up negative charges, showing charge differences
@@ -397,8 +397,8 @@ define( require => {
// move the balloon to the sweater without picking up charges
model.yellowBalloon.setCenter( new Vector2( PlayAreaMap.COLUMN_RANGES.LEFT_SIDE_OF_SWEATER.getCenter(), PlayAreaMap.Y_BOUNDARY_LOCATIONS.AT_TOP ) );
- var actualAlert = balloonNode.describer.getNoChargePickupDescription();
- var expectedAlert = 'No change in charges. On upper-left side of sweater. More pairs of charges up and to the left.';
+ let actualAlert = balloonNode.describer.getNoChargePickupDescription();
+ let expectedAlert = 'No change in charges. On upper-left side of sweater. More pairs of charges up and to the left.';
assert.equal( actualAlert, expectedAlert, 'no pick up 1' );
// same balloon on sweater but didn't pick up charges
@@ -442,8 +442,8 @@ define( require => {
// neutral balloon rubbing along wall, all charges shown
model.yellowBalloon.setCenter( new Vector2( PlayAreaMap.X_LOCATIONS.AT_WALL, PlayAreaMap.Y_BOUNDARY_LOCATIONS.AT_TOP ) );
- var actualAlert = balloonNode.describer.getWallRubbingDescription();
- var expectedAlert = 'At upper wall. No transfer of charge. In upper wall, no change in charges.';
+ let actualAlert = balloonNode.describer.getWallRubbingDescription();
+ let expectedAlert = 'At upper wall. No transfer of charge. In upper wall, no change in charges.';
assert.equal( actualAlert, expectedAlert, 'wall rub test 1' );
// charged balloon rubbing along upper wall, all charges shown
@@ -486,8 +486,8 @@ define( require => {
model.greenBalloon.chargeProperty.set( -10 );
model.yellowBalloon.setCenter( new Vector2( PlayAreaMap.X_LOCATIONS.AT_WALL, PlayAreaMap.Y_BOUNDARY_LOCATIONS.AT_TOP + 1 ) );
model.greenBalloon.setCenter( new Vector2( PlayAreaMap.X_LOCATIONS.AT_WALL, PlayAreaMap.Y_BOUNDARY_LOCATIONS.AT_TOP + 1 ) );
- var actualAlert = balloonNode.describer.getWallRubbingDescription();
- var expectedAlert = 'At upper wall, next to Green Balloon. No transfer of charge. Negative charges in upper wall move away from balloons a lot. Positive charges do not move.';
+ let actualAlert = balloonNode.describer.getWallRubbingDescription();
+ let expectedAlert = 'At upper wall, next to Green Balloon. No transfer of charge. Negative charges in upper wall move away from balloons a lot. Positive charges do not move.';
assert.equal( actualAlert, expectedAlert, 'wall rub, two balloons, test 1' );
// only one balloon has charge, all charges shown - nudge the balloon so that induced Properties update
diff --git a/js/balloons-and-static-electricity/view/describers/BalloonLocationDescriber.js b/js/balloons-and-static-electricity/view/describers/BalloonLocationDescriber.js
index 22bc7919..d969516e 100644
--- a/js/balloons-and-static-electricity/view/describers/BalloonLocationDescriber.js
+++ b/js/balloons-and-static-electricity/view/describers/BalloonLocationDescriber.js
@@ -22,73 +22,73 @@ define( require => {
const WallDescriber = require( 'BALLOONS_AND_STATIC_ELECTRICITY/balloons-and-static-electricity/view/describers/WallDescriber' );
// a11y strings
- var atWallString = BASEA11yStrings.atWall.value;
- var balloonStickingToString = BASEA11yStrings.balloonStickingTo.value;
- var balloonOnString = BASEA11yStrings.balloonOn.value;
- var balloonAtString = BASEA11yStrings.balloonAt.value;
- var balloonLocationAttractiveStatePatternString = BASEA11yStrings.balloonLocationAttractiveStatePattern.value;
- var initialMovementPatternString = BASEA11yStrings.initialMovementPattern.value;
- var continuousMovementWithLabelPatternString = BASEA11yStrings.continuousMovementWithLabelPattern.value;
- var twoBalloonInitialMovementPatternString = BASEA11yStrings.twoBalloonInitialMovementPattern.value;
- var twoBalloonNoChangeAndLocationPatternString = BASEA11yStrings.twoBalloonNoChangeAndLocationPattern.value;
- var twoBalloonNowDirectionPatternString = BASEA11yStrings.twoBalloonNowDirectionPattern.value;
- var extremelySlowlyString = BASEA11yStrings.extremelySlowly.value;
- var verySlowlyString = BASEA11yStrings.verySlowly.value;
- var slowlyString = BASEA11yStrings.slowly.value;
- var quicklyString = BASEA11yStrings.quickly.value;
- var veryQuicklyString = BASEA11yStrings.veryQuickly.value;
- var upDraggingString = BASEA11yStrings.upDragging.value;
- var leftDraggingString = BASEA11yStrings.leftDragging.value;
- var downDraggingString = BASEA11yStrings.downDragging.value;
- var rightDraggingString = BASEA11yStrings.rightDragging.value;
- var upAndToTheRightDraggingString = BASEA11yStrings.upAndToTheRightDragging.value;
- var upAndToTheLeftDraggingString = BASEA11yStrings.upAndToTheLeftDragging.value;
- var downAndToTheRightDraggingString = BASEA11yStrings.downAndToTheRightDragging.value;
- var downAndToTheLeftDraggingString = BASEA11yStrings.downAndToTheLeftDragging.value;
- var upString = BASEA11yStrings.up.value;
- var leftString = BASEA11yStrings.left.value;
- var downString = BASEA11yStrings.down.value;
- var rightString = BASEA11yStrings.right.value;
- var upAndToTheRightString = BASEA11yStrings.upAndToTheRight.value;
- var upAndToTheLeftString = BASEA11yStrings.upAndToTheLeft.value;
- var downAndToTheRightString = BASEA11yStrings.downAndToTheRight.value;
- var downAndToTheLeftString = BASEA11yStrings.downAndToTheLeft.value;
- var atLeftEdgeString = BASEA11yStrings.atLeftEdge.value;
- var atTopString = BASEA11yStrings.atTop.value;
- var atBottomString = BASEA11yStrings.atBottom.value;
- var atRightEdgeString = BASEA11yStrings.atRightEdge.value;
- var onSweaterString = BASEA11yStrings.onSweater.value;
- var offSweaterString = BASEA11yStrings.offSweater.value;
- var balloonNewRegionPatternString = BASEA11yStrings.balloonNewRegionPattern.value;
- var closerToObjectPatternString = BASEA11yStrings.closerToObjectPattern.value;
- var sweaterString = BASEA11yStrings.sweater.value;
- var wallString = BASEA11yStrings.wall.value;
- var centerOfPlayAreaString = BASEA11yStrings.centerOfPlayArea.value;
- var rightEdgeOfPlayAreaString = BASEA11yStrings.rightEdgeOfPlayArea.value;
- var topEdgeOfPlayAreaString = BASEA11yStrings.topEdgeOfPlayArea.value;
- var bottomEdgeOfPlayAreaString = BASEA11yStrings.bottomEdgeOfPlayArea.value;
- var noChangeAndLocationPatternString = BASEA11yStrings.noChangeAndLocationPattern.value;
- var nearSweaterString = BASEA11yStrings.nearSweater.value;
- var balloonNearString = BASEA11yStrings.balloonNear.value;
- var locationAndInducedChargePatternString = BASEA11yStrings.locationAndInducedChargePattern.value;
- var singleStatementPatternString = BASEA11yStrings.singleStatementPattern.value;
- var interactionCueString = BASEA11yStrings.interactionCue.value;
- var balloonLabelWithAttractiveStatePatternString = BASEA11yStrings.balloonLabelWithAttractiveStatePattern.value;
- var balloonVeryCloseToString = BASEA11yStrings.balloonVeryCloseTo.value;
- var continuousMovementPatternString = BASEA11yStrings.continuousMovementPattern.value;
- var continuousMovementWithLandmarkPatternString = BASEA11yStrings.continuousMovementWithLandmarkPattern.value;
- var nowDirectionPatternString = BASEA11yStrings.nowDirectionPattern.value;
- var balloonLocationNoChangePatternString = BASEA11yStrings.balloonLocationNoChangePattern.value;
- var noChangeWithInducedChargePatternString = BASEA11yStrings.noChangeWithInducedChargePattern.value;
- var balloonLocationNearOtherPatternString = BASEA11yStrings.balloonLocationNearOtherPattern.value;
- var grabbedNonePatternString = BASEA11yStrings.grabbedNonePattern.value;
- var grabbedChargePatternString = BASEA11yStrings.grabbedChargePattern.value;
- var grabbedWithOtherChargePatternString = BASEA11yStrings.grabbedWithOtherChargePattern.value;
- var grabbedWithHelpPatternString = BASEA11yStrings.grabbedWithHelpPattern.value;
+ const atWallString = BASEA11yStrings.atWall.value;
+ const balloonStickingToString = BASEA11yStrings.balloonStickingTo.value;
+ const balloonOnString = BASEA11yStrings.balloonOn.value;
+ const balloonAtString = BASEA11yStrings.balloonAt.value;
+ const balloonLocationAttractiveStatePatternString = BASEA11yStrings.balloonLocationAttractiveStatePattern.value;
+ const initialMovementPatternString = BASEA11yStrings.initialMovementPattern.value;
+ const continuousMovementWithLabelPatternString = BASEA11yStrings.continuousMovementWithLabelPattern.value;
+ const twoBalloonInitialMovementPatternString = BASEA11yStrings.twoBalloonInitialMovementPattern.value;
+ const twoBalloonNoChangeAndLocationPatternString = BASEA11yStrings.twoBalloonNoChangeAndLocationPattern.value;
+ const twoBalloonNowDirectionPatternString = BASEA11yStrings.twoBalloonNowDirectionPattern.value;
+ const extremelySlowlyString = BASEA11yStrings.extremelySlowly.value;
+ const verySlowlyString = BASEA11yStrings.verySlowly.value;
+ const slowlyString = BASEA11yStrings.slowly.value;
+ const quicklyString = BASEA11yStrings.quickly.value;
+ const veryQuicklyString = BASEA11yStrings.veryQuickly.value;
+ const upDraggingString = BASEA11yStrings.upDragging.value;
+ const leftDraggingString = BASEA11yStrings.leftDragging.value;
+ const downDraggingString = BASEA11yStrings.downDragging.value;
+ const rightDraggingString = BASEA11yStrings.rightDragging.value;
+ const upAndToTheRightDraggingString = BASEA11yStrings.upAndToTheRightDragging.value;
+ const upAndToTheLeftDraggingString = BASEA11yStrings.upAndToTheLeftDragging.value;
+ const downAndToTheRightDraggingString = BASEA11yStrings.downAndToTheRightDragging.value;
+ const downAndToTheLeftDraggingString = BASEA11yStrings.downAndToTheLeftDragging.value;
+ const upString = BASEA11yStrings.up.value;
+ const leftString = BASEA11yStrings.left.value;
+ const downString = BASEA11yStrings.down.value;
+ const rightString = BASEA11yStrings.right.value;
+ const upAndToTheRightString = BASEA11yStrings.upAndToTheRight.value;
+ const upAndToTheLeftString = BASEA11yStrings.upAndToTheLeft.value;
+ const downAndToTheRightString = BASEA11yStrings.downAndToTheRight.value;
+ const downAndToTheLeftString = BASEA11yStrings.downAndToTheLeft.value;
+ const atLeftEdgeString = BASEA11yStrings.atLeftEdge.value;
+ const atTopString = BASEA11yStrings.atTop.value;
+ const atBottomString = BASEA11yStrings.atBottom.value;
+ const atRightEdgeString = BASEA11yStrings.atRightEdge.value;
+ const onSweaterString = BASEA11yStrings.onSweater.value;
+ const offSweaterString = BASEA11yStrings.offSweater.value;
+ const balloonNewRegionPatternString = BASEA11yStrings.balloonNewRegionPattern.value;
+ const closerToObjectPatternString = BASEA11yStrings.closerToObjectPattern.value;
+ const sweaterString = BASEA11yStrings.sweater.value;
+ const wallString = BASEA11yStrings.wall.value;
+ const centerOfPlayAreaString = BASEA11yStrings.centerOfPlayArea.value;
+ const rightEdgeOfPlayAreaString = BASEA11yStrings.rightEdgeOfPlayArea.value;
+ const topEdgeOfPlayAreaString = BASEA11yStrings.topEdgeOfPlayArea.value;
+ const bottomEdgeOfPlayAreaString = BASEA11yStrings.bottomEdgeOfPlayArea.value;
+ const noChangeAndLocationPatternString = BASEA11yStrings.noChangeAndLocationPattern.value;
+ const nearSweaterString = BASEA11yStrings.nearSweater.value;
+ const balloonNearString = BASEA11yStrings.balloonNear.value;
+ const locationAndInducedChargePatternString = BASEA11yStrings.locationAndInducedChargePattern.value;
+ const singleStatementPatternString = BASEA11yStrings.singleStatementPattern.value;
+ const interactionCueString = BASEA11yStrings.interactionCue.value;
+ const balloonLabelWithAttractiveStatePatternString = BASEA11yStrings.balloonLabelWithAttractiveStatePattern.value;
+ const balloonVeryCloseToString = BASEA11yStrings.balloonVeryCloseTo.value;
+ const continuousMovementPatternString = BASEA11yStrings.continuousMovementPattern.value;
+ const continuousMovementWithLandmarkPatternString = BASEA11yStrings.continuousMovementWithLandmarkPattern.value;
+ const nowDirectionPatternString = BASEA11yStrings.nowDirectionPattern.value;
+ const balloonLocationNoChangePatternString = BASEA11yStrings.balloonLocationNoChangePattern.value;
+ const noChangeWithInducedChargePatternString = BASEA11yStrings.noChangeWithInducedChargePattern.value;
+ const balloonLocationNearOtherPatternString = BASEA11yStrings.balloonLocationNearOtherPattern.value;
+ const grabbedNonePatternString = BASEA11yStrings.grabbedNonePattern.value;
+ const grabbedChargePatternString = BASEA11yStrings.grabbedChargePattern.value;
+ const grabbedWithOtherChargePatternString = BASEA11yStrings.grabbedWithOtherChargePattern.value;
+ const grabbedWithHelpPatternString = BASEA11yStrings.grabbedWithHelpPattern.value;
// constants
// maps balloon direction to a description string while the balloon is being dragged
- var BALLOON_DIRECTION_DRAGGING_MAP = {
+ const BALLOON_DIRECTION_DRAGGING_MAP = {
UP: upDraggingString,
DOWN: downDraggingString,
LEFT: leftDraggingString,
@@ -100,7 +100,7 @@ define( require => {
};
// maps balloon direction to a description string for while the balloon is released
- var BALLOON_DIRECTION_RELEASE_MAP = {
+ const BALLOON_DIRECTION_RELEASE_MAP = {
UP: upString,
DOWN: downString,
LEFT: leftString,
@@ -112,13 +112,13 @@ define( require => {
};
// maximum velocity of a balloon immediately after release in this simulation, determined by observation
- var MAXIMUM_VELOCITY_ON_RELEASE = 0.4;
+ const MAXIMUM_VELOCITY_ON_RELEASE = 0.4;
// speed of the balloon to be considered moving slowly, determined empirically so that descriptions sound nice
- var SLOW_BALLOON_SPEED = 0.09;
+ const SLOW_BALLOON_SPEED = 0.09;
// maps magnitude of velocity to the description
- var BALLOON_VELOCITY_MAP = {
+ const BALLOON_VELOCITY_MAP = {
EXTREMELY_SLOWLY_RANGE: {
range: new Range( 0, MAXIMUM_VELOCITY_ON_RELEASE / 200 ),
description: extremelySlowlyString
@@ -173,7 +173,7 @@ define( require => {
* @returns {string}
*/
getAttractiveStateOrProximityDescription: function() {
- var string = '';
+ let string = '';
if ( this.balloonModel.onSweater() ) {
if ( !this.balloonModel.isDraggedProperty.get() && Math.abs( this.balloonModel.chargeProperty.get() ) > 0 ) {
@@ -202,9 +202,9 @@ define( require => {
* @returns {string}
*/
getPreposition: function() {
- var string = '';
+ let string = '';
- var wallVisible = this.wall.isVisibleProperty.get();
+ const wallVisible = this.wall.isVisibleProperty.get();
if ( this.balloonModel.nearWall() && wallVisible ) {
@@ -242,10 +242,10 @@ define( require => {
* @returns {string}
*/
getAttractiveStateAndLocationDescription: function() {
- var locationDescriptionString = this.getBalloonLocationDescription();
+ const locationDescriptionString = this.getBalloonLocationDescription();
- var attractiveStateDescriptionString = this.getAttractiveStateOrProximityDescription();
- var attractiveStateAndLocationString = StringUtils.fillIn( balloonLocationAttractiveStatePatternString, {
+ const attractiveStateDescriptionString = this.getAttractiveStateOrProximityDescription();
+ const attractiveStateAndLocationString = StringUtils.fillIn( balloonLocationAttractiveStatePatternString, {
attractiveState: attractiveStateDescriptionString,
location: locationDescriptionString
} );
@@ -261,10 +261,10 @@ define( require => {
* @returns {string}
*/
getAttractiveStateAndLocationDescriptionWithLabel: function() {
- var alert;
+ let alert;
// to lower case since it is used elsewhere in the string
- var location = this.getAttractiveStateAndLocationDescription().toLowerCase();
+ const location = this.getAttractiveStateAndLocationDescription().toLowerCase();
alert = StringUtils.fillIn( balloonLabelWithAttractiveStatePatternString, {
balloonLabel: this.accessibleName,
attractiveStateAndLocation: location
@@ -284,7 +284,7 @@ define( require => {
*/
getOnLocationDescription: function() {
- var locationDescription = this.getBalloonLocationDescription();
+ const locationDescription = this.getBalloonLocationDescription();
return StringUtils.fillIn( balloonLocationAttractiveStatePatternString, {
attractiveState: this.getPreposition(),
@@ -306,7 +306,7 @@ define( require => {
* @returns {string}
*/
getBalloonLocationDescription: function() {
- var description = this.getLocationDescriptionWithoutOverlap();
+ let description = this.getLocationDescriptionWithoutOverlap();
// include information about how balloons are adjacent if necessary
if ( this.model.getBalloonsAdjacent() ) {
@@ -330,8 +330,8 @@ define( require => {
* @returns {string}
*/
getLocationDescriptionWithoutOverlap: function() {
- var describedBalloonPosition = this.getDescribedPoint();
- var wallVisible = this.wall.isVisibleProperty.get();
+ const describedBalloonPosition = this.getDescribedPoint();
+ const wallVisible = this.wall.isVisibleProperty.get();
return BASEDescriber.getLocationDescription( describedBalloonPosition, wallVisible );
},
@@ -343,7 +343,7 @@ define( require => {
* @returns {Vector2}
*/
getDescribedPoint: function() {
- var describedBalloonPosition;
+ let describedBalloonPosition;
if ( this.balloonModel.onSweater() ) {
describedBalloonPosition = this.balloonModel.getSweaterTouchingCenter();
@@ -365,7 +365,7 @@ define( require => {
getTouchingBoundaryDescription: function( attemptedDirection ) {
assert && assert ( this.balloonModel.isTouchingBoundary(), 'balloon is not touching a boundary' );
- var boundaryString;
+ let boundaryString;
if ( this.balloonModel.isTouchingBottomBoundary() && attemptedDirection === BalloonDirectionEnum.DOWN ) {
boundaryString = atBottomString;
}
@@ -397,7 +397,7 @@ define( require => {
* @returns {string}
*/
getOnSweaterString: function( onSweater ) {
- var description;
+ let description;
if ( onSweater ) {
description = onSweaterString;
@@ -431,9 +431,9 @@ define( require => {
* @returns {string|null}
*/
getLandmarkDragDescription: function() {
- var playAreaLandmark = this.balloonModel.playAreaLandmarkProperty.get();
- var dragSpeed = this.balloonModel.dragVelocityProperty.get().magnitude;
- var alert = this.getAttractiveStateAndLocationDescription();
+ const playAreaLandmark = this.balloonModel.playAreaLandmarkProperty.get();
+ const dragSpeed = this.balloonModel.dragVelocityProperty.get().magnitude;
+ let alert = this.getAttractiveStateAndLocationDescription();
// wrap as a single statement with punctuation
alert = StringUtils.fillIn( singleStatementPatternString, { statement: alert } );
@@ -466,12 +466,12 @@ define( require => {
* @returns {string}
*/
getKeyboardMovementAlert: function() {
- var alert;
+ let alert;
// percent of progress through the region
- var progressThroughCell = this.balloonModel.getProgressThroughRegion();
- var dragVelocity = this.balloonModel.dragVelocityProperty.get().magnitude;
- var movingDiagonally = this.balloonModel.movingDiagonally();
+ const progressThroughCell = this.balloonModel.getProgressThroughRegion();
+ const dragVelocity = this.balloonModel.dragVelocityProperty.get().magnitude;
+ const movingDiagonally = this.balloonModel.movingDiagonally();
if ( dragVelocity > SLOW_BALLOON_SPEED && progressThroughCell >= 0.66 && !movingDiagonally ) {
@@ -507,10 +507,10 @@ define( require => {
getInitialReleaseDescription: function( location, oldLocation ) {
// the balloon is moving with some initial velocity, describe that
- var velocityString = this.getVelocityString();
- var directionString= this.getReleaseDirectionDescription( this.balloonModel.directionProperty.get() );
+ const velocityString = this.getVelocityString();
+ const directionString= this.getReleaseDirectionDescription( this.balloonModel.directionProperty.get() );
- var description;
+ let description;
if ( this.model.bothBalloonsVisible() ) {
description = StringUtils.fillIn( twoBalloonInitialMovementPatternString, {
balloon: this.accessibleName,
@@ -538,8 +538,8 @@ define( require => {
* @returns {string}
*/
getContinuousReleaseDescription: function() {
- var description;
- var directionString = this.getReleaseDirectionDescription( this.balloonModel.directionProperty.get() );
+ let description;
+ const directionString = this.getReleaseDirectionDescription( this.balloonModel.directionProperty.get() );
// describes movement and direction, including label if both balloons are visible
if ( this.balloonModel.other.isVisibleProperty.get() ) {
@@ -575,9 +575,9 @@ define( require => {
* @returns {string}
*/
getNoChangeReleaseDescription: function() {
- var description;
+ let description;
- var attractiveStateAndLocationDescription = this.getAttractiveStateAndLocationDescriptionWithLabel();
+ const attractiveStateAndLocationDescription = this.getAttractiveStateAndLocationDescriptionWithLabel();
if ( this.model.bothBalloonsVisible() ) {
description = StringUtils.fillIn( twoBalloonNoChangeAndLocationPatternString, {
balloon: this.accessibleName,
@@ -592,12 +592,12 @@ define( require => {
// if balloon touching wall and inducing charge, include induced charge information
if ( this.balloonModel.touchingWall() && this.model.showChargesProperty.get() === 'all' ) {
- var wallVisible = this.model.wall.isVisibleProperty.get();
+ const wallVisible = this.model.wall.isVisibleProperty.get();
- var thisInducingAndVisible = this.balloonModel.inducingChargeAndVisible();
- var otherInducingAndVisible = this.balloonModel.other.inducingChargeAndVisible();
+ const thisInducingAndVisible = this.balloonModel.inducingChargeAndVisible();
+ const otherInducingAndVisible = this.balloonModel.other.inducingChargeAndVisible();
- var inducedChargeString;
+ let inducedChargeString;
if ( thisInducingAndVisible && otherInducingAndVisible && this.model.getBalloonsAdjacent() ) {
// if both inducing charge, combine induced charge description with "both balloons"
@@ -626,13 +626,13 @@ define( require => {
* @returns {string}
*/
getVelocityString: function() {
- var velocityString;
+ let velocityString;
- var balloonVelocity = this.balloonModel.velocityProperty.get();
+ const balloonVelocity = this.balloonModel.velocityProperty.get();
- var keys = Object.keys( BALLOON_VELOCITY_MAP );
- for ( var i = 0; i < keys.length; i++ ) {
- var entry = BALLOON_VELOCITY_MAP[ keys[ i ] ];
+ const keys = Object.keys( BALLOON_VELOCITY_MAP );
+ for ( let i = 0; i < keys.length; i++ ) {
+ const entry = BALLOON_VELOCITY_MAP[ keys[ i ] ];
if ( entry.range.contains( balloonVelocity.magnitude ) ) {
velocityString = entry.description;
break;
@@ -652,7 +652,7 @@ define( require => {
* @returns {string}
*/
getDraggingDirectionDescription: function( direction ) {
- var movementString = BALLOON_DIRECTION_DRAGGING_MAP[ direction ];
+ const movementString = BALLOON_DIRECTION_DRAGGING_MAP[ direction ];
assert && assert( movementString, 'no direction description found for balloon moving direction ' + direction );
return movementString;
@@ -665,7 +665,7 @@ define( require => {
* @param {string} direction - one of BalloonDirectionEnum
*/
getReleaseDirectionDescription: function( direction ) {
- var movementString = BALLOON_DIRECTION_RELEASE_MAP[ direction ];
+ const movementString = BALLOON_DIRECTION_RELEASE_MAP[ direction ];
assert && assert( movementString, 'no direction description found for balloon moving direction ' + direction );
return movementString;
@@ -679,11 +679,11 @@ define( require => {
*/
getPlayAreaDragNewRegionDescription: function() {
- var nearOrAt = this.getPreposition();
- var balloonCenter = this.balloonModel.getCenter();
+ const nearOrAt = this.getPreposition();
+ const balloonCenter = this.balloonModel.getCenter();
- var wallVisible = this.model.wall.isVisibleProperty.get();
- var locationString = BASEDescriber.getLocationDescription( balloonCenter, wallVisible );
+ const wallVisible = this.model.wall.isVisibleProperty.get();
+ const locationString = BASEDescriber.getLocationDescription( balloonCenter, wallVisible );
return StringUtils.fillIn( balloonNewRegionPatternString, {
nearOrAt: nearOrAt,
@@ -697,14 +697,14 @@ define( require => {
* @returns {string}
*/
getPlayAreaDragProgressDescription: function() {
- var alert;
- var nearestObjectString;
+ let alert;
+ let nearestObjectString;
- var centerPlayAreaX = PlayAreaMap.X_LOCATIONS.AT_CENTER_PLAY_AREA;
- var centerPlayAreaY = PlayAreaMap.Y_LOCATIONS.AT_CENTER_PLAY_AREA;
- var balloonCenterX = this.balloonModel.getCenterX();
- var balloonCenterY = this.balloonModel.getCenterY();
- var balloonDirection = this.balloonModel.directionProperty.get();
+ const centerPlayAreaX = PlayAreaMap.X_LOCATIONS.AT_CENTER_PLAY_AREA;
+ const centerPlayAreaY = PlayAreaMap.Y_LOCATIONS.AT_CENTER_PLAY_AREA;
+ const balloonCenterX = this.balloonModel.getCenterX();
+ const balloonCenterY = this.balloonModel.getCenterY();
+ const balloonDirection = this.balloonModel.directionProperty.get();
if ( balloonDirection === BalloonDirectionEnum.LEFT ) {
@@ -755,9 +755,9 @@ define( require => {
* @returns {string}
*/
getDirectionChangedDescription: function() {
- var description;
+ let description;
- var direction = this.balloonModel.directionProperty.get();
+ const direction = this.balloonModel.directionProperty.get();
if ( this.balloonModel.isDraggedProperty.get() ) {
// when dragged, just the direction
@@ -766,7 +766,7 @@ define( require => {
else {
// when not dragged, add 'Now' to direction
- var directionString = this.getReleaseDirectionDescription( direction );
+ const directionString = this.getReleaseDirectionDescription( direction );
if ( this.model.bothBalloonsVisible() ) {
description = StringUtils.fillIn( twoBalloonNowDirectionPatternString, {
balloon: this.accessibleName,
@@ -795,19 +795,19 @@ define( require => {
* @returns {string}
*/
getMovementStopsDescription: function() {
- var descriptionString;
+ let descriptionString;
// the location string is used for all charge views, used as a single sentence
- var locationString = this.getAttractiveStateAndLocationDescriptionWithLabel();
+ const locationString = this.getAttractiveStateAndLocationDescriptionWithLabel();
- var shownCharges = this.model.showChargesProperty.get();
+ const shownCharges = this.model.showChargesProperty.get();
if ( shownCharges === 'all' && this.wall.isVisibleProperty.get() ) {
// don't include information about adjacency to other balloon in this location description
- var chargeLocationString = this.getLocationDescriptionWithoutOverlap();
+ const chargeLocationString = this.getLocationDescriptionWithoutOverlap();
- var chargeString;
+ let chargeString;
if ( this.balloonModel.inducingChargeProperty.get() ) {
chargeString = WallDescriber.getInducedChargeDescription( this.balloonModel, this.accessibleName, this.wall.isVisibleProperty.get() );
}
@@ -834,7 +834,7 @@ define( require => {
* @returns {boolean}
*/
balloonMovingAtContinousDescriptionVelocity: function() {
- var velocityMagnitude = this.balloonModel.velocityProperty.get().magnitude;
+ const velocityMagnitude = this.balloonModel.velocityProperty.get().magnitude;
return velocityMagnitude < BALLOON_VELOCITY_MAP.QUICKLY_RANGE.range.max &&
velocityMagnitude > 0.0005; // value chosen empirically, see #413
},
@@ -850,13 +850,13 @@ define( require => {
* @returns {string}
*/
getGrabbedAlert: function() {
- var description;
+ let description;
// charges visible in the view
- var chargesShown = this.model.showChargesProperty.get();
+ const chargesShown = this.model.showChargesProperty.get();
// attractive state and location is described for every charge view, it is a single sentence in this use case
- var stateAndLocation = this.getOnLocationDescription();
+ let stateAndLocation = this.getOnLocationDescription();
stateAndLocation = StringUtils.fillIn( singleStatementPatternString, {
statement: stateAndLocation
} );
@@ -864,7 +864,7 @@ define( require => {
// get a description of the relative charge of the grabbed balloon, and possibly the other relative charge
// of the other balloon if visible
if ( chargesShown !== 'none' ) {
- var chargeDescription;
+ let chargeDescription;
if ( this.model.getBalloonsAdjacent() ) {
chargeDescription = this.balloonDescriber.chargeDescriber.getCombinedRelativeChargeDescription();
@@ -878,10 +878,10 @@ define( require => {
} );
// if the balloon is inducing charge, or touching the sweater or wall we include a description for this
- var inducingChargeOrTouchingWall = this.balloonModel.inducingChargeProperty.get() || this.balloonModel.touchingWall();
- var onSweater = this.balloonModel.onSweater();
+ const inducingChargeOrTouchingWall = this.balloonModel.inducingChargeProperty.get() || this.balloonModel.touchingWall();
+ const onSweater = this.balloonModel.onSweater();
if ( inducingChargeOrTouchingWall || onSweater && ( chargesShown !== 'none' ) ) {
- var otherObjectCharge = this.balloonDescriber.chargeDescriber.getOtherObjectChargeDescription();
+ const otherObjectCharge = this.balloonDescriber.chargeDescriber.getOtherObjectChargeDescription();
chargeDescription = StringUtils.fillIn( grabbedWithOtherChargePatternString, {
balloonCharge: chargeDescription,
otherObjectCharge: otherObjectCharge
@@ -924,10 +924,10 @@ define( require => {
* @returns {string}
*/
getJumpingDescription: function( center ) {
- var description = '';
+ let description = '';
// all jumping is in the x direction
- var centerX = center.x;
+ const centerX = center.x;
// determine which description we should use depending on the center location of the balloon
if ( centerX === PlayAreaMap.X_LOCATIONS.AT_NEAR_SWEATER ) {
@@ -936,12 +936,12 @@ define( require => {
else {
// general location description for the balloon
- var locationDescription = this.getAttractiveStateAndLocationDescription();
+ const locationDescription = this.getAttractiveStateAndLocationDescription();
// state variables used to generate description content
- var wallVisible = this.wall.isVisibleProperty.get();
- var inducingCharge = this.balloonModel.inducingChargeProperty.get();
- var showCharges = this.model.showChargesProperty.get();
+ const wallVisible = this.wall.isVisibleProperty.get();
+ const inducingCharge = this.balloonModel.inducingChargeProperty.get();
+ const showCharges = this.model.showChargesProperty.get();
// if jumping to wall, describe as if balloon is rubbing along the wall for the first time
if ( this.balloonModel.touchingWallProperty.get() && showCharges !== 'none') {
@@ -957,7 +957,7 @@ define( require => {
else if ( wallVisible && inducingCharge && showCharges === 'all' ) {
// if there is an induced charge and the charges are visible, describe induced charge summary
- var inducedChargeDescription = WallDescriber.getInducedChargeDescriptionWithNoAmount( this.balloonModel, this.accessibleName, wallVisible );
+ const inducedChargeDescription = WallDescriber.getInducedChargeDescriptionWithNoAmount( this.balloonModel, this.accessibleName, wallVisible );
description = StringUtils.fillIn( locationAndInducedChargePatternString, {
location: locationDescription,
inducedCharge: inducedChargeDescription
diff --git a/js/balloons-and-static-electricity/view/describers/SweaterDescriber.js b/js/balloons-and-static-electricity/view/describers/SweaterDescriber.js
index dc44648c..0a7a96da 100644
--- a/js/balloons-and-static-electricity/view/describers/SweaterDescriber.js
+++ b/js/balloons-and-static-electricity/view/describers/SweaterDescriber.js
@@ -20,34 +20,34 @@ define( require => {
const StringUtils = require( 'PHETCOMMON/util/StringUtils' );
// strings
- var sweaterLocationString = BASEA11yStrings.sweaterLocation.value;
- var zeroString = BASEA11yStrings.zero.value;
- var manyString = BASEA11yStrings.many.value;
- var allString = BASEA11yStrings.all.value;
- var positiveString = BASEA11yStrings.positive.value;
- var sweaterDescriptionPatternString = BASEA11yStrings.sweaterDescriptionPattern.value;
- var sweaterRelativeChargeAllPatternString = BASEA11yStrings.sweaterRelativeChargeAllPattern.value;
- var sweaterRelativeChargeDifferencesPatternString = BASEA11yStrings.sweaterRelativeChargeDifferencesPattern.value;
- var sweaterNoMoreChargesString = BASEA11yStrings.sweaterNoMoreCharges.value;
- var sweaterNetChargePatternString = BASEA11yStrings.sweaterNetChargePattern.value;
- var sweaterChargePatternString = BASEA11yStrings.sweaterChargePattern.value;
- var showingNoChargesString = BASEA11yStrings.showingNoCharges.value;
- var sweaterHasRelativeChargePatternString = BASEA11yStrings.sweaterHasRelativeChargePattern.value;
- var sweaterHasNetChargeShowingPatternString = BASEA11yStrings.sweaterHasNetChargeShowingPattern.value;
- var moreChargesPatternString = BASEA11yStrings.moreChargesPattern.value;
- var moreChargesFurtherPatternString = BASEA11yStrings.moreChargesFurtherPattern.value;
- var morePairsOfChargesString = BASEA11yStrings.morePairsOfCharges.value;
- var sweaterLabelString = BASEA11yStrings.sweaterLabel.value;
- var moreHiddenPairsOfChargesString = BASEA11yStrings.moreHiddenPairsOfCharges.value;
- var positiveNetChargeString = BASEA11yStrings.positiveNetCharge.value;
- var neutralNetChargeString = BASEA11yStrings.neutralNetCharge.value;
- var summaryObjectHasChargePatternString = BASEA11yStrings.summaryObjectHasChargePattern.value;
- var sweaterRelativeChargePatternString = BASEA11yStrings.sweaterRelativeChargePattern.value;
- var summaryObjectChargePatternString = BASEA11yStrings.summaryObjectChargePattern.value;
- var summaryNeutralChargesPatternString = BASEA11yStrings.summaryNeutralChargesPattern.value;
- var sweaterShowingPatternString = BASEA11yStrings.sweaterShowingPattern.value;
- var showingAllPositiveChargesString = BASEA11yStrings.showingAllPositiveCharges.value;
- var singleStatementPatternString = BASEA11yStrings.singleStatementPattern.value;
+ const sweaterLocationString = BASEA11yStrings.sweaterLocation.value;
+ const zeroString = BASEA11yStrings.zero.value;
+ const manyString = BASEA11yStrings.many.value;
+ const allString = BASEA11yStrings.all.value;
+ const positiveString = BASEA11yStrings.positive.value;
+ const sweaterDescriptionPatternString = BASEA11yStrings.sweaterDescriptionPattern.value;
+ const sweaterRelativeChargeAllPatternString = BASEA11yStrings.sweaterRelativeChargeAllPattern.value;
+ const sweaterRelativeChargeDifferencesPatternString = BASEA11yStrings.sweaterRelativeChargeDifferencesPattern.value;
+ const sweaterNoMoreChargesString = BASEA11yStrings.sweaterNoMoreCharges.value;
+ const sweaterNetChargePatternString = BASEA11yStrings.sweaterNetChargePattern.value;
+ const sweaterChargePatternString = BASEA11yStrings.sweaterChargePattern.value;
+ const showingNoChargesString = BASEA11yStrings.showingNoCharges.value;
+ const sweaterHasRelativeChargePatternString = BASEA11yStrings.sweaterHasRelativeChargePattern.value;
+ const sweaterHasNetChargeShowingPatternString = BASEA11yStrings.sweaterHasNetChargeShowingPattern.value;
+ const moreChargesPatternString = BASEA11yStrings.moreChargesPattern.value;
+ const moreChargesFurtherPatternString = BASEA11yStrings.moreChargesFurtherPattern.value;
+ const morePairsOfChargesString = BASEA11yStrings.morePairsOfCharges.value;
+ const sweaterLabelString = BASEA11yStrings.sweaterLabel.value;
+ const moreHiddenPairsOfChargesString = BASEA11yStrings.moreHiddenPairsOfCharges.value;
+ const positiveNetChargeString = BASEA11yStrings.positiveNetCharge.value;
+ const neutralNetChargeString = BASEA11yStrings.neutralNetCharge.value;
+ const summaryObjectHasChargePatternString = BASEA11yStrings.summaryObjectHasChargePattern.value;
+ const sweaterRelativeChargePatternString = BASEA11yStrings.sweaterRelativeChargePattern.value;
+ const summaryObjectChargePatternString = BASEA11yStrings.summaryObjectChargePattern.value;
+ const summaryNeutralChargesPatternString = BASEA11yStrings.summaryNeutralChargesPattern.value;
+ const sweaterShowingPatternString = BASEA11yStrings.sweaterShowingPattern.value;
+ const showingAllPositiveChargesString = BASEA11yStrings.showingAllPositiveCharges.value;
+ const singleStatementPatternString = BASEA11yStrings.singleStatementPattern.value;
/**
* Manages all descriptions relating to the sweater.
@@ -76,7 +76,7 @@ define( require => {
* @returns {string}
*/
getSweaterDescription: function( showCharges ) {
- var description;
+ let description;
// if we are not showing any charges, just return a description for the location
if ( showCharges === 'none' ) {
@@ -84,15 +84,15 @@ define( require => {
}
// relative charge like "no" or "several"
- var sweaterCharge = this.sweaterModel.chargeProperty.get();
- var relativeChargeString = BASEDescriber.getRelativeChargeDescription( sweaterCharge );
+ const sweaterCharge = this.sweaterModel.chargeProperty.get();
+ const relativeChargeString = BASEDescriber.getRelativeChargeDescription( sweaterCharge );
// assemble net charge string, like "Has zero net charge"
- var netChargeString = StringUtils.fillIn( sweaterNetChargePatternString, {
+ const netChargeString = StringUtils.fillIn( sweaterNetChargePatternString, {
netCharge: sweaterCharge > 0 ? positiveString : zeroString
} );
- var chargeString;
+ let chargeString;
if ( showCharges === 'all' ) {
// special case - if sweater is totally out of charges, say "no more negative charges, only positive charges""
@@ -155,11 +155,11 @@ define( require => {
* @returns {string}
*/
getRelativeChargeDescriptionWithLabel: function( charge, shownCharges ) {
- var description;
+ let description;
// the relative charge on the sweater, something like 'several' or 'many'
- var absCharge = Math.abs( charge );
- var relative = SweaterDescriber.getRelativeChargeDescription( absCharge );
+ const absCharge = Math.abs( charge );
+ const relative = SweaterDescriber.getRelativeChargeDescription( absCharge );
if ( shownCharges === 'all' ) {
if ( absCharge === BASEConstants.MAX_BALLOON_CHARGE ) {
@@ -172,7 +172,7 @@ define( require => {
else {
// else something like "Sweater has several more positive charges than negative charges"
- var relativeChargeString = StringUtils.fillIn( sweaterRelativeChargeAllPatternString, {
+ const relativeChargeString = StringUtils.fillIn( sweaterRelativeChargeAllPatternString, {
charge: relative
} );
@@ -182,7 +182,7 @@ define( require => {
}
}
else if ( shownCharges === 'diff' ) {
- var showingString = StringUtils.fillIn( sweaterRelativeChargeDifferencesPatternString, {
+ const showingString = StringUtils.fillIn( sweaterRelativeChargeDifferencesPatternString, {
charge: relative
} );
@@ -220,7 +220,7 @@ define( require => {
* @returns {string}
*/
getNoMoreChargesAlert: function( charge, shownCharges ) {
- var alert;
+ let alert;
if ( shownCharges === 'all' ) {
alert = StringUtils.fillIn( sweaterHasRelativeChargePatternString, {
relativeCharge: sweaterNoMoreChargesString
@@ -242,7 +242,7 @@ define( require => {
* @returns {string}
*/
getNetChargeDescription: function( sweaterCharge ) {
- var relativeChargeString = ( sweaterCharge === 0 ) ? neutralNetChargeString : positiveNetChargeString;
+ const relativeChargeString = ( sweaterCharge === 0 ) ? neutralNetChargeString : positiveNetChargeString;
return StringUtils.fillIn( sweaterHasRelativeChargePatternString, {
relativeCharge: relativeChargeString
} );
@@ -264,8 +264,8 @@ define( require => {
assert && assert( shownCharges !== 'none', 'this description should not be used when no charges are shown' );
// get the next charge to describe
- var charge;
- for ( var i = 0; i < sweaterCharges.length; i++ ) {
+ let charge;
+ for ( let i = 0; i < sweaterCharges.length; i++ ) {
charge = sweaterCharges[ i ];
if ( !charge.movedProperty.get() ) {
break;
@@ -273,12 +273,12 @@ define( require => {
}
// get the description of the direction to the closest charge
- var direction = BalloonModel.getDirection( charge.location, balloon.getCenter() );
- var directionDescription = BASEDescriber.getDirectionDescription( direction );
+ const direction = BalloonModel.getDirection( charge.location, balloon.getCenter() );
+ const directionDescription = BASEDescriber.getDirectionDescription( direction );
- var patternString = BalloonDirectionEnum.isRelativeDirection( direction ) ? moreChargesFurtherPatternString : moreChargesPatternString;
+ const patternString = BalloonDirectionEnum.isRelativeDirection( direction ) ? moreChargesFurtherPatternString : moreChargesPatternString;
- var moreChargesString;
+ let moreChargesString;
if ( shownCharges === 'all' ) {
moreChargesString = morePairsOfChargesString;
}
@@ -304,15 +304,15 @@ define( require => {
getSummaryChargeDescription: function( chargesShown, charge ) {
// description of the sweater object, like "Sweater has zero net charge"
- var chargeSignString = charge > 0 ? positiveString : zeroString;
- var sweaterObjectString = StringUtils.fillIn( summaryObjectHasChargePatternString, {
+ const chargeSignString = charge > 0 ? positiveString : zeroString;
+ const sweaterObjectString = StringUtils.fillIn( summaryObjectHasChargePatternString, {
object: sweaterLabelString,
charge: chargeSignString
} );
// description of the charges shown, like 'a few more positive charges than negative charges'
- var chargeString;
- var relativeChargeString = BASEDescriber.getRelativeChargeDescription( charge );
+ let chargeString;
+ const relativeChargeString = BASEDescriber.getRelativeChargeDescription( charge );
if ( chargesShown === 'all' ) {
chargeString = ( charge === 0 ) ?
StringUtils.fillIn( summaryNeutralChargesPatternString, { amount: manyString } ) :
diff --git a/js/balloons-and-static-electricity/view/describers/SweaterDescriberTests.js b/js/balloons-and-static-electricity/view/describers/SweaterDescriberTests.js
index 9f85f0ba..3541f7b7 100644
--- a/js/balloons-and-static-electricity/view/describers/SweaterDescriberTests.js
+++ b/js/balloons-and-static-electricity/view/describers/SweaterDescriberTests.js
@@ -18,16 +18,16 @@ define( require => {
QUnit.module( 'SweaterDescriberTests' );
// create model and view for testing
- var model = new BASEModel( 768, 504, Tandem.rootTandem.createTandem( 'model' ) );
+ const model = new BASEModel( 768, 504, Tandem.rootTandem.createTandem( 'model' ) );
// create a wallNode for testing
- var sweaterNode = new SweaterNode( model, Tandem.rootTandem.createTandem( 'sweaterNode' ) );
+ const sweaterNode = new SweaterNode( model, Tandem.rootTandem.createTandem( 'sweaterNode' ) );
QUnit.test( 'SweaterDescriber tests', function( assert ) {
// on load
- var actualDescription = sweaterNode.descriptionContent;
- var expectedDescription = 'At left edge of Play Area. Has zero net charge, no more positive charges than negative charges.';
+ let actualDescription = sweaterNode.descriptionContent;
+ let expectedDescription = 'At left edge of Play Area. Has zero net charge, no more positive charges than negative charges.';
assert.equal( actualDescription, expectedDescription );
// all charges shown, several positive charges
diff --git a/js/balloons-and-static-electricity/view/describers/WallDescriber.js b/js/balloons-and-static-electricity/view/describers/WallDescriber.js
index 93b4d722..8271a9f9 100644
--- a/js/balloons-and-static-electricity/view/describers/WallDescriber.js
+++ b/js/balloons-and-static-electricity/view/describers/WallDescriber.js
@@ -19,34 +19,34 @@ define( require => {
const Vector2 = require( 'DOT/Vector2' );
// strings
- var wallDescriptionPatternString = BASEA11yStrings.wallDescriptionPattern.value;
- var wallLocationString = BASEA11yStrings.wallLocation.value;
- var wallNoNetChargeString = BASEA11yStrings.wallNoNetCharge.value;
- var aLittleBitString = BASEA11yStrings.aLittleBit.value;
- var aLotString = BASEA11yStrings.aLot.value;
- var quiteALotString = BASEA11yStrings.quiteALot.value;
- var inducedChargePatternString = BASEA11yStrings.inducedChargePattern.value;
- var greenBalloonLabelString = BASEA11yStrings.greenBalloonLabel.value;
- var yellowBalloonLabelString = BASEA11yStrings.yellowBalloonLabel.value;
- var wallTwoBalloonInducedChargePatternString = BASEA11yStrings.wallTwoBalloonInducedChargePattern.value;
- var wallChargeWithoutInducedPatternString = BASEA11yStrings.wallChargeWithoutInducedPattern.value;
- var wallChargeWithInducedPatternString = BASEA11yStrings.wallChargeWithInducedPattern.value;
- var showingNoChargesString = BASEA11yStrings.showingNoCharges.value;
- var manyChargePairsString = BASEA11yStrings.manyChargePairs.value;
- var singleStatementPatternString = BASEA11yStrings.singleStatementPattern.value;
- var wallNoChangeInChargesPatternString = BASEA11yStrings.wallNoChangeInChargesPattern.value;
- var inducedChargeNoAmountPatternString = BASEA11yStrings.inducedChargeNoAmountPattern.value;
- var wallChargePatternStringWithLabel = BASEA11yStrings.wallChargePatternStringWithLabel.value;
- var summaryObjectHasChargePatternString = BASEA11yStrings.summaryObjectHasChargePattern.value;
- var summaryObjectChargePatternString = BASEA11yStrings.summaryObjectChargePattern.value;
- var wallLabelString = BASEA11yStrings.wallLabel.value;
- var zeroString = BASEA11yStrings.zero.value;
- var bothBalloonsString = BASEA11yStrings.bothBalloons.value;
- var wallInducedChargeSummaryPatternString = BASEA11yStrings.wallInducedChargeSummaryPattern.value;
- var positiveChargesDoNotMoveString = BASEA11yStrings.positiveChargesDoNotMove.value;
+ const wallDescriptionPatternString = BASEA11yStrings.wallDescriptionPattern.value;
+ const wallLocationString = BASEA11yStrings.wallLocation.value;
+ const wallNoNetChargeString = BASEA11yStrings.wallNoNetCharge.value;
+ const aLittleBitString = BASEA11yStrings.aLittleBit.value;
+ const aLotString = BASEA11yStrings.aLot.value;
+ const quiteALotString = BASEA11yStrings.quiteALot.value;
+ const inducedChargePatternString = BASEA11yStrings.inducedChargePattern.value;
+ const greenBalloonLabelString = BASEA11yStrings.greenBalloonLabel.value;
+ const yellowBalloonLabelString = BASEA11yStrings.yellowBalloonLabel.value;
+ const wallTwoBalloonInducedChargePatternString = BASEA11yStrings.wallTwoBalloonInducedChargePattern.value;
+ const wallChargeWithoutInducedPatternString = BASEA11yStrings.wallChargeWithoutInducedPattern.value;
+ const wallChargeWithInducedPatternString = BASEA11yStrings.wallChargeWithInducedPattern.value;
+ const showingNoChargesString = BASEA11yStrings.showingNoCharges.value;
+ const manyChargePairsString = BASEA11yStrings.manyChargePairs.value;
+ const singleStatementPatternString = BASEA11yStrings.singleStatementPattern.value;
+ const wallNoChangeInChargesPatternString = BASEA11yStrings.wallNoChangeInChargesPattern.value;
+ const inducedChargeNoAmountPatternString = BASEA11yStrings.inducedChargeNoAmountPattern.value;
+ const wallChargePatternStringWithLabel = BASEA11yStrings.wallChargePatternStringWithLabel.value;
+ const summaryObjectHasChargePatternString = BASEA11yStrings.summaryObjectHasChargePattern.value;
+ const summaryObjectChargePatternString = BASEA11yStrings.summaryObjectChargePattern.value;
+ const wallLabelString = BASEA11yStrings.wallLabel.value;
+ const zeroString = BASEA11yStrings.zero.value;
+ const bothBalloonsString = BASEA11yStrings.bothBalloons.value;
+ const wallInducedChargeSummaryPatternString = BASEA11yStrings.wallInducedChargeSummaryPattern.value;
+ const positiveChargesDoNotMoveString = BASEA11yStrings.positiveChargesDoNotMove.value;
// constants
- var INDUCED_CHARGE_DESCRIPTION_MAP = {
+ const INDUCED_CHARGE_DESCRIPTION_MAP = {
A_LITTLE_BIT: {
range: new Range( 0, 10 ),
description: aLittleBitString
@@ -96,7 +96,7 @@ define( require => {
* @returns {string}
*/
getWallDescription: function( yellowBalloon, greenBalloon, balloonsAdjacent ) {
- var description;
+ let description;
// if no charges are shown, the location is the only part of the description
if ( this.showChargesProperty.get() === 'none' ) {
@@ -105,7 +105,7 @@ define( require => {
} );
}
else {
- var chargeDescription = WallDescriber.getWallChargeDescription( yellowBalloon, greenBalloon, balloonsAdjacent, this.wallModel.isVisibleProperty.get(), this.showChargesProperty.get() );
+ const chargeDescription = WallDescriber.getWallChargeDescription( yellowBalloon, greenBalloon, balloonsAdjacent, this.wallModel.isVisibleProperty.get(), this.showChargesProperty.get() );
// assemble the whole description
description = StringUtils.fillIn( wallDescriptionPatternString, {
@@ -125,14 +125,14 @@ define( require => {
* @returns {string}
*/
getWallChargeDescription: function( yellowBalloon, greenBalloon, balloonsAdjacent, wallVisible, chargesShown ) {
- var descriptionString;
+ let descriptionString;
- var inducedChargeString;
- var yellowBalloonInducedChargeString;
- var greenBalloonInducedChargeString;
+ let inducedChargeString;
+ let yellowBalloonInducedChargeString;
+ let greenBalloonInducedChargeString;
- var yellowInducingAndvisible = yellowBalloon.inducingChargeAndVisible();
- var greenInducingAndVisible = greenBalloon.inducingChargeAndVisible();
+ const yellowInducingAndvisible = yellowBalloon.inducingChargeAndVisible();
+ const greenInducingAndVisible = greenBalloon.inducingChargeAndVisible();
// if all charges are shown, and a balloon is inducing charge, generate the description for induced charge which
// can change depending on whether balloons are adjacent or whether both balloons are inducing at the same time
@@ -180,10 +180,10 @@ define( require => {
}
// get the description for what charges are currently shown
- var shownChargesString = ( chargesShown === 'diff' ) ? showingNoChargesString : manyChargePairsString;
+ const shownChargesString = ( chargesShown === 'diff' ) ? showingNoChargesString : manyChargePairsString;
// if there is an induced charge, include it in the full charge description
- var wallChargeString;
+ let wallChargeString;
if ( ( yellowBalloon.inducingChargeProperty.get() || greenInducingAndVisible ) && chargesShown === 'all' && wallVisible ) {
inducedChargeString = StringUtils.fillIn( wallInducedChargeSummaryPatternString, {
inducedCharge: inducedChargeString,
@@ -220,7 +220,7 @@ define( require => {
* @returns {string}
*/
getWallChargeDescriptionWithLabel: function( yellowBalloon, greenBalloon, balloonsAdjacent, wallVisible, chargesShown ) {
- var description = WallDescriber.getWallChargeDescription( yellowBalloon, greenBalloon, balloonsAdjacent, wallVisible, chargesShown );
+ let description = WallDescriber.getWallChargeDescription( yellowBalloon, greenBalloon, balloonsAdjacent, wallVisible, chargesShown );
description = description.toLowerCase();
return StringUtils.fillIn( wallChargePatternStringWithLabel, {
@@ -236,10 +236,10 @@ define( require => {
*/
getInducedChargeAmountDescription: function( balloon ) {
- var amountDescription;
- var descriptionKeys = Object.keys( INDUCED_CHARGE_DESCRIPTION_MAP );
- for ( var j = 0; j < descriptionKeys.length; j++ ) {
- var value = INDUCED_CHARGE_DESCRIPTION_MAP[ descriptionKeys[ j ] ];
+ let amountDescription;
+ const descriptionKeys = Object.keys( INDUCED_CHARGE_DESCRIPTION_MAP );
+ for ( let j = 0; j < descriptionKeys.length; j++ ) {
+ const value = INDUCED_CHARGE_DESCRIPTION_MAP[ descriptionKeys[ j ] ];
if ( value.range.contains( balloon.closestChargeInWall.getDisplacement() ) ) {
amountDescription = value.description;
}
@@ -270,9 +270,9 @@ define( require => {
* @returns {string}
*/
getInducedChargeDescriptionWithNoAmount: function( balloon, balloonLabel, wallVisible ) {
- var descriptionString;
+ let descriptionString;
- var chargeLocationString = WallDescriber.getInducedChargeLocationDescription( balloon, wallVisible, true );
+ const chargeLocationString = WallDescriber.getInducedChargeLocationDescription( balloon, wallVisible, true );
if ( balloon.inducingChargeProperty.get() ) {
descriptionString = StringUtils.fillIn( inducedChargeNoAmountPatternString, {
wallLocation: chargeLocationString,
@@ -309,11 +309,11 @@ define( require => {
includePositiveChargeInfo: true // include information about positive charges how positive charges do not move?
}, options );
- var descriptionString;
- var chargeLocationString = WallDescriber.getInducedChargeLocationDescription( balloon, wallVisible, options.includeWallLocation );
+ let descriptionString;
+ const chargeLocationString = WallDescriber.getInducedChargeLocationDescription( balloon, wallVisible, options.includeWallLocation );
if ( balloon.inducingChargeProperty.get() ) {
- var inducedChargeAmount = WallDescriber.getInducedChargeAmountDescription( balloon );
+ const inducedChargeAmount = WallDescriber.getInducedChargeAmountDescription( balloon );
descriptionString = StringUtils.fillIn( inducedChargePatternString, {
wallLocation: chargeLocationString,
@@ -356,10 +356,10 @@ define( require => {
includeWallLocation: true,
includePositiveChargeInfo: true
}, options );
- var descriptionString;
- var chargeLocationString = WallDescriber.getInducedChargeLocationDescription( balloon, wallVisible, options.includeWallLocation );
+ let descriptionString;
+ const chargeLocationString = WallDescriber.getInducedChargeLocationDescription( balloon, wallVisible, options.includeWallLocation );
- var inducedChargeAmount = WallDescriber.getInducedChargeAmountDescription( balloon );
+ const inducedChargeAmount = WallDescriber.getInducedChargeAmountDescription( balloon );
descriptionString = StringUtils.fillIn( inducedChargePatternString, {
wallLocation: chargeLocationString,
@@ -397,9 +397,9 @@ define( require => {
* @returns {[type]} [description]
*/
getInducedChargeLocationDescription: function( balloon, wallVisible, includeWallLocation ) {
- var chargeLocationX = PlayAreaMap.X_LOCATIONS.AT_WALL;
- var chargeLocationY = includeWallLocation ? balloon.getCenterY() : PlayAreaMap.ROW_RANGES.CENTER_PLAY_AREA.getCenter();
- var chargeLocation = new Vector2( chargeLocationX, chargeLocationY );
+ const chargeLocationX = PlayAreaMap.X_LOCATIONS.AT_WALL;
+ const chargeLocationY = includeWallLocation ? balloon.getCenterY() : PlayAreaMap.ROW_RANGES.CENTER_PLAY_AREA.getCenter();
+ const chargeLocation = new Vector2( chargeLocationX, chargeLocationY );
return BASEDescriber.getLocationDescription( chargeLocation, wallVisible );
},
@@ -412,9 +412,9 @@ define( require => {
* @returns {string}
*/
getSummaryChargeDescription: function( chargesShown, numberOfCharges ) {
- var chargeString = BASEDescriber.getNeutralChargesShownDescription( chargesShown, numberOfCharges );
+ const chargeString = BASEDescriber.getNeutralChargesShownDescription( chargesShown, numberOfCharges );
- var wallObjectString = StringUtils.fillIn( summaryObjectHasChargePatternString, {
+ const wallObjectString = StringUtils.fillIn( summaryObjectHasChargePatternString, {
object: wallLabelString,
charge: zeroString
} );
diff --git a/js/balloons-and-static-electricity/view/describers/WallDescriberTests.js b/js/balloons-and-static-electricity/view/describers/WallDescriberTests.js
index dd5e5bfa..ebaa6eeb 100644
--- a/js/balloons-and-static-electricity/view/describers/WallDescriberTests.js
+++ b/js/balloons-and-static-electricity/view/describers/WallDescriberTests.js
@@ -21,17 +21,17 @@ define( require => {
QUnit.module( 'WallDescriberTests' );
// create model and view for testing
- var model = new BASEModel( 768, 504, Tandem.rootTandem.createTandem( 'model' ) );
- var view = new BASEView( model, Tandem.rootTandem.createTandem( 'view' ) );
+ const model = new BASEModel( 768, 504, Tandem.rootTandem.createTandem( 'model' ) );
+ const view = new BASEView( model, Tandem.rootTandem.createTandem( 'view' ) );
QUnit.test( 'WallDescriber tests', function( assert ) {
// create a view
- var wallNode = new WallNode( model, view.layoutBounds, Tandem.rootTandem.createTandem( 'wallNode' ) );
+ const wallNode = new WallNode( model, view.layoutBounds, Tandem.rootTandem.createTandem( 'wallNode' ) );
// on page load
- var actualDescription = wallNode.descriptionContent;
- var expectedDescription = 'At right edge of Play Area. Has zero net charge, many pairs of negative and positive charges.';
+ let actualDescription = wallNode.descriptionContent;
+ let expectedDescription = 'At right edge of Play Area. Has zero net charge, many pairs of negative and positive charges.';
assert.equal( actualDescription, expectedDescription );
// yellow balloon neutral at wall, all charges shown