diff --git a/app/views/groups/edit.html.haml b/app/views/groups/edit.html.haml index 2a43c6067..fd251e6ef 100644 --- a/app/views/groups/edit.html.haml +++ b/app/views/groups/edit.html.haml @@ -9,7 +9,7 @@ %li.requests %ul - for request in @remote_requests - %li.person{:id => request.person.id, :request_id => request.id} + %li.requested_person{:id => request.person.id, :request_id => request.id} = image_tag(request.person.profile.image_url(:thumb_small)) unless request.person.profile.image_url.nil? .name = request.person.real_name diff --git a/public/javascripts/group-edit.js b/public/javascripts/group-edit.js index 923a8bcc2..c3449b315 100644 --- a/public/javascripts/group-edit.js +++ b/public/javascripts/group-edit.js @@ -14,44 +14,55 @@ $(function() { revert: true }); - + $("li .requested_person").draggable({ + revert: true + }); $(".group ul").droppable({ drop: function(event, ui) { - if (ui.draggable[0].getAttribute('request_id') != null){ - $.ajax({ - type: "DELETE", - url: "/requests/" + ui.draggable[0].getAttribute('request_id') , - data: {"accept" : true , "group_id" : $(this)[0].id } - }); - alert("Sent the ajax, check it out!") - } - var move = {}; - move[ 'friend_id' ] = ui.draggable[0].id - move[ 'to' ] = $(this)[0].id; - move[ 'from' ] = ui.draggable[0].getAttribute('from_group_id'); - if (move['to'] == move['from']){ - $('#group_list').data( ui.draggable[0].id, []); - ui.draggable.css('background-color','white'); - } else { - $('#group_list').data( ui.draggable[0].id, move); - ui.draggable.css('background-color','orange'); - } - $(this).closest("ul").append(ui.draggable); + if ($(ui.draggable[0]).hasClass('requested_person')){ + $.ajax({ + type: "DELETE", + url: "/requests/" + ui.draggable[0].getAttribute('request_id') , + data: {"accept" : true , "group_id" : $(this)[0].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_group_id'); + if (move['to'] == move['from']){ + $('#group_list').data( ui.draggable[0].id, []); + ui.draggable.css('background-color','white'); + } else { + $('#group_list').data( ui.draggable[0].id, move); + ui.draggable.css('background-color','orange'); + } + $(this).closest("ul").append(ui.draggable); + } } }); $(".remove ul").droppable({ drop: function(event, ui) { - if (ui.draggable[0].getAttribute('request_id') != null){ - $.ajax({ - type: "DELETE", - url: "/requests/" + ui.draggable[0].getAttribute('request_id') - }); - alert("Removed Request, proably want an undo countdown.") - $(ui.draggable[0]).fadeOut('slow') + + 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", + url: "/people/" + ui.draggable[0].id) + }); + alert("Removed Friend, proably want an undo countdown.") + $(ui.draggable[0]).fadeOut('slow') + } - } }); }); diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index b0bc2b1ff..652f1e4ef 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -609,8 +609,11 @@ h1.big_text { list-style: none; padding: 15px; } .group .person, + .group .requested_person, .requests .person, - .remove .person { + .requests .requested_person, + .remove .person, + .remove .requested_person { display: inline-block; margin-left: 0; padding: 5px; @@ -624,14 +627,20 @@ h1.big_text { padding: 5px; border: 1px solid #999999; } .group .person img, + .group .requested_person img, .requests .person img, - .remove .person img { + .requests .requested_person img, + .remove .person img, + .remove .requested_person img { height: 50px; width: 50px; display: inline-block; } .group .person .grey, + .group .requested_person .grey, .requests .person .grey, - .remove .person .grey { + .requests .requested_person .grey, + .remove .person .grey, + .remove .requested_person .grey { font-style: italic; color: #666666; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 3f2e841a9..03fa4dae6 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -794,7 +794,8 @@ h1.big_text :style none :padding 15px - .person + .person, + .requested_person :display inline-block :margin :left 0