]> git.openstreetmap.org Git - rails.git/blob - app/views/site/_potlatch2.html.erb
Use leaflet css for print
[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.assets = "<%= asset_path "potlatch2/assets.zip" %>";
32     flashvars.font_library = "<%= asset_path "potlatch2/FontLibrary.swf" %>";
33     flashvars.locale = "<%= Potlatch2::LOCALES[locale] %>";
34     flashvars.locale_paths = "<%= Potlatch2::LOCALES[locale] %>=<%= asset_path("potlatch2/locales/#{Potlatch2::LOCALES[locale]}.swf") %>";
35     <% if params['gpx'] %>
36     flashvars.gpx = '<%= h(params['gpx']) %>';
37     <% end %>
38     <% if params['tileurl'] %>
39     flashvars.tileurl = '<%= h(params['tileurl']) %>';
40     <% end %>
41     flashvars.api = "<%= request.protocol + request.host_with_port %>/api/<%= API_VERSION %>/";
42     flashvars.policy = "<%= request.protocol + request.host_with_port %>/api/crossdomain.xml";
43     flashvars.connection = "XML";
44     flashvars.show_help = "once";
45     <% if token %>
46     flashvars.oauth_token = "<%= token.token %>";
47     flashvars.oauth_token_secret = "<%= token.secret %>";
48     flashvars.oauth_consumer_key = "<%= token.client_application.key %>";
49     flashvars.oauth_consumer_secret = "<%= token.client_application.secret %>";
50     <% end %>
51     flashvars.maximise_function = "maximiseMap";
52     flashvars.minimise_function = "minimiseMap";
53     flashvars.move_function = "mapMoved";
54
55     var params = {};
56     params.base = "/potlatch2";
57
58     var attributes = {};
59     attributes.id = "potlatch";
60     attributes.bgcolor = "#FFFFFF";
61
62     swfobject.embedSWF("<%= asset_path("potlatch2.swf") %>", "potlatch", "100%", "100%", "10.1.102","<%= asset_path("expressInstall.swf") %>", flashvars, params, attributes);
63     // 700,600 for fixed size, 100%,100% for resizable
64   }
65
66   <% if @lat && @lon -%>
67   doSWF(<%= @lat %>,<%= @lon %>,16);
68   <% else -%>
69   var params = OSM.mapParams();
70   doSWF(params.lat, params.lon, params.zoom || 17);
71   <% end -%>
72
73   $(document).ready(function () {
74     $("body").on("click", "a.set_position", function () {
75       var data = $(this).data();
76
77       $("#potlatch").each(function () {
78         this.setPosition(data.lat, data.lon, Math.max(data.zoom || 15, 13));
79       });
80     });
81   });
82
83   function mapMoved(lon, lat, zoom, minlon, minlat, maxlon, maxlat) {
84     updatelinks(lon, lat, zoom, null, minlon, minlat, maxlon, maxlat);
85   }
86 </script>