Commit b8d34eaabf63f24d0e9d5f8bc942b67bb775ebdd
1 parent
847ea853
Moved map initialization call
Showing
2 changed files
with
28 additions
and
23 deletions
Show diff stats
js/crep.js
@@ -4,7 +4,9 @@ function loadDoc(ev) { | @@ -4,7 +4,9 @@ function loadDoc(ev) { | ||
4 | $.get(location + '?c', function (data) { | 4 | $.get(location + '?c', function (data) { |
5 | mainContainer = $("#mainContainer") | 5 | mainContainer = $("#mainContainer") |
6 | mainContainer.html(data) | 6 | mainContainer.html(data) |
7 | + // POST | ||
7 | dynamiseLinks(mainContainer) | 8 | dynamiseLinks(mainContainer) |
9 | + pageSpecific(location) | ||
8 | }) | 10 | }) |
9 | return false | 11 | return false |
10 | } | 12 | } |
@@ -14,6 +16,30 @@ function dynamiseLinks(el) { | @@ -14,6 +16,30 @@ function dynamiseLinks(el) { | ||
14 | $("a", el).click(loadDoc) | 16 | $("a", el).click(loadDoc) |
15 | } | 17 | } |
16 | 18 | ||
19 | +function pageSpecific(location) { | ||
20 | + if (location.indexOf('contact') >= 0) { | ||
21 | + initializeMap() | ||
22 | + } | ||
23 | +} | ||
24 | + | ||
17 | $(document).ready(function () { | 25 | $(document).ready(function () { |
18 | dynamiseLinks(document) | 26 | dynamiseLinks(document) |
19 | -}) | ||
20 | \ No newline at end of file | 27 | \ No newline at end of file |
28 | + pageSpecific(window.location.href) | ||
29 | +}) | ||
30 | + | ||
31 | +function initializeMap() { | ||
32 | + var mapCanvas = document.getElementById('map-canvas'); | ||
33 | + mapCanvas.innerHTML = '' | ||
34 | + var polytechPos = new google.maps.LatLng(50.6074998, 3.1373338); | ||
35 | + var mapOptions = { | ||
36 | + center: polytechPos, | ||
37 | + zoom: 16, | ||
38 | + mapTypeId: google.maps.MapTypeId.ROADMAP | ||
39 | + } | ||
40 | + var map = new google.maps.Map(mapCanvas, mapOptions) | ||
41 | + var marker = new google.maps.Marker({ | ||
42 | + position: polytechPos, | ||
43 | + map: map, | ||
44 | + title: "Polytech Lille" | ||
45 | + }); | ||
46 | +} | ||
21 | \ No newline at end of file | 47 | \ No newline at end of file |
pages/contact.php
@@ -6,25 +6,4 @@ | @@ -6,25 +6,4 @@ | ||
6 | | 6 | |
7 | <div id="map-canvas"> | 7 | <div id="map-canvas"> |
8 | <img src="img/polyMap.png"/> | 8 | <img src="img/polyMap.png"/> |
9 | -</div> | ||
10 | -<script> | ||
11 | - function initialize() | ||
12 | - { | ||
13 | - var mapCanvas = document.getElementById('map-canvas'); | ||
14 | - mapCanvas.innerHTML = '' | ||
15 | - var polytechPos = new google.maps.LatLng(50.6074998, 3.1373338); | ||
16 | - var mapOptions = | ||
17 | - { | ||
18 | - center: polytechPos, | ||
19 | - zoom: 16, | ||
20 | - mapTypeId: google.maps.MapTypeId.ROADMAP | ||
21 | - } | ||
22 | - var map = new google.maps.Map(mapCanvas, mapOptions) | ||
23 | - var marker = new google.maps.Marker({ | ||
24 | - position: polytechPos, | ||
25 | - map: map, | ||
26 | - title:"Polytech Lille" | ||
27 | - }); | ||
28 | - } | ||
29 | - initialize() | ||
30 | -</script> | 9 | +</div> |
31 | \ No newline at end of file | 10 | \ No newline at end of file |