@syncfusion/ej2-ribbon 30.2.4 → 31.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ej2-ribbon.umd.min.js +1 -1
- package/dist/global/ej2-ribbon.min.js +1 -1
- package/dist/global/index.d.ts +1 -1
- package/dist/ts/index.d.ts +1 -0
- package/dist/ts/index.ts +3 -0
- package/dist/ts/ribbon/base/constant.d.ts +201 -0
- package/dist/ts/ribbon/base/constant.ts +204 -0
- package/dist/ts/ribbon/base/index.d.ts +8 -0
- package/dist/ts/ribbon/base/index.ts +8 -0
- package/dist/ts/ribbon/base/interface.d.ts +398 -0
- package/dist/ts/ribbon/base/interface.ts +424 -0
- package/dist/ts/ribbon/base/ribbon-model.d.ts +195 -0
- package/dist/ts/ribbon/base/ribbon.d.ts +608 -0
- package/dist/ts/ribbon/base/ribbon.ts +4896 -0
- package/dist/ts/ribbon/base/utils.d.ts +139 -0
- package/dist/ts/ribbon/base/utils.ts +341 -0
- package/dist/ts/ribbon/index.d.ts +7 -0
- package/dist/ts/ribbon/index.ts +7 -0
- package/dist/ts/ribbon/items/index.d.ts +8 -0
- package/dist/ts/ribbon/items/index.ts +8 -0
- package/dist/ts/ribbon/items/ribbon-button.d.ts +64 -0
- package/dist/ts/ribbon/items/ribbon-button.ts +160 -0
- package/dist/ts/ribbon/items/ribbon-checkbox.d.ts +55 -0
- package/dist/ts/ribbon/items/ribbon-checkbox.ts +130 -0
- package/dist/ts/ribbon/items/ribbon-colorpicker.d.ts +72 -0
- package/dist/ts/ribbon/items/ribbon-colorpicker.ts +228 -0
- package/dist/ts/ribbon/items/ribbon-combobox.d.ts +77 -0
- package/dist/ts/ribbon/items/ribbon-combobox.ts +201 -0
- package/dist/ts/ribbon/items/ribbon-dropdown.d.ts +128 -0
- package/dist/ts/ribbon/items/ribbon-dropdown.ts +400 -0
- package/dist/ts/ribbon/items/ribbon-gallery.d.ts +97 -0
- package/dist/ts/ribbon/items/ribbon-gallery.ts +773 -0
- package/dist/ts/ribbon/items/ribbon-groupbutton.d.ts +73 -0
- package/dist/ts/ribbon/items/ribbon-groupbutton.ts +531 -0
- package/dist/ts/ribbon/items/ribbon-splitbutton.d.ts +85 -0
- package/dist/ts/ribbon/items/ribbon-splitbutton.ts +257 -0
- package/dist/ts/ribbon/models/index.d.ts +42 -0
- package/dist/ts/ribbon/models/index.ts +44 -0
- package/dist/ts/ribbon/models/ribbon-back-button-model.d.ts +29 -0
- package/dist/ts/ribbon/models/ribbon-back-button.d.ts +24 -0
- package/dist/ts/ribbon/models/ribbon-back-button.ts +31 -0
- package/dist/ts/ribbon/models/ribbon-back-stage-settings-model.d.ts +83 -0
- package/dist/ts/ribbon/models/ribbon-back-stage-settings.d.ts +81 -0
- package/dist/ts/ribbon/models/ribbon-back-stage-settings.ts +109 -0
- package/dist/ts/ribbon/models/ribbon-backstage-item-model.d.ts +69 -0
- package/dist/ts/ribbon/models/ribbon-backstage-item.d.ts +80 -0
- package/dist/ts/ribbon/models/ribbon-backstage-item.ts +102 -0
- package/dist/ts/ribbon/models/ribbon-button-settings-model.d.ts +64 -0
- package/dist/ts/ribbon/models/ribbon-button-settings.d.ts +63 -0
- package/dist/ts/ribbon/models/ribbon-button-settings.ts +80 -0
- package/dist/ts/ribbon/models/ribbon-checkbox-settings-model.d.ts +57 -0
- package/dist/ts/ribbon/models/ribbon-checkbox-settings.d.ts +58 -0
- package/dist/ts/ribbon/models/ribbon-checkbox-settings.ts +74 -0
- package/dist/ts/ribbon/models/ribbon-collection-model.d.ts +30 -0
- package/dist/ts/ribbon/models/ribbon-collection.d.ts +33 -0
- package/dist/ts/ribbon/models/ribbon-collection.ts +45 -0
- package/dist/ts/ribbon/models/ribbon-colorpicker-settings-model.d.ts +137 -0
- package/dist/ts/ribbon/models/ribbon-colorpicker-settings.d.ts +129 -0
- package/dist/ts/ribbon/models/ribbon-colorpicker-settings.ts +165 -0
- package/dist/ts/ribbon/models/ribbon-combobox-settings-model.d.ts +275 -0
- package/dist/ts/ribbon/models/ribbon-combobox-settings.d.ts +257 -0
- package/dist/ts/ribbon/models/ribbon-combobox-settings.ts +313 -0
- package/dist/ts/ribbon/models/ribbon-contextual-tab-settings-model.d.ts +30 -0
- package/dist/ts/ribbon/models/ribbon-contextual-tab-settings.d.ts +33 -0
- package/dist/ts/ribbon/models/ribbon-contextual-tab-settings.ts +44 -0
- package/dist/ts/ribbon/models/ribbon-dropdown-settings-model.d.ts +114 -0
- package/dist/ts/ribbon/models/ribbon-dropdown-settings.d.ts +107 -0
- package/dist/ts/ribbon/models/ribbon-dropdown-settings.ts +139 -0
- package/dist/ts/ribbon/models/ribbon-file-menu-settings-model.d.ts +123 -0
- package/dist/ts/ribbon/models/ribbon-file-menu-settings.d.ts +173 -0
- package/dist/ts/ribbon/models/ribbon-file-menu-settings.ts +220 -0
- package/dist/ts/ribbon/models/ribbon-gallery-group-model.d.ts +44 -0
- package/dist/ts/ribbon/models/ribbon-gallery-group.d.ts +38 -0
- package/dist/ts/ribbon/models/ribbon-gallery-group.ts +50 -0
- package/dist/ts/ribbon/models/ribbon-gallery-item-model.d.ts +43 -0
- package/dist/ts/ribbon/models/ribbon-gallery-item.d.ts +38 -0
- package/dist/ts/ribbon/models/ribbon-gallery-item.ts +47 -0
- package/dist/ts/ribbon/models/ribbon-gallery-settings-model.d.ts +108 -0
- package/dist/ts/ribbon/models/ribbon-gallery-settings.d.ts +95 -0
- package/dist/ts/ribbon/models/ribbon-gallery-settings.ts +123 -0
- package/dist/ts/ribbon/models/ribbon-group-button-item-model.d.ts +64 -0
- package/dist/ts/ribbon/models/ribbon-group-button-item.d.ts +65 -0
- package/dist/ts/ribbon/models/ribbon-group-button-item.ts +85 -0
- package/dist/ts/ribbon/models/ribbon-group-button-settings-model.d.ts +32 -0
- package/dist/ts/ribbon/models/ribbon-group-button-settings.d.ts +29 -0
- package/dist/ts/ribbon/models/ribbon-group-button-settings.ts +38 -0
- package/dist/ts/ribbon/models/ribbon-group-model.d.ts +112 -0
- package/dist/ts/ribbon/models/ribbon-group.d.ts +105 -0
- package/dist/ts/ribbon/models/ribbon-group.ts +138 -0
- package/dist/ts/ribbon/models/ribbon-item-model.d.ts +144 -0
- package/dist/ts/ribbon/models/ribbon-item.d.ts +141 -0
- package/dist/ts/ribbon/models/ribbon-item.ts +190 -0
- package/dist/ts/ribbon/models/ribbon-splitbutton-settings-model.d.ts +114 -0
- package/dist/ts/ribbon/models/ribbon-splitbutton-settings.d.ts +107 -0
- package/dist/ts/ribbon/models/ribbon-splitbutton-settings.ts +140 -0
- package/dist/ts/ribbon/models/ribbon-tab-model.d.ts +44 -0
- package/dist/ts/ribbon/models/ribbon-tab.d.ts +45 -0
- package/dist/ts/ribbon/models/ribbon-tab.ts +61 -0
- package/dist/ts/ribbon/models/ribbon-tooltip-model.d.ts +43 -0
- package/dist/ts/ribbon/models/ribbon-tooltip.d.ts +36 -0
- package/dist/ts/ribbon/models/ribbon-tooltip.ts +47 -0
- package/dist/ts/ribbon/modules/index.d.ts +4 -0
- package/dist/ts/ribbon/modules/index.ts +5 -0
- package/dist/ts/ribbon/modules/ribbon-backstage.d.ts +117 -0
- package/dist/ts/ribbon/modules/ribbon-backstage.ts +620 -0
- package/dist/ts/ribbon/modules/ribbon-contextualtab.d.ts +27 -0
- package/dist/ts/ribbon/modules/ribbon-contextualtab.ts +93 -0
- package/dist/ts/ribbon/modules/ribbon-filemenu.d.ts +96 -0
- package/dist/ts/ribbon/modules/ribbon-filemenu.ts +353 -0
- package/dist/ts/ribbon/modules/ribbon-keytip.d.ts +56 -0
- package/dist/ts/ribbon/modules/ribbon-keytip.ts +580 -0
- package/package.json +55 -19
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Ribbon } from '../base/ribbon';
|
|
2
|
+
import { RibbonTabModel } from '../models';
|
|
3
|
+
import * as constants from '../base/constant';
|
|
4
|
+
import { RibbonContextualTabSettingsModel } from '../models/ribbon-contextual-tab-settings-model';
|
|
5
|
+
import { isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Defines the ribbon contextual tab.
|
|
9
|
+
*/
|
|
10
|
+
export class RibbonContextualTab {
|
|
11
|
+
private parent: Ribbon;
|
|
12
|
+
|
|
13
|
+
constructor(parent: Ribbon) {
|
|
14
|
+
this.parent = parent;
|
|
15
|
+
}
|
|
16
|
+
protected getModuleName(): string {
|
|
17
|
+
return 'ribbonContextualTab';
|
|
18
|
+
}
|
|
19
|
+
protected destroy(): void {
|
|
20
|
+
this.parent = null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates Contextual tab.
|
|
25
|
+
*
|
|
26
|
+
* @returns {void}
|
|
27
|
+
* @hidden
|
|
28
|
+
*/
|
|
29
|
+
public addContextualTabs(): void {
|
|
30
|
+
let isSelected: boolean = false;
|
|
31
|
+
for (let n: number = 0; n < this.parent.contextualTabs.length; n++) {
|
|
32
|
+
for (let i: number = 0; i < this.parent.contextualTabs[parseInt(n.toString(), 10)].tabs.length; i++) {
|
|
33
|
+
this.parent.addTab(this.parent.contextualTabs[parseInt(n.toString(), 10)].tabs[parseInt(i.toString(), 10)]);
|
|
34
|
+
const index: number = this.parent.tabs.length - 1;
|
|
35
|
+
const tabEle: HTMLElement = this.parent.tabObj.element;
|
|
36
|
+
const toolbarEle: HTMLElement = tabEle.querySelectorAll('.e-toolbar-item')[parseInt(index.toString(), 10)] as HTMLElement;
|
|
37
|
+
toolbarEle.classList.add(constants.RIBBON_CONTEXTUAL_TAB);
|
|
38
|
+
toolbarEle.classList.add('e-hidden');
|
|
39
|
+
if (this.parent.contextualTabs[parseInt(n.toString(), 10)].visible) {
|
|
40
|
+
this.parent.showTab(this.parent.contextualTabs[parseInt(n.toString(), 10)].tabs[parseInt(i.toString(), 10)].id, true);
|
|
41
|
+
if (this.parent.contextualTabs[parseInt(n.toString(), 10)].isSelected && !isSelected) {
|
|
42
|
+
this.parent.selectTab(this.parent.contextualTabs[parseInt(n.toString(), 10)].tabs[0].id);
|
|
43
|
+
isSelected = true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Updates Contextual tab.
|
|
52
|
+
*
|
|
53
|
+
* @param {RibbonContextualTabSettingsModel} newProp - Specifies new properties.
|
|
54
|
+
* @param {RibbonContextualTabSettingsModel} contextualTab - Gets the property of contextual tab.
|
|
55
|
+
* @returns {void}
|
|
56
|
+
* @hidden
|
|
57
|
+
*/
|
|
58
|
+
public updateContextualTabs(newProp: RibbonContextualTabSettingsModel, contextualTab: RibbonContextualTabSettingsModel): void {
|
|
59
|
+
if (!(isNullOrUndefined(newProp.visible))) {
|
|
60
|
+
for (let i: number = 0; i < contextualTab.tabs.length; i++) {
|
|
61
|
+
if (newProp.visible) {
|
|
62
|
+
this.parent.showTab(contextualTab.tabs[parseInt(i.toString(), 10)].id, true);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.parent.hideTab(contextualTab.tabs[parseInt(i.toString(), 10)].id, true);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!(isNullOrUndefined(newProp.isSelected))) {
|
|
70
|
+
if (newProp.isSelected && contextualTab.visible) {
|
|
71
|
+
this.parent.selectTab(contextualTab.tabs[0].id);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const tabEle: HTMLElement = this.parent.tabObj.element;
|
|
75
|
+
for (let i: number = 0; i < this.parent.tabs.length; i++) {
|
|
76
|
+
const toolbarEle: HTMLElement = tabEle.querySelectorAll('.e-toolbar-item')[parseInt(i.toString(), 10)] as HTMLElement;
|
|
77
|
+
if (!(toolbarEle.classList.contains('e-hidden') || toolbarEle.classList.contains('e-disable'))) {
|
|
78
|
+
this.parent.selectTab(this.parent.tabs[parseInt(i.toString(), 10)].id);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (newProp.tabs) {
|
|
85
|
+
for (const key of Object.keys(newProp.tabs)) {
|
|
86
|
+
const index: number = parseInt(key, 10);
|
|
87
|
+
const tab: RibbonTabModel = this.parent.tabs.filter((e: RibbonTabModel) =>
|
|
88
|
+
e.id === contextualTab.tabs[parseInt(index.toString(), 10)].id)[0];
|
|
89
|
+
this.parent.updateTab(tab);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { MenuItem, MenuItemModel } from '@syncfusion/ej2-navigations';
|
|
2
|
+
import { FileMenuSettingsModel } from '../models/index';
|
|
3
|
+
import { commonProperties, Ribbon } from '../base/index';
|
|
4
|
+
/**
|
|
5
|
+
* Defines the items of Ribbon.
|
|
6
|
+
*/
|
|
7
|
+
export declare class RibbonFileMenu {
|
|
8
|
+
private parent;
|
|
9
|
+
private fileMenuDDB;
|
|
10
|
+
private menuctrl;
|
|
11
|
+
private ddbElement;
|
|
12
|
+
constructor(parent: Ribbon);
|
|
13
|
+
protected getModuleName(): string;
|
|
14
|
+
protected destroy(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Creates File Menu
|
|
17
|
+
*
|
|
18
|
+
* @param {FileMenuSettingsModel} fileMenuOptions - Gets the property of filemenu.
|
|
19
|
+
* @returns {void}
|
|
20
|
+
* @hidden
|
|
21
|
+
*/
|
|
22
|
+
createFileMenu(fileMenuOptions: FileMenuSettingsModel): void;
|
|
23
|
+
private addFileMenuTooltip;
|
|
24
|
+
private addFileMenuKeytip;
|
|
25
|
+
private ddbBeforeEvent;
|
|
26
|
+
private ddbAfterEvent;
|
|
27
|
+
private cloneMenuItem;
|
|
28
|
+
private createRibbonMenu;
|
|
29
|
+
private menuBeforeEvent;
|
|
30
|
+
private menuAfterEvent;
|
|
31
|
+
private beforeItemRender;
|
|
32
|
+
private menuSelect;
|
|
33
|
+
/**
|
|
34
|
+
* setRtl
|
|
35
|
+
*
|
|
36
|
+
* @param {commonProperties} commonProp - Get the common property of ribbon.
|
|
37
|
+
* @returns {void}
|
|
38
|
+
* @hidden
|
|
39
|
+
*/
|
|
40
|
+
setCommonProperties(commonProp: commonProperties): void;
|
|
41
|
+
/**
|
|
42
|
+
* Update FileMenu
|
|
43
|
+
*
|
|
44
|
+
* @param {FileMenuSettingsModel} fileMenuOptions - Gets the property of filemenu.
|
|
45
|
+
* @returns {void}
|
|
46
|
+
* @hidden
|
|
47
|
+
*/
|
|
48
|
+
updateFileMenu(fileMenuOptions: FileMenuSettingsModel): void;
|
|
49
|
+
private destroyMenu;
|
|
50
|
+
private destroyDDB;
|
|
51
|
+
private removeFileMenuTooltip;
|
|
52
|
+
private removeFileMenuKeytip;
|
|
53
|
+
/**
|
|
54
|
+
* Add items to FileMenu.
|
|
55
|
+
*
|
|
56
|
+
* @param {MenuItemModel[]} items - Gets the items to be added.
|
|
57
|
+
* @param {string} target - Gets the target item to add the items.
|
|
58
|
+
* @param {boolean} isAfter - Gets the boolean value to add the items after or before the target item.
|
|
59
|
+
* @param {boolean} isUniqueId - Gets whether the target provided is uniqueId or not.
|
|
60
|
+
* @returns {void}
|
|
61
|
+
*/
|
|
62
|
+
addItems(items: MenuItemModel[], target: string, isAfter: boolean, isUniqueId?: boolean): void;
|
|
63
|
+
/**
|
|
64
|
+
* Remove items from FileMenu.
|
|
65
|
+
*
|
|
66
|
+
* @param {string[]} items - Gets the items to be removed.
|
|
67
|
+
* @param {boolean} isUniqueId - Gets whether the target provided is uniqueId or not.
|
|
68
|
+
* @returns {void}
|
|
69
|
+
*/
|
|
70
|
+
removeItems(items: string[], isUniqueId?: boolean): void;
|
|
71
|
+
/**
|
|
72
|
+
* Enable items in FileMenu.
|
|
73
|
+
*
|
|
74
|
+
* @param {string[]} items - Gets the items to be enabled.
|
|
75
|
+
* @param {boolean} isUniqueId - Gets whether the target provided is uniqueId or not.
|
|
76
|
+
* @returns {void}
|
|
77
|
+
*/
|
|
78
|
+
enableItems(items: string[], isUniqueId?: boolean): void;
|
|
79
|
+
/**
|
|
80
|
+
* Disable items in FileMenu.
|
|
81
|
+
*
|
|
82
|
+
* @param {string[]} items - Gets the items to be disabled.
|
|
83
|
+
* @param {boolean} isUniqueId - Gets whether the target provided is uniqueId or not.
|
|
84
|
+
* @returns {void}
|
|
85
|
+
*/
|
|
86
|
+
disableItems(items: string[], isUniqueId?: boolean): void;
|
|
87
|
+
/**
|
|
88
|
+
* Update items in FileMenu.
|
|
89
|
+
*
|
|
90
|
+
* @param {MenuItem} item - Gets the item to be updated.
|
|
91
|
+
* @param {boolean} id - Gets the id of the item to be updated.
|
|
92
|
+
* @param {boolean} isUniqueId - Gets whether the id provided is uniqueId or not.
|
|
93
|
+
* @returns {void}
|
|
94
|
+
*/
|
|
95
|
+
setItem(item: MenuItem, id?: string, isUniqueId?: boolean): void;
|
|
96
|
+
}
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { EmitType, EventHandler, remove } from '@syncfusion/ej2-base';
|
|
2
|
+
import { DropDownButton } from '@syncfusion/ej2-splitbuttons';
|
|
3
|
+
import { Menu, MenuEventArgs, MenuItem, MenuItemModel } from '@syncfusion/ej2-navigations';
|
|
4
|
+
import { BeforeOpenCloseMenuEventArgs as BeforeDDBArgs, OpenCloseMenuEventArgs as AfterDDBArgs } from '@syncfusion/ej2-splitbuttons';
|
|
5
|
+
import { BeforeOpenCloseMenuEventArgs as BeforeMenuArgs, OpenCloseMenuEventArgs as AfterMenuArgs } from '@syncfusion/ej2-navigations';
|
|
6
|
+
import { FileMenuBeforeOpenCloseEventArgs, FileMenuEventArgs, FileMenuOpenCloseEventArgs, FileMenuSettings, FileMenuSettingsModel } from '../models/index';
|
|
7
|
+
import { commonProperties, getIndex, isTooltipPresent, Ribbon, ribbonTooltipData } from '../base/index';
|
|
8
|
+
import * as constants from '../base/constant';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Defines the items of Ribbon.
|
|
12
|
+
*/
|
|
13
|
+
export class RibbonFileMenu {
|
|
14
|
+
private parent: Ribbon;
|
|
15
|
+
private fileMenuDDB: DropDownButton;
|
|
16
|
+
private menuctrl: Menu;
|
|
17
|
+
private ddbElement: HTMLButtonElement;
|
|
18
|
+
|
|
19
|
+
constructor(parent: Ribbon) {
|
|
20
|
+
this.parent = parent;
|
|
21
|
+
}
|
|
22
|
+
protected getModuleName(): string {
|
|
23
|
+
return 'ribbonFileMenu';
|
|
24
|
+
}
|
|
25
|
+
protected destroy(): void {
|
|
26
|
+
if (this.fileMenuDDB) {
|
|
27
|
+
this.destroyDDB();
|
|
28
|
+
}
|
|
29
|
+
this.parent = null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Creates File Menu
|
|
34
|
+
*
|
|
35
|
+
* @param {FileMenuSettingsModel} fileMenuOptions - Gets the property of filemenu.
|
|
36
|
+
* @returns {void}
|
|
37
|
+
* @hidden
|
|
38
|
+
*/
|
|
39
|
+
public createFileMenu(fileMenuOptions: FileMenuSettingsModel): void {
|
|
40
|
+
if (!fileMenuOptions.visible) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
this.ddbElement = this.parent.createElement('button', {
|
|
44
|
+
id: this.parent.element.id + constants.RIBBON_FILE_MENU_ID
|
|
45
|
+
});
|
|
46
|
+
const tabEle: HTMLElement = this.parent.tabObj.element;
|
|
47
|
+
const toolbarEle: HTMLElement = tabEle.querySelector('.e-toolbar');
|
|
48
|
+
tabEle.insertBefore(this.ddbElement, toolbarEle);
|
|
49
|
+
this.fileMenuDDB = new DropDownButton({
|
|
50
|
+
content: fileMenuOptions.text,
|
|
51
|
+
enableRtl: this.parent.enableRtl,
|
|
52
|
+
cssClass: 'e-ribbon-file-menu e-caret-hide',
|
|
53
|
+
created: () => {
|
|
54
|
+
tabEle.style.setProperty(constants.RIBBON_FILE_MENU_WIDTH, this.ddbElement.offsetWidth + 'px');
|
|
55
|
+
},
|
|
56
|
+
beforeClose: this.ddbBeforeEvent.bind(this, false),
|
|
57
|
+
beforeOpen: this.ddbBeforeEvent.bind(this, true),
|
|
58
|
+
close: this.ddbAfterEvent.bind(this, false),
|
|
59
|
+
open: this.ddbAfterEvent.bind(this, true)
|
|
60
|
+
}, this.ddbElement);
|
|
61
|
+
if (this.parent.fileMenu.popupTemplate) {
|
|
62
|
+
this.fileMenuDDB.setProperties({ target: this.parent.fileMenu.popupTemplate });
|
|
63
|
+
} else {
|
|
64
|
+
this.createRibbonMenu(fileMenuOptions);
|
|
65
|
+
}
|
|
66
|
+
this.parent.tabObj.refreshActiveTabBorder();
|
|
67
|
+
this.addFileMenuTooltip(fileMenuOptions);
|
|
68
|
+
this.addFileMenuKeytip();
|
|
69
|
+
}
|
|
70
|
+
private addFileMenuTooltip(fileMenuOptions: FileMenuSettingsModel): void {
|
|
71
|
+
if (isTooltipPresent(fileMenuOptions.ribbonTooltipSettings)) {
|
|
72
|
+
this.ddbElement.classList.add(constants.RIBBON_TOOLTIP_TARGET);
|
|
73
|
+
this.parent.tooltipData.push({ id: this.ddbElement.id, data: fileMenuOptions.ribbonTooltipSettings });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
private addFileMenuKeytip(): void {
|
|
77
|
+
if (this.parent.fileMenu.keyTip) {
|
|
78
|
+
((this.parent.keyTipElements as {[key: string]: object})['filemenu'] as object[]) = [];
|
|
79
|
+
((this.parent.keyTipElements as {[key: string]: object})['filemenu'] as object[]).push({ id: this.ddbElement.id, type: 'filemenu', keyTip: this.parent.fileMenu.keyTip});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
private ddbBeforeEvent(isOpen: boolean, args: BeforeDDBArgs): void {
|
|
83
|
+
//args.event is null when dropdown button is closed using a method call
|
|
84
|
+
if (!isOpen && args.event && (args.event.target as HTMLElement).closest('.e-ribbon-menu')) {
|
|
85
|
+
args.cancel = true;
|
|
86
|
+
}
|
|
87
|
+
const event: EmitType<FileMenuBeforeOpenCloseEventArgs> = isOpen ? this.parent.fileMenu.beforeOpen :
|
|
88
|
+
this.parent.fileMenu.beforeClose;
|
|
89
|
+
if (event) {
|
|
90
|
+
const eventArgs: FileMenuBeforeOpenCloseEventArgs = { cancel: args.cancel, element: args.element, event: args.event };
|
|
91
|
+
event.call(this, eventArgs);
|
|
92
|
+
args.cancel = eventArgs.cancel;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
private ddbAfterEvent(isOpen: boolean, args: AfterDDBArgs): void {
|
|
96
|
+
const element: HTMLElement = isOpen ? this.fileMenuDDB.target as HTMLElement : this.fileMenuDDB.element;
|
|
97
|
+
element.focus();
|
|
98
|
+
const event: EmitType<FileMenuOpenCloseEventArgs> = isOpen ? this.parent.fileMenu.open : this.parent.fileMenu.close;
|
|
99
|
+
if (event) {
|
|
100
|
+
const eventArgs: FileMenuOpenCloseEventArgs = { element: args.element };
|
|
101
|
+
event.call(this, eventArgs);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//Clone RibbonMenuItems before assigning to avoid reference issues.
|
|
105
|
+
private cloneMenuItem(items: MenuItemModel[]): MenuItemModel[] {
|
|
106
|
+
const itemsList: MenuItemModel[] = [];
|
|
107
|
+
for (let i: number = 0; i < items.length; i++) {
|
|
108
|
+
const item: MenuItemModel = items[parseInt(i.toString(), 10)];
|
|
109
|
+
itemsList.push({
|
|
110
|
+
iconCss: item.iconCss,
|
|
111
|
+
id: item.id,
|
|
112
|
+
separator: item.separator,
|
|
113
|
+
text: item.text,
|
|
114
|
+
url: item.url,
|
|
115
|
+
items: this.cloneMenuItem(item.items)
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return itemsList;
|
|
119
|
+
}
|
|
120
|
+
private createRibbonMenu(menuOptions: FileMenuSettingsModel): void {
|
|
121
|
+
const ulElem: HTMLUListElement = this.parent.createElement('ul', {
|
|
122
|
+
id: this.parent.element.id + constants.RIBBON_FILE_MENU_LIST
|
|
123
|
+
});
|
|
124
|
+
this.fileMenuDDB.setProperties({ target: ulElem });
|
|
125
|
+
this.menuctrl = new Menu({
|
|
126
|
+
orientation: 'Vertical',
|
|
127
|
+
enableRtl: this.parent.enableRtl,
|
|
128
|
+
cssClass: 'e-ribbon-menu',
|
|
129
|
+
animationSettings: menuOptions.animationSettings,
|
|
130
|
+
items: this.cloneMenuItem(menuOptions.menuItems),
|
|
131
|
+
showItemOnClick: menuOptions.showItemOnClick,
|
|
132
|
+
template: menuOptions.itemTemplate as string | Function,
|
|
133
|
+
beforeClose: this.menuBeforeEvent.bind(this, false),
|
|
134
|
+
beforeOpen: this.menuBeforeEvent.bind(this, true),
|
|
135
|
+
beforeItemRender: this.beforeItemRender.bind(this),
|
|
136
|
+
onClose: this.menuAfterEvent.bind(this, false),
|
|
137
|
+
onOpen: this.menuAfterEvent.bind(this, true),
|
|
138
|
+
select: this.menuSelect.bind(this)
|
|
139
|
+
}, ulElem);
|
|
140
|
+
EventHandler.add(ulElem, 'keydown', (e: KeyboardEvent) => {
|
|
141
|
+
if (e.key === 'Tab') { this.fileMenuDDB.toggle(); }
|
|
142
|
+
}, this);
|
|
143
|
+
}
|
|
144
|
+
private menuBeforeEvent(isOpen: boolean, args: BeforeMenuArgs): void {
|
|
145
|
+
const event: EmitType<FileMenuBeforeOpenCloseEventArgs> = isOpen ? this.parent.fileMenu.beforeOpen :
|
|
146
|
+
this.parent.fileMenu.beforeClose;
|
|
147
|
+
if (event) {
|
|
148
|
+
const eventArgs: FileMenuBeforeOpenCloseEventArgs = {
|
|
149
|
+
cancel: args.cancel, element: args.element, event: args.event,
|
|
150
|
+
items: args.items, parentItem: args.parentItem
|
|
151
|
+
};
|
|
152
|
+
event.call(this, eventArgs);
|
|
153
|
+
args.cancel = eventArgs.cancel;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
private menuAfterEvent(isOpen: boolean, args: AfterMenuArgs): void {
|
|
157
|
+
const event: EmitType<FileMenuOpenCloseEventArgs> = isOpen ? this.parent.fileMenu.open : this.parent.fileMenu.close;
|
|
158
|
+
if (event) {
|
|
159
|
+
const eventArgs: FileMenuOpenCloseEventArgs = { element: args.element, items: args.items, parentItem: args.parentItem };
|
|
160
|
+
event.call(this, eventArgs);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
private beforeItemRender(args: MenuEventArgs): void {
|
|
164
|
+
const event: EmitType<FileMenuEventArgs> = this.parent.fileMenu.beforeItemRender;
|
|
165
|
+
if (event) {
|
|
166
|
+
const eventArgs: FileMenuEventArgs = { element: args.element, item: args.item };
|
|
167
|
+
event.call(this, eventArgs);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
private menuSelect(args: MenuEventArgs): void {
|
|
171
|
+
const event: EmitType<FileMenuEventArgs> = this.parent.fileMenu.select;
|
|
172
|
+
if (event) {
|
|
173
|
+
const eventArgs: FileMenuEventArgs = { element: args.element, item: args.item, event: args.event };
|
|
174
|
+
event.call(this, eventArgs);
|
|
175
|
+
}
|
|
176
|
+
const menuOpen: boolean = !!args.element.closest('.e-ribbon-menu.e-popup-open');
|
|
177
|
+
const fileTriggerOpen: boolean = !!args.element.closest('.e-ribbon-file-menu.e-popup-open');
|
|
178
|
+
const fileMenuOpen: boolean = !!document.querySelector('.e-ribbon-file-menu.e-popup-open');
|
|
179
|
+
// True if the file trigger was clicked open, or if the ribbon menu is open and the file menu popup is actually present
|
|
180
|
+
const isMenuOpen: boolean = fileTriggerOpen || (menuOpen && fileMenuOpen);
|
|
181
|
+
if (!args.element.classList.contains('e-menu-caret-icon') && isMenuOpen) {
|
|
182
|
+
this.fileMenuDDB.toggle();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* setRtl
|
|
188
|
+
*
|
|
189
|
+
* @param {commonProperties} commonProp - Get the common property of ribbon.
|
|
190
|
+
* @returns {void}
|
|
191
|
+
* @hidden
|
|
192
|
+
*/
|
|
193
|
+
public setCommonProperties(commonProp: commonProperties): void {
|
|
194
|
+
if (this.fileMenuDDB) {
|
|
195
|
+
this.fileMenuDDB.setProperties(commonProp);
|
|
196
|
+
if (this.menuctrl) {
|
|
197
|
+
this.menuctrl.setProperties(commonProp);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Update FileMenu
|
|
204
|
+
*
|
|
205
|
+
* @param {FileMenuSettingsModel} fileMenuOptions - Gets the property of filemenu.
|
|
206
|
+
* @returns {void}
|
|
207
|
+
* @hidden
|
|
208
|
+
*/
|
|
209
|
+
public updateFileMenu(fileMenuOptions: FileMenuSettingsModel): void {
|
|
210
|
+
if (fileMenuOptions.visible) {
|
|
211
|
+
if (this.fileMenuDDB) {
|
|
212
|
+
if (fileMenuOptions.text) {
|
|
213
|
+
this.fileMenuDDB.setProperties({
|
|
214
|
+
content: fileMenuOptions.text
|
|
215
|
+
});
|
|
216
|
+
this.parent.tabObj.element.style.setProperty(constants.RIBBON_FILE_MENU_WIDTH, this.ddbElement.offsetWidth + 'px');
|
|
217
|
+
}
|
|
218
|
+
if (fileMenuOptions.popupTemplate) {
|
|
219
|
+
if (this.menuctrl) {
|
|
220
|
+
this.destroyMenu();
|
|
221
|
+
}
|
|
222
|
+
this.fileMenuDDB.setProperties({ target: fileMenuOptions.popupTemplate });
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
if (this.menuctrl) {
|
|
226
|
+
this.menuctrl.setProperties({
|
|
227
|
+
animationSettings: fileMenuOptions.animationSettings,
|
|
228
|
+
items: this.cloneMenuItem(fileMenuOptions.menuItems),
|
|
229
|
+
showItemOnClick: fileMenuOptions.showItemOnClick,
|
|
230
|
+
template: fileMenuOptions.itemTemplate
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
this.createRibbonMenu(fileMenuOptions);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
this.removeFileMenuTooltip();
|
|
238
|
+
this.removeFileMenuKeytip();
|
|
239
|
+
this.addFileMenuTooltip(fileMenuOptions);
|
|
240
|
+
this.addFileMenuKeytip();
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
this.createFileMenu(fileMenuOptions);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
else if (this.fileMenuDDB) {
|
|
247
|
+
this.destroyDDB();
|
|
248
|
+
}
|
|
249
|
+
this.parent.tabObj.refreshActiveTabBorder();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private destroyMenu(): void {
|
|
253
|
+
if (this.menuctrl) {
|
|
254
|
+
this.menuctrl.destroy();
|
|
255
|
+
this.menuctrl = null;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
private destroyDDB(): void {
|
|
259
|
+
this.removeFileMenuTooltip();
|
|
260
|
+
this.removeFileMenuKeytip();
|
|
261
|
+
const tabEle: HTMLElement = this.parent.tabObj.element;
|
|
262
|
+
tabEle.style.removeProperty(constants.RIBBON_FILE_MENU_WIDTH);
|
|
263
|
+
this.destroyMenu();
|
|
264
|
+
this.fileMenuDDB.destroy();
|
|
265
|
+
this.fileMenuDDB = null;
|
|
266
|
+
remove(this.ddbElement);
|
|
267
|
+
this.ddbElement = null;
|
|
268
|
+
}
|
|
269
|
+
private removeFileMenuTooltip(): void {
|
|
270
|
+
const index: number = getIndex(this.parent.tooltipData, (e: ribbonTooltipData) => { return e.id === this.ddbElement.id; });
|
|
271
|
+
if (index !== -1) {
|
|
272
|
+
this.ddbElement.classList.remove(constants.RIBBON_TOOLTIP_TARGET);
|
|
273
|
+
this.parent.tooltipData.splice(index, 1);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
private removeFileMenuKeytip(): void {
|
|
277
|
+
if ((this.parent.keyTipElements as {[key: string]: object})['filemenu']) {
|
|
278
|
+
const index: number = getIndex(((this.parent.keyTipElements as {[key: string]: object})['filemenu'] as object[]), (e: { [key: string]: string }) => { return e.id === this.ddbElement.id; });
|
|
279
|
+
if (index !== -1) {
|
|
280
|
+
((this.parent.keyTipElements as {[key: string]: object})['filemenu'] as object[]).splice(index, 1);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Add items to FileMenu.
|
|
287
|
+
*
|
|
288
|
+
* @param {MenuItemModel[]} items - Gets the items to be added.
|
|
289
|
+
* @param {string} target - Gets the target item to add the items.
|
|
290
|
+
* @param {boolean} isAfter - Gets the boolean value to add the items after or before the target item.
|
|
291
|
+
* @param {boolean} isUniqueId - Gets whether the target provided is uniqueId or not.
|
|
292
|
+
* @returns {void}
|
|
293
|
+
*/
|
|
294
|
+
public addItems(items: MenuItemModel[], target: string, isAfter: boolean, isUniqueId?: boolean): void {
|
|
295
|
+
if (isAfter) {
|
|
296
|
+
this.menuctrl.insertAfter(items, target, isUniqueId);
|
|
297
|
+
} else {
|
|
298
|
+
this.menuctrl.insertBefore(items, target, isUniqueId);
|
|
299
|
+
}
|
|
300
|
+
(this.parent.fileMenu as FileMenuSettings).setProperties({ menuItems: this.menuctrl.items }, true);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Remove items from FileMenu.
|
|
305
|
+
*
|
|
306
|
+
* @param {string[]} items - Gets the items to be removed.
|
|
307
|
+
* @param {boolean} isUniqueId - Gets whether the target provided is uniqueId or not.
|
|
308
|
+
* @returns {void}
|
|
309
|
+
*/
|
|
310
|
+
public removeItems(items: string[], isUniqueId?: boolean): void {
|
|
311
|
+
this.menuctrl.removeItems(items, isUniqueId);
|
|
312
|
+
(this.parent.fileMenu as FileMenuSettings).setProperties({ menuItems: this.menuctrl.items }, true);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Enable items in FileMenu.
|
|
317
|
+
*
|
|
318
|
+
* @param {string[]} items - Gets the items to be enabled.
|
|
319
|
+
* @param {boolean} isUniqueId - Gets whether the target provided is uniqueId or not.
|
|
320
|
+
* @returns {void}
|
|
321
|
+
*/
|
|
322
|
+
public enableItems(items: string[], isUniqueId?: boolean): void {
|
|
323
|
+
this.menuctrl.enableItems(items, true, isUniqueId);
|
|
324
|
+
(this.parent.fileMenu as FileMenuSettings).setProperties({ menuItems: this.menuctrl.items }, true);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Disable items in FileMenu.
|
|
329
|
+
*
|
|
330
|
+
* @param {string[]} items - Gets the items to be disabled.
|
|
331
|
+
* @param {boolean} isUniqueId - Gets whether the target provided is uniqueId or not.
|
|
332
|
+
* @returns {void}
|
|
333
|
+
*/
|
|
334
|
+
public disableItems(items: string[], isUniqueId?: boolean): void {
|
|
335
|
+
this.menuctrl.enableItems(items, false, isUniqueId);
|
|
336
|
+
(this.parent.fileMenu as FileMenuSettings).setProperties({ menuItems: this.menuctrl.items }, true);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Update items in FileMenu.
|
|
341
|
+
*
|
|
342
|
+
* @param {MenuItem} item - Gets the item to be updated.
|
|
343
|
+
* @param {boolean} id - Gets the id of the item to be updated.
|
|
344
|
+
* @param {boolean} isUniqueId - Gets whether the id provided is uniqueId or not.
|
|
345
|
+
* @returns {void}
|
|
346
|
+
*/
|
|
347
|
+
public setItem(item: MenuItem, id?: string, isUniqueId?: boolean): void {
|
|
348
|
+
this.menuctrl.setItem(item, id, isUniqueId);
|
|
349
|
+
this.menuctrl.refresh();
|
|
350
|
+
(this.parent.fileMenu as FileMenuSettings).setProperties({ menuItems: this.menuctrl.items }, true);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Ribbon } from '../base';
|
|
2
|
+
/**
|
|
3
|
+
* Defines the keytip of Ribbon.
|
|
4
|
+
*/
|
|
5
|
+
export declare class RibbonKeyTip {
|
|
6
|
+
private parent;
|
|
7
|
+
private isKeytipPopupOpen;
|
|
8
|
+
private isKeytipPresent;
|
|
9
|
+
constructor(parent: Ribbon);
|
|
10
|
+
protected getModuleName(): string;
|
|
11
|
+
protected destroy(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Creates the keytips.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} key - get's the keytip type.
|
|
16
|
+
* @returns {void}
|
|
17
|
+
* @hidden
|
|
18
|
+
*/
|
|
19
|
+
createKeytip(key?: string): void;
|
|
20
|
+
private calculateItemPosition;
|
|
21
|
+
private createKeyTipElement;
|
|
22
|
+
private calculateKeyTipPosition;
|
|
23
|
+
/**
|
|
24
|
+
* Performs keytip action.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} keyPress - Gets the keytip text.
|
|
27
|
+
* @param {boolean} isMethod - Gets the isMethod.
|
|
28
|
+
* @returns {void}
|
|
29
|
+
* @hidden
|
|
30
|
+
*/
|
|
31
|
+
keytipPress(keyPress: string, isMethod?: boolean): void;
|
|
32
|
+
private clickItems;
|
|
33
|
+
private isInteractableElement;
|
|
34
|
+
private commonItemsKeyTipPress;
|
|
35
|
+
/**
|
|
36
|
+
* Removes the keytip.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} key - Gets the keyboard key element.
|
|
39
|
+
* @returns {void}
|
|
40
|
+
* @hidden
|
|
41
|
+
*/
|
|
42
|
+
removeKeytip(key?: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Shows the Keytip dynamically.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} keyAction - Item for which the tooltip is to be shown.
|
|
47
|
+
* @returns {void}
|
|
48
|
+
*/
|
|
49
|
+
showKeyTips(keyAction?: string): void;
|
|
50
|
+
/**
|
|
51
|
+
* Hides the Keytip dynamically.
|
|
52
|
+
*
|
|
53
|
+
* @returns {void}
|
|
54
|
+
*/
|
|
55
|
+
hideKeyTips(): void;
|
|
56
|
+
}
|