]> git.openstreetmap.org Git - rails.git/blob - app/views/site/_potlatch2.html.erb
Serve swfobject via the assets pipeline
[rails.git] / app / views / site / _potlatch2.html.erb
1 <div id="map">
2   <div id="potlatch"><%= t 'site.edit.flash_player_required' %></div>
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 changesaved=true;
18   
19   window.onbeforeunload=function() {
20     if (!changesaved) {
21       return '<%= escape_javascript(t('site.edit.potlatch2_unsaved_changes')) %>';
22     }
23   }
24
25   function markChanged(a) { changesaved=a; }
26
27   function doSWF(lat,lon,zoom) {
28     var flashvars = {};
29     if (lat) { flashvars.lat = lat; }
30     if (lon) { flashvars.lon = lon; }
31     flashvars.zoom = zoom;
32     flashvars.locale = "<%= Potlatch2::LOCALES[locale] %>";
33     <% if params['gpx'] %>
34     flashvars.gpx = '<%= h(params['gpx']) %>';
35     <% end %>
36     <% if params['tileurl'] %>
37     flashvars.tileurl = '<%= h(params['tileurl']) %>';
38     <% end %>
39     flashvars.api = "<%= request.protocol + request.host_with_port %>/api/<%= API_VERSION %>/";
40     flashvars.policy = "<%= request.protocol + request.host_with_port %>/api/crossdomain.xml";
41     flashvars.connection = "XML";
42     flashvars.show_help = "once";
43     <% if token %>
44     flashvars.oauth_token = "<%= token.token %>";
45     flashvars.oauth_token_secret = "<%= token.secret %>";
46     flashvars.oauth_consumer_key = "<%= token.client_application.key %>";
47     flashvars.oauth_consumer_secret = "<%= token.client_application.secret %>";
48     <% end %>
49     flashvars.maximise_function = "maximiseMap";
50     flashvars.minimise_function = "minimiseMap";
51     flashvars.move_function = "mapMoved";
52
53     var params = {};
54     params.base = "/potlatch2";
55
56     var attributes = {};
57     attributes.id = "potlatch";
58     attributes.bgcolor = "#FFFFFF";
59
60     swfobject.embedSWF("<%= asset_path("/potlatch2/potlatch2.swf") %>", "potlatch", "100%", "100%", "10.1.85","<%= asset_path("expressInstall.swf") %>", flashvars, params, attributes);
61     // 700,600 for fixed size, 100%,100% for resizable
62   }
63
64   doSWF(<%= @lat || 'null' %>,<%= @lon || 'null' %>,<%= @zoom %>);
65
66   function setPosition(lat, lon, zoom) {
67     $("potlatch").setPosition(lat, lon, Math.max(zoom || 15, 13));
68   }
69
70   function mapMoved(lon, lat, zoom, minlon, minlat, maxlon, maxlat) {
71     updatelinks(lon, lat, zoom, null, minlon, minlat, maxlon, maxlat);
72   }
73 </script>