]> git.openstreetmap.org Git - rails.git/blob - app/views/site/_potlatch2.html.erb
Update Potlatch 2 to 2.3-29-gffe3474 build
[rails.git] / app / views / site / _potlatch2.html.erb
1 <div id="map">
2   <%= t 'site.edit.flash_player_required' %>
3 </div>
4
5 <%= javascript_include_tag 'swfobject.js' %>
6
7 <% if defined? POTLATCH2_KEY %>
8 <% token = @user.access_token(POTLATCH2_KEY) %>
9 <% else%>
10 <script type="text/javascript">alert("<%= t 'site.edit.potlatch2_not_configured' %>")</script>
11 <% end %>
12
13 <% locale = request.compatible_language_from(Potlatch2::LOCALES.keys) || "en" %>
14
15 <script type="text/javascript" defer="defer">
16   var brokenContentSize = $("content").offsetWidth == 0;
17   var fo = new SWFObject("<%= asset_path("/potlatch2/potlatch2.swf") %>", "potlatch", "100%", "100%", "10", "#FFFFFF");
18   // 700,600 for fixed size, 100%,100% for resizable
19   var changesaved=true;
20   
21   window.onbeforeunload=function() {
22     if (!changesaved) {
23       return '<%= escape_javascript(t('site.edit.potlatch2_unsaved_changes')) %>';
24     }
25   }
26
27   function markChanged(a) { changesaved=a; }
28
29   function doSWF(lat,lon,zoom) {
30     fo.addParam("base","/potlatch2");
31     if (lat) { fo.addVariable("lat",lat); }
32     if (lon) { fo.addVariable("lon",lon); }
33     fo.addVariable("locale", "<%= Potlatch2::LOCALES[locale] %>");
34     <% if params['gpx'] %>
35     fo.addVariable('gpx' ,'<%= h(params['gpx']) %>');
36     <% end %>
37     <% if params['tileurl'] %>
38     fo.addVariable('tileurl' ,'<%= h(params['tileurl']) %>');
39     <% end %>
40     fo.addVariable("zoom",zoom);
41     fo.addVariable("api","<%= request.protocol + request.host_with_port %>/api/<%= API_VERSION %>/");
42     fo.addVariable("policy","<%= request.protocol + request.host_with_port %>/api/crossdomain.xml");
43     fo.addVariable("connection","XML");
44     fo.addVariable("show_help","once");
45     <% if token %>
46     fo.addVariable("oauth_token","<%= token.token %>");
47     fo.addVariable("oauth_token_secret","<%= token.secret %>");
48     fo.addVariable("oauth_consumer_key","<%= token.client_application.key %>");
49     fo.addVariable("oauth_consumer_secret","<%= token.client_application.secret %>");
50     <% end %>
51     fo.addVariable("maximise_function","maximiseMap");
52     fo.addVariable("minimise_function","minimiseMap");
53     fo.addVariable("move_function","mapMoved");
54     fo.write("map");
55   }
56
57   doSWF(<%= @lat || 'null' %>,<%= @lon || 'null' %>,<%= @zoom %>);
58
59   function setPosition(lat, lon, zoom) {
60     $("potlatch").setPosition(lat, lon, Math.max(zoom || 15, 13));
61   }
62
63   function mapMoved(lon, lat, zoom, minlon, minlat, maxlon, maxlat) {
64     updatelinks(lon, lat, zoom, null, minlon, minlat, maxlon, maxlat);
65   }
66 </script>