Component.RemoveBuddyLink=Class.create(Component.Link,{onClick:function(A){A.stop();
new View.ConfirmationPopup(this.element,{content:"Are you sure you want to remove this friend?",onConfirm:this.onDelete.bindAsEventListener(this)});
},onDelete:function(){var B=this.element.readAttribute("me");
var A=this.element.readAttribute("friend");
var C={_method:"delete",_format:"json"};
new Ajax.Request("/api/v1/users/"+B+"/friends/"+A,{parameters:C,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
},onSuccess:function(A){this.element.replace("Removed.");
},onFailure:function(A){this.element.replace("Oops, please try again later.");
}});
Component.RemoveBuddyGalleryLink=Class.create(Component.RemoveBuddyLink,{onSuccess:function(A){new Effect.Shrink(this.element.up(".row"),{direction:"top-left",duration:0.5});
},onFailure:function(A){new Effect.Shrink(this.element.up(".row"),{direction:"top-left",duration:0.5});
}});
Component.RemovePendingBuddyLink=Class.create(Component.Link,{onClick:function(A){A.stop();
new View.ConfirmationPopup(this.element,{content:"Are you sure you want to remove this pending friend?",onConfirm:this.onDelete.bindAsEventListener(this)});
},onDelete:function(){var A={user:this.element.readAttribute("friend")};
new Ajax.Request("/friends/action/remove-pending-friend",{parameters:A,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
},onSuccess:function(A){new Effect.Shrink(this.element.up(".row"),{direction:"top-left",duration:0.5});
},onFailure:function(A){new Effect.Shrink(this.element.up(".row"),{direction:"top-left",duration:0.5});
}});
Component.TopFriendsForm=Class.create(Component.Form,{initialize:function($super,A){$super(A);
this.element.observe("top:add",this.onAdd.bindAsEventListener(this));
this.element.observe("top:remove",this.onRemove.bindAsEventListener(this));
this.sort();
},sort:function(){Sortable.create("sortableFriends",{tag:"li",scroll:window,handle:"thumbnail",constraint:false});
},onSubmit:function(A){this.element.select("input[type=submit]").each(function(B){B.disable();
});
return true;
},onAdd:function(B){var A=new Template("<li id='friends_#{user}'><input type='hidden' name='buddy' value='#{user}' /><div class='thumbnail'><img src='#{thumbnail}' /></div><div>#{username}</div><div class='delete'>[ <input type='button' value='delete' component='TopFriendsRemoveButton' user='#{user}' /> ]</div></li>");
$("sortableFriends").insert({bottom:A.evaluate(B.memo)});
new Component.Binder("friends_"+B.memo.user);
this.sort();
},onRemove:function(A){$("friends_"+A.memo.user).remove();
$("buddy"+A.memo.user).removeClassName("selected");
}});
Component.TopFriendsAddLink=Class.create(Component.Link,{onClick:function(A){A.stop();
this.element.up("li").addClassName("selected");
this.element.fire("top:add",{user:this.element.readAttribute("user"),username:this.element.readAttribute("username"),thumbnail:this.element.readAttribute("thumbnail")});
}});
Component.TopFriendsRemoveLink=Class.create(Component.Link,{onClick:function(A){A.stop();
this.element.up("li").removeClassName("selected");
this.element.fire("top:remove",{user:this.element.readAttribute("user")});
}});
Component.TopFriendsRemoveButton=Class.create(Component.Button,{onClick:function(A){A.stop();
this.element.fire("top:remove",{user:this.element.readAttribute("user")});
}});




