standardize all javascript blocks in English docs

This commit is contained in:
Zeke Sikelianos 2016-07-25 18:39:25 -07:00
parent dd9935a9d7
commit 06a354a2eb
37 changed files with 567 additions and 445 deletions

View file

@ -15,18 +15,18 @@ the user right clicks the page:
```html
<!-- index.html -->
<script>
const {remote} = require('electron');
const {remote} = require('electron')
const {Menu, MenuItem} = remote;
const menu = new Menu();
menu.append(new MenuItem({label: 'MenuItem1', click() { console.log('item 1 clicked'); }}));
menu.append(new MenuItem({type: 'separator'}));
menu.append(new MenuItem({label: 'MenuItem2', type: 'checkbox', checked: true}));
const menu = new Menu()
menu.append(new MenuItem({label: 'MenuItem1', click() { console.log('item 1 clicked') }}))
menu.append(new MenuItem({type: 'separator'}))
menu.append(new MenuItem({label: 'MenuItem2', type: 'checkbox', checked: true}))
window.addEventListener('contextmenu', (e) => {
e.preventDefault();
menu.popup(remote.getCurrentWindow());
}, false);
e.preventDefault()
menu.popup(remote.getCurrentWindow())
}, false)
</script>
```
@ -34,6 +34,8 @@ An example of creating the application menu in the render process with the
simple template API:
```javascript
const {Menu} = require('electron')
const template = [
{
label: 'Edit',
@ -64,7 +66,7 @@ const template = [
},
{
role: 'selectall'
},
}
]
},
{
@ -73,8 +75,8 @@ const template = [
{
label: 'Reload',
accelerator: 'CmdOrCtrl+R',
click(item, focusedWindow) {
if (focusedWindow) focusedWindow.reload();
click (item, focusedWindow) {
if (focusedWindow) focusedWindow.reload()
}
},
{
@ -83,11 +85,10 @@ const template = [
{
label: 'Toggle Developer Tools',
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
click(item, focusedWindow) {
if (focusedWindow)
focusedWindow.webContents.toggleDevTools();
click (item, focusedWindow) {
if (focusedWindow) focusedWindow.webContents.toggleDevTools()
}
},
}
]
},
{
@ -98,7 +99,7 @@ const template = [
},
{
role: 'close'
},
}
]
},
{
@ -106,14 +107,14 @@ const template = [
submenu: [
{
label: 'Learn More',
click() { require('electron').shell.openExternal('http://electron.atom.io'); }
},
click () { require('electron').shell.openExternal('http://electron.atom.io') }
}
]
},
];
}
]
if (process.platform === 'darwin') {
const name = require('electron').remote.app.getName();
const name = require('electron').remote.app.getName()
template.unshift({
label: name,
submenu: [
@ -144,9 +145,9 @@ if (process.platform === 'darwin') {
},
{
role: 'quit'
},
}
]
});
})
// Window menu.
template[3].submenu = [
{
@ -170,11 +171,11 @@ if (process.platform === 'darwin') {
label: 'Bring All to Front',
role: 'front'
}
];
]
}
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
```
## Class: Menu
@ -320,7 +321,7 @@ the first item.
Template:
```javascript
```
[
{label: '4', id: '4'},
{label: '5', id: '5'},
@ -342,7 +343,7 @@ Menu:
Template:
```javascript
```
[
{label: 'a', position: 'endof=letters'},
{label: '1', position: 'endof=numbers'},