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