@syncfusion/ej2-inputs 19.3.53 → 19.4.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +1 -1
- package/common.d.ts +4 -0
- package/common.js +4 -0
- package/dist/ej2-inputs.umd.min.js +2 -2
- package/dist/ej2-inputs.umd.min.js.map +1 -1
- package/dist/es6/ej2-inputs.es2015.js +1116 -8
- package/dist/es6/ej2-inputs.es2015.js.map +1 -1
- package/dist/es6/ej2-inputs.es5.js +1150 -7
- package/dist/es6/ej2-inputs.es5.js.map +1 -1
- package/dist/global/ej2-inputs.min.js +2 -2
- package/dist/global/ej2-inputs.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +9 -9
- package/signature.d.ts +4 -0
- package/signature.js +4 -0
- package/src/common/index.d.ts +4 -0
- package/src/common/index.js +4 -0
- package/src/common/signature-base.d.ts +320 -0
- package/src/common/signature-base.js +946 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +2 -0
- package/src/input/input.js +10 -6
- package/src/numerictextbox/numerictextbox.js +10 -0
- package/src/signature/index.d.ts +5 -0
- package/src/signature/index.js +4 -0
- package/src/signature/signature-model.d.ts +131 -0
- package/src/signature/signature.d.ts +167 -0
- package/src/signature/signature.js +171 -0
- package/src/slider/slider.d.ts +1 -0
- package/src/slider/slider.js +9 -0
- package/styles/bootstrap-dark.css +43 -16
- package/styles/bootstrap-dark.scss +1 -0
- package/styles/bootstrap.css +43 -16
- package/styles/bootstrap.scss +1 -0
- package/styles/bootstrap4.css +43 -16
- package/styles/bootstrap4.scss +1 -0
- package/styles/bootstrap5-dark.css +46 -41
- package/styles/bootstrap5-dark.scss +1 -0
- package/styles/bootstrap5.css +46 -41
- package/styles/bootstrap5.scss +1 -0
- package/styles/color-picker/_fabric-dark-definition.scss +1 -1
- package/styles/color-picker/_fluent-definition.scss +134 -0
- package/styles/color-picker/_layout.scss +5 -5
- package/styles/color-picker/_theme.scss +16 -15
- package/styles/color-picker/bootstrap-dark.css +20 -0
- package/styles/color-picker/bootstrap.css +20 -0
- package/styles/color-picker/bootstrap4.css +20 -0
- package/styles/color-picker/bootstrap5-dark.css +22 -20
- package/styles/color-picker/bootstrap5.css +22 -20
- package/styles/color-picker/fabric-dark.css +23 -3
- package/styles/color-picker/fabric.css +20 -0
- package/styles/color-picker/highcontrast-light.css +20 -0
- package/styles/color-picker/highcontrast.css +20 -0
- package/styles/color-picker/icons/_fluent.scss +10 -0
- package/styles/color-picker/material-dark.css +20 -0
- package/styles/color-picker/material.css +20 -0
- package/styles/color-picker/tailwind-dark.css +20 -0
- package/styles/color-picker/tailwind.css +20 -0
- package/styles/fabric-dark.css +46 -19
- package/styles/fabric-dark.scss +1 -0
- package/styles/fabric.css +43 -16
- package/styles/fabric.scss +1 -0
- package/styles/highcontrast-light.css +43 -16
- package/styles/highcontrast-light.scss +1 -0
- package/styles/highcontrast.css +43 -16
- package/styles/highcontrast.scss +1 -0
- package/styles/input/_fluent-definition.scss +321 -0
- package/styles/input/_layout.scss +138 -37
- package/styles/input/_theme.scss +42 -24
- package/styles/input/bootstrap-dark.css +13 -16
- package/styles/input/bootstrap.css +13 -16
- package/styles/input/bootstrap4.css +13 -16
- package/styles/input/bootstrap5-dark.css +13 -16
- package/styles/input/bootstrap5.css +13 -16
- package/styles/input/fabric-dark.css +13 -16
- package/styles/input/fabric.css +13 -16
- package/styles/input/highcontrast-light.css +13 -16
- package/styles/input/highcontrast.css +13 -16
- package/styles/input/icons/_fluent.scss +17 -0
- package/styles/input/material-dark.css +13 -16
- package/styles/input/material.css +13 -16
- package/styles/input/tailwind-dark.css +13 -16
- package/styles/input/tailwind.css +13 -16
- package/styles/maskedtextbox/_fluent-definition.scss +7 -0
- package/styles/maskedtextbox/_theme.scss +2 -2
- package/styles/material-dark.css +43 -16
- package/styles/material-dark.scss +1 -0
- package/styles/material.css +43 -16
- package/styles/material.scss +1 -0
- package/styles/numerictextbox/_fluent-definition.scss +5 -0
- package/styles/numerictextbox/_theme.scss +18 -0
- package/styles/numerictextbox/icons/_fluent.scss +12 -0
- package/styles/signature/_all.scss +2 -0
- package/styles/signature/_bootstrap-dark-definition.scss +3 -0
- package/styles/signature/_bootstrap-definition.scss +3 -0
- package/styles/signature/_bootstrap4-definition.scss +3 -0
- package/styles/signature/_bootstrap5-dark-definition.scss +1 -0
- package/styles/signature/_bootstrap5-definition.scss +3 -0
- package/styles/signature/_fabric-dark-definition.scss +3 -0
- package/styles/signature/_fabric-definition.scss +3 -0
- package/styles/signature/_fluent-definition.scss +3 -0
- package/styles/signature/_highcontrast-definition.scss +3 -0
- package/styles/signature/_highcontrast-light-definition.scss +3 -0
- package/styles/signature/_layout.scss +5 -0
- package/styles/signature/_material-dark-definition.scss +3 -0
- package/styles/signature/_material-definition.scss +3 -0
- package/styles/signature/_tailwind-dark-definition.scss +1 -0
- package/styles/signature/_tailwind-definition.scss +3 -0
- package/styles/signature/_theme.scss +7 -0
- package/styles/signature/bootstrap-dark.css +9 -0
- package/styles/signature/bootstrap-dark.scss +3 -0
- package/styles/signature/bootstrap.css +9 -0
- package/styles/signature/bootstrap.scss +3 -0
- package/styles/signature/bootstrap4.css +9 -0
- package/styles/signature/bootstrap4.scss +3 -0
- package/styles/signature/bootstrap5-dark.css +9 -0
- package/styles/signature/bootstrap5-dark.scss +3 -0
- package/styles/signature/bootstrap5.css +9 -0
- package/styles/signature/bootstrap5.scss +3 -0
- package/styles/signature/fabric-dark.css +9 -0
- package/styles/signature/fabric-dark.scss +3 -0
- package/styles/signature/fabric.css +9 -0
- package/styles/signature/fabric.scss +3 -0
- package/styles/signature/highcontrast-light.css +9 -0
- package/styles/signature/highcontrast-light.scss +3 -0
- package/styles/signature/highcontrast.css +9 -0
- package/styles/signature/highcontrast.scss +3 -0
- package/styles/signature/material-dark.css +10 -0
- package/styles/signature/material-dark.scss +3 -0
- package/styles/signature/material.css +10 -0
- package/styles/signature/material.scss +3 -0
- package/styles/signature/tailwind-dark.css +10 -0
- package/styles/signature/tailwind-dark.scss +3 -0
- package/styles/signature/tailwind.css +10 -0
- package/styles/signature/tailwind.scss +3 -0
- package/styles/slider/_bootstrap5-definition.scss +2 -2
- package/styles/slider/_fluent-definition.scss +94 -0
- package/styles/slider/_layout.scss +7 -2
- package/styles/slider/_tailwind-definition.scss +2 -2
- package/styles/slider/bootstrap5-dark.css +1 -5
- package/styles/slider/bootstrap5.css +1 -5
- package/styles/slider/tailwind-dark.css +1 -5
- package/styles/slider/tailwind.css +1 -5
- package/styles/tailwind-dark.css +45 -21
- package/styles/tailwind-dark.scss +1 -0
- package/styles/tailwind.css +45 -21
- package/styles/tailwind.scss +1 -0
- package/styles/textbox/_fluent-definition.scss +0 -0
- package/styles/uploader/_fluent-definition.scss +234 -0
- package/styles/uploader/_layout.scss +99 -8
- package/styles/uploader/_theme.scss +5 -2
- package/styles/uploader/icons/_fluent.scss +34 -0
|
@@ -188,7 +188,7 @@ var Input;
|
|
|
188
188
|
if (args.floatLabelType === 'Auto') {
|
|
189
189
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
190
190
|
args.element.addEventListener('input', function (event) {
|
|
191
|
-
updateLabelState(args.element.value, floatLabelElement);
|
|
191
|
+
updateLabelState(args.element.value, floatLabelElement, args.element);
|
|
192
192
|
});
|
|
193
193
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
194
194
|
args.element.addEventListener('blur', function (event) {
|
|
@@ -238,7 +238,8 @@ var Input;
|
|
|
238
238
|
addClass([button], CLASSNAMES.CLEARICONHIDE);
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
function updateLabelState(value, label) {
|
|
241
|
+
function updateLabelState(value, label, element) {
|
|
242
|
+
if (element === void 0) { element = null; }
|
|
242
243
|
if (value) {
|
|
243
244
|
addClass([label], CLASSNAMES.LABELTOP);
|
|
244
245
|
if (label.classList.contains(CLASSNAMES.LABELBOTTOM)) {
|
|
@@ -246,10 +247,13 @@ var Input;
|
|
|
246
247
|
}
|
|
247
248
|
}
|
|
248
249
|
else {
|
|
249
|
-
|
|
250
|
-
|
|
250
|
+
var isNotFocused = element != null ? element !== document.activeElement : true;
|
|
251
|
+
if (isNotFocused) {
|
|
252
|
+
if (label.classList.contains(CLASSNAMES.LABELTOP)) {
|
|
253
|
+
removeClass([label], CLASSNAMES.LABELTOP);
|
|
254
|
+
}
|
|
255
|
+
addClass([label], CLASSNAMES.LABELBOTTOM);
|
|
251
256
|
}
|
|
252
|
-
addClass([label], CLASSNAMES.LABELBOTTOM);
|
|
253
257
|
}
|
|
254
258
|
}
|
|
255
259
|
function getParentNode(element) {
|
|
@@ -318,7 +322,7 @@ var Input;
|
|
|
318
322
|
var parent = getParentNode(element);
|
|
319
323
|
if (parent.classList.contains(CLASSNAMES.FLOATINPUT) && floatLabelType === 'Auto') {
|
|
320
324
|
var label = getParentNode(element).getElementsByClassName('e-float-text')[0];
|
|
321
|
-
updateLabelState(element.value, label);
|
|
325
|
+
updateLabelState(element.value, label, element);
|
|
322
326
|
}
|
|
323
327
|
}
|
|
324
328
|
/**
|
|
@@ -1434,6 +1438,10 @@ var NumericTextBox = /** @__PURE__ @class */ (function (_super) {
|
|
|
1434
1438
|
}
|
|
1435
1439
|
_this.element.setSelectionRange(_this.element.selectionStart, _this.element.selectionStart);
|
|
1436
1440
|
}
|
|
1441
|
+
if (_this.element.value[_this.element.selectionStart - 1] === decimalSeparator && _this.decimals === 0 && _this.validateDecimalOnType) {
|
|
1442
|
+
_this.element.value = _this.element.value.substring(0, prevPos) +
|
|
1443
|
+
_this.element.value.substring(currentPos, _this.element.value.length);
|
|
1444
|
+
}
|
|
1437
1445
|
}
|
|
1438
1446
|
_this.prevVal = _this.element.value;
|
|
1439
1447
|
}
|
|
@@ -1481,6 +1489,11 @@ var NumericTextBox = /** @__PURE__ @class */ (function (_super) {
|
|
|
1481
1489
|
if (this.isVue) {
|
|
1482
1490
|
var current = this.instance.getNumberParser({ format: 'n' })(this.element.value);
|
|
1483
1491
|
var previous = this.instance.getNumberParser({ format: 'n' })(this.elementPrevValue);
|
|
1492
|
+
//EJ2-54963-if type "." or ".0" or "-.0" it converts to "0" automatically when binding v-model
|
|
1493
|
+
var nonZeroRegex = new RegExp('[^1-9]+$');
|
|
1494
|
+
if (nonZeroRegex.test(this.element.value)) {
|
|
1495
|
+
current = this.value;
|
|
1496
|
+
}
|
|
1484
1497
|
var eventArgs = {
|
|
1485
1498
|
event: event,
|
|
1486
1499
|
value: (current === null || isNaN(current) ? null : current),
|
|
@@ -1798,6 +1811,7 @@ var NumericTextBox = /** @__PURE__ @class */ (function (_super) {
|
|
|
1798
1811
|
}
|
|
1799
1812
|
};
|
|
1800
1813
|
NumericTextBox.prototype.mouseUpOnSpinner = function (event) {
|
|
1814
|
+
this.prevValue = this.value;
|
|
1801
1815
|
if (this.isPrevFocused) {
|
|
1802
1816
|
this.element.focus();
|
|
1803
1817
|
if (!Browser.isDevice) {
|
|
@@ -4430,9 +4444,11 @@ var Slider = /** @__PURE__ @class */ (function (_super) {
|
|
|
4430
4444
|
this.sliderBarClick(e);
|
|
4431
4445
|
if (e.currentTarget === this.firstHandle) {
|
|
4432
4446
|
this.firstHandle.classList.add(classNames.sliderHandleFocused);
|
|
4447
|
+
this.firstHandle.classList.add(classNames.sliderTabHandle);
|
|
4433
4448
|
}
|
|
4434
4449
|
else {
|
|
4435
4450
|
this.secondHandle.classList.add(classNames.sliderHandleFocused);
|
|
4451
|
+
this.secondHandle.classList.add(classNames.sliderTabHandle);
|
|
4436
4452
|
}
|
|
4437
4453
|
EventHandler.add(document, 'mousemove touchmove', this.sliderBarMove, this);
|
|
4438
4454
|
EventHandler.add(document, 'mouseup touchend', this.sliderBarUp, this);
|
|
@@ -4846,6 +4862,11 @@ var Slider = /** @__PURE__ @class */ (function (_super) {
|
|
|
4846
4862
|
this.getHandle().classList.add('e-large-thumb-size');
|
|
4847
4863
|
}
|
|
4848
4864
|
};
|
|
4865
|
+
Slider.prototype.focusHandle = function () {
|
|
4866
|
+
if (!this.getHandle().classList.contains(classNames.sliderTabHandle)) {
|
|
4867
|
+
this.getHandle().classList.add(classNames.sliderTabHandle);
|
|
4868
|
+
}
|
|
4869
|
+
};
|
|
4849
4870
|
Slider.prototype.repeatHandlerUp = function (e) {
|
|
4850
4871
|
this.changeEvent('changed', e);
|
|
4851
4872
|
this.closeTooltip();
|
|
@@ -5238,6 +5259,7 @@ var Slider = /** @__PURE__ @class */ (function (_super) {
|
|
|
5238
5259
|
}
|
|
5239
5260
|
this.tooltipToggle(this.getHandle());
|
|
5240
5261
|
this.getHandle().focus();
|
|
5262
|
+
this.focusHandle();
|
|
5241
5263
|
if (args.currentTarget.classList.contains(classNames.firstButton)) {
|
|
5242
5264
|
EventHandler.add(this.firstBtn, 'mouseup touchend', this.buttonUp, this);
|
|
5243
5265
|
}
|
|
@@ -6182,6 +6204,7 @@ var Slider = /** @__PURE__ @class */ (function (_super) {
|
|
|
6182
6204
|
event.preventDefault();
|
|
6183
6205
|
this.focusSliderElement();
|
|
6184
6206
|
this.sliderBarClick(event);
|
|
6207
|
+
this.focusHandle();
|
|
6185
6208
|
};
|
|
6186
6209
|
Slider.prototype.wireEvents = function () {
|
|
6187
6210
|
this.onresize = this.reposition.bind(this);
|
|
@@ -13677,9 +13700,1129 @@ var TextBox = /** @__PURE__ @class */ (function (_super) {
|
|
|
13677
13700
|
* Uploader modules
|
|
13678
13701
|
*/
|
|
13679
13702
|
|
|
13703
|
+
var __extends$8 = (undefined && undefined.__extends) || (function () {
|
|
13704
|
+
var extendStatics = function (d, b) {
|
|
13705
|
+
extendStatics = Object.setPrototypeOf ||
|
|
13706
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
13707
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
13708
|
+
return extendStatics(d, b);
|
|
13709
|
+
};
|
|
13710
|
+
return function (d, b) {
|
|
13711
|
+
extendStatics(d, b);
|
|
13712
|
+
function __() { this.constructor = d; }
|
|
13713
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13714
|
+
};
|
|
13715
|
+
})();
|
|
13716
|
+
var SignatureBase = /** @__PURE__ @class */ (function (_super) {
|
|
13717
|
+
__extends$8(SignatureBase, _super);
|
|
13718
|
+
function SignatureBase() {
|
|
13719
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
13720
|
+
/* minDistance(distance between the two point) was calaculated for smoothness.*/
|
|
13721
|
+
_this.minDistance = 5;
|
|
13722
|
+
_this.previous = 0;
|
|
13723
|
+
/* interval handles for the smoothness in the mouse move event.*/
|
|
13724
|
+
_this.interval = 30;
|
|
13725
|
+
_this.timeout = null;
|
|
13726
|
+
_this.isSignatureEmpty = true;
|
|
13727
|
+
_this.backgroundLoaded = null;
|
|
13728
|
+
_this.clearArray = [];
|
|
13729
|
+
_this.isBlazor = false;
|
|
13730
|
+
return _this;
|
|
13731
|
+
}
|
|
13732
|
+
/**
|
|
13733
|
+
* To Initialize the component rendering
|
|
13734
|
+
*
|
|
13735
|
+
* @private
|
|
13736
|
+
* @param {HTMLCanvasElement} element - Specifies the canvas element.
|
|
13737
|
+
* @param {parameter} parameter - Specifies only for the blazor parameter.
|
|
13738
|
+
* @param {BlazorDotnetObject} dotnetRef - Specifies for blazor client to server communication.
|
|
13739
|
+
* @returns {void}
|
|
13740
|
+
*/
|
|
13741
|
+
SignatureBase.prototype.initialize = function (element, parameter, dotnetRef) {
|
|
13742
|
+
this.element = element;
|
|
13743
|
+
this.canvasContext = this.element.getContext('2d');
|
|
13744
|
+
this.canvasContext.canvas.tabIndex = 0;
|
|
13745
|
+
if (parameter) {
|
|
13746
|
+
this.setBlazorParameter(parameter);
|
|
13747
|
+
this.dotnetRef = dotnetRef;
|
|
13748
|
+
}
|
|
13749
|
+
this.setHTMLProperties();
|
|
13750
|
+
if (isNullOrUndefined(this.signatureValue)) {
|
|
13751
|
+
this.updateSnapCollection(true);
|
|
13752
|
+
}
|
|
13753
|
+
this.wireEvents();
|
|
13754
|
+
this.isSignatureEmpty = true;
|
|
13755
|
+
if (!this.isBlazor) {
|
|
13756
|
+
this.trigger('created', null);
|
|
13757
|
+
}
|
|
13758
|
+
};
|
|
13759
|
+
SignatureBase.prototype.setBlazorParameter = function (parameter) {
|
|
13760
|
+
this.isBlazor = true;
|
|
13761
|
+
this.backgroundColor = parameter.backgroundColor;
|
|
13762
|
+
this.backgroundImage = parameter.backgroundImage;
|
|
13763
|
+
this.disabled = parameter.disabled;
|
|
13764
|
+
this.isReadOnly = parameter.isReadOnly;
|
|
13765
|
+
this.maxStrokeWidth = parameter.maxStrokeWidth || 2;
|
|
13766
|
+
this.minStrokeWidth = parameter.minStrokeWidth || 0.5;
|
|
13767
|
+
this.velocity = parameter.velocity || 0.7;
|
|
13768
|
+
this.strokeColor = parameter.strokeColor || '#000000';
|
|
13769
|
+
this.saveWithBackground = parameter.saveWithBackground;
|
|
13770
|
+
this.interval = 30;
|
|
13771
|
+
this.previous = 0;
|
|
13772
|
+
this.minDistance = 5;
|
|
13773
|
+
this.signatureValue = parameter.signatureValue;
|
|
13774
|
+
if (this.signatureValue) {
|
|
13775
|
+
this.loadPersistedSignature();
|
|
13776
|
+
}
|
|
13777
|
+
};
|
|
13778
|
+
SignatureBase.prototype.wireEvents = function () {
|
|
13779
|
+
if (isNullOrUndefined(this.pointColl) && !this.isReadOnly && !this.disabled) {
|
|
13780
|
+
EventHandler.add(this.canvasContext.canvas, 'mousedown touchstart', this.mouseDownHandler, this);
|
|
13781
|
+
EventHandler.add(this.canvasContext.canvas, 'keydown', this.keyboardHandler, this);
|
|
13782
|
+
window.addEventListener('resize', this.resizeHandler.bind(this));
|
|
13783
|
+
}
|
|
13784
|
+
else if (this.pointColl) {
|
|
13785
|
+
EventHandler.add(this.canvasContext.canvas, 'mousemove touchmove', this.mouseMoveHandler, this);
|
|
13786
|
+
EventHandler.add(this.canvasContext.canvas, 'mouseup touchend', this.mouseUpHandler, this);
|
|
13787
|
+
EventHandler.add(document, 'mouseup', this.mouseUpHandler, this);
|
|
13788
|
+
}
|
|
13789
|
+
};
|
|
13790
|
+
SignatureBase.prototype.unwireEvents = function (type) {
|
|
13791
|
+
if (type === 'mouseup' || type === 'touchend') {
|
|
13792
|
+
EventHandler.remove(this.canvasContext.canvas, 'mousemove touchmove', this.mouseMoveHandler);
|
|
13793
|
+
EventHandler.remove(this.canvasContext.canvas, 'mouseup touchend', this.mouseUpHandler);
|
|
13794
|
+
EventHandler.remove(document, 'mouseup', this.mouseUpHandler);
|
|
13795
|
+
}
|
|
13796
|
+
else {
|
|
13797
|
+
EventHandler.remove(this.canvasContext.canvas, 'mousedown touchstart', this.mouseDownHandler);
|
|
13798
|
+
EventHandler.remove(this.canvasContext.canvas, 'mousemove touchmove', this.mouseMoveHandler);
|
|
13799
|
+
EventHandler.remove(this.canvasContext.canvas, 'mouseup touchend', this.mouseUpHandler);
|
|
13800
|
+
EventHandler.remove(document, 'mouseup', this.mouseUpHandler);
|
|
13801
|
+
EventHandler.remove(this.canvasContext.canvas, 'keydown', this.keyboardHandler);
|
|
13802
|
+
window.removeEventListener('resize', this.resizeHandler);
|
|
13803
|
+
}
|
|
13804
|
+
};
|
|
13805
|
+
SignatureBase.prototype.setHTMLProperties = function () {
|
|
13806
|
+
if (this.element.height === 150) {
|
|
13807
|
+
this.element.height = this.element.offsetHeight;
|
|
13808
|
+
}
|
|
13809
|
+
if (this.element.width === 300) {
|
|
13810
|
+
this.element.width = this.element.offsetWidth;
|
|
13811
|
+
}
|
|
13812
|
+
this.canvasContext.scale(1, 1);
|
|
13813
|
+
this.canvasContext.fillStyle = this.strokeColor;
|
|
13814
|
+
if (this.backgroundImage) {
|
|
13815
|
+
this.canvasContext.canvas.style.backgroundImage = 'url(' + this.backgroundImage + ')';
|
|
13816
|
+
}
|
|
13817
|
+
else if (this.backgroundColor) {
|
|
13818
|
+
this.canvasContext.canvas.style.backgroundColor = this.backgroundColor;
|
|
13819
|
+
}
|
|
13820
|
+
};
|
|
13821
|
+
SignatureBase.prototype.mouseDownHandler = function (e) {
|
|
13822
|
+
if (e.buttons === 1 || e.buttons === 2 || e.type === 'touchstart') {
|
|
13823
|
+
if (e.type === 'touchstart') {
|
|
13824
|
+
e.preventDefault();
|
|
13825
|
+
e.stopPropagation();
|
|
13826
|
+
}
|
|
13827
|
+
this.beginStroke(e);
|
|
13828
|
+
this.wireEvents();
|
|
13829
|
+
}
|
|
13830
|
+
};
|
|
13831
|
+
SignatureBase.prototype.mouseMoveHandler = function (e) {
|
|
13832
|
+
if (e.buttons === 1 || e.buttons === 2 || e.type === 'touchmove') {
|
|
13833
|
+
if (e.type === 'touchmove') {
|
|
13834
|
+
e.preventDefault();
|
|
13835
|
+
e.stopPropagation();
|
|
13836
|
+
}
|
|
13837
|
+
if (this.interval) {
|
|
13838
|
+
this.updateStrokeWithThrottle(e);
|
|
13839
|
+
}
|
|
13840
|
+
else {
|
|
13841
|
+
this.updateStroke(e);
|
|
13842
|
+
}
|
|
13843
|
+
}
|
|
13844
|
+
};
|
|
13845
|
+
SignatureBase.prototype.mouseUpHandler = function (e) {
|
|
13846
|
+
var args = { actionName: 'strokeUpdate' };
|
|
13847
|
+
if (e.type === 'touchstart') {
|
|
13848
|
+
e.preventDefault();
|
|
13849
|
+
e.stopPropagation();
|
|
13850
|
+
}
|
|
13851
|
+
this.endDraw();
|
|
13852
|
+
this.updateSnapCollection();
|
|
13853
|
+
this.unwireEvents(e.type);
|
|
13854
|
+
if (!this.isBlazor) {
|
|
13855
|
+
this.trigger('change', args);
|
|
13856
|
+
}
|
|
13857
|
+
else {
|
|
13858
|
+
this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'mouseUp');
|
|
13859
|
+
}
|
|
13860
|
+
this.signatureValue = this.snapColl[this.incStep];
|
|
13861
|
+
};
|
|
13862
|
+
SignatureBase.prototype.keyboardHandler = function (e) {
|
|
13863
|
+
var _this = this;
|
|
13864
|
+
var args = { fileName: 'Signature', type: 'Png', cancel: false };
|
|
13865
|
+
switch (e.key) {
|
|
13866
|
+
case 'Delete':
|
|
13867
|
+
this.clear();
|
|
13868
|
+
break;
|
|
13869
|
+
case (e.ctrlKey && 's'):
|
|
13870
|
+
if (!this.isBlazor) {
|
|
13871
|
+
this.trigger('beforeSave', args, function (observableSaveArgs) {
|
|
13872
|
+
if (!args.cancel) {
|
|
13873
|
+
_this.save(observableSaveArgs.type, observableSaveArgs.fileName);
|
|
13874
|
+
}
|
|
13875
|
+
});
|
|
13876
|
+
}
|
|
13877
|
+
else {
|
|
13878
|
+
this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'beforeSave');
|
|
13879
|
+
}
|
|
13880
|
+
e.preventDefault();
|
|
13881
|
+
e.stopImmediatePropagation();
|
|
13882
|
+
break;
|
|
13883
|
+
case (e.ctrlKey && 'z'):
|
|
13884
|
+
this.undo();
|
|
13885
|
+
break;
|
|
13886
|
+
case (e.ctrlKey && 'y'):
|
|
13887
|
+
this.redo();
|
|
13888
|
+
break;
|
|
13889
|
+
}
|
|
13890
|
+
};
|
|
13891
|
+
SignatureBase.prototype.resizeHandler = function () {
|
|
13892
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
13893
|
+
var proxy = this;
|
|
13894
|
+
this.canvasContext.canvas.width = this.element.offsetWidth;
|
|
13895
|
+
this.canvasContext.canvas.height = this.element.offsetHeight;
|
|
13896
|
+
this.canvasContext.scale(1, 1);
|
|
13897
|
+
var restoreImg = new Image();
|
|
13898
|
+
restoreImg.src = this.snapColl[this.incStep];
|
|
13899
|
+
restoreImg.onload = function () {
|
|
13900
|
+
proxy.canvasContext.clearRect(0, 0, proxy.element.width, proxy.element.height);
|
|
13901
|
+
proxy.canvasContext.drawImage(restoreImg, 0, 0, proxy.element.width, proxy.element.height);
|
|
13902
|
+
};
|
|
13903
|
+
};
|
|
13904
|
+
SignatureBase.prototype.beginStroke = function (e) {
|
|
13905
|
+
this.refresh();
|
|
13906
|
+
this.updateStroke(e);
|
|
13907
|
+
};
|
|
13908
|
+
SignatureBase.prototype.updateStroke = function (e) {
|
|
13909
|
+
var point = this.createPoint(e);
|
|
13910
|
+
this.addPoint(point);
|
|
13911
|
+
};
|
|
13912
|
+
SignatureBase.prototype.updateStrokeWithThrottle = function (args) {
|
|
13913
|
+
var now = Date.now();
|
|
13914
|
+
var remaining = this.interval - (now - this.previous);
|
|
13915
|
+
this.storedArgs = args;
|
|
13916
|
+
if (remaining <= 0 || remaining > this.interval) {
|
|
13917
|
+
if (this.timeout) {
|
|
13918
|
+
clearTimeout(this.timeout);
|
|
13919
|
+
this.timeout = null;
|
|
13920
|
+
}
|
|
13921
|
+
this.previous = now;
|
|
13922
|
+
this.updateStroke(this.storedArgs);
|
|
13923
|
+
if (!this.timeout) {
|
|
13924
|
+
this.storedArgs = null;
|
|
13925
|
+
}
|
|
13926
|
+
}
|
|
13927
|
+
else if (!this.timeout) {
|
|
13928
|
+
this.timeout = window.setTimeout(this.delay.bind(this), remaining);
|
|
13929
|
+
}
|
|
13930
|
+
};
|
|
13931
|
+
SignatureBase.prototype.delay = function () {
|
|
13932
|
+
this.previous = Date.now();
|
|
13933
|
+
this.timeout = null;
|
|
13934
|
+
this.updateStroke(this.storedArgs);
|
|
13935
|
+
if (!this.timeout) {
|
|
13936
|
+
this.storedArgs = null;
|
|
13937
|
+
}
|
|
13938
|
+
};
|
|
13939
|
+
SignatureBase.prototype.createPoint = function (e) {
|
|
13940
|
+
var rect = this.canvasContext.canvas.getBoundingClientRect();
|
|
13941
|
+
if (e.type === 'mousedown' || e.type === 'mousemove') {
|
|
13942
|
+
return this.point(e.clientX - rect.left, e.clientY - rect.top, new Date().getTime());
|
|
13943
|
+
}
|
|
13944
|
+
else {
|
|
13945
|
+
return this.point(e.touches[0].clientX - rect.left, e.touches[0].clientY - rect.top, new Date().getTime());
|
|
13946
|
+
}
|
|
13947
|
+
};
|
|
13948
|
+
/* Returns the current point corrdinates(x, y) and time.*/
|
|
13949
|
+
SignatureBase.prototype.point = function (pointX, pointY, time) {
|
|
13950
|
+
this.pointX = pointX;
|
|
13951
|
+
this.pointY = pointY;
|
|
13952
|
+
this.time = time || new Date().getTime();
|
|
13953
|
+
return { x: this.pointX, y: this.pointY, time: this.time };
|
|
13954
|
+
};
|
|
13955
|
+
SignatureBase.prototype.addPoint = function (point) {
|
|
13956
|
+
var points = this.pointColl;
|
|
13957
|
+
var controlPoint1;
|
|
13958
|
+
var controlPoint2;
|
|
13959
|
+
var lastPoint = points.length > 0 && points[points.length - 1];
|
|
13960
|
+
var isLastPointTooClose = lastPoint ? this.distanceTo(lastPoint) <= this.minDistance : false;
|
|
13961
|
+
if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
|
|
13962
|
+
points.push(point);
|
|
13963
|
+
if (points.length > 2) {
|
|
13964
|
+
if (points.length === 3) {
|
|
13965
|
+
points.unshift(points[0]);
|
|
13966
|
+
}
|
|
13967
|
+
controlPoint1 = (this.calculateCurveControlPoints(points[0], points[1], points[2])).controlPoint2;
|
|
13968
|
+
controlPoint2 = (this.calculateCurveControlPoints(points[1], points[2], points[3])).controlPoint1;
|
|
13969
|
+
this.startPoint = points[1];
|
|
13970
|
+
this.controlPoint1 = controlPoint1;
|
|
13971
|
+
this.controlPoint2 = controlPoint2;
|
|
13972
|
+
this.endPoint = points[2];
|
|
13973
|
+
this.startDraw();
|
|
13974
|
+
points.shift();
|
|
13975
|
+
}
|
|
13976
|
+
}
|
|
13977
|
+
};
|
|
13978
|
+
SignatureBase.prototype.startDraw = function () {
|
|
13979
|
+
var velocity;
|
|
13980
|
+
velocity = this.pointVelocityCalc(this.startPoint);
|
|
13981
|
+
velocity = this.velocity * velocity + (1 - this.velocity) * this.lastVelocity;
|
|
13982
|
+
var newWidth = Math.max(this.maxStrokeWidth / (velocity + 1), this.minStrokeWidth);
|
|
13983
|
+
this.curveDraw(this.lastWidth, newWidth);
|
|
13984
|
+
this.lastVelocity = velocity;
|
|
13985
|
+
this.lastWidth = newWidth;
|
|
13986
|
+
};
|
|
13987
|
+
SignatureBase.prototype.endDraw = function () {
|
|
13988
|
+
var canDrawCurve = this.pointColl.length > 2;
|
|
13989
|
+
var point = this.pointColl[0];
|
|
13990
|
+
if (!canDrawCurve && point) {
|
|
13991
|
+
this.strokeDraw(point);
|
|
13992
|
+
}
|
|
13993
|
+
};
|
|
13994
|
+
/* Calculate the Bezier (x, y) coordinate of the curve. */
|
|
13995
|
+
SignatureBase.prototype.curveDraw = function (startWidth, endWidth) {
|
|
13996
|
+
var context = this.canvasContext;
|
|
13997
|
+
var width;
|
|
13998
|
+
var i;
|
|
13999
|
+
var t1;
|
|
14000
|
+
var t2;
|
|
14001
|
+
var t3;
|
|
14002
|
+
var u1;
|
|
14003
|
+
var u2;
|
|
14004
|
+
var u3;
|
|
14005
|
+
var x;
|
|
14006
|
+
var y;
|
|
14007
|
+
var widthValue = endWidth - startWidth;
|
|
14008
|
+
var bezierLength = this.bezierLengthCalc();
|
|
14009
|
+
var drawSteps = Math.ceil(bezierLength) * 2;
|
|
14010
|
+
context.beginPath();
|
|
14011
|
+
for (i = 0; i < drawSteps; i++) {
|
|
14012
|
+
t1 = i / drawSteps;
|
|
14013
|
+
t2 = t1 * t1;
|
|
14014
|
+
t3 = t2 * t1;
|
|
14015
|
+
u1 = 1 - t1;
|
|
14016
|
+
u2 = u1 * u1;
|
|
14017
|
+
u3 = u2 * u1;
|
|
14018
|
+
x = u3 * this.startPoint.x;
|
|
14019
|
+
x += 3 * u2 * t1 * this.controlPoint1.x;
|
|
14020
|
+
x += 3 * u1 * t2 * this.controlPoint2.x;
|
|
14021
|
+
x += t3 * this.endPoint.x;
|
|
14022
|
+
y = u3 * this.startPoint.y;
|
|
14023
|
+
y += 3 * u2 * t1 * this.controlPoint1.y;
|
|
14024
|
+
y += 3 * u1 * t2 * this.controlPoint2.y;
|
|
14025
|
+
y += t3 * this.endPoint.y;
|
|
14026
|
+
width = Math.min(startWidth + t3 * widthValue, this.maxStrokeWidth);
|
|
14027
|
+
this.arcDraw(x, y, width);
|
|
14028
|
+
}
|
|
14029
|
+
context.closePath();
|
|
14030
|
+
context.fill();
|
|
14031
|
+
this.isSignatureEmpty = false;
|
|
14032
|
+
};
|
|
14033
|
+
SignatureBase.prototype.strokeDraw = function (point) {
|
|
14034
|
+
var context = this.canvasContext;
|
|
14035
|
+
var pointSize = (this.minStrokeWidth + this.maxStrokeWidth) / 2;
|
|
14036
|
+
context.beginPath();
|
|
14037
|
+
this.arcDraw(point.x, point.y, pointSize);
|
|
14038
|
+
context.closePath();
|
|
14039
|
+
context.fill();
|
|
14040
|
+
this.isSignatureEmpty = false;
|
|
14041
|
+
};
|
|
14042
|
+
SignatureBase.prototype.arcDraw = function (x, y, size) {
|
|
14043
|
+
var context = this.canvasContext;
|
|
14044
|
+
context.moveTo(x, y);
|
|
14045
|
+
context.arc(x, y, size, 0, 2 * Math.PI, false);
|
|
14046
|
+
};
|
|
14047
|
+
/* Utility functions for Bezier algorithm*/
|
|
14048
|
+
SignatureBase.prototype.calculateCurveControlPoints = function (p1, p2, p3) {
|
|
14049
|
+
var dx1 = p1.x - p2.x;
|
|
14050
|
+
var dy1 = p1.y - p2.y;
|
|
14051
|
+
var dx2 = p2.x - p3.x;
|
|
14052
|
+
var dy2 = p2.y - p3.y;
|
|
14053
|
+
var m1 = { x: (p1.x + p2.x) / 2.0, y: (p1.y + p2.y) / 2.0 };
|
|
14054
|
+
var m2 = { x: (p2.x + p3.x) / 2.0, y: (p2.y + p3.y) / 2.0 };
|
|
14055
|
+
var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
|
|
14056
|
+
var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
|
|
14057
|
+
var dxm = (m1.x - m2.x);
|
|
14058
|
+
var dym = (m1.y - m2.y);
|
|
14059
|
+
var k = l2 / (l1 + l2);
|
|
14060
|
+
var cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
|
|
14061
|
+
var tx = p2.x - cm.x;
|
|
14062
|
+
var ty = p2.y - cm.y;
|
|
14063
|
+
return {
|
|
14064
|
+
controlPoint1: this.point(m1.x + tx, m1.y + ty, 0),
|
|
14065
|
+
controlPoint2: this.point(m2.x + tx, m2.y + ty, 0)
|
|
14066
|
+
};
|
|
14067
|
+
};
|
|
14068
|
+
/* Returns approximated bezier length of the curuve.*/
|
|
14069
|
+
SignatureBase.prototype.bezierLengthCalc = function () {
|
|
14070
|
+
var steps = 10;
|
|
14071
|
+
var length = 0;
|
|
14072
|
+
var i;
|
|
14073
|
+
var t;
|
|
14074
|
+
var pointx1;
|
|
14075
|
+
var pointy1;
|
|
14076
|
+
var pointx2;
|
|
14077
|
+
var pointy2;
|
|
14078
|
+
var pointx3;
|
|
14079
|
+
var pointy3;
|
|
14080
|
+
for (i = 0; i <= steps; i++) {
|
|
14081
|
+
t = i / steps;
|
|
14082
|
+
pointx1 = this.bezierPointCalc(t, this.startPoint.x, this.controlPoint1.x, this.controlPoint2.x, this.endPoint.x);
|
|
14083
|
+
pointy1 = this.bezierPointCalc(t, this.startPoint.y, this.controlPoint1.y, this.controlPoint2.y, this.endPoint.y);
|
|
14084
|
+
if (i > 0) {
|
|
14085
|
+
pointx3 = pointx1 - pointx2;
|
|
14086
|
+
pointy3 = pointy1 - pointy2;
|
|
14087
|
+
length += Math.sqrt(pointx3 * pointx3 + pointy3 * pointy3);
|
|
14088
|
+
}
|
|
14089
|
+
pointx2 = pointx1;
|
|
14090
|
+
pointy2 = pointy1;
|
|
14091
|
+
}
|
|
14092
|
+
return length;
|
|
14093
|
+
};
|
|
14094
|
+
/* Calculate parametric value of x or y given t and the
|
|
14095
|
+
four point(startpoint, controlpoint1, controlpoint2, endpoint) coordinates of a cubic bezier curve.*/
|
|
14096
|
+
SignatureBase.prototype.bezierPointCalc = function (t, startpoint, cp1, cp2, endpoint) {
|
|
14097
|
+
return startpoint * (1.0 - t) * (1.0 - t) * (1.0 - t) + 3.0 * cp1 * (1.0 - t) * (1.0 - t) * t + 3.0 *
|
|
14098
|
+
cp2 * (1.0 - t) * t * t + endpoint * t * t * t;
|
|
14099
|
+
};
|
|
14100
|
+
/* Velocity between the current point and last point.*/
|
|
14101
|
+
SignatureBase.prototype.pointVelocityCalc = function (startPoint) {
|
|
14102
|
+
return (this.time !== startPoint.time) ? this.distanceTo(startPoint) / (this.time - startPoint.time) : 0;
|
|
14103
|
+
};
|
|
14104
|
+
/* Distance between the current point and last point.*/
|
|
14105
|
+
SignatureBase.prototype.distanceTo = function (start) {
|
|
14106
|
+
return Math.sqrt(Math.pow(this.pointX - start.x, 2) + Math.pow(this.pointY - start.y, 2));
|
|
14107
|
+
};
|
|
14108
|
+
SignatureBase.prototype.isRead = function (isRead) {
|
|
14109
|
+
if (isRead) {
|
|
14110
|
+
EventHandler.remove(this.canvasContext.canvas, 'mousedown touchstart', this.mouseDownHandler);
|
|
14111
|
+
}
|
|
14112
|
+
else if (!this.disabled) {
|
|
14113
|
+
EventHandler.add(this.canvasContext.canvas, 'mousedown touchstart', this.mouseDownHandler, this);
|
|
14114
|
+
}
|
|
14115
|
+
};
|
|
14116
|
+
SignatureBase.prototype.enableOrDisable = function (isDisable) {
|
|
14117
|
+
this.disabled = isDisable;
|
|
14118
|
+
if (isDisable) {
|
|
14119
|
+
this.reDraw('0.5');
|
|
14120
|
+
this.isRead(true);
|
|
14121
|
+
}
|
|
14122
|
+
else {
|
|
14123
|
+
this.reDraw('1');
|
|
14124
|
+
this.isRead(false);
|
|
14125
|
+
}
|
|
14126
|
+
};
|
|
14127
|
+
SignatureBase.prototype.reDraw = function (opacity) {
|
|
14128
|
+
var data = this.canvasContext.getImageData(0, 0, this.element.width, this.element.height);
|
|
14129
|
+
this.canvasContext.clearRect(0, 0, this.element.width, this.element.height);
|
|
14130
|
+
this.element.style.opacity = opacity;
|
|
14131
|
+
this.canvasContext.putImageData(data, 0, 0);
|
|
14132
|
+
};
|
|
14133
|
+
SignatureBase.prototype.updateSnapCollection = function (isClear) {
|
|
14134
|
+
if (isNullOrUndefined(this.incStep)) {
|
|
14135
|
+
this.incStep = -1;
|
|
14136
|
+
this.incStep++;
|
|
14137
|
+
this.snapColl = [];
|
|
14138
|
+
this.clearArray = [];
|
|
14139
|
+
}
|
|
14140
|
+
else {
|
|
14141
|
+
this.incStep++;
|
|
14142
|
+
}
|
|
14143
|
+
if (this.incStep < this.snapColl.length) {
|
|
14144
|
+
this.snapColl.length = this.incStep;
|
|
14145
|
+
}
|
|
14146
|
+
if (this.incStep > 0) {
|
|
14147
|
+
var canvasNew = this.createElement('canvas', { className: 'e-' + this.getModuleName() + '-wrapper' });
|
|
14148
|
+
var canvasContextNew = canvasNew.getContext('2d');
|
|
14149
|
+
canvasNew.width = this.canvasContext.canvas.width;
|
|
14150
|
+
canvasNew.height = this.canvasContext.canvas.height;
|
|
14151
|
+
canvasContextNew.drawImage(this.canvasContext.canvas, 0, 0, canvasNew.width, canvasNew.height);
|
|
14152
|
+
this.snapColl.push(canvasNew.toDataURL());
|
|
14153
|
+
}
|
|
14154
|
+
else {
|
|
14155
|
+
this.snapColl.push(this.canvasContext.canvas.toDataURL());
|
|
14156
|
+
}
|
|
14157
|
+
if (isClear) {
|
|
14158
|
+
this.clearArray.push(this.incStep);
|
|
14159
|
+
}
|
|
14160
|
+
};
|
|
14161
|
+
SignatureBase.prototype.setBackgroundImage = function (imageSrc) {
|
|
14162
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
14163
|
+
var proxy = this;
|
|
14164
|
+
var imageObj = new Image();
|
|
14165
|
+
imageObj.crossOrigin = 'anonymous';
|
|
14166
|
+
imageObj.src = imageSrc;
|
|
14167
|
+
imageObj.onload = function () {
|
|
14168
|
+
proxy.canvasContext.globalCompositeOperation = 'source-over';
|
|
14169
|
+
proxy.canvasContext.drawImage(imageObj, 0, 0, proxy.element.width, proxy.element.height);
|
|
14170
|
+
proxy.updateSnapCollection();
|
|
14171
|
+
proxy.saveBackground(true);
|
|
14172
|
+
};
|
|
14173
|
+
this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
14174
|
+
};
|
|
14175
|
+
SignatureBase.prototype.setBackgroundColor = function (color) {
|
|
14176
|
+
var canvasEle = this.canvasContext;
|
|
14177
|
+
canvasEle.strokeStyle = color;
|
|
14178
|
+
var i;
|
|
14179
|
+
var j;
|
|
14180
|
+
for (i = 1; i <= canvasEle.canvas.width; i++) {
|
|
14181
|
+
for (j = 1; j <= canvasEle.canvas.height; j++) {
|
|
14182
|
+
canvasEle.strokeRect(0, 0, i, j);
|
|
14183
|
+
}
|
|
14184
|
+
}
|
|
14185
|
+
this.updateSnapCollection();
|
|
14186
|
+
};
|
|
14187
|
+
SignatureBase.prototype.loadPersistedSignature = function () {
|
|
14188
|
+
if (isNullOrUndefined(this.signatureValue)) {
|
|
14189
|
+
return;
|
|
14190
|
+
}
|
|
14191
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
14192
|
+
var proxy = this;
|
|
14193
|
+
var lastImage = new Image();
|
|
14194
|
+
lastImage.src = this.signatureValue;
|
|
14195
|
+
lastImage.onload = function () {
|
|
14196
|
+
proxy.canvasContext.clearRect(0, 0, proxy.element.width, proxy.element.height);
|
|
14197
|
+
proxy.canvasContext.drawImage(lastImage, 0, 0);
|
|
14198
|
+
proxy.updateSnapCollection();
|
|
14199
|
+
};
|
|
14200
|
+
this.isSignatureEmpty = false;
|
|
14201
|
+
};
|
|
14202
|
+
/**
|
|
14203
|
+
* To get the signature as Blob.
|
|
14204
|
+
*
|
|
14205
|
+
* @param {string} url - specify the url/base 64 string to get blob of the signature.
|
|
14206
|
+
* @returns {Blob}.
|
|
14207
|
+
*/
|
|
14208
|
+
SignatureBase.prototype.getBlob = function (url) {
|
|
14209
|
+
var arr = url.split(',');
|
|
14210
|
+
var type = arr[0].match(/:(.*?);/)[1];
|
|
14211
|
+
var bstr = atob(arr[1]);
|
|
14212
|
+
var n = bstr.length;
|
|
14213
|
+
var u8arr = new Uint8Array(n);
|
|
14214
|
+
while (n--) {
|
|
14215
|
+
u8arr[n] = bstr.charCodeAt(n);
|
|
14216
|
+
}
|
|
14217
|
+
return new Blob([u8arr], { type: type });
|
|
14218
|
+
};
|
|
14219
|
+
SignatureBase.prototype.download = function (blob, fileName) {
|
|
14220
|
+
var blobUrl = URL.createObjectURL(blob);
|
|
14221
|
+
var a = document.createElement('a');
|
|
14222
|
+
a.href = blobUrl;
|
|
14223
|
+
a.target = '_parent';
|
|
14224
|
+
a.download = fileName;
|
|
14225
|
+
(document.body || document.documentElement).appendChild(a);
|
|
14226
|
+
a.click();
|
|
14227
|
+
a.parentNode.removeChild(a);
|
|
14228
|
+
};
|
|
14229
|
+
/**
|
|
14230
|
+
* To refresh the signature.
|
|
14231
|
+
*
|
|
14232
|
+
* @private
|
|
14233
|
+
* @returns {void}.
|
|
14234
|
+
*/
|
|
14235
|
+
SignatureBase.prototype.refresh = function () {
|
|
14236
|
+
this.pointColl = [];
|
|
14237
|
+
this.lastVelocity = 0;
|
|
14238
|
+
this.lastWidth = (this.minStrokeWidth + this.maxStrokeWidth) / 2;
|
|
14239
|
+
};
|
|
14240
|
+
/**
|
|
14241
|
+
* Erases all the signature strokes signed by user.
|
|
14242
|
+
*
|
|
14243
|
+
* @returns {void}.
|
|
14244
|
+
*/
|
|
14245
|
+
SignatureBase.prototype.clear = function () {
|
|
14246
|
+
var args = { actionName: 'clear' };
|
|
14247
|
+
this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
14248
|
+
this.refresh();
|
|
14249
|
+
this.updateSnapCollection(true);
|
|
14250
|
+
this.isSignatureEmpty = true;
|
|
14251
|
+
if (!this.isBlazor) {
|
|
14252
|
+
this.trigger('change', args);
|
|
14253
|
+
}
|
|
14254
|
+
else {
|
|
14255
|
+
this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'Clear');
|
|
14256
|
+
}
|
|
14257
|
+
};
|
|
14258
|
+
/**
|
|
14259
|
+
* Undo the last user action.
|
|
14260
|
+
*
|
|
14261
|
+
* @returns {void}.
|
|
14262
|
+
*/
|
|
14263
|
+
SignatureBase.prototype.undo = function () {
|
|
14264
|
+
var args = { actionName: 'undo' };
|
|
14265
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
14266
|
+
var proxy = this;
|
|
14267
|
+
if (this.incStep > 0) {
|
|
14268
|
+
this.incStep--;
|
|
14269
|
+
var undoImg_1 = new Image();
|
|
14270
|
+
undoImg_1.src = this.snapColl[this.incStep];
|
|
14271
|
+
undoImg_1.onload = function () {
|
|
14272
|
+
proxy.canvasContext.clearRect(0, 0, proxy.element.width, proxy.element.height);
|
|
14273
|
+
proxy.canvasContext.drawImage(undoImg_1, 0, 0, proxy.element.width, proxy.element.height);
|
|
14274
|
+
};
|
|
14275
|
+
}
|
|
14276
|
+
this.isClear();
|
|
14277
|
+
if (!this.isBlazor) {
|
|
14278
|
+
this.trigger('change', args);
|
|
14279
|
+
}
|
|
14280
|
+
else {
|
|
14281
|
+
this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'Undo');
|
|
14282
|
+
}
|
|
14283
|
+
};
|
|
14284
|
+
/**
|
|
14285
|
+
* Redo the last user action.
|
|
14286
|
+
*
|
|
14287
|
+
* @returns {void}.
|
|
14288
|
+
*/
|
|
14289
|
+
SignatureBase.prototype.redo = function () {
|
|
14290
|
+
var args = { actionName: 'redo' };
|
|
14291
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
14292
|
+
var proxy = this;
|
|
14293
|
+
if (this.incStep < this.snapColl.length - 1) {
|
|
14294
|
+
this.incStep++;
|
|
14295
|
+
var redoImg_1 = new Image();
|
|
14296
|
+
redoImg_1.src = this.snapColl[this.incStep];
|
|
14297
|
+
redoImg_1.onload = function () {
|
|
14298
|
+
proxy.canvasContext.clearRect(0, 0, proxy.element.width, proxy.element.height);
|
|
14299
|
+
proxy.canvasContext.drawImage(redoImg_1, 0, 0, proxy.element.width, proxy.element.height);
|
|
14300
|
+
};
|
|
14301
|
+
}
|
|
14302
|
+
this.isClear();
|
|
14303
|
+
if (!this.isBlazor) {
|
|
14304
|
+
this.trigger('change', args);
|
|
14305
|
+
}
|
|
14306
|
+
else {
|
|
14307
|
+
this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'Redo');
|
|
14308
|
+
}
|
|
14309
|
+
};
|
|
14310
|
+
SignatureBase.prototype.isClear = function () {
|
|
14311
|
+
if (this.clearArray) {
|
|
14312
|
+
var empty = false;
|
|
14313
|
+
for (var i = 0; i < this.clearArray.length; i++) {
|
|
14314
|
+
if (this.clearArray[i] === this.incStep) {
|
|
14315
|
+
this.isSignatureEmpty = true;
|
|
14316
|
+
empty = true;
|
|
14317
|
+
}
|
|
14318
|
+
}
|
|
14319
|
+
if (!empty) {
|
|
14320
|
+
this.isSignatureEmpty = false;
|
|
14321
|
+
}
|
|
14322
|
+
}
|
|
14323
|
+
};
|
|
14324
|
+
/**
|
|
14325
|
+
* To check whether the signature is empty or not.
|
|
14326
|
+
*
|
|
14327
|
+
* @returns {boolean}.
|
|
14328
|
+
*/
|
|
14329
|
+
SignatureBase.prototype.isEmpty = function () {
|
|
14330
|
+
return this.isSignatureEmpty;
|
|
14331
|
+
};
|
|
14332
|
+
/**
|
|
14333
|
+
* To check whether the undo collection is empty or not.
|
|
14334
|
+
*
|
|
14335
|
+
* @returns {boolean}.
|
|
14336
|
+
*/
|
|
14337
|
+
SignatureBase.prototype.canUndo = function () {
|
|
14338
|
+
return this.incStep > 0;
|
|
14339
|
+
};
|
|
14340
|
+
/**
|
|
14341
|
+
* To check whether the redo collection is empty or not.
|
|
14342
|
+
*
|
|
14343
|
+
* @returns {boolean}.
|
|
14344
|
+
*/
|
|
14345
|
+
SignatureBase.prototype.canRedo = function () {
|
|
14346
|
+
return this.incStep < this.snapColl.length - 1;
|
|
14347
|
+
};
|
|
14348
|
+
/**
|
|
14349
|
+
* To draw the signature based on the given text, with the font family and font size.
|
|
14350
|
+
*
|
|
14351
|
+
* @param {string} text - specify text to be drawn as signature.
|
|
14352
|
+
* @param {string} fontFamily - specify font family of a signature.
|
|
14353
|
+
* @param {number} fontSize - specify font size of a signature.
|
|
14354
|
+
*
|
|
14355
|
+
* @returns {void}.
|
|
14356
|
+
*/
|
|
14357
|
+
SignatureBase.prototype.draw = function (text, fontFamily, fontSize) {
|
|
14358
|
+
this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
14359
|
+
fontFamily = fontFamily || 'Arial';
|
|
14360
|
+
fontSize = fontSize || 30;
|
|
14361
|
+
this.canvasContext.font = fontSize + 'px ' + fontFamily;
|
|
14362
|
+
this.canvasContext.textAlign = 'center';
|
|
14363
|
+
this.canvasContext.textBaseline = 'middle';
|
|
14364
|
+
this.canvasContext.fillText(text, this.element.width / 2, this.element.height / 2);
|
|
14365
|
+
this.updateSnapCollection();
|
|
14366
|
+
this.isSignatureEmpty = false;
|
|
14367
|
+
};
|
|
14368
|
+
/**
|
|
14369
|
+
* To load the signature with the given base 64 string, height and width.
|
|
14370
|
+
*
|
|
14371
|
+
* @param {string} signature - specify the url/base 64 string to be drawn as signature.
|
|
14372
|
+
* @param {number} width - specify the width of the loaded signature image.
|
|
14373
|
+
* @param {number} height - specify the height of the loaded signature image.
|
|
14374
|
+
* @returns {void}.
|
|
14375
|
+
*/
|
|
14376
|
+
SignatureBase.prototype.load = function (signature, width, height) {
|
|
14377
|
+
height = height || this.element.height;
|
|
14378
|
+
width = width || this.element.width;
|
|
14379
|
+
this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
14380
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
14381
|
+
var proxy = this;
|
|
14382
|
+
var bitmapImage = new Image();
|
|
14383
|
+
bitmapImage.src = signature;
|
|
14384
|
+
bitmapImage.onload = function () {
|
|
14385
|
+
Promise.all([
|
|
14386
|
+
createImageBitmap(bitmapImage, 0, 0, width, height)
|
|
14387
|
+
]).then(function (results) {
|
|
14388
|
+
var tempCanvas = document.createElement('canvas');
|
|
14389
|
+
tempCanvas.width = width;
|
|
14390
|
+
tempCanvas.height = height;
|
|
14391
|
+
tempCanvas.getContext('2d').drawImage(results[0], 0, 0);
|
|
14392
|
+
proxy.canvasContext.drawImage(tempCanvas, 0, 0, width, height, 0, 0, proxy.element.width, proxy.element.height);
|
|
14393
|
+
proxy.updateSnapCollection();
|
|
14394
|
+
});
|
|
14395
|
+
};
|
|
14396
|
+
this.isSignatureEmpty = false;
|
|
14397
|
+
};
|
|
14398
|
+
SignatureBase.prototype.saveBackground = function (savebg) {
|
|
14399
|
+
var imageSrc;
|
|
14400
|
+
if (savebg && this.backgroundImage) {
|
|
14401
|
+
imageSrc = this.snapColl[this.incStep - 1];
|
|
14402
|
+
}
|
|
14403
|
+
else {
|
|
14404
|
+
imageSrc = this.snapColl[this.incStep];
|
|
14405
|
+
}
|
|
14406
|
+
if (!savebg) {
|
|
14407
|
+
this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
14408
|
+
if (this.backgroundImage) {
|
|
14409
|
+
this.setBackgroundImage(this.backgroundImage);
|
|
14410
|
+
}
|
|
14411
|
+
else if (this.backgroundColor) {
|
|
14412
|
+
this.setBackgroundColor(this.backgroundColor);
|
|
14413
|
+
savebg = true;
|
|
14414
|
+
}
|
|
14415
|
+
}
|
|
14416
|
+
if (savebg) {
|
|
14417
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
14418
|
+
var proxy_1 = this;
|
|
14419
|
+
var imageObj_1 = new Image();
|
|
14420
|
+
imageObj_1.crossOrigin = 'anonymous';
|
|
14421
|
+
imageObj_1.src = imageSrc;
|
|
14422
|
+
imageObj_1.onload = function () {
|
|
14423
|
+
proxy_1.backgroundLoaded = true;
|
|
14424
|
+
proxy_1.canvasContext.globalCompositeOperation = 'source-over';
|
|
14425
|
+
proxy_1.canvasContext.drawImage(imageObj_1, 0, 0, proxy_1.element.width, proxy_1.element.height);
|
|
14426
|
+
proxy_1.save(proxy_1.fileType, proxy_1.fileName);
|
|
14427
|
+
};
|
|
14428
|
+
}
|
|
14429
|
+
};
|
|
14430
|
+
/**
|
|
14431
|
+
* To save the signature with the given file type and file name.
|
|
14432
|
+
*
|
|
14433
|
+
* @param {SignatureFileType} type - specify type of the file to be saved a signature.
|
|
14434
|
+
* @param {string} fileName - specify name of the file to be saved a signature.
|
|
14435
|
+
*
|
|
14436
|
+
* @returns {void}.
|
|
14437
|
+
*/
|
|
14438
|
+
SignatureBase.prototype.save = function (type, fileName) {
|
|
14439
|
+
if (this.saveWithBackground && this.backgroundLoaded == null && (this.backgroundImage || this.backgroundColor)) {
|
|
14440
|
+
this.backgroundLoaded = false;
|
|
14441
|
+
this.fileType = type;
|
|
14442
|
+
this.fileName = fileName;
|
|
14443
|
+
this.saveBackground(false);
|
|
14444
|
+
}
|
|
14445
|
+
else if (type === 'Svg') {
|
|
14446
|
+
fileName = fileName || 'Signature';
|
|
14447
|
+
this.toSVG(fileName);
|
|
14448
|
+
}
|
|
14449
|
+
else if (type === 'Jpeg') {
|
|
14450
|
+
fileName = fileName || 'Signature';
|
|
14451
|
+
if (!this.saveWithBackground || this.saveWithBackground && !(this.backgroundImage || this.backgroundColor)) {
|
|
14452
|
+
this.toJPEG(fileName);
|
|
14453
|
+
}
|
|
14454
|
+
else {
|
|
14455
|
+
var dataURL = this.canvasContext.canvas.toDataURL('image/jpeg');
|
|
14456
|
+
this.download(this.getBlob(dataURL), fileName + '.' + 'jpeg');
|
|
14457
|
+
}
|
|
14458
|
+
}
|
|
14459
|
+
else {
|
|
14460
|
+
fileName = fileName || 'Signature';
|
|
14461
|
+
var dataURL = this.canvasContext.canvas.toDataURL('image/png');
|
|
14462
|
+
this.download(this.getBlob(dataURL), fileName + '.' + 'png');
|
|
14463
|
+
}
|
|
14464
|
+
if (this.saveWithBackground && this.backgroundLoaded) {
|
|
14465
|
+
this.resetSnap();
|
|
14466
|
+
}
|
|
14467
|
+
};
|
|
14468
|
+
SignatureBase.prototype.resetSnap = function () {
|
|
14469
|
+
this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
14470
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
14471
|
+
var proxy = this;
|
|
14472
|
+
var restoreObj = new Image();
|
|
14473
|
+
restoreObj.src = this.snapColl[this.incStep - 1];
|
|
14474
|
+
restoreObj.onload = function () {
|
|
14475
|
+
proxy.canvasContext.drawImage(restoreObj, 0, 0, proxy.element.width, proxy.element.height);
|
|
14476
|
+
proxy.updateSnapCollection();
|
|
14477
|
+
};
|
|
14478
|
+
this.backgroundLoaded = null;
|
|
14479
|
+
this.snapColl.pop();
|
|
14480
|
+
this.incStep--;
|
|
14481
|
+
this.snapColl.pop();
|
|
14482
|
+
this.incStep--;
|
|
14483
|
+
};
|
|
14484
|
+
SignatureBase.prototype.toJPEG = function (fileName) {
|
|
14485
|
+
var _this = this;
|
|
14486
|
+
var imageSrc = this.snapColl[this.incStep];
|
|
14487
|
+
this.setBackgroundColor('#ffffff');
|
|
14488
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
14489
|
+
var proxy = this;
|
|
14490
|
+
var imageObj = new Image();
|
|
14491
|
+
imageObj.crossOrigin = 'anonymous';
|
|
14492
|
+
imageObj.src = imageSrc;
|
|
14493
|
+
imageObj.onload = function () {
|
|
14494
|
+
proxy.canvasContext.globalCompositeOperation = 'source-over';
|
|
14495
|
+
proxy.canvasContext.drawImage(imageObj, 0, 0, proxy.element.width, proxy.element.height);
|
|
14496
|
+
var dataURL = proxy.canvasContext.canvas.toDataURL('image/jpeg');
|
|
14497
|
+
proxy.download(proxy.getBlob(dataURL), fileName + '.' + 'jpeg');
|
|
14498
|
+
proxy.canvasContext.clearRect(0, 0, proxy.canvasContext.canvas.width, proxy.canvasContext.canvas.height);
|
|
14499
|
+
_this.resizeHandler();
|
|
14500
|
+
};
|
|
14501
|
+
this.snapColl.pop();
|
|
14502
|
+
this.incStep--;
|
|
14503
|
+
};
|
|
14504
|
+
SignatureBase.prototype.toSVG = function (fileName) {
|
|
14505
|
+
var dataUrl = this.canvasContext.canvas.toDataURL();
|
|
14506
|
+
var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
14507
|
+
svg.setAttribute('width', this.canvasContext.canvas.width.toString());
|
|
14508
|
+
svg.setAttribute('height', this.canvasContext.canvas.height.toString());
|
|
14509
|
+
var XLinkNS = 'http://www.w3.org/1999/xlink';
|
|
14510
|
+
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
|
|
14511
|
+
img.setAttributeNS(null, 'height', this.canvasContext.canvas.height.toString());
|
|
14512
|
+
img.setAttributeNS(null, 'width', this.canvasContext.canvas.width.toString());
|
|
14513
|
+
img.setAttributeNS(XLinkNS, 'xlink:href', dataUrl);
|
|
14514
|
+
svg.appendChild(img);
|
|
14515
|
+
var prefix = 'data:image/svg+xml;base64,';
|
|
14516
|
+
var header = '<svg' + ' xmlns="http://www.w3.org/2000/svg"' + ' xmlns:xlink="http://www.w3.org/1999/xlink"'
|
|
14517
|
+
+ (" width=\"" + this.canvasContext.canvas.width + "\"") + (" height=\"" + this.canvasContext.canvas.height + "\"") + '>';
|
|
14518
|
+
var footer = '</svg>';
|
|
14519
|
+
var body = svg.innerHTML;
|
|
14520
|
+
var data = header + body + footer;
|
|
14521
|
+
var svgDataUrl = prefix + btoa(data);
|
|
14522
|
+
if (fileName == null) {
|
|
14523
|
+
return svgDataUrl;
|
|
14524
|
+
}
|
|
14525
|
+
else {
|
|
14526
|
+
this.download(this.getBlob(svgDataUrl), fileName + '.' + 'svg');
|
|
14527
|
+
return null;
|
|
14528
|
+
}
|
|
14529
|
+
};
|
|
14530
|
+
/**
|
|
14531
|
+
* To save the signature as Blob.
|
|
14532
|
+
*
|
|
14533
|
+
* @returns {Blob}.
|
|
14534
|
+
*/
|
|
14535
|
+
SignatureBase.prototype.saveAsBlob = function () {
|
|
14536
|
+
return this.getBlob(this.canvasContext.canvas.toDataURL('image/png'));
|
|
14537
|
+
};
|
|
14538
|
+
/**
|
|
14539
|
+
* To get the signature as Base 64.
|
|
14540
|
+
*
|
|
14541
|
+
* @private
|
|
14542
|
+
* @param {SignatureFileType} type - Specifies the type of the image format.
|
|
14543
|
+
* @returns {string}.
|
|
14544
|
+
*/
|
|
14545
|
+
SignatureBase.prototype.getSignature = function (type) {
|
|
14546
|
+
if (type === 'Jpeg') {
|
|
14547
|
+
var imgData = this.canvasContext.getImageData(0, 0, this.element.width, this.element.height);
|
|
14548
|
+
var data = imgData.data;
|
|
14549
|
+
for (var i = 0; i < data.length; i += 4) {
|
|
14550
|
+
if (data[i + 3] < 255) {
|
|
14551
|
+
data[i] = 255 - data[i];
|
|
14552
|
+
data[i + 1] = 255 - data[i + 1];
|
|
14553
|
+
data[i + 2] = 255 - data[i + 2];
|
|
14554
|
+
data[i + 3] = 255 - data[i + 3];
|
|
14555
|
+
}
|
|
14556
|
+
}
|
|
14557
|
+
this.canvasContext.putImageData(imgData, 0, 0);
|
|
14558
|
+
var dataURL = this.canvasContext.canvas.toDataURL('image/jpeg');
|
|
14559
|
+
this.resizeHandler();
|
|
14560
|
+
return dataURL;
|
|
14561
|
+
}
|
|
14562
|
+
else if (type === 'Svg') {
|
|
14563
|
+
return this.toSVG(null);
|
|
14564
|
+
}
|
|
14565
|
+
else {
|
|
14566
|
+
return this.canvasContext.canvas.toDataURL('image/png');
|
|
14567
|
+
}
|
|
14568
|
+
};
|
|
14569
|
+
/**
|
|
14570
|
+
* Get component name.
|
|
14571
|
+
*
|
|
14572
|
+
* @returns {string} - Module Name
|
|
14573
|
+
* @private
|
|
14574
|
+
*/
|
|
14575
|
+
SignatureBase.prototype.getModuleName = function () {
|
|
14576
|
+
return 'signature';
|
|
14577
|
+
};
|
|
14578
|
+
/**
|
|
14579
|
+
* To get the properties to be maintained in the persisted state.
|
|
14580
|
+
*
|
|
14581
|
+
* @returns {string} - Persist data
|
|
14582
|
+
*/
|
|
14583
|
+
SignatureBase.prototype.getPersistData = function () {
|
|
14584
|
+
this.signatureValue = this.snapColl[this.incStep];
|
|
14585
|
+
return this.addOnPersist(['signatureValue']);
|
|
14586
|
+
};
|
|
14587
|
+
/**
|
|
14588
|
+
* Removes the component from the DOM and detaches all its related event handlers.
|
|
14589
|
+
* Also it maintains the initial input element from the DOM.
|
|
14590
|
+
*
|
|
14591
|
+
* @method destroy
|
|
14592
|
+
* @returns {void}
|
|
14593
|
+
*/
|
|
14594
|
+
SignatureBase.prototype.destroy = function () {
|
|
14595
|
+
this.unwireEvents(null);
|
|
14596
|
+
removeClass([this.element], 'e-' + this.getModuleName());
|
|
14597
|
+
this.element.removeAttribute('tabindex');
|
|
14598
|
+
this.pointColl = null;
|
|
14599
|
+
_super.prototype.destroy.call(this);
|
|
14600
|
+
};
|
|
14601
|
+
/**
|
|
14602
|
+
* Modified onPropertyChanged method for both blazor and EJ2 signature component.
|
|
14603
|
+
*
|
|
14604
|
+
* @private
|
|
14605
|
+
* @param {string} key - Specifies the property, which changed.
|
|
14606
|
+
* @param {string} value - Specifies the property value changed.
|
|
14607
|
+
* @returns {void}
|
|
14608
|
+
*/
|
|
14609
|
+
SignatureBase.prototype.propertyChanged = function (key, value) {
|
|
14610
|
+
var canvasNew = this.canvasContext;
|
|
14611
|
+
switch (key) {
|
|
14612
|
+
case 'backgroundColor':
|
|
14613
|
+
canvasNew.canvas.style.backgroundColor = value;
|
|
14614
|
+
this.backgroundColor = value;
|
|
14615
|
+
break;
|
|
14616
|
+
case 'backgroundImage':
|
|
14617
|
+
canvasNew.canvas.style.backgroundImage = 'url(' + value + ')';
|
|
14618
|
+
this.backgroundImage = value;
|
|
14619
|
+
break;
|
|
14620
|
+
case 'strokeColor':
|
|
14621
|
+
canvasNew.fillStyle = value;
|
|
14622
|
+
this.strokeColor = value;
|
|
14623
|
+
break;
|
|
14624
|
+
case 'saveWithBackground':
|
|
14625
|
+
this.saveWithBackground = value;
|
|
14626
|
+
break;
|
|
14627
|
+
case 'maxStrokeWidth':
|
|
14628
|
+
this.maxStrokeWidth = value;
|
|
14629
|
+
break;
|
|
14630
|
+
case 'minStrokeWidth':
|
|
14631
|
+
this.minStrokeWidth = value;
|
|
14632
|
+
break;
|
|
14633
|
+
case 'velocity':
|
|
14634
|
+
this.velocity = value;
|
|
14635
|
+
break;
|
|
14636
|
+
case 'isReadOnly':
|
|
14637
|
+
this.isRead(value);
|
|
14638
|
+
break;
|
|
14639
|
+
case 'disabled':
|
|
14640
|
+
this.enableOrDisable(value);
|
|
14641
|
+
break;
|
|
14642
|
+
}
|
|
14643
|
+
};
|
|
14644
|
+
return SignatureBase;
|
|
14645
|
+
}(Component));
|
|
14646
|
+
|
|
14647
|
+
var __extends$7 = (undefined && undefined.__extends) || (function () {
|
|
14648
|
+
var extendStatics = function (d, b) {
|
|
14649
|
+
extendStatics = Object.setPrototypeOf ||
|
|
14650
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
14651
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
14652
|
+
return extendStatics(d, b);
|
|
14653
|
+
};
|
|
14654
|
+
return function (d, b) {
|
|
14655
|
+
extendStatics(d, b);
|
|
14656
|
+
function __() { this.constructor = d; }
|
|
14657
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14658
|
+
};
|
|
14659
|
+
})();
|
|
14660
|
+
var __decorate$7 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
14661
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
14662
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
14663
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
14664
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14665
|
+
};
|
|
14666
|
+
/**
|
|
14667
|
+
* The Signature component allows user to draw smooth signatures as vector outline of strokes using variable width bezier curve interpolation.
|
|
14668
|
+
* It allows to save signature as image.
|
|
14669
|
+
* You can use your finger, pen, or mouse on a tablet, touchscreen, etc., to draw your own signature on this Signature component.
|
|
14670
|
+
* Signature component is a user interface to draw the Signature or Text.
|
|
14671
|
+
* It provides supports for various Background color, Stroke color and Background Image.
|
|
14672
|
+
* ```html
|
|
14673
|
+
* <canvas id="signature"></canvas>
|
|
14674
|
+
* ```
|
|
14675
|
+
* ```typescript
|
|
14676
|
+
* <script>
|
|
14677
|
+
* let signatureObj: Signature = new Signature(null , "#signature");
|
|
14678
|
+
* </script>
|
|
14679
|
+
* ```
|
|
14680
|
+
*/
|
|
14681
|
+
var Signature = /** @__PURE__ @class */ (function (_super) {
|
|
14682
|
+
__extends$7(Signature, _super);
|
|
14683
|
+
/**
|
|
14684
|
+
* Constructor for creating the widget.
|
|
14685
|
+
*
|
|
14686
|
+
* @param {SignatureModel} options - Specifies the Signature model.
|
|
14687
|
+
* @param {string | HTMLCanvasElement} element - Specifies the element.
|
|
14688
|
+
* @private
|
|
14689
|
+
*/
|
|
14690
|
+
function Signature(options, element) {
|
|
14691
|
+
return _super.call(this, options, element) || this;
|
|
14692
|
+
}
|
|
14693
|
+
Signature.prototype.preRender = function () {
|
|
14694
|
+
// pre render code snippets
|
|
14695
|
+
};
|
|
14696
|
+
/**
|
|
14697
|
+
* To Initialize the component rendering
|
|
14698
|
+
*
|
|
14699
|
+
* @private
|
|
14700
|
+
* @returns {void}
|
|
14701
|
+
*/
|
|
14702
|
+
Signature.prototype.render = function () {
|
|
14703
|
+
this.initialize();
|
|
14704
|
+
};
|
|
14705
|
+
Signature.prototype.initialize = function () {
|
|
14706
|
+
addClass([this.element], 'e-' + this.getModuleName());
|
|
14707
|
+
_super.prototype.initialize.call(this, this.element);
|
|
14708
|
+
if (this.enablePersistence) {
|
|
14709
|
+
this.loadPersistedSignature();
|
|
14710
|
+
}
|
|
14711
|
+
};
|
|
14712
|
+
/**
|
|
14713
|
+
* To get component name.
|
|
14714
|
+
*
|
|
14715
|
+
* @returns {string} - Module Name
|
|
14716
|
+
* @private
|
|
14717
|
+
*/
|
|
14718
|
+
Signature.prototype.getModuleName = function () {
|
|
14719
|
+
return 'signature';
|
|
14720
|
+
};
|
|
14721
|
+
/**
|
|
14722
|
+
* To get the properties to be maintained in the persisted state.
|
|
14723
|
+
*
|
|
14724
|
+
* @returns {string} - Persist data
|
|
14725
|
+
*/
|
|
14726
|
+
Signature.prototype.getPersistData = function () {
|
|
14727
|
+
return this.addOnPersist(['signatureValue']);
|
|
14728
|
+
};
|
|
14729
|
+
/**
|
|
14730
|
+
* Called internally if any of the property value changed.
|
|
14731
|
+
*
|
|
14732
|
+
* @param {SignatureModel} newProp - Specifies new properties
|
|
14733
|
+
* @param {SignatureModel} oldProp - Specifies old properties
|
|
14734
|
+
* @returns {void}
|
|
14735
|
+
* @private
|
|
14736
|
+
*/
|
|
14737
|
+
Signature.prototype.onPropertyChanged = function (newProp, oldProp) {
|
|
14738
|
+
for (var _i = 0, _a = Object.keys(newProp); _i < _a.length; _i++) {
|
|
14739
|
+
var prop = _a[_i];
|
|
14740
|
+
switch (prop) {
|
|
14741
|
+
case 'backgroundColor':
|
|
14742
|
+
_super.prototype.propertyChanged.call(this, prop, newProp.backgroundColor);
|
|
14743
|
+
break;
|
|
14744
|
+
case 'backgroundImage':
|
|
14745
|
+
_super.prototype.propertyChanged.call(this, prop, newProp.backgroundImage);
|
|
14746
|
+
break;
|
|
14747
|
+
case 'strokeColor':
|
|
14748
|
+
if (newProp.strokeColor !== oldProp.strokeColor) {
|
|
14749
|
+
_super.prototype.propertyChanged.call(this, prop, newProp.strokeColor);
|
|
14750
|
+
}
|
|
14751
|
+
break;
|
|
14752
|
+
case 'saveWithBackground':
|
|
14753
|
+
_super.prototype.propertyChanged.call(this, prop, newProp.saveWithBackground);
|
|
14754
|
+
break;
|
|
14755
|
+
case 'isReadOnly':
|
|
14756
|
+
_super.prototype.propertyChanged.call(this, prop, newProp.isReadOnly);
|
|
14757
|
+
break;
|
|
14758
|
+
case 'disabled':
|
|
14759
|
+
_super.prototype.propertyChanged.call(this, prop, newProp.disabled);
|
|
14760
|
+
break;
|
|
14761
|
+
}
|
|
14762
|
+
}
|
|
14763
|
+
};
|
|
14764
|
+
__decorate$7([
|
|
14765
|
+
Property('')
|
|
14766
|
+
], Signature.prototype, "backgroundColor", void 0);
|
|
14767
|
+
__decorate$7([
|
|
14768
|
+
Property('')
|
|
14769
|
+
], Signature.prototype, "backgroundImage", void 0);
|
|
14770
|
+
__decorate$7([
|
|
14771
|
+
Property(false)
|
|
14772
|
+
], Signature.prototype, "disabled", void 0);
|
|
14773
|
+
__decorate$7([
|
|
14774
|
+
Property(false)
|
|
14775
|
+
], Signature.prototype, "isReadOnly", void 0);
|
|
14776
|
+
__decorate$7([
|
|
14777
|
+
Property(true)
|
|
14778
|
+
], Signature.prototype, "saveWithBackground", void 0);
|
|
14779
|
+
__decorate$7([
|
|
14780
|
+
Property('#000000')
|
|
14781
|
+
], Signature.prototype, "strokeColor", void 0);
|
|
14782
|
+
__decorate$7([
|
|
14783
|
+
Property(0.5)
|
|
14784
|
+
], Signature.prototype, "minStrokeWidth", void 0);
|
|
14785
|
+
__decorate$7([
|
|
14786
|
+
Property(2)
|
|
14787
|
+
], Signature.prototype, "maxStrokeWidth", void 0);
|
|
14788
|
+
__decorate$7([
|
|
14789
|
+
Property(0.7)
|
|
14790
|
+
], Signature.prototype, "velocity", void 0);
|
|
14791
|
+
__decorate$7([
|
|
14792
|
+
Property('en-US')
|
|
14793
|
+
], Signature.prototype, "locale", void 0);
|
|
14794
|
+
__decorate$7([
|
|
14795
|
+
Property(false)
|
|
14796
|
+
], Signature.prototype, "enableRtl", void 0);
|
|
14797
|
+
__decorate$7([
|
|
14798
|
+
Property(false)
|
|
14799
|
+
], Signature.prototype, "enablePersistence", void 0);
|
|
14800
|
+
__decorate$7([
|
|
14801
|
+
Event()
|
|
14802
|
+
], Signature.prototype, "beforeSave", void 0);
|
|
14803
|
+
__decorate$7([
|
|
14804
|
+
Event()
|
|
14805
|
+
], Signature.prototype, "change", void 0);
|
|
14806
|
+
__decorate$7([
|
|
14807
|
+
Event()
|
|
14808
|
+
], Signature.prototype, "created", void 0);
|
|
14809
|
+
Signature = __decorate$7([
|
|
14810
|
+
NotifyPropertyChanges
|
|
14811
|
+
], Signature);
|
|
14812
|
+
return Signature;
|
|
14813
|
+
}(SignatureBase));
|
|
14814
|
+
|
|
14815
|
+
/**
|
|
14816
|
+
* Signature modules
|
|
14817
|
+
*/
|
|
14818
|
+
|
|
14819
|
+
/**
|
|
14820
|
+
* Signature base modules
|
|
14821
|
+
*/
|
|
14822
|
+
|
|
13680
14823
|
/**
|
|
13681
14824
|
* NumericTextBox all modules
|
|
13682
14825
|
*/
|
|
13683
14826
|
|
|
13684
|
-
export { NumericTextBox, regularExpressions, createMask, applyMask, wireEvents, unwireEvents, bindClearEvent, unstrippedValue, strippedValue, maskInputMouseDownHandler, maskInputMouseUpHandler, maskInputFocusHandler, triggerFocus, maskInputBlurHandler, maskInputDropHandler, mobileRemoveFunction, setMaskValue, setElementValue, maskInput, getVal, getMaskedVal, MaskUndo, MaskedTextBox, Input, TicksData, ColorRangeData, LimitData, TooltipData, Slider, regex, ErrorOption, FormValidator, FilesProp, ButtonsProps, AsyncSettings, Uploader, ColorPicker, TextBox };
|
|
14827
|
+
export { NumericTextBox, regularExpressions, createMask, applyMask, wireEvents, unwireEvents, bindClearEvent, unstrippedValue, strippedValue, maskInputMouseDownHandler, maskInputMouseUpHandler, maskInputFocusHandler, triggerFocus, maskInputBlurHandler, maskInputDropHandler, mobileRemoveFunction, setMaskValue, setElementValue, maskInput, getVal, getMaskedVal, MaskUndo, MaskedTextBox, Input, TicksData, ColorRangeData, LimitData, TooltipData, Slider, regex, ErrorOption, FormValidator, FilesProp, ButtonsProps, AsyncSettings, Uploader, ColorPicker, TextBox, Signature, SignatureBase };
|
|
13685
14828
|
//# sourceMappingURL=ej2-inputs.es5.js.map
|