git ssb

5+

Matt McKegg / ferment



Tree: 13868e1aa6a7204af20406c760dac884fd24fdf1

Files: 13868e1aa6a7204af20406c760dac884fd24fdf1 / lib / context-menu.js

1476 bytesRaw
1var electron = require('electron')
2var Menu = electron.remote.Menu
3var MenuItem = electron.remote.MenuItem
4var BrowserWindow = electron.remote.BrowserWindow
5
6window.addEventListener('contextmenu', function (e) {
7 module.exports(null, null, e)
8}, false)
9
10module.exports = function (context, item, ev) {
11 ev.preventDefault()
12 ev.stopPropagation()
13 var menu = new Menu()
14 menu.append(new MenuItem({
15 label: 'Reload',
16 click: function (item, focusedWindow) {
17 if (focusedWindow) {
18 focusedWindow.reload()
19 }
20 }
21 }))
22 menu.append(new MenuItem({
23 type: 'separator'
24 }))
25 menu.append(new MenuItem({
26 label: 'Inspect Element',
27 click: function () {
28 var x = ev.clientX
29 var y = ev.clientY
30 BrowserWindow.getFocusedWindow().inspectElement(x, y)
31 }
32 }))
33 menu.append(new MenuItem({
34 label: 'Inspect Background Process',
35 click: function () {
36 electron.ipcRenderer.send('open-background-devtools')
37 }
38 }))
39
40 if (item && item.id) {
41 menu.append(new MenuItem({
42 label: 'Copy SSB ID',
43 click: function () {
44 electron.clipboard.writeText(item.id)
45 }
46 }))
47 }
48
49 if (item && item._type === 'ferment/audio' && item.author.id !== context.api.id) {
50 menu.append(new MenuItem({
51 label: 'Stop Sharing Post (delete cached)',
52 click: function () {
53 context.background.deleteTorrent(item.audioSrc())
54 }
55 }))
56 }
57
58 menu.popup(electron.remote.getCurrentWindow())
59}
60

Built with git-ssb-web