From 344c5534ee328243ce8f5787e0ef6c3dcbf87b15 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 18 Jun 2012 14:36:59 +0100 Subject: [PATCH] Tidy up generation of UJS data attributes --- app/helpers/geocoder_helper.rb | 4 ++-- app/helpers/user_helper.rb | 2 +- app/views/site/edit.html.erb | 2 +- app/views/site/index.html.erb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/helpers/geocoder_helper.rb b/app/helpers/geocoder_helper.rb index 735ac8153..4c58d54dd 100644 --- a/app/helpers/geocoder_helper.rb +++ b/app/helpers/geocoder_helper.rb @@ -1,6 +1,6 @@ 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]}" @@ -9,7 +9,7 @@ module GeocoderHelper end result.each do |key,value| - html_options["data-#{key.to_s.tr('_', '-')}"] = value + html_options[:data][key.to_s.tr('_', '-')] = value end html = "" diff --git a/app/helpers/user_helper.rb b/app/helpers/user_helper.rb index 89e744548..acaecff48 100644 --- a/app/helpers/user_helper.rb +++ b/app/helpers/user_helper.rb @@ -7,7 +7,7 @@ module UserHelper 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 diff --git a/app/views/site/edit.html.erb b/app/views/site/edit.html.erb index a87da1125..d68b989df 100644 --- a/app/views/site/edit.html.erb +++ b/app/views/site/edit.html.erb @@ -11,7 +11,7 @@ <% 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 %> diff --git a/app/views/site/index.html.erb b/app/views/site/index.html.erb index 0bbf66e15..a74c7b356 100644 --- a/app/views/site/index.html.erb +++ b/app/views/site/index.html.erb @@ -1,6 +1,6 @@ <% 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 %> -- 2.43.2