| 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 | 1×
1×
1×
1×
6584×
6584×
6584×
6584×
6584×
6584×
6584×
1×
6584×
6584×
1×
3419×
3419×
3419×
85475×
5696×
56×
56×
56×
56×
56×
56×
56×
56×
56×
1×
2849×
1×
1×
1×
2826×
2×
2×
2824×
1×
3438×
56×
56×
56×
56×
1×
2829×
2829×
1×
2829×
2829×
2829×
2829×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "../base/constant", "../models/items", "../base/classes", "../base/enum", "../base/util"], function (require, exports, ej2_base_1, events, model, classes, enum_1, util_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var MenuButton = (function () {
function MenuButton(parent, serviceLocator) {
this.isDestroyed = false;
this.parent = parent;
this.locator = serviceLocator;
this.i10n = serviceLocator.getService('rteLocale');
this.renderFactory = this.locator.getService('rendererFactory');
this.addEventListener();
this.initRender = true;
}
MenuButton.prototype.addEventListener = function () {
this.parent.on(events.rtlMode, this.setRtl, this);
this.parent.on(events.bindCssClass, this.setCssClass, this);
};
MenuButton.prototype.renderMenu = function (toolbarItems, toolbarElement, containerType) {
var _this = this;
this.toolbarRenderer = this.renderFactory.getRenderer(enum_1.RenderType.Toolbar);
model.templateItems.forEach(function (item) {
if (util_1.getIndex(item, toolbarItems) !== -1) {
switch (item) {
case 'aicommands': {
var menuName = item;
var rootElement = ej2_base_1.select('#' + _this.parent.getID() + '_' + containerType.toLowerCase() + '_AICommandsDropDownMenu', toolbarElement);
var ulElement = _this.parent.createElement('ul', { id: _this.parent.getID() + '_' + containerType.toLowerCase() + '_AICommandsMenu' });
rootElement.appendChild(ulElement);
var argument = {
dropDownItems: {
iconCss: 'e-ai-chat e-icons',
cssClass: classes.CLS_DROPDOWN_POPUP + ' ' + classes.CLS_DROPDOWN_ITEMS + ' ' + classes.CLS_AI_COMMANDS_TBAR_BTN + ' ' + classes.CLS_DROPDOWN_MENU,
target: '#' + ulElement.id
},
menuItems: {
items: _this.parent.aiAssistantSettings.commands
},
name: menuName,
containerType: containerType,
toolbarElement: toolbarElement,
dropDownRoot: rootElement,
menuRoot: ulElement
};
var _a = _this.toolbarRenderer.renderMenu(argument), menu = _a.menu, dropDownButton = _a.dropDownButton;
_this.aiCommandsMenu = menu;
_this.aiCommandsDropDownButton = dropDownButton;
break;
}
}
}
});
};
MenuButton.prototype.setRtl = function (args) {
if (this.aiCommandsMenu) {
this.aiCommandsMenu.setProperties({ enableRtl: args.enableRtl });
this.aiCommandsDropDownButton.setProperties({ enableRtl: args.enableRtl });
}
};
MenuButton.prototype.setCssClass = function (args) {
if (this.aiCommandsMenu && !this.initRender) {
this.aiCommandsMenu.setProperties({ cssClass: args.cssClass + ' e-rte-aicommands-menu' + 'e-rte-menu ' + classes.CLS_RTE_ELEMENTS });
this.aiCommandsDropDownButton.setProperties({ cssClass: args.cssClass + '' + classes.CLS_DROPDOWN_POPUP + ' ' + classes.CLS_DROPDOWN_ITEMS + ' ' + classes.CLS_AI_COMMANDS_TBAR_BTN + ' ' + classes.CLS_DROPDOWN_MENU });
}
else {
this.initRender = false;
}
};
MenuButton.prototype.destroyMenu = function () {
if (this.aiCommandsMenu && !this.aiCommandsMenu.isDestroyed) {
this.aiCommandsMenu.destroy();
this.aiCommandsDropDownButton.destroy();
this.aiCommandsMenu = null;
this.aiCommandsDropDownButton = null;
}
};
MenuButton.prototype.removeEventListener = function () {
this.parent.off(events.rtlMode, this.setRtl);
this.parent.off(events.bindCssClass, this.setCssClass);
};
MenuButton.prototype.destroy = function () {
Iif (this.isDestroyed) {
return;
}
this.removeEventListener();
this.destroyMenu();
this.isDestroyed = true;
};
return MenuButton;
}());
exports.MenuButton = MenuButton;
});
|