Skip to content

Commit

Permalink
support for dynamic locale, #140
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Aug 30, 2022
1 parent a0ee7df commit 98e1eb9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 38 deletions.
4 changes: 2 additions & 2 deletions js/common/view/ElectronegativitySlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ class ElectronegativitySlider extends HSlider {
font: new PhetFont( 16 ),
maxWidth: 40
};
this.addMajorTick( range.min, new Text( moleculePolarityStrings.less, tickLabelOptions ) );
this.addMajorTick( range.max, new Text( moleculePolarityStrings.more, tickLabelOptions ) );
this.addMajorTick( range.min, new Text( moleculePolarityStrings.lessStringProperty, tickLabelOptions ) );
this.addMajorTick( range.max, new Text( moleculePolarityStrings.moreStringProperty, tickLabelOptions ) );
const centerTick = range.min + ( range.getLength() / 2 );
this.addMajorTick( centerTick );
for ( let i = range.min + options.tickInterval; i < range.max; i += options.tickInterval ) {
Expand Down
46 changes: 13 additions & 33 deletions js/common/view/MolecularDipoleCheckbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import moleculePolarity from '../../moleculePolarity.js';
import moleculePolarityStrings from '../../moleculePolarityStrings.js';
import MolecularDipoleNode from './MolecularDipoleNode.js';

class MolecularDipoleCheckbox extends Checkbox {
export default class MolecularDipoleCheckbox extends Checkbox {

/**
* @param {Property.<boolean>} molecularDipoleVisibleProperty
Expand All @@ -29,40 +29,20 @@ class MolecularDipoleCheckbox extends Checkbox {
tandem: Tandem.REQUIRED
}, options );

const labelNode = createLabelNode( {
tandem: options.tandem.createTandem( 'labelNode' )
} );

super( molecularDipoleVisibleProperty, labelNode, options );
}
}
const textNode = new Text( moleculePolarityStrings.molecularDipoleStringProperty, merge( {
tandem: options.tandem.createTandem( 'textNode' ),
phetioVisiblePropertyInstrumented: false
}, MPConstants.CONTROL_TEXT_OPTIONS ) );

/**
* Creates the label for this checkbox.
* @param {Object} [options]
* @returns {HBox}
*/
function createLabelNode( options ) {
const iconNode = MolecularDipoleNode.createIcon();

options = merge( {
singular: false,
spacing: MPConstants.CONTROL_ICON_X_SPACING,
tandem: Tandem.REQUIRED
}, options );

const labelText = new Text( moleculePolarityStrings.molecularDipole,
merge( {
tandem: options.tandem.createTandem( 'labelText' )
}, MPConstants.CONTROL_TEXT_OPTIONS )
);

const labelIcon = MolecularDipoleNode.createIcon();

assert && assert( !options.children, 'createLabelNode sets children' );
options.children = [ labelText, labelIcon ];
const content = new HBox( {
children: [ textNode, iconNode ],
spacing: MPConstants.CONTROL_ICON_X_SPACING
} );

return new HBox( options );
super( molecularDipoleVisibleProperty, content, options );
}
}

moleculePolarity.register( 'MolecularDipoleCheckbox', MolecularDipoleCheckbox );
export default MolecularDipoleCheckbox;
moleculePolarity.register( 'MolecularDipoleCheckbox', MolecularDipoleCheckbox );
3 changes: 0 additions & 3 deletions js/molecule-polarity-phet-io-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ window.phet.preloads.phetio.phetioElementsOverrides =
"moleculePolarity.threeAtomsScreen.view.controlPanel.separator1.visibleProperty": {
"phetioFeatured": true
},
"moleculePolarity.threeAtomsScreen.view.controlPanel.viewControls.molecularDipoleCheckbox.labelNode.labelText.textProperty": {
"phetioFeatured": true
},
"moleculePolarity.threeAtomsScreen.view.controlPanel.viewControls.partialChargesCheckbox.labelText.textProperty": {
"phetioFeatured": true
},
Expand Down

0 comments on commit 98e1eb9

Please sign in to comment.