-
Notifications
You must be signed in to change notification settings - Fork 6
/
SliderControlsHelpContent.js
115 lines (95 loc) · 5.52 KB
/
SliderControlsHelpContent.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Copyright 2017, University of Colorado Boulder
/**
* Content for a KeyboardHelpDialog that describes how to use sliders.
*
* @author Jesse Greenberg
*/
define( function( require ) {
'use strict';
// modules
var EndKeyNode = require( 'SCENERY_PHET/keyboard/EndKeyNode' );
var HBox = require( 'SCENERY/nodes/HBox' );
var HelpContent = require( 'SCENERY_PHET/keyboard/help/HelpContent' );
var HomeKeyNode = require( 'SCENERY_PHET/keyboard/HomeKeyNode' );
var inherit = require( 'PHET_CORE/inherit' );
var PageDownKeyNode = require( 'SCENERY_PHET/keyboard/PageDownKeyNode' );
var PageUpKeyNode = require( 'SCENERY_PHET/keyboard/PageUpKeyNode' );
var RichText = require( 'SCENERY/nodes/RichText' );
var SceneryPhetA11yStrings = require( 'SCENERY_PHET/SceneryPhetA11yStrings' );
var sceneryPhet = require( 'SCENERY_PHET/sceneryPhet' );
// strings
var keyboardHelpDialogAdjustInLargerStepsString = require( 'string!SCENERY_PHET/keyboardHelpDialog.adjustInLargerSteps' );
var keyboardHelpDialogAdjustInSmallerStepsString = require( 'string!SCENERY_PHET/keyboardHelpDialog.adjustInSmallerSteps' );
var keyboardHelpDialogAdjustSliderString = require( 'string!SCENERY_PHET/keyboardHelpDialog.adjustSlider' );
var keyboardHelpDialogJumpToMaximumString = require( 'string!SCENERY_PHET/keyboardHelpDialog.jumpToMaximum' );
var keyboardHelpDialogJumpToMinimumString = require( 'string!SCENERY_PHET/keyboardHelpDialog.jumpToMinimum' );
var keyboardHelpDialogSliderControlsString = require( 'string!SCENERY_PHET/keyboardHelpDialog.sliderControls' );
// AT strings, not yet translatable
var keyboardHelpDialogAdjustLargerStepsString = SceneryPhetA11yStrings.keyboardHelpDialogAdjustLargerStepsString.value;
var keyboardHelpDialogJumpToHomeString = SceneryPhetA11yStrings.keyboardHelpDialogJumpToHomeString.value;
var keyboardHelpDialogJumpToEndString = SceneryPhetA11yStrings.keyboardHelpDialogJumpToEndString.value;
var keyboardHelpDialogAdjustDefaultStepsString = SceneryPhetA11yStrings.keyboardHelpDialogAdjustDefaultStepsString.value;
var keyboardHelpDialogAdjustSmallerStepsString = SceneryPhetA11yStrings.keyboardHelpDialogAdjustSmallerStepsString.value;
// constants
var DEFAULT_LABEL_OPTIONS = {
font: HelpContent.DEFAULT_LABEL_FONT,
maxWidth: HelpContent.DEFAULT_TEXT_MAX_WIDTH
};
/**
* @constructor
* @param {Object} options
*/
function SliderControlsHelpContent( options ) {
options = _.extend( {
// heading string for this content
headingString: keyboardHelpDialogSliderControlsString,
// icon options
verticalIconSpacing: HelpContent.DEFAULT_VERTICAL_ICON_SPACING
}, options );
// 'Move sliders' content
var adjustSliderText = new RichText( keyboardHelpDialogAdjustSliderString, DEFAULT_LABEL_OPTIONS );
var adjustSliderLeftRightIcon = HelpContent.leftRightArrowKeysRowIcon();
var adjustSliderUpDownIcon = HelpContent.upDownArrowKeysRowIcon();
var adjustSliderIcon = HelpContent.iconOrIcon( adjustSliderLeftRightIcon, adjustSliderUpDownIcon );
var adjustSliderRow = HelpContent.labelWithIcon( adjustSliderText, adjustSliderIcon, {
a11yIconAccessibleLabel: keyboardHelpDialogAdjustDefaultStepsString
} );
// 'move in smaller steps' content
var adjustInSmallerStepsText = new RichText( keyboardHelpDialogAdjustInSmallerStepsString, DEFAULT_LABEL_OPTIONS );
var smallStepsLeftRightIcon = HelpContent.leftRightArrowKeysRowIcon();
var smallStepsUpDownIcon = HelpContent.upDownArrowKeysRowIcon();
var shiftPlusLeftRightIcon = HelpContent.shiftPlusIcon( smallStepsLeftRightIcon );
var shiftPlusUpDownIcon = HelpContent.shiftPlusIcon( smallStepsUpDownIcon );
var adjustSliderInSmallerStepsRow = HelpContent.labelWithIconList( adjustInSmallerStepsText, [ shiftPlusLeftRightIcon, shiftPlusUpDownIcon ], {
a11yIconAccessibleLabel: keyboardHelpDialogAdjustSmallerStepsString
} );
// 'move in larger steps' content
var adjustInLargerStepsText = new RichText( keyboardHelpDialogAdjustInLargerStepsString, DEFAULT_LABEL_OPTIONS );
var pageUpKeyNode = new PageUpKeyNode();
var pageDownKeyNode = new PageDownKeyNode();
var pageUpPageDownIcon = new HBox( {
children: [ pageUpKeyNode, pageDownKeyNode ],
spacing: HelpContent.DEFAULT_ICON_SPACING
} );
var adjustInLargerStepsRow = HelpContent.labelWithIcon( adjustInLargerStepsText, pageUpPageDownIcon, {
a11yIconAccessibleLabel: keyboardHelpDialogAdjustLargerStepsString
} );
// 'move to minimum value' content
var jumpToMinimumText = new RichText( keyboardHelpDialogJumpToMinimumString, DEFAULT_LABEL_OPTIONS );
var homeKeyNode = new HomeKeyNode();
var jumpToMinimumRow = HelpContent.labelWithIcon( jumpToMinimumText, homeKeyNode, {
a11yIconAccessibleLabel: keyboardHelpDialogJumpToHomeString
} );
// 'move to maximum value' content
var jumpToMaximumText = new RichText( keyboardHelpDialogJumpToMaximumString, DEFAULT_LABEL_OPTIONS );
var endKeyNode = new EndKeyNode();
var jumpToMaximumRow = HelpContent.labelWithIcon( jumpToMaximumText, endKeyNode, {
a11yIconAccessibleLabel: keyboardHelpDialogJumpToEndString
} );
// assemble final content for HelpContent
var content = [ adjustSliderRow, adjustSliderInSmallerStepsRow, adjustInLargerStepsRow, jumpToMinimumRow, jumpToMaximumRow ];
HelpContent.call( this, options.headingString, content, options );
}
sceneryPhet.register( 'SliderControlsHelpContent', SliderControlsHelpContent );
return inherit( HelpContent, SliderControlsHelpContent );
} );