chore: version inicial del codigo fuente del LMS Estafeta
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/* *
|
||||
*
|
||||
* (c) 2009-2020 Øystein Moseng
|
||||
*
|
||||
* Create announcer to speak messages to screen readers and other AT.
|
||||
*
|
||||
* License: www.highcharts.com/license
|
||||
*
|
||||
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
|
||||
*
|
||||
* */
|
||||
'use strict';
|
||||
import H from '../../Core/Globals.js';
|
||||
import DOMElementProvider from './DOMElementProvider.js';
|
||||
import HTMLUtilities from './HTMLUtilities.js';
|
||||
var visuallyHideElement = HTMLUtilities.visuallyHideElement;
|
||||
var Announcer = /** @class */ (function () {
|
||||
function Announcer(chart, type) {
|
||||
this.chart = chart;
|
||||
this.domElementProvider = new DOMElementProvider();
|
||||
this.announceRegion = this.addAnnounceRegion(type);
|
||||
}
|
||||
Announcer.prototype.destroy = function () {
|
||||
this.domElementProvider.destroyCreatedElements();
|
||||
};
|
||||
Announcer.prototype.announce = function (message) {
|
||||
var _this = this;
|
||||
this.announceRegion.innerHTML = message;
|
||||
// Delete contents after a little while to avoid user finding the live
|
||||
// region in the DOM.
|
||||
if (this.clearAnnouncementRegionTimer) {
|
||||
clearTimeout(this.clearAnnouncementRegionTimer);
|
||||
}
|
||||
this.clearAnnouncementRegionTimer = setTimeout(function () {
|
||||
_this.announceRegion.innerHTML = '';
|
||||
delete _this.clearAnnouncementRegionTimer;
|
||||
}, 1000);
|
||||
};
|
||||
Announcer.prototype.addAnnounceRegion = function (type) {
|
||||
var chartContainer = this.chart.renderTo;
|
||||
var div = this.domElementProvider.createElement('div');
|
||||
div.setAttribute('aria-hidden', false);
|
||||
div.setAttribute('aria-live', type);
|
||||
visuallyHideElement(div);
|
||||
chartContainer.insertBefore(div, chartContainer.firstChild);
|
||||
return div;
|
||||
};
|
||||
return Announcer;
|
||||
}());
|
||||
H.Announcer = Announcer;
|
||||
export default Announcer;
|
||||
@@ -0,0 +1,187 @@
|
||||
/* *
|
||||
*
|
||||
* (c) 2009-2020 Øystein Moseng
|
||||
*
|
||||
* Utils for dealing with charts.
|
||||
*
|
||||
* License: www.highcharts.com/license
|
||||
*
|
||||
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
|
||||
*
|
||||
* */
|
||||
'use strict';
|
||||
import HTMLUtilities from './HTMLUtilities.js';
|
||||
var stripHTMLTags = HTMLUtilities.stripHTMLTagsFromString;
|
||||
import U from '../../Core/Utilities.js';
|
||||
var defined = U.defined, find = U.find, fireEvent = U.fireEvent;
|
||||
/* eslint-disable valid-jsdoc */
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
function getChartTitle(chart) {
|
||||
return stripHTMLTags(chart.options.title.text ||
|
||||
chart.langFormat('accessibility.defaultChartTitle', { chart: chart }));
|
||||
}
|
||||
/**
|
||||
* @param {Highcharts.Axis} axis
|
||||
* @return {string}
|
||||
*/
|
||||
function getAxisDescription(axis) {
|
||||
return stripHTMLTags(axis && (axis.userOptions && axis.userOptions.accessibility &&
|
||||
axis.userOptions.accessibility.description ||
|
||||
axis.axisTitle && axis.axisTitle.textStr ||
|
||||
axis.options.id ||
|
||||
axis.categories && 'categories' ||
|
||||
axis.dateTime && 'Time' ||
|
||||
'values'));
|
||||
}
|
||||
/**
|
||||
* Get the DOM element for the first point in the series.
|
||||
* @private
|
||||
* @param {Highcharts.Series} series
|
||||
* The series to get element for.
|
||||
* @return {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement|undefined}
|
||||
* The DOM element for the point.
|
||||
*/
|
||||
function getSeriesFirstPointElement(series) {
|
||||
if (series.points &&
|
||||
series.points.length &&
|
||||
series.points[0].graphic) {
|
||||
return series.points[0].graphic.element;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the DOM element for the series that we put accessibility info on.
|
||||
* @private
|
||||
* @param {Highcharts.Series} series
|
||||
* The series to get element for.
|
||||
* @return {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement|undefined}
|
||||
* The DOM element for the series
|
||||
*/
|
||||
function getSeriesA11yElement(series) {
|
||||
var firstPointEl = getSeriesFirstPointElement(series);
|
||||
return (firstPointEl &&
|
||||
firstPointEl.parentNode || series.graph &&
|
||||
series.graph.element || series.group &&
|
||||
series.group.element); // Could be tracker series depending on series type
|
||||
}
|
||||
/**
|
||||
* Remove aria-hidden from element. Also unhides parents of the element, and
|
||||
* hides siblings that are not explicitly unhidden.
|
||||
* @private
|
||||
* @param {Highcharts.Chart} chart
|
||||
* @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} element
|
||||
*/
|
||||
function unhideChartElementFromAT(chart, element) {
|
||||
element.setAttribute('aria-hidden', false);
|
||||
if (element === chart.renderTo || !element.parentNode) {
|
||||
return;
|
||||
}
|
||||
// Hide siblings unless their hidden state is already explicitly set
|
||||
Array.prototype.forEach.call(element.parentNode.childNodes, function (node) {
|
||||
if (!node.hasAttribute('aria-hidden')) {
|
||||
node.setAttribute('aria-hidden', true);
|
||||
}
|
||||
});
|
||||
// Repeat for parent
|
||||
unhideChartElementFromAT(chart, element.parentNode);
|
||||
}
|
||||
/**
|
||||
* Hide series from screen readers.
|
||||
* @private
|
||||
* @param {Highcharts.Series} series
|
||||
* The series to hide
|
||||
* @return {void}
|
||||
*/
|
||||
function hideSeriesFromAT(series) {
|
||||
var seriesEl = getSeriesA11yElement(series);
|
||||
if (seriesEl) {
|
||||
seriesEl.setAttribute('aria-hidden', true);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get series objects by series name.
|
||||
* @private
|
||||
* @param {Highcharts.Chart} chart
|
||||
* @param {string} name
|
||||
* @return {Array<Highcharts.Series>}
|
||||
*/
|
||||
function getSeriesFromName(chart, name) {
|
||||
if (!name) {
|
||||
return chart.series;
|
||||
}
|
||||
return (chart.series || []).filter(function (s) {
|
||||
return s.name === name;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Get point in a series from x/y values.
|
||||
* @private
|
||||
* @param {Array<Highcharts.Series>} series
|
||||
* @param {number} x
|
||||
* @param {number} y
|
||||
* @return {Highcharts.Point|undefined}
|
||||
*/
|
||||
function getPointFromXY(series, x, y) {
|
||||
var i = series.length, res;
|
||||
while (i--) {
|
||||
res = find(series[i].points || [], function (p) {
|
||||
return p.x === x && p.y === y;
|
||||
});
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get relative position of point on an x/y axis from 0 to 1.
|
||||
* @private
|
||||
* @param {Highcharts.Axis} axis
|
||||
* @param {Highcharts.Point} point
|
||||
* @return {number}
|
||||
*/
|
||||
function getRelativePointAxisPosition(axis, point) {
|
||||
if (!defined(axis.dataMin) || !defined(axis.dataMax)) {
|
||||
return 0;
|
||||
}
|
||||
var axisStart = axis.toPixels(axis.dataMin);
|
||||
var axisEnd = axis.toPixels(axis.dataMax);
|
||||
// We have to use pixel position because of axis breaks, log axis etc.
|
||||
var positionProp = axis.coll === 'xAxis' ? 'x' : 'y';
|
||||
var pointPos = axis.toPixels(point[positionProp] || 0);
|
||||
return (pointPos - axisStart) / (axisEnd - axisStart);
|
||||
}
|
||||
/**
|
||||
* Get relative position of point on an x/y axis from 0 to 1.
|
||||
* @private
|
||||
* @param {Highcharts.Point} point
|
||||
*/
|
||||
function scrollToPoint(point) {
|
||||
var xAxis = point.series.xAxis;
|
||||
var yAxis = point.series.yAxis;
|
||||
var axis = (xAxis === null || xAxis === void 0 ? void 0 : xAxis.scrollbar) ? xAxis : yAxis;
|
||||
var scrollbar = axis === null || axis === void 0 ? void 0 : axis.scrollbar;
|
||||
if (scrollbar && defined(scrollbar.to) && defined(scrollbar.from)) {
|
||||
var range = scrollbar.to - scrollbar.from;
|
||||
var pos = getRelativePointAxisPosition(axis, point);
|
||||
scrollbar.updatePosition(pos - range / 2, pos + range / 2);
|
||||
fireEvent(scrollbar, 'changed', {
|
||||
from: scrollbar.from,
|
||||
to: scrollbar.to,
|
||||
trigger: 'scrollbar',
|
||||
DOMEvent: null
|
||||
});
|
||||
}
|
||||
}
|
||||
var ChartUtilities = {
|
||||
getChartTitle: getChartTitle,
|
||||
getAxisDescription: getAxisDescription,
|
||||
getPointFromXY: getPointFromXY,
|
||||
getSeriesFirstPointElement: getSeriesFirstPointElement,
|
||||
getSeriesFromName: getSeriesFromName,
|
||||
getSeriesA11yElement: getSeriesA11yElement,
|
||||
unhideChartElementFromAT: unhideChartElementFromAT,
|
||||
hideSeriesFromAT: hideSeriesFromAT,
|
||||
scrollToPoint: scrollToPoint
|
||||
};
|
||||
export default ChartUtilities;
|
||||
@@ -0,0 +1,50 @@
|
||||
/* *
|
||||
*
|
||||
* (c) 2009-2020 Øystein Moseng
|
||||
*
|
||||
* Class that can keep track of elements added to DOM and clean them up on
|
||||
* destroy.
|
||||
*
|
||||
* License: www.highcharts.com/license
|
||||
*
|
||||
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
|
||||
*
|
||||
* */
|
||||
'use strict';
|
||||
import H from '../../Core/Globals.js';
|
||||
var doc = H.win.document;
|
||||
import U from '../../Core/Utilities.js';
|
||||
var extend = U.extend;
|
||||
import HTMLUtilities from './HTMLUtilities.js';
|
||||
var removeElement = HTMLUtilities.removeElement;
|
||||
/* eslint-disable no-invalid-this, valid-jsdoc */
|
||||
/**
|
||||
* @private
|
||||
* @class
|
||||
*/
|
||||
var DOMElementProvider = function () {
|
||||
this.elements = [];
|
||||
};
|
||||
extend(DOMElementProvider.prototype, {
|
||||
/**
|
||||
* Create an element and keep track of it for later removal.
|
||||
* Same args as document.createElement
|
||||
* @private
|
||||
*/
|
||||
createElement: function () {
|
||||
var el = doc.createElement.apply(doc, arguments);
|
||||
this.elements.push(el);
|
||||
return el;
|
||||
},
|
||||
/**
|
||||
* Destroy all created elements, removing them from the DOM.
|
||||
* @private
|
||||
*/
|
||||
destroyCreatedElements: function () {
|
||||
this.elements.forEach(function (element) {
|
||||
removeElement(element);
|
||||
});
|
||||
this.elements = [];
|
||||
}
|
||||
});
|
||||
export default DOMElementProvider;
|
||||
@@ -0,0 +1,48 @@
|
||||
/* *
|
||||
*
|
||||
* (c) 2009-2020 Øystein Moseng
|
||||
*
|
||||
* Class that can keep track of events added, and clean them up on destroy.
|
||||
*
|
||||
* License: www.highcharts.com/license
|
||||
*
|
||||
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
|
||||
*
|
||||
* */
|
||||
'use strict';
|
||||
import H from '../../Core/Globals.js';
|
||||
import U from '../../Core/Utilities.js';
|
||||
var addEvent = U.addEvent, extend = U.extend;
|
||||
/* eslint-disable no-invalid-this, valid-jsdoc */
|
||||
/**
|
||||
* @private
|
||||
* @class
|
||||
*/
|
||||
var EventProvider = function () {
|
||||
this.eventRemovers = [];
|
||||
};
|
||||
extend(EventProvider.prototype, {
|
||||
/**
|
||||
* Add an event to an element and keep track of it for later removal.
|
||||
* Same args as Highcharts.addEvent.
|
||||
* @private
|
||||
* @return {Function}
|
||||
*/
|
||||
addEvent: function () {
|
||||
var remover = addEvent.apply(H, arguments);
|
||||
this.eventRemovers.push(remover);
|
||||
return remover;
|
||||
},
|
||||
/**
|
||||
* Remove all added events.
|
||||
* @private
|
||||
* @return {void}
|
||||
*/
|
||||
removeAddedEvents: function () {
|
||||
this.eventRemovers.forEach(function (remover) {
|
||||
remover();
|
||||
});
|
||||
this.eventRemovers = [];
|
||||
}
|
||||
});
|
||||
export default EventProvider;
|
||||
@@ -0,0 +1,173 @@
|
||||
/* *
|
||||
*
|
||||
* (c) 2009-2020 Øystein Moseng
|
||||
*
|
||||
* Utility functions for accessibility module.
|
||||
*
|
||||
* License: www.highcharts.com/license
|
||||
*
|
||||
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
|
||||
*
|
||||
* */
|
||||
'use strict';
|
||||
import U from '../../Core/Utilities.js';
|
||||
var merge = U.merge;
|
||||
import H from '../../Core/Globals.js';
|
||||
var win = H.win, doc = win.document;
|
||||
/* eslint-disable valid-jsdoc */
|
||||
/**
|
||||
* @private
|
||||
* @param {Highcharts.HTMLDOMElement} el
|
||||
* @param {string} className
|
||||
* @return {void}
|
||||
*/
|
||||
function addClass(el, className) {
|
||||
if (el.classList) {
|
||||
el.classList.add(className);
|
||||
}
|
||||
else if (el.className.indexOf(className) < 0) {
|
||||
// Note: Dumb check for class name exists, should be fine for practical
|
||||
// use cases, but will return false positives if the element has a class
|
||||
// that contains the className.
|
||||
el.className += className;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @private
|
||||
* @param {string} str
|
||||
* @return {string}
|
||||
*/
|
||||
function escapeStringForHTML(str) {
|
||||
return str
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
.replace(/\//g, '/');
|
||||
}
|
||||
/**
|
||||
* Get an element by ID
|
||||
* @param {string} id
|
||||
* @private
|
||||
* @return {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement|null}
|
||||
*/
|
||||
function getElement(id) {
|
||||
return doc.getElementById(id);
|
||||
}
|
||||
/**
|
||||
* Get a fake mouse event of a given type
|
||||
* @param {string} type
|
||||
* @private
|
||||
* @return {global.MouseEvent}
|
||||
*/
|
||||
function getFakeMouseEvent(type) {
|
||||
if (typeof win.MouseEvent === 'function') {
|
||||
return new win.MouseEvent(type);
|
||||
}
|
||||
// No MouseEvent support, try using initMouseEvent
|
||||
if (doc.createEvent) {
|
||||
var evt = doc.createEvent('MouseEvent');
|
||||
if (evt.initMouseEvent) {
|
||||
evt.initMouseEvent(type, true, // Bubble
|
||||
true, // Cancel
|
||||
win, // View
|
||||
type === 'click' ? 1 : 0, // Detail
|
||||
// Coords
|
||||
0, 0, 0, 0,
|
||||
// Pressed keys
|
||||
false, false, false, false, 0, // button
|
||||
null // related target
|
||||
);
|
||||
return evt;
|
||||
}
|
||||
}
|
||||
return { type: type };
|
||||
}
|
||||
/**
|
||||
* Remove an element from the DOM.
|
||||
* @private
|
||||
* @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} [element]
|
||||
* @return {void}
|
||||
*/
|
||||
function removeElement(element) {
|
||||
if (element && element.parentNode) {
|
||||
element.parentNode.removeChild(element);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Utility function. Reverses child nodes of a DOM element.
|
||||
* @private
|
||||
* @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} node
|
||||
* @return {void}
|
||||
*/
|
||||
function reverseChildNodes(node) {
|
||||
var i = node.childNodes.length;
|
||||
while (i--) {
|
||||
node.appendChild(node.childNodes[i]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set attributes on element. Set to null to remove attribute.
|
||||
* @private
|
||||
* @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} el
|
||||
* @param {Highcharts.HTMLAttributes|Highcharts.SVGAttributes} attrs
|
||||
* @return {void}
|
||||
*/
|
||||
function setElAttrs(el, attrs) {
|
||||
Object.keys(attrs).forEach(function (attr) {
|
||||
var val = attrs[attr];
|
||||
if (val === null) {
|
||||
el.removeAttribute(attr);
|
||||
}
|
||||
else {
|
||||
var cleanedVal = escapeStringForHTML('' + val);
|
||||
el.setAttribute(attr, cleanedVal);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Used for aria-label attributes, painting on a canvas will fail if the
|
||||
* text contains tags.
|
||||
* @private
|
||||
* @param {string} str
|
||||
* @return {string}
|
||||
*/
|
||||
function stripHTMLTagsFromString(str) {
|
||||
return typeof str === 'string' ?
|
||||
str.replace(/<\/?[^>]+(>|$)/g, '') : str;
|
||||
}
|
||||
/**
|
||||
* Utility function for hiding an element visually, but still keeping it
|
||||
* available to screen reader users.
|
||||
* @private
|
||||
* @param {Highcharts.HTMLDOMElement} element
|
||||
* @return {void}
|
||||
*/
|
||||
function visuallyHideElement(element) {
|
||||
var hiddenStyle = {
|
||||
position: 'absolute',
|
||||
width: '1px',
|
||||
height: '1px',
|
||||
overflow: 'hidden',
|
||||
whiteSpace: 'nowrap',
|
||||
clip: 'rect(1px, 1px, 1px, 1px)',
|
||||
marginTop: '-3px',
|
||||
'-ms-filter': 'progid:DXImageTransform.Microsoft.Alpha(Opacity=1)',
|
||||
filter: 'alpha(opacity=1)',
|
||||
opacity: '0.01'
|
||||
};
|
||||
merge(true, element.style, hiddenStyle);
|
||||
}
|
||||
var HTMLUtilities = {
|
||||
addClass: addClass,
|
||||
escapeStringForHTML: escapeStringForHTML,
|
||||
getElement: getElement,
|
||||
getFakeMouseEvent: getFakeMouseEvent,
|
||||
removeElement: removeElement,
|
||||
reverseChildNodes: reverseChildNodes,
|
||||
setElAttrs: setElAttrs,
|
||||
stripHTMLTagsFromString: stripHTMLTagsFromString,
|
||||
visuallyHideElement: visuallyHideElement
|
||||
};
|
||||
export default HTMLUtilities;
|
||||
Reference in New Issue
Block a user