更改贴吧描述
This commit is contained in:
parent
44acf1a383
commit
f332307cae
|
@ -271,6 +271,19 @@ class ForumsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 更新贴吧描述
|
||||
def update_memo_description
|
||||
@forum = Forum.find(params[:id])
|
||||
if @forum.blank?
|
||||
result = { :result => false }
|
||||
else
|
||||
forum_decription = params[:forum][:description]
|
||||
@forum.update_attributes(:description => forum_decription )
|
||||
result = { :result => true }
|
||||
end
|
||||
render :json => result
|
||||
end
|
||||
|
||||
def search_forum
|
||||
# @forums = paginateHelper Forum.where("name LIKE '%#{params[:name]}%'")
|
||||
q = "%#{params[:name].strip}%"
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
</div>
|
||||
<div class="fl" style="width: 120px;">
|
||||
<% user_name = @forum.creator.show_name.empty? ? @forum.creator.name : @forum.creator.show_name %>
|
||||
<div class="fl mb8 mt10">吧主:</div><a href="<%= user_path(@forum.creator)%>" class="linkBlue w80 fl mb8 mt10" style="overflow: hidden;white-space: nowrap;text-overflow:ellipsis; "><%= user_name %></a>
|
||||
<div class="fl mb8 mt10">吧主:</div>
|
||||
<a href="<%= user_path(@forum.creator)%>" target="_blank" class="linkBlue w80 fl mb8 mt10" style="overflow: hidden;white-space: nowrap;text-overflow:ellipsis; "><%= user_name %></a>
|
||||
<div class="fontGrey3 fl">回答:<a href="javascript:void(0);" class="linkOrange mr5" style="cursor: default"><%= @my_replies_count %></a> 帖子:<a href="javascript:void(0);" class="linkOrange" style="cursor: default"><%= @my_topic_count %></a></div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
@ -13,8 +14,9 @@
|
|||
<%= link_to @forum.name, forum_path(@forum), :class => "f16 fontBlue", :style => "word-break: break-all; word-wrap:break-word;white-space:pre-wrap;" %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="fontGrey2 mt10"><span id="forum_desc_span" style="word-break:normal; width:auto; display:block; white-space:pre-wrap;word-wrap : break-word ;overflow: hidden ;"><%= @forum.description.html_safe%></span>
|
||||
<%if @forum.creator.id == User.current.id%>
|
||||
<div class="fontGrey2 mt10">
|
||||
<span id="forum_desc_span" style="word-break:normal; width:auto; display:block; white-space:pre-wrap;word-wrap : break-word ;overflow: hidden ;"><%= h @forum.description.html_safe%></span>
|
||||
<% if @forum.creator.id == User.current.id %>
|
||||
<a href="javascript:void(0);" onclick="edit_desc();">
|
||||
<%= image_tag('signature_edit.png',{:width => 12,:height => 12}) %>
|
||||
</a>
|
||||
|
@ -49,23 +51,22 @@
|
|||
<script>
|
||||
var desc;
|
||||
function edit_desc(){
|
||||
if(<%= @forum.creator.id == User.current.id %>) {
|
||||
desc = $("#forum_desc_span").html();
|
||||
$("#forum_desc_span").html("<textarea id='forum_desc_input' onblur='change_forum_desc();' style='width: 200px;height: 80px; max-width: 207px; max-height: 80px; border: 1px solid #d9d9d9;outline: none;margin: 0px 0px 12px 0px;'>" + desc + "</textarea>");
|
||||
$("#forum_desc_input").focus();
|
||||
}
|
||||
}
|
||||
|
||||
function change_forum_desc(){
|
||||
$.ajax({
|
||||
url: '<%= forums_path + '/'+@forum.id.to_s+".js" %>',
|
||||
type: 'PUT',
|
||||
dataType: 'json',
|
||||
url: '<%= update_memo_description_forum_path(@forum) %>',
|
||||
type: 'post',
|
||||
data:{"forum[description]":$("#forum_desc_input").val().trim()},
|
||||
success:function(data){
|
||||
if(data == true){
|
||||
if(data.result == true){
|
||||
$("#forum_desc_input").hide();
|
||||
$("#forum_desc_span").html($("#forum_desc_input").val().trim());
|
||||
}else{
|
||||
alert("失败");
|
||||
$("#forum_desc_span").html(desc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -457,6 +457,7 @@ RedmineApp::Application.routes.draw do
|
|||
member do
|
||||
post 'create_memo'
|
||||
post 'create_feedback'
|
||||
post 'update_memo_description'
|
||||
match 'search_memo', :via => [:get, :post]
|
||||
match 'delete_forum_tag',:via =>[:get]
|
||||
match 'add_forum_tag',:via=>[:get]
|
||||
|
|
Loading…
Reference in New Issue