socialforge/app/views/boards/_project_show.html.erb

361 lines
17 KiB
Plaintext
Raw Normal View History

2015-05-23 16:02:41 +08:00
<div nhname="container_board">
<div class="project_r_h" xmlns="http://www.w3.org/1999/html">
<h2 class="project_h2 fl">
<% if User.current.language == "zh"%>
<%= h @board.name %>
<% else %>
<%= l(:project_module_boards) %>
<% end %>
</h2>
<% if User.current.logged? %>
<a href="javascript:void(0)" class="green_btn fr newtalk " nhname="showbtn"><%= l(:label_message_new) %></a>
<% end %>
2015-05-23 16:02:41 +08:00
<div class="cl"></div>
</div>
<% if !User.current.logged? %>
<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 class="cl"></div>
2015-05-23 16:02:41 +08:00
<div class=" talklist_box" >
<div class="talk_new ml15 mb10" nhname="about_talk" style="display:<%= !@flag.nil? && @flag=='true' ? 'block' : 'none' %>;">
<ul>
<%= render :partial => 'project_new_topic' %>
</ul>
</div><!--talknew end-->
</div>
</div>
<div class=" talklist_box" >
<p class="c_dark mb5">讨论区共有<span class="c_orange"><%= @topic_count %></span>个帖子</p>
2015-05-23 16:02:41 +08:00
<% if @topics.any? %>
<% @topics.each do |topic| %>
2015-05-25 15:19:42 +08:00
<div class="talkmain_box" id="topic<%= topic.id %>" nhname="container_board" mhname="container_board_reply" style="border:none; margin-bottom:0; border-bottom: 1px dashed #d9d9d9;">
<%= link_to image_tag(url_to_avatar(topic.author), :width=>"42",:height=>"42"), user_path(topic.author),:class =>'talkmain_pic fl' %>
<div class="talkmain_txt fl mt5">
<% author = topic.author.to_s + "" %>
<%= link_to author, user_path(topic.author), :class =>"talkmain_name fl " %>
<p class="talkmain_tit fl fb break_word" style="width:auto;">&nbsp;&nbsp;<%= h(topic.subject) %></p>
<div style="float:right;max-width:110px;">
<% if topic.editable_by?(User.current) %>
<a href="javascript:void(0)" nhname="showbtn" style="color: #426e9a;float: right;margin-right: 10px;"><%= l(:button_edit) %></a>
<% end %>
<%= link_to(
l(:button_delete),
{:controller =>'messages',:action => 'destroy', :id => topic.id, :board_id => topic.board_id, :is_board=>'true'},
:method => :post,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'talk_edit fr',
:style => ' margin-right: 10px;'
) if topic.destroyable_by?(User.current) %>
<% if topic.sticky? %>
<a href="javascript:void(0)" class="talk_up fr c_red" style="margin-right: 10px;"><%= l(:label_board_sticky)%></a>
<% end %>
2015-05-26 17:01:25 +08:00
<script>
$(function(){if($("#contentmessage<%=topic.id %>").height()>182){$("#project_show_<%= topic.id%>").show();}});
</script>
2015-05-25 15:19:42 +08:00
</div>
<div class="cl"></div>
<div class="project_board_content break_word" id="content_<%=topic.id%>">
<div id="contentmessage<%=topic.id %>" class="upload_img">
<%= topic.content.html_safe %>
</div>
</div>
2015-05-26 17:01:25 +08:00
<p style="display: none;" id="project_show_<%= topic.id%>">
2015-05-25 15:19:42 +08:00
<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">
<img id="arrow<%=topic.id%>" src="/images/jiantou.jpg" width="12" height="6" />
</span>
</p>
<%= link_to_attachments_course topic, :author => false %>
<%= l(:label_activity_time)%>&nbsp;&nbsp;<%= format_time topic.created_on %>
</div>
<% if User.current.logged? %>
<a href="javascript:void(0)" nhname="showbtn_reply" class="c_dblue fr" style="margin-right:10px;"><%= l(:button_reply) %></a>
<% end %>
<div class="cl"></div>
<div class="talk_new ml15 mb10" nhname='about_talk' id="about_newtalk<%=topic.id%>" style="display: none">
<ul>
<%= render :partial => 'edit',locals: {:topic => topic} %>
</ul>
</div>
<div class="cl"></div>
<div class="talkWrapBox">
2015-05-26 14:18:42 +08:00
<% reply = Message.new(:subject => "RE: #{topic.subject}")%>
2015-05-25 15:19:42 +08:00
<% if !topic.locked? && authorize_for('messages', 'reply') %>
<em class="talkWrapArrow"></em>
<div class="cl"></div>
<div class="talkConIpt ml15 mb10" style="display:none;margin-left:40px;" nhname="about_talk_reply" id="reply<%= topic.id %>">
<%= form_for reply, :as => :reply, :url => {:controller=>'messages',:action => 'reply', :id => topic.id, :board_id => topic.board_id, :is_board => 'true'},
:html => {:nhname=>"form",:multipart => true, :id => 'message_form' + topic.id.to_s, :name=>'message-form'} do |f| %>
<%= render :partial => 'form_project', :locals => {:f => f, :replying => true} %>
2015-05-26 17:01:25 +08:00
<div class="fl" nhname="toolbar_container"></div>
2015-05-25 15:19:42 +08:00
<div style="padding-top:5px;" class="fr">
<a href="javascript:void(0)" nhname="cancelbtn" class="blue_btn fr ml10" style=""><%= l(:button_cancel)%></a>
<a href="javascript:void(0)" nhname="submitbtn" class="blue_btn fr " style=""><%= l(:label_memo_create)%></a>
</div>
<% end %>
<div class="cl"></div>
</div>
<% end %>
</div>
<div class="cl"></div>
2015-05-26 14:18:42 +08:00
<% replies_all = topic.children.includes(:author, :attachments, {:board => :project}).
reorder("#{Message.table_name}.id asc").all %>
<% unless replies_all.empty? %>
<div class="talkWrapMsg">
<ul>
<% replies_all_i = 0 %>
<% replies_all.each do |message| %>
<% replies_all_i=replies_all_i+1 %>
<li nhname="reply_rec" style="display:<%= replies_all_i>2?'none':'' %>">
<%= link_to image_tag(url_to_avatar(message.author), :width => '34',:height => '34'), user_path(message.author), :class =>'Msg_pic' %>
<div class="Msg_txt">
<%= link_to_user_header message.author,false,:class => 'fl c_orange ' %>
<br/>
<p class="fl break_word"><%= textAreailizable message,:content,:attachments => message.attachments %></p>
<br/>
<span class=" c_grey fl"><%= format_time(message.created_on) %></span>
<%= link_to(
l(:button_delete),
{:controller => 'messages', :action => 'destroy', :id => message.id, :board_id => message.board_id, :is_board => 'true'},
:method => :post,
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:button_delete),
:class => ' c_dblue fr'
) if message.course_destroyable_by?(User.current) %>
<%= link_to(
l(:button_reply),
'javascript:;',
:nhname =>'showbtn_child_reply',
:class => ' c_dblue fr',
:style => 'margin-right: 10px;',
:title => l(:button_reply)) if !topic.locked? && authorize_for('messages', 'reply') %>
</div>
<div class="cl"></div>
</li>
<% end %>
</ul>
</div>
<%if topic.replies_count>2 %>
<div class="talkWrapMsg">
<a nhname="reply_ex_btn" data-count="<%= topic.replies_count %>" data-init="0" href="javascript:void(0)" class="ml258 c_dblue lh23">展开回复(<%= topic.replies_count.to_s%>)</a>
</div>
<% end %>
<% end %>
2015-05-25 15:19:42 +08:00
</div>
2015-05-23 16:02:41 +08:00
<% end %>
2015-05-26 14:18:42 +08:00
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>
<ul class="wlist">
<%= pagination_links_full @topic_pages, @topic_count, :per_page_links => false, :remote => false, :flag => true %>
</ul>
<!--讨论主类容 end-->
<%# other_formats_links do |f| %>
<%#= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
<%# end %>
<% html_title @board.name %>
<% content_for :header_tags do %>
<%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@project}: #{@board}") %>
2015-05-23 16:02:41 +08:00
<% end %>
</div>
2015-05-26 14:18:42 +08:00
<div style="display:none;"><a href="#" id="nhjump"></a></div>
2015-05-26 17:01:25 +08:00
<style>
.ke-toolbar{display:none;width:400px;border:none;background:none;}
</style>
<script type="text/javascript">
2015-05-23 16:02:41 +08:00
function nh_check_field(params){
var result=true;
2015-05-26 14:18:42 +08:00
if(params.subject!=undefined){
if($.trim(params.subject.val()) == ""){
params.subjectmsg.html('主题不能为空');
params.subjectmsg.css({color:'#ff0000'});
result=false;
}else{
params.subjectmsg.html('填写正确');
params.subjectmsg.css({color:'#008000'});
}
params.subjectmsg.show();
2015-05-23 16:02:41 +08:00
}
2015-05-26 14:18:42 +08:00
if(params.content!=undefined){
if($.trim(params.content.html()) == ""){
result=false;
}
2015-05-26 15:01:11 +08:00
if(params.content.html()!=params.textarea.html() || params.issubmit==true){
params.textarea.html(params.content.html());
2015-05-26 14:18:42 +08:00
if($.trim(params.content.html()) == ""){
params.contentmsg.html('内容不能为空');
params.contentmsg.css({color:'#ff0000'});
}else{
params.contentmsg.html('填写正确');
params.contentmsg.css({color:'#008000'});
}
params.contentmsg.show();
}
2015-05-23 16:02:41 +08:00
}
return result;
}
function nh_init_board(params){
2015-05-26 14:18:42 +08:00
//发帖/编辑/回复按钮的click
params.showbtn.click(function(){
2015-05-23 16:02:41 +08:00
if(params.textarea.data('init') == undefined){
2015-05-25 15:19:42 +08:00
//初始化编辑器
var editor = params.kindutil.create(params.textarea, {
2015-05-23 16:02:41 +08:00
resizeType : 1,
allowPreviewEmoticons : false,
allowImageUpload : false,
minWidth:"1px",
width:"565px",
2015-05-26 17:01:25 +08:00
items : ['emoticons'],
2015-05-26 14:18:42 +08:00
afterChange:function(){//按键事件
nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
2015-05-26 17:01:25 +08:00
},
afterCreate:function(){
var toolbar = $("div[class='ke-toolbar']",params.about_talk);
params.toolbar_container.append(toolbar);
2015-05-26 14:18:42 +08:00
}
2015-05-23 16:02:41 +08:00
});
2015-05-26 17:01:25 +08:00
2015-05-26 14:18:42 +08:00
//主题输入框按键事件
2015-05-26 17:01:25 +08:00
params.inputsubject.keyup(function(){
2015-05-26 14:18:42 +08:00
nh_check_field({subject:params.inputsubject,subjectmsg:params.subjectmsg});
})
2015-05-25 15:19:42 +08:00
//表单提交
params.form.submit(function(){
2015-05-23 16:02:41 +08:00
var is_checked = nh_check_field({
2015-05-26 15:01:11 +08:00
issubmit:true,
2015-05-23 16:02:41 +08:00
subject:params.inputsubject,
subjectmsg:params.subjectmsg,
content:editor,
contentmsg:params.contentmsg,
2015-05-26 14:18:42 +08:00
textarea:params.textarea
2015-05-23 16:02:41 +08:00
});
if(is_checked){
2015-05-26 15:01:11 +08:00
// alert('submit');
2015-05-26 14:18:42 +08:00
// return false;
return true;
2015-05-23 16:02:41 +08:00
}
2015-05-25 15:19:42 +08:00
return false;
2015-05-23 16:02:41 +08:00
});
2015-05-25 15:19:42 +08:00
//提交按钮click
params.submitbtn.click(function(){
params.form.submit();
});
//取消按钮click
params.cancelbtn.click(function(){
2015-05-23 16:02:41 +08:00
params.about_talk.toggle();//显示/隐藏编辑区
2015-05-25 15:19:42 +08:00
if(params.about_talk.is(':hidden')){//隐藏时reset表单数据
params.form[0].reset();
2015-05-26 15:01:11 +08:00
if(params.type=='reply'){
params.textarea.empty();
}else{
params.textarea.html(params.init_content_val.val());
}
2015-05-25 15:19:42 +08:00
editor.html(params.textarea.html());
params.subjectmsg.hide();
params.contentmsg.hide();
2015-05-26 14:18:42 +08:00
params.quote_show.empty();
params.quote_input.empty();
2015-05-25 15:19:42 +08:00
}else{
2015-05-26 14:18:42 +08:00
if(params.type=='reply'){
params.jumphref.attr('href','#'+params.form.attr('id'));
params.jumphref[0].click();
}else params.inputsubject.focus();
2015-05-25 15:19:42 +08:00
}
2015-05-23 16:02:41 +08:00
});
2015-05-25 15:19:42 +08:00
params.textarea.data('init','1');//标记为已经初始化
2015-05-23 16:02:41 +08:00
}
params.cancelbtn.click();//显示/隐藏编辑区
});
2015-05-26 14:18:42 +08:00
if(params.type == 'reply'){
params.showbtn_child.click(function(){
if(params.textarea.data('init') == undefined){
params.showbtn.click();
}else{
params.cancelbtn.click();
if(params.about_talk.is(':hidden')){
params.cancelbtn.click();
}
}
var ref_str = params.get_ref_str_call($(this));
params.quote_show.html(ref_str);
params.quote_input.html(ref_str);
});
}
2015-05-23 16:02:41 +08:00
}
$(function(){
2015-05-26 14:18:42 +08:00
$(".talkmain_box").each(function(){
var target = $("li[nhname='reply_rec']",$(this));
var btn = $("a[nhname='reply_ex_btn']",$(this));
btn.click(function(){
if($(this).data('init')=='0'){
$(this).data('init',1);
$(this).html('收起回复('+$(this).data('count')+')');
target.show();
}else{
$(this).data('init',0);
$(this).html('展开回复('+$(this).data('count')+')');
target.hide();
target.eq(0).show();
target.eq(1).show();
}
});
});
2015-05-23 16:02:41 +08:00
KindEditor.ready(function(K){
$("div[nhname='container_board']").each(function(){
var container = $(this);
2015-05-23 16:35:57 +08:00
var about_talk = $("div[nhname='about_talk']",container);
2015-05-26 17:01:25 +08:00
var params = ({
2015-05-23 16:02:41 +08:00
kindutil:K,
showbtn:$("a[nhname='showbtn']",container),
2015-05-23 16:35:57 +08:00
about_talk:about_talk,
inputsubject:$("input[nhname='inputsubject']",about_talk),
subjectmsg:$("p[nhname='subjectmsg']",about_talk),
textarea:$("textarea[nhname='textarea']",about_talk),
contentmsg:$("p[nhname='contentmsg']",about_talk),
submitbtn:$("a[nhname='submitbtn']",about_talk),
cancelbtn:$("a[nhname='cancelbtn']",about_talk),
2015-05-26 15:01:11 +08:00
form:$("form[nhname='form']",about_talk),
2015-05-26 17:01:25 +08:00
toolbar_container:$("div[nhname='toolbar_container']",about_talk),
2015-05-26 15:01:11 +08:00
init_content_val:$("input[nhname='init_content_val']",about_talk)
2015-05-23 16:35:57 +08:00
});
2015-05-26 17:01:25 +08:00
nh_init_board(params);
2015-05-23 16:35:57 +08:00
});
2015-05-25 15:19:42 +08:00
$("div[mhname='container_board_reply']").each(function(){
2015-05-23 16:35:57 +08:00
var container = $(this);
var about_talk = $("div[nhname='about_talk_reply']",container);
2015-05-26 14:18:42 +08:00
var params = {
2015-05-25 15:19:42 +08:00
type:'reply',
2015-05-23 16:35:57 +08:00
kindutil:K,
showbtn:$("a[nhname='showbtn_reply']",container),
2015-05-26 14:18:42 +08:00
showbtn_child:$("a[nhname='showbtn_child_reply']",container),
2015-05-23 16:35:57 +08:00
about_talk:about_talk,
inputsubject:$("input[nhname='inputsubject']",about_talk),
subjectmsg:$("p[nhname='subjectmsg']",about_talk),
textarea:$("textarea[nhname='textarea']",about_talk),
contentmsg:$("p[nhname='contentmsg']",about_talk),
submitbtn:$("a[nhname='submitbtn']",about_talk),
cancelbtn:$("a[nhname='cancelbtn']",about_talk),
2015-05-26 14:18:42 +08:00
form:$("form[nhname='form']",about_talk),
quote_show:$("div[nhname='quote_show']",about_talk),
quote_input:$("textarea[nhname='quote_input']",about_talk),
2015-05-26 17:01:25 +08:00
toolbar_container:$("div[nhname='toolbar_container']",about_talk),
2015-05-26 14:18:42 +08:00
jumphref:$("#nhjump")
};
params.get_ref_str_call=function(btn){
var div = btn.parent('div');
var str = '<blockquote>'+$('a',div).filter(':first').html()+' 写到: <br/>'+$('p',div).filter(':first').html()+'</blockquote>';
return str;
}
nh_init_board(params);
2015-05-23 16:02:41 +08:00
});
});
});
</script>