diaspora/public/javascripts/contact-list.js
zhitomirskiyi df4ebb286d accept invitation feature passing
wip, added a form to add aspect to the contact list

added files

typo

render the partial

remote friend

specifying the provider for the route

refactored local person person friend finder functionality to use the partial

typo

trying to use the stream
2011-02-08 16:40:28 -08:00

83 lines
2.3 KiB
JavaScript

/* Copyright (c) 2010, Diaspora Inc. This file is
* licensed under the Affero General Public License version 3 or later. See
* the COPYRIGHT file.
*/
$(document).ready(function() {
var List = {
initialize: function() {
$(".contact_list_search").live("keyup", function(e) {
var search = $(this);
var list = $(this).siblings("ul").first();
var query = new RegExp(search.val(),'i');
$("li", list).each( function() {
var element = $(this);
if( !element.text().match(query) ) {
if( !element.hasClass('hidden') ) {
element.addClass('hidden');
}
} else {
element.removeClass('hidden');
}
});
});
}
};
$('.added').live('ajax:loading', function() {
$(this).fadeTo(200,0.4);
});
$('.added').live('ajax:success', function(data, json, xhr) {
var json = $.parseJSON(json);
var contactPictures = $(".contact_pictures");
if( contactPictures.length > 0 ) {
if( contactPictures[0].childElementCount == 0 ) {
$("#no_contacts").fadeIn(200);
}
}
$(".aspect_badge[guid='" + json.aspect_id + "']", ".aspects").remove();
$(this).parent().html(json.button_html);
$(this).fadeTo(200,1);
});
$('.added').live('ajax:failure', function(data, html, xhr) {
alert(Diaspora.widgets.i18n.t('shared.contact_list.cannot_remove'));
$(this).fadeTo(200,1);
});
$('.add').live('ajax:loading', function() {
$(this).fadeTo(200,0.4);
});
$('.add').live('ajax:success', function(data, json, xhr) {
var json = $.parseJSON(json);
if( $("#no_contacts").is(':visible') ) {
$("#no_contacts").fadeOut(200);
}
$(".badges").prepend(json['badge_html']);
$(this).parent().html(json['button_html']);
$(this).fadeTo(200,1);
});
$('.added').live('mouseover', function() {
$(this).addClass("remove");
$(this).children("img").attr("src","/images/icons/monotone_close_exit_delete.png");
}).live('mouseout', function() {
$(this).removeClass("remove");
$(this).children("img").attr("src","/images/icons/monotone_check_yes.png");
});
$('.new_aspect').live('ajax:success', function(data, json, xhr){
var json = JSON.parse(json);
$('#aspects_list ul').append(json.html);
});
List.initialize();
});