Skip to content

Commit

Permalink
use merge instead of _.extend throughout natural-selection, phetsims/…
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Oct 11, 2019
1 parent 3229460 commit 8f9a185
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 20 deletions.
3 changes: 2 additions & 1 deletion js/common/view/AddAMateButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions js/common/view/AddMutationPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -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( {
Expand All @@ -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 ]
} ) );

Expand Down
3 changes: 2 additions & 1 deletion js/common/view/ClimateRadioButtonGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -29,7 +30,7 @@ define( require => {
*/
constructor( climateProperty, options ) {

options = _.extend( {
options = merge( {
orientation: 'horizontal',
spacing: 8,
cornerRadius: NaturalSelectionConstants.CORNER_RADIUS,
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/GraphRadioButtonGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -31,7 +32,7 @@ define( require => {
*/
constructor( graphProperty, options ) {

options = _.extend( {
options = merge( {
radius: 8,
xSpacing: 10,
spacing: 12
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/LimitedFoodCheckbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions js/common/view/MutationComingNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -38,15 +39,15 @@ define( require => {
*/
constructor( options ) {

options = _.extend( {
options = merge( {
cancelButtonListener: null
}, options );

const iconNode = new Image( mutationIcon, { scale: 0.75 } );

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 } ),
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/NaturalSelectionPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );

Expand All @@ -21,7 +22,7 @@ define( require => {
*/
constructor( content, options ) {

options = _.extend( {
options = merge( {
fixedWidth: null // {number|null} optional fixed width
}, options );

Expand Down
3 changes: 2 additions & 1 deletion js/common/view/NaturalSelectionTimeControlNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );

Expand All @@ -21,7 +22,7 @@ define( require => {
*/
constructor( isPlayingProperty, options ) {

options = _.extend( {
options = merge( {
//TODO
}, options );

Expand Down
5 changes: 3 additions & 2 deletions js/common/view/PedigreeControlPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -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, {
Expand All @@ -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 ]
} ) );

Expand Down
5 changes: 3 additions & 2 deletions js/common/view/PopulationControlPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -33,7 +34,7 @@ define( require => {
*/
constructor( totalVisibleProperty, valuesMarkerVisibleProperty, traits, options ) {

options = _.extend( {
options = merge( {
fixedWidth: 100,
xMargin: 0
}, NaturalSelectionConstants.PANEL_OPTIONS, options );
Expand Down Expand Up @@ -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 ]
} ) );

Expand Down
5 changes: 3 additions & 2 deletions js/common/view/PopulationGraphNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions js/common/view/ProportionControlPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -30,7 +31,7 @@ define( require => {
*/
constructor( valuesVisibleProperty, traits, options ) {

options = _.extend( {
options = merge( {
fixedWidth: 100,
xMargin: 0
}, NaturalSelectionConstants.PANEL_OPTIONS, options );
Expand Down Expand Up @@ -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 ]
} ) );

Expand Down
5 changes: 3 additions & 2 deletions js/common/view/SelectionAgentsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -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, {
Expand All @@ -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 ]
} ) );

Expand Down

0 comments on commit 8f9a185

Please sign in to comment.