diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 02bc3d8b3..bff7831d1 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -43,7 +43,7 @@ module WatchersHelper ) method = watched ? 'delete' : 'post' - link_to text, url, :remote => true, :method => method, :style => "color: #fff; display:block; padding: 0px 5px; margin-right: 10px; height: 22px; line-height: 21px;padding-top:1px; background: none repeat scroll 0% 0% #64BDD9; TES" + link_to text, url, :remote => true, :method => method, :class => css end ############## added by linchun @@ -278,11 +278,46 @@ module WatchersHelper ) method = applied ? 'delete' : 'post' - link_to text, url, :remote => true, :method => method ,:style => "color: #fff; display:block; padding: 0px 5px; margin-right: 10px; height: 21px; line-height: 22px;padding-top:1px; background: none repeat scroll 0% 0% #64BDD9; TES" + link_to text, url, :remote => true, :method => method , :class => css end def exit_project_link(project) link_to(l(:label_exit_project),exit_cur_project_path(project.id), - :remote => true, :confirm => l(:lable_sure_exit_project), :style => "color: #fff; display:block; padding: 0px 5px; margin-right: 10px; height: 21px; line-height: 22px; background: none repeat scroll 0% 0% #64BDD9; TES;padding-top:1px;" ) + :remote => true, :confirm => l(:lable_sure_exit_project), + :style => "color: #fff; display:block; padding: 0px 5px; margin-right: 10px; height: 21px; line-height: 22px; background: none repeat scroll 0% 0% #64BDD9; TES;padding-top:1px;" ) + end + + #项目关注、取消关注 + #REDO:项目样式确定后方法需要对CSS变量进行改进 + def watcher_link_for_project(objects, user, options=[]) + 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 ? + (watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch)) + 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" + end + + #申请加入项目 + def join_in_project_link(project, user, options=[]) + return '' unless user && user.logged? + applied = project.applied_projects.find_by_user_id(user.id) + text = applied ? l(:label_unapply_project) : l(:label_apply_project) + @applied_flag = project.instance_of?(Project) + if applied + appliedid = applied.id + end + 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" end + end diff --git a/app/views/issues/_action_menu.html.erb b/app/views/issues/_action_menu.html.erb index bcd7b30c5..61cea920c 100644 --- a/app/views/issues/_action_menu.html.erb +++ b/app/views/issues/_action_menu.html.erb @@ -12,7 +12,7 @@ <% end %> - +<%= watcher_link(@issue, User.current) %> <%= link_to l(:button_copy), project_copy_issue_path(@project, @issue), :class => 'icon icon-copy' if User.current.allowed_to?(:add_issues, @project) %> <%= link_to l(:button_delete), issue_path(@issue.id), :data => {:confirm => issues_destroy_confirmation_message(@issue)}, :method => :delete, :class => 'icon icon-del' if User.current.allowed_to?(:delete_issues, @project) %> diff --git a/app/views/layouts/_join_exit_project.html.erb b/app/views/layouts/_join_exit_project.html.erb index 0c4e54317..a5269d422 100644 --- a/app/views/layouts/_join_exit_project.html.erb +++ b/app/views/layouts/_join_exit_project.html.erb @@ -1,11 +1,11 @@
<% if ( !(User.current.member_of? @project) && User.current.login?) %> - <%= watcher_link(@project, User.current) %> + <%= watcher_link_for_project(@project, User.current) %> <% end %> <% if ( !(User.current.member_of? @project) && User.current.login?) %> - <%= applied_link(@project, User.current) %> + <%= join_in_project_link(@project, User.current) %> <% end %> <% if ((User.current.member_of? @project) && diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index ca8f0c3b6..1270f6bcf 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -31,7 +31,7 @@ a{ text-decoration:none; } .fl{ float: left;} .fr{ float:right;} .project_h4{ font-size:14px; color:#3b3b3b;} - +.project_watch_new{color: #fff !important; display:block !important; padding: 0px 5px !important; margin-right: 10px !important; height: 22px !important; line-height: 21px !important;padding-top:1px !important; background: none repeat scroll 0% 0% #64BDD9 !important;} .project_content{ width:940px; margin:10px auto;} .project_left{ float:left;} @@ -51,7 +51,6 @@ a{ text-decoration:none; } a.info_foot_num{ font-weight: bold; color:#3ca5c6; } .pr_info_foot{ color:#7f7f7f; margin-top:5px; font-size:12px } a:hover.info_foot_num{ color:#2390b2;} - /*左侧导航*/ .subNavBox{width:222px; background:#fff;margin:10px 10px 0 0;} .subNav{border-bottom:solid 1px #e5e3da;cursor:pointer;font-weight:bold;font-size:14px;color:#3ca5c6;line-height:28px;padding-left:10px;background-color:#fff;} @@ -74,6 +73,7 @@ a:hover.subnav_green{ background:#14ad5a;} .course_description_none{max-height: none;} .lg-foot{ border:1px solid #e8eef2; color: #929598; text-align:center; width:220px; height:23px; cursor:pointer;} .lg-foot:hover{ color:#787b7e;} +. /****标签(和资源库的tag样式一致)***/ .project_Label{ width:220px; padding-left:10px; padding-right:10px; background:#fff; margin-top:10px;} a.yellowBtn{ display:inline-block;color:#0d90c3; height:22px;}