@syncfusion/ej2-grids
Version:
Feature-rich JavaScript datagrid (datatable) control with built-in support for editing, filtering, grouping, paging, sorting, and exporting to Excel.
67 lines (66 loc) • 2.21 kB
JavaScript
/**
* AriaService
*
* @hidden
*/
var AriaService = /** @class */ (function () {
function AriaService() {
}
AriaService.prototype.setOptions = function (target, options) {
var props = Object.keys(options);
for (var i = 0; i < props.length; i++) {
setStateAndProperties(target, config[props[parseInt(i.toString(), 10)]], options[props[parseInt(i.toString(), 10)]]);
}
};
AriaService.prototype.setExpand = function (target, expand) {
setStateAndProperties(target, config.expand, expand);
};
AriaService.prototype.setSort = function (target, direction) {
setStateAndProperties(target, config.sort, direction, typeof direction === 'boolean');
};
AriaService.prototype.setBusy = function (target, isBusy) {
setStateAndProperties(target, config.busy, isBusy);
setStateAndProperties(target, config.invalid, null, true);
};
AriaService.prototype.setGrabbed = function (target, isGrabbed, remove) {
setStateAndProperties(target, config.grabbed, isGrabbed, remove);
};
AriaService.prototype.setDropTarget = function (target, isTarget) {
setStateAndProperties(target, config.dropeffect, 'copy', !isTarget);
};
return AriaService;
}());
export { AriaService };
/**
* @param {HTMLElement} target - specifies the target
* @param {string} attribute - specifies the attribute
* @param {ValueType} value - specifies the value
* @param {boolean} remove - specifies the boolean for remove
* @returns {void}
* @hidden
*/
function setStateAndProperties(target, attribute, value, remove) {
if (remove && target) {
target.removeAttribute(attribute);
return;
}
if (target) {
target.setAttribute(attribute, value);
}
}
var config = {
expand: 'aria-expanded',
role: 'role',
datarole: 'data-role',
selected: 'aria-selected',
multiselectable: 'aria-multiselectable',
sort: 'aria-sort',
busy: 'aria-busy',
invalid: 'aria-invalid',
grabbed: 'aria-grabbed',
dropeffect: 'aria-dropeffect',
haspopup: 'aria-haspopup',
level: 'aria-level',
colcount: 'aria-colcount',
rowcount: 'aria-rowcount'
};