all files / grid/services/ aria-service.js

92.86% Statements 26/28
100% Branches 4/4
81.82% Functions 9/11
92.59% Lines 25/27
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     269556× 359220×   80×   619×   12536× 12536×             384991× 12536× 12536×   372455× 372454×                                  
define(["require", "exports"], function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var AriaService = (function () {
        function AriaService() {
        }
        AriaService.prototype.setOptions = function (target, options) {
            var props = Object.keys(options);
            props.forEach(function (name) { return setStateAndProperties(target, config[name], options[name]); });
        };
        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;
    }());
    exports.AriaService = AriaService;
    function setStateAndProperties(target, attribute, value, remove) {
        if (remove) {
            target.removeAttribute(attribute);
            return;
        }
        if (target) {
            target.setAttribute(attribute, value);
        }
    }
    var config = {
        expand: 'aria-expanded',
        role: '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'
    };
});