]> git.openstreetmap.org Git - rails.git/blob - app/views/site/edit.rhtml
Moving inbox styling definitions into the stylesheet.
[rails.git] / app / views / site / edit.rhtml
1 <% if API_READONLY %>
2 <p>The OpenStreetMap database is currently in read-only mode while
3    essential database maintenance work is carried out.
4 </p>
5 <% else %>
6 <%= render :partial => 'search', :locals => { :onopen => "resizeMap();", :onclose => "resizeMap();" } %>
7
8 <% session[:token] = @user.tokens.create.token unless session[:token] %>
9
10 <% if params['mlon'] and params['mlat'] %>
11 <% lon =  params['mlon'] %>
12 <% lat =  params['mlat']  %>
13 <% zoom =  params['zoom'] || '12' %>
14 <% elsif @user and params['lon'].nil? and params['lat'].nil? %> 
15 <% lon =  @user.home_lon %>
16 <% lat =  @user.home_lat %>
17 <% zoom = '12' %>
18 <%else%>
19 <% lon =  params['lon'] || '-0.1' %>
20 <% lat =  params['lat'] || '51.5' %>
21 <% zoom =  params['zoom'] || '12' %>
22 <% end %>
23
24 <div id="map">You need a Flash player to use Potlatch, the
25     OpenStreetMap Flash editor. You can <a href="http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">download Flash Player from Adobe.com</a>.
26
27     <a href="http://wiki.openstreetmap.org/index.php/Editing">Several other options</a> are also available
28     for editing OpenStreetMap.
29 </div>
30 <script type="text/javascript" src="/javascripts/swfobject.js"></script>
31 <script type="text/javascript">
32   var brokenContentSize = $("content").offsetWidth == 0;
33   var fo = new SWFObject("/potlatch/potlatch.swf?d="+Math.round(Math.random()*1000), "potlatch", "700", "600", "6", "#FFFFFF");
34
35   function doSWF(lat,lon,sc) {
36     fo.addVariable('lat',lat);
37     fo.addVariable('long',lon);
38     fo.addVariable('scale',sc);
39     fo.addVariable('token','<%= session[:token] %>');
40     fo.write("map");
41   }
42
43   doSWF(<%= lat %>,<%= lon %>,<%= zoom %>);
44
45   function setPosition(lat, lon, zoom) {
46     doSWF(lat, lon, zoom);
47   }
48
49   function resizeContent() {
50     var content = $("content");
51     var rightMargin = parseInt(getStyle(content, "right"));
52     var bottomMargin = parseInt(getStyle(content, "bottom"));
53
54     content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
55     content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
56   }
57   
58   function resizeMap() {
59     var search_results_width = $("search_results").offsetWidth;
60
61     if (search_results_width > 0) {
62       search_results_width = search_results_width + 5
63     }
64
65     $("map").style.left = (search_results_width) + "px";
66     $("map").style.width = ($("content").offsetWidth - search_results_width) + "px";
67     $("map").style.height = ($("content").offsetHeight - 2) + "px";
68   }
69
70   function handleResize() {
71     if (brokenContentSize) {
72       resizeContent();
73     }
74
75     resizeMap();
76   }
77
78   window.onresize = handleResize;
79   window.onload = handleResize;
80 </script>
81 <% end %>