-
+
<%= image_tag(url_to_avatar(@user),width:"206", height: "206", :id=>'nh_user_tx') %>
<% if User.current.logged?%>
<% if User.current == @user%>
@@ -39,13 +39,8 @@
<% else %>
-
-
- <%if(@user.watched_by?(User.current))%>
- <%= link_to "",watch_path(:object_type=> 'user',:object_id=>@user.id,:target_id=>@user.id),:class => "homepageFollow", :method => "delete",:remote => "true", :title => "取消关注"%>
- <% else %>
- <%= link_to "",watch_path(:object_type=> 'user',:object_id=>@user.id,:target_id=>@user.id),:class => "homepageFollow", :method => "post",:remote => "true", :title => "添加关注"%>
- <% end %>
+
+ <%= render :partial => 'layouts/user_watch_btn', :locals => {:target => @user} %>
<% end %>
<% end%>
@@ -89,7 +84,7 @@
- <%= link_to @user.watcher_users.count.to_s, {:controller=>"users", :action=>"user_fanslist",:id=>@user.id},:class=>"homepageImageNumber"%>
+ <%= link_to @user.watcher_users.count.to_s, {:controller=>"users", :action=>"user_fanslist",:id=>@user.id},:class=>"homepageImageNumber", :id => "user_fans_number"%>
粉丝
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index d96fd1036..02791d02d 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -215,7 +215,7 @@
-
+
\ No newline at end of file
diff --git a/app/views/watchers/_set_watcher.js.erb b/app/views/watchers/_set_watcher.js.erb
index da794d18b..1efa8a4a1 100644
--- a/app/views/watchers/_set_watcher.js.erb
+++ b/app/views/watchers/_set_watcher.js.erb
@@ -1,57 +1,15 @@
<% if( params[:object_type] == 'user') %>
+ //点击头像下面的添加关注按钮
<% if( params[:target_id] == params[:object_id] ) %>
- <% target = User.find_by_id(params[:target_id]) %>
- //btn
- var btn_html = "<%= escape_javascript( render( :partial => 'layouts/user_watch_btn', :locals => {:target => target} ) )%>";
- $('#user_watch_id').replaceWith(btn_html);
- //count
- $("*[nh_name='fans_count']").html("<%= target.watcher_users.count.to_s %>");
- //left list
- var list_left_html = "<%= escape_javascript( render( :partial => 'layouts/user_fans_list', :locals => {:user => target} ) )%>";
- $('#fans_nav_list').replaceWith(list_left_html);
- //list
- if( $("#nh_fans_list") != undefined && $("#nh_fans_list").length != 0 ){
- <% if( opt == 'add') %>
- var list_html = "<%= escape_javascript( render( :partial => 'users/user_fans_item', :locals => {:item=>User.current,:target => target} ) )%>";
- $("#nh_fans_list").after(list_html);
- $("#nodata").hide();
- <% else %>
- $("#fans_item_<%= User.current.id %>",$("#nh_fans_list").parent('div')).remove();
- if( $('>div',$("#nh_fans_list").parent('div')).length == 1 ){
- $("#nodata").show();
- }
- <% end %>
- }
-
+ $("#watch_user_btn").html("<%= escape_javascript render(:partial => "layouts/user_watch_btn", :locals => {:target => watched.first}) %>");
+ $("#user_fans_number").html("<%= watched.first.watcher_users.count.to_s%>");
+ //在当前用户的粉丝、关注页面
<% elsif( params[:target_id] == User.current.id.to_s )%>
- <% target = User.find_by_id(params[:target_id]) %>
- <% item = User.find_by_id(params[:object_id]) %>
- //count
- $("*[nh_name='watcher_count']").html("<%= User.watched_by(target.id).count.to_s %>");
- //left list
- var list_left_html = "<%= escape_javascript( render( :partial => 'layouts/user_watch_list', :locals => {:user => target} ) )%>";
- $('#watcher_nav_list').replaceWith(list_left_html);
- //list
- if( $("#nh_wacth_list") != undefined && $("#nh_wacth_list").length != 0 ){
- <% if( opt == 'delete') %>
- $("#fans_item_<%= item.id %>",$("#nh_wacth_list").parent('div')).remove();
- if( $('>div',$("#nh_wacth_list").parent('div')).length == 1 ){
- $("#nodata").show();
- }
- <% end %>
- }else if($("#nh_fans_list") != undefined && $("#nh_fans_list").length != 0){
- var list_html = "<%= escape_javascript( render( :partial => 'users/user_fans_item', :locals => {:item=>item,:target => target} ) )%>";
- $('#fans_item_<%= item.id %>').replaceWith(list_html);
- }
+ //在其他用户的粉丝、关注页面
<% else %>
- <% target = User.find_by_id(params[:target_id]) %>
- <% item = User.find_by_id(params[:object_id]) %>
- //list
- var list_html = "<%= escape_javascript( render( :partial => 'users/user_fans_item', :locals => {:item=>item,:target => target} ) )%>";
- $('#fans_item_<%= item.id %>').replaceWith(list_html);
- <% end %>
+ <% end %>
<% else %>
<% selector = ".#{watcher_css(watched)}" %>
diff --git a/public/javascripts/user.js b/public/javascripts/user.js
index a26b6b94a..c97f617a5 100644
--- a/public/javascripts/user.js
+++ b/public/javascripts/user.js
@@ -1,5 +1,14 @@
$(function(){
$("#RSide").css("min-height",$("#LSide").height()-40).css("padding","10px");
+
+ //头像相关
+ $("#homepage_portrait_image").live("mouseover",function(){
+ $("#edit_user_file_btn").show();
+ $("#watch_user_btn").show();
+ }).live("mouseout",function(){
+ $("#edit_user_file_btn").hide();
+ $("#watch_user_btn").hide();
+ });
});
$(function(){