]> git.openstreetmap.org Git - rails.git/commitdiff
Remove inline javascript from user views
authorTom Hughes <tom@compton.nu>
Mon, 27 Feb 2017 22:48:36 +0000 (22:48 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 27 Feb 2017 22:51:03 +0000 (22:51 +0000)
app/assets/javascripts/osm.js.erb
app/assets/javascripts/user.js
app/views/user/confirm.html.erb
app/views/user/confirm_email.html.erb
app/views/user/list.html.erb
app/views/user/terms.html.erb

index 10b7cfdb81cda46676c9d397ded0d558fcf61af6..697017697f1d320451c64e7600fd18789d68e1ea 100644 (file)
@@ -38,6 +38,8 @@ OSM = {
   OPEN_NOTE_MARKER:        <%= image_path("open_note_marker.png").to_json %>,
   CLOSED_NOTE_MARKER:      <%= image_path("closed_note_marker.png").to_json %>,
 
+  SEARCHING:               <%= image_path("searching.gif").to_json %>,
+
   apiUrl: function (object) {
     var url = "/api/" + OSM.API_VERSION + "/" + object.type + "/" + object.id;
 
index 7e7e7c8032a6cbab6d9018d7d0ee888eb0dd0df2..44872a78c6f12c2432df5fa40f268406b0109c30 100644 (file)
@@ -103,4 +103,20 @@ $(document).ready(function () {
   } else {
     enableAuth();
   }
+
+  $("#user_all").change(function () {
+    $("#user_list input[type=checkbox]").prop("checked", $("#user_all").prop("checked"));
+  });
+
+  $("#content.user_confirm").each(function () {
+    $(this).hide();
+    $(this).find("#confirm").submit();
+  });
+
+  $("input[name=legale]").change(function () {
+    var url = $(this).data("url");
+
+    $("#contributorTerms").html("<img src='" + OSM.SEARCHING + "' />");
+    $("#contributorTerms").load(url);
+  });
 });
index 9fc33094e090dfa5d21034a4cebfad54c3f60fd8..f520982896b703eff203f1e242e8fdab504cf09f 100644 (file)
@@ -4,9 +4,11 @@
 <% end %>
 
 <% if params[:confirm_string] %>
-  <script>
-  $("#content").hide();
-  </script>
+  <% content_for :head do %>
+    <%= javascript_include_tag "user" %>
+  <% end %>
+
+  <% content_for(:content_class) { "user_confirm" } %>  
 
   <p><%= t 'user.confirm.press confirm button' %></p>
 
     <input type="hidden" name="confirm_string" value="<%= params[:confirm_string] %>">
     <input type="submit" name="confirm_action" value="<%= t 'user.confirm.button' %>">
   <% end %>
-
-  <script>
-  $("#confirm").submit();
-  </script>
 <% else %>
   <h1>
     <%= t "user.confirm.introduction_1" %>
index 1170631caf38cb238dd23859c3df31c65766e269..1791cfc732f362190117c9ef074665cd4d8528ad 100644 (file)
@@ -1,6 +1,8 @@
-<script>
-$("#content").hide();
-</script>
+<% content_for :head do %>
+  <%= javascript_include_tag "user" %>
+<% end %>
+
+<% content_for(:content_class) { "user_confirm" } %>  
 
 <% content_for :heading do %>
   <h1><%= t 'user.confirm_email.heading' %></h1>
@@ -12,7 +14,3 @@ $("#content").hide();
   <input type="hidden" name="confirm_string" value="<%= params[:confirm_string] %>">
   <input type="submit" name="confirm_action" value="<%= t 'user.confirm_email.button' %>">
 <% end %>
-
-<script>
-$("#confirm").submit();
-</script>
index 93839cbe8d5276ef7b50f399e7cd23aefe4e9d7c..fcd0c41fcfd7f49a349ecd2f1035f0f24ad804e2 100644 (file)
@@ -1,5 +1,9 @@
 <% @title = t('user.list.title') %>
 
+<% content_for :head do %>
+  <%= javascript_include_tag "user" %>
+<% end %>
+
 <% content_for :heading do %>
   <h1><%= t('user.list.heading') %></h1>
 <% end %>
       <%= submit_tag t('user.list.confirm'), :name => "confirm" %>
       <%= submit_tag t('user.list.hide'), :name => "hide" %>
     </div>
-
-    <script type="text/javascript">
-     $("#user_all").change(function () {
-       $("#user_list input[type=checkbox]").prop("checked", $("#user_all").prop("checked"));
-     });
-    </script>
   <% end %>
 <% else %>
   <p><%= t "user.list.empty" %></p>
index 47e2f8b54e7004ec274a41be1dcd1ff1c045e40d..3d8cb22f72c19555b27bac45ed4ff1e07f4a825e 100644 (file)
@@ -1,3 +1,7 @@
+<% content_for :head do %>
+  <%= javascript_include_tag "user" %>
+<% end %>
+
 <% content_for :heading do %>
   <h1><%= t 'user.terms.heading' %></h1>
   <div class='header-illustration new-user-terms'></div>
     <% [['france', 'FR'], ['italy', 'IT'], ['rest_of_world', 'GB']].each do |name, legale| %>
       <div class="form-row">
         <label for="legale_<%= legale %>">
-          <%= radio_button_tag 'legale', legale, @legale == legale %>
+          <%= radio_button_tag 'legale', legale, @legale == legale, :data => { :url => url_for(:legale => legale) } %>
           <%= t('user.terms.legale_names.' + name) %>
         </label>
-        <script>
-          $("#legale_<%= legale %>").change(function () {
-            $("#contributorTerms").html("<%=j image_tag 'searching.gif' %>");
-            $("#contributorTerms").load("<%= url_for :legale => legale %>");
-          });
-        </script>
       </div>
     <% end %>
   </div>