@syncfusion/ej2-ribbon 30.1.42 → 31.1.17
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.
- package/aceconfig.js +17 -0
- package/dist/ej2-ribbon.umd.min.js +1 -1
- package/dist/global/ej2-ribbon.min.js +1 -1
- package/dist/global/index.d.ts +1 -1
- package/dist/ts/index.d.ts +1 -0
- package/dist/ts/index.ts +3 -0
- package/dist/ts/ribbon/base/constant.d.ts +201 -0
- package/dist/ts/ribbon/base/constant.ts +204 -0
- package/dist/ts/ribbon/base/index.d.ts +8 -0
- package/dist/ts/ribbon/base/index.ts +8 -0
- package/dist/ts/ribbon/base/interface.d.ts +398 -0
- package/dist/ts/ribbon/base/interface.ts +424 -0
- package/dist/ts/ribbon/base/ribbon-model.d.ts +195 -0
- package/dist/ts/ribbon/base/ribbon.d.ts +608 -0
- package/dist/ts/ribbon/base/ribbon.ts +4896 -0
- package/dist/ts/ribbon/base/utils.d.ts +139 -0
- package/dist/ts/ribbon/base/utils.ts +341 -0
- package/dist/ts/ribbon/index.d.ts +7 -0
- package/dist/ts/ribbon/index.ts +7 -0
- package/dist/ts/ribbon/items/index.d.ts +8 -0
- package/dist/ts/ribbon/items/index.ts +8 -0
- package/dist/ts/ribbon/items/ribbon-button.d.ts +64 -0
- package/dist/ts/ribbon/items/ribbon-button.ts +160 -0
- package/dist/ts/ribbon/items/ribbon-checkbox.d.ts +55 -0
- package/dist/ts/ribbon/items/ribbon-checkbox.ts +130 -0
- package/dist/ts/ribbon/items/ribbon-colorpicker.d.ts +72 -0
- package/dist/ts/ribbon/items/ribbon-colorpicker.ts +228 -0
- package/dist/ts/ribbon/items/ribbon-combobox.d.ts +77 -0
- package/dist/ts/ribbon/items/ribbon-combobox.ts +201 -0
- package/dist/ts/ribbon/items/ribbon-dropdown.d.ts +128 -0
- package/dist/ts/ribbon/items/ribbon-dropdown.ts +400 -0
- package/dist/ts/ribbon/items/ribbon-gallery.d.ts +97 -0
- package/dist/ts/ribbon/items/ribbon-gallery.ts +773 -0
- package/dist/ts/ribbon/items/ribbon-groupbutton.d.ts +73 -0
- package/dist/ts/ribbon/items/ribbon-groupbutton.ts +531 -0
- package/dist/ts/ribbon/items/ribbon-splitbutton.d.ts +85 -0
- package/dist/ts/ribbon/items/ribbon-splitbutton.ts +257 -0
- package/dist/ts/ribbon/models/index.d.ts +42 -0
- package/dist/ts/ribbon/models/index.ts +44 -0
- package/dist/ts/ribbon/models/ribbon-back-button-model.d.ts +29 -0
- package/dist/ts/ribbon/models/ribbon-back-button.d.ts +24 -0
- package/dist/ts/ribbon/models/ribbon-back-button.ts +31 -0
- package/dist/ts/ribbon/models/ribbon-back-stage-settings-model.d.ts +83 -0
- package/dist/ts/ribbon/models/ribbon-back-stage-settings.d.ts +81 -0
- package/dist/ts/ribbon/models/ribbon-back-stage-settings.ts +109 -0
- package/dist/ts/ribbon/models/ribbon-backstage-item-model.d.ts +69 -0
- package/dist/ts/ribbon/models/ribbon-backstage-item.d.ts +80 -0
- package/dist/ts/ribbon/models/ribbon-backstage-item.ts +102 -0
- package/dist/ts/ribbon/models/ribbon-button-settings-model.d.ts +64 -0
- package/dist/ts/ribbon/models/ribbon-button-settings.d.ts +63 -0
- package/dist/ts/ribbon/models/ribbon-button-settings.ts +80 -0
- package/dist/ts/ribbon/models/ribbon-checkbox-settings-model.d.ts +57 -0
- package/dist/ts/ribbon/models/ribbon-checkbox-settings.d.ts +58 -0
- package/dist/ts/ribbon/models/ribbon-checkbox-settings.ts +74 -0
- package/dist/ts/ribbon/models/ribbon-collection-model.d.ts +30 -0
- package/dist/ts/ribbon/models/ribbon-collection.d.ts +33 -0
- package/dist/ts/ribbon/models/ribbon-collection.ts +45 -0
- package/dist/ts/ribbon/models/ribbon-colorpicker-settings-model.d.ts +137 -0
- package/dist/ts/ribbon/models/ribbon-colorpicker-settings.d.ts +129 -0
- package/dist/ts/ribbon/models/ribbon-colorpicker-settings.ts +165 -0
- package/dist/ts/ribbon/models/ribbon-combobox-settings-model.d.ts +275 -0
- package/dist/ts/ribbon/models/ribbon-combobox-settings.d.ts +257 -0
- package/dist/ts/ribbon/models/ribbon-combobox-settings.ts +313 -0
- package/dist/ts/ribbon/models/ribbon-contextual-tab-settings-model.d.ts +30 -0
- package/dist/ts/ribbon/models/ribbon-contextual-tab-settings.d.ts +33 -0
- package/dist/ts/ribbon/models/ribbon-contextual-tab-settings.ts +44 -0
- package/dist/ts/ribbon/models/ribbon-dropdown-settings-model.d.ts +114 -0
- package/dist/ts/ribbon/models/ribbon-dropdown-settings.d.ts +107 -0
- package/dist/ts/ribbon/models/ribbon-dropdown-settings.ts +139 -0
- package/dist/ts/ribbon/models/ribbon-file-menu-settings-model.d.ts +123 -0
- package/dist/ts/ribbon/models/ribbon-file-menu-settings.d.ts +173 -0
- package/dist/ts/ribbon/models/ribbon-file-menu-settings.ts +220 -0
- package/dist/ts/ribbon/models/ribbon-gallery-group-model.d.ts +44 -0
- package/dist/ts/ribbon/models/ribbon-gallery-group.d.ts +38 -0
- package/dist/ts/ribbon/models/ribbon-gallery-group.ts +50 -0
- package/dist/ts/ribbon/models/ribbon-gallery-item-model.d.ts +43 -0
- package/dist/ts/ribbon/models/ribbon-gallery-item.d.ts +38 -0
- package/dist/ts/ribbon/models/ribbon-gallery-item.ts +47 -0
- package/dist/ts/ribbon/models/ribbon-gallery-settings-model.d.ts +108 -0
- package/dist/ts/ribbon/models/ribbon-gallery-settings.d.ts +95 -0
- package/dist/ts/ribbon/models/ribbon-gallery-settings.ts +123 -0
- package/dist/ts/ribbon/models/ribbon-group-button-item-model.d.ts +64 -0
- package/dist/ts/ribbon/models/ribbon-group-button-item.d.ts +65 -0
- package/dist/ts/ribbon/models/ribbon-group-button-item.ts +85 -0
- package/dist/ts/ribbon/models/ribbon-group-button-settings-model.d.ts +32 -0
- package/dist/ts/ribbon/models/ribbon-group-button-settings.d.ts +29 -0
- package/dist/ts/ribbon/models/ribbon-group-button-settings.ts +38 -0
- package/dist/ts/ribbon/models/ribbon-group-model.d.ts +112 -0
- package/dist/ts/ribbon/models/ribbon-group.d.ts +105 -0
- package/dist/ts/ribbon/models/ribbon-group.ts +138 -0
- package/dist/ts/ribbon/models/ribbon-item-model.d.ts +144 -0
- package/dist/ts/ribbon/models/ribbon-item.d.ts +141 -0
- package/dist/ts/ribbon/models/ribbon-item.ts +190 -0
- package/dist/ts/ribbon/models/ribbon-splitbutton-settings-model.d.ts +114 -0
- package/dist/ts/ribbon/models/ribbon-splitbutton-settings.d.ts +107 -0
- package/dist/ts/ribbon/models/ribbon-splitbutton-settings.ts +140 -0
- package/dist/ts/ribbon/models/ribbon-tab-model.d.ts +44 -0
- package/dist/ts/ribbon/models/ribbon-tab.d.ts +45 -0
- package/dist/ts/ribbon/models/ribbon-tab.ts +61 -0
- package/dist/ts/ribbon/models/ribbon-tooltip-model.d.ts +43 -0
- package/dist/ts/ribbon/models/ribbon-tooltip.d.ts +36 -0
- package/dist/ts/ribbon/models/ribbon-tooltip.ts +47 -0
- package/dist/ts/ribbon/modules/index.d.ts +4 -0
- package/dist/ts/ribbon/modules/index.ts +5 -0
- package/dist/ts/ribbon/modules/ribbon-backstage.d.ts +117 -0
- package/dist/ts/ribbon/modules/ribbon-backstage.ts +620 -0
- package/dist/ts/ribbon/modules/ribbon-contextualtab.d.ts +27 -0
- package/dist/ts/ribbon/modules/ribbon-contextualtab.ts +93 -0
- package/dist/ts/ribbon/modules/ribbon-filemenu.d.ts +96 -0
- package/dist/ts/ribbon/modules/ribbon-filemenu.ts +353 -0
- package/dist/ts/ribbon/modules/ribbon-keytip.d.ts +56 -0
- package/dist/ts/ribbon/modules/ribbon-keytip.ts +580 -0
- package/package.json +55 -19
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { KeyboardEventArgs, closest, getComponent, isNullOrUndefined, merge, remove } from '@syncfusion/ej2-base';
|
|
2
|
+
import { BeforeOpenCloseMenuEventArgs, DropDownButton, ItemModel, OpenCloseMenuEventArgs } from '@syncfusion/ej2-splitbuttons';
|
|
3
|
+
import { Tooltip } from '@syncfusion/ej2-popups';
|
|
4
|
+
import { getItem, Ribbon, itemProps, getItemElement, RibbonItemSize, createTooltip, setCustomAttributes } from '../base/index';
|
|
5
|
+
import { RibbonDropDownSettingsModel, RibbonItemModel } from '../models/index';
|
|
6
|
+
import { DROPDOWN_ID, ITEM_VERTICAL_CENTER, OVERFLOW_ID, RIBBON_CONTROL, RIBBON_GROUP_OVERFLOW_DDB, RIBBON_POPUP_CONTROL, SPACE, VERTICAL_DDB } from '../base/constant';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Defines the items of Ribbon.
|
|
11
|
+
*/
|
|
12
|
+
export class RibbonDropDown {
|
|
13
|
+
private parent: Ribbon;
|
|
14
|
+
|
|
15
|
+
constructor(parent: Ribbon) {
|
|
16
|
+
this.parent = parent;
|
|
17
|
+
}
|
|
18
|
+
protected getModuleName(): string {
|
|
19
|
+
return 'ribbonDropDown';
|
|
20
|
+
}
|
|
21
|
+
protected destroy(): void {
|
|
22
|
+
this.parent = null;
|
|
23
|
+
}
|
|
24
|
+
private itemIndex: number;
|
|
25
|
+
private enableRtl: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Creates DropDown.
|
|
28
|
+
*
|
|
29
|
+
* @param {RibbonItemModel} item - Gets the ribbon item model.
|
|
30
|
+
* @param {HTMLElement} itemEle - Gets the ribbon item element.
|
|
31
|
+
* @returns {void}
|
|
32
|
+
* @hidden
|
|
33
|
+
*/
|
|
34
|
+
public createDropDown(item: RibbonItemModel, itemEle: HTMLElement): void {
|
|
35
|
+
const buttonEle: HTMLButtonElement = this.parent.createElement('button', {
|
|
36
|
+
id: item.id
|
|
37
|
+
});
|
|
38
|
+
itemEle.appendChild(buttonEle);
|
|
39
|
+
const dropDownSettings: RibbonDropDownSettingsModel = item.dropDownSettings;
|
|
40
|
+
const cssClass: string = (ITEM_VERTICAL_CENTER + SPACE + RIBBON_CONTROL + SPACE + (dropDownSettings.cssClass ?
|
|
41
|
+
dropDownSettings.cssClass : '')).trim();
|
|
42
|
+
new DropDownButton({
|
|
43
|
+
locale: this.parent.locale,
|
|
44
|
+
enableRtl: this.parent.enableRtl,
|
|
45
|
+
enablePersistence: this.parent.enablePersistence,
|
|
46
|
+
iconPosition: item.activeSize === RibbonItemSize.Large ? 'Top' : 'Left',
|
|
47
|
+
closeActionEvents: dropDownSettings.closeActionEvents,
|
|
48
|
+
content: item.activeSize === RibbonItemSize.Small ? '' : dropDownSettings.content,
|
|
49
|
+
cssClass: cssClass + ((item.activeSize === RibbonItemSize.Large) ? (SPACE + VERTICAL_DDB) : ''),
|
|
50
|
+
disabled: item.disabled,
|
|
51
|
+
iconCss: dropDownSettings.iconCss,
|
|
52
|
+
items: dropDownSettings.items,
|
|
53
|
+
target: dropDownSettings.target,
|
|
54
|
+
createPopupOnClick: dropDownSettings.createPopupOnClick,
|
|
55
|
+
beforeClose: (e: BeforeOpenCloseMenuEventArgs) => {
|
|
56
|
+
if (dropDownSettings.beforeClose) { dropDownSettings.beforeClose.call(this, e); }
|
|
57
|
+
},
|
|
58
|
+
beforeItemRender: dropDownSettings.beforeItemRender,
|
|
59
|
+
beforeOpen: dropDownSettings.beforeOpen,
|
|
60
|
+
close: (e: OpenCloseMenuEventArgs) => {
|
|
61
|
+
if (dropDownSettings.close) { dropDownSettings.close.call(this, e); }
|
|
62
|
+
},
|
|
63
|
+
created: dropDownSettings.created,
|
|
64
|
+
open: dropDownSettings.open,
|
|
65
|
+
select: dropDownSettings.select
|
|
66
|
+
}).appendTo(buttonEle);
|
|
67
|
+
if (dropDownSettings.htmlAttributes) {
|
|
68
|
+
if (dropDownSettings.htmlAttributes.id) {
|
|
69
|
+
delete dropDownSettings.htmlAttributes.id;
|
|
70
|
+
}
|
|
71
|
+
setCustomAttributes(buttonEle, dropDownSettings.htmlAttributes);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Adds the additional event handlers as the item moved into overflow popup.
|
|
76
|
+
*
|
|
77
|
+
* @param {RibbonItemModel} item - Gets the ribbon item model.
|
|
78
|
+
* @param {HTMLElement} itemEle - Gets the ribbon item element.
|
|
79
|
+
* @param {DropDownButton} overflowButton - Gets the overflow button.
|
|
80
|
+
* @returns {void}
|
|
81
|
+
* @hidden
|
|
82
|
+
*/
|
|
83
|
+
public addOverFlowEvents(item: RibbonItemModel, itemEle: HTMLElement, overflowButton: DropDownButton): void {
|
|
84
|
+
const dropdownElement: HTMLElement = itemEle.querySelector('#' + item.id);
|
|
85
|
+
dropdownElement.setAttribute('data-control', item.type.toString());
|
|
86
|
+
const dropdown: DropDownButton = getComponent(dropdownElement, DropDownButton);
|
|
87
|
+
dropdown.cssClass = dropdown.cssClass + SPACE + RIBBON_POPUP_CONTROL;
|
|
88
|
+
dropdown.dataBind();
|
|
89
|
+
let target: HTMLElement;
|
|
90
|
+
dropdown.beforeClose = (e: BeforeOpenCloseMenuEventArgs) => {
|
|
91
|
+
if (item.dropDownSettings.beforeClose) { item.dropDownSettings.beforeClose.call(this, e); }
|
|
92
|
+
target = e.event ? e.event.target as HTMLElement : null;
|
|
93
|
+
};
|
|
94
|
+
dropdown.close = (e: OpenCloseMenuEventArgs) => {
|
|
95
|
+
if (item.dropDownSettings.close) { item.dropDownSettings.close.call(this, e); }
|
|
96
|
+
if (target && !target.closest('.e-ribbon-group-overflow-ddb')) {
|
|
97
|
+
if (overflowButton.element.classList.contains('e-active')) {
|
|
98
|
+
overflowButton.toggle();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Removes the additional event handlers as the item moved from overflow popup.
|
|
105
|
+
*
|
|
106
|
+
* @param {RibbonItemModel} item - Gets the ribbon item model.
|
|
107
|
+
* @param {HTMLElement} itemEle - Gets the ribbon item element.
|
|
108
|
+
* @returns {void}
|
|
109
|
+
* @hidden
|
|
110
|
+
*/
|
|
111
|
+
public removeOverFlowEvents(item: RibbonItemModel, itemEle: HTMLElement): void {
|
|
112
|
+
const dropdownElement: HTMLElement = itemEle.querySelector('#' + item.id);
|
|
113
|
+
const dropdown: DropDownButton = getComponent(dropdownElement, DropDownButton);
|
|
114
|
+
let cssClass: string[] = dropdown.cssClass.split(SPACE);
|
|
115
|
+
cssClass = cssClass.filter((value: string) => value !== RIBBON_POPUP_CONTROL);
|
|
116
|
+
dropdown.cssClass = cssClass.join(SPACE);
|
|
117
|
+
dropdown.dataBind();
|
|
118
|
+
dropdown.close = (e: OpenCloseMenuEventArgs) => {
|
|
119
|
+
if (item.dropDownSettings.close) { item.dropDownSettings.close.call(this, e); }
|
|
120
|
+
};
|
|
121
|
+
dropdown.beforeClose = (e: BeforeOpenCloseMenuEventArgs) => {
|
|
122
|
+
if (item.dropDownSettings.beforeClose) { item.dropDownSettings.beforeClose.call(this, e); }
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Creates Overflow DropDown.
|
|
128
|
+
*
|
|
129
|
+
* @param {string} id - Gets the ID of the dropdown item.
|
|
130
|
+
* @param {string} name - Gets the name of the dropdown item.
|
|
131
|
+
* @param {string} iconCss - Gets the icon of the dropdown item.
|
|
132
|
+
* @param {HTMLElement} groupEle - Gets the overflow group element.
|
|
133
|
+
* @param {HTMLElement} overflowEle - Gets the overflow element.
|
|
134
|
+
* @returns {void}
|
|
135
|
+
* @hidden
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
public createOverFlowDropDown(id: string, name: string, iconCss: string,
|
|
139
|
+
groupEle: HTMLElement, overflowEle: HTMLElement, enableRtl?: boolean): DropDownButton {
|
|
140
|
+
this.enableRtl = enableRtl;
|
|
141
|
+
const buttonEle: HTMLButtonElement = this.parent.createElement('button', {
|
|
142
|
+
id: id + OVERFLOW_ID + DROPDOWN_ID
|
|
143
|
+
});
|
|
144
|
+
groupEle.setAttribute('tabindex', '0');
|
|
145
|
+
overflowEle.appendChild(buttonEle);
|
|
146
|
+
const dropdown: DropDownButton = new DropDownButton({
|
|
147
|
+
iconCss: iconCss,
|
|
148
|
+
target: groupEle,
|
|
149
|
+
locale: this.parent.locale,
|
|
150
|
+
enableRtl: this.parent.enableRtl,
|
|
151
|
+
enablePersistence: this.parent.enablePersistence,
|
|
152
|
+
cssClass: VERTICAL_DDB + SPACE + RIBBON_GROUP_OVERFLOW_DDB,
|
|
153
|
+
iconPosition: 'Top',
|
|
154
|
+
content: name,
|
|
155
|
+
beforeClose: (args: BeforeOpenCloseMenuEventArgs) => {
|
|
156
|
+
args.cancel = !isNullOrUndefined(args.event && closest(args.event.target as HTMLElement, '.' + RIBBON_POPUP_CONTROL));
|
|
157
|
+
}
|
|
158
|
+
}, buttonEle);
|
|
159
|
+
createTooltip(groupEle, this.parent);
|
|
160
|
+
buttonEle.onclick = buttonEle.onkeydown = () => { this.itemIndex = 0; };
|
|
161
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
162
|
+
groupEle.onkeydown = (e: KeyboardEventArgs) => { this.keyActionHandler(e, groupEle), this; };
|
|
163
|
+
return dropdown;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private keyActionHandler(e: KeyboardEventArgs, target: HTMLElement): void {
|
|
167
|
+
const controlElements: Array<Element> = Array.prototype.slice.call(target.querySelectorAll('.e-control'));
|
|
168
|
+
const templateElements: Array<Element> = Array.prototype.slice.call(target.querySelectorAll('.e-ribbon-template'));
|
|
169
|
+
const items: Element[] = controlElements.concat(templateElements);
|
|
170
|
+
const comboBoxElements: NodeListOf<Element> = target.querySelectorAll('.e-combobox');
|
|
171
|
+
let comboBoxEle: HTMLElement;
|
|
172
|
+
if (comboBoxElements) {
|
|
173
|
+
for (let i: number = 0; i < comboBoxElements.length; i++) {
|
|
174
|
+
if (comboBoxElements[parseInt(i.toString(), 10)].closest('.e-input-focus')) {
|
|
175
|
+
comboBoxEle = comboBoxElements[parseInt(i.toString(), 10)] as HTMLElement;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (comboBoxEle) {
|
|
180
|
+
for (let i: number = 0; i < items.length; i++) {
|
|
181
|
+
if (items[parseInt(i.toString(), 10)].classList.contains('e-combobox')) {
|
|
182
|
+
if (items[parseInt(i.toString(), 10)].closest('.e-input-focus')) {
|
|
183
|
+
this.itemIndex = i;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if ((e.target as HTMLElement).classList.contains('e-control') || (e.target as HTMLElement).classList.contains('e-ribbon-template') || (e.target as HTMLElement).classList.contains('e-ribbon-launcher-icon') ||
|
|
189
|
+
(e.target as HTMLElement).classList.contains('e-ribbon-last-item') || (e.target as HTMLElement).classList.contains('e-ribbon-first-item')) {
|
|
190
|
+
if (e.key === 'ArrowRight' || (!e.shiftKey && e.key === 'Tab')) {
|
|
191
|
+
this.handleNavigation(e, !this.enableRtl, items);
|
|
192
|
+
}
|
|
193
|
+
if (e.key === 'ArrowLeft' || (e.shiftKey && e.key === 'Tab')) {
|
|
194
|
+
this.handleNavigation(e, this.enableRtl, items);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
private handleNavigation(e: KeyboardEventArgs, enableRtl: boolean, items: Element[]): void {
|
|
200
|
+
if (!(items[0].classList.contains('e-ribbon-first-item'))) { items[0].classList.add('e-ribbon-first-item'); }
|
|
201
|
+
if (!(items[items.length - 1].classList.contains('e-ribbon-last-item'))) { items[items.length - 1].classList.add('e-ribbon-last-item'); }
|
|
202
|
+
if (enableRtl) {
|
|
203
|
+
if (this.itemIndex === 0 && (items[parseInt(this.itemIndex.toString(), 10)] as HTMLElement).classList.contains('e-ribbon-first-item')) { this.updateItemIndex(e, items, true); }
|
|
204
|
+
if (!(e.target as HTMLElement).classList.contains('e-combobox') && !(e.target as HTMLElement).classList.contains('e-ribbon-last-item') &&
|
|
205
|
+
!(e.target as HTMLElement).classList.contains('e-ribbon-group-container') && ((e.target as HTMLElement).classList.contains('e-ribbon-first-item')
|
|
206
|
+
|| this.itemIndex !== 0) && ((e.target as HTMLElement).classList.contains('e-control') || (e.target as HTMLElement).classList.contains('e-ribbon-template'))) {
|
|
207
|
+
this.itemIndex++;
|
|
208
|
+
this.updateItemIndex(e, items, true);
|
|
209
|
+
}
|
|
210
|
+
if ((e.target as HTMLElement).classList.contains('e-ribbon-last-item')) {
|
|
211
|
+
let launcherIcon: boolean = false;
|
|
212
|
+
launcherIcon = this.focusLauncherIcon(e, items);
|
|
213
|
+
if (!launcherIcon) { this.itemIndex = 0; this.updateItemIndex(e, items, true); }
|
|
214
|
+
}
|
|
215
|
+
if ((e.target as HTMLElement).classList.contains('e-ribbon-launcher-icon')) { this.itemIndex = 0; this.updateItemIndex(e, items, true); }
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
if (!(e.target as HTMLElement).classList.contains('e-combobox') && this.itemIndex !== 0) { this.itemIndex--; this.updateItemIndex(e, items, false); }
|
|
219
|
+
if ((e.target as HTMLElement).classList.contains('e-ribbon-first-item')) {
|
|
220
|
+
let launcherIcon: boolean = false;
|
|
221
|
+
launcherIcon = this.focusLauncherIcon(e, items);
|
|
222
|
+
if (!launcherIcon) { this.itemIndex = items.length - 1; this.updateItemIndex(e, items, false); }
|
|
223
|
+
}
|
|
224
|
+
if ((e.target as HTMLElement).classList.contains('e-ribbon-launcher-icon')) { this.itemIndex = items.length - 1; this.updateItemIndex(e, items, false); }
|
|
225
|
+
}
|
|
226
|
+
if ((e.target as HTMLElement).classList.contains('e-combobox') && (e.key === 'Tab')) {
|
|
227
|
+
if (enableRtl) { if (this.itemIndex < items.length - 1) { this.itemIndex++; } }
|
|
228
|
+
else { if (this.itemIndex > 0) { this.itemIndex--; } }
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
private focusLauncherIcon(e: KeyboardEventArgs, items: Element[]): boolean {
|
|
233
|
+
const groupContainer: HTMLElement = items[parseInt(this.itemIndex.toString(), 10)].closest('.e-ribbon-group-container') as HTMLElement;
|
|
234
|
+
let launcherIconEle: HTMLElement;
|
|
235
|
+
if (groupContainer) { launcherIconEle = groupContainer.querySelector('.e-ribbon-launcher-icon') as HTMLElement; }
|
|
236
|
+
if (launcherIconEle) {
|
|
237
|
+
if (e.key === 'Tab') { e.preventDefault(); }
|
|
238
|
+
(groupContainer.querySelector('.e-ribbon-launcher-icon')as HTMLElement).focus();
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
else { return false; }
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
private updateItemIndex(e: KeyboardEventArgs, items: Element[], enableRtl: boolean): void {
|
|
245
|
+
let ribbonItem: HTMLElement = items[this.itemIndex].closest('.e-ribbon-item') as HTMLElement;
|
|
246
|
+
while (ribbonItem && ribbonItem.classList.contains('e-disabled')) {
|
|
247
|
+
if (enableRtl) {
|
|
248
|
+
if (this.itemIndex < items.length - 1) { this.itemIndex++; }
|
|
249
|
+
else {
|
|
250
|
+
let launcherIcon: boolean = false;
|
|
251
|
+
launcherIcon = this.focusLauncherIcon(e, items);
|
|
252
|
+
if (launcherIcon) { break; }
|
|
253
|
+
this.itemIndex = 0;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
if (this.itemIndex > 0) { this.itemIndex--; }
|
|
258
|
+
else {
|
|
259
|
+
let launcherIcon: boolean = false;
|
|
260
|
+
launcherIcon = this.focusLauncherIcon(e, items);
|
|
261
|
+
if (launcherIcon) { break; }
|
|
262
|
+
this.itemIndex = items.length - 1;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
ribbonItem = items[this.itemIndex].closest('.e-ribbon-item') as HTMLElement;
|
|
266
|
+
}
|
|
267
|
+
if (e.key === 'Tab') { e.preventDefault(); }
|
|
268
|
+
(items[parseInt(this.itemIndex.toString(), 10)] as HTMLElement).focus();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Removes Overflow DropDown.
|
|
273
|
+
*
|
|
274
|
+
* @param {HTMLElement} dropdownElement - Gets the ribbon DropDown element.
|
|
275
|
+
* @returns {void}
|
|
276
|
+
* @hidden
|
|
277
|
+
*/
|
|
278
|
+
public removeOverFlowDropDown(dropdownElement: HTMLElement): void {
|
|
279
|
+
const dropdown: DropDownButton = getComponent(dropdownElement, DropDownButton);
|
|
280
|
+
const tooltip: Tooltip = getComponent(dropdown.target as HTMLElement, Tooltip);
|
|
281
|
+
tooltip.destroy();
|
|
282
|
+
dropdownElement.parentElement.parentElement.insertBefore(dropdown.target as HTMLElement, dropdownElement.parentElement);
|
|
283
|
+
dropdown.destroy();
|
|
284
|
+
remove(dropdownElement);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Gets DropDown item element.
|
|
289
|
+
*
|
|
290
|
+
* @param {HTMLElement} dropdownElement - Gets the ribbon DropDown element.
|
|
291
|
+
* @param {string} id - Gets the ID of ribbon DropDown element.
|
|
292
|
+
* @returns {HTMLElement} - Returns the DropDown item element.
|
|
293
|
+
* @hidden
|
|
294
|
+
*/
|
|
295
|
+
public getDDBItemElement(dropdownElement: HTMLElement, id: string): HTMLElement {
|
|
296
|
+
const dropdown: DropDownButton = getComponent(dropdownElement, DropDownButton);
|
|
297
|
+
const dropDownPopup: HTMLElement = dropdown.dropDown.element;
|
|
298
|
+
return dropDownPopup.querySelector('#' + id);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Gets Overflow DropDown Popup.
|
|
303
|
+
*
|
|
304
|
+
* @param {itemProps} itemProp - Gets the property of ribbon item.
|
|
305
|
+
* @param {HTMLElement} contentEle - Gets the content element.
|
|
306
|
+
* @returns {HTMLElement} - Returns the Overflow DropDown Popup.
|
|
307
|
+
* @hidden
|
|
308
|
+
*/
|
|
309
|
+
public getOverflowDropDownPopup(itemProp: itemProps, contentEle: HTMLElement): HTMLElement {
|
|
310
|
+
const dropdownElement: HTMLElement = contentEle.querySelector('#' + this.parent.tabs[itemProp.tabIndex].groups[itemProp.groupIndex].id + OVERFLOW_ID + DROPDOWN_ID);
|
|
311
|
+
const dropdown: DropDownButton = getComponent(dropdownElement, DropDownButton);
|
|
312
|
+
return dropdown.dropDown.element;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
private getDropDownObj(controlId: string): DropDownButton {
|
|
316
|
+
const dropDownEle: HTMLElement = getItemElement(this.parent, controlId);
|
|
317
|
+
return dropDownEle ? getComponent(dropDownEle, DropDownButton) : null;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Adds a new item to the menu. By default, new item appends to
|
|
321
|
+
* the list as the last item, but you can insert based on the text parameter.
|
|
322
|
+
*
|
|
323
|
+
* @param {string} controlId - Gets the control ID.
|
|
324
|
+
* @param {ItemModel[]} Items - Gets the DropDown items.
|
|
325
|
+
* @param {string} text - Gets the text of the dropdown item where the new item needs to be inserted.
|
|
326
|
+
* @returns {void}
|
|
327
|
+
*/
|
|
328
|
+
public addItems(controlId: string, Items: ItemModel[], text?: string): void {
|
|
329
|
+
this.getDropDownObj(controlId).addItems(Items, text);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Removes the items from the menu.
|
|
333
|
+
*
|
|
334
|
+
* @param {string} controlId - Gets the control ID.
|
|
335
|
+
* @param {string[]} Items -
|
|
336
|
+
* @param {string} isUniqueId -
|
|
337
|
+
* @returns {void}
|
|
338
|
+
*/
|
|
339
|
+
public removeItems(controlId: string, Items: string[], isUniqueId?: boolean): void {
|
|
340
|
+
this.getDropDownObj(controlId).removeItems(Items, isUniqueId);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* To open/close DropDownButton popup based on current state of the DropDownButton.
|
|
344
|
+
*
|
|
345
|
+
* @param {string} controlId - Gets the control ID.
|
|
346
|
+
* @returns {void}
|
|
347
|
+
*/
|
|
348
|
+
public toggle(controlId: string): void {
|
|
349
|
+
const dropdownObj: DropDownButton = this.getDropDownObj(controlId);
|
|
350
|
+
if (!dropdownObj) { return; }
|
|
351
|
+
if (!dropdownObj.disabled) {
|
|
352
|
+
dropdownObj.toggle();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Updates the dropdown.
|
|
357
|
+
*
|
|
358
|
+
* @param {RibbonDropDownSettingsModel} prop - Gets the dropdown property.
|
|
359
|
+
* @param {string} id - Gets the ID of dropdown.
|
|
360
|
+
* @returns {void}
|
|
361
|
+
*/
|
|
362
|
+
public updateDropDown(prop: RibbonDropDownSettingsModel, id: string): void {
|
|
363
|
+
const itemProp: itemProps = getItem(this.parent.tabs, id);
|
|
364
|
+
if (!itemProp) { return; }
|
|
365
|
+
merge(itemProp.item.dropDownSettings, prop);
|
|
366
|
+
const btnEle: HTMLElement = getItemElement(this.parent, id, itemProp);
|
|
367
|
+
if (!btnEle) { return; }
|
|
368
|
+
const control: DropDownButton = getComponent(btnEle, DropDownButton);
|
|
369
|
+
if (prop.cssClass) {
|
|
370
|
+
prop.cssClass = (RIBBON_CONTROL + SPACE + ITEM_VERTICAL_CENTER + SPACE + prop.cssClass).trim();
|
|
371
|
+
prop.cssClass = itemProp.item.activeSize === RibbonItemSize.Large ?
|
|
372
|
+
(VERTICAL_DDB + SPACE + prop.cssClass).trim() : prop.cssClass;
|
|
373
|
+
control.cssClass = prop.cssClass;
|
|
374
|
+
}
|
|
375
|
+
delete prop.close;
|
|
376
|
+
delete prop.beforeClose;
|
|
377
|
+
if (prop.content) { prop.content = itemProp.item.activeSize === RibbonItemSize.Small ? '' : prop.content; }
|
|
378
|
+
control.setProperties(prop);
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Updated DropDown size
|
|
382
|
+
*
|
|
383
|
+
* @param {HTMLElement} element - Gets the dropdown element.
|
|
384
|
+
* @param {RibbonItemModel} item - Gets the ribbon item model.
|
|
385
|
+
* @returns {void}
|
|
386
|
+
* @hidden
|
|
387
|
+
*/
|
|
388
|
+
public updateDropDownSize(element: HTMLElement, item: RibbonItemModel): void {
|
|
389
|
+
const control: DropDownButton = getComponent(element, DropDownButton);
|
|
390
|
+
let cssClass: string[] = control.cssClass.split(SPACE);
|
|
391
|
+
if (item.activeSize === RibbonItemSize.Large) {
|
|
392
|
+
cssClass.push(VERTICAL_DDB);
|
|
393
|
+
} else {
|
|
394
|
+
cssClass = cssClass.filter((value: string) => value !== VERTICAL_DDB);
|
|
395
|
+
}
|
|
396
|
+
control.cssClass = cssClass.join(SPACE);
|
|
397
|
+
control.setProperties({ iconPosition: item.activeSize === RibbonItemSize.Large ? 'Top' : 'Left' });
|
|
398
|
+
control.setProperties({ content: item.activeSize === RibbonItemSize.Small ? '' : item.dropDownSettings.content });
|
|
399
|
+
}
|
|
400
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Ribbon } from '../base/index';
|
|
2
|
+
import { RibbonItemModel } from '../models/index';
|
|
3
|
+
import { Popup } from '@syncfusion/ej2-popups';
|
|
4
|
+
/**
|
|
5
|
+
* Defines the items of Ribbon.
|
|
6
|
+
*/
|
|
7
|
+
export declare class RibbonGallery {
|
|
8
|
+
private parent;
|
|
9
|
+
private count;
|
|
10
|
+
private isAdded;
|
|
11
|
+
private galleryItemsIndex;
|
|
12
|
+
private registeredTemplate;
|
|
13
|
+
constructor(parent: Ribbon);
|
|
14
|
+
protected getModuleName(): string;
|
|
15
|
+
protected destroy(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Creates gallery.
|
|
18
|
+
*
|
|
19
|
+
* @param {RibbonItemModel} item - Gets the ribbon item model.
|
|
20
|
+
* @param {HTMLElement} itemEle - Gets the ribbon item element.
|
|
21
|
+
* @returns {void}
|
|
22
|
+
* @hidden
|
|
23
|
+
*/
|
|
24
|
+
createGallery(item: RibbonItemModel, itemEle: HTMLElement): void;
|
|
25
|
+
private renderGalleryItems;
|
|
26
|
+
private setWrapperWidth;
|
|
27
|
+
private setWrapperStyle;
|
|
28
|
+
/**
|
|
29
|
+
* Checks the gallery items height.
|
|
30
|
+
*
|
|
31
|
+
* @param {HTMLElement} activeContent - Gets the current active content.
|
|
32
|
+
* @returns {void}
|
|
33
|
+
* @hidden
|
|
34
|
+
*/
|
|
35
|
+
checkAvailableHeight(activeContent: HTMLElement): void;
|
|
36
|
+
/**
|
|
37
|
+
* Checks the popup collision.
|
|
38
|
+
*
|
|
39
|
+
* @param {Popup} popup - Gets the popup.
|
|
40
|
+
* @param {HTMLElement} popupEle - Gets the popup element.
|
|
41
|
+
* @param {number} offsetValue - Gets the offset value of gallery popup button.
|
|
42
|
+
* @returns {void}
|
|
43
|
+
* @hidden
|
|
44
|
+
*/
|
|
45
|
+
checkCollision(popup: Popup, popupEle: HTMLElement, offsetValue?: number): void;
|
|
46
|
+
private setGalleryPopupHeight;
|
|
47
|
+
private createPopup;
|
|
48
|
+
/**
|
|
49
|
+
* Updates gallery in mode switching.
|
|
50
|
+
*
|
|
51
|
+
* @param {string} activeLayout - Gets the current active layout.
|
|
52
|
+
* @param {string} itemID - Gets the ribbon item id.
|
|
53
|
+
* @returns {void}
|
|
54
|
+
* @hidden
|
|
55
|
+
*/
|
|
56
|
+
switchGalleryItems(activeLayout: string, itemID: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* Adds the additional event handlers as the item moved into overflow popup.
|
|
59
|
+
*
|
|
60
|
+
* @param {RibbonItemModel} item - Gets the ribbon item model.
|
|
61
|
+
* @param {HTMLElement} itemEle - Gets the ribbon item element.
|
|
62
|
+
* @returns {void}
|
|
63
|
+
* @hidden
|
|
64
|
+
*/
|
|
65
|
+
addOverFlowEvents(item: RibbonItemModel, itemEle: HTMLElement): void;
|
|
66
|
+
/**
|
|
67
|
+
* Removes the additional event handlers as the item moved into overflow popup.
|
|
68
|
+
*
|
|
69
|
+
* @param {RibbonItemModel} item - Gets the ribbon item model.
|
|
70
|
+
* @param {HTMLElement} itemEle - Gets the ribbon item element.
|
|
71
|
+
* @returns {void}
|
|
72
|
+
* @hidden
|
|
73
|
+
*/
|
|
74
|
+
removeOverFlowEvents(item: RibbonItemModel, itemEle: HTMLElement): void;
|
|
75
|
+
private setActiveState;
|
|
76
|
+
private popupEvents;
|
|
77
|
+
private showPopup;
|
|
78
|
+
private hidePopup;
|
|
79
|
+
/**
|
|
80
|
+
* Shows a specific gallery popup in the ribbon.
|
|
81
|
+
*
|
|
82
|
+
* @param {string} id - Gets the ribbon item id.
|
|
83
|
+
* @returns {void}
|
|
84
|
+
*/
|
|
85
|
+
showGalleryPopup(id: string): void;
|
|
86
|
+
/**
|
|
87
|
+
* Hides a specific gallery popup in the ribbon.
|
|
88
|
+
*
|
|
89
|
+
* @param {string} id - Gets the ribbon item id.
|
|
90
|
+
* @returns {void}
|
|
91
|
+
*/
|
|
92
|
+
hideGalleryPopup(id: string): void;
|
|
93
|
+
private setFoucsToFirstItem;
|
|
94
|
+
private handleGalleryPopupNavigation;
|
|
95
|
+
private createGalleryTemplate;
|
|
96
|
+
private createGalleryPopupTemplate;
|
|
97
|
+
}
|