@syncfusion/ej2-ribbon 31.1.17 → 31.2.2

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 (186) hide show
  1. package/dist/ej2-ribbon.umd.min.js +3 -3
  2. package/dist/ej2-ribbon.umd.min.js.map +1 -1
  3. package/dist/es6/ej2-ribbon.es2015.js +24 -5
  4. package/dist/es6/ej2-ribbon.es2015.js.map +1 -1
  5. package/dist/es6/ej2-ribbon.es5.js +24 -5
  6. package/dist/es6/ej2-ribbon.es5.js.map +1 -1
  7. package/dist/global/ej2-ribbon.min.js +3 -3
  8. package/dist/global/ej2-ribbon.min.js.map +1 -1
  9. package/dist/global/index.d.ts +2 -2
  10. package/package.json +19 -55
  11. package/src/ribbon/base/ribbon-model.d.ts +1 -1
  12. package/src/ribbon/base/ribbon.js +14 -5
  13. package/src/ribbon/items/ribbon-splitbutton.js +11 -0
  14. package/styles/bds-lite.css +9 -0
  15. package/styles/bds.css +9 -0
  16. package/styles/bootstrap-dark-lite.css +9 -0
  17. package/styles/bootstrap-dark.css +9 -0
  18. package/styles/bootstrap-lite.css +9 -0
  19. package/styles/bootstrap.css +9 -0
  20. package/styles/bootstrap4-lite.css +17 -0
  21. package/styles/bootstrap4.css +17 -0
  22. package/styles/bootstrap5-dark-lite.css +9 -0
  23. package/styles/bootstrap5-dark.css +9 -0
  24. package/styles/bootstrap5-lite.css +9 -0
  25. package/styles/bootstrap5.3-lite.css +9 -0
  26. package/styles/bootstrap5.3.css +9 -0
  27. package/styles/bootstrap5.css +9 -0
  28. package/styles/fabric-dark-lite.css +9 -0
  29. package/styles/fabric-dark.css +9 -0
  30. package/styles/fabric-lite.css +9 -0
  31. package/styles/fabric.css +9 -0
  32. package/styles/fluent-dark-lite.css +9 -0
  33. package/styles/fluent-dark.css +9 -0
  34. package/styles/fluent-lite.css +9 -0
  35. package/styles/fluent.css +9 -0
  36. package/styles/fluent2-lite.css +11 -2
  37. package/styles/fluent2.css +11 -2
  38. package/styles/highcontrast-light-lite.css +9 -0
  39. package/styles/highcontrast-light.css +9 -0
  40. package/styles/highcontrast-lite.css +9 -0
  41. package/styles/highcontrast.css +9 -0
  42. package/styles/material-dark-lite.css +9 -0
  43. package/styles/material-dark.css +9 -0
  44. package/styles/material-lite.css +9 -0
  45. package/styles/material.css +9 -0
  46. package/styles/material3-dark-lite.css +9 -0
  47. package/styles/material3-dark.css +9 -0
  48. package/styles/material3-lite.css +9 -0
  49. package/styles/material3.css +9 -0
  50. package/styles/ribbon/_fluent2-definition.scss +2 -2
  51. package/styles/ribbon/_layout.scss +7 -0
  52. package/styles/ribbon/bds.css +9 -0
  53. package/styles/ribbon/bootstrap-dark.css +9 -0
  54. package/styles/ribbon/bootstrap.css +9 -0
  55. package/styles/ribbon/bootstrap4.css +17 -0
  56. package/styles/ribbon/bootstrap5-dark.css +9 -0
  57. package/styles/ribbon/bootstrap5.3.css +9 -0
  58. package/styles/ribbon/bootstrap5.css +9 -0
  59. package/styles/ribbon/fabric-dark.css +9 -0
  60. package/styles/ribbon/fabric.css +9 -0
  61. package/styles/ribbon/fluent-dark.css +9 -0
  62. package/styles/ribbon/fluent.css +9 -0
  63. package/styles/ribbon/fluent2.css +11 -2
  64. package/styles/ribbon/highcontrast-light.css +9 -0
  65. package/styles/ribbon/highcontrast.css +9 -0
  66. package/styles/ribbon/material-dark.css +9 -0
  67. package/styles/ribbon/material.css +9 -0
  68. package/styles/ribbon/material3-dark.css +9 -0
  69. package/styles/ribbon/material3.css +9 -0
  70. package/styles/ribbon/tailwind-dark.css +9 -0
  71. package/styles/ribbon/tailwind.css +9 -0
  72. package/styles/ribbon/tailwind3.css +9 -0
  73. package/styles/tailwind-dark-lite.css +9 -0
  74. package/styles/tailwind-dark.css +9 -0
  75. package/styles/tailwind-lite.css +9 -0
  76. package/styles/tailwind.css +9 -0
  77. package/styles/tailwind3-lite.css +9 -0
  78. package/styles/tailwind3.css +9 -0
  79. package/dist/ts/index.d.ts +0 -1
  80. package/dist/ts/index.ts +0 -3
  81. package/dist/ts/ribbon/base/constant.d.ts +0 -201
  82. package/dist/ts/ribbon/base/constant.ts +0 -204
  83. package/dist/ts/ribbon/base/index.d.ts +0 -8
  84. package/dist/ts/ribbon/base/index.ts +0 -8
  85. package/dist/ts/ribbon/base/interface.d.ts +0 -398
  86. package/dist/ts/ribbon/base/interface.ts +0 -424
  87. package/dist/ts/ribbon/base/ribbon-model.d.ts +0 -195
  88. package/dist/ts/ribbon/base/ribbon.d.ts +0 -608
  89. package/dist/ts/ribbon/base/ribbon.ts +0 -4896
  90. package/dist/ts/ribbon/base/utils.d.ts +0 -139
  91. package/dist/ts/ribbon/base/utils.ts +0 -341
  92. package/dist/ts/ribbon/index.d.ts +0 -7
  93. package/dist/ts/ribbon/index.ts +0 -7
  94. package/dist/ts/ribbon/items/index.d.ts +0 -8
  95. package/dist/ts/ribbon/items/index.ts +0 -8
  96. package/dist/ts/ribbon/items/ribbon-button.d.ts +0 -64
  97. package/dist/ts/ribbon/items/ribbon-button.ts +0 -160
  98. package/dist/ts/ribbon/items/ribbon-checkbox.d.ts +0 -55
  99. package/dist/ts/ribbon/items/ribbon-checkbox.ts +0 -130
  100. package/dist/ts/ribbon/items/ribbon-colorpicker.d.ts +0 -72
  101. package/dist/ts/ribbon/items/ribbon-colorpicker.ts +0 -228
  102. package/dist/ts/ribbon/items/ribbon-combobox.d.ts +0 -77
  103. package/dist/ts/ribbon/items/ribbon-combobox.ts +0 -201
  104. package/dist/ts/ribbon/items/ribbon-dropdown.d.ts +0 -128
  105. package/dist/ts/ribbon/items/ribbon-dropdown.ts +0 -400
  106. package/dist/ts/ribbon/items/ribbon-gallery.d.ts +0 -97
  107. package/dist/ts/ribbon/items/ribbon-gallery.ts +0 -773
  108. package/dist/ts/ribbon/items/ribbon-groupbutton.d.ts +0 -73
  109. package/dist/ts/ribbon/items/ribbon-groupbutton.ts +0 -531
  110. package/dist/ts/ribbon/items/ribbon-splitbutton.d.ts +0 -85
  111. package/dist/ts/ribbon/items/ribbon-splitbutton.ts +0 -257
  112. package/dist/ts/ribbon/models/index.d.ts +0 -42
  113. package/dist/ts/ribbon/models/index.ts +0 -44
  114. package/dist/ts/ribbon/models/ribbon-back-button-model.d.ts +0 -29
  115. package/dist/ts/ribbon/models/ribbon-back-button.d.ts +0 -24
  116. package/dist/ts/ribbon/models/ribbon-back-button.ts +0 -31
  117. package/dist/ts/ribbon/models/ribbon-back-stage-settings-model.d.ts +0 -83
  118. package/dist/ts/ribbon/models/ribbon-back-stage-settings.d.ts +0 -81
  119. package/dist/ts/ribbon/models/ribbon-back-stage-settings.ts +0 -109
  120. package/dist/ts/ribbon/models/ribbon-backstage-item-model.d.ts +0 -69
  121. package/dist/ts/ribbon/models/ribbon-backstage-item.d.ts +0 -80
  122. package/dist/ts/ribbon/models/ribbon-backstage-item.ts +0 -102
  123. package/dist/ts/ribbon/models/ribbon-button-settings-model.d.ts +0 -64
  124. package/dist/ts/ribbon/models/ribbon-button-settings.d.ts +0 -63
  125. package/dist/ts/ribbon/models/ribbon-button-settings.ts +0 -80
  126. package/dist/ts/ribbon/models/ribbon-checkbox-settings-model.d.ts +0 -57
  127. package/dist/ts/ribbon/models/ribbon-checkbox-settings.d.ts +0 -58
  128. package/dist/ts/ribbon/models/ribbon-checkbox-settings.ts +0 -74
  129. package/dist/ts/ribbon/models/ribbon-collection-model.d.ts +0 -30
  130. package/dist/ts/ribbon/models/ribbon-collection.d.ts +0 -33
  131. package/dist/ts/ribbon/models/ribbon-collection.ts +0 -45
  132. package/dist/ts/ribbon/models/ribbon-colorpicker-settings-model.d.ts +0 -137
  133. package/dist/ts/ribbon/models/ribbon-colorpicker-settings.d.ts +0 -129
  134. package/dist/ts/ribbon/models/ribbon-colorpicker-settings.ts +0 -165
  135. package/dist/ts/ribbon/models/ribbon-combobox-settings-model.d.ts +0 -275
  136. package/dist/ts/ribbon/models/ribbon-combobox-settings.d.ts +0 -257
  137. package/dist/ts/ribbon/models/ribbon-combobox-settings.ts +0 -313
  138. package/dist/ts/ribbon/models/ribbon-contextual-tab-settings-model.d.ts +0 -30
  139. package/dist/ts/ribbon/models/ribbon-contextual-tab-settings.d.ts +0 -33
  140. package/dist/ts/ribbon/models/ribbon-contextual-tab-settings.ts +0 -44
  141. package/dist/ts/ribbon/models/ribbon-dropdown-settings-model.d.ts +0 -114
  142. package/dist/ts/ribbon/models/ribbon-dropdown-settings.d.ts +0 -107
  143. package/dist/ts/ribbon/models/ribbon-dropdown-settings.ts +0 -139
  144. package/dist/ts/ribbon/models/ribbon-file-menu-settings-model.d.ts +0 -123
  145. package/dist/ts/ribbon/models/ribbon-file-menu-settings.d.ts +0 -173
  146. package/dist/ts/ribbon/models/ribbon-file-menu-settings.ts +0 -220
  147. package/dist/ts/ribbon/models/ribbon-gallery-group-model.d.ts +0 -44
  148. package/dist/ts/ribbon/models/ribbon-gallery-group.d.ts +0 -38
  149. package/dist/ts/ribbon/models/ribbon-gallery-group.ts +0 -50
  150. package/dist/ts/ribbon/models/ribbon-gallery-item-model.d.ts +0 -43
  151. package/dist/ts/ribbon/models/ribbon-gallery-item.d.ts +0 -38
  152. package/dist/ts/ribbon/models/ribbon-gallery-item.ts +0 -47
  153. package/dist/ts/ribbon/models/ribbon-gallery-settings-model.d.ts +0 -108
  154. package/dist/ts/ribbon/models/ribbon-gallery-settings.d.ts +0 -95
  155. package/dist/ts/ribbon/models/ribbon-gallery-settings.ts +0 -123
  156. package/dist/ts/ribbon/models/ribbon-group-button-item-model.d.ts +0 -64
  157. package/dist/ts/ribbon/models/ribbon-group-button-item.d.ts +0 -65
  158. package/dist/ts/ribbon/models/ribbon-group-button-item.ts +0 -85
  159. package/dist/ts/ribbon/models/ribbon-group-button-settings-model.d.ts +0 -32
  160. package/dist/ts/ribbon/models/ribbon-group-button-settings.d.ts +0 -29
  161. package/dist/ts/ribbon/models/ribbon-group-button-settings.ts +0 -38
  162. package/dist/ts/ribbon/models/ribbon-group-model.d.ts +0 -112
  163. package/dist/ts/ribbon/models/ribbon-group.d.ts +0 -105
  164. package/dist/ts/ribbon/models/ribbon-group.ts +0 -138
  165. package/dist/ts/ribbon/models/ribbon-item-model.d.ts +0 -144
  166. package/dist/ts/ribbon/models/ribbon-item.d.ts +0 -141
  167. package/dist/ts/ribbon/models/ribbon-item.ts +0 -190
  168. package/dist/ts/ribbon/models/ribbon-splitbutton-settings-model.d.ts +0 -114
  169. package/dist/ts/ribbon/models/ribbon-splitbutton-settings.d.ts +0 -107
  170. package/dist/ts/ribbon/models/ribbon-splitbutton-settings.ts +0 -140
  171. package/dist/ts/ribbon/models/ribbon-tab-model.d.ts +0 -44
  172. package/dist/ts/ribbon/models/ribbon-tab.d.ts +0 -45
  173. package/dist/ts/ribbon/models/ribbon-tab.ts +0 -61
  174. package/dist/ts/ribbon/models/ribbon-tooltip-model.d.ts +0 -43
  175. package/dist/ts/ribbon/models/ribbon-tooltip.d.ts +0 -36
  176. package/dist/ts/ribbon/models/ribbon-tooltip.ts +0 -47
  177. package/dist/ts/ribbon/modules/index.d.ts +0 -4
  178. package/dist/ts/ribbon/modules/index.ts +0 -5
  179. package/dist/ts/ribbon/modules/ribbon-backstage.d.ts +0 -117
  180. package/dist/ts/ribbon/modules/ribbon-backstage.ts +0 -620
  181. package/dist/ts/ribbon/modules/ribbon-contextualtab.d.ts +0 -27
  182. package/dist/ts/ribbon/modules/ribbon-contextualtab.ts +0 -93
  183. package/dist/ts/ribbon/modules/ribbon-filemenu.d.ts +0 -96
  184. package/dist/ts/ribbon/modules/ribbon-filemenu.ts +0 -353
  185. package/dist/ts/ribbon/modules/ribbon-keytip.d.ts +0 -56
  186. package/dist/ts/ribbon/modules/ribbon-keytip.ts +0 -580
@@ -1,773 +0,0 @@
1
- import { KeyboardEventArgs, append, getComponent, remove, formatUnit, isNullOrUndefined, setValue } from '@syncfusion/ej2-base';
2
- import { GalleryHoverEventArgs, GalleryItemEventArgs, GalleryPopupEventArgs, GallerySelectEventArgs, GalleryBeforeSelectEventArgs, getItem, getTemplateFunction, itemProps, Ribbon, setCustomAttributes } from '../base/index';
3
- import { RibbonGalleryItemModel, RibbonGallerySettingsModel, RibbonItemModel } from '../models/index';
4
- import { BeforeOpenCloseMenuEventArgs, DropDownButton } from '@syncfusion/ej2-splitbuttons';
5
- import * as constants from '../base/constant';
6
- import { Popup } from '@syncfusion/ej2-popups';
7
-
8
- /**
9
- * Defines the items of Ribbon.
10
- */
11
- export class RibbonGallery {
12
- private parent: Ribbon;
13
- private count: number = 0;
14
- private isAdded: boolean = false;
15
- private galleryItemsIndex: number = 0;
16
- private registeredTemplate: Object = {};
17
-
18
- constructor(parent: Ribbon) {
19
- this.parent = parent;
20
- const ref: string = 'viewContainerRef';
21
- setValue('registeredTemplate', this.registeredTemplate, this);
22
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
- setValue(ref, (this.parent as any)[`${ref}`], this);
24
- }
25
- protected getModuleName(): string {
26
- return 'ribbonGallery';
27
- }
28
- protected destroy(): void {
29
- this.parent = null;
30
- }
31
-
32
- /**
33
- * Creates gallery.
34
- *
35
- * @param {RibbonItemModel} item - Gets the ribbon item model.
36
- * @param {HTMLElement} itemEle - Gets the ribbon item element.
37
- * @returns {void}
38
- * @hidden
39
- */
40
- public createGallery(item: RibbonItemModel, itemEle: HTMLElement): void {
41
- const gallerySettings: RibbonGallerySettingsModel = item.gallerySettings;
42
- this.renderGalleryItems(gallerySettings, false, item.id, itemEle);
43
- const buttonEle: HTMLButtonElement = this.parent.createElement('button', {
44
- id: item.id + '_popupButton',
45
- className: 'e-ribbon-gallery-button e-icons e-drop-icon'
46
- });
47
- buttonEle.setAttribute('aria-label', 'gallerydropdownbutton');
48
- itemEle.appendChild(buttonEle);
49
- this.createPopup(item, buttonEle);
50
- buttonEle.onclick = (args: Event) => {
51
- const popupEle: HTMLElement = document.querySelector('#' + item.id + '_galleryPopup');
52
- if (popupEle) {
53
- const popup: Popup = getComponent(popupEle, Popup);
54
- if (popupEle.classList.contains('e-popup-close')) { this.showPopup(popup, popupEle, args, gallerySettings, item.id); }
55
- else { this.hidePopup(popup, popupEle, args, gallerySettings, item.id); }
56
- }
57
- };
58
- document.onclick = (args: Event) => {
59
- const popupEle: NodeListOf<Element> = document.querySelectorAll('.e-ribbon-gallery-popup.e-popup-open');
60
- let popupID: string;
61
- let itemProp: itemProps;
62
- for (let i: number = 0; i < popupEle.length; i++) {
63
- const popup: Popup = getComponent(popupEle[parseInt(i.toString(), 10)] as HTMLElement, Popup);
64
- if ((args.target as HTMLElement).classList.contains('e-ribbon-gallery-button')) {
65
- popupID = ((popupEle[parseInt(i.toString(), 10)] as HTMLElement).id).replace(/_galleryPopup/g, '');
66
- if (((args.target as HTMLElement).id).replace(/_popupButton/g, '') !== popupID) {
67
- itemProp = getItem(this.parent.tabs, popupID);
68
- this.hidePopup(popup, popupEle[parseInt(i.toString(), 10)] as HTMLElement, args,
69
- itemProp.item.gallerySettings, popupID);
70
- break;
71
- }
72
- }
73
- else {
74
- popupID = ((popupEle[parseInt(i.toString(), 10)] as HTMLElement).id).replace(/_galleryPopup/g, '');
75
- itemProp = getItem(this.parent.tabs, popupID);
76
- this.hidePopup(popup, popupEle[parseInt(i.toString(), 10)] as HTMLElement, args,
77
- itemProp.item.gallerySettings, popupID);
78
- break;
79
- }
80
- }
81
- };
82
- }
83
-
84
- private renderGalleryItems(gallerySettings: RibbonGallerySettingsModel, isPopup: boolean, id: string, itemEle: HTMLElement): void {
85
- let galleryContainerEle: HTMLElement;
86
- let galleryEle: HTMLElement;
87
- const itemProp: itemProps = getItem(this.parent.tabs, id);
88
- if (itemProp && itemProp.group) {
89
- itemProp.group.isCollapsible = false;
90
- }
91
- const galleryWrapper: HTMLElement = this.parent.createElement('div', {
92
- className: 'e-ribbon-gallery-wrapper',
93
- id: id + '_galleryWrapper'
94
- });
95
- if (!isPopup) {
96
- itemEle.appendChild(galleryWrapper);
97
- }
98
- for (let i: number = 0; i < gallerySettings.groups.length; i++) {
99
- let isHeightDefined: boolean = false;
100
- galleryContainerEle = this.parent.createElement('ol', {
101
- className: 'e-ribbon-gallery-container',
102
- id: id + '_galleryContainer' + i
103
- });
104
- if (gallerySettings.groups[parseInt(i.toString(), 10)].itemHeight && gallerySettings.groups[parseInt(i.toString(), 10)].itemHeight !== 'auto') {
105
- isHeightDefined = true;
106
- }
107
- if (gallerySettings.groups[parseInt(i.toString(), 10)].cssClass) {
108
- galleryContainerEle.classList.add(gallerySettings.groups[parseInt(i.toString(), 10)].cssClass);
109
- }
110
- for (let j: number = 0; j < gallerySettings.groups[parseInt(i.toString(), 10)].items.length; j++) {
111
- galleryEle = this.parent.createElement('li', {
112
- className: 'e-ribbon-gallery-item',
113
- id: (isPopup ? 'popup_' : '') + galleryContainerEle.id + '_gallery' + j,
114
- attrs: { 'tabindex': '0' }
115
- });
116
- const itemEventArgs: GalleryItemEventArgs = { name: 'beforeItemRender', item: gallerySettings.groups[parseInt(i.toString(), 10)].items[parseInt(j.toString(), 10)] };
117
- if (gallerySettings.beforeItemRender) {
118
- gallerySettings.beforeItemRender.call(this, itemEventArgs);
119
- }
120
- galleryContainerEle.appendChild(galleryEle);
121
- if (gallerySettings.selectedItemIndex && gallerySettings.selectedItemIndex === this.count) {
122
- galleryEle.classList.add('e-ribbon-gallery-selected');
123
- }
124
- else {
125
- if (!gallerySettings.selectedItemIndex && this.count === 0) {
126
- galleryEle.classList.add('e-ribbon-gallery-selected');
127
- gallerySettings.selectedItemIndex = this.count;
128
- }
129
- }
130
- this.count = this.count + 1;
131
- galleryEle.onclick = (e: Event) => {
132
- this.setActiveState(e.currentTarget as HTMLElement, gallerySettings, id, true, e, isPopup);
133
- };
134
- galleryEle.onkeydown = (e: Event) => {
135
- if ((e as KeyboardEventArgs).key === 'Enter' || (e as KeyboardEventArgs).key === ' ') {
136
- this.setActiveState(e.currentTarget as HTMLElement, gallerySettings, id, true, e, isPopup);
137
- }
138
- };
139
- galleryEle.onmouseover = (e: Event) => {
140
- const hoverEventArgs: GalleryHoverEventArgs = { event: e, name: 'itemHover', item: gallerySettings.groups[parseInt(i.toString(), 10)].items[parseInt(j.toString(), 10)] };
141
- if (gallerySettings.itemHover) {
142
- gallerySettings.itemHover.call(this, hoverEventArgs);
143
- }
144
- };
145
- if (gallerySettings.groups[parseInt(i.toString(), 10)].itemWidth && gallerySettings.groups[parseInt(i.toString(), 10)].itemWidth !== 'auto') {
146
- galleryEle.style.width = gallerySettings.groups[parseInt(i.toString(), 10)].itemWidth + 'px';
147
- }
148
- if (gallerySettings.groups[parseInt(i.toString(), 10)].itemHeight && gallerySettings.groups[parseInt(i.toString(), 10)].itemHeight !== 'auto') {
149
- galleryEle.style.height = gallerySettings.groups[parseInt(i.toString(), 10)].itemHeight + 'px';
150
- if (this.parent.activeLayout !== 'Simplified' && !isPopup) {
151
- galleryContainerEle.style.flexFlow = 'wrap';
152
- }
153
- }
154
- if ((!gallerySettings.template && !gallerySettings.popupTemplate) ||
155
- ((gallerySettings.template && !gallerySettings.popupTemplate) && isPopup) ||
156
- ((gallerySettings.popupTemplate && !gallerySettings.template) && !isPopup)) {
157
- if (gallerySettings.groups[parseInt(i.toString(), 10)].items[parseInt(j.toString(), 10)].htmlAttributes) {
158
- setCustomAttributes(galleryEle, gallerySettings.groups[parseInt(i.toString(), 10)]
159
- .items[parseInt(j.toString(), 10)].htmlAttributes);
160
- }
161
- if (gallerySettings.groups[parseInt(i.toString(), 10)].items[parseInt(j.toString(), 10)].iconCss) {
162
- const iconEle: HTMLElement = this.parent.createElement('span', {
163
- className: 'e-ribbon-gallery-icons' + ' ' + gallerySettings.groups[parseInt(i.toString(), 10)].items[parseInt(j.toString(), 10)].iconCss
164
- });
165
- galleryEle.appendChild(iconEle);
166
- if (this.parent.activeLayout === 'Simplified' && !isPopup) {
167
- iconEle.classList.add('e-hidden');
168
- }
169
- }
170
- if (gallerySettings.groups[parseInt(i.toString(), 10)].items[parseInt(j.toString(), 10)].content) {
171
- galleryEle.appendChild(this.parent.createElement('span', {
172
- innerHTML: gallerySettings.groups[parseInt(i.toString(), 10)].items[parseInt(j.toString(), 10)].content,
173
- className: 'e-ribbon-gallery-text'
174
- }));
175
- }
176
- if (gallerySettings.groups[parseInt(i.toString(), 10)].items[parseInt(j.toString(), 10)].disabled) {
177
- galleryEle.classList.add('e-disabled');
178
- }
179
- if (gallerySettings.groups[parseInt(i.toString(), 10)].items[parseInt(j.toString(), 10)].cssClass) {
180
- galleryEle.classList.add(
181
- gallerySettings.groups[parseInt(i.toString(), 10)].items[parseInt(j.toString(), 10)].cssClass);
182
- }
183
- }
184
- if (gallerySettings.template && !isPopup) {
185
- this.createGalleryTemplate(galleryEle, gallerySettings, id,
186
- gallerySettings.groups[parseInt(i.toString(), 10)].items[parseInt(j.toString(), 10)]);
187
- }
188
- if (gallerySettings.popupTemplate && isPopup) {
189
- this.createGalleryPopupTemplate(galleryEle, gallerySettings, id,
190
- gallerySettings.groups[parseInt(i.toString(), 10)].items[parseInt(j.toString(), 10)]);
191
- }
192
- if ((!isPopup && !isHeightDefined && (gallerySettings.itemCount === this.count))) {
193
- galleryWrapper.appendChild(galleryContainerEle);
194
- this.isAdded = true;
195
- break;
196
- }
197
- }
198
- if (this.isAdded && !isPopup) {
199
- break;
200
- }
201
- if (!isPopup) { galleryWrapper.appendChild(galleryContainerEle); }
202
- else { itemEle.appendChild(galleryContainerEle); }
203
- if (isPopup && gallerySettings.groups[parseInt(i.toString(), 10)].header) {
204
- const headerEle: HTMLElement = (this.parent.createElement('div', {
205
- className: 'e-ribbon-gallery-header',
206
- innerHTML: gallerySettings.groups[parseInt(i.toString(), 10)].header
207
- }));
208
- itemEle.insertBefore(headerEle, galleryContainerEle);
209
- }
210
- }
211
- this.count = 0;
212
- this.isAdded = false;
213
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
214
- if ((this.parent as any).isReact) {
215
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
216
- (this.parent as any).portals = (this.parent as any).portals.concat((this as any)['portals']);
217
- this.parent['renderReactTemplates']();
218
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
219
- (this as any)['portals'] = undefined;
220
- }
221
- }
222
-
223
- private setWrapperWidth(itemCount: number, galleryWrapper: HTMLElement,
224
- gallerySettings: RibbonGallerySettingsModel, itemID: string): void {
225
- let count: number = 1;
226
- let itemsWidth: number = 0;
227
- let isWidthApplied: boolean = false;
228
- for (let i: number = 0; i < gallerySettings.groups.length; i++) {
229
- for (let j: number = 0; j < gallerySettings.groups[parseInt(i.toString(), 10)].items.length; j++) {
230
- if (itemCount >= count) {
231
- const galleryItemEle: HTMLElement = galleryWrapper.querySelector('#' + itemID + '_galleryContainer' + i + '_gallery' + j);
232
- if (galleryItemEle) {
233
- itemsWidth += galleryItemEle.offsetWidth;
234
- const itemStyles: CSSStyleDeclaration = window.getComputedStyle(galleryItemEle);
235
- if (itemStyles) {
236
- const paddingWidth: number = parseFloat(itemStyles.paddingLeft) + parseFloat(itemStyles.paddingRight);
237
- if (!(isNullOrUndefined(paddingWidth))) {
238
- itemsWidth += paddingWidth;
239
- }
240
- const marginWidth: number = parseFloat(itemStyles.marginLeft) + parseFloat(itemStyles.marginRight);
241
- if (!(isNullOrUndefined(marginWidth))) {
242
- itemsWidth += marginWidth;
243
- }
244
- }
245
- }
246
- }
247
- else {
248
- isWidthApplied = true;
249
- break;
250
- }
251
- count++;
252
- }
253
- if (isWidthApplied) {
254
- break;
255
- }
256
- }
257
- if (itemsWidth > 0) {
258
- galleryWrapper.style.width = itemsWidth + 'px'; }
259
- }
260
-
261
- private setWrapperStyle(popup: Popup, popupContainerItems: NodeListOf<Element>): void {
262
- if (popup.width !== 'auto') {
263
- popupContainerItems.forEach((ele: HTMLElement) => {
264
- ele.style.flexFlow = 'wrap';
265
- });
266
- }
267
- }
268
-
269
- /**
270
- * Checks the gallery items height.
271
- *
272
- * @param {HTMLElement} activeContent - Gets the current active content.
273
- * @returns {void}
274
- * @hidden
275
- */
276
- public checkAvailableHeight(activeContent: HTMLElement): void {
277
- const galleryWrapperItems: NodeListOf<Element> = activeContent.querySelectorAll('.e-ribbon-gallery-wrapper');
278
- for (let n: number = 0; n < galleryWrapperItems.length; n++) {
279
- let count: number = 0;
280
- let simplifiedItemsCount: number = 0;
281
- let isHeight: boolean = false;
282
- const galleryWrapper: HTMLElement = galleryWrapperItems[parseInt(n.toString(), 10)] as HTMLElement;
283
- const itemID: string = galleryWrapper.id.replace(/_galleryWrapper/g, '');
284
- let galleryWrapperHeight: number = galleryWrapper.offsetHeight;
285
- const itemProp: itemProps = getItem(this.parent.tabs, itemID);
286
- if (itemProp) {
287
- this.setWrapperWidth(itemProp.item.gallerySettings.itemCount, galleryWrapper, itemProp.item.gallerySettings, itemID);
288
- for (let i: number = 0; i < itemProp.item.gallerySettings.groups.length; i++) {
289
- for (let j: number = 0; j < itemProp.item.gallerySettings.groups[parseInt(i.toString(), 10)].items.length; j++) {
290
- const galleryItemEle: HTMLElement = galleryWrapper.querySelector('#' + itemID + '_galleryContainer' + i + '_gallery' + j);
291
- if (galleryItemEle) {
292
- if (this.parent.activeLayout === 'Classic') {
293
- if (galleryItemEle.classList.contains('e-hidden')) {
294
- galleryItemEle.classList.remove('e-hidden');
295
- }
296
- if (!isHeight) {
297
- let itemsValues: number = 0;
298
- const itemStyles: CSSStyleDeclaration = window.getComputedStyle(galleryItemEle);
299
- if (itemStyles) {
300
- const marginWidth: number = parseFloat(itemStyles.marginTop) + parseFloat(itemStyles.marginBottom);
301
- if (!(isNullOrUndefined(marginWidth))) {
302
- itemsValues += marginWidth;
303
- }
304
- }
305
- count++;
306
- if (itemProp.item.gallerySettings.itemCount === count) {
307
- count = 0;
308
- if (galleryWrapperHeight >= (galleryItemEle.offsetHeight + itemsValues)) {
309
- galleryWrapperHeight -= (galleryItemEle.offsetHeight + itemsValues);
310
- }
311
- else {
312
- isHeight = true;
313
- galleryItemEle.remove();
314
- }
315
- }
316
- else if (galleryWrapperHeight < (galleryItemEle.offsetHeight + itemsValues)) {
317
- isHeight = true;
318
- galleryItemEle.remove();
319
- }
320
- }
321
- else {
322
- galleryItemEle.remove();
323
- }
324
- }
325
- else {
326
- simplifiedItemsCount++;
327
- if (simplifiedItemsCount > itemProp.item.gallerySettings.itemCount) {
328
- galleryItemEle.classList.add('e-hidden');
329
- }
330
- }
331
- }
332
- }
333
- }
334
- }
335
- }
336
- }
337
-
338
- /**
339
- * Checks the popup collision.
340
- *
341
- * @param {Popup} popup - Gets the popup.
342
- * @param {HTMLElement} popupEle - Gets the popup element.
343
- * @param {number} offsetValue - Gets the offset value of gallery popup button.
344
- * @returns {void}
345
- * @hidden
346
- */
347
- public checkCollision(popup: Popup, popupEle: HTMLElement, offsetValue: number = 0): void {
348
- let paddingWidth: number = 0;
349
- let marginWidth: number = 0;
350
- if (popupEle) {
351
- const windowWidth: number = window.innerWidth;
352
- let screenWidth: number = offsetValue === 0 ? windowWidth : Math.abs(windowWidth - (windowWidth - offsetValue));
353
- const paddingStyles: CSSStyleDeclaration = window.getComputedStyle(popupEle);
354
- if (paddingStyles) {
355
- paddingWidth = parseFloat(paddingStyles.paddingLeft) + parseFloat(paddingStyles.paddingRight);
356
- if (!(isNullOrUndefined(paddingWidth))) {
357
- screenWidth = screenWidth - paddingWidth; }
358
- }
359
- const popupContainerItems: NodeListOf<Element> = popupEle.querySelectorAll('.e-ribbon-gallery-container');
360
- this.setWrapperStyle(popup, popupContainerItems);
361
- let isCollideOccurs: boolean = false;
362
- for (let i: number = 0; i < popupContainerItems.length; i++) {
363
- let itemsWidth: number = 0;
364
- for (let j: number = 0; j < (popupContainerItems[parseInt(i.toString(), 10)] as HTMLElement).querySelectorAll('.e-ribbon-gallery-item').length; j++) {
365
- const popupItemStyles: CSSStyleDeclaration = window.getComputedStyle(popupContainerItems[parseInt(i.toString(), 10)].querySelectorAll('.e-ribbon-gallery-item')[parseInt(j.toString(), 10)] as HTMLElement);
366
- if (popupItemStyles) {
367
- marginWidth = parseFloat(popupItemStyles.marginLeft) + parseFloat(popupItemStyles.marginRight);
368
- if (!(isNullOrUndefined(marginWidth))) {
369
- itemsWidth += marginWidth; }
370
- }
371
- itemsWidth += Math.round(parseFloat(popupItemStyles.width));
372
- if (((screenWidth <= itemsWidth) && popup.width === 'auto') || ((popup.width !== 'auto') && (screenWidth <= parseInt(popup.width.toString(), 10)) && (screenWidth <= itemsWidth)) ) {
373
- popupEle.style.width = ((itemsWidth + Math.abs(paddingWidth - marginWidth)) - Math.round(parseFloat(popupItemStyles.width))) + 'px';
374
- isCollideOccurs = true;
375
- break;
376
- }
377
- }
378
- if (isCollideOccurs) {
379
- popupContainerItems.forEach((ele: HTMLElement) => {
380
- ele.style.flexFlow = 'wrap';
381
- });
382
- if (popup.height === 'auto') {
383
- this.setGalleryPopupHeight(popupEle, parseFloat(paddingStyles.height), parseFloat(paddingStyles.top));
384
- }
385
- break;
386
- }
387
- }
388
- if (!isCollideOccurs) {
389
- if (popup.width === 'auto') {
390
- popupContainerItems.forEach((ele: HTMLElement) => {
391
- ele.style.flexFlow = 'nowrap';
392
- });
393
- popupEle.style.width = 'auto';
394
- }
395
- else {
396
- popupEle.style.width = (popup.width).toString();
397
- }
398
- if (popup.height === 'auto') {
399
- this.setGalleryPopupHeight(popupEle, parseFloat(paddingStyles.height), parseFloat(paddingStyles.top));
400
- }
401
- }
402
- }
403
- }
404
-
405
- private setGalleryPopupHeight(popupEle: HTMLElement, popupHeight: number, popupTop: number): void {
406
- if (window.innerHeight < popupHeight || window.innerHeight < Math.round(popupHeight + popupTop)) {
407
- popupEle.style.height = (window.innerHeight - popupTop) + 'px';
408
- }
409
- else {
410
- popupEle.style.height = 'auto';
411
- }
412
- }
413
-
414
- private createPopup(item: RibbonItemModel, buttonEle: HTMLElement): void {
415
- const popupContainer: HTMLElement = this.parent.createElement('div', {
416
- className: 'e-ribbon-popup-container',
417
- id: item.id + '_popupContainer'
418
- });
419
- this.renderGalleryItems(item.gallerySettings, true, item.id, popupContainer);
420
- const gallerypopupElement: HTMLElement = this.parent.createElement('div', {
421
- className: 'e-ribbon-gallery-popup',
422
- id: item.id + '_galleryPopup'
423
- });
424
- document.body.append(gallerypopupElement);
425
- const galleryPopup: Popup = new Popup(gallerypopupElement, {
426
- relateTo: buttonEle,
427
- content: popupContainer,
428
- collision: { X: 'fit', Y: 'flip' },
429
- actionOnScroll: 'hide',
430
- targetType: 'relative',
431
- position: { X: 'left', Y: 'bottom' },
432
- enableRtl: this.parent.enableRtl,
433
- width: item.gallerySettings.popupWidth,
434
- height: item.gallerySettings.popupHeight
435
- });
436
- galleryPopup.hide();
437
- }
438
-
439
- /**
440
- * Updates gallery in mode switching.
441
- *
442
- * @param {string} activeLayout - Gets the current active layout.
443
- * @param {string} itemID - Gets the ribbon item id.
444
- * @returns {void}
445
- * @hidden
446
- */
447
- public switchGalleryItems(activeLayout: string, itemID: string): void {
448
- const itemEle: HTMLElement = this.parent.element.querySelector('#' + itemID + constants.CONTAINER_ID);
449
- const itemProp: itemProps = getItem(this.parent.tabs, itemID);
450
- if (itemEle) {
451
- const galleryIcons: NodeListOf<Element> = itemEle.querySelectorAll('.e-ribbon-gallery-icons');
452
- const galleryContainer: NodeListOf<Element> = itemEle.querySelectorAll('.e-ribbon-gallery-container');
453
- if (galleryIcons.length) {
454
- for (let i: number = 0; i < galleryIcons.length; i++) {
455
- if (activeLayout === 'Simplified') { galleryIcons[parseInt(i.toString(), 10)].classList.add('e-hidden'); }
456
- else { galleryIcons[parseInt(i.toString(), 10)].classList.remove('e-hidden'); }
457
- }
458
- }
459
- if (galleryContainer.length && itemProp) {
460
- for (let n: number = 0; n < itemProp.item.gallerySettings.groups.length; n++) {
461
- for (let i: number = 0; i < galleryContainer.length; i++) {
462
- if (itemProp.item.gallerySettings.groups[parseInt(n.toString(), 10)].itemHeight && itemProp.item.gallerySettings.groups[parseInt(n.toString(), 10)].itemHeight !== 'auto') {
463
- if (itemID + '_galleryContainer' + n === (galleryContainer[parseInt(i.toString(), 10)] as HTMLElement).id) {
464
- if (activeLayout === 'Simplified') { (galleryContainer[parseInt(i.toString(), 10)] as HTMLElement).style.flexFlow = 'nowrap'; }
465
- else { (galleryContainer[parseInt(i.toString(), 10)] as HTMLElement).style.flexFlow = 'wrap'; }
466
- }
467
- }
468
- }
469
- }
470
- }
471
- const activeContent: HTMLElement = this.parent.tabObj.element.querySelector('#' + this.parent.tabs[this.parent.selectedTab].id + constants.CONTENT_ID);
472
- if (activeContent) {
473
- this.checkAvailableHeight(activeContent);
474
- }
475
- }
476
- }
477
-
478
- /**
479
- * Adds the additional event handlers as the item moved into overflow popup.
480
- *
481
- * @param {RibbonItemModel} item - Gets the ribbon item model.
482
- * @param {HTMLElement} itemEle - Gets the ribbon item element.
483
- * @returns {void}
484
- * @hidden
485
- */
486
- public addOverFlowEvents(item: RibbonItemModel, itemEle: HTMLElement ): void {
487
- if (itemEle.closest('.e-ribbon-overflow-target')) {
488
- const buttonEle: HTMLButtonElement = this.parent.createElement('button', {
489
- id: item.id
490
- });
491
- itemEle.appendChild(buttonEle);
492
- if (itemEle.querySelector('.e-ribbon-gallery-wrapper').classList.contains('e-disabled')) {
493
- buttonEle.classList.add('e-disabled');
494
- }
495
- itemEle.querySelector('.e-ribbon-gallery-wrapper').classList.add('e-hidden');
496
- itemEle.querySelectorAll('.e-ribbon-gallery-container').forEach((ele: HTMLElement) => {
497
- ele.classList.add('e-hidden');
498
- });
499
- const popupButton: HTMLElement = itemEle.querySelector('#' + item.id + '_popupButton');
500
- if (popupButton) {
501
- popupButton.classList.add('e-hidden'); }
502
- const itemProp: itemProps = getItem(this.parent.tabs, item.id);
503
- let iconCss: string = itemProp && itemProp.group.groupIconCss ? itemProp.group.groupIconCss : '';
504
- const content: string = itemProp && itemProp.group.header ? itemProp.group.header : '';
505
- if (!iconCss) {
506
- for (let i: number = 0; i < item.gallerySettings.groups.length; i++) {
507
- for (let j: number = 0; j < item.gallerySettings.groups[parseInt(i.toString(), 10)].items.length; j++) {
508
- if (item.gallerySettings.groups[parseInt(i.toString(), 10)].items[parseInt(j.toString(), 10)].iconCss) {
509
- iconCss = item.gallerySettings.groups[parseInt(i.toString(), 10)].items[parseInt(j.toString(), 10)].iconCss;
510
- break;
511
- }
512
- }
513
- if (iconCss) {
514
- break;
515
- }
516
- }
517
- }
518
- const popupEle: HTMLElement = document.querySelector('#' + item.id + '_galleryPopup');
519
- const popup: Popup = getComponent(popupEle, Popup);
520
- const popupContainerEle: HTMLElement = document.querySelector('#' + item.id + '_galleryPopup .e-ribbon-popup-container');
521
- const dropdown: DropDownButton = new DropDownButton({
522
- iconCss: iconCss,
523
- content: content,
524
- target: popupContainerEle,
525
- enableRtl: this.parent.enableRtl,
526
- cssClass: 'e-ribbon-gallery-dropdown',
527
- disabled: item.disabled,
528
- open: () => {
529
- const popupContainerItems: NodeListOf<Element> = popupContainerEle.querySelectorAll('.e-ribbon-gallery-container');
530
- this.setWrapperStyle(popup, popupContainerItems);
531
- this.setFoucsToFirstItem(popupContainerEle, true, item.id);
532
- },
533
- beforeClose: (args: BeforeOpenCloseMenuEventArgs) => {
534
- const isCancelled: boolean = this.popupEvents(args.event, item.gallerySettings, 'popupClose', false);
535
- if (isCancelled) { args.cancel = true; }
536
- }
537
- }, buttonEle);
538
- if (popup.width !== 'auto') {
539
- dropdown.dropDown.width = formatUnit(popup.width);
540
- }
541
- if (popup.height !== 'auto') {
542
- dropdown.dropDown.height = formatUnit(popup.height);
543
- dropdown.dropDown.element.style.height = (popup.height).toString();
544
- }
545
- }
546
- }
547
-
548
- /**
549
- * Removes the additional event handlers as the item moved into overflow popup.
550
- *
551
- * @param {RibbonItemModel} item - Gets the ribbon item model.
552
- * @param {HTMLElement} itemEle - Gets the ribbon item element.
553
- * @returns {void}
554
- * @hidden
555
- */
556
- public removeOverFlowEvents(item: RibbonItemModel, itemEle: HTMLElement): void {
557
- const popupButton: HTMLElement = itemEle.querySelector('#' + item.id + '_popupButton');
558
- if (popupButton) { popupButton.classList.remove('e-hidden'); }
559
- itemEle.querySelector('.e-ribbon-gallery-wrapper').classList.remove('e-hidden');
560
- itemEle.querySelectorAll('.e-ribbon-gallery-container').forEach((ele: HTMLElement) => {
561
- ele.classList.remove('e-hidden');
562
- });
563
- const galleryDDBEle: HTMLButtonElement = document.querySelector('#' + item.id);
564
- if (galleryDDBEle) {
565
- const popupEle: HTMLElement = document.querySelector('#' + item.id + '_galleryPopup');
566
- const dropdown: DropDownButton = getComponent(galleryDDBEle, DropDownButton);
567
- popupEle.appendChild((dropdown.target as HTMLElement));
568
- dropdown.destroy();
569
- remove(galleryDDBEle);
570
- }
571
- }
572
-
573
- private setActiveState(galleryEle: HTMLElement, gallerySettings: RibbonGallerySettingsModel, itemID: string,
574
- isInteracted: boolean, event: Event, isPopup: boolean): void {
575
- let previousItem: RibbonGalleryItemModel;
576
- let currentItem: RibbonGalleryItemModel;
577
- const itemEle: HTMLElement = document.querySelector('#' + itemID + constants.CONTAINER_ID);
578
- let selctedGalleryItem: Array<Element> = Array.prototype.slice.call(itemEle.querySelectorAll('.e-ribbon-gallery-selected'));
579
- const popupEle: HTMLElement = document.querySelector('#' + itemID + '_popupContainer');
580
- const popupGalleryItem: Array<Element> = Array.prototype.slice.call(popupEle.querySelectorAll('.e-ribbon-gallery-selected'));
581
- if (popupGalleryItem.length) {
582
- selctedGalleryItem = selctedGalleryItem.concat(popupGalleryItem);
583
- }
584
- for (let i: number = 0; i < gallerySettings.groups.length; i++) {
585
- for (let j: number = 0; j < gallerySettings.groups[parseInt(i.toString(), 10)].items.length; j++) {
586
- if (selctedGalleryItem[0].id === itemID + '_galleryContainer' + i + '_gallery' + j) {
587
- previousItem = gallerySettings.groups[parseInt(i.toString(), 10)].items[parseInt(j.toString(), 10)];
588
- }
589
- if (galleryEle.id === (isPopup ? 'popup_' : '') + itemID + '_galleryContainer' + i + '_gallery' + j) {
590
- currentItem = gallerySettings.groups[parseInt(i.toString(), 10)].items[parseInt(j.toString(), 10)];
591
- }
592
- }
593
- }
594
- const galleryItem: HTMLElement = document.getElementById(galleryEle.id);
595
- let galleryItemPopup: HTMLElement;
596
- const selectingEventArgs: GalleryBeforeSelectEventArgs = { cancel: false, name: 'beforeSelect', previousItem: previousItem, currentItem: currentItem, isInteracted: isInteracted, event: event};
597
- if (gallerySettings.beforeSelect) {
598
- gallerySettings.beforeSelect.call(this, selectingEventArgs);
599
- }
600
- if (selectingEventArgs.cancel) {
601
- return;
602
- }
603
- else {
604
- for (let i: number = 0; i < selctedGalleryItem.length; i++) {
605
- selctedGalleryItem[parseInt(i.toString(), 10)].classList.remove('e-ribbon-gallery-selected');
606
- }
607
- if (!galleryItem.id.startsWith('popup_')) {
608
- galleryItemPopup = document.getElementById('popup_' + galleryEle.id);
609
- } else if (document.getElementById(galleryItem.id.slice(6))) {
610
- galleryItemPopup = document.getElementById(galleryItem.id.slice(6));
611
- }
612
- if (galleryItemPopup) {
613
- galleryItemPopup.classList.add('e-ribbon-gallery-selected');
614
- }
615
- galleryItem.classList.add('e-ribbon-gallery-selected');
616
- const selectedEventArgs: GallerySelectEventArgs = { previousItem: previousItem, currentItem: currentItem, name: 'select', isInteracted: isInteracted, event: event };
617
- const galleryPopupItems: NodeListOf<Element> = document.querySelectorAll('#' + itemID + '_popupContainer .e-ribbon-gallery-item');
618
- for (let i: number = 0; i < galleryPopupItems.length; i++) {
619
- if (galleryPopupItems[parseInt(i.toString(), 10)].id === galleryEle.id) {
620
- gallerySettings.selectedItemIndex = i;
621
- break;
622
- }
623
- }
624
- if (gallerySettings.select) {
625
- gallerySettings.select.call(this, selectedEventArgs);
626
- }
627
- }
628
- }
629
-
630
- private popupEvents(args: Event, gallerySettings: RibbonGallerySettingsModel, name: string, isOpen: boolean): boolean {
631
- const popupEventArgs: GalleryPopupEventArgs = { cancel: false, event: args, name: name };
632
- if (isOpen && gallerySettings.popupOpen) {
633
- gallerySettings.popupOpen.call(this, popupEventArgs);
634
- }
635
- else if (!isOpen && gallerySettings.popupClose) {
636
- gallerySettings.popupClose.call(this, popupEventArgs);
637
- }
638
- if (popupEventArgs.cancel) { return true; }
639
- return false;
640
- }
641
-
642
- private showPopup(popup: Popup, popupEle: HTMLElement, args: Event, gallerySettings: RibbonGallerySettingsModel, itemID: string): void {
643
- const isCancelled: boolean = this.popupEvents(args, gallerySettings, 'popupOpen', true);
644
- if (isCancelled) { return; }
645
- popup.show();
646
- this.checkCollision(popup, popupEle);
647
- const buttonEle: HTMLElement = document.querySelector('#' + itemID + '_popupButton');
648
- buttonEle.classList.add('e-gallery-button-active');
649
- const buttonPosition: ClientRect = buttonEle.getBoundingClientRect();
650
- if (popupEle.offsetWidth > buttonPosition.left) {
651
- this.checkCollision(popup, popupEle, buttonPosition.left);
652
- }
653
- const offsetX: number = Math.abs((popupEle.offsetWidth - buttonPosition.left)) + buttonEle.offsetWidth;
654
- popupEle.style.left = offsetX + 'px';
655
- popupEle.style.top = popupEle.getBoundingClientRect().top + 2 + 'px';
656
- this.setFoucsToFirstItem(popupEle, false, itemID, popup, gallerySettings);
657
- }
658
-
659
- private hidePopup(popup: Popup, popupEle: HTMLElement, args: Event, gallerySettings: RibbonGallerySettingsModel, itemID: string): void {
660
- const isCancelled: boolean = this.popupEvents(args, gallerySettings, 'popupClose', false);
661
- if (isCancelled) { return; }
662
- popup.hide();
663
- const buttonEle: HTMLElement = document.querySelector('#' + itemID + '_popupButton');
664
- buttonEle.classList.remove('e-gallery-button-active');
665
- }
666
-
667
- /**
668
- * Shows a specific gallery popup in the ribbon.
669
- *
670
- * @param {string} id - Gets the ribbon item id.
671
- * @returns {void}
672
- */
673
- public showGalleryPopup(id: string): void {
674
- const itemProp: itemProps = getItem(this.parent.tabs, id);
675
- const popupEle: HTMLElement = document.querySelector('#' + id + '_galleryPopup');
676
- const popup: Popup = getComponent(popupEle, Popup);
677
- this.showPopup(popup, popupEle, null, itemProp.item.gallerySettings, id);
678
- }
679
-
680
- /**
681
- * Hides a specific gallery popup in the ribbon.
682
- *
683
- * @param {string} id - Gets the ribbon item id.
684
- * @returns {void}
685
- */
686
- public hideGalleryPopup(id: string): void {
687
- const itemProp: itemProps = getItem(this.parent.tabs, id);
688
- const popupEle: HTMLElement = document.querySelector('#' + id + '_galleryPopup');
689
- const popup: Popup = getComponent(popupEle, Popup);
690
- this.hidePopup(popup, popupEle, null, itemProp.item.gallerySettings, id);
691
- }
692
-
693
- private setFoucsToFirstItem(popupEle: HTMLElement, isDropdown: boolean, itemID: string, popup?: Popup,
694
- gallerySettings?: RibbonGallerySettingsModel): void {
695
- (popupEle.querySelectorAll('.e-ribbon-gallery-item')[0] as HTMLElement).focus();
696
- this.galleryItemsIndex = 0;
697
- popupEle.onkeydown = (e: KeyboardEventArgs) => {
698
- this.handleGalleryPopupNavigation(e, popupEle, isDropdown, itemID, popup, gallerySettings);
699
- };
700
- }
701
-
702
- private handleGalleryPopupNavigation(e: KeyboardEventArgs, popupEle: HTMLElement, isDropdown: boolean,
703
- itemID: string, popup?: Popup, gallerySettings?: RibbonGallerySettingsModel): void {
704
- const galleryPopupEle: NodeListOf<Element> = popupEle.querySelectorAll('.e-ribbon-gallery-item');
705
- if (galleryPopupEle) {
706
- if (e.key === 'Home') {
707
- this.galleryItemsIndex = 0;
708
- (galleryPopupEle[this.galleryItemsIndex] as HTMLElement).focus();
709
- }
710
- else if (e.key === 'End') {
711
- this.galleryItemsIndex = galleryPopupEle.length - 1;
712
- (galleryPopupEle[this.galleryItemsIndex] as HTMLElement).focus();
713
- }
714
- else if (e.key === 'ArrowRight' || e.key === 'ArrowDown') {
715
- this.galleryItemsIndex++;
716
- if (this.galleryItemsIndex !== galleryPopupEle.length) {
717
- if (galleryPopupEle && (galleryPopupEle[this.galleryItemsIndex])) {
718
- (galleryPopupEle[this.galleryItemsIndex] as HTMLElement).focus();
719
- }
720
- }
721
- else {
722
- this.galleryItemsIndex = 0;
723
- (galleryPopupEle[this.galleryItemsIndex] as HTMLElement).focus();
724
- }
725
- }
726
- else if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') {
727
- if (this.galleryItemsIndex !== 0) {
728
- this.galleryItemsIndex--;
729
- if (galleryPopupEle && (galleryPopupEle[this.galleryItemsIndex])) {
730
- (galleryPopupEle[this.galleryItemsIndex] as HTMLElement).focus();
731
- }
732
- }
733
- else {
734
- this.galleryItemsIndex = galleryPopupEle.length - 1;
735
- (galleryPopupEle[this.galleryItemsIndex] as HTMLElement).focus();
736
- }
737
- }
738
- else if ((e.key === 'Enter' || e.code === 'Space') || (e.key === 'Escape' && !isDropdown)) {
739
- this.hidePopup(popup, popupEle, e, gallerySettings, itemID);
740
- }
741
- }
742
- }
743
-
744
- private createGalleryTemplate(galleryItemEle: HTMLElement, gallerySettings: RibbonGallerySettingsModel, id: string,
745
- items: RibbonGalleryItemModel): void {
746
- galleryItemEle.classList.add('e-ribbon-gallery-template');
747
- const templateName: string = 'ribbon' + id + 'galleryTemplate';
748
- this.parent['clearTemplate']([templateName]);
749
- const templateFunction: Function = getTemplateFunction(gallerySettings.template);
750
- if (items.disabled) {
751
- galleryItemEle.classList.add('e-disabled');
752
- }
753
- if (items.cssClass) {
754
- galleryItemEle.classList.add(items.cssClass);
755
- }
756
- append(templateFunction({ items: items }, this, templateName, (id + 'galleryTemplate'), this.parent.isStringTemplate, null, null, this.parent), galleryItemEle);
757
- }
758
-
759
- private createGalleryPopupTemplate(galleryItemEle: HTMLElement, gallerySettings: RibbonGallerySettingsModel, id: string,
760
- items: RibbonGalleryItemModel): void {
761
- galleryItemEle.classList.add('e-ribbon-gallery-popup-template');
762
- const templateName: string = 'ribbon' + id + 'galleryPopupTemplate';
763
- this.parent['clearTemplate']([templateName]);
764
- const templateFunction: Function = getTemplateFunction(gallerySettings.popupTemplate);
765
- if (items.disabled) {
766
- galleryItemEle.classList.add('e-disabled');
767
- }
768
- if (items.cssClass) {
769
- galleryItemEle.classList.add(items.cssClass);
770
- }
771
- append(templateFunction({ items: items }, this, templateName, (id + 'galleryPopupTemplate'), this.parent.isStringTemplate, null, null, this.parent), galleryItemEle);
772
- }
773
- }