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 7cb765e commit caa9595
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 112 deletions.
4 changes: 2 additions & 2 deletions js/fraction-comparison-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ define( require => {
// strings
const fractionComparisonTitleString = require( 'string!FRACTION_COMPARISON/fraction-comparison.title' );

var simOptions = {
const simOptions = {
credits: {
leadDesign: 'Karina K. R. Hensberry',
softwareDevelopment: 'Sam Reid',
Expand All @@ -25,7 +25,7 @@ define( require => {
};

SimLauncher.launch( function() {
var sim = new Sim( fractionComparisonTitleString, [ new IntroScreen() ], simOptions );
const sim = new Sim( fractionComparisonTitleString, [ new IntroScreen() ], simOptions );
sim.start();
} );
} );
2 changes: 1 addition & 1 deletion js/intro/model/FractionModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ define( require => {
const StringProperty = require( 'AXON/StringProperty' );

// constants
var VALID_STATE_VALUES = [ 'start', 'dragging', 'compare' ];
const VALID_STATE_VALUES = [ 'start', 'dragging', 'compare' ];

/**
* @constructor
Expand Down
2 changes: 1 addition & 1 deletion js/intro/model/IntroModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ define( require => {
const StringProperty = require( 'AXON/StringProperty' );

// constants
var VALID_REPRESENTATION_VALUES = [
const VALID_REPRESENTATION_VALUES = [
'horizontal-bar',
'vertical-bar',
'circle',
Expand Down
34 changes: 17 additions & 17 deletions js/intro/view/CompareSeparateButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,32 @@ define( require => {
function CompareSeparateButton( compareButtonPressed, separateButtonPressed, compareBothProperty, options ) {
Node.call( this );
options = options || {};
var xTip = 20;
var yTip = 8;
var xControl = 12;
var yControl = -5;
const xTip = 20;
const yTip = 8;
const xControl = 12;
const yControl = -5;

var rightCurve = new Path( new Shape().moveTo( 0, 0 ).quadraticCurveTo( -xControl, yControl, -xTip, yTip ), { stroke: 'black', lineWidth: 3 } );
var leftCurve = new Path( new Shape().moveTo( 0, 0 ).quadraticCurveTo( xControl, yControl, xTip, yTip ), { stroke: 'black', lineWidth: 3 } );
const rightCurve = new Path( new Shape().moveTo( 0, 0 ).quadraticCurveTo( -xControl, yControl, -xTip, yTip ), { stroke: 'black', lineWidth: 3 } );
const leftCurve = new Path( new Shape().moveTo( 0, 0 ).quadraticCurveTo( xControl, yControl, xTip, yTip ), { stroke: 'black', lineWidth: 3 } );

var compareIcon = new HBox( {
const compareIcon = new HBox( {
spacing: 5, children: [
new Node( { children: [ leftCurve, createArrowhead( Math.PI / 3, new Vector2( xTip, yTip ) ) ] } ),
new Node( { children: [ rightCurve, createArrowhead( Math.PI - Math.PI / 3, new Vector2( -xTip, yTip ) ) ] } )
]
} );

var separateIcon = new HBox( {
const separateIcon = new HBox( {
spacing: 5, children: [
new Node( { children: [ leftCurve, createArrowhead( Math.PI / 3 + Math.PI * 0.5, new Vector2( 0, 0 ) ) ] } ),
new Node( { children: [ rightCurve, createArrowhead( Math.PI - Math.PI / 3 - Math.PI / 2, new Vector2( 0, 0 ) ) ] } )
]
} );

var maxWidth = Math.max( compareIcon.width, separateIcon.width );
var maxHeight = Math.max( compareIcon.height, separateIcon.height );
const maxWidth = Math.max( compareIcon.width, separateIcon.width );
const maxHeight = Math.max( compareIcon.height, separateIcon.height );

var compareButton = new RectangularPushButton( {
const compareButton = new RectangularPushButton( {
content: new Rectangle( 0, 0, maxWidth, maxHeight, {
children: [ compareIcon.mutate( { centerX: maxWidth / 2, centerY: maxHeight / 2 } ) ]
} ),
Expand All @@ -65,7 +65,7 @@ define( require => {
listener: compareButtonPressed
} );

var separateButton = new RectangularPushButton( {
const separateButton = new RectangularPushButton( {
content: new Rectangle( 0, 0, maxWidth, maxHeight, {
children: [ separateIcon.mutate( { centerX: maxWidth / 2, centerY: maxHeight / 2 } ) ]
} ),
Expand All @@ -92,11 +92,11 @@ define( require => {
* @returns {Path}
*/
var createArrowhead = function( angle, tail ) {
var headWidth = 10;
var headHeight = 10;
var directionUnitVector = Vector2.createPolar( 1, angle );
var orthogonalUnitVector = directionUnitVector.perpendicular;
var tip = directionUnitVector.times( headHeight ).plus( tail );
const headWidth = 10;
const headHeight = 10;
const directionUnitVector = Vector2.createPolar( 1, angle );
const orthogonalUnitVector = directionUnitVector.perpendicular;
const tip = directionUnitVector.times( headHeight ).plus( tail );
return new Path( new Shape().moveToPoint( tail ).
lineToPoint( tail.plus( orthogonalUnitVector.times( headWidth / 2 ) ) ).
lineToPoint( tip ).
Expand Down
4 changes: 2 additions & 2 deletions js/intro/view/ComparisonRegion.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ define( require => {
* @constructor
*/
function ComparisonRegion( compareButtonPressed, separateButtonPressed, compareBothProperty, eitherCompareProperty, options ) {
var comparisonRegionLength = 220;
const comparisonRegionLength = 220;
Rectangle.call( this, 0, 0, comparisonRegionLength, comparisonRegionLength, 10, 10, { lineStroke: 1, fill: 'white' } );

this.addChild( new CompareSeparateButton( compareButtonPressed, separateButtonPressed, compareBothProperty, {
centerX: this.bounds.centerX,
bottom: this.bottom - 5
} ) );

var target = new Rectangle( 0, 0, 180, 100, { stroke: 'red', lineWidth: 1, lineDash: [ 6, 5 ], centerX: this.bounds.centerX, top: 59 } );
const target = new Rectangle( 0, 0, 180, 100, { stroke: 'red', lineWidth: 1, lineDash: [ 6, 5 ], centerX: this.bounds.centerX, top: 59 } );
this.addChild( target );

//Only show the target region if both shapes are not in the compare region
Expand Down
22 changes: 11 additions & 11 deletions js/intro/view/FractionNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ define( require => {
}, options );

Node.call( this );
var font = new PhetFont( { size: 84 } );
var numeratorNode = new Text( numeratorProperty.get(), { font: font, fill: options.fill } );
const font = new PhetFont( { size: 84 } );
const numeratorNode = new Text( numeratorProperty.get(), { font: font, fill: options.fill } );

var line = new Line( 0, 0, 80, 0, { lineWidth: 4, stroke: options.fill } );
const line = new Line( 0, 0, 80, 0, { lineWidth: 4, stroke: options.fill } );
this.addChild( line );

numeratorProperty.link( function( value ) {
numeratorNode.text = value + '';
numeratorNode.centerX = line.centerX;
} );

var denominatorNode = new Text( denominatorProperty.get(), { font: font, fill: options.fill } );
const denominatorNode = new Text( denominatorProperty.get(), { font: font, fill: options.fill } );
denominatorProperty.link( function( value ) {
denominatorNode.text = value + '';
denominatorNode.centerX = line.centerX;
Expand All @@ -61,23 +61,23 @@ define( require => {
this.addChild( denominatorNode );

if ( options.interactive ) {
var numeratorUpEnabledProperty = new DerivedProperty(
const numeratorUpEnabledProperty = new DerivedProperty(
[ numeratorProperty, denominatorProperty ],
function( numerator, denominator ) { return numerator < denominator; } );
var numeratorDownEnabledProperty = new DerivedProperty(
const numeratorDownEnabledProperty = new DerivedProperty(
[ numeratorProperty ],
function( numerator ) { return numerator > 0; } );
var denominatorUpEnabledProperty = new DerivedProperty(
const denominatorUpEnabledProperty = new DerivedProperty(
[ denominatorProperty ],
function( denominator ) { return denominator < 10;} );
var denominatorDownEnabledProperty = new DerivedProperty(
const denominatorDownEnabledProperty = new DerivedProperty(
[ numeratorProperty, denominatorProperty ],
function( numerator, denominator ) { return denominator > 1 && numerator < denominator;} );

var numeratorSpinner = new UpDownSpinner( numeratorProperty, numeratorUpEnabledProperty, numeratorDownEnabledProperty );
var denominatorSpinner = new UpDownSpinner( denominatorProperty, denominatorUpEnabledProperty, denominatorDownEnabledProperty );
const numeratorSpinner = new UpDownSpinner( numeratorProperty, numeratorUpEnabledProperty, numeratorDownEnabledProperty );
const denominatorSpinner = new UpDownSpinner( denominatorProperty, denominatorUpEnabledProperty, denominatorDownEnabledProperty );

var spinners = new VBox( {
const spinners = new VBox( {
spacing: 20,
children: [ numeratorSpinner, denominatorSpinner ],
left: line.bounds.maxX + 5,
Expand Down
42 changes: 21 additions & 21 deletions js/intro/view/HorizontalBarContainerNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ define( require => {
startPositionFunction,
comparePositionFunction,
options ) {
var fractionProperty = fractionModel.fractionProperty;
var self = this;
const fractionProperty = fractionModel.fractionProperty;
const self = this;

this.stateProperty = stateProperty;
this.animatingProperty = animatingProperty;

options = _.extend( { cursor: 'pointer' }, options );
Node.call( this );

var border = new Rectangle( 0, 0, 180, 100, { stroke: 'black', lineWidth: 1 } );
const border = new Rectangle( 0, 0, 180, 100, { stroke: 'black', lineWidth: 1 } );
this.addChild( border );

this.contents = new Rectangle( 0, 0, fractionProperty.get() * 180, 100, {
Expand All @@ -65,12 +65,12 @@ define( require => {
this.addChild( this.contents );

//Solid lines to show pieces
var pieceDivisions = new Node();
const pieceDivisions = new Node();
Property.multilink( [ fractionModel.numeratorProperty, fractionModel.denominatorProperty ],
function( numerator, denominator ) {
var children = [];
for ( var i = 1; i < numerator; i++ ) {
var x = i * 180 / denominator;
const children = [];
for ( let i = 1; i < numerator; i++ ) {
const x = i * 180 / denominator;
children.push( new Line( x, 0, x, 100, { stroke: 'black', lineWidth: 1 } ) );
}
pieceDivisions.children = children;
Expand All @@ -79,10 +79,10 @@ define( require => {
this.addChild( pieceDivisions );

//Dotted lines to show user-selected divisions
var divisionsNode = new Node();
const divisionsNode = new Node();
divisionsProperty.link( function( divisions ) {
var children = [];
for ( var i = 1; i < divisions; i++ ) {
const children = [];
for ( let i = 1; i < divisions; i++ ) {
children.push( new Line( i * 180 / divisions, 0, i * 180 / divisions, 100, {
stroke: 'gray',
lineDash: [ 5, 4 ],
Expand Down Expand Up @@ -117,9 +117,9 @@ define( require => {
},
endDrag: function() {
//Move to the start position or compare position, whichever is closer.
var center = self.center;
var distToStart = self.startPosition.distance( center );
var distToCompare = self.comparePosition.distance( center );
const center = self.center;
const distToStart = self.startPosition.distance( center );
const distToCompare = self.comparePosition.distance( center );

if ( distToStart < distToCompare ) {
self.animateToStart();
Expand All @@ -140,17 +140,17 @@ define( require => {
*/
animateToComparison: function() {
this.animatingProperty.value = true;
var self = this;
var positionProperty = new Property( this.center );
var animation = new Animation( {
const self = this;
const positionProperty = new Property( this.center );
const animation = new Animation( {
duration: 0.5,
targets: [ {
property: positionProperty,
easing: Easing.CUBIC_IN_OUT,
to: this.comparePosition
} ]
} );
var listener = function( position ) {
const listener = function( position ) {
self.center = position;
};
positionProperty.link( listener );
Expand All @@ -167,17 +167,17 @@ define( require => {
*/
animateToStart: function() {
this.animatingProperty.value = true;
var self = this;
var positionProperty = new Property( this.center );
var animation = new Animation( {
const self = this;
const positionProperty = new Property( this.center );
const animation = new Animation( {
duration: 0.5,
targets: [ {
property: positionProperty,
easing: Easing.CUBIC_IN_OUT,
to: this.startPosition
} ]
} );
var listener = function( position ) {
const listener = function( position ) {
self.center = position;
};
positionProperty.link( listener );
Expand Down
Loading

0 comments on commit caa9595

Please sign in to comment.