SymphonyElectron/js/menus/menuTemplate.js

165 lines
3.8 KiB
JavaScript
Raw Normal View History

2017-02-14 19:44:15 -06:00
'use strict';
2017-03-03 18:07:48 -06:00
const electron = require('electron');
2016-11-07 14:31:39 -06:00
const template = [
2017-03-03 18:07:48 -06:00
{
label: 'Edit',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
{ role: 'pasteandmatchstyle' },
{ role: 'delete' },
{ role: 'selectall' }
]
},
{
label: 'View',
submenu: [
{
label: 'Reload',
accelerator: 'CmdOrCtrl+R',
click (item, focusedWindow) {
if (focusedWindow) {
focusedWindow.reload();
}
}
},
{
label: 'Toggle Developer Tools',
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
click (item, focusedWindow) {
if (focusedWindow) {
focusedWindow.webContents.toggleDevTools();
}
}
},
{
type: 'separator'
},
{
role: 'resetzoom'
},
{
role: 'zoomin'
},
{
role: 'zoomout'
},
{
type: 'separator'
},
{
role: 'togglefullscreen'
}
]
},
{
role: 'window',
submenu: [
{
role: 'minimize'
},
{
role: 'close'
}
]
},
{
role: 'help',
submenu: [
{
label: 'Learn More',
click () { electron.shell.openExternal('https://www.symphony.com') }
}
]
}
2016-11-07 14:31:39 -06:00
];
function getTemplate(app) {
2016-11-08 18:32:04 -06:00
if (process.platform === 'darwin' && template[0].label !== app.getName()) {
2017-03-03 18:07:48 -06:00
template.unshift({
label: app.getName(),
submenu: [
{
role: 'about'
},
{
type: 'separator'
},
{
role: 'services',
submenu: []
},
{
type: 'separator'
},
{
role: 'hide'
},
{
role: 'hideothers'
},
{
role: 'unhide'
},
{
type: 'separator'
},
{
role: 'quit'
}
]
});
2016-11-07 14:31:39 -06:00
// Edit menu.
2017-03-03 18:07:48 -06:00
template[1].submenu.push(
{
type: 'separator'
2016-11-07 14:31:39 -06:00
},
{
2017-03-03 18:07:48 -06:00
label: 'Speech',
submenu: [
{
role: 'startspeaking'
},
{
role: 'stopspeaking'
}
]
2016-11-07 14:31:39 -06:00
}
)
// Window menu.
2017-03-03 18:07:48 -06:00
template[3].submenu = [
{
label: 'Close',
accelerator: 'CmdOrCtrl+W',
role: 'close'
},
{
label: 'Minimize',
accelerator: 'CmdOrCtrl+M',
role: 'minimize'
},
{
label: 'Zoom',
role: 'zoom'
},
{
type: 'separator'
},
{
label: 'Bring All to Front',
role: 'front'
}
]
2016-11-07 14:31:39 -06:00
}
return template;
}
module.exports = getTemplate;