# all files / lib/utilities/ rtl.js

57.89% Statements 11/19
20% Branches 2/10
33.33% Functions 1/3
57.89% Lines 11/19

    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
    1×
    1×

    1×
    12×
    1×

    12×

    1×

    1×

    1×

    1×

    1×

     "use strict";
    var KeyCodes_1 = require('./KeyCodes');
    var _isRTL;
    /**
     * Gets the rtl state of the page (returns true if in rtl.)
     */
    function getRTL() {
        if (_isRTL === undefined) {
            _isRTL = document.documentElement.getAttribute('dir') === 'rtl';
        }
        return _isRTL;
    }
    exports.getRTL = getRTL;
    /**
     * Sets the rtl state of the page (by adjusting the dir attribute of the html element.)
     */
    function setRTL(isRTL) {
        document.documentElement.setAttribute('dir', isRTL ? 'rtl' : 'ltr');
        _isRTL = isRTL;
    }
    exports.setRTL = setRTL;
    /**
     * Returns the given key, but flips right/left arrows if necessary.
     */
    function getRTLSafeKeyCode(key) {
        if (getRTL()) {
            if (key === KeyCodes_1.KeyCodes.left) {
                key = KeyCodes_1.KeyCodes.right;
            }
            else if (key === KeyCodes_1.KeyCodes.right) {
                key = KeyCodes_1.KeyCodes.left;
            }
        }
        return key;
    }
    exports.getRTLSafeKeyCode = getRTLSafeKeyCode;

    //# sourceMappingURL=rtl.js.map