37 lines
2.5 KiB
Plaintext
37 lines
2.5 KiB
Plaintext
<% if( params[:object_type] == 'user') %>
|
|
//点击头像下面的添加关注按钮
|
|
<% if( params[:target_id] == params[:object_id] ) %>
|
|
$("#watch_user_btn_div").html("<%= escape_javascript render(:partial => "layouts/user_watch_btn", :locals => {:target => watched.first}) %>");
|
|
$("#user_fans_number").html("<%= watched.first.watcher_users.count.to_s%>");
|
|
$(".add_cancel_watch_<%= watched.first.id %>").html("<%= escape_javascript (render :partial => 'users/watch_btn_for_picture', :locals => {:user => watched.first}) %>");
|
|
$(".fans_count_<%= watched.first.id %>").text("<%= watched.first.watcher_users.count.to_s %>");
|
|
//在当前用户的粉丝、关注页面
|
|
<% elsif( params[:target_id] == User.current.id.to_s )%>
|
|
$("#users_list").html("<%= escape_javascript (render :partial => 'users/user_fans_item', :locals => {:list => list,:target=>User.current,:action_name=>action_name,:page=>params[:page]}) %>");
|
|
$("#watch_user_number_div").html('<%= escape_javascript ( link_to User.watched_by(params[:target_id]).count.to_s, {:controller=>"users", :action=>"user_watchlist",:id=>params[:target_id]},:class=>"homepageImageNumber") %>');
|
|
$("#fans_user_number_div").html('<%= escape_javascript ( link_to User.find(params[:target_id]).watcher_users.count.to_s, {:controller=>"users", :action=>"user_fanslist",:id=>params[:target_id]},:class=>"homepageImageNumber", :id => "user_fans_number") %>');
|
|
$("#fans_span").html('<%= count %>');
|
|
$("#watch_span").html('<%= count %>');
|
|
//在其他用户的粉丝、关注页面
|
|
<% else %>
|
|
$("#users_list").html("<%= escape_javascript (render :partial => 'users/user_fans_item', :locals => {:list => list,:target=>User.find(params[:target_id]),:action_name=>action_name,:page=>params[:page]}) %>");
|
|
//在他人的用户分析下关注,不会改变他人的关注数,所以不必要刷新
|
|
//$("#watch_user_number").html('<%#= escape_javascript ( link_to User.watched_by(params[:target_id]).count.to_s, {:controller=>"users", :action=>"user_watchlist",:id=>params[:target_id]},:class=>"homepageImageNumber") %>');
|
|
<% end %>
|
|
<% else %>
|
|
|
|
<% selector = ".#{watcher_css(watched)}" %>
|
|
<% id_selector = "#{watcher_css(watched)}" %>
|
|
if($("<%= selector %>").get(0) == undefined)
|
|
{
|
|
$("#<%= id_selector %>").each(function(){$(this).replaceWith("<%= escape_javascript watcher_link_for_project(watched, user) %>")});
|
|
}
|
|
else
|
|
{
|
|
$("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript watcher_link(watched, user) %>")});
|
|
}
|
|
|
|
<% end %>
|
|
|
|
|