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 eff3b62 commit 954ba7d
Show file tree
Hide file tree
Showing 54 changed files with 571 additions and 571 deletions.
18 changes: 9 additions & 9 deletions js/ABSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ define( require => {
tandem: Tandem.required
}, options );

var defaultTrackFill = new LinearGradient( 0, 0, 0, options.switchSize.height ).addColorStop( 0, 'rgb(40,40,40)' ).addColorStop( 1, 'rgb(200,200,200)' );
const defaultTrackFill = new LinearGradient( 0, 0, 0, options.switchSize.height ).addColorStop( 0, 'rgb(40,40,40)' ).addColorStop( 1, 'rgb(200,200,200)' );
options.trackFillA = options.trackFillA || defaultTrackFill;
options.trackFillB = options.trackFillB || defaultTrackFill;
options.thumbFill = options.thumbFill ||
Expand All @@ -61,9 +61,9 @@ define( require => {
Node.call( this );

// property for adapting to OnOffSwitch. 'true' is 'B', the object on the 'on' end of the OnOffSwitch.
var onProperty = new Property( valueB === property.get() );
const onProperty = new Property( valueB === property.get() );

var onOffSwitch = new OnOffSwitch( onProperty, {
const onOffSwitch = new OnOffSwitch( onProperty, {
size: options.switchSize,
cursor: options.cursor,
thumbFill: options.thumbFill,
Expand All @@ -89,8 +89,8 @@ define( require => {

// add a horizontal strut that will cause the 'centerX' of this node to be at the center of the button
if ( options.centerOnButton ) {
var additionalWidth = Math.abs( labelA.width - labelB.width );
var strut = new Line( 0, 0, this.width + additionalWidth, 0 );
const additionalWidth = Math.abs( labelA.width - labelB.width );
const strut = new Line( 0, 0, this.width + additionalWidth, 0 );
this.addChild( strut );
strut.moveToBack();
if ( labelA.width < labelB.width ) {
Expand All @@ -102,12 +102,12 @@ define( require => {
}

// sync properties, listeners must be disposed
var propertyListener = function( object ) {
const propertyListener = function( object ) {
onProperty.set( valueB === object );
};
property.link( propertyListener );

var onPropertyListener = function( on ) {
const onPropertyListener = function( on ) {
property.set( on ? valueB : valueA );
if ( options.setEnabled ) {
options.setEnabled( labelA, !on );
Expand All @@ -117,10 +117,10 @@ define( require => {
onProperty.link( onPropertyListener );

// click on labels to select, must be disposed
var aInputListener = new ButtonListener( {
const aInputListener = new ButtonListener( {
fire: function() { onProperty.set( false ); }
} );
var bInputListener = new ButtonListener( {
const bInputListener = new ButtonListener( {
fire: function() { onProperty.set( true ); }
} );
labelA.addInputListener( aInputListener );
Expand Down
28 changes: 14 additions & 14 deletions js/AccordionBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ define( require => {
*/
function AccordionBox( contentNode, options ) {

var self = this;
const self = this;

options = _.extend( {

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

// Expanded box
var boxOptions = {
const boxOptions = {
fill: options.fill,
cornerRadius: options.cornerRadius
};
Expand Down Expand Up @@ -258,7 +258,7 @@ define( require => {
// optional box outline, on top of everything else
if ( options.stroke ) {

var outlineOptions = {
const outlineOptions = {
stroke: options.stroke,
lineWidth: options.lineWidth,
cornerRadius: options.cornerRadius
Expand All @@ -279,7 +279,7 @@ define( require => {

// Watch future changes for re-layout (don't want to trigger on our first layout and queue useless ones)
if ( options.resize ) {
var layoutListener = this.layout.bind( this );
const layoutListener = this.layout.bind( this );
contentNode.on( 'bounds', layoutListener );
this.titleNode.on( 'bounds', layoutListener );
this.disposeEmitterAccordionBox.addListener( function() {
Expand All @@ -289,7 +289,7 @@ define( require => {
}

// expand/collapse the box
var expandedPropertyObserver = function( expanded ) {
const expandedPropertyObserver = function( expanded ) {
self.expandedBox.visible = expanded;
self.collapsedBox.visible = !expanded;

Expand Down Expand Up @@ -318,14 +318,14 @@ define( require => {
* @private
*/
layout: function() {
var collapsedBoxHeight = this.getCollapsedBoxHeight();
var boxWidth = this.getBoxWidth();
var expandedBoxHeight = this.getExpandedBoxHeight();
const collapsedBoxHeight = this.getCollapsedBoxHeight();
const boxWidth = this.getBoxWidth();
const expandedBoxHeight = this.getExpandedBoxHeight();

this.expandedBox.rectWidth = boxWidth;
this.expandedBox.rectHeight = expandedBoxHeight;

var expandedBounds = this.expandedBox.selfBounds;
const expandedBounds = this.expandedBox.selfBounds;

this.expandedBoxOutline.rectWidth = boxWidth;
this.expandedBoxOutline.rectHeight = expandedBoxHeight;
Expand All @@ -349,8 +349,8 @@ define( require => {

// content layout
this._contentNode.bottom = expandedBounds.bottom - this._contentYMargin;
var contentSpanLeft = expandedBounds.left + this._contentXMargin;
var contentSpanRight = expandedBounds.right - this._contentXMargin;
let contentSpanLeft = expandedBounds.left + this._contentXMargin;
let contentSpanRight = expandedBounds.right - this._contentXMargin;
if ( !this._showTitleWhenExpanded ) {
// content will be placed next to button
if ( this._buttonAlign === 'left' ) {
Expand All @@ -371,8 +371,8 @@ define( require => {
}

// button horizontal layout
var titleLeftSpan = expandedBounds.left + this._titleXMargin;
var titleRightSpan = expandedBounds.right - this._titleXMargin;
let titleLeftSpan = expandedBounds.left + this._titleXMargin;
let titleRightSpan = expandedBounds.right - this._titleXMargin;
if ( this._buttonAlign === 'left' ) {
this.expandCollapseButton.left = expandedBounds.left + this._buttonXMargin;
titleLeftSpan = this.expandCollapseButton.right + this._titleXSpacing;
Expand Down Expand Up @@ -429,7 +429,7 @@ define( require => {
getBoxWidth: function() {

// Initial width is dependent on width of title section of the accordion box
var width = Math.max( this._minWidth, this._buttonXMargin + this.expandCollapseButton.width + this._titleXSpacing + this.titleNode.width + this._titleXMargin );
let width = Math.max( this._minWidth, this._buttonXMargin + this.expandCollapseButton.width + this._titleXSpacing + this.titleNode.width + this._titleXMargin );

// Limit width by the necessary space for the title node
if ( this._titleAlignX === 'center' ) {
Expand Down
24 changes: 12 additions & 12 deletions js/AquaRadioButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ define( require => {
const Tandem = require( 'TANDEM/Tandem' );

// constants
var DEFAULT_RADIUS = 7;
const DEFAULT_RADIUS = 7;

/**
* @param property
Expand Down Expand Up @@ -59,7 +59,7 @@ define( require => {
a11yNameAttribute: null
}, options );

var self = this;
const self = this;

// @private - converted to an AXON/Property from a property to support PhET-iO
this.enabledProperty = new BooleanProperty( options.enabled, {
Expand All @@ -68,9 +68,9 @@ define( require => {
} );

// selected node creation
var selectedNode = new Node();
var innerCircle = new Circle( options.radius / 3, { fill: options.centerColor } );
var outerCircleSelected = new Circle( options.radius, { fill: options.selectedColor, stroke: options.stroke } );
const selectedNode = new Node();
const innerCircle = new Circle( options.radius / 3, { fill: options.centerColor } );
const outerCircleSelected = new Circle( options.radius, { fill: options.selectedColor, stroke: options.stroke } );

// @private
this.selectedCircleButton = new Node( {
Expand All @@ -82,7 +82,7 @@ define( require => {
node.centerY = outerCircleSelected.centerY;

// deselected node
var deselectedNode = new Node();
const deselectedNode = new Node();

// @private
this.deselectedCircleButton = new Circle( options.radius, {
Expand All @@ -97,32 +97,32 @@ define( require => {
Node.call( this );

//Add an invisible node to make sure the layout for selected vs deselected is the same
var background = new Rectangle( selectedNode.bounds.union( deselectedNode.bounds ) );
const background = new Rectangle( selectedNode.bounds.union( deselectedNode.bounds ) );
selectedNode.pickable = deselectedNode.pickable = false; // the background rectangle suffices

this.addChild( background );
this.addChild( selectedNode );
this.addChild( deselectedNode );

// sync control with model
var syncWithModel = function( newValue ) {
const syncWithModel = function( newValue ) {
selectedNode.visible = ( newValue === value );
deselectedNode.visible = !selectedNode.visible;
};
property.link( syncWithModel );

// set property value on fire
var fire = function() {
const fire = function() {
property.set( value );
};
var inputListener = new FireListener( {
const inputListener = new FireListener( {
fire: fire,
tandem: options.tandem.createTandem( 'inputListener' )
} );
this.addInputListener( inputListener );

// a11y - input listener so that updates the state of the radio button with keyboard interaction
var changeListener = {
const changeListener = {
change: fire
};
this.addInputListener( changeListener );
Expand All @@ -137,7 +137,7 @@ define( require => {

// a11y - when the property changes, make sure the correct radio button is marked as 'checked' so that this button
// receives focus on 'tab'
var accessibleCheckedListener = function( newValue ) {
const accessibleCheckedListener = function( newValue ) {
self.accessibleChecked = newValue === value;
};
property.link( accessibleCheckedListener );
Expand Down
8 changes: 4 additions & 4 deletions js/CallbackTimer.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ define( require => {

// @public Starts the timer.
start: function() {
var self = this;
const self = this;
if ( !self.isRunning() ) {
self.fired = false;
self.delayID = timer.setTimeout( function() {
Expand Down Expand Up @@ -100,7 +100,7 @@ define( require => {

// @public Removes a {function} callback.
removeCallback: function( callback ) {
var index = this.callbacks.indexOf( callback );
const index = this.callbacks.indexOf( callback );
if ( index !== -1 ) {
this.callbacks.splice( index, 1 );
}
Expand All @@ -112,8 +112,8 @@ define( require => {
* @public
*/
fire: function() {
var callbacksCopy = this.callbacks.slice( 0 );
for ( var i = 0; i < callbacksCopy.length; i++ ) {
const callbacksCopy = this.callbacks.slice( 0 );
for ( let i = 0; i < callbacksCopy.length; i++ ) {
callbacksCopy[ i ]();
}
this.fired = true;
Expand Down
Loading

0 comments on commit 954ba7d

Please sign in to comment.