]> git.openstreetmap.org Git - rails.git/blob - app/views/site/edit.rhtml
Added translations to notifier/diary_comment_notification
[rails.git] / app / views / site / edit.rhtml
1 <% if OSM_STATUS == :database_offline or OSM_STATUS == :api_offline %>
2 <p><%= t 'layouts.osm_offline' %>
3 </p>
4 <% elsif OSM_STATUS == :database_readonly or OSM_STATUS == :api_readonly %>
5 <p><%= t 'layouts.osm_read_only' %>
6 </p>
7 <% elsif !@user.data_public? %>
8 <p><%= t 'site.edit.not_public' %></p>
9 <p><%= t 'site.edit.not_public_description', 
10 :user_page => (link_to t('site.edit.user_page_link'), {:controller => 'user', :action => 'account', :display_name => @user.display_name, :anchor => 'public'}) %></p>
11 <p><%= t 'site.edit.anon_edits', :link => link_to(t('site.edit.anon_edit_link_text'), t('site.edit.anon_edits_link')) %> (<a href=""></a>)</p>
12 <% else %>
13 <% content_for :greeting do %>
14 <% if @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
15 <%= link_to_function 'home', "setPosition(#{@user.home_lat}, #{@user.home_lon}, 10)" %> |
16 <% end %>
17 <% end %>
18
19 <%= render :partial => 'sidebar', :locals => { :onopen => "resizeMap();", :onclose => "resizeMap();" } %>
20 <%= render :partial => 'search' %>
21
22 <%
23 session[:token] = @user.tokens.create.token unless session[:token]
24
25 # Decide on a lat lon to initialise potlatch with. Various ways of doing this
26 if params['lon'] and params['lat']
27         lon =  h(params['lon']) 
28         lat =  h(params['lat']) 
29         zoom =  h(params['zoom'])
30
31 elsif params['mlon'] and params['mlat'] 
32         lon =  h(params['mlon']) 
33         lat =  h(params['mlat']) 
34         zoom =  h(params['zoom'])
35         
36 elsif params['gpx']
37         #use gpx id to locate (dealt with below)
38         
39 elsif cookies.key?("_osm_location")
40         lon,lat,zoom,layers = cookies["_osm_location"].split("|")
41         
42 elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil? 
43         lon =  @user.home_lon
44         lat =  @user.home_lat
45
46 else
47         #catch all.  Do nothing.  lat=nil, lon=nil
48         #Currently this results in potlatch starting up at 0,0 (Atlantic ocean).
49 end
50
51 zoom='14' if zoom.nil?
52 %>
53
54 <div id="map">
55         <%= t 'site.edit.flash_player_required' %>
56 </div>
57
58 <%= javascript_include_tag 'swfobject.js' %>
59 <script type="text/javascript" defer="defer">
60   var brokenContentSize = $("content").offsetWidth == 0;
61   var fo = new SWFObject("/potlatch/potlatch.swf?d="+Math.round(Math.random()*1000), "potlatch", "100%", "100%", "6", "#FFFFFF");
62   // 700,600 for fixed size, 100%,100% for resizable
63   var changesaved=true;
64   var winie=false; if (document.all && window.print) { winie=true; }
65   
66   window.onbeforeunload=function() {
67         if (!changesaved && !winie) {
68             return "<%= t 'site.edit.potlatch_unsaved_changes' %>";
69         }
70   }
71
72   function markChanged(a) { changesaved=a; }
73
74   function doSWF(lat,lon,sc) {
75     if (sc < 11) sc = 11;
76     fo.addVariable('scale',sc);
77     fo.addVariable('token','<%= session[:token] %>');
78     if (lat) { fo.addVariable('lat',lat); }
79     if (lon) { fo.addVariable('long',lon); }
80     <% if params['gpx']  %>fo.addVariable('gpx' ,'<%= h(params['gpx'] ) %>');<% end %>
81     <% if params['way']  %>fo.addVariable('way' ,'<%= h(params['way'] ) %>');<% end %>
82     <% if params['node'] %>fo.addVariable('node','<%= h(params['node']) %>');<% end %>
83     fo.write("map");
84   }
85
86   doSWF(<%= lat || 'null' %>,<%= lon || 'null' %>,<%= zoom %>);
87
88   function setPosition(lat, lon, zoom) {
89     doSWF(lat, lon, zoom);
90   }
91
92   function resizeContent() {
93     var content = $("content");
94     var rightMargin = parseInt(getStyle(content, "right"));
95     var bottomMargin = parseInt(getStyle(content, "bottom"));
96
97     content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
98     content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
99   }
100   
101   function resizeMap() {
102     var sidebar_width = $("sidebar").offsetWidth;
103
104     if (sidebar_width > 0) {
105       sidebar_width = sidebar_width + 5
106     }
107
108     $("map").style.left = (sidebar_width) + "px";
109     $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
110     $("map").style.height = ($("content").offsetHeight - 2) + "px";
111   }
112
113   function handleResize() {
114     if (brokenContentSize) {
115       resizeContent();
116     }
117
118     resizeMap();
119   }
120
121   function maximiseMap() {
122     $("left").style.display = "none";
123     $("greeting").style.display = "none";
124     $("tabnav").style.display = "none";
125
126     $("content").style.top = "10px";
127     $("content").style.left = "10px";
128
129     handleResize();
130   }
131   
132   function minimiseMap() {
133     $("left").style.display = "";
134     $("greeting").style.display = "";
135     $("tabnav").style.display = "";
136
137     $("content").style.top = "35px";
138     $("content").style.left = "192px";
139
140     handleResize();
141   }
142
143   handleResize();
144
145   window.onload = handleResize;
146   window.onresize = handleResize;
147 </script>
148 <% end %>