clean up popup

This commit is contained in:
Shelley Vohr 2017-10-23 00:47:02 -04:00
parent f9c3123f5f
commit 61a93c711c
No known key found for this signature in database
GPG key ID: F13993A75599653C

View file

@ -132,40 +132,31 @@ Menu.prototype._init = function () {
}
Menu.prototype.popup = function (window, x, y, positioningItem) {
let [newX, newY, newPositioningItem] = [x, y, positioningItem]
let asyncPopup
// menu.popup(x, y, positioningItem)
if (window != null && (typeof window !== 'object' || window.constructor !== BrowserWindow)) {
// Shift.
positioningItem = y
y = x
x = window
window = null
if (window != null) {
if (typeof window !== 'object' || window.constructor !== BrowserWindow) {
[newPositioningItem, newY, newX] = [y, x, window]
window = null
}
}
// menu.popup(window, {})
if (x != null && typeof x === 'object') {
const options = x
x = options.x
y = options.y
positioningItem = options.positioningItem
asyncPopup = options.async
[newX, newY, newPositioningItem] = [x.x, x.y, x.positioningItem]
asyncPopup = x.async
}
// Default to showing in focused window.
// set up defaults
if (window == null) window = BrowserWindow.getFocusedWindow()
// Default to showing under mouse location.
if (typeof x !== 'number') x = -1
if (typeof y !== 'number') y = -1
// Default to not highlighting any item.
if (typeof positioningItem !== 'number') positioningItem = -1
// Default to synchronous for backwards compatibility.
if (typeof x !== 'number') newX = -1
if (typeof y !== 'number') newY = -1
if (typeof positioningItem !== 'number') newPositioningItem = -1
if (typeof asyncPopup !== 'boolean') asyncPopup = false
this.popupAt(window, x, y, positioningItem, asyncPopup)
this.popupAt(window, newX, newY, newPositioningItem, asyncPopup)
}
Menu.prototype.closePopup = function (window) {