Files: d9ba09fe7118718dfeddc73ddab338839d9e78c7 / modules_core / menu.js
896 bytesRaw
1 | var h = require('hyperscript') |
2 | |
3 | module.exports = { |
4 | needs: {menu_items: 'map'}, |
5 | gives: {connection_status: true, menu: true}, |
6 | create: function (api) { |
7 | |
8 | var menu_items = api.menu_items |
9 | |
10 | var status = h('div.status.error') //start off disconnected |
11 | var list = h('div.menu.column', {style: 'display: none;'}) |
12 | |
13 | var menu = h('div.column', status, list , { |
14 | onmouseover: function (e) { |
15 | list.style.display = 'flex' |
16 | }, onmouseout: function () { |
17 | list.style.display = 'none' |
18 | } |
19 | }) |
20 | |
21 | setTimeout(function () { |
22 | menu_items().forEach(function (el) { |
23 | if(el) |
24 | list.appendChild(el) |
25 | }) |
26 | }, 0) |
27 | |
28 | return { |
29 | connection_status: function (err) { |
30 | if(err) status.classList.add('error') |
31 | else status.classList.remove('error') |
32 | }, |
33 | menu: function () { |
34 | return menu |
35 | } |
36 | } |
37 | } |
38 | } |
39 | |
40 | |
41 | |
42 | |
43 | |
44 | |
45 |
Built with git-ssb-web