Use `const`
This commit is contained in:
Родитель
9103253f62
Коммит
3a0fb42737
|
@ -26,8 +26,8 @@ MenuItem = (function() {
|
|||
MenuItem.types = ['normal', 'separator', 'submenu', 'checkbox', 'radio'];
|
||||
|
||||
function MenuItem(options) {
|
||||
var Menu, click, ref;
|
||||
Menu = require('electron').Menu;
|
||||
var click, ref;
|
||||
const Menu = require('electron').Menu;
|
||||
click = options.click, this.selector = options.selector, this.type = options.type, this.role = options.role, this.label = options.label, this.sublabel = options.sublabel, this.accelerator = options.accelerator, this.icon = options.icon, this.enabled = options.enabled, this.visible = options.visible, this.checked = options.checked, this.submenu = options.submenu;
|
||||
if ((this.submenu != null) && this.submenu.constructor !== Menu) {
|
||||
this.submenu = Menu.buildFromTemplate(this.submenu);
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
var BrowserWindow, EventEmitter, Menu, MenuItem, applicationMenu, bindings, generateGroupId, indexOfItemById, indexToInsertByPosition, nextGroupId, ref, v8Util;
|
||||
|
||||
ref = require('electron'), BrowserWindow = ref.BrowserWindow, MenuItem = ref.MenuItem;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
v8Util = process.atomBinding('v8_util');
|
||||
|
||||
bindings = process.atomBinding('menu');
|
||||
const BrowserWindow = require('electron').BrowserWindow;
|
||||
const MenuItem = require('electron').MenuItem;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const v8Util = process.atomBinding('v8_util');
|
||||
const bindings = process.atomBinding('menu');
|
||||
|
||||
// Automatically generated radio menu item's group id.
|
||||
nextGroupId = 0;
|
||||
var nextGroupId = 0;
|
||||
|
||||
// Search between seperators to find a radio menu item and return its group id,
|
||||
// otherwise generate a group id.
|
||||
generateGroupId = function(items, pos) {
|
||||
var generateGroupId = function(items, pos) {
|
||||
var i, item, j, k, ref1, ref2, ref3;
|
||||
if (pos > 0) {
|
||||
for (i = j = ref1 = pos - 1; ref1 <= 0 ? j <= 0 : j >= 0; i = ref1 <= 0 ? ++j : --j) {
|
||||
|
@ -40,7 +36,7 @@ generateGroupId = function(items, pos) {
|
|||
};
|
||||
|
||||
// Returns the index of item according to |id|.
|
||||
indexOfItemById = function(items, id) {
|
||||
var indexOfItemById = function(items, id) {
|
||||
var i, item, j, len;
|
||||
for (i = j = 0, len = items.length; j < len; i = ++j) {
|
||||
item = items[i];
|
||||
|
@ -52,7 +48,7 @@ indexOfItemById = function(items, id) {
|
|||
};
|
||||
|
||||
// Returns the index of where to insert the item according to |position|.
|
||||
indexToInsertByPosition = function(items, position) {
|
||||
var indexToInsertByPosition = function(items, position) {
|
||||
var id, insertIndex, query, ref1;
|
||||
if (!position) {
|
||||
return items.length;
|
||||
|
@ -87,7 +83,7 @@ indexToInsertByPosition = function(items, position) {
|
|||
return insertIndex;
|
||||
};
|
||||
|
||||
Menu = bindings.Menu;
|
||||
const Menu = bindings.Menu;
|
||||
|
||||
Menu.prototype.__proto__ = EventEmitter.prototype;
|
||||
|
||||
|
@ -265,7 +261,7 @@ Menu.prototype._callMenuWillShow = function() {
|
|||
return results;
|
||||
};
|
||||
|
||||
applicationMenu = null;
|
||||
var applicationMenu = null;
|
||||
|
||||
Menu.setApplicationMenu = function(menu) {
|
||||
var j, len, results, w, windows;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
var NavigationController, ipcMain,
|
||||
slice = [].slice;
|
||||
const ipcMain = require('electron').ipcMain;
|
||||
|
||||
ipcMain = require('electron').ipcMain;
|
||||
var slice = [].slice;
|
||||
|
||||
// The history operation in renderer is redirected to browser.
|
||||
ipcMain.on('ATOM_SHELL_NAVIGATION_CONTROLLER', function() {
|
||||
|
@ -21,7 +20,7 @@ ipcMain.on('ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER', function() {
|
|||
// control on user land, and only rely on WebContents.loadURL for navigation.
|
||||
// This helps us avoid Chromium's various optimizations so we can ensure renderer
|
||||
// process is restarted everytime.
|
||||
NavigationController = (function() {
|
||||
var NavigationController = (function() {
|
||||
function NavigationController(webContents) {
|
||||
this.webContents = webContents;
|
||||
this.clearHistory();
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
var EventEmitter, powerMonitor;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
powerMonitor = process.atomBinding('power_monitor').powerMonitor;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const powerMonitor = process.atomBinding('power_monitor').powerMonitor;
|
||||
|
||||
powerMonitor.__proto__ = EventEmitter.prototype;
|
||||
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
var app, logAndThrow, protocol;
|
||||
|
||||
app = require('electron').app;
|
||||
const app = require('electron').app;
|
||||
|
||||
if (!app.isReady()) {
|
||||
throw new Error('Can not initialize protocol module before app is ready');
|
||||
}
|
||||
|
||||
protocol = process.atomBinding('protocol').protocol;
|
||||
const protocol = process.atomBinding('protocol').protocol;
|
||||
|
||||
// Warn about removed APIs.
|
||||
logAndThrow = function(callback, message) {
|
||||
var logAndThrow = function(callback, message) {
|
||||
console.error(message);
|
||||
if (callback) {
|
||||
return callback(new Error(message));
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
var EventEmitter, screen;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
screen = process.atomBinding('screen').screen;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const screen = process.atomBinding('screen').screen;
|
||||
|
||||
screen.__proto__ = EventEmitter.prototype;
|
||||
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
var EventEmitter, PERSIST_PERFIX, bindings, wrapSession;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
bindings = process.atomBinding('session');
|
||||
|
||||
PERSIST_PERFIX = 'persist:';
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const bindings = process.atomBinding('session');
|
||||
const PERSIST_PERFIX = 'persist:';
|
||||
|
||||
// Returns the Session from |partition| string.
|
||||
exports.fromPartition = function(partition) {
|
||||
|
@ -29,7 +25,7 @@ Object.defineProperty(exports, 'defaultSession', {
|
|||
}
|
||||
});
|
||||
|
||||
wrapSession = function(session) {
|
||||
var wrapSession = function(session) {
|
||||
// session is an EventEmitter.
|
||||
return session.__proto__ = EventEmitter.prototype;
|
||||
};
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
var EventEmitter, Tray, deprecate;
|
||||
|
||||
deprecate = require('electron').deprecate;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
Tray = process.atomBinding('tray').Tray;
|
||||
const deprecate = require('electron').deprecate;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const Tray = process.atomBinding('tray').Tray;
|
||||
|
||||
Tray.prototype.__proto__ = EventEmitter.prototype;
|
||||
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
'use strict';
|
||||
|
||||
var EventEmitter, Menu, NavigationController, PDFPageSize, binding, deprecate, getNextId, ipcMain, nextId, ref, session, wrapWebContents,
|
||||
slice = [].slice;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const deprecate = require('electron').deprecate;
|
||||
const ipcMain = require('electron').ipcMain;
|
||||
const session = require('electron').session;
|
||||
const NavigationController = require('electron').NavigationController;
|
||||
const Menu = require('electron').Menu;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
const binding = process.atomBinding('web_contents');
|
||||
|
||||
ref = require('electron'), deprecate = ref.deprecate, ipcMain = ref.ipcMain, session = ref.session, NavigationController = ref.NavigationController, Menu = ref.Menu;
|
||||
let slice = [].slice;
|
||||
let nextId = 0;
|
||||
|
||||
binding = process.atomBinding('web_contents');
|
||||
|
||||
nextId = 0;
|
||||
|
||||
getNextId = function() {
|
||||
let getNextId = function() {
|
||||
return ++nextId;
|
||||
};
|
||||
|
||||
PDFPageSize = {
|
||||
let PDFPageSize = {
|
||||
A5: {
|
||||
custom_display_name: "A5",
|
||||
height_microns: 210000,
|
||||
|
@ -64,7 +65,7 @@ const webFrameMethods = [
|
|||
'setZoomLevelLimits',
|
||||
];
|
||||
|
||||
wrapWebContents = function(webContents) {
|
||||
let wrapWebContents = function(webContents) {
|
||||
// webContents is an EventEmitter.
|
||||
var controller, method, name, ref1;
|
||||
webContents.__proto__ = EventEmitter.prototype;
|
||||
|
|
|
@ -1,33 +1,28 @@
|
|||
var app, electron, extensionInfoMap, fs, getExtensionInfoFromPath, getHostForPath, getPathForHost, hostPathMap, hostPathMapNextKey, loadedExtensions, loadedExtensionsPath, path, url;
|
||||
|
||||
electron = require('electron');
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
path = require('path');
|
||||
|
||||
url = require('url');
|
||||
const electron = require('electron');
|
||||
const app = electron.app;
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const url = require('url');
|
||||
|
||||
// Mapping between hostname and file path.
|
||||
hostPathMap = {};
|
||||
var hostPathMap = {};
|
||||
var hostPathMapNextKey = 0;
|
||||
|
||||
hostPathMapNextKey = 0;
|
||||
|
||||
getHostForPath = function(path) {
|
||||
var getHostForPath = function(path) {
|
||||
var key;
|
||||
key = "extension-" + (++hostPathMapNextKey);
|
||||
hostPathMap[key] = path;
|
||||
return key;
|
||||
};
|
||||
|
||||
getPathForHost = function(host) {
|
||||
var getPathForHost = function(host) {
|
||||
return hostPathMap[host];
|
||||
};
|
||||
|
||||
// Cache extensionInfo.
|
||||
extensionInfoMap = {};
|
||||
var extensionInfoMap = {};
|
||||
|
||||
getExtensionInfoFromPath = function(srcDirectory) {
|
||||
var getExtensionInfoFromPath = function(srcDirectory) {
|
||||
var manifest, page;
|
||||
manifest = JSON.parse(fs.readFileSync(path.join(srcDirectory, 'manifest.json')));
|
||||
if (extensionInfoMap[manifest.name] == null) {
|
||||
|
@ -51,11 +46,8 @@ getExtensionInfoFromPath = function(srcDirectory) {
|
|||
};
|
||||
|
||||
// The loaded extensions cache and its persistent path.
|
||||
loadedExtensions = null;
|
||||
loadedExtensionsPath = null;
|
||||
|
||||
// Persistent loaded extensions.
|
||||
app = electron.app;
|
||||
var loadedExtensions = null;
|
||||
var loadedExtensionsPath = null;
|
||||
|
||||
app.on('will-quit', function() {
|
||||
var e, error1, error2;
|
||||
|
|
Загрузка…
Ссылка в новой задаче