问吧编辑

This commit is contained in:
huang 2016-12-30 11:30:40 +08:00
parent 6c86f655fd
commit 11135bfabf
9 changed files with 146 additions and 17 deletions

View File

@ -203,6 +203,10 @@ class ForumsController < ApplicationController
# GET /forums/1/edit
def edit
@forum = Forum.find(params[:id])
respond_to do |format|
format.html
format.js
end
end
# POST /forums

View File

@ -85,7 +85,6 @@ class MemosController < ApplicationController
REPLIES_PER_PAGE = 20 unless const_defined?(:REPLIES_PER_PAGE)
def show
# 更新贴吧帖子留言对应的memo_messages的viewed字段
unless @memo.children.blank?
@memo.children.each do |child|

View File

@ -0,0 +1,55 @@
<div style="width:460px;">
<div class="sy_popup_top">
<h3 class="fl">新建贴吧</h3>
<a href="javascript:void(0);" class="sy_icons_close fr" onclick="hideModal()"></a>
<div class="cl"></div>
</div>
<div class="muban_popup_con mt15" >
<%= labelled_form_for @forum, :html => {:id => "forum_new"} do |f| %>
<%= render :partial => "forums/form" %>
<% end %>
<%#= form_tag({:controller => 'forums', :action => 'create'}, :method => 'post', :id => "forum_new") do |f| %>
<%# end %>
</div>
</div>
<script>
function forums_commit(){
$("#forum_name_error_tips").hide();
$("#forum_description_error_tips").hide();
if ($("#forum_name").val().trim() == ""){
$("#forum_name_error_tips").html("贴吧名称不能为空").show();
}
else if($("#forum_desc").val().trim() == ""){
$("#forum_description_error_tips").html("贴吧描述不能为空").show();
}
else if($("#forum_desc").val().length > 5000){
$("#forum_description_error_tips").html("贴吧描述不能超过5000个字符").show();
}
else{
$.ajax({
url:'<%= check_forum_name_forums_path %>',
type:'get',
data:{
forum_name:$("#forum_name").val().trim()
},
success:function(data){
if(data.result == true){
alert("提交成功");
$("#forum_new").submit();
hideModal();
return true;
}else{
alert("提交失败");
$("#forum_name_error_tips").html("贴吧名称已存在").show();
return false;
}
},
error:function(){
alert('请检查当前网络连接')
}
});
}
}
</script>

View File

@ -0,0 +1,61 @@
<ul class="newuploadbox">
<li class="mb10 clear">
<label class="fl" style="width: 90px;text-align: right;">贴吧名称&nbsp;&nbsp;:&nbsp;</label>
<!--<input maxlength="80" class="postCreateInput" onfocus="hideError();" onblur="check_forum_name();" placeholder="输入贴吧名称" >-->
<input type="text" name="forum[name]" value="<%= @forum.name %>" id="forum_name" onfocus="$('#forum_name_error_tips').hide();" placeholder="请输入贴吧名称最多50个字符" class="issues_calendar_input fl" style="width:320px;height:28px;">
<div class="clear"></div>
<p class="c_red ml90" style="display: none" id="forum_name_error_tips"></p>
</li>
<li class=" clear">
<label class="fl" style="width: 90px;text-align: right;">贴吧描述&nbsp;&nbsp;:&nbsp;</label>
<textarea type="text" name="forum[description]" id="forum_desc" maxlength="5000" class="mr15 mb10 fl newupload_textarea" style="width:320px; height:100px;" placeholder="请输入新建贴吧描述最多5000个字符" onfocus="$('#forum_description_error_tips').hide();"><%= @forum.description.html_safe %></textarea>
<!--<textarea class="mr15 mb10 fl newupload_textarea " placeholder=" 请输入新建贴吧描述最多250个字符" style="width:320px; height:100px;"></textarea>-->
<div class="clear"></div>
<p class="c_red ml90" style="display: none" id="forum_description_error_tips"></p>
</li>
</ul>
<div class="clear mr45 mb10">
<a href="javascript:void(0);" class="btn fr" onclick="hideModal()" >取消</a>
<a href="javascript:void(0);" class="btn btn-blue fr mr5" onclick="forums_commit();">确定</a>
</div>
<script>
function forums_commit(){
$("#forum_name_error_tips").hide();
$("#forum_description_error_tips").hide();
if ($("#forum_name").val().trim() == ""){
$("#forum_name_error_tips").html("贴吧名称不能为空").show();
}
else if($("#forum_desc").val().trim() == ""){
$("#forum_description_error_tips").html("贴吧描述不能为空").show();
}
else if($("#forum_desc").val().length > 5000){
$("#forum_description_error_tips").html("贴吧描述不能超过5000个字符").show();
}
else{
$.ajax({
url:'<%= check_forum_name_forums_path %>',
type:'get',
data:{
forum_name:$("#forum_name").val().trim()
},
success:function(data){
if(data.result == true){
alert("提交成功");
$("#forum_new").submit();
hideModal();
return true;
}else{
alert("提交失败");
$("#forum_name_error_tips").html("贴吧名称已存在").show();
return false;
}
},
error:function(){
alert('请检查当前网络连接')
}
});
}
}
</script>

View File

@ -0,0 +1,5 @@
var htmlvalue = "<%= escape_javascript(render :partial => 'forums/edit') %>";
pop_box_new(htmlvalue,460,190);

View File

@ -21,16 +21,20 @@
</div>
</div>
<%= render :partial => "memos/my_count_message" %>
<div class="fl">
<%= render :partial => "memos/my_count_message" %>
<div class="homepageLeft-new" id="forum_right_bar">
<div class="wenba-rightbar">
<div class="wenba-rightbar-top clearfix">
<h3 class="fl ml10">推荐问吧</h3>
<div class="homepageLeft-new" id="forum_right_bar">
<div class="wenba-rightbar">
<div class="wenba-rightbar-top clearfix">
<h3 class="fl ml10">推荐问吧</h3>
</div>
<%= render :partial => "forums/right_bar" %>
</div>
<%= render :partial => "forums/right_bar" %>
</div>
</div>
<script>
function add_class(id){
if($("#"+id).hasClass("sortArrowActiveD")){

View File

@ -30,17 +30,16 @@
</span></div>
<div class="cl"></div>
<% if @forum.creator.id == User.current.id %>
<span class="postEdit">
</span>
<a href="<%= edit_forum_path(@forum) %>" class="linkGrey3">编辑贴吧</a>
<span class="postEdit"></span>
<%= link_to "编辑贴吧", edit_forum_path(@forum), :class => "linkGrey3", :remote => true %>
<a href="javascript:void(0);" data-method="delete" onclick="del_forum_confirm();" class="fr linkGrey3">删除贴吧</a>
<a href="<%= forum_path(@forum) %>" data-method="delete" id="del_link" type="hidden"></a>
<span class="postDelete"></span>
<% end %>
</div>
<div class="f1">
<%= link_to "<span class='btn-big-blue mt10'>我要提问</span>".html_safe, new_forum_memo_path(:forum_id => @forum) %>
</div>
<% unless params[:controller] == "forums" %>
<div class="f1">
<%= link_to "<span class='btn-big-blue mt10'>我要提问</span>".html_safe, new_forum_memo_path(:forum_id => @forum) %>
</div>
<% end %>
</div>

View File

@ -99,8 +99,10 @@
</div>
</div>
</div>
<div class="fl">
<%= render :partial => "memos/my_count_message" %>
</div>
<%= render :partial => "memos/my_count_message" %>
<script type="text/javascript">

View File

@ -304,7 +304,7 @@ a:hover.qx_btn{color:#64bdd9;}
/*.navHomepageProfile ul li ul {display:none;}
.navHomepageProfile ul li:hover ul {display:block;}*/
.homepageLeft {width:240px; float:left; margin-right:10px; margin-bottom:10px;}
.homepageLeft-new {width:240px; float:left; margin-bottom:10px;}
.homepageLeft-new {width:240px; margin-bottom:10px;}
.homepageRight {width:750px; float:left; margin-top:10px; margin-bottom:10px;}
.homepagePortraitContainer {width:208px; border:1px solid #dddddd; background-color:#ffffff; margin-top:10px; padding:15px;}
.homepagePortraitImage {width:78px; height:78px; position:relative; border:1px solid #cbcbcb; padding: 2px;}