论坛编辑功能
This commit is contained in:
parent
eed530db2b
commit
6ac5b738e3
|
@ -1,49 +1,26 @@
|
|||
<!-- added by fq -->
|
||||
<!-- %= form_for(@forum) do |f| % -->
|
||||
|
||||
<div id="share_new" style = "width: 500px; margin:0 auto; " >
|
||||
<%= labelled_form_for(@forum) do |f| %>
|
||||
<% if @forum.errors.any? %>
|
||||
<!--<div id="error_explanation">
|
||||
<h2><#%= pluralize(@forum.errors.count, "error") %> prohibited this forum from being saved:</h2>
|
||||
<div class="homepageContentContainer mb10">
|
||||
<div class="homepageContent">
|
||||
<div class="pageBanner mt15"><div class="NewsBannerName">编辑贴吧</div></div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<ul>
|
||||
<#% @forum.errors.full_messages.each do |msg| %>
|
||||
<li><#%= msg %></li>
|
||||
<#% end %>
|
||||
</ul>
|
||||
</div> -->
|
||||
<% end %>
|
||||
<div style="width: 120%;">
|
||||
<div class="field">
|
||||
<%= f.text_field :name, :required => true, :style => 'width: 100%;', :class => 'create-share', :maxlength => 50%>
|
||||
</div>
|
||||
<div>
|
||||
<% if User.current.logged? && User.current.admin? %>
|
||||
<% if @forum.safe_attribute? 'sticky' %>
|
||||
<%= f.check_box :sticky %>
|
||||
<%= label_tag 'message_sticky', l(:label_board_sticky) %>
|
||||
<% end %>
|
||||
<% if @forum.safe_attribute? 'locked' %>
|
||||
<%= f.check_box :locked %>
|
||||
<%= label_tag 'message_locked', l(:label_board_locked) %>
|
||||
<% end %>
|
||||
<div class="postContainer">
|
||||
<%= labelled_form_for(@forum) do |f| %>
|
||||
<div id="error" style="display: none;color: red;">
|
||||
</div>
|
||||
<div>
|
||||
<textarea type="text" id="forum_name" name="forum[name]" class="postCreateInput" placeholder="对应贴吧名称" ><%= @forum.name.html_safe%></textarea>
|
||||
</div>
|
||||
<div class="mt15">
|
||||
<textarea type="text" id="forum_desc" name="forum[description]" class="postCreateInput" placeholder="对应贴吧描述" ><%= @forum.description.html_safe%></textarea>
|
||||
</div>
|
||||
<div class="mt10">
|
||||
<div class="fr"><a href="javascript:void(0);" class="submit_btn" onclick="check_and_submit($(this));">确定</a></div>
|
||||
<div class="fr"><a href="<%= forum_path(@forum)%>" class="linkGrey2 mr10" >取消</a><span class="mr10 fontGrey">或</span></div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div>
|
||||
<p style="max-width:680px">
|
||||
<%= f.kindeditor :description, :required => true,:owner_id => @forum.id,:owner_type => 2 %>
|
||||
</p>
|
||||
<!-- <script type="text/javascript">var ckeditor=CKEDITOR.replace('editor01');</script> -->
|
||||
|
||||
<p style="color: #ff0000">
|
||||
(<%= l(:label_forums_max_length) %>)
|
||||
</p>
|
||||
</div>
|
||||
<div class="actions" style=" padding-top: 10px; float:right">
|
||||
<%= submit_tag l(:button_submit) %>
|
||||
<%= link_to l(:button_back), forums_path ,:style => 'font-size: 14px; padding: 0px 3px;' %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
|
@ -1,4 +1,72 @@
|
|||
<!-- added by fq -->
|
||||
<h1>编辑讨论区</h1>
|
||||
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
|
||||
|
||||
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' ,'new_user' %>
|
||||
<script>
|
||||
$(function(){
|
||||
document.getElementById('forum_name').onkeydown = function()
|
||||
{
|
||||
var n = 0;
|
||||
var str = this.value;
|
||||
for (i = 0; i < str.length; i++) {
|
||||
var leg = str.charCodeAt(i);//ASCII码
|
||||
if (leg > 255) {
|
||||
n += 2;
|
||||
} else {
|
||||
n += 1;
|
||||
}
|
||||
}
|
||||
if(n >= 160)
|
||||
event.returnValue = false;
|
||||
}
|
||||
})
|
||||
|
||||
function check_and_submit(doc){
|
||||
$("#error").html('').hide();
|
||||
check_forum_name();
|
||||
if(check_pass == false){
|
||||
return;
|
||||
}
|
||||
if( $("textarea[name='forum[name]']").val().trim() == "" && $("textarea[name='forum[description]']").val().trim() != "" ){
|
||||
$("#error").html("名称不能为空").show();
|
||||
return;
|
||||
} else if( $("textarea[name='forum[description]']").val().trim() == "" && $("textarea[name='forum[name]']").val().trim() != "" ){
|
||||
$("#error").html("描述不能为空").show();
|
||||
return;
|
||||
}else if($("textarea[name='forum[description]']").val().trim() == "" && $("textarea[name='forum[name]']").val().trim() == ""){
|
||||
$("#error").html("名称和描述不能为空").show();
|
||||
return;
|
||||
}
|
||||
else{
|
||||
doc.parent().parent().parent().submit();
|
||||
}
|
||||
}
|
||||
var check_pass = true;
|
||||
function check_forum_name(){
|
||||
check_pass = true;
|
||||
name = $("textarea[name='forum[name]']").val().trim();
|
||||
if(name == '<%= @forum.name%>'){
|
||||
return;
|
||||
}
|
||||
if( name != ""){
|
||||
$.get(
|
||||
'<%= check_forum_name_forums_path %>',
|
||||
{"forum_name":name},
|
||||
function(data){
|
||||
|
||||
if( data == 'true'){
|
||||
$("#error").html("贴吧名称已经存在").show();
|
||||
check_pass = false;
|
||||
}
|
||||
}
|
||||
);
|
||||
}else{
|
||||
check_pass = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<%= render 'form_edit_mode' %>
|
||||
<script>
|
||||
var textarea = document.getElementById('forum_name');
|
||||
autoTextarea(textarea);
|
||||
var textarea1 = document.getElementById('forum_desc');
|
||||
autoTextarea(textarea1);
|
||||
</script>
|
|
@ -143,7 +143,7 @@
|
|||
<!--<div class="homepageEditProfile"><a href="javascript:void(0);" class="homepageEditProfileIcon"></a></div>-->
|
||||
</div>
|
||||
<div class="fl">
|
||||
<div class="f16 fontBlue mb10"><a href="<%= forums_path+"/"+@forum.id.to_s%>"><%= @forum.name%></a></div>
|
||||
<div class="f16 fontBlue mb10"><a href="<%= forums_path+"/"+@forum.id.to_s%>" style="word-break: break-all; word-wrap:break-word;"><%= @forum.name%></a></div>
|
||||
<div class="fontGrey2 mb8">吧主:<a href="<%= user_path(@forum.creator)%>" class="linkBlue"><%= @forum.creator.name%></a></div>
|
||||
<div class="fontGrey3">回答:<a href="javascript:void(0);" class="linkOrange mr5"><%= @forum.memo_count %></a> 帖子:<a href="javascript:void(0);" class="linkOrange"><%=@forum.topic_count%></a></div>
|
||||
</div>
|
||||
|
@ -171,7 +171,7 @@
|
|||
<div class="cl"></div>
|
||||
<span class="postEdit">
|
||||
</span>
|
||||
<a href="javascript:void(0);" class="linkGrey3">编辑贴吧</a>
|
||||
<a href="<%= edit_forum_path(@forum) %>" class="linkGrey3">编辑贴吧</a>
|
||||
<a href="javascript:void(0);" class="fr linkGrey3">删除贴吧</a>
|
||||
<span class="postDelete"></span>
|
||||
<% end %>
|
||||
|
|
|
@ -723,7 +723,7 @@ a.sortArrowActiveU {background:url(images/post_image_list.png) -17px -20px no-re
|
|||
.postRow {width:970px; border-bottom:1px solid #efefef; padding:15px 0;}
|
||||
.postPortrait {width:75px; height:75px; float:left; margin-right:15px;}
|
||||
.postWrap {width:690px; float:left; margin-right:95px;}
|
||||
.postTitle {width:690px; max-width:690px; margin-bottom:5px;}
|
||||
.postTitle {width:690px; max-width:690px; margin-bottom:5px;word-break: break-all; word-wrap:break-word; }
|
||||
.postDes {width:690px; max-width:690px; margin-bottom:6px; color:#484848;}
|
||||
.postCreater {color:#888888; font-size:12px; float:left; margin-right:40px;}
|
||||
.postDate {color:#888888; font-size:12px;}
|
||||
|
@ -761,6 +761,7 @@ a.AnnexBtn{ background: url(images/homepage_icon2.png) 0px -343px no-repeat !im
|
|||
a:hover.AnnexBtn{background: url(images/homepage_icon2.png) -90px -343px no-repeat !important; color:#3598db;}
|
||||
.postEdit {background:url(images/post_image_list.png) 0px -94px no-repeat; width:18px; height:18px; display:block; float:left;}
|
||||
.postDelete {background:url(images/post_image_list.png) -42px -93px no-repeat; width:18px; height:18px; display:block; float:right;}
|
||||
.pageBanner {width:968px; margin:0px auto; border:1px solid #dddddd; background-color: #FFF; padding: 10px 15px; float:left;}
|
||||
/*底部*/
|
||||
#Footer{background-color:#ffffff; padding-bottom:15px; color:#666666;} /*margin-bottom:10px;*/
|
||||
.footerAboutContainer {width:auto; border-bottom:1px solid #efefef;}
|
||||
|
|
Loading…
Reference in New Issue