]> git.openstreetmap.org Git - rails.git/blob - app/views/site/id.html.erb
Add tags to features before propogating them.
[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' || !iD.detect().support) {
14     document.getElementById('id-container').innerHTML = 'This editor is supported ' +
15       'in Firefox, Chrome, Safari, Opera, and Internet Explorer 11 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 = ID::LOCALES.preferred(preferred_languages).to_s %>
20
21     var id = iD()
22       .presets(iD.data.presets)
23       .imagery(iD.data.imagery)
24       .taginfo(iD.services.taginfo())
25       .embed(true)
26       .assetPath("iD/")
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       if (id.inIntro()) return;
40       var zoom = ~~id.map().zoom(),
41         center = id.map().center(),
42         llz = { lon: center[0], lat: center[1], zoom: zoom };
43
44       parent.updateLinks(llz, zoom);
45
46       // Manually resolve URL to avoid iframe JS context weirdness.
47       // http://bl.ocks.org/jfirebaugh/5439412
48       var hash = parent.OSM.formatHash(llz);
49       if (hash !== parent.location.hash) {
50         parent.location.replace(parent.location.href.replace(/(#.*|$)/, hash));
51       }
52     }));
53
54     parent.$("body").on("click", "a.set_position", function (e) {
55       e.preventDefault();
56       var data = parent.$(this).data();
57
58       // 0ms timeout to avoid iframe JS context weirdness.
59       // http://bl.ocks.org/jfirebaugh/5439412
60       setTimeout(function() {
61         id.map().centerZoom(
62           [data.lon, data.lat],
63           Math.max(data.zoom || 15, 13));
64       }, 0);
65     });
66
67     d3.select('#id-container')
68       .call(id.ui());
69   }
70 </script>
71 </body>
72 </html>