@openui5/sap.ui.dt 1.95.0 → 1.96.3
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/.reuse/dep5 +10 -5
- package/THIRDPARTY.txt +17 -8
- package/package.json +2 -2
- package/src/sap/ui/dt/.library +1 -1
- package/src/sap/ui/dt/AggregationDesignTimeMetadata.js +1 -1
- package/src/sap/ui/dt/AggregationOverlay.js +1 -1
- package/src/sap/ui/dt/ControlObserver.js +1 -1
- package/src/sap/ui/dt/DOMUtil.js +1 -1
- package/src/sap/ui/dt/DesignTime.js +1 -1
- package/src/sap/ui/dt/DesignTimeMetadata.js +1 -1
- package/src/sap/ui/dt/ElementDesignTimeMetadata.js +1 -1
- package/src/sap/ui/dt/ElementOverlay.js +1 -1
- package/src/sap/ui/dt/ElementUtil.js +1 -1
- package/src/sap/ui/dt/ManagedObjectObserver.js +1 -1
- package/src/sap/ui/dt/MetadataPropagationUtil.js +1 -1
- package/src/sap/ui/dt/MutationObserver.js +1 -1
- package/src/sap/ui/dt/Overlay.js +1 -1
- package/src/sap/ui/dt/OverlayRegistry.js +1 -1
- package/src/sap/ui/dt/OverlayUtil.js +1 -1
- package/src/sap/ui/dt/Plugin.js +1 -1
- package/src/sap/ui/dt/ScrollbarSynchronizer.js +1 -1
- package/src/sap/ui/dt/SelectionManager.js +1 -1
- package/src/sap/ui/dt/SelectionMode.js +1 -1
- package/src/sap/ui/dt/TaskManager.js +1 -1
- package/src/sap/ui/dt/TaskRunner.js +1 -1
- package/src/sap/ui/dt/Util.js +1 -1
- package/src/sap/ui/dt/enablement/ElementEnablementTest.js +1 -1
- package/src/sap/ui/dt/enablement/Test.js +1 -1
- package/src/sap/ui/dt/enablement/Util.js +1 -1
- package/src/sap/ui/dt/enablement/report/LibraryReport.js +1 -1
- package/src/sap/ui/dt/enablement/report/QUnitReport.js +1 -1
- package/src/sap/ui/dt/enablement/report/Statistic.js +1 -1
- package/src/sap/ui/dt/enablement/report/StatisticRenderer.js +1 -1
- package/src/sap/ui/dt/enablement/report/Table.js +1 -1
- package/src/sap/ui/dt/enablement/report/TableRenderer.js +1 -1
- package/src/sap/ui/dt/library.js +2 -2
- package/src/sap/ui/dt/plugin/ContextMenu.js +115 -374
- package/src/sap/ui/dt/plugin/ControlDragDrop.js +1 -1
- package/src/sap/ui/dt/plugin/CutPaste.js +1 -1
- package/src/sap/ui/dt/plugin/DragDrop.js +1 -1
- package/src/sap/ui/dt/plugin/ElementMover.js +1 -1
- package/src/sap/ui/dt/plugin/MouseSelection.js +1 -1
- package/src/sap/ui/dt/plugin/TabHandling.js +1 -1
- package/src/sap/ui/dt/plugin/ToolHooks.js +1 -1
- package/src/sap/ui/dt/themes/base/ContextMenu.less +104 -75
- package/src/sap/ui/dt/util/ZIndexManager.js +1 -1
- package/ui5.yaml +4 -1
- package/src/sap/ui/dt/ContextMenuControl.js +0 -929
|
@@ -5,24 +5,24 @@
|
|
|
5
5
|
*/
|
|
6
6
|
sap.ui.define([
|
|
7
7
|
"sap/ui/dt/Plugin",
|
|
8
|
-
"sap/
|
|
8
|
+
"sap/m/Menu",
|
|
9
|
+
"sap/m/MenuItem",
|
|
9
10
|
"sap/ui/dt/Util",
|
|
10
11
|
"sap/ui/dt/OverlayRegistry",
|
|
11
12
|
"sap/ui/dt/util/_createPromise",
|
|
12
13
|
"sap/ui/Device",
|
|
13
14
|
"sap/base/assert",
|
|
14
|
-
"sap/ui/events/KeyCodes"
|
|
15
|
-
"sap/base/util/restricted/_debounce"
|
|
15
|
+
"sap/ui/events/KeyCodes"
|
|
16
16
|
], function(
|
|
17
17
|
Plugin,
|
|
18
|
-
|
|
18
|
+
Menu,
|
|
19
|
+
MenuItem,
|
|
19
20
|
DtUtil,
|
|
20
21
|
OverlayRegistry,
|
|
21
22
|
_createPromise,
|
|
22
23
|
Device,
|
|
23
24
|
assert,
|
|
24
|
-
KeyCodes
|
|
25
|
-
_debounce
|
|
25
|
+
KeyCodes
|
|
26
26
|
) {
|
|
27
27
|
"use strict";
|
|
28
28
|
|
|
@@ -34,7 +34,7 @@ sap.ui.define([
|
|
|
34
34
|
* @class The ContextMenu registers event handler to open the context menu. Menu entries can dynamically be added
|
|
35
35
|
* @extends sap.ui.dt.Plugin
|
|
36
36
|
* @author SAP SE
|
|
37
|
-
* @version 1.
|
|
37
|
+
* @version 1.96.3
|
|
38
38
|
* @constructor
|
|
39
39
|
* @private
|
|
40
40
|
* @since 1.53
|
|
@@ -48,13 +48,6 @@ sap.ui.define([
|
|
|
48
48
|
contextElement: {
|
|
49
49
|
type: "object"
|
|
50
50
|
},
|
|
51
|
-
styleClass: {
|
|
52
|
-
type: "string"
|
|
53
|
-
},
|
|
54
|
-
openOnHover: {
|
|
55
|
-
type: "boolean",
|
|
56
|
-
defaultValue: true
|
|
57
|
-
},
|
|
58
51
|
openOnClick: {
|
|
59
52
|
type: "boolean",
|
|
60
53
|
defaultValue: true
|
|
@@ -68,30 +61,23 @@ sap.ui.define([
|
|
|
68
61
|
|
|
69
62
|
});
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
this.iMenuHoverClosingDelay = 250; //Should be lower than iMenuHoverOpeningDelay, otherwise ContextMenu is instantly closed
|
|
74
|
-
|
|
75
|
-
this.oContextMenuControl = new ContextMenuControl({
|
|
76
|
-
maxButtonsDisplayed: 4 //The maximum number of buttons which should be displayed in the collapsed version of the ContextMenu (including overflow-button)
|
|
77
|
-
});
|
|
64
|
+
var mainStyleClass = "sapUiDtContextMenu";
|
|
65
|
+
var miniMenuStyleClass = "sapUiDtContextMiniMenu";
|
|
78
66
|
|
|
67
|
+
ContextMenu.prototype.init = function () {
|
|
68
|
+
this.oContextMenuControl = new Menu();
|
|
69
|
+
this.oContextMenuControl.attachItemSelected(this._onItemSelected, this);
|
|
79
70
|
this.oContextMenuControl.attachClosed(this._contextMenuClosed, this);
|
|
80
|
-
this.oContextMenuControl.
|
|
81
|
-
|
|
71
|
+
this.oContextMenuControl.addStyleClass(mainStyleClass);
|
|
82
72
|
this._aMenuItems = [];
|
|
83
73
|
this._aGroupedItems = [];
|
|
84
74
|
this._aSubMenus = [];
|
|
85
75
|
};
|
|
86
76
|
|
|
87
77
|
ContextMenu.prototype.exit = function () {
|
|
88
|
-
this._clearHoverTimeout();
|
|
89
78
|
delete this._aMenuItems;
|
|
90
79
|
if (this.oContextMenuControl) {
|
|
91
|
-
this.oContextMenuControl.detachClosed(this._contextMenuClosed, this);
|
|
92
|
-
this.oContextMenuControl.detachOverflowButtonPressed(this._pressedOverflowButton, this);
|
|
93
80
|
this.oContextMenuControl.destroy();
|
|
94
|
-
delete this.oContextMenuControl;
|
|
95
81
|
}
|
|
96
82
|
};
|
|
97
83
|
|
|
@@ -101,14 +87,14 @@ sap.ui.define([
|
|
|
101
87
|
* @param {object} mMenuItem json object with the menu item settings
|
|
102
88
|
* @param {string} mMenuItem.id id, which corresponds to the text key
|
|
103
89
|
* @param {string} mMenuItems.text menu item text (translated)
|
|
104
|
-
* @param {string} mMenuItems.icon a icon for the
|
|
90
|
+
* @param {string} mMenuItems.icon a icon for the menu item
|
|
105
91
|
* @param {function} mMenuItem.handler event handler if menu is selected, the element for which the menu was opened is passed to the handler
|
|
106
92
|
* @param {function} mMenuItem.startSection? function to determine if a new section should be started, the element for which the menu was opened
|
|
107
93
|
* is passed to the handler, default false
|
|
108
94
|
* @param {function} mMenuItem.enabled? function to determine if the menu entry should be enabled, the element for which the menu should be opened
|
|
109
95
|
* is passed, default true
|
|
110
96
|
* @param {boolean} bRetrievedFromPlugin flag to mark if a menu item was retrieved from a plugin (in runtime)
|
|
111
|
-
* @param {
|
|
97
|
+
* @param {boolean} bPersistOneTime flag to mark that the Button persist the next Menu clearing
|
|
112
98
|
*/
|
|
113
99
|
ContextMenu.prototype.addMenuItem = function (mMenuItem, bRetrievedFromPlugin, bPersistOneTime) {
|
|
114
100
|
var mMenuItemEntry = {
|
|
@@ -126,11 +112,9 @@ sap.ui.define([
|
|
|
126
112
|
* @override
|
|
127
113
|
*/
|
|
128
114
|
ContextMenu.prototype.registerElementOverlay = function (oOverlay) {
|
|
129
|
-
oOverlay.attachBrowserEvent("click", this.
|
|
130
|
-
oOverlay.attachBrowserEvent("touchstart", this.
|
|
131
|
-
oOverlay.attachBrowserEvent("contextmenu", this.
|
|
132
|
-
// oOverlay.attachBrowserEvent("mouseover", this._onHover, this); FIXME: wait for hover PoC from UX colleagues
|
|
133
|
-
// oOverlay.attachBrowserEvent("mouseout", this._clearHoverTimeout, this);
|
|
115
|
+
oOverlay.attachBrowserEvent("click", this._openContextMenu, this);
|
|
116
|
+
oOverlay.attachBrowserEvent("touchstart", this._openContextMenu, this);
|
|
117
|
+
oOverlay.attachBrowserEvent("contextmenu", this._openContextMenu, this);
|
|
134
118
|
oOverlay.attachBrowserEvent("keydown", this._onKeyDown, this);
|
|
135
119
|
oOverlay.attachBrowserEvent("keyup", this._onKeyUp, this);
|
|
136
120
|
};
|
|
@@ -143,25 +127,48 @@ sap.ui.define([
|
|
|
143
127
|
* @override
|
|
144
128
|
*/
|
|
145
129
|
ContextMenu.prototype.deregisterElementOverlay = function (oOverlay) {
|
|
146
|
-
oOverlay.detachBrowserEvent("click", this.
|
|
147
|
-
oOverlay.detachBrowserEvent("touchstart", this.
|
|
148
|
-
oOverlay.detachBrowserEvent("contextmenu", this.
|
|
149
|
-
// oOverlay.detachBrowserEvent("mouseover", this._onHover, this); FIXME: wait for hover PoC from UX colleagues
|
|
150
|
-
// oOverlay.detachBrowserEvent("mouseout", this._clearHoverTimeout, this);
|
|
130
|
+
oOverlay.detachBrowserEvent("click", this._openContextMenu, this);
|
|
131
|
+
oOverlay.detachBrowserEvent("touchstart", this._openContextMenu, this);
|
|
132
|
+
oOverlay.detachBrowserEvent("contextmenu", this._openContextMenu, this);
|
|
151
133
|
oOverlay.detachBrowserEvent("keydown", this._onKeyDown, this);
|
|
152
134
|
oOverlay.detachBrowserEvent("keyup", this._onKeyUp, this);
|
|
153
135
|
};
|
|
154
136
|
|
|
155
137
|
/**
|
|
156
138
|
* Opens the Context Menu
|
|
157
|
-
* @param {object} mPosition position of the element triggering the open
|
|
158
139
|
* @param {sap.ui.dt.Overlay} oOverlay overlay object
|
|
159
140
|
* @param {boolean} bContextMenu whether the control should be opened as a context menu
|
|
160
|
-
* @param {boolean} bIsSubMenu whether the new ContextMenu is a SubMenu opened by a
|
|
141
|
+
* @param {boolean} bIsSubMenu whether the new ContextMenu is a SubMenu opened by a menu item inside another ContextMenu
|
|
161
142
|
*/
|
|
162
|
-
ContextMenu.prototype.open = function (
|
|
163
|
-
|
|
143
|
+
ContextMenu.prototype.open = function (oOverlay, bContextMenu, bIsSubMenu, oEvent) {
|
|
144
|
+
function addMenuItems(oMenu, aMenuItems) {
|
|
145
|
+
aMenuItems.forEach(function(oMenuItem, index) {
|
|
146
|
+
var sText = typeof oMenuItem.text === "function" ? oMenuItem.text(oOverlay) : oMenuItem.text;
|
|
147
|
+
var bEnabled = typeof oMenuItem.enabled === "function" ? oMenuItem.enabled(aSelectedOverlays) : oMenuItem.enabled;
|
|
148
|
+
var sTooltip;
|
|
149
|
+
if (!bContextMenu) {
|
|
150
|
+
sTooltip = sText;
|
|
151
|
+
}
|
|
152
|
+
oMenu.addItem(
|
|
153
|
+
new MenuItem({
|
|
154
|
+
key: oMenuItem.id,
|
|
155
|
+
icon: oMenuItem.icon,
|
|
156
|
+
text: sText,
|
|
157
|
+
enabled: bEnabled
|
|
158
|
+
}).setTooltip(sTooltip)
|
|
159
|
+
);
|
|
160
|
+
if (oMenuItem.submenu) {
|
|
161
|
+
addMenuItems(oMenu.getItems()[index], oMenuItem.submenu);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
164
165
|
|
|
166
|
+
this._bContextMenu = !!bContextMenu;
|
|
167
|
+
if (this._bContextMenu) {
|
|
168
|
+
this.oContextMenuControl.removeStyleClass(miniMenuStyleClass);
|
|
169
|
+
} else {
|
|
170
|
+
this.oContextMenuControl.addStyleClass(miniMenuStyleClass);
|
|
171
|
+
}
|
|
165
172
|
var oNewContextElement = oOverlay.getElement();
|
|
166
173
|
if (this._fnCancelMenuPromise) {
|
|
167
174
|
// Menu is still opening
|
|
@@ -174,7 +181,6 @@ sap.ui.define([
|
|
|
174
181
|
}
|
|
175
182
|
|
|
176
183
|
this.setContextElement(oNewContextElement);
|
|
177
|
-
|
|
178
184
|
this.getDesignTime().getSelectionManager().attachChange(this._onSelectionChanged, this);
|
|
179
185
|
|
|
180
186
|
var aSelectedOverlays = this.getSelectedOverlays().filter(function (oElementOverlay) {
|
|
@@ -182,12 +188,7 @@ sap.ui.define([
|
|
|
182
188
|
});
|
|
183
189
|
aSelectedOverlays.unshift(oOverlay);
|
|
184
190
|
|
|
185
|
-
//
|
|
186
|
-
if (document.activeElement) {
|
|
187
|
-
document.activeElement.blur();
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
//Remove all previous entries retrieved by plugins (the list should always be rebuilt)
|
|
191
|
+
// Keep all persisted menu items
|
|
191
192
|
this._aMenuItems = this._aMenuItems.filter(function (mMenuItemEntry) {
|
|
192
193
|
if (mMenuItemEntry.bPersistOneTime) {
|
|
193
194
|
mMenuItemEntry.bPersistOneTime = false;
|
|
@@ -196,6 +197,9 @@ sap.ui.define([
|
|
|
196
197
|
return !mMenuItemEntry.fromPlugin;
|
|
197
198
|
});
|
|
198
199
|
|
|
200
|
+
// Remove all previous entries retrieved by plugins (the list should always be rebuilt)
|
|
201
|
+
this.oContextMenuControl.destroyItems();
|
|
202
|
+
|
|
199
203
|
var oPromise = Promise.resolve();
|
|
200
204
|
if (!bIsSubMenu) {
|
|
201
205
|
var oDtSyncPromise = _createPromise(function (resolve, reject) {
|
|
@@ -229,16 +233,21 @@ sap.ui.define([
|
|
|
229
233
|
})
|
|
230
234
|
.then(function(aPluginMenuItems) {
|
|
231
235
|
aPluginMenuItems.forEach(function (mMenuItem) {
|
|
236
|
+
// Show only enabled items in Minimenu
|
|
237
|
+
var bEnabled = typeof mMenuItem.enabled === "function" ? mMenuItem.enabled(aSelectedOverlays) : mMenuItem.enabled;
|
|
238
|
+
if (!bEnabled && !bContextMenu) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
232
241
|
if (mMenuItem.group !== undefined && !bContextMenu) {
|
|
233
242
|
this._addMenuItemToGroup(mMenuItem);
|
|
234
243
|
} else if (mMenuItem.submenu !== undefined) {
|
|
235
|
-
this._addSubMenu(mMenuItem
|
|
244
|
+
this._addSubMenu(mMenuItem);
|
|
236
245
|
} else {
|
|
237
246
|
this.addMenuItem(mMenuItem, true);
|
|
238
247
|
}
|
|
239
248
|
}.bind(this));
|
|
240
249
|
|
|
241
|
-
this._addItemGroupsToMenu(
|
|
250
|
+
this._addItemGroupsToMenu();
|
|
242
251
|
delete this._fnCancelMenuPromise;
|
|
243
252
|
}.bind(this));
|
|
244
253
|
}
|
|
@@ -250,23 +259,18 @@ sap.ui.define([
|
|
|
250
259
|
|
|
251
260
|
if (aMenuItems.length > 0) {
|
|
252
261
|
aMenuItems = this._sortMenuItems(aMenuItems);
|
|
253
|
-
this.oContextMenuControl
|
|
254
|
-
this.oContextMenuControl.
|
|
255
|
-
|
|
256
|
-
this.oContextMenuControl.show(oOverlay, bContextMenu, {
|
|
257
|
-
x: mPosition.clientX,
|
|
258
|
-
y: mPosition.clientY
|
|
259
|
-
});
|
|
262
|
+
addMenuItems(this.oContextMenuControl, aMenuItems);
|
|
263
|
+
this.oContextMenuControl.openAsContextMenu(oEvent, oOverlay);
|
|
260
264
|
}
|
|
261
265
|
|
|
262
266
|
this.fireOpenedContextMenu();
|
|
263
267
|
}.bind(this))
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
268
|
+
.catch(function(oError) {
|
|
269
|
+
throw DtUtil.createError(
|
|
270
|
+
"ContextMenu#open",
|
|
271
|
+
"An error occured during calling getMenuItems: " + oError
|
|
272
|
+
);
|
|
273
|
+
});
|
|
270
274
|
};
|
|
271
275
|
|
|
272
276
|
/**
|
|
@@ -291,20 +295,6 @@ sap.ui.define([
|
|
|
291
295
|
});
|
|
292
296
|
};
|
|
293
297
|
|
|
294
|
-
/**
|
|
295
|
-
* Funcion is called when "_onContextMenu" is fired -> opens the ContextMenu
|
|
296
|
-
* @param {sap.ui.base.Event} oEvent Event object
|
|
297
|
-
* @private
|
|
298
|
-
*/
|
|
299
|
-
ContextMenu.prototype._onContextMenu = function (oEvent) {
|
|
300
|
-
var oOverlay = OverlayRegistry.getOverlay(oEvent.currentTarget.id);
|
|
301
|
-
var mPosition = {
|
|
302
|
-
clientX: oEvent.clientX,
|
|
303
|
-
clientY: oEvent.clientY
|
|
304
|
-
};
|
|
305
|
-
this._openContextMenu(oEvent, oOverlay, mPosition);
|
|
306
|
-
};
|
|
307
|
-
|
|
308
298
|
/**
|
|
309
299
|
* Called when a context menu item gets selected by user
|
|
310
300
|
* @param {sap.ui.base.Event} oEventItem event object
|
|
@@ -312,156 +302,33 @@ sap.ui.define([
|
|
|
312
302
|
* @private
|
|
313
303
|
*/
|
|
314
304
|
ContextMenu.prototype._onItemSelected = function (oEventItem) {
|
|
315
|
-
this.oContextMenuControl.close(true);
|
|
316
305
|
this._ensureSelection(this._oCurrentOverlay);
|
|
317
|
-
this.setFocusLock(true);
|
|
318
306
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
aSelection = mMenuItemEntry.menuItem.responsible || this.getSelectedOverlays();
|
|
327
|
-
assert(aSelection.length > 0, "sap.ui.rta - Opening context menu, with empty selection - check event order");
|
|
328
|
-
var mPropertiesBag = {};
|
|
329
|
-
mPropertiesBag.eventItem = oEventItem;
|
|
330
|
-
mPropertiesBag.contextElement = oContextElement;
|
|
331
|
-
var fnHandler = oItem.handler;
|
|
332
|
-
if (this.oContextMenuControl.isPopupOpen()) {
|
|
333
|
-
this.oContextMenuControl.attachEventOnce("Closed", function() {
|
|
334
|
-
fnHandler(aSelection, mPropertiesBag);
|
|
335
|
-
});
|
|
336
|
-
} else {
|
|
337
|
-
fnHandler(aSelection, mPropertiesBag);
|
|
338
|
-
}
|
|
339
|
-
oItem = null;
|
|
340
|
-
return true;
|
|
341
|
-
}
|
|
342
|
-
}, this);
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
ContextMenu.prototype._onContextMenuOrClick = function(oEvent) {
|
|
346
|
-
if (!this.fnDebounced) {
|
|
347
|
-
this.fnDebounced = _debounce(function() {
|
|
348
|
-
if (this._oCurrentEvent.type === "contextmenu") {
|
|
349
|
-
this._onContextMenu(this._oCurrentEvent);
|
|
350
|
-
} else {
|
|
351
|
-
this._onClickorTouch(this._oCurrentEvent);
|
|
352
|
-
}
|
|
353
|
-
this._oCurrentEvent = undefined;
|
|
354
|
-
this.fnDebounced = undefined;
|
|
355
|
-
}.bind(this), 50);
|
|
307
|
+
function callHandler(oMenuItem, oEventItem) {
|
|
308
|
+
var aSelection = oMenuItem.responsible || this.getSelectedOverlays() || [];
|
|
309
|
+
assert(aSelection.length > 0, "sap.ui.rta - Opening context menu, with empty selection - check event order");
|
|
310
|
+
var mPropertiesBag = {};
|
|
311
|
+
mPropertiesBag.eventItem = oEventItem;
|
|
312
|
+
mPropertiesBag.contextElement = this.getContextElement();
|
|
313
|
+
oMenuItem.handler(aSelection, mPropertiesBag);
|
|
356
314
|
}
|
|
357
315
|
|
|
358
|
-
var
|
|
359
|
-
if (oOverlay && oOverlay.isSelectable() && oOverlay.getSelected()) {
|
|
360
|
-
this._oCurrentEvent = oEvent;
|
|
361
|
-
oEvent.stopPropagation();
|
|
362
|
-
this.fnDebounced();
|
|
363
|
-
}
|
|
364
|
-
};
|
|
316
|
+
var sSelectedItemId = oEventItem.getParameter("item").getKey();
|
|
365
317
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
}
|
|
377
|
-
this._startOpening(oEvent);
|
|
378
|
-
}
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* Called before the ContextMenu is opened (except by contextMenu event)
|
|
383
|
-
* Checks whether a new ContextMenu should been opened and does so, if check returned true
|
|
384
|
-
* @param {sap.ui.base.Event} oEvent event object
|
|
385
|
-
* @param {boolean} bLockOpening should the Opening of the ContextMenu be locked
|
|
386
|
-
* @return {boolean} Whether a new ContextMenu has been opened or not
|
|
387
|
-
* @private
|
|
388
|
-
*/
|
|
389
|
-
ContextMenu.prototype._startOpening = function (oEvent, bLockOpening) {
|
|
390
|
-
clearTimeout(this.hoverTimeout);
|
|
391
|
-
this._bOpenedByHover = false;
|
|
392
|
-
|
|
393
|
-
this._oTempTarget = oEvent.currentTarget.id;
|
|
394
|
-
|
|
395
|
-
var oOverlay = OverlayRegistry.getOverlay(oEvent.currentTarget.id);
|
|
396
|
-
var sTargetClasses = oEvent.target.className;
|
|
397
|
-
|
|
398
|
-
if (oOverlay && oOverlay.isSelectable() && sTargetClasses.indexOf("sapUiDtOverlay") > -1 && (!this.isMenuOpeningLocked())) {
|
|
399
|
-
oEvent.stopPropagation();
|
|
400
|
-
|
|
401
|
-
if (this._shouldContextMenuOpen(oEvent)) {
|
|
402
|
-
this._ensureSelection(oOverlay);
|
|
403
|
-
if (this._oCurrentOverlay.isSelected() || Device.os.android) {
|
|
404
|
-
if (bLockOpening) {
|
|
405
|
-
this.lockMenuOpening();
|
|
318
|
+
this._aMenuItems.some(function (mMenuItemEntry) {
|
|
319
|
+
var oItem = mMenuItemEntry.menuItem;
|
|
320
|
+
if (sSelectedItemId === mMenuItemEntry.menuItem.id) {
|
|
321
|
+
callHandler.apply(this, [oItem, oEventItem]);
|
|
322
|
+
return true;
|
|
323
|
+
} else if (oItem.submenu) {
|
|
324
|
+
oItem.submenu.some(function(mSubMenuItem) {
|
|
325
|
+
if (sSelectedItemId === mSubMenuItem.id) {
|
|
326
|
+
callHandler.apply(this, [mSubMenuItem, oEventItem]);
|
|
327
|
+
return true;
|
|
406
328
|
}
|
|
407
|
-
|
|
408
|
-
{
|
|
409
|
-
clientX: oEvent.clientX,
|
|
410
|
-
clientY: oEvent.clientY
|
|
411
|
-
},
|
|
412
|
-
oOverlay
|
|
413
|
-
);
|
|
414
|
-
|
|
415
|
-
return true;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* Called when the user hovers over an overlay
|
|
423
|
-
* @param {sap.ui.base.Event} oEvent event object
|
|
424
|
-
* @private
|
|
425
|
-
*/
|
|
426
|
-
ContextMenu.prototype._onHover = function (oEvent) {
|
|
427
|
-
var oOverlay = OverlayRegistry.getOverlay(oEvent.currentTarget.id);
|
|
428
|
-
if (oOverlay && oOverlay.isSelectable() && !oEvent.ctrlKey && this.getOpenOnHover()) {
|
|
429
|
-
oEvent.stopPropagation();
|
|
430
|
-
if (this._shouldContextMenuOpen(oEvent, true)) {
|
|
431
|
-
if (this.iMenuHoverClosingDelay >= this.iMenuHoverOpeningDelay) {
|
|
432
|
-
throw new Error("sap.ui.dt ContextMenu iMenuHoverClosingDelay is bigger or equal to iMenuHoverOpeningDelay!");
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
if (this.oContextMenuControl.getPopover().isOpen()) {
|
|
436
|
-
this._closingTimeout = setTimeout(function () {
|
|
437
|
-
if (this.oContextMenuControl.getPopover().isOpen()) {
|
|
438
|
-
this.oContextMenuControl.close();
|
|
439
|
-
}
|
|
440
|
-
}.bind(this), this.iMenuHoverClosingDelay);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
this.hoverTimeout = setTimeout(function () {
|
|
444
|
-
OverlayRegistry.getOverlay(oEvent.currentTarget.id).focus();
|
|
445
|
-
this._startOpening(oEvent);
|
|
446
|
-
this._bOpenedByHover = true;
|
|
447
|
-
}.bind(this), this.iMenuHoverOpeningDelay);
|
|
329
|
+
}.bind(this));
|
|
448
330
|
}
|
|
449
|
-
}
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
/**
|
|
453
|
-
* Called when the user stops hovering over an overlay
|
|
454
|
-
* @private
|
|
455
|
-
*/
|
|
456
|
-
ContextMenu.prototype._clearHoverTimeout = function () {
|
|
457
|
-
if (this.hoverTimeout) {
|
|
458
|
-
clearTimeout(this.hoverTimeout);
|
|
459
|
-
this.hoverTimeout = null;
|
|
460
|
-
}
|
|
461
|
-
if (this._closingTimeout) {
|
|
462
|
-
clearTimeout(this._closingTimeout);
|
|
463
|
-
this._closingTimeout = null;
|
|
464
|
-
}
|
|
331
|
+
}, this);
|
|
465
332
|
};
|
|
466
333
|
|
|
467
334
|
/**
|
|
@@ -483,8 +350,8 @@ sap.ui.define([
|
|
|
483
350
|
(oEvent.shiftKey === false) &&
|
|
484
351
|
(oEvent.altKey === false) &&
|
|
485
352
|
(oEvent.ctrlKey === false)) {
|
|
486
|
-
if (
|
|
487
|
-
this.
|
|
353
|
+
if (!this._checkForPluginLock()) {
|
|
354
|
+
this._openContextMenu(oEvent);
|
|
488
355
|
oEvent.stopPropagation();
|
|
489
356
|
oEvent.preventDefault();
|
|
490
357
|
}
|
|
@@ -493,15 +360,10 @@ sap.ui.define([
|
|
|
493
360
|
(oEvent.shiftKey === true) &&
|
|
494
361
|
(oEvent.altKey === false) &&
|
|
495
362
|
(oEvent.ctrlKey === false)) {
|
|
496
|
-
if (
|
|
363
|
+
if (!this._checkForPluginLock()) {
|
|
364
|
+
this._openContextMenu(oEvent);
|
|
365
|
+
oEvent.stopPropagation();
|
|
497
366
|
oEvent.preventDefault();
|
|
498
|
-
|
|
499
|
-
var mPosition = {
|
|
500
|
-
clientX: "not set",
|
|
501
|
-
clientY: "not set"
|
|
502
|
-
};
|
|
503
|
-
|
|
504
|
-
this._openContextMenu(oEvent, oOverlay, mPosition);
|
|
505
367
|
}
|
|
506
368
|
}
|
|
507
369
|
};
|
|
@@ -518,6 +380,7 @@ sap.ui.define([
|
|
|
518
380
|
(oEvent.altKey === false) &&
|
|
519
381
|
(oEvent.ctrlKey === false)) {
|
|
520
382
|
if (oOverlay && oOverlay.isSelectable() && !this._checkForPluginLock()) {
|
|
383
|
+
oOverlay.setSelected(true);
|
|
521
384
|
oEvent.stopPropagation();
|
|
522
385
|
oEvent.preventDefault();
|
|
523
386
|
}
|
|
@@ -525,55 +388,16 @@ sap.ui.define([
|
|
|
525
388
|
};
|
|
526
389
|
|
|
527
390
|
/**
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
* @param {
|
|
531
|
-
* @return {boolean} whether the check was sucessfull and a new ContextMenu should be opened
|
|
532
|
-
* @private
|
|
533
|
-
*/
|
|
534
|
-
ContextMenu.prototype._shouldContextMenuOpen = function (oEvent, onHover) {
|
|
535
|
-
if ((!this._checkForPluginLock() && !this.isMenuOpeningLocked())) {
|
|
536
|
-
if (!onHover) {
|
|
537
|
-
this._oCurrentOverlay = OverlayRegistry.getOverlay(oEvent.currentTarget.id);
|
|
538
|
-
}
|
|
539
|
-
return true;
|
|
540
|
-
}
|
|
541
|
-
return false;
|
|
542
|
-
};
|
|
543
|
-
|
|
544
|
-
/**
|
|
545
|
-
* Called when overflow button is pressed on compact ContextMenu
|
|
546
|
-
* @param {sap.ui.base.Event} oEvent event object
|
|
547
|
-
* @private
|
|
391
|
+
* Called when user presses key on keyboard.
|
|
392
|
+
* Opens the ContextMenu on Click or Shift-F10 when no other plugin is active
|
|
393
|
+
* @param {sap.ui.base.Event} oEvent the event which was fired
|
|
548
394
|
*/
|
|
549
|
-
ContextMenu.prototype.
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
var mPosition = {
|
|
553
|
-
clientX: oEvent.mParameters.oButton.$().offset().left,
|
|
554
|
-
clientY: oEvent.mParameters.oButton.$().offset().top
|
|
555
|
-
};
|
|
556
|
-
this._openContextMenu(oEvent, oOverlay, mPosition);
|
|
557
|
-
|
|
558
|
-
this.setFocusLock(true);
|
|
559
|
-
};
|
|
560
|
-
|
|
561
|
-
ContextMenu.prototype._openContextMenu = function(oEvent, oOverlay, mPosition) {
|
|
562
|
-
if (oOverlay && oOverlay.isSelectable()) {
|
|
563
|
-
oEvent.preventDefault();
|
|
395
|
+
ContextMenu.prototype._openContextMenu = function(oEvent) {
|
|
396
|
+
var oOverlay = OverlayRegistry.getOverlay(oEvent.currentTarget.id);
|
|
397
|
+
if (oOverlay && oOverlay.isSelectable() && oOverlay.getSelected()) {
|
|
564
398
|
this._oCurrentOverlay = oOverlay;
|
|
565
|
-
|
|
566
|
-
this.
|
|
567
|
-
|
|
568
|
-
clearTimeout(this.hoverTimeout);
|
|
569
|
-
|
|
570
|
-
this._ensureSelection(oOverlay);
|
|
571
|
-
|
|
572
|
-
this.lockMenuOpening();
|
|
573
|
-
this.open(mPosition, oOverlay, true);
|
|
574
|
-
if (oEvent.stopPropagation) {
|
|
575
|
-
oEvent.stopPropagation();
|
|
576
|
-
}
|
|
399
|
+
var bContextMenu = oEvent.type === "contextmenu" || oEvent.keyCode === KeyCodes.F10;
|
|
400
|
+
this.open(oOverlay, bContextMenu, undefined, oEvent);
|
|
577
401
|
}
|
|
578
402
|
};
|
|
579
403
|
|
|
@@ -581,61 +405,19 @@ sap.ui.define([
|
|
|
581
405
|
* Called when ContextMenu gets closed
|
|
582
406
|
*/
|
|
583
407
|
ContextMenu.prototype._contextMenuClosed = function () {
|
|
584
|
-
this.
|
|
585
|
-
this.
|
|
408
|
+
this.oContextMenuControl.removeStyleClass(miniMenuStyleClass);
|
|
409
|
+
this.fireClosedContextMenu();
|
|
586
410
|
};
|
|
587
411
|
|
|
588
412
|
/**
|
|
589
413
|
* Called when the selection changes
|
|
590
414
|
*/
|
|
591
415
|
ContextMenu.prototype._onSelectionChanged = function() {
|
|
592
|
-
this.oContextMenuControl.close(true);
|
|
593
416
|
this.getDesignTime().getSelectionManager().detachChange(this._onSelectionChanged, this);
|
|
594
417
|
};
|
|
595
418
|
|
|
596
419
|
/**
|
|
597
|
-
*
|
|
598
|
-
* Note: should be called BEFORE a new ContextMenu is opened
|
|
599
|
-
* @param {boolean} bOverwriteOpenValue overwrites the "isOpen" value from the ContextMenuControl
|
|
600
|
-
*/
|
|
601
|
-
ContextMenu.prototype.lockMenuOpening = function (bOverwriteOpenValue) {
|
|
602
|
-
if ((this.oContextMenuControl.getPopover(true).isOpen() ||
|
|
603
|
-
this.oContextMenuControl.getPopover(false).isOpen()) &&
|
|
604
|
-
bOverwriteOpenValue !== true) { // sometimes this function needs to be called after the old ContextMenu is closed
|
|
605
|
-
this._bAsyncLock = true;
|
|
606
|
-
} else {
|
|
607
|
-
this._bOpeningLocked = true;
|
|
608
|
-
}
|
|
609
|
-
};
|
|
610
|
-
|
|
611
|
-
/**
|
|
612
|
-
* Unlocks the Opening of the ContextMenu
|
|
613
|
-
*/
|
|
614
|
-
ContextMenu.prototype.unlockMenuOpening = function () {
|
|
615
|
-
this._bOpeningLocked = false;
|
|
616
|
-
if (this._bAsyncLock) {
|
|
617
|
-
this.lockMenuOpening(true);
|
|
618
|
-
}
|
|
619
|
-
this._bAsyncLock = false;
|
|
620
|
-
};
|
|
621
|
-
|
|
622
|
-
/**
|
|
623
|
-
* @return {boolean} whether the Opening is locked or not
|
|
624
|
-
*/
|
|
625
|
-
ContextMenu.prototype.isMenuOpeningLocked = function () {
|
|
626
|
-
return this._bOpeningLocked;
|
|
627
|
-
};
|
|
628
|
-
|
|
629
|
-
/**
|
|
630
|
-
* Locks/ Unlocks the focus reset
|
|
631
|
-
* @param {boolean} bIsLocked whether the Focus should be locked on the ContextMenu or not
|
|
632
|
-
*/
|
|
633
|
-
ContextMenu.prototype.setFocusLock = function (bIsLocked) {
|
|
634
|
-
this._bFocusLocked = bIsLocked;
|
|
635
|
-
};
|
|
636
|
-
|
|
637
|
-
/**
|
|
638
|
-
* checks wehther the given Overlay is selected, if not it does so
|
|
420
|
+
* checks whether the given Overlay is selected, if not it does so
|
|
639
421
|
* @param {object} oOverlay the Overlay which should be checked for
|
|
640
422
|
*/
|
|
641
423
|
ContextMenu.prototype._ensureSelection = function (oOverlay) {
|
|
@@ -646,10 +428,8 @@ sap.ui.define([
|
|
|
646
428
|
|
|
647
429
|
/**
|
|
648
430
|
* checks whether a Plugin locks the opening of a new ContextMenu
|
|
649
|
-
* @param {object} oOverlay the Overlay which should be checked for
|
|
650
431
|
* @return {boolean} true, if locked; false if not
|
|
651
432
|
*/
|
|
652
|
-
|
|
653
433
|
ContextMenu.prototype._checkForPluginLock = function () {
|
|
654
434
|
//As long as Selection doesn't work correctly on ios we need to ensure that the ContextMenu opens even if a plugin mistakenly locks it
|
|
655
435
|
if (Device.os.ios) {
|
|
@@ -660,12 +440,11 @@ sap.ui.define([
|
|
|
660
440
|
return true;
|
|
661
441
|
}
|
|
662
442
|
|
|
663
|
-
this.setFocusLock(false);
|
|
664
443
|
return false;
|
|
665
444
|
};
|
|
666
445
|
|
|
667
446
|
/**
|
|
668
|
-
* Adds single
|
|
447
|
+
* Adds single item to an array of groups
|
|
669
448
|
* @param {object} mMenuItem The menu item to add to a group
|
|
670
449
|
*/
|
|
671
450
|
ContextMenu.prototype._addMenuItemToGroup = function (mMenuItem) {
|
|
@@ -687,38 +466,14 @@ sap.ui.define([
|
|
|
687
466
|
/**
|
|
688
467
|
* Adds a submenu to the list of submenus
|
|
689
468
|
* @param {object} mMenuItem The menu item to add to a group
|
|
690
|
-
* @param {object} mPosition The position where the submenu should be opened
|
|
691
|
-
* @param {sap.ui.dt.Overlay} oOverlay The Overlay on which the ContextMenu was opened
|
|
692
469
|
*/
|
|
693
|
-
ContextMenu.prototype._addSubMenu = function (mMenuItem
|
|
470
|
+
ContextMenu.prototype._addSubMenu = function (mMenuItem) {
|
|
694
471
|
mMenuItem.submenu.forEach(function (oSubMenuItem) {
|
|
695
472
|
if (!oSubMenuItem.handler) {
|
|
696
473
|
oSubMenuItem.handler = mMenuItem.handler;
|
|
697
474
|
}
|
|
698
475
|
});
|
|
699
476
|
|
|
700
|
-
mMenuItem.handler = function (sMenuItemId, mPosition, oOverlay) {
|
|
701
|
-
this._aSubMenus.some(function (_oMenuItem) {
|
|
702
|
-
if (_oMenuItem.sSubMenuId === sMenuItemId) {
|
|
703
|
-
_oMenuItem.aSubMenuItems.forEach(function (oSubMenuItem) {
|
|
704
|
-
this.addMenuItem(oSubMenuItem, true, true);
|
|
705
|
-
}.bind(this));
|
|
706
|
-
return true;
|
|
707
|
-
}
|
|
708
|
-
}.bind(this));
|
|
709
|
-
|
|
710
|
-
if (!this._bContextMenu) {
|
|
711
|
-
mPosition.clientX = null;
|
|
712
|
-
mPosition.clientY = null;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
this.oContextMenuControl.close();
|
|
716
|
-
setTimeout(function () {
|
|
717
|
-
this.open(mPosition, oOverlay, true, true);
|
|
718
|
-
}.bind(this), 0);
|
|
719
|
-
this.lockMenuOpening();
|
|
720
|
-
}.bind(this, mMenuItem.id, mPosition, oOverlay);
|
|
721
|
-
|
|
722
477
|
this._aSubMenus.push({
|
|
723
478
|
sSubMenuId: mMenuItem.id,
|
|
724
479
|
aSubMenuItems: mMenuItem.submenu
|
|
@@ -728,35 +483,21 @@ sap.ui.define([
|
|
|
728
483
|
};
|
|
729
484
|
|
|
730
485
|
/**
|
|
731
|
-
* Adds the grouped
|
|
732
|
-
* @param {object} mPosition The position where the menu is opened
|
|
733
|
-
* @param {sap.ui.dt.Overlay} oOverlay The Overlay on which the ContextMenu was opened
|
|
486
|
+
* Adds the grouped menu item to the collapsed version of a ContextMenu
|
|
734
487
|
*/
|
|
735
|
-
ContextMenu.prototype._addItemGroupsToMenu = function (
|
|
736
|
-
this._aGroupedItems.forEach(function (oGroupedItem
|
|
737
|
-
//If there is only one
|
|
488
|
+
ContextMenu.prototype._addItemGroupsToMenu = function () {
|
|
489
|
+
this._aGroupedItems.forEach(function (oGroupedItem) {
|
|
490
|
+
//If there is only one menu item that belongs to a group we don't need that group
|
|
738
491
|
if (oGroupedItem.aGroupedItems.length === 1) {
|
|
739
|
-
this.addMenuItem(oGroupedItem.aGroupedItems[0], true
|
|
492
|
+
this.addMenuItem(oGroupedItem.aGroupedItems[0], true);
|
|
740
493
|
} else {
|
|
741
|
-
var fHandlerForGroupedButton = function (iIndex, mPosition, oOverlay) {
|
|
742
|
-
this._aGroupedItems[iIndex].aGroupedItems.forEach(function (mMenuItem) {
|
|
743
|
-
this.addMenuItem(mMenuItem, true, true);
|
|
744
|
-
}.bind(this));
|
|
745
|
-
|
|
746
|
-
this.oContextMenuControl.close();
|
|
747
|
-
setTimeout(function () {
|
|
748
|
-
this.open(mPosition, oOverlay, true, true);
|
|
749
|
-
}.bind(this), 0);
|
|
750
|
-
this.lockMenuOpening();
|
|
751
|
-
};
|
|
752
|
-
|
|
753
494
|
this.addMenuItem({
|
|
754
|
-
id: oGroupedItem.sGroupName + "-
|
|
495
|
+
id: oGroupedItem.sGroupName + "-groupItem",
|
|
755
496
|
enabled: true,
|
|
756
497
|
text: oGroupedItem.sGroupName,
|
|
757
498
|
icon: oGroupedItem.aGroupedItems[0].icon,
|
|
758
499
|
rank: oGroupedItem.aGroupedItems[0].rank,
|
|
759
|
-
|
|
500
|
+
submenu: oGroupedItem.aGroupedItems
|
|
760
501
|
}, true);
|
|
761
502
|
}
|
|
762
503
|
}.bind(this));
|