项目关注、取消关注、申请加入、取消申请加入返回js修改

This commit is contained in:
z9hang 2015-03-21 10:20:04 +08:00
parent 821cb885a9
commit f0bc0b2e93
3 changed files with 28 additions and 8 deletions

View File

@ -293,14 +293,15 @@ module WatchersHelper
return '' unless user && user.logged?
objects = Array.wrap(objects)
watched = objects.any? {|object| object.watched_by?(user)}
@watch_flag = objects.first.instance_of?(Project)
text = @watch_flag ?
@watch_flag = objects.first.instance_of?(Project)
id = watcher_css(objects)
text = @watch_flag ?
(watched ? l(:button_unfollow) : l(:label_button_following)) : (watched ? l(:button_unwatch) : l(:label_button_following))
url = watch_path(:object_type => objects.first.class.to_s.underscore,
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort))
method = watched ? 'delete' : 'post'
link_to text, url, :remote => true, :method => method,
:class => "project_watch_new"
method = watched ? 'delete' : 'post'
link_to text, url, :remote => true, :method => method,
:class => "project_watch_new" ,:id=>id
end
#申请加入项目
@ -312,12 +313,13 @@ module WatchersHelper
if applied
appliedid = applied.id
end
id = applied_css(project)
url = appliedproject_path(
:id=>appliedid,
:user_id => user.id,
:project_id => project.id)
method = applied ? 'delete' : 'post'
link_to text, url, :remote => true, :method => method , :class => "project_watch_new"
link_to text, url, :remote => true, :method => method , :class => "project_watch_new",:id => id
end
end

View File

@ -1,5 +1,14 @@
<% selector = ".#{applied_css(@project)}" %>
$("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript applied_link(@project, User.current) %>")});
<% id_selector = "#{applied_css(@project)}" %>
if($("<%= selector %>").get(0) == undefined)
{
$("#<%= id_selector %>").each(function(){$(this).replaceWith("<%= escape_javascript join_in_project_link(@project, User.current) %>")});
}
else
{
$("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript applied_link(@project, User.current) %>")});
}
if (window.Messenger) {
Messenger.options = {
extraClasses: 'messenger-fixed messenger-on-bottom messenger-on-right',

View File

@ -1,2 +1,11 @@
<% selector = ".#{watcher_css(watched)}" %>
$("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript watcher_link(watched, user) %>")});
<% 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) %>")});
}