From 9e6cbc0ff3e2de0df9f7babdc8191aef7886c54d Mon Sep 17 00:00:00 2001 From: samreid Date: Sat, 9 Feb 2019 07:27:55 -0700 Subject: [PATCH] Port to es6, see https://github.com/phetsims/circuit-construction-kit-common/issues/445 --- js/circuit-construction-kit-dc-main.js | 28 +++++++++++++------------- js/circuitConstructionKitDc.js | 4 ++-- js/intro/IntroScreen.js | 2 +- js/intro/model/IntroModel.js | 6 +++--- js/intro/view/IntroScreenView.js | 16 +++++++-------- js/lab/LabScreen.js | 2 +- js/lab/model/LabModel.js | 6 +++--- js/lab/view/LabScreenView.js | 2 +- package.json | 2 +- 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/js/circuit-construction-kit-dc-main.js b/js/circuit-construction-kit-dc-main.js index f9f753e..b3f78a2 100644 --- a/js/circuit-construction-kit-dc-main.js +++ b/js/circuit-construction-kit-dc-main.js @@ -5,25 +5,25 @@ * * @author Sam Reid (PhET Interactive Simulations) */ -define( function( require ) { +define( require => { 'use strict'; // modules require( 'SCENERY/nodes/Image' ); // Image is required for making toDataURLNodeSynchronous work in the built version - var IntroScreen = require( 'CIRCUIT_CONSTRUCTION_KIT_DC/intro/IntroScreen' ); - var KeyboardUtil = require( 'SCENERY/accessibility/KeyboardUtil' ); - var LabScreen = require( 'CIRCUIT_CONSTRUCTION_KIT_DC/lab/LabScreen' ); - var Sim = require( 'JOIST/Sim' ); - var SimLauncher = require( 'JOIST/SimLauncher' ); - var Tandem = require( 'TANDEM/Tandem' ); + const IntroScreen = require( 'CIRCUIT_CONSTRUCTION_KIT_DC/intro/IntroScreen' ); + const KeyboardUtil = require( 'SCENERY/accessibility/KeyboardUtil' ); + const LabScreen = require( 'CIRCUIT_CONSTRUCTION_KIT_DC/lab/LabScreen' ); + const Sim = require( 'JOIST/Sim' ); + const SimLauncher = require( 'JOIST/SimLauncher' ); + const Tandem = require( 'TANDEM/Tandem' ); // constants - var tandem = Tandem.rootTandem; + const tandem = Tandem.rootTandem; // strings - var circuitConstructionKitDcTitleString = require( 'string!CIRCUIT_CONSTRUCTION_KIT_DC/circuit-construction-kit-dc.title' ); + const circuitConstructionKitDcTitleString = require( 'string!CIRCUIT_CONSTRUCTION_KIT_DC/circuit-construction-kit-dc.title' ); - var simOptions = { + const simOptions = { credits: { leadDesign: 'Amy Rouinfar', softwareDevelopment: 'Sam Reid, Denzell Barnett', @@ -37,8 +37,8 @@ define( function( require ) { // Support accessibility for deleting selected circuit elements, but don't support broader tab navigation until it // is complete - document.addEventListener( 'keydown', function( event ) { - var keyCode = event.keyCode || event.which; + document.addEventListener( 'keydown', event => { + const keyCode = event.keyCode || event.which; if ( keyCode === KeyboardUtil.KEY_TAB ) { event.preventDefault(); } @@ -48,10 +48,10 @@ define( function( require ) { // order to load the classes into an accessible namespace, the *-config.js and *-main.js are loaded however, when // running the unit tests we don't also want to launch the simulation. if ( !window.circuitConstructionKitTestSuite ) { - SimLauncher.launch( function() { + SimLauncher.launch( () => { // Launch the simulation once everything is ready - var sim = new Sim( circuitConstructionKitDcTitleString, [ + const sim = new Sim( circuitConstructionKitDcTitleString, [ new IntroScreen( tandem.createTandem( 'introScreen' ) ), new LabScreen( tandem.createTandem( 'labScreen' ) ) ], simOptions ); diff --git a/js/circuitConstructionKitDc.js b/js/circuitConstructionKitDc.js index 7994c93..a37d74a 100644 --- a/js/circuitConstructionKitDc.js +++ b/js/circuitConstructionKitDc.js @@ -5,11 +5,11 @@ * * @author Sam Reid (PhET Interactive Simulations) */ -define( function( require ) { +define( require => { 'use strict'; // modules - var Namespace = require( 'PHET_CORE/Namespace' ); + const Namespace = require( 'PHET_CORE/Namespace' ); return new Namespace( 'circuitConstructionKitDc' ); } ); \ No newline at end of file diff --git a/js/intro/IntroScreen.js b/js/intro/IntroScreen.js index 8d4bdb8..6c48299 100644 --- a/js/intro/IntroScreen.js +++ b/js/intro/IntroScreen.js @@ -5,7 +5,7 @@ * * @author Sam Reid (PhET Interactive Simulations) */ -define( function( require ) { +define( require => { 'use strict'; // modules diff --git a/js/intro/model/IntroModel.js b/js/intro/model/IntroModel.js index f581445..d29149e 100644 --- a/js/intro/model/IntroModel.js +++ b/js/intro/model/IntroModel.js @@ -5,12 +5,12 @@ * * @author Sam Reid (PhET Interactive Simulations) */ -define( function( require ) { +define( require => { 'use strict'; // modules - var circuitConstructionKitDc = require( 'CIRCUIT_CONSTRUCTION_KIT_DC/circuitConstructionKitDc' ); - var CircuitConstructionKitModel = require( 'CIRCUIT_CONSTRUCTION_KIT_COMMON/model/CircuitConstructionKitModel' ); + const circuitConstructionKitDc = require( 'CIRCUIT_CONSTRUCTION_KIT_DC/circuitConstructionKitDc' ); + const CircuitConstructionKitModel = require( 'CIRCUIT_CONSTRUCTION_KIT_COMMON/model/CircuitConstructionKitModel' ); class IntroModel extends CircuitConstructionKitModel { diff --git a/js/intro/view/IntroScreenView.js b/js/intro/view/IntroScreenView.js index bfcfed7..ac91df2 100644 --- a/js/intro/view/IntroScreenView.js +++ b/js/intro/view/IntroScreenView.js @@ -5,14 +5,14 @@ * * @author Sam Reid (PhET Interactive Simulations) */ -define( function( require ) { +define( require => { 'use strict'; // modules - var CCKCScreenView = require( 'CIRCUIT_CONSTRUCTION_KIT_COMMON/view/CCKCScreenView' ); - var circuitConstructionKitDc = require( 'CIRCUIT_CONSTRUCTION_KIT_DC/circuitConstructionKitDc' ); - var CircuitElementToolFactory = require( 'CIRCUIT_CONSTRUCTION_KIT_COMMON/view/CircuitElementToolFactory' ); - var Node = require( 'SCENERY/nodes/Node' ); + const CCKCScreenView = require( 'CIRCUIT_CONSTRUCTION_KIT_COMMON/view/CCKCScreenView' ); + const circuitConstructionKitDc = require( 'CIRCUIT_CONSTRUCTION_KIT_DC/circuitConstructionKitDc' ); + const CircuitElementToolFactory = require( 'CIRCUIT_CONSTRUCTION_KIT_COMMON/view/CircuitElementToolFactory' ); + const Node = require( 'SCENERY/nodes/Node' ); class IntroScreenView extends CCKCScreenView { @@ -21,13 +21,13 @@ define( function( require ) { * @param {Tandem} tandem */ constructor( model, tandem ) { - var circuitElementToolFactory = new CircuitElementToolFactory( model.circuit, model.showLabelsProperty, model.viewTypeProperty, + const circuitElementToolFactory = new CircuitElementToolFactory( model.circuit, model.showLabelsProperty, model.viewTypeProperty, point => this.circuitLayerNode.globalToLocalPoint( point ) ); - var wireToolNode = circuitElementToolFactory.createWireToolNode( 25, tandem.createTandem( 'wireToolNode' ) ); + const wireToolNode = circuitElementToolFactory.createWireToolNode( 25, tandem.createTandem( 'wireToolNode' ) ); // Tool nodes that appear on every screen. Pagination for the carousel, each page should begin with wire node - var circuitElementToolNodes = [ + const circuitElementToolNodes = [ // This page is duplicated in the Lab Screen View wireToolNode, diff --git a/js/lab/LabScreen.js b/js/lab/LabScreen.js index 6b87da3..08fdac1 100644 --- a/js/lab/LabScreen.js +++ b/js/lab/LabScreen.js @@ -5,7 +5,7 @@ * * @author Sam Reid (PhET Interactive Simulations) */ -define( function( require ) { +define( require => { 'use strict'; // modules diff --git a/js/lab/model/LabModel.js b/js/lab/model/LabModel.js index e861428..133fe28 100644 --- a/js/lab/model/LabModel.js +++ b/js/lab/model/LabModel.js @@ -5,12 +5,12 @@ * * @author Sam Reid (PhET Interactive Simulations) */ -define( function( require ) { +define( require => { 'use strict'; // modules - var circuitConstructionKitDc = require( 'CIRCUIT_CONSTRUCTION_KIT_DC/circuitConstructionKitDc' ); - var CircuitConstructionKitModel = require( 'CIRCUIT_CONSTRUCTION_KIT_COMMON/model/CircuitConstructionKitModel' ); + const circuitConstructionKitDc = require( 'CIRCUIT_CONSTRUCTION_KIT_DC/circuitConstructionKitDc' ); + const CircuitConstructionKitModel = require( 'CIRCUIT_CONSTRUCTION_KIT_COMMON/model/CircuitConstructionKitModel' ); class LabModel extends CircuitConstructionKitModel { diff --git a/js/lab/view/LabScreenView.js b/js/lab/view/LabScreenView.js index 33bff64..1570fb7 100644 --- a/js/lab/view/LabScreenView.js +++ b/js/lab/view/LabScreenView.js @@ -5,7 +5,7 @@ * * @author Sam Reid (PhET Interactive Simulations) */ -define( function( require ) { +define( require => { 'use strict'; // modules diff --git a/package.json b/package.json index 93c1155..d4fa502 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,6 @@ "simulation": true }, "eslintConfig": { - "extends": "../chipper/eslint/sim_eslintrc.js" + "extends": "../chipper/eslint/sim_es6_eslintrc.js" } } \ No newline at end of file