$(function(){var t=$(document).find("#notification-sidebar"),n=function(t){var n=$(document).find(".badge.notification-count");t>0?n.text(t).show():n.text("0").hide()},i=function(n){$httpClient.make().get(n||t.data("url")).then(function(n){var i=n.data;t.find(".notification-content").html(i.data)})},a=function(){t.offcanvas("hide")};t.on("hide.bs.offcanvas",function(){$(".offcanvas-backdrop").remove()}),$(document).on("click",".offcanvas-backdrop",function(){$(this).remove(),a()}),t.on("show.bs.offcanvas",function(){i(),$httpClient.make().get(t.data("count-url")).then(function(t){var i=t.data;n(i.data)}),$("body").after('<div class="offcanvas-backdrop"></div>')}).on("click",".mark-all-notifications-as-read",function(t){t.preventDefault(),n(0),$httpClient.make().put($(this).data("url")).then(function(){i()})}).on("click",".clear-notifications",function(){n(0),$httpClient.make().delete($(this).data("url")).then(function(){a()})}).on("click",".list-group-item .btn-delete-notification",function(){var t=$(this).closest(".list-group-item"),a=t.hasClass("active");$httpClient.make().delete($(this).data("url")).then(function(){if(t.hide("slow",function(){t.remove(),i()}),a){var o=parseInt($(document).find(".badge.notification-count").first().text(),10)||0;n(Math.max(0,o-1))}})}).on("click","nav .btn-previous",function(){i($(this).data("url"))}).on("click","nav .btn-next",function(){i($(this).data("url"))})});