编辑个人简介

This commit is contained in:
sw 2015-08-21 16:29:25 +08:00
parent d942cc3123
commit 2a522f144e
7 changed files with 48 additions and 18 deletions

View File

@ -48,7 +48,7 @@ class UsersController < ApplicationController
:watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages]
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction]
before_filter :auth_user_extension, only: :show
#before_filter :rest_user_score, only: :show
#before_filter :select_entry, only: :user_projects
@ -1044,6 +1044,16 @@ class UsersController < ApplicationController
@user = User.find(params[:id])
end
#修改个人简介
def edit_brief_introduction
if @user && @user.extensions
@user.extensions.update_column("brief_introduction",params[:brief_introduction])
end
respond_to do |format|
format.js
end
end
private
def find_user

View File

@ -0,0 +1,10 @@
<% if user.user_extensions && user.user_extensions.brief_introduction && !user.user_extensions.brief_introduction.empty? %>
<%= user.user_extensions.brief_introduction %>&nbsp;
<% else%>
这位童鞋很懒,什么也没有留下~&nbsp;
<% end %>
<% if User.current == user%>
<a href="javascript:void(0);" onclick="show_edit_user_introduction();">
<img src="../images/signature_edit.png" width="12" height="12" />
</a>
<% end%>

View File

@ -58,24 +58,11 @@
</div>
<div>
<div class="homepageSignature">
<% if @user.user_extensions && @user.user_extensions.brief_introduction && !@user.user_extensions.brief_introduction.empty? %>
<p>
<%= @user.user_extensions.brief_introduction %>&nbsp;
<a href="javascript:void(0);">
<img src="../images/signature_edit.png" width="12" height="12" />
</a>
</p>
<% else%>
<% if is_current_user%>
<p>
这位童鞋很懒,什么也没有留下~&nbsp;
<a href="javascript:void(0);">
<img src="../images/signature_edit.png" width="12" height="12" />
</a>
</p>
<% end%>
<% end %>
<p id="user_brief_introduction_show">
<%= render :partial => 'layouts/user_brief_introduction', :locals => {:user => @user} %>
</p>
</div>
<textarea class="homepageSignatureTextarea none" placeholder="请输入回复" id="user_brief_introduction_edit" onblur="edit_user_introduction('<%= edit_brief_introduction_user_path(@user.id)%>');"><%= @user.user_extensions.brief_introduction %></textarea>
</div>
<div>
<div class="homepageImageBlock">

View File

@ -0,0 +1,3 @@
$("#user_brief_introduction_show").html("<%= escape_javascript render(:partial => "layouts/user_brief_introduction", :locals => {:user => @user}) %>");
$("#user_brief_introduction_show").show();
$("#user_brief_introduction_edit").hide();

View File

@ -345,6 +345,7 @@ RedmineApp::Application.routes.draw do
match 'file_score_index', :to => 'projects#file_score_index', :via => [:get, :post]
match 'code_submit_score_index', :to => 'projects#code_submit_score_index', :via => [:get, :post]
match 'projects_topic_score_index', :to => 'projects#projects_topic_score_index', :via => [:get, :post]
get 'edit_brief_introduction'
# end
end
end

View File

@ -11,6 +11,24 @@ $(function(){
});
});
//编辑个人简介
function show_edit_user_introduction() {
$("#user_brief_introduction_show").hide();
$("#user_brief_introduction_edit").show();
$("#user_brief_introduction_edit").focus();
}
//编辑个人简介完成之后提交
function edit_user_introduction(url){
$.get(
url,
{ brief_introduction: $("#user_brief_introduction_edit").val() },
function (data) {
}
);
}
$(function(){
$(".newsType").mouseover(function(){
$(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px -25px no-repeat"});

View File

@ -412,6 +412,7 @@ a.homepageSearchIcon:hover {background:url(../images/nav_icon.png) -49px 3px no-
.homepageImageName {font-size:16px; color:#484848; margin-left:15px; height:21px; float:left;max-width: 100px;}
.homepageImageSexMan {width:20px; height:20px; background:url(../images/homepage_icon.png) -10px -112px no-repeat; float:left;}
.homepageImageSexWomen {width: 20px;height: 20px;background: url(../images/homepage_icon.png) -10px -149px no-repeat;float: left;}
.homepageSignatureTextarea {width:207px; height:80px; max-width:207px; max-height:80px; border:1px solid #d9d9d9; outline:none; margin:0px 0px 12px 15px;;}
.homepageSignature {font-size:12px; color:#888888; margin-left:15px; margin-top:10px; margin-bottom:12px; width:208px;}
.homepageImageBlock {margin:0 auto; width:78px; float:left; text-align:center; display:inline-block;}
.homepageImageNumber {font-size:12px; color:#484848;}