-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.js
73 lines (58 loc) · 1.42 KB
/
bootstrap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
let linkmap = alchemy.shared('Connection.map'),
options,
menus;
/**
* Get the default menu object
*
* @author Jelle De Loecker <[email protected]>
* @since 0.3.0
* @version 0.3.0
*/
alchemy.plugins.menu.getDefault = function getDefault(name, callback) {
// Wait for alchemy, and all models, to be ready
alchemy.ready(function onReady() {
// Get the actual menu
let menu = Classes.Alchemy.Model.Menu.getDefault(name);
callback(null, menu);
});
};
alchemy.ready(function preloadMenus() {
var Menu = Model.get('Menu');
Menu.find('all', {document: false}, function allMenus(err, results) {
if (err) {
throw err;
}
let children,
entry,
temp,
c,
i,
j;
menus = {};
for (i = 0; i < results.length; i++) {
temp = results[i];
children = [];
if (temp.MenuPiece) {
for (j = 0; j < temp.MenuPiece.length; j++) {
c = temp.MenuPiece[j];
children.push(Object.assign({
id: c._id,
type: c.type
}, c.settings));
}
}
entry = {
name: temp.Menu.name,
id: temp.Menu._id,
children: children
};
menus[temp.Menu.name] = entry;
}
});
});
// Send the menu options to the client
alchemy.hawkejs.on({type: 'viewrender', status: 'begin', client: false}, function onBegin(viewRender) {
viewRender.expose('allMenus', menus);
viewRender.expose('linkMap', linkmap);
viewRender.expose('menuOptions', alchemy.plugins.menu);
});