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