1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528 | 1×
1×
1×
1×
1808×
1808×
1808×
1808×
1808×
1808×
1808×
1×
1981×
1981×
12581×
12580×
375×
375×
374×
374×
375×
375×
11456×
11456×
1×
1981×
1×
1981×
1×
1982×
1×
1981×
1981×
1981×
1×
1804×
1804×
1804×
1×
1×
1×
444×
68×
376×
376×
376×
22×
22×
376×
376×
376×
376×
376×
376×
376×
376×
376×
376×
376×
376×
375×
375×
376×
376×
376×
376×
376×
376×
376×
22×
22×
376×
376×
376×
1×
78×
78×
78×
78×
78×
78×
1×
53×
53×
1×
88×
15×
1×
395×
2×
395×
2×
395×
2×
395×
395×
1×
395×
395×
7×
1×
11×
11×
11×
10×
1×
320×
51×
51×
51×
51×
41×
41×
41×
41×
41×
41×
1×
40×
40×
40×
40×
40×
33×
3×
30×
30×
317×
15×
15×
15×
15×
15×
15×
15×
15×
15×
3×
12×
12×
1×
12×
12×
1×
611×
611×
611×
488×
488×
1×
1×
408×
1×
408×
29×
1×
144×
144×
21×
10×
9×
9×
10×
11×
134×
1×
1×
1×
4×
4×
4×
4×
1×
4×
2×
2×
2×
2×
1×
144×
1×
3587×
1780×
1807×
376×
376×
376×
1807×
22×
22×
22×
1807×
375×
375×
375×
1807×
376×
376×
376×
1807×
376×
376×
376×
1807×
376×
376×
376×
1807×
76×
76×
76×
9×
76×
1807×
1807×
1×
1821×
1821×
1821×
1821×
1821×
1821×
1×
1821×
1821×
1821×
1821×
1821×
1821×
1×
1905×
11×
1905×
74×
1905×
8×
1905×
18×
1905×
74×
1×
1808×
1808×
1808×
1808×
1808×
1808×
1808×
1808×
1807×
1807×
1808×
1808×
1808×
1808×
1808×
1808×
1808×
1×
607×
607×
124×
1×
124×
124×
124×
124×
1×
124×
1×
1×
10×
10×
1×
9085×
18×
7×
11×
1×
1817×
1817×
9085×
1×
1810×
2×
1810×
1×
1810×
1×
1810×
1×
1810×
1×
1810×
1×
1807×
12×
12×
1807×
1807×
1807×
1807×
1807×
1807×
1807×
1806×
1806×
1807×
1807×
1807×
1807×
1807×
1807×
1807×
1×
210×
14×
14×
14×
2×
1×
1×
1×
1×
2×
210×
195×
15×
14×
14×
14×
15×
13×
13×
1×
32680×
1×
5×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "../base/enum", "../base/constant", "../base/util", "./base-quick-toolbar", "../renderer/popup-renderer", "../base/classes"], function (require, exports, ej2_base_1, enum_1, events, util_1, base_quick_toolbar_1, popup_renderer_1, classes_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var QuickToolbar = (function () {
function QuickToolbar(parent, locator) {
this.debounceTimeout = 1000;
this.parent = parent;
this.locator = locator;
this.renderFactory = this.locator.getService('rendererFactory');
this.renderFactory.addRenderer(enum_1.RenderType.Popup, new popup_renderer_1.PopupRenderer(this.parent));
this.addEventListener();
this.isDestroyed = false;
}
QuickToolbar.prototype.formatItems = function (items) {
var formattedItems = [];
items.forEach(function (item) {
if (typeof item === 'string') {
switch (item.toLocaleLowerCase()) {
case 'open':
formattedItems.push('openLink');
break;
case 'edit':
formattedItems.push('editLink');
break;
case 'unlink':
formattedItems.push('removeLink');
break;
default:
formattedItems.push(item);
break;
}
}
else {
formattedItems.push(item);
}
});
return formattedItems;
};
QuickToolbar.prototype.getQTBarOptions = function (popType, mode, items, type) {
return {
popupType: popType,
toolbarItems: items,
mode: mode,
renderType: type,
cssClass: this.parent.getCssClass()
};
};
QuickToolbar.prototype.createQTBar = function (popupType, mode, items, type) {
if (items.length < 1) {
return null;
}
var qTBar = new base_quick_toolbar_1.BaseQuickToolbar(this.parent, this.locator);
qTBar.render(this.getQTBarOptions(popupType, mode, this.formatItems(items), type));
return qTBar;
};
QuickToolbar.prototype.initializeQuickToolbars = function () {
this.parent.quickToolbarModule = this;
this.contentRenderer = this.renderFactory.getRenderer(enum_1.RenderType.Content);
Iif (this.parent.inlineMode.enable && this.parent.inlineMode.onSelection && util_1.isIDevice()) {
ej2_base_1.EventHandler.add(this.contentRenderer.getDocument(), 'selectionchange', this.selectionChangeHandler, this);
}
};
QuickToolbar.prototype.onMouseDown = function (e) {
this.parent.isBlur = false;
this.parent.isRTE = true;
};
QuickToolbar.prototype.keyUpQT = function (e) {
if (e.which === 27) {
this.hideQuickToolbars();
}
};
QuickToolbar.prototype.renderQuickToolbars = function () {
if (this.linkQTBar || this.imageQTBar || this.audioQTBar || this.videoQTBar || this.textQTBar || this.tableQTBar) {
return;
}
this.linkQTBar = this.createQTBar('Link', 'Scrollable', this.parent.quickToolbarSettings.link, enum_1.RenderType.LinkToolbar);
this.renderFactory.addRenderer(enum_1.RenderType.LinkToolbar, this.linkQTBar);
if (!ej2_base_1.isNullOrUndefined(this.parent.quickToolbarSettings.text) && !this.parent.inlineMode.enable) {
this.textQTBar = this.createQTBar('Text', 'MultiRow', this.parent.quickToolbarSettings.text, enum_1.RenderType.TextToolbar);
this.renderFactory.addRenderer(enum_1.RenderType.TextToolbar, this.textQTBar);
}
this.imageQTBar = this.createQTBar('Image', 'MultiRow', this.parent.quickToolbarSettings.image, enum_1.RenderType.ImageToolbar);
this.renderFactory.addRenderer(enum_1.RenderType.ImageToolbar, this.imageQTBar);
this.audioQTBar = this.createQTBar('Audio', 'MultiRow', this.parent.quickToolbarSettings.audio, enum_1.RenderType.AudioToolbar);
this.renderFactory.addRenderer(enum_1.RenderType.AudioToolbar, this.audioQTBar);
this.videoQTBar = this.createQTBar('Video', 'MultiRow', this.parent.quickToolbarSettings.video, enum_1.RenderType.VideoToolbar);
this.renderFactory.addRenderer(enum_1.RenderType.VideoToolbar, this.videoQTBar);
this.tableQTBar = this.createQTBar('Table', 'MultiRow', this.parent.quickToolbarSettings.table, enum_1.RenderType.TableToolbar);
this.renderFactory.addRenderer(enum_1.RenderType.TableToolbar, this.tableQTBar);
Eif (this.linkQTBar) {
ej2_base_1.EventHandler.add(this.linkQTBar.element, 'mousedown', this.onMouseDown, this);
ej2_base_1.EventHandler.add(this.linkQTBar.element, 'keyup', this.keyUpQT, this);
}
if (this.imageQTBar) {
ej2_base_1.EventHandler.add(this.imageQTBar.element, 'mousedown', this.onMouseDown, this);
ej2_base_1.EventHandler.add(this.imageQTBar.element, 'keyup', this.keyUpQT, this);
}
Eif (this.audioQTBar) {
ej2_base_1.EventHandler.add(this.audioQTBar.element, 'mousedown', this.onMouseDown, this);
ej2_base_1.EventHandler.add(this.audioQTBar.element, 'keyup', this.keyUpQT, this);
}
Eif (this.videoQTBar) {
ej2_base_1.EventHandler.add(this.videoQTBar.element, 'mousedown', this.onMouseDown, this);
ej2_base_1.EventHandler.add(this.videoQTBar.element, 'keyup', this.keyUpQT, this);
}
if (this.textQTBar) {
ej2_base_1.EventHandler.add(this.textQTBar.element, 'mousedown', this.onMouseDown, this);
ej2_base_1.EventHandler.add(this.textQTBar.element, 'keyup', this.keyUpQT, this);
}
Eif (this.tableQTBar) {
ej2_base_1.EventHandler.add(this.tableQTBar.element, 'mousedown', this.onMouseDown, this);
ej2_base_1.EventHandler.add(this.tableQTBar.element, 'keyup', this.keyUpQT, this);
}
};
QuickToolbar.prototype.renderInlineQuickToolbar = function () {
Eif (this.parent.inlineMode.enable && (!ej2_base_1.Browser.isDevice || util_1.isIDevice())) {
ej2_base_1.addClass([this.parent.element], [classes_1.CLS_INLINE]);
this.inlineQTBar = this.createQTBar('Inline', 'MultiRow', this.parent.toolbarSettings.items, enum_1.RenderType.InlineToolbar);
this.renderFactory.addRenderer(enum_1.RenderType.InlineToolbar, this.inlineQTBar);
ej2_base_1.EventHandler.add(this.inlineQTBar.element, 'mousedown', this.onMouseDown, this);
ej2_base_1.EventHandler.add(this.inlineQTBar.element, 'keyup', this.keyUpQT, this);
}
};
QuickToolbar.prototype.showInlineQTBar = function (x, y, target) {
Iif (ej2_base_1.isNullOrUndefined(this.parent) || this.parent.readonly || target.tagName.toLowerCase() === 'img' || this.inlineQTBar.element.querySelector('.e-rte-color-content')) {
return;
}
this.inlineQTBar.showPopup(x, y, target);
};
QuickToolbar.prototype.hideInlineQTBar = function () {
if (this.inlineQTBar && !util_1.hasClass(this.inlineQTBar.element, 'e-popup-close')) {
this.inlineQTBar.hidePopup();
}
};
QuickToolbar.prototype.hideQuickToolbars = function () {
if (this.linkQTBar && !util_1.hasClass(this.linkQTBar.element, 'e-popup-close') && document.body.contains(this.linkQTBar.element)) {
this.linkQTBar.hidePopup();
}
if (this.textQTBar && !util_1.hasClass(this.textQTBar.element, 'e-popup-close') && document.body.contains(this.textQTBar.element)) {
this.textQTBar.hidePopup();
}
if (this.imageQTBar && !util_1.hasClass(this.imageQTBar.element, 'e-popup-close') && document.body.contains(this.imageQTBar.element)) {
this.imageQTBar.hidePopup();
}
Iif (this.audioQTBar && !util_1.hasClass(this.audioQTBar.element, 'e-popup-close') && document.body.contains(this.audioQTBar.element)) {
this.audioQTBar.hidePopup();
}
if (this.videoQTBar && !util_1.hasClass(this.videoQTBar.element, 'e-popup-close') && document.body.contains(this.videoQTBar.element)) {
this.videoQTBar.hidePopup();
}
Iif (this.tableQTBar && !util_1.hasClass(this.tableQTBar.element, 'e-popup-close') && document.body.contains(this.tableQTBar.element)) {
this.tableQTBar.hidePopup();
}
if (!ej2_base_1.isNullOrUndefined(this.parent) && this.parent.inlineMode.enable && (!ej2_base_1.Browser.isDevice || util_1.isIDevice())) {
this.hideInlineQTBar();
}
};
QuickToolbar.prototype.deBounce = function (x, y, target) {
var _this = this;
clearTimeout(this.deBouncer);
this.deBouncer = window.setTimeout(function () {
_this.showInlineQTBar(x, y, target);
}, this.debounceTimeout);
};
QuickToolbar.prototype.mouseUpHandler = function (e) {
if (this.parent.inlineMode.enable && (!ej2_base_1.Browser.isDevice || util_1.isIDevice())) {
var args = e.args.touches ?
e.args.changedTouches[0] : e.args;
var range = this.parent.getRange();
var target = e.args.target;
if (ej2_base_1.isNullOrUndefined(ej2_base_1.select('.' + classes_1.CLS_INLINE_POP, document.body))) {
Iif (util_1.isIDevice() && e.touchData && e.touchData.prevClientX !== e.touchData.clientX
&& e.touchData.prevClientY !== e.touchData.clientY) {
return;
}
this.hideInlineQTBar();
var parentLeft = this.parent.element.getBoundingClientRect().left;
this.offsetX = this.parent.iframeSettings.enable ? window.pageXOffset + parentLeft + args.clientX : args.pageX;
this.offsetY = util_1.pageYOffset(args, this.parent.element, this.parent.iframeSettings.enable);
if (target.nodeName === 'TEXTAREA') {
this.showInlineQTBar(this.offsetX, this.offsetY, target);
}
else {
var closestAnchor = ej2_base_1.closest(target, 'a');
target = closestAnchor ? closestAnchor : target;
var startNode = this.parent.getRange().startContainer.parentElement;
var endNode = this.parent.getRange().endContainer.parentElement;
if ((ej2_base_1.isNullOrUndefined(ej2_base_1.closest(startNode, 'A')) || ej2_base_1.isNullOrUndefined(ej2_base_1.closest(endNode, 'A'))) && (!ej2_base_1.closest(target, 'td,th') || !range.collapsed) &&
(target.tagName !== 'IMG' || this.parent.getRange().startOffset !== this.parent.getRange().endOffset)) {
if (this.parent.inlineMode.onSelection && range.collapsed) {
return;
}
this.target = target;
this.showInlineQTBar(this.offsetX, this.offsetY, target);
}
}
}
}
if (!ej2_base_1.isNullOrUndefined(this.textQTBar) && !ej2_base_1.isNullOrUndefined(this.parent.quickToolbarSettings.text) && !this.parent.inlineMode.enable) {
Iif (!ej2_base_1.isNullOrUndefined(e) && !ej2_base_1.isNullOrUndefined(e.name) && e.name === 'sourceCodeMouseDown') {
return;
}
var args = e.args.touches ?
e.args.changedTouches[0] : e.args;
var target = e.args.target;
this.hideQuickToolbars();
var parentLeft = this.parent.element.getBoundingClientRect().left;
this.offsetX = this.parent.iframeSettings.enable ? this.parent.element.ownerDocument.documentElement.scrollLeft
+ parentLeft + args.clientX : args.pageX;
this.offsetY = util_1.pageYOffset(args, this.parent.element, this.parent.iframeSettings.enable);
var range = this.parent.getRange();
if ((range.endContainer.parentElement.tagName === range.startContainer.parentElement.tagName && (range.startContainer.parentElement.tagName === 'A' && range.endContainer.parentElement.tagName === 'A')) ||
(target.tagName === 'IMG') || (target.tagName === 'VIDEO' || this.isEmbedVidElem(target)) || (target.tagName === 'AUDIO') || (target.childNodes[0] && target.childNodes[0].nodeType === 1 && target.childNodes[0].classList.contains('e-rte-audio')) ||
(this.parent.getRange().startOffset === this.parent.getRange().endOffset)) {
return;
}
this.target = target;
this.textQTBar.showPopup(this.offsetX, this.offsetY, target, 'text');
}
};
QuickToolbar.prototype.isEmbedVidElem = function (target) {
Iif ((target && target.nodeType !== 3 && target.nodeName !== 'BR' && (target.classList && target.classList.contains(classes_1.CLS_VID_CLICK_ELEM))) ||
(target && target.nodeName === 'IFRAME')) {
return true;
}
else {
return false;
}
};
QuickToolbar.prototype.keyDownHandler = function (e) {
var preventHide = e.args.altKey;
Iif (this.parent.inlineMode.enable && e.args.metaKey && e.args.keyCode === 65) {
this.showInlineQTBar(this.offsetX, this.offsetY, e.args.target);
return;
}
if (!preventHide) {
Iif ((this.parent.inlineMode.enable && (!ej2_base_1.Browser.isDevice || util_1.isIDevice()))
&& !ej2_base_1.isNullOrUndefined(ej2_base_1.select('.' + classes_1.CLS_INLINE_POP, document))) {
this.hideInlineQTBar();
}
if (this.textQTBar && !util_1.hasClass(this.textQTBar.element, 'e-popup-close')) {
this.textQTBar.hidePopup();
}
}
};
QuickToolbar.prototype.inlineQTBarMouseDownHandler = function () {
if ((this.parent.inlineMode.enable && (!ej2_base_1.Browser.isDevice || util_1.isIDevice()))
&& !ej2_base_1.isNullOrUndefined(ej2_base_1.select('.' + classes_1.CLS_INLINE_POP, document))) {
this.hideInlineQTBar();
}
if (!ej2_base_1.isNullOrUndefined(this.parent.quickToolbarSettings.text)) {
Iif (this.textQTBar && !util_1.hasClass(this.textQTBar.element, 'e-popup-close') && document.body.contains(this.textQTBar.element)) {
this.textQTBar.hidePopup();
}
}
};
QuickToolbar.prototype.keyUpHandler = function (e) {
var args = e.args;
if (this.parent.inlineMode.enable && !ej2_base_1.Browser.isDevice) {
if (this.parent.inlineMode.onSelection) {
if (this.parent.getSelection().length > 0) {
Eif ((args.ctrlKey && args.keyCode === 65) || (args.shiftKey && (args.keyCode === 33 || args.keyCode === 34 ||
args.keyCode === 35 || args.keyCode === 36 || args.keyCode === 37 || args.keyCode === 38 ||
args.keyCode === 39 || args.keyCode === 40))) {
this.showInlineQTBar(this.offsetX, this.offsetY, args.target);
}
}
return;
}
this.deBounce(this.offsetX, this.offsetY, args.target);
}
if (this.parent.quickToolbarSettings.text && !ej2_base_1.Browser.isDevice) {
Eif ((args.ctrlKey && args.keyCode === 65) || (args.shiftKey && (args.keyCode === 33 || args.keyCode === 34 ||
args.keyCode === 35 || args.keyCode === 36 || args.keyCode === 37 || args.keyCode === 38 ||
args.keyCode === 39 || args.keyCode === 40))) {
this.textQTBar.showPopup(this.offsetX, this.offsetY, args.target, 'text');
}
}
};
QuickToolbar.prototype.selectionChangeHandler = function (e) {
var _this = this;
clearTimeout(this.deBouncer);
this.deBouncer = window.setTimeout(function () {
_this.onSelectionChange(e);
}, this.debounceTimeout);
};
QuickToolbar.prototype.onSelectionChange = function (e) {
if (!ej2_base_1.isNullOrUndefined(ej2_base_1.select('.' + classes_1.CLS_INLINE_POP, document.body))) {
return;
}
var selection = this.contentRenderer.getDocument().getSelection();
Eif (!selection.isCollapsed) {
this.mouseUpHandler({ args: e });
}
};
QuickToolbar.prototype.getInlineBaseToolbar = function () {
return this.inlineQTBar && this.inlineQTBar.quickTBarObj;
};
QuickToolbar.prototype.destroy = function () {
if (this.isDestroyed) {
return;
}
if (this.linkQTBar && !this.linkQTBar.isDestroyed) {
ej2_base_1.EventHandler.remove(this.linkQTBar.element, 'mousedown', this.onMouseDown);
ej2_base_1.EventHandler.remove(this.linkQTBar.element, 'keyup', this.keyUpQT);
this.linkQTBar.destroy();
}
if (this.textQTBar && !this.textQTBar.isDestroyed) {
ej2_base_1.EventHandler.remove(this.textQTBar.element, 'mousedown', this.onMouseDown);
ej2_base_1.EventHandler.remove(this.textQTBar.element, 'keyup', this.keyUpQT);
this.textQTBar.destroy();
}
if (this.imageQTBar && !this.imageQTBar.isDestroyed) {
ej2_base_1.EventHandler.remove(this.imageQTBar.element, 'mousedown', this.onMouseDown);
ej2_base_1.EventHandler.remove(this.imageQTBar.element, 'keyup', this.keyUpQT);
this.imageQTBar.destroy();
}
if (this.audioQTBar && !this.audioQTBar.isDestroyed) {
ej2_base_1.EventHandler.remove(this.audioQTBar.element, 'mousedown', this.onMouseDown);
ej2_base_1.EventHandler.remove(this.audioQTBar.element, 'keyup', this.keyUpQT);
this.audioQTBar.destroy();
}
if (this.videoQTBar && !this.videoQTBar.isDestroyed) {
ej2_base_1.EventHandler.remove(this.videoQTBar.element, 'mousedown', this.onMouseDown);
ej2_base_1.EventHandler.remove(this.videoQTBar.element, 'keyup', this.keyUpQT);
this.videoQTBar.destroy();
}
if (this.tableQTBar && !this.tableQTBar.isDestroyed) {
ej2_base_1.EventHandler.remove(this.tableQTBar.element, 'mousedown', this.onMouseDown);
ej2_base_1.EventHandler.remove(this.tableQTBar.element, 'keyup', this.keyUpQT);
this.tableQTBar.destroy();
}
if (this.inlineQTBar && !this.inlineQTBar.isDestroyed) {
ej2_base_1.EventHandler.remove(this.inlineQTBar.element, 'mousedown', this.onMouseDown);
ej2_base_1.EventHandler.remove(this.inlineQTBar.element, 'keyup', this.keyUpQT);
if (util_1.isIDevice()) {
ej2_base_1.EventHandler.remove(document, 'selectionchange', this.selectionChangeHandler);
}
this.inlineQTBar.destroy();
}
this.removeEventListener();
this.isDestroyed = true;
};
QuickToolbar.prototype.wireInlineQTBarEvents = function () {
this.parent.on(events.mouseUp, this.mouseUpHandler, this);
this.parent.on(events.mouseDown, this.inlineQTBarMouseDownHandler, this);
this.parent.on(events.keyDown, this.keyDownHandler, this);
this.parent.on(events.keyUp, this.keyUpHandler, this);
this.parent.on(events.sourceCodeMouseDown, this.mouseUpHandler, this);
this.parent.on(events.renderInlineToolbar, this.renderInlineQuickToolbar, this);
};
QuickToolbar.prototype.unWireInlineQTBarEvents = function () {
this.parent.off(events.mouseUp, this.mouseUpHandler);
this.parent.off(events.mouseDown, this.inlineQTBarMouseDownHandler);
this.parent.off(events.keyDown, this.keyDownHandler);
this.parent.off(events.keyUp, this.keyUpHandler);
this.parent.off(events.sourceCodeMouseDown, this.mouseUpHandler);
this.parent.off(events.renderInlineToolbar, this.renderInlineQuickToolbar);
};
QuickToolbar.prototype.toolbarUpdated = function (args) {
if (this.linkQTBar && !util_1.hasClass(this.linkQTBar.element, 'e-popup-close')) {
this.linkQTBar.hidePopup();
}
if (this.imageQTBar && !util_1.hasClass(this.imageQTBar.element, 'e-popup-close')) {
this.imageQTBar.hidePopup();
}
if (this.audioQTBar && !util_1.hasClass(this.audioQTBar.element, 'e-popup-close')) {
this.audioQTBar.hidePopup();
}
if (this.videoQTBar && !util_1.hasClass(this.videoQTBar.element, 'e-popup-close')) {
this.videoQTBar.hidePopup();
}
if (this.tableQTBar && !util_1.hasClass(this.tableQTBar.element, 'e-popup-close')) {
this.tableQTBar.hidePopup();
}
};
QuickToolbar.prototype.addEventListener = function () {
Iif (this.parent.isDestroyed) {
return;
}
this.parent.on(events.initialEnd, this.initializeQuickToolbars, this);
this.parent.on(events.mouseDown, this.renderQuickToolbars, this);
this.parent.on(events.toolbarUpdated, this.toolbarUpdated, this);
this.parent.on(events.drop, this.renderQuickToolbars, this);
this.wireInlineQTBarEvents();
this.parent.on(events.modelChanged, this.onPropertyChanged, this);
if (this.parent.quickToolbarSettings.actionOnScroll === 'hide') {
this.parent.on(events.scroll, this.hideQuickToolbars, this);
this.parent.on(events.contentscroll, this.hideQuickToolbars, this);
}
this.parent.on(events.focusChange, this.hideQuickToolbars, this);
this.parent.on(events.iframeMouseDown, this.onIframeMouseDown, this);
this.parent.on(events.destroy, this.destroy, this);
this.parent.on(events.keyDown, this.onKeyDown, this);
this.parent.on(events.rtlMode, this.setRtl, this);
this.parent.on(events.bindCssClass, this.setCssClass, this);
this.parent.on(events.hidePopup, this.hideQuickToolbars, this);
};
QuickToolbar.prototype.onKeyDown = function (e) {
var args = e.args;
if (args.which === 8 || args.which === 46) {
if (this.imageQTBar && !util_1.hasClass(this.imageQTBar.element, 'e-popup-close')) {
this.imageQTBar.hidePopup();
}
Iif (this.audioQTBar && !util_1.hasClass(this.audioQTBar.element, 'e-popup-close')) {
this.audioQTBar.hidePopup();
}
Iif (this.videoQTBar && !util_1.hasClass(this.videoQTBar.element, 'e-popup-close')) {
this.videoQTBar.hidePopup();
}
Iif (this.tableQTBar && !util_1.hasClass(this.tableQTBar.element, 'e-popup-close')) {
this.tableQTBar.hidePopup();
}
if (this.linkQTBar && !util_1.hasClass(this.linkQTBar.element, 'e-popup-close')) {
this.linkQTBar.hidePopup();
}
if (this.textQTBar && !util_1.hasClass(this.textQTBar.element, 'e-popup-close')) {
this.textQTBar.hidePopup();
}
}
};
QuickToolbar.prototype.onIframeMouseDown = function () {
this.hideQuickToolbars();
this.hideInlineQTBar();
};
QuickToolbar.prototype.updateCss = function (baseQTObj, e) {
if (baseQTObj && e.cssClass) {
if (ej2_base_1.isNullOrUndefined(e.oldCssClass && baseQTObj.quickTBarObj.toolbarObj.cssClass !== e.cssClass)) {
baseQTObj.quickTBarObj.toolbarObj.setProperties({ cssClass: (baseQTObj.quickTBarObj.toolbarObj.cssClass + ' ' + e.cssClass).trim() });
}
else {
baseQTObj.quickTBarObj.toolbarObj.setProperties({ cssClass: (baseQTObj.quickTBarObj.toolbarObj.cssClass.replace(e.oldCssClass, '').trim() + ' ' + e.cssClass).trim() });
}
}
};
QuickToolbar.prototype.setCssClass = function (e) {
var baseQuickToolbarObj = [
this.inlineQTBar, this.imageQTBar, this.linkQTBar, this.textQTBar, this.tableQTBar
];
for (var i = 0; i < baseQuickToolbarObj.length; i++) {
this.updateCss(baseQuickToolbarObj[i], e);
}
};
QuickToolbar.prototype.setRtl = function (args) {
if (this.inlineQTBar) {
this.inlineQTBar.quickTBarObj.toolbarObj.setProperties({ enableRtl: args.enableRtl });
}
if (this.imageQTBar) {
this.imageQTBar.quickTBarObj.toolbarObj.setProperties({ enableRtl: args.enableRtl });
}
if (this.audioQTBar) {
this.audioQTBar.quickTBarObj.toolbarObj.setProperties({ enableRtl: args.enableRtl });
}
if (this.videoQTBar) {
this.videoQTBar.quickTBarObj.toolbarObj.setProperties({ enableRtl: args.enableRtl });
}
if (this.linkQTBar) {
this.linkQTBar.quickTBarObj.toolbarObj.setProperties({ enableRtl: args.enableRtl });
}
Iif (this.textQTBar) {
this.textQTBar.quickTBarObj.toolbarObj.setProperties({ enableRtl: args.enableRtl });
}
};
QuickToolbar.prototype.removeEventListener = function () {
if (this.deBouncer) {
clearTimeout(this.deBouncer);
this.deBouncer = null;
}
this.parent.off(events.initialEnd, this.initializeQuickToolbars);
this.parent.off(events.mouseDown, this.renderQuickToolbars);
this.parent.off(events.toolbarUpdated, this.toolbarUpdated);
this.parent.off(events.drop, this.renderQuickToolbars);
this.unWireInlineQTBarEvents();
this.parent.off(events.modelChanged, this.onPropertyChanged);
if (this.parent.quickToolbarSettings.actionOnScroll === 'hide') {
this.parent.off(events.scroll, this.hideQuickToolbars);
this.parent.off(events.contentscroll, this.hideQuickToolbars);
}
this.parent.off(events.focusChange, this.hideQuickToolbars);
this.parent.off(events.destroy, this.destroy);
this.parent.off(events.iframeMouseDown, this.onIframeMouseDown);
this.parent.off(events.keyDown, this.onKeyDown);
this.parent.off(events.rtlMode, this.setRtl);
this.parent.off(events.bindCssClass, this.setCssClass);
this.parent.off(events.hidePopup, this.hideQuickToolbars);
};
QuickToolbar.prototype.onPropertyChanged = function (e) {
if (!ej2_base_1.isNullOrUndefined(e.newProp.quickToolbarSettings)) {
for (var _i = 0, _a = Object.keys(e.newProp.quickToolbarSettings); _i < _a.length; _i++) {
var prop = _a[_i];
switch (prop) {
case 'actionOnScroll':
if (e.newProp.quickToolbarSettings.actionOnScroll === 'none') {
this.parent.off(events.scroll, this.hideQuickToolbars);
this.parent.off(events.contentscroll, this.hideQuickToolbars);
}
else {
this.parent.on(events.scroll, this.hideQuickToolbars, this);
this.parent.on(events.contentscroll, this.hideQuickToolbars, this);
}
break;
}
}
}
if (e.module !== this.getModuleName()) {
return;
}
if (this.inlineQTBar) {
ej2_base_1.removeClass([this.parent.element], [classes_1.CLS_INLINE]);
this.unWireInlineQTBarEvents();
this.hideInlineQTBar();
}
if (this.parent.inlineMode.enable && (!ej2_base_1.Browser.isDevice || util_1.isIDevice())) {
ej2_base_1.addClass([this.parent.element], [classes_1.CLS_INLINE]);
this.wireInlineQTBarEvents();
}
};
QuickToolbar.prototype.getModuleName = function () {
return 'quickToolbar';
};
QuickToolbar.prototype.getQuickToolbarInstance = function () {
return [this.linkQTBar, this.imageQTBar, this.audioQTBar, this.videoQTBar, this.tableQTBar, this.textQTBar, this.inlineQTBar];
};
return QuickToolbar;
}());
exports.QuickToolbar = QuickToolbar;
});
|