aboutsummaryrefslogtreecommitdiffstats
path: root/app/assets/javascripts/access_points.js.coffee
blob: ee5e89defd645a8eb1d7365f0a613c630d7fd177 (plain)
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
jQuery ->
  x_y_change = (event) -> 
    c = $('input#access_point_coordinates').val().split(",")
    if c.length == 2
      if referential_projection != undefined
        referential_point = new OpenLayers.Geometry.Point(c[1], c[0]).transform(new OpenLayers.Projection("EPSG:4326"), referential_projection )      
        
        $('input#access_point_projection_xy').val(referential_point.x.toString()+","+referential_point.y.toString())
            
      feature = map.getLayersByName("access_point")[0].getFeatureByFid($('input#access_point_id').val())  
      google_point = new OpenLayers.LonLat(c[1], c[0]).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject())
      feature.move(google_point)
      map.setCenter(google_point, 16, false, true)      

  $('input#access_point_coordinates').change(x_y_change)
   
  lon_lat_change = (event) -> 
    c = $('input#access_point_projection_xy').val().split(",")
    if c.length == 2
      if referential_projection != undefined
        wgs84_point = new OpenLayers.Geometry.Point(c[0], c[1]).transform(referential_projection, new OpenLayers.Projection("EPSG:4326"))    
       
        $('input#access_point_coordinates').val( wgs84_point.y.toString()+","+wgs84_point.x)
  
      feature = map.getLayersByName("access_point")[0].getFeatureByFid($('input#access_point_id').val())  
      google_point =  new OpenLayers.LonLat(wgs84_point.x, wgs84_point.y).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject())
      feature.move(google_point)
      map.setCenter(google_point, 16, false, true)      

  $('input#access_point_projection_xy').change(lon_lat_change)  
  
  # switch visibility of access_links
  switch_generics = (event) -> 
    event.preventDefault()
    $('.access_points .generics.content').toggle('slow')
    $('a.generics .switcher').toggle()

  $('.access_points a.generics').click(switch_generics)

  switch_details = (event) -> 
    event.preventDefault()
    $('.access_points .details.content').toggle('slow')
    $('a.details .switcher').toggle()

  $('.access_points a.details').click(switch_details)