-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
93 lines (92 loc) · 2.68 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
91
92
93
(function($) {
var app = $.sammy("#app", function() {
this.use("Template");
this.around(function(callback) {
var context = this;
this.load("dist/data/pano.json")
.then(function(items) {
context.items = items;
})
.then(callback);
});
this.around(function(callback) {
var context = this;
this.load("dist/data/planet.json")
.then(function(items2) {
context.items2 = items2;
})
.then(callback);
});
this.get("#/", function(context) {
context.app.swap("");
context.render("templates/home.template").appendTo(context.$element());
});
this.get("#/about", function(context) {
context.app.swap("");
context.render("templates/about.template").appendTo(context.$element());
});
this.get("#/jurusan", function(context) {
context.app.swap("");
context.render("templates/course.template").appendTo(context.$element());
});
this.get("#/petunjuk", function(context) {
context.app.swap("");
context.render("templates/guide.template").appendTo(context.$element());
});
this.get("#/stat_poll", function(context) {
context.app.swap("");
context
.render("templates/stat_poll.template")
.appendTo(context.$element());
});
this.get("#/panorama", function(context) {
context.app.swap("");
context
.render("templates/panorama.template")
.appendTo(context.$element());
$.each(this.items, function(i, item) {
var url = item.url;
var slug = url.substring(0, url.length - 19);
context
.render("templates/list.template", {
id: i,
item: item,
slug: slug
})
.appendTo("#data");
//console.log(item);
});
$.each(this.items2, function(i, item) {
context
.render("templates/list2.template", {
id: i,
item: item
})
.appendTo("#data-planet");
});
});
this.before(".*", function() {
var hash = document.location.hash;
$(".nav")
.find("a")
.removeClass("active");
$(".nav")
.find("a[href='" + hash + "']")
.addClass("active");
});
this.before(
["#/about", "#/jurusan", "#/petunjuk", "#/panorama", "#/stat_poll"],
function() {
$(".navbar").removeClass("navbar-fixed-top navbar-off");
$(".nav").removeClass("navbar-virtual");
}
);
this.before("#/", function() {
$(".navbar").addClass("navbar-fixed-top navbar-off");
$(".nav").addClass("navbar-virtual");
});
});
$(function() {
app.run("#/");
});
})(jQuery);