all files / grid/services/ value-formatter.js

100% Statements 29/29
95.65% Branches 22/23
100% Functions 8/8
100% Lines 29/29
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   17519× 17519× 1520×     912× 439×     473×     2702× 359×     2343×     23× 22×         23768× 23768× 23068×   23768×            
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1, ej2_base_2) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ValueFormatter = (function () {
        function ValueFormatter(cultureName) {
            this.intl = new ej2_base_2.Internationalization();
            if (!ej2_base_1.isNullOrUndefined(cultureName)) {
                this.intl.culture = cultureName;
            }
        }
        ValueFormatter.prototype.getFormatFunction = function (format) {
            if (!ej2_base_1.isNullOrUndefined(format) && (format.type === 'dateTime' || format.type === 'datetime' || format.type === 'date' || format.type === 'time')) {
                return this.intl.getDateFormat(format);
            }
            else {
                return this.intl.getNumberFormat(format);
            }
        };
        ValueFormatter.prototype.getParserFunction = function (format) {
            if (format.type) {
                return this.intl.getDateParser(format);
            }
            else {
                return this.intl.getNumberParser(format);
            }
        };
        ValueFormatter.prototype.fromView = function (value, format, type) {
            if ((type === 'date' || type === 'datetime' || type === 'number') && (!ej2_base_1.isNullOrUndefined(format))) {
                return format(value);
            }
            else {
                return value;
            }
        };
        ValueFormatter.prototype.toView = function (value, format) {
            var result = value;
            if (!ej2_base_1.isNullOrUndefined(format) && !ej2_base_1.isNullOrUndefined(value)) {
                result = format(value);
            }
            return result;
        };
        ValueFormatter.prototype.setCulture = function (cultureName) {
            Eif (!ej2_base_1.isNullOrUndefined(cultureName)) {
                ej2_base_2.setCulture(cultureName);
            }
        };
        return ValueFormatter;
    }());
    exports.ValueFormatter = ValueFormatter;
});