socialforge/app/views/news/_course_show.html.erb

137 lines
5.1 KiB
Plaintext
Raw Normal View History

<script type="text/javascript">
function regexTitle()
{
var name = $("#news_title").val();
if(name.length ==0)
{
$("#title_notice_span").text("标题不能为空");
$("#title_notice_span").css('color','#ff0000');
$("#title_notice_span").focus();
return false;
}
else if(name.length <= 60)
{
$("#title_notice_span").text("填写正确");
$("#title_notice_span").css('color','#008000');
return true;
}
else
{
$("#title_notice_span").text("标题超过60个字符");
$("#title_notice_span").css('color','#ff0000');
$("#title_notice_span").focus();
return false;
}
}
function regexDescription()
{
var name = $("#news_description").val();
if(name.length ==0)
{
$("#description_notice_span").text("描述不能为空");
$("#description_notice_span").css('color','#ff0000');
$("#description_notice_span").focus();
return false;
}
else
{
$("#description_notice_span").text("填写正确");
$("#description_notice_span").css('color','#008000');
return true;
}
}
function submitNews()
{
if(regexTitle() && regexDescription())
{
$("#news-form").submit();
}
}
2015-03-25 20:36:49 +08:00
function submitComment()
{
2015-03-26 11:02:18 +08:00
$("#add_comment_form").submit();
}
function clearMessage()
{
$("#comment_comments").val("");
2015-03-25 20:36:49 +08:00
}
</script>
2015-03-25 20:36:49 +08:00
<div class="project_r_h">
<h2 class="project_h2"><%= l(:label_course_news) %></h2>
2015-03-25 20:36:49 +08:00
</div>
2015-03-26 11:02:18 +08:00
<% if authorize_for_course('news', 'edit') %>
<div id="edit-news" style="display:none;">
<%= labelled_form_for :news, @news, :url => news_path(@news),
:html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %>
<%= render :partial => 'course_form', :locals => { :f => f, :is_new => false } %>
<% end %>
<div id="preview" class="wiki"></div>
</div>
<% end %>
2015-03-25 20:36:49 +08:00
<div class="problem_main">
<%= link_to image_tag(url_to_avatar(@news.author),:width => 42,:height => 42), user_path(@news.author), :class => "problem_pic fl" %>
<div class="problem_txt fl mt5">
<h4 class="r_txt_tit mb5"> <%=h @news.title %></h4>
<%= watcher_link(@news, User.current) %>
<%= link_to(l(:button_edit),
edit_news_path(@news),
:class => 'talk_edit fr',
:accesskey => accesskey(:edit),
:onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_news, @course) %>
<%= delete_link(news_path(@news),:class => 'talk_edit fr') if User.current.allowed_to?(:manage_news, @course) %>
<div class="cl"></div>
<div class="mb5"><%= textilizable(@news, :description) %><br /> <%= l(:label_create_time) %> <%= format_time(@news.created_on) %></div>
<%= link_to_attachments @news %>
<!--<a href="#" class=" link_file">附件爱覅俄方if.zip(27.5kB)</a> -->
</div>
<div class="cl"></div>
2015-03-26 11:02:18 +08:00
</div>
2015-03-25 20:36:49 +08:00
<% if @news.commentable? %>
<div class="msg_box">
2015-03-26 11:02:18 +08:00
<h4><%= l(:label_comment_add) %></h4>
2015-03-25 20:36:49 +08:00
<%= form_tag({:controller => 'comments', :action => 'create', :id => @news}, :id => "add_comment_form") do %>
<div class="box">
<%= text_area 'comment', 'comments', :placeholder=>"最多250个字"%>
</div>
<p>
2015-03-26 11:02:18 +08:00
<a href="#" class="grey_btn fr ml10" onclick="clearMessage();"><%= l(:label_cancel_with_space) %></a>
<a href="#" class="blue_btn fr" onclick="submitComment();"><%= l(:label_comment_with_space) %></a>
2015-03-25 20:36:49 +08:00
</p>
<% end %>
</div>
<% end %>
2015-03-26 11:02:18 +08:00
<% comments = @comments.reverse %>
<% comments.each do |comment| %>
<% next if comment.new_record? %>
<div class="ping_C mb10">
<div class="ping_dispic"><%= link_to image_tag(url_to_avatar(comment.author),:width => 42,:height => 42), user_path(comment.author)%></div>
<div class="ping_discon">
<div class="ping_distop">
<%= link_to_user_header(comment.author,false,:class => 'c_blue fb fl mb10 ') if comment.respond_to?(:author) %><span class="c_grey fr"><%= format_time(comment.created_on) %></span>
<div class="cl"></div>
<%= textilizable(comment.comments) %>
</div>
<div class="ping_disfoot"><%= link_to_if_authorized_course image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment},
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %>
</div>
</div>
2015-03-25 20:36:49 +08:00
<div class="cl"></div>
</div>
2015-03-26 11:02:18 +08:00
<% end if @comments.any? %>
2015-03-25 20:36:49 +08:00
2015-03-26 11:02:18 +08:00
<!--problem_main end-->
<% content_for :header_tags do %>
<%= stylesheet_link_tag 'scm' %>
<% end %>
2015-03-26 11:02:18 +08:00
<% html_title @news.title -%>