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