Decrement request counter on request action
This commit is contained in:
parent
d9055a73d3
commit
b77260af6b
1 changed files with 16 additions and 11 deletions
|
|
@ -28,6 +28,20 @@ $('#move_friends_link').live( 'click', function(){
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function decrementRequestsCounter(){
|
||||||
|
var old_request_count = $(".new_requests").html().match(/\d+/);
|
||||||
|
|
||||||
|
if( old_request_count == 1 ) {
|
||||||
|
$(".new_requests").html(
|
||||||
|
$(".new_requests").html().replace(/ \(\d+\)/,''));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$(".new_requests").html(
|
||||||
|
$(".new_requests").html().replace(/\d+/,old_request_count-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
$("ul .person").draggable({
|
$("ul .person").draggable({
|
||||||
revert: true
|
revert: true
|
||||||
|
|
@ -46,16 +60,7 @@ $(function() {
|
||||||
url: "/requests/" + ui.draggable[0].getAttribute('request_id') ,
|
url: "/requests/" + ui.draggable[0].getAttribute('request_id') ,
|
||||||
data: {"accept" : true , "aspect_id" : $(this)[0].id },
|
data: {"accept" : true , "aspect_id" : $(this)[0].id },
|
||||||
success: function(data){
|
success: function(data){
|
||||||
var old_request_count = $(".new_requests").html().match(/\d+/);
|
decrementRequestsCounter();
|
||||||
|
|
||||||
if( old_request_count == 1 ) {
|
|
||||||
$(".new_requests").html(
|
|
||||||
$(".new_requests").html().replace(/ \(\d+\)/,''));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$(".new_requests").html(
|
|
||||||
$(".new_requests").html().replace(/\d+/,old_request_count-1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -84,7 +89,7 @@ $(function() {
|
||||||
type: "DELETE",
|
type: "DELETE",
|
||||||
url: "/requests/" + ui.draggable[0].getAttribute('request_id')
|
url: "/requests/" + ui.draggable[0].getAttribute('request_id')
|
||||||
});
|
});
|
||||||
alert("Removed Request, proably want an undo countdown.")
|
decrementRequestsCounter();
|
||||||
$(ui.draggable[0]).fadeOut('slow')
|
$(ui.draggable[0]).fadeOut('slow')
|
||||||
}else{
|
}else{
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue