]> git.openstreetmap.org Git - rails.git/blob - app/views/site/id.html.erb
Fix rubocop style issues
[rails.git] / app / views / site / id.html.erb
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <meta charset='utf-8'>
5   <%= stylesheet_link_tag 'id' %>
6   <!--[if !IE || gte IE 9]><!-->
7   <%= javascript_include_tag 'id' %>
8   <!-- <![endif]-->
9 </head>
10 <body>
11 <div id='id-container'></div>
12 <script>
13   if (typeof iD == 'undefined') {
14     document.getElementById('id-container').innerHTML = 'This editor is supported ' +
15       'in Firefox, Chrome, Safari, Opera, and Internet Explorer 9 and above. ' +
16       'Please upgrade your browser or use Potlatch 2 to edit the map.';
17     document.getElementById('id-container').className = 'unsupported';
18   } else {
19     <% locale = select_locale(ID::LOCALES).to_s %>
20
21     var id = iD()
22       .presets(iD.data.presets)
23       .imagery(iD.data.imagery)
24       .taginfo(iD.taginfo())
25       .embed(true)
26       .assetPath("/iD/") <%# Cant use asset_path('iD/') in production. %>
27       .assetMap(<%= assets("iD").to_json.html_safe %>)
28       .locale("<%= locale %>", "<%= asset_path("iD/locales/#{locale}.json") %>")
29       .preauth({
30         <% token = @user.access_token(ID_KEY) %>
31         url: "<%= request.protocol + request.host_with_port %>",
32         oauth_consumer_key: "<%= token.client_application.key %>",
33         oauth_secret: "<%= token.client_application.secret %>",
34         oauth_token: "<%= token.token %>",
35         oauth_token_secret: "<%= token.secret %>"
36       });
37
38     id.map().on('move.embed', parent.$.throttle(250, function() {
39       var zoom = ~~id.map().zoom(),
40         center = id.map().center(),
41         llz = { lon: center[0], lat: center[1], zoom: zoom };
42
43       parent.updateLinks(llz, zoom);
44
45       // Manually resolve URL to avoid iframe JS context weirdness.
46       // http://bl.ocks.org/jfirebaugh/5439412
47       var hash = parent.OSM.formatHash(llz);
48       if (hash !== parent.location.hash) {
49         parent.location.replace(parent.location.href.replace(/(#.*|$)/, hash));
50       }
51     }));
52
53     parent.$("body").on("click", "a.set_position", function (e) {
54       e.preventDefault();
55       var data = parent.$(this).data();
56
57       // 0ms timeout to avoid iframe JS context weirdness.
58       // http://bl.ocks.org/jfirebaugh/5439412
59       setTimeout(function() {
60         id.map().centerZoom(
61           [data.lon, data.lat],
62           Math.max(data.zoom || 15, 13));
63       }, 0);
64     });
65
66     d3.select('#id-container')
67       .call(id.ui());
68   }
69 </script>
70 </body>
71 </html>