<% 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 %> } <% 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 %> <% 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 %>