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

197 lines
8.1 KiB
Plaintext
Raw Normal View History

<style type="text/css">
2015-06-16 12:01:06 +08:00
div.talk_new .ke-container{margin-left:2px;}
2015-05-29 14:31:37 +08:00
.break_word {width:100%;}
2015-05-27 14:42:36 +08:00
</style>
<script type="text/javascript">
//头部导航
var menuids=["TopUserNav"] //Enter id(s) of SuckerTree UL menus, separated by commas
function buildsubmenus(){
for (var i=0; i<menuids.length; i++){
2015-06-04 16:22:37 +08:00
var div = document.getElementById(menuids[i]);
if(div == undefined)continue;
var ultags=div.getElementsByTagName("ul");
for (var t=0; t<ultags.length; t++){
ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle";
ultags[t].parentNode.onmouseover=function(){
this.getElementsByTagName("ul")[0].style.display="block";
}
ultags[t].parentNode.onmouseout=function(){
this.getElementsByTagName("ul")[0].style.display="none";
}
}
}
}
if (window.addEventListener)
window.addEventListener("load", buildsubmenus, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus)
</script>
2015-12-06 15:03:36 +08:00
<%= content_for(:header_tags) do %>
2015-12-17 15:14:52 +08:00
<%= import_ke(enable_at: true, prettify: false) %>
2015-12-06 15:03:36 +08:00
<% end %>
2015-12-29 11:29:43 +08:00
<% if @project %>
2015-12-29 11:04:20 +08:00
<%= render :partial => 'project_show', locals: {:topics => @topics, :page => 0, project: @project} %>
2015-12-29 11:29:43 +08:00
<% elsif @course %>
<%= render :partial => 'course_show', :locals => {:topics => @topics, :page => 0, :course => @course} %>
<% end %>
2015-05-27 14:42:36 +08:00
<script type="text/javascript">//侧导航
2015-05-27 14:42:36 +08:00
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'});
}
2015-05-27 14:42:36 +08:00
params.subjectmsg.show();
}
2015-05-27 14:42:36 +08:00
if(params.content!=undefined){
2015-05-29 14:36:14 +08:00
if(params.content.isEmpty()){
2015-05-27 14:42:36 +08:00
result=false;
}
if(params.content.html()!=params.textarea.html() || params.issubmit==true){
2015-06-11 16:24:09 +08:00
params.textarea.html(params.content.html());
params.content.sync(); //用上面那句ie11提交到服务器居然木有值
2015-05-29 14:36:14 +08:00
if(params.content.isEmpty()){
2015-05-27 14:42:36 +08:00
params.contentmsg.html('内容不能为空');
params.contentmsg.css({color:'#ff0000'});
}else{
params.contentmsg.html('填写正确');
params.contentmsg.css({color:'#008000'});
}
params.contentmsg.show();
}
}
2015-05-27 14:42:36 +08:00
return result;
}
2015-05-27 14:42:36 +08:00
function nh_init_board(params){
//发帖/编辑/回复按钮的click
params.showbtn.click(function(){
params.textarea.removeAttr('placeholder');
2015-05-27 14:42:36 +08:00
if(params.textarea.data('init') == undefined){
//初始化编辑器
var editor = params.kindutil.create(params.textarea, {
// allowPreviewEmoticons : false,
// allowImageUpload : false,
autoHeightMode : true,
resizeType : 1,minWidth:"1px",width:"560px",height:"150px",
allowFileManager:true,uploadJson:"/kindeditor/upload",
fileManagerJson:"/kindeditor/filemanager",
2015-05-27 14:42:36 +08:00
afterChange:function(){//按键事件
nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
// var edit = this.edit;
// var body = edit.doc.body;
// edit.iframe.height(minHeight);
// this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 30, minHeight));
2015-05-27 14:42:36 +08:00
},
afterCreate:function(){
this.loadPlugin("autoheight");
2015-06-16 12:01:06 +08:00
var userAgent = navigator.userAgent.toLowerCase();
if(/trident/.test(userAgent)){
$("div.talk_new .ke-container").css({'margin-left':'0px'});
}
2015-12-17 15:14:52 +08:00
if(typeof enableAt === 'function'){
enableAt(this,params.about_talk.attr('data-at-id'), params.about_talk.attr('data-at-type'));
}
// var toolbar = $("div[class='ke-toolbar']",params.about_talk);
// $(".ke-outline>.ke-toolbar-icon",toolbar).append('表情');
// params.toolbar_container.append(toolbar);
2015-05-27 14:42:36 +08:00
}
}).loadPlugin('paste');
2015-05-27 14:42:36 +08:00
//主题输入框按键事件
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){
2015-05-28 10:12:43 +08:00
//return true 居然不提交 fuck your sister
$(this)[0].submit();
// return true;
2015-05-27 14:42:36 +08:00
}
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());
}
2015-05-28 17:14:52 +08:00
var str = params.textarea.html();
str=str.replace(new RegExp(/&lt;/g),'<');
str=str.replace(new RegExp(/&gt;/g),'>');
editor.html(str);
2015-05-27 14:42:36 +08:00
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'){
2015-06-12 10:52:15 +08:00
params.textarea.show();
params.textarea.focus();
params.textarea.hide();
//params.jumphref.attr('href','#'+params.form.attr('id'));
//params.jumphref[0].click();
2015-06-12 14:49:50 +08:00
}else{
params.textarea.show();
params.textarea.focus();
params.textarea.hide();
// params.inputsubject.focus();
}
2015-05-27 14:42:36 +08:00
}
});
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();
}
}
2015-06-04 15:55:41 +08:00
var parent_topic_id = $(this).data('topic-id');
if(parent_topic_id!=undefined)$("input[name='parent_topic']",params.form).val(parent_topic_id);
2015-05-27 14:42:36 +08:00
var ref_str = params.get_ref_str_call($(this));
params.quote_show.html(ref_str);
params.quote_input.html(ref_str);
});
}
}
2015-06-17 17:01:03 +08:00
</script>