Added icon to directly unfollow a tag to listing of followed tags.

This commit is contained in:
Andrej Kacian 2011-07-29 18:00:37 +02:00
parent aac72b12e7
commit 2a970145c8
8 changed files with 45 additions and 6 deletions

View file

@ -22,11 +22,23 @@ class TagFollowingsController < ApplicationController
@tag = ActsAsTaggableOn::Tag.find_by_name(params[:name])
@tag_following = current_user.tag_followings.where(:tag_id => @tag.id).first
if @tag_following && @tag_following.destroy
flash[:notice] = I18n.t('tag_followings.destroy.success', :name => params[:name])
@tag_unfollowed = true
else
flash[:error] = I18n.t('tag_followings.destroy.failure', :name => params[:name])
@tag_unfollowed = false
end
redirect_to tag_path(:name => params[:name])
if params[:remote]
respond_to do |format|
format.all{}
format.js{ render 'tags/update' }
end
else
if @tag_unfollowed
flash[:notice] = I18n.t('tag_followings.destroy.success', :name => params[:name])
else
flash[:error] = I18n.t('tag_followings.destroy.failure', :name => params[:name])
end
redirect_to tag_path(:name => params[:name])
end
end
end

View file

@ -21,7 +21,7 @@
.section
= render 'aspects/aspect_listings'
.section
.section#followed_tags_listing
= render 'tags/followed_tags_listings'
.span-13.append-1

View file

@ -10,7 +10,9 @@
%ul.sub_nav
- if current_user.followed_tags.size > 0
- for tg in current_user.followed_tags
%li
%li.unfollow{:id => tg.name}
.unfollow_icon.hidden
= link_to image_tag("icons/monotone_close_exit_delete.png", :height => 12), tag_tag_followings_path(:name => tg.name, :remote => true), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :id => "unfollow_" + tg.name
=link_to "##{tg.name}", tag_path(:name => tg.name), :class => "tag_selector"
- else
%li

View file

@ -0,0 +1 @@
$("#followed_tags_listing").first().html("<%= escape_javascript(render('tags/followed_tags_listings')) =%>");

View file

@ -70,6 +70,7 @@ javascripts:
- public/javascripts/publisher.js
- public/javascripts/aspect-filters.js
- public/javascripts/aspect-edit-pane.js
- public/javascripts/tag-followings.js
- public/javascripts/fileuploader-custom.js
people:
- public/javascripts/vendor/jquery.autoSuggest.custom.js

View file

@ -158,6 +158,7 @@ en:
your_aspects: "Your Aspects"
tags_following: "Followed Tags"
no_tags: "+ Find a tag to follow"
unfollow_tag: "Stop following #%{tag}"
handle_explanation: "This is your diaspora id. Like an email address, you can give this to people to reach you."
no_contacts: "No contacts"
post_a_message: "post a message >>"

View file

@ -0,0 +1,18 @@
/* Copyright (c) 2011, Diaspora Inc. This file is
* licensed under the Affero General Public License version 3 or later. See
* the COPYRIGHT file.
*/
var TagFollowings = {
initialize: function(){
$('.unfollow').live('mouseover', function(){
$(this).find('.unfollow_icon').removeClass('hidden');
}).live('mouseout', function(){
$(this).find('.unfollow_icon').addClass('hidden');
});
}
};
$(document).ready(function() {
TagFollowings.initialize();
});

View file

@ -2902,9 +2902,13 @@ ul.left_nav
:color #666
.contact_count,
.edit
.edit,
.unfollow_icon
:float right
.unfollow_icon
:margin-top 4px
.edit
:margin-top 4px
:display none