Blame view

js/crep.js 1.53 KB
dcc55bea   Geoffrey PREUD'HOMME   Minor cleanup nav...
1
2
3
4
5
6
7
  function pageSpecific(location) {
      if (location.indexOf('contact') >= 0) {
          initializeMap()
      }
  }
  
  function actLink(ev) {
8485d451   Geoffrey PREUD'HOMME   New dynamic JS nav
8
9
      var location = ev.currentTarget.href
      if (location.indexOf(window.location.host) >= 0) {
d6489a75   Geoffrey PREUD'HOMME   History working w...
10
11
12
13
14
          loadDoc(location, function () {
              history.pushState({
                  loc: location
              }, document.title, location)
          })
8485d451   Geoffrey PREUD'HOMME   New dynamic JS nav
15
16
          return false
      }
7ab7e900   Jean Wasilewski   file function added
17
18
  }
  
8485d451   Geoffrey PREUD'HOMME   New dynamic JS nav
19
  function dynamiseLinks(el) {
dcc55bea   Geoffrey PREUD'HOMME   Minor cleanup nav...
20
      $("a", el).click(actLink)
8485d451   Geoffrey PREUD'HOMME   New dynamic JS nav
21
22
  }
  
be816fc8   Geoffrey PREUD'HOMME   Removed extra par...
23
  function loadDoc(location, callback) {
d6489a75   Geoffrey PREUD'HOMME   History working w...
24
25
26
27
28
      if (!callback) {
          callaback = function () {
              return undefined
          }
      }
dcc55bea   Geoffrey PREUD'HOMME   Minor cleanup nav...
29
30
31
      $.get(location + '?c', function (data) {
          mainContainer = $("#mainContainer")
          mainContainer.html(data)
d6489a75   Geoffrey PREUD'HOMME   History working w...
32
          document.title = location
dcc55bea   Geoffrey PREUD'HOMME   Minor cleanup nav...
33
34
          dynamiseLinks(mainContainer)
          pageSpecific(location)
d6489a75   Geoffrey PREUD'HOMME   History working w...
35
          callback()
dcc55bea   Geoffrey PREUD'HOMME   Minor cleanup nav...
36
37
      })
  
b8d34eaa   Geoffrey PREUD'HOMME   Moved map initial...
38
39
  }
  
d71b5167   Geoffrey PREUD'HOMME   Almost functionni...
40
41
42
43
  function historyChange(ev) {
      loadDoc(ev.state.loc)
  }
  
8485d451   Geoffrey PREUD'HOMME   New dynamic JS nav
44
45
  $(document).ready(function () {
      dynamiseLinks(document)
b8d34eaa   Geoffrey PREUD'HOMME   Moved map initial...
46
      pageSpecific(window.location.href)
d71b5167   Geoffrey PREUD'HOMME   Almost functionni...
47
      window.onpopstate = historyChange
b8d34eaa   Geoffrey PREUD'HOMME   Moved map initial...
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  })
  
  function initializeMap() {
      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({
          position: polytechPos,
          map: map,
          title: "Polytech Lille"
      });
  }