1 $(document).ready(function () {
2 $(".inbox-mark-unread").on("ajax:success", function (event, data) {
4 updateReadState(this, false);
7 $(".inbox-mark-read").on("ajax:success", function (event, data) {
9 updateReadState(this, true);
12 $(".inbox-destroy").on("ajax:success", function (event, data) {
15 $(this).closest("tr").fadeOut(800, "linear", function () {
20 function updateHtml(data) {
21 $("#inboxanchor").remove();
22 $(".user-button").before(data.inboxanchor);
24 $("#inbox-count").replaceWith(data.inbox_count);
25 $("#outbox-count").replaceWith(data.outbox_count);
26 $("#muted-count").replaceWith(data.muted_count);
29 function updateReadState(target, isRead) {
30 $(target).closest("tr")
31 .toggleClass("inbox-row", isRead)
32 .toggleClass("inbox-row-unread", !isRead)
33 .find(".inbox-mark-unread").prop("hidden", !isRead).end()
34 .find(".inbox-mark-read").prop("hidden", isRead);