/
buddypress-notifications.min.js
1 lines (1 loc) · 1.98 KB
/
buddypress-notifications.min.js
1
window.bp=window.bp||{},function(t,i){"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},bp.Nouveau.Notifications={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){bp.Nouveau.setStorage("bp-notifications","extras","DESC")},addListeners:function(){i('#buddypress [data-bp-list="notifications"]').on("bp_ajax_request",this.prepareDocument),i('#buddypress [data-bp-list="notifications"]').on("click","[data-bp-notifications-order]",bp.Nouveau,this.sortNotifications),i('#buddypress [data-bp-list="notifications"]').on("change","#notification-select",this.enableBulkSubmit),i('#buddypress [data-bp-list="notifications"]').on("click","#select-all-notifications",this.selectAll),i(window).on("unload",this.resetFilter)},prepareDocument:function(){"ASC"===bp.Nouveau.getStorage("bp-notifications").extras?(i('[data-bp-notifications-order="DESC"]').show(),i('[data-bp-notifications-order="ASC"]').hide()):(i('[data-bp-notifications-order="ASC"]').show(),i('[data-bp-notifications-order="DESC"]').hide()),i("#notification-bulk-manage").prop("disabled","disabled")},sortNotifications:function(t){var e=t.data.getStorage("bp-notifications"),o=e.scope||null,a=e.filter||null,n=e.extra||null,s="";t.preventDefault(),n=i(t.currentTarget).data("bp-notifications-order"),bp.Nouveau.setStorage("bp-notifications","extras",n),i('#buddypress [data-bp-search="notifications"] input[type=search]').length&&(s=i('#buddypress [data-bp-search="notifications"] input[type=search]').val()),bp.Nouveau.objectRequest({object:"notifications",scope:o,filter:a,search_terms:s,extras:n,page:1,template:"members/single/notifications/notifications-loop"})},enableBulkSubmit:function(t){i("#notification-bulk-manage").prop("disabled",i(t.currentTarget).val().length<=0)},selectAll:function(t){i.each(i(".notification-check"),function(e,o){i(o).prop("checked",i(t.currentTarget).prop("checked"))})},resetFilter:function(){bp.Nouveau.setStorage("bp-notifications","filter",0)}},bp.Nouveau.Notifications.start())}(bp,jQuery);