@syncfusion/ej2-ribbon 21.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/.eslintrc.json +259 -0
- package/.github/PULL_REQUEST_TEMPLATE/Bug.md +60 -0
- package/.github/PULL_REQUEST_TEMPLATE/feature.md +37 -0
- package/CHANGELOG.md +19 -0
- package/README.md +3 -0
- package/dist/ej2-ribbon.umd.min.js +11 -0
- package/dist/ej2-ribbon.umd.min.js.map +1 -0
- package/dist/es6/ej2-ribbon.es2015.js +4946 -0
- package/dist/es6/ej2-ribbon.es2015.js.map +1 -0
- package/dist/es6/ej2-ribbon.es5.js +5253 -0
- package/dist/es6/ej2-ribbon.es5.js.map +1 -0
- package/dist/global/ej2-ribbon.min.js +11 -0
- package/dist/global/ej2-ribbon.min.js.map +1 -0
- package/dist/global/index.d.ts +14 -0
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/license +10 -0
- package/package.json +67 -0
- package/ribbon.d.ts +4 -0
- package/ribbon.js +4 -0
- package/src/global.js +3 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -0
- package/src/ribbon/base/constant.d.ts +151 -0
- package/src/ribbon/base/constant.js +151 -0
- package/src/ribbon/base/index.d.ts +8 -0
- package/src/ribbon/base/index.js +7 -0
- package/src/ribbon/base/interface.d.ts +194 -0
- package/src/ribbon/base/interface.js +106 -0
- package/src/ribbon/base/ribbon-model.d.ts +129 -0
- package/src/ribbon/base/ribbon.d.ts +357 -0
- package/src/ribbon/base/ribbon.js +2413 -0
- package/src/ribbon/base/utils.d.ts +113 -0
- package/src/ribbon/base/utils.js +288 -0
- package/src/ribbon/index.d.ts +7 -0
- package/src/ribbon/index.js +7 -0
- package/src/ribbon/items/index.d.ts +6 -0
- package/src/ribbon/items/index.js +6 -0
- package/src/ribbon/items/ribbon-button.d.ts +65 -0
- package/src/ribbon/items/ribbon-button.js +153 -0
- package/src/ribbon/items/ribbon-checkbox.d.ts +56 -0
- package/src/ribbon/items/ribbon-checkbox.js +134 -0
- package/src/ribbon/items/ribbon-colorpicker.d.ts +66 -0
- package/src/ribbon/items/ribbon-colorpicker.js +163 -0
- package/src/ribbon/items/ribbon-combobox.d.ts +78 -0
- package/src/ribbon/items/ribbon-combobox.js +185 -0
- package/src/ribbon/items/ribbon-dropdown.d.ts +123 -0
- package/src/ribbon/items/ribbon-dropdown.js +268 -0
- package/src/ribbon/items/ribbon-splitbutton.d.ts +86 -0
- package/src/ribbon/items/ribbon-splitbutton.js +227 -0
- package/src/ribbon/models/index.d.ts +24 -0
- package/src/ribbon/models/index.js +13 -0
- package/src/ribbon/models/ribbon-button-settings-model.d.ts +57 -0
- package/src/ribbon/models/ribbon-button-settings.d.ts +55 -0
- package/src/ribbon/models/ribbon-button-settings.js +61 -0
- package/src/ribbon/models/ribbon-checkbox-settings-model.d.ts +50 -0
- package/src/ribbon/models/ribbon-checkbox-settings.d.ts +50 -0
- package/src/ribbon/models/ribbon-checkbox-settings.js +58 -0
- package/src/ribbon/models/ribbon-collection-model.d.ts +30 -0
- package/src/ribbon/models/ribbon-collection.d.ts +33 -0
- package/src/ribbon/models/ribbon-collection.js +50 -0
- package/src/ribbon/models/ribbon-colorpicker-settings-model.d.ts +123 -0
- package/src/ribbon/models/ribbon-colorpicker-settings.d.ts +115 -0
- package/src/ribbon/models/ribbon-colorpicker-settings.js +88 -0
- package/src/ribbon/models/ribbon-combobox-settings-model.d.ts +241 -0
- package/src/ribbon/models/ribbon-combobox-settings.d.ts +223 -0
- package/src/ribbon/models/ribbon-combobox-settings.js +122 -0
- package/src/ribbon/models/ribbon-dropdown-settings-model.d.ts +100 -0
- package/src/ribbon/models/ribbon-dropdown-settings.d.ts +93 -0
- package/src/ribbon/models/ribbon-dropdown-settings.js +80 -0
- package/src/ribbon/models/ribbon-file-menu-settings-model.d.ts +108 -0
- package/src/ribbon/models/ribbon-file-menu-settings.d.ts +159 -0
- package/src/ribbon/models/ribbon-file-menu-settings.js +84 -0
- package/src/ribbon/models/ribbon-group-model.d.ts +91 -0
- package/src/ribbon/models/ribbon-group.d.ts +87 -0
- package/src/ribbon/models/ribbon-group.js +74 -0
- package/src/ribbon/models/ribbon-item-model.d.ts +120 -0
- package/src/ribbon/models/ribbon-item.d.ts +118 -0
- package/src/ribbon/models/ribbon-item.js +93 -0
- package/src/ribbon/models/ribbon-splitbutton-settings-model.d.ts +107 -0
- package/src/ribbon/models/ribbon-splitbutton-settings.d.ts +99 -0
- package/src/ribbon/models/ribbon-splitbutton-settings.js +83 -0
- package/src/ribbon/models/ribbon-tab-model.d.ts +37 -0
- package/src/ribbon/models/ribbon-tab.d.ts +39 -0
- package/src/ribbon/models/ribbon-tab.js +53 -0
- package/src/ribbon/models/ribbon-tooltip-model.d.ts +43 -0
- package/src/ribbon/models/ribbon-tooltip.d.ts +36 -0
- package/src/ribbon/models/ribbon-tooltip.js +46 -0
- package/src/ribbon/modules/index.d.ts +1 -0
- package/src/ribbon/modules/index.js +1 -0
- package/src/ribbon/modules/ribbon-filemenu.d.ts +94 -0
- package/src/ribbon/modules/ribbon-filemenu.js +318 -0
- package/styles/bootstrap-dark.css +1502 -0
- package/styles/bootstrap-dark.scss +1 -0
- package/styles/bootstrap.css +1507 -0
- package/styles/bootstrap.scss +1 -0
- package/styles/bootstrap4.css +1557 -0
- package/styles/bootstrap4.scss +1 -0
- package/styles/bootstrap5-dark.css +1586 -0
- package/styles/bootstrap5-dark.scss +1 -0
- package/styles/bootstrap5.css +1586 -0
- package/styles/bootstrap5.scss +1 -0
- package/styles/fabric-dark.css +1478 -0
- package/styles/fabric-dark.scss +1 -0
- package/styles/fabric.css +1476 -0
- package/styles/fabric.scss +1 -0
- package/styles/fluent-dark.css +1562 -0
- package/styles/fluent-dark.scss +1 -0
- package/styles/fluent.css +1562 -0
- package/styles/fluent.scss +1 -0
- package/styles/highcontrast-light.css +1485 -0
- package/styles/highcontrast-light.scss +1 -0
- package/styles/highcontrast.css +1494 -0
- package/styles/highcontrast.scss +1 -0
- package/styles/material-dark.css +1548 -0
- package/styles/material-dark.scss +1 -0
- package/styles/material.css +1581 -0
- package/styles/material.scss +1 -0
- package/styles/ribbon/_all.scss +2 -0
- package/styles/ribbon/_bootstrap-dark-definition.scss +206 -0
- package/styles/ribbon/_bootstrap-definition.scss +206 -0
- package/styles/ribbon/_bootstrap4-definition.scss +206 -0
- package/styles/ribbon/_bootstrap5-dark-definition.scss +1 -0
- package/styles/ribbon/_bootstrap5-definition.scss +206 -0
- package/styles/ribbon/_fabric-dark-definition.scss +206 -0
- package/styles/ribbon/_fabric-definition.scss +206 -0
- package/styles/ribbon/_fluent-dark-definition.scss +1 -0
- package/styles/ribbon/_fluent-definition.scss +206 -0
- package/styles/ribbon/_fusionnew-definition.scss +206 -0
- package/styles/ribbon/_highcontrast-definition.scss +206 -0
- package/styles/ribbon/_highcontrast-light-definition.scss +206 -0
- package/styles/ribbon/_layout.scss +1040 -0
- package/styles/ribbon/_material-dark-definition.scss +206 -0
- package/styles/ribbon/_material-definition.scss +206 -0
- package/styles/ribbon/_tailwind-dark-definition.scss +1 -0
- package/styles/ribbon/_tailwind-definition.scss +206 -0
- package/styles/ribbon/_theme.scss +343 -0
- package/styles/ribbon/bootstrap-dark.css +1502 -0
- package/styles/ribbon/bootstrap-dark.scss +17 -0
- package/styles/ribbon/bootstrap.css +1507 -0
- package/styles/ribbon/bootstrap.scss +17 -0
- package/styles/ribbon/bootstrap4.css +1557 -0
- package/styles/ribbon/bootstrap4.scss +17 -0
- package/styles/ribbon/bootstrap5-dark.css +1586 -0
- package/styles/ribbon/bootstrap5-dark.scss +17 -0
- package/styles/ribbon/bootstrap5.css +1586 -0
- package/styles/ribbon/bootstrap5.scss +17 -0
- package/styles/ribbon/fabric-dark.css +1478 -0
- package/styles/ribbon/fabric-dark.scss +17 -0
- package/styles/ribbon/fabric.css +1476 -0
- package/styles/ribbon/fabric.scss +17 -0
- package/styles/ribbon/fluent-dark.css +1562 -0
- package/styles/ribbon/fluent-dark.scss +17 -0
- package/styles/ribbon/fluent.css +1562 -0
- package/styles/ribbon/fluent.scss +17 -0
- package/styles/ribbon/highcontrast-light.css +1485 -0
- package/styles/ribbon/highcontrast-light.scss +16 -0
- package/styles/ribbon/highcontrast.css +1494 -0
- package/styles/ribbon/highcontrast.scss +17 -0
- package/styles/ribbon/icons/_bootstrap-dark.scss +9 -0
- package/styles/ribbon/icons/_bootstrap.scss +9 -0
- package/styles/ribbon/icons/_bootstrap4.scss +9 -0
- package/styles/ribbon/icons/_bootstrap5-dark.scss +1 -0
- package/styles/ribbon/icons/_bootstrap5.scss +9 -0
- package/styles/ribbon/icons/_fabric-dark.scss +9 -0
- package/styles/ribbon/icons/_fabric.scss +9 -0
- package/styles/ribbon/icons/_fluent-dark.scss +1 -0
- package/styles/ribbon/icons/_fluent.scss +9 -0
- package/styles/ribbon/icons/_fusionnew.scss +9 -0
- package/styles/ribbon/icons/_highcontrast.scss +9 -0
- package/styles/ribbon/icons/_material-dark.scss +9 -0
- package/styles/ribbon/icons/_material.scss +9 -0
- package/styles/ribbon/icons/_material3.scss +9 -0
- package/styles/ribbon/icons/_tailwind-dark.scss +9 -0
- package/styles/ribbon/icons/_tailwind.scss +9 -0
- package/styles/ribbon/material-dark.css +1548 -0
- package/styles/ribbon/material-dark.scss +17 -0
- package/styles/ribbon/material.css +1581 -0
- package/styles/ribbon/material.scss +17 -0
- package/styles/ribbon/tailwind-dark.css +1560 -0
- package/styles/ribbon/tailwind-dark.scss +17 -0
- package/styles/ribbon/tailwind.css +1560 -0
- package/styles/ribbon/tailwind.scss +17 -0
- package/styles/tailwind-dark.css +1560 -0
- package/styles/tailwind-dark.scss +1 -0
- package/styles/tailwind.css +1560 -0
- package/styles/tailwind.scss +1 -0
- package/tslint.json +111 -0
|
@@ -0,0 +1,2413 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
15
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
16
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
17
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
18
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
19
|
+
};
|
|
20
|
+
import { addClass, append, Event, Collection, Complex, Component, EventHandler, formatUnit, getInstance, getComponent, getUniqueID, closest } from '@syncfusion/ej2-base';
|
|
21
|
+
import { isNullOrUndefined, isUndefined, NotifyPropertyChanges, Property, remove, removeClass } from '@syncfusion/ej2-base';
|
|
22
|
+
import { Tab, TabAnimationSettings, HScroll, Toolbar } from '@syncfusion/ej2-navigations';
|
|
23
|
+
import { RibbonTab, FileMenuSettings } from '../models/index';
|
|
24
|
+
import { DisplayMode, RibbonLayout } from './interface';
|
|
25
|
+
import { ItemOrientation, RibbonItemSize, RibbonItemType } from './interface';
|
|
26
|
+
import { RibbonButton, RibbonComboBox, RibbonCheckBox, RibbonDropDown, RibbonSplitButton } from '../items/index';
|
|
27
|
+
import { destroyControl, getCollection, getGroup, getIndex, getItem, getItemElement, updateCommonProperty, updateControlDisabled, isTooltipPresent, getTemplateFunction, createTooltip, destroyTooltip, updateTooltipProp } from './utils';
|
|
28
|
+
import * as constants from './constant';
|
|
29
|
+
import { DropDownButton, SplitButton } from '@syncfusion/ej2-splitbuttons';
|
|
30
|
+
/**
|
|
31
|
+
* The Ribbon Component is a structured layout to manage tools with tabs and groups.
|
|
32
|
+
*/
|
|
33
|
+
var Ribbon = /** @class */ (function (_super) {
|
|
34
|
+
__extends(Ribbon, _super);
|
|
35
|
+
/**
|
|
36
|
+
* Constructor for creating the widget.
|
|
37
|
+
*
|
|
38
|
+
* @param {RibbonModel} options - Specifies the ribbon model
|
|
39
|
+
* @param {string|HTMLDivElement} element - Specifies the target element
|
|
40
|
+
*/
|
|
41
|
+
function Ribbon(options, element) {
|
|
42
|
+
var _this = this;
|
|
43
|
+
Ribbon_1.Inject(RibbonButton, RibbonCheckBox, RibbonDropDown, RibbonSplitButton, RibbonComboBox);
|
|
44
|
+
_this = _super.call(this, options, element) || this;
|
|
45
|
+
return _this;
|
|
46
|
+
}
|
|
47
|
+
Ribbon_1 = Ribbon;
|
|
48
|
+
/**
|
|
49
|
+
* Initialize the control rendering.
|
|
50
|
+
*
|
|
51
|
+
* @returns {void}
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
Ribbon.prototype.render = function () {
|
|
55
|
+
this.initialize();
|
|
56
|
+
};
|
|
57
|
+
Ribbon.prototype.preRender = function () {
|
|
58
|
+
this.idIndex = 0;
|
|
59
|
+
this.tooltipData = [];
|
|
60
|
+
this.isAddRemove = false;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Get the properties to be maintained in the persisted state.
|
|
64
|
+
*
|
|
65
|
+
* @returns {string} - Persist data
|
|
66
|
+
*/
|
|
67
|
+
Ribbon.prototype.getPersistData = function () {
|
|
68
|
+
return this.addOnPersist(['activeLayout']);
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Get component name.
|
|
72
|
+
*
|
|
73
|
+
* @returns {string} - Module name
|
|
74
|
+
* @private
|
|
75
|
+
*/
|
|
76
|
+
Ribbon.prototype.getModuleName = function () {
|
|
77
|
+
return 'ribbon';
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* To provide the array of modules needed for component rendering
|
|
81
|
+
*
|
|
82
|
+
* @returns {ModuleDeclaration[]} - returns module declaration.
|
|
83
|
+
* @hidden
|
|
84
|
+
*/
|
|
85
|
+
Ribbon.prototype.requiredModules = function () {
|
|
86
|
+
var modules = [];
|
|
87
|
+
modules.push({ member: 'ribbonButton', args: [this] }, { member: 'ribbonDropDown', args: [this] }, { member: 'ribbonSplitButton', args: [this] }, { member: 'ribbonCheckBox', args: [this] }, { member: 'ribbonColorPicker', args: [this] }, { member: 'ribbonComboBox', args: [this] }, { member: 'ribbonFileMenu', args: [this] });
|
|
88
|
+
return modules;
|
|
89
|
+
};
|
|
90
|
+
Ribbon.prototype.initialize = function () {
|
|
91
|
+
this.element.id = this.element.id || getUniqueID('e-' + this.getModuleName());
|
|
92
|
+
addClass([this.element], ['e-rbn'].concat((this.cssClass ? this.cssClass.split(constants.SPACE) : [])));
|
|
93
|
+
if (this.enableRtl) {
|
|
94
|
+
this.element.classList.add(constants.RTL_CSS);
|
|
95
|
+
}
|
|
96
|
+
this.element.style.width = formatUnit(this.width);
|
|
97
|
+
this.renderTabs();
|
|
98
|
+
if (this.ribbonFileMenuModule) {
|
|
99
|
+
this.ribbonFileMenuModule.createFileMenu(this.fileMenu);
|
|
100
|
+
}
|
|
101
|
+
this.createHelpPaneTemplate();
|
|
102
|
+
createTooltip(this.element, this);
|
|
103
|
+
this.wireEvents();
|
|
104
|
+
};
|
|
105
|
+
Ribbon.prototype.wireEvents = function () {
|
|
106
|
+
EventHandler.add(window, 'resize', this.resizeHandler, this);
|
|
107
|
+
};
|
|
108
|
+
Ribbon.prototype.resizeHandler = function () {
|
|
109
|
+
var activeContent = this.tabObj.element.querySelector('#' + this.tabs[this.selectedTab].id + constants.CONTENT_ID);
|
|
110
|
+
this.checkOverflow(this.selectedTab, activeContent);
|
|
111
|
+
if (this.scrollModule) {
|
|
112
|
+
var scrollEle = this.tabObj.element.querySelector('.' + constants.HORIZONTAL_SCROLLBAR);
|
|
113
|
+
this.scrollModule.scrollStep = scrollEle.offsetWidth;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
Ribbon.prototype.renderTabs = function () {
|
|
117
|
+
this.tabsInternal = this.tabs.slice();
|
|
118
|
+
this.tabsInternal = this.checkID(this.tabsInternal, 'tab', this.element.id);
|
|
119
|
+
this.setProperties({ tabs: this.tabsInternal }, true);
|
|
120
|
+
var tabEle = this.createElement('div', {
|
|
121
|
+
id: this.element.id + constants.TAB_ID
|
|
122
|
+
});
|
|
123
|
+
this.element.appendChild(tabEle);
|
|
124
|
+
this.validateItemSize();
|
|
125
|
+
var tabItems = this.createTabItems(this.tabs);
|
|
126
|
+
this.tabObj = new Tab({
|
|
127
|
+
cssClass: constants.RIBBON_TAB,
|
|
128
|
+
selectedItem: this.selectedTab,
|
|
129
|
+
overflowMode: 'Popup',
|
|
130
|
+
width: this.width,
|
|
131
|
+
items: tabItems,
|
|
132
|
+
enableRtl: this.enableRtl,
|
|
133
|
+
created: this.tabCreated.bind(this),
|
|
134
|
+
selected: this.ribbonTabSelected.bind(this),
|
|
135
|
+
selecting: this.ribbonTabSelecting.bind(this)
|
|
136
|
+
});
|
|
137
|
+
this.tabObj.appendTo(tabEle);
|
|
138
|
+
//Set the width value as "0px" with unit for proper calculation.
|
|
139
|
+
this.element.style.setProperty(constants.RIBBON_FILE_MENU_WIDTH, '0px');
|
|
140
|
+
this.element.style.setProperty(constants.RIBBON_HELP_PANE_TEMPLATE_WIDTH, '0px');
|
|
141
|
+
var toolbarEle = tabEle.querySelector('.e-toolbar');
|
|
142
|
+
var toolbar = getComponent(toolbarEle, Toolbar);
|
|
143
|
+
toolbar.setProperties({ width: 'calc(100% - var(--fileMenuWidth) - var(--helpTemplateWidth))' });
|
|
144
|
+
this.element.classList[this.isMinimized ? 'add' : 'remove'](constants.RIBBON_MINIMIZE);
|
|
145
|
+
};
|
|
146
|
+
Ribbon.prototype.minimize = function (val) {
|
|
147
|
+
var _this = this;
|
|
148
|
+
if (val === this.isMinimized) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
var eventArgs = { cancel: false };
|
|
152
|
+
this.trigger(val ? 'ribbonCollapsing' : 'ribbonExpanding', eventArgs, function (args) {
|
|
153
|
+
if (args.cancel) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
_this.setProperties({ isMinimized: val }, true);
|
|
157
|
+
_this.element.classList.toggle(constants.RIBBON_MINIMIZE, _this.isMinimized);
|
|
158
|
+
//to overwrite inline styles from hscroll
|
|
159
|
+
_this.tabObj.element.querySelector('.e-content').style.display = val ? 'none' : 'block';
|
|
160
|
+
if (!val) {
|
|
161
|
+
_this.refreshLayout();
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
Ribbon.prototype.toggleLayout = function () {
|
|
166
|
+
this.setProperties({ activeLayout: this.activeLayout === 'Simplified' ? 'Classic' : 'Simplified' }, true);
|
|
167
|
+
this.switchLayout();
|
|
168
|
+
};
|
|
169
|
+
Ribbon.prototype.tabCreated = function () {
|
|
170
|
+
this.addExpandCollapse();
|
|
171
|
+
this.renderInitialTab(this.selectedTab);
|
|
172
|
+
};
|
|
173
|
+
Ribbon.prototype.ribbonTabSelected = function (e) {
|
|
174
|
+
this.isAddRemove = false;
|
|
175
|
+
var selectedTabId = e.selectedItem.getAttribute('data-id');
|
|
176
|
+
var selectedIndex = getIndex(this.tabs, (function (tab) { return (tab.id === selectedTabId); }));
|
|
177
|
+
selectedIndex = selectedIndex === -1 ? this.selectedTab : selectedIndex;
|
|
178
|
+
var eventArgs = { previousIndex: this.selectedTab, selectedIndex: selectedIndex };
|
|
179
|
+
this.setProperties({ selectedTab: selectedIndex }, true);
|
|
180
|
+
this.checkOverflow(selectedIndex, e.selectedContent);
|
|
181
|
+
if (this.activeLayout === 'Simplified' && this.overflowDDB) {
|
|
182
|
+
var overflowTarget = this.overflowDDB.target;
|
|
183
|
+
var ofTabContainer = overflowTarget.querySelector('.' + constants.RIBBON_TAB_ACTIVE);
|
|
184
|
+
if (ofTabContainer) {
|
|
185
|
+
ofTabContainer.classList.remove(constants.RIBBON_TAB_ACTIVE);
|
|
186
|
+
}
|
|
187
|
+
var activeTab = overflowTarget.querySelector('#' + selectedTabId + constants.OVERFLOW_ID);
|
|
188
|
+
if (activeTab) {
|
|
189
|
+
activeTab.classList.add(constants.RIBBON_TAB_ACTIVE);
|
|
190
|
+
this.overflowDDB.element.classList.remove(constants.HIDE_CSS);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
this.overflowDDB.element.classList.add(constants.HIDE_CSS);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
this.trigger('tabSelected', eventArgs);
|
|
197
|
+
};
|
|
198
|
+
Ribbon.prototype.checkOverflow = function (tabIndex, activeContent) {
|
|
199
|
+
if (!activeContent) {
|
|
200
|
+
activeContent = this.tabObj.element.querySelector('#' + this.tabs[parseInt(tabIndex.toString(), 10)].id + constants.CONTENT_ID);
|
|
201
|
+
}
|
|
202
|
+
var tabContent = activeContent.closest('.' + constants.TAB_CONTENT);
|
|
203
|
+
var isOverFlow = tabContent.offsetWidth < activeContent.offsetWidth;
|
|
204
|
+
if (isOverFlow && !this.scrollModule) {
|
|
205
|
+
if (this.activeLayout === 'Classic') {
|
|
206
|
+
// Defines whether the shrinking is breaked due to insufficient space.
|
|
207
|
+
var isBreak = false;
|
|
208
|
+
isBreak = this.checkGroupShrinking(tabIndex, tabContent, activeContent, true);
|
|
209
|
+
if (!isBreak && (tabContent.offsetWidth < activeContent.offsetWidth)) {
|
|
210
|
+
isBreak = this.checkGroupShrinking(tabIndex, tabContent, activeContent, false);
|
|
211
|
+
}
|
|
212
|
+
if (tabContent.offsetWidth < activeContent.offsetWidth) {
|
|
213
|
+
this.createOverflowDropdown(tabIndex, tabContent, activeContent);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
this.checkSimplifiedItemShrinking(tabIndex, tabContent, activeContent);
|
|
218
|
+
if (tabContent.offsetWidth < activeContent.offsetWidth) {
|
|
219
|
+
this.createSimplfiedOverflow(tabContent, activeContent, tabIndex);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
//Adds Scroll if the tabwidth is less the content width even after adding overflow dropdown.
|
|
223
|
+
if ((tabContent.offsetWidth < activeContent.offsetWidth) && (!this.scrollModule)) {
|
|
224
|
+
this.scrollModule = new HScroll({}, this.tabObj.element.querySelector('.' + constants.TAB_CONTENT));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
else if (!isOverFlow) {
|
|
228
|
+
this.destroyScroll();
|
|
229
|
+
if (this.activeLayout === 'Classic') {
|
|
230
|
+
var isBreak = false;
|
|
231
|
+
isBreak = this.removeOverflowDropdown(tabContent, activeContent, false, tabIndex);
|
|
232
|
+
//Check for expanding small items to medium items.
|
|
233
|
+
if (!isBreak && (tabContent.offsetWidth > activeContent.offsetWidth)) {
|
|
234
|
+
isBreak = this.checkGroupExpanding(tabIndex, tabContent, activeContent, true);
|
|
235
|
+
}
|
|
236
|
+
//Check for expanding medium items to large items.
|
|
237
|
+
if (!isBreak && (tabContent.offsetWidth > activeContent.offsetWidth)) {
|
|
238
|
+
isBreak = this.checkGroupExpanding(tabIndex, tabContent, activeContent, false);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
this.removeSimplfiedOverflow(tabContent, activeContent, tabIndex);
|
|
243
|
+
if (tabContent.offsetWidth > activeContent.offsetWidth) {
|
|
244
|
+
this.checkSimplifiedItemExpanding(tabIndex, tabContent, activeContent);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
Ribbon.prototype.checkSimplifiedItemShrinking = function (tabIndex, tabContent, activeContent) {
|
|
250
|
+
var tab = this.tabs[parseInt(tabIndex.toString(), 10)];
|
|
251
|
+
for (var i = (tab.groups.length - 1); (i >= 0); i--) {
|
|
252
|
+
var group = tab.groups[parseInt(i.toString(), 10)];
|
|
253
|
+
var groupContainer = tabContent.querySelector('#' + group.id + constants.CONTAINER_ID);
|
|
254
|
+
for (var j = 0; ((j < group.collections.length) && (tabContent.offsetWidth < activeContent.offsetWidth)); j++) {
|
|
255
|
+
var collection = group.collections[parseInt(j.toString(), 10)];
|
|
256
|
+
for (var k = collection.items.length; ((k >= 1) && (tabContent.offsetWidth < activeContent.offsetWidth)); k--) {
|
|
257
|
+
var item = collection.items[k - 1];
|
|
258
|
+
if (((item.allowedSizes & RibbonItemSize.Small) && (item.allowedSizes & RibbonItemSize.Medium))
|
|
259
|
+
&& (item.activeSize === RibbonItemSize.Medium) && (item.displayOptions & DisplayMode.Simplified)) {
|
|
260
|
+
var itemContainer = groupContainer.querySelector('#' + item.id + constants.CONTAINER_ID);
|
|
261
|
+
if (itemContainer) {
|
|
262
|
+
var itemEle = itemContainer.querySelector('#' + item.id);
|
|
263
|
+
itemContainer.setAttribute('data-medium-width', activeContent.offsetWidth.toString());
|
|
264
|
+
item.setProperties({ activeSize: RibbonItemSize.Small }, true);
|
|
265
|
+
this.setItemSize(itemEle, item);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
Ribbon.prototype.checkSimplifiedItemExpanding = function (tabIndex, tabContent, activeContent) {
|
|
273
|
+
var tab = this.tabs[parseInt(tabIndex.toString(), 10)];
|
|
274
|
+
for (var i = (tab.groups.length - 1); (i >= 0); i--) {
|
|
275
|
+
var group = tab.groups[parseInt(i.toString(), 10)];
|
|
276
|
+
var groupContainer = tabContent.querySelector('#' + group.id + constants.CONTAINER_ID);
|
|
277
|
+
for (var j = 0; ((j < group.collections.length) && (tabContent.offsetWidth > activeContent.offsetWidth)); j++) {
|
|
278
|
+
var collection = group.collections[parseInt(j.toString(), 10)];
|
|
279
|
+
for (var k = collection.items.length; ((k >= 1) && (tabContent.offsetWidth > activeContent.offsetWidth)); k--) {
|
|
280
|
+
var item = collection.items[k - 1];
|
|
281
|
+
if (((item.allowedSizes & RibbonItemSize.Small) && (item.allowedSizes & RibbonItemSize.Medium))
|
|
282
|
+
&& (item.activeSize === RibbonItemSize.Small) && (item.displayOptions & DisplayMode.Simplified)) {
|
|
283
|
+
var itemContainer = groupContainer.querySelector('#' + item.id + constants.CONTAINER_ID);
|
|
284
|
+
if (itemContainer) {
|
|
285
|
+
var valString = itemContainer.getAttribute('data-medium-width');
|
|
286
|
+
var value = valString ? parseInt(valString, 10) : null;
|
|
287
|
+
if (value && (tabContent.offsetWidth > value)) {
|
|
288
|
+
itemContainer.removeAttribute('data-medium-width');
|
|
289
|
+
var itemEle = itemContainer.querySelector('#' + item.id);
|
|
290
|
+
item.setProperties({ activeSize: RibbonItemSize.Medium }, true);
|
|
291
|
+
this.setItemSize(itemEle, item);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
Ribbon.prototype.createSimplfiedOverflow = function (tabContent, activeContent, tabIndex) {
|
|
300
|
+
var orderedGroups = this.getGroupResizeOrder(true, tabIndex);
|
|
301
|
+
for (var i = 0; ((i < orderedGroups.length) && (tabContent.offsetWidth < activeContent.offsetWidth)); i++) {
|
|
302
|
+
var group = orderedGroups[parseInt(i.toString(), 10)];
|
|
303
|
+
var groupEle = tabContent.querySelector('#' + group.id);
|
|
304
|
+
var groupContainer = groupEle.querySelector('#' + group.id + constants.CONTAINER_ID);
|
|
305
|
+
for (var j = 0; ((j < group.collections.length) && (tabContent.offsetWidth < activeContent.offsetWidth)); j++) {
|
|
306
|
+
var collection = group.collections[parseInt(j.toString(), 10)];
|
|
307
|
+
var collectionEle = groupEle.querySelector('#' + collection.id);
|
|
308
|
+
for (var k = collection.items.length; ((k >= 1) && (tabContent.offsetWidth < activeContent.offsetWidth)); k--) {
|
|
309
|
+
var item = collection.items[k - 1];
|
|
310
|
+
var itemContainer = collectionEle.querySelector('#' + item.id + constants.CONTAINER_ID);
|
|
311
|
+
if ((item.displayOptions === (DisplayMode.Simplified | DisplayMode.Overflow)) && !isNullOrUndefined(itemContainer)) {
|
|
312
|
+
itemContainer.setAttribute('data-simplified-width', activeContent.offsetWidth.toString());
|
|
313
|
+
this.createOverflowPopup(item, tabIndex, group.enableGroupOverflow, group.id, group.header, itemContainer, groupContainer);
|
|
314
|
+
if (item.activeSize === RibbonItemSize.Small) {
|
|
315
|
+
var itemEle = itemContainer.querySelector('#' + item.id);
|
|
316
|
+
item.setProperties({ activeSize: RibbonItemSize.Medium }, true);
|
|
317
|
+
this.setItemSize(itemEle, item);
|
|
318
|
+
}
|
|
319
|
+
if ((item.type === RibbonItemType.DropDown) || (item.type === RibbonItemType.SplitButton)) {
|
|
320
|
+
this.updatePopupItems(item, itemContainer, group.enableGroupOverflow, true);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (!(group.enableGroupOverflow || groupEle.querySelector('.' + constants.RIBBON_ITEM))) {
|
|
326
|
+
groupEle.classList.add('e-ribbon-emptyCollection');
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
Ribbon.prototype.updatePopupItems = function (item, itemEle, isGroupOF, isMenu) {
|
|
331
|
+
var dropdown = getComponent(itemEle.querySelector('#' + item.id), (item.type === RibbonItemType.DropDown) ? DropDownButton : SplitButton);
|
|
332
|
+
var dropDownPopup = dropdown.dropDown;
|
|
333
|
+
// popup is on right if (isGroupOF && isMenu)
|
|
334
|
+
// The position is reversed if RTL is enabled.
|
|
335
|
+
// isRight = ((isGroupOF && isMenu) && !this.enableRtl ) || (!(isGroupOF && isMenu) && this.enableRtl) ==> (isGroupOF && isMenu) !== this.enableRtl
|
|
336
|
+
var isLeft = (isGroupOF && isMenu) === this.enableRtl;
|
|
337
|
+
dropDownPopup.setProperties({ position: { X: isLeft ? 'left' : 'right', Y: isMenu ? 'top' : 'bottom' } }, true);
|
|
338
|
+
if (isMenu) {
|
|
339
|
+
dropdown.beforeOpen = function () {
|
|
340
|
+
if (isLeft) {
|
|
341
|
+
dropDownPopup.element.style.setProperty('visibility', 'hidden');
|
|
342
|
+
dropDownPopup.element.style.setProperty('display', 'block');
|
|
343
|
+
dropDownPopup.setProperties({ offsetX: -1 * dropDownPopup.element.offsetWidth });
|
|
344
|
+
dropDownPopup.element.style.removeProperty('display');
|
|
345
|
+
dropDownPopup.element.style.removeProperty('visibility');
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
dropDownPopup.setProperties({ offsetX: 0 }, true);
|
|
351
|
+
dropdown.beforeOpen = null;
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
Ribbon.prototype.removeSimplfiedOverflow = function (tabContent, activeContent, tabIndex, isClear) {
|
|
355
|
+
if (isClear === void 0) { isClear = false; }
|
|
356
|
+
var orderedGroups = this.getGroupResizeOrder(false, tabIndex);
|
|
357
|
+
var flag = true;
|
|
358
|
+
for (var i = 0; ((i < orderedGroups.length) && flag); i++) {
|
|
359
|
+
var group = orderedGroups[parseInt(i.toString(), 10)];
|
|
360
|
+
var overflowDDB = void 0;
|
|
361
|
+
var overflowtarget = void 0;
|
|
362
|
+
if (group.enableGroupOverflow) {
|
|
363
|
+
var overflowDDBEle = tabContent.querySelector('#' + group.id + constants.GROUPOF_BUTTON_ID);
|
|
364
|
+
if (overflowDDBEle) {
|
|
365
|
+
overflowDDB = getInstance(overflowDDBEle, DropDownButton);
|
|
366
|
+
overflowtarget = overflowDDB.target;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
overflowDDB = this.overflowDDB;
|
|
371
|
+
overflowtarget = this.overflowDDB ? this.overflowDDB.target : null;
|
|
372
|
+
}
|
|
373
|
+
for (var j = (group.collections.length); ((j >= 1) && flag); j--) {
|
|
374
|
+
var collection = group.collections[parseInt((j - 1).toString(), 10)];
|
|
375
|
+
// eslint-disable-next-line max-len
|
|
376
|
+
for (var k = 0; ((k < collection.items.length) && flag && !isClear && (tabContent.offsetWidth > activeContent.offsetWidth)); k++) {
|
|
377
|
+
var item = collection.items[parseInt(k.toString(), 10)];
|
|
378
|
+
var itemContainer = void 0;
|
|
379
|
+
if (overflowtarget) {
|
|
380
|
+
itemContainer = overflowtarget.querySelector('#' + item.id + constants.CONTAINER_ID);
|
|
381
|
+
}
|
|
382
|
+
if ((item.displayOptions === (DisplayMode.Simplified | DisplayMode.Overflow)) && !isNullOrUndefined(itemContainer)) {
|
|
383
|
+
var width = parseInt(itemContainer.getAttribute('data-simplified-width'), 10);
|
|
384
|
+
if (!isClear && (tabContent.offsetWidth < width)) {
|
|
385
|
+
flag = false;
|
|
386
|
+
break;
|
|
387
|
+
}
|
|
388
|
+
var groupEle_1 = tabContent.querySelector('#' + collection.id);
|
|
389
|
+
if ((item.type === RibbonItemType.DropDown) || (item.type === RibbonItemType.SplitButton)) {
|
|
390
|
+
this.updatePopupItems(item, itemContainer, group.enableGroupOverflow, false);
|
|
391
|
+
}
|
|
392
|
+
groupEle_1.append(itemContainer);
|
|
393
|
+
this.removeOverflowEvent(item, itemContainer);
|
|
394
|
+
if (item.allowedSizes & RibbonItemSize.Small) {
|
|
395
|
+
item.setProperties({ activeSize: RibbonItemSize.Small }, true);
|
|
396
|
+
this.setItemSize(itemContainer.querySelector('#' + item.id), item);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
var groupEle = tabContent.querySelector('#' + group.id);
|
|
402
|
+
var itemEle = groupEle.querySelector('.' + constants.RIBBON_ITEM);
|
|
403
|
+
if (groupEle.classList.contains('e-ribbon-emptyCollection') && itemEle !== null) {
|
|
404
|
+
groupEle.classList.remove('e-ribbon-emptyCollection');
|
|
405
|
+
}
|
|
406
|
+
if (overflowDDB) {
|
|
407
|
+
if (group.enableGroupOverflow) {
|
|
408
|
+
if (overflowtarget.childElementCount === 0) {
|
|
409
|
+
this.removeOverflowButton(overflowDDB);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
var ofGroupContainer = overflowtarget.querySelector('#' + group.id + constants.CONTAINER_ID);
|
|
414
|
+
if (ofGroupContainer && ofGroupContainer.childElementCount === 1) {
|
|
415
|
+
ofGroupContainer.remove();
|
|
416
|
+
}
|
|
417
|
+
var ofTabContainer = overflowtarget.querySelector('#' + this.tabs[parseInt(tabIndex.toString(), 10)].id + constants.OVERFLOW_ID);
|
|
418
|
+
if (ofTabContainer && ofTabContainer.childElementCount === 0) {
|
|
419
|
+
ofTabContainer.remove();
|
|
420
|
+
this.overflowDDB.element.classList.add(constants.HIDE_CSS);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
if (this.overflowDDB) {
|
|
426
|
+
var overflowEle = this.overflowDDB.target;
|
|
427
|
+
if (overflowEle.childElementCount === 0) {
|
|
428
|
+
this.removeOverflowButton(this.overflowDDB);
|
|
429
|
+
this.overflowDDB = null;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
Ribbon.prototype.createOverflowPopup = function (item, tabIndex, isGroupOF, groupId, groupHeader, itemEle, groupContainer) {
|
|
434
|
+
var overflowButton;
|
|
435
|
+
if (isGroupOF) {
|
|
436
|
+
var overflowDDB = groupContainer.querySelector('#' + groupId + constants.GROUPOF_BUTTON_ID);
|
|
437
|
+
if (!overflowDDB) {
|
|
438
|
+
overflowButton = this.addOverflowButton(groupId + constants.GROUPOF_BUTTON_ID);
|
|
439
|
+
overflowButton.element.classList.add(constants.RIBBON_GROUP_OF_BUTTON);
|
|
440
|
+
groupContainer.appendChild(overflowButton.element);
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
overflowButton = getInstance(overflowDDB, DropDownButton);
|
|
444
|
+
}
|
|
445
|
+
overflowButton.target.append(itemEle);
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
448
|
+
if (!this.overflowDDB) {
|
|
449
|
+
this.overflowDDB = this.addOverflowButton(this.tabObj.element.id + constants.OVRLOF_BUTTON_ID);
|
|
450
|
+
this.tabObj.element.insertBefore(this.overflowDDB.element, this.collapseButton);
|
|
451
|
+
this.overflowDDB.element.classList.add(constants.RIBBON_OVERALL_OF_BUTTON);
|
|
452
|
+
this.createOfTabContainer(groupId, groupHeader, itemEle, tabIndex);
|
|
453
|
+
}
|
|
454
|
+
else {
|
|
455
|
+
this.overflowDDB.element.classList.remove(constants.HIDE_CSS);
|
|
456
|
+
var overflowEle = this.overflowDDB.target;
|
|
457
|
+
var ofTabContainer = overflowEle.querySelector('#' + this.tabs[parseInt(tabIndex.toString(), 10)].id + constants.OVERFLOW_ID);
|
|
458
|
+
if (ofTabContainer) {
|
|
459
|
+
var ofGroupContainer = overflowEle.querySelector('#' + groupId + constants.CONTAINER_ID);
|
|
460
|
+
if (!ofGroupContainer) {
|
|
461
|
+
ofGroupContainer = this.createGroupContainer(groupId, groupHeader);
|
|
462
|
+
ofTabContainer.append(ofGroupContainer);
|
|
463
|
+
}
|
|
464
|
+
ofGroupContainer.append(itemEle);
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
this.createOfTabContainer(groupId, groupHeader, itemEle, tabIndex);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
overflowButton = this.overflowDDB;
|
|
471
|
+
}
|
|
472
|
+
this.addOverflowEvents(item, itemEle, overflowButton);
|
|
473
|
+
};
|
|
474
|
+
Ribbon.prototype.addOverflowEvents = function (item, itemEle, overflowButton) {
|
|
475
|
+
switch (item.type) {
|
|
476
|
+
case 'Button':
|
|
477
|
+
this.ribbonButtonModule.addOverFlowEvents(item, itemEle, overflowButton);
|
|
478
|
+
break;
|
|
479
|
+
case 'DropDown':
|
|
480
|
+
this.ribbonDropDownModule.addOverFlowEvents(item, itemEle, overflowButton);
|
|
481
|
+
break;
|
|
482
|
+
case 'SplitButton':
|
|
483
|
+
this.ribbonSplitButtonModule.addOverFlowEvents(item, itemEle, overflowButton);
|
|
484
|
+
break;
|
|
485
|
+
case 'CheckBox':
|
|
486
|
+
this.ribbonCheckBoxModule.addOverFlowEvents(item, itemEle, overflowButton);
|
|
487
|
+
break;
|
|
488
|
+
case 'ColorPicker':
|
|
489
|
+
this.ribbonColorPickerModule.addOverFlowEvents(item, itemEle, overflowButton);
|
|
490
|
+
break;
|
|
491
|
+
case 'ComboBox':
|
|
492
|
+
this.ribbonComboBoxModule.addOverFlowEvents(item, itemEle, overflowButton);
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
Ribbon.prototype.createOfTabContainer = function (groupId, groupHeader, itemEle, tabIndex) {
|
|
497
|
+
var ofTabContainer = this.createElement('div', {
|
|
498
|
+
id: this.tabs[parseInt(tabIndex.toString(), 10)].id + constants.OVERFLOW_ID,
|
|
499
|
+
className: constants.RIBBON_OF_TAB_CONTAINER
|
|
500
|
+
});
|
|
501
|
+
var overflowtarget = this.overflowDDB.target;
|
|
502
|
+
overflowtarget.append(ofTabContainer);
|
|
503
|
+
var ofGroupContainer = this.createGroupContainer(groupId, groupHeader);
|
|
504
|
+
ofGroupContainer.append(itemEle);
|
|
505
|
+
ofTabContainer.append(ofGroupContainer);
|
|
506
|
+
if (tabIndex === this.selectedTab) {
|
|
507
|
+
ofTabContainer.classList.add(constants.RIBBON_TAB_ACTIVE);
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
Ribbon.prototype.checkGroupShrinking = function (tabIndex, tabContent, activeContent, isLarge) {
|
|
511
|
+
var isOverFlow = true;
|
|
512
|
+
var isBreak = false;
|
|
513
|
+
var tab = this.tabs[parseInt(tabIndex.toString(), 10)];
|
|
514
|
+
for (var j = (tab.groups.length - 1); (isOverFlow && (j >= 0)); j--) {
|
|
515
|
+
// eslint-disable-next-line max-len
|
|
516
|
+
isBreak = isLarge ? this.checkLargeToMedium(tabIndex, tab, j, tabContent, activeContent) : this.checkMediumToSmall(tabIndex, tab, j, tabContent, activeContent);
|
|
517
|
+
isOverFlow = !isBreak && (tabContent.offsetWidth < activeContent.offsetWidth);
|
|
518
|
+
}
|
|
519
|
+
return isBreak;
|
|
520
|
+
};
|
|
521
|
+
Ribbon.prototype.checkLargeToMedium = function (tabIndex, tab, groupIndex, tabContent, activeContent, shouldSkip) {
|
|
522
|
+
var _this = this;
|
|
523
|
+
if (shouldSkip === void 0) { shouldSkip = false; }
|
|
524
|
+
var group = tab.groups[parseInt(groupIndex.toString(), 10)];
|
|
525
|
+
if (group.isCollapsed && !shouldSkip) {
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
var canReduceCollection = function (collection) {
|
|
529
|
+
return (collection.items.length === 1) && canReduceItem(collection.items[0]);
|
|
530
|
+
};
|
|
531
|
+
var canReduceItem = function (item) {
|
|
532
|
+
return (item.allowedSizes & RibbonItemSize.Medium) && (item.activeSize === RibbonItemSize.Large);
|
|
533
|
+
};
|
|
534
|
+
var createShrinkEle = function (id, firstItem, start, end) {
|
|
535
|
+
var shrinkEle = _this.createElement('div', {
|
|
536
|
+
className: 'e-ribbon-shrink' + constants.SPACE + constants.RIBBON_ROW,
|
|
537
|
+
id: id + '_shrink_container' + start,
|
|
538
|
+
attrs: { 'data-start': start.toString(), 'data-end': end.toString() }
|
|
539
|
+
});
|
|
540
|
+
firstItem.parentElement.insertBefore(shrinkEle, firstItem);
|
|
541
|
+
if (!shouldSkip) {
|
|
542
|
+
shrinkEle.setAttribute('data-large-width', activeContent.offsetWidth.toString());
|
|
543
|
+
}
|
|
544
|
+
return shrinkEle;
|
|
545
|
+
};
|
|
546
|
+
var moveItemToColumn = function (start, end) {
|
|
547
|
+
var collection = _this.tabs[parseInt(tabIndex.toString(), 10)]
|
|
548
|
+
.groups[parseInt(groupIndex.toString(), 10)].collections[0];
|
|
549
|
+
var firstItem = activeContent.querySelector('#' + collection.items[parseInt(start.toString(), 10)].id + constants.CONTAINER_ID);
|
|
550
|
+
var shrinkEle = shouldSkip ? activeContent.querySelector('#' + collection.id + '_shrink_container' + start) :
|
|
551
|
+
createShrinkEle(collection.id, firstItem, start, end);
|
|
552
|
+
for (var i = start; i <= end; i++) {
|
|
553
|
+
var item = collection.items[parseInt(i.toString(), 10)];
|
|
554
|
+
var ele = activeContent.querySelector('#' + item.id + constants.CONTAINER_ID);
|
|
555
|
+
shrinkEle.appendChild(ele);
|
|
556
|
+
item.setProperties({ activeSize: RibbonItemSize.Medium }, true);
|
|
557
|
+
_this.setItemSize(ele.querySelector('#' + item.id), item);
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
var moveCollectionToColumn = function (start, end) {
|
|
561
|
+
var group = _this.tabs[parseInt(tabIndex.toString(), 10)]
|
|
562
|
+
.groups[parseInt(groupIndex.toString(), 10)];
|
|
563
|
+
var firstItem = activeContent.querySelector('#' + group.collections[parseInt(start.toString(), 10)].id);
|
|
564
|
+
var shrinkEle = shouldSkip ? activeContent.querySelector('#' + group.id + '_shrink_container' + start) :
|
|
565
|
+
createShrinkEle(group.id, firstItem, start, end);
|
|
566
|
+
for (var i = start; i <= end; i++) {
|
|
567
|
+
var collection = group.collections[parseInt(i.toString(), 10)];
|
|
568
|
+
var ele = activeContent.querySelector('#' + collection.id);
|
|
569
|
+
shrinkEle.appendChild(ele);
|
|
570
|
+
collection.items[0].setProperties({ activeSize: RibbonItemSize.Medium }, true);
|
|
571
|
+
_this.setItemSize(ele.querySelector('#' + collection.items[0].id), collection.items[0]);
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
var orientation = group.orientation;
|
|
575
|
+
if (orientation === ItemOrientation.Column) {
|
|
576
|
+
for (var k = (group.collections.length - 1); k > 0; k--) {
|
|
577
|
+
//to avoid negative index while checking for the second collection
|
|
578
|
+
if (((k - 1) >= 0) && canReduceCollection(group.collections[parseInt(k.toString(), 10)])) {
|
|
579
|
+
if (canReduceCollection(group.collections[k - 1])) {
|
|
580
|
+
if (((k - 2) >= 0) && canReduceCollection(group.collections[k - 2])) {
|
|
581
|
+
moveCollectionToColumn(k - 2, k);
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
moveCollectionToColumn(k - 1, k);
|
|
585
|
+
}
|
|
586
|
+
k -= 2;
|
|
587
|
+
if (!shouldSkip && (tabContent.offsetWidth > activeContent.offsetWidth)) {
|
|
588
|
+
return true;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
k--;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
else {
|
|
598
|
+
if (group.collections.length === 1) {
|
|
599
|
+
var collection = group.collections[0];
|
|
600
|
+
for (var k = (collection.items.length - 1); k > 0; k--) {
|
|
601
|
+
//to avoid negative index while checking for the second item
|
|
602
|
+
if (((k - 1) >= 0) && canReduceItem(collection.items[parseInt(k.toString(), 10)])) {
|
|
603
|
+
if (canReduceItem(collection.items[k - 1])) {
|
|
604
|
+
if (((k - 2) >= 0) && canReduceItem(collection.items[k - 2])) {
|
|
605
|
+
moveItemToColumn(k - 2, k);
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
moveItemToColumn(k - 1, k);
|
|
609
|
+
}
|
|
610
|
+
k -= 2;
|
|
611
|
+
if (!shouldSkip && (tabContent.offsetWidth > activeContent.offsetWidth)) {
|
|
612
|
+
return true;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
else {
|
|
616
|
+
k--;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return false;
|
|
623
|
+
};
|
|
624
|
+
Ribbon.prototype.checkMediumToSmall = function (tabIndex, tab, groupIndex, tabContent, activeContent, shouldSkip) {
|
|
625
|
+
var _this = this;
|
|
626
|
+
if (shouldSkip === void 0) { shouldSkip = false; }
|
|
627
|
+
var group = tab.groups[parseInt(groupIndex.toString(), 10)];
|
|
628
|
+
if (group.isCollapsed && !shouldSkip) {
|
|
629
|
+
return false;
|
|
630
|
+
}
|
|
631
|
+
var orientation = group.orientation;
|
|
632
|
+
var ele = activeContent.querySelector('#' + group.id);
|
|
633
|
+
var shrinkColumns = ele.querySelectorAll('.' + 'e-ribbon-shrink');
|
|
634
|
+
var canReduceItem = function (item) {
|
|
635
|
+
return (item.allowedSizes & RibbonItemSize.Small) && (item.activeSize === RibbonItemSize.Medium);
|
|
636
|
+
};
|
|
637
|
+
var reduceItemsToSmall = function (collectionIndex, start, end) {
|
|
638
|
+
var collection = _this.tabs[parseInt(tabIndex.toString(), 10)]
|
|
639
|
+
.groups[parseInt(groupIndex.toString(), 10)].collections[parseInt(collectionIndex.toString(), 10)];
|
|
640
|
+
for (var i = start; i <= end; i++) {
|
|
641
|
+
var item = collection.items[parseInt(i.toString(), 10)];
|
|
642
|
+
var ele_1 = activeContent.querySelector('#' + item.id);
|
|
643
|
+
item.setProperties({ activeSize: RibbonItemSize.Small }, true);
|
|
644
|
+
_this.setItemSize(ele_1, item);
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
var reduceCollectionsToSmall = function (index, start, end) {
|
|
648
|
+
var group = _this.tabs[parseInt(tabIndex.toString(), 10)]
|
|
649
|
+
.groups[parseInt(groupIndex.toString(), 10)];
|
|
650
|
+
if (!shouldSkip) {
|
|
651
|
+
shrinkColumns[parseInt(index.toString(), 10)].setAttribute('data-medium-width', activeContent.offsetWidth.toString());
|
|
652
|
+
}
|
|
653
|
+
for (var i = start; i <= end; i++) {
|
|
654
|
+
var collection = group.collections[parseInt(i.toString(), 10)];
|
|
655
|
+
var ele_2 = activeContent.querySelector('#' + collection.items[0].id);
|
|
656
|
+
collection.items[0].setProperties({ activeSize: RibbonItemSize.Small }, true);
|
|
657
|
+
_this.setItemSize(ele_2, collection.items[0]);
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
var setWidth = function (id) {
|
|
661
|
+
if (!shouldSkip) {
|
|
662
|
+
var ele_3 = activeContent.querySelector('#' + id);
|
|
663
|
+
ele_3.setAttribute('data-medium-width', activeContent.offsetWidth.toString());
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
if (orientation === ItemOrientation.Column) {
|
|
667
|
+
if (shrinkColumns.length > 0) {
|
|
668
|
+
for (var k = (shrinkColumns.length - 1); k >= 0; k--) {
|
|
669
|
+
var start = parseInt(shrinkColumns[parseInt(k.toString(), 10)].getAttribute('data-start'), 10);
|
|
670
|
+
var end = parseInt(shrinkColumns[parseInt(k.toString(), 10)].getAttribute('data-end'), 10);
|
|
671
|
+
//only 2 or 3 itmes alone can be present in shrinked column
|
|
672
|
+
if (canReduceItem(group.collections[parseInt(start.toString(), 10)].items[0])
|
|
673
|
+
&& canReduceItem(group.collections[start + 1].items[0])) {
|
|
674
|
+
if ((end - start) === 1) { //if only 2 item, the difference will be 1, else check for 3 rd item satus.
|
|
675
|
+
reduceCollectionsToSmall(k, start, end);
|
|
676
|
+
}
|
|
677
|
+
else if (canReduceItem(group.collections[parseInt(start.toString(), 10)].items[0])) {
|
|
678
|
+
reduceCollectionsToSmall(k, start, end);
|
|
679
|
+
}
|
|
680
|
+
if (!shouldSkip && (tabContent.offsetWidth > activeContent.offsetWidth)) {
|
|
681
|
+
return true;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
for (var k = (group.collections.length - 1); k >= 0; k--) {
|
|
687
|
+
var collection = group.collections[parseInt(k.toString(), 10)];
|
|
688
|
+
//If items length is 1 then, it would have been already check for shrinked column
|
|
689
|
+
if ((collection.items.length > 1)) {
|
|
690
|
+
if (canReduceItem(collection.items[0]) && canReduceItem(collection.items[1])) {
|
|
691
|
+
if (collection.items.length === 2) {
|
|
692
|
+
setWidth(collection.id);
|
|
693
|
+
reduceItemsToSmall(k, 0, 1);
|
|
694
|
+
}
|
|
695
|
+
else if (canReduceItem(collection.items[2])) {
|
|
696
|
+
setWidth(collection.id);
|
|
697
|
+
reduceItemsToSmall(k, 0, 2);
|
|
698
|
+
}
|
|
699
|
+
if (!shouldSkip && (tabContent.offsetWidth > activeContent.offsetWidth)) {
|
|
700
|
+
return true;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
else {
|
|
707
|
+
if (group.collections.length === 1) {
|
|
708
|
+
if (shrinkColumns.length > 0) {
|
|
709
|
+
for (var k = (shrinkColumns.length - 1); k >= 0; k--) {
|
|
710
|
+
var shrinkColumn = shrinkColumns[parseInt(k.toString(), 10)];
|
|
711
|
+
var start = parseInt(shrinkColumn.getAttribute('data-start'), 10);
|
|
712
|
+
var end = parseInt(shrinkColumn.getAttribute('data-end'), 10);
|
|
713
|
+
//only 2 or 3 itmes alone can be present in shrinked column
|
|
714
|
+
if (canReduceItem(group.collections[0].items[parseInt(start.toString(), 10)])
|
|
715
|
+
&& canReduceItem(group.collections[0].items[start + 1])) {
|
|
716
|
+
if ((end - start) === 1) { //if only 2 item, the difference will be 1, else check for 3 rd item satus.
|
|
717
|
+
setWidth(shrinkColumn.id);
|
|
718
|
+
reduceItemsToSmall(0, start, end);
|
|
719
|
+
}
|
|
720
|
+
else if (canReduceItem(group.collections[0].items[parseInt(end.toString(), 10)])) {
|
|
721
|
+
setWidth(shrinkColumn.id);
|
|
722
|
+
reduceItemsToSmall(0, start, end);
|
|
723
|
+
}
|
|
724
|
+
if (!shouldSkip && (tabContent.offsetWidth > activeContent.offsetWidth)) {
|
|
725
|
+
return true;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
else {
|
|
732
|
+
for (var k = (group.collections.length - 1); k >= 0; k--) {
|
|
733
|
+
var collection = group.collections[parseInt(k.toString(), 10)];
|
|
734
|
+
for (var l = (collection.items.length - 1); l >= 0; l--) {
|
|
735
|
+
var item = collection.items[parseInt(l.toString(), 10)];
|
|
736
|
+
if (canReduceItem(item)) {
|
|
737
|
+
setWidth(item.id);
|
|
738
|
+
reduceItemsToSmall(k, l, l);
|
|
739
|
+
if (!shouldSkip && (tabContent.offsetWidth > activeContent.offsetWidth)) {
|
|
740
|
+
return true;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
return false;
|
|
748
|
+
};
|
|
749
|
+
Ribbon.prototype.checkGroupExpanding = function (tabIndex, tabContent, activeContent, isSmall) {
|
|
750
|
+
var isBreak = false;
|
|
751
|
+
var tab = this.tabs[parseInt(tabIndex.toString(), 10)];
|
|
752
|
+
for (var j = 0; (!isBreak && (j < tab.groups.length)); j++) {
|
|
753
|
+
isBreak = isSmall ? this.checkSmallToMedium(tabIndex, tab, j, tabContent, activeContent, false, true) :
|
|
754
|
+
this.checkMediumToLarge(tabIndex, tab, j, tabContent, activeContent, false, true);
|
|
755
|
+
}
|
|
756
|
+
return isBreak;
|
|
757
|
+
};
|
|
758
|
+
// eslint-disable-next-line max-len
|
|
759
|
+
Ribbon.prototype.checkSmallToMedium = function (tabIndex, tab, groupIndex, tabContent, activeContent, shouldSkip, shouldClear) {
|
|
760
|
+
var _this = this;
|
|
761
|
+
var group = tab.groups[parseInt(groupIndex.toString(), 10)];
|
|
762
|
+
var orientation = group.orientation;
|
|
763
|
+
var ele = activeContent.querySelector('#' + group.id);
|
|
764
|
+
var shrinkColumns = ele.querySelectorAll('.' + 'e-ribbon-shrink');
|
|
765
|
+
var canExpandItem = function (item) {
|
|
766
|
+
return (item.allowedSizes & RibbonItemSize.Medium) && (item.activeSize === RibbonItemSize.Small);
|
|
767
|
+
};
|
|
768
|
+
var expandItemsToMedium = function (collectionIndex, start, end, parentEle) {
|
|
769
|
+
var collection = _this.tabs[parseInt(tabIndex.toString(), 10)]
|
|
770
|
+
.groups[parseInt(groupIndex.toString(), 10)].collections[parseInt(collectionIndex.toString(), 10)];
|
|
771
|
+
for (var i = start; i <= end; i++) {
|
|
772
|
+
var item = collection.items[parseInt(i.toString(), 10)];
|
|
773
|
+
var ele_4 = parentEle.id === item.id ? parentEle : parentEle.querySelector('#' + item.id);
|
|
774
|
+
item.setProperties({ activeSize: RibbonItemSize.Medium }, true);
|
|
775
|
+
_this.setItemSize(ele_4, item);
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
var expandCollectionsToMedium = function (start, end) {
|
|
779
|
+
var collections = _this.tabs[parseInt(tabIndex.toString(), 10)]
|
|
780
|
+
.groups[parseInt(groupIndex.toString(), 10)].collections;
|
|
781
|
+
for (var i = start; i <= end; i++) {
|
|
782
|
+
var ele_5 = activeContent.querySelector('#' + collections[parseInt(i.toString(), 10)].items[0].id);
|
|
783
|
+
collections[parseInt(i.toString(), 10)].items[0].setProperties({ activeSize: RibbonItemSize.Medium }, true);
|
|
784
|
+
_this.setItemSize(ele_5, collections[parseInt(i.toString(), 10)].items[0]);
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
if (orientation === ItemOrientation.Row) {
|
|
788
|
+
// collection length is 1, then the it wll be covered in shrinked columns
|
|
789
|
+
if (group.collections.length !== 1) {
|
|
790
|
+
for (var k = 0; k < group.collections.length; k++) {
|
|
791
|
+
var collection = group.collections[parseInt(k.toString(), 10)];
|
|
792
|
+
for (var l = 0; l < collection.items.length; l++) {
|
|
793
|
+
var item = collection.items[parseInt(l.toString(), 10)];
|
|
794
|
+
if (canExpandItem(item)) {
|
|
795
|
+
var itemEle = activeContent.querySelector('#' + item.id);
|
|
796
|
+
var valString = itemEle.getAttribute('data-medium-width');
|
|
797
|
+
var value = valString ? parseInt(valString, 10) : null;
|
|
798
|
+
if (value && (shouldSkip || (tabContent.offsetWidth > value))) {
|
|
799
|
+
expandItemsToMedium(k, l, l, itemEle);
|
|
800
|
+
if (!shouldSkip || shouldClear) {
|
|
801
|
+
itemEle.removeAttribute('data-medium-width');
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
else if (value) {
|
|
805
|
+
return true;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
else {
|
|
813
|
+
for (var k = 0; k < group.collections.length; k++) {
|
|
814
|
+
//If items length is 1 then, it will be handled in shrinked column
|
|
815
|
+
if ((group.collections[parseInt(k.toString(), 10)].items.length > 1)) {
|
|
816
|
+
var collection = group.collections[parseInt(k.toString(), 10)];
|
|
817
|
+
var itemEle = activeContent.querySelector('#' + collection.id);
|
|
818
|
+
var valString = itemEle.getAttribute('data-medium-width');
|
|
819
|
+
var value = valString ? parseInt(valString, 10) : null;
|
|
820
|
+
if (value && (shouldSkip || (tabContent.offsetWidth > value))) {
|
|
821
|
+
expandItemsToMedium(k, 0, (collection.items.length === 2) ? 1 : 2, itemEle);
|
|
822
|
+
if (!shouldSkip || shouldClear) {
|
|
823
|
+
itemEle.removeAttribute('data-medium-width');
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
else if (value) {
|
|
827
|
+
return true;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
if (shrinkColumns.length > 0) {
|
|
833
|
+
for (var k = 0; k < shrinkColumns.length; k++) {
|
|
834
|
+
var shrinkColumn = shrinkColumns[parseInt(k.toString(), 10)];
|
|
835
|
+
var valString = shrinkColumn.getAttribute('data-medium-width');
|
|
836
|
+
var value = valString ? parseInt(valString, 10) : null;
|
|
837
|
+
if (value && (shouldSkip || (tabContent.offsetWidth > value))) {
|
|
838
|
+
var start = parseInt(shrinkColumn.getAttribute('data-start'), 10);
|
|
839
|
+
var end = parseInt(shrinkColumn.getAttribute('data-end'), 10);
|
|
840
|
+
if (orientation === ItemOrientation.Row) {
|
|
841
|
+
expandItemsToMedium(0, start, end, shrinkColumn);
|
|
842
|
+
}
|
|
843
|
+
else {
|
|
844
|
+
expandCollectionsToMedium(start, end);
|
|
845
|
+
}
|
|
846
|
+
if (!shouldSkip || shouldClear) {
|
|
847
|
+
shrinkColumn.removeAttribute('data-medium-width');
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
else if (value) {
|
|
851
|
+
return true;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
return false;
|
|
856
|
+
};
|
|
857
|
+
Ribbon.prototype.checkMediumToLarge = function (tabIndex, tab, groupIndex, tabContent, activeContent, shouldSkip, shouldClear) {
|
|
858
|
+
var _this = this;
|
|
859
|
+
var group = tab.groups[parseInt(groupIndex.toString(), 10)];
|
|
860
|
+
var orientation = group.orientation;
|
|
861
|
+
var ele = activeContent.querySelector('#' + group.id);
|
|
862
|
+
var shrinkColumns = ele.querySelectorAll('.' + 'e-ribbon-shrink');
|
|
863
|
+
if (shrinkColumns.length === 0) {
|
|
864
|
+
return false;
|
|
865
|
+
}
|
|
866
|
+
var expandItemsToLarge = function (start, end, parentEle) {
|
|
867
|
+
var items = _this.tabs[parseInt(tabIndex.toString(), 10)].
|
|
868
|
+
groups[parseInt(groupIndex.toString(), 10)].collections[0].items;
|
|
869
|
+
for (var i = end; i >= start; i--) {
|
|
870
|
+
var item = items[parseInt(i.toString(), 10)];
|
|
871
|
+
var container = parentEle.querySelector('#' + item.id + constants.CONTAINER_ID);
|
|
872
|
+
var ele_6 = container.querySelector('#' + item.id);
|
|
873
|
+
item.setProperties({ activeSize: RibbonItemSize.Large }, true);
|
|
874
|
+
_this.setItemSize(ele_6, item);
|
|
875
|
+
parentEle.insertAdjacentElement('afterend', container);
|
|
876
|
+
}
|
|
877
|
+
if (!shouldSkip || shouldClear) {
|
|
878
|
+
remove(parentEle);
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
var expandCollectionsToLarge = function (start, end, parentEle) {
|
|
882
|
+
var collections = _this.tabs[parseInt(tabIndex.toString(), 10)].
|
|
883
|
+
groups[parseInt(groupIndex.toString(), 10)].collections;
|
|
884
|
+
for (var i = end; i >= start; i--) {
|
|
885
|
+
var collection = collections[parseInt(i.toString(), 10)];
|
|
886
|
+
var collectionEle = parentEle.querySelector('#' + collection.id);
|
|
887
|
+
var ele_7 = collectionEle.querySelector('#' + collection.items[0].id);
|
|
888
|
+
collection.items[0].setProperties({ activeSize: RibbonItemSize.Large }, true);
|
|
889
|
+
_this.setItemSize(ele_7, collection.items[0]);
|
|
890
|
+
parentEle.insertAdjacentElement('afterend', collectionEle);
|
|
891
|
+
}
|
|
892
|
+
if (!shouldSkip || shouldClear) {
|
|
893
|
+
remove(parentEle);
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
for (var k = 0; k < shrinkColumns.length; k++) {
|
|
897
|
+
var shrinkColumn = shrinkColumns[parseInt(k.toString(), 10)];
|
|
898
|
+
var valString = shrinkColumn.getAttribute('data-large-width');
|
|
899
|
+
var value = valString ? parseInt(valString, 10) : null;
|
|
900
|
+
if (value && (shouldSkip || (tabContent.offsetWidth > value))) {
|
|
901
|
+
var start = parseInt(shrinkColumn.getAttribute('data-start'), 10);
|
|
902
|
+
var end = parseInt(shrinkColumn.getAttribute('data-end'), 10);
|
|
903
|
+
if (orientation === ItemOrientation.Row) {
|
|
904
|
+
expandItemsToLarge(start, end, shrinkColumn);
|
|
905
|
+
}
|
|
906
|
+
else {
|
|
907
|
+
expandCollectionsToLarge(start, end, shrinkColumn);
|
|
908
|
+
}
|
|
909
|
+
if (!shouldSkip || shouldClear) {
|
|
910
|
+
shrinkColumn.removeAttribute('data-large-width');
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
else if (value) {
|
|
914
|
+
return true;
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
return false;
|
|
918
|
+
};
|
|
919
|
+
Ribbon.prototype.setItemSize = function (itemEle, item) {
|
|
920
|
+
var itemContainer = itemEle.closest('.' + constants.RIBBON_ITEM);
|
|
921
|
+
if (item.type === RibbonItemType.Button) {
|
|
922
|
+
this.ribbonButtonModule.updateButtonSize(itemEle, item);
|
|
923
|
+
}
|
|
924
|
+
else if (item.type === RibbonItemType.DropDown) {
|
|
925
|
+
this.ribbonDropDownModule.updateDropDownSize(itemEle, item);
|
|
926
|
+
}
|
|
927
|
+
else if (item.type === RibbonItemType.SplitButton) {
|
|
928
|
+
this.ribbonSplitButtonModule.updateSplitButtonSize(itemEle, item);
|
|
929
|
+
}
|
|
930
|
+
else if (item.type === RibbonItemType.Template) {
|
|
931
|
+
remove(itemEle);
|
|
932
|
+
this.createTemplateContent(item, itemContainer);
|
|
933
|
+
}
|
|
934
|
+
itemContainer.classList.remove(constants.RIBBON_CONTENT_HEIGHT, constants.RIBBON_LARGE_ITEM, constants.RIBBON_MEDIUM_ITEM, constants.RIBBON_SMALL_ITEM);
|
|
935
|
+
if (item.activeSize === RibbonItemSize.Large) {
|
|
936
|
+
itemContainer.classList.add(constants.RIBBON_LARGE_ITEM, constants.RIBBON_CONTENT_HEIGHT);
|
|
937
|
+
}
|
|
938
|
+
else {
|
|
939
|
+
itemContainer.classList.add((item.activeSize === RibbonItemSize.Medium) ?
|
|
940
|
+
constants.RIBBON_MEDIUM_ITEM : constants.RIBBON_SMALL_ITEM);
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
Ribbon.prototype.createOverflowDropdown = function (tabIndex, tabContent, activeContent) {
|
|
944
|
+
var collapseOrder = this.getGroupResizeOrder(true, tabIndex);
|
|
945
|
+
if (collapseOrder.length === 0) {
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
var _loop_1 = function (i) {
|
|
949
|
+
var group = collapseOrder[parseInt(i.toString(), 10)];
|
|
950
|
+
var groupEle = this_1.tabObj.element.querySelector('#' + group.id);
|
|
951
|
+
groupEle.setAttribute('data-expanded-width', activeContent.offsetWidth.toString());
|
|
952
|
+
var groupContainer = groupEle.querySelector('#' + group.id + constants.CONTAINER_ID);
|
|
953
|
+
var groupOverFlow = this_1.createElement('div', {
|
|
954
|
+
className: constants.RIBBON_GROUP_OVERFLOW + constants.SPACE + constants.RIBBON_LARGE_ITEM,
|
|
955
|
+
id: group.id + constants.OVERFLOW_ID + constants.CONTAINER_ID
|
|
956
|
+
});
|
|
957
|
+
groupEle.insertBefore(groupOverFlow, groupContainer);
|
|
958
|
+
var groupIndex = getIndex(this_1.tabs[parseInt(tabIndex.toString(), 10)].groups, function (e) { return e.id === group.id; });
|
|
959
|
+
var tab = this_1.tabs[parseInt(tabIndex.toString(), 10)];
|
|
960
|
+
//Expanding the items in the group to their original expanded state
|
|
961
|
+
this_1.checkSmallToMedium(tabIndex, tab, groupIndex, tabContent, activeContent, true, false);
|
|
962
|
+
this_1.checkMediumToLarge(tabIndex, tab, groupIndex, tabContent, activeContent, true, false);
|
|
963
|
+
var dropdown = this_1.ribbonDropDownModule.createOverFlowDropDown(group.id, group.header, group.groupIconCss, groupContainer, groupOverFlow);
|
|
964
|
+
this_1.tabs[parseInt(tabIndex.toString(), 10)].
|
|
965
|
+
groups[parseInt(groupIndex.toString(), 10)].setProperties({ isCollapsed: true }, true);
|
|
966
|
+
for (var j = 0; j < group.collections.length; j++) {
|
|
967
|
+
var collection = group.collections[parseInt(j.toString(), 10)];
|
|
968
|
+
var collectionEle = groupContainer.querySelector('#' + collection.id);
|
|
969
|
+
for (var k = 0; k < collection.items.length; k++) {
|
|
970
|
+
var item = collection.items[parseInt(k.toString(), 10)];
|
|
971
|
+
var itemEle = collectionEle.querySelector('#' + item.id + constants.CONTAINER_ID);
|
|
972
|
+
this_1.addOverflowEvents(item, itemEle, dropdown);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
var this_1 = this;
|
|
977
|
+
for (var i = 0; ((i < collapseOrder.length) && (tabContent.offsetWidth < activeContent.offsetWidth)); i++) {
|
|
978
|
+
_loop_1(i);
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
// eslint-disable-next-line max-len
|
|
982
|
+
Ribbon.prototype.removeOverflowDropdown = function (tabContent, activeContent, isClear, tabIndex) {
|
|
983
|
+
if (isClear === void 0) { isClear = false; }
|
|
984
|
+
var expandOrder = this.getGroupResizeOrder(false, tabIndex);
|
|
985
|
+
if (expandOrder.length === 0) {
|
|
986
|
+
return false;
|
|
987
|
+
}
|
|
988
|
+
var _loop_2 = function (i) {
|
|
989
|
+
var group = expandOrder[parseInt(i.toString(), 10)];
|
|
990
|
+
var groupEle = this_2.tabObj.element.querySelector('#' + group.id);
|
|
991
|
+
if (!groupEle) {
|
|
992
|
+
return "break";
|
|
993
|
+
} //to handle the rerendering of tabcontrol when a ribbon tab is added/removed
|
|
994
|
+
var width = parseInt(groupEle.getAttribute('data-expanded-width'), 10);
|
|
995
|
+
if (!isClear && (tabContent.offsetWidth < width)) {
|
|
996
|
+
return { value: true };
|
|
997
|
+
}
|
|
998
|
+
this_2.removeDropdown(group.id);
|
|
999
|
+
var groupIndex = getIndex(this_2.tabs[parseInt(tabIndex.toString(), 10)].groups, function (e) { return e.id === group.id; });
|
|
1000
|
+
this_2.tabs[parseInt(tabIndex.toString(), 10)].
|
|
1001
|
+
groups[parseInt(groupIndex.toString(), 10)].setProperties({ isCollapsed: false }, true);
|
|
1002
|
+
var tab = this_2.tabs[parseInt(tabIndex.toString(), 10)];
|
|
1003
|
+
//Shrinking the items in the group to their previous shrinked state (before moving to dropdown)
|
|
1004
|
+
this_2.checkLargeToMedium(tabIndex, tab, groupIndex, tabContent, activeContent, true);
|
|
1005
|
+
this_2.checkMediumToSmall(tabIndex, tab, groupIndex, tabContent, activeContent, true);
|
|
1006
|
+
for (var j = 0; j < group.collections.length; j++) {
|
|
1007
|
+
var collection = group.collections[parseInt(j.toString(), 10)];
|
|
1008
|
+
var collectionEle = groupEle.querySelector('#' + collection.id);
|
|
1009
|
+
for (var k = 0; k < collection.items.length; k++) {
|
|
1010
|
+
var item = collection.items[parseInt(k.toString(), 10)];
|
|
1011
|
+
var itemEle = collectionEle.querySelector('#' + item.id + constants.CONTAINER_ID);
|
|
1012
|
+
this_2.removeOverflowEvent(item, itemEle);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
var this_2 = this;
|
|
1017
|
+
for (var i = 0; i < expandOrder.length; i++) {
|
|
1018
|
+
var state_1 = _loop_2(i);
|
|
1019
|
+
if (typeof state_1 === "object")
|
|
1020
|
+
return state_1.value;
|
|
1021
|
+
if (state_1 === "break")
|
|
1022
|
+
break;
|
|
1023
|
+
}
|
|
1024
|
+
return false;
|
|
1025
|
+
};
|
|
1026
|
+
Ribbon.prototype.removeDropdown = function (groupId) {
|
|
1027
|
+
var dropdownElement = this.tabObj.element.querySelector('#' + groupId + constants.OVERFLOW_ID + constants.DROPDOWN_ID);
|
|
1028
|
+
if (dropdownElement) {
|
|
1029
|
+
var groupOverFlow = dropdownElement.parentElement;
|
|
1030
|
+
this.ribbonDropDownModule.removeOverFlowDropDown(dropdownElement);
|
|
1031
|
+
remove(groupOverFlow);
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
Ribbon.prototype.getGroupResizeOrder = function (isCollapse, tabIndex) {
|
|
1035
|
+
var _this = this;
|
|
1036
|
+
var groups = this.tabs[parseInt(tabIndex.toString(), 10)].groups;
|
|
1037
|
+
groups = groups.filter(function (e) {
|
|
1038
|
+
// (isUndefined(e.isCollapsible) || e.isCollapsible) => check whethe rhte item is collapsible
|
|
1039
|
+
// if a isCollapsed property is undefined, then it is considered collapsible and included in collapsible list
|
|
1040
|
+
// ((isCollapse && !e.isCollapsed)||(!isCollapse && e.isCollapsed)) => isCollapse !== e.isCollapsed
|
|
1041
|
+
return (_this.activeLayout === 'Classic') ? (isUndefined(e.isCollapsible) || e.isCollapsible) && ((isCollapse &&
|
|
1042
|
+
isUndefined(e.isCollapsed)) || (!isUndefined(e.isCollapsed) && (isCollapse !== e.isCollapsed))) : true;
|
|
1043
|
+
});
|
|
1044
|
+
//sort the collapsible groups based on the priority
|
|
1045
|
+
groups.sort(function (a, b) { return a.priority - b.priority; });
|
|
1046
|
+
//reverse the sorted array to return the array in descending order while collapsing.
|
|
1047
|
+
return isCollapse ? groups.reverse() : groups;
|
|
1048
|
+
};
|
|
1049
|
+
Ribbon.prototype.destroyScroll = function () {
|
|
1050
|
+
if (this.scrollModule) {
|
|
1051
|
+
this.scrollModule.destroy();
|
|
1052
|
+
this.scrollModule = null;
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
Ribbon.prototype.clearOverflowDropDown = function (index) {
|
|
1056
|
+
var activeContent = this.tabObj.element.querySelector('#' + this.tabs[parseInt(index.toString(), 10)].id + constants.CONTENT_ID);
|
|
1057
|
+
if (!activeContent) {
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
var tabContent = activeContent.closest('.' + constants.TAB_CONTENT);
|
|
1061
|
+
if (this.activeLayout === 'Simplified') {
|
|
1062
|
+
this.removeSimplfiedOverflow(activeContent, tabContent, index, true);
|
|
1063
|
+
}
|
|
1064
|
+
else {
|
|
1065
|
+
this.removeOverflowDropdown(activeContent, tabContent, true, index);
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
Ribbon.prototype.ribbonTabSelecting = function (e) {
|
|
1069
|
+
var _this = this;
|
|
1070
|
+
var nextTabId = e.selectingItem.getAttribute('data-id');
|
|
1071
|
+
var previousTabId = e.previousItem.getAttribute('data-id');
|
|
1072
|
+
var nextIndex = getIndex(this.tabs, (function (tab) { return (tab.id === nextTabId); }));
|
|
1073
|
+
var previousIndex = getIndex(this.tabs, (function (tab) { return (tab.id === previousTabId); }));
|
|
1074
|
+
nextIndex = nextIndex === -1 ? this.selectedTab : nextIndex;
|
|
1075
|
+
var eventArgs = {
|
|
1076
|
+
cancel: e.cancel, isInteracted: e.isInteracted, previousIndex: previousIndex, selectedIndex: nextIndex
|
|
1077
|
+
};
|
|
1078
|
+
this.trigger('tabSelecting', eventArgs, function (args) {
|
|
1079
|
+
if (args.cancel) {
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
_this.destroyScroll();
|
|
1083
|
+
if (!_this.isAddRemove && (previousIndex !== -1)) {
|
|
1084
|
+
_this.clearOverflowDropDown(previousIndex);
|
|
1085
|
+
}
|
|
1086
|
+
var selectedTabContent = _this.tabObj.items[parseInt(nextIndex.toString(), 10)].content;
|
|
1087
|
+
if ((!selectedTabContent.querySelector('.' + constants.RIBBON_GROUP)) && (_this.tabs[parseInt(nextIndex.toString(), 10)].groups.length !== 0)) {
|
|
1088
|
+
var elements = _this.createGroups(_this.tabs[parseInt(nextIndex.toString(), 10)].groups, nextIndex);
|
|
1089
|
+
append(elements, selectedTabContent);
|
|
1090
|
+
}
|
|
1091
|
+
});
|
|
1092
|
+
};
|
|
1093
|
+
Ribbon.prototype.createTabItems = function (tabs) {
|
|
1094
|
+
var _this = this;
|
|
1095
|
+
var tabItems = [];
|
|
1096
|
+
for (var i = 0; i < tabs.length; i++) {
|
|
1097
|
+
var ribbonTab = tabs[parseInt(i.toString(), 10)];
|
|
1098
|
+
var header = this.createElement('span', {
|
|
1099
|
+
innerHTML: ribbonTab.header,
|
|
1100
|
+
id: ribbonTab.id + constants.HEADER_ID
|
|
1101
|
+
});
|
|
1102
|
+
header.onclick = function () { _this.minimize(false); };
|
|
1103
|
+
header.ondblclick = function () { _this.minimize(true); };
|
|
1104
|
+
var tab = { header: { text: header }, id: ribbonTab.id, cssClass: ribbonTab.cssClass };
|
|
1105
|
+
var content = this.createElement('div', {
|
|
1106
|
+
className: tab.cssClass,
|
|
1107
|
+
id: ribbonTab.id + constants.CONTENT_ID
|
|
1108
|
+
});
|
|
1109
|
+
content.classList.add(constants.RIBBON_TAB_ITEM);
|
|
1110
|
+
tab.content = content;
|
|
1111
|
+
tabItems.push(tab);
|
|
1112
|
+
}
|
|
1113
|
+
return tabItems;
|
|
1114
|
+
};
|
|
1115
|
+
Ribbon.prototype.renderInitialTab = function (index) {
|
|
1116
|
+
var elements = this.createGroups(this.tabs[parseInt(index.toString(), 10)].groups, index);
|
|
1117
|
+
var content = this.tabObj.items[parseInt(index.toString(), 10)].content;
|
|
1118
|
+
append(elements, content);
|
|
1119
|
+
if (this.activeLayout === 'Simplified') {
|
|
1120
|
+
this.element.classList.add(constants.RIBBON_SIMPLIFIED_MODE);
|
|
1121
|
+
}
|
|
1122
|
+
var activeContent = this.tabObj.element.querySelector('#' + this.tabs[this.selectedTab].id + constants.CONTENT_ID);
|
|
1123
|
+
this.checkOverflow(this.selectedTab, activeContent);
|
|
1124
|
+
};
|
|
1125
|
+
Ribbon.prototype.addOverflowButton = function (btnId) {
|
|
1126
|
+
var overflowButton = this.createElement('button', {
|
|
1127
|
+
id: btnId
|
|
1128
|
+
});
|
|
1129
|
+
var overflowTarget = this.createElement('div', {
|
|
1130
|
+
className: constants.RIBBON_OVERFLOW_TARGET
|
|
1131
|
+
});
|
|
1132
|
+
var overflowDDB = new DropDownButton({
|
|
1133
|
+
iconCss: constants.OVERFLOW_ICON,
|
|
1134
|
+
cssClass: constants.DROPDOWNBUTTON_HIDE + constants.SPACE + constants.RIBBON_GROUP_OVERFLOW_DDB,
|
|
1135
|
+
target: overflowTarget,
|
|
1136
|
+
locale: this.locale,
|
|
1137
|
+
enableRtl: this.enableRtl,
|
|
1138
|
+
enablePersistence: this.enablePersistence,
|
|
1139
|
+
beforeClose: function (args) {
|
|
1140
|
+
var ele = args.event ? closest(args.event.target, '.' + constants.RIBBON_POPUP_CONTROL) : null;
|
|
1141
|
+
if (ele) {
|
|
1142
|
+
args.cancel = true;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
}, overflowButton);
|
|
1146
|
+
this.element.classList.add(constants.RIBBON_OVERFLOW);
|
|
1147
|
+
createTooltip(overflowTarget, this);
|
|
1148
|
+
return overflowDDB;
|
|
1149
|
+
};
|
|
1150
|
+
Ribbon.prototype.removeOverflowButton = function (overflowDDB) {
|
|
1151
|
+
if (overflowDDB) {
|
|
1152
|
+
var btnEle = overflowDDB.element;
|
|
1153
|
+
destroyTooltip(overflowDDB.target);
|
|
1154
|
+
overflowDDB.destroy();
|
|
1155
|
+
btnEle.remove();
|
|
1156
|
+
}
|
|
1157
|
+
};
|
|
1158
|
+
Ribbon.prototype.removeOverflowEvent = function (item, itemEle) {
|
|
1159
|
+
switch (item.type) {
|
|
1160
|
+
case 'Button':
|
|
1161
|
+
this.ribbonButtonModule.removeOverFlowEvents(item, itemEle);
|
|
1162
|
+
break;
|
|
1163
|
+
case 'DropDown':
|
|
1164
|
+
this.ribbonDropDownModule.removeOverFlowEvents(item, itemEle);
|
|
1165
|
+
break;
|
|
1166
|
+
case 'SplitButton':
|
|
1167
|
+
this.ribbonSplitButtonModule.removeOverFlowEvents(item, itemEle);
|
|
1168
|
+
break;
|
|
1169
|
+
case 'CheckBox':
|
|
1170
|
+
this.ribbonCheckBoxModule.removeOverFlowEvents(item, itemEle);
|
|
1171
|
+
break;
|
|
1172
|
+
case 'ColorPicker':
|
|
1173
|
+
this.ribbonColorPickerModule.removeOverFlowEvents(item, itemEle);
|
|
1174
|
+
break;
|
|
1175
|
+
case 'ComboBox':
|
|
1176
|
+
this.ribbonComboBoxModule.removeOverFlowEvents(item, itemEle);
|
|
1177
|
+
break;
|
|
1178
|
+
}
|
|
1179
|
+
};
|
|
1180
|
+
Ribbon.prototype.createGroupContainer = function (groupId, groupHeader) {
|
|
1181
|
+
var ofGroupContainer = this.createElement('div', {
|
|
1182
|
+
className: constants.RIBBON_OF_GROUP_CONTAINER,
|
|
1183
|
+
id: groupId + constants.CONTAINER_ID
|
|
1184
|
+
});
|
|
1185
|
+
var ofGroupHeader = this.createElement('div', {
|
|
1186
|
+
className: constants.RIBBON_OVERFLOW_HEADER,
|
|
1187
|
+
id: groupId + constants.HEADER_ID,
|
|
1188
|
+
innerHTML: groupHeader
|
|
1189
|
+
});
|
|
1190
|
+
ofGroupContainer.append(ofGroupHeader);
|
|
1191
|
+
return ofGroupContainer;
|
|
1192
|
+
};
|
|
1193
|
+
Ribbon.prototype.addExpandCollapse = function () {
|
|
1194
|
+
var _this = this;
|
|
1195
|
+
this.collapseButton = this.createElement('span', {
|
|
1196
|
+
className: constants.RIBBON_COLLAPSE_BUTTON + constants.SPACE + constants.EXPAND_COLLAPSE_ICON,
|
|
1197
|
+
id: this.tabObj.element.id + constants.COLLAPSE_BUTTON_ID,
|
|
1198
|
+
attrs: { 'tabindex': '0', 'type': 'button', 'aria-label': 'Layout Switcher' }
|
|
1199
|
+
});
|
|
1200
|
+
this.collapseButton.onclick = function () { _this.toggleLayout(); };
|
|
1201
|
+
this.collapseButton.onkeydown = function (e) {
|
|
1202
|
+
if (e.key === "Enter") {
|
|
1203
|
+
_this.toggleLayout();
|
|
1204
|
+
}
|
|
1205
|
+
};
|
|
1206
|
+
this.element.classList.add(constants.RIBBON_COLLAPSIBLE);
|
|
1207
|
+
if (this.activeLayout === 'Simplified') {
|
|
1208
|
+
this.collapseButton.classList.add(constants.RIBBON_EXPAND_BUTTON);
|
|
1209
|
+
}
|
|
1210
|
+
this.tabObj.element.appendChild(this.collapseButton);
|
|
1211
|
+
};
|
|
1212
|
+
Ribbon.prototype.removeExpandCollapse = function () {
|
|
1213
|
+
var _this = this;
|
|
1214
|
+
var index = getIndex(this.tooltipData, function (e) { return e.id === _this.collapseButton.id; });
|
|
1215
|
+
if (index !== -1) {
|
|
1216
|
+
this.tooltipData.splice(index, 1);
|
|
1217
|
+
}
|
|
1218
|
+
this.element.classList.remove(constants.RIBBON_COLLAPSIBLE);
|
|
1219
|
+
remove(this.tabObj.element.querySelector('.' + constants.RIBBON_COLLAPSE_BUTTON));
|
|
1220
|
+
this.collapseButton = null;
|
|
1221
|
+
};
|
|
1222
|
+
Ribbon.prototype.reRenderTabs = function () {
|
|
1223
|
+
this.destroyScroll();
|
|
1224
|
+
this.destroyTabItems(this.tabsInternal);
|
|
1225
|
+
this.checkID(this.tabs, 'tab', this.element.id);
|
|
1226
|
+
this.tabsInternal = this.tabs.slice();
|
|
1227
|
+
this.validateItemSize();
|
|
1228
|
+
var tabItems = this.createTabItems(this.tabs);
|
|
1229
|
+
if (this.selectedTab >= this.tabs.length) {
|
|
1230
|
+
this.selectedTab = this.tabs.length - 1;
|
|
1231
|
+
}
|
|
1232
|
+
this.tabObj.setProperties({ items: tabItems, selectedItem: this.selectedTab });
|
|
1233
|
+
var contentEle = this.tabObj.items[this.selectedTab].content;
|
|
1234
|
+
if (contentEle.innerHTML === '') {
|
|
1235
|
+
this.renderInitialTab(this.selectedTab);
|
|
1236
|
+
}
|
|
1237
|
+
};
|
|
1238
|
+
Ribbon.prototype.switchLayout = function () {
|
|
1239
|
+
this.destroyScroll();
|
|
1240
|
+
this.collapseButton.classList.toggle(constants.RIBBON_EXPAND_BUTTON, this.activeLayout === 'Simplified');
|
|
1241
|
+
this.element.classList.toggle(constants.RIBBON_SIMPLIFIED_MODE, this.activeLayout === 'Simplified');
|
|
1242
|
+
for (var i = 0; i <= (this.tabs.length - 1); i++) {
|
|
1243
|
+
var tabIndex = i;
|
|
1244
|
+
var contentEle = this.tabObj.items[parseInt(tabIndex.toString(), 10)].content;
|
|
1245
|
+
if (contentEle.innerHTML !== '') {
|
|
1246
|
+
var tab = this.tabs[parseInt(tabIndex.toString(), 10)];
|
|
1247
|
+
var groupList = this.tabs[parseInt(tabIndex.toString(), 10)].groups;
|
|
1248
|
+
var activeContent = this.tabObj.element.querySelector('#' + this.tabs[parseInt(tabIndex.toString(), 10)].id + constants.CONTENT_ID);
|
|
1249
|
+
var tabContent = activeContent.closest('.' + constants.TAB_CONTENT);
|
|
1250
|
+
if (this.activeLayout === 'Simplified') {
|
|
1251
|
+
for (var i_1 = 0; i_1 < groupList.length; i_1++) {
|
|
1252
|
+
var group = groupList[parseInt(i_1.toString(), 10)];
|
|
1253
|
+
if (group.isCollapsed) {
|
|
1254
|
+
group.setProperties({ isCollapsed: false }, true);
|
|
1255
|
+
this.removeDropdown(group.id);
|
|
1256
|
+
}
|
|
1257
|
+
else {
|
|
1258
|
+
this.checkSmallToMedium(tabIndex, tab, i_1, tabContent, activeContent, true, false);
|
|
1259
|
+
this.checkMediumToLarge(tabIndex, tab, i_1, tabContent, activeContent, true, false);
|
|
1260
|
+
}
|
|
1261
|
+
var groupEle = tabContent.querySelector('#' + group.id);
|
|
1262
|
+
var groupContainer = groupEle.querySelector('#' + group.id + constants.CONTAINER_ID);
|
|
1263
|
+
var shrinkColumns = groupContainer.querySelectorAll('.' + 'e-ribbon-shrink');
|
|
1264
|
+
for (var i_2 = 0; i_2 < shrinkColumns.length; i_2++) {
|
|
1265
|
+
shrinkColumns[parseInt(i_2.toString(), 10)].remove();
|
|
1266
|
+
}
|
|
1267
|
+
var groupHeader = groupContainer.querySelector('#' + group.id + constants.HEADER_ID);
|
|
1268
|
+
groupHeader.remove();
|
|
1269
|
+
var groupContent = groupContainer.querySelector('#' + group.id + constants.CONTENT_ID);
|
|
1270
|
+
groupContent.classList.replace(constants.RIBBON_ROW, constants.RIBBON_COLUMN);
|
|
1271
|
+
groupContent.classList.remove(constants.RIBBON_CONTENT_HEIGHT);
|
|
1272
|
+
for (var j = 0; j < group.collections.length; j++) {
|
|
1273
|
+
var collection = group.collections[parseInt(j.toString(), 10)];
|
|
1274
|
+
var groupCollection = groupContainer.querySelector('#' + collection.id);
|
|
1275
|
+
groupCollection.classList.replace(constants.RIBBON_ROW, constants.RIBBON_COLUMN);
|
|
1276
|
+
for (var k = 0; k < collection.items.length; k++) {
|
|
1277
|
+
var itemList = collection.items;
|
|
1278
|
+
var item = collection.items[parseInt(k.toString(), 10)];
|
|
1279
|
+
var flag = true;
|
|
1280
|
+
while ((flag) && (item.displayOptions === DisplayMode.None)) {
|
|
1281
|
+
k++;
|
|
1282
|
+
var itemEle_1 = groupContainer.querySelector('#' + item.id + constants.CONTAINER_ID);
|
|
1283
|
+
var ele_8 = itemEle_1.querySelector('#' + item.id);
|
|
1284
|
+
this.destroyFunction(item, ele_8);
|
|
1285
|
+
itemEle_1.remove();
|
|
1286
|
+
if (k < itemList.length) {
|
|
1287
|
+
item = itemList[parseInt(k.toString(), 10)];
|
|
1288
|
+
}
|
|
1289
|
+
else {
|
|
1290
|
+
flag = false;
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
if (!flag) {
|
|
1294
|
+
break;
|
|
1295
|
+
}
|
|
1296
|
+
var itemEle = groupContainer.querySelector('#' + item.id + constants.CONTAINER_ID);
|
|
1297
|
+
var ele = itemEle.querySelector('#' + item.id);
|
|
1298
|
+
var size = ((item.allowedSizes === RibbonItemSize.Large) ||
|
|
1299
|
+
(item.allowedSizes & RibbonItemSize.Medium)) ? RibbonItemSize.Medium : RibbonItemSize.Small;
|
|
1300
|
+
if (item.displayOptions === DisplayMode.Overflow) {
|
|
1301
|
+
this.createOverflowPopup(item, tabIndex, group.enableGroupOverflow, group.id, group.header, itemEle, groupContainer);
|
|
1302
|
+
size = RibbonItemSize.Medium;
|
|
1303
|
+
if ((item.type === RibbonItemType.DropDown) || (item.type === RibbonItemType.SplitButton)) {
|
|
1304
|
+
this.updatePopupItems(item, itemEle, group.enableGroupOverflow, true);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
item.setProperties({ activeSize: size }, true);
|
|
1308
|
+
this.setItemSize(ele, item);
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
if (!(group.enableGroupOverflow || groupEle.querySelector('.' + constants.RIBBON_ITEM))) {
|
|
1312
|
+
groupEle.classList.add('e-ribbon-emptyCollection');
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
else {
|
|
1317
|
+
this.element.classList.remove(constants.RIBBON_OVERFLOW);
|
|
1318
|
+
for (var i_3 = 0; i_3 < groupList.length; i_3++) {
|
|
1319
|
+
var group = groupList[parseInt(i_3.toString(), 10)];
|
|
1320
|
+
var alignType = groupList[parseInt(i_3.toString(), 10)].orientation;
|
|
1321
|
+
var groupContainer = tabContent.querySelector('#' + group.id + constants.CONTAINER_ID);
|
|
1322
|
+
var groupContent = groupContainer.querySelector('#' + group.id + constants.CONTENT_ID);
|
|
1323
|
+
var groupHeader = this.createElement('div', {
|
|
1324
|
+
className: constants.RIBBON_GROUP_HEADER,
|
|
1325
|
+
id: group.id + constants.HEADER_ID,
|
|
1326
|
+
innerHTML: group.header
|
|
1327
|
+
});
|
|
1328
|
+
groupContainer.appendChild(groupHeader);
|
|
1329
|
+
if (alignType === 'Row') {
|
|
1330
|
+
groupContent.classList.replace(constants.RIBBON_COLUMN, constants.RIBBON_ROW);
|
|
1331
|
+
}
|
|
1332
|
+
groupContent.classList.add(constants.RIBBON_CONTENT_HEIGHT);
|
|
1333
|
+
for (var j = 0; j < group.collections.length; j++) {
|
|
1334
|
+
var overflowDDB = void 0;
|
|
1335
|
+
var overflowtarget = void 0;
|
|
1336
|
+
if (!group.enableGroupOverflow) {
|
|
1337
|
+
overflowDDB = this.overflowDDB;
|
|
1338
|
+
if (overflowDDB) {
|
|
1339
|
+
overflowtarget = this.overflowDDB.target;
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
else {
|
|
1343
|
+
var overflowDDBEle = groupContainer.querySelector('#' + group.id + constants.GROUPOF_BUTTON_ID);
|
|
1344
|
+
if (overflowDDBEle) {
|
|
1345
|
+
overflowDDB = getInstance(overflowDDBEle, DropDownButton);
|
|
1346
|
+
overflowtarget = overflowDDB.target;
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
var collection = group.collections[parseInt(j.toString(), 10)];
|
|
1350
|
+
var groupCollection = groupContainer.querySelector('#' + collection.id);
|
|
1351
|
+
if (alignType === 'Column') {
|
|
1352
|
+
groupCollection.classList.replace(constants.RIBBON_COLUMN, constants.RIBBON_ROW);
|
|
1353
|
+
}
|
|
1354
|
+
for (var k = 0; k < collection.items.length; k++) {
|
|
1355
|
+
var item = collection.items[parseInt(k.toString(), 10)];
|
|
1356
|
+
if (item.displayOptions === DisplayMode.None) {
|
|
1357
|
+
var itemEle = this.createItems([item], alignType, group.id, group.header, group.enableGroupOverflow, tabIndex)[0];
|
|
1358
|
+
groupCollection.append(itemEle);
|
|
1359
|
+
}
|
|
1360
|
+
else if ((item.displayOptions === DisplayMode.Overflow)) {
|
|
1361
|
+
var itemEle = overflowtarget.querySelector('#' + item.id + constants.CONTAINER_ID);
|
|
1362
|
+
if ((item.type === RibbonItemType.DropDown) || (item.type === RibbonItemType.SplitButton)) {
|
|
1363
|
+
this.updatePopupItems(item, itemEle, group.enableGroupOverflow, false);
|
|
1364
|
+
}
|
|
1365
|
+
groupCollection.append(itemEle);
|
|
1366
|
+
this.removeOverflowEvent(item, itemEle);
|
|
1367
|
+
}
|
|
1368
|
+
else if ((item.displayOptions === DisplayMode.Simplified)) {
|
|
1369
|
+
//To make sure the items are in proper order
|
|
1370
|
+
var itemEle = groupContainer.querySelector('#' + item.id + constants.CONTAINER_ID);
|
|
1371
|
+
groupCollection.append(itemEle);
|
|
1372
|
+
}
|
|
1373
|
+
else {
|
|
1374
|
+
var itemEle = groupContainer.querySelector('#' + item.id + constants.CONTAINER_ID);
|
|
1375
|
+
if (!itemEle) {
|
|
1376
|
+
itemEle = overflowtarget.querySelector('#' + item.id + constants.CONTAINER_ID);
|
|
1377
|
+
if ((item.type === RibbonItemType.DropDown) || (item.type === RibbonItemType.SplitButton)) {
|
|
1378
|
+
this.updatePopupItems(item, itemEle, group.enableGroupOverflow, false);
|
|
1379
|
+
}
|
|
1380
|
+
this.removeOverflowEvent(item, itemEle);
|
|
1381
|
+
}
|
|
1382
|
+
groupCollection.append(itemEle);
|
|
1383
|
+
}
|
|
1384
|
+
var ele = groupContainer.querySelector('#' + item.id);
|
|
1385
|
+
var itemsize = (item.allowedSizes & RibbonItemSize.Large) ? RibbonItemSize.Large :
|
|
1386
|
+
(item.allowedSizes & RibbonItemSize.Medium) ? RibbonItemSize.Medium : RibbonItemSize.Small;
|
|
1387
|
+
item.setProperties({ activeSize: itemsize }, true);
|
|
1388
|
+
this.setItemSize(ele, item);
|
|
1389
|
+
}
|
|
1390
|
+
if (group.enableGroupOverflow && overflowDDB) {
|
|
1391
|
+
if (overflowtarget.childElementCount === 0) {
|
|
1392
|
+
this.removeOverflowButton(overflowDDB);
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
if (this.selectedTab === tabIndex) {
|
|
1399
|
+
this.checkOverflow(tabIndex, activeContent);
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
if (this.activeLayout === 'Classic') {
|
|
1404
|
+
this.removeOverflowButton(this.overflowDDB);
|
|
1405
|
+
this.overflowDDB = null;
|
|
1406
|
+
}
|
|
1407
|
+
};
|
|
1408
|
+
Ribbon.prototype.launcherIconClicked = function (id) {
|
|
1409
|
+
var eventArgs = { groupId: id };
|
|
1410
|
+
this.trigger('launcherIconClick', eventArgs);
|
|
1411
|
+
};
|
|
1412
|
+
Ribbon.prototype.createGroups = function (groupList, tabIndex) {
|
|
1413
|
+
var _this = this;
|
|
1414
|
+
var groupElements = [];
|
|
1415
|
+
var _loop_3 = function (i) {
|
|
1416
|
+
var group = groupList[parseInt(i.toString(), 10)];
|
|
1417
|
+
var alignType = group.orientation;
|
|
1418
|
+
var groupEle = this_3.createElement('div', {
|
|
1419
|
+
className: group.cssClass,
|
|
1420
|
+
id: group.id
|
|
1421
|
+
});
|
|
1422
|
+
groupEle.classList.add(constants.RIBBON_GROUP);
|
|
1423
|
+
groupElements.push(groupEle);
|
|
1424
|
+
var groupContainer = this_3.createElement('div', {
|
|
1425
|
+
className: group.cssClass,
|
|
1426
|
+
id: group.id + constants.CONTAINER_ID
|
|
1427
|
+
});
|
|
1428
|
+
groupContainer.classList.add(constants.RIBBON_GROUP_CONTAINER);
|
|
1429
|
+
groupEle.appendChild(groupContainer);
|
|
1430
|
+
var groupContent = this_3.createElement('div', {
|
|
1431
|
+
className: this_3.activeLayout === 'Simplified' ? constants.RIBBON_GROUP_CONTENT : (constants.RIBBON_GROUP_CONTENT + constants.SPACE + constants.RIBBON_CONTENT_HEIGHT),
|
|
1432
|
+
id: group.id + constants.CONTENT_ID
|
|
1433
|
+
});
|
|
1434
|
+
groupContent.classList.add(((alignType === 'Column') || (this_3.activeLayout === 'Simplified')) ? constants.RIBBON_COLUMN : constants.RIBBON_ROW);
|
|
1435
|
+
groupContainer.appendChild(groupContent);
|
|
1436
|
+
if (this_3.activeLayout === 'Classic') {
|
|
1437
|
+
var groupHeader = this_3.createElement('div', {
|
|
1438
|
+
className: constants.RIBBON_GROUP_HEADER,
|
|
1439
|
+
id: group.id + constants.HEADER_ID,
|
|
1440
|
+
innerHTML: group.header
|
|
1441
|
+
});
|
|
1442
|
+
groupContainer.appendChild(groupHeader);
|
|
1443
|
+
}
|
|
1444
|
+
if (group.showLauncherIcon) {
|
|
1445
|
+
var launcherIcon = this_3.createElement('div', {
|
|
1446
|
+
className: constants.RIBBON_LAUNCHER_ICON_ELE + ' ' + (this_3.launcherIconCss ? this_3.launcherIconCss : constants.RIBBON_LAUNCHER_ICON),
|
|
1447
|
+
id: group.id + constants.LAUNCHER_ID,
|
|
1448
|
+
attrs: { 'tabindex': '0', 'type': 'button', 'aria-label': 'Launcher Icon' }
|
|
1449
|
+
});
|
|
1450
|
+
groupContainer.appendChild(launcherIcon);
|
|
1451
|
+
groupContainer.classList.add(constants.RIBBON_LAUNCHER);
|
|
1452
|
+
EventHandler.add(launcherIcon, 'click', this_3.launcherIconClicked.bind(this_3, group.id), this_3);
|
|
1453
|
+
EventHandler.add(launcherIcon, 'keydown', function (e) {
|
|
1454
|
+
if (e.key === "Enter") {
|
|
1455
|
+
_this.launcherIconClicked(group.id);
|
|
1456
|
+
}
|
|
1457
|
+
}, this_3);
|
|
1458
|
+
}
|
|
1459
|
+
var elements = this_3.createCollection(group.collections, group.orientation, group.id, group.header, group.enableGroupOverflow, tabIndex, groupContainer);
|
|
1460
|
+
append(elements, groupContent);
|
|
1461
|
+
if ((this_3.activeLayout === 'Simplified') && !(group.enableGroupOverflow || groupEle.querySelector('.' + constants.RIBBON_ITEM))) {
|
|
1462
|
+
groupEle.classList.add('e-ribbon-emptyCollection');
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1465
|
+
var this_3 = this;
|
|
1466
|
+
for (var i = 0; i < groupList.length; i++) {
|
|
1467
|
+
_loop_3(i);
|
|
1468
|
+
}
|
|
1469
|
+
return groupElements;
|
|
1470
|
+
};
|
|
1471
|
+
Ribbon.prototype.validateItemSize = function () {
|
|
1472
|
+
for (var k = 0; k < this.tabs.length; k++) {
|
|
1473
|
+
var groupList = this.tabs[parseInt(k.toString(), 10)].groups;
|
|
1474
|
+
for (var l = 0; l < groupList.length; l++) {
|
|
1475
|
+
var collectionList = groupList[parseInt(l.toString(), 10)].collections;
|
|
1476
|
+
var alignType = groupList[parseInt(l.toString(), 10)].orientation;
|
|
1477
|
+
for (var i = 0; i < collectionList.length; i++) {
|
|
1478
|
+
var items = collectionList[parseInt(i.toString(), 10)].items;
|
|
1479
|
+
for (var j = 0; j < items.length; j++) {
|
|
1480
|
+
var ribbonitem = items[parseInt(j.toString(), 10)];
|
|
1481
|
+
if (!ribbonitem.allowedSizes || (ribbonitem.allowedSizes === 0)) {
|
|
1482
|
+
ribbonitem.setProperties({ allowedSizes: (RibbonItemSize.Small | RibbonItemSize.Medium | RibbonItemSize.Large) }, true);
|
|
1483
|
+
}
|
|
1484
|
+
if ((ribbonitem.type === 'ColorPicker') && (ribbonitem.allowedSizes !== RibbonItemSize.Small)) {
|
|
1485
|
+
ribbonitem.setProperties({ allowedSizes: RibbonItemSize.Small }, true);
|
|
1486
|
+
}
|
|
1487
|
+
else if ((ribbonitem.type === 'ComboBox' || ribbonitem.type === 'CheckBox') &&
|
|
1488
|
+
(ribbonitem.allowedSizes !== RibbonItemSize.Medium)) {
|
|
1489
|
+
ribbonitem.setProperties({ allowedSizes: RibbonItemSize.Medium }, true);
|
|
1490
|
+
}
|
|
1491
|
+
else if (((alignType === 'Column') && (items.length > 1)) || ((alignType === 'Row') && (collectionList.length > 1))) {
|
|
1492
|
+
if (ribbonitem.allowedSizes & RibbonItemSize.Large) {
|
|
1493
|
+
// To remove large size, perform 'and' with 011(3).
|
|
1494
|
+
var sizeVal = ribbonitem.allowedSizes & (RibbonItemSize.Small | RibbonItemSize.Medium);
|
|
1495
|
+
sizeVal = sizeVal ? sizeVal : RibbonItemSize.Medium;
|
|
1496
|
+
ribbonitem.setProperties({ allowedSizes: sizeVal }, true);
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
var itemsize = (ribbonitem.allowedSizes & RibbonItemSize.Large) ? RibbonItemSize.Large :
|
|
1500
|
+
(ribbonitem.allowedSizes & RibbonItemSize.Medium) ? RibbonItemSize.Medium : RibbonItemSize.Small;
|
|
1501
|
+
ribbonitem.setProperties({ activeSize: itemsize }, true);
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
};
|
|
1507
|
+
Ribbon.prototype.createCollection = function (collectionList, alignType, groupId, groupHeader, isGroupOF, tabIndex, groupContainer) {
|
|
1508
|
+
var collectionElements = [];
|
|
1509
|
+
for (var i = 0; i < collectionList.length; i++) {
|
|
1510
|
+
var collection = collectionList[parseInt(i.toString(), 10)];
|
|
1511
|
+
var collectionEle = this.createElement('div', {
|
|
1512
|
+
className: collection.cssClass,
|
|
1513
|
+
id: collection.id
|
|
1514
|
+
});
|
|
1515
|
+
collectionEle.classList.add(constants.RIBBON_COLLECTION);
|
|
1516
|
+
collectionEle.classList.add(((alignType !== 'Column') || (this.activeLayout === 'Simplified')) ?
|
|
1517
|
+
constants.RIBBON_COLUMN : constants.RIBBON_ROW);
|
|
1518
|
+
collectionElements.push(collectionEle);
|
|
1519
|
+
var elements = this.createItems(collection.items, alignType, groupId, groupHeader, isGroupOF, tabIndex, groupContainer);
|
|
1520
|
+
append(elements, collectionEle);
|
|
1521
|
+
if ((alignType === 'Row') && (i === 2)) {
|
|
1522
|
+
break;
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
return collectionElements;
|
|
1526
|
+
};
|
|
1527
|
+
Ribbon.prototype.createItems = function (itemList, alignType, groupId, groupHeader, isGroupOF, tabIndex, groupContainer) {
|
|
1528
|
+
var _a;
|
|
1529
|
+
var itemElements = [];
|
|
1530
|
+
for (var i = 0; i < itemList.length; i++) {
|
|
1531
|
+
var item = itemList[parseInt(i.toString(), 10)];
|
|
1532
|
+
//To stop rendering of items with simplified mode position type as none
|
|
1533
|
+
var flag = true;
|
|
1534
|
+
while ((this.activeLayout === 'Simplified') && (flag) && (item.displayOptions === DisplayMode.None)) {
|
|
1535
|
+
i++;
|
|
1536
|
+
if (i < itemList.length) {
|
|
1537
|
+
item = itemList[parseInt(i.toString(), 10)];
|
|
1538
|
+
}
|
|
1539
|
+
else {
|
|
1540
|
+
flag = false;
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
if (!flag) {
|
|
1544
|
+
break;
|
|
1545
|
+
}
|
|
1546
|
+
var itemEle = this.createElement('div', {
|
|
1547
|
+
className: item.cssClass,
|
|
1548
|
+
id: item.id + constants.CONTAINER_ID
|
|
1549
|
+
});
|
|
1550
|
+
(_a = itemEle.classList).add.apply(_a, [constants.RIBBON_ITEM].concat((item.disabled ? [constants.DISABLED_CSS] : [])));
|
|
1551
|
+
// To avoid undefined items condition is added
|
|
1552
|
+
if (item.ribbonTooltipSettings && isTooltipPresent(item.ribbonTooltipSettings)) {
|
|
1553
|
+
itemEle.classList.add(constants.RIBBON_TOOLTIP_TARGET);
|
|
1554
|
+
this.tooltipData.push({ id: itemEle.id, data: item.ribbonTooltipSettings });
|
|
1555
|
+
}
|
|
1556
|
+
var size = item.activeSize;
|
|
1557
|
+
if (this.activeLayout === 'Simplified') {
|
|
1558
|
+
size = ((item.allowedSizes === RibbonItemSize.Large) || (item.allowedSizes & RibbonItemSize.Medium) ||
|
|
1559
|
+
(item.displayOptions === DisplayMode.Overflow)) ? RibbonItemSize.Medium : RibbonItemSize.Small;
|
|
1560
|
+
item.setProperties({ activeSize: size }, true);
|
|
1561
|
+
}
|
|
1562
|
+
if (size & RibbonItemSize.Large) {
|
|
1563
|
+
itemEle.classList.add(constants.RIBBON_LARGE_ITEM, constants.RIBBON_CONTENT_HEIGHT);
|
|
1564
|
+
}
|
|
1565
|
+
else {
|
|
1566
|
+
itemEle.classList.add((size & RibbonItemSize.Medium) ? constants.RIBBON_MEDIUM_ITEM : constants.RIBBON_SMALL_ITEM);
|
|
1567
|
+
}
|
|
1568
|
+
switch (item.type) {
|
|
1569
|
+
case 'Button':
|
|
1570
|
+
this.ribbonButtonModule.createButton(item, itemEle);
|
|
1571
|
+
break;
|
|
1572
|
+
case 'DropDown':
|
|
1573
|
+
this.ribbonDropDownModule.createDropDown(item, itemEle);
|
|
1574
|
+
break;
|
|
1575
|
+
case 'SplitButton':
|
|
1576
|
+
this.ribbonSplitButtonModule.createSplitButton(item, itemEle);
|
|
1577
|
+
break;
|
|
1578
|
+
case 'CheckBox':
|
|
1579
|
+
this.ribbonCheckBoxModule.createCheckBox(item, itemEle);
|
|
1580
|
+
break;
|
|
1581
|
+
case 'ColorPicker':
|
|
1582
|
+
this.ribbonColorPickerModule.createColorPicker(item, itemEle);
|
|
1583
|
+
break;
|
|
1584
|
+
case 'ComboBox':
|
|
1585
|
+
this.ribbonComboBoxModule.createComboBox(item, itemEle);
|
|
1586
|
+
break;
|
|
1587
|
+
case 'Template':
|
|
1588
|
+
this.createTemplateContent(item, itemEle);
|
|
1589
|
+
break;
|
|
1590
|
+
}
|
|
1591
|
+
if ((this.activeLayout === 'Simplified') && (item.displayOptions === DisplayMode.Overflow)) {
|
|
1592
|
+
this.createOverflowPopup(item, tabIndex, isGroupOF, groupId, groupHeader, itemEle, groupContainer);
|
|
1593
|
+
if ((item.type === RibbonItemType.DropDown) || (item.type === RibbonItemType.SplitButton)) {
|
|
1594
|
+
this.updatePopupItems(item, itemEle, isGroupOF, true);
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
else {
|
|
1598
|
+
// For normal mode and Simplified mode position type as Group and Auto
|
|
1599
|
+
itemElements.push(itemEle);
|
|
1600
|
+
}
|
|
1601
|
+
if ((alignType === 'Column') && (i === 2)) {
|
|
1602
|
+
break;
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
return itemElements;
|
|
1606
|
+
};
|
|
1607
|
+
Ribbon.prototype.createHelpPaneTemplate = function () {
|
|
1608
|
+
if (this.helpPaneTemplate) {
|
|
1609
|
+
var templateName = 'helpPaneTemplate';
|
|
1610
|
+
this.clearTemplate([templateName]);
|
|
1611
|
+
this.ribbonTempEle = this.createElement('div', {
|
|
1612
|
+
className: constants.RIBBON_HELP_TEMPLATE,
|
|
1613
|
+
id: this.element.id + constants.RIBBON_HELP_PANE_TEMPLATE_ID
|
|
1614
|
+
});
|
|
1615
|
+
var templateFunction = getTemplateFunction(this.helpPaneTemplate);
|
|
1616
|
+
append(templateFunction({}, this, templateName, 'helpPaneTemplate', this.isStringTemplate), this.ribbonTempEle);
|
|
1617
|
+
var tabEle = this.tabObj.element;
|
|
1618
|
+
var toolbarEle = tabEle.querySelector('.e-toolbar');
|
|
1619
|
+
toolbarEle.after(this.ribbonTempEle);
|
|
1620
|
+
tabEle.style.setProperty(constants.RIBBON_HELP_PANE_TEMPLATE_WIDTH, this.ribbonTempEle.offsetWidth + 'px');
|
|
1621
|
+
this.renderReactTemplates();
|
|
1622
|
+
}
|
|
1623
|
+
};
|
|
1624
|
+
Ribbon.prototype.createTemplateContent = function (item, itemElement) {
|
|
1625
|
+
var itemEle = this.createElement('div', {
|
|
1626
|
+
className: item.disabled ? constants.DISABLED_CSS + constants.SPACE + item.cssClass : item.cssClass,
|
|
1627
|
+
id: item.id
|
|
1628
|
+
});
|
|
1629
|
+
if (item.disabled) {
|
|
1630
|
+
itemEle.setAttribute('disabled', '');
|
|
1631
|
+
}
|
|
1632
|
+
itemElement.appendChild(itemEle);
|
|
1633
|
+
this.renderItemTemplate(item, itemEle);
|
|
1634
|
+
};
|
|
1635
|
+
Ribbon.prototype.renderItemTemplate = function (item, itemElement) {
|
|
1636
|
+
var templateName = 'ribbon' + item.id + 'itemTemplate';
|
|
1637
|
+
this.clearTemplate([templateName]);
|
|
1638
|
+
var templateFunction = getTemplateFunction(item.itemTemplate);
|
|
1639
|
+
append(templateFunction({ activeSize: RibbonItemSize[item.activeSize] }, this, templateName, (item.id + 'itemTemplate'), this.isStringTemplate), itemElement);
|
|
1640
|
+
this.renderReactTemplates();
|
|
1641
|
+
};
|
|
1642
|
+
Ribbon.prototype.checkID = function (list, type, initId) {
|
|
1643
|
+
var key = type === 'tab' ? constants.TAB_ID : type === 'group' ? constants.GROUP_ID :
|
|
1644
|
+
type === 'collection' ? constants.COLLECTION_ID : constants.ITEM_ID;
|
|
1645
|
+
for (var i = 0; i < list.length; i++) {
|
|
1646
|
+
var listitem = list[parseInt(i.toString(), 10)];
|
|
1647
|
+
if (!listitem.id) {
|
|
1648
|
+
listitem.setProperties({ id: initId + key + (this.idIndex++) }, true);
|
|
1649
|
+
}
|
|
1650
|
+
switch (type) {
|
|
1651
|
+
case 'tab':
|
|
1652
|
+
listitem.setProperties({ groups: this.checkID(listitem.groups, 'group', listitem.id) }, true);
|
|
1653
|
+
break;
|
|
1654
|
+
case 'group':
|
|
1655
|
+
listitem.setProperties({ collections: this.checkID(listitem.collections, 'collection', listitem.id) }, true);
|
|
1656
|
+
break;
|
|
1657
|
+
case 'collection':
|
|
1658
|
+
listitem.setProperties({ items: this.checkID(listitem.items, 'item', listitem.id) }, true);
|
|
1659
|
+
break;
|
|
1660
|
+
default:
|
|
1661
|
+
break;
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
return list;
|
|
1665
|
+
};
|
|
1666
|
+
Ribbon.prototype.updateCommonProperty = function (commonProp) {
|
|
1667
|
+
this.tabObj.setProperties(commonProp);
|
|
1668
|
+
if (this.ribbonFileMenuModule) {
|
|
1669
|
+
this.ribbonFileMenuModule.setCommonProperties(commonProp);
|
|
1670
|
+
}
|
|
1671
|
+
for (var i = 0; i < this.tabs.length; i++) {
|
|
1672
|
+
var tab = this.tabs[parseInt(i.toString(), 10)];
|
|
1673
|
+
var contentEle = this.tabObj.items[parseInt(i.toString(), 10)].content;
|
|
1674
|
+
for (var _i = 0, _a = tab.groups; _i < _a.length; _i++) {
|
|
1675
|
+
var group = _a[_i];
|
|
1676
|
+
var dropdownElement = void 0;
|
|
1677
|
+
var dropdown = void 0;
|
|
1678
|
+
if (this.activeLayout === RibbonLayout.Classic) {
|
|
1679
|
+
dropdownElement = group.isCollapsed ?
|
|
1680
|
+
contentEle.querySelector('#' + group.id + constants.OVERFLOW_ID + constants.DROPDOWN_ID) : null;
|
|
1681
|
+
}
|
|
1682
|
+
else {
|
|
1683
|
+
dropdownElement = group.enableGroupOverflow ?
|
|
1684
|
+
contentEle.querySelector('#' + group.id + constants.GROUPOF_BUTTON_ID) : null;
|
|
1685
|
+
dropdown = dropdownElement ? getComponent(dropdownElement, DropDownButton) : this.overflowDDB;
|
|
1686
|
+
if (dropdown) {
|
|
1687
|
+
updateTooltipProp(dropdown.target, commonProp);
|
|
1688
|
+
dropdown.setProperties(commonProp);
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
for (var _b = 0, _c = group.collections; _b < _c.length; _b++) {
|
|
1692
|
+
var collection = _c[_b];
|
|
1693
|
+
for (var _d = 0, _e = collection.items; _d < _e.length; _d++) {
|
|
1694
|
+
var item = _e[_d];
|
|
1695
|
+
var ele = null;
|
|
1696
|
+
if (this.activeLayout === RibbonLayout.Classic) {
|
|
1697
|
+
ele = dropdownElement ? this.ribbonDropDownModule.getDDBItemElement(dropdownElement, item.id) : contentEle.querySelector('#' + item.id);
|
|
1698
|
+
}
|
|
1699
|
+
else {
|
|
1700
|
+
//Checks for Simplified and Auto options (Auto = simplified + popup)
|
|
1701
|
+
ele = (item.displayOptions & DisplayMode.Simplified) ? contentEle.querySelector('#' + item.id) : null;
|
|
1702
|
+
// element will be null for "Popup" and if the item is moved to overflow in "Auto" mode
|
|
1703
|
+
if (!ele && (item.displayOptions !== DisplayMode.None)) {
|
|
1704
|
+
ele = dropdown.target.querySelector('#' + item.id);
|
|
1705
|
+
if (item.type === 'DropDown') {
|
|
1706
|
+
this.updatePopupItems(item, dropdown.target, group.enableGroupOverflow, true);
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
if (ele) {
|
|
1711
|
+
var moduleName = this.getItemModuleName(item);
|
|
1712
|
+
if (moduleName !== 'template') {
|
|
1713
|
+
updateCommonProperty(ele, moduleName, commonProp);
|
|
1714
|
+
}
|
|
1715
|
+
else if (!isNullOrUndefined(commonProp.enableRtl)) {
|
|
1716
|
+
ele.classList.toggle(constants.RTL_CSS, commonProp.enableRtl);
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
};
|
|
1724
|
+
Ribbon.prototype.removeLauncherIcon = function (groupId, dropdownElement, contentEle) {
|
|
1725
|
+
var containerId = groupId + constants.CONTAINER_ID;
|
|
1726
|
+
var containerEle = dropdownElement ? this.ribbonDropDownModule.getDDBItemElement(dropdownElement, containerId) : contentEle.querySelector('#' + containerId);
|
|
1727
|
+
if (containerEle) {
|
|
1728
|
+
containerEle.classList.remove(constants.RIBBON_LAUNCHER);
|
|
1729
|
+
var launcherIcon = containerEle.querySelector('#' + groupId + constants.LAUNCHER_ID);
|
|
1730
|
+
remove(launcherIcon);
|
|
1731
|
+
}
|
|
1732
|
+
};
|
|
1733
|
+
Ribbon.prototype.destroyTabItems = function (tabs) {
|
|
1734
|
+
for (var i = 0; i < tabs.length; i++) {
|
|
1735
|
+
var tab = tabs[parseInt(i.toString(), 10)];
|
|
1736
|
+
var contentEle = this.tabObj.items[parseInt(i.toString(), 10)].content;
|
|
1737
|
+
for (var _i = 0, _a = tab.groups; _i < _a.length; _i++) {
|
|
1738
|
+
var group = _a[_i];
|
|
1739
|
+
var dropdownElement = void 0;
|
|
1740
|
+
var dropdown = void 0;
|
|
1741
|
+
if (this.activeLayout === RibbonLayout.Classic) {
|
|
1742
|
+
dropdownElement = group.isCollapsed ?
|
|
1743
|
+
contentEle.querySelector('#' + group.id + constants.OVERFLOW_ID + constants.DROPDOWN_ID) : null;
|
|
1744
|
+
if (group.showLauncherIcon) {
|
|
1745
|
+
this.removeLauncherIcon(group.id, dropdownElement, contentEle);
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
else {
|
|
1749
|
+
dropdownElement = group.enableGroupOverflow ?
|
|
1750
|
+
contentEle.querySelector('#' + group.id + constants.GROUPOF_BUTTON_ID) : null;
|
|
1751
|
+
dropdown = dropdownElement ? getComponent(dropdownElement, DropDownButton) : this.overflowDDB;
|
|
1752
|
+
}
|
|
1753
|
+
for (var _b = 0, _c = group.collections; _b < _c.length; _b++) {
|
|
1754
|
+
var collection = _c[_b];
|
|
1755
|
+
for (var _d = 0, _e = collection.items; _d < _e.length; _d++) {
|
|
1756
|
+
var item = _e[_d];
|
|
1757
|
+
var ele = void 0;
|
|
1758
|
+
if (this.activeLayout === RibbonLayout.Classic) {
|
|
1759
|
+
ele = dropdownElement ? this.ribbonDropDownModule.getDDBItemElement(dropdownElement, item.id) :
|
|
1760
|
+
contentEle.querySelector('#' + item.id);
|
|
1761
|
+
}
|
|
1762
|
+
else {
|
|
1763
|
+
//Checks for Simplified and Auto options (Auto = simplified + popup)
|
|
1764
|
+
ele = (item.displayOptions & DisplayMode.Simplified) ?
|
|
1765
|
+
contentEle.querySelector('#' + item.id) : null;
|
|
1766
|
+
// element will be null for "Popup" and if the item is moved to overflow in "Auto" mode
|
|
1767
|
+
if (!ele && (item.displayOptions !== DisplayMode.None)) {
|
|
1768
|
+
ele = dropdown ? dropdown.target.querySelector('#' + item.id) : null;
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
if (ele) {
|
|
1772
|
+
this.destroyFunction(item, ele);
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
if ((this.activeLayout === RibbonLayout.Classic) && dropdownElement) {
|
|
1777
|
+
this.ribbonDropDownModule.removeOverFlowDropDown(dropdownElement);
|
|
1778
|
+
}
|
|
1779
|
+
else if ((this.activeLayout === RibbonLayout.Simplified) && group.enableGroupOverflow && dropdownElement) {
|
|
1780
|
+
this.removeOverflowButton(dropdown);
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
if (this.overflowDDB) {
|
|
1785
|
+
this.removeOverflowButton(this.overflowDDB);
|
|
1786
|
+
this.overflowDDB = null;
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
Ribbon.prototype.destroyFunction = function (item, ele) {
|
|
1790
|
+
var moduleName = this.getItemModuleName(item);
|
|
1791
|
+
if (moduleName !== 'template') {
|
|
1792
|
+
destroyControl(ele, moduleName);
|
|
1793
|
+
}
|
|
1794
|
+
if (item.ribbonTooltipSettings) {
|
|
1795
|
+
var index = getIndex(this.tooltipData, function (e) { return e.id === item.id + constants.CONTAINER_ID; });
|
|
1796
|
+
if (index !== -1) {
|
|
1797
|
+
this.tooltipData.splice(index, 1);
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
};
|
|
1801
|
+
Ribbon.prototype.getItemModuleName = function (item) {
|
|
1802
|
+
switch (item.type) {
|
|
1803
|
+
case 'Button':
|
|
1804
|
+
return 'btn';
|
|
1805
|
+
case 'DropDown':
|
|
1806
|
+
return 'dropdown-btn';
|
|
1807
|
+
case 'SplitButton':
|
|
1808
|
+
return 'split-btn';
|
|
1809
|
+
case 'CheckBox':
|
|
1810
|
+
return 'checkbox';
|
|
1811
|
+
case 'ColorPicker':
|
|
1812
|
+
return 'colorpicker';
|
|
1813
|
+
case 'ComboBox':
|
|
1814
|
+
return 'combobox';
|
|
1815
|
+
default:
|
|
1816
|
+
return 'template';
|
|
1817
|
+
}
|
|
1818
|
+
};
|
|
1819
|
+
Ribbon.prototype.clearOverflowResize = function () {
|
|
1820
|
+
this.destroyScroll();
|
|
1821
|
+
this.clearOverflowDropDown(this.selectedTab);
|
|
1822
|
+
var tab = this.tabs[this.selectedTab];
|
|
1823
|
+
var activeContent = this.tabObj.element.querySelector('#' + this.tabs[this.selectedTab].id + constants.CONTENT_ID);
|
|
1824
|
+
var tabContent = activeContent.closest('.' + constants.TAB_CONTENT);
|
|
1825
|
+
for (var j = 0; (j < tab.groups.length); j++) {
|
|
1826
|
+
this.checkSmallToMedium(this.selectedTab, tab, j, tabContent, activeContent, true, true);
|
|
1827
|
+
this.checkMediumToLarge(this.selectedTab, tab, j, tabContent, activeContent, true, true);
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
/**
|
|
1831
|
+
* Refreshes the layout.
|
|
1832
|
+
*
|
|
1833
|
+
* @returns {void}
|
|
1834
|
+
*/
|
|
1835
|
+
Ribbon.prototype.refreshLayout = function () {
|
|
1836
|
+
this.resizeHandler();
|
|
1837
|
+
};
|
|
1838
|
+
/**
|
|
1839
|
+
* Selects the tab
|
|
1840
|
+
*
|
|
1841
|
+
* @param {string} tabId - Gets the tab ID
|
|
1842
|
+
* @returns {void}
|
|
1843
|
+
*/
|
|
1844
|
+
Ribbon.prototype.selectTab = function (tabId) {
|
|
1845
|
+
var index = getIndex(this.tabs, function (e) { return e.id === tabId; });
|
|
1846
|
+
this.setProperties({ selectedTab: index });
|
|
1847
|
+
};
|
|
1848
|
+
/**
|
|
1849
|
+
* Adds the ribbon tab.
|
|
1850
|
+
*
|
|
1851
|
+
* @param {RibbonTabModel} tab - Gets the ribbon tab model
|
|
1852
|
+
* @param {string} targetId - Gets the ID of the target tab to add the new tab.
|
|
1853
|
+
* @param {boolean} isAfter - Defines whether the tab is added before or after the target.
|
|
1854
|
+
* @returns {void}
|
|
1855
|
+
*/
|
|
1856
|
+
Ribbon.prototype.addTab = function (tab, targetId, isAfter) {
|
|
1857
|
+
var index = targetId ? getIndex(this.tabs, function (e) { return e.id === targetId; }) : -1;
|
|
1858
|
+
index = (index === -1) ? this.tabs.length : (index + (isAfter ? 1 : 0));
|
|
1859
|
+
this.tabsInternal = this.tabs.slice();
|
|
1860
|
+
this.tabsInternal.splice(index, 0, tab);
|
|
1861
|
+
this.setProperties({ tabs: this.tabsInternal }, true);
|
|
1862
|
+
this.checkID([this.tabs[parseInt(index.toString(), 10)]], 'tab', this.element.id);
|
|
1863
|
+
this.tabsInternal = this.tabs.slice();
|
|
1864
|
+
this.validateItemSize();
|
|
1865
|
+
var tabItem = this.createTabItems([tab]);
|
|
1866
|
+
this.tabObj.addTab(tabItem, index);
|
|
1867
|
+
};
|
|
1868
|
+
/**
|
|
1869
|
+
* Removes the ribbon tab.
|
|
1870
|
+
*
|
|
1871
|
+
* @param {string} tabId - Gets the tab ID
|
|
1872
|
+
* @returns {void}
|
|
1873
|
+
*/
|
|
1874
|
+
Ribbon.prototype.removeTab = function (tabId) {
|
|
1875
|
+
var index = getIndex(this.tabs, function (e) { return e.id === tabId; });
|
|
1876
|
+
if (index === -1) {
|
|
1877
|
+
return;
|
|
1878
|
+
}
|
|
1879
|
+
var contentEle = this.tabObj.items[parseInt(index.toString(), 10)].content;
|
|
1880
|
+
var groups = this.tabs[parseInt(index.toString(), 10)].groups;
|
|
1881
|
+
if (groups && (contentEle.innerHTML !== '')) {
|
|
1882
|
+
for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
|
|
1883
|
+
var group = groups_1[_i];
|
|
1884
|
+
var dropdownElement = group.isCollapsed ? contentEle.querySelector('#' + group.id + constants.OVERFLOW_ID + constants.DROPDOWN_ID) : null;
|
|
1885
|
+
for (var _a = 0, _b = group.collections; _a < _b.length; _a++) {
|
|
1886
|
+
var collection = _b[_a];
|
|
1887
|
+
for (var _c = 0, _d = collection.items; _c < _d.length; _c++) {
|
|
1888
|
+
var item = _d[_c];
|
|
1889
|
+
var ele = dropdownElement ? this.ribbonDropDownModule.getDDBItemElement(dropdownElement, item.id) : contentEle.querySelector('#' + item.id);
|
|
1890
|
+
if (ele) {
|
|
1891
|
+
this.destroyFunction(item, ele);
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
if (dropdownElement) {
|
|
1896
|
+
this.ribbonDropDownModule.removeOverFlowDropDown(dropdownElement);
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
if (index === this.selectedTab) {
|
|
1901
|
+
this.isAddRemove = true;
|
|
1902
|
+
}
|
|
1903
|
+
this.tabsInternal = this.tabs.slice();
|
|
1904
|
+
this.tabsInternal.splice(index, 1);
|
|
1905
|
+
this.setProperties({ tabs: this.tabsInternal }, true);
|
|
1906
|
+
this.tabObj.removeTab(index);
|
|
1907
|
+
};
|
|
1908
|
+
/**
|
|
1909
|
+
* Adds the ribbon group.
|
|
1910
|
+
*
|
|
1911
|
+
* @param {string} tabId - Gets the tab ID.
|
|
1912
|
+
* @param {RibbonGroupModel} group - Gets the ribbon group model.
|
|
1913
|
+
* @param {string} targetId - Gets the ID of the target group to add the new group.
|
|
1914
|
+
* @param {boolean} isAfter - Defines whether the group is added before or after the target.
|
|
1915
|
+
* @returns {void}
|
|
1916
|
+
*/
|
|
1917
|
+
Ribbon.prototype.addGroup = function (tabId, group, targetId, isAfter) {
|
|
1918
|
+
var tabIndex = getIndex(this.tabs, function (e) { return e.id === tabId; });
|
|
1919
|
+
if (tabIndex === -1) {
|
|
1920
|
+
return;
|
|
1921
|
+
}
|
|
1922
|
+
if (this.selectedTab === tabIndex) {
|
|
1923
|
+
this.clearOverflowResize();
|
|
1924
|
+
}
|
|
1925
|
+
var tab = this.tabs[parseInt(tabIndex.toString(), 10)];
|
|
1926
|
+
var ribbonGroups = tab.groups.slice();
|
|
1927
|
+
var index = targetId ? getIndex(ribbonGroups, function (e) { return e.id === targetId; }) : -1;
|
|
1928
|
+
index = (index === -1) ? ribbonGroups.length : (index + (isAfter ? 1 : 0));
|
|
1929
|
+
ribbonGroups.splice(index, 0, group);
|
|
1930
|
+
tab.setProperties({ groups: ribbonGroups }, true);
|
|
1931
|
+
this.checkID([tab.groups[parseInt(index.toString(), 10)]], 'group', tabId);
|
|
1932
|
+
this.validateItemSize();
|
|
1933
|
+
//Check whether the tab items are rendered
|
|
1934
|
+
var contentEle = this.tabObj.items[parseInt(tabIndex.toString(), 10)].content;
|
|
1935
|
+
if (contentEle.innerHTML !== '') {
|
|
1936
|
+
var element = this.createGroups([tab.groups[parseInt(index.toString(), 10)]], tabIndex)[0];
|
|
1937
|
+
//insert the element in tab items property.
|
|
1938
|
+
var targetEle = targetId ? contentEle.querySelector('#' + targetId) : null;
|
|
1939
|
+
if (targetEle) {
|
|
1940
|
+
targetEle.insertAdjacentElement(isAfter ? 'afterend' : 'beforebegin', element);
|
|
1941
|
+
}
|
|
1942
|
+
else {
|
|
1943
|
+
contentEle.append(element);
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
if (this.selectedTab === tabIndex) {
|
|
1947
|
+
this.refreshLayout();
|
|
1948
|
+
}
|
|
1949
|
+
};
|
|
1950
|
+
/**
|
|
1951
|
+
* Removes the ribbon group.
|
|
1952
|
+
*
|
|
1953
|
+
* @param {string} groupId -Gets the group ID.
|
|
1954
|
+
* @returns {void}
|
|
1955
|
+
*/
|
|
1956
|
+
Ribbon.prototype.removeGroup = function (groupId) {
|
|
1957
|
+
var itemProp = getGroup(this.tabs, groupId);
|
|
1958
|
+
if (!itemProp) {
|
|
1959
|
+
return;
|
|
1960
|
+
}
|
|
1961
|
+
if (this.selectedTab === itemProp.tabIndex) {
|
|
1962
|
+
this.clearOverflowResize();
|
|
1963
|
+
}
|
|
1964
|
+
//Check whether the tab items are rendered
|
|
1965
|
+
var contentEle = this.tabObj.items[itemProp.tabIndex].content;
|
|
1966
|
+
if (contentEle.innerHTML !== '') {
|
|
1967
|
+
var dropdownElement = void 0;
|
|
1968
|
+
var dropdown = void 0;
|
|
1969
|
+
if (itemProp.group.showLauncherIcon) {
|
|
1970
|
+
this.removeLauncherIcon(itemProp.group.id, null, contentEle);
|
|
1971
|
+
}
|
|
1972
|
+
if (this.activeLayout === RibbonLayout.Simplified) {
|
|
1973
|
+
dropdownElement = itemProp.group.enableGroupOverflow ?
|
|
1974
|
+
contentEle.querySelector('#' + itemProp.group.id + constants.GROUPOF_BUTTON_ID) : null;
|
|
1975
|
+
dropdown = dropdownElement ? getComponent(dropdownElement, DropDownButton) : this.overflowDDB;
|
|
1976
|
+
}
|
|
1977
|
+
for (var _i = 0, _a = itemProp.group.collections; _i < _a.length; _i++) {
|
|
1978
|
+
var collection = _a[_i];
|
|
1979
|
+
for (var _b = 0, _c = collection.items; _b < _c.length; _b++) {
|
|
1980
|
+
var item = _c[_b];
|
|
1981
|
+
this.removeItemElement(contentEle, item, dropdown);
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
if (this.activeLayout === RibbonLayout.Simplified) {
|
|
1985
|
+
if (itemProp.group.enableGroupOverflow) {
|
|
1986
|
+
if (dropdown.target.childElementCount === 0) {
|
|
1987
|
+
this.removeOverflowButton(dropdown);
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
else {
|
|
1991
|
+
var ofGroupContainer = dropdown.target.querySelector('#' + itemProp.group.id + constants.CONTAINER_ID);
|
|
1992
|
+
if (ofGroupContainer && ofGroupContainer.childElementCount === 1) {
|
|
1993
|
+
ofGroupContainer.remove();
|
|
1994
|
+
}
|
|
1995
|
+
var ofTabContainer = dropdown.target.querySelector('#' + this.tabs[parseInt(itemProp.tabIndex.toString(), 10)].id + constants.OVERFLOW_ID);
|
|
1996
|
+
if (ofTabContainer && ofTabContainer.childElementCount === 0) {
|
|
1997
|
+
ofTabContainer.remove();
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
var groupEle = contentEle.querySelector('#' + groupId);
|
|
2002
|
+
if (groupEle) {
|
|
2003
|
+
groupEle.remove();
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
var ribbonGroups = this.tabs[itemProp.tabIndex].groups.slice();
|
|
2007
|
+
ribbonGroups.splice(itemProp.groupIndex, 1);
|
|
2008
|
+
this.tabs[itemProp.tabIndex].setProperties({ groups: ribbonGroups }, true);
|
|
2009
|
+
if (this.selectedTab === itemProp.tabIndex) {
|
|
2010
|
+
this.refreshLayout();
|
|
2011
|
+
}
|
|
2012
|
+
};
|
|
2013
|
+
/**
|
|
2014
|
+
* adds the ribbon collection.
|
|
2015
|
+
*
|
|
2016
|
+
* @param {string} groupId - Gets the ribbon group ID.
|
|
2017
|
+
* @param {RibbonCollectionModel} collection - Gets the ribbon collection model.
|
|
2018
|
+
* @param {string} targetId - Gets the ID of the target collection to add the new collection.
|
|
2019
|
+
* @param {boolean} isAfter - Defines whether the collection is added before or after the target.
|
|
2020
|
+
* @returns {void}
|
|
2021
|
+
*/
|
|
2022
|
+
Ribbon.prototype.addCollection = function (groupId, collection, targetId, isAfter) {
|
|
2023
|
+
var itemProp = getGroup(this.tabs, groupId);
|
|
2024
|
+
if (!itemProp) {
|
|
2025
|
+
return;
|
|
2026
|
+
}
|
|
2027
|
+
if ((itemProp.group.orientation === 'Row') && (itemProp.group.collections.length === 3)) {
|
|
2028
|
+
return;
|
|
2029
|
+
}
|
|
2030
|
+
if (this.selectedTab === itemProp.tabIndex) {
|
|
2031
|
+
this.clearOverflowResize();
|
|
2032
|
+
}
|
|
2033
|
+
var ribbonCollections = itemProp.group.collections.slice();
|
|
2034
|
+
var index = targetId ? getIndex(ribbonCollections, function (e) { return e.id === targetId; }) : -1;
|
|
2035
|
+
index = (index === -1) ? ribbonCollections.length : (index + (isAfter ? 1 : 0));
|
|
2036
|
+
ribbonCollections.splice(index, 0, collection);
|
|
2037
|
+
itemProp.group.setProperties({ collections: ribbonCollections }, true);
|
|
2038
|
+
this.checkID([itemProp.group.collections[parseInt(index.toString(), 10)]], 'collection', groupId);
|
|
2039
|
+
this.validateItemSize();
|
|
2040
|
+
var contentEle = this.tabObj.items[itemProp.tabIndex].content;
|
|
2041
|
+
if (contentEle.innerHTML !== '') {
|
|
2042
|
+
var collection_1 = itemProp.group.collections[parseInt(index.toString(), 10)];
|
|
2043
|
+
var element = this.createCollection([collection_1], itemProp.group.orientation, itemProp.group.id, itemProp.group.header, itemProp.group.enableGroupOverflow, itemProp.tabIndex)[0];
|
|
2044
|
+
if (itemProp.group.isCollapsed) {
|
|
2045
|
+
contentEle = this.ribbonDropDownModule.getOverflowDropDownPopup(itemProp, contentEle);
|
|
2046
|
+
}
|
|
2047
|
+
//insert the element in tab items property.
|
|
2048
|
+
var targetEle = targetId ? contentEle.querySelector('#' + targetId) : null;
|
|
2049
|
+
if (targetEle) {
|
|
2050
|
+
targetEle.insertAdjacentElement(isAfter ? 'afterend' : 'beforebegin', element);
|
|
2051
|
+
}
|
|
2052
|
+
else {
|
|
2053
|
+
contentEle.querySelector('#' + groupId + constants.CONTENT_ID).append(element);
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
if (this.selectedTab === itemProp.tabIndex) {
|
|
2057
|
+
this.refreshLayout();
|
|
2058
|
+
}
|
|
2059
|
+
};
|
|
2060
|
+
/**
|
|
2061
|
+
* Removes the ribbon collection.
|
|
2062
|
+
*
|
|
2063
|
+
* @param {string} collectionId - Gets the collection ID.
|
|
2064
|
+
* @returns {void}
|
|
2065
|
+
*/
|
|
2066
|
+
Ribbon.prototype.removeCollection = function (collectionId) {
|
|
2067
|
+
var itemProp = getCollection(this.tabs, collectionId);
|
|
2068
|
+
if (!itemProp) {
|
|
2069
|
+
return;
|
|
2070
|
+
}
|
|
2071
|
+
if (this.selectedTab === itemProp.tabIndex) {
|
|
2072
|
+
this.clearOverflowResize();
|
|
2073
|
+
}
|
|
2074
|
+
//Check whether the tab items are rendered
|
|
2075
|
+
var contentEle = this.tabObj.items[itemProp.tabIndex].content;
|
|
2076
|
+
if (contentEle.innerHTML !== '') {
|
|
2077
|
+
var dropdownElement = void 0;
|
|
2078
|
+
var dropdown = void 0;
|
|
2079
|
+
if (this.activeLayout === RibbonLayout.Simplified) {
|
|
2080
|
+
dropdownElement = itemProp.group.enableGroupOverflow ?
|
|
2081
|
+
contentEle.querySelector('#' + itemProp.group.id + constants.GROUPOF_BUTTON_ID) : null;
|
|
2082
|
+
dropdown = dropdownElement ? getComponent(dropdownElement, DropDownButton) : this.overflowDDB;
|
|
2083
|
+
}
|
|
2084
|
+
for (var _i = 0, _a = itemProp.collection.items; _i < _a.length; _i++) {
|
|
2085
|
+
var item = _a[_i];
|
|
2086
|
+
this.removeItemElement(contentEle, item, dropdown);
|
|
2087
|
+
}
|
|
2088
|
+
var groupEle = contentEle.querySelector('#' + collectionId);
|
|
2089
|
+
if (groupEle) {
|
|
2090
|
+
groupEle.remove();
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
var ribbonGroup = itemProp.group;
|
|
2094
|
+
var ribbonCollections = ribbonGroup.collections.slice();
|
|
2095
|
+
ribbonCollections.splice(itemProp.collectionIndex, 1);
|
|
2096
|
+
ribbonGroup.setProperties({ collections: ribbonCollections }, true);
|
|
2097
|
+
if (this.selectedTab === itemProp.tabIndex) {
|
|
2098
|
+
this.refreshLayout();
|
|
2099
|
+
}
|
|
2100
|
+
};
|
|
2101
|
+
/**
|
|
2102
|
+
* Adds ribbon item.
|
|
2103
|
+
*
|
|
2104
|
+
* @param {string} collectionId - Gets the collection ID.
|
|
2105
|
+
* @param {RibbonItemModel} item - Gets the ribbon item model.
|
|
2106
|
+
* @param {string} targetId - Gets the ID of the target item to add the new item.
|
|
2107
|
+
* @param {boolean} isAfter - Defines whether the item is added before or after the target.
|
|
2108
|
+
* @returns {void}
|
|
2109
|
+
*/
|
|
2110
|
+
Ribbon.prototype.addItem = function (collectionId, item, targetId, isAfter) {
|
|
2111
|
+
var itemProp = getCollection(this.tabs, collectionId);
|
|
2112
|
+
if (!itemProp) {
|
|
2113
|
+
return;
|
|
2114
|
+
}
|
|
2115
|
+
if ((itemProp.group.orientation === 'Column') && (itemProp.collection.items.length === 3)) {
|
|
2116
|
+
return;
|
|
2117
|
+
}
|
|
2118
|
+
if (this.selectedTab === itemProp.tabIndex) {
|
|
2119
|
+
this.clearOverflowResize();
|
|
2120
|
+
}
|
|
2121
|
+
var ribbonItems = itemProp.collection.items.slice();
|
|
2122
|
+
var index = targetId ? getIndex(ribbonItems, function (e) { return e.id === targetId; }) : -1;
|
|
2123
|
+
index = (index === -1) ? ribbonItems.length : (index + (isAfter ? 1 : 0));
|
|
2124
|
+
ribbonItems.splice(index, 0, item);
|
|
2125
|
+
itemProp.collection.setProperties({ items: ribbonItems }, true);
|
|
2126
|
+
this.checkID([itemProp.collection.items[parseInt(index.toString(), 10)]], 'item', collectionId);
|
|
2127
|
+
this.validateItemSize();
|
|
2128
|
+
var contentEle = this.tabObj.items[itemProp.tabIndex].content;
|
|
2129
|
+
var groupContainer = contentEle.querySelector('#' + itemProp.group.id + constants.CONTAINER_ID);
|
|
2130
|
+
if (contentEle.innerHTML !== '') {
|
|
2131
|
+
var item_1 = itemProp.collection.items[parseInt(index.toString(), 10)];
|
|
2132
|
+
var element = this.createItems([item_1], itemProp.group.orientation, itemProp.group.id, itemProp.group.header, itemProp.group.enableGroupOverflow, itemProp.tabIndex, groupContainer)[0];
|
|
2133
|
+
if (itemProp.group.isCollapsed) {
|
|
2134
|
+
contentEle = this.ribbonDropDownModule.getOverflowDropDownPopup(itemProp, contentEle);
|
|
2135
|
+
}
|
|
2136
|
+
//insert the element in tab items property.
|
|
2137
|
+
var targetEle = targetId ? contentEle.querySelector('#' + targetId) : null;
|
|
2138
|
+
if (targetEle) {
|
|
2139
|
+
targetEle.closest('.' + constants.RIBBON_ITEM).insertAdjacentElement(isAfter ? 'afterend' : 'beforebegin', element);
|
|
2140
|
+
}
|
|
2141
|
+
else {
|
|
2142
|
+
if (element) {
|
|
2143
|
+
contentEle.querySelector('#' + collectionId).append(element);
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
if (this.selectedTab === itemProp.tabIndex) {
|
|
2148
|
+
this.refreshLayout();
|
|
2149
|
+
}
|
|
2150
|
+
};
|
|
2151
|
+
/**
|
|
2152
|
+
* Removes ribbon item.
|
|
2153
|
+
*
|
|
2154
|
+
* @param {string} itemId - Gets the item ID.
|
|
2155
|
+
* @returns {void}
|
|
2156
|
+
*/
|
|
2157
|
+
Ribbon.prototype.removeItem = function (itemId) {
|
|
2158
|
+
var itemProp = getItem(this.tabs, itemId);
|
|
2159
|
+
if (!itemProp) {
|
|
2160
|
+
return;
|
|
2161
|
+
}
|
|
2162
|
+
if (this.selectedTab === itemProp.tabIndex) {
|
|
2163
|
+
this.clearOverflowResize();
|
|
2164
|
+
}
|
|
2165
|
+
//Check whether the tab items are rendered
|
|
2166
|
+
var contentEle = this.tabObj.items[itemProp.tabIndex].content;
|
|
2167
|
+
if (contentEle.innerHTML !== '') {
|
|
2168
|
+
var dropdownElement = void 0;
|
|
2169
|
+
var dropdown = void 0;
|
|
2170
|
+
if (this.activeLayout === RibbonLayout.Simplified) {
|
|
2171
|
+
dropdownElement = itemProp.group.enableGroupOverflow ?
|
|
2172
|
+
contentEle.querySelector('#' + itemProp.group.id + constants.GROUPOF_BUTTON_ID) : null;
|
|
2173
|
+
dropdown = dropdownElement ? getComponent(dropdownElement, DropDownButton) : this.overflowDDB;
|
|
2174
|
+
}
|
|
2175
|
+
var item = itemProp.item;
|
|
2176
|
+
this.removeItemElement(contentEle, item, dropdown);
|
|
2177
|
+
}
|
|
2178
|
+
var ribbonCollection = itemProp.collection;
|
|
2179
|
+
var ribbonItems = ribbonCollection.items;
|
|
2180
|
+
ribbonItems.splice(itemProp.itemIndex, 1);
|
|
2181
|
+
ribbonCollection.setProperties({ items: ribbonItems }, true);
|
|
2182
|
+
if (this.selectedTab === itemProp.tabIndex) {
|
|
2183
|
+
this.refreshLayout();
|
|
2184
|
+
}
|
|
2185
|
+
};
|
|
2186
|
+
Ribbon.prototype.removeItemElement = function (contentEle, item, dropdown) {
|
|
2187
|
+
var ele = null;
|
|
2188
|
+
if (this.activeLayout === RibbonLayout.Classic) {
|
|
2189
|
+
ele = contentEle.querySelector('#' + item.id);
|
|
2190
|
+
}
|
|
2191
|
+
else {
|
|
2192
|
+
//Checks for Simplified and Auto options (Auto = simplified + popup)
|
|
2193
|
+
ele = (item.displayOptions & DisplayMode.Simplified) ? contentEle.querySelector('#' + item.id) : null;
|
|
2194
|
+
// element will be null for "Popup" and if the item is moved to overflow in "Auto" mode
|
|
2195
|
+
if (!ele && (item.displayOptions !== DisplayMode.None)) {
|
|
2196
|
+
ele = dropdown.target.querySelector('#' + item.id);
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
if (ele) {
|
|
2200
|
+
this.destroyFunction(item, ele);
|
|
2201
|
+
ele.closest('#' + item.id + constants.CONTAINER_ID).remove();
|
|
2202
|
+
}
|
|
2203
|
+
};
|
|
2204
|
+
/**
|
|
2205
|
+
* Enables ribbon item.
|
|
2206
|
+
*
|
|
2207
|
+
* @param {string} itemId - Gets the item ID.
|
|
2208
|
+
* @returns {void}
|
|
2209
|
+
*/
|
|
2210
|
+
Ribbon.prototype.enableItem = function (itemId) {
|
|
2211
|
+
this.enableDisableItem(itemId, false);
|
|
2212
|
+
};
|
|
2213
|
+
/**
|
|
2214
|
+
* Disables ribbon item.
|
|
2215
|
+
*
|
|
2216
|
+
* @param {string} itemId - Gets the item ID.
|
|
2217
|
+
* @returns {void}
|
|
2218
|
+
*/
|
|
2219
|
+
Ribbon.prototype.disableItem = function (itemId) {
|
|
2220
|
+
this.enableDisableItem(itemId, true);
|
|
2221
|
+
};
|
|
2222
|
+
Ribbon.prototype.enableDisableItem = function (itemId, isDisabled) {
|
|
2223
|
+
var itemProp = getItem(this.tabs, itemId);
|
|
2224
|
+
if (!itemProp) {
|
|
2225
|
+
return;
|
|
2226
|
+
}
|
|
2227
|
+
itemProp.item.setProperties({ disabled: isDisabled }, true);
|
|
2228
|
+
var ele = getItemElement(this, itemId, itemProp);
|
|
2229
|
+
if (ele) {
|
|
2230
|
+
var itemEle = closest(ele, '.e-ribbon-item');
|
|
2231
|
+
itemEle.classList.toggle(constants.DISABLED_CSS, itemProp.item.disabled);
|
|
2232
|
+
var moduleName = this.getItemModuleName(itemProp.item);
|
|
2233
|
+
if (moduleName !== 'template') {
|
|
2234
|
+
updateControlDisabled(ele, moduleName, isDisabled);
|
|
2235
|
+
}
|
|
2236
|
+
else {
|
|
2237
|
+
ele.classList.toggle(constants.DISABLED_CSS, isDisabled);
|
|
2238
|
+
ele.toggleAttribute('disabled', isDisabled);
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
};
|
|
2242
|
+
Ribbon.prototype.unwireEvents = function () {
|
|
2243
|
+
EventHandler.remove(window, 'resize', this.resizeHandler);
|
|
2244
|
+
};
|
|
2245
|
+
Ribbon.prototype.destroy = function () {
|
|
2246
|
+
destroyTooltip(this.element);
|
|
2247
|
+
this.destroyTabItems(this.tabs);
|
|
2248
|
+
this.removeExpandCollapse();
|
|
2249
|
+
this.collapseButton = undefined;
|
|
2250
|
+
if (this.scrollModule) {
|
|
2251
|
+
this.scrollModule.destroy();
|
|
2252
|
+
}
|
|
2253
|
+
if (this.ribbonTempEle) {
|
|
2254
|
+
remove(this.ribbonTempEle);
|
|
2255
|
+
this.ribbonTempEle = null;
|
|
2256
|
+
}
|
|
2257
|
+
_super.prototype.destroy.call(this);
|
|
2258
|
+
this.tabObj.destroy();
|
|
2259
|
+
this.tabObj = undefined;
|
|
2260
|
+
remove(this.element.querySelector('#' + this.element.id + constants.TAB_ID));
|
|
2261
|
+
this.element.style.removeProperty(constants.RIBBON_FILE_MENU_WIDTH);
|
|
2262
|
+
this.element.style.removeProperty(constants.RIBBON_HELP_PANE_TEMPLATE_WIDTH);
|
|
2263
|
+
this.element.style.removeProperty('width');
|
|
2264
|
+
if (this.cssClass) {
|
|
2265
|
+
removeClass([this.element], this.cssClass.split(constants.SPACE));
|
|
2266
|
+
}
|
|
2267
|
+
this.element.classList.remove(constants.RTL_CSS, constants.RIBBON_SIMPLIFIED_MODE, constants.RIBBON_OVERFLOW, constants.RIBBON_COLLAPSIBLE, constants.RIBBON_MINIMIZE, 'e-rbn');
|
|
2268
|
+
this.unwireEvents();
|
|
2269
|
+
};
|
|
2270
|
+
/**
|
|
2271
|
+
* Called internally if any of the property value changed.
|
|
2272
|
+
*
|
|
2273
|
+
* @param {RibbonModel} newProp - Specifies new properties
|
|
2274
|
+
* @param {RibbonModel} oldProp - Specifies old properties
|
|
2275
|
+
* @returns {void}
|
|
2276
|
+
* @private
|
|
2277
|
+
*/
|
|
2278
|
+
Ribbon.prototype.onPropertyChanged = function (newProp, oldProp) {
|
|
2279
|
+
var _a, _b;
|
|
2280
|
+
for (var _i = 0, _c = Object.keys(newProp); _i < _c.length; _i++) {
|
|
2281
|
+
var prop = _c[_i];
|
|
2282
|
+
switch (prop) {
|
|
2283
|
+
case 'activeLayout':
|
|
2284
|
+
this.switchLayout();
|
|
2285
|
+
break;
|
|
2286
|
+
case 'cssClass':
|
|
2287
|
+
if (oldProp.cssClass) {
|
|
2288
|
+
(_a = this.element.classList).remove.apply(_a, oldProp.cssClass.split(constants.SPACE));
|
|
2289
|
+
}
|
|
2290
|
+
if (newProp.cssClass) {
|
|
2291
|
+
(_b = this.element.classList).add.apply(_b, newProp.cssClass.split(constants.SPACE));
|
|
2292
|
+
}
|
|
2293
|
+
break;
|
|
2294
|
+
case 'isMinimized':
|
|
2295
|
+
this.element.classList.toggle(constants.RIBBON_MINIMIZE, this.isMinimized);
|
|
2296
|
+
break;
|
|
2297
|
+
case 'locale':
|
|
2298
|
+
this.updateCommonProperty({ locale: this.locale });
|
|
2299
|
+
break;
|
|
2300
|
+
case 'enablePersistence':
|
|
2301
|
+
this.updateCommonProperty({ enablePersistence: this.enablePersistence });
|
|
2302
|
+
break;
|
|
2303
|
+
case 'enableRtl':
|
|
2304
|
+
this.element.classList.toggle(constants.RTL_CSS, this.enableRtl);
|
|
2305
|
+
this.updateCommonProperty({ enableRtl: newProp.enableRtl });
|
|
2306
|
+
break;
|
|
2307
|
+
case 'launcherIconCss':
|
|
2308
|
+
for (var i = 0; i < this.tabs.length; i++) {
|
|
2309
|
+
var tabContent = this.tabObj.items[parseInt(i.toString(), 10)].content;
|
|
2310
|
+
var tab = this.tabs[parseInt(i.toString(), 10)];
|
|
2311
|
+
if (tabContent.querySelector('.' + constants.RIBBON_GROUP)) {
|
|
2312
|
+
for (var _d = 0, _e = tab.groups; _d < _e.length; _d++) {
|
|
2313
|
+
var group = _e[_d];
|
|
2314
|
+
if (group.showLauncherIcon) {
|
|
2315
|
+
var className = constants.RIBBON_LAUNCHER_ICON_ELE + ' ' + (this.launcherIconCss || constants.RIBBON_LAUNCHER_ICON);
|
|
2316
|
+
if (group.isCollapsed) {
|
|
2317
|
+
var element = tabContent.querySelector('.' + constants.RIBBON_GROUP_OVERFLOW_DDB);
|
|
2318
|
+
var dropdown = getComponent(element, DropDownButton);
|
|
2319
|
+
var launcherIconEle = dropdown.target.querySelector('#' + group.id + constants.LAUNCHER_ID);
|
|
2320
|
+
launcherIconEle.className = className;
|
|
2321
|
+
}
|
|
2322
|
+
else {
|
|
2323
|
+
var element = tabContent.querySelector('#' + group.id + constants.LAUNCHER_ID);
|
|
2324
|
+
element.className = className;
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
break;
|
|
2331
|
+
case 'selectedTab':
|
|
2332
|
+
this.tabObj.setProperties({ selectedItem: newProp.selectedTab });
|
|
2333
|
+
break;
|
|
2334
|
+
case 'tabAnimation':
|
|
2335
|
+
this.tabObj.setProperties({ animation: newProp.tabAnimation });
|
|
2336
|
+
break;
|
|
2337
|
+
case 'tabs':
|
|
2338
|
+
this.reRenderTabs();
|
|
2339
|
+
break;
|
|
2340
|
+
case 'width':
|
|
2341
|
+
this.element.style.width = formatUnit(newProp.width);
|
|
2342
|
+
break;
|
|
2343
|
+
case 'fileMenu':
|
|
2344
|
+
if (this.ribbonFileMenuModule) {
|
|
2345
|
+
this.ribbonFileMenuModule.updateFileMenu(this.fileMenu);
|
|
2346
|
+
}
|
|
2347
|
+
break;
|
|
2348
|
+
case 'helpPaneTemplate':
|
|
2349
|
+
if (this.ribbonTempEle) {
|
|
2350
|
+
remove(this.ribbonTempEle);
|
|
2351
|
+
}
|
|
2352
|
+
if (this.helpPaneTemplate) {
|
|
2353
|
+
this.createHelpPaneTemplate();
|
|
2354
|
+
}
|
|
2355
|
+
break;
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
};
|
|
2359
|
+
var Ribbon_1;
|
|
2360
|
+
__decorate([
|
|
2361
|
+
Property('Classic')
|
|
2362
|
+
], Ribbon.prototype, "activeLayout", void 0);
|
|
2363
|
+
__decorate([
|
|
2364
|
+
Property('')
|
|
2365
|
+
], Ribbon.prototype, "cssClass", void 0);
|
|
2366
|
+
__decorate([
|
|
2367
|
+
Complex({}, FileMenuSettings)
|
|
2368
|
+
], Ribbon.prototype, "fileMenu", void 0);
|
|
2369
|
+
__decorate([
|
|
2370
|
+
Property('')
|
|
2371
|
+
], Ribbon.prototype, "launcherIconCss", void 0);
|
|
2372
|
+
__decorate([
|
|
2373
|
+
Property(false)
|
|
2374
|
+
], Ribbon.prototype, "isMinimized", void 0);
|
|
2375
|
+
__decorate([
|
|
2376
|
+
Property('en-us')
|
|
2377
|
+
], Ribbon.prototype, "locale", void 0);
|
|
2378
|
+
__decorate([
|
|
2379
|
+
Property(0)
|
|
2380
|
+
], Ribbon.prototype, "selectedTab", void 0);
|
|
2381
|
+
__decorate([
|
|
2382
|
+
Complex({}, TabAnimationSettings)
|
|
2383
|
+
], Ribbon.prototype, "tabAnimation", void 0);
|
|
2384
|
+
__decorate([
|
|
2385
|
+
Collection([], RibbonTab)
|
|
2386
|
+
], Ribbon.prototype, "tabs", void 0);
|
|
2387
|
+
__decorate([
|
|
2388
|
+
Property('100%')
|
|
2389
|
+
], Ribbon.prototype, "width", void 0);
|
|
2390
|
+
__decorate([
|
|
2391
|
+
Property('')
|
|
2392
|
+
], Ribbon.prototype, "helpPaneTemplate", void 0);
|
|
2393
|
+
__decorate([
|
|
2394
|
+
Event()
|
|
2395
|
+
], Ribbon.prototype, "tabSelecting", void 0);
|
|
2396
|
+
__decorate([
|
|
2397
|
+
Event()
|
|
2398
|
+
], Ribbon.prototype, "tabSelected", void 0);
|
|
2399
|
+
__decorate([
|
|
2400
|
+
Event()
|
|
2401
|
+
], Ribbon.prototype, "ribbonExpanding", void 0);
|
|
2402
|
+
__decorate([
|
|
2403
|
+
Event()
|
|
2404
|
+
], Ribbon.prototype, "ribbonCollapsing", void 0);
|
|
2405
|
+
__decorate([
|
|
2406
|
+
Event()
|
|
2407
|
+
], Ribbon.prototype, "launcherIconClick", void 0);
|
|
2408
|
+
Ribbon = Ribbon_1 = __decorate([
|
|
2409
|
+
NotifyPropertyChanges
|
|
2410
|
+
], Ribbon);
|
|
2411
|
+
return Ribbon;
|
|
2412
|
+
}(Component));
|
|
2413
|
+
export { Ribbon };
|