all files / document-editor/implementation/dialogs/ datepicker-dialog.js

76.67% Statements 46/60
55.56% Branches 10/18
77.78% Functions 7/9
76.67% Lines 46/60
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83   144× 144×       144×   14468×                                     99×       99× 99×   99×                    
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-calendars"], function (require, exports, ej2_base_1, ej2_calendars_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var DatePickerDialog = (function () {
        function DatePickerDialog(documentHelper) {
            var _this = this;
            this.onCancelButtonClick = function () {
                _this.documentHelper.dialog.hide();
                _this.documentHelper.updateFocus();
            };
            this.documentHelper = documentHelper;
        }
        DatePickerDialog.prototype.getModuleName = function () {
            return 'DateContentDialog';
        };
        DatePickerDialog.prototype.initDateContentDialog = function (localValue) {
            this.target = ej2_base_1.createElement('div');
            this.parentDiv = ej2_base_1.createElement('div');
            this.target.appendChild(this.parentDiv);
            var calendar = new ej2_calendars_1.Calendar({
                change: this.valueChange.bind(this)
            });
            Iif (this.documentHelper.owner.editor.dateValue) {
                calendar.value = new Date(this.documentHelper.owner.editor.dateValue);
            }
            calendar.appendTo(this.parentDiv);
            Iif (this.documentHelper.owner.editor.dateValue) {
                calendar.value = new Date(this.documentHelper.owner.editor.dateValue);
            }
        };
        DatePickerDialog.prototype.valueChange = function (args) {
            if (args.event) {
                var value = args.value.toLocaleDateString();
                var contenControl = this.documentHelper.owner.editor.getContentControl();
                this.documentHelper.owner.editor.dropDownChange(contenControl, value);
                this.documentHelper.hideDialog();
            }
        };
        DatePickerDialog.prototype.show = function () {
            var localValue = new ej2_base_1.L10n('documenteditor', this.documentHelper.owner.defaultLocale);
            localValue.setLocale(this.documentHelper.owner.locale);
            this.localeValue = localValue;
            Eif (!this.target) {
                this.initDateContentDialog(localValue);
            }
            Eif (this.documentHelper.selection.caret.style.display !== 'none') {
                this.documentHelper.selection.caret.style.display = 'none';
            }
            this.documentHelper.dialog.header = localValue.getConstant('Datepicker Content Control');
            this.documentHelper.dialog.height = 'auto';
            this.documentHelper.dialog.width = 'auto';
            this.documentHelper.dialog.content = this.target;
            this.documentHelper.dialog.beforeOpen = this.documentHelper.updateFocus;
            this.documentHelper.dialog.close = this.documentHelper.updateFocus;
            this.documentHelper.dialog.dataBind();
            this.documentHelper.dialog.show();
        };
        DatePickerDialog.prototype.destroy = function () {
            Iif (this.calendar) {
                this.calendar.destroy();
                this.calendar = undefined;
            }
            this.documentHelper = undefined;
            if (this.parentDiv) {
                this.parentDiv.remove();
                this.parentDiv = undefined;
            }
            if (!ej2_base_1.isNullOrUndefined(this.target)) {
                Iif (this.target.parentElement) {
                    this.target.parentElement.removeChild(this.target);
                }
                for (var i = 0; i < this.target.childNodes.length; i++) {
                    this.target.removeChild(this.target.childNodes[parseInt(i.toString(), 10)]);
                    i--;
                }
                this.target = undefined;
            }
        };
        return DatePickerDialog;
    }());
    exports.DatePickerDialog = DatePickerDialog;
});