Remove inline javascript from user views

This commit is contained in:
Tom Hughes 2017-02-27 22:48:36 +00:00
parent 57443546f8
commit d13348c0ea
6 changed files with 37 additions and 27 deletions

View 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;

View 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);
});
});

View 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>
@ -15,10 +17,6 @@
<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" %>

View 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>

View 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 %>
@ -34,12 +38,6 @@
<%= 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>

View 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>
@ -13,15 +17,9 @@
<% [['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>