]> git.openstreetmap.org Git - rails.git/commitdiff
Tidy up generation of UJS data attributes
authorTom Hughes <tom@compton.nu>
Mon, 18 Jun 2012 13:36:59 +0000 (14:36 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 18 Jun 2012 13:36:59 +0000 (14:36 +0100)
app/helpers/geocoder_helper.rb
app/helpers/user_helper.rb
app/views/site/edit.html.erb
app/views/site/index.html.erb

index 735ac815302f8ec86ec0c5a97bd8e71fc3ccee6b..4c58d54dde5f54171568d4e0b182bc05c45d532e 100644 (file)
@@ -1,6 +1,6 @@
 module GeocoderHelper
   def result_to_html(result)
 module GeocoderHelper
   def result_to_html(result)
-    html_options = { :class => "set_position" }
+    html_options = { :class => "set_position", :data => {} }
 
     if result[:min_lon] and result[:min_lat] and result[:max_lon] and result[:max_lat]
       url = "?minlon=#{result[:min_lon]}&minlat=#{result[:min_lat]}&maxlon=#{result[:max_lon]}&maxlat=#{result[:max_lat]}"
 
     if result[:min_lon] and result[:min_lat] and result[:max_lon] and result[:max_lat]
       url = "?minlon=#{result[:min_lon]}&minlat=#{result[:min_lat]}&maxlon=#{result[:max_lon]}&maxlat=#{result[:max_lat]}"
@@ -9,7 +9,7 @@ module GeocoderHelper
     end
 
     result.each do |key,value|
     end
 
     result.each do |key,value|
-      html_options["data-#{key.to_s.tr('_', '-')}"] = value
+      html_options[:data][key.to_s.tr('_', '-')] = value
     end
 
     html = ""
     end
 
     html = ""
index 89e744548a5a5f9451f79289278e04c4c0c12a43..acaecff48fdd0a59ec7ddd4c30a688fb4257bab1 100644 (file)
@@ -7,7 +7,7 @@ module UserHelper
     link_to(
       image_tag("#{name}.png", :alt => t("user.login.openid_providers.#{name}.alt")),
       "#",
     link_to(
       image_tag("#{name}.png", :alt => t("user.login.openid_providers.#{name}.alt")),
       "#",
-      :class => "openid_button", "data-url" => url,
+      :class => "openid_button", :data => { :url => url },
       :title => t("user.login.openid_providers.#{name}.title")
     )
   end
       :title => t("user.login.openid_providers.#{name}.title")
     )
   end
index a87da1125e233fce24e0b939c9a29a657ca1f631..d68b989df628a39e10577a46b099c9037c2fcd6a 100644 (file)
@@ -11,7 +11,7 @@
 <% else %>
 <% content_for :greeting do %>
 <% if @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
 <% else %>
 <% content_for :greeting do %>
 <% if @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
-<%= link_to t("layouts.home"), "#", :class => "set_position", "data-lat" => @user.home_lat, "data-lon" => @user.home_lon, "data-zoom" => 15, :title => t("layouts.home_tooltip") %> |
+<%= link_to t("layouts.home"), "#", :class => "set_position", :data => { :lat => @user.home_lat, :lon => @user.home_lon, :zoom => 15 }, :title => t("layouts.home_tooltip") %> |
 <% end %>
 <% end %>
 
 <% end %>
 <% end %>
 
index 0bbf66e1557ab43473e81c88b05f8048dc4eacb9..a74c7b356032433cad85a6726fd69108f48f5b14 100644 (file)
@@ -1,6 +1,6 @@
 <% if @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
   <% content_for :greeting do %>
 <% if @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
   <% content_for :greeting do %>
-    <%= link_to t("layouts.home"), "#", :class => "set_position", "data-lat" => @user.home_lat, "data-lon" => @user.home_lon, "data-zoom" => 15, :title => t("layouts.home_tooltip") %> |
+    <%= link_to t("layouts.home"), "#", :class => "set_position", :data => { :lat => @user.home_lat, :lon => @user.home_lon, :zoom => 15 }, :title => t("layouts.home_tooltip") %> |
   <% end %>
 <% end %>
 
   <% end %>
 <% end %>