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