followers.js
2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
$("#action-follow").live("click", function() {
var button = $(this);
var url = button.attr("href");
loading_for_button(button);
$.post(url, function(data) {
button.fadeOut("fast", function() {
$("#circles-container").html(data);
$("#circles-container").fadeIn();
});
}).always(function() {
hide_loading_for_button(button);
});
return false;
});
$("#cancel-set-circle").live("click", function() {
$("#circles-container").fadeOut("fast", function() {
$("#action-follow").fadeIn();
});
return false;
});
$("#new-circle").live("click", function() {
$(this).fadeOut();
$("#circle-actions").fadeOut("fast", function() {
$("#new-circle-form").fadeIn();
});
return false;
});
$("#new-circle-cancel").live("click", function() {
$("#new-circle-form").fadeOut("fast", function() {
$("#circle-actions").fadeIn();
$("#new-circle").fadeIn();
$("#text-field-name-new-circle").val('')
});
return false;
});
$('#follow-circles-form').live("submit", function() {
var valuesToSubmit = $(this).serialize();
$.ajax({
type: "POST",
url: $(this).attr('action'),
data: valuesToSubmit,
dataType: "JSON",
statusCode: {
200: function(response){
$("#circles-container").fadeOut();
$("#action-unfollow").fadeIn();
$.colorbox.close();
display_notice(response.responseText);
},
400: function(response) {
display_notice(response.responseText);
}
}
})
return false;
});
$("#new-circle-submit").live("click", function() {
$.ajax({
method: 'POST',
url: $(this).attr("href"),
data: {'circle[name]': $("#text-field-name-new-circle").val(),
'circle[profile_type]': $("#circle_profile_type").val()},
success: function(response) {
$('#circles-checkboxes').append(response);
},
error: function(response) {
display_notice(response.responseText);
},
complete: function(response) {
$("#text-field-name-new-circle").val('')
$("#new-circle-cancel").trigger("click");
}
})
return false;
});