-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
accessible summary for RIAW, see #126
- Loading branch information
1 parent
3ea607d
commit c0fca2a
Showing
5 changed files
with
175 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// Copyright 2018, University of Colorado Boulder | ||
|
||
/** | ||
* The Scene Summary for Resistance in a Wire. This summary is at the top of the document, and is the first thing | ||
* that a screen reader user reads when using the sim. It provides overview information about the resistance | ||
* equation, visualization of the circuit, and the controls in the interface. | ||
* | ||
* @author Jesse Greenberg (PhET Interactive Simulations) | ||
*/ | ||
|
||
define( function( require ) { | ||
'use strict'; | ||
|
||
// modules | ||
var AccessibleSectionNode = require( 'SCENERY_PHET/accessibility/AccessibleSectionNode' ); | ||
var inherit = require( 'PHET_CORE/inherit' ); | ||
var JoistA11yStrings = require( 'JOIST/JoistA11yStrings' ); | ||
var Node = require( 'SCENERY/nodes/Node' ); | ||
var resistanceInAWire = require( 'RESISTANCE_IN_A_WIRE/resistanceInAWire' ); | ||
var ResistanceInAWireA11yStrings = require( 'RESISTANCE_IN_A_WIRE/resistance-in-a-wire/ResistanceInAWireA11yStrings' ); | ||
var ResistanceInAWireConstants = require( 'RESISTANCE_IN_A_WIRE/resistance-in-a-wire/ResistanceInAWireConstants' ); | ||
var StringUtils = require( 'PHETCOMMON/util/StringUtils' ); | ||
var Util = require( 'DOT/Util' ); | ||
|
||
var sceneSummaryString = JoistA11yStrings.sceneSummaryString; | ||
var summarySimString = ResistanceInAWireA11yStrings.summarySimString.value; | ||
var currentlyString = ResistanceInAWireA11yStrings.currentlyString.value; | ||
var summaryResistancePatternString = ResistanceInAWireA11yStrings.summaryResistancePatternString.value; | ||
var summaryResistivityPatternString = ResistanceInAWireA11yStrings.summaryResistivityPatternString.value; | ||
var summaryLengthPatternString = ResistanceInAWireA11yStrings.summaryLengthPatternString.value; | ||
var summaryAreaPatternString = ResistanceInAWireA11yStrings.summaryAreaPatternString.value; | ||
var summaryInteractionHintString = ResistanceInAWireA11yStrings.summaryInteractionHintString.value; | ||
var checkOutShortcutsString = JoistA11yStrings.checkOutShortcutsString; | ||
|
||
// constants | ||
function AccessibleSummaryNode( model ) { | ||
AccessibleSectionNode.call( this, sceneSummaryString ); | ||
|
||
// main summary for this sim - this content never changes | ||
this.addChild( new Node( { | ||
tagName: 'p', | ||
accessibleLabelAsHTML: summarySimString | ||
} ) ); | ||
|
||
// indicates that the summary updates with model changes | ||
this.addChild( new Node( { tagName: 'p', accessibleLabel: currentlyString } ) ); | ||
|
||
// list that updates according to model Properties | ||
var listNode = new Node( { tagName: 'ul' } ); | ||
var resistanceItemNode = new Node( { tagName: 'li' } ); | ||
var resistivityItemNode = new Node( { tagName: 'li' } ); | ||
var lengthItemNode = new Node( { tagName: 'li' } ); | ||
var areaItemNode = new Node( { tagName: 'li' } ); | ||
this.addChild( listNode ); | ||
listNode.children = [ resistanceItemNode, resistivityItemNode, lengthItemNode, areaItemNode ]; | ||
|
||
// hint to look for other elements in the UI | ||
this.addChild( new Node( { tagName: 'p', accessibleLabel: summaryInteractionHintString } ) ); | ||
|
||
// hint to look for help dialog for more information | ||
this.addChild( new Node( { tagName: 'p', accessibleLabel: checkOutShortcutsString } ) ); | ||
|
||
// add listeners - add all values to a list so we can easily iterate and add listeners to update descriptions | ||
// with each property | ||
var valueItemList = [ | ||
{ | ||
property: model.resistivityProperty, | ||
patternString: summaryResistivityPatternString, | ||
node: resistivityItemNode, | ||
precision: ResistanceInAWireConstants.SLIDER_READOUT_DECIMALS | ||
}, | ||
{ | ||
property: model.lengthProperty, | ||
patternString: summaryLengthPatternString, | ||
node: lengthItemNode, | ||
precision: ResistanceInAWireConstants.SLIDER_READOUT_DECIMALS | ||
}, | ||
{ | ||
property: model.areaProperty, | ||
patternString: summaryAreaPatternString, | ||
node: areaItemNode, | ||
precision: ResistanceInAWireConstants.SLIDER_READOUT_DECIMALS | ||
}, | ||
{ | ||
property: model.resistanceProperty, | ||
patternString: summaryResistancePatternString, | ||
node: resistanceItemNode, | ||
precision: ResistanceInAWireConstants.getResistanceDecimals // TODO: get dynamically, it will update | ||
} | ||
]; | ||
|
||
// register listeners that update the labels in the scene summary - this summary exists for life of sim, | ||
// no need to dispose | ||
valueItemList.forEach( function( item ) { | ||
item.property.link( function( value ) { | ||
|
||
// the precision might change during interaction, get precision if property is a function | ||
var precision = typeof item.precision === 'number' ? item.precision : item.precision( value ); | ||
console.log( item.patternString ); | ||
item.node.accessibleLabelAsHTML = StringUtils.fillIn( item.patternString, { | ||
value: Util.toFixed( value, precision ) | ||
} ); | ||
} ); | ||
} ); | ||
} | ||
|
||
resistanceInAWire.register( 'AccessibleSummaryNode', AccessibleSummaryNode ); | ||
|
||
return inherit( AccessibleSectionNode, AccessibleSummaryNode, {} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters