diff --git a/lib/browser/api/menu.js b/lib/browser/api/menu.js index 3e56bea04b6..caa65afbbf0 100644 --- a/lib/browser/api/menu.js +++ b/lib/browser/api/menu.js @@ -43,7 +43,6 @@ Menu.prototype._init = function () { } } -// create and show a popup Menu.prototype.popup = function (window, x, y, positioningItem) { let asyncPopup let [newX, newY, newPosition, newWindow] = [x, y, positioningItem, window] @@ -75,7 +74,6 @@ Menu.prototype.popup = function (window, x, y, positioningItem) { this.popupAt(newWindow, newX, newY, newPosition, asyncPopup) } -// close an existing popup Menu.prototype.closePopup = function (window) { if (!window || window.constructor !== BrowserWindow) { window = BrowserWindow.getFocusedWindow() @@ -83,7 +81,6 @@ Menu.prototype.closePopup = function (window) { if (window) this.closePopupAt(window.id) } -// return a MenuItem with the specified id Menu.prototype.getMenuItemById = function (id) { const items = this.items @@ -96,12 +93,10 @@ Menu.prototype.getMenuItemById = function (id) { return found } -// append a new MenuItem to an existing Menu Menu.prototype.append = function (item) { return this.insert(this.getItemCount(), item) } -// insert a new menu item at a specified location Menu.prototype.insert = function (pos, item) { if ((item ? item.constructor : void 0) !== MenuItem) { throw new TypeError('Invalid item') @@ -123,7 +118,6 @@ Menu.prototype.insert = function (pos, item) { this.commandsMap[item.commandId] = item } -// Force menuWillShow to be called Menu.prototype._callMenuWillShow = function () { if (this.delegate) this.delegate.menuWillShow() this.items.forEach(item => { @@ -133,7 +127,6 @@ Menu.prototype._callMenuWillShow = function () { /* Static Methods */ -// return application menu Menu.getApplicationMenu = () => applicationMenu Menu.sendActionToFirstResponder = bindings.sendActionToFirstResponder @@ -155,7 +148,6 @@ Menu.setApplicationMenu = function (menu) { } } -// build a menu by passing in a template Menu.buildFromTemplate = function (template) { if (!(template instanceof Array)) { throw new TypeError('Invalid template for Menu') @@ -201,13 +193,11 @@ function generateGroupId (items, pos) { return groupIdIndex } -// Returns the index of item according to |id|. function indexOfItemById (items, id) { const foundItem = items.find(item => item.id === id) || -1 return items.indexOf(foundItem) } -// Returns the index of where to insert the item according to |position| function indexToInsertByPosition (items, position) { if (!position) return items.length @@ -242,7 +232,6 @@ function indexToInsertByPosition (items, position) { return (query in queries) ? queries[query](idx) : idx } -// insert a new MenuItem depending on its type function insertItemByType (item, pos) { const types = { normal: () => this.insertItem(pos, item.commandId, item.label),