module WatchersHelper
def watcher_tag(object, user, options={})
- content_tag("span", watcher_link(object, user), :class => watcher_css(object))
+ ActiveSupport::Deprecation.warn "#watcher_tag is deprecated and will be removed in Redmine 3.0. Use #watcher_link instead."
+ watcher_link(object, user)
end
def watcher_link(object, user)
return '' unless user && user.logged? && object.respond_to?('watched_by?')
watched = object.watched_by?(user)
+ css = [watcher_css(object), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ')
url = {:controller => 'watchers',
:action => (watched ? 'unwatch' : 'watch'),
:object_type => object.class.to_s.underscore,
:object_id => object.id}
link_to((watched ? l(:button_unwatch) : l(:button_watch)), url,
- :remote => true, :method => 'post', :class => (watched ? 'icon icon-fav' : 'icon icon-fav-off'))
-
+ :remote => true, :method => 'post', :class => css)
end
# Returns the css class used to identify watch links for a given +object+
new_board_message_path(@board),
:class => 'icon icon-add',
:onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' if User.current.allowed_to?(:add_messages, @board.project) %>
-<%= watcher_tag(@board, User.current) %>
+<%= watcher_link(@board, User.current) %>
</div>
<div id="add-message" style="display:none;">
<div class="contextual">
<%= link_to l(:button_update), edit_issue_path(@issue), :onclick => 'showAndScrollTo("update", "issue_notes"); return false;', :class => 'icon icon-edit', :accesskey => accesskey(:edit) if @issue.editable? %>
<%= link_to l(:button_log_time), new_issue_time_entry_path(@issue), :class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project) %>
-<%= watcher_tag(@issue, User.current) %>
+<%= 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), :data => {:confirm => issues_destroy_confirmation_message(@issue)}, :method => :delete, :class => 'icon icon-del' if User.current.allowed_to?(:delete_issues, @project) %>
</div>
<%= board_breadcrumb(@message) %>
<div class="contextual">
- <%= watcher_tag(@topic, User.current) %>
+ <%= watcher_link(@topic, User.current) %>
<%= link_to(
l(:button_quote),
{:action => 'quote', :id => @topic},
<div class="contextual">
-<%= watcher_tag(@news, User.current) %>
+<%= watcher_link(@news, User.current) %>
<%= link_to(l(:button_edit),
edit_news_path(@news),
:class => 'icon icon-edit',
<% selector = ".#{watcher_css(watched)}" %>
-$("<%= selector %>").each(function(){$(this).html("<%= escape_javascript watcher_link(watched, user) %>")});
+$("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript watcher_link(watched, user) %>")});
<div class="contextual">
-<%= watcher_tag(@wiki, User.current) %>
+<%= watcher_link(@wiki, User.current) %>
</div>
<h2><%= l(:label_index_by_date) %></h2>
<div class="contextual">
-<%= watcher_tag(@wiki, User.current) %>
+<%= watcher_link(@wiki, User.current) %>
</div>
<h2><%= l(:label_index_by_title) %></h2>
<% if @editable %>
<% if @content.current_version? %>
<%= link_to_if_authorized(l(:button_edit), {:action => 'edit', :id => @page.title}, :class => 'icon icon-edit', :accesskey => accesskey(:edit)) %>
- <%= watcher_tag(@page, User.current) %>
+ <%= watcher_link(@page, User.current) %>
<%= link_to_if_authorized(l(:button_lock), {:action => 'protect', :id => @page.title, :protected => 1}, :method => :post, :class => 'icon icon-lock') if !@page.protected? %>
<%= link_to_if_authorized(l(:button_unlock), {:action => 'protect', :id => @page.title, :protected => 0}, :method => :post, :class => 'icon icon-unlock') if @page.protected? %>
<%= link_to_if_authorized(l(:button_rename), {:action => 'rename', :id => @page.title}, :class => 'icon icon-move') %>