-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
90 lines (78 loc) · 2.24 KB
/
app.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
80
81
82
83
84
85
86
87
88
89
90
// If we need to use custom DOM library, let's save it to $$ variable:
var $$ = Dom7;
// set base url
$$.baseUrl = 'http://localhost:8080/wax/app/';
// App instance
var app = new Framework7({
template7Pages: true,
precompileTemplates: true,
init: false,
debug: true,
// If it is webapp, we can enable hash navigation:
pushState: true,
// Hide and show indicator during ajax requests
onAjaxStart: function (xhr) {
app.showIndicator();
},
onAjaxComplete: function (xhr) {
app.hideIndicator();
},
preroute: function (view, options) {
var activePage = view.activePage;
var fromPage = activePage.fromPage;
if (options.isBack) {
if (activePage && activePage.container) {
var instance = $$(activePage.container).data('instance');
// preventing back to prev page
if (instance && instance.preventBack) {
return instance.preventBack();
}
}
}
}
});
// creating class instances for pages
$$(document).on('page:init', function (e) {
var page = e.detail.page;
var el = $$(page.container);
var dataset = $$(page.container).dataset();
// page jsclass
if (dataset.jsclass) {
var instance = createClass(dataset.jsclass, page);
$$(page.container).data('instance', instance);
// page event listeners
if (instance.onReinit) {
el.on('page:reinit', function(e) { return instance.onReinit(e); })
}
if (instance.onBeforeAnimation) {
el.on('page:beforeanimation', function(e) { return instance.onBeforeAnimation(e); })
}
if (instance.onAfterAnimation) {
el.on('page:afteranimation', function(e) { return instance.onAfterAnimation(e); })
}
if (instance.onBeforeRemove) {
el.on('page:beforeremove', function(e) { return instance.onBeforeRemove(e); })
}
if (instance.onBack) {
el.on('page:back', function(e) { return instance.onBack(e); })
}
if (instance.onAfterBack) {
el.on('page:afterback', function(e) { return instance.onAfterBack(e); })
}
}
});
// Add views
var mainView = app.addView('#tab1', {
dynamicNavbar: true,
precompileTemplates: true
});
var statisticView = app.addView('#tab2', {
dynamicNavbar: true,
precompileTemplates: true
});
var battleView = app.addView('#tab3', {
dynamicNavbar: true,
precompileTemplates: true
});
// init app
app.init();