Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/mapml/handlers/ContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,14 @@ export var ContextMenu = Handler.extend({
{
// 8
text: locale.cmToggleControls + ' (<kbd>T</kbd>)',
callback: this._toggleControls
callback: this._toggleControls,
toggle: true
},
{
// 9
text: locale.cmToggleDebug + ' (<kbd>D</kbd>)',
callback: this._toggleDebug
callback: this._toggleDebug,
toggle: true
},
{
// 10
Expand Down Expand Up @@ -461,6 +463,11 @@ export var ContextMenu = Handler.extend({
},

_toggleControls: function (e) {
let el = this.contextMenu._items[8].el.el;
el.setAttribute(
'aria-checked',
el.getAttribute('aria-checked') === 'true' ? 'false' : 'true'
);
let mapEl =
e instanceof KeyboardEvent ? this._map.options.mapEl : this.options.mapEl;
if (mapEl.controls) {
Expand Down Expand Up @@ -505,6 +512,11 @@ export var ContextMenu = Handler.extend({
},

_toggleDebug: function (e) {
let el = this.contextMenu._items[9].el.el;
el.setAttribute(
'aria-checked',
el.getAttribute('aria-checked') === 'true' ? 'false' : 'true'
);
let mapEl =
e instanceof KeyboardEvent ? this._map.options.mapEl : this.options.mapEl;
mapEl.toggleDebug();
Expand Down Expand Up @@ -754,6 +766,11 @@ export var ContextMenu = Handler.extend({
el.setAttribute('aria-controls', 'mapml-copy-submenu');
}

if (options.toggle) {
el.setAttribute('role', 'checkbox');
el.setAttribute('aria-checked', 'false');
}

DomEvent.on(el, 'mouseover', this._onItemMouseOver, this)
.on(el, 'mouseout', this._onItemMouseOut, this)
.on(el, 'mousedown', DomEvent.stopPropagation)
Expand Down