socialforge/app/views/watchers/_set_watcher.js.erb

35 lines
2.2 KiB
Plaintext
Raw Normal View History

2015-07-09 15:27:49 +08:00
<% if( params[:object_type] == 'user') %>
//点击头像下面的添加关注按钮
2015-07-09 15:27:49 +08:00
<% if( params[:target_id] == params[:object_id] ) %>
2015-08-29 14:46:30 +08:00
$("#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%>");
//在当前用户的粉丝、关注页面
2015-07-09 15:27:49 +08:00
<% elsif( params[:target_id] == User.current.id.to_s )%>
2015-08-26 11:41:32 +08:00
$("#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") %>');
2015-08-26 14:39:33 +08:00
$("#fans_span").html('<%= count %>');
$("#watch_span").html('<%= count %>');
//在其他用户的粉丝、关注页面
2015-07-09 15:27:49 +08:00
<% else %>
2015-08-26 11:41:32 +08:00
$("#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 %>
2015-07-09 15:27:49 +08:00
<% else %>
<% selector = ".#{watcher_css(watched)}" %>
<% id_selector = "#{watcher_css(watched)}" %>
if($("<%= selector %>").get(0) == undefined)
{
2015-07-09 15:27:49 +08:00
$("#<%= id_selector %>").each(function(){$(this).replaceWith("<%= escape_javascript watcher_link_for_project(watched, user) %>")});
}
else
{
2015-07-09 15:27:49 +08:00
$("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript watcher_link(watched, user) %>")});
}
2015-07-09 15:27:49 +08:00
<% end %>