_comment_form.html.erb
3.85 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<% edition_mode = (defined? edition_mode) ? edition_mode : false %>
<div class="<%= edition_mode ? '' : 'page-comment-form' %>">
<% focus_on = logged_in? ? 'title' : 'name' %>
<% if !edition_mode && !pass_without_comment_captcha? %>
<div id="recaptcha-container" style="display: none">
<h3><%= _('Please type the two words below') %></h3>
<%= recaptcha_tags(:display => { :theme => 'clean' }, :ajax => true) %>
<% button_bar do %>
<%= button_to_function :add, _('Confirm'), "return false", :id => "confirm-captcha" %>
<%= button_to_function :cancel, _('Cancel'), "noosfero.modal.close()" %>
<% end %>
</div>
<script type="text/javascript">
jQuery(document).bind('cbox_cleanup', function() {
jQuery('#recaptcha-container').hide();
});
</script>
<% end %>
<script type="text/javascript">
function check_captcha(button, confirm_action) {
<% if edition_mode %>
return true;
<% elsif pass_without_comment_captcha? %>
button.form.confirm.value = 'true';
button.disabled = true;
return true;
<% else %>
jQuery('#recaptcha-container').show();
noosfero.modal.inline('#recaptcha-container', {maxWidth :'600px', maxHeight : '300px' });
jQuery('#confirm-captcha').unbind('click');
jQuery('#confirm-captcha').bind('click', function() {
noosfero.modal.close();
button.form.recaptcha_response_field.value = jQuery('#recaptcha_response_field').val();
button.form.recaptcha_challenge_field.value = jQuery('#recaptcha_challenge_field').val();
button.form.confirm.value = 'true';
button.disabled = false;
confirm_action(button);
});
return false;
<% end %>
}
</script>
<% @comment ||= Comment.new %>
<% if @comment.errors.any? %>
<%= error_messages_for :comment %>
<% end %>
<div class="post_comment_box <%= ((defined? show_form) && show_form) ? 'opened' : 'closed' %>">
<%= link_to(_('Post a comment'), '#', :class => 'display-comment-form') if display_link && @comment.reply_of_id.blank? %>
<%= remote_form_for(@comment, :url => {:profile => profile.identifier, :controller => 'comment', :action => (edition_mode ? 'update' : 'create'), :id => (edition_mode ? @comment.id : @page.id)}, :html => { :class => 'comment_form' } ) do |f| %>
<%= required_fields_message %>
<% unless logged_in? %>
<%= required labelled_form_field(_('Name'), f.text_field(:name)) %>
<%= required labelled_form_field(_('e-mail'), f.text_field(:email)) %>
<p>
<%= _('If you are a registered user, you can login and be automatically recognized.') %>
</p>
<% end %>
<% if !edition_mode && !pass_without_comment_captcha? %>
<%= hidden_field_tag(:recaptcha_response_field, nil, :id => nil) %>
<%= hidden_field_tag(:recaptcha_challenge_field, nil, :id => nil) %>
<% end %>
<%= labelled_form_field(_('Title'), f.text_field(:title)) %>
<%= required labelled_form_field(_('Enter your comment'), f.text_area(:body, :rows => 5)) %>
<% if logged_in? %>
<%= labelled_form_field check_box(:comment, :follow_article, {}, true, false) + _('Follow this article'), '' %>
<% end%>
<%= hidden_field_tag(:confirm, 'false') %>
<%= hidden_field_tag(:view, params[:view])%>
<%= f.hidden_field(:reply_of_id) %>
<%= safe_join(@plugins.dispatch(:comment_form_extra_contents, local_assigns.merge(:comment => @comment)).collect { |content| instance_exec(&content) }, "") %>
<% button_bar do %>
<%= submit_button('add', _('Post comment'), :onclick => "if(check_captcha(this)) { save_comment(this) } else { check_captcha(this, save_comment)};return false;") %>
<% if !edition_mode %>
<%= button :cancel, _('Cancel'), '', :id => 'cancel-comment' %>
<% else %>
<%= button :cancel, _('Cancel'), '#', :onclick => "noosfero.modal.close();" %>
<% end %>
<% end %>
<% end %>
</div><!-- end class="post_comment_box" -->
</div><!-- end class="page-comment-form" -->
<%= javascript_include_tag 'comment_form'%>