@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', (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', (event) => {
|
|
@@ -237,7 +237,7 @@ var Input;
|
|
|
237
237
|
addClass([button], CLASSNAMES.CLEARICONHIDE);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
function updateLabelState(value, label) {
|
|
240
|
+
function updateLabelState(value, label, element = null) {
|
|
241
241
|
if (value) {
|
|
242
242
|
addClass([label], CLASSNAMES.LABELTOP);
|
|
243
243
|
if (label.classList.contains(CLASSNAMES.LABELBOTTOM)) {
|
|
@@ -245,10 +245,13 @@ var Input;
|
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
else {
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
const isNotFocused = element != null ? element !== document.activeElement : true;
|
|
249
|
+
if (isNotFocused) {
|
|
250
|
+
if (label.classList.contains(CLASSNAMES.LABELTOP)) {
|
|
251
|
+
removeClass([label], CLASSNAMES.LABELTOP);
|
|
252
|
+
}
|
|
253
|
+
addClass([label], CLASSNAMES.LABELBOTTOM);
|
|
250
254
|
}
|
|
251
|
-
addClass([label], CLASSNAMES.LABELBOTTOM);
|
|
252
255
|
}
|
|
253
256
|
}
|
|
254
257
|
function getParentNode(element) {
|
|
@@ -317,7 +320,7 @@ var Input;
|
|
|
317
320
|
const parent = getParentNode(element);
|
|
318
321
|
if (parent.classList.contains(CLASSNAMES.FLOATINPUT) && floatLabelType === 'Auto') {
|
|
319
322
|
const label = getParentNode(element).getElementsByClassName('e-float-text')[0];
|
|
320
|
-
updateLabelState(element.value, label);
|
|
323
|
+
updateLabelState(element.value, label, element);
|
|
321
324
|
}
|
|
322
325
|
}
|
|
323
326
|
/**
|
|
@@ -1408,6 +1411,10 @@ let NumericTextBox = class NumericTextBox extends Component {
|
|
|
1408
1411
|
}
|
|
1409
1412
|
this.element.setSelectionRange(this.element.selectionStart, this.element.selectionStart);
|
|
1410
1413
|
}
|
|
1414
|
+
if (this.element.value[this.element.selectionStart - 1] === decimalSeparator && this.decimals === 0 && this.validateDecimalOnType) {
|
|
1415
|
+
this.element.value = this.element.value.substring(0, prevPos) +
|
|
1416
|
+
this.element.value.substring(currentPos, this.element.value.length);
|
|
1417
|
+
}
|
|
1411
1418
|
}
|
|
1412
1419
|
this.prevVal = this.element.value;
|
|
1413
1420
|
}
|
|
@@ -1453,8 +1460,13 @@ let NumericTextBox = class NumericTextBox extends Component {
|
|
|
1453
1460
|
this.preventChange = true;
|
|
1454
1461
|
}
|
|
1455
1462
|
if (this.isVue) {
|
|
1456
|
-
|
|
1463
|
+
let current = this.instance.getNumberParser({ format: 'n' })(this.element.value);
|
|
1457
1464
|
const previous = this.instance.getNumberParser({ format: 'n' })(this.elementPrevValue);
|
|
1465
|
+
//EJ2-54963-if type "." or ".0" or "-.0" it converts to "0" automatically when binding v-model
|
|
1466
|
+
const nonZeroRegex = new RegExp('[^1-9]+$');
|
|
1467
|
+
if (nonZeroRegex.test(this.element.value)) {
|
|
1468
|
+
current = this.value;
|
|
1469
|
+
}
|
|
1458
1470
|
const eventArgs = {
|
|
1459
1471
|
event: event,
|
|
1460
1472
|
value: (current === null || isNaN(current) ? null : current),
|
|
@@ -1769,6 +1781,7 @@ let NumericTextBox = class NumericTextBox extends Component {
|
|
|
1769
1781
|
}
|
|
1770
1782
|
}
|
|
1771
1783
|
mouseUpOnSpinner(event) {
|
|
1784
|
+
this.prevValue = this.value;
|
|
1772
1785
|
if (this.isPrevFocused) {
|
|
1773
1786
|
this.element.focus();
|
|
1774
1787
|
if (!Browser.isDevice) {
|
|
@@ -4333,9 +4346,11 @@ let Slider = class Slider extends Component {
|
|
|
4333
4346
|
this.sliderBarClick(e);
|
|
4334
4347
|
if (e.currentTarget === this.firstHandle) {
|
|
4335
4348
|
this.firstHandle.classList.add(classNames.sliderHandleFocused);
|
|
4349
|
+
this.firstHandle.classList.add(classNames.sliderTabHandle);
|
|
4336
4350
|
}
|
|
4337
4351
|
else {
|
|
4338
4352
|
this.secondHandle.classList.add(classNames.sliderHandleFocused);
|
|
4353
|
+
this.secondHandle.classList.add(classNames.sliderTabHandle);
|
|
4339
4354
|
}
|
|
4340
4355
|
EventHandler.add(document, 'mousemove touchmove', this.sliderBarMove, this);
|
|
4341
4356
|
EventHandler.add(document, 'mouseup touchend', this.sliderBarUp, this);
|
|
@@ -4746,6 +4761,11 @@ let Slider = class Slider extends Component {
|
|
|
4746
4761
|
this.getHandle().classList.add('e-large-thumb-size');
|
|
4747
4762
|
}
|
|
4748
4763
|
}
|
|
4764
|
+
focusHandle() {
|
|
4765
|
+
if (!this.getHandle().classList.contains(classNames.sliderTabHandle)) {
|
|
4766
|
+
this.getHandle().classList.add(classNames.sliderTabHandle);
|
|
4767
|
+
}
|
|
4768
|
+
}
|
|
4749
4769
|
repeatHandlerUp(e) {
|
|
4750
4770
|
this.changeEvent('changed', e);
|
|
4751
4771
|
this.closeTooltip();
|
|
@@ -5136,6 +5156,7 @@ let Slider = class Slider extends Component {
|
|
|
5136
5156
|
}
|
|
5137
5157
|
this.tooltipToggle(this.getHandle());
|
|
5138
5158
|
this.getHandle().focus();
|
|
5159
|
+
this.focusHandle();
|
|
5139
5160
|
if (args.currentTarget.classList.contains(classNames.firstButton)) {
|
|
5140
5161
|
EventHandler.add(this.firstBtn, 'mouseup touchend', this.buttonUp, this);
|
|
5141
5162
|
}
|
|
@@ -6076,6 +6097,7 @@ let Slider = class Slider extends Component {
|
|
|
6076
6097
|
event.preventDefault();
|
|
6077
6098
|
this.focusSliderElement();
|
|
6078
6099
|
this.sliderBarClick(event);
|
|
6100
|
+
this.focusHandle();
|
|
6079
6101
|
}
|
|
6080
6102
|
wireEvents() {
|
|
6081
6103
|
this.onresize = this.reposition.bind(this);
|
|
@@ -13398,9 +13420,1095 @@ TextBox = __decorate$6([
|
|
|
13398
13420
|
* Uploader modules
|
|
13399
13421
|
*/
|
|
13400
13422
|
|
|
13423
|
+
class SignatureBase extends Component {
|
|
13424
|
+
constructor() {
|
|
13425
|
+
super(...arguments);
|
|
13426
|
+
/* minDistance(distance between the two point) was calaculated for smoothness.*/
|
|
13427
|
+
this.minDistance = 5;
|
|
13428
|
+
this.previous = 0;
|
|
13429
|
+
/* interval handles for the smoothness in the mouse move event.*/
|
|
13430
|
+
this.interval = 30;
|
|
13431
|
+
this.timeout = null;
|
|
13432
|
+
this.isSignatureEmpty = true;
|
|
13433
|
+
this.backgroundLoaded = null;
|
|
13434
|
+
this.clearArray = [];
|
|
13435
|
+
this.isBlazor = false;
|
|
13436
|
+
}
|
|
13437
|
+
/**
|
|
13438
|
+
* To Initialize the component rendering
|
|
13439
|
+
*
|
|
13440
|
+
* @private
|
|
13441
|
+
* @param {HTMLCanvasElement} element - Specifies the canvas element.
|
|
13442
|
+
* @param {parameter} parameter - Specifies only for the blazor parameter.
|
|
13443
|
+
* @param {BlazorDotnetObject} dotnetRef - Specifies for blazor client to server communication.
|
|
13444
|
+
* @returns {void}
|
|
13445
|
+
*/
|
|
13446
|
+
initialize(element, parameter, dotnetRef) {
|
|
13447
|
+
this.element = element;
|
|
13448
|
+
this.canvasContext = this.element.getContext('2d');
|
|
13449
|
+
this.canvasContext.canvas.tabIndex = 0;
|
|
13450
|
+
if (parameter) {
|
|
13451
|
+
this.setBlazorParameter(parameter);
|
|
13452
|
+
this.dotnetRef = dotnetRef;
|
|
13453
|
+
}
|
|
13454
|
+
this.setHTMLProperties();
|
|
13455
|
+
if (isNullOrUndefined(this.signatureValue)) {
|
|
13456
|
+
this.updateSnapCollection(true);
|
|
13457
|
+
}
|
|
13458
|
+
this.wireEvents();
|
|
13459
|
+
this.isSignatureEmpty = true;
|
|
13460
|
+
if (!this.isBlazor) {
|
|
13461
|
+
this.trigger('created', null);
|
|
13462
|
+
}
|
|
13463
|
+
}
|
|
13464
|
+
setBlazorParameter(parameter) {
|
|
13465
|
+
this.isBlazor = true;
|
|
13466
|
+
this.backgroundColor = parameter.backgroundColor;
|
|
13467
|
+
this.backgroundImage = parameter.backgroundImage;
|
|
13468
|
+
this.disabled = parameter.disabled;
|
|
13469
|
+
this.isReadOnly = parameter.isReadOnly;
|
|
13470
|
+
this.maxStrokeWidth = parameter.maxStrokeWidth || 2;
|
|
13471
|
+
this.minStrokeWidth = parameter.minStrokeWidth || 0.5;
|
|
13472
|
+
this.velocity = parameter.velocity || 0.7;
|
|
13473
|
+
this.strokeColor = parameter.strokeColor || '#000000';
|
|
13474
|
+
this.saveWithBackground = parameter.saveWithBackground;
|
|
13475
|
+
this.interval = 30;
|
|
13476
|
+
this.previous = 0;
|
|
13477
|
+
this.minDistance = 5;
|
|
13478
|
+
this.signatureValue = parameter.signatureValue;
|
|
13479
|
+
if (this.signatureValue) {
|
|
13480
|
+
this.loadPersistedSignature();
|
|
13481
|
+
}
|
|
13482
|
+
}
|
|
13483
|
+
wireEvents() {
|
|
13484
|
+
if (isNullOrUndefined(this.pointColl) && !this.isReadOnly && !this.disabled) {
|
|
13485
|
+
EventHandler.add(this.canvasContext.canvas, 'mousedown touchstart', this.mouseDownHandler, this);
|
|
13486
|
+
EventHandler.add(this.canvasContext.canvas, 'keydown', this.keyboardHandler, this);
|
|
13487
|
+
window.addEventListener('resize', this.resizeHandler.bind(this));
|
|
13488
|
+
}
|
|
13489
|
+
else if (this.pointColl) {
|
|
13490
|
+
EventHandler.add(this.canvasContext.canvas, 'mousemove touchmove', this.mouseMoveHandler, this);
|
|
13491
|
+
EventHandler.add(this.canvasContext.canvas, 'mouseup touchend', this.mouseUpHandler, this);
|
|
13492
|
+
EventHandler.add(document, 'mouseup', this.mouseUpHandler, this);
|
|
13493
|
+
}
|
|
13494
|
+
}
|
|
13495
|
+
unwireEvents(type) {
|
|
13496
|
+
if (type === 'mouseup' || type === 'touchend') {
|
|
13497
|
+
EventHandler.remove(this.canvasContext.canvas, 'mousemove touchmove', this.mouseMoveHandler);
|
|
13498
|
+
EventHandler.remove(this.canvasContext.canvas, 'mouseup touchend', this.mouseUpHandler);
|
|
13499
|
+
EventHandler.remove(document, 'mouseup', this.mouseUpHandler);
|
|
13500
|
+
}
|
|
13501
|
+
else {
|
|
13502
|
+
EventHandler.remove(this.canvasContext.canvas, 'mousedown touchstart', this.mouseDownHandler);
|
|
13503
|
+
EventHandler.remove(this.canvasContext.canvas, 'mousemove touchmove', this.mouseMoveHandler);
|
|
13504
|
+
EventHandler.remove(this.canvasContext.canvas, 'mouseup touchend', this.mouseUpHandler);
|
|
13505
|
+
EventHandler.remove(document, 'mouseup', this.mouseUpHandler);
|
|
13506
|
+
EventHandler.remove(this.canvasContext.canvas, 'keydown', this.keyboardHandler);
|
|
13507
|
+
window.removeEventListener('resize', this.resizeHandler);
|
|
13508
|
+
}
|
|
13509
|
+
}
|
|
13510
|
+
setHTMLProperties() {
|
|
13511
|
+
if (this.element.height === 150) {
|
|
13512
|
+
this.element.height = this.element.offsetHeight;
|
|
13513
|
+
}
|
|
13514
|
+
if (this.element.width === 300) {
|
|
13515
|
+
this.element.width = this.element.offsetWidth;
|
|
13516
|
+
}
|
|
13517
|
+
this.canvasContext.scale(1, 1);
|
|
13518
|
+
this.canvasContext.fillStyle = this.strokeColor;
|
|
13519
|
+
if (this.backgroundImage) {
|
|
13520
|
+
this.canvasContext.canvas.style.backgroundImage = 'url(' + this.backgroundImage + ')';
|
|
13521
|
+
}
|
|
13522
|
+
else if (this.backgroundColor) {
|
|
13523
|
+
this.canvasContext.canvas.style.backgroundColor = this.backgroundColor;
|
|
13524
|
+
}
|
|
13525
|
+
}
|
|
13526
|
+
mouseDownHandler(e) {
|
|
13527
|
+
if (e.buttons === 1 || e.buttons === 2 || e.type === 'touchstart') {
|
|
13528
|
+
if (e.type === 'touchstart') {
|
|
13529
|
+
e.preventDefault();
|
|
13530
|
+
e.stopPropagation();
|
|
13531
|
+
}
|
|
13532
|
+
this.beginStroke(e);
|
|
13533
|
+
this.wireEvents();
|
|
13534
|
+
}
|
|
13535
|
+
}
|
|
13536
|
+
mouseMoveHandler(e) {
|
|
13537
|
+
if (e.buttons === 1 || e.buttons === 2 || e.type === 'touchmove') {
|
|
13538
|
+
if (e.type === 'touchmove') {
|
|
13539
|
+
e.preventDefault();
|
|
13540
|
+
e.stopPropagation();
|
|
13541
|
+
}
|
|
13542
|
+
if (this.interval) {
|
|
13543
|
+
this.updateStrokeWithThrottle(e);
|
|
13544
|
+
}
|
|
13545
|
+
else {
|
|
13546
|
+
this.updateStroke(e);
|
|
13547
|
+
}
|
|
13548
|
+
}
|
|
13549
|
+
}
|
|
13550
|
+
mouseUpHandler(e) {
|
|
13551
|
+
const args = { actionName: 'strokeUpdate' };
|
|
13552
|
+
if (e.type === 'touchstart') {
|
|
13553
|
+
e.preventDefault();
|
|
13554
|
+
e.stopPropagation();
|
|
13555
|
+
}
|
|
13556
|
+
this.endDraw();
|
|
13557
|
+
this.updateSnapCollection();
|
|
13558
|
+
this.unwireEvents(e.type);
|
|
13559
|
+
if (!this.isBlazor) {
|
|
13560
|
+
this.trigger('change', args);
|
|
13561
|
+
}
|
|
13562
|
+
else {
|
|
13563
|
+
this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'mouseUp');
|
|
13564
|
+
}
|
|
13565
|
+
this.signatureValue = this.snapColl[this.incStep];
|
|
13566
|
+
}
|
|
13567
|
+
keyboardHandler(e) {
|
|
13568
|
+
const args = { fileName: 'Signature', type: 'Png', cancel: false };
|
|
13569
|
+
switch (e.key) {
|
|
13570
|
+
case 'Delete':
|
|
13571
|
+
this.clear();
|
|
13572
|
+
break;
|
|
13573
|
+
case (e.ctrlKey && 's'):
|
|
13574
|
+
if (!this.isBlazor) {
|
|
13575
|
+
this.trigger('beforeSave', args, (observableSaveArgs) => {
|
|
13576
|
+
if (!args.cancel) {
|
|
13577
|
+
this.save(observableSaveArgs.type, observableSaveArgs.fileName);
|
|
13578
|
+
}
|
|
13579
|
+
});
|
|
13580
|
+
}
|
|
13581
|
+
else {
|
|
13582
|
+
this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'beforeSave');
|
|
13583
|
+
}
|
|
13584
|
+
e.preventDefault();
|
|
13585
|
+
e.stopImmediatePropagation();
|
|
13586
|
+
break;
|
|
13587
|
+
case (e.ctrlKey && 'z'):
|
|
13588
|
+
this.undo();
|
|
13589
|
+
break;
|
|
13590
|
+
case (e.ctrlKey && 'y'):
|
|
13591
|
+
this.redo();
|
|
13592
|
+
break;
|
|
13593
|
+
}
|
|
13594
|
+
}
|
|
13595
|
+
resizeHandler() {
|
|
13596
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
13597
|
+
const proxy = this;
|
|
13598
|
+
this.canvasContext.canvas.width = this.element.offsetWidth;
|
|
13599
|
+
this.canvasContext.canvas.height = this.element.offsetHeight;
|
|
13600
|
+
this.canvasContext.scale(1, 1);
|
|
13601
|
+
const restoreImg = new Image();
|
|
13602
|
+
restoreImg.src = this.snapColl[this.incStep];
|
|
13603
|
+
restoreImg.onload = () => {
|
|
13604
|
+
proxy.canvasContext.clearRect(0, 0, proxy.element.width, proxy.element.height);
|
|
13605
|
+
proxy.canvasContext.drawImage(restoreImg, 0, 0, proxy.element.width, proxy.element.height);
|
|
13606
|
+
};
|
|
13607
|
+
}
|
|
13608
|
+
beginStroke(e) {
|
|
13609
|
+
this.refresh();
|
|
13610
|
+
this.updateStroke(e);
|
|
13611
|
+
}
|
|
13612
|
+
updateStroke(e) {
|
|
13613
|
+
const point = this.createPoint(e);
|
|
13614
|
+
this.addPoint(point);
|
|
13615
|
+
}
|
|
13616
|
+
updateStrokeWithThrottle(args) {
|
|
13617
|
+
const now = Date.now();
|
|
13618
|
+
const remaining = this.interval - (now - this.previous);
|
|
13619
|
+
this.storedArgs = args;
|
|
13620
|
+
if (remaining <= 0 || remaining > this.interval) {
|
|
13621
|
+
if (this.timeout) {
|
|
13622
|
+
clearTimeout(this.timeout);
|
|
13623
|
+
this.timeout = null;
|
|
13624
|
+
}
|
|
13625
|
+
this.previous = now;
|
|
13626
|
+
this.updateStroke(this.storedArgs);
|
|
13627
|
+
if (!this.timeout) {
|
|
13628
|
+
this.storedArgs = null;
|
|
13629
|
+
}
|
|
13630
|
+
}
|
|
13631
|
+
else if (!this.timeout) {
|
|
13632
|
+
this.timeout = window.setTimeout(this.delay.bind(this), remaining);
|
|
13633
|
+
}
|
|
13634
|
+
}
|
|
13635
|
+
delay() {
|
|
13636
|
+
this.previous = Date.now();
|
|
13637
|
+
this.timeout = null;
|
|
13638
|
+
this.updateStroke(this.storedArgs);
|
|
13639
|
+
if (!this.timeout) {
|
|
13640
|
+
this.storedArgs = null;
|
|
13641
|
+
}
|
|
13642
|
+
}
|
|
13643
|
+
createPoint(e) {
|
|
13644
|
+
const rect = this.canvasContext.canvas.getBoundingClientRect();
|
|
13645
|
+
if (e.type === 'mousedown' || e.type === 'mousemove') {
|
|
13646
|
+
return this.point(e.clientX - rect.left, e.clientY - rect.top, new Date().getTime());
|
|
13647
|
+
}
|
|
13648
|
+
else {
|
|
13649
|
+
return this.point(e.touches[0].clientX - rect.left, e.touches[0].clientY - rect.top, new Date().getTime());
|
|
13650
|
+
}
|
|
13651
|
+
}
|
|
13652
|
+
/* Returns the current point corrdinates(x, y) and time.*/
|
|
13653
|
+
point(pointX, pointY, time) {
|
|
13654
|
+
this.pointX = pointX;
|
|
13655
|
+
this.pointY = pointY;
|
|
13656
|
+
this.time = time || new Date().getTime();
|
|
13657
|
+
return { x: this.pointX, y: this.pointY, time: this.time };
|
|
13658
|
+
}
|
|
13659
|
+
addPoint(point) {
|
|
13660
|
+
const points = this.pointColl;
|
|
13661
|
+
let controlPoint1;
|
|
13662
|
+
let controlPoint2;
|
|
13663
|
+
const lastPoint = points.length > 0 && points[points.length - 1];
|
|
13664
|
+
const isLastPointTooClose = lastPoint ? this.distanceTo(lastPoint) <= this.minDistance : false;
|
|
13665
|
+
if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
|
|
13666
|
+
points.push(point);
|
|
13667
|
+
if (points.length > 2) {
|
|
13668
|
+
if (points.length === 3) {
|
|
13669
|
+
points.unshift(points[0]);
|
|
13670
|
+
}
|
|
13671
|
+
controlPoint1 = (this.calculateCurveControlPoints(points[0], points[1], points[2])).controlPoint2;
|
|
13672
|
+
controlPoint2 = (this.calculateCurveControlPoints(points[1], points[2], points[3])).controlPoint1;
|
|
13673
|
+
this.startPoint = points[1];
|
|
13674
|
+
this.controlPoint1 = controlPoint1;
|
|
13675
|
+
this.controlPoint2 = controlPoint2;
|
|
13676
|
+
this.endPoint = points[2];
|
|
13677
|
+
this.startDraw();
|
|
13678
|
+
points.shift();
|
|
13679
|
+
}
|
|
13680
|
+
}
|
|
13681
|
+
}
|
|
13682
|
+
startDraw() {
|
|
13683
|
+
let velocity;
|
|
13684
|
+
velocity = this.pointVelocityCalc(this.startPoint);
|
|
13685
|
+
velocity = this.velocity * velocity + (1 - this.velocity) * this.lastVelocity;
|
|
13686
|
+
const newWidth = Math.max(this.maxStrokeWidth / (velocity + 1), this.minStrokeWidth);
|
|
13687
|
+
this.curveDraw(this.lastWidth, newWidth);
|
|
13688
|
+
this.lastVelocity = velocity;
|
|
13689
|
+
this.lastWidth = newWidth;
|
|
13690
|
+
}
|
|
13691
|
+
endDraw() {
|
|
13692
|
+
const canDrawCurve = this.pointColl.length > 2;
|
|
13693
|
+
const point = this.pointColl[0];
|
|
13694
|
+
if (!canDrawCurve && point) {
|
|
13695
|
+
this.strokeDraw(point);
|
|
13696
|
+
}
|
|
13697
|
+
}
|
|
13698
|
+
/* Calculate the Bezier (x, y) coordinate of the curve. */
|
|
13699
|
+
curveDraw(startWidth, endWidth) {
|
|
13700
|
+
const context = this.canvasContext;
|
|
13701
|
+
let width;
|
|
13702
|
+
let i;
|
|
13703
|
+
let t1;
|
|
13704
|
+
let t2;
|
|
13705
|
+
let t3;
|
|
13706
|
+
let u1;
|
|
13707
|
+
let u2;
|
|
13708
|
+
let u3;
|
|
13709
|
+
let x;
|
|
13710
|
+
let y;
|
|
13711
|
+
const widthValue = endWidth - startWidth;
|
|
13712
|
+
const bezierLength = this.bezierLengthCalc();
|
|
13713
|
+
const drawSteps = Math.ceil(bezierLength) * 2;
|
|
13714
|
+
context.beginPath();
|
|
13715
|
+
for (i = 0; i < drawSteps; i++) {
|
|
13716
|
+
t1 = i / drawSteps;
|
|
13717
|
+
t2 = t1 * t1;
|
|
13718
|
+
t3 = t2 * t1;
|
|
13719
|
+
u1 = 1 - t1;
|
|
13720
|
+
u2 = u1 * u1;
|
|
13721
|
+
u3 = u2 * u1;
|
|
13722
|
+
x = u3 * this.startPoint.x;
|
|
13723
|
+
x += 3 * u2 * t1 * this.controlPoint1.x;
|
|
13724
|
+
x += 3 * u1 * t2 * this.controlPoint2.x;
|
|
13725
|
+
x += t3 * this.endPoint.x;
|
|
13726
|
+
y = u3 * this.startPoint.y;
|
|
13727
|
+
y += 3 * u2 * t1 * this.controlPoint1.y;
|
|
13728
|
+
y += 3 * u1 * t2 * this.controlPoint2.y;
|
|
13729
|
+
y += t3 * this.endPoint.y;
|
|
13730
|
+
width = Math.min(startWidth + t3 * widthValue, this.maxStrokeWidth);
|
|
13731
|
+
this.arcDraw(x, y, width);
|
|
13732
|
+
}
|
|
13733
|
+
context.closePath();
|
|
13734
|
+
context.fill();
|
|
13735
|
+
this.isSignatureEmpty = false;
|
|
13736
|
+
}
|
|
13737
|
+
strokeDraw(point) {
|
|
13738
|
+
const context = this.canvasContext;
|
|
13739
|
+
const pointSize = (this.minStrokeWidth + this.maxStrokeWidth) / 2;
|
|
13740
|
+
context.beginPath();
|
|
13741
|
+
this.arcDraw(point.x, point.y, pointSize);
|
|
13742
|
+
context.closePath();
|
|
13743
|
+
context.fill();
|
|
13744
|
+
this.isSignatureEmpty = false;
|
|
13745
|
+
}
|
|
13746
|
+
arcDraw(x, y, size) {
|
|
13747
|
+
const context = this.canvasContext;
|
|
13748
|
+
context.moveTo(x, y);
|
|
13749
|
+
context.arc(x, y, size, 0, 2 * Math.PI, false);
|
|
13750
|
+
}
|
|
13751
|
+
/* Utility functions for Bezier algorithm*/
|
|
13752
|
+
calculateCurveControlPoints(p1, p2, p3) {
|
|
13753
|
+
const dx1 = p1.x - p2.x;
|
|
13754
|
+
const dy1 = p1.y - p2.y;
|
|
13755
|
+
const dx2 = p2.x - p3.x;
|
|
13756
|
+
const dy2 = p2.y - p3.y;
|
|
13757
|
+
const m1 = { x: (p1.x + p2.x) / 2.0, y: (p1.y + p2.y) / 2.0 };
|
|
13758
|
+
const m2 = { x: (p2.x + p3.x) / 2.0, y: (p2.y + p3.y) / 2.0 };
|
|
13759
|
+
const l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
|
|
13760
|
+
const l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
|
|
13761
|
+
const dxm = (m1.x - m2.x);
|
|
13762
|
+
const dym = (m1.y - m2.y);
|
|
13763
|
+
const k = l2 / (l1 + l2);
|
|
13764
|
+
const cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
|
|
13765
|
+
const tx = p2.x - cm.x;
|
|
13766
|
+
const ty = p2.y - cm.y;
|
|
13767
|
+
return {
|
|
13768
|
+
controlPoint1: this.point(m1.x + tx, m1.y + ty, 0),
|
|
13769
|
+
controlPoint2: this.point(m2.x + tx, m2.y + ty, 0)
|
|
13770
|
+
};
|
|
13771
|
+
}
|
|
13772
|
+
/* Returns approximated bezier length of the curuve.*/
|
|
13773
|
+
bezierLengthCalc() {
|
|
13774
|
+
const steps = 10;
|
|
13775
|
+
let length = 0;
|
|
13776
|
+
let i;
|
|
13777
|
+
let t;
|
|
13778
|
+
let pointx1;
|
|
13779
|
+
let pointy1;
|
|
13780
|
+
let pointx2;
|
|
13781
|
+
let pointy2;
|
|
13782
|
+
let pointx3;
|
|
13783
|
+
let pointy3;
|
|
13784
|
+
for (i = 0; i <= steps; i++) {
|
|
13785
|
+
t = i / steps;
|
|
13786
|
+
pointx1 = this.bezierPointCalc(t, this.startPoint.x, this.controlPoint1.x, this.controlPoint2.x, this.endPoint.x);
|
|
13787
|
+
pointy1 = this.bezierPointCalc(t, this.startPoint.y, this.controlPoint1.y, this.controlPoint2.y, this.endPoint.y);
|
|
13788
|
+
if (i > 0) {
|
|
13789
|
+
pointx3 = pointx1 - pointx2;
|
|
13790
|
+
pointy3 = pointy1 - pointy2;
|
|
13791
|
+
length += Math.sqrt(pointx3 * pointx3 + pointy3 * pointy3);
|
|
13792
|
+
}
|
|
13793
|
+
pointx2 = pointx1;
|
|
13794
|
+
pointy2 = pointy1;
|
|
13795
|
+
}
|
|
13796
|
+
return length;
|
|
13797
|
+
}
|
|
13798
|
+
/* Calculate parametric value of x or y given t and the
|
|
13799
|
+
four point(startpoint, controlpoint1, controlpoint2, endpoint) coordinates of a cubic bezier curve.*/
|
|
13800
|
+
bezierPointCalc(t, startpoint, cp1, cp2, endpoint) {
|
|
13801
|
+
return startpoint * (1.0 - t) * (1.0 - t) * (1.0 - t) + 3.0 * cp1 * (1.0 - t) * (1.0 - t) * t + 3.0 *
|
|
13802
|
+
cp2 * (1.0 - t) * t * t + endpoint * t * t * t;
|
|
13803
|
+
}
|
|
13804
|
+
/* Velocity between the current point and last point.*/
|
|
13805
|
+
pointVelocityCalc(startPoint) {
|
|
13806
|
+
return (this.time !== startPoint.time) ? this.distanceTo(startPoint) / (this.time - startPoint.time) : 0;
|
|
13807
|
+
}
|
|
13808
|
+
/* Distance between the current point and last point.*/
|
|
13809
|
+
distanceTo(start) {
|
|
13810
|
+
return Math.sqrt(Math.pow(this.pointX - start.x, 2) + Math.pow(this.pointY - start.y, 2));
|
|
13811
|
+
}
|
|
13812
|
+
isRead(isRead) {
|
|
13813
|
+
if (isRead) {
|
|
13814
|
+
EventHandler.remove(this.canvasContext.canvas, 'mousedown touchstart', this.mouseDownHandler);
|
|
13815
|
+
}
|
|
13816
|
+
else if (!this.disabled) {
|
|
13817
|
+
EventHandler.add(this.canvasContext.canvas, 'mousedown touchstart', this.mouseDownHandler, this);
|
|
13818
|
+
}
|
|
13819
|
+
}
|
|
13820
|
+
enableOrDisable(isDisable) {
|
|
13821
|
+
this.disabled = isDisable;
|
|
13822
|
+
if (isDisable) {
|
|
13823
|
+
this.reDraw('0.5');
|
|
13824
|
+
this.isRead(true);
|
|
13825
|
+
}
|
|
13826
|
+
else {
|
|
13827
|
+
this.reDraw('1');
|
|
13828
|
+
this.isRead(false);
|
|
13829
|
+
}
|
|
13830
|
+
}
|
|
13831
|
+
reDraw(opacity) {
|
|
13832
|
+
const data = this.canvasContext.getImageData(0, 0, this.element.width, this.element.height);
|
|
13833
|
+
this.canvasContext.clearRect(0, 0, this.element.width, this.element.height);
|
|
13834
|
+
this.element.style.opacity = opacity;
|
|
13835
|
+
this.canvasContext.putImageData(data, 0, 0);
|
|
13836
|
+
}
|
|
13837
|
+
updateSnapCollection(isClear) {
|
|
13838
|
+
if (isNullOrUndefined(this.incStep)) {
|
|
13839
|
+
this.incStep = -1;
|
|
13840
|
+
this.incStep++;
|
|
13841
|
+
this.snapColl = [];
|
|
13842
|
+
this.clearArray = [];
|
|
13843
|
+
}
|
|
13844
|
+
else {
|
|
13845
|
+
this.incStep++;
|
|
13846
|
+
}
|
|
13847
|
+
if (this.incStep < this.snapColl.length) {
|
|
13848
|
+
this.snapColl.length = this.incStep;
|
|
13849
|
+
}
|
|
13850
|
+
if (this.incStep > 0) {
|
|
13851
|
+
const canvasNew = this.createElement('canvas', { className: 'e-' + this.getModuleName() + '-wrapper' });
|
|
13852
|
+
const canvasContextNew = canvasNew.getContext('2d');
|
|
13853
|
+
canvasNew.width = this.canvasContext.canvas.width;
|
|
13854
|
+
canvasNew.height = this.canvasContext.canvas.height;
|
|
13855
|
+
canvasContextNew.drawImage(this.canvasContext.canvas, 0, 0, canvasNew.width, canvasNew.height);
|
|
13856
|
+
this.snapColl.push(canvasNew.toDataURL());
|
|
13857
|
+
}
|
|
13858
|
+
else {
|
|
13859
|
+
this.snapColl.push(this.canvasContext.canvas.toDataURL());
|
|
13860
|
+
}
|
|
13861
|
+
if (isClear) {
|
|
13862
|
+
this.clearArray.push(this.incStep);
|
|
13863
|
+
}
|
|
13864
|
+
}
|
|
13865
|
+
setBackgroundImage(imageSrc) {
|
|
13866
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
13867
|
+
const proxy = this;
|
|
13868
|
+
const imageObj = new Image();
|
|
13869
|
+
imageObj.crossOrigin = 'anonymous';
|
|
13870
|
+
imageObj.src = imageSrc;
|
|
13871
|
+
imageObj.onload = () => {
|
|
13872
|
+
proxy.canvasContext.globalCompositeOperation = 'source-over';
|
|
13873
|
+
proxy.canvasContext.drawImage(imageObj, 0, 0, proxy.element.width, proxy.element.height);
|
|
13874
|
+
proxy.updateSnapCollection();
|
|
13875
|
+
proxy.saveBackground(true);
|
|
13876
|
+
};
|
|
13877
|
+
this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
13878
|
+
}
|
|
13879
|
+
setBackgroundColor(color) {
|
|
13880
|
+
const canvasEle = this.canvasContext;
|
|
13881
|
+
canvasEle.strokeStyle = color;
|
|
13882
|
+
let i;
|
|
13883
|
+
let j;
|
|
13884
|
+
for (i = 1; i <= canvasEle.canvas.width; i++) {
|
|
13885
|
+
for (j = 1; j <= canvasEle.canvas.height; j++) {
|
|
13886
|
+
canvasEle.strokeRect(0, 0, i, j);
|
|
13887
|
+
}
|
|
13888
|
+
}
|
|
13889
|
+
this.updateSnapCollection();
|
|
13890
|
+
}
|
|
13891
|
+
loadPersistedSignature() {
|
|
13892
|
+
if (isNullOrUndefined(this.signatureValue)) {
|
|
13893
|
+
return;
|
|
13894
|
+
}
|
|
13895
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
13896
|
+
const proxy = this;
|
|
13897
|
+
const lastImage = new Image();
|
|
13898
|
+
lastImage.src = this.signatureValue;
|
|
13899
|
+
lastImage.onload = () => {
|
|
13900
|
+
proxy.canvasContext.clearRect(0, 0, proxy.element.width, proxy.element.height);
|
|
13901
|
+
proxy.canvasContext.drawImage(lastImage, 0, 0);
|
|
13902
|
+
proxy.updateSnapCollection();
|
|
13903
|
+
};
|
|
13904
|
+
this.isSignatureEmpty = false;
|
|
13905
|
+
}
|
|
13906
|
+
/**
|
|
13907
|
+
* To get the signature as Blob.
|
|
13908
|
+
*
|
|
13909
|
+
* @param {string} url - specify the url/base 64 string to get blob of the signature.
|
|
13910
|
+
* @returns {Blob}.
|
|
13911
|
+
*/
|
|
13912
|
+
getBlob(url) {
|
|
13913
|
+
const arr = url.split(',');
|
|
13914
|
+
const type = arr[0].match(/:(.*?);/)[1];
|
|
13915
|
+
const bstr = atob(arr[1]);
|
|
13916
|
+
let n = bstr.length;
|
|
13917
|
+
const u8arr = new Uint8Array(n);
|
|
13918
|
+
while (n--) {
|
|
13919
|
+
u8arr[n] = bstr.charCodeAt(n);
|
|
13920
|
+
}
|
|
13921
|
+
return new Blob([u8arr], { type: type });
|
|
13922
|
+
}
|
|
13923
|
+
download(blob, fileName) {
|
|
13924
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
13925
|
+
const a = document.createElement('a');
|
|
13926
|
+
a.href = blobUrl;
|
|
13927
|
+
a.target = '_parent';
|
|
13928
|
+
a.download = fileName;
|
|
13929
|
+
(document.body || document.documentElement).appendChild(a);
|
|
13930
|
+
a.click();
|
|
13931
|
+
a.parentNode.removeChild(a);
|
|
13932
|
+
}
|
|
13933
|
+
/**
|
|
13934
|
+
* To refresh the signature.
|
|
13935
|
+
*
|
|
13936
|
+
* @private
|
|
13937
|
+
* @returns {void}.
|
|
13938
|
+
*/
|
|
13939
|
+
refresh() {
|
|
13940
|
+
this.pointColl = [];
|
|
13941
|
+
this.lastVelocity = 0;
|
|
13942
|
+
this.lastWidth = (this.minStrokeWidth + this.maxStrokeWidth) / 2;
|
|
13943
|
+
}
|
|
13944
|
+
/**
|
|
13945
|
+
* Erases all the signature strokes signed by user.
|
|
13946
|
+
*
|
|
13947
|
+
* @returns {void}.
|
|
13948
|
+
*/
|
|
13949
|
+
clear() {
|
|
13950
|
+
const args = { actionName: 'clear' };
|
|
13951
|
+
this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
13952
|
+
this.refresh();
|
|
13953
|
+
this.updateSnapCollection(true);
|
|
13954
|
+
this.isSignatureEmpty = true;
|
|
13955
|
+
if (!this.isBlazor) {
|
|
13956
|
+
this.trigger('change', args);
|
|
13957
|
+
}
|
|
13958
|
+
else {
|
|
13959
|
+
this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'Clear');
|
|
13960
|
+
}
|
|
13961
|
+
}
|
|
13962
|
+
/**
|
|
13963
|
+
* Undo the last user action.
|
|
13964
|
+
*
|
|
13965
|
+
* @returns {void}.
|
|
13966
|
+
*/
|
|
13967
|
+
undo() {
|
|
13968
|
+
const args = { actionName: 'undo' };
|
|
13969
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
13970
|
+
const proxy = this;
|
|
13971
|
+
if (this.incStep > 0) {
|
|
13972
|
+
this.incStep--;
|
|
13973
|
+
const undoImg = new Image();
|
|
13974
|
+
undoImg.src = this.snapColl[this.incStep];
|
|
13975
|
+
undoImg.onload = () => {
|
|
13976
|
+
proxy.canvasContext.clearRect(0, 0, proxy.element.width, proxy.element.height);
|
|
13977
|
+
proxy.canvasContext.drawImage(undoImg, 0, 0, proxy.element.width, proxy.element.height);
|
|
13978
|
+
};
|
|
13979
|
+
}
|
|
13980
|
+
this.isClear();
|
|
13981
|
+
if (!this.isBlazor) {
|
|
13982
|
+
this.trigger('change', args);
|
|
13983
|
+
}
|
|
13984
|
+
else {
|
|
13985
|
+
this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'Undo');
|
|
13986
|
+
}
|
|
13987
|
+
}
|
|
13988
|
+
/**
|
|
13989
|
+
* Redo the last user action.
|
|
13990
|
+
*
|
|
13991
|
+
* @returns {void}.
|
|
13992
|
+
*/
|
|
13993
|
+
redo() {
|
|
13994
|
+
const args = { actionName: 'redo' };
|
|
13995
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
13996
|
+
const proxy = this;
|
|
13997
|
+
if (this.incStep < this.snapColl.length - 1) {
|
|
13998
|
+
this.incStep++;
|
|
13999
|
+
const redoImg = new Image();
|
|
14000
|
+
redoImg.src = this.snapColl[this.incStep];
|
|
14001
|
+
redoImg.onload = () => {
|
|
14002
|
+
proxy.canvasContext.clearRect(0, 0, proxy.element.width, proxy.element.height);
|
|
14003
|
+
proxy.canvasContext.drawImage(redoImg, 0, 0, proxy.element.width, proxy.element.height);
|
|
14004
|
+
};
|
|
14005
|
+
}
|
|
14006
|
+
this.isClear();
|
|
14007
|
+
if (!this.isBlazor) {
|
|
14008
|
+
this.trigger('change', args);
|
|
14009
|
+
}
|
|
14010
|
+
else {
|
|
14011
|
+
this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'Redo');
|
|
14012
|
+
}
|
|
14013
|
+
}
|
|
14014
|
+
isClear() {
|
|
14015
|
+
if (this.clearArray) {
|
|
14016
|
+
let empty = false;
|
|
14017
|
+
for (let i = 0; i < this.clearArray.length; i++) {
|
|
14018
|
+
if (this.clearArray[i] === this.incStep) {
|
|
14019
|
+
this.isSignatureEmpty = true;
|
|
14020
|
+
empty = true;
|
|
14021
|
+
}
|
|
14022
|
+
}
|
|
14023
|
+
if (!empty) {
|
|
14024
|
+
this.isSignatureEmpty = false;
|
|
14025
|
+
}
|
|
14026
|
+
}
|
|
14027
|
+
}
|
|
14028
|
+
/**
|
|
14029
|
+
* To check whether the signature is empty or not.
|
|
14030
|
+
*
|
|
14031
|
+
* @returns {boolean}.
|
|
14032
|
+
*/
|
|
14033
|
+
isEmpty() {
|
|
14034
|
+
return this.isSignatureEmpty;
|
|
14035
|
+
}
|
|
14036
|
+
/**
|
|
14037
|
+
* To check whether the undo collection is empty or not.
|
|
14038
|
+
*
|
|
14039
|
+
* @returns {boolean}.
|
|
14040
|
+
*/
|
|
14041
|
+
canUndo() {
|
|
14042
|
+
return this.incStep > 0;
|
|
14043
|
+
}
|
|
14044
|
+
/**
|
|
14045
|
+
* To check whether the redo collection is empty or not.
|
|
14046
|
+
*
|
|
14047
|
+
* @returns {boolean}.
|
|
14048
|
+
*/
|
|
14049
|
+
canRedo() {
|
|
14050
|
+
return this.incStep < this.snapColl.length - 1;
|
|
14051
|
+
}
|
|
14052
|
+
/**
|
|
14053
|
+
* To draw the signature based on the given text, with the font family and font size.
|
|
14054
|
+
*
|
|
14055
|
+
* @param {string} text - specify text to be drawn as signature.
|
|
14056
|
+
* @param {string} fontFamily - specify font family of a signature.
|
|
14057
|
+
* @param {number} fontSize - specify font size of a signature.
|
|
14058
|
+
*
|
|
14059
|
+
* @returns {void}.
|
|
14060
|
+
*/
|
|
14061
|
+
draw(text, fontFamily, fontSize) {
|
|
14062
|
+
this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
14063
|
+
fontFamily = fontFamily || 'Arial';
|
|
14064
|
+
fontSize = fontSize || 30;
|
|
14065
|
+
this.canvasContext.font = fontSize + 'px ' + fontFamily;
|
|
14066
|
+
this.canvasContext.textAlign = 'center';
|
|
14067
|
+
this.canvasContext.textBaseline = 'middle';
|
|
14068
|
+
this.canvasContext.fillText(text, this.element.width / 2, this.element.height / 2);
|
|
14069
|
+
this.updateSnapCollection();
|
|
14070
|
+
this.isSignatureEmpty = false;
|
|
14071
|
+
}
|
|
14072
|
+
/**
|
|
14073
|
+
* To load the signature with the given base 64 string, height and width.
|
|
14074
|
+
*
|
|
14075
|
+
* @param {string} signature - specify the url/base 64 string to be drawn as signature.
|
|
14076
|
+
* @param {number} width - specify the width of the loaded signature image.
|
|
14077
|
+
* @param {number} height - specify the height of the loaded signature image.
|
|
14078
|
+
* @returns {void}.
|
|
14079
|
+
*/
|
|
14080
|
+
load(signature, width, height) {
|
|
14081
|
+
height = height || this.element.height;
|
|
14082
|
+
width = width || this.element.width;
|
|
14083
|
+
this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
14084
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
14085
|
+
const proxy = this;
|
|
14086
|
+
const bitmapImage = new Image();
|
|
14087
|
+
bitmapImage.src = signature;
|
|
14088
|
+
bitmapImage.onload = () => {
|
|
14089
|
+
Promise.all([
|
|
14090
|
+
createImageBitmap(bitmapImage, 0, 0, width, height)
|
|
14091
|
+
]).then((results) => {
|
|
14092
|
+
const tempCanvas = document.createElement('canvas');
|
|
14093
|
+
tempCanvas.width = width;
|
|
14094
|
+
tempCanvas.height = height;
|
|
14095
|
+
tempCanvas.getContext('2d').drawImage(results[0], 0, 0);
|
|
14096
|
+
proxy.canvasContext.drawImage(tempCanvas, 0, 0, width, height, 0, 0, proxy.element.width, proxy.element.height);
|
|
14097
|
+
proxy.updateSnapCollection();
|
|
14098
|
+
});
|
|
14099
|
+
};
|
|
14100
|
+
this.isSignatureEmpty = false;
|
|
14101
|
+
}
|
|
14102
|
+
saveBackground(savebg) {
|
|
14103
|
+
let imageSrc;
|
|
14104
|
+
if (savebg && this.backgroundImage) {
|
|
14105
|
+
imageSrc = this.snapColl[this.incStep - 1];
|
|
14106
|
+
}
|
|
14107
|
+
else {
|
|
14108
|
+
imageSrc = this.snapColl[this.incStep];
|
|
14109
|
+
}
|
|
14110
|
+
if (!savebg) {
|
|
14111
|
+
this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
14112
|
+
if (this.backgroundImage) {
|
|
14113
|
+
this.setBackgroundImage(this.backgroundImage);
|
|
14114
|
+
}
|
|
14115
|
+
else if (this.backgroundColor) {
|
|
14116
|
+
this.setBackgroundColor(this.backgroundColor);
|
|
14117
|
+
savebg = true;
|
|
14118
|
+
}
|
|
14119
|
+
}
|
|
14120
|
+
if (savebg) {
|
|
14121
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
14122
|
+
const proxy = this;
|
|
14123
|
+
const imageObj = new Image();
|
|
14124
|
+
imageObj.crossOrigin = 'anonymous';
|
|
14125
|
+
imageObj.src = imageSrc;
|
|
14126
|
+
imageObj.onload = () => {
|
|
14127
|
+
proxy.backgroundLoaded = true;
|
|
14128
|
+
proxy.canvasContext.globalCompositeOperation = 'source-over';
|
|
14129
|
+
proxy.canvasContext.drawImage(imageObj, 0, 0, proxy.element.width, proxy.element.height);
|
|
14130
|
+
proxy.save(proxy.fileType, proxy.fileName);
|
|
14131
|
+
};
|
|
14132
|
+
}
|
|
14133
|
+
}
|
|
14134
|
+
/**
|
|
14135
|
+
* To save the signature with the given file type and file name.
|
|
14136
|
+
*
|
|
14137
|
+
* @param {SignatureFileType} type - specify type of the file to be saved a signature.
|
|
14138
|
+
* @param {string} fileName - specify name of the file to be saved a signature.
|
|
14139
|
+
*
|
|
14140
|
+
* @returns {void}.
|
|
14141
|
+
*/
|
|
14142
|
+
save(type, fileName) {
|
|
14143
|
+
if (this.saveWithBackground && this.backgroundLoaded == null && (this.backgroundImage || this.backgroundColor)) {
|
|
14144
|
+
this.backgroundLoaded = false;
|
|
14145
|
+
this.fileType = type;
|
|
14146
|
+
this.fileName = fileName;
|
|
14147
|
+
this.saveBackground(false);
|
|
14148
|
+
}
|
|
14149
|
+
else if (type === 'Svg') {
|
|
14150
|
+
fileName = fileName || 'Signature';
|
|
14151
|
+
this.toSVG(fileName);
|
|
14152
|
+
}
|
|
14153
|
+
else if (type === 'Jpeg') {
|
|
14154
|
+
fileName = fileName || 'Signature';
|
|
14155
|
+
if (!this.saveWithBackground || this.saveWithBackground && !(this.backgroundImage || this.backgroundColor)) {
|
|
14156
|
+
this.toJPEG(fileName);
|
|
14157
|
+
}
|
|
14158
|
+
else {
|
|
14159
|
+
const dataURL = this.canvasContext.canvas.toDataURL('image/jpeg');
|
|
14160
|
+
this.download(this.getBlob(dataURL), fileName + '.' + 'jpeg');
|
|
14161
|
+
}
|
|
14162
|
+
}
|
|
14163
|
+
else {
|
|
14164
|
+
fileName = fileName || 'Signature';
|
|
14165
|
+
const dataURL = this.canvasContext.canvas.toDataURL('image/png');
|
|
14166
|
+
this.download(this.getBlob(dataURL), fileName + '.' + 'png');
|
|
14167
|
+
}
|
|
14168
|
+
if (this.saveWithBackground && this.backgroundLoaded) {
|
|
14169
|
+
this.resetSnap();
|
|
14170
|
+
}
|
|
14171
|
+
}
|
|
14172
|
+
resetSnap() {
|
|
14173
|
+
this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
14174
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
14175
|
+
const proxy = this;
|
|
14176
|
+
const restoreObj = new Image();
|
|
14177
|
+
restoreObj.src = this.snapColl[this.incStep - 1];
|
|
14178
|
+
restoreObj.onload = () => {
|
|
14179
|
+
proxy.canvasContext.drawImage(restoreObj, 0, 0, proxy.element.width, proxy.element.height);
|
|
14180
|
+
proxy.updateSnapCollection();
|
|
14181
|
+
};
|
|
14182
|
+
this.backgroundLoaded = null;
|
|
14183
|
+
this.snapColl.pop();
|
|
14184
|
+
this.incStep--;
|
|
14185
|
+
this.snapColl.pop();
|
|
14186
|
+
this.incStep--;
|
|
14187
|
+
}
|
|
14188
|
+
toJPEG(fileName) {
|
|
14189
|
+
const imageSrc = this.snapColl[this.incStep];
|
|
14190
|
+
this.setBackgroundColor('#ffffff');
|
|
14191
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
14192
|
+
const proxy = this;
|
|
14193
|
+
const imageObj = new Image();
|
|
14194
|
+
imageObj.crossOrigin = 'anonymous';
|
|
14195
|
+
imageObj.src = imageSrc;
|
|
14196
|
+
imageObj.onload = () => {
|
|
14197
|
+
proxy.canvasContext.globalCompositeOperation = 'source-over';
|
|
14198
|
+
proxy.canvasContext.drawImage(imageObj, 0, 0, proxy.element.width, proxy.element.height);
|
|
14199
|
+
const dataURL = proxy.canvasContext.canvas.toDataURL('image/jpeg');
|
|
14200
|
+
proxy.download(proxy.getBlob(dataURL), fileName + '.' + 'jpeg');
|
|
14201
|
+
proxy.canvasContext.clearRect(0, 0, proxy.canvasContext.canvas.width, proxy.canvasContext.canvas.height);
|
|
14202
|
+
this.resizeHandler();
|
|
14203
|
+
};
|
|
14204
|
+
this.snapColl.pop();
|
|
14205
|
+
this.incStep--;
|
|
14206
|
+
}
|
|
14207
|
+
toSVG(fileName) {
|
|
14208
|
+
const dataUrl = this.canvasContext.canvas.toDataURL();
|
|
14209
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
14210
|
+
svg.setAttribute('width', this.canvasContext.canvas.width.toString());
|
|
14211
|
+
svg.setAttribute('height', this.canvasContext.canvas.height.toString());
|
|
14212
|
+
const XLinkNS = 'http://www.w3.org/1999/xlink';
|
|
14213
|
+
const img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
|
|
14214
|
+
img.setAttributeNS(null, 'height', this.canvasContext.canvas.height.toString());
|
|
14215
|
+
img.setAttributeNS(null, 'width', this.canvasContext.canvas.width.toString());
|
|
14216
|
+
img.setAttributeNS(XLinkNS, 'xlink:href', dataUrl);
|
|
14217
|
+
svg.appendChild(img);
|
|
14218
|
+
const prefix = 'data:image/svg+xml;base64,';
|
|
14219
|
+
const header = '<svg' + ' xmlns="http://www.w3.org/2000/svg"' + ' xmlns:xlink="http://www.w3.org/1999/xlink"'
|
|
14220
|
+
+ ` width="${this.canvasContext.canvas.width}"` + ` height="${this.canvasContext.canvas.height}"` + '>';
|
|
14221
|
+
const footer = '</svg>';
|
|
14222
|
+
const body = svg.innerHTML;
|
|
14223
|
+
const data = header + body + footer;
|
|
14224
|
+
const svgDataUrl = prefix + btoa(data);
|
|
14225
|
+
if (fileName == null) {
|
|
14226
|
+
return svgDataUrl;
|
|
14227
|
+
}
|
|
14228
|
+
else {
|
|
14229
|
+
this.download(this.getBlob(svgDataUrl), fileName + '.' + 'svg');
|
|
14230
|
+
return null;
|
|
14231
|
+
}
|
|
14232
|
+
}
|
|
14233
|
+
/**
|
|
14234
|
+
* To save the signature as Blob.
|
|
14235
|
+
*
|
|
14236
|
+
* @returns {Blob}.
|
|
14237
|
+
*/
|
|
14238
|
+
saveAsBlob() {
|
|
14239
|
+
return this.getBlob(this.canvasContext.canvas.toDataURL('image/png'));
|
|
14240
|
+
}
|
|
14241
|
+
/**
|
|
14242
|
+
* To get the signature as Base 64.
|
|
14243
|
+
*
|
|
14244
|
+
* @private
|
|
14245
|
+
* @param {SignatureFileType} type - Specifies the type of the image format.
|
|
14246
|
+
* @returns {string}.
|
|
14247
|
+
*/
|
|
14248
|
+
getSignature(type) {
|
|
14249
|
+
if (type === 'Jpeg') {
|
|
14250
|
+
const imgData = this.canvasContext.getImageData(0, 0, this.element.width, this.element.height);
|
|
14251
|
+
const data = imgData.data;
|
|
14252
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
14253
|
+
if (data[i + 3] < 255) {
|
|
14254
|
+
data[i] = 255 - data[i];
|
|
14255
|
+
data[i + 1] = 255 - data[i + 1];
|
|
14256
|
+
data[i + 2] = 255 - data[i + 2];
|
|
14257
|
+
data[i + 3] = 255 - data[i + 3];
|
|
14258
|
+
}
|
|
14259
|
+
}
|
|
14260
|
+
this.canvasContext.putImageData(imgData, 0, 0);
|
|
14261
|
+
const dataURL = this.canvasContext.canvas.toDataURL('image/jpeg');
|
|
14262
|
+
this.resizeHandler();
|
|
14263
|
+
return dataURL;
|
|
14264
|
+
}
|
|
14265
|
+
else if (type === 'Svg') {
|
|
14266
|
+
return this.toSVG(null);
|
|
14267
|
+
}
|
|
14268
|
+
else {
|
|
14269
|
+
return this.canvasContext.canvas.toDataURL('image/png');
|
|
14270
|
+
}
|
|
14271
|
+
}
|
|
14272
|
+
/**
|
|
14273
|
+
* Get component name.
|
|
14274
|
+
*
|
|
14275
|
+
* @returns {string} - Module Name
|
|
14276
|
+
* @private
|
|
14277
|
+
*/
|
|
14278
|
+
getModuleName() {
|
|
14279
|
+
return 'signature';
|
|
14280
|
+
}
|
|
14281
|
+
/**
|
|
14282
|
+
* To get the properties to be maintained in the persisted state.
|
|
14283
|
+
*
|
|
14284
|
+
* @returns {string} - Persist data
|
|
14285
|
+
*/
|
|
14286
|
+
getPersistData() {
|
|
14287
|
+
this.signatureValue = this.snapColl[this.incStep];
|
|
14288
|
+
return this.addOnPersist(['signatureValue']);
|
|
14289
|
+
}
|
|
14290
|
+
/**
|
|
14291
|
+
* Removes the component from the DOM and detaches all its related event handlers.
|
|
14292
|
+
* Also it maintains the initial input element from the DOM.
|
|
14293
|
+
*
|
|
14294
|
+
* @method destroy
|
|
14295
|
+
* @returns {void}
|
|
14296
|
+
*/
|
|
14297
|
+
destroy() {
|
|
14298
|
+
this.unwireEvents(null);
|
|
14299
|
+
removeClass([this.element], 'e-' + this.getModuleName());
|
|
14300
|
+
this.element.removeAttribute('tabindex');
|
|
14301
|
+
this.pointColl = null;
|
|
14302
|
+
super.destroy();
|
|
14303
|
+
}
|
|
14304
|
+
/**
|
|
14305
|
+
* Modified onPropertyChanged method for both blazor and EJ2 signature component.
|
|
14306
|
+
*
|
|
14307
|
+
* @private
|
|
14308
|
+
* @param {string} key - Specifies the property, which changed.
|
|
14309
|
+
* @param {string} value - Specifies the property value changed.
|
|
14310
|
+
* @returns {void}
|
|
14311
|
+
*/
|
|
14312
|
+
propertyChanged(key, value) {
|
|
14313
|
+
const canvasNew = this.canvasContext;
|
|
14314
|
+
switch (key) {
|
|
14315
|
+
case 'backgroundColor':
|
|
14316
|
+
canvasNew.canvas.style.backgroundColor = value;
|
|
14317
|
+
this.backgroundColor = value;
|
|
14318
|
+
break;
|
|
14319
|
+
case 'backgroundImage':
|
|
14320
|
+
canvasNew.canvas.style.backgroundImage = 'url(' + value + ')';
|
|
14321
|
+
this.backgroundImage = value;
|
|
14322
|
+
break;
|
|
14323
|
+
case 'strokeColor':
|
|
14324
|
+
canvasNew.fillStyle = value;
|
|
14325
|
+
this.strokeColor = value;
|
|
14326
|
+
break;
|
|
14327
|
+
case 'saveWithBackground':
|
|
14328
|
+
this.saveWithBackground = value;
|
|
14329
|
+
break;
|
|
14330
|
+
case 'maxStrokeWidth':
|
|
14331
|
+
this.maxStrokeWidth = value;
|
|
14332
|
+
break;
|
|
14333
|
+
case 'minStrokeWidth':
|
|
14334
|
+
this.minStrokeWidth = value;
|
|
14335
|
+
break;
|
|
14336
|
+
case 'velocity':
|
|
14337
|
+
this.velocity = value;
|
|
14338
|
+
break;
|
|
14339
|
+
case 'isReadOnly':
|
|
14340
|
+
this.isRead(value);
|
|
14341
|
+
break;
|
|
14342
|
+
case 'disabled':
|
|
14343
|
+
this.enableOrDisable(value);
|
|
14344
|
+
break;
|
|
14345
|
+
}
|
|
14346
|
+
}
|
|
14347
|
+
}
|
|
14348
|
+
|
|
14349
|
+
var __decorate$7 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
14350
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
14351
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
14352
|
+
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;
|
|
14353
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14354
|
+
};
|
|
14355
|
+
/**
|
|
14356
|
+
* The Signature component allows user to draw smooth signatures as vector outline of strokes using variable width bezier curve interpolation.
|
|
14357
|
+
* It allows to save signature as image.
|
|
14358
|
+
* You can use your finger, pen, or mouse on a tablet, touchscreen, etc., to draw your own signature on this Signature component.
|
|
14359
|
+
* Signature component is a user interface to draw the Signature or Text.
|
|
14360
|
+
* It provides supports for various Background color, Stroke color and Background Image.
|
|
14361
|
+
* ```html
|
|
14362
|
+
* <canvas id="signature"></canvas>
|
|
14363
|
+
* ```
|
|
14364
|
+
* ```typescript
|
|
14365
|
+
* <script>
|
|
14366
|
+
* let signatureObj: Signature = new Signature(null , "#signature");
|
|
14367
|
+
* </script>
|
|
14368
|
+
* ```
|
|
14369
|
+
*/
|
|
14370
|
+
let Signature = class Signature extends SignatureBase {
|
|
14371
|
+
/**
|
|
14372
|
+
* Constructor for creating the widget.
|
|
14373
|
+
*
|
|
14374
|
+
* @param {SignatureModel} options - Specifies the Signature model.
|
|
14375
|
+
* @param {string | HTMLCanvasElement} element - Specifies the element.
|
|
14376
|
+
* @private
|
|
14377
|
+
*/
|
|
14378
|
+
constructor(options, element) {
|
|
14379
|
+
super(options, element);
|
|
14380
|
+
}
|
|
14381
|
+
preRender() {
|
|
14382
|
+
// pre render code snippets
|
|
14383
|
+
}
|
|
14384
|
+
/**
|
|
14385
|
+
* To Initialize the component rendering
|
|
14386
|
+
*
|
|
14387
|
+
* @private
|
|
14388
|
+
* @returns {void}
|
|
14389
|
+
*/
|
|
14390
|
+
render() {
|
|
14391
|
+
this.initialize();
|
|
14392
|
+
}
|
|
14393
|
+
initialize() {
|
|
14394
|
+
addClass([this.element], 'e-' + this.getModuleName());
|
|
14395
|
+
super.initialize(this.element);
|
|
14396
|
+
if (this.enablePersistence) {
|
|
14397
|
+
this.loadPersistedSignature();
|
|
14398
|
+
}
|
|
14399
|
+
}
|
|
14400
|
+
/**
|
|
14401
|
+
* To get component name.
|
|
14402
|
+
*
|
|
14403
|
+
* @returns {string} - Module Name
|
|
14404
|
+
* @private
|
|
14405
|
+
*/
|
|
14406
|
+
getModuleName() {
|
|
14407
|
+
return 'signature';
|
|
14408
|
+
}
|
|
14409
|
+
/**
|
|
14410
|
+
* To get the properties to be maintained in the persisted state.
|
|
14411
|
+
*
|
|
14412
|
+
* @returns {string} - Persist data
|
|
14413
|
+
*/
|
|
14414
|
+
getPersistData() {
|
|
14415
|
+
return this.addOnPersist(['signatureValue']);
|
|
14416
|
+
}
|
|
14417
|
+
/**
|
|
14418
|
+
* Called internally if any of the property value changed.
|
|
14419
|
+
*
|
|
14420
|
+
* @param {SignatureModel} newProp - Specifies new properties
|
|
14421
|
+
* @param {SignatureModel} oldProp - Specifies old properties
|
|
14422
|
+
* @returns {void}
|
|
14423
|
+
* @private
|
|
14424
|
+
*/
|
|
14425
|
+
onPropertyChanged(newProp, oldProp) {
|
|
14426
|
+
for (const prop of Object.keys(newProp)) {
|
|
14427
|
+
switch (prop) {
|
|
14428
|
+
case 'backgroundColor':
|
|
14429
|
+
super.propertyChanged(prop, newProp.backgroundColor);
|
|
14430
|
+
break;
|
|
14431
|
+
case 'backgroundImage':
|
|
14432
|
+
super.propertyChanged(prop, newProp.backgroundImage);
|
|
14433
|
+
break;
|
|
14434
|
+
case 'strokeColor':
|
|
14435
|
+
if (newProp.strokeColor !== oldProp.strokeColor) {
|
|
14436
|
+
super.propertyChanged(prop, newProp.strokeColor);
|
|
14437
|
+
}
|
|
14438
|
+
break;
|
|
14439
|
+
case 'saveWithBackground':
|
|
14440
|
+
super.propertyChanged(prop, newProp.saveWithBackground);
|
|
14441
|
+
break;
|
|
14442
|
+
case 'isReadOnly':
|
|
14443
|
+
super.propertyChanged(prop, newProp.isReadOnly);
|
|
14444
|
+
break;
|
|
14445
|
+
case 'disabled':
|
|
14446
|
+
super.propertyChanged(prop, newProp.disabled);
|
|
14447
|
+
break;
|
|
14448
|
+
}
|
|
14449
|
+
}
|
|
14450
|
+
}
|
|
14451
|
+
};
|
|
14452
|
+
__decorate$7([
|
|
14453
|
+
Property('')
|
|
14454
|
+
], Signature.prototype, "backgroundColor", void 0);
|
|
14455
|
+
__decorate$7([
|
|
14456
|
+
Property('')
|
|
14457
|
+
], Signature.prototype, "backgroundImage", void 0);
|
|
14458
|
+
__decorate$7([
|
|
14459
|
+
Property(false)
|
|
14460
|
+
], Signature.prototype, "disabled", void 0);
|
|
14461
|
+
__decorate$7([
|
|
14462
|
+
Property(false)
|
|
14463
|
+
], Signature.prototype, "isReadOnly", void 0);
|
|
14464
|
+
__decorate$7([
|
|
14465
|
+
Property(true)
|
|
14466
|
+
], Signature.prototype, "saveWithBackground", void 0);
|
|
14467
|
+
__decorate$7([
|
|
14468
|
+
Property('#000000')
|
|
14469
|
+
], Signature.prototype, "strokeColor", void 0);
|
|
14470
|
+
__decorate$7([
|
|
14471
|
+
Property(0.5)
|
|
14472
|
+
], Signature.prototype, "minStrokeWidth", void 0);
|
|
14473
|
+
__decorate$7([
|
|
14474
|
+
Property(2)
|
|
14475
|
+
], Signature.prototype, "maxStrokeWidth", void 0);
|
|
14476
|
+
__decorate$7([
|
|
14477
|
+
Property(0.7)
|
|
14478
|
+
], Signature.prototype, "velocity", void 0);
|
|
14479
|
+
__decorate$7([
|
|
14480
|
+
Property('en-US')
|
|
14481
|
+
], Signature.prototype, "locale", void 0);
|
|
14482
|
+
__decorate$7([
|
|
14483
|
+
Property(false)
|
|
14484
|
+
], Signature.prototype, "enableRtl", void 0);
|
|
14485
|
+
__decorate$7([
|
|
14486
|
+
Property(false)
|
|
14487
|
+
], Signature.prototype, "enablePersistence", void 0);
|
|
14488
|
+
__decorate$7([
|
|
14489
|
+
Event()
|
|
14490
|
+
], Signature.prototype, "beforeSave", void 0);
|
|
14491
|
+
__decorate$7([
|
|
14492
|
+
Event()
|
|
14493
|
+
], Signature.prototype, "change", void 0);
|
|
14494
|
+
__decorate$7([
|
|
14495
|
+
Event()
|
|
14496
|
+
], Signature.prototype, "created", void 0);
|
|
14497
|
+
Signature = __decorate$7([
|
|
14498
|
+
NotifyPropertyChanges
|
|
14499
|
+
], Signature);
|
|
14500
|
+
|
|
14501
|
+
/**
|
|
14502
|
+
* Signature modules
|
|
14503
|
+
*/
|
|
14504
|
+
|
|
14505
|
+
/**
|
|
14506
|
+
* Signature base modules
|
|
14507
|
+
*/
|
|
14508
|
+
|
|
13401
14509
|
/**
|
|
13402
14510
|
* NumericTextBox all modules
|
|
13403
14511
|
*/
|
|
13404
14512
|
|
|
13405
|
-
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 };
|
|
14513
|
+
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 };
|
|
13406
14514
|
//# sourceMappingURL=ej2-inputs.es2015.js.map
|