//   Copyright (c) 2010-2011, Diaspora Inc.  This file is
//   licensed under the Affero General Public License version 3 or later.  See
//   the COPYRIGHT file.

// TODO handle this completely in Backbone.js, then remove this view!

var element = $(".add[data-aspect_id=<%= @aspect.id %>][data-person_id=<%= @contact.person_id%>]");

if( $("#no_contacts").is(':visible') ) {
  $("#no_contacts").fadeOut(200);
}

element.parent().html("<%= escape_javascript(render('aspect_memberships/add_to_aspect', :aspect_id => @aspect.id, :person_id => @person.id)) %>");

if($('#aspects_list').length == 1) {
  $('.aspect_list').attr('data-contact_id', "<%= @contact_id %>");
  $('.aspect_list ul').find('.add').each(function(a,b){$(b).attr('href', $(b).attr('href').replace('contacts','aspect_memberships'));})
};

element.fadeTo(200,1);
