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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104 | 1×
1×
1×
1×
1×
1091×
1091×
1091×
35×
49×
360×
1×
360×
360×
94×
266×
1×
49×
49×
39×
1×
35×
35×
35×
33×
35×
2×
1×
33×
33×
33×
33×
1×
1×
32×
32×
33×
33×
33×
33×
33×
33×
33×
33×
33×
33×
1×
1428×
892×
892×
27×
27×
1428×
892×
1×
1091×
1091×
1091×
1091×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-inputs", "../base/css-constant"], function (require, exports, ej2_base_1, ej2_inputs_1, cls) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var FieldValidator = (function () {
function FieldValidator() {
}
FieldValidator.prototype.renderFormValidator = function (form, rules, element, locale) {
var _this = this;
this.element = element;
this.formObj = new ej2_inputs_1.FormValidator(form, {
locale: locale,
customPlacement: function (inputElement, error) {
_this.errorPlacement(inputElement, error);
},
rules: rules,
validationComplete: function (args) {
_this.validationComplete(args);
},
focusout: function (args) {
_this.focusOut(args);
}
});
};
FieldValidator.prototype.focusOut = function (args) {
var target = args.relatedTarget;
if (target && (target.classList.contains('e-dlg-closeicon-btn') || target.classList.contains('e-close')
|| target.classList.contains(cls.ALLDAY_CELLS_CLASS) || target.classList.contains(cls.HEADER_CELLS_CLASS)
|| target.classList.contains(cls.QUICK_POPUP_EVENT_DETAILS_CLASS) || target.classList.contains(cls.WORK_CELLS_CLASS)
|| target.classList.contains(cls.EVENT_WINDOW_CANCEL_BUTTON_CLASS))) {
this.ignoreError = true;
}
else {
this.ignoreError = false;
}
};
FieldValidator.prototype.validationComplete = function (args) {
var elem = this.element.querySelector('#' + args.inputName + '_Error');
if (elem) {
elem.style.display = (args.status === 'failure') ? '' : 'none';
}
};
FieldValidator.prototype.errorPlacement = function (inputElement, error) {
var id = error.getAttribute('for');
var elem = this.element.querySelector('#' + id + '_Error');
if (!elem && !this.ignoreError) {
this.createTooltip(inputElement, error, id, '');
}
if (!ej2_base_1.isNullOrUndefined(elem)) {
elem.querySelector('.e-error').innerHTML = error.innerHTML;
}
};
FieldValidator.prototype.createTooltip = function (element, error, name, display) {
var dlgContent;
var client;
var inputClient = element.getBoundingClientRect();
if (this.element.classList.contains(cls.POPUP_WRAPPER_CLASS)) {
dlgContent = this.element;
client = this.element.getBoundingClientRect();
}
else {
dlgContent = this.element.querySelector('.e-schedule-dialog .e-dlg-content');
client = dlgContent.getBoundingClientRect();
}
var div = ej2_base_1.createElement('div', {
className: 'e-tooltip-wrap e-popup ' + cls.ERROR_VALIDATION_CLASS,
id: name + '_Error',
styles: 'display:' + display + ';top:' +
(inputClient.bottom - client.top + dlgContent.scrollTop + 9) + 'px;left:' +
(inputClient.left - client.left + dlgContent.scrollLeft + inputClient.width / 2) + 'px;'
});
var content = ej2_base_1.createElement('div', { className: 'e-tip-content' });
content.appendChild(error);
var arrow = ej2_base_1.createElement('div', { className: 'e-arrow-tip e-tip-top' });
arrow.appendChild(ej2_base_1.createElement('div', { className: 'e-arrow-tip-outer e-tip-top' }));
arrow.appendChild(ej2_base_1.createElement('div', { className: 'e-arrow-tip-inner e-tip-top' }));
div.appendChild(content);
div.appendChild(arrow);
dlgContent.appendChild(div);
div.style.left = (parseInt(div.style.left, 10) - div.offsetWidth / 2) + 'px';
};
FieldValidator.prototype.destroyToolTip = function () {
if (this.element) {
var elements = [].slice.call(this.element.querySelectorAll('.' + cls.ERROR_VALIDATION_CLASS));
for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
var elem = elements_1[_i];
ej2_base_1.remove(elem);
}
}
if (this.formObj && this.formObj.element) {
this.formObj.reset();
}
};
FieldValidator.prototype.destroy = function () {
Eif (this.formObj && this.formObj.element && !this.formObj.isDestroyed) {
this.formObj.destroy();
}
this.formObj = null;
this.element = null;
};
return FieldValidator;
}());
exports.FieldValidator = FieldValidator;
});
|