From 8f9a18535ebf366af0f80651813ae4af72b76f8d Mon Sep 17 00:00:00 2001 From: Chris Malley Date: Thu, 10 Oct 2019 19:47:03 -0600 Subject: [PATCH] use merge instead of _.extend throughout natural-selection, https://github.com/phetsims/phet-core/issues/71 --- js/common/view/AddAMateButton.js | 3 ++- js/common/view/AddMutationPanel.js | 5 +++-- js/common/view/ClimateRadioButtonGroup.js | 3 ++- js/common/view/GraphRadioButtonGroup.js | 3 ++- js/common/view/LimitedFoodCheckbox.js | 3 ++- js/common/view/MutationComingNode.js | 5 +++-- js/common/view/NaturalSelectionPanel.js | 3 ++- js/common/view/NaturalSelectionTimeControlNode.js | 3 ++- js/common/view/PedigreeControlPanel.js | 5 +++-- js/common/view/PopulationControlPanel.js | 5 +++-- js/common/view/PopulationGraphNode.js | 5 +++-- js/common/view/ProportionControlPanel.js | 5 +++-- js/common/view/SelectionAgentsPanel.js | 5 +++-- 13 files changed, 33 insertions(+), 20 deletions(-) diff --git a/js/common/view/AddAMateButton.js b/js/common/view/AddAMateButton.js index 2b88139d..cf46fcf0 100644 --- a/js/common/view/AddAMateButton.js +++ b/js/common/view/AddAMateButton.js @@ -9,6 +9,7 @@ define( require => { 'use strict'; // modules + const merge = require( 'PHET_CORE/merge' ); const naturalSelection = require( 'NATURAL_SELECTION/naturalSelection' ); const NaturalSelectionColors = require( 'NATURAL_SELECTION/common/NaturalSelectionColors' ); const NaturalSelectionConstants = require( 'NATURAL_SELECTION/common/NaturalSelectionConstants' ); @@ -25,7 +26,7 @@ define( require => { */ constructor( options ) { - options = _.extend( {}, NaturalSelectionConstants.RECTANGULAR_PUSH_BUTTON_OPTIONS, { + options = merge( {}, NaturalSelectionConstants.RECTANGULAR_PUSH_BUTTON_OPTIONS, { baseColor: NaturalSelectionColors.ADD_A_MATE_BUTTON, xMargin: 12, yMargin: 8 diff --git a/js/common/view/AddMutationPanel.js b/js/common/view/AddMutationPanel.js index e76b2320..45b1279f 100644 --- a/js/common/view/AddMutationPanel.js +++ b/js/common/view/AddMutationPanel.js @@ -12,6 +12,7 @@ define( require => { const HBox = require( 'SCENERY/nodes/HBox' ); const HStrut = require( 'SCENERY/nodes/HStrut' ); const Image = require( 'SCENERY/nodes/Image' ); + const merge = require( 'PHET_CORE/merge' ); const naturalSelection = require( 'NATURAL_SELECTION/naturalSelection' ); const NaturalSelectionConstants = require( 'NATURAL_SELECTION/common/NaturalSelectionConstants' ); const NaturalSelectionPanel = require( 'NATURAL_SELECTION/common/view/NaturalSelectionPanel' ); @@ -38,7 +39,7 @@ define( require => { */ constructor( options ) { - options = _.extend( {}, NaturalSelectionConstants.PANEL_OPTIONS, options ); + options = merge( {}, NaturalSelectionConstants.PANEL_OPTIONS, options ); // title is text + icon const titleNode = new HBox( { @@ -63,7 +64,7 @@ define( require => { //TODO placeholder const rectangle = new Rectangle( 0, 0, 175, 75 ); - const content = new VBox( _.extend( {}, NaturalSelectionConstants.VBOX_OPTIONS, { + const content = new VBox( merge( {}, NaturalSelectionConstants.VBOX_OPTIONS, { children: [ titleNode, columnHeadingsNode, rectangle ] } ) ); diff --git a/js/common/view/ClimateRadioButtonGroup.js b/js/common/view/ClimateRadioButtonGroup.js index eef73826..aee9756c 100644 --- a/js/common/view/ClimateRadioButtonGroup.js +++ b/js/common/view/ClimateRadioButtonGroup.js @@ -11,6 +11,7 @@ define( require => { // modules const Climates = require( 'NATURAL_SELECTION/common/model/Climates' ); const FontAwesomeNode = require( 'SUN/FontAwesomeNode' ); + const merge = require( 'PHET_CORE/merge' ); const naturalSelection = require( 'NATURAL_SELECTION/naturalSelection' ); const NaturalSelectionConstants = require( 'NATURAL_SELECTION/common/NaturalSelectionConstants' ); const Node = require( 'SCENERY/nodes/Node' ); @@ -29,7 +30,7 @@ define( require => { */ constructor( climateProperty, options ) { - options = _.extend( { + options = merge( { orientation: 'horizontal', spacing: 8, cornerRadius: NaturalSelectionConstants.CORNER_RADIUS, diff --git a/js/common/view/GraphRadioButtonGroup.js b/js/common/view/GraphRadioButtonGroup.js index 43518bdb..67007ac6 100644 --- a/js/common/view/GraphRadioButtonGroup.js +++ b/js/common/view/GraphRadioButtonGroup.js @@ -10,6 +10,7 @@ define( require => { // modules const Graphs = require( 'NATURAL_SELECTION/common/view/Graphs' ); + const merge = require( 'PHET_CORE/merge' ); const naturalSelection = require( 'NATURAL_SELECTION/naturalSelection' ); const NaturalSelectionConstants = require( 'NATURAL_SELECTION/common/NaturalSelectionConstants' ); const Text = require( 'SCENERY/nodes/Text' ); @@ -31,7 +32,7 @@ define( require => { */ constructor( graphProperty, options ) { - options = _.extend( { + options = merge( { radius: 8, xSpacing: 10, spacing: 12 diff --git a/js/common/view/LimitedFoodCheckbox.js b/js/common/view/LimitedFoodCheckbox.js index 6565253e..02261529 100644 --- a/js/common/view/LimitedFoodCheckbox.js +++ b/js/common/view/LimitedFoodCheckbox.js @@ -10,6 +10,7 @@ define( require => { // modules const Checkbox = require( 'SUN/Checkbox' ); + const merge = require( 'PHET_CORE/merge' ); const naturalSelection = require( 'NATURAL_SELECTION/naturalSelection' ); const NaturalSelectionConstants = require( 'NATURAL_SELECTION/common/NaturalSelectionConstants' ); const Text = require( 'SCENERY/nodes/Text' ); @@ -25,7 +26,7 @@ define( require => { */ constructor( limitedFoodProperty, options ) { - options = _.extend( {}, NaturalSelectionConstants.CHECKBOX_OPTIONS, options ); + options = merge( {}, NaturalSelectionConstants.CHECKBOX_OPTIONS, options ); const content = new Text( limitedFoodString, { font: NaturalSelectionConstants.CHECKBOX_FONT diff --git a/js/common/view/MutationComingNode.js b/js/common/view/MutationComingNode.js index 5149b9ac..06a24f01 100644 --- a/js/common/view/MutationComingNode.js +++ b/js/common/view/MutationComingNode.js @@ -12,6 +12,7 @@ define( require => { // modules const HBox = require( 'SCENERY/nodes/HBox' ); const Image = require( 'SCENERY/nodes/Image' ); + const merge = require( 'PHET_CORE/merge' ); const naturalSelection = require( 'NATURAL_SELECTION/naturalSelection' ); const NaturalSelectionColors = require( 'NATURAL_SELECTION/common/NaturalSelectionColors' ); const NaturalSelectionConstants = require( 'NATURAL_SELECTION/common/NaturalSelectionConstants' ); @@ -38,7 +39,7 @@ define( require => { */ constructor( options ) { - options = _.extend( { + options = merge( { cancelButtonListener: null }, options ); @@ -46,7 +47,7 @@ define( require => { const textNode = new Text( mutationComingString, { font: NaturalSelectionConstants.TEXT_FONT } ); - const cancelButton = new RectangularPushButton( _.extend( {}, + const cancelButton = new RectangularPushButton( merge( {}, NaturalSelectionConstants.RECTANGULAR_PUSH_BUTTON_OPTIONS, { baseColor: NaturalSelectionColors.CANCEL_BUTTON, content: new Text( cancelString, { font: NaturalSelectionConstants.PUSH_BUTTON_FONT } ), diff --git a/js/common/view/NaturalSelectionPanel.js b/js/common/view/NaturalSelectionPanel.js index f26c153b..f4977e00 100644 --- a/js/common/view/NaturalSelectionPanel.js +++ b/js/common/view/NaturalSelectionPanel.js @@ -10,6 +10,7 @@ define( require => { 'use strict'; // modules + const merge = require( 'PHET_CORE/merge' ); const naturalSelection = require( 'NATURAL_SELECTION/naturalSelection' ); const Panel = require( 'SUN/Panel' ); @@ -21,7 +22,7 @@ define( require => { */ constructor( content, options ) { - options = _.extend( { + options = merge( { fixedWidth: null // {number|null} optional fixed width }, options ); diff --git a/js/common/view/NaturalSelectionTimeControlNode.js b/js/common/view/NaturalSelectionTimeControlNode.js index bf3de0ff..4202945f 100644 --- a/js/common/view/NaturalSelectionTimeControlNode.js +++ b/js/common/view/NaturalSelectionTimeControlNode.js @@ -10,6 +10,7 @@ define( require => { 'use strict'; // modules + const merge = require( 'PHET_CORE/merge' ); const naturalSelection = require( 'NATURAL_SELECTION/naturalSelection' ); const TimeControlNode = require( 'SCENERY_PHET/TimeControlNode' ); @@ -21,7 +22,7 @@ define( require => { */ constructor( isPlayingProperty, options ) { - options = _.extend( { + options = merge( { //TODO }, options ); diff --git a/js/common/view/PedigreeControlPanel.js b/js/common/view/PedigreeControlPanel.js index 0ee57e57..80382c5c 100644 --- a/js/common/view/PedigreeControlPanel.js +++ b/js/common/view/PedigreeControlPanel.js @@ -10,6 +10,7 @@ define( require => { // modules const Checkbox = require( 'SUN/Checkbox' ); + const merge = require( 'PHET_CORE/merge' ); const naturalSelection = require( 'NATURAL_SELECTION/naturalSelection' ); const NaturalSelectionConstants = require( 'NATURAL_SELECTION/common/NaturalSelectionConstants' ); const NaturalSelectionPanel = require( 'NATURAL_SELECTION/common/view/NaturalSelectionPanel' ); @@ -27,7 +28,7 @@ define( require => { */ constructor( alleles, options ) { - options = _.extend( {}, NaturalSelectionConstants.PANEL_OPTIONS, options ); + options = merge( {}, NaturalSelectionConstants.PANEL_OPTIONS, options ); // Alleles title const titleNode = new Text( allelesString, { @@ -44,7 +45,7 @@ define( require => { } ); // Arranged vertically - const content = new VBox( _.extend( {}, NaturalSelectionConstants.VBOX_OPTIONS, { + const content = new VBox( merge( {}, NaturalSelectionConstants.VBOX_OPTIONS, { children: [ titleNode, ...checkboxes ] } ) ); diff --git a/js/common/view/PopulationControlPanel.js b/js/common/view/PopulationControlPanel.js index 151631df..0bd84ec4 100644 --- a/js/common/view/PopulationControlPanel.js +++ b/js/common/view/PopulationControlPanel.js @@ -11,6 +11,7 @@ define( require => { // modules const Checkbox = require( 'SUN/Checkbox' ); const HSeparator = require( 'SUN/HSeparator' ); + const merge = require( 'PHET_CORE/merge' ); const naturalSelection = require( 'NATURAL_SELECTION/naturalSelection' ); const NaturalSelectionColors = require( 'NATURAL_SELECTION/common/NaturalSelectionColors' ); const NaturalSelectionConstants = require( 'NATURAL_SELECTION/common/NaturalSelectionConstants' ); @@ -33,7 +34,7 @@ define( require => { */ constructor( totalVisibleProperty, valuesMarkerVisibleProperty, traits, options ) { - options = _.extend( { + options = merge( { fixedWidth: 100, xMargin: 0 }, NaturalSelectionConstants.PANEL_OPTIONS, options ); @@ -66,7 +67,7 @@ define( require => { NaturalSelectionConstants.CHECKBOX_OPTIONS ); // Arranged vertically - const content = new VBox( _.extend( {}, NaturalSelectionConstants.VBOX_OPTIONS, { + const content = new VBox( merge( {}, NaturalSelectionConstants.VBOX_OPTIONS, { children: [ totalCheckbox, ...traitCheckboxes, separator, valuesMarkerCheckbox ] } ) ); diff --git a/js/common/view/PopulationGraphNode.js b/js/common/view/PopulationGraphNode.js index 53e3a493..36d60e25 100644 --- a/js/common/view/PopulationGraphNode.js +++ b/js/common/view/PopulationGraphNode.js @@ -10,6 +10,7 @@ define( require => { // modules const HBox = require( 'SCENERY/nodes/HBox' ); + const merge = require( 'PHET_CORE/merge' ); const naturalSelection = require( 'NATURAL_SELECTION/naturalSelection' ); const NaturalSelectionColors = require( 'NATURAL_SELECTION/common/NaturalSelectionColors' ); const NaturalSelectionConstants = require( 'NATURAL_SELECTION/common/NaturalSelectionConstants' ); @@ -46,14 +47,14 @@ define( require => { center: rectangle.center } ); - const zoomInButton = new ZoomButton( _.extend( {}, ZOOM_BUTTON_OPTIONS, { + const zoomInButton = new ZoomButton( merge( {}, ZOOM_BUTTON_OPTIONS, { in: true, listener: () => { //TODO } } ) ); - const zoomOutButton = new ZoomButton( _.extend( {}, ZOOM_BUTTON_OPTIONS, { + const zoomOutButton = new ZoomButton( merge( {}, ZOOM_BUTTON_OPTIONS, { in: false, listener: () => { //TODO diff --git a/js/common/view/ProportionControlPanel.js b/js/common/view/ProportionControlPanel.js index bfb1002f..fabbb9bf 100644 --- a/js/common/view/ProportionControlPanel.js +++ b/js/common/view/ProportionControlPanel.js @@ -11,6 +11,7 @@ define( require => { // modules const Checkbox = require( 'SUN/Checkbox' ); const HSeparator = require( 'SUN/HSeparator' ); + const merge = require( 'PHET_CORE/merge' ); const naturalSelection = require( 'NATURAL_SELECTION/naturalSelection' ); const NaturalSelectionConstants = require( 'NATURAL_SELECTION/common/NaturalSelectionConstants' ); const NaturalSelectionPanel = require( 'NATURAL_SELECTION/common/view/NaturalSelectionPanel' ); @@ -30,7 +31,7 @@ define( require => { */ constructor( valuesVisibleProperty, traits, options ) { - options = _.extend( { + options = merge( { fixedWidth: 100, xMargin: 0 }, NaturalSelectionConstants.PANEL_OPTIONS, options ); @@ -60,7 +61,7 @@ define( require => { } ); // Arranged vertically - const content = new VBox( _.extend( {}, NaturalSelectionConstants.VBOX_OPTIONS, { + const content = new VBox( merge( {}, NaturalSelectionConstants.VBOX_OPTIONS, { children: [ valuesCheckbox, separator, ...traitLegends ] } ) ); diff --git a/js/common/view/SelectionAgentsPanel.js b/js/common/view/SelectionAgentsPanel.js index 34a19dda..04c04158 100644 --- a/js/common/view/SelectionAgentsPanel.js +++ b/js/common/view/SelectionAgentsPanel.js @@ -12,6 +12,7 @@ define( require => { const Checkbox = require( 'SUN/Checkbox' ); const HBox = require( 'SCENERY/nodes/HBox' ); const Image = require( 'SCENERY/nodes/Image' ); + const merge = require( 'PHET_CORE/merge' ); const naturalSelection = require( 'NATURAL_SELECTION/naturalSelection' ); const NaturalSelectionConstants = require( 'NATURAL_SELECTION/common/NaturalSelectionConstants' ); const NaturalSelectionPanel = require( 'NATURAL_SELECTION/common/view/NaturalSelectionPanel' ); @@ -32,7 +33,7 @@ define( require => { assert && assert( selectionAgents.length > 0, 'at least 1 selection agent is required' ); - options = _.extend( {}, NaturalSelectionConstants.PANEL_OPTIONS, options ); + options = merge( {}, NaturalSelectionConstants.PANEL_OPTIONS, options ); const titleString = ( selectionAgents.length === 1 ) ? selectionAgentString : selectionAgentsString; const titleNode = new Text( titleString, { @@ -59,7 +60,7 @@ define( require => { checkboxes.push( checkbox ); } ); - const content = new VBox( _.extend( {}, NaturalSelectionConstants.VBOX_OPTIONS, { + const content = new VBox( merge( {}, NaturalSelectionConstants.VBOX_OPTIONS, { children: [ titleNode, ...checkboxes ] } ) );