Use arrow functions to replace old CoffeeScript => this wrappers
This commit is contained in:
parent
100ea975bd
commit
a3f08c9b51
10 changed files with 176 additions and 212 deletions
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
const BrowserWindow = require('electron').BrowserWindow;
|
||||
const MenuItem = require('electron').MenuItem;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
|
@ -92,65 +94,51 @@ Menu.prototype._init = function() {
|
|||
this.groupsMap = {};
|
||||
this.items = [];
|
||||
return this.delegate = {
|
||||
isCommandIdChecked: (function(_this) {
|
||||
return function(commandId) {
|
||||
var ref1;
|
||||
return (ref1 = _this.commandsMap[commandId]) != null ? ref1.checked : void 0;
|
||||
};
|
||||
})(this),
|
||||
isCommandIdEnabled: (function(_this) {
|
||||
return function(commandId) {
|
||||
var ref1;
|
||||
return (ref1 = _this.commandsMap[commandId]) != null ? ref1.enabled : void 0;
|
||||
};
|
||||
})(this),
|
||||
isCommandIdVisible: (function(_this) {
|
||||
return function(commandId) {
|
||||
var ref1;
|
||||
return (ref1 = _this.commandsMap[commandId]) != null ? ref1.visible : void 0;
|
||||
};
|
||||
})(this),
|
||||
getAcceleratorForCommandId: (function(_this) {
|
||||
return function(commandId) {
|
||||
var ref1;
|
||||
return (ref1 = _this.commandsMap[commandId]) != null ? ref1.accelerator : void 0;
|
||||
};
|
||||
})(this),
|
||||
getIconForCommandId: (function(_this) {
|
||||
return function(commandId) {
|
||||
var ref1;
|
||||
return (ref1 = _this.commandsMap[commandId]) != null ? ref1.icon : void 0;
|
||||
};
|
||||
})(this),
|
||||
executeCommand: (function(_this) {
|
||||
return function(commandId) {
|
||||
var ref1;
|
||||
return (ref1 = _this.commandsMap[commandId]) != null ? ref1.click(BrowserWindow.getFocusedWindow()) : void 0;
|
||||
};
|
||||
})(this),
|
||||
menuWillShow: (function(_this) {
|
||||
return function() {
|
||||
|
||||
// Make sure radio groups have at least one menu item seleted.
|
||||
var checked, group, id, j, len, radioItem, ref1;
|
||||
ref1 = _this.groupsMap;
|
||||
for (id in ref1) {
|
||||
group = ref1[id];
|
||||
checked = false;
|
||||
for (j = 0, len = group.length; j < len; j++) {
|
||||
radioItem = group[j];
|
||||
if (!radioItem.checked) {
|
||||
continue;
|
||||
}
|
||||
checked = true;
|
||||
break;
|
||||
}
|
||||
if (!checked) {
|
||||
v8Util.setHiddenValue(group[0], 'checked', true);
|
||||
isCommandIdChecked: (commandId) => {
|
||||
var command = this.commandsMap[commandId];
|
||||
return command != null ? command.checked : undefined;
|
||||
},
|
||||
isCommandIdEnabled: (commandId) => {
|
||||
var command = this.commandsMap[commandId];
|
||||
return command != null ? command.enabled : undefined;
|
||||
},
|
||||
isCommandIdVisible: (commandId) => {
|
||||
var command = this.commandsMap[commandId];
|
||||
return command != null ? command.visible : undefined;
|
||||
},
|
||||
getAcceleratorForCommandId: (commandId) => {
|
||||
var command = this.commandsMap[commandId];
|
||||
return command != null ? command.accelerator : undefined;
|
||||
},
|
||||
getIconForCommandId: (commandId) => {
|
||||
var command = this.commandsMap[commandId];
|
||||
return command != null ? command.icon : void 0;
|
||||
},
|
||||
executeCommand: (commandId) => {
|
||||
var command = this.commandsMap[commandId];
|
||||
return command != null ? command.click(BrowserWindow.getFocusedWindow()) : undefined;
|
||||
},
|
||||
menuWillShow: () => {
|
||||
// Make sure radio groups have at least one menu item seleted.
|
||||
var checked, group, id, j, len, radioItem, ref1;
|
||||
ref1 = this.groupsMap;
|
||||
results = [];
|
||||
for (id in ref1) {
|
||||
group = ref1[id];
|
||||
checked = false;
|
||||
for (j = 0, len = group.length; j < len; j++) {
|
||||
radioItem = group[j];
|
||||
if (!radioItem.checked) {
|
||||
continue;
|
||||
}
|
||||
checked = true;
|
||||
break;
|
||||
}
|
||||
if (!checked) {
|
||||
v8Util.setHiddenValue(group[0], 'checked', true);
|
||||
}
|
||||
};
|
||||
})(this)
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -208,19 +196,17 @@ Menu.prototype.insert = function(pos, item) {
|
|||
get: function() {
|
||||
return v8Util.getHiddenValue(item, 'checked');
|
||||
},
|
||||
set: (function(_this) {
|
||||
return function() {
|
||||
var j, len, otherItem, ref1;
|
||||
ref1 = _this.groupsMap[item.groupId];
|
||||
for (j = 0, len = ref1.length; j < len; j++) {
|
||||
otherItem = ref1[j];
|
||||
if (otherItem !== item) {
|
||||
v8Util.setHiddenValue(otherItem, 'checked', false);
|
||||
}
|
||||
set: () => {
|
||||
var j, len, otherItem, ref1;
|
||||
ref1 = this.groupsMap[item.groupId];
|
||||
for (j = 0, len = ref1.length; j < len; j++) {
|
||||
otherItem = ref1[j];
|
||||
if (otherItem !== item) {
|
||||
v8Util.setHiddenValue(otherItem, 'checked', false);
|
||||
}
|
||||
return v8Util.setHiddenValue(item, 'checked', true);
|
||||
};
|
||||
})(this)
|
||||
}
|
||||
return v8Util.setHiddenValue(item, 'checked', true);
|
||||
}
|
||||
});
|
||||
this.insertRadioItem(pos, item.commandId, item.label, item.groupId);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue