修改《匿名发布新帖》《编辑时出现跳转错误》

Signed-off-by: alan <547533434@qq.com>
This commit is contained in:
alan 2015-05-22 11:09:43 +08:00
parent a0ca31780e
commit c18d1d9585
7 changed files with 85 additions and 30 deletions

View File

@ -193,7 +193,7 @@ class MessagesController < ApplicationController
else else
redirect_to board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id)) redirect_to board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id))
end end
elsif request.get? elsif request.get? || request.post?
if params[:is_board] if params[:is_board]
if @project if @project
redirect_to project_boards_path(@project) redirect_to project_boards_path(@project)

View File

@ -10,7 +10,9 @@
<% end %> <% end %>
</h2> </h2>
<% if User.current.logged? %>
<a href="javascript:void(0)" class="green_btn fr newtalk " onclick="show_newtalk();"><%= l(:label_message_new) %></a> <a href="javascript:void(0)" class="green_btn fr newtalk " onclick="show_newtalk();"><%= l(:label_message_new) %></a>
<% end %>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<!-- 发布新帖部分 --> <!-- 发布新帖部分 -->
@ -40,7 +42,7 @@
<p class="talkmain_tit fl fb break_word">&nbsp;&nbsp;<%= h(topic.subject) %></p> <p class="talkmain_tit fl fb break_word">&nbsp;&nbsp;<%= h(topic.subject) %></p>
<% if topic.course_editable_by?(User.current) %> <% if topic.course_editable_by?(User.current) %>
<a href="javascript:void(0)" onclick="show_newtalk1('#about_newtalk<%= topic.id%>');" style="color: #426e9a;float: right; <a href="javascript:" onclick="show_newtalk1('#about_newtalk<%= topic.id%>');" style="color: #426e9a;float: right;
margin-right: 10px;"><%= l(:button_edit) %></a> margin-right: 10px;"><%= l(:button_edit) %></a>
<% end %> <% end %>
@ -70,7 +72,7 @@
<p style="display: none" id="project_show_<%= topic.id%>"> <p style="display: none" id="project_show_<%= topic.id%>">
<a id="expend_more_information<%= topic.id%>" href="javascript:(0)" style="color: #0781b4;" onclick="show_more_reply('#content_<%=topic.id%>','#expend_more_information<%= topic.id%>','#arrow<%=topic.id%>');" value="show_more">[展开]</a> <a id="expend_more_information<%= topic.id%>" href="javascript:void(0)" style="color: #0781b4;" onclick="show_more_reply('#content_<%=topic.id%>','#expend_more_information<%= topic.id%>','#arrow<%=topic.id%>');" value="show_more">[展开]</a>
<span class="g-arr-down"> <span class="g-arr-down">
<img id="arrow<%=topic.id%>" src="/images/jiantou.jpg" width="12" height="6" /> <img id="arrow<%=topic.id%>" src="/images/jiantou.jpg" width="12" height="6" />
</span> </span>
@ -81,7 +83,9 @@
<%= l(:label_activity_time)%>&nbsp;&nbsp;<%= format_time topic.created_on %> <%= l(:label_activity_time)%>&nbsp;&nbsp;<%= format_time topic.created_on %>
</div> </div>
<%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => 'message_content',:class => ' c_dblue fr' %> <% if User.current.logged? %>
<%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => "about_newtalk#{topic.id}",:class => ' c_dblue fr' %>
<% end %>
<div class="cl"></div> <div class="cl"></div>
@ -98,11 +102,11 @@
<em class="talkWrapArrow"></em> <em class="talkWrapArrow"></em>
<div class="cl"></div> <div class="cl"></div>
<div class="talkConIpt ml15 mb10" style="display: none" id="reply<%= topic.id %>" name="container_board"> <div class="talkConIpt ml15 mb10" style="display: none" id="reply<%= topic.id %>" name="container_board">
<%= form_for reply, :as => :reply, :url => {:controller=>'messages',:action => 'reply', :id => topic.id, :board_id => topic.board_id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message_form' + topic.id.to_s} do |f| %> <%= form_for reply, :as => :reply, :url => {:controller=>'messages',:action => 'reply', :id => topic.id, :board_id => topic.board_id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message_form' + topic.id.to_s, :name=>'message-form'} do |f| %>
<%= render :partial => 'form_project', :locals => {:f => f, :replying => true} %> <%= render :partial => 'form_course', :locals => {:f => f, :replying => true} %>
<%= toggle_link l(:button_cancel), "reply" + topic.id.to_s, :focus => 'message_content',:class => 'grey_btn fr ml10' %> <%= toggle_link l(:button_cancel), "reply" + topic.id.to_s, :focus => 'message_content',:class => 'grey_btn fr ml10' %>
<a href="javascript:(0)" name="submitbtn" class="blue_btn fr " style=""><%= l(:label_memo_create)%></a> <a href="javascript:void(0)" name="submitbtn" class="blue_btn fr " style=""><%= l(:label_memo_create)%></a>
<% end %> <% end %>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
@ -139,6 +143,15 @@
:title => l(:button_delete), :title => l(:button_delete),
:class => ' c_dblue fr' :class => ' c_dblue fr'
) if message.course_destroyable_by?(User.current) %> ) if message.course_destroyable_by?(User.current) %>
<%= link_to(
l(:button_reply),
{:controller => 'messages', :action => 'quote', :id => message.id, :board_id => message.board_id, :is_board => 'true'},
:remote => true,
:method => 'get',
:focus => "about_newtalk#{topic.id}",
:class => ' c_dblue fr',
:style => 'margin-right: 10px;',
:title => l(:button_quote)) if !topic.locked? && authorize_for('messages', 'reply') %>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
@ -168,6 +181,15 @@
:title => l(:button_delete), :title => l(:button_delete),
:class => ' c_dblue fr' :class => ' c_dblue fr'
) if message.course_destroyable_by?(User.current) %> ) if message.course_destroyable_by?(User.current) %>
<%= link_to(
l(:button_reply),
{:controller => 'messages', :action => 'quote', :id => message.id, :board_id => message.board_id, :is_board => 'true'},
:remote => true,
:method => 'get',
:focus => "about_newtalk#{topic.id}",
:class => ' c_dblue fr',
:style => 'margin-right: 10px;',
:title => l(:button_quote)) if !topic.locked? && authorize_for('messages', 'reply') %>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
@ -176,7 +198,7 @@
</ul> </ul>
</div> </div>
<%if replies_all.first %> <%if replies_all.first %>
<div class="talkWrapMsg"><a class=" ml258" href="javascript:(0)" id="showgithelp<%= topic.id%>" value="show_help" onclick ="showhelpAndScrollToMessage('talkWrapMsg<%= topic.id %>','#showgithelp<%= topic.id%>','<%=topic.replies_count%>'); " class="c_dblue lh23">展开回复(<%= topic.replies_count.to_s%>)</a></div> <div class="talkWrapMsg"><a class=" ml258" href="javascript:" id="showgithelp<%= topic.id%>" style="color: #0781b4;" value="show_help" onclick ="showhelpAndScrollToMessage('talkWrapMsg<%= topic.id %>','#showgithelp<%= topic.id%>','<%=topic.replies_count%>'); " class="c_dblue lh23">展开回复(<%= topic.replies_count.to_s%>)</a></div>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
@ -196,6 +218,7 @@
<% content_for :header_tags do %> <% content_for :header_tags do %>
<%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@course}: #{@board}") %> <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@course}: #{@board}") %>
<% end %> <% end %>
</div>
<script type="text/javascript"> <script type="text/javascript">
//submitProjectsBoard() //submitProjectsBoard()
KindEditor.ready(function(K){ KindEditor.ready(function(K){
@ -203,6 +226,7 @@
var container=$(this); var container=$(this);
var textarea= $("textarea[aa='content']",container); var textarea= $("textarea[aa='content']",container);
var message = $("p[aa='message_show']", container);
var editor = K.create(textarea, { var editor = K.create(textarea, {
resizeType : 1, resizeType : 1,
allowPreviewEmoticons : false, allowPreviewEmoticons : false,
@ -214,12 +238,34 @@
$("a[name='submitbtn']",container).click(function(){ $("a[name='submitbtn']",container).click(function(){
textarea[0].value = editor.html(); textarea[0].value = editor.html();
var id = textarea[0].id.toString().substr(15); var id = textarea[0].id.toString().substr(15);
var subject = document.getElementById("message_subject");
if(subject.value == "RE: ") {
if (textarea[0].value.length == 0) {
if(this.parentNode.name == 'message-form') { message[0].text("描述不能为空");
message[0].css('color', '#ff0000');
}
else {
message[0].text("填写正确");
message[0].css('color', '#008000');
this.parentNode.submit(); this.parentNode.submit();
} }
else }
else {
if (regexContent(id) && regexSubject(id)) {
if (this.parentNode.name.toString() == 'message-form') {
this.parentNode.submit();
}
else {
this.parentNode.parentNode.submit(); this.parentNode.parentNode.submit();
}
}
}
}); });
}); });

View File

@ -25,13 +25,13 @@
<%= form_for topic, { <%= form_for topic, {
:as => :message, :as => :message,
:url => {:controller => 'messages',:action => 'edit', :is_board => 'true',:id => topic.id, :board_id => topic.board_id}, :url => {:controller => 'messages',:action => 'edit', :is_board => 'true',:id => topic.id, :board_id => topic.board_id},
:html => {:multipart => true, :html => {:multipart => true, :name=>'message-form',
:id => 'message-form' + topic.id.to_s, :id => 'message-form' + topic.id.to_s,
:method => :post} :method => :post}
} do |f| %> } do |f| %>
<%= render :partial => 'form_course', <%= render :partial => 'form_course',
:locals => {:f => f, :replying => !topic.parent.nil?, :topic => topic} %> :locals => {:f => f, :replying => !topic.parent.nil?, :topic => topic} %>
<a href="javascript:void(0)" onclick="submitProjectsBoard('<%= topic.id%>');"class="blue_btn fl c_white"><%= l(:button_submit)%></a> <a href="javascript:void(0)" name='submitbtn' class="blue_btn fl c_white"><%= l(:button_submit)%></a>
<a href="javascript:void(0)" onclick="show_newtalk1('#about_newtalk<%= topic.id%>');" class="blue_btn grey_btn fl c_white"><%= l(:button_cancel) %></a> <a href="javascript:void(0)" onclick="show_newtalk1('#about_newtalk<%= topic.id%>');" class="blue_btn grey_btn fl c_white"><%= l(:button_cancel) %></a>
<% end %> <% end %>

View File

@ -68,7 +68,7 @@
<% end %> <% end %>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<p id="message_content_span<%= f.object.id%>" class="ml55"></p> <p id="message_content_span<%= f.object.id%>" aa="message_show" class="ml55"></p>
</li> </li>
<div class="cl"></div> <div class="cl"></div>
<li> <li>

View File

@ -81,7 +81,7 @@
<% end %> <% end %>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<p id="message_content_span<%= f.object.id%>" class="ml55"></p> <p id="message_content_span<%= f.object.id%>" aa="message_show" class="ml55"></p>
</li> </li>
<div class="cl"></div> <div class="cl"></div>
<li> <li>

View File

@ -7,7 +7,9 @@
<% end %> <% end %>
</h2> </h2>
<a href="javascript:void(0)" class="green_btn fr newtalk " onclick="show_newtalk();"><%= l(:label_message_new) %></a> <% if User.current.logged? %>
<a href="javascript:void" class="green_btn fr newtalk " onclick="show_newtalk();"><%= l(:label_message_new) %></a>
<% end %>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
@ -70,7 +72,7 @@
<p style="display: none" id="project_show_<%= topic.id%>"> <p style="display: none" id="project_show_<%= topic.id%>">
<a id="expend_more_information<%= topic.id%>" style="color: #0781b4;" href="javascript:(0)" onclick="show_more_reply('#content_<%=topic.id%>','#expend_more_information<%= topic.id%>','#arrow<%=topic.id%>');" value="show_more">[展开]</a> <a id="expend_more_information<%= topic.id%>" style="color: #0781b4;" href="javascript:void(0)" onclick="show_more_reply('#content_<%=topic.id%>','#expend_more_information<%= topic.id%>','#arrow<%=topic.id%>');" value="show_more">[展开]</a>
<span class="g-arr-down"> <span class="g-arr-down">
<img id="arrow<%=topic.id%>" src="/images/jiantou.jpg" width="12" height="6" /> <img id="arrow<%=topic.id%>" src="/images/jiantou.jpg" width="12" height="6" />
</span> </span>
@ -82,8 +84,9 @@
<%= l(:label_activity_time)%>&nbsp;&nbsp;<%= format_time topic.created_on %> <%= l(:label_activity_time)%>&nbsp;&nbsp;<%= format_time topic.created_on %>
</div> </div>
<% if User.current.logged? %>
<%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => "about_newtalk#{topic.id}",:class => ' c_dblue fr' %> <%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => "about_newtalk#{topic.id}",:class => ' c_dblue fr' %>
<% end %>
<div class="cl"></div> <div class="cl"></div>
@ -104,7 +107,7 @@
<%= render :partial => 'form_project', :locals => {:f => f, :replying => true} %> <%= render :partial => 'form_project', :locals => {:f => f, :replying => true} %>
<%= toggle_link l(:button_cancel), "reply" + topic.id.to_s, :focus => 'message_content',:class => 'grey_btn fr ml10' %> <%= toggle_link l(:button_cancel), "reply" + topic.id.to_s, :focus => 'message_content',:class => 'grey_btn fr ml10' %>
<a href="javascript:(0)" name="submitbtn" class="blue_btn fr " style=""><%= l(:label_memo_create)%></a> <a href="javascript:void(0)" name="submitbtn" class="blue_btn fr " style=""><%= l(:label_memo_create)%></a>
<% end %> <% end %>
@ -144,7 +147,7 @@
:class => ' c_dblue fr' :class => ' c_dblue fr'
) if message.course_destroyable_by?(User.current) %> ) if message.course_destroyable_by?(User.current) %>
<%= link_to( <%= link_to(
l(:button_quote), l(:button_reply),
{:controller => 'messages', :action => 'quote', :id => message.id, :board_id => message.board_id, :is_board => 'true'}, {:controller => 'messages', :action => 'quote', :id => message.id, :board_id => message.board_id, :is_board => 'true'},
:class => ' c_dblue fr', :class => ' c_dblue fr',
:style => 'margin-right: 10px;', :style => 'margin-right: 10px;',
@ -184,7 +187,7 @@
:class => ' c_dblue fr' :class => ' c_dblue fr'
) if message.course_destroyable_by?(User.current) %> ) if message.course_destroyable_by?(User.current) %>
<%= link_to( <%= link_to(
l(:button_quote), l(:button_reply),
{:controller => 'messages', :action => 'quote', :id => message.id, :board_id => message.board_id, :is_board => 'true'}, {:controller => 'messages', :action => 'quote', :id => message.id, :board_id => message.board_id, :is_board => 'true'},
:remote => true, :remote => true,
:method => 'get', :method => 'get',
@ -200,7 +203,7 @@
</ul> </ul>
</div> </div>
<%if replies_all.first %> <%if replies_all.first %>
<div class="talkWrapMsg"><a class=" c_blue ml258" href="javascript:(0)" style="color: #0781b4;" id="showgithelp<%= topic.id%>" value="show_help" onclick ="showhelpAndScrollToMessage('talkWrapMsg<%= topic.id %>','#showgithelp<%= topic.id%>','<%=topic.replies_count%>'); " class="c_dblue lh23">展开回复(<%= topic.replies_count.to_s%>)</a></div> <div class="talkWrapMsg"><a class=" c_blue ml258" href="javascript:void(0)" style="color: #0781b4;" id="showgithelp<%= topic.id%>" value="show_help" onclick ="showhelpAndScrollToMessage('talkWrapMsg<%= topic.id %>','#showgithelp<%= topic.id%>','<%=topic.replies_count%>'); " class="c_dblue lh23">展开回复(<%= topic.replies_count.to_s%>)</a></div>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
@ -256,12 +259,16 @@
$("a[name='submitbtn']",container).click(function(){ $("a[name='submitbtn']",container).click(function(){
textarea[0].value = editor.html(); textarea[0].value = editor.html();
var id = textarea[0].id.toString().substr(15); var id = textarea[0].id.toString().substr(15);
if(regexContent(id) && regexSubject(id)) {
if(this.parentNode.name == 'message-form') { if (this.parentNode.name.toString() == 'message-form') {
this.parentNode.submit(); this.parentNode.submit();
} }
else else {
this.parentNode.parentNode.submit(); this.parentNode.parentNode.submit();
}
}
}); });
}); });

View File

@ -168,9 +168,11 @@ function regexSubject(id) {
return false; return false;
} }
function regexContent(id) { function regexContent(id) {
var contentid = "#message_content" + id; var contentid = "#message_content" + id;
var message = "#message_content_span"+ id; var message = "#message_content_span"+ id;
var content = $.trim($(contentid).val()); var content = $.trim($(contentid).val());
if (content.length == 0) { if (content.length == 0) {
$(message).text("描述不能为空"); $(message).text("描述不能为空");
$(message).css('color', '#ff0000'); $(message).css('color', '#ff0000');