Skip to content
Open
Show file tree
Hide file tree
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
38 changes: 34 additions & 4 deletions htdocs/js/GraphTool/circletool.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@
fixed: true,
highlight: false,
strokeColor: gt.color.curve,
dash: solid ? 0 : 2
dash: solid ? 0 : 2,
tabindex: ''
})
);
this.baseObj.setAttribute({
aria: {
enabled: true,
label: this.constructor.ariaLabel,
roledescription: this.constructor.strId,
live: 'assertive',
atomic: true
}
});
this.definingPts.push(center, point);
this.focusPoint = center;

Expand Down Expand Up @@ -47,6 +57,14 @@
);
}

static ariaLabel(c) {
return (
(c.getAttribute('dash') == 0 ? 'solid' : 'dashed') +
` circle centered at ${c.center.X()}, ${c.center.Y()} and ` +
`passing through the point ${c.point2.X()}, ${c.point2.Y()}`
);
}

static restore(string) {
let pointData = gt.pointRegexp.exec(string);
const points = [];
Expand Down Expand Up @@ -116,7 +134,9 @@
highlight: false,
snapSizeX: gt.snapSizeX,
snapSizeY: gt.snapSizeY,
withLabel: false
withLabel: false,
tabindex: 0,
aria: gt.pointAria
});
this.hlObjs.hl_point.rendNode.focus();
}
Expand All @@ -129,7 +149,15 @@
fixed: true,
strokeColor: gt.color.underConstruction,
highlight: false,
dash: gt.drawSolid ? 0 : 2
dash: gt.drawSolid ? 0 : 2,
tabindex: '',
aria: {
enabled: true,
label: gt.graphObjectTypes[this.object].ariaLabel,
roledescription: this.object,
live: 'assertive',
atomic: true
}
});
}

Expand All @@ -151,7 +179,9 @@
highlight: false,
snapToGrid: true,
snapSizeX: gt.snapSizeX,
snapSizeY: gt.snapSizeY
snapSizeY: gt.snapSizeY,
tabindex: '',
aria: gt.pointAria
});
this.center.setAttribute({ fixed: true });

Expand Down
31 changes: 28 additions & 3 deletions htdocs/js/GraphTool/cubictool.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,19 @@
strokeWidth: 2,
highlight: false,
strokeColor: color ? color : gt.color.underConstruction,
dash: solid ? 0 : 2
dash: solid ? 0 : 2,
tabindex: '',
aria: {
enabled: true,
label: (c) =>
(c.getAttribute('dash') == 0 ? 'solid' : 'dashed') +
` cubic passing through ${point1.X()}, ${point1.Y()}, and ` +
`${point2.X()}, ${point2.Y()}, and ${point3.X()}, ${point3.Y()}, ` +
`and ${point4.X()}, ${point4.Y()}`,
roledescription: 'cubic',
live: 'assertive',
atomic: true
}
}
);
}
Expand Down Expand Up @@ -294,7 +306,9 @@
snapSizeX: gt.snapSizeX,
snapSizeY: gt.snapSizeY,
highlight: false,
withLabel: false
withLabel: false,
tabindex: '',
aria: gt.pointAria
});
this.hlObjs.hl_point.rendNode.focus();
}
Expand Down Expand Up @@ -341,7 +355,18 @@
fixed: true,
strokeColor: gt.color.underConstruction,
highlight: false,
dash: gt.drawSolid ? 0 : 2
dash: gt.drawSolid ? 0 : 2,
tabindex: '',
aria: {
enabled: true,
label: (l) =>
(l.getAttribute('dash') == 0 ? 'solid' : 'dashed') +
` line through ${l.point1.X()}, ${l.point1.Y()}, ` +
`and ${l.point2.X()}, ${l.point2.Y()}`,
roledescription: 'line',
live: 'assertive',
atomic: true
}
});
}

Expand Down
55 changes: 50 additions & 5 deletions htdocs/js/GraphTool/filltool.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@
highlightStrokeOpacity: 0,
fillOpacity: 0,
highlightFillOpacity: 0,
fixed: gt.isStatic
fixed: gt.isStatic,
tabindex: 0,
aria: {
enabled: true,
label: (p) => `shade the region containing the point ${p.X()}, ${p.Y()}`,
roledescription: 'shading point',
live: 'assertive',
atomic: true
}
});
this.definingPts.push(point);
this.focusPoint = point;
Expand All @@ -41,7 +49,15 @@
[() => point.X() - 12 / gt.board.unitX, () => point.Y() - 12 / gt.board.unitY],
[() => 24 / gt.board.unitX, () => 24 / gt.board.unitY]
],
{ withLabel: false, highlight: false, layer: 8, name: 'FillIcon', fixed: true }
{
withLabel: false,
highlight: false,
layer: 8,
name: 'FillIcon',
fixed: true,
tabindex: '',
aria: { enabled: true, hidden: true, live: 'off' }
}
);

if (!gt.isStatic) {
Expand Down Expand Up @@ -226,7 +242,21 @@
this.fillObj = gt.board.create(
'image',
[dataURL, [bBox[0], bBox[3]], [bBox[2] - bBox[0], bBox[1] - bBox[3]]],
{ withLabel: false, highlight: false, fixed: true, layer: 0 }
{
withLabel: false,
highlight: false,
fixed: true,
layer: 0,
tabindex: '',
aria: {
enabled: true,
label: () =>
`shaded region containing the point ${this.baseObj.X()}, ${this.baseObj.Y()}`,
roledescription: 'shading',
live: 'assertive',
atomic: true
}
}
);
};

Expand Down Expand Up @@ -343,7 +373,15 @@
withLabel: false,
snapToGrid: true,
snapSizeX: gt.snapSizeX,
snapSizeY: gt.snapSizeY
snapSizeY: gt.snapSizeY,
tabindex: 0,
aria: {
enabled: true,
label: (p) => `shade the region containing the point ${p.X()}, ${p.Y()}`,
roledescription: 'shading point',
live: 'assertive',
atomic: true
}
});
this.hlObjs.hl_point.rendNode.classList.add('hidden-fill-point');

Expand All @@ -357,7 +395,14 @@
],
[() => 24 / gt.board.unitX, () => 24 / gt.board.unitY]
],
{ withLabel: false, highlight: false, fixed: true, layer: 8 }
{
withLabel: false,
highlight: false,
fixed: true,
layer: 8,
tabindex: '',
aria: { enabled: true, hidden: true, live: 'off' }
}
);

this.hlObjs.hl_point.rendNode.focus();
Expand Down
31 changes: 22 additions & 9 deletions htdocs/js/GraphTool/graphtool.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global JXG */
/* global JXG, MathJax */

'use strict';

Expand All @@ -14,6 +14,7 @@ window.graphTool = (containerId, options) => {
setTimeout(() => window.graphTool(containerId, options), 100);
return;
}
gt.graphContainer.role = 'application';

// Semantic color control
gt.color = {
Expand Down Expand Up @@ -95,9 +96,11 @@ window.graphTool = (containerId, options) => {
lastArrow: { size: 7 },
straightFirst: false,
straightLast: false,
fixed: true
fixed: true,
tabindex: '',
aria: { enabled: true, hidden: true, live: 'off' }
},
grid: { majorStep: [gt.snapSizeX, gt.snapSizeY] },
grid: { majorStep: [gt.snapSizeX, gt.snapSizeY], aria: { enabled: true, hidden: true, live: 'off' } },
keyboard: {
enabled: true,
dx: gt.snapSizeX,
Expand Down Expand Up @@ -711,15 +714,20 @@ window.graphTool = (containerId, options) => {
}, 100);
});

let currentContent = '';

gt.setMessageText = (content) => {
if (gt.confirmationActive || !gt.helpEnabled) return;

const newMessage = content instanceof Array ? content.join(' ') : content;
if (newMessage) {
if (currentContent === newMessage) return;
currentContent = newMessage;
const par = document.createElement('p');
par.textContent = newMessage;
gt.setMessageContent(par);
} else {
currentContent = '';
gt.setMessageContent();
}
};
Expand Down Expand Up @@ -777,6 +785,14 @@ window.graphTool = (containerId, options) => {

gt.pointRegexp = /\( *(-?[0-9]*(?:\.[0-9]*)?), *(-?[0-9]*(?:\.[0-9]*)?) *\)/g;

gt.pointAria = {
enabled: true,
label: (p) => `point at ${p.X()}, ${p.Y()}`,
roledescription: 'point',
live: 'assertive',
atomic: true
};

// This returns true if the points p1, p2, and p3 are colinear.
// Note that p1 must be an array of two numbers, and p2 and p3 must be JSXGraph points.
gt.areColinear = (p1, p2, p3) => {
Expand Down Expand Up @@ -913,6 +929,7 @@ window.graphTool = (containerId, options) => {
const point = gt.board.create('point', [gt.snapRound(x, gt.snapSizeX), gt.snapRound(y, gt.snapSizeY)], {
snapSizeX: gt.snapSizeX,
snapSizeY: gt.snapSizeY,
aria: gt.pointAria,
...gt.definingPointAttributes()
});
point.setAttribute({ snapToGrid: true });
Expand Down Expand Up @@ -1514,12 +1531,8 @@ window.graphTool = (containerId, options) => {
helpText() {
return (gt.selectedObj && gt.selectedObj.supportsSolidDash) ||
(gt.activeTool && gt.activeTool.supportsSolidDash)
? 'Use the ' +
'\\(\\rule[3px]{34px}{2px}\\) or ' +
'\\(\\rule[3px]{3px}{2px}' +
'\\hspace{4px}\\rule[3px]{4px}{2px}'.repeat(3) +
'\\hspace{4px}\\rule[3px]{3px}{2px}\\)' +
' button or type s or d to make the selected object solid or dashed.'
? 'Use the solid line or dashed line buttons or type s or d to ' +
'make the selected object solid or dashed.'
: '';
}
}
Expand Down
Loading
Loading