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
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// React
const {
createFactory,
Component,
} = require("devtools/client/shared/vendor/react");
const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
const { L10N } = require("devtools/client/accessibility/utils/l10n");
const { hr } = require("devtools/client/shared/vendor/react-dom-factories");
loader.lazyGetter(this, "MenuButton", function() {
return createFactory(
require("devtools/client/shared/components/menu/MenuButton")
);
});
loader.lazyGetter(this, "MenuItem", function() {
return createFactory(
require("devtools/client/shared/components/menu/MenuItem")
);
});
loader.lazyGetter(this, "MenuList", function() {
return createFactory(
require("devtools/client/shared/components/menu/MenuList")
);
});
const {
A11Y_LEARN_MORE_LINK,
} = require("devtools/client/accessibility/constants");
const { openDocLink } = require("devtools/client/shared/link");
const { updatePref } = require("devtools/client/accessibility/actions/ui");
const { connect } = require("devtools/client/shared/vendor/react-redux");
const { PREFS } = require("devtools/client/accessibility/constants");
class AccessibilityPrefs extends Component {
static get propTypes() {
return {
dispatch: PropTypes.func.isRequired,
[PREFS.SCROLL_INTO_VIEW]: PropTypes.bool.isRequired,
toolboxDoc: PropTypes.object.isRequired,
};
}
togglePref(prefKey) {
this.props.dispatch(updatePref(prefKey, !this.props[prefKey]));
}
onPrefClick(prefKey) {
this.togglePref(prefKey);
}
onLearnMoreClick() {
openDocLink(
A11Y_LEARN_MORE_LINK +
"?utm_source=devtools&utm_medium=a11y-panel-toolbar"
);
}
render() {
return MenuButton(
{
menuId: "accessibility-tree-filters-prefs-menu",
toolboxDoc: this.props.toolboxDoc,
className: `devtools-button badge toolbar-menu-button prefs`,
title: L10N.getStr("accessibility.tree.filters.prefs"),
},
MenuList({}, [
MenuItem({
key: "pref-scroll-into-view",
checked: this.props[PREFS.SCROLL_INTO_VIEW],
className: `pref ${PREFS.SCROLL_INTO_VIEW}`,
label: L10N.getStr("accessibility.pref.scroll.into.view.label"),
tooltip: L10N.getStr("accessibility.pref.scroll.into.view.title"),
onClick: this.onPrefClick.bind(this, PREFS.SCROLL_INTO_VIEW),
}),
hr(),
MenuItem({
role: "link",
key: "accessibility-tree-filters-prefs-menu-help",
className: "help",
label: L10N.getStr("accessibility.documentation.label"),
tooltip: L10N.getStr("accessibility.learnMore"),
onClick: this.onLearnMoreClick,
}),
])
);
}
}
const mapStateToProps = ({ ui }) => ({
[PREFS.SCROLL_INTO_VIEW]: ui[PREFS.SCROLL_INTO_VIEW],
});
// Exports from this module
module.exports = connect(mapStateToProps)(AccessibilityPrefs);
|