@@ -0,0 +1,6 | |||||
|
1 | $('message_subject').value = "<%= raw escape_javascript(@subject) %>"; | |||
|
2 | $('message_content').value = "<%= raw escape_javascript(@content) %>"; | |||
|
3 | Element.show('reply'); | |||
|
4 | Form.Element.focus('message_content'); | |||
|
5 | Element.scrollTo('reply'); | |||
|
6 | $('message_content').scrollTop = $('message_content').scrollHeight - $('message_content').clientHeight; |
@@ -105,20 +105,11 class MessagesController < ApplicationController | |||||
105 | end |
|
105 | end | |
106 |
|
106 | |||
107 | def quote |
|
107 | def quote | |
108 |
|
|
108 | @subject = @message.subject | |
109 | text = @message.content |
|
109 | @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') | |
110 | subject = @message.subject.gsub('"', '\"') |
|
110 | ||
111 | subject = "RE: #{subject}" unless subject.starts_with?('RE:') |
|
111 | @content = "#{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> " | |
112 | content = "#{ll(Setting.default_language, :text_user_wrote, user)}\\n> " |
|
112 | @content << @message.content.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" | |
113 | content << text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub('"', '\"').gsub(/(\r?\n|\r\n?)/, "\\n> ") + "\\n\\n" |
|
|||
114 | render(:update) { |page| |
|
|||
115 | page << "$('message_subject').value = \"#{subject}\";" |
|
|||
116 | page.<< "$('message_content').value = \"#{content}\";" |
|
|||
117 | page.show 'reply' |
|
|||
118 | page << "Form.Element.focus('message_content');" |
|
|||
119 | page << "Element.scrollTo('reply');" |
|
|||
120 | page << "$('message_content').scrollTop = $('message_content').scrollHeight - $('message_content').clientHeight;" |
|
|||
121 | } |
|
|||
122 | end |
|
113 | end | |
123 |
|
114 | |||
124 | def preview |
|
115 | def preview |
@@ -186,7 +186,10 class MessagesControllerTest < ActionController::TestCase | |||||
186 | @request.session[:user_id] = 2 |
|
186 | @request.session[:user_id] = 2 | |
187 | xhr :get, :quote, :board_id => 1, :id => 3 |
|
187 | xhr :get, :quote, :board_id => 1, :id => 3 | |
188 | assert_response :success |
|
188 | assert_response :success | |
189 | assert_select_rjs :show, 'reply' |
|
189 | assert_equal 'text/javascript', response.content_type | |
|
190 | assert_template 'quote' | |||
|
191 | assert_include 'RE: First post', response.body | |||
|
192 | assert_include '> An other reply', response.body | |||
190 | end |
|
193 | end | |
191 |
|
194 | |||
192 | def test_preview_new |
|
195 | def test_preview_new |
General Comments 0
You need to be logged in to leave comments.
Login now