tabulator-tables 5.0.7 → 5.1.0
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/.editorconfig +6 -0
- package/LICENSE +1 -1
- package/bower.json +1 -1
- package/build/rollup.js +1 -1
- package/dist/css/tabulator.css +15 -2
- package/dist/css/tabulator.css.map +1 -1
- package/dist/css/tabulator.min.css +1 -1
- package/dist/css/tabulator.min.css.map +1 -1
- package/dist/css/tabulator_bootstrap3.css +15 -2
- package/dist/css/tabulator_bootstrap3.css.map +1 -1
- package/dist/css/tabulator_bootstrap3.min.css +1 -1
- package/dist/css/tabulator_bootstrap3.min.css.map +1 -1
- package/dist/css/tabulator_bootstrap4.css +15 -2
- package/dist/css/tabulator_bootstrap4.css.map +1 -1
- package/dist/css/tabulator_bootstrap4.min.css +1 -1
- package/dist/css/tabulator_bootstrap4.min.css.map +1 -1
- package/dist/css/tabulator_bulma.css +15 -2
- package/dist/css/tabulator_bulma.css.map +1 -1
- package/dist/css/tabulator_bulma.min.css +1 -1
- package/dist/css/tabulator_bulma.min.css.map +1 -1
- package/dist/css/tabulator_materialize.css +22 -6
- package/dist/css/tabulator_materialize.css.map +1 -1
- package/dist/css/tabulator_materialize.min.css +1 -1
- package/dist/css/tabulator_materialize.min.css.map +1 -1
- package/dist/css/tabulator_midnight.css +19 -2
- package/dist/css/tabulator_midnight.css.map +1 -1
- package/dist/css/tabulator_midnight.min.css +1 -1
- package/dist/css/tabulator_midnight.min.css.map +1 -1
- package/dist/css/tabulator_modern.css +15 -2
- package/dist/css/tabulator_modern.css.map +1 -1
- package/dist/css/tabulator_modern.min.css +1 -1
- package/dist/css/tabulator_modern.min.css.map +1 -1
- package/dist/css/tabulator_semanticui.css +15 -2
- package/dist/css/tabulator_semanticui.css.map +1 -1
- package/dist/css/tabulator_semanticui.min.css +1 -1
- package/dist/css/tabulator_semanticui.min.css.map +1 -1
- package/dist/css/tabulator_simple.css +15 -2
- package/dist/css/tabulator_simple.css.map +1 -1
- package/dist/css/tabulator_simple.min.css +1 -1
- package/dist/css/tabulator_simple.min.css.map +1 -1
- package/dist/css/tabulator_site.css +19 -2
- package/dist/css/tabulator_site.css.map +1 -1
- package/dist/css/tabulator_site.min.css +1 -1
- package/dist/css/tabulator_site.min.css.map +1 -1
- package/dist/js/tabulator.js +1121 -533
- package/dist/js/tabulator.js.map +1 -1
- package/dist/js/tabulator.min.js +2 -2
- package/dist/js/tabulator.min.js.map +1 -1
- package/dist/js/tabulator_esm.js +1566 -991
- package/dist/js/tabulator_esm.js.map +1 -1
- package/dist/js/tabulator_esm.min.js +2 -2
- package/dist/js/tabulator_esm.min.js.map +1 -1
- package/package.json +1 -1
- package/src/js/core/ColumnManager.js +4 -2
- package/src/js/core/CoreFeature.js +1 -5
- package/src/js/core/RowManager.js +15 -9
- package/src/js/core/Tabulator.js +14 -59
- package/src/js/core/cell/Cell.js +5 -1
- package/src/js/core/column/Column.js +21 -6
- package/src/js/core/column/ColumnComponent.js +4 -0
- package/src/js/core/column/defaults/options.js +1 -0
- package/src/js/core/defaults/options.js +3 -3
- package/src/js/core/modules/optional.js +1 -0
- package/src/js/core/rendering/Renderer.js +3 -2
- package/src/js/core/rendering/renderers/BasicVertical.js +2 -1
- package/src/js/core/rendering/renderers/VirtualDomHorizontal.js +165 -151
- package/src/js/core/rendering/renderers/VirtualDomVertical.js +1 -1
- package/src/js/core/row/Row.js +2 -2
- package/src/js/core/tools/{ComponentFuctionBinder.js → ComponentFunctionBinder.js} +1 -1
- package/src/js/core/tools/DataLoader.js +6 -6
- package/src/js/core/tools/InteractionMonitor.js +149 -49
- package/src/js/core/tools/OptionsList.js +2 -2
- package/src/js/modules/Ajax/Ajax.js +62 -82
- package/src/js/modules/ColumnCalcs/ColumnCalcs.js +15 -2
- package/src/js/modules/DataTree/DataTree.js +23 -9
- package/src/js/modules/Download/defaults/downloaders/json.js +1 -1
- package/src/js/modules/Download/defaults/downloaders/jsonLines.js +32 -0
- package/src/js/modules/Download/defaults/downloaders/pdf.js +0 -2
- package/src/js/modules/Download/defaults/downloaders/xlsx.js +3 -2
- package/src/js/modules/Download/defaults/downloaders.js +2 -0
- package/src/js/modules/Edit/Edit.js +27 -39
- package/src/js/modules/Edit/defaults/editors/progress.js +2 -2
- package/src/js/modules/Export/Export.js +1 -1
- package/src/js/modules/Filter/Filter.js +2 -2
- package/src/js/modules/Format/defaults/formatters/datetime.js +2 -2
- package/src/js/modules/Format/defaults/formatters/datetimediff.js +2 -1
- package/src/js/modules/FrozenColumns/FrozenColumns.js +1 -1
- package/src/js/modules/FrozenRows/FrozenRows.js +9 -0
- package/src/js/modules/GroupRows/Group.js +18 -67
- package/src/js/modules/GroupRows/GroupRows.js +8 -3
- package/src/js/modules/HtmlTableImport/HtmlTableImport.js +4 -7
- package/src/js/modules/Import/Import.js +197 -0
- package/src/js/modules/Import/defaults/importers/csv.js +63 -0
- package/src/js/modules/Import/defaults/importers/json.js +8 -0
- package/src/js/modules/Import/defaults/importers.js +7 -0
- package/src/js/modules/Interaction/Interaction.js +5 -0
- package/src/js/modules/Keybindings/Keybindings.js +9 -14
- package/src/js/modules/Keybindings/defaults/bindings.js +3 -3
- package/src/js/modules/Localize/defaults/langs.js +6 -0
- package/src/js/modules/Menu/Menu.js +200 -155
- package/src/js/modules/MoveColumns/MoveColumns.js +58 -57
- package/src/js/modules/MoveRows/MoveRows.js +4 -0
- package/src/js/modules/Page/Page.js +279 -183
- package/src/js/modules/Page/defaults/pageCounters/pages.js +33 -0
- package/src/js/modules/Page/defaults/pageCounters/rows.js +32 -0
- package/src/js/modules/Page/defaults/pageCounters.js +8 -0
- package/src/js/modules/ResizeRows/ResizeRows.js +1 -1
- package/src/js/modules/ResponsiveLayout/ResponsiveLayout.js +3 -5
- package/src/js/modules/SelectRow/SelectRow.js +4 -8
- package/src/js/modules/Sort/Sort.js +1 -1
- package/src/js/modules/Sort/defaults/sorters/datetime.js +3 -2
- package/src/js/modules/Validate/Validate.js +7 -5
- package/src/scss/tabulator.scss +20 -2
- package/src/scss/themes/materialize/tabulator_materialize.scss +5 -4
- package/src/scss/themes/tabulator_midnight.scss +4 -0
- package/src/scss/themes/tabulator_site.scss +4 -0
|
@@ -2,164 +2,194 @@ import Module from '../../core/Module.js';
|
|
|
2
2
|
import Helpers from '../../core/tools/Helpers.js';
|
|
3
3
|
|
|
4
4
|
class Menu extends Module{
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
constructor(table){
|
|
7
7
|
super(table);
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
this.menuContainer = null;
|
|
9
10
|
this.menuElements = [];
|
|
10
11
|
this.blurEvent = this.hideMenu.bind(this);
|
|
11
12
|
this.escEvent = this.escMenu.bind(this);
|
|
12
13
|
this.nestedMenuBlock = false;
|
|
13
14
|
this.positionReversedX = false;
|
|
14
|
-
|
|
15
|
+
|
|
16
|
+
this.currentComponent = null;
|
|
17
|
+
|
|
18
|
+
this.columnSubscribers = {};
|
|
19
|
+
|
|
15
20
|
this.registerTableOption("rowContextMenu", false);
|
|
16
21
|
this.registerTableOption("rowClickMenu", false);
|
|
17
22
|
this.registerTableOption("groupContextMenu", false);
|
|
18
23
|
this.registerTableOption("groupClickMenu", false);
|
|
19
|
-
|
|
24
|
+
this.registerTableOption("menuContainer", false);
|
|
25
|
+
|
|
20
26
|
this.registerColumnOption("headerContextMenu");
|
|
27
|
+
this.registerColumnOption("headerClickMenu");
|
|
21
28
|
this.registerColumnOption("headerMenu");
|
|
22
29
|
this.registerColumnOption("contextMenu");
|
|
23
30
|
this.registerColumnOption("clickMenu");
|
|
24
31
|
}
|
|
25
|
-
|
|
32
|
+
|
|
26
33
|
initialize(){
|
|
27
|
-
this.
|
|
34
|
+
this.lookupMenuContainer();
|
|
35
|
+
|
|
36
|
+
this.initializeRowWatchers();
|
|
37
|
+
this.initializeGroupWatchers();
|
|
38
|
+
|
|
28
39
|
this.subscribe("column-init", this.initializeColumn.bind(this));
|
|
29
|
-
this.subscribe("row-init", this.initializeRow.bind(this));
|
|
30
40
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
|
|
42
|
+
lookupMenuContainer(){
|
|
43
|
+
|
|
44
|
+
this.menuContainer = this.table.options.menuContainer;
|
|
45
|
+
|
|
46
|
+
if(typeof this.menuContainer === "string"){
|
|
47
|
+
this.menuContainer = document.querySelector(this.menuContainer);
|
|
48
|
+
|
|
49
|
+
if(!this.menuContainer){
|
|
50
|
+
console.warn("Menu Error - no container element found matching selector:", this.table.options.menuContainer , "(defaulting to document body)");
|
|
51
|
+
}
|
|
52
|
+
}else if (this.menuContainer === true){
|
|
53
|
+
this.menuContainer = this.table.element;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if(this.menuContainer && !this.checkMenuContainerIsParent(this.menuContainer)){
|
|
57
|
+
this.menuContainer = false;
|
|
58
|
+
console.warn("Menu Error - container element does not contain this table:", this.table.options.menuContainer , "(defaulting to document body)");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if(!this.menuContainer){
|
|
62
|
+
this.menuContainer = document.body;
|
|
35
63
|
}
|
|
36
64
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this.
|
|
65
|
+
|
|
66
|
+
checkMenuContainerIsParent(container, element = this.table.element){
|
|
67
|
+
if(container === element){
|
|
68
|
+
return true;
|
|
69
|
+
}else{
|
|
70
|
+
return element.parentNode ? this.checkMenuContainerIsParent(container, element.parentNode) : false;
|
|
43
71
|
}
|
|
44
72
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
column.getElement().addEventListener("contextmenu", this.LoadMenuEvent.bind(this, column, column.definition.headerContextMenu));
|
|
51
|
-
this.tapHold(column, column.definition.headerContextMenu);
|
|
73
|
+
|
|
74
|
+
initializeRowWatchers(){
|
|
75
|
+
if(this.table.options.rowContextMenu){
|
|
76
|
+
this.subscribe("row-contextmenu", this.loadMenuEvent.bind(this, this.table.options.rowContextMenu));
|
|
77
|
+
this.table.on("rowTapHold", this.loadMenuEvent.bind(this, this.table.options.rowContextMenu));
|
|
52
78
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// }
|
|
57
|
-
|
|
58
|
-
if(column.definition.headerMenu){
|
|
59
|
-
|
|
60
|
-
headerMenuEl = document.createElement("span");
|
|
61
|
-
headerMenuEl.classList.add("tabulator-header-menu-button");
|
|
62
|
-
headerMenuEl.innerHTML = "⋮";
|
|
63
|
-
|
|
64
|
-
headerMenuEl.addEventListener("click", (e) => {
|
|
65
|
-
e.stopPropagation();
|
|
66
|
-
e.preventDefault();
|
|
67
|
-
|
|
68
|
-
this.LoadMenuEvent(column, column.definition.headerMenu, e);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
column.titleElement.insertBefore(headerMenuEl, column.titleElement.firstChild);
|
|
79
|
+
|
|
80
|
+
if(this.table.options.rowClickMenu){
|
|
81
|
+
this.subscribe("row-click", this.loadMenuEvent.bind(this, this.table.options.rowClickMenu));
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
|
|
85
|
+
initializeGroupWatchers(){
|
|
86
|
+
if(this.table.options.groupContextMenu){
|
|
87
|
+
this.subscribe("group-contextmenu", this.loadMenuEvent.bind(this, this.table.options.groupContextMenu));
|
|
88
|
+
this.table.on("groupTapHold", this.loadMenuEvent.bind(this, this.table.options.groupContextMenu));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if(this.table.options.groupClickMenu){
|
|
92
|
+
this.subscribe("group-click", this.loadMenuEvent.bind(this, this.table.options.groupClickMenu));
|
|
93
|
+
}
|
|
83
94
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
var
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
95
|
+
|
|
96
|
+
initializeColumn(column){
|
|
97
|
+
var options = ["headerContextMenu", "headerClickMenu"],
|
|
98
|
+
def = column.definition;
|
|
99
|
+
|
|
100
|
+
//handle column events
|
|
101
|
+
if(def.headerContextMenu && !this.columnSubscribers.headerContextMenu){
|
|
102
|
+
this.columnSubscribers.headerContextMenu = this.loadMenuTableColumnEvent.bind(this, "headerContextMenu");
|
|
103
|
+
this.subscribe("column-contextmenu", this.columnSubscribers.headerContextMenu);
|
|
104
|
+
this.table.on("headerTapHold", this.loadMenuTableColumnEvent.bind(this, "headerContextMenu"))
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if(def.headerClickMenu && !this.columnSubscribers.headerClickMenu){
|
|
108
|
+
this.columnSubscribers.headerClickMenu = this.loadMenuTableColumnEvent.bind(this, "headerClickMenu");
|
|
109
|
+
this.subscribe("column-click", this.columnSubscribers.headerClickMenu);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if(def.headerMenu){
|
|
113
|
+
this.initializeColumnHeaderMenu(column);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
//handle cell events
|
|
117
|
+
if(def.contextMenu && !this.columnSubscribers.contextMenu){
|
|
118
|
+
this.columnSubscribers.contextMenu = this.loadMenuTableCellEvent.bind(this, "contextMenu");
|
|
119
|
+
this.subscribe("cell-contextmenu", this.columnSubscribers.contextMenu);
|
|
120
|
+
this.table.on("cellTapHold", this.loadMenuTableCellEvent.bind(this, "contextMenu"))
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if(def.clickMenu && !this.columnSubscribers.clickMenu){
|
|
124
|
+
this.columnSubscribers.clickMenu = this.loadMenuTableCellEvent.bind(this, "clickMenu");
|
|
125
|
+
this.subscribe("cell-click", this.columnSubscribers.clickMenu);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
initializeColumnHeaderMenu(column){
|
|
130
|
+
var headerMenuEl;
|
|
131
|
+
|
|
132
|
+
headerMenuEl = document.createElement("span");
|
|
133
|
+
headerMenuEl.classList.add("tabulator-header-menu-button");
|
|
134
|
+
headerMenuEl.innerHTML = "⋮";
|
|
135
|
+
|
|
136
|
+
headerMenuEl.addEventListener("click", (e) => {
|
|
137
|
+
e.stopPropagation();
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
|
|
140
|
+
this.loadMenuEvent(column.definition.headerMenu, e, column);
|
|
111
141
|
});
|
|
142
|
+
|
|
143
|
+
column.titleElement.insertBefore(headerMenuEl, column.titleElement.firstChild);
|
|
112
144
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if(cell.
|
|
116
|
-
cell
|
|
117
|
-
this.tapHold(cell, cell.column.definition.contextMenu);
|
|
145
|
+
|
|
146
|
+
loadMenuTableCellEvent(option, e, cell){
|
|
147
|
+
if(cell._cell){
|
|
148
|
+
cell = cell._cell;
|
|
118
149
|
}
|
|
119
|
-
|
|
120
|
-
if(cell.column.definition
|
|
121
|
-
|
|
150
|
+
|
|
151
|
+
if(cell.column.definition[option]){
|
|
152
|
+
this.loadMenuEvent(cell.column.definition[option], e, cell);
|
|
122
153
|
}
|
|
123
154
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if(
|
|
127
|
-
|
|
128
|
-
this.tapHold(row, this.table.options.rowContextMenu);
|
|
155
|
+
|
|
156
|
+
loadMenuTableColumnEvent(option, e, column){
|
|
157
|
+
if(column._column){
|
|
158
|
+
column = column._column;
|
|
129
159
|
}
|
|
130
|
-
|
|
131
|
-
if(
|
|
132
|
-
|
|
160
|
+
|
|
161
|
+
if(column.definition[option]){
|
|
162
|
+
this.loadMenuEvent(column.definition[option], e, column);
|
|
133
163
|
}
|
|
134
164
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if(this.table.options.groupClickMenu){
|
|
143
|
-
group.getElement().addEventListener("click", this.LoadMenuEvent.bind(this, group, this.table.options.groupClickMenu));
|
|
165
|
+
|
|
166
|
+
loadMenuEvent(menu, e, component){
|
|
167
|
+
if(component._group){
|
|
168
|
+
component = component._group;
|
|
169
|
+
}else if(component._row){
|
|
170
|
+
component = component._row;
|
|
144
171
|
}
|
|
172
|
+
|
|
173
|
+
menu = typeof menu == "function" ? menu.call(this.table, component.getComponent(), e) : menu;
|
|
174
|
+
|
|
175
|
+
this.loadMenu(e, component, menu);
|
|
145
176
|
}
|
|
146
|
-
|
|
177
|
+
|
|
147
178
|
loadMenu(e, component, menu, parentEl){
|
|
148
|
-
|
|
149
179
|
var touch = !(e instanceof MouseEvent);
|
|
150
|
-
|
|
180
|
+
|
|
151
181
|
var menuEl = document.createElement("div");
|
|
152
182
|
menuEl.classList.add("tabulator-menu");
|
|
153
|
-
|
|
183
|
+
|
|
154
184
|
if(!touch){
|
|
155
185
|
e.preventDefault();
|
|
156
186
|
}
|
|
157
|
-
|
|
187
|
+
|
|
158
188
|
//abort if no menu set
|
|
159
189
|
if(!menu || !menu.length){
|
|
160
190
|
return;
|
|
161
191
|
}
|
|
162
|
-
|
|
192
|
+
|
|
163
193
|
if(!parentEl){
|
|
164
194
|
if(this.nestedMenuBlock){
|
|
165
195
|
//abort if child menu already open
|
|
@@ -171,35 +201,35 @@ class Menu extends Module{
|
|
|
171
201
|
this.nestedMenuBlock = false;
|
|
172
202
|
}, 100)
|
|
173
203
|
}
|
|
174
|
-
|
|
204
|
+
|
|
175
205
|
this.hideMenu();
|
|
176
206
|
this.menuElements = [];
|
|
177
207
|
}
|
|
178
|
-
|
|
208
|
+
|
|
179
209
|
menu.forEach((item) => {
|
|
180
210
|
var itemEl = document.createElement("div"),
|
|
181
211
|
label = item.label,
|
|
182
212
|
disabled = item.disabled;
|
|
183
|
-
|
|
213
|
+
|
|
184
214
|
if(item.separator){
|
|
185
215
|
itemEl.classList.add("tabulator-menu-separator");
|
|
186
216
|
}else{
|
|
187
217
|
itemEl.classList.add("tabulator-menu-item");
|
|
188
|
-
|
|
218
|
+
|
|
189
219
|
if(typeof label == "function"){
|
|
190
220
|
label = label.call(this.table, component.getComponent());
|
|
191
221
|
}
|
|
192
|
-
|
|
222
|
+
|
|
193
223
|
if(label instanceof Node){
|
|
194
224
|
itemEl.appendChild(label);
|
|
195
225
|
}else{
|
|
196
226
|
itemEl.innerHTML = label;
|
|
197
227
|
}
|
|
198
|
-
|
|
228
|
+
|
|
199
229
|
if(typeof disabled == "function"){
|
|
200
230
|
disabled = disabled.call(this.table, component.getComponent());
|
|
201
231
|
}
|
|
202
|
-
|
|
232
|
+
|
|
203
233
|
if(disabled){
|
|
204
234
|
itemEl.classList.add("tabulator-menu-item-disabled");
|
|
205
235
|
itemEl.addEventListener("click", (e) => {
|
|
@@ -220,57 +250,67 @@ class Menu extends Module{
|
|
|
220
250
|
}
|
|
221
251
|
}
|
|
222
252
|
}
|
|
223
|
-
|
|
253
|
+
|
|
224
254
|
if(item.menu && item.menu.length){
|
|
225
255
|
itemEl.classList.add("tabulator-menu-item-submenu");
|
|
226
256
|
}
|
|
227
257
|
}
|
|
228
|
-
|
|
258
|
+
|
|
229
259
|
menuEl.appendChild(itemEl);
|
|
230
260
|
});
|
|
231
|
-
|
|
261
|
+
|
|
232
262
|
menuEl.addEventListener("click", (e) => {
|
|
233
263
|
this.hideMenu();
|
|
234
264
|
});
|
|
235
|
-
|
|
265
|
+
|
|
236
266
|
this.menuElements.push(menuEl);
|
|
237
267
|
this.positionMenu(menuEl, parentEl, touch, e);
|
|
268
|
+
|
|
269
|
+
this.currentComponent = component
|
|
270
|
+
|
|
271
|
+
this.dispatchExternal("menuOpened", component.getComponent())
|
|
238
272
|
}
|
|
239
|
-
|
|
273
|
+
|
|
240
274
|
hideOldSubMenus(menuEl){
|
|
241
275
|
var index = this.menuElements.indexOf(menuEl);
|
|
242
|
-
|
|
276
|
+
|
|
243
277
|
if(index > -1){
|
|
244
278
|
for(let i = this.menuElements.length - 1; i > index; i--){
|
|
245
279
|
var el = this.menuElements[i];
|
|
246
|
-
|
|
280
|
+
|
|
247
281
|
if(el.parentNode){
|
|
248
282
|
el.parentNode.removeChild(el);
|
|
249
283
|
}
|
|
250
|
-
|
|
284
|
+
|
|
251
285
|
this.menuElements.pop();
|
|
252
286
|
}
|
|
253
287
|
}
|
|
254
288
|
}
|
|
255
|
-
|
|
289
|
+
|
|
256
290
|
positionMenu(element, parentEl, touch, e){
|
|
257
|
-
var
|
|
258
|
-
|
|
259
|
-
|
|
291
|
+
var x, y, parentOffset;
|
|
292
|
+
|
|
260
293
|
if(!parentEl){
|
|
261
294
|
x = touch ? e.touches[0].pageX : e.pageX;
|
|
262
295
|
y = touch ? e.touches[0].pageY : e.pageY;
|
|
263
|
-
|
|
296
|
+
|
|
297
|
+
if(this.menuContainer !== document.body){
|
|
298
|
+
parentOffset = Helpers.elOffset(this.menuContainer);
|
|
299
|
+
|
|
300
|
+
x -= parentOffset.left;
|
|
301
|
+
y -= parentOffset.top;
|
|
302
|
+
}
|
|
303
|
+
|
|
264
304
|
this.positionReversedX = false;
|
|
265
305
|
}else{
|
|
266
306
|
parentOffset = Helpers.elOffset(parentEl);
|
|
267
307
|
x = parentOffset.left + parentEl.offsetWidth;
|
|
268
308
|
y = parentOffset.top - 1;
|
|
269
309
|
}
|
|
270
|
-
|
|
310
|
+
|
|
271
311
|
element.style.top = y + "px";
|
|
272
312
|
element.style.left = x + "px";
|
|
273
|
-
|
|
313
|
+
|
|
274
314
|
setTimeout(() => {
|
|
275
315
|
this.table.rowManager.element.addEventListener("scroll", this.blurEvent);
|
|
276
316
|
document.body.addEventListener("click", this.blurEvent);
|
|
@@ -278,56 +318,61 @@ class Menu extends Module{
|
|
|
278
318
|
window.addEventListener("resize", this.blurEvent);
|
|
279
319
|
document.body.addEventListener("keydown", this.escEvent);
|
|
280
320
|
}, 100);
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
//move menu to start on
|
|
285
|
-
if((
|
|
286
|
-
element.style.
|
|
287
|
-
|
|
321
|
+
|
|
322
|
+
this.menuContainer.appendChild(element);
|
|
323
|
+
|
|
324
|
+
//move menu to start on right edge if it is too close to the edge of the screen
|
|
325
|
+
if((x + element.offsetWidth) >= this.menuContainer.offsetWidth || this.positionReversedX){
|
|
326
|
+
element.style.left = "";
|
|
327
|
+
|
|
288
328
|
if(parentEl){
|
|
289
|
-
element.style.
|
|
329
|
+
element.style.right = (this.menuContainer.offsetWidth - parentOffset.left) + "px";
|
|
290
330
|
}else{
|
|
291
|
-
element.style.
|
|
331
|
+
element.style.right = (this.menuContainer.offsetWidth - x) + "px";
|
|
292
332
|
}
|
|
333
|
+
|
|
334
|
+
this.positionReversedX = true;
|
|
293
335
|
}
|
|
294
|
-
|
|
295
|
-
//move menu to start on
|
|
296
|
-
if((
|
|
297
|
-
element.style.
|
|
298
|
-
|
|
336
|
+
|
|
337
|
+
//move menu to start on bottom edge if it is too close to the edge of the screen
|
|
338
|
+
if((y + element.offsetHeight) >= this.menuContainer.offsetHeight){
|
|
339
|
+
element.style.top = "";
|
|
340
|
+
|
|
299
341
|
if(parentEl){
|
|
300
|
-
element.style.
|
|
342
|
+
element.style.bottom = (this.menuContainer.offsetHeight - parentOffset.top - parentEl.offsetHeight - 1) + "px";
|
|
301
343
|
}else{
|
|
302
|
-
element.style.
|
|
344
|
+
element.style.bottom = (this.menuContainer.offsetHeight - y) + "px";
|
|
303
345
|
}
|
|
304
|
-
|
|
305
|
-
this.positionReversedX = true;
|
|
306
346
|
}
|
|
307
347
|
}
|
|
308
|
-
|
|
348
|
+
|
|
309
349
|
isOpen(){
|
|
310
350
|
return !!this.menuElements.length;
|
|
311
351
|
}
|
|
312
|
-
|
|
352
|
+
|
|
313
353
|
escMenu(e){
|
|
314
354
|
if(e.keyCode == 27){
|
|
315
355
|
this.hideMenu();
|
|
316
356
|
}
|
|
317
357
|
}
|
|
318
|
-
|
|
319
|
-
hideMenu(){
|
|
358
|
+
|
|
359
|
+
hideMenu(){
|
|
320
360
|
this.menuElements.forEach((menuEl) => {
|
|
321
361
|
if(menuEl.parentNode){
|
|
322
362
|
menuEl.parentNode.removeChild(menuEl);
|
|
323
363
|
}
|
|
324
364
|
});
|
|
325
|
-
|
|
365
|
+
|
|
326
366
|
document.body.removeEventListener("keydown", this.escEvent);
|
|
327
367
|
document.body.removeEventListener("click", this.blurEvent);
|
|
328
368
|
document.body.removeEventListener("contextmenu", this.blurEvent);
|
|
329
369
|
window.removeEventListener("resize", this.blurEvent);
|
|
330
370
|
this.table.rowManager.element.removeEventListener("scroll", this.blurEvent);
|
|
371
|
+
|
|
372
|
+
if(this.currentComponent){
|
|
373
|
+
this.dispatchExternal("menuClosed", this.currentComponent.getComponent());
|
|
374
|
+
this.currentComponent = null;
|
|
375
|
+
}
|
|
331
376
|
}
|
|
332
377
|
}
|
|
333
378
|
|