...
This commit is contained in:
parent
dc557f7826
commit
94c7c68b7f
|
@ -1,9 +1,10 @@
|
|||
<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
||||
<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %>
|
||||
|
||||
<%= render :partial => 'form_course', :locals => {:f => f, :topic => @message} %>
|
||||
<li>
|
||||
<a href="javascript:void(0);" onclick="show_newtalk();" class="grey_btn fr ml10"><%= l(:button_cancel) %></a>
|
||||
<a href="javascript:void(0);" name="submitbtn" class="blue_btn fr " style="margin-left: 55px">
|
||||
<div class="ml55 fl" nhname="toolbar_container"></div>
|
||||
<a href="javascript:void(0);" nhname="cancelbtn" class="grey_btn fr ml10"><%= l(:button_cancel) %></a>
|
||||
<a href="javascript:void(0);" nhname="submitbtn" class="blue_btn fr " style="margin-left: 55px">
|
||||
<%= l(:button_submit)%>
|
||||
</a>
|
||||
<div class="cl"></div>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
|
||||
<!--display the board-->
|
||||
<div class="project_r_h">
|
||||
<div nhname="container_board">
|
||||
<div class="project_r_h">
|
||||
<h2 class="project_h2 fl">
|
||||
<% if User.current.language == "zh"%>
|
||||
<%= h @board.name %>
|
||||
|
@ -10,17 +8,20 @@
|
|||
<% end %>
|
||||
|
||||
</h2>
|
||||
<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 " nhname="showbtn"><%= l(:label_message_new) %></a>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<!-- 发布新帖部分 -->
|
||||
<div class="cl"></div>
|
||||
<div class=" talklist_box" >
|
||||
<div class="talk_new ml15 mb10" name="container_board" id="about_newtalk" style="display:<%= !@flag.nil? && @flag=='true' ? 'block' : 'none' %>;" >
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class=" talklist_box" >
|
||||
<div class="talk_new ml15 mb10" nhname="about_talk" id="about_newtalk" style="display:<%= !@flag.nil? && @flag=='true' ? 'block' : 'none' %>;" >
|
||||
<ul>
|
||||
<%= render :partial => 'course_new' %>
|
||||
</ul>
|
||||
</div><!--talknew end-->
|
||||
</div><!--talknew end-->
|
||||
</div>
|
||||
</div>
|
||||
<!-- 发布新帖部分 -->
|
||||
<div class=" talklist_box" >
|
||||
|
||||
<% if !User.current.logged?%>
|
||||
<div style="font-size: 14px;margin:20px;">
|
||||
|
@ -32,7 +33,7 @@
|
|||
<p class="c_dark mb5">讨论区共有<span class="c_orange"><%= @topic_count %></span>个帖子</p>
|
||||
<% if @topics.any? %>
|
||||
<% @topics.each do |topic| %>
|
||||
<div class="talkmain_box" style="border:none; margin-bottom:0; border-bottom: 1px dashed #d9d9d9;" id="topic<%= topic.id %>">
|
||||
<div class="talkmain_box" style="border:none; margin-bottom:0; border-bottom: 1px dashed #d9d9d9;" id="topic<%= topic.id %>" nhname="container_board" mhname="container_board_reply">
|
||||
<%= 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 + ":" %>
|
||||
|
@ -40,7 +41,7 @@
|
|||
|
||||
<p class="talkmain_tit fl fb break_word"> <%= h(topic.subject) %></p>
|
||||
<% 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:void(0)" nhname="showbtn" style="color: #426e9a;float: right;
|
||||
margin-right: 10px;"><%= l(:button_edit) %></a>
|
||||
<% end %>
|
||||
|
||||
|
@ -81,28 +82,31 @@
|
|||
<%= l(:label_activity_time)%>: <%= format_time topic.created_on %>
|
||||
|
||||
</div>
|
||||
<%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => 'message_content',:class => ' c_dblue fr' %>
|
||||
<a href="javascript:void(0)" nhname="showbtn_reply" class="c_dblue fr" style="margin-right:10px;"><%= l(:button_reply) %></a>
|
||||
|
||||
<div class="cl"></div>
|
||||
|
||||
|
||||
</div><!--讨论主类容 end-->
|
||||
<div class="talk_new ml15 mb10" id="about_newtalk<%=topic.id%>" style="display: none">
|
||||
<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">
|
||||
<% reply = Message.new(:subject => "RE: #{@message.subject}")%>
|
||||
<% if !topic.locked? && authorize_for('messages', 'reply') %>
|
||||
<em class="talkWrapArrow"></em>
|
||||
<div class="cl"></div>
|
||||
<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, :name=>'message-form'} do |f| %>
|
||||
<div class="talkConIpt ml15 mb10" style="display: none;margin-left:40px;" id="reply<%= topic.id %>" nhname="about_talk_reply">
|
||||
<%= 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} %>
|
||||
<%= toggle_link l(:button_cancel), "reply" + topic.id.to_s, :focus => 'message_content',:class => 'grey_btn fr ml10' %>
|
||||
<a href="javascript:void(0)" name="submitbtn" class="blue_btn fr " style=""><%= l(:label_memo_create)%></a>
|
||||
<div class="fl" style="padding-top:5px;" nhname="toolbar_container"></div>
|
||||
<div style="padding-top:5px;" class="fr">
|
||||
<a href="javascript:void(0)" nhname="cancelbtn" class="grey_btn fr ml10" style=""><%= l(:button_cancel)%></a>
|
||||
<a href="javascript:void(0)" nhname="submitbtn" class="blue_btn fr " style=""><%= l(:button_submit)%></a>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
@ -127,7 +131,7 @@
|
|||
<%= link_to_user_header message.author,false,:class => 'fl c_orange ' %>
|
||||
<br/>
|
||||
<p class="fl break_word"><%= textAreailizable message,:content,:attachments => message.attachments %></p>
|
||||
|
||||
<input nhname="nh_content_val" type="hidden" value="<%= message.content %>"/>
|
||||
<br/>
|
||||
<span class=" c_grey fl"><%= format_time(message.created_on) %></span>
|
||||
<%= link_to(
|
||||
|
@ -139,6 +143,13 @@
|
|||
: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>
|
||||
|
||||
|
@ -180,6 +191,9 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div><!--讨论主类容 end-->
|
||||
|
||||
<% end %>
|
||||
<% else %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
|
@ -197,58 +211,80 @@
|
|||
<%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@course}: #{@board}") %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div style="display:none;"><a href="#" id="nhjump"></a></div>
|
||||
<script type="text/javascript">
|
||||
//submitProjectsBoard()
|
||||
$(function(){
|
||||
$(".talkmain_box").each(function(){
|
||||
var target = $("li[nhname='reply_rec']",$(this));
|
||||
var btn = $("a[nhname='reply_ex_btn']",$(this));
|
||||
var jumpobj = $("div[nhname='nh_reply_div']",$(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();
|
||||
$("#nhjump").attr('href','#'+jumpobj.attr('id'));
|
||||
$("#nhjump")[0].click();
|
||||
}
|
||||
});
|
||||
});
|
||||
KindEditor.ready(function(K){
|
||||
$("div[name='container_board']").each(function(){
|
||||
var container=$(this);
|
||||
var messege = $("p[aa='message_show']",container);
|
||||
var subject = $("input[aa='subject']",container);
|
||||
var textarea= $("textarea[aa='content']",container);
|
||||
var form = $("form",container);
|
||||
var editor = K.create(textarea, {
|
||||
resizeType : 1,
|
||||
allowPreviewEmoticons : false,
|
||||
allowImageUpload : false,
|
||||
width:"89%",
|
||||
items : []
|
||||
$("div[nhname='container_board']").each(function(){
|
||||
var container = $(this);
|
||||
var about_talk = $("div[nhname='about_talk']",container);
|
||||
var params = ({
|
||||
kindutil:K,
|
||||
showbtn:$("a[nhname='showbtn']",container),
|
||||
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),
|
||||
form:$("form[nhname='form']",about_talk),
|
||||
toolbar_container:$("div[nhname='toolbar_container']",about_talk),
|
||||
init_content_val:$("input[nhname='init_content_val']",about_talk)
|
||||
});
|
||||
// form.submit(function(){
|
||||
// alert(textarea.html());
|
||||
// });
|
||||
// $("a[name='submitbtn']",container).click(function(){
|
||||
// form.submit();
|
||||
// });
|
||||
|
||||
$("a[name='submitbtn']",container).click(function(){
|
||||
textarea[0].value = editor.html() ;
|
||||
var id = textarea[0].id.toString().substr(15);
|
||||
|
||||
if(subject.val() == "RE: ") {
|
||||
|
||||
if (editor.html() == "") {
|
||||
messege.html("回复内容不能为空") ;
|
||||
messege.css('color', '#ff0000');
|
||||
messege.show();
|
||||
}
|
||||
else {
|
||||
messege.html("填写正确");
|
||||
messege.css('color', '#008000');
|
||||
messege.show();
|
||||
this.parentNode.submit();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(regexContent(id) && regexSubject(id)) {
|
||||
if (this.parentNode.name == 'message-form') {
|
||||
this.parentNode.submit();
|
||||
}
|
||||
else
|
||||
this.parentNode.parentNode.submit();
|
||||
}
|
||||
}
|
||||
nh_init_board(params);
|
||||
});
|
||||
|
||||
$("div[mhname='container_board_reply']").each(function(){
|
||||
var container = $(this);
|
||||
var about_talk = $("div[nhname='about_talk_reply']",container);
|
||||
var params = {
|
||||
type:'reply',
|
||||
kindutil:K,
|
||||
showbtn:$("a[nhname='showbtn_reply']",container),
|
||||
showbtn_child:$("a[nhname='showbtn_child_reply']",container),
|
||||
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),
|
||||
form:$("form[nhname='form']",about_talk),
|
||||
quote_show:$("div[nhname='quote_show']",about_talk),
|
||||
quote_input:$("textarea[nhname='quote_input']",about_talk),
|
||||
toolbar_container:$("div[nhname='toolbar_container']",about_talk),
|
||||
jumphref:$("#nhjump")
|
||||
};
|
||||
params.get_ref_str_call=function(btn){
|
||||
var div = btn.parent('div');
|
||||
var str = '<blockquote>'+$('a',div).filter(':first').html()+' 写到: <br/>'+$("input[nhname='nh_content_val']",div).val()+'</blockquote>';
|
||||
return str;
|
||||
}
|
||||
nh_init_board(params);
|
||||
});
|
||||
<% if(!@flag.nil? && @flag=='true') %>
|
||||
if($("#new_topic_btn")!=undefined)$("#new_topic_btn").click();
|
||||
<% end %>
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -5,19 +5,19 @@
|
|||
<li style="display: none">
|
||||
<label><span class="c_red">*</span> <%= l(:field_subject) %> :</label>
|
||||
|
||||
<%= f.text_field :subject, { size: 60, id: "message_subject",:class=>"talk_input w585", :aa=>"subject" }.merge(extra_option) %>
|
||||
<%= f.text_field :subject, { size: 60, id: "message_subject",:class=>"talk_input w585", :nhname=>'inputsubject' }.merge(extra_option) %>
|
||||
|
||||
|
||||
<p id="subject_span<%= f.object.id%>" class="ml55"></p>
|
||||
<p nhname="subjectmsg" class="ml55"></p>
|
||||
</li>
|
||||
<% else %>
|
||||
<li >
|
||||
<label><span class="c_red">*</span> <%= l(:field_subject) %> :</label>
|
||||
|
||||
|
||||
<%= f.text_field :subject, { size: 60, id: "message_subject#{f.object.id}", onkeyup: "regexSubject('#{f.object.id}');",:class=>"talk_input w585", :aa=>"subject" }.merge(extra_option) %>
|
||||
<%= f.text_field :subject, { size: 60, id: "message_subject#{f.object.id}", onkeyup: "regexSubject('#{f.object.id}');",:class=>"talk_input w585", :nhname=>'inputsubject' }.merge(extra_option) %>
|
||||
|
||||
<p id="subject_span<%= f.object.id%>" class="ml55"></p>
|
||||
<p nhname="subjectmsg" class="ml55"></p>
|
||||
</li>
|
||||
<% end %>
|
||||
<li class="ml60 mb5">
|
||||
|
@ -34,11 +34,11 @@
|
|||
<div class="cl"></div>
|
||||
</li>
|
||||
<li>
|
||||
<div id="message_quote" class="wiki" style="width: 100%;word-break: break-all;word-wrap: break-word;"></div>
|
||||
<div nhname="quote_show" id="message_quote" class="wiki" style="width: 100%;word-break: break-all;word-wrap: break-word;"></div>
|
||||
<% unless replying %>
|
||||
<label class="fl ml3" ><span class="c_red">*</span> <%= l(:field_description) %> :</label>
|
||||
<% end %>
|
||||
<%= text_area :quote,:quote,:style => 'display:none' %>
|
||||
<%= text_area :quote,:quote,:style => 'display:none',:nhname=>"quote_input" %>
|
||||
<div class="content">
|
||||
<% if replying%>
|
||||
|
||||
|
@ -46,13 +46,14 @@
|
|||
:width => '89%',
|
||||
:height => 300,
|
||||
:id => "message_content#{f.object.id}",
|
||||
:aa => 'content',
|
||||
:nhname => 'textarea',
|
||||
:onkeyup => "regexContent('#{f.object.id}');",
|
||||
:class => 'talk_text fl',
|
||||
:placeholder => "最多3000个汉字(或6000个英文字符)",
|
||||
:maxlength => 5000 %>
|
||||
|
||||
<% else %>
|
||||
<input nhname="init_content_val" value="<%=topic.content%>" type="hidden"/>
|
||||
<%= f.text_area :content,
|
||||
:width => '90%',
|
||||
:height => 300,
|
||||
|
@ -61,14 +62,14 @@
|
|||
:id => "message_content#{f.object.id}",
|
||||
:onkeyup => "regexContent('#{f.object.id}');",
|
||||
:class => 'talk_text fl',
|
||||
:aa => 'content',
|
||||
:nhname => 'textarea',
|
||||
:placeholder => "最多3000个汉字(或6000个英文字符)",
|
||||
:maxlength => 5000 %>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<p id="message_content_span<%= f.object.id%>" aa="message_show" class="ml55"></p>
|
||||
<p id="message_content_span<%= f.object.id%>" nhname="contentmsg" class="ml55"></p>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li>
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
<%= 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} %>
|
||||
<div class="fl" nhname="toolbar_container"></div>
|
||||
<div class="fl" style="padding-top:5px;" nhname="toolbar_container"></div>
|
||||
<div style="padding-top:5px;" class="fr">
|
||||
<a href="javascript:void(0)" nhname="cancelbtn" class="grey_btn fr ml10" style=""><%= l(:button_cancel)%></a>
|
||||
<a href="javascript:void(0)" nhname="submitbtn" class="blue_btn fr " style=""><%= l(:button_submit)%></a>
|
||||
|
@ -115,6 +115,7 @@
|
|||
<%= link_to_user_header message.author,false,:class => 'fl c_orange ' %>
|
||||
<br/>
|
||||
<p class="fl break_word"><%= textAreailizable message,:content,:attachments => message.attachments %></p>
|
||||
<input nhname="nh_content_val" type="hidden" value="<%= message.content %>"/>
|
||||
<br/>
|
||||
<span class=" c_grey fl"><%= format_time(message.created_on) %></span>
|
||||
<%= link_to(
|
||||
|
@ -165,131 +166,7 @@
|
|||
</div>
|
||||
<div style="display:none;"><a href="#" id="nhjump"></a></div>
|
||||
|
||||
<style>
|
||||
.ke-toolbar{display:none;width:400px;border:none;background:none;}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
function nh_check_field(params){
|
||||
var result=true;
|
||||
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();
|
||||
}
|
||||
|
||||
if(params.content!=undefined){
|
||||
if($.trim(params.content.html()) == ""){
|
||||
result=false;
|
||||
}
|
||||
if(params.content.html()!=params.textarea.html() || params.issubmit==true){
|
||||
params.textarea.html(params.content.html());
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
function nh_init_board(params){
|
||||
//发帖/编辑/回复按钮的click
|
||||
params.showbtn.click(function(){
|
||||
if(params.textarea.data('init') == undefined){
|
||||
//初始化编辑器
|
||||
var editor = params.kindutil.create(params.textarea, {
|
||||
resizeType : 1,
|
||||
allowPreviewEmoticons : false,
|
||||
allowImageUpload : false,
|
||||
minWidth:"1px",
|
||||
width:"565px",
|
||||
items : ['emoticons'],
|
||||
afterChange:function(){//按键事件
|
||||
nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
|
||||
},
|
||||
afterCreate:function(){
|
||||
var toolbar = $("div[class='ke-toolbar']",params.about_talk);
|
||||
params.toolbar_container.append(toolbar);
|
||||
}
|
||||
});
|
||||
|
||||
//主题输入框按键事件
|
||||
params.inputsubject.keyup(function(){
|
||||
nh_check_field({subject:params.inputsubject,subjectmsg:params.subjectmsg});
|
||||
})
|
||||
//表单提交
|
||||
params.form.submit(function(){
|
||||
var is_checked = nh_check_field({
|
||||
issubmit:true,
|
||||
subject:params.inputsubject,
|
||||
subjectmsg:params.subjectmsg,
|
||||
content:editor,
|
||||
contentmsg:params.contentmsg,
|
||||
textarea:params.textarea
|
||||
});
|
||||
if(is_checked){
|
||||
// alert('submit');
|
||||
// return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
//提交按钮click
|
||||
params.submitbtn.click(function(){
|
||||
params.form.submit();
|
||||
});
|
||||
//取消按钮click
|
||||
params.cancelbtn.click(function(){
|
||||
params.about_talk.toggle();//显示/隐藏编辑区
|
||||
if(params.about_talk.is(':hidden')){//隐藏时reset表单数据
|
||||
params.form[0].reset();
|
||||
if(params.type=='reply'){
|
||||
params.textarea.empty();
|
||||
}else{
|
||||
params.textarea.html(params.init_content_val.val());
|
||||
}
|
||||
editor.html(params.textarea.html());
|
||||
params.subjectmsg.hide();
|
||||
params.contentmsg.hide();
|
||||
params.quote_show.empty();
|
||||
params.quote_input.empty();
|
||||
}else{
|
||||
if(params.type=='reply'){
|
||||
params.jumphref.attr('href','#'+params.form.attr('id'));
|
||||
params.jumphref[0].click();
|
||||
}else params.inputsubject.focus();
|
||||
}
|
||||
});
|
||||
params.textarea.data('init','1');//标记为已经初始化
|
||||
}
|
||||
params.cancelbtn.click();//显示/隐藏编辑区
|
||||
});
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
$(function(){
|
||||
$(".talkmain_box").each(function(){
|
||||
var target = $("li[nhname='reply_rec']",$(this));
|
||||
|
@ -354,7 +231,7 @@
|
|||
};
|
||||
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>';
|
||||
var str = '<blockquote>'+$('a',div).filter(':first').html()+' 写到: <br/>'+$("input[nhname='nh_content_val']",div).val()+'</blockquote>';
|
||||
return str;
|
||||
}
|
||||
nh_init_board(params);
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<style>
|
||||
.ke-toolbar{display:none;width:400px;border:none;background:none;}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
//头部导航
|
||||
var menuids=["TopUserNav"] //Enter id(s) of SuckerTree UL menus, separated by commas
|
||||
|
@ -20,52 +23,6 @@
|
|||
window.addEventListener("load", buildsubmenus, false)
|
||||
else if (window.attachEvent)
|
||||
window.attachEvent("onload", buildsubmenus)
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">//侧导航
|
||||
|
||||
window.onload = function () {
|
||||
var topic_id = getParam('topic_id');
|
||||
document.getElementById(topic_id).focus();
|
||||
}
|
||||
|
||||
var getParam = function(name){
|
||||
var search = document.location.search;
|
||||
var pattern = new RegExp("[?&]"+name+"\=([^&]+)", "g");
|
||||
var matcher = pattern.exec(search);
|
||||
var items = null;
|
||||
if(null != matcher){
|
||||
try{
|
||||
items = decodeURIComponent(decodeURIComponent(matcher[1]));
|
||||
}catch(e){
|
||||
try{
|
||||
items = decodeURIComponent(matcher[1]);
|
||||
}catch(e){
|
||||
items = matcher[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return items;
|
||||
};
|
||||
|
||||
function show_newtalk()
|
||||
{
|
||||
$("#about_newtalk").toggle();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function show_newtalk1(id)
|
||||
{
|
||||
$(id).toggle();
|
||||
$(id).focus();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<% if @project %>
|
||||
|
@ -73,3 +30,171 @@ function show_newtalk1(id)
|
|||
<% elsif @course %>
|
||||
<%= render :partial => 'course_show', locals: {course: @course} %>
|
||||
<% end %>
|
||||
|
||||
|
||||
<script type="text/javascript">//侧导航
|
||||
|
||||
//window.onload = function () {
|
||||
// var topic_id = getParam('topic_id');
|
||||
// document.getElementById(topic_id).focus();
|
||||
//}
|
||||
//
|
||||
//var getParam = function(name){
|
||||
// var search = document.location.search;
|
||||
// var pattern = new RegExp("[?&]"+name+"\=([^&]+)", "g");
|
||||
// var matcher = pattern.exec(search);
|
||||
// var items = null;
|
||||
// if(null != matcher){
|
||||
// try{
|
||||
// items = decodeURIComponent(decodeURIComponent(matcher[1]));
|
||||
// }catch(e){
|
||||
// try{
|
||||
// items = decodeURIComponent(matcher[1]);
|
||||
// }catch(e){
|
||||
// items = matcher[1];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return items;
|
||||
//};
|
||||
//
|
||||
//function show_newtalk()
|
||||
//{
|
||||
// $("#about_newtalk").toggle();
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
//
|
||||
//function show_newtalk1(id)
|
||||
//{
|
||||
// $(id).toggle();
|
||||
// $(id).focus();
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
function nh_check_field(params){
|
||||
var result=true;
|
||||
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();
|
||||
}
|
||||
|
||||
if(params.content!=undefined){
|
||||
if($.trim(params.content.html()) == ""){
|
||||
result=false;
|
||||
}
|
||||
if(params.content.html()!=params.textarea.html() || params.issubmit==true){
|
||||
params.textarea.html(params.content.html());
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
function nh_init_board(params){
|
||||
//发帖/编辑/回复按钮的click
|
||||
params.showbtn.click(function(){
|
||||
if(params.textarea.data('init') == undefined){
|
||||
//初始化编辑器
|
||||
var editor = params.kindutil.create(params.textarea, {
|
||||
resizeType : 1,
|
||||
allowPreviewEmoticons : false,
|
||||
allowImageUpload : false,
|
||||
minWidth:"1px",
|
||||
width:"565px",
|
||||
items : ['emoticons'],
|
||||
afterChange:function(){//按键事件
|
||||
nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
|
||||
},
|
||||
afterCreate:function(){
|
||||
var toolbar = $("div[class='ke-toolbar']",params.about_talk);
|
||||
params.toolbar_container.append(toolbar);
|
||||
}
|
||||
});
|
||||
|
||||
//主题输入框按键事件
|
||||
params.inputsubject.keyup(function(){
|
||||
nh_check_field({subject:params.inputsubject,subjectmsg:params.subjectmsg});
|
||||
})
|
||||
//表单提交
|
||||
params.form.submit(function(){
|
||||
var is_checked = nh_check_field({
|
||||
issubmit:true,
|
||||
subject:params.inputsubject,
|
||||
subjectmsg:params.subjectmsg,
|
||||
content:editor,
|
||||
contentmsg:params.contentmsg,
|
||||
textarea:params.textarea
|
||||
});
|
||||
if(is_checked){
|
||||
alert('submit');
|
||||
return false;
|
||||
// return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
//提交按钮click
|
||||
params.submitbtn.click(function(){
|
||||
params.form.submit();
|
||||
});
|
||||
//取消按钮click
|
||||
params.cancelbtn.click(function(){
|
||||
params.about_talk.toggle();//显示/隐藏编辑区
|
||||
if(params.about_talk.is(':hidden')){//隐藏时reset表单数据
|
||||
params.form[0].reset();
|
||||
if(params.type=='reply'){
|
||||
params.textarea.empty();
|
||||
}else{
|
||||
params.textarea.html(params.init_content_val.val());
|
||||
}
|
||||
editor.html(params.textarea.html());
|
||||
params.subjectmsg.hide();
|
||||
params.contentmsg.hide();
|
||||
if(params.quote_show!=undefined)params.quote_show.empty();
|
||||
if(params.quote_input!=undefined)params.quote_input.empty();
|
||||
}else{
|
||||
if(params.type=='reply'){
|
||||
params.jumphref.attr('href','#'+params.form.attr('id'));
|
||||
params.jumphref[0].click();
|
||||
}else params.inputsubject.focus();
|
||||
}
|
||||
});
|
||||
params.textarea.data('init','1');//标记为已经初始化
|
||||
}
|
||||
params.cancelbtn.click();//显示/隐藏编辑区
|
||||
});
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</script>
|
Loading…
Reference in New Issue