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';
const ipcRenderer = require('electron').ipcRenderer;
const remote = require('electron').remote;
@ -37,12 +39,10 @@ var BrowserWindowProxy = (function() {
function BrowserWindowProxy(guestId1) {
this.guestId = guestId1;
this.closed = false;
ipcRenderer.once("ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSED_" + this.guestId, (function(_this) {
return function() {
BrowserWindowProxy.remove(_this.guestId);
return (_this.closed = true);
};
})(this));
ipcRenderer.once("ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSED_" + this.guestId, () => {
BrowserWindowProxy.remove(this.guestId);
this.closed = true;
});
}
BrowserWindowProxy.prototype.close = function() {
@ -182,7 +182,7 @@ if (process.openerId != null) {
ipcRenderer.on('ATOM_RENDERER_WINDOW_VISIBILITY_CHANGE', function (event, isVisible, isMinimized) {
var hasChanged = _isVisible != isVisible || _isMinimized != isMinimized;
if (hasChanged) {
_isVisible = isVisible;
_isMinimized = isMinimized;

View file

@ -86,25 +86,22 @@ var WebViewImpl = (function() {
WebViewImpl.prototype.setupFocusPropagation = function() {
if (!this.webviewNode.hasAttribute('tabIndex')) {
// <webview> needs a tabIndex in order to be focusable.
// TODO(fsamuel): It would be nice to avoid exposing a tabIndex attribute
// to allow <webview> to be focusable.
// See http://crbug.com/231664.
this.webviewNode.setAttribute('tabIndex', -1);
}
this.webviewNode.addEventListener('focus', (function(_this) {
return function() {
// Focus the BrowserPlugin when the <webview> takes focus.
return _this.browserPluginNode.focus();
};
})(this));
return this.webviewNode.addEventListener('blur', (function(_this) {
return function() {
// Blur the BrowserPlugin when the <webview> loses focus.
return _this.browserPluginNode.blur();
};
})(this));
// Focus the BrowserPlugin when the <webview> takes focus.
this.webviewNode.addEventListener('focus', () => {
this.browserPluginNode.focus();
});
// Blur the BrowserPlugin when the <webview> loses focus.
this.webviewNode.addEventListener('blur', () => {
this.browserPluginNode.blur();
});
};
@ -178,11 +175,9 @@ var WebViewImpl = (function() {
};
WebViewImpl.prototype.createGuest = function() {
return guestViewInternal.createGuest(this.buildParams(), (function(_this) {
return function(event, guestInstanceId) {
return _this.attachWindow(guestInstanceId);
};
})(this));
return guestViewInternal.createGuest(this.buildParams(), (event, guestInstanceId) => {
this.attachWindow(guestInstanceId);
});
};
WebViewImpl.prototype.dispatchEvent = function(webViewEvent) {
@ -195,22 +190,18 @@ var WebViewImpl = (function() {
var propertyName;
propertyName = 'on' + eventName.toLowerCase();
return Object.defineProperty(this.webviewNode, propertyName, {
get: (function(_this) {
return function() {
return _this.on[propertyName];
};
})(this),
set: (function(_this) {
return function(value) {
if (_this.on[propertyName]) {
_this.webviewNode.removeEventListener(eventName, _this.on[propertyName]);
}
_this.on[propertyName] = value;
if (value) {
return _this.webviewNode.addEventListener(eventName, value);
}
};
})(this),
get: () => {
this.on[propertyName];
},
set: (value) => {
if (this.on[propertyName]) {
this.webviewNode.removeEventListener(eventName, this.on[propertyName]);
}
this.on[propertyName] = value;
if (value) {
return this.webviewNode.addEventListener(eventName, value);
}
},
enumerable: true
});
};