Use arrow functions to replace old CoffeeScript => this wrappers

This commit is contained in:
Kevin Sawicki 2016-03-10 11:54:17 -08:00
parent 100ea975bd
commit a3f08c9b51
10 changed files with 176 additions and 212 deletions

View file

@ -1,3 +1,5 @@
'use strict';
var MenuItem, methodInBrowserWindow, nextCommandId, rolesMap;
nextCommandId = 0;
@ -51,28 +53,25 @@ MenuItem = (function() {
throw new Error("Unknown menu type " + this.type);
}
this.commandId = ++nextCommandId;
this.click = (function(_this) {
return function(focusedWindow) {
// Manually flip the checked flags when clicked.
var methodName, ref1, ref2;
if ((ref1 = _this.type) === 'checkbox' || ref1 === 'radio') {
_this.checked = !_this.checked;
this.click = (focusedWindow) => {
// Manually flip the checked flags when clicked.
var methodName, ref1, ref2;
if ((ref1 = this.type) === 'checkbox' || ref1 === 'radio') {
this.checked = !this.checked;
}
if (this.role && rolesMap[this.role] && process.platform !== 'darwin' && (focusedWindow != null)) {
methodName = rolesMap[this.role];
if (methodInBrowserWindow[methodName]) {
return focusedWindow[methodName]();
} else {
return (ref2 = focusedWindow.webContents) != null ? ref2[methodName]() : void 0;
}
if (_this.role && rolesMap[_this.role] && process.platform !== 'darwin' && (focusedWindow != null)) {
methodName = rolesMap[_this.role];
if (methodInBrowserWindow[methodName]) {
return focusedWindow[methodName]();
} else {
return (ref2 = focusedWindow.webContents) != null ? ref2[methodName]() : void 0;
}
} else if (typeof click === 'function') {
return click(_this, focusedWindow);
} else if (typeof _this.selector === 'string' && process.platform === 'darwin') {
return Menu.sendActionToFirstResponder(_this.selector);
}
};
})(this);
} else if (typeof click === 'function') {
return click(this, focusedWindow);
} else if (typeof this.selector === 'string' && process.platform === 'darwin') {
return Menu.sendActionToFirstResponder(this.selector);
}
};
}
MenuItem.prototype.overrideProperty = function(name, defaultValue) {