Commit 9e98ed029e51941fd4a480200dce10260ac093ab
1 parent
95ef4646
Exists in
master
and in
29 other branches
Fixing javascript
Showing
3 changed files
with
8 additions
and
9 deletions
Show diff stats
app/controllers/public/comment_controller.rb
... | ... | @@ -154,7 +154,7 @@ class CommentController < ApplicationController |
154 | 154 | render :json => { |
155 | 155 | :ok => false, |
156 | 156 | :render_target => 'form', |
157 | - :html => render_to_string(:partial => 'comment_form', :object => @comment, :locals => {:comment => @comment, :display_link => false, :edition_mode => true}) | |
157 | + :html => render_to_string(:partial => 'comment_form', :object => @comment, :locals => {:comment => @comment, :display_link => false, :edition_mode => true, :show_form => true}) | |
158 | 158 | } |
159 | 159 | end |
160 | 160 | end | ... | ... |
app/views/comment/_comment_form.rhtml
... | ... | @@ -10,8 +10,8 @@ |
10 | 10 | if (d.hasClass('closed')) { |
11 | 11 | d.removeClass('closed'); |
12 | 12 | d.addClass('opened'); |
13 | - d.find('input[name=comment[title]], textarea').val(''); | |
14 | - d.find('.comment_form input[name=comment[<%= focus_on %>]]').focus(); | |
13 | + d.find('input[name=\'comment[title]\'], textarea').val(''); | |
14 | + d.find('.comment_form input[name=\'comment[<%= focus_on %>]\']').focus(); | |
15 | 15 | }"> |
16 | 16 | <%= content_tag('a', '', :name => 'comment_form') + _('Post a comment') %> |
17 | 17 | </h4> |
... | ... | @@ -61,10 +61,7 @@ function check_captcha(button, confirm_action) { |
61 | 61 | |
62 | 62 | <% remote_form_for(:comment, 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| %> |
63 | 63 | |
64 | - <% if comment && comment.errors.any? %> | |
65 | - <%= error_messages_for :comment %> | |
66 | - <script type="text/javascript">jQuery(function() { document.location.href = "<%= comment.reply_of_id.nil? ? '#page-comment-form' : '#comment-' + comment.reply_of_id.to_s %>"; });</script> | |
67 | - <% end %> | |
64 | + <%= error_messages_for :comment %> | |
68 | 65 | |
69 | 66 | <%= hidden_field_tag(:confirm, 'false') %> |
70 | 67 | ... | ... |
public/javascripts/application.js
... | ... | @@ -752,7 +752,9 @@ function save_comment(button) { |
752 | 752 | |
753 | 753 | } else if(data.render_target == 'form') { |
754 | 754 | //Comment with errors |
755 | - $(button).parents('.page-comment-form').html(data.html); | |
755 | + var page_comment_form = $(button).parents('.page-comment-form'); | |
756 | + $.scrollTo(page_comment_form); | |
757 | + page_comment_form.html(data.html); | |
756 | 758 | |
757 | 759 | } else if($('#' + data.render_target).size() > 0) { |
758 | 760 | //Comment of reply |
... | ... | @@ -768,6 +770,7 @@ function save_comment(button) { |
768 | 770 | }); |
769 | 771 | |
770 | 772 | form.find('.errorExplanation').remove(); |
773 | + $.colorbox.close(); | |
771 | 774 | |
772 | 775 | } |
773 | 776 | |
... | ... | @@ -784,7 +787,6 @@ function save_comment(button) { |
784 | 787 | display_notice(data.msg); |
785 | 788 | } |
786 | 789 | |
787 | - $.colorbox.close(); | |
788 | 790 | close_loading(); |
789 | 791 | post_comment_box.removeClass('opened'); |
790 | 792 | post_comment_box.addClass('closed'); | ... | ... |