Skip to content

Commit

Permalink
var -> const using eslint auto fix, phetsims/tasks#1012
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Sep 19, 2019
1 parent 586ffd2 commit 3b5c3a4
Show file tree
Hide file tree
Showing 30 changed files with 439 additions and 439 deletions.
2 changes: 1 addition & 1 deletion js/common/ForcesAndMotionBasicsQueryParameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ define( require => {
// modules
const forcesAndMotionBasics = require( 'FORCES_AND_MOTION_BASICS/forcesAndMotionBasics' );

var ForcesAndMotionBasicsQueryParameters = QueryStringMachine.getAll( {
const ForcesAndMotionBasicsQueryParameters = QueryStringMachine.getAll( {

// Allow hiding the item toolboxes, see https://github.com/phetsims/forces-and-motion-basics/issues/215
showItemToolboxes: {
Expand Down
4 changes: 2 additions & 2 deletions js/common/view/ForcesAndMotionBasicsIconFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ define( require => {
/**
* Static object, not meant to be instantiated.
*/
var ForcesAndMotionBasicsIconFactory = {
const ForcesAndMotionBasicsIconFactory = {
speedometerIcon: function( tandem ) {

// the 'speed' option requires the text and a speedometer icon
var speedometerIconValueProperty = new Property( 0 );
const speedometerIconValueProperty = new Property( 0 );
return new GaugeNode( speedometerIconValueProperty, speedString, new Range( 0, MotionConstants.MAX_SPEED ),
{ radius: 67, scale: 0.2, tandem: tandem.createTandem( 'speedometerIcon' ) } );
}
Expand Down
2 changes: 1 addition & 1 deletion js/common/view/ForcesAndMotionBasicsLayoutBounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ define( require => {
const Bounds2 = require( 'DOT/Bounds2' );
const forcesAndMotionBasics = require( 'FORCES_AND_MOTION_BASICS/forcesAndMotionBasics' );

var ForcesAndMotionBasicsLayoutBounds = new Bounds2( 0, 0, 981, 604 );
const ForcesAndMotionBasicsLayoutBounds = new Bounds2( 0, 0, 981, 604 );

forcesAndMotionBasics.register( 'ForcesAndMotionBasicsLayoutBounds', ForcesAndMotionBasicsLayoutBounds );

Expand Down
26 changes: 13 additions & 13 deletions js/common/view/ReadoutArrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ define( require => {
const pattern0ValueUnitsNString = require( 'string!FORCES_AND_MOTION_BASICS/pattern.0valueUnitsN' );

// constants
var ARROW_HEAD_WIDTH = 50;
var ARROW_HEAD_HEIGHT = 25;
const ARROW_HEAD_WIDTH = 50;
const ARROW_HEAD_HEIGHT = 25;

/**
* @param label the text to show for the arrow
Expand All @@ -39,7 +39,7 @@ define( require => {
* @constructor
*/
function ReadoutArrow( label, fill, tailX, tailY, valueProperty, showValuesProperty, tandem, options ) {
var self = this;
const self = this;

//Store fields
options = _.extend( { labelPosition: 'top', arrowScale: 1 }, options );
Expand All @@ -61,7 +61,7 @@ define( require => {
lineWidth: 1,
tandem: tandem.createTandem( 'arrowNode' )
}, options ) );
var fontOptions = { font: new PhetFont( { size: 16, weight: 'bold' } ), maxWidth: 112 };
const fontOptions = { font: new PhetFont( { size: 16, weight: 'bold' } ), maxWidth: 112 };
this.valueNode = new Text( '110N', _.extend( { tandem: tandem.createTandem( 'valueTextNode' ) }, fontOptions ) );
this.labelNode = new Text( label, _.extend( { tandem: tandem.createTandem( 'labelTextNode' ) }, fontOptions ) );
this.addChild( this.arrowNode );
Expand All @@ -71,7 +71,7 @@ define( require => {
//Update when the value changes
valueProperty.link( function( value ) {
self.value = value;
var roundedValue = Util.toFixed( Math.abs( value ), 0 );
const roundedValue = Util.toFixed( Math.abs( value ), 0 );
self.valueNode.text = StringUtils.format( pattern0ValueUnitsNString, roundedValue );
self.update();
} );
Expand Down Expand Up @@ -104,24 +104,24 @@ define( require => {

//Update the arrow graphics and text labels
update: function() {
var value = this.value * this.options.arrowScale;
const value = this.value * this.options.arrowScale;

//Don't show it if it is too small
var hidden = Math.abs( value ) < 1E-6;
const hidden = Math.abs( value ) < 1E-6;
this.hidden = hidden;
this.arrowNode.visible = !hidden;
this.valueNode.visible = !hidden && this.showValuesProperty.value;
this.labelNode.visible = !hidden;

//Only change the node if visible, for performance
if ( !hidden ) {
var tailX = this.tailX;
var tailY = this.tailY;
var tailWidth = ARROW_HEAD_HEIGHT;
var headWidth = ARROW_HEAD_WIDTH;
const tailX = this.tailX;
const tailY = this.tailY;
const tailWidth = ARROW_HEAD_HEIGHT;
const headWidth = ARROW_HEAD_WIDTH;

//For short arrows, the head height should be half of the arrow length. See https://github.com/phetsims/scenery-phet/issues/30
var headHeight = Math.min( Math.abs( value ) / 2, 40 );
const headHeight = Math.min( Math.abs( value ) / 2, 40 );
this.arrowNode.shape = new ArrowShape( tailX, tailY, tailX + value, tailY,
{ tailWidth: tailWidth, headWidth: headWidth, headHeight: headHeight } );

Expand Down Expand Up @@ -167,7 +167,7 @@ define( require => {
this.labelNode.bottom = isFinite( this.arrowNode.centerY ) ? this.arrowNode.centerY - this.labelNode.height * 3 / 2 : 0;

if ( this.valueNode.width + 5 > this.arrowNode.width ) {
var spacingOffset = 5;
const spacingOffset = 5;
if ( value > 0 ) {
this.valueNode.left = this.arrowNode.right + spacingOffset;
}
Expand Down
28 changes: 14 additions & 14 deletions js/common/view/SliderKnob.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ define( require => {
this.enabledProperty = options.enabledProperty;

// different fill colors for when the slider is enabled or disabled
var enabledFillColor = '#2FB0E4';
var disabledFillColor = 'gray';
var enabledColorStop = '#B8E4FB';
var disabledColorStop = 'white';
const enabledFillColor = '#2FB0E4';
const disabledFillColor = 'gray';
const enabledColorStop = '#B8E4FB';
const disabledColorStop = 'white';

Node.call( this, {
tandem: tandem
} );

//Add the rounded rectangle background
var scale = 0.8;
var width = 20 * scale;
var height = 50 * scale;
var enabledGradient = new LinearGradient( -width / 2, 0, width / 2, 0 ).addColorStop( 0, enabledFillColor ).addColorStop( 0.5, enabledColorStop ).addColorStop( 1, enabledFillColor );
var disabledGradient = new LinearGradient( -width / 2, 0, width / 2, 0 ).addColorStop( 0, disabledFillColor ).addColorStop( 0.5, disabledColorStop ).addColorStop( 1, disabledFillColor );
const scale = 0.8;
const width = 20 * scale;
const height = 50 * scale;
const enabledGradient = new LinearGradient( -width / 2, 0, width / 2, 0 ).addColorStop( 0, enabledFillColor ).addColorStop( 0.5, enabledColorStop ).addColorStop( 1, enabledFillColor );
const disabledGradient = new LinearGradient( -width / 2, 0, width / 2, 0 ).addColorStop( 0, disabledFillColor ).addColorStop( 0.5, disabledColorStop ).addColorStop( 1, disabledFillColor );

var rectangle = new Rectangle( -width / 2, 0, width, height, 10 * scale, 10 * scale, {
const rectangle = new Rectangle( -width / 2, 0, width, height, 10 * scale, 10 * scale, {
fill: this.enabledProperty.value ? enabledGradient : 'gray',
stroke: this.enabledProperty.value ? 'black' : 'gray',
lineWidth: 2
Expand All @@ -62,8 +62,8 @@ define( require => {
} );

//add a grid of grip dots
var dx = width / 5;
var dy = height / 6;
const dx = width / 5;
const dy = height / 6;
this.addGripDot( -dx, height / 2 - dy );
this.addGripDot( dx, height / 2 - dy );
this.addGripDot( -dx, height / 2 );
Expand All @@ -80,8 +80,8 @@ define( require => {

return inherit( Node, SliderKnob, {
addGripDot: function( x, y ) {
var radius = 1.8;
var stroke = new LinearGradient( -radius, -radius, radius * 2, radius * 2 ).addColorStop( 0, 'black' ).addColorStop( 0.5, '#56889F' ).addColorStop( 1, 'white' );
const radius = 1.8;
const stroke = new LinearGradient( -radius, -radius, radius * 2, radius * 2 ).addColorStop( 0, 'black' ).addColorStop( 0.5, '#56889F' ).addColorStop( 1, 'white' );
this.addChild( new Circle( radius, {
x: x,
y: y,
Expand Down
24 changes: 12 additions & 12 deletions js/forces-and-motion-basics-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ define( require => {
const netForceString = require( 'string!FORCES_AND_MOTION_BASICS/netForce' );

// constants
var tandem = Tandem.rootTandem;
const tandem = Tandem.rootTandem;

var simOptions = {
const simOptions = {
credits: {
leadDesign: 'Ariel Paul, Noah Podolefsky',
graphicArts: 'Mariah Hermsmeyer, Sharon Siman-Tov',
Expand All @@ -47,15 +47,15 @@ define( require => {

SimLauncher.launch( function() {

var netForceScreenTandem = tandem.createTandem( 'netForceScreen' );
var motionScreenTandem = tandem.createTandem( 'motionScreen' );
var frictionScreenTandem = tandem.createTandem( 'frictionScreen' );
var accelerationScreenTandem = tandem.createTandem( 'accelerationScreen' );
const netForceScreenTandem = tandem.createTandem( 'netForceScreen' );
const motionScreenTandem = tandem.createTandem( 'motionScreen' );
const frictionScreenTandem = tandem.createTandem( 'frictionScreen' );
const accelerationScreenTandem = tandem.createTandem( 'accelerationScreen' );

//Provide the screen names as named fields so they can be easily accessed dynamically, for API features
//And lookups will still work properly even if the screens are reduced with ?screens=...
var netForceImageNode = new Image( tugIcon, { tandem: netForceScreenTandem.createTandem( 'icon' ) } );
var netForceScreen = new Screen(
const netForceImageNode = new Image( tugIcon, { tandem: netForceScreenTandem.createTandem( 'icon' ) } );
const netForceScreen = new Screen(
function() {return new NetForceModel( netForceScreenTandem.createTandem( 'model' ) );},
function( model ) {return new NetForceScreenView( model, netForceScreenTandem.createTandem( 'view' ) );}, {
name: netForceString,
Expand All @@ -64,29 +64,29 @@ define( require => {
}
);

var motionScreen = new MotionScreen( 'motion', motionScreenTandem, {
const motionScreen = new MotionScreen( 'motion', motionScreenTandem, {
name: motionString,
homeScreenIcon: new Image( motionIcon, {
tandem: motionScreenTandem.createTandem( 'icon' )
} )
} );

var frictionScreen = new MotionScreen( 'friction', frictionScreenTandem, {
const frictionScreen = new MotionScreen( 'friction', frictionScreenTandem, {
name: frictionString,
homeScreenIcon: new Image( frictionIcon, {
tandem: frictionScreenTandem.createTandem( 'icon' )
} )
} );

var accelerationScreen = new MotionScreen( 'acceleration', accelerationScreenTandem, {
const accelerationScreen = new MotionScreen( 'acceleration', accelerationScreenTandem, {
name: accelerationString,
homeScreenIcon: new Image( accelerationIcon, {
tandem: accelerationScreenTandem.createTandem( 'icon' )
} )
} );

//Create and start the sim
var sim = new Sim( forcesAndMotionBasicsTitleString, [
const sim = new Sim( forcesAndMotionBasicsTitleString, [
netForceScreen,
motionScreen,
frictionScreen,
Expand Down
2 changes: 1 addition & 1 deletion js/motion/MotionConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ define( require => {

const forcesAndMotionBasics = require( 'FORCES_AND_MOTION_BASICS/forcesAndMotionBasics' );

var MotionConstants = {
const MotionConstants = {

// The scale mapping between model units (meters) and stage coordinates, How much to translate model
// coordinates into view pixels for translating the background ground
Expand Down
10 changes: 5 additions & 5 deletions js/motion/model/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ define( require => {
* @param {boolean} mystery [description]
*/
function Item( context, name, tandem, image, mass, x, y, imageScale, homeScale, pusherInset, sittingImage, holdingImage, mystery ) {
var self = this;
const self = this;

this.name = name;

Expand Down Expand Up @@ -100,7 +100,7 @@ define( require => {
} );

// How much the object grows or shrinks when interacting with it
var minValue = homeScale || 1.0;
const minValue = homeScale || 1.0;
this.interactionScaleProperty = new NumberProperty( homeScale || 1.0, {
tandem: tandem.createTandem( 'interactionScaleProperty' ),
range: new Range( minValue, 1.3 )
Expand Down Expand Up @@ -193,13 +193,13 @@ define( require => {
}

if ( this.animationStateProperty.get().enabled ) {
var destination = new Vector2( this.animationStateProperty.get().x, this.animationStateProperty.get().y );
const destination = new Vector2( this.animationStateProperty.get().x, this.animationStateProperty.get().y );

//Make sure not to blend outside of 0..1 or it could cause overshooting and oscillation
var blendAmount = Util.clamp( 15 * dt, 0.1, 0.9 );
const blendAmount = Util.clamp( 15 * dt, 0.1, 0.9 );
this.positionProperty.set( this.positionProperty.get().blend( destination, blendAmount ) );

var distanceToTarget = this.positionProperty.get().distance( destination );
const distanceToTarget = this.positionProperty.get().distance( destination );
if ( distanceToTarget < 1 && ( this.interactionScaleProperty.get() === 1.3 || this.interactionScaleProperty.get() === this.homeScale ) ) {

//Snap to exact final destination, see #59
Expand Down
Loading

0 comments on commit 3b5c3a4

Please sign in to comment.