-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.js
More file actions
167 lines (117 loc) · 3.52 KB
/
jquery.js
File metadata and controls
167 lines (117 loc) · 3.52 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
var PAGE_HOME = "about_notes";
var PAGE_LEGAL = "legal2";
var PAGE_ABOUT_US = "about_us";
var current = PAGE_HOME;
//https://stackoverflow.com/a/23853418/4673960
if (typeof(Storage) !== "undefined" && sessionStorage.getItem('pageToShow')) {
var pageToShow = sessionStorage.getItem('pageToShow');
current = pageToShow;
}
$(document).ready(function() {
//load saved page
if (current === PAGE_HOME) {
loadAboutNotes();
} else {
if (current === PAGE_LEGAL) {
loadLegal();
} else if (current === PAGE_ABOUT_US) {
loadAboutCherry();
}
}
$("#community_placeholder").load("community.html");
$("#download_placeholder").load("download.html");
if (typeof(Storage) !== "undefined" && sessionStorage.getItem('scrollTop')) {
var scr = sessionStorage.getItem('scrollTop');
// console.log(scr);
//$(document).scrollTop(scr); works in IE and Edge, not others
// $('html, body').animate({ scrollTop: scr }, "fast"); //works in Chrome, but has an annoying side-effect.
//$("html").scrollTop(scr); in ie and Edge
window.setTimeout(function() {
// console.log("afTimeOut " + scr);
$(window).scrollTop(scr);
}, 100); //works in all. thanks: JamoCA https://github.com/flesler/jquery.scrollTo/issues/164
}
var scroll = $(window).scrollTop()
if (typeof(Storage) !== "undefined") {
sessionStorage.setItem('scrollTop', scroll);
}
$("#pp").click(function() {
scrollToTop();
loadLegal();
});
$("#legal").click(function() {
scrollToTop();
loadLegal();
});
$("#about").click(function() {
scrollToTop();
loadAboutCherry();
});
$("#home").click(function() {
scrollToAfterLoad("top");
});
$("#home_about").click(function() {
scrollToAfterLoad("#about");
});
$("#home_features").click(function() {
scrollToAfterLoad("#features");
});
$("#community_nav").click(function() {
scrollToElement("#community", -120);
});
$("#download_nav").click(function() {
scrollToElement("#download", -120);
});
});
function loadAboutNotes() {
$("#content_placeholder").load("about_notes.html");
//current = PAGE_HOME; not needed because already initialized to that value TODO
if (typeof(Storage) !== "undefined") {
sessionStorage.setItem('pageToShow', current);
}
}
function loadLegal() {
$("#content_placeholder").load("legal2.html");
current = PAGE_LEGAL;
if (typeof(Storage) !== "undefined") {
sessionStorage.setItem('pageToShow', current);
}
}
function loadAboutCherry() {
$("#content_placeholder").load("about_us.html");
current = PAGE_ABOUT_US;
if (typeof(Storage) !== "undefined") {
sessionStorage.setItem('pageToShow', current);
}
}
function scrollToTop() {
$("html, body").animate({
scrollTop: 0
}, "slow");
}
function scrollToElement(where, offset) {
$('html, body').animate({
scrollTop: $(where).offset().top + offset
}, 2000);
}
function scrollToAfterLoad(scrollToWhere) {
if (current != PAGE_HOME) {
$("#content_placeholder").load("about_notes.html", function() {
if (scrollToWhere === "top") scrollToTop();
else scrollToElement(scrollToWhere, -120);
});
current = PAGE_HOME;
} else {
if (scrollToWhere === "top") scrollToTop();
else scrollToElement(scrollToWhere, -120);
}
if (typeof(Storage) !== "undefined") {
sessionStorage.setItem('pageToShow', current);
}
}
$(window).scroll(function() {
var scroll = $(this).scrollTop()
if (typeof(Storage) !== "undefined") {
sessionStorage.setItem('scrollTop', scroll);
}
});