@syncfusion/ej2-image-editor 21.2.10 → 22.1.36

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.
Files changed (107) hide show
  1. package/.eslintrc.json +1 -0
  2. package/CHANGELOG.md +8 -32
  3. package/dist/ej2-image-editor.umd.min.js +2 -2
  4. package/dist/ej2-image-editor.umd.min.js.map +1 -1
  5. package/dist/es6/ej2-image-editor.es2015.js +19320 -12622
  6. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  7. package/dist/es6/ej2-image-editor.es5.js +19139 -12414
  8. package/dist/es6/ej2-image-editor.es5.js.map +1 -1
  9. package/dist/global/ej2-image-editor.min.js +2 -2
  10. package/dist/global/ej2-image-editor.min.js.map +1 -1
  11. package/dist/global/index.d.ts +1 -1
  12. package/package.json +11 -11
  13. package/src/image-editor/action/crop.d.ts +36 -0
  14. package/src/image-editor/action/crop.js +829 -0
  15. package/src/image-editor/action/draw.d.ts +125 -0
  16. package/src/image-editor/action/draw.js +3263 -0
  17. package/src/image-editor/action/export.d.ts +23 -0
  18. package/src/image-editor/action/export.js +364 -0
  19. package/src/image-editor/action/filter.d.ts +35 -0
  20. package/src/image-editor/action/filter.js +699 -0
  21. package/src/image-editor/action/freehand-draw.d.ts +61 -0
  22. package/src/image-editor/action/freehand-draw.js +1015 -0
  23. package/src/image-editor/action/index.d.ts +9 -0
  24. package/src/image-editor/action/index.js +9 -0
  25. package/src/image-editor/action/selection.d.ts +139 -0
  26. package/src/image-editor/action/selection.js +4518 -0
  27. package/src/image-editor/action/shape.d.ts +94 -0
  28. package/src/image-editor/action/shape.js +2745 -0
  29. package/src/image-editor/action/transform.d.ts +67 -0
  30. package/src/image-editor/action/transform.js +1859 -0
  31. package/src/image-editor/action/undo-redo.d.ts +43 -0
  32. package/src/image-editor/action/undo-redo.js +800 -0
  33. package/src/image-editor/base/enum.d.ts +189 -0
  34. package/src/image-editor/base/enum.js +198 -0
  35. package/src/image-editor/{image-editor-model.d.ts → base/image-editor-model.d.ts} +130 -42
  36. package/src/image-editor/{image-editor.d.ts → base/image-editor.d.ts} +413 -1111
  37. package/src/image-editor/base/image-editor.js +2270 -0
  38. package/src/image-editor/base/index.d.ts +4 -0
  39. package/src/image-editor/base/index.js +2 -0
  40. package/src/image-editor/base/interface.d.ts +1128 -0
  41. package/src/image-editor/base/interface.js +1 -0
  42. package/src/image-editor/index.d.ts +3 -5
  43. package/src/image-editor/index.js +3 -4
  44. package/src/image-editor/renderer/index.d.ts +1 -0
  45. package/src/image-editor/renderer/index.js +1 -0
  46. package/src/image-editor/renderer/toolbar.d.ts +105 -0
  47. package/src/image-editor/renderer/toolbar.js +3018 -0
  48. package/styles/bootstrap-dark.css +69 -3
  49. package/styles/bootstrap.css +69 -3
  50. package/styles/bootstrap4.css +69 -3
  51. package/styles/bootstrap5-dark.css +69 -3
  52. package/styles/bootstrap5.css +69 -3
  53. package/styles/fabric-dark.css +69 -3
  54. package/styles/fabric.css +69 -3
  55. package/styles/fluent-dark.css +69 -3
  56. package/styles/fluent.css +69 -3
  57. package/styles/highcontrast-light.css +71 -5
  58. package/styles/highcontrast.css +72 -5
  59. package/styles/image-editor/_highcontrast-definition.scss +1 -1
  60. package/styles/image-editor/_highcontrast-light-definition.scss +1 -1
  61. package/styles/image-editor/_layout.scss +21 -7
  62. package/styles/image-editor/_material3-dark-definition.scss +1 -0
  63. package/styles/image-editor/_material3-definition.scss +11 -0
  64. package/styles/image-editor/_theme.scss +7 -2
  65. package/styles/image-editor/bootstrap-dark.css +69 -3
  66. package/styles/image-editor/bootstrap.css +69 -3
  67. package/styles/image-editor/bootstrap4.css +69 -3
  68. package/styles/image-editor/bootstrap5-dark.css +69 -3
  69. package/styles/image-editor/bootstrap5.css +69 -3
  70. package/styles/image-editor/fabric-dark.css +69 -3
  71. package/styles/image-editor/fabric.css +69 -3
  72. package/styles/image-editor/fluent-dark.css +69 -3
  73. package/styles/image-editor/fluent.css +69 -3
  74. package/styles/image-editor/highcontrast-light.css +71 -5
  75. package/styles/image-editor/highcontrast.css +72 -5
  76. package/styles/image-editor/icons/_bootstrap-dark.scss +132 -0
  77. package/styles/image-editor/icons/_bootstrap.scss +132 -0
  78. package/styles/image-editor/icons/_bootstrap4.scss +132 -0
  79. package/styles/image-editor/icons/_bootstrap5.scss +132 -0
  80. package/styles/image-editor/icons/_fabric-dark.scss +132 -0
  81. package/styles/image-editor/icons/_fabric.scss +132 -0
  82. package/styles/image-editor/icons/_fluent.scss +132 -0
  83. package/styles/image-editor/icons/_fusionnew.scss +132 -0
  84. package/styles/image-editor/icons/_highcontrast-light.scss +132 -0
  85. package/styles/image-editor/icons/_highcontrast.scss +132 -0
  86. package/styles/image-editor/icons/_material-dark.scss +132 -0
  87. package/styles/image-editor/icons/_material.scss +132 -0
  88. package/styles/image-editor/icons/_material3-dark.scss +1 -0
  89. package/styles/image-editor/icons/_material3.scss +133 -1
  90. package/styles/image-editor/icons/_tailwind.scss +132 -0
  91. package/styles/image-editor/material-dark.css +69 -3
  92. package/styles/image-editor/material.css +69 -3
  93. package/styles/image-editor/material3-dark.css +453 -0
  94. package/styles/image-editor/material3-dark.scss +14 -0
  95. package/styles/image-editor/material3.css +509 -0
  96. package/styles/image-editor/material3.scss +14 -0
  97. package/styles/image-editor/tailwind-dark.css +69 -3
  98. package/styles/image-editor/tailwind.css +69 -3
  99. package/styles/material-dark.css +69 -3
  100. package/styles/material.css +69 -3
  101. package/styles/material3-dark.css +453 -0
  102. package/styles/material3-dark.scss +3 -0
  103. package/styles/material3.css +509 -0
  104. package/styles/material3.scss +3 -0
  105. package/styles/tailwind-dark.css +69 -3
  106. package/styles/tailwind.css +69 -3
  107. package/src/image-editor/image-editor.js +0 -14827
@@ -0,0 +1,3018 @@
1
+ import { extend, Browser, detach, select } from '@syncfusion/ej2-base';
2
+ import { EventHandler, getComponent, isNullOrUndefined, L10n } from '@syncfusion/ej2-base';
3
+ import { Toolbar } from '@syncfusion/ej2-navigations';
4
+ import { DropDownButton } from '@syncfusion/ej2-splitbuttons';
5
+ import { ColorPicker, Uploader, Slider } from '@syncfusion/ej2-inputs';
6
+ import { ZoomTrigger } from '../index';
7
+ import { hideSpinner, showSpinner } from '@syncfusion/ej2-popups';
8
+ var ToolbarModule = /** @class */ (function () {
9
+ function ToolbarModule(parent) {
10
+ this.defToolbarItems = [];
11
+ this.toolbarHeight = 46;
12
+ this.currToolbar = '';
13
+ this.preventZoomBtn = false;
14
+ this.currentToolbar = 'main';
15
+ this.selFhdColor = '#42a5f5';
16
+ this.preventEnableDisableUr = false;
17
+ this.parent = parent;
18
+ this.addEventListener();
19
+ this.initLocale();
20
+ }
21
+ ToolbarModule.prototype.destroy = function () {
22
+ if (this.parent.isDestroyed) {
23
+ return;
24
+ }
25
+ this.removeEventListener();
26
+ };
27
+ ToolbarModule.prototype.addEventListener = function () {
28
+ this.parent.on('toolbar', this.toolbar, this);
29
+ this.parent.on('destroyed', this.destroy, this);
30
+ };
31
+ ToolbarModule.prototype.removeEventListener = function () {
32
+ this.parent.off('toolbar', this.toolbar);
33
+ this.parent.off('destroyed', this.destroy);
34
+ };
35
+ ToolbarModule.prototype.initLocale = function () {
36
+ this.defaultLocale = {
37
+ Crop: 'Crop',
38
+ ZoomIn: 'Zoom In',
39
+ ZoomOut: 'Zoom Out',
40
+ Undo: 'Undo',
41
+ Redo: 'Redo',
42
+ Transform: 'Transform',
43
+ Annotation: 'Annotation',
44
+ Finetune: 'Finetune',
45
+ Brightness: 'Brightness',
46
+ Contrast: 'Contrast',
47
+ Hue: 'Hue',
48
+ Saturation: 'Saturation',
49
+ Opacity: 'Opacity',
50
+ Blur: 'Blur',
51
+ Sharpen: 'Sharpen',
52
+ Exposure: 'Exposure',
53
+ Filter: 'Filter',
54
+ Default: 'Default',
55
+ Chrome: 'Chrome',
56
+ Cold: 'Cold',
57
+ Warm: 'Warm',
58
+ Grayscale: 'Grayscale',
59
+ BlackAndWhite: 'Black and White',
60
+ Sepia: 'Sepia',
61
+ Invert: 'Invert',
62
+ Text: 'Add Text',
63
+ Pen: 'Pen',
64
+ Reset: 'Reset',
65
+ Save: 'Save',
66
+ Select: 'Select',
67
+ RotateLeft: 'Rotate Left',
68
+ RotateRight: 'Rotate Right',
69
+ HorizontalFlip: 'Horizontal Flip',
70
+ VerticalFlip: 'Vertical Flip',
71
+ OK: 'OK',
72
+ Cancel: 'Cancel',
73
+ FillColor: 'Fill Color',
74
+ StrokeColor: 'Stroke Color',
75
+ StrokeWidth: 'Stroke Width',
76
+ FontFamily: 'Font Family',
77
+ FontStyle: 'Font Style',
78
+ FontSize: 'Font Size',
79
+ FontColor: 'Font Color',
80
+ Pan: 'Pan',
81
+ Move: 'Move',
82
+ Load: 'Load',
83
+ Custom: 'Custom',
84
+ Square: 'Square',
85
+ Circle: 'Circle',
86
+ Ellipse: 'Ellipse',
87
+ Rectangle: 'Rectangle',
88
+ Line: 'Line',
89
+ Arrow: 'Arrow',
90
+ Path: 'Path',
91
+ Bold: 'Bold',
92
+ Italic: 'Italic',
93
+ BoldItalic: 'Bold Italic',
94
+ XSmall: 'X-Small',
95
+ Small: 'Small',
96
+ Medium: 'Medium',
97
+ Large: 'Large',
98
+ XLarge: 'X-Large',
99
+ ABC: 'ABC',
100
+ Browse: 'Browse',
101
+ Duplicate: 'Duplicate',
102
+ Remove: 'Remove',
103
+ EditText: 'Edit Text',
104
+ Start: 'Start',
105
+ End: 'End',
106
+ Bar: 'Bar',
107
+ ArrowSolid: 'Arrow Solid',
108
+ CircleSolid: 'Circle Solid',
109
+ SquareSolid: 'Square Solid',
110
+ None: 'None',
111
+ CropAndTransform: 'Crop and Transform',
112
+ CropSelection: 'Crop Selection'
113
+ };
114
+ this.l10n = new L10n('image-editor', this.defaultLocale, this.parent.locale);
115
+ };
116
+ ToolbarModule.prototype.toolbar = function (args) {
117
+ var parent = this.parent;
118
+ this.updatePrivateVariables();
119
+ switch (args.prop) {
120
+ case 'create-toolbar':
121
+ this.createToolbar();
122
+ break;
123
+ case 'create-contextual-toolbar':
124
+ this.createContextualToolbar();
125
+ break;
126
+ case 'update-toolbar-items':
127
+ this.updateToolbarItems();
128
+ break;
129
+ case 'refresh-toolbar':
130
+ this.refreshToolbar(args.value['type'], args.value['isApplyBtn'], args.value['isCropping'], args.value['isZooming'], args.value['cType']);
131
+ break;
132
+ case 'renderQAT':
133
+ this.renderQAT(args.value['isPenEdit']);
134
+ break;
135
+ case 'enable-disable-btns':
136
+ this.enableDisableTbrBtn();
137
+ break;
138
+ case 'init-main-toolbar':
139
+ this.initMainToolbar(args.value['isApplyBtn'], args.value['isDevice'], args.value['isOkBtn']);
140
+ break;
141
+ case 'create-bottom-toolbar':
142
+ this.createBottomToolbar();
143
+ break;
144
+ case 'refresh-main-toolbar':
145
+ this.refreshMainToolbar();
146
+ break;
147
+ case 'create-qa-toolbar':
148
+ this.createQuickAccessToolbar();
149
+ break;
150
+ case 'destroy-qa-toolbar':
151
+ this.destroyQuickAccessToolbar();
152
+ break;
153
+ case 'zoom-up-handler':
154
+ this.zoomBtnMouseUpHandler();
155
+ break;
156
+ case 'refresh-dropdown-btn':
157
+ this.refreshDropDownBtn(args.value['isDisabled']);
158
+ break;
159
+ case 'close-contextual-toolbar':
160
+ this.closeContextualToolbar();
161
+ break;
162
+ case 'destroy-bottom-toolbar':
163
+ this.destroyBottomToolbar();
164
+ break;
165
+ case 'destroy-top-toolbar':
166
+ this.destroyTopToolbar();
167
+ break;
168
+ case 'destroySubComponents':
169
+ this.destroySubComponents();
170
+ break;
171
+ case 'setLocale':
172
+ this.l10n.setLocale(args.value['locale']);
173
+ break;
174
+ case 'setPreventZoomBtn':
175
+ this.preventZoomBtn = args.value['isPrevent'];
176
+ break;
177
+ case 'getToolbarHeight':
178
+ args.value['obj']['toolbarHeight'] = this.toolbarHeight;
179
+ break;
180
+ case 'setToolbarHeight':
181
+ this.toolbarHeight = args.value['height'];
182
+ break;
183
+ case 'setCurrentToolbar':
184
+ this.currentToolbar = args.value['type'];
185
+ break;
186
+ case 'setSelectedFreehandColor':
187
+ this.selFhdColor = args.value['color'];
188
+ break;
189
+ case 'getCurrentFilter':
190
+ args.value['obj']['currentFilter'] = parent.currentFilter;
191
+ break;
192
+ case 'setCurrentFilter':
193
+ parent.currentFilter = args.value['filter'];
194
+ break;
195
+ case 'setInitialAdjustmentValue':
196
+ parent.initialAdjustmentValue = args.value['value'];
197
+ break;
198
+ case 'getCanvasFilter':
199
+ args.value['obj']['canvasFilter'] = parent.canvasFilter;
200
+ break;
201
+ case 'setCanvasFilter':
202
+ parent.canvasFilter = args.value['filter'];
203
+ break;
204
+ case 'getDefToolbarItems':
205
+ args.value['obj']['defToolbarItems'] = this.defToolbarItems;
206
+ break;
207
+ case 'getPenStroke':
208
+ this.getPenStroke(args.value['value']);
209
+ break;
210
+ case 'performDefToolbarClickAction':
211
+ this.performDefTbrClick(args.value['type'], args.value['isContextualToolbar'], args.value['isDisabledAdjustment'], args.value['isDisabledFilter'], args.value['isFilterFinetune']);
212
+ break;
213
+ case 'setTempFilterProperties':
214
+ parent.setTempFilterProperties();
215
+ break;
216
+ case 'refreshSlider':
217
+ this.refreshSlider();
218
+ break;
219
+ case 'renderSlider':
220
+ this.renderSlider(args.value['type']);
221
+ break;
222
+ case 'getCurrAdjustmentValue':
223
+ parent.getCurrAdjustmentValue(args.value['type']);
224
+ break;
225
+ case 'setCurrAdjustmentValue':
226
+ parent.setCurrAdjustmentValue(args.value['type'], args.value['value']);
227
+ break;
228
+ case 'refreshShapeDrawing':
229
+ this.refreshShapeDrawing();
230
+ break;
231
+ case 'getCropToolbar':
232
+ args.value['obj']['isCropToolbar'] = parent.isCropToolbar;
233
+ break;
234
+ case 'getPrevCurrSelectionPoint':
235
+ args.value['obj']['prevCurrSelectionPoint'] = parent.prevCurrSelectionPoint;
236
+ break;
237
+ case 'setPrevCurrSelectionPoint':
238
+ parent.prevCurrSelectionPoint = args.value['point'];
239
+ break;
240
+ case 'updateCropTransformItems':
241
+ parent.updateCropTransformItems();
242
+ break;
243
+ case 'setEnableDisableUndoRedo':
244
+ this.preventEnableDisableUr = args.value['isPrevent'];
245
+ break;
246
+ case 'reset':
247
+ this.reset();
248
+ break;
249
+ }
250
+ };
251
+ ToolbarModule.prototype.updatePrivateVariables = function () {
252
+ var parent = this.parent;
253
+ this.inMemoryCanvas = parent.inMemoryCanvas;
254
+ if (parent.lowerCanvas) {
255
+ this.lowerContext = parent.lowerCanvas.getContext('2d');
256
+ }
257
+ if (parent.upperCanvas) {
258
+ this.upperContext = parent.upperCanvas.getContext('2d');
259
+ }
260
+ if (this.inMemoryCanvas) {
261
+ this.inMemoryContext = this.inMemoryCanvas.getContext('2d');
262
+ }
263
+ };
264
+ ToolbarModule.prototype.reset = function () {
265
+ var parent = this.parent;
266
+ this.defToolbarItems = [];
267
+ this.toolbarHeight = 46;
268
+ parent.prevCurrSelectionPoint = null;
269
+ this.zoomBtnHold = null;
270
+ this.currToolbar = '';
271
+ this.currentToolbar = 'main';
272
+ this.selFhdColor = '#42a5f5';
273
+ parent.currentFilter = '';
274
+ this.preventZoomBtn = parent.isCropToolbar = this.preventEnableDisableUr = false;
275
+ parent.initialAdjustmentValue = parent.canvasFilter =
276
+ 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
277
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
278
+ };
279
+ ToolbarModule.prototype.destroyTopToolbar = function () {
280
+ var parent = this.parent;
281
+ var toolbar = document.getElementById(parent.element.id + '_toolbar');
282
+ if (this.isToolbar() && toolbar && toolbar.classList.contains('e-control')) {
283
+ getComponent(document.getElementById(parent.element.id + '_toolbar'), 'toolbar').destroy();
284
+ }
285
+ };
286
+ ToolbarModule.prototype.destroyBottomToolbar = function () {
287
+ var parent = this.parent;
288
+ var toolbar = document.getElementById(parent.element.id + '_bottomToolbar');
289
+ if (toolbar && toolbar.classList.contains('e-control')) {
290
+ getComponent(document.getElementById(parent.element.id + '_bottomToolbar'), 'toolbar').destroy();
291
+ }
292
+ };
293
+ ToolbarModule.prototype.isToolbar = function () {
294
+ var parent = this.parent;
295
+ return (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.length > 0)
296
+ || !isNullOrUndefined(parent.toolbarTemplate));
297
+ };
298
+ ToolbarModule.prototype.createToolbar = function () {
299
+ var _this = this;
300
+ var parent = this.parent;
301
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.length > 0)) {
302
+ parent.element.appendChild(parent.createElement('div', {
303
+ id: parent.element.id + '_toolbarArea', className: 'e-toolbar-area'
304
+ }));
305
+ var toolbarItems = { cssClass: 'e-image-upload', align: 'Left', type: 'Input',
306
+ tooltipText: this.l10n.getConstant('Browse'), template: new Uploader({ allowedExtensions: '.jpg, .jpeg, .png,.svg' }) };
307
+ if (isNullOrUndefined(this.defToolbarItems)) {
308
+ this.defToolbarItems = [];
309
+ }
310
+ this.defToolbarItems.push(toolbarItems);
311
+ var toolbarArea = document.getElementById(parent.element.id + '_toolbarArea');
312
+ var toolbar_1 = parent.createElement('div', {
313
+ id: parent.element.id + '_toolbar'
314
+ });
315
+ toolbarArea.appendChild(toolbar_1);
316
+ var uploadItems = [
317
+ {
318
+ cssClass: 'e-image-upload',
319
+ align: 'Left', type: 'Input',
320
+ tooltipText: this.l10n.getConstant('Browse'),
321
+ template: new Uploader({
322
+ allowedExtensions: '.jpg, .jpeg, .png,.svg',
323
+ selected: function () {
324
+ if (!parent.disabled) {
325
+ if (Browser.isDevice) {
326
+ if (_this.defToolbarItems.length > 0 &&
327
+ document.getElementById(parent.element.id + '_toolbar')) {
328
+ getComponent(document.getElementById(parent.element.id + '_toolbar'), 'toolbar').destroy();
329
+ }
330
+ if (document.getElementById(parent.element.id + '_bottomToolbar')) {
331
+ getComponent(document.getElementById(parent.element.id + '_bottomToolbar'), 'toolbar').destroy();
332
+ }
333
+ _this.initMainToolbar(false, Browser.isDevice, null);
334
+ _this.createBottomToolbar();
335
+ }
336
+ else {
337
+ if (_this.defToolbarItems.length > 0 &&
338
+ document.getElementById(parent.element.id + '_toolbar')) {
339
+ getComponent(document.getElementById(parent.element.id + '_toolbar'), 'toolbar').destroy();
340
+ }
341
+ _this.initMainToolbar(false, false, null);
342
+ }
343
+ }
344
+ }
345
+ })
346
+ }
347
+ ];
348
+ var toolbarObj = new Toolbar({ items: uploadItems, width: '100%',
349
+ created: function () {
350
+ parent.trigger('toolbarCreated', { toolbarType: 'main' });
351
+ },
352
+ clicked: this.defToolbarClicked.bind(this) });
353
+ toolbarObj.appendTo('#' + parent.element.id + '_toolbar');
354
+ this.createLeftToolbarControls();
355
+ if (document.getElementById(parent.element.id + '_toolbar')) {
356
+ this.toolbarHeight = document.getElementById(parent.element.id + '_toolbar').clientHeight;
357
+ }
358
+ }
359
+ else {
360
+ this.toolbarHeight = 0;
361
+ }
362
+ };
363
+ ToolbarModule.prototype.createContextualToolbar = function () {
364
+ var parent = this.parent;
365
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.length > 0)) {
366
+ parent.element.appendChild(parent.createElement('div', { id: parent.element.id + '_contextualToolbarArea',
367
+ className: 'e-contextual-toolbar-wrapper e-hide', attrs: { style: 'position: absolute;' }
368
+ }));
369
+ var toolbarArea = document.getElementById(parent.element.id + '_contextualToolbarArea');
370
+ var toolbar_2 = parent.createElement('div', { id: parent.element.id + '_contextualToolbar' });
371
+ toolbarArea.appendChild(toolbar_2);
372
+ }
373
+ };
374
+ ToolbarModule.prototype.createBottomToolbar = function () {
375
+ var parent = this.parent;
376
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.length > 0)) {
377
+ parent.element.appendChild(parent.createElement('div', {
378
+ id: parent.element.id + '_bottomToolbarArea', className: 'e-bottom-toolbar'
379
+ }));
380
+ if (!parent.toolbarTemplate) {
381
+ document.getElementById(parent.element.id + '_canvasWrapper').style.height = (parent.element.offsetHeight
382
+ - this.toolbarHeight * 2) - 3 + 'px';
383
+ var toolbarArea = document.getElementById(parent.element.id + '_bottomToolbarArea');
384
+ var toolbarElem = parent.createElement('div', {
385
+ id: parent.element.id + '_bottomToolbar'
386
+ });
387
+ toolbarArea.appendChild(toolbarElem);
388
+ }
389
+ this.initBottomToolbar();
390
+ }
391
+ };
392
+ ToolbarModule.prototype.createQuickAccessToolbar = function () {
393
+ var parent = this.parent;
394
+ if (parent.showQuickAccessToolbar) {
395
+ var toolbarItems = { cssClass: 'e-image-upload', align: 'Left', type: 'Input',
396
+ tooltipText: this.l10n.getConstant('Browse'), template: new Uploader({ allowedExtensions: '.jpg, .jpeg, .png,.svg' }) };
397
+ if (isNullOrUndefined(this.defToolbarItems)) {
398
+ this.defToolbarItems = [];
399
+ }
400
+ this.defToolbarItems.push(toolbarItems);
401
+ var toolbarArea = document.getElementById(parent.element.id + '_quickAccessToolbarArea');
402
+ var toolbar_3 = parent.createElement('div', {
403
+ id: parent.element.id + '_quickAccessToolbar'
404
+ });
405
+ toolbarArea.appendChild(toolbar_3);
406
+ var toolbarObj = new Toolbar({ clicked: this.defToolbarClicked.bind(this) });
407
+ toolbarObj.appendTo('#' + parent.element.id + '_quickAccessToolbar');
408
+ }
409
+ };
410
+ ToolbarModule.prototype.initMainToolbar = function (isApplyOption, isDevice, isOkBtn) {
411
+ var _this = this;
412
+ var parent = this.parent;
413
+ if (this.isToolbar()) {
414
+ var leftItem = this.getLeftToolbarItem(isOkBtn);
415
+ var rightItem = this.getRightToolbarItem(isOkBtn);
416
+ var mainItem = this.getMainToolbarItem(isApplyOption);
417
+ var zoomItem = this.getZoomToolbarItem();
418
+ if (isDevice) {
419
+ this.defToolbarItems = leftItem.concat(rightItem);
420
+ }
421
+ else {
422
+ this.defToolbarItems = leftItem.concat(mainItem, rightItem, zoomItem);
423
+ }
424
+ var toolbarObj = new Toolbar({
425
+ width: '100%',
426
+ items: this.defToolbarItems,
427
+ clicked: this.defToolbarClicked.bind(this),
428
+ created: function () {
429
+ if (!isDevice) {
430
+ _this.renderAnnotationBtn();
431
+ }
432
+ _this.wireZoomBtnEvents();
433
+ _this.renderSaveBtn();
434
+ parent.trigger('toolbarCreated', { toolbarType: 'main' });
435
+ }
436
+ });
437
+ toolbarObj.appendTo('#' + parent.element.id + '_toolbar');
438
+ this.createLeftToolbarControls();
439
+ this.enableDisableTbrBtn();
440
+ if (this.isToolbar() && document.getElementById(parent.element.id + '_toolbar')) {
441
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
442
+ var toolbar_4 = getComponent(parent.element.id + '_toolbar', 'toolbar');
443
+ toolbar_4.refreshOverflow();
444
+ }
445
+ }
446
+ };
447
+ ToolbarModule.prototype.initBottomToolbar = function () {
448
+ var _this = this;
449
+ var parent = this.parent;
450
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.length > 0)) {
451
+ var items = this.getMainToolbarItem();
452
+ var toolbarObj = new Toolbar({ items: items, width: '100%',
453
+ created: function () {
454
+ _this.renderAnnotationBtn();
455
+ _this.renderCropBtn();
456
+ _this.renderTransformBtn();
457
+ parent.trigger('toolbarCreated', { toolbarType: 'main' });
458
+ },
459
+ clicked: this.defToolbarClicked.bind(this)
460
+ });
461
+ toolbarObj.appendTo('#' + parent.element.id + '_bottomToolbar');
462
+ if (this.defToolbarItems.length > 0 && document.getElementById(parent.element.id + '_bottomToolbar')) {
463
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
464
+ var toolbar_5 = getComponent(parent.element.id + '_bottomToolbar', 'toolbar');
465
+ toolbar_5.refreshOverflow();
466
+ }
467
+ }
468
+ };
469
+ ToolbarModule.prototype.getLeftToolbarItem = function (isOkBtn) {
470
+ var parent = this.parent;
471
+ var toolbarItems = [];
472
+ if (!isOkBtn) {
473
+ toolbarItems.push({ id: parent.element.id + '_upload', cssClass: 'e-image-upload', align: 'Left', type: 'Input', template: new Uploader({ allowedExtensions: '.jpg, .jpeg, .png,.svg' }) });
474
+ toolbarItems.push({ visible: false, cssClass: 'e-image-position e-btn e-flat', tooltipText: this.l10n.getConstant('Browse'), align: 'Left' });
475
+ }
476
+ if (parent.allowUndoRedo) {
477
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Undo') > -1)) {
478
+ toolbarItems.push({ id: parent.element.id + '_undo', prefixIcon: 'e-icons e-undo', cssClass: 'top-icon e-undo',
479
+ tooltipText: this.l10n.getConstant('Undo'), align: 'Left' });
480
+ }
481
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Redo') > -1)) {
482
+ toolbarItems.push({ id: parent.element.id + '_redo', prefixIcon: 'e-icons e-redo', cssClass: 'top-icon e-redo',
483
+ tooltipText: this.l10n.getConstant('Redo'), align: 'Left' });
484
+ }
485
+ }
486
+ if (!this.preventZoomBtn && (parent.zoomSettings.zoomTrigger & ZoomTrigger.Toolbar) === ZoomTrigger.Toolbar) {
487
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('ZoomOut') > -1)) {
488
+ toolbarItems.push({ id: parent.element.id + '_zoomOut', prefixIcon: 'e-icons e-zoom-out', cssClass: 'top-icon e-dec-zoom',
489
+ tooltipText: this.l10n.getConstant('ZoomOut'), align: 'Left' });
490
+ }
491
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('ZoomIn') > -1)) {
492
+ toolbarItems.push({ id: parent.element.id + '_zoomIn', prefixIcon: 'e-icons e-zoom-in', cssClass: 'top-icon e-inc-zoom',
493
+ tooltipText: this.l10n.getConstant('ZoomIn'), align: 'Left' });
494
+ }
495
+ }
496
+ var tempToolbarItems = this.processToolbar('left');
497
+ for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
498
+ toolbarItems.push(tempToolbarItems[i]);
499
+ }
500
+ return toolbarItems;
501
+ };
502
+ ToolbarModule.prototype.getRightToolbarItem = function (isOkBtn) {
503
+ var parent = this.parent;
504
+ var toolbarItems = [];
505
+ if (isOkBtn) {
506
+ toolbarItems.push({ id: parent.element.id + '_ok', prefixIcon: 'e-icons e-check', cssClass: 'top-icon e-tick',
507
+ tooltipText: this.l10n.getConstant('OK'), align: 'Right' });
508
+ toolbarItems.push({ id: parent.element.id + '_cancel', prefixIcon: 'e-icons e-close', cssClass: 'top-icon e-save',
509
+ tooltipText: this.l10n.getConstant('Cancel'), align: 'Right' });
510
+ }
511
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Reset') > -1)) {
512
+ toolbarItems.push({ id: parent.element.id + '_reset', prefixIcon: 'e-icons e-btn-reset', cssClass: 'top-icon e-img-reset',
513
+ tooltipText: this.l10n.getConstant('Reset'), align: 'Right' });
514
+ }
515
+ if (!isOkBtn) {
516
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Save') > -1)) {
517
+ toolbarItems.push({ id: parent.element.id + '_save', prefixIcon: 'e-icons e-btn-save', cssClass: 'top-icon e-save',
518
+ tooltipText: this.l10n.getConstant('Save'), align: 'Right', template: '<button id="' + parent.element.id + '_saveBtn"></button>' });
519
+ }
520
+ }
521
+ var tempToolbarItems = this.processToolbar('right');
522
+ for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
523
+ toolbarItems.push(tempToolbarItems[i]);
524
+ }
525
+ return toolbarItems;
526
+ };
527
+ ToolbarModule.prototype.getMainToolbarItem = function (isApplyOption) {
528
+ var parent = this.parent;
529
+ var toolbarItems = [];
530
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Crop') > -1)) {
531
+ toolbarItems.push({ id: parent.element.id + '_cropTransform', prefixIcon: 'e-icons e-crop', cssClass: 'top-icon e-crop',
532
+ tooltipText: this.l10n.getConstant('CropAndTransform'), align: 'Center' });
533
+ }
534
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Annotate') > -1)) {
535
+ toolbarItems.push({ id: parent.element.id + '_annotation', tooltipText: this.l10n.getConstant('Annotation'), align: 'Center',
536
+ template: '<button id="' + parent.element.id + '_annotationBtn"></button>' });
537
+ }
538
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Finetune') > -1)) {
539
+ toolbarItems.push({ id: parent.element.id + '_adjustment', prefixIcon: 'e-icons e-adjustment', cssClass: 'top-icon e-adjustment',
540
+ tooltipText: this.l10n.getConstant('Finetune'), align: 'Center' });
541
+ }
542
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Filter') > -1)) {
543
+ toolbarItems.push({ id: parent.element.id + '_filter', prefixIcon: 'e-icons e-filters', cssClass: 'top-icon e-filters',
544
+ tooltipText: this.l10n.getConstant('Filter'), align: 'Center' });
545
+ }
546
+ var tempToolbarItems = this.processToolbar('center');
547
+ for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
548
+ toolbarItems.push(tempToolbarItems[i]);
549
+ }
550
+ if (isApplyOption) {
551
+ toolbarItems.push({ id: parent.element.id + '_ok', prefixIcon: 'e-icons e-check', cssClass: 'top-icon e-tick',
552
+ tooltipText: this.l10n.getConstant('OK'), align: 'Right' });
553
+ toolbarItems.push({ id: parent.element.id + '_cancel', prefixIcon: 'e-icons e-close', cssClass: 'top-icon e-save',
554
+ tooltipText: this.l10n.getConstant('Cancel'), align: 'Right' });
555
+ }
556
+ return toolbarItems;
557
+ };
558
+ ToolbarModule.prototype.getZoomToolbarItem = function () {
559
+ var toolbarItems = [];
560
+ return toolbarItems;
561
+ };
562
+ ToolbarModule.prototype.updateContextualToolbar = function (type, cType) {
563
+ var parent = this.parent;
564
+ var toolbarArea = parent.element.querySelector('#' + parent.element.id + '_toolbarArea');
565
+ var contextualToolbarArea = parent.element.querySelector('#' + parent.element.id + '_contextualToolbarArea');
566
+ contextualToolbarArea.classList.remove('e-hide');
567
+ contextualToolbarArea.style.left = toolbarArea.offsetLeft + 'px';
568
+ if (type === 'filter') {
569
+ if (document.getElementById(parent.element.id + '_toolbar') && this.defToolbarItems.length > 0) {
570
+ getComponent(document.getElementById(parent.element.id + '_toolbar'), 'toolbar').destroy();
571
+ }
572
+ if (Browser.isDevice) {
573
+ this.initMainToolbar(false, true, true);
574
+ }
575
+ else {
576
+ this.initMainToolbar(true, null, null);
577
+ }
578
+ this.refreshSlider();
579
+ this.initFilterToolbarItem();
580
+ }
581
+ else {
582
+ if (document.querySelector('#' + parent.element.id + '_contextualToolbar').classList.contains('e-control')) {
583
+ getComponent(document.getElementById(parent.element.id + '_contextualToolbar'), 'toolbar').destroy();
584
+ }
585
+ this.refreshSlider();
586
+ this.renderSlider(cType);
587
+ }
588
+ if (Browser.isDevice) {
589
+ var cHt = contextualToolbarArea.offsetHeight;
590
+ var ht = parent.element.querySelector('#' + parent.element.id + '_canvasWrapper').offsetHeight;
591
+ contextualToolbarArea.style.top = this.toolbarHeight + ht - cHt + 'px';
592
+ }
593
+ else {
594
+ contextualToolbarArea.style.top = this.toolbarHeight + 'px';
595
+ }
596
+ };
597
+ ToolbarModule.prototype.processToolbar = function (position) {
598
+ var parent = this.parent;
599
+ var toolbarItems = [];
600
+ if (parent.toolbar) {
601
+ for (var i = 0, len = parent.toolbar.length; i < len; i++) {
602
+ if (typeof (parent.toolbar[i]) === 'object') {
603
+ if (isNullOrUndefined(parent.toolbar[i].align)) {
604
+ if (position === 'left') {
605
+ toolbarItems.push(parent.toolbar[i]);
606
+ }
607
+ }
608
+ else if (parent.toolbar[i].align.toLowerCase() === position) {
609
+ toolbarItems.push(parent.toolbar[i]);
610
+ }
611
+ }
612
+ }
613
+ }
614
+ return toolbarItems;
615
+ };
616
+ ToolbarModule.prototype.processSubToolbar = function (items) {
617
+ var toolbarItems = [];
618
+ if (items) {
619
+ for (var i = 0, len = items.length; i < len; i++) {
620
+ if (typeof (items[i]) === 'object') {
621
+ items[i].align = 'Center';
622
+ toolbarItems.push(items[i]);
623
+ }
624
+ }
625
+ }
626
+ return toolbarItems;
627
+ };
628
+ ToolbarModule.prototype.wireZoomBtnEvents = function () {
629
+ var zoomIn = document.querySelector('#' + this.parent.element.id + '_zoomIn');
630
+ var zoomOut = document.querySelector('#' + this.parent.element.id + '_zoomOut');
631
+ if (zoomIn) {
632
+ zoomIn.addEventListener('mousedown', this.zoomInBtnMouseDownHandler.bind(this));
633
+ zoomIn.addEventListener('mouseup', this.zoomBtnMouseUpHandler.bind(this));
634
+ zoomIn.addEventListener('click', this.zoomInBtnClickHandler.bind(this));
635
+ zoomIn.addEventListener('touchstart', this.zoomInBtnClickHandler.bind(this));
636
+ }
637
+ if (zoomOut) {
638
+ zoomOut.addEventListener('mousedown', this.zoomOutBtnMouseDownHandler.bind(this));
639
+ zoomOut.addEventListener('mouseup', this.zoomBtnMouseUpHandler.bind(this));
640
+ zoomOut.addEventListener('click', this.zoomOutBtnClickHandler.bind(this));
641
+ zoomIn.addEventListener('touchstart', this.zoomInBtnClickHandler.bind(this));
642
+ }
643
+ };
644
+ ToolbarModule.prototype.enableDisableTbrBtn = function () {
645
+ var parent = this.parent;
646
+ if (!this.preventEnableDisableUr) {
647
+ var object = { appliedUndoRedoColl: [] };
648
+ parent.notify('undo-redo', { prop: 'getAppliedUndoRedoColl', value: { obj: object } });
649
+ var undoRedoObj = { undoRedoStep: null };
650
+ parent.notify('undo-redo', { prop: 'getUndoRedoStep', value: { obj: undoRedoObj } });
651
+ var undo = document.querySelector('#' + parent.element.id + '_undo');
652
+ if (undo && undoRedoObj['undoRedoStep'] === 0) {
653
+ undo.classList.add('e-disabled');
654
+ undo.parentElement.classList.add('e-overlay');
655
+ }
656
+ else if (undo && undoRedoObj['undoRedoStep'] > 0) {
657
+ undo.classList.remove('e-disabled');
658
+ undo.parentElement.classList.remove('e-overlay');
659
+ }
660
+ var redo = document.querySelector('#' + parent.element.id + '_redo');
661
+ if (redo && (undoRedoObj['undoRedoStep'] === object['appliedUndoRedoColl'].length)) {
662
+ redo.classList.add('e-disabled');
663
+ redo.parentElement.classList.add('e-overlay');
664
+ }
665
+ else if (redo && (undoRedoObj['undoRedoStep'] === 0 && object['appliedUndoRedoColl'].length > 0)) {
666
+ redo.classList.remove('e-disabled');
667
+ redo.parentElement.classList.remove('e-overlay');
668
+ }
669
+ else if (redo && undoRedoObj['undoRedoStep'] > 0) {
670
+ redo.classList.remove('e-disabled');
671
+ redo.parentElement.classList.remove('e-overlay');
672
+ }
673
+ }
674
+ var zoomIn = document.querySelector('#' + parent.element.id + '_zoomIn');
675
+ if (zoomIn && parent.zoomSettings.zoomFactor >= parent.zoomSettings.maxZoomFactor) {
676
+ zoomIn.classList.add('e-disabled');
677
+ zoomIn.parentElement.classList.add('e-overlay');
678
+ }
679
+ else if (zoomIn) {
680
+ zoomIn.classList.remove('e-disabled');
681
+ zoomIn.parentElement.classList.remove('e-overlay');
682
+ }
683
+ var zoomOut = document.querySelector('#' + parent.element.id + '_zoomOut');
684
+ if (zoomOut && parent.zoomSettings.zoomFactor <= parent.zoomSettings.minZoomFactor) {
685
+ zoomOut.classList.add('e-disabled');
686
+ zoomOut.parentElement.classList.add('e-overlay');
687
+ }
688
+ else if (zoomOut) {
689
+ zoomOut.classList.remove('e-disabled');
690
+ zoomOut.parentElement.classList.remove('e-overlay');
691
+ }
692
+ var pan = document.querySelector('#' + parent.element.id + '_pan');
693
+ if (pan && parent.zoomSettings.zoomFactor <= parent.zoomSettings.minZoomFactor) {
694
+ pan.style.display = 'none';
695
+ }
696
+ else if (pan) {
697
+ pan.style.display = 'block';
698
+ }
699
+ };
700
+ ToolbarModule.prototype.createLeftToolbarControls = function () {
701
+ var parent = this.parent;
702
+ if (this.defToolbarItems !== undefined && this.defToolbarItems.length > 0 &&
703
+ (document.getElementById(parent.element.id + '_toolbar'))) {
704
+ var uploadDiv = document.getElementById(parent.element.id + '_toolbar')
705
+ .querySelector('.e-image-upload');
706
+ if (uploadDiv) {
707
+ var uploadElem = uploadDiv.getElementsByTagName('input')[0];
708
+ var uploadBtnElem = uploadDiv.getElementsByTagName('button')[0];
709
+ uploadBtnElem.className = 'e-tbar-btn e-tbtn-txt top-icon';
710
+ uploadBtnElem.innerHTML = '';
711
+ uploadBtnElem.appendChild(parent.createElement('span', {
712
+ className: 'e-btn-icon e-icons e-upload-icon e-icon-left'
713
+ }));
714
+ uploadElem.onchange = this.fileSelect.bind(this, uploadElem);
715
+ }
716
+ }
717
+ };
718
+ ToolbarModule.prototype.fileSelect = function (inputElement, args) {
719
+ this.parent.notify('draw', { prop: 'fileSelect', value: { inputElement: inputElement, args: args } });
720
+ };
721
+ ToolbarModule.prototype.renderAnnotationBtn = function (isContextualToolbar) {
722
+ var _this = this;
723
+ var parent = this.parent;
724
+ var items = [];
725
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Pen') > -1)) {
726
+ items.push({ text: this.l10n.getConstant('Pen'), id: 'pen', iconCss: 'e-icons e-free-pen' });
727
+ }
728
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Line') > -1)) {
729
+ items.push({ text: this.l10n.getConstant('Line'), id: 'line', iconCss: 'e-icons e-line' });
730
+ }
731
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Rectangle') > -1)) {
732
+ items.push({ text: this.l10n.getConstant('Rectangle'), id: 'rectangle', iconCss: 'e-icons e-rectangle' });
733
+ }
734
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Ellipse') > -1)) {
735
+ items.push({ text: this.l10n.getConstant('Ellipse'), id: 'ellipse', iconCss: 'e-icons e-circle' });
736
+ }
737
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Arrow') > -1)) {
738
+ items.push({ text: this.l10n.getConstant('Arrow'), id: 'arrow', iconCss: 'e-icons e-arrow-right-up' });
739
+ }
740
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Path') > -1)) {
741
+ items.push({ text: this.l10n.getConstant('Path'), id: 'path', iconCss: 'e-icons e-critical-path' });
742
+ }
743
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Text') > -1)) {
744
+ items.push({ text: this.l10n.getConstant('Text'), id: 'text', iconCss: 'e-icons e-add-text' });
745
+ }
746
+ var obj = { freehandDrawSelectedId: null };
747
+ parent.notify('freehand-draw', { prop: 'getFreehandDrawSelectedId', onPropertyChange: false, value: { obj: obj } });
748
+ var duplicateElement = document.querySelector('#' + parent.element.id + '_duplicate');
749
+ var removeElement = document.querySelector('#' + parent.element.id + '_remove');
750
+ var editTextElement = document.querySelector('#' + parent.element.id + '_editText');
751
+ if ((parent.activeObj.activePoint.width === 0 && parent.activeObj.activePoint.height === 0) &&
752
+ (isNullOrUndefined(parent.activeObj.pointColl) || (parent.activeObj.pointColl
753
+ && parent.activeObj.pointColl.length === 0)) &&
754
+ isNullOrUndefined(obj['freehandDrawSelectedId'])) {
755
+ if (duplicateElement) {
756
+ duplicateElement.classList.add('e-disabled');
757
+ }
758
+ if (removeElement) {
759
+ removeElement.classList.add('e-disabled');
760
+ }
761
+ if (editTextElement) {
762
+ editTextElement.classList.add('e-disabled');
763
+ }
764
+ }
765
+ else {
766
+ if (duplicateElement) {
767
+ duplicateElement.classList.remove('e-disabled');
768
+ }
769
+ if (removeElement) {
770
+ removeElement.classList.remove('e-disabled');
771
+ }
772
+ if (editTextElement) {
773
+ editTextElement.classList.remove('e-disabled');
774
+ }
775
+ }
776
+ var iconCss = isContextualToolbar ? this.getCurrentShapeIcon(parent.activeObj.shape) : 'e-annotation';
777
+ var drpDownBtn = new DropDownButton({ items: items, iconCss: 'e-icons ' + iconCss,
778
+ cssClass: 'e-image-popup',
779
+ open: function (args) {
780
+ if (Browser.isDevice) {
781
+ args.element.parentElement.style.top = drpDownBtn.element.getBoundingClientRect().top -
782
+ args.element.parentElement.offsetHeight + 'px';
783
+ }
784
+ if (parent.activeObj.shape) {
785
+ document.getElementById(parent.activeObj.shape).classList.add('e-selected');
786
+ }
787
+ else if (parent.togglePen) {
788
+ document.getElementById('pen').classList.add('e-selected');
789
+ }
790
+ },
791
+ select: function (args) {
792
+ parent.okBtn();
793
+ var isCropSelection = false;
794
+ var splitWords;
795
+ if (parent.activeObj.shape !== undefined) {
796
+ splitWords = parent.activeObj.shape.split('-');
797
+ }
798
+ if (splitWords === undefined && parent.currObjType.isCustomCrop) {
799
+ isCropSelection = true;
800
+ }
801
+ else if (splitWords !== undefined && splitWords[0] === 'crop') {
802
+ isCropSelection = true;
803
+ }
804
+ parent.currObjType.isCustomCrop = false;
805
+ if (isCropSelection || parent.togglePan) {
806
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
807
+ _this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
808
+ _this.refreshToolbar('main');
809
+ }
810
+ var obj = { currentFreehandDrawIndex: null };
811
+ parent.notify('freehand-draw', { prop: 'getCurrentFreehandDrawIndex', value: { obj: obj } });
812
+ drpDownBtn.iconCss = 'e-icons ' + _this.getCurrentShapeIcon(args.item.id);
813
+ switch (args.item.id) {
814
+ case 'pen':
815
+ parent.notify('draw', { prop: 'setTempFreehandCounter', value: { tempFreehandCounter: parent.freehandCounter } });
816
+ parent.notify('draw', { prop: 'setTempCurrentFreehandDrawIndex', value: { tempCurrentFreehandDrawIndex: obj['currentFreehandDrawIndex'] } });
817
+ _this.currentToolbar = 'pen';
818
+ parent.freeHandDraw(true);
819
+ break;
820
+ case 'text':
821
+ _this.currentToolbar = 'text';
822
+ parent.notify('shape', { prop: 'draw-shape-text' });
823
+ // this.setInitialShapeSettings(args);
824
+ // parent.activeObj.textFlip = parent.transform.currFlipState;
825
+ // parent.notify('selection', {prop: 'annotate', value: {shape: args.item.id }});
826
+ // parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: {type: 'text',
827
+ // isApplyBtn: null, isCropping: null, isZooming: null, cType: null}});
828
+ break;
829
+ default:
830
+ _this.currentToolbar = 'shapes';
831
+ /// parent.notify('shape', { prop: 'draw-shape', value: {obj: (args.item.id).toLowerCase()}});
832
+ _this.setInitialShapeSettings(args);
833
+ parent.notify('selection', { prop: 'annotate', value: { shape: args.item.id } });
834
+ parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'shapes',
835
+ isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
836
+ break;
837
+ }
838
+ _this.updateToolbarItems();
839
+ }
840
+ });
841
+ // Render initialized DropDownButton.
842
+ drpDownBtn.appendTo('#' + parent.element.id + '_annotationBtn');
843
+ };
844
+ ToolbarModule.prototype.renderCropBtn = function () {
845
+ var _this = this;
846
+ var parent = this.parent;
847
+ var items = [];
848
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('CustomSelection') > -1)) {
849
+ items.push({ text: this.l10n.getConstant('Custom'), id: 'custom', iconCss: 'e-icons e-custom' });
850
+ }
851
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('CircleSelection') > -1)) {
852
+ items.push({ text: this.l10n.getConstant('Circle'), id: 'circle', iconCss: 'e-icons e-circle' });
853
+ }
854
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('SquareSelection') > -1)) {
855
+ items.push({ text: this.l10n.getConstant('Square'), id: 'square', iconCss: 'e-icons e-square' });
856
+ }
857
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('RatioSelection') > -1)) {
858
+ items.push({ text: '3:2', id: '3:2', iconCss: 'e-icons e-custom-a' });
859
+ items.push({ text: '4:3', id: '4:3', iconCss: 'e-icons e-custom-b' });
860
+ items.push({ text: '5:4', id: '5:4', iconCss: 'e-icons e-custom-c' });
861
+ items.push({ text: '7:5', id: '7:5', iconCss: 'e-icons e-custom-d' });
862
+ items.push({ text: '16:9', id: '16:9', iconCss: 'e-icons e-custom-e' });
863
+ }
864
+ var iconCss;
865
+ var shape;
866
+ if (parent.activeObj.shape) {
867
+ iconCss = this.getCurrentShapeIcon(parent.activeObj.shape);
868
+ shape = parent.activeObj.shape;
869
+ }
870
+ else if (parent.currSelectionPoint) {
871
+ iconCss = this.getCurrentShapeIcon(parent.currSelectionPoint.shape);
872
+ shape = parent.currSelectionPoint.shape;
873
+ }
874
+ else {
875
+ iconCss = 'e-custom';
876
+ shape = 'custom';
877
+ }
878
+ var drpDownBtn = new DropDownButton({
879
+ open: function (args) {
880
+ if (parent.togglePan) {
881
+ _this.cancelPan();
882
+ }
883
+ if (Browser.isDevice) {
884
+ args.element.parentElement.style.top = drpDownBtn.element.getBoundingClientRect().top -
885
+ args.element.parentElement.offsetHeight + 'px';
886
+ }
887
+ if (parent.activeObj.shape && parent.activeObj.shape.split('-').length > 1) {
888
+ document.getElementById(parent.activeObj.shape.split('-')[1]).classList.add('e-selected');
889
+ }
890
+ parent.notify('transform', { prop: 'disableZoomOutBtn', value: { isZoomOut: true } });
891
+ },
892
+ items: items,
893
+ select: function (args) {
894
+ _this.cropSelect(args);
895
+ drpDownBtn.iconCss = 'e-icons ' + _this.getCurrentShapeIcon('crop-' + args.item.id);
896
+ drpDownBtn.content = parent.toPascalCase(args.item.id);
897
+ },
898
+ iconCss: 'e-icons ' + iconCss, cssClass: 'e-image-popup',
899
+ content: parent.toPascalCase(shape.replace('crop-', ''))
900
+ });
901
+ drpDownBtn.appendTo('#' + parent.element.id + '_cropBtn');
902
+ };
903
+ ToolbarModule.prototype.renderTransformBtn = function () {
904
+ var parent = this.parent;
905
+ var items = [];
906
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('RotateLeft') > -1)) {
907
+ items.push({ text: this.l10n.getConstant('RotateLeft'), id: 'rotateleft', iconCss: 'e-icons e-anti-clock-wise' });
908
+ }
909
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('RotateRight') > -1)) {
910
+ items.push({ text: this.l10n.getConstant('RotateRight'), id: 'rotateright', iconCss: 'e-icons e-clock-wise' });
911
+ }
912
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('FlipHorizontal') > -1)) {
913
+ items.push({ text: this.l10n.getConstant('HorizontalFlip'), id: 'horizontalflip', iconCss: 'e-icons e-horizontal-flip' });
914
+ }
915
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('FlipVertical') > -1)) {
916
+ items.push({ text: this.l10n.getConstant('VerticalFlip'), id: 'verticalflip', iconCss: 'e-icons e-vertical-flip' });
917
+ }
918
+ var drpDownBtn = new DropDownButton({
919
+ open: function (args) {
920
+ if (Browser.isDevice) {
921
+ var ht = args.element.parentElement.offsetHeight;
922
+ args.element.parentElement.style.display = 'none';
923
+ args.element.parentElement.style.top = drpDownBtn.element.getBoundingClientRect().top -
924
+ ht + 'px';
925
+ args.element.parentElement.style.display = 'block';
926
+ }
927
+ },
928
+ items: items, select: parent.transformSelect.bind(this),
929
+ iconCss: 'e-icons e-transform', cssClass: 'e-image-popup'
930
+ });
931
+ drpDownBtn.appendTo('#' + parent.element.id + '_transformBtn');
932
+ };
933
+ ToolbarModule.prototype.renderSaveBtn = function () {
934
+ var parent = this.parent;
935
+ var saveItems = [
936
+ { text: 'JPEG', id: 'jpeg' },
937
+ { text: 'PNG', id: 'png' },
938
+ { text: 'SVG', id: 'svg' }
939
+ ];
940
+ var ddbElem = document.getElementById(parent.element.id + '_saveBtn');
941
+ if (ddbElem) {
942
+ // Initialize the DropDownButton component.
943
+ var saveDrpDownBtn = new DropDownButton({ items: saveItems, cssClass: 'e-caret-hide e-image-popup', iconCss: 'e-icons e-save',
944
+ select: function (args) {
945
+ parent.export(args.item.text);
946
+ }
947
+ });
948
+ saveDrpDownBtn.appendTo('#' + parent.element.id + '_saveBtn');
949
+ }
950
+ };
951
+ ToolbarModule.prototype.getCropTransformToolbarItem = function () {
952
+ var parent = this.parent;
953
+ var toolbarItems = [];
954
+ toolbarItems.push({ id: parent.element.id + '_crop', tooltipText: this.l10n.getConstant('CropSelection'), align: 'Center',
955
+ template: '<button id="' + parent.element.id + '_cropBtn"></button>'
956
+ });
957
+ toolbarItems.push({ align: 'Center', type: 'Separator' });
958
+ toolbarItems.push({ id: parent.element.id + '_rotateLeft', prefixIcon: 'e-icons e-anti-clock-wise',
959
+ tooltipText: this.l10n.getConstant('RotateLeft'), align: 'Center' });
960
+ toolbarItems.push({ id: parent.element.id + '_rotateRight', prefixIcon: 'e-icons e-clock-wise',
961
+ tooltipText: this.l10n.getConstant('RotateRight'), align: 'Center' });
962
+ toolbarItems.push({ align: 'Center', type: 'Separator' });
963
+ toolbarItems.push({ id: parent.element.id + '_horizontalFlip', prefixIcon: 'e-icons e-horizontal-flip',
964
+ tooltipText: this.l10n.getConstant('HorizontalFlip'), align: 'Center' });
965
+ toolbarItems.push({ id: parent.element.id + '_verticalFlip', prefixIcon: 'e-icons e-vertical-flip',
966
+ tooltipText: this.l10n.getConstant('VerticalFlip'), align: 'Center' });
967
+ if (!Browser.isDevice) {
968
+ toolbarItems.push({ id: parent.element.id + '_ok', prefixIcon: 'e-icons e-check', cssClass: 'top-icon e-tick',
969
+ tooltipText: this.l10n.getConstant('OK'), align: 'Right' });
970
+ toolbarItems.push({ id: parent.element.id + '_cancel', prefixIcon: 'e-icons e-close', cssClass: 'top-icon e-save',
971
+ tooltipText: this.l10n.getConstant('Cancel'), align: 'Right' });
972
+ }
973
+ return toolbarItems;
974
+ };
975
+ ToolbarModule.prototype.getShapesToolbarItem = function (items) {
976
+ var parent = this.parent;
977
+ var toolbarItems = [];
978
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar)) {
979
+ toolbarItems.push({ id: parent.element.id + '_annotation', tooltipText: this.l10n.getConstant('Annotation'), align: 'Center',
980
+ template: '<button id="' + parent.element.id + '_annotationBtn"></button>' });
981
+ }
982
+ if (items.indexOf('fillColor') > -1) {
983
+ toolbarItems.push({ prefixIcon: 'e-icons e-copy', id: parent.element.id + '_fillcolor',
984
+ cssClass: 'top-icon e-fill', tooltipText: this.l10n.getConstant('FillColor'), align: 'Center', type: 'Input',
985
+ template: '<button id="' + parent.element.id + '_fillColorBtn"></button>' });
986
+ }
987
+ if (items.indexOf('strokeColor') > -1) {
988
+ toolbarItems.push({ prefixIcon: 'e-icons e-copy', id: parent.element.id + '_strokecolor',
989
+ cssClass: 'top-icon e-stroke', tooltipText: this.l10n.getConstant('StrokeColor'), align: 'Center', type: 'Input',
990
+ template: '<button id="' + parent.element.id + '_borderColorBtn"></button>' });
991
+ }
992
+ if (items.indexOf('strokeWidth') > -1) {
993
+ toolbarItems.push({ id: parent.element.id + '_strokeWidth', cssClass: 'top-icon e-size', tooltipText: 'Stroke Width', align: 'Center',
994
+ type: 'Input', template: '<button id="' + parent.element.id + '_borderWidthBtn"></button>' });
995
+ }
996
+ if (items.indexOf('start') > -1) {
997
+ toolbarItems.push({ id: parent.element.id + '_start', cssClass: 'top-icon e-size', tooltipText: 'Start', align: 'Center',
998
+ type: 'Input', template: '<button id="' + parent.element.id + '_startBtn"></button>' });
999
+ }
1000
+ if (items.indexOf('end') > -1) {
1001
+ toolbarItems.push({ id: parent.element.id + '_end', cssClass: 'top-icon e-size', tooltipText: 'End', align: 'Center',
1002
+ type: 'Input', template: '<button id="' + parent.element.id + '_endBtn"></button>' });
1003
+ }
1004
+ toolbarItems.push({ align: 'Center', type: 'Separator' });
1005
+ if (items.indexOf('duplicate') > -1) {
1006
+ toolbarItems.push({ id: parent.element.id + '_duplicate', prefixIcon: 'e-icons e-order', cssClass: 'top-icon e-order',
1007
+ tooltipText: this.l10n.getConstant('Duplicate'), align: 'Center' });
1008
+ }
1009
+ if (items.indexOf('remove') > -1) {
1010
+ toolbarItems.push({ id: parent.element.id + '_remove', prefixIcon: 'e-icons e-trash', cssClass: 'top-icon e-trash',
1011
+ tooltipText: this.l10n.getConstant('Remove'), align: 'Center' });
1012
+ }
1013
+ if (items.indexOf('text') > -1) {
1014
+ toolbarItems.push({ id: parent.element.id + '_editText', prefixIcon: 'e-icons e-annotation-edit', cssClass: 'top-icon e-annotation-edit',
1015
+ tooltipText: this.l10n.getConstant('EditText'), align: 'Center' });
1016
+ }
1017
+ var tempToolbarItems = this.processSubToolbar(items);
1018
+ for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
1019
+ toolbarItems.push(tempToolbarItems[i]);
1020
+ }
1021
+ if (!Browser.isDevice) {
1022
+ var obj = { shape: null };
1023
+ parent.notify('selection', { prop: 'getCurrentDrawingShape', value: { obj: obj } });
1024
+ if (obj['shape'] !== 'path') {
1025
+ toolbarItems.push({ id: parent.element.id + '_ok', prefixIcon: 'e-icons e-check', cssClass: 'top-icon e-tick',
1026
+ tooltipText: this.l10n.getConstant('OK'), align: 'Right' });
1027
+ toolbarItems.push({ id: parent.element.id + '_cancel', prefixIcon: 'e-icons e-close', cssClass: 'top-icon e-save',
1028
+ tooltipText: this.l10n.getConstant('Cancel'), align: 'Right' });
1029
+ }
1030
+ }
1031
+ return toolbarItems;
1032
+ };
1033
+ ToolbarModule.prototype.initCropTransformToolbar = function () {
1034
+ var _this = this;
1035
+ var parent = this.parent;
1036
+ var leftItem = this.getLeftToolbarItem();
1037
+ var rightItem = this.getRightToolbarItem();
1038
+ var mainItem = this.getCropTransformToolbarItem();
1039
+ var zoomItem = this.getZoomToolbarItem();
1040
+ if (Browser.isDevice) {
1041
+ this.defToolbarItems = mainItem;
1042
+ }
1043
+ else {
1044
+ this.defToolbarItems = leftItem.concat(zoomItem, mainItem, rightItem);
1045
+ }
1046
+ var toolbar = new Toolbar({
1047
+ width: '100%',
1048
+ items: this.defToolbarItems,
1049
+ clicked: this.defToolbarClicked.bind(this),
1050
+ created: function () {
1051
+ _this.renderCropBtn();
1052
+ _this.wireZoomBtnEvents();
1053
+ if (!Browser.isDevice) {
1054
+ _this.renderSaveBtn();
1055
+ }
1056
+ parent.trigger('toolbarCreated', { toolbarType: 'shapes' });
1057
+ if (Browser.isDevice) {
1058
+ if (_this.defToolbarItems.length > 0 && document.getElementById(parent.element.id + '_bottomToolbar')) {
1059
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1060
+ toolbar.refreshOverflow();
1061
+ toolbar.refreshOverflow();
1062
+ toolbar.refreshOverflow();
1063
+ }
1064
+ }
1065
+ else {
1066
+ _this.createLeftToolbarControls();
1067
+ if (_this.defToolbarItems.length > 0 && document.getElementById(parent.element.id + '_toolbar')) {
1068
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1069
+ toolbar.refreshOverflow();
1070
+ }
1071
+ }
1072
+ parent.select('custom');
1073
+ }
1074
+ });
1075
+ if (Browser.isDevice) {
1076
+ toolbar.appendTo('#' + parent.element.id + '_bottomToolbar');
1077
+ }
1078
+ else {
1079
+ toolbar.appendTo('#' + parent.element.id + '_toolbar');
1080
+ }
1081
+ this.enableDisableTbrBtn();
1082
+ parent.notify('transform', { prop: 'disableZoomOutBtn', value: { isZoomOut: true } });
1083
+ };
1084
+ ToolbarModule.prototype.getCurrentShapeIcon = function (shape) {
1085
+ var icon = '';
1086
+ switch (shape) {
1087
+ case 'rectangle':
1088
+ icon = 'e-rectangle';
1089
+ break;
1090
+ case 'ellipse':
1091
+ icon = 'e-circle';
1092
+ break;
1093
+ case 'line':
1094
+ icon = 'e-line';
1095
+ break;
1096
+ case 'arrow':
1097
+ icon = 'e-arrow-right-up';
1098
+ break;
1099
+ case 'path':
1100
+ icon = 'e-critical-path';
1101
+ break;
1102
+ case 'text':
1103
+ icon = 'e-add-text';
1104
+ break;
1105
+ case 'pen':
1106
+ icon = 'e-free-pen';
1107
+ break;
1108
+ case 'crop-custom':
1109
+ icon = 'e-custom';
1110
+ break;
1111
+ case 'crop-circle':
1112
+ icon = 'e-circle';
1113
+ break;
1114
+ case 'crop-square':
1115
+ icon = 'e-square';
1116
+ break;
1117
+ case 'crop-3:2':
1118
+ icon = 'e-custom-a';
1119
+ break;
1120
+ case 'crop-4:3':
1121
+ icon = 'e-custom-b';
1122
+ break;
1123
+ case 'crop-5:4':
1124
+ icon = 'e-custom-c';
1125
+ break;
1126
+ case 'crop-7:5':
1127
+ icon = 'e-custom-d';
1128
+ break;
1129
+ case 'crop-16:9':
1130
+ icon = 'e-custom-e';
1131
+ break;
1132
+ default:
1133
+ icon = 'e-free-pen';
1134
+ break;
1135
+ }
1136
+ return icon;
1137
+ };
1138
+ ToolbarModule.prototype.initShapesToolbarItem = function (items) {
1139
+ var _this = this;
1140
+ var parent = this.parent;
1141
+ var leftItem = this.getLeftToolbarItem();
1142
+ var rightItem = this.getRightToolbarItem();
1143
+ var mainItem = this.getShapesToolbarItem(items);
1144
+ var zoomItem = this.getZoomToolbarItem();
1145
+ if (Browser.isDevice) {
1146
+ this.defToolbarItems = mainItem;
1147
+ }
1148
+ else {
1149
+ this.defToolbarItems = leftItem.concat(zoomItem, mainItem, rightItem);
1150
+ }
1151
+ var toolbar = new Toolbar({
1152
+ width: '100%',
1153
+ items: this.defToolbarItems,
1154
+ clicked: this.defToolbarClicked.bind(this),
1155
+ created: function () {
1156
+ _this.renderAnnotationBtn(true);
1157
+ _this.createShapeColor(items);
1158
+ _this.createShapeBtn(items);
1159
+ if (parent.activeObj.shape === 'arrow') {
1160
+ _this.createStartBtn();
1161
+ _this.createEndBtn();
1162
+ }
1163
+ _this.wireZoomBtnEvents();
1164
+ if (!Browser.isDevice) {
1165
+ _this.renderSaveBtn();
1166
+ }
1167
+ parent.trigger('toolbarCreated', { toolbarType: 'shapes' });
1168
+ if (Browser.isDevice) {
1169
+ if (_this.defToolbarItems.length > 0 && document.getElementById(parent.element.id + '_bottomToolbar')) {
1170
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1171
+ toolbar.refreshOverflow();
1172
+ toolbar.refreshOverflow();
1173
+ toolbar.refreshOverflow();
1174
+ }
1175
+ }
1176
+ else {
1177
+ _this.createLeftToolbarControls();
1178
+ if (_this.defToolbarItems.length > 0 && document.getElementById(parent.element.id + '_toolbar')) {
1179
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1180
+ toolbar.refreshOverflow();
1181
+ }
1182
+ }
1183
+ }
1184
+ });
1185
+ if (Browser.isDevice) {
1186
+ toolbar.appendTo('#' + parent.element.id + '_bottomToolbar');
1187
+ }
1188
+ else {
1189
+ toolbar.appendTo('#' + parent.element.id + '_toolbar');
1190
+ }
1191
+ this.enableDisableTbrBtn();
1192
+ };
1193
+ ToolbarModule.prototype.createShapeColor = function (items) {
1194
+ var parent = this.parent;
1195
+ if (items.indexOf('fillColor') > -1) {
1196
+ parent.element.querySelector('.e-template.e-fill').appendChild(parent.createElement('input', {
1197
+ id: parent.element.id + '_shape_fill'
1198
+ }));
1199
+ var fillColor = new ColorPicker({
1200
+ modeSwitcher: false, noColor: true, value: '',
1201
+ showButtons: false, mode: 'Palette', cssClass: 'e-shape-fill-color',
1202
+ change: function (args) {
1203
+ parent.updateFillColor(args.currentValue.hex);
1204
+ if (args.currentValue.rgba === '') {
1205
+ fillDDB_1.element.children[0].classList.add('e-nocolor-item');
1206
+ }
1207
+ else {
1208
+ fillDDB_1.element.children[0].classList.remove('e-nocolor-item');
1209
+ fillDDB_1.element.children[0].style.backgroundColor = args.currentValue.rgba;
1210
+ }
1211
+ fillDDB_1.toggle();
1212
+ }
1213
+ }, '#' + parent.element.id + '_shape_fill');
1214
+ var fillDDB_1 = new DropDownButton({
1215
+ open: function (args) {
1216
+ if (Browser.isDevice) {
1217
+ args.element.parentElement.style.top = fillDDB_1.element.getBoundingClientRect().top -
1218
+ args.element.parentElement.offsetHeight + 'px';
1219
+ args.element.parentElement.style.left = parent.element.offsetLeft + 'px';
1220
+ }
1221
+ },
1222
+ target: '.e-shape-fill-color',
1223
+ iconCss: 'e-dropdownbtn-preview'
1224
+ }, '#' + parent.element.id + '_fillColorBtn');
1225
+ fillColor.inline = true;
1226
+ parent.element.querySelector('.e-fill.e-template .e-dropdownbtn-preview').classList.add('e-nocolor-item');
1227
+ }
1228
+ if (items.indexOf('strokeColor') > -1) {
1229
+ parent.element.querySelector('.e-template.e-stroke').appendChild(parent.createElement('input', {
1230
+ id: parent.element.id + '_shape_stroke'
1231
+ }));
1232
+ var strokeColor = new ColorPicker({
1233
+ modeSwitcher: false, noColor: false, value: '#fff',
1234
+ showButtons: false, mode: 'Palette', cssClass: 'e-shape-stroke-color',
1235
+ change: function (args) {
1236
+ parent.updateStrokeColor(args.currentValue.hex);
1237
+ strokeDDB_1.element.children[0].style.backgroundColor = args.currentValue.rgba;
1238
+ strokeDDB_1.toggle();
1239
+ }
1240
+ }, '#' + parent.element.id + '_shape_stroke');
1241
+ var strokeDDB_1 = new DropDownButton({
1242
+ open: function (args) {
1243
+ if (Browser.isDevice) {
1244
+ args.element.parentElement.style.top = strokeDDB_1.element.getBoundingClientRect().top -
1245
+ args.element.parentElement.offsetHeight + 'px';
1246
+ args.element.parentElement.style.left = parent.element.offsetLeft + 'px';
1247
+ }
1248
+ },
1249
+ target: '.e-shape-stroke-color',
1250
+ iconCss: 'e-dropdownbtn-preview'
1251
+ }, '#' + parent.element.id + '_borderColorBtn');
1252
+ strokeColor.inline = true;
1253
+ parent.element.querySelector('.e-stroke.e-template .e-dropdownbtn-preview').style.background = '#fff';
1254
+ }
1255
+ };
1256
+ ToolbarModule.prototype.createShapeBtn = function (items) {
1257
+ var parent = this.parent;
1258
+ var strokeWidthItems = [
1259
+ { id: '1', text: this.l10n.getConstant('XSmall') },
1260
+ { id: '2', text: this.l10n.getConstant('Small') },
1261
+ { id: '3', text: this.l10n.getConstant('Medium') },
1262
+ { id: '4', text: this.l10n.getConstant('Large') },
1263
+ { id: '5', text: this.l10n.getConstant('XLarge') }
1264
+ ];
1265
+ if (items.indexOf('strokeWidth') > -1) {
1266
+ var strokeWidthBtn = document.getElementById(parent.element.id + '_borderWidthBtn');
1267
+ var spanElem_1 = document.createElement('span');
1268
+ spanElem_1.innerHTML = this.l10n.getConstant('XSmall');
1269
+ spanElem_1.className = 'e-shape-stroke-width';
1270
+ strokeWidthBtn.appendChild(spanElem_1);
1271
+ // Initialize the DropDownButton component.
1272
+ var drpDownBtn_1 = new DropDownButton({ items: strokeWidthItems,
1273
+ open: function (args) {
1274
+ if (Browser.isDevice) {
1275
+ args.element.parentElement.style.top = drpDownBtn_1.element.getBoundingClientRect().top -
1276
+ args.element.parentElement.offsetHeight + 'px';
1277
+ }
1278
+ var activeBtn = spanElem_1.innerHTML;
1279
+ if (activeBtn !== '') {
1280
+ args.element.querySelector('[aria-label = ' + '"' + activeBtn + '"' + ']').classList.add('e-selected-btn');
1281
+ }
1282
+ },
1283
+ select: function (args) {
1284
+ spanElem_1.textContent = args.item.text;
1285
+ parent.updateStrokeWidth(args.item.id);
1286
+ if (Browser.isDevice) {
1287
+ if (document.getElementById(parent.element.id + '_bottomToolbar')) {
1288
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1289
+ var toolbar_6 = getComponent(parent.element.id + '_bottomToolbar', 'toolbar');
1290
+ toolbar_6.refreshOverflow();
1291
+ }
1292
+ }
1293
+ else {
1294
+ if (document.getElementById(parent.element.id + '_toolbar')) {
1295
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1296
+ var toolbar_7 = getComponent(parent.element.id + '_toolbar', 'toolbar');
1297
+ toolbar_7.refreshOverflow();
1298
+ }
1299
+ }
1300
+ }
1301
+ });
1302
+ // Render initialized DropDownButton.
1303
+ drpDownBtn_1.appendTo('#' + parent.element.id + '_borderWidthBtn');
1304
+ }
1305
+ };
1306
+ ToolbarModule.prototype.createStartBtn = function () {
1307
+ var parent = this.parent;
1308
+ var strokeWidthItems = [
1309
+ { id: '1', text: this.l10n.getConstant('None') },
1310
+ { id: '2', text: this.l10n.getConstant('Bar') },
1311
+ { id: '3', text: this.l10n.getConstant('Arrow') },
1312
+ { id: '4', text: this.l10n.getConstant('ArrowSolid') },
1313
+ { id: '5', text: this.l10n.getConstant('Circle') },
1314
+ { id: '6', text: this.l10n.getConstant('CircleSolid') },
1315
+ { id: '7', text: this.l10n.getConstant('Square') },
1316
+ { id: '8', text: this.l10n.getConstant('SquareSolid') }
1317
+ ];
1318
+ var strokeWidthBtn = document.getElementById(parent.element.id + '_startBtn');
1319
+ var spanElem = document.createElement('span');
1320
+ if (isNullOrUndefined(parent.activeObj.start)) {
1321
+ parent.activeObj.start = 'none';
1322
+ }
1323
+ spanElem.innerHTML = parent.pascalToSplitWords(parent.activeObj.start);
1324
+ spanElem.className = 'e-shape-start';
1325
+ strokeWidthBtn.appendChild(spanElem);
1326
+ // Initialize the DropDownButton component.
1327
+ var drpDownBtn = new DropDownButton({ items: strokeWidthItems,
1328
+ open: function (args) {
1329
+ if (Browser.isDevice) {
1330
+ args.element.parentElement.style.top = drpDownBtn.element.getBoundingClientRect().top -
1331
+ args.element.parentElement.offsetHeight + 'px';
1332
+ }
1333
+ var activeBtn = spanElem.innerHTML;
1334
+ if (activeBtn !== '') {
1335
+ args.element.querySelector('[aria-label = ' + '"' + activeBtn + '"' + ']').classList.add('e-selected-btn');
1336
+ }
1337
+ },
1338
+ select: function (args) {
1339
+ spanElem.textContent = args.item.text;
1340
+ parent.updateArrow('startArrow', args.item.id);
1341
+ }
1342
+ });
1343
+ // Render initialized DropDownButton.
1344
+ drpDownBtn.appendTo('#' + parent.element.id + '_startBtn');
1345
+ };
1346
+ ToolbarModule.prototype.createEndBtn = function () {
1347
+ var parent = this.parent;
1348
+ var strokeWidthItems = [
1349
+ { id: '1', text: this.l10n.getConstant('None') },
1350
+ { id: '2', text: this.l10n.getConstant('Bar') },
1351
+ { id: '3', text: this.l10n.getConstant('Arrow') },
1352
+ { id: '4', text: this.l10n.getConstant('ArrowSolid') },
1353
+ { id: '5', text: this.l10n.getConstant('Circle') },
1354
+ { id: '6', text: this.l10n.getConstant('CircleSolid') },
1355
+ { id: '7', text: this.l10n.getConstant('Square') },
1356
+ { id: '8', text: this.l10n.getConstant('SquareSolid') }
1357
+ ];
1358
+ var strokeEndBtn = document.getElementById(parent.element.id + '_endBtn');
1359
+ var spanElem = document.createElement('span');
1360
+ if (isNullOrUndefined(parent.activeObj.end)) {
1361
+ parent.activeObj.end = 'arrowSolid';
1362
+ }
1363
+ spanElem.innerHTML = parent.pascalToSplitWords(parent.activeObj.end);
1364
+ spanElem.className = 'e-shape-end';
1365
+ strokeEndBtn.appendChild(spanElem);
1366
+ // Initialize the DropDownButton component.
1367
+ var drpDownBtn = new DropDownButton({ items: strokeWidthItems,
1368
+ open: function (args) {
1369
+ if (Browser.isDevice) {
1370
+ args.element.parentElement.style.top = drpDownBtn.element.getBoundingClientRect().top -
1371
+ args.element.parentElement.offsetHeight + 'px';
1372
+ }
1373
+ var activeBtn = spanElem.innerHTML;
1374
+ if (activeBtn !== '') {
1375
+ args.element.querySelector('[aria-label = ' + '"' + activeBtn + '"' + ']').classList.add('e-selected-btn');
1376
+ }
1377
+ },
1378
+ select: function (args) {
1379
+ spanElem.textContent = args.item.text;
1380
+ parent.updateArrow('endArrow', args.item.id);
1381
+ }
1382
+ });
1383
+ // Render initialized DropDownButton.
1384
+ drpDownBtn.appendTo('#' + parent.element.id + '_endBtn');
1385
+ };
1386
+ ToolbarModule.prototype.getTextToolbarItem = function (items) {
1387
+ var parent = this.parent;
1388
+ var toolbarItems = [];
1389
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar)) {
1390
+ toolbarItems.push({ id: parent.element.id + '_annotation', tooltipText: this.l10n.getConstant('Annotation'), align: 'Center',
1391
+ template: '<button id="' + parent.element.id + '_annotationBtn"></button>' });
1392
+ }
1393
+ if (items.indexOf('fontFamily') > -1) {
1394
+ toolbarItems.push({ id: parent.element.id + '_fontFamily', cssClass: 'top-icon e-img-font-family',
1395
+ tooltipText: this.l10n.getConstant('FontFamily'), align: 'Center',
1396
+ template: '<button id="' + parent.element.id + '_fontFamilyBtn"></button>' });
1397
+ }
1398
+ if (items.indexOf('fontSize') > -1) {
1399
+ toolbarItems.push({ id: parent.element.id + '_fontSize', cssClass: 'top-icon e-img-font-size',
1400
+ tooltipText: this.l10n.getConstant('FontSize'), align: 'Center',
1401
+ template: '<button id="' + parent.element.id + '_fontSizeBtn"></button>' });
1402
+ }
1403
+ if (items.indexOf('fontColor') > -1) {
1404
+ toolbarItems.push({ cssClass: 'top-icon e-text-font-color', id: parent.element.id + '_text_strokecolor',
1405
+ tooltipText: this.l10n.getConstant('FontColor'), align: 'Center',
1406
+ type: 'Input', template: '<button id="' + parent.element.id + '_fontColorBtn"></button>' });
1407
+ }
1408
+ if (items.indexOf('bold') > -1) {
1409
+ toolbarItems.push({ id: parent.element.id + '_bold', prefixIcon: 'e-icons e-bold', cssClass: 'top-icon e-bold',
1410
+ tooltipText: this.l10n.getConstant('Bold'), align: 'Center' });
1411
+ }
1412
+ if (items.indexOf('italic') > -1) {
1413
+ toolbarItems.push({ id: parent.element.id + '_italic', prefixIcon: 'e-icons e-italic', cssClass: 'top-icon e-italic',
1414
+ tooltipText: this.l10n.getConstant('Italic'), align: 'Center' });
1415
+ }
1416
+ toolbarItems.push({ align: 'Center', type: 'Separator' });
1417
+ if (items.indexOf('duplicate') > -1) {
1418
+ toolbarItems.push({ id: parent.element.id + '_duplicate', prefixIcon: 'e-icons e-order', cssClass: 'top-icon e-order',
1419
+ tooltipText: this.l10n.getConstant('Duplicate'), align: 'Center' });
1420
+ }
1421
+ if (items.indexOf('remove') > -1) {
1422
+ toolbarItems.push({ id: parent.element.id + '_remove', prefixIcon: 'e-icons e-trash', cssClass: 'top-icon e-trash',
1423
+ tooltipText: this.l10n.getConstant('Remove'), align: 'Center' });
1424
+ }
1425
+ if (items.indexOf('text') > -1) {
1426
+ toolbarItems.push({ id: parent.element.id + '_editText', prefixIcon: 'e-icons e-annotation-edit', cssClass: 'top-icon e-annotation-edit',
1427
+ tooltipText: this.l10n.getConstant('EditText'), align: 'Center' });
1428
+ }
1429
+ var tempToolbarItems = this.processSubToolbar(items);
1430
+ for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
1431
+ toolbarItems.push(tempToolbarItems[i]);
1432
+ }
1433
+ if (!Browser.isDevice) {
1434
+ toolbarItems.push({ id: parent.element.id + '_ok', prefixIcon: 'e-icons e-check', cssClass: 'top-icon e-tick',
1435
+ tooltipText: this.l10n.getConstant('OK'), align: 'Right' });
1436
+ toolbarItems.push({ id: parent.element.id + '_cancel', prefixIcon: 'e-icons e-close', cssClass: 'top-icon e-save',
1437
+ tooltipText: this.l10n.getConstant('Cancel'), align: 'Right' });
1438
+ }
1439
+ return toolbarItems;
1440
+ };
1441
+ ToolbarModule.prototype.getFontFamilyItems = function () {
1442
+ if (Browser.isDevice) {
1443
+ return [{ id: 'arial', text: 'ABC' }, { id: 'calibri', text: 'ABC' }, { id: 'georgia', text: 'ABC' },
1444
+ { id: 'roboto', text: 'ABC' }, { id: 'tahoma', text: 'ABC' }];
1445
+ }
1446
+ return [{ id: 'arial', text: 'Arial' }, { id: 'calibri', text: 'Calibri' }, { id: 'georgia', text: 'Georgia' },
1447
+ { id: 'roboto', text: 'Roboto' }, { id: 'tahoma', text: 'Tahoma' }];
1448
+ };
1449
+ ToolbarModule.prototype.initTextToolbarItem = function (items) {
1450
+ var _this = this;
1451
+ var parent = this.parent;
1452
+ var leftItem = this.getLeftToolbarItem();
1453
+ var rightItem = this.getRightToolbarItem();
1454
+ var mainItem = this.getTextToolbarItem(items);
1455
+ var zoomItem = this.getZoomToolbarItem();
1456
+ if (Browser.isDevice) {
1457
+ this.defToolbarItems = mainItem;
1458
+ }
1459
+ else {
1460
+ this.defToolbarItems = leftItem.concat(zoomItem, mainItem, rightItem);
1461
+ }
1462
+ var toolbar = new Toolbar({
1463
+ width: '100%',
1464
+ items: this.defToolbarItems,
1465
+ clicked: this.defToolbarClicked.bind(this),
1466
+ created: function () {
1467
+ _this.renderAnnotationBtn(true);
1468
+ _this.createTextColor(items);
1469
+ _this.createTextBtn(items);
1470
+ _this.wireZoomBtnEvents();
1471
+ if (!Browser.isDevice) {
1472
+ _this.renderSaveBtn();
1473
+ }
1474
+ parent.trigger('toolbarCreated', { toolbarType: 'text' });
1475
+ if (Browser.isDevice) {
1476
+ if (_this.defToolbarItems.length > 0 && document.getElementById(parent.element.id + '_bottomToolbar')) {
1477
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1478
+ toolbar.refreshOverflow();
1479
+ toolbar.refreshOverflow();
1480
+ toolbar.refreshOverflow();
1481
+ }
1482
+ }
1483
+ else {
1484
+ _this.createLeftToolbarControls();
1485
+ if (_this.defToolbarItems.length > 0 && document.getElementById(parent.element.id + '_toolbar')) {
1486
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1487
+ toolbar.refreshOverflow();
1488
+ }
1489
+ }
1490
+ }
1491
+ });
1492
+ if (Browser.isDevice) {
1493
+ toolbar.appendTo('#' + parent.element.id + '_bottomToolbar');
1494
+ }
1495
+ else {
1496
+ toolbar.appendTo('#' + parent.element.id + '_toolbar');
1497
+ }
1498
+ this.enableDisableTbrBtn();
1499
+ };
1500
+ ToolbarModule.prototype.createTextColor = function (items) {
1501
+ var parent = this.parent;
1502
+ if (items.indexOf('fontColor') > -1 && parent.element.querySelector('.e-template.e-text-font-color')) {
1503
+ parent.element.querySelector('.e-template.e-text-font-color').appendChild(parent.createElement('input', {
1504
+ id: parent.element.id + '_text_font'
1505
+ }));
1506
+ var fontColor = new ColorPicker({
1507
+ modeSwitcher: false, value: '#fff',
1508
+ showButtons: false, mode: 'Palette', cssClass: 'e-text-fontt-color',
1509
+ change: function (args) {
1510
+ parent.updateFontColor(args.currentValue.hex);
1511
+ strokeDDB_2.element.children[0].style.backgroundColor = args.currentValue.rgba;
1512
+ strokeDDB_2.toggle();
1513
+ }
1514
+ }, '#' + parent.element.id + '_text_font');
1515
+ var strokeDDB_2 = new DropDownButton({
1516
+ open: function (args) {
1517
+ if (Browser.isDevice) {
1518
+ args.element.parentElement.style.top = strokeDDB_2.element.getBoundingClientRect().top -
1519
+ args.element.parentElement.offsetHeight + 'px';
1520
+ args.element.parentElement.style.left = parent.element.offsetLeft + 'px';
1521
+ }
1522
+ },
1523
+ target: '.e-text-fontt-color',
1524
+ iconCss: 'e-dropdownbtn-preview'
1525
+ }, '#' + parent.element.id + '_fontColorBtn');
1526
+ fontColor.inline = true;
1527
+ parent.element.querySelector('.e-text-font-color.e-template .e-dropdownbtn-preview').style.background
1528
+ = '#fff';
1529
+ }
1530
+ };
1531
+ ToolbarModule.prototype.createTextBtn = function (items) {
1532
+ var parent = this.parent;
1533
+ if (items.indexOf('fontFamily') > -1) {
1534
+ var fontNameBtn = document.getElementById(parent.element.id + '_fontFamilyBtn');
1535
+ var spanElem_2 = document.createElement('span');
1536
+ if (Browser.isDevice) {
1537
+ spanElem_2.innerHTML = 'ABC';
1538
+ spanElem_2.setAttribute('style', 'font-family: arial');
1539
+ }
1540
+ else {
1541
+ spanElem_2.innerHTML = 'Arial';
1542
+ }
1543
+ spanElem_2.className = 'e-text-font-family';
1544
+ if (fontNameBtn) {
1545
+ fontNameBtn.appendChild(spanElem_2);
1546
+ }
1547
+ var fontFamilyBtn_1 = new DropDownButton({ items: this.getFontFamilyItems(),
1548
+ cssClass: 'e-font-family',
1549
+ createPopupOnClick: true,
1550
+ beforeItemRender: function (args) {
1551
+ args.element.setAttribute('style', 'font-family:' + args.element.id);
1552
+ },
1553
+ open: function (args) {
1554
+ if (Browser.isDevice) {
1555
+ args.element.parentElement.style.top = fontFamilyBtn_1.element.getBoundingClientRect().top -
1556
+ args.element.parentElement.offsetHeight + 'px';
1557
+ }
1558
+ var fontFamily;
1559
+ if (parent.textArea.style.display === 'block') {
1560
+ fontFamily = parent.textArea.style.fontFamily;
1561
+ }
1562
+ else {
1563
+ fontFamily = parent.activeObj.textSettings.fontFamily;
1564
+ }
1565
+ args.element.querySelector('[id *= ' + '"' + fontFamily.toLowerCase()
1566
+ + '"' + ']').classList.add('e-selected-btn');
1567
+ },
1568
+ select: function (args) {
1569
+ spanElem_2.textContent = args.item.text;
1570
+ if (Browser.isDevice) {
1571
+ spanElem_2.setAttribute('style', 'font-family:' + args.item.id);
1572
+ }
1573
+ parent.updateFontFamily(args.item.id);
1574
+ }
1575
+ });
1576
+ fontFamilyBtn_1.appendTo('#' + parent.element.id + '_fontFamilyBtn');
1577
+ }
1578
+ if (items.indexOf('fontSize') > -1) {
1579
+ var fontSizeBtnElem = document.getElementById(parent.element.id + '_fontSizeBtn');
1580
+ var fontSizeSpanElem_1 = document.createElement('span');
1581
+ var fontSizes = parent.getFontSizes();
1582
+ fontSizeSpanElem_1.innerHTML = fontSizes[0].text;
1583
+ fontSizeSpanElem_1.className = 'e-text-font-size';
1584
+ fontSizeBtnElem.appendChild(fontSizeSpanElem_1);
1585
+ var fontSizeBtn_1 = new DropDownButton({
1586
+ cssClass: 'e-font-size',
1587
+ items: fontSizes,
1588
+ open: function (args) {
1589
+ if (Browser.isDevice) {
1590
+ args.element.parentElement.style.top = fontSizeBtn_1.element.getBoundingClientRect().top -
1591
+ args.element.parentElement.offsetHeight + 'px';
1592
+ }
1593
+ var activeBtn = fontSizeSpanElem_1.innerHTML;
1594
+ args.element.querySelector('[aria-label *= ' + '"' + activeBtn + '"' + ']').classList.add('e-selected-btn');
1595
+ },
1596
+ select: function (args) {
1597
+ fontSizeSpanElem_1.textContent = args.item.text;
1598
+ parent.updateFontSize(args.item.text);
1599
+ }
1600
+ });
1601
+ fontSizeBtn_1.appendTo('#' + parent.element.id + '_fontSizeBtn');
1602
+ }
1603
+ };
1604
+ ToolbarModule.prototype.refreshToolbar = function (type, isApplyBtn, isCropping, isZooming, cType) {
1605
+ var parent = this.parent;
1606
+ if (!parent.isImageLoaded || parent.isCropToolbar) {
1607
+ return;
1608
+ }
1609
+ var args = { toolbarType: type };
1610
+ if (type !== 'filter' && type !== 'color') {
1611
+ if (document.getElementById(parent.element.id + '_toolbar') && this.defToolbarItems.length > 0) {
1612
+ getComponent(document.getElementById(parent.element.id + '_toolbar'), 'toolbar').destroy();
1613
+ document.getElementById(parent.element.id + '_toolbar').innerHTML = '';
1614
+ }
1615
+ if (document.getElementById(parent.element.id + '_bottomToolbar') && this.defToolbarItems.length > 0) {
1616
+ if (document.getElementById(parent.element.id + '_bottomToolbar').className.indexOf('e-control') > -1) {
1617
+ getComponent(document.getElementById(parent.element.id + '_bottomToolbar'), 'toolbar').destroy();
1618
+ document.getElementById(parent.element.id + '_bottomToolbar').innerHTML = '';
1619
+ }
1620
+ }
1621
+ }
1622
+ this.refreshSlider();
1623
+ parent.isCropTab = false;
1624
+ switch (type) {
1625
+ case 'main':
1626
+ if (Browser.isDevice) {
1627
+ if (isCropping) {
1628
+ this.initMainToolbar(false, true, true);
1629
+ }
1630
+ else {
1631
+ this.initMainToolbar(false, true, null);
1632
+ }
1633
+ }
1634
+ else if (!Browser.isDevice || isZooming) {
1635
+ if (isZooming) {
1636
+ this.initMainToolbar(isApplyBtn, Browser.isDevice, null);
1637
+ }
1638
+ else {
1639
+ this.initMainToolbar(isApplyBtn, Browser.isDevice, null);
1640
+ }
1641
+ }
1642
+ if (Browser.isDevice) {
1643
+ this.initBottomToolbar();
1644
+ }
1645
+ break;
1646
+ case 'shapes':
1647
+ if (Browser.isDevice) {
1648
+ this.initMainToolbar(false, true, true);
1649
+ }
1650
+ if (parent.activeObj.shape === 'line' || parent.activeObj.shape === 'path') {
1651
+ args.toolbarItems = ['strokeColor', 'strokeWidth', 'duplicate', 'remove'];
1652
+ }
1653
+ else if (parent.activeObj.shape === 'arrow') {
1654
+ args.toolbarItems = ['strokeColor', 'strokeWidth', 'start', 'end', 'duplicate', 'remove'];
1655
+ }
1656
+ else {
1657
+ args.toolbarItems = ['fillColor', 'strokeColor', 'strokeWidth', 'duplicate', 'remove'];
1658
+ }
1659
+ parent.trigger('toolbarUpdating', args);
1660
+ this.initShapesToolbarItem(args.toolbarItems);
1661
+ break;
1662
+ case 'text':
1663
+ if (Browser.isDevice) {
1664
+ this.initMainToolbar(false, true, true);
1665
+ }
1666
+ args.toolbarItems = ['fontFamily', 'fontSize', 'fontColor', 'bold', 'italic', 'duplicate', 'remove', 'text'];
1667
+ parent.trigger('toolbarUpdating', args);
1668
+ this.initTextToolbarItem(args.toolbarItems);
1669
+ break;
1670
+ case 'pen':
1671
+ if (Browser.isDevice) {
1672
+ this.initMainToolbar(false, true, true);
1673
+ }
1674
+ args.toolbarItems = ['strokeColor', 'strokeWidth', 'remove'];
1675
+ parent.trigger('toolbarUpdating', args);
1676
+ this.initPenToolbarItem(args.toolbarItems);
1677
+ break;
1678
+ case 'adjustment':
1679
+ if (Browser.isDevice) {
1680
+ this.initMainToolbar(false, true, true);
1681
+ }
1682
+ this.initAdjustmentToolbarItem();
1683
+ break;
1684
+ case 'filter':
1685
+ this.updateContextualToolbar(type);
1686
+ break;
1687
+ case 'color':
1688
+ this.updateContextualToolbar(type, cType);
1689
+ break;
1690
+ case 'croptransform':
1691
+ parent.isCropTab = true;
1692
+ if (Browser.isDevice) {
1693
+ this.initMainToolbar(false, true, true);
1694
+ }
1695
+ parent.updateCropTransformItems();
1696
+ this.initCropTransformToolbar();
1697
+ break;
1698
+ }
1699
+ this.currToolbar = type;
1700
+ this.refreshDropDownBtn(isCropping);
1701
+ };
1702
+ ToolbarModule.prototype.getAdjustmentToolbarItem = function () {
1703
+ var toolbarItems = [];
1704
+ var parent = this.parent;
1705
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Brightness') > -1)) {
1706
+ toolbarItems.push({ id: parent.element.id + '_brightness', prefixIcon: 'e-icons e-brightness', cssClass: 'top-icon e-brightness',
1707
+ tooltipText: this.l10n.getConstant('Brightness'), align: 'Center' });
1708
+ }
1709
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Contrast') > -1)) {
1710
+ toolbarItems.push({ id: parent.element.id + '_contrast', prefixIcon: 'e-icons e-contrast', cssClass: 'top-icon e-contrast',
1711
+ tooltipText: this.l10n.getConstant('Contrast'), align: 'Center' });
1712
+ }
1713
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Hue') > -1)) {
1714
+ toolbarItems.push({ id: parent.element.id + '_hue', prefixIcon: 'e-icons e-fade', cssClass: 'top-icon e-fade',
1715
+ tooltipText: this.l10n.getConstant('Hue'), align: 'Center' });
1716
+ }
1717
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Saturation') > -1)) {
1718
+ toolbarItems.push({ id: parent.element.id + '_saturation', prefixIcon: 'e-icons e-saturation', cssClass: 'top-icon e-saturation',
1719
+ tooltipText: this.l10n.getConstant('Saturation'), align: 'Center' });
1720
+ }
1721
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Exposure') > -1)) {
1722
+ toolbarItems.push({ id: parent.element.id + '_exposure', prefixIcon: 'e-icons e-grain', cssClass: 'top-icon e-grain',
1723
+ tooltipText: this.l10n.getConstant('Exposure'), align: 'Center' });
1724
+ }
1725
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Opacity') > -1)) {
1726
+ toolbarItems.push({ id: parent.element.id + '_opacity', prefixIcon: 'e-icons e-opacity', cssClass: 'top-icon e-opacity',
1727
+ tooltipText: this.l10n.getConstant('Opacity'), align: 'Center' });
1728
+ }
1729
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Blur') > -1)) {
1730
+ toolbarItems.push({ id: parent.element.id + '_blur', prefixIcon: 'e-icons e-tint', cssClass: 'top-icon e-tint',
1731
+ tooltipText: this.l10n.getConstant('Blur'), align: 'Center' });
1732
+ }
1733
+ var tempToolbarItems = this.processToolbar('center');
1734
+ for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
1735
+ toolbarItems.push(tempToolbarItems[i]);
1736
+ }
1737
+ if (!Browser.isDevice) {
1738
+ toolbarItems.push({ id: parent.element.id + '_ok', prefixIcon: 'e-icons e-check', cssClass: 'top-icon e-tick',
1739
+ tooltipText: this.l10n.getConstant('OK'), align: 'Right' });
1740
+ toolbarItems.push({ id: parent.element.id + '_cancel', prefixIcon: 'e-icons e-close', cssClass: 'top-icon e-save',
1741
+ tooltipText: this.l10n.getConstant('Cancel'), align: 'Right' });
1742
+ }
1743
+ return toolbarItems;
1744
+ };
1745
+ ToolbarModule.prototype.getFilterToolbarItem = function () {
1746
+ var toolbarItems = [];
1747
+ var parent = this.parent;
1748
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Default') > -1)) {
1749
+ toolbarItems.push({ id: parent.element.id + '_default', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
1750
+ tooltipText: this.l10n.getConstant('Default'), align: 'Center',
1751
+ template: '<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id=' + parent.element.id + '_defaultCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Default') + '</span></div></div>' });
1752
+ }
1753
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Chrome') > -1)) {
1754
+ toolbarItems.push({ id: parent.element.id + '_chrome', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
1755
+ tooltipText: this.l10n.getConstant('Chrome'), align: 'Center',
1756
+ template: '<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id=' + parent.element.id + '_chromeCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Chrome') + '</span></div></div>' });
1757
+ }
1758
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Cold') > -1)) {
1759
+ toolbarItems.push({ id: parent.element.id + '_cold', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
1760
+ tooltipText: this.l10n.getConstant('Cold'), align: 'Center',
1761
+ template: '<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id=' + parent.element.id + '_coldCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Cold') + '</span></div></div>' });
1762
+ }
1763
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Warm') > -1)) {
1764
+ toolbarItems.push({ id: parent.element.id + '_warm', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
1765
+ tooltipText: this.l10n.getConstant('Warm'), align: 'Center',
1766
+ template: '<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id=' + parent.element.id + '_warmCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Warm') + '</span></div></div>' });
1767
+ }
1768
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Grayscale') > -1)) {
1769
+ toolbarItems.push({ id: parent.element.id + '_grayscale', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
1770
+ tooltipText: this.l10n.getConstant('Grayscale'), align: 'Center',
1771
+ template: '<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id=' + parent.element.id + '_grayscaleCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Grayscale') + '</span></div></div>' });
1772
+ }
1773
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Sepia') > -1)) {
1774
+ toolbarItems.push({ id: parent.element.id + '_sepia', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
1775
+ tooltipText: this.l10n.getConstant('Sepia'), align: 'Center',
1776
+ template: '<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id=' + parent.element.id + '_sepiaCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Sepia') + '</span></div></div>' });
1777
+ }
1778
+ if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Invert') > -1)) {
1779
+ toolbarItems.push({ id: parent.element.id + '_invert', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
1780
+ tooltipText: this.l10n.getConstant('Invert'), align: 'Center',
1781
+ template: '<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id=' + parent.element.id + '_invertCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Invert') + '</span></div></div>' });
1782
+ }
1783
+ var tempToolbarItems = this.processToolbar('center');
1784
+ for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
1785
+ toolbarItems.push(tempToolbarItems[i]);
1786
+ }
1787
+ return toolbarItems;
1788
+ };
1789
+ ToolbarModule.prototype.getPenToolbarItem = function (items) {
1790
+ var parent = this.parent;
1791
+ var toolbarItems = [];
1792
+ if (isNullOrUndefined(parent.toolbar) || parent.toolbar) {
1793
+ toolbarItems.push({ id: parent.element.id + '_annotation', tooltipText: this.l10n.getConstant('Annotation'), align: 'Center',
1794
+ template: '<button id="' + parent.element.id + '_annotationBtn"></button>' });
1795
+ }
1796
+ if (items.indexOf('strokeColor') > -1) {
1797
+ toolbarItems.push({ prefixIcon: 'e-icons e-copy', id: parent.element.id + '_pen_strokecolor',
1798
+ cssClass: 'top-icon e-pen-stroke-color',
1799
+ tooltipText: this.l10n.getConstant('StrokeColor'), align: 'Center', type: 'Input',
1800
+ template: '<button id="' + parent.element.id + '_penColorBtn"></button>' });
1801
+ }
1802
+ if (items.indexOf('strokeWidth') > -1) {
1803
+ toolbarItems.push({ prefixIcon: 'e-icons e-copy', cssClass: 'top-icon e-size',
1804
+ tooltipText: this.l10n.getConstant('StrokeWidth'),
1805
+ align: 'Center', type: 'Input', template: '<button id="' + parent.element.id + '_penStrokeWidth"></button>' });
1806
+ }
1807
+ toolbarItems.push({ align: 'Center', type: 'Separator' });
1808
+ if (items.indexOf('remove') > -1) {
1809
+ toolbarItems.push({ id: parent.element.id + '_remove', prefixIcon: 'e-icons e-trash', cssClass: 'top-icon e-trash',
1810
+ tooltipText: this.l10n.getConstant('Remove'), align: 'Center' });
1811
+ }
1812
+ var tempToolbarItems = this.processSubToolbar(items);
1813
+ for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
1814
+ toolbarItems.push(tempToolbarItems[i]);
1815
+ }
1816
+ if (!Browser.isDevice) {
1817
+ toolbarItems.push({ id: parent.element.id + '_ok', prefixIcon: 'e-icons e-check', cssClass: 'top-icon e-tick',
1818
+ tooltipText: this.l10n.getConstant('OK'), align: 'Right' });
1819
+ toolbarItems.push({ id: parent.element.id + '_cancel', prefixIcon: 'e-icons e-close', cssClass: 'top-icon e-save',
1820
+ tooltipText: this.l10n.getConstant('Cancel'), align: 'Right' });
1821
+ }
1822
+ return toolbarItems;
1823
+ };
1824
+ ToolbarModule.prototype.initPenToolbarItem = function (items) {
1825
+ var _this = this;
1826
+ var parent = this.parent;
1827
+ var leftItem = this.getLeftToolbarItem();
1828
+ var rightItem = this.getRightToolbarItem();
1829
+ var mainItem = this.getPenToolbarItem(items);
1830
+ var zoomItem = this.getZoomToolbarItem();
1831
+ if (Browser.isDevice) {
1832
+ this.defToolbarItems = mainItem;
1833
+ }
1834
+ else {
1835
+ this.defToolbarItems = leftItem.concat(zoomItem, mainItem, rightItem);
1836
+ }
1837
+ var toolbar = new Toolbar({
1838
+ width: '100%',
1839
+ items: this.defToolbarItems,
1840
+ clicked: this.defToolbarClicked.bind(this),
1841
+ created: function () {
1842
+ _this.renderAnnotationBtn(true);
1843
+ _this.createPenColor(items);
1844
+ _this.createPenBtn(items);
1845
+ _this.wireZoomBtnEvents();
1846
+ if (!Browser.isDevice) {
1847
+ _this.renderSaveBtn();
1848
+ }
1849
+ parent.trigger('toolbarCreated', { toolbarType: 'pen' });
1850
+ if (Browser.isDevice) {
1851
+ if (_this.defToolbarItems.length > 0 && document.getElementById(parent.element.id + '_toolbar')) {
1852
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1853
+ toolbar.refreshOverflow();
1854
+ toolbar.refreshOverflow();
1855
+ }
1856
+ }
1857
+ else {
1858
+ _this.createLeftToolbarControls();
1859
+ if (_this.defToolbarItems.length > 0 && document.getElementById(parent.element.id + '_toolbar')) {
1860
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1861
+ toolbar.refreshOverflow();
1862
+ }
1863
+ }
1864
+ }
1865
+ });
1866
+ if (Browser.isDevice) {
1867
+ toolbar.appendTo('#' + parent.element.id + '_bottomToolbar');
1868
+ }
1869
+ else {
1870
+ toolbar.appendTo('#' + parent.element.id + '_toolbar');
1871
+ }
1872
+ this.enableDisableTbrBtn();
1873
+ };
1874
+ ToolbarModule.prototype.createPenColor = function (items) {
1875
+ var _this = this;
1876
+ var parent = this.parent;
1877
+ if (items.indexOf('strokeColor') > -1) {
1878
+ parent.element.querySelector('.e-template.e-pen-stroke-color').appendChild(parent.createElement('input', {
1879
+ id: parent.element.id + '_pen_stroke'
1880
+ }));
1881
+ var penColor = new ColorPicker({
1882
+ modeSwitcher: false, value: '#fff',
1883
+ showButtons: false, mode: 'Palette', cssClass: 'e-pen-color',
1884
+ change: function (args) {
1885
+ parent.updatePenStrokeColor(args.currentValue.hex);
1886
+ _this.selFhdColor = args.currentValue.hex;
1887
+ strokeDDB_3.element.children[0].style.backgroundColor = args.currentValue.rgba;
1888
+ strokeDDB_3.toggle();
1889
+ }
1890
+ }, '#' + parent.element.id + '_pen_stroke');
1891
+ var strokeDDB_3 = new DropDownButton({
1892
+ open: function (args) {
1893
+ if (Browser.isDevice) {
1894
+ args.element.parentElement.style.top = strokeDDB_3.element.getBoundingClientRect().top -
1895
+ args.element.parentElement.offsetHeight + 'px';
1896
+ args.element.parentElement.style.left = parent.element.offsetLeft + 'px';
1897
+ }
1898
+ },
1899
+ target: '.e-pen-color',
1900
+ iconCss: 'e-dropdownbtn-preview'
1901
+ }, '#' + parent.element.id + '_penColorBtn');
1902
+ penColor.inline = true;
1903
+ var obj = { tempFreeHandDrawEditingStyles: null };
1904
+ parent.notify('freehand-draw', { prop: 'getTempFreeHandDrawEditingStyles', value: { obj: obj } });
1905
+ var indexObj = { freehandSelectedIndex: null };
1906
+ parent.notify('freehand-draw', { prop: 'getFreehandSelectedIndex', onPropertyChange: false, value: { obj: indexObj } });
1907
+ if (!isNullOrUndefined(indexObj['freehandSelectedIndex']) && indexObj['freehandSelectedIndex'] > -1) {
1908
+ parent.element.querySelector('.e-pen-stroke-color.e-template .e-dropdownbtn-preview').style.background
1909
+ = this.selFhdColor === '#42a5f5' ? obj['tempFreeHandDrawEditingStyles'].strokeColor :
1910
+ parent.pointColl[indexObj['freehandSelectedIndex']].strokeColor;
1911
+ }
1912
+ else {
1913
+ parent.element.querySelector('.e-pen-stroke-color.e-template .e-dropdownbtn-preview').style.background
1914
+ = '#fff';
1915
+ }
1916
+ }
1917
+ };
1918
+ ToolbarModule.prototype.createPenBtn = function (items) {
1919
+ var parent = this.parent;
1920
+ var strokeWidthItems = [
1921
+ { id: '1', text: this.l10n.getConstant('XSmall') },
1922
+ { id: '2', text: this.l10n.getConstant('Small') },
1923
+ { id: '3', text: this.l10n.getConstant('Medium') },
1924
+ { id: '4', text: this.l10n.getConstant('Large') },
1925
+ { id: '5', text: this.l10n.getConstant('XLarge') }
1926
+ ];
1927
+ if (items.indexOf('strokeWidth') > -1) {
1928
+ var strokeWidthBtn = document.getElementById(parent.element.id + '_penStrokeWidth');
1929
+ var spanElem_3 = document.createElement('span');
1930
+ var indexObj = { freehandSelectedIndex: null };
1931
+ parent.notify('freehand-draw', { prop: 'getFreehandSelectedIndex', onPropertyChange: false, value: { obj: indexObj } });
1932
+ if (!isNullOrUndefined(indexObj['freehandSelectedIndex']) && indexObj['freehandSelectedIndex'] > -1) {
1933
+ spanElem_3.innerHTML = this.getPenStroke(parent.pointColl[indexObj['freehandSelectedIndex']].strokeWidth);
1934
+ }
1935
+ else {
1936
+ spanElem_3.innerHTML = this.l10n.getConstant('Small');
1937
+ }
1938
+ spanElem_3.className = 'e-pen-stroke-width';
1939
+ strokeWidthBtn.appendChild(spanElem_3);
1940
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
1941
+ var drpDownBtn_2 = new DropDownButton({ items: strokeWidthItems,
1942
+ open: function (args) {
1943
+ if (Browser.isDevice) {
1944
+ args.element.parentElement.style.top = drpDownBtn_2.element.getBoundingClientRect().top -
1945
+ args.element.parentElement.offsetHeight + 'px';
1946
+ }
1947
+ var activeBtn = spanElem_3.innerHTML;
1948
+ args.element.querySelector('[aria-label = ' + '"' + activeBtn + '"' + ']').classList.add('e-selected-btn');
1949
+ },
1950
+ select: function (args) {
1951
+ spanElem_3.textContent = args.item.text;
1952
+ parent.updatePenStrokeWidth(args.item.id);
1953
+ if (Browser.isDevice) {
1954
+ if (document.getElementById(parent.element.id + '_bottomToolbar')) {
1955
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1956
+ var toolbar_8 = getComponent(parent.element.id + '_bottomToolbar', 'toolbar');
1957
+ toolbar_8.refreshOverflow();
1958
+ }
1959
+ }
1960
+ else {
1961
+ if (document.getElementById(parent.element.id + '_toolbar')) {
1962
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1963
+ var toolbar_9 = getComponent(parent.element.id + '_toolbar', 'toolbar');
1964
+ toolbar_9.refreshOverflow();
1965
+ }
1966
+ }
1967
+ }
1968
+ });
1969
+ // Render initialized DropDownButton.
1970
+ drpDownBtn_2.appendTo('#' + parent.element.id + '_penStrokeWidth');
1971
+ }
1972
+ };
1973
+ ToolbarModule.prototype.getPenStroke = function (value) {
1974
+ var textContent = '';
1975
+ var valueToTextContent = {
1976
+ 1: this.l10n.getConstant('XSmall'),
1977
+ 2: this.l10n.getConstant('Small'),
1978
+ 3: this.l10n.getConstant('Medium'),
1979
+ 4: this.l10n.getConstant('Large'),
1980
+ 5: this.l10n.getConstant('XLarge')
1981
+ };
1982
+ if (value >= 1 && value <= 5) {
1983
+ textContent = valueToTextContent[value];
1984
+ }
1985
+ return textContent;
1986
+ };
1987
+ ToolbarModule.prototype.initAdjustmentToolbarItem = function () {
1988
+ var _this = this;
1989
+ var parent = this.parent;
1990
+ var leftItem = this.getLeftToolbarItem(null);
1991
+ var rightItem = this.getRightToolbarItem();
1992
+ var mainItem = this.getAdjustmentToolbarItem();
1993
+ var zoomItem = this.getZoomToolbarItem();
1994
+ if (Browser.isDevice) {
1995
+ this.defToolbarItems = mainItem;
1996
+ }
1997
+ else {
1998
+ this.defToolbarItems = leftItem.concat(zoomItem, mainItem, rightItem);
1999
+ }
2000
+ var toolbar = new Toolbar({
2001
+ width: '100%',
2002
+ items: this.defToolbarItems,
2003
+ clicked: this.defToolbarClicked.bind(this),
2004
+ created: function () {
2005
+ _this.wireZoomBtnEvents();
2006
+ if (!Browser.isDevice) {
2007
+ _this.renderSaveBtn();
2008
+ }
2009
+ if (Browser.isDevice) {
2010
+ if (_this.defToolbarItems.length > 0 && document.getElementById(parent.element.id + '_toolbar')) {
2011
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2012
+ toolbar.refreshOverflow();
2013
+ }
2014
+ }
2015
+ else {
2016
+ _this.createLeftToolbarControls();
2017
+ if (_this.defToolbarItems.length > 0 && document.getElementById(parent.element.id + '_toolbar')) {
2018
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2019
+ toolbar.refreshOverflow();
2020
+ }
2021
+ }
2022
+ }
2023
+ });
2024
+ if (Browser.isDevice) {
2025
+ toolbar.appendTo('#' + parent.element.id + '_bottomToolbar');
2026
+ }
2027
+ else {
2028
+ toolbar.appendTo('#' + parent.element.id + '_toolbar');
2029
+ }
2030
+ this.enableDisableTbrBtn();
2031
+ };
2032
+ ToolbarModule.prototype.initFilterToolbarItem = function () {
2033
+ var _this = this;
2034
+ var parent = this.parent;
2035
+ var mainItem = this.getFilterToolbarItem();
2036
+ if (document.querySelector('#' + parent.element.id + '_contextualToolbar').classList.contains('e-control')) {
2037
+ getComponent(document.getElementById(parent.element.id + '_contextualToolbar'), 'toolbar').destroy();
2038
+ }
2039
+ var toolbar = new Toolbar({
2040
+ width: '100%',
2041
+ items: mainItem,
2042
+ clicked: this.contextualToolbarClicked.bind(this),
2043
+ created: function () {
2044
+ _this.updatePrivateVariables();
2045
+ _this.createCanvasFilter();
2046
+ if (parent.currentFilter === '') {
2047
+ parent.currentFilter = parent.element.id + '_default';
2048
+ }
2049
+ var hdrWrapper = document.querySelector('#' + parent.element.id + '_headWrapper');
2050
+ if (hdrWrapper) {
2051
+ hdrWrapper.style.display = 'none';
2052
+ }
2053
+ document.getElementById(parent.currentFilter + 'Canvas').parentElement.parentElement.classList.add('e-selected');
2054
+ _this.enableDisableTbrBtn();
2055
+ toolbar.refreshOverflow();
2056
+ }
2057
+ });
2058
+ toolbar.appendTo('#' + parent.element.id + '_contextualToolbar');
2059
+ };
2060
+ ToolbarModule.prototype.createCanvasFilter = function () {
2061
+ var parent = this.parent;
2062
+ showSpinner(parent.element);
2063
+ parent.element.style.opacity = '0.5';
2064
+ var imageData = parent.getCurrentCanvasData();
2065
+ this.inMemoryCanvas.width = imageData.width;
2066
+ this.inMemoryCanvas.height = imageData.height;
2067
+ this.inMemoryContext.putImageData(imageData, 0, 0);
2068
+ this.updateFilterCanvas('_defaultCanvas', 'default');
2069
+ this.updateFilterCanvas('_chromeCanvas', 'chrome');
2070
+ this.updateFilterCanvas('_coldCanvas', 'cold');
2071
+ this.updateFilterCanvas('_warmCanvas', 'warm');
2072
+ this.updateFilterCanvas('_grayscaleCanvas', 'grayscale');
2073
+ this.updateFilterCanvas('_sepiaCanvas', 'sepia');
2074
+ this.updateFilterCanvas('_invertCanvas', 'invert');
2075
+ hideSpinner(parent.element);
2076
+ parent.element.style.opacity = '1';
2077
+ parent.initialAdjustmentValue = this.lowerContext.filter;
2078
+ };
2079
+ ToolbarModule.prototype.updateFilterCanvas = function (selector, type) {
2080
+ var parent = this.parent;
2081
+ var filter = parent.element.querySelector('#' + parent.element.id + selector);
2082
+ if (filter) {
2083
+ var ctx = filter.getContext('2d');
2084
+ ctx = filter.getContext('2d');
2085
+ filter.style.width = '100px';
2086
+ filter.style.height = '100px';
2087
+ parent.notify('filter', { prop: 'updateAdj', value: { type: type, value: null, isPreview: true, ctx: ctx } });
2088
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
2089
+ }
2090
+ };
2091
+ ToolbarModule.prototype.getQuickAccessToolbarItem = function (isPenEdit) {
2092
+ var parent = this.parent;
2093
+ var args = { cancel: false, toolbarItems: [] };
2094
+ var toolbarItems = [];
2095
+ if (isNullOrUndefined(isPenEdit)) {
2096
+ toolbarItems.push('Clone');
2097
+ toolbarItems.push('Delete');
2098
+ if (parent.activeObj.shape === 'text') {
2099
+ toolbarItems.push('EditText');
2100
+ }
2101
+ args.shape = parent.toPascalCase(parent.activeObj.shape);
2102
+ }
2103
+ else if (isPenEdit) {
2104
+ toolbarItems.push('Delete');
2105
+ args.shape = 'Freehand draw';
2106
+ }
2107
+ args.toolbarItems = extend([], toolbarItems, null, true);
2108
+ parent.trigger('quickAccessToolbarOpen', args);
2109
+ var orgToolbarItems = [];
2110
+ if (args.cancel) {
2111
+ orgToolbarItems = [];
2112
+ }
2113
+ else {
2114
+ for (var i = 0; i < args.toolbarItems.length; i++) {
2115
+ switch (args.toolbarItems[i]) {
2116
+ case 'Clone':
2117
+ orgToolbarItems.push({ id: parent.element.id + '_duplicate', prefixIcon: 'e-icons e-order', cssClass: 'top-icon e-order',
2118
+ tooltipText: this.l10n.getConstant('Duplicate'), align: 'Left' });
2119
+ break;
2120
+ case 'Delete':
2121
+ orgToolbarItems.push({ id: parent.element.id + '_remove', prefixIcon: 'e-icons e-trash', cssClass: 'top-icon e-trash',
2122
+ tooltipText: this.l10n.getConstant('Remove'), align: 'Left' });
2123
+ break;
2124
+ case 'EditText':
2125
+ orgToolbarItems.push({ id: parent.element.id + '_editText', prefixIcon: 'e-icons e-annotation-edit', cssClass: 'top-icon e-annotation-edit',
2126
+ tooltipText: this.l10n.getConstant('EditText'), align: 'Left' });
2127
+ break;
2128
+ default:
2129
+ orgToolbarItems.push(args.toolbarItems[i]);
2130
+ break;
2131
+ }
2132
+ }
2133
+ }
2134
+ return orgToolbarItems;
2135
+ };
2136
+ ToolbarModule.prototype.renderQAT = function (isPenEdit) {
2137
+ var parent = this.parent;
2138
+ if (parent.activeObj && parent.showQuickAccessToolbar) {
2139
+ var qtArea = document.getElementById(parent.element.id + '_quickAccessToolbarArea');
2140
+ if (qtArea) {
2141
+ this.destroyQuickAccessToolbar();
2142
+ qtArea.style.display = 'block';
2143
+ }
2144
+ var items = this.getQuickAccessToolbarItem(isPenEdit);
2145
+ if (items.length === 0) {
2146
+ return;
2147
+ }
2148
+ if (isNullOrUndefined(parent.quickAccessToolbarTemplate)) {
2149
+ var toolbarObj = new Toolbar({
2150
+ items: items,
2151
+ clicked: this.quickAccessToolbarClicked.bind(this)
2152
+ });
2153
+ toolbarObj.appendTo('#' + parent.element.id + '_quickAccessToolbar');
2154
+ }
2155
+ if (isNullOrUndefined(isPenEdit)) {
2156
+ qtArea.style.width = 'auto';
2157
+ parent.activeObj.activePoint.width = Math.abs(parent.activeObj.activePoint.width);
2158
+ parent.activeObj.activePoint.height = Math.abs(parent.activeObj.activePoint.height);
2159
+ var x = parent.activeObj.activePoint.startX < parent.activeObj.activePoint.endX ?
2160
+ parent.activeObj.activePoint.startX : parent.activeObj.activePoint.endX;
2161
+ var y = parent.activeObj.activePoint.startY < parent.activeObj.activePoint.endY ?
2162
+ parent.activeObj.activePoint.startY : parent.activeObj.activePoint.endY;
2163
+ var width = parent.activeObj.activePoint.width;
2164
+ if (parent.activeObj.rotatedAngle !== 0 && parent.activeObj.shape !== 'arrow') {
2165
+ var object = { activePoint: null };
2166
+ parent.notify('shape', { prop: 'getSquarePointForRotatedShape', onPropertyChange: false,
2167
+ value: { obj: parent.activeObj, object: object } });
2168
+ var point = object['activePoint'];
2169
+ x = point.startX;
2170
+ y = point.startY;
2171
+ width = point.width;
2172
+ }
2173
+ else if (parent.activeObj.shape === 'path') {
2174
+ var path = parent.getSquarePointForPath(parent.activeObj);
2175
+ x = path.startX;
2176
+ y = path.startY;
2177
+ width = path.width;
2178
+ }
2179
+ qtArea.style.left = (x + (width / 2)) - (items.length * 25) + 'px';
2180
+ if (y - 60 < parent.img.destTop) {
2181
+ qtArea.style.top = parent.img.destTop + 'px';
2182
+ }
2183
+ else {
2184
+ qtArea.style.top = y - 60 + 'px';
2185
+ }
2186
+ }
2187
+ else if (isPenEdit) {
2188
+ var obj = { activePoint: null };
2189
+ var indexObj = { freehandSelectedIndex: null };
2190
+ parent.notify('freehand-draw', { prop: 'getFreehandSelectedIndex', onPropertyChange: false, value: { obj: indexObj } });
2191
+ parent.notify('freehand-draw', { prop: 'getSqPtFD',
2192
+ value: { idx: indexObj['freehandSelectedIndex'], obj: obj } });
2193
+ var point = obj['activePoint'];
2194
+ qtArea.style.width = 'auto';
2195
+ qtArea.style.left = (point.startX + (point.width / 2)) - (items.length * 27) + 'px';
2196
+ if (point.startY - 60 < parent.img.destTop) {
2197
+ qtArea.style.top = parent.img.destTop + 'px';
2198
+ }
2199
+ else {
2200
+ qtArea.style.top = point.startY - 60 + 'px';
2201
+ }
2202
+ }
2203
+ }
2204
+ };
2205
+ ToolbarModule.prototype.refreshDropDownBtn = function (isDisabled) {
2206
+ if (isNullOrUndefined(isDisabled)) {
2207
+ return;
2208
+ }
2209
+ var parent = this.parent;
2210
+ var annotation = document.querySelector('#' + parent.element.id + '_annotationBtn');
2211
+ if (annotation) {
2212
+ if (isDisabled) {
2213
+ annotation.classList.add('e-disabled');
2214
+ annotation.parentElement.classList.add('e-overlay');
2215
+ }
2216
+ else {
2217
+ annotation.classList.remove('e-disabled');
2218
+ annotation.parentElement.classList.remove('e-overlay');
2219
+ }
2220
+ getComponent(annotation, 'dropdown-btn').disabled = isDisabled;
2221
+ }
2222
+ var transform = document.querySelector('#' + parent.element.id + '_transformBtn');
2223
+ if (transform) {
2224
+ if (isDisabled) {
2225
+ transform.classList.add('e-disabled');
2226
+ transform.parentElement.classList.add('e-overlay');
2227
+ }
2228
+ else {
2229
+ transform.classList.remove('e-disabled');
2230
+ transform.parentElement.classList.remove('e-overlay');
2231
+ }
2232
+ getComponent(transform, 'dropdown-btn').disabled = isDisabled;
2233
+ }
2234
+ var adjustment = document.querySelector('#' + parent.element.id + '_adjustment');
2235
+ if (adjustment) {
2236
+ if (isDisabled) {
2237
+ adjustment.classList.add('e-disabled');
2238
+ adjustment.parentElement.classList.add('e-overlay');
2239
+ }
2240
+ else {
2241
+ adjustment.classList.remove('e-disabled');
2242
+ adjustment.parentElement.classList.remove('e-overlay');
2243
+ }
2244
+ getComponent(adjustment, 'btn').disabled = isDisabled;
2245
+ }
2246
+ var filter = document.querySelector('#' + parent.element.id + '_filter');
2247
+ if (filter) {
2248
+ if (isDisabled) {
2249
+ filter.classList.add('e-disabled');
2250
+ filter.parentElement.classList.add('e-overlay');
2251
+ }
2252
+ else {
2253
+ filter.classList.remove('e-disabled');
2254
+ filter.parentElement.classList.remove('e-overlay');
2255
+ }
2256
+ getComponent(filter, 'btn').disabled = isDisabled;
2257
+ }
2258
+ };
2259
+ ToolbarModule.prototype.cropSelect = function (args) {
2260
+ var parent = this.parent;
2261
+ parent.isCropTab = true;
2262
+ if (isNullOrUndefined(parent.transform.cropZoomFactor)) {
2263
+ parent.transform.cropZoomFactor = parent.transform.zoomFactor;
2264
+ parent.notify('draw', { prop: 'setTempZoomFactor', onPropertyChange: false, value: { tempZoomFactor: parent.transform.zoomFactor } });
2265
+ }
2266
+ parent.transform.zoomFactor = parent.transform.cropZoomFactor;
2267
+ var text = args.item.id;
2268
+ this.currentToolbar = 'crop';
2269
+ parent.currSelectionPoint = null;
2270
+ parent.select(text);
2271
+ this.enableDisableTbrBtn();
2272
+ parent.notify('transform', { prop: 'disableZoomOutBtn', value: { isZoomOut: true } });
2273
+ };
2274
+ ToolbarModule.prototype.quickAccessToolbarClicked = function (args, isContextualToolbar) {
2275
+ var parent = this.parent;
2276
+ var points = { x: parent.activeObj.activePoint.startX, y: parent.activeObj.activePoint.startY };
2277
+ if (args.item) {
2278
+ var duplicateObj = void 0;
2279
+ var objColl = void 0;
2280
+ var isPreventUndoRedo = null;
2281
+ var obj = { prevActObj: null };
2282
+ var object = { tempObj: null };
2283
+ parent.notify('draw', { prop: 'getPrevActObj', onPropertyChange: false, value: { obj: obj } });
2284
+ parent.notify('selection', { prop: 'getTempActObj', onPropertyChange: false, value: { obj: object } });
2285
+ object['tempObj']['activePoint']['height'] = Math.abs(object['tempObj']['activePoint']['height']);
2286
+ var pathObject = { isNewPath: null };
2287
+ parent.notify('draw', { prop: 'getNewPath', value: { obj: pathObject } });
2288
+ switch (args.item.id.replace(parent.element.id + '_', '').toLowerCase()) {
2289
+ case 'duplicate':
2290
+ if (!parent.element.querySelector('#' + parent.element.id + '_duplicate').classList.contains('e-disabled')) {
2291
+ if (!pathObject['isNewPath'] && JSON.stringify(object['tempObj']) === JSON.stringify(parent.activeObj)) {
2292
+ isPreventUndoRedo = true;
2293
+ }
2294
+ duplicateObj = extend({}, parent.activeObj, {}, true);
2295
+ if (isNullOrUndefined(parent.activeObj.currIndex)) {
2296
+ parent.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: isPreventUndoRedo } });
2297
+ }
2298
+ else if (obj['prevActObj']) {
2299
+ parent.activeObj.currIndex = null;
2300
+ duplicateObj.currIndex = null;
2301
+ parent.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: isPreventUndoRedo } });
2302
+ }
2303
+ else {
2304
+ parent.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: true } });
2305
+ }
2306
+ if (pathObject['isNewPath']) {
2307
+ parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
2308
+ }
2309
+ objColl = extend([], parent.objColl, [], true);
2310
+ duplicateObj.activePoint.startX += 10;
2311
+ duplicateObj.activePoint.startY -= 10;
2312
+ duplicateObj.activePoint.endX += 10;
2313
+ duplicateObj.activePoint.endY -= 10;
2314
+ if (duplicateObj.shape === 'path') {
2315
+ for (var i = 0; i < duplicateObj.pointColl.length; i++) {
2316
+ duplicateObj.pointColl[i].x += 10;
2317
+ duplicateObj.pointColl[i].y -= 10;
2318
+ }
2319
+ }
2320
+ parent.activeObj = duplicateObj;
2321
+ if (parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow') {
2322
+ parent.notify('shape', { prop: 'setPointCollForLineArrow', onPropertyChange: false,
2323
+ value: { obj: parent.activeObj } });
2324
+ }
2325
+ // parent.updateTrianglePoints(parent.activeObj); Invoke
2326
+ parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj } });
2327
+ parent.notify('undo-redo', { prop: 'updateUrObj', onPropertyChange: false, value: { objColl: objColl } });
2328
+ this.renderQAT();
2329
+ }
2330
+ break;
2331
+ case 'remove':
2332
+ if (!parent.element.querySelector('#' + parent.element.id + '_remove').classList.contains('e-disabled')) {
2333
+ parent.notify('selection', { prop: 'deleteItem', onPropertyChange: false });
2334
+ }
2335
+ break;
2336
+ case 'edittext':
2337
+ if (!parent.element.querySelector('#' + parent.element.id + '_editText').classList.contains('e-disabled')) {
2338
+ this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
2339
+ parent.notify('selection', { prop: 'setTempActObj', onPropertyChange: false,
2340
+ value: { obj: extend({}, parent.activeObj, {}, true) } });
2341
+ parent.notify('selection', { prop: 'setInitialTextEdit', onPropertyChange: false,
2342
+ value: { bool: true } });
2343
+ parent.notify('draw', { prop: 'setPrevActObj', onPropertyChange: false,
2344
+ value: { prevActObj: extend({}, parent.activeObj, {}, true) } });
2345
+ if (parent.activeObj.rotatedAngle !== 0) {
2346
+ points.x = parent.activeObj.horTopLinePointColl[0].x;
2347
+ points.y = parent.activeObj.horTopLinePointColl[0].y;
2348
+ }
2349
+ parent.notify('shape', { prop: 'renderTextArea', onPropertyChange: false,
2350
+ value: { x: points.x, y: points.y, actObj: parent.activeObj } });
2351
+ if (isNullOrUndefined(parent.activeObj.currIndex)) {
2352
+ parent.notify('draw', { prop: 'setShapeTextInsert', onPropertyChange: false, value: { bool: true } });
2353
+ }
2354
+ else if (obj['prevActObj']) {
2355
+ parent.notify('draw', { prop: 'setShapeTextInsert', onPropertyChange: false, value: { bool: true } });
2356
+ }
2357
+ if (document.getElementById(parent.element.id + '_quickAccessToolbarArea')) {
2358
+ document.getElementById(parent.element.id + '_quickAccessToolbarArea').style.display = 'none';
2359
+ }
2360
+ }
2361
+ break;
2362
+ }
2363
+ }
2364
+ if (isNullOrUndefined(isContextualToolbar)) {
2365
+ parent.trigger('quickAccessToolbarItemClick', args);
2366
+ }
2367
+ };
2368
+ ToolbarModule.prototype.defToolbarClicked = function (args) {
2369
+ var parent = this.parent;
2370
+ var isContextualToolbar = false;
2371
+ var isFilterFinetune = false;
2372
+ if (parent.element.querySelector('.e-contextual-toolbar-wrapper')) {
2373
+ if (!parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.contains('e-hide')) {
2374
+ isContextualToolbar = isFilterFinetune = true;
2375
+ }
2376
+ parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
2377
+ }
2378
+ if (args.item) {
2379
+ var type = args.item.id.replace(parent.element.id + '_', '').toLowerCase();
2380
+ if (type === 'duplicate' || type === 'remove' || type === 'edittext') {
2381
+ this.quickAccessToolbarClicked(args, true);
2382
+ parent.trigger('toolbarItemClicked', args);
2383
+ }
2384
+ else {
2385
+ var isDisabledFilter = false;
2386
+ var isDisabledAdjustment = false;
2387
+ var adjustment = document.querySelector('#' + parent.element.id + '_adjustment');
2388
+ if (adjustment && adjustment.classList.contains('e-disabled')) {
2389
+ isDisabledAdjustment = true;
2390
+ }
2391
+ var filter = document.querySelector('#' + parent.element.id + '_filter');
2392
+ if (filter && filter.classList.contains('e-disabled')) {
2393
+ isDisabledFilter = true;
2394
+ }
2395
+ this.enableDisableTbrBtn();
2396
+ this.performDefTbrClick(type, isContextualToolbar, isDisabledAdjustment, isDisabledFilter, isFilterFinetune);
2397
+ parent.trigger('toolbarItemClicked', args);
2398
+ }
2399
+ }
2400
+ };
2401
+ ToolbarModule.prototype.performDefTbrClick = function (type, isContextualToolbar, isDisabledAdjustment, isDisabledFilter, isFilterFinetune) {
2402
+ var parent = this.parent;
2403
+ var zoomIn = parent.element.querySelector('#' + parent.element.id + '_zoomIn');
2404
+ var isCropSelection = false;
2405
+ var panBtn;
2406
+ var splitWords;
2407
+ if (parent.activeObj.shape !== undefined) {
2408
+ splitWords = parent.activeObj.shape.split('-');
2409
+ }
2410
+ if (splitWords === undefined && parent.currObjType.isCustomCrop) {
2411
+ isCropSelection = true;
2412
+ }
2413
+ else if (splitWords !== undefined && splitWords[0] === 'crop') {
2414
+ isCropSelection = true;
2415
+ }
2416
+ if (!parent.disabled) {
2417
+ switch (type) {
2418
+ case 'pan':
2419
+ parent.currObjType.isCustomCrop = parent.currObjType.isFiltered = false;
2420
+ if (parent.currObjType.isUndoAction) {
2421
+ parent.notify('undo-redo', { prop: 'refreshUrc', value: { bool: null } });
2422
+ }
2423
+ if (isCropSelection) {
2424
+ parent.currObjType.isCustomCrop = false;
2425
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
2426
+ this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
2427
+ this.refreshToolbar('main');
2428
+ }
2429
+ if (parent.togglePan) {
2430
+ this.cancelPan();
2431
+ parent.notify('transform', { prop: 'setDisablePan', onPropertyChange: false, value: { bool: true } });
2432
+ if (this.currentToolbar === 'pen') {
2433
+ parent.freehandDraw(true);
2434
+ }
2435
+ }
2436
+ else {
2437
+ panBtn = parent.element.querySelector('.e-img-pan .e-btn');
2438
+ if (panBtn) {
2439
+ panBtn.classList.add('e-selected-btn');
2440
+ }
2441
+ parent.pan(true);
2442
+ parent.notify('transform', { prop: 'setDisablePan', onPropertyChange: false, value: { bool: false } });
2443
+ }
2444
+ if (zoomIn && parent.zoomSettings.zoomFactor >= parent.zoomSettings.maxZoomFactor) {
2445
+ zoomIn.classList.add('e-disabled');
2446
+ zoomIn.parentElement.classList.add('e-overlay');
2447
+ }
2448
+ else if (zoomIn) {
2449
+ zoomIn.classList.remove('e-disabled');
2450
+ zoomIn.parentElement.classList.remove('e-overlay');
2451
+ }
2452
+ this.refreshToolbar('main');
2453
+ break;
2454
+ case 'cancel':
2455
+ parent.notify('draw', { prop: 'performCancel', value: { isContextualToolbar: isContextualToolbar } });
2456
+ break;
2457
+ case 'ok':
2458
+ parent.okBtn();
2459
+ this.refreshDropDownBtn(false);
2460
+ this.currentToolbar = 'main';
2461
+ break;
2462
+ case 'crop':
2463
+ parent.notify('transform', { prop: 'disableZoomOutBtn', value: { isZoomOut: true } });
2464
+ break;
2465
+ case 'reset':
2466
+ parent.reset();
2467
+ this.currentToolbar = 'main';
2468
+ break;
2469
+ case 'undo':
2470
+ parent.notify('undo-redo', { prop: 'call-undo' });
2471
+ break;
2472
+ case 'redo':
2473
+ parent.notify('undo-redo', { prop: 'call-redo' });
2474
+ break;
2475
+ case 'adjustment':
2476
+ if (!isDisabledAdjustment) {
2477
+ if (parent.currObjType.isFiltered) {
2478
+ parent.okBtn();
2479
+ }
2480
+ this.refreshToolbar('adjustment');
2481
+ parent.setTempFilterProperties();
2482
+ this.openSlider('brightness');
2483
+ }
2484
+ break;
2485
+ case 'brightness':
2486
+ case 'contrast':
2487
+ case 'hue':
2488
+ case 'saturation':
2489
+ case 'opacity':
2490
+ case 'blur':
2491
+ case 'exposure':
2492
+ this.openSlider(type);
2493
+ break;
2494
+ case 'filter':
2495
+ if (!isDisabledFilter) {
2496
+ showSpinner(parent.element);
2497
+ this.refreshToolbar('filter');
2498
+ parent.setTempFilterProperties();
2499
+ hideSpinner(parent.element);
2500
+ }
2501
+ break;
2502
+ case 'default':
2503
+ case 'chrome':
2504
+ case 'cold':
2505
+ case 'warm':
2506
+ case 'grayscale':
2507
+ case 'blackandwhite':
2508
+ case 'sepia':
2509
+ case 'invert':
2510
+ case 'sharpen':
2511
+ parent.currObjType.isFiltered = true;
2512
+ parent.notify('filter', { prop: 'applyImageFilter', value: { option: type } });
2513
+ break;
2514
+ case 'upload':
2515
+ if (isFilterFinetune) {
2516
+ parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.remove('e-hide');
2517
+ }
2518
+ break;
2519
+ case 'bold':
2520
+ parent.notify('selection', { prop: 'setInitialTextEdit', value: { bool: false } });
2521
+ if (parent.activeObj.textSettings.bold && parent.activeObj.textSettings.italic) {
2522
+ parent.notify('shape', { prop: 'applyFontStyle', onPropertyChange: false,
2523
+ value: { item: 'italic' } });
2524
+ }
2525
+ else if (parent.activeObj.textSettings.bold && !parent.activeObj.textSettings.italic) {
2526
+ parent.notify('shape', { prop: 'applyFontStyle', onPropertyChange: false,
2527
+ value: { item: 'default' } });
2528
+ }
2529
+ else if (!parent.activeObj.textSettings.bold && parent.activeObj.textSettings.italic) {
2530
+ parent.notify('shape', { prop: 'applyFontStyle', onPropertyChange: false,
2531
+ value: { item: 'bolditalic' } });
2532
+ }
2533
+ else if (!parent.activeObj.textSettings.bold && !parent.activeObj.textSettings.italic) {
2534
+ parent.notify('shape', { prop: 'applyFontStyle', onPropertyChange: false,
2535
+ value: { item: 'bold' } });
2536
+ }
2537
+ if (parent.element.querySelector('#' + parent.element.id + '_bold').classList.contains('e-selected-btn')) {
2538
+ parent.element.querySelector('#' + parent.element.id + '_bold').classList.remove('e-selected-btn');
2539
+ }
2540
+ else {
2541
+ parent.element.querySelector('#' + parent.element.id + '_bold').classList.add('e-selected-btn');
2542
+ }
2543
+ break;
2544
+ case 'italic':
2545
+ parent.notify('selection', { prop: 'setInitialTextEdit', value: { bool: false } });
2546
+ if (parent.activeObj.textSettings.bold && parent.activeObj.textSettings.italic) {
2547
+ parent.notify('shape', { prop: 'applyFontStyle', onPropertyChange: false,
2548
+ value: { item: 'bold' } });
2549
+ }
2550
+ else if (parent.activeObj.textSettings.bold && !parent.activeObj.textSettings.italic) {
2551
+ parent.notify('shape', { prop: 'applyFontStyle', onPropertyChange: false,
2552
+ value: { item: 'bolditalic' } });
2553
+ }
2554
+ else if (!parent.activeObj.textSettings.bold && parent.activeObj.textSettings.italic) {
2555
+ parent.notify('shape', { prop: 'applyFontStyle', onPropertyChange: false,
2556
+ value: { item: 'default' } });
2557
+ }
2558
+ else if (!parent.activeObj.textSettings.bold && !parent.activeObj.textSettings.italic) {
2559
+ parent.notify('shape', { prop: 'applyFontStyle', onPropertyChange: false,
2560
+ value: { item: 'italic' } });
2561
+ }
2562
+ if (parent.element.querySelector('#' + parent.element.id + '_italic').classList.contains('e-selected-btn')) {
2563
+ parent.element.querySelector('#' + parent.element.id + '_italic').classList.remove('e-selected-btn');
2564
+ }
2565
+ else {
2566
+ parent.element.querySelector('#' + parent.element.id + '_italic').classList.add('e-selected-btn');
2567
+ }
2568
+ break;
2569
+ case 'croptransform':
2570
+ this.refreshToolbar('croptransform');
2571
+ break;
2572
+ case 'rotateleft':
2573
+ case 'rotateright':
2574
+ case 'horizontalflip':
2575
+ case 'verticalflip':
2576
+ parent.transformSelect(type);
2577
+ parent.notify('transform', { prop: 'disableZoomOutBtn', value: { isZoomOut: true } });
2578
+ break;
2579
+ case 'save':
2580
+ if (parent.element.querySelector('#' + parent.element.id + '_saveBtn').classList.contains('e-hide')) {
2581
+ parent.element.querySelector('#' + parent.element.id + '_saveBtn').classList.remove('e-hide');
2582
+ break;
2583
+ }
2584
+ else {
2585
+ parent.okBtn();
2586
+ }
2587
+ parent.element.querySelector('#' + parent.element.id + '_saveBtn').classList.add('e-hide');
2588
+ parent.element.querySelector('#' + parent.element.id + '_saveBtn').click();
2589
+ break;
2590
+ }
2591
+ }
2592
+ };
2593
+ ToolbarModule.prototype.contextualToolbarClicked = function (args) {
2594
+ var parent = this.parent;
2595
+ var selEle = parent.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
2596
+ if (selEle) {
2597
+ selEle.classList.remove('e-selected');
2598
+ }
2599
+ var type = args.item.id.replace(parent.element.id, '').split('_')[1];
2600
+ var imageFiltering = { filter: parent.toPascalCase(type), cancel: false };
2601
+ parent.trigger('imageFiltering', imageFiltering);
2602
+ if (imageFiltering.cancel) {
2603
+ return;
2604
+ }
2605
+ document.getElementById(args.item.id + 'Canvas').parentElement.parentElement.classList.add('e-selected');
2606
+ parent.currObjType.isFiltered = true;
2607
+ parent.notify('filter', { prop: 'applyImageFilter', value: { option: type.toLowerCase() } });
2608
+ parent.currentFilter = args.item.id;
2609
+ this.enableDisableTbrBtn();
2610
+ };
2611
+ ToolbarModule.prototype.refreshShapeDrawing = function () {
2612
+ var parent = this.parent;
2613
+ var object = { shape: '' };
2614
+ parent.notify('selection', { prop: 'getCurrentDrawingShape', onPropertyChange: false, value: { obj: object } });
2615
+ if (object['shape'] !== '') {
2616
+ parent.notify('selection', { prop: 'setCurrentDrawingShape', onPropertyChange: false, value: { value: '' } });
2617
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
2618
+ this.refreshToolbar('main', false);
2619
+ }
2620
+ };
2621
+ ToolbarModule.prototype.zoomInBtnClickHandler = function (e) {
2622
+ var parent = this.parent;
2623
+ if ((parent.zoomSettings.zoomTrigger & ZoomTrigger.Toolbar) === ZoomTrigger.Toolbar) {
2624
+ this.refreshShapeDrawing();
2625
+ if (Browser.isDevice && e.type === 'touchstart') {
2626
+ if (!e.returnValue) {
2627
+ return;
2628
+ }
2629
+ e.preventDefault();
2630
+ }
2631
+ var zoomIn = document.querySelector('#' + parent.element.id + '_zoomIn');
2632
+ EventHandler.trigger(zoomIn, 'click');
2633
+ var obj = { bool: false };
2634
+ parent.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: obj } });
2635
+ if (obj['bool']) {
2636
+ parent.notify('freehand-draw', { prop: 'applyFhd', onPropertyChange: false });
2637
+ this.destroyQuickAccessToolbar();
2638
+ }
2639
+ this.applyPreviewFilter();
2640
+ parent.currObjType.isFiltered = false;
2641
+ if (parent.togglePen) {
2642
+ parent.currObjType.isZoomed = true;
2643
+ parent.freeHandDraw(false);
2644
+ parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
2645
+ }
2646
+ parent.notify('draw', { prop: 'resetCurrentSelectionPoint' });
2647
+ parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
2648
+ value: { zoomFactor: .1, zoomPoint: null } });
2649
+ }
2650
+ };
2651
+ ToolbarModule.prototype.zoomOutBtnClickHandler = function (e) {
2652
+ var parent = this.parent;
2653
+ if ((parent.zoomSettings.zoomTrigger & ZoomTrigger.Toolbar) === ZoomTrigger.Toolbar) {
2654
+ this.refreshShapeDrawing();
2655
+ if (Browser.isDevice && e.type === 'touchstart') {
2656
+ if (!e.returnValue) {
2657
+ return;
2658
+ }
2659
+ e.preventDefault();
2660
+ }
2661
+ var zoomOut = document.querySelector('#' + parent.element.id + '_zoomOut');
2662
+ EventHandler.trigger(zoomOut, 'click');
2663
+ var obj = { bool: false };
2664
+ parent.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: obj } });
2665
+ if (obj['bool']) {
2666
+ parent.notify('freehand-draw', { prop: 'applyFhd', onPropertyChange: false });
2667
+ this.destroyQuickAccessToolbar();
2668
+ }
2669
+ this.applyPreviewFilter();
2670
+ parent.currObjType.isFiltered = false;
2671
+ if (parent.togglePen) {
2672
+ parent.currObjType.isZoomed = true;
2673
+ parent.freeHandDraw(false);
2674
+ parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
2675
+ }
2676
+ parent.notify('draw', { prop: 'resetCurrentSelectionPoint' });
2677
+ parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
2678
+ value: { zoomFactor: -.1, zoomPoint: null } });
2679
+ }
2680
+ };
2681
+ ToolbarModule.prototype.zoomInBtnMouseDownHandler = function (e) {
2682
+ e.preventDefault();
2683
+ this.zoomBtnHold = setInterval(this.zoomInBtnClickHandler.bind(this), 250);
2684
+ };
2685
+ ToolbarModule.prototype.zoomOutBtnMouseDownHandler = function (e) {
2686
+ e.preventDefault();
2687
+ this.zoomBtnHold = setInterval(this.zoomOutBtnClickHandler.bind(this), 250);
2688
+ };
2689
+ ToolbarModule.prototype.zoomBtnMouseUpHandler = function () {
2690
+ clearInterval(this.zoomBtnHold);
2691
+ this.zoomBtnHold = 0;
2692
+ };
2693
+ ToolbarModule.prototype.closeContextualToolbar = function () {
2694
+ var parent = this.parent;
2695
+ var isContextualToolbar = false;
2696
+ if ((parent.element.querySelector('#' + parent.element.id + '_contextualToolbar') &&
2697
+ !parent.element.querySelector('#' + parent.element.id + '_contextualToolbar').parentElement.classList.contains('e-hide')) ||
2698
+ (parent.element.querySelector('#' + parent.element.id + '_headWrapper')
2699
+ && !parent.element.querySelector('#' + parent.element.id + '_headWrapper').parentElement.classList.contains('e-hide'))) {
2700
+ parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
2701
+ parent.okBtn();
2702
+ this.refreshMainToolbar();
2703
+ isContextualToolbar = true;
2704
+ }
2705
+ return isContextualToolbar;
2706
+ };
2707
+ ToolbarModule.prototype.destroyQuickAccessToolbar = function () {
2708
+ var parent = this.parent;
2709
+ var quickToolbar = document.getElementById(parent.element.id + '_quickAccessToolbar');
2710
+ if (quickToolbar && quickToolbar.classList.contains('e-control')) {
2711
+ getComponent(quickToolbar, 'toolbar').destroy();
2712
+ }
2713
+ var qatArea = document.getElementById(parent.element.id + '_quickAccessToolbarArea');
2714
+ if (qatArea) {
2715
+ qatArea.style.display = 'none';
2716
+ }
2717
+ };
2718
+ ToolbarModule.prototype.renderSlider = function (type) {
2719
+ var parent = this.parent;
2720
+ var canvasWrapper = document.querySelector('#' + parent.element.id + '_contextualToolbarArea');
2721
+ var hdrWrapper = document.querySelector('#' + parent.element.id + '_headWrapper');
2722
+ var labelWrapper = document.querySelector('#' + parent.element.id + '_labelWrapper');
2723
+ if (!hdrWrapper) {
2724
+ hdrWrapper = canvasWrapper.appendChild(parent.createElement('div', {
2725
+ id: parent.element.id + '_headWrapper',
2726
+ styles: 'position: relative'
2727
+ }));
2728
+ labelWrapper = hdrWrapper.appendChild(parent.createElement('label', {
2729
+ id: parent.element.id + '_labelWrapper',
2730
+ styles: Browser.isDevice ? 'position: absolute; top: 25%; left: calc(50% - 150px); font-size: 15px; text-transform: capitalize; font-weight: 400;'
2731
+ : 'position: absolute; top: 25%; left: calc(50% - 226px); font-size: 15px; text-transform: capitalize; font-weight: 400;'
2732
+ }));
2733
+ }
2734
+ else {
2735
+ hdrWrapper.style.display = 'block';
2736
+ }
2737
+ labelWrapper.textContent = this.l10n.getConstant(parent.toPascalCase(type));
2738
+ var sliderWrapper = hdrWrapper.appendChild(parent.createElement('div', {
2739
+ id: parent.element.id + '_sliderWrapper',
2740
+ styles: 'position: absolute'
2741
+ }));
2742
+ var value = parent.getCurrAdjustmentValue(type);
2743
+ var min;
2744
+ var max;
2745
+ var slider;
2746
+ if (type === 'brightness' || type === 'contrast' || type === 'saturation' || type === 'exposure') {
2747
+ if (parent.finetuneSettings) {
2748
+ if (type === 'brightness' && parent.finetuneSettings.brightness) {
2749
+ min = parent.finetuneSettings.brightness.min;
2750
+ max = parent.finetuneSettings.brightness.max;
2751
+ }
2752
+ else if (type === 'contrast' && parent.finetuneSettings.contrast) {
2753
+ min = parent.finetuneSettings.contrast.min;
2754
+ max = parent.finetuneSettings.contrast.max;
2755
+ }
2756
+ else if (type === 'saturation' && parent.finetuneSettings.saturation) {
2757
+ min = parent.finetuneSettings.saturation.min;
2758
+ max = parent.finetuneSettings.saturation.max;
2759
+ }
2760
+ else if (type === 'exposure' && parent.finetuneSettings.exposure) {
2761
+ min = parent.finetuneSettings.exposure.min;
2762
+ max = parent.finetuneSettings.exposure.max;
2763
+ }
2764
+ else {
2765
+ min = -100;
2766
+ max = 100;
2767
+ }
2768
+ }
2769
+ else {
2770
+ min = -100;
2771
+ max = 100;
2772
+ }
2773
+ slider = this.createSlider(min, max, value, type);
2774
+ }
2775
+ else if (type === 'hue' || type === 'blur' || type === 'opacity') {
2776
+ if (parent.finetuneSettings) {
2777
+ if (type === 'hue' && parent.finetuneSettings.hue) {
2778
+ min = parent.finetuneSettings.hue.min;
2779
+ max = parent.finetuneSettings.hue.max;
2780
+ }
2781
+ else if (type === 'blur' && parent.finetuneSettings.blur) {
2782
+ min = parent.finetuneSettings.blur.min;
2783
+ max = parent.finetuneSettings.blur.max;
2784
+ }
2785
+ else if (type === 'opacity' && parent.finetuneSettings.opacity) {
2786
+ min = parent.finetuneSettings.opacity.min;
2787
+ max = parent.finetuneSettings.opacity.max;
2788
+ }
2789
+ else {
2790
+ min = 0;
2791
+ max = 100;
2792
+ }
2793
+ }
2794
+ else {
2795
+ min = 0;
2796
+ max = 100;
2797
+ }
2798
+ slider = this.createSlider(min, max, value, type);
2799
+ }
2800
+ slider.appendTo('#' + parent.element.id + '_sliderWrapper');
2801
+ sliderWrapper.style.left = (parseFloat(canvasWrapper.style.width) - parseFloat(slider.width)) / 2 + 'px';
2802
+ };
2803
+ ToolbarModule.prototype.createSlider = function (min, max, value, type) {
2804
+ var _this = this;
2805
+ var parent = this.parent;
2806
+ return new Slider({
2807
+ value: value,
2808
+ tooltip: { isVisible: true, placement: 'Before', showOn: 'Always' },
2809
+ type: 'MinRange',
2810
+ min: min,
2811
+ max: max,
2812
+ step: 10,
2813
+ width: Browser.isDevice ? '200px' : '300px',
2814
+ cssClass: 'e-slider',
2815
+ change: function (args) {
2816
+ parent.setCurrAdjustmentValue(type, args.value);
2817
+ _this.enableDisableTbrBtn();
2818
+ }
2819
+ });
2820
+ };
2821
+ ToolbarModule.prototype.applyPreviewFilter = function () {
2822
+ var parent = this.parent;
2823
+ if (document.querySelector('#' + parent.element.id + '_sliderWrapper') ||
2824
+ parent.currObjType.isFiltered) {
2825
+ parent.initialAdjustmentValue = parent.canvasFilter = this.lowerContext.filter;
2826
+ parent.currObjType.isFiltered = false;
2827
+ }
2828
+ };
2829
+ ToolbarModule.prototype.unselectBtn = function () {
2830
+ var parent = this.parent;
2831
+ var selectors = [
2832
+ '#' + parent.element.id + '_brightness',
2833
+ '#' + parent.element.id + '_contrast',
2834
+ '#' + parent.element.id + '_hue',
2835
+ '#' + parent.element.id + '_saturation',
2836
+ '#' + parent.element.id + '_opacity',
2837
+ '#' + parent.element.id + '_blur',
2838
+ '#' + parent.element.id + '_exposure'
2839
+ ];
2840
+ for (var _i = 0, selectors_1 = selectors; _i < selectors_1.length; _i++) {
2841
+ var selector = selectors_1[_i];
2842
+ var element = document.querySelector(selector);
2843
+ if (element.classList.contains('e-selected-btn')) {
2844
+ element.classList.remove('e-selected-btn');
2845
+ break;
2846
+ }
2847
+ }
2848
+ };
2849
+ ToolbarModule.prototype.openSlider = function (type) {
2850
+ this.unselectBtn();
2851
+ this.parent.currObjType.isFiltered = true;
2852
+ this.refreshToolbar('color', null, null, null, type);
2853
+ document.getElementById(this.parent.element.id + '_' + type).classList.add('e-selected-btn');
2854
+ };
2855
+ ToolbarModule.prototype.refreshSlider = function () {
2856
+ var sliderWrapper = document.querySelector('#' + this.parent.element.id + '_sliderWrapper');
2857
+ // eslint-disable-next-line
2858
+ var slider = document.querySelector('.e-slider');
2859
+ var hdrWrapper = document.querySelector('#' + this.parent.element.id + '_headWrapper');
2860
+ if (hdrWrapper) {
2861
+ hdrWrapper.style.display = 'none';
2862
+ }
2863
+ if (sliderWrapper && slider) {
2864
+ slider.ej2_instances[0].destroy();
2865
+ sliderWrapper.remove();
2866
+ }
2867
+ };
2868
+ ToolbarModule.prototype.updateToolbarItems = function () {
2869
+ var parent = this.parent;
2870
+ var selFillElem = parent.element.querySelector('.e-fill.e-template .e-dropdownbtn-preview');
2871
+ var selStrokeElem = parent.element.querySelector('.e-stroke.e-template .e-dropdownbtn-preview');
2872
+ var selTextStrokeElem = parent.element.querySelector('.e-text-font-color.e-template .e-dropdownbtn-preview');
2873
+ var selPenStrokeElem = parent.element.querySelector('.e-pen-stroke-color.e-template .e-dropdownbtn-preview');
2874
+ var strokeWidthElem = parent.element.querySelector('.e-shape-stroke-width');
2875
+ var fontFamilyElem = parent.element.querySelector('.e-text-font-family');
2876
+ var fontSizeElem = parent.element.querySelector('.e-text-font-size');
2877
+ var boldBtn = parent.element.querySelector('#' + parent.element.id + '_bold');
2878
+ var italicBtn = parent.element.querySelector('#' + parent.element.id + '_italic');
2879
+ if (isNullOrUndefined(parent.activeObj.strokeSettings.strokeWidth)) {
2880
+ parent.activeObj.strokeSettings.strokeWidth = 2;
2881
+ }
2882
+ if (selFillElem) {
2883
+ if (parent.activeObj.strokeSettings.fillColor === '') {
2884
+ selFillElem.classList.add('e-nocolor-item');
2885
+ }
2886
+ else {
2887
+ selFillElem.classList.remove('e-nocolor-item');
2888
+ selFillElem.style.background = parent.activeObj.strokeSettings.fillColor;
2889
+ }
2890
+ getComponent(parent.element.id + '_shape_fill', 'colorpicker').value
2891
+ = parent.activeObj.strokeSettings.fillColor + 'ff';
2892
+ }
2893
+ if (selStrokeElem) {
2894
+ selStrokeElem.style.background = parent.activeObj.strokeSettings.strokeColor;
2895
+ getComponent(parent.element.id + '_shape_stroke', 'colorpicker').value
2896
+ = parent.activeObj.strokeSettings.strokeColor + 'ff';
2897
+ }
2898
+ if (selTextStrokeElem) {
2899
+ selTextStrokeElem.style.background = parent.activeObj.strokeSettings.strokeColor;
2900
+ getComponent(parent.element.id + '_text_font', 'colorpicker').value
2901
+ = parent.activeObj.strokeSettings.strokeColor + 'ff';
2902
+ }
2903
+ if (selPenStrokeElem) {
2904
+ selPenStrokeElem.style.background = parent.activeObj.strokeSettings.strokeColor;
2905
+ getComponent(parent.element.id + '_pen_stroke', 'colorpicker').value
2906
+ = parent.activeObj.strokeSettings.strokeColor + 'ff';
2907
+ }
2908
+ if (fontFamilyElem) {
2909
+ if (Browser.isDevice) {
2910
+ fontFamilyElem.setAttribute('style', 'font-family:' + parent.activeObj.textSettings.fontFamily.toLowerCase());
2911
+ }
2912
+ else {
2913
+ fontFamilyElem.textContent = parent.activeObj.textSettings.fontFamily;
2914
+ }
2915
+ }
2916
+ if (fontSizeElem) {
2917
+ for (var i = 0; i < parent.fontSizeColl.length; i++) {
2918
+ if (parseInt(parent.fontSizeColl[i].text, 10) >= Math.round(parent.activeObj.textSettings.fontSize)) {
2919
+ fontSizeElem.textContent = (i + 1).toString();
2920
+ break;
2921
+ }
2922
+ }
2923
+ }
2924
+ if (boldBtn) {
2925
+ if (parent.activeObj.textSettings.bold) {
2926
+ boldBtn.classList.add('e-selected-btn');
2927
+ }
2928
+ else {
2929
+ boldBtn.classList.remove('e-selected-btn');
2930
+ }
2931
+ }
2932
+ if (italicBtn) {
2933
+ if (parent.activeObj.textSettings.italic) {
2934
+ italicBtn.classList.add('e-selected-btn');
2935
+ }
2936
+ else {
2937
+ italicBtn.classList.remove('e-selected-btn');
2938
+ }
2939
+ }
2940
+ if (strokeWidthElem) {
2941
+ var strokeWidth = Math.round((parent.activeObj.strokeSettings.strokeWidth)).toString();
2942
+ strokeWidthElem.textContent = this.getStrokeWidth(strokeWidth);
2943
+ }
2944
+ };
2945
+ ToolbarModule.prototype.getStrokeWidth = function (text) {
2946
+ var strokeWidth;
2947
+ var currentWidth = parseInt(text, 10) / 2;
2948
+ switch (currentWidth) {
2949
+ case 1:
2950
+ strokeWidth = this.l10n.getConstant('XSmall');
2951
+ break;
2952
+ case 2:
2953
+ strokeWidth = this.l10n.getConstant('Small');
2954
+ break;
2955
+ case 3:
2956
+ strokeWidth = this.l10n.getConstant('Medium');
2957
+ break;
2958
+ case 4:
2959
+ strokeWidth = this.l10n.getConstant('Large');
2960
+ break;
2961
+ case 5:
2962
+ strokeWidth = this.l10n.getConstant('XLarge');
2963
+ break;
2964
+ }
2965
+ return strokeWidth;
2966
+ };
2967
+ ToolbarModule.prototype.cancelPan = function () {
2968
+ var parent = this.parent;
2969
+ parent.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: true } });
2970
+ var panBtn = parent.element.querySelector('.e-img-pan .e-btn');
2971
+ if (panBtn) {
2972
+ panBtn.classList.remove('e-selected-btn');
2973
+ }
2974
+ parent.pan(false);
2975
+ };
2976
+ ToolbarModule.prototype.refreshMainToolbar = function () {
2977
+ if (this.currToolbar !== 'main') {
2978
+ this.refreshToolbar('main');
2979
+ }
2980
+ };
2981
+ ToolbarModule.prototype.destroySubComponents = function () {
2982
+ var parent = this.parent;
2983
+ var inputElement = parent.element.querySelectorAll('input.e-control');
2984
+ var btnElement = parent.element.querySelectorAll('button.e-control');
2985
+ for (var i = 0, len = inputElement.length; i < len; i++) {
2986
+ if (inputElement[i].classList.contains('e-color-picker')) {
2987
+ getComponent(inputElement[i], 'color-picker').destroy();
2988
+ detach(select('input#' + inputElement[i].id, parent.element));
2989
+ }
2990
+ }
2991
+ for (var i = 0, len = btnElement.length; i < len; i++) {
2992
+ if (btnElement[i].classList.contains('e-dropdown-btn')) {
2993
+ getComponent(btnElement[i], 'dropdown-btn').destroy();
2994
+ detach(select('button#' + btnElement[i].id, parent.element));
2995
+ }
2996
+ else if (btnElement[i].classList.contains('e-btn')) {
2997
+ getComponent(btnElement[i], 'btn').destroy();
2998
+ detach(select('button#' + btnElement[i].id, parent.element));
2999
+ }
3000
+ }
3001
+ };
3002
+ ToolbarModule.prototype.setInitialShapeSettings = function (args) {
3003
+ var parent = this.parent;
3004
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
3005
+ parent.currObjType.shape = args.item.id;
3006
+ parent.activeObj.shape = parent.currObjType.shape.toLowerCase();
3007
+ parent.currObjType.isDragging = parent.currObjType.isCustomCrop = false;
3008
+ parent.activeObj.shapeDegree = parent.transform.degree;
3009
+ parent.activeObj.shapeFlip = parent.transform.currFlipState;
3010
+ parent.activeObj.textFlip = parent.transform.currFlipState;
3011
+ parent.activeObj.flipObjColl = [];
3012
+ };
3013
+ ToolbarModule.prototype.getModuleName = function () {
3014
+ return 'toolbar-module';
3015
+ };
3016
+ return ToolbarModule;
3017
+ }());
3018
+ export { ToolbarModule };