forked from prose/prose
-
Notifications
You must be signed in to change notification settings - Fork 1
/
boot.js
79 lines (66 loc) · 2.13 KB
/
boot.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
74
75
76
77
78
79
---
---
{% include vendor/jquery-1.7.1.min.js %}
{% include vendor/underscore-min.js %}
{% include vendor/backbone-min.js %}
{% include vendor/js-yaml.min.js %}
{% include vendor/chrono.js %}
{% include vendor/marked.js %}
{% include vendor/base64.js %}
{% include vendor/github.js %}
{% include vendor/keymaster.js %}
{% include vendor/codemirror/codemirror.js %}
{% include vendor/codemirror/xml.js %}
{% include vendor/codemirror/markdown.js %}
{% include vendor/codemirror/yaml.js %}
{% include vendor/jquery.cookie.js %}
{% include vendor/bootstrap-dropdown.js %}
window.app = {
config: {},
models: {},
views: {},
routers: {},
utils: {},
templates: _($('script[name]')).reduce(function(memo, el) {
memo[el.getAttribute('name')] = _(el.innerHTML).template();
return memo;
}, {}),
state: {'repo': ''},
instance: {}
};
window.args = _(window.app).toArray();
{% include util.js %}
{% include model.js %}
{% include routers/application.js %}
{% include views/application.js %}
{% include views/notification.js %}
{% include views/start.js %}
{% include views/header.js %}
{% include views/posts.js %}
{% include views/post.js %}
// Prevent exit when there are unsaved changes
window.onbeforeunload = function() {
if (window.app.instance.mainView && window.app.instance.mainView.dirty)
return "You have unsaved changes. Are you sure you want to leave?";
};
function confirmExit() {
if (window.app.instance.mainView && window.app.instance.mainView.dirty)
return confirm("You have unsaved changes. Are you sure you want to leave?");
return true;
}
(function(config, models, views, routers, utils, templates) {
$(function() {
if (authenticate()) {
loadApplication(function(err, data) {
// Start the engines
window.app.instance = new views.Application({ el: '#container', model: data }).render();
if (!window.location.href.match(/\.html/)) {
// Initialize router
window.router = new routers.Application({});
// Start responding to routes
Backbone.history.start();
}
});
}
});
}).apply(this, window.args);