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);
27 function updateReadState(target, isRead) {
28 $(target).closest("tr")
29 .toggleClass("inbox-row", isRead)
30 .toggleClass("inbox-row-unread", !isRead)
31 .find(".inbox-mark-unread").prop("hidden", !isRead).end()
32 .find(".inbox-mark-read").prop("hidden", isRead);