e6ec151e
Geoffrey PREUD'HOMME
Ensure only corre...
|
1
|
function removeAfter(string, pattern) {
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
2
3
|
var n = string.indexOf(pattern);
return string.substring(0, n != -1 ? n : string.length);
|
e6ec151e
Geoffrey PREUD'HOMME
Ensure only corre...
|
4
5
6
|
}
function pageName(href) {
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
7
8
9
10
11
12
|
if (href.indexOf(window.location.host) >= 0) {
href = removeAfter(removeAfter(href, '?'), '#');
hrefE = href.split('/');
return hrefE[hrefE.length - 1];
}
return false;
|
e6ec151e
Geoffrey PREUD'HOMME
Ensure only corre...
|
13
14
|
}
|
71b34f50
Geoffrey PREUD'HOMME
Navigation preser...
|
15
|
function updateScrollData() {
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
16
17
|
history.state.scrollTop = $(document.body).scrollTop();
history.replaceState(history.state);
|
71b34f50
Geoffrey PREUD'HOMME
Navigation preser...
|
18
19
|
}
|
dcc55bea
Geoffrey PREUD'HOMME
Minor cleanup nav...
|
20
|
function pageSpecific(location) {
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
21
22
|
if (pageName(location) == 'contact') {
initializeMap();
|
84032f20
Geoffrey PREUD'HOMME
tel: → callto: on PC
|
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// enhance tel-links (from http://stackoverflow.com/a/18921965/2766106)
$("a[href^='tel:']").each(function () {
var target = "call-" + this.href.replace(/[^a-z0-9]*/gi, "");
var link = this;
// load in iframe to supress potential errors when protocol is not available
$("body").append("<iframe name=\"" + target + "\" style=\"display: none\"></iframe>");
link.target = target;
// replace tel with callto on desktop browsers for skype fallback
if (!navigator.userAgent.match(/(mobile)/gi)) {
link.href = link.href.replace(/^tel:/, "callto:");
}
});
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
38
39
|
}
$(document).scroll(updateScrollData);
|
dcc55bea
Geoffrey PREUD'HOMME
Minor cleanup nav...
|
40
41
|
}
|
71b34f50
Geoffrey PREUD'HOMME
Navigation preser...
|
42
43
|
|
dcc55bea
Geoffrey PREUD'HOMME
Minor cleanup nav...
|
44
|
function actLink(ev) {
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
45
46
47
|
var location = ev.currentTarget.href;
var page = pageName(location);
if (page && page != pageName(window.location.href)) {
|
84032f20
Geoffrey PREUD'HOMME
tel: → callto: on PC
|
48
|
loadDoc(location, function () {
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
49
50
51
52
53
54
|
history.pushState({
loc: location
}, document.title, location);
});
return false;
}
|
7ab7e900
Jean Wasilewski
file function added
|
55
56
|
}
|
8485d451
Geoffrey PREUD'HOMME
New dynamic JS nav
|
57
|
function dynamiseLinks(el) {
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
58
|
$("a", el).click(actLink);
|
8485d451
Geoffrey PREUD'HOMME
New dynamic JS nav
|
59
60
|
}
|
be816fc8
Geoffrey PREUD'HOMME
Removed extra par...
|
61
|
function loadDoc(location, callback) {
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
62
|
if (!callback) {
|
84032f20
Geoffrey PREUD'HOMME
tel: → callto: on PC
|
63
|
callback = function () {
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
64
65
66
67
68
69
70
|
return undefined;
};
}
var eventsLeft = 2;
var html = '';
var mainContainer = $("#mainContainer");
var oldHeight = mainContainer.height();
|
0b2adb5b
Geoffrey PREUD'HOMME
Better animation
|
71
|
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
72
73
74
75
76
77
78
79
80
81
82
83
84
|
function events() {
eventsLeft += -1;
if (eventsLeft <= 0) {
// In
// Calculations
mainContainer.html(html);
mainContainer.height('auto');
newHeight = mainContainer.height();
mainContainer.height(oldHeight);
// Transition
mainContainer.animate({
height: newHeight,
opacity: 1,
|
84032f20
Geoffrey PREUD'HOMME
tel: → callto: on PC
|
85
|
}, 'fast', function () {
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
86
87
88
89
90
91
|
mainContainer.height('auto');
dynamiseLinks(mainContainer);
pageSpecific(location);
callback();
});
}
|
ae5ad01d
Geoffrey PREUD'HOMME
Animations !
|
92
|
}
|
0b2adb5b
Geoffrey PREUD'HOMME
Better animation
|
93
|
// Out
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
94
95
96
97
|
$(document).off('scroll', updateScrollData);
$(document.body).animate({
scrollTop: $('.navbar-lower').height()
}, 'fast');
|
84032f20
Geoffrey PREUD'HOMME
tel: → callto: on PC
|
98
|
$.get(location + '?c', function (data) {
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
99
100
101
102
103
104
105
|
html = data;
events();
});
mainContainer.height(oldHeight);
mainContainer.animate({
opacity: 0
}, 'fast', events);
|
b8d34eaa
Geoffrey PREUD'HOMME
Moved map initial...
|
106
107
|
}
|
d71b5167
Geoffrey PREUD'HOMME
Almost functionni...
|
108
|
function historyChange(ev) {
|
84032f20
Geoffrey PREUD'HOMME
tel: → callto: on PC
|
109
|
loadDoc(ev.state.loc, function () {
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
110
111
112
113
114
115
|
if (ev.state.scrollTop > $('.navbar-lower').height()) {
$(document.body).animate({
scrollTop: ev.state.scrollTop
}, 'fast');
}
});
|
d71b5167
Geoffrey PREUD'HOMME
Almost functionni...
|
116
117
|
}
|
84032f20
Geoffrey PREUD'HOMME
tel: → callto: on PC
|
118
|
$(document).ready(function () {
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
119
120
121
122
123
124
125
|
dynamiseLinks(document.body);
var current = window.location.href;
pageSpecific(current);
history.replaceState({
loc: current
}, document.title, current);
window.onpopstate = historyChange;
|
84032f20
Geoffrey PREUD'HOMME
tel: → callto: on PC
|
126
|
$('.navbar-fixed-top .navbar-toggle').click(function () {
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
127
128
129
130
131
|
$(document.body).animate({
scrollTop: 0
});
});
});
|
b8d34eaa
Geoffrey PREUD'HOMME
Moved map initial...
|
132
133
|
function initializeMap() {
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
var mapCanvas = document.getElementById('map-canvas');
mapCanvas.innerHTML = '';
var polytechPos = new google.maps.LatLng(50.6074998, 3.1373338);
var mapOptions = {
center: polytechPos,
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(mapCanvas, mapOptions);
var marker = new google.maps.Marker({
place: {
location: polytechPos,
query: "Polytech Lille"
},
attribution: {
source: "Coupe de Robotique des Écoles Primaires",
webUrl: window.location.host
},
map: map,
title: "Polytech Lille"
});
var infowindow = new google.maps.InfoWindow({
content: "<strong>Polytech Lille</strong><br/>Lieux des évènements de la Coupe de Robotique des Écoles Primaires"
});
|
84032f20
Geoffrey PREUD'HOMME
tel: → callto: on PC
|
158
|
marker.addListener('click', function () {
|
8cea2eb9
Geoffrey PREUD'HOMME
Beautifier passe
|
159
160
161
|
infowindow.open(map, this);
});
}
|