@boldreports/javascript-reporting-extensions 6.3.18 → 6.3.24

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.
@@ -0,0 +1,737 @@
1
+ var SignatureDialog = (function () {
2
+ function SignatureDialog() {
3
+ this.container = null;
4
+ this.footerTag = null;
5
+ this.ejOkbtn = null;
6
+ this.ejCancelbtn = null;
7
+ this.dlgInstance = null;
8
+ this.id = null;
9
+ this.isDrawing = false;
10
+ this.lastX = 0;
11
+ this.lastY = 0;
12
+ this.strokeColorObj = null;
13
+ this.dropDownObj = null;
14
+ this.canvasElement = null;
15
+ this.locale = 'en-US';
16
+ this.isMouseDown = false;
17
+ this.isCropping = false;
18
+ this.cropStartX = 0;
19
+ this.cropStartY = 0;
20
+ this.isCropEnabled = false;
21
+ this.initialHgt = 273;
22
+ this.initialWdth = 560;
23
+ this.instance = null;
24
+ }
25
+ SignatureDialog.prototype.renderDialog = function () {
26
+ this.container = this.buildElement('div', 'e-reportdesigner-designer-configuration e-userselect', '', {}, { id: this.id + '_signDialog' });
27
+ var bodyRootEle = this.buildElement('div', 'e-signDialog-root-container', '', {}, {});
28
+ var okBtn = this.buildElement('button', '', '', {}, { 'id': this.id + '_signDialog_okBtn', 'type': 'button' });
29
+ var cancelBtn = this.buildElement('button', '', '', {}, { 'id': this.id + '_signDialog_cancelBtn' });
30
+ this.container.append(bodyRootEle);
31
+ $(document.body).append(this.container);
32
+ ejs.popups.createSpinner({
33
+ target: this.container.find('.e-signDialog-browsingDiv')[0],
34
+ cssClass: 'e-spin-overlay'
35
+ });
36
+ this.dlgInstance = new ejs.popups.Dialog({
37
+ allowDragging: true,
38
+ width: 599,
39
+ height: 'auto',
40
+ visible: false,
41
+ isModal: true,
42
+ showCloseIcon: true,
43
+ enableResize: true,
44
+ header: this.getLocale('title'),
45
+ footerTemplate: '<div id="' + this.id + '_signDialog_foot"></div>',
46
+ target: document.body,
47
+ cssClass: 'e-signDialog-size',
48
+ beforeOpen: $.proxy(this.onOpen, this),
49
+ close: $.proxy(this.resetDialogValues, this),
50
+ resizeStop: $.proxy(this.onResizeStop, this)
51
+ });
52
+ this.dlgInstance.appendTo(this.container[0]);
53
+ this.footerTag = $(this.dlgInstance.ftrTemplateContent).find('#' + this.id + '_signDialog_foot');
54
+ this.footerTag.attr('tabindex', '-1');
55
+ this.footerTag.append(okBtn).append(cancelBtn);
56
+ this.ejOkbtn = new ejs.buttons.Button({
57
+ content: this.getLocale('ok'),
58
+ isPrimary: true,
59
+ cssClass: 'e-rptdesigner-dlgbtn e-rptdesigner-btn e-medium '
60
+ });
61
+ this.ejOkbtn.appendTo(okBtn[0]);
62
+ okBtn[0].onclick = $.proxy(this.saveSign, this);
63
+ this.ejCancelbtn = new ejs.buttons.Button({
64
+ content: this.getLocale('cancel'),
65
+ cssClass: ' e-rptdesigner-dlgbtn e-rptdesigner-btn e-medium'
66
+ });
67
+ this.ejCancelbtn.appendTo(cancelBtn[0]);
68
+ cancelBtn[0].onclick = $.proxy(this.closeDialog, this, true);
69
+ $(this.dlgInstance.closeIcon).attr('title', this.getLocale('closeToolTip'));
70
+ };
71
+ SignatureDialog.prototype.openDialog = function (instance, dialogInfo) {
72
+ this.canvasElement = dialogInfo.canvas;
73
+ this.locale = dialogInfo.locale;
74
+ this.callBackfn = dialogInfo.callBackFn;
75
+ this.instance = instance;
76
+ if (this.hasViewerInstance(this.instance)) {
77
+ this.id = this.instance._id;
78
+ }
79
+ else if (this.hasDesignerInstance(this.instance)) {
80
+ this.id = this.instance._id + '_reportviewer';
81
+ }
82
+ this.renderDialog();
83
+ this.renderBody();
84
+ this.wiredDesignerEvents();
85
+ this.dlgInstance.show();
86
+ this.setSign(dialogInfo.imageData);
87
+ };
88
+ SignatureDialog.prototype.resetDialogValues = function (args) {
89
+ this.dlgInstance.refreshPosition();
90
+ this.resetValues();
91
+ };
92
+ SignatureDialog.prototype.onOpen = function (args) {
93
+ args.maxHeight = '670px';
94
+ args.element.style.maxWidth = '800px';
95
+ };
96
+ SignatureDialog.prototype.renderBody = function () {
97
+ var bodyRootEle = this.container.find('.e-signDialog-root-container');
98
+ this.renderOptions(bodyRootEle);
99
+ this.renderContent(bodyRootEle);
100
+ };
101
+ SignatureDialog.prototype.renderOptions = function (target) {
102
+ var holderDiv = this.buildElement('div', '', '', { 'display': 'flex', 'gap': '13px', 'justify-content': 'space-between', 'align-items': 'center' }, {});
103
+ var labelDiv = this.buildElement('div', 'e-signDialog-firstRow', '', { width: '100%', 'height': '37px', display: 'flex', 'justify-content': 'space-between', 'gap': '5px', 'align-items': 'center' }, {});
104
+ this.appendStrokeWidth(holderDiv);
105
+ this.appendStrokeColor(holderDiv);
106
+ this.appendCropButton(holderDiv);
107
+ labelDiv.append(holderDiv);
108
+ this.appendClearBtn(labelDiv);
109
+ target.append(labelDiv);
110
+ };
111
+ SignatureDialog.prototype.appendCropButton = function (target) {
112
+ var cropBtn = this.buildElement('div', 'e-signDialog-cropIconDiv', '', {}, {});
113
+ var cropDiv = this.buildElement('div', 'e-signDialog-cropIconChildDiv e-signDialog-cropIcon-disable', '', {}, {});
114
+ var cropText = this.buildElement('span', 'e-signDialog-cropIcon', '', {}, { 'title': this.getLocale('crop') });
115
+ cropDiv.append(cropText);
116
+ cropBtn.append(cropDiv);
117
+ cropBtn.bind('click', $.proxy(this.updateCropState, this));
118
+ target.append(cropBtn);
119
+ };
120
+ SignatureDialog.prototype.appendStrokeColor = function (target) {
121
+ var strokeColorDiv = this.buildElement('div', 'e-signDialog-strokeColorDiv', '', {}, {});
122
+ var strokeColorLabel = this.buildElement('span', 'e-rptdesigner-add-label e-signDialog-text-span', this.getLocale('strokeColor'), {}, { type: 'label', 'title': this.getLocale('strokeColor') });
123
+ var strokeColorTag = this.buildElement('div', 'e-signDialog-strokeColorTag', '', {}, {});
124
+ var strokeColor = this.buildElement('input', 'e-signDialog-strokeColor', '', null, {});
125
+ this.strokeColorObj = new ejs.inputs.ColorPicker({
126
+ value: '#000000',
127
+ cssClass: 'e-designer-colorpicker',
128
+ mode: 'Palette',
129
+ height: '37px',
130
+ open: $.proxy(this.colorPickerOpen, this),
131
+ onModeSwitch: $.proxy(this.colorPickerModeSwitch, this),
132
+ change: $.proxy(this.onStrokeColorChange, this)
133
+ });
134
+ strokeColorTag.append(strokeColor);
135
+ strokeColorDiv.append(strokeColorLabel, strokeColorTag);
136
+ this.strokeColorObj.appendTo(strokeColor[0]);
137
+ target.append(strokeColorDiv);
138
+ };
139
+ SignatureDialog.prototype.appendStrokeWidth = function (target) {
140
+ var strokeWidth = this.buildElement('div', 'e-signDialog-strokeWidthDiv', '', {}, {});
141
+ var drpdwnLbl = this.buildElement('span', 'e-rptdesigner-add-label e-signDialog-text-span', this.getLocale('strokeWidth'), {}, { type: 'label', 'title': this.getLocale('strokeWidth') });
142
+ var drpdwnTag = this.buildElement('div', 'e-signDialog-drpDwnTag', '', {}, {});
143
+ var dropDown = this.buildElement('input', 'e-field', '', {}, { type: 'text' });
144
+ this.dropDownObj = new ejs.dropdowns.DropDownList({
145
+ width: '73px',
146
+ dataSource: [1, 2, 3, 4, 5],
147
+ fields: { text: 'text' },
148
+ value: 2,
149
+ enabled: true,
150
+ placeHolder: '2',
151
+ cssClass: 'e-rptdesigner-param-assign e-designer-ejwidgets e-rptdesigner-filter e-designer-dropdownlist e-standard',
152
+ allowFiltering: true,
153
+ popupHeight: '180px',
154
+ change: $.proxy(this.onLineWidthChange, this)
155
+ });
156
+ drpdwnTag.append(dropDown);
157
+ strokeWidth.append(drpdwnLbl, drpdwnTag);
158
+ this.dropDownObj.appendTo(dropDown[0]);
159
+ target.append(strokeWidth);
160
+ };
161
+ SignatureDialog.prototype.appendClearBtn = function (target) {
162
+ var clearBtn = this.buildElement('div', 'e-signDialog-btn-clear', '', {}, {});
163
+ var textSpan = this.buildElement('span', 'e-btntxt e-rptdesigner-add-btn e-signDialog-text-span', this.getLocale('clear'), {}, { 'title': this.getLocale('clear') });
164
+ clearBtn.append(textSpan);
165
+ clearBtn.bind('click', $.proxy(this.clearSignature, this));
166
+ target.append(clearBtn);
167
+ };
168
+ SignatureDialog.prototype.renderContent = function (target) {
169
+ var bodyRootEle = this.container.find('.e-signDialog-root-container');
170
+ var labelDivHgt = this.container.find('.e-signDialog-firstRow').height();
171
+ var gapValue = bodyRootEle.css('gap');
172
+ var remainingHgt = labelDivHgt + parseFloat(gapValue) + 'px';
173
+ var canvasContDiv = this.buildElement('div', 'e-signDialog-border e-signDialog-canvasDiv', '', { 'display': 'flex', 'width': '100%', height: "calc(100% - " + remainingHgt + ")" }, {});
174
+ var cropBox = this.buildElement('div', 'e-signDialog-cropBox crop-disable', '', { 'display': 'none' }, {});
175
+ var canvas = document.createElement('canvas');
176
+ var context = canvas.getContext('2d');
177
+ canvas.id = this.id + '_signDialog_canvas';
178
+ canvas.className = 'e-signDialog-canvas';
179
+ canvas.width = this.initialWdth;
180
+ canvas.height = this.initialHgt;
181
+ context.lineWidth = 2;
182
+ context.strokeStyle = '#000000';
183
+ canvasContDiv.append(canvas, cropBox);
184
+ target.append(canvasContDiv);
185
+ };
186
+ SignatureDialog.prototype.onStrokeColorChange = function (args) {
187
+ var canvas = this.container.find('#' + this.id + '_signDialog_canvas')[0];
188
+ if (canvas) {
189
+ var context = canvas.getContext('2d');
190
+ context.strokeStyle = args.currentValue.hex;
191
+ }
192
+ };
193
+ SignatureDialog.prototype.onLineWidthChange = function (args) {
194
+ var canvas = this.container.find('#' + this.id + '_signDialog_canvas')[0];
195
+ if (canvas) {
196
+ var ctx = canvas.getContext('2d');
197
+ ctx.lineWidth = args.itemData.value;
198
+ }
199
+ };
200
+ SignatureDialog.prototype.setSign = function (imgData) {
201
+ var canvas = this.container.find('#' + this.id + '_signDialog_canvas')[0];
202
+ if (imgData) {
203
+ var image = new Image();
204
+ image.src = imgData;
205
+ image.onload = $.proxy(this.drawImage, this, image, canvas);
206
+ }
207
+ };
208
+ SignatureDialog.prototype.drawImage = function (image, canvas) {
209
+ var ctx = canvas.getContext('2d');
210
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
211
+ ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
212
+ };
213
+ SignatureDialog.prototype.onResizeStop = function () {
214
+ var canvas = this.container.find('#' + this.id + '_signDialog_canvas')[0];
215
+ var cropBox = this.container.find('.e-signDialog-cropBox');
216
+ var imgData = canvas.toDataURL('image/png');
217
+ var ctx = canvas.getContext('2d');
218
+ canvas.height = this.container.find('.e-signDialog-canvasDiv')[0].offsetHeight;
219
+ canvas.width = this.container.find('.e-signDialog-canvasDiv')[0].offsetWidth;
220
+ ctx.lineWidth = this.dropDownObj.value;
221
+ ctx.strokeStyle = this.strokeColorObj.value;
222
+ this.setSign(imgData);
223
+ if (cropBox) {
224
+ cropBox.css('display', 'none');
225
+ }
226
+ };
227
+ SignatureDialog.prototype.updateCropState = function () {
228
+ var cropBox = this.container.find('.e-signDialog-cropBox');
229
+ if (cropBox && cropBox.length > 0) {
230
+ if (cropBox.hasClass('crop-disable')) {
231
+ this.enableCropIcon();
232
+ }
233
+ else {
234
+ this.disableCropIcon();
235
+ }
236
+ }
237
+ };
238
+ SignatureDialog.prototype.enableCropIcon = function () {
239
+ var cropBox = this.container.find('.e-signDialog-cropBox');
240
+ var cropDiv = this.container.find('.e-signDialog-cropIconChildDiv');
241
+ if (cropBox.hasClass('crop-disable')) {
242
+ cropBox.removeClass('crop-disable');
243
+ cropBox.addClass('crop-enable');
244
+ cropDiv.removeClass('e-signDialog-cropIcon-disable');
245
+ cropDiv.addClass('e-signDialog-cropIcon-enable');
246
+ var canvas = this.container.find('#' + this.id + '_signDialog_canvas')[0];
247
+ if (canvas) {
248
+ this.isCropEnabled = true;
249
+ canvas.style.cursor = 'crosshair';
250
+ }
251
+ }
252
+ };
253
+ SignatureDialog.prototype.disableCropIcon = function () {
254
+ var canvas = this.container.find('#' + this.id + '_signDialog_canvas')[0];
255
+ var cropDiv = this.container.find('.e-signDialog-cropIconChildDiv');
256
+ var cropBox = this.container.find('.e-signDialog-cropBox');
257
+ if (cropBox.hasClass('crop-enable')) {
258
+ cropBox.removeClass('crop-enable');
259
+ cropBox.addClass('crop-disable');
260
+ cropDiv.addClass('e-signDialog-cropIcon-disable');
261
+ cropDiv.removeClass('e-signDialog-cropIcon-enable');
262
+ }
263
+ cropBox.css({ width: '0px', height: '0px', display: 'none' });
264
+ canvas.style.cursor = 'default';
265
+ this.isCropEnabled = false;
266
+ this.isCropping = false;
267
+ };
268
+ SignatureDialog.prototype.hasCropBox = function () {
269
+ var cropBox = this.container.find('.e-signDialog-cropBox');
270
+ return cropBox.length > 0 && cropBox.is(':visible');
271
+ };
272
+ SignatureDialog.prototype.cropSelectedRegion = function () {
273
+ var canvas = this.container.find('#' + this.id + '_signDialog_canvas')[0];
274
+ var cropBox = this.container.find('.e-signDialog-cropBox');
275
+ var ctx = canvas.getContext('2d');
276
+ var rect = cropBox[0].getBoundingClientRect();
277
+ var left = rect.left - canvas.getBoundingClientRect().left;
278
+ var top = rect.top - canvas.getBoundingClientRect().top;
279
+ var width = rect.width;
280
+ var height = rect.height;
281
+ var croppedimgData = ctx.getImageData(left, top, width, height);
282
+ var tempCanvas = document.createElement('canvas');
283
+ var croppedCtx = tempCanvas.getContext('2d');
284
+ tempCanvas.width = width;
285
+ tempCanvas.height = height;
286
+ croppedCtx.putImageData(croppedimgData, 0, 0);
287
+ return tempCanvas;
288
+ };
289
+ SignatureDialog.prototype.drawLine = function (x1, y1, x2, y2) {
290
+ var canvas = this.container.find('#' + this.id + '_signDialog_canvas')[0];
291
+ var ctx = canvas.getContext('2d');
292
+ if (ctx) {
293
+ ctx.beginPath();
294
+ ctx.moveTo(x1, y1);
295
+ ctx.lineTo(x2, y2);
296
+ ctx.stroke();
297
+ }
298
+ };
299
+ SignatureDialog.prototype.onMouseDown = function (e) {
300
+ if (this.isCropEnabled) {
301
+ this.onMouseDownCrop(e);
302
+ return;
303
+ }
304
+ e.preventDefault();
305
+ var canvas = this.container.find('#' + this.id + '_signDialog_canvas')[0];
306
+ var rect = canvas.getBoundingClientRect();
307
+ this.lastX = e.clientX - rect.left;
308
+ this.lastY = e.clientY - rect.top;
309
+ this.isDrawing = true;
310
+ this.isMouseDown = true;
311
+ };
312
+ SignatureDialog.prototype.onMouseMove = function (e) {
313
+ if (this.isCropEnabled && this.isMouseDown) {
314
+ this.onMouseMoveCrop(e);
315
+ return;
316
+ }
317
+ e.preventDefault();
318
+ if (this.isDrawing && this.isMouseDown) {
319
+ var canvas = this.container.find('#' + this.id + '_signDialog_canvas')[0];
320
+ var rect = canvas.getBoundingClientRect();
321
+ var x = 0;
322
+ var y = 0;
323
+ if (e.touches && e.touches.length > 0) {
324
+ x = e.touches[0].clientX - rect.left;
325
+ y = e.touches[0].clientY - rect.top;
326
+ }
327
+ else {
328
+ x = e.clientX - rect.left;
329
+ y = e.clientY - rect.top;
330
+ }
331
+ this.drawLine(this.lastX, this.lastY, x, y);
332
+ this.lastX = x;
333
+ this.lastY = y;
334
+ }
335
+ };
336
+ SignatureDialog.prototype.onMouseUp = function (e) {
337
+ if (this.isCropEnabled) {
338
+ this.onMouseUpCrop(e);
339
+ return;
340
+ }
341
+ e.preventDefault();
342
+ this.isDrawing = false;
343
+ this.isMouseDown = false;
344
+ };
345
+ SignatureDialog.prototype.onMouseLeave = function (e) {
346
+ if (this.isDrawing || this.isCropping) {
347
+ this.isMouseDown = false;
348
+ }
349
+ };
350
+ SignatureDialog.prototype.onMouseEnter = function (e) {
351
+ if (e.buttons === 1) {
352
+ this.isMouseDown = true;
353
+ }
354
+ };
355
+ SignatureDialog.prototype.onMouseDownCrop = function (e) {
356
+ if (this.isCropEnabled) {
357
+ var canvas = this.container.find('#' + this.id + '_signDialog_canvas')[0];
358
+ var cropBox = this.container.find('.e-signDialog-cropBox');
359
+ var rect = canvas.getBoundingClientRect();
360
+ e.preventDefault();
361
+ this.isCropping = true;
362
+ this.isDrawing = false;
363
+ this.isMouseDown = true;
364
+ if (e.touches && e.touches.length > 0) {
365
+ this.cropStartX = (e.touches[0].clientX - rect.left) + canvas.offsetLeft;
366
+ this.cropStartY = (e.touches[0].clientY - rect.top) + canvas.offsetTop;
367
+ }
368
+ else {
369
+ this.cropStartX = (e.clientX - rect.left) + canvas.offsetLeft;
370
+ this.cropStartY = (e.clientY - rect.top) + canvas.offsetTop;
371
+ }
372
+ cropBox.css({
373
+ display: 'block',
374
+ width: '0px',
375
+ height: '0px',
376
+ left: this.cropStartX + "px",
377
+ top: this.cropStartY + "px"
378
+ });
379
+ }
380
+ };
381
+ SignatureDialog.prototype.onMouseUpCrop = function (e) {
382
+ if (!this.isCropping) {
383
+ return;
384
+ }
385
+ e.preventDefault();
386
+ this.isCropping = false;
387
+ this.isMouseDown = false;
388
+ };
389
+ SignatureDialog.prototype.onMouseMoveCrop = function (e) {
390
+ if (!this.isCropping) {
391
+ return;
392
+ }
393
+ e.preventDefault();
394
+ var canvas = this.container.find('#' + this.id + '_signDialog_canvas')[0];
395
+ var cropBox = this.container.find('.e-signDialog-cropBox');
396
+ var rect = canvas.getBoundingClientRect();
397
+ var currentX = null;
398
+ var currentY = null;
399
+ if (e.touches && e.touches.length > 0) {
400
+ currentX = (e.touches[0].clientX - rect.left) + canvas.offsetLeft;
401
+ currentY = (e.touches[0].clientY - rect.top) + canvas.offsetTop;
402
+ }
403
+ else {
404
+ currentX = (e.clientX - rect.left) + canvas.offsetLeft;
405
+ currentY = (e.clientY - rect.top) + canvas.offsetTop;
406
+ }
407
+ cropBox.css({
408
+ width: Math.abs(currentX - this.cropStartX) + "px",
409
+ height: Math.abs(currentY - this.cropStartY) + "px",
410
+ left: Math.min(this.cropStartX, currentX) + "px",
411
+ top: Math.min(this.cropStartY, currentY) + "px"
412
+ });
413
+ };
414
+ SignatureDialog.prototype.clearSignature = function () {
415
+ var canvas = this.container.find('#' + this.id + '_signDialog_canvas')[0];
416
+ if (canvas.getContext) {
417
+ var ctx = canvas.getContext('2d');
418
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
419
+ }
420
+ this.disableCropIcon();
421
+ };
422
+ SignatureDialog.prototype.saveSign = function () {
423
+ var canvasContDiv = this.container.find('.e-signDialog-canvasDiv');
424
+ var imgData = null;
425
+ if (canvasContDiv) {
426
+ if (this.hasCropBox()) {
427
+ var tempCanvas = this.cropSelectedRegion();
428
+ imgData = tempCanvas.toDataURL('image/png');
429
+ }
430
+ else {
431
+ var canvas = this.container.find('#' + this.id + '_signDialog_canvas')[0];
432
+ if (canvas) {
433
+ imgData = canvas.toDataURL('image/png');
434
+ }
435
+ }
436
+ }
437
+ if (this.callBackfn) {
438
+ this.invokeCallBack(this.callBackfn, { imageData: imgData, canvasElement: this.canvasElement });
439
+ }
440
+ this.dlgInstance.hide();
441
+ };
442
+ SignatureDialog.prototype.resetValues = function () {
443
+ this.unwiredDesignerEvents();
444
+ if (this.hasViewerInstance(this.instance)) {
445
+ this.instance._destroyEJ2Objects(this.container.find('.e-dlg-content .e-signDialog-root-container'));
446
+ }
447
+ else {
448
+ ej.ReportUtil.destroyEj2Objects(this.container.find('.e-dlg-content .e-signDialog-root-container'));
449
+ }
450
+ this.dlgInstance.destroy();
451
+ $('#' + this.id + '_signDialog').remove();
452
+ this.resetGlobalVbles();
453
+ };
454
+ SignatureDialog.prototype.closeDialog = function () {
455
+ this.dlgInstance.hide();
456
+ };
457
+ SignatureDialog.prototype.updateCulture = function () {
458
+ };
459
+ SignatureDialog.prototype.updateSize = function () {
460
+ };
461
+ SignatureDialog.prototype.wiredDesignerEvents = function () {
462
+ var canvas = this.container.find('#' + this.id + '_signDialog_canvas')[0];
463
+ canvas.addEventListener('mousedown', $.proxy(this.onMouseDown, this));
464
+ canvas.addEventListener('mousemove', $.proxy(this.onMouseMove, this));
465
+ canvas.addEventListener('mouseup', $.proxy(this.onMouseUp, this));
466
+ canvas.addEventListener('mouseleave', $.proxy(this.onMouseLeave, this));
467
+ canvas.addEventListener('mouseenter', $.proxy(this.onMouseEnter, this));
468
+ canvas.addEventListener('touchstart', $.proxy(this.onMouseDown, this));
469
+ canvas.addEventListener('touchmove', $.proxy(this.onMouseMove, this));
470
+ canvas.addEventListener('touchend', $.proxy(this.onMouseUp, this));
471
+ };
472
+ SignatureDialog.prototype.unwiredDesignerEvents = function () {
473
+ var canvas = this.container.find('#' + this.id + '_signDialog_canvas')[0];
474
+ canvas.removeEventListener('mousedown', $.proxy(this.onMouseDown, this));
475
+ canvas.removeEventListener('mousemove', $.proxy(this.onMouseMove, this));
476
+ canvas.removeEventListener('mouseup', $.proxy(this.onMouseUp, this));
477
+ canvas.removeEventListener('mouseenter', $.proxy(this.onMouseEnter, this));
478
+ canvas.removeEventListener('mouseleave', $.proxy(this.onMouseLeave, this));
479
+ canvas.removeEventListener('touchstart', $.proxy(this.onMouseDown, this));
480
+ canvas.removeEventListener('touchmove', $.proxy(this.onMouseMove, this));
481
+ canvas.removeEventListener('touchend', $.proxy(this.onMouseUp, this));
482
+ };
483
+ SignatureDialog.prototype.getLocale = function (text) {
484
+ var locale;
485
+ var defaultLocale = SignatureDialog.Locale['en-US'];
486
+ if (!ej.isNullOrUndefined(SignatureDialog.Locale[this.locale])) {
487
+ locale = SignatureDialog.Locale[this.locale];
488
+ }
489
+ switch (text.toLowerCase()) {
490
+ case 'title':
491
+ if (locale && locale.title) {
492
+ return locale.title;
493
+ }
494
+ return defaultLocale.title;
495
+ case 'closetooltip':
496
+ if (locale && locale.closeToolTip) {
497
+ return locale.closeToolTip;
498
+ }
499
+ return defaultLocale.closeToolTip;
500
+ case 'ok':
501
+ if (locale && locale.ok) {
502
+ return locale.ok;
503
+ }
504
+ return defaultLocale.ok;
505
+ case 'cancel':
506
+ if (locale && locale.cancel) {
507
+ return locale.cancel;
508
+ }
509
+ return defaultLocale.cancel;
510
+ case 'clear':
511
+ if (locale && locale.clear) {
512
+ return locale.clear;
513
+ }
514
+ return defaultLocale.clear;
515
+ case 'strokecolor':
516
+ if (locale && locale.strokeColor) {
517
+ return locale.strokeColor;
518
+ }
519
+ return defaultLocale.strokeColor;
520
+ case 'strokewidth':
521
+ if (locale && locale.strokeWidth) {
522
+ return locale.strokeWidth;
523
+ }
524
+ return defaultLocale.strokeWidth;
525
+ case 'crop':
526
+ if (locale && locale.crop) {
527
+ return locale.crop;
528
+ }
529
+ return defaultLocale.crop;
530
+ }
531
+ return text;
532
+ };
533
+ SignatureDialog.prototype.colorPickerOpen = function (args) {
534
+ if (window.innerHeight <=
535
+ parseFloat(args.element.offsetParent.style.top) +
536
+ args.element.offsetParent.clientHeight) {
537
+ args.element.offsetParent.style.top = '0px';
538
+ }
539
+ };
540
+ SignatureDialog.prototype.colorPickerModeSwitch = function (args) {
541
+ if (window.innerHeight <=
542
+ parseFloat(args.element.offsetParent.style.top) +
543
+ args.element.offsetParent.clientHeight) {
544
+ args.element.offsetParent.style.top = '0px';
545
+ }
546
+ };
547
+ SignatureDialog.prototype.hasDesignerInstance = function (instance) {
548
+ return instance && instance.pluginName && instance.pluginName.toLowerCase() === 'boldreportdesigner';
549
+ };
550
+ SignatureDialog.prototype.hasViewerInstance = function (instance) {
551
+ return instance && instance.pluginName && instance.pluginName.toLowerCase() === 'boldreportviewer';
552
+ };
553
+ SignatureDialog.prototype.invokeCallBack = function (fnction, args) {
554
+ if (fnction) {
555
+ if (typeof fnction === 'function') {
556
+ fnction(args);
557
+ }
558
+ else if (typeof fnction === 'string' && window[fnction]) {
559
+ var callBack = (fnction);
560
+ window[callBack](args);
561
+ }
562
+ else if (typeof fnction === 'string' && this[fnction]) {
563
+ var callBack = (fnction);
564
+ this[callBack](args);
565
+ }
566
+ }
567
+ };
568
+ SignatureDialog.prototype.buildElement = function (tag, classes, innerHtml, styles, attributes) {
569
+ var tagElement = document.createElement(tag);
570
+ if (classes && classes.length > 0) {
571
+ tagElement.className = '' + classes;
572
+ }
573
+ if (innerHtml) {
574
+ var txtNode = document.createTextNode(innerHtml);
575
+ tagElement.appendChild(txtNode);
576
+ }
577
+ if (attributes) {
578
+ var keys = Object.keys(attributes);
579
+ for (var index = 0; index < keys.length; index++) {
580
+ tagElement.setAttribute(keys[index], attributes[keys[index]]);
581
+ }
582
+ }
583
+ if (styles) {
584
+ var keys = Object.keys(styles);
585
+ for (var index = 0; index < keys.length; index++) {
586
+ tagElement.style[keys[index]] = styles[keys[index]];
587
+ }
588
+ }
589
+ return $(tagElement);
590
+ };
591
+ SignatureDialog.prototype.dispose = function () {
592
+ if (!ej.isNullOrUndefined(this.container) && this.container.length > 0
593
+ && !ej.isNullOrUndefined(this.dlgInstance)) {
594
+ if (this.hasViewerInstance(this.instance)) {
595
+ this.instance._destroyEJ2Objects(this.container.find('.e-dlg-content .e-signDialog-root-container'));
596
+ }
597
+ else {
598
+ ej.ReportUtil.destroyEj2Objects(this.container.find('.e-dlg-content .e-signDialog-root-container'));
599
+ }
600
+ this.dlgInstance.destroy();
601
+ this.container = null;
602
+ this.canvasElement = null;
603
+ this.instance = null;
604
+ this.isDrawing = false;
605
+ this.resetGlobalVbles();
606
+ $('#' + this.id + '_signDialog').remove();
607
+ }
608
+ };
609
+ SignatureDialog.prototype.resetGlobalVbles = function () {
610
+ this.callBackfn = null;
611
+ this.strokeColorObj = null;
612
+ this.dropDownObj = null;
613
+ this.locale = 'en-US';
614
+ this.isCropping = false;
615
+ this.isCropEnabled = false;
616
+ this.cropStartX = null;
617
+ this.cropStartY = null;
618
+ this.lastX = null;
619
+ this.lastY = null;
620
+ this.isMouseDown = false;
621
+ this.dlgInstance = null;
622
+ this.container = null;
623
+ };
624
+ return SignatureDialog;
625
+ }());
626
+ SignatureDialog.Locale = {};
627
+ SignatureDialog.Instance = new SignatureDialog();
628
+ SignatureDialog.Locale['en-US'] = {
629
+ cancel: 'Cancel',
630
+ closeToolTip: 'Close',
631
+ clear: 'Clear',
632
+ ok: 'OK',
633
+ title: 'Signature',
634
+ strokeColor: 'Stroke Color',
635
+ strokeWidth: 'Stroke Width',
636
+ crop: 'Crop'
637
+ };
638
+ SignatureDialog.Locale['ar-AE'] = {
639
+ cancel: 'إلغاء',
640
+ closeToolTip: 'إغلاق',
641
+ clear: 'مسح',
642
+ ok: 'موافق',
643
+ title: 'التوقيع',
644
+ strokeColor: 'لون الخط',
645
+ strokeWidth: 'عرض الخط',
646
+ crop: 'اقتصاص'
647
+ };
648
+ SignatureDialog.Locale['fr-FR'] = {
649
+ cancel: 'Annuler',
650
+ closeToolTip: 'Fermer',
651
+ ok: 'OK',
652
+ title: 'Signature',
653
+ clear: 'Effacer',
654
+ strokeColor: 'Couleur du trait',
655
+ strokeWidth: 'Épaisseur du trait',
656
+ crop: 'Recadrer'
657
+ };
658
+ SignatureDialog.Locale['de-DE'] = {
659
+ cancel: 'Abbrechen',
660
+ closeToolTip: 'Schließen',
661
+ ok: 'OK',
662
+ title: 'Unterschrift',
663
+ clear: 'Löschen',
664
+ strokeColor: 'Strichfarbe',
665
+ strokeWidth: 'Strichstärke',
666
+ crop: 'Zuschneiden'
667
+ };
668
+ SignatureDialog.Locale['en-AU'] = {
669
+ cancel: 'Cancel',
670
+ closeToolTip: 'Close',
671
+ clear: 'Clear',
672
+ ok: 'OK',
673
+ title: 'Signature',
674
+ strokeColor: 'Stroke Color',
675
+ strokeWidth: 'Stroke Width',
676
+ crop: 'Crop'
677
+ };
678
+ SignatureDialog.Locale['en-CA'] = {
679
+ cancel: 'Cancel',
680
+ closeToolTip: 'Close',
681
+ clear: 'Clear',
682
+ ok: 'OK',
683
+ title: 'Signature',
684
+ strokeColor: 'Stroke Color',
685
+ strokeWidth: 'Stroke Width',
686
+ crop: 'Crop'
687
+ };
688
+ SignatureDialog.Locale['it-IT'] = {
689
+ cancel: 'Annulla',
690
+ closeToolTip: 'Chiudi',
691
+ ok: 'OK',
692
+ title: 'Firma',
693
+ clear: 'Cancella',
694
+ strokeColor: 'Colore tratto',
695
+ strokeWidth: 'Spessore tratto',
696
+ crop: 'Ritaglia'
697
+ };
698
+ SignatureDialog.Locale['es-ES'] = {
699
+ cancel: 'Cancelar',
700
+ closeToolTip: 'Cerrar',
701
+ ok: 'Aceptar',
702
+ title: 'Firma',
703
+ clear: 'Borrar',
704
+ strokeColor: 'Color del trazo',
705
+ strokeWidth: 'Ancho del trazo',
706
+ crop: 'Recortar'
707
+ };
708
+ SignatureDialog.Locale['fr-CA'] = {
709
+ cancel: 'Annuler',
710
+ closeToolTip: 'Fermer',
711
+ ok: 'OK',
712
+ title: 'Signature',
713
+ clear: 'Effacer',
714
+ strokeColor: 'Couleur du trait',
715
+ strokeWidth: 'Épaisseur du trait',
716
+ crop: 'Recadrer'
717
+ };
718
+ SignatureDialog.Locale['tr-TR'] = {
719
+ cancel: 'İptal',
720
+ closeToolTip: 'Kapat',
721
+ ok: 'Tamam',
722
+ title: 'İmza',
723
+ clear: 'Temizle',
724
+ strokeColor: 'Çizgi Rengi',
725
+ strokeWidth: 'Çizgi Kalınlığı',
726
+ crop: 'Kırp'
727
+ };
728
+ SignatureDialog.Locale['zh-CN'] = {
729
+ cancel: '取消',
730
+ closeToolTip: '关闭',
731
+ ok: '确定',
732
+ title: '签名',
733
+ clear: '清除',
734
+ strokeColor: '笔触颜色',
735
+ strokeWidth: '笔触宽度',
736
+ crop: '裁剪'
737
+ };