Newer
Older
$.post('/aspects/move_friends',
{ 'moves' : $('#aspect_list').data() },
function(){ $('#aspect_title').html("Groups edited successfully!");});
$('#aspect_list').removeData();
$(".person").attr('from_aspect_id', function(){return $(this).parent().attr('id')})
$(function() {
$("li .person").draggable({
revert: true
});
$("li .requested_person").draggable({
revert: true
});
if ($(ui.draggable[0]).hasClass('requested_person')){
$.ajax({
type: "DELETE",
url: "/requests/" + ui.draggable[0].getAttribute('request_id') ,
});
alert("Sent the ajax, check it out!")
}else {
var move = {};
move[ 'friend_id' ] = ui.draggable[0].id
move[ 'to' ] = $(this)[0].id;
move[ 'from' ] = ui.draggable[0].getAttribute('from_aspect_id');
if (move['to'] == move['from']){
ui.draggable.css('background-color','white');
} else {
ui.draggable.css('background-color','orange');
}
$(this).closest("ul").append(ui.draggable);
}
$(".remove ul").droppable({
drop: function(event, ui) {
if ($(ui.draggable[0]).hasClass('requested_person')){
$.ajax({
type: "DELETE",
url: "/requests/" + ui.draggable[0].getAttribute('request_id')
});
alert("Removed Request, proably want an undo countdown.")
$(ui.draggable[0]).fadeOut('slow')
}else{
$.ajax({
type: "DELETE",
});
alert("Removed Friend, proably want an undo countdown.")
$(ui.draggable[0]).fadeOut('slow')
var $this = $(this);
var id = $this.closest("li").children("ul").attr("id");
$this.keypress(function(e) {
if (e.which == 13) {
e.preventDefault();
$this.blur();
//save changes
$.ajax({
type: "PUT",
url: link,
$this.keyup(function(e) {
$("a[href='"+link+"']").text($this.text());
});
});
});