课程讨论区代码重构

解决路由匹配和JS显示冲突
This commit is contained in:
huang 2015-04-29 14:29:03 +08:00
parent 412052dd0d
commit 135c3d9b19
7 changed files with 42 additions and 39 deletions

View File

@ -1,12 +1,3 @@
<script type="text/javascript" xmlns="http://www.w3.org/1999/html">
function submitProjectBoard()
{
if(regexSubject()&&regexContent())
{
$("#message-form").submit();
}
}
</script>
<div class="project_r_h">
<h2 class="project_h2">
<% if User.current.language == "zh"%>
@ -16,20 +7,6 @@
<% end %>
</h2>
</div>
<div id="add-message" class="talk_new ml15" style="display:<%= !@flag.nil?&&@flag=='true' ? '' : 'none' %>;">
<% if User.current.logged? %>
<%= form_for @message, :url => new_board_message_path(@board), :html => {:multipart => true, :id => 'message-form'} do |f| %>
<p class="talk_top"><%= l(:project_module_boards_post) %></p>
<%= render :partial => 'messages/form_project', :locals => {:f => f} %>
<p>
<a href="javascript:void(0)" onclick="submitProjectBoard();" class="blue_btn fl ml55" style="margin-left: 55px"><%= l(:button_submit)%></a>
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-message").hide(); return false;', :class => 'grey_btn ml10 fl' %>
</p>
<% end %>
<div id="preview" class="wiki"></div>
<br/><br/>
<% end %>
</div>
<!--display the board-->
<% if !User.current.logged? %>

View File

@ -23,7 +23,7 @@
<a class="subnav_num">(<%= @project.boards.first.topics.count %>)</a>
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:project_module_boards_post), project_boards_path(@project, :flag => true), :layout => 'base_projects', :class => "subnav_green ml105" %>
<%= link_to "+"+l(:project_module_boards_post), new_board_message_path(@project.boards.first), :layout => 'base_projects', :class => "subnav_green ml105" %>
<% end %>
</div>
<% end%>

View File

@ -12,7 +12,7 @@
<a class="subnav_num">(<%= @project.boards.first.topics.count %>)</a>
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:project_module_boards_post), project_boards_path(@project, :flag => true), :layout => 'base_projects', :class => "subnav_green ml105" %>
<%= link_to "+"+l(:project_module_boards_post), new_board_message_path(@project.boards.first), :layout => 'base_projects', :class => "subnav_green ml105" %>
<% end %>
</div>
<% end%>

View File

@ -23,7 +23,7 @@
<a class="subnav_num">(<%= @project.boards.first.topics.count %>)</a>
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:project_module_boards_post), project_boards_path(@project, :flag => true), :layout => 'base_projects', :class => "subnav_green ml105" %>
<%= link_to "+"+l(:project_module_boards_post), new_board_message_path(@project.boards.first), :layout => 'base_projects', :class => "subnav_green ml105" %>
<% end %>
</div>
<% end%>

View File

@ -0,0 +1,28 @@
<div class="project_r_h">
<h2 class="project_h2">
<% if User.current.language == "zh"%>
<%= h @board.name %>
<% else %>
<%= l(:project_module_boards) %>
<% end %>
</h2>
</div>
<div id="cancel-message" class="talk_new ml15">
<% if User.current.logged? %>
<%= form_for @message, :url => new_board_message_path(@board), :html => {:multipart => true, :id => 'message-form'} do |f| %>
<p class="talk_top"><%= l(:project_module_boards_post) %></p>
<%= render :partial => 'messages/form_project', :locals => {:f => f} %>
<p>
<a href="javascript:void(0)" onclick="submitProjectBoard();" class="blue_btn fl ml55" style="margin-left: 55px"><%= l(:button_submit)%></a>
<%= link_to l(:button_cancel), project_boards_path(@project), :class => 'grey_btn ml10 fl' %>
</p>
<% end %>
<div id="preview" class="wiki"></div>
<br/><br/>
<% else %>
<div class="c_grey f14">
<%= l(:label_user_login_project_board) %>
<%= link_to l(:label_user_login_new), signin_path, :class => "c_blue ml5" %>
</div>
<% end %>
</div>

View File

@ -1,16 +1,5 @@
<% if @project %>
<h3>
<%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %>
&#187;
<%= l(:label_message_new) %>
</h3>
<%= form_for @message, :url => {:action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f,:is_new => true} %>
<%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %>
<%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form' ,target='preview',{:class => 'whiteButton m3p10'} )%>
<% end %>
<div id="preview" class="wiki"></div>
<%= render :partial => 'project_new_topic' %>
<% elsif @course %>
<%= render :partial => 'course_new' %>
<% end %>

View File

@ -306,4 +306,13 @@ $(document).ready(function () {
$("pre").addClass("break_word");
}
});
});
//论坛提交
function submitProjectBoard()
{
if(regexSubject()&&regexContent())
{
$("#message-form").submit();
}
}