report_abuse.html.erb
2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<%= form_for :abuse_report, :url => {:action => 'register_report'},
:html => {:onsubmit => "return send_request(this)", :id => 'report-abuse-form'} do |f| %>
<%= labelled_form_field('* ' + _('Report reasons'), f.text_area(:reason, :rows => 6, :cols => 60, :class => 'required')) %>
<%= hidden_field_tag(:content_type, params[:content_type]) %>
<%= hidden_field_tag(:content_id, params[:content_id]) %>
<% unless user.is_admin? %>
<p><%= recaptcha_tags :ajax => true, :display => {:theme => 'clean'} %> </p>
<% end %>
<%= submit_button(:send, _('Report profile'), :style => 'float: left; cursor: pointer;', :id => 'report-abuse-submit-button', :onclick => "jQuery('#form-submit-loading').show()") %>
<%= button(:cancel, _('Cancel'), {}, :style => 'float: left; padding-top: 0px; padding-bottom: 0px;', :onclick => 'noosfero.modal.close(); return false;')%>
<div id="form-submit-loading" class="small-loading" style="width: 16px; height: 16px; margin-top: 3px; float: left; display: none;"></div>
<% end %>
<script type="text/javascript">
//<![CDATA[
var $ = jQuery;
$(document).ready(function(){
$("#report-abuse-form").validate();
});
var send_request = function(form){
$('#report-abuse-submit-button').css('cursor', 'progress');
$.ajax({
type: 'POST',
url: <%= url_for({:controller => 'profile', :action => 'register_report', :profile => profile.identifier}).to_json %>,
data: $(form).serialize(),
dataType: 'json',
success: function(data, status, ajax){
if ( !data.ok ) display_notice(data.error.message);
else {
noosfero.modal.close();
display_notice(data.message);
window.location.reload();
}
},
cache: false,
error: function(ajax, status, errorThrown) {
alert('Send request - HTTP '+status+': '+errorThrown);
},
complete: function(){
$('#report-abuse-submit-button').css('cursor', 'pointer');
$('#form-submit-loading').hide();
}
});
return false;
}
//]]>
</script>