all files / grid/renderer/ number-filter-ui.js

100% Statements 36/36
87.5% Branches 14/16
100% Functions 8/8
100% Lines 36/36
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 55 56   22× 22× 22× 22× 22× 22×                             14×          
define(["require", "exports", "@syncfusion/ej2-inputs", "@syncfusion/ej2-base", "../base/constant"], function (require, exports, ej2_inputs_1, ej2_base_1, events) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var NumberFilterUI = (function () {
        function NumberFilterUI(parent, serviceLocator, filterSettings) {
            this.filterSettings = filterSettings;
            this.parent = parent;
            this.serviceLocator = serviceLocator;
            Eif (this.parent) {
                this.parent.on(events.filterMenuClose, this.destroy, this);
                this.parent.on(events.destroy, this.destroy, this);
            }
        }
        NumberFilterUI.prototype.keyEventHandler = function (args) {
            Eif (args.keyCode === 13 || args.keyCode === 9) {
                var evt = document.createEvent('HTMLEvents');
                evt.initEvent('change', false, true);
                this.dispatchEvent(evt);
            }
        };
        NumberFilterUI.prototype.create = function (args) {
            this.instance = this.parent.createElement('input', { className: 'e-flmenu-input', id: 'numberui-' + args.column.uid });
            args.target.appendChild(this.instance);
            this.numericTxtObj = new ej2_inputs_1.NumericTextBox(ej2_base_1.extend({
                format: typeof (args.column.format) === 'string' || ej2_base_1.isUndefined(args.column.format) ? args.column.format :
                    args.column.format.format,
                locale: this.parent.locale,
                cssClass: this.parent.cssClass ? 'e-popup-flmenu' + ' ' + this.parent.cssClass : 'e-popup-flmenu',
                placeholder: args.localizeText.getConstant('EnterValue'),
                enableRtl: this.parent.enableRtl
            }, args.column.filter.params));
            this.numericTxtObj.appendTo(this.instance);
        };
        NumberFilterUI.prototype.write = function (args) {
            var numberuiObj = document.querySelector('#numberui-' + args.column.uid).ej2_instances[0];
            numberuiObj.element.addEventListener('keydown', this.keyEventHandler);
            numberuiObj.value = args.filteredValue;
        };
        NumberFilterUI.prototype.read = function (element, column, filterOptr, filterObj) {
            var numberuiObj = document.querySelector('#numberui-' + column.uid).ej2_instances[0];
            var filterValue = numberuiObj.value;
            filterObj.filterByColumn(column.field, filterOptr, filterValue, 'and', true);
        };
        NumberFilterUI.prototype.destroy = function () {
            if (!this.numericTxtObj || this.numericTxtObj.isDestroyed) {
                return;
            }
            this.numericTxtObj.destroy();
            this.parent.off(events.filterMenuClose, this.destroy);
            this.parent.off(events.destroy, this.destroy);
        };
        return NumberFilterUI;
    }());
    exports.NumberFilterUI = NumberFilterUI;
});