@boldreports/javascript-reporting-extensions 6.3.17 → 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,27 @@
1
+ .e-rptdesigner-designarea:not(.e-waitingpopup) .customitem-signature {
2
+ background-repeat: no-repeat;
3
+ height: 42px;
4
+ background-position: center;
5
+ background-image: url('images/signature.svg');
6
+ }
7
+
8
+ .e-rptdesigner-customItem-sign {
9
+ border: 1px dotted gray;
10
+ overflow: hidden;
11
+ position: absolute;
12
+ height: 100%;
13
+ width: 100%;
14
+ }
15
+
16
+ .e-rptdesigner-sign-editIcon {
17
+ float: right;
18
+ height: 17px;
19
+ width: 24px;
20
+ padding: 1px;
21
+ right: 0px;
22
+ position: absolute;
23
+ z-index: 1003;
24
+ top: 7px;
25
+ background-image: url('images/editicon.svg');
26
+ background-repeat: no-repeat;
27
+ }
@@ -0,0 +1,446 @@
1
+ var EJSignature = (function () {
2
+ function EJSignature(instance) {
3
+ this.customJSON = null;
4
+ this.rootElement = null;
5
+ this.customItemDiv = null;
6
+ this.instance = null;
7
+ this.canvasTag = null;
8
+ this.customItemInstance = null;
9
+ this.instance = instance;
10
+ }
11
+ EJSignature.prototype.initializeItem = function (args) {
12
+ args.isBuildInService = false;
13
+ args.defaultHeight = 120;
14
+ args.defaultWidth = 180;
15
+ args.minimumHeight = 15;
16
+ args.minimumWidth = 90;
17
+ };
18
+ EJSignature.prototype.renderItem = function (customJson, target) {
19
+ this.customJSON = customJson;
20
+ this.rootElement = target;
21
+ this.customItemInstance = target.data('CustomItem');
22
+ this.renderSignature();
23
+ };
24
+ EJSignature.prototype.renderSignature = function () {
25
+ this.customItemDiv = this.buildElement('div', 'customitem e-rptdesigner-customItem-sign', '', {}, {});
26
+ this.canvasTag = this.buildElement('canvas', '', '', { id: this.customJSON.Name + '_customItem_canvas' }, { width: '100%', height: '100%' });
27
+ this.customItemDiv.append(this.canvasTag);
28
+ this.rootElement.append(this.customItemDiv);
29
+ var bgColor = (this.customJSON && this.customJSON.Style) ? (this.customJSON.Style.BackgroundColor === 'Transparent' ?
30
+ 'white' : this.customJSON.Style.BackgroundColor) : 'white';
31
+ var imgData = this.getPropertyVal('SignatureValue');
32
+ imgData = imgData && imgData.length > 0 ? 'data:image/png;base64,' + imgData : imgData;
33
+ this.setSign(imgData, document.getElementById(this.customJSON.Name + '_customItem_canvas'), bgColor);
34
+ };
35
+ EJSignature.prototype.onPropertyChange = function (name, oldValue, newValue) {
36
+ var args = [];
37
+ for (var _i = 3; _i < arguments.length; _i++) {
38
+ args[_i - 3] = arguments[_i];
39
+ }
40
+ switch (name.toLowerCase()) {
41
+ case 'backgroundcolor':
42
+ this.canvasTag.css('background-color', newValue === 'Transparent' ? 'white' : newValue);
43
+ break;
44
+ }
45
+ };
46
+ EJSignature.prototype.updatePropertyUIValue = function (name, value) {
47
+ if (this.hasDesignerInstance(this.instance)) {
48
+ switch (name.toLowerCase()) {
49
+ case 'backgroundcolor':
50
+ this.instance.propertyPanel.updatePropertyUIValue('backgroundcolor', value, this.customJSON.UniqueId);
51
+ break;
52
+ }
53
+ }
54
+ };
55
+ EJSignature.prototype.onPositionChanged = function (top, left) {
56
+ };
57
+ EJSignature.prototype.onSizeChanged = function (height, width) {
58
+ var imgData = this.getPropertyVal('SignatureValue');
59
+ imgData = imgData && imgData.length > 0 ? 'data:image/png;base64,' + imgData : imgData;
60
+ if (!ej.isNullOrUndefined(height) && !ej.isNullOrUndefined(width)) {
61
+ this.customItemDiv.css({
62
+ width: width,
63
+ height: height
64
+ });
65
+ this.canvasTag.css({
66
+ width: width,
67
+ height: height
68
+ });
69
+ }
70
+ else if (!ej.isNullOrUndefined(height) && ej.isNullOrUndefined(width)) {
71
+ this.customItemDiv.css({
72
+ height: height
73
+ });
74
+ this.canvasTag.css({
75
+ height: height
76
+ });
77
+ }
78
+ else if (ej.isNullOrUndefined(height) && !ej.isNullOrUndefined(width)) {
79
+ this.customItemDiv.css({
80
+ width: width
81
+ });
82
+ this.canvasTag.css({
83
+ width: width
84
+ });
85
+ }
86
+ this.setSign(imgData, document.getElementById(this.customJSON.Name + '_customItem_canvas'), this.customJSON.Style.BackgroundColor === 'Transparent' ? 'white' : this.customJSON.Style.BackgroundColor);
87
+ };
88
+ EJSignature.prototype.customAction = function (paramInfo) {
89
+ var imgData = this.getPropertyVal('SignatureValue');
90
+ imgData = imgData && imgData.length > 0 ? 'data:image/png;base64,' + imgData : null;
91
+ var dlgData = {
92
+ callBackFn: $.proxy(this.saveSign, this, false),
93
+ locale: this.instance.model.locale,
94
+ imageData: imgData,
95
+ canvas: null
96
+ };
97
+ if (this.hasDesignerInstance(this.instance)) {
98
+ var dlgInstance = window['SignatureDialog'].Instance;
99
+ dlgInstance.openDialog(this.instance, dlgData);
100
+ }
101
+ };
102
+ EJSignature.prototype.getPropertyGridItems = function () {
103
+ var propertyItems = {
104
+ 'HeaderText': this.customJSON.Name,
105
+ 'PropertyType': 'sign',
106
+ 'SubType': 'signature',
107
+ 'IsEditHeader': true,
108
+ 'Items': [{
109
+ 'CategoryId': 'basicsettings',
110
+ 'DisplayName': 'categoryBasicSettings',
111
+ 'IsExpand': true,
112
+ 'IsIgnoreCommon': true,
113
+ 'Items': [{
114
+ ItemId: 'signature',
115
+ Name: 'signature',
116
+ DisplayName: 'signature',
117
+ ItemType: 'CustomBtn',
118
+ IsVisible: true
119
+ }]
120
+ }],
121
+ 'getItemProperty': {
122
+ event: $.proxy(this.customAction, this), eventData: {}
123
+ }
124
+ };
125
+ return propertyItems;
126
+ };
127
+ EJSignature.prototype.setSign = function (imgData, canvas, bgColor) {
128
+ if (canvas) {
129
+ canvas.style.backgroundColor = bgColor;
130
+ if (imgData) {
131
+ var image = new Image();
132
+ image.src = imgData;
133
+ image.onload = $.proxy(this.drawImage, this, image, canvas);
134
+ }
135
+ }
136
+ };
137
+ EJSignature.prototype.drawImage = function (image, canvas) {
138
+ var ctx = canvas.getContext('2d');
139
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
140
+ ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
141
+ };
142
+ EJSignature.prototype.clearSign = function (canvas) {
143
+ if (canvas && canvas.getContext) {
144
+ var ctx = canvas.getContext('2d');
145
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
146
+ }
147
+ };
148
+ EJSignature.prototype.setPropertyVal = function (name, val) {
149
+ if (this.customJSON.CustomProperties === null) {
150
+ this.customJSON.CustomProperties = [];
151
+ }
152
+ this.customJSON.CustomProperties.push(new ej.ReportModel.CustomProperty(name, val));
153
+ };
154
+ EJSignature.prototype.getPropertyVal = function (name) {
155
+ if (this.customJSON.CustomProperties && this.customJSON.CustomProperties.length > 0) {
156
+ for (var index = 0; index < this.customJSON.CustomProperties.length; index++) {
157
+ if (this.customJSON.CustomProperties[index].Name === name) {
158
+ return this.customJSON.CustomProperties[index].Value;
159
+ }
160
+ }
161
+ }
162
+ return null;
163
+ };
164
+ EJSignature.prototype.updatePropertyVal = function (propertyName, value) {
165
+ if (this.customJSON.CustomProperties && this.customJSON.CustomProperties.length > 0) {
166
+ for (var index = 0; index < this.customJSON.CustomProperties.length; index++) {
167
+ if (this.customJSON.CustomProperties[index].Name === propertyName) {
168
+ this.customJSON.CustomProperties[index].Value = value;
169
+ break;
170
+ }
171
+ }
172
+ }
173
+ };
174
+ EJSignature.prototype.getReportItemJson = function () {
175
+ if (this.customJSON === null) {
176
+ this.customJSON = new ej.ReportModel.CustomReportItem().getModel();
177
+ this.setPropertyVal('SignatureValue', '');
178
+ this.setPropertyVal('ContentEditable', 'true');
179
+ }
180
+ return this.customJSON;
181
+ };
182
+ EJSignature.prototype.setReportItemJson = function (reportItem) {
183
+ this.customJSON = reportItem;
184
+ };
185
+ EJSignature.prototype.saveSign = function (isUndoRedo, imageDetails) {
186
+ var imgData = imageDetails ? imageDetails.imageData : null;
187
+ var prevVal = this.getPropertyVal('SignatureValue');
188
+ prevVal = prevVal && prevVal.length > 0 ? 'data:image/png;base64,' + prevVal : prevVal;
189
+ if (imgData) {
190
+ var base64String = imgData.replace('data:image/png;base64,', '');
191
+ this.updatePropertyVal('SignatureValue', base64String);
192
+ this.setSign(imgData, document.getElementById(this.customJSON.Name + '_customItem_canvas'), this.customJSON.Style.BackgroundColor === 'Transparent' ? 'white' : this.customJSON.Style.BackgroundColor);
193
+ }
194
+ else {
195
+ this.clearSign(document.getElementById(this.customJSON.Name + '_customItem_canvas'));
196
+ this.updatePropertyVal('SignatureValue', '');
197
+ }
198
+ if (!isUndoRedo) {
199
+ this.customItemInstance.addCustomAction('CommandAction', [{ method: 'saveSign', imageData: prevVal, propertyName: 'signature', undoRedo: false }], [{ method: 'saveSign', imageData: imgData, propertyName: 'signature', undoRedo: true }]);
200
+ }
201
+ };
202
+ EJSignature.prototype.undoRedoAction = function (canvasInfo) {
203
+ if (canvasInfo) {
204
+ if (canvasInfo.propertyName && canvasInfo.propertyName.toLowerCase() === 'signature') {
205
+ ej.ReportUtil.invokeMethod(this, canvasInfo.method, [canvasInfo.undoRedo, { imageData: canvasInfo.imageData }]);
206
+ }
207
+ }
208
+ };
209
+ EJSignature.prototype.hasDesignerInstance = function (instance) {
210
+ return instance && instance.pluginName && instance.pluginName.toLowerCase() === 'boldreportdesigner';
211
+ };
212
+ EJSignature.prototype.hasViewerInstance = function (instance) {
213
+ return instance && instance.pluginName && instance.pluginName.toLowerCase() === 'boldreportviewer';
214
+ };
215
+ EJSignature.prototype.getLocale = function (text) {
216
+ var signatureLocale;
217
+ var defaultLocale = EJSignature.Locale['en-US'];
218
+ if (this.instance && this.hasDesignerInstance(this.instance) && !ej.isNullOrUndefined(this.instance.model) && !ej.isNullOrUndefined(EJSignature.Locale[this.instance.model.locale])) {
219
+ signatureLocale = EJSignature.Locale[this.instance.model.locale];
220
+ }
221
+ switch (text.toLowerCase()) {
222
+ case 'signature':
223
+ if (signatureLocale && signatureLocale.signatureLabel) {
224
+ return signatureLocale.signatureLabel;
225
+ }
226
+ return defaultLocale.signatureLabel;
227
+ case 'categorybasicsettings':
228
+ if (signatureLocale && signatureLocale.categoryBasicSettings) {
229
+ return signatureLocale.categoryBasicSettings;
230
+ }
231
+ return defaultLocale.categoryBasicSettings;
232
+ case 'btndisplaytext':
233
+ if (signatureLocale && signatureLocale.btnText) {
234
+ return signatureLocale.btnText;
235
+ }
236
+ return defaultLocale.btnText;
237
+ }
238
+ return text;
239
+ };
240
+ EJSignature.prototype.buildElement = function (tag, classes, innerHtml, attributes, styles) {
241
+ var tagElement = document.createElement(tag);
242
+ if (classes && classes.length > 0) {
243
+ tagElement.className = '' + classes;
244
+ }
245
+ if (innerHtml) {
246
+ var txtNode = document.createTextNode(innerHtml);
247
+ tagElement.appendChild(txtNode);
248
+ }
249
+ if (attributes) {
250
+ var keys = Object.keys(attributes);
251
+ for (var index = 0; index < keys.length; index++) {
252
+ tagElement.setAttribute(keys[index], attributes[keys[index]]);
253
+ }
254
+ }
255
+ if (styles) {
256
+ var keys = Object.keys(styles);
257
+ for (var index = 0; index < keys.length; index++) {
258
+ tagElement.style[keys[index]] = styles[keys[index]];
259
+ }
260
+ }
261
+ return $(tagElement);
262
+ };
263
+ EJSignature.prototype.dispose = function () {
264
+ this.canvasTag = null;
265
+ this.instance = null;
266
+ this.customItemInstance = null;
267
+ this.customItemDiv = null;
268
+ this.customJSON = null;
269
+ this.rootElement = null;
270
+ };
271
+ EJSignature.prototype.renderItemPreview = function (criModel, targetDiv, locale) {
272
+ var canvas = this.buildElement('canvas', '', '', {}, { width: '100%', height: '100%' });
273
+ var editIcon = this.buildElement('span', 'e-designer-click e-rptdesigner-sign-editIcon', '', {}, { 'display': 'none' });
274
+ var bgColor = criModel.BackgroundColor;
275
+ var imgData = criModel.ImageUrl;
276
+ var proxy = this;
277
+ var callBackFn = function (imageDetails) {
278
+ proxy.updateSignature(imageDetails, ej.isNullOrUndefined(criModel.ItemName) ? criModel.Name : criModel.ItemName);
279
+ proxy.saveViewerSignature(imageDetails);
280
+ };
281
+ $(targetDiv).append(canvas, editIcon);
282
+ $(targetDiv).bind('mouseenter', $.proxy(this.showEditIcon, this, editIcon));
283
+ $(targetDiv).bind('mouseleave', $.proxy(this.hideEditIcon, this, editIcon));
284
+ imgData = imgData && imgData.length > 0 ? 'data:image/png;base64,' + imgData : imgData;
285
+ bgColor = bgColor === 'Transparent' ? 'white' : bgColor;
286
+ this.setSign(imgData, canvas[0], bgColor);
287
+ canvas.attr('imageString', imgData);
288
+ var dataInfo = {
289
+ callBackfn: callBackFn, locale: locale
290
+ };
291
+ editIcon.bind('click', $.proxy(this.invokeDialog, this, canvas, dataInfo));
292
+ };
293
+ EJSignature.prototype.updateSignature = function (imageDetails, reportItemName) {
294
+ if (this.hasViewerInstance(this.instance) && imageDetails.imageData && imageDetails.imageData.length > 0) {
295
+ (this.instance).doAjaxPost('POST', (this.instance)._actionUrl, JSON.stringify({
296
+ 'reportAction': 'UpdateValue',
297
+ 'modelType': 'CustomReportItemModel',
298
+ 'newValue': { 'imageData': imageDetails.imageData.replace(/^data:image\/png;base64,/, '') },
299
+ 'itemName': reportItemName
300
+ }), '_handleCustomItemError');
301
+ }
302
+ };
303
+ EJSignature.prototype.showEditIcon = function (editIcon) {
304
+ editIcon.css('display', 'block');
305
+ };
306
+ EJSignature.prototype.hideEditIcon = function (editIcon) {
307
+ editIcon.css('display', 'none');
308
+ };
309
+ EJSignature.prototype.invokeDialog = function (canvas, dataInfo) {
310
+ var dlgInstance = window['SignatureDialog'].Instance;
311
+ var dlgData = {
312
+ callBackFn: $.proxy(dataInfo.callBackfn, this),
313
+ locale: dataInfo.locale,
314
+ imageData: canvas.attr('imageString'),
315
+ canvas: canvas
316
+ };
317
+ if (this.hasViewerInstance(this.instance) && dlgInstance) {
318
+ dlgInstance.openDialog(this.instance, dlgData);
319
+ }
320
+ };
321
+ EJSignature.prototype.saveViewerSignature = function (imageDetails) {
322
+ var imgData = imageDetails != null ? imageDetails.imageData : null;
323
+ if (imgData) {
324
+ var canvas = imageDetails.canvasElement;
325
+ if (canvas) {
326
+ this.setSign(imgData, canvas[0], imageDetails.bgColor);
327
+ $(canvas).attr('imageString', imgData);
328
+ }
329
+ }
330
+ else {
331
+ this.clearSign(imageDetails.canvasElement);
332
+ }
333
+ };
334
+ return EJSignature;
335
+ }());
336
+ EJSignature.Locale = {};
337
+ EJSignature.Locale['ar-AE'] = {
338
+ btnText: 'رسم',
339
+ categoryBasicSettings: 'الإعدادات الأساسية',
340
+ signatureLabel: 'التوقيع',
341
+ toolTip: {
342
+ requirements: 'عرض أي توقيع إلكتروني للتوقيع.',
343
+ description: 'يُستخدم عنصر التقرير هذا لإضافة توقيع رسومي',
344
+ title: 'التوقيع'
345
+ }
346
+ };
347
+ EJSignature.Locale['en-US'] = {
348
+ btnText: 'Draw',
349
+ categoryBasicSettings: 'Basic Settings',
350
+ signatureLabel: 'Signature',
351
+ toolTip: {
352
+ requirements: 'Display any electronic signature for signing.',
353
+ description: 'This report item is used to add a graphic signature',
354
+ title: 'Signature'
355
+ }
356
+ };
357
+ EJSignature.Locale['fr-FR'] = {
358
+ signatureLabel: 'Signature',
359
+ btnText: 'Dessiner',
360
+ categoryBasicSettings: 'Paramètres de base',
361
+ toolTip: {
362
+ requirements: 'Afficher toute signature électronique pour la signature.',
363
+ description: 'Cet élément de rapport est utilisé pour ajouter une signature graphique',
364
+ title: 'Signature'
365
+ }
366
+ };
367
+ EJSignature.Locale['de-DE'] = {
368
+ signatureLabel: 'Unterschrift',
369
+ btnText: 'ziehen',
370
+ categoryBasicSettings: 'Grundlegende Einstellungen',
371
+ toolTip: {
372
+ requirements: 'Zeigen Sie alle elektronischen Signaturen für die Unterschrift an.',
373
+ description: 'Dieses Element wird verwendet, um eine grafische Unterschrift hinzuzufügen.',
374
+ title: 'Unterschrift'
375
+ }
376
+ };
377
+ EJSignature.Locale['en-AU'] = {
378
+ btnText: 'Draw',
379
+ categoryBasicSettings: 'Basic Settings',
380
+ signatureLabel: 'Signature',
381
+ toolTip: {
382
+ requirements: 'Display any electronic signature for signing.',
383
+ description: 'This report item is used to add a graphic signature',
384
+ title: 'Signature'
385
+ }
386
+ };
387
+ EJSignature.Locale['en-CA'] = {
388
+ btnText: 'Draw',
389
+ categoryBasicSettings: 'Basic Settings',
390
+ signatureLabel: 'Signature',
391
+ toolTip: {
392
+ requirements: 'Display any electronic signature for signing.',
393
+ description: 'This report item is used to add a graphic signature',
394
+ title: 'Signature'
395
+ }
396
+ };
397
+ EJSignature.Locale['es-ES'] = {
398
+ signatureLabel: 'Firma',
399
+ categoryBasicSettings: 'Configuración básica',
400
+ btnText: 'Dibujar',
401
+ toolTip: {
402
+ requirements: 'Mostrar todas las firmas electrónicas para la firma.',
403
+ description: 'Este elemento de informe se utiliza para agregar una firma gráfica.',
404
+ title: 'Firma'
405
+ }
406
+ };
407
+ EJSignature.Locale['it-IT'] = {
408
+ signatureLabel: 'Firma',
409
+ categoryBasicSettings: 'Impostazioni di base',
410
+ btnText: 'Disegna',
411
+ toolTip: {
412
+ requirements: 'Mostra tutte le firme elettroniche per la firma.',
413
+ description: 'Questo elemento di report viene utilizzato per aggiungere una firma grafica.',
414
+ title: 'Firma'
415
+ }
416
+ };
417
+ EJSignature.Locale['fr-CA'] = {
418
+ signatureLabel: 'Signature',
419
+ categoryBasicSettings: 'Paramètres de base',
420
+ btnText: 'Dessiner',
421
+ toolTip: {
422
+ requirements: 'Afficher toute signature électronique pour la signature.',
423
+ description: 'Cet élément de rapport est utilisé pour ajouter une signature graphique',
424
+ title: 'Signature'
425
+ }
426
+ };
427
+ EJSignature.Locale['tr-TR'] = {
428
+ signatureLabel: 'İmza',
429
+ categoryBasicSettings: 'Temel Ayarlar',
430
+ btnText: 'çizmek',
431
+ toolTip: {
432
+ requirements: 'İmza için tüm elektronik imzaları göster.',
433
+ description: 'Bu rapor öğesi grafiksel bir imza eklemek için kullanılır.',
434
+ title: 'İmza'
435
+ }
436
+ };
437
+ EJSignature.Locale['zh-CN'] = {
438
+ signatureLabel: '签名',
439
+ categoryBasicSettings: '基本设置',
440
+ btnText: '绘制签名',
441
+ toolTip: {
442
+ requirements: '显示所有电子签名以进行签名。',
443
+ description: '此报表项用于添加图形签名。',
444
+ title: '签名'
445
+ }
446
+ };