From 9929f59714461a0517b7bdf315429802d667c3ac Mon Sep 17 00:00:00 2001
From: Yudhisthir Nahar
Date: Fri, 29 Nov 2024 02:40:00 +0530
Subject: [PATCH 1/3] PROD-8092 Update reactions popup refresh logic
---
src/bp-templates/bp-nouveau/js/bb-activity-reacted.js | 6 +++++-
src/bp-templates/bp-nouveau/js/bb-activity-reacted.min.js | 2 +-
src/bp-templates/bp-nouveau/js/buddypress-activity.js | 7 +++++++
src/bp-templates/bp-nouveau/js/buddypress-activity.min.js | 2 +-
4 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/bp-templates/bp-nouveau/js/bb-activity-reacted.js b/src/bp-templates/bp-nouveau/js/bb-activity-reacted.js
index 6e4ee30233..0521e7f529 100644
--- a/src/bp-templates/bp-nouveau/js/bb-activity-reacted.js
+++ b/src/bp-templates/bp-nouveau/js/bb-activity-reacted.js
@@ -77,7 +77,10 @@ window.bp = window.bp || {};
target.find( '#reaction-content-' + item_id + ' .reaction-loader' ).remove();
target.find( '#reaction-content-' + item_id + ' .activity_reaction_popup_error' ).remove();
- if ( '' === $.trim( target.find( '#reaction-content-' + item_id ).html() ) ) {
+ if ( '' === $.trim( target.find( '#reaction-content-' + item_id ).html() ) || target.parent().hasClass( 'bb-has-reaction_update' ) ) {
+ if ( '' !== $.trim( target.find( '#reaction-content-' + item_id ).html() ) ) {
+ target.find( '#reaction-content-' + item_id ).html('');
+ }
self.collections[ collection_key ] = new bp.Collections.ActivityReactionCollection();
self.loader[ item_id ] = new bp.Views.ReactionPopup(
{
@@ -87,6 +90,7 @@ window.bp = window.bp || {};
item_type: item_type,
}
);
+ target.parent().removeClass( 'bb-has-reaction_update' );
}
target.show();
}
diff --git a/src/bp-templates/bp-nouveau/js/bb-activity-reacted.min.js b/src/bp-templates/bp-nouveau/js/bb-activity-reacted.min.js
index d6018d2fe8..92cc78e85c 100644
--- a/src/bp-templates/bp-nouveau/js/bb-activity-reacted.min.js
+++ b/src/bp-templates/bp-nouveau/js/bb-activity-reacted.min.js
@@ -1 +1 @@
-window.wp=window.wp||{},window.bp=window.bp||{},function(c){"undefined"!=typeof BP_Nouveau&&(_.extend(bp,_.pick(wp,"Backbone","ajax","template")),bp.Models=bp.Models||{},bp.Collections=bp.Collections||{},bp.Views=bp.Views||{},bp.Nouveau=bp.Nouveau||{},bp.Nouveau.ActivityReaction={start:function(){this.views=new Backbone.Collection,this.collections=[],this.types=[],this.fetchXhr=null,this.loader=[],this.loader_html=c('
'),this.addListeners(),this.Initialize()},addListeners:function(){c(document).on("click",".activity-state-reactions",this.showActivityReactions)},Initialize:function(){},showActivityReactions:function(t){t.preventDefault();var e=bp.Nouveau.ActivityReaction,i=c(t.currentTarget),a=i.next(".activity-state-popup"),o=0,t="",t=0 ul")&&(n=this).targetElement.find(".activity-state-popup_tab_item > ul").each(function(){c(this).on("scroll",_.bind(n.onScrollLoadMore,n))})):this.onOpenFailedRender(t,e,i),this},onOpenFailedRender:function(t,e,i){this.loader.remove(),void 0!==e.statusText&&"abort"===e.statusText||(e={collection:i.collection,data:e.success?{}:e.data},this.targetElement.find(".activity_reaction_popup_error").remove(),e=new bp.Views.ReactionErrorHandle(e),this.targetElement.append(e.render().el))},onScrollLoadMore:function(t){var e,i,a,arguments,o,n=t.currentTarget,s=c(n);c(n).hasClass("loading")||(e=n.scrollHeight-s.scrollTop()-s.outerHeight(),i=s.parents(".activity-state-popup_tab_item").attr("data-reaction-id"),a=parseInt(s.parents(".activity-state-popup_tab_item").attr("data-total-pages")),void 0===(o=s.parents(".activity-state-popup_tab_item").attr("data-paged"))&&(o=1),e<=10&&o a",_.bind(this.LoadTabData,this)),this.args={collection:this.options.collection,item_id:this.options.item_id,item_type:this.options.item_type,model:this.model}},render:function(){return this.$el.html(this.template(this.options.data)),this},LoadTabData:function(t){var arguments,e=c(t.currentTarget),i=e.data("tab"),e=e.parents(".activity-state-popup_tab").find("."+i);0
'),this.addListeners(),this.Initialize()},addListeners:function(){c(document).on("click",".activity-state-reactions",this.showActivityReactions)},Initialize:function(){},showActivityReactions:function(t){t.preventDefault();var e=bp.Nouveau.ActivityReaction,i=c(t.currentTarget),a=i.next(".activity-state-popup"),o=0,t="",t=0 ul")&&(n=this).targetElement.find(".activity-state-popup_tab_item > ul").each(function(){c(this).on("scroll",_.bind(n.onScrollLoadMore,n))})):this.onOpenFailedRender(t,e,i),this},onOpenFailedRender:function(t,e,i){this.loader.remove(),void 0!==e.statusText&&"abort"===e.statusText||(e={collection:i.collection,data:e.success?{}:e.data},this.targetElement.find(".activity_reaction_popup_error").remove(),e=new bp.Views.ReactionErrorHandle(e),this.targetElement.append(e.render().el))},onScrollLoadMore:function(t){var e,i,a,arguments,o,n=t.currentTarget,s=c(n);c(n).hasClass("loading")||(e=n.scrollHeight-s.scrollTop()-s.outerHeight(),i=s.parents(".activity-state-popup_tab_item").attr("data-reaction-id"),a=parseInt(s.parents(".activity-state-popup_tab_item").attr("data-total-pages")),void 0===(o=s.parents(".activity-state-popup_tab_item").attr("data-paged"))&&(o=1),e<=10&&o a",_.bind(this.LoadTabData,this)),this.args={collection:this.options.collection,item_id:this.options.item_id,item_type:this.options.item_type,model:this.model}},render:function(){return this.$el.html(this.template(this.options.data)),this},LoadTabData:function(t){var arguments,e=c(t.currentTarget),i=e.data("tab"),e=e.parents(".activity-state-popup_tab").find("."+i);0li.bb-edit-privacy a",bp.Nouveau,this.activityPrivacyRedirect.bind(this)),Z('#buddypress [data-bp-list="activity"], #activity-modal').on("click",".activity-privacy>li:not(.bb-edit-privacy)",bp.Nouveau,this.activityPrivacyChange.bind(this)),Z('#buddypress [data-bp-list="activity"], #bb-media-model-container .activity-list, #activity-modal').on("click","span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),Z("#bb-media-model-container .activity-list").on("click",".activity-item",bp.Nouveau,this.activityActions.bind(this)),Z(".bb-activity-model-wrapper").on("click",".ac-form-placeholder",bp.Nouveau,this.activityRootComment.bind(this)),Z(document).keydown(this.commentFormAction),Z(document).click(this.togglePopupDropdown),Z('#buddypress [data-bp-list="activity"], #bb-media-model-container .activity-list, #activity-modal .activity-list, .bb-modal-activity-footer').on("click",".ac-reply-media-button",this.openCommentsMediaUploader.bind(this)),Z('#buddypress [data-bp-list="activity"], #bb-media-model-container .activity-list, #activity-modal .activity-list, .bb-modal-activity-footer').on("click",".ac-reply-document-button",this.openCommentsDocumentUploader.bind(this)),Z('#buddypress [data-bp-list="activity"], #bb-media-model-container .activity-list, #activity-modal .activity-list, .bb-modal-activity-footer').on("click",".ac-reply-video-button",this.openCommentsVideoUploader.bind(this)),Z('#buddypress [data-bp-list="activity"], #bb-media-model-container .activity-list, #activity-modal .activity-list, .bb-modal-activity-footer').on("click",".ac-reply-gif-button",this.openGifPicker.bind(this)),Z(document).on("click",".activity-state-popup_overlay",bp.Nouveau,this.closeActivityState.bind(this)),Z(document).on("click",".activity-state-popup .activity-state-popup_tab_panel a",this.ReactionStatePopupTab),_.isUndefined(BP_Nouveau.activity.params.autoload)||Z(window).scroll(this.loadMoreActivities),Z(".bb-activity-model-wrapper, .bb-media-model-wrapper").on("click",".acomments-view-more",this.viewMoreComments.bind(this)),Z(document).on("click","#activity-stream .activity-comments .view-more-comments, #activity-stream .activity-state-comments > .comments-count",function(e){e.preventDefault(),Z(this).parents("li.activity-item").find(".activity-comments > ul > li.acomments-view-more, .activity-comments > .activity-actions > ul > li.acomments-view-more").trigger("click")}),Z("#activity-modal > .bb-modal-activity-body").on("scroll",this.autoloadMoreComments.bind(this)),Z("#activity-modal > .bb-modal-activity-body").on("scroll",this.discardGifEmojiPicker.bind(this)),Z(".bb-activity-model-wrapper .bb-model-close-button").on("click",this.activitySyncOnModalClose.bind(this)),void 0!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request?Z("#buddypress").on("bp_ajax_request",'[data-bp-list="activity"]',function(){setTimeout(function(){Z(".ac-form.not-initialized").each(function(){var e=Z(this),t=e.find(".ac-textarea");bp.Nouveau.Activity.toggleMultiMediaOptions(e,t)})},1e3)}):setTimeout(function(){Z(".ac-form.not-initialized").each(function(){var e=Z(this),t=e.find(".ac-textarea");bp.Nouveau.Activity.toggleMultiMediaOptions(e,t)})},1e3)},heartbeatSend:function(e,t){this.heartbeat_data.first_recorded=Z("#buddypress [data-bp-list] [data-bp-activity-id]:not(.bb-pinned)").first().data("bp-timestamp")||0;var a=Z("#buddypress [data-bp-list] [data-bp-activity-id]").first().data("bp-timestamp")||0;a>this.heartbeat_data.first_recorded&&(this.heartbeat_data.first_recorded=a),(0===this.heartbeat_data.last_recorded||this.heartbeat_data.first_recorded>this.heartbeat_data.last_recorded)&&(this.heartbeat_data.last_recorded=this.heartbeat_data.first_recorded),t.bp_activity_last_recorded=this.heartbeat_data.last_recorded,Z("#buddypress .dir-search input[type=search]").length&&(t.bp_activity_last_recorded_search_terms=Z("#buddypress .dir-search input[type=search]").val()),Z.extend(t,{bp_heartbeat:bp.Nouveau.getStorage("bp-activity")})},heartbeatTick:function(e,t){var a,i,o=bp.Nouveau.objects,d=bp.Nouveau.getStorage("bp-activity","scope"),s=this;void 0!==t&&t.bp_activity_newest_activities&&(this.heartbeat_data.newest=Z.trim(t.bp_activity_newest_activities.activities)+this.heartbeat_data.newest,this.heartbeat_data.last_recorded=Number(t.bp_activity_newest_activities.last_recorded),i=Z(this.heartbeat_data.newest).filter(".activity-item"),a=Number(i.length),o.push("mentions"),"all"===d?(Z.each(i,function(e,a){a=Z(a),Z.each(o,function(e,t){-1!==Z.inArray("bp-my-"+t,a.get(0).classList)&&(void 0===s.heartbeat_data.highlights[t]?s.heartbeat_data.highlights[t]=[a.data("bp-activity-id")]:-1===Z.inArray(a.data("bp-activity-id"),s.heartbeat_data.highlights[t])&&s.heartbeat_data.highlights[t].push(a.data("bp-activity-id")))})}),t=new RegExp("bp-my-("+o.join("|")+")","g"),this.heartbeat_data.newest=this.heartbeat_data.newest.replace(t,""),Z(bp.Nouveau.objectNavParent+' [data-bp-scope="all"]').find("a span").html(a)):(this.heartbeat_data.highlights[d]=[],Z.each(i,function(e,t){s.heartbeat_data.highlights[d].push(Z(t).data("bp-activity-id"))})),Z.each(o,function(e,t){var a;void 0!==s.heartbeat_data.highlights[t]&&s.heartbeat_data.highlights[t].length&&(a=0,"mentions"===t&&(a=s.mentions_count),Z(bp.Nouveau.objectNavParent+' [data-bp-scope="'+t+'"]').find("a span").html(Number(s.heartbeat_data.highlights[t].length)+a))}),o.pop(),Z(document).prop("title","("+a+") "+this.heartbeat_data.document_title),Z('#buddypress [data-bp-list="activity"]').first().hasClass("load-newest")?(i=Z('#buddypress [data-bp-list="activity"] .load-newest a').html(),Z('#buddypress [data-bp-list="activity"] .load-newest a').html(i.replace(/([0-9]+)/,a))):Z('#buddypress [data-bp-list="activity"] ul.activity-list').prepend(''+BP_Nouveau.newest+" ("+a+")"),Z('#buddypress [data-bp-list="activity"] li.load-newest').trigger("click"),Z('#buddypress [data-bp-list="activity"]').trigger("bp_heartbeat_pending",this.heartbeat_data),void 0!==bp.Nouveau&&bp.Nouveau.reportPopUp())},injectActivities:function(e){var t,a,i,o,d=bp.Nouveau.getStorage("bp-activity"),s=d.scope||null,d=d.filter||null;Z(e.currentTarget).hasClass("load-newest")?(e.preventDefault(),Z(e.currentTarget).remove(),i=Z.parseHTML(this.heartbeat_data.newest),Z.each(i,function(e,t){"LI"===t.nodeName&&Z(t).hasClass("just-posted")&&Z("#"+Z(t).prop("id")).length&&Z("#"+Z(t).prop("id")).remove()}),(0<(i=Z(e.delegateTarget).find(".activity-list .activity-item").first()).length&&i.hasClass("bb-pinned")?Z(i).after(this.heartbeat_data.newest):Z(e.delegateTarget).find(".activity-list").prepend(this.heartbeat_data.newest)).find("li.activity-item").each(bp.Nouveau.hideSingleUrl).trigger("bp_heartbeat_prepend",this.heartbeat_data),this.heartbeat_data.newest="","all"===s&&Z(bp.Nouveau.objectNavParent+' [data-bp-scope="all"]').find("a span").html(""),"mentions"===s&&(bp.Nouveau.ajax({action:"activity_clear_new_mentions"},"activity"),this.mentions_count=0),Z(bp.Nouveau.objectNavParent+' [data-bp-scope="'+s+'"]').find("a span").html(""),void 0!==this.heartbeat_data.highlights[s]&&(this.heartbeat_data.highlights[s]=[]),setTimeout(function(){Z(e.delegateTarget).find("[data-bp-activity-id]").removeClass("newest_"+s+"_activity")},3e3),Z(document).prop("title",this.heartbeat_data.document_title),jQuery(window).scroll()):Z(e.currentTarget).hasClass("load-more")&&(t=+Number(this.current_page)+1,a=this,i="",e.preventDefault(),(o=Z(e.currentTarget)).find("a").first().addClass("loading"),this.just_posted=[],Z(e.delegateTarget).children(".just-posted").each(function(){a.just_posted.push(Z(this).data("bp-activity-id"))}),Z("#buddypress .dir-search input[type=search]").length&&(i=Z("#buddypress .dir-search input[type=search]").val()),bp.Nouveau.objectRequest({object:"activity",scope:s,filter:d,search_terms:i,page:t,method:"append",exclude_just_posted:this.just_posted.join(","),target:'#buddypress [data-bp-list]:not( #bb-schedule-posts_modal [data-bp-list="activity"] ) ul.bp-list'}).done(function(e){!0===e.success&&(o.remove(),a.current_page=t,jQuery(window).scroll())})),Z(".activity-item.bb-closed-comments").find(".edit-activity, .acomment-edit").parents(".generic-button").hide()},hideComments:function(e){var a,i,o,e=Z(e.target).find(".activity-comments");e.length&&e.each(function(e,t){o=Z(t).children("ul").not(".conflict-activity-ul-li-comment"),(i=Z(o).find("li").not(Z(".document-action-class, .media-action-class, .video-action-class"))).length&&(Z("body").hasClass("activity-singular")&&""!==window.location.hash&&Z(window.location.hash).length&&0!==Z(window.location.hash).closest(".activity-comments").length||(a=Z(t).closest(".activity-item"),Z("#acomment-comment-"+a.data("bp-activity-id")+" span.comment-count").html(),i.each(function(e,t){if(e"),window.location.hash&&"#"+Z(t).attr("id")===window.location.hash)return Z(t).parents("li.comment-item").show(),!1;Z(t).addClass("bp-hidden").hide()}}),Z(o).children(".bp-hidden").length===Z(o).children("li").length-1&&Z(o).find("li.show-all").length&&Z(o).children("li:not(.show-all)").removeClass("bp-hidden").toggle()))})},showActivity:function(e){e.preventDefault();var t=Z(e.currentTarget).parent(),a=t.data("parent_comment_id"),t=Z(t).data("activity_id");Z(document).trigger("activityModalOpened",{activityId:t}),Z(e.currentTarget).parents(".activity-comments").find(".ac-form").each(function(){var e=Z(this),t=Z(this).closest(".activity-comments"),a=Z(this).closest(".comment-item");e.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),bp.Nouveau.Activity.resetActivityCommentForm(e,"hardReset"),t.append(e),a.find(".acomment-display").removeClass("display-focus"),a.removeClass("comment-item-focus")}),bp.Nouveau.Activity.launchActivityPopup(t,a)},closeActivity:function(e){e.preventDefault();var t=Z(e.target).closest(".bb-activity-model-wrapper"),a=t.find(".bb-modal-activity-footer"),i=t.find(".activity-item").data("bp-activity-id"),e=t.find("#ac-form-"+i);bp.Nouveau.Activity.reinitializeActivityCommentForm(e),_.isUndefined(BP_Nouveau.media)||_.isUndefined(BP_Nouveau.media.emoji)||bp.Nouveau.Activity.initializeEmojioneArea(!1,"",i),t.find("#activity-modal").removeClass("bb-closed-comments"),t.closest("body").removeClass("acomments-modal-open"),t.hide(),t.find("ul.activity-list").empty(),a.removeClass("active"),a.find("form.ac-form").remove()},scopeLoaded:function(e,a){this.current_page=1,"mentions"===a.scope&&void 0!==a.response.new_mentions?(Z.each(a.response.new_mentions,function(e,t){Z("#buddypress #activity-stream").find('[data-bp-activity-id="'+t+'"]').addClass("newest_mentions_activity")}),this.mentions_count=0):void 0!==this.heartbeat_data.highlights[a.scope]&&this.heartbeat_data.highlights[a.scope].length&&Z.each(this.heartbeat_data.highlights[a.scope],function(e,t){Z("#buddypress #activity-stream").find('[data-bp-activity-id="'+t+'"]').length&&Z("#buddypress #activity-stream").find('[data-bp-activity-id="'+t+'"]').addClass("newest_"+a.scope+"_activity")}),this.heartbeat_data.newest="",Z.each(Z(bp.Nouveau.objectNavParent+" [data-bp-scope]").find("a span"),function(e,t){0===parseInt(Z(t).html(),10)&&Z(t).html("")}),void 0!==this.heartbeat_data.highlights[a.scope]&&(this.heartbeat_data.highlights[a.scope]=[]),Z(document).prop("title",this.heartbeat_data.document_title),setTimeout(function(){Z("#buddypress #activity-stream .activity-item").removeClass("newest_"+a.scope+"_activity")},3e3),void 0!==window.instgrm&&window.instgrm.Embeds.process(),void 0!==window.FB&&void 0!==window.FB.XFBML&&window.FB.XFBML.parse(),this.fixAtWhoActivity(),this.openEditActivityPopup(),this.navigateToSpecificComment(),setTimeout(function(){jQuery(window).scroll()},200)},openEditActivityPopup:function(){var e,t;!_.isUndefined(BP_Nouveau.activity.params.is_activity_edit)&&0 ul");if(e.data.redirect)return window.location.href=e.data.redirect;e.data.parent_activity_id&&e.data.activity&&Z("body:not(.activity-singular) #buddypress #activity-stream ul.activity-list li#activity-"+e.data.parent_activity_id).replaceWith(e.data.activity),k&&(x=1,i=B.find(".acomments-view-more").data("child-count"),c.append(B.find("form")),Z.each(B.find("li.comment-item"),function(){x+=1}),x+=void 0!==i?parseFloat(i):0,N=m.find("span.comments-count"),z=N.text().length?N.text().match(/\d+/)[0]:0,z=Number(z-x),p.length?(i=1 ul").html().trim()&&t.removeClass("has-child-comments")}),k||c.data("bp-timestamp")!==d.Activity.heartbeat_data.last_recorded||(d.Activity.heartbeat_data.newest="",d.Activity.heartbeat_data.last_recorded=0),Z(document).trigger("bp_activity_ajax_delete_request",Z.extend(A,{response:e})),Z(document).trigger("bp_activity_ajax_delete_request_video",Z.extend(A,{response:e})),bp.Nouveau.Activity.activityHasUpdates=!0,bp.Nouveau.Activity.currentActivityId=r}P.removeClass("active")})}if(l.closest("span").hasClass("activity-read-more")){var T=l.closest("div"),U=l.closest("span");if(C=null,Z(T).hasClass("activity-inner")?C=r:Z(T).hasClass("acomment-content")&&(C=l.closest("li").data("bp-activity-comment-id")),!C)return e;e.preventDefault(),Z(U).addClass("loading"),d.ajax({action:"get_single_activity_content",id:C},"activity").done(function(e){"object"!=typeof e&&0@'+L+" ";_.isUndefined(BP_Nouveau.activity.params.user_id)||(D=BP_Nouveau.activity.params.user_id);var L={offset:-(Z(window).height()/2-75),easing:"swing"},I=M.get(0);jQuery("body").hasClass("bb-is-mobile")?setTimeout(function(){var e=300/gi,"\n").replace(/<\/div>/gi,""),O={action:"new_activity_comment",_wpnonce_new_activity_comment:Z("#_wpnonce_new_activity_comment").val(),comment_id:C,form_id:r,content:H};Z("#_bp_as_nonce_"+r).val()&&(O["_bp_as_nonce_"+r]=Z("#_bp_as_nonce_"+r).val()),this.dropzone_media.length&&(O.media=this.dropzone_media),this.dropzone_document.length&&(O.document=this.dropzone_document),this.dropzone_video.length&&(O.video=this.dropzone_video,_.isEmpty(O.content)&&(O.content="")),_.isUndefined(this.models[r])||(n=this.models[r],O.gif_data=this.models[r].get("gif_data")),O.content=O.content.replace(/ /g," "),s.hasClass("acomment-edit")&&(O.edit_comment=!0);var Q=0"):t.append("")),Q?s.closest("#activity-modal").find(".bb-modal-activity-body .activity-comments, .bb-modal-activity-body .activity-comments .activity-actions").children("ul").append(Z(a)):t.children("ul").append(Z(a).hide().fadeIn(200)),Z(s).find(".ac-input").first().html(""),t.parent().addClass("has-comments"),t.parent().addClass("comments-loaded"),m.addClass("has-comments")),s.removeClass("acomment-edit");t=s.find(".ac-reply-content");if(0'+BP_Nouveau.activity.strings.commentPostError+""):(e=e.responseJSON&&e.responseJSON.message?e.responseJSON.message:e.statusText,s.find(".ac-reply-content").after(''+e+"
"))})}if(l.hasClass("edit")&&l.hasClass("edit-activity")&&(e.preventDefault(),H=c.data("bp-activity"),O=""!==c.data("link-url")?c.data("link-url"):null,void 0!==H&&(bp.Nouveau.Activity.postForm.displayEditActivityForm(H,O),l.closest("li").hasClass("groups")?Z("#bp-nouveau-activity-form").addClass("group-activity"):Z("#bp-nouveau-activity-form").removeClass("group-activity"),void 0!==bp.Nouveau.Media&&void 0!==bp.Nouveau.Media.Theatre&&(bp.Nouveau.Media.Theatre.is_open_media||bp.Nouveau.Media.Theatre.is_open_document)&&(Z(document).find(".bb-close-media-theatre").trigger("click"),Z(document).find(".bb-close-document-theatre").trigger("click")))),v&&(l.hasClass("bb-open-media-theatre")||l.hasClass("bb-open-video-theatre")||l.hasClass("bb-open-document-theatre")||l.hasClass("document-detail-wrap-description-popup"))&&(e.preventDefault(),l.closest("#activity-modal").find(".bb-modal-activity-header .bb-close-action-popup").trigger("click")),l.hasClass("pin-activity")||l.hasClass("unpin-activity")){if(e.preventDefault(),!r)return e;l.closest(".activity-item").addClass("loading-pin");var V="pin";l.hasClass("unpin-activity")&&(V="unpin"),d.ajax({action:"activity_update_pinned_post",id:r,pin_action:V},"activity").done(function(e){var t,a,i,o,d,s,n;l.closest(".activity-item").removeClass("loading-pin"),void 0!==(e="object"!=typeof e?JSON.parse(e):e).data&&void 0!==e.data.feedback&&(t=l.closest("ul.activity-list"),n=v?l.closest(".buddypress-wrap").find("#activity-stream"):l.closest("#activity-stream"),e.success&&(a=bp.Nouveau.getStorage("bp-activity","scope"),o=i=!1,d="",l.closest("li.activity-item").hasClass("groups")&&(o=!0,d=(d=l.closest("li.activity-item").attr("class").match(/group-\d+/))[0].replace("group-","")),n.hasClass("single-user")?i=!1:(n.hasClass("activity")&&"all"===a&&!o||n.hasClass("single-group"))&&(i=!0),"pin"===V?(i&&t.find("li.activity-item").removeClass("bb-pinned"),s="li.activity-item:not(.groups)",o&&!n.hasClass("single-group")?s="li.activity-item.group-"+d:o&&n.hasClass("single-group")&&(s="li.activity-item"),t.find(s).each(function(){var e=Z(this).find(".unpin-activity");e.removeClass("unpin-activity").addClass("pin-activity"),o?e.find("span").html(BP_Nouveau.activity.strings.pinGroupPost):e.find("span").html(BP_Nouveau.activity.strings.pinPost)}),i&&l.closest("li.activity-item").addClass("bb-pinned"),l.addClass("unpin-activity"),l.removeClass("pin-activity"),l.closest("li.activity-item").hasClass("groups")?l.find("span").html(BP_Nouveau.activity.strings.unpinGroupPost):l.find("span").html(BP_Nouveau.activity.strings.unpinPost)):"unpin"===V&&(l.closest("li.activity-item").removeClass("bb-pinned"),l.addClass("pin-activity"),l.removeClass("unpin-activity"),l.closest("li.activity-item").hasClass("groups")?l.find("span").html(BP_Nouveau.activity.strings.pinGroupPost):l.find("span").html(BP_Nouveau.activity.strings.pinPost)),"all"===a&&i&&(bp.Nouveau.Activity.heartbeat_data.last_recorded=0,bp.Nouveau.refreshActivities())),Z(document).trigger("bb_trigger_toast_message",["",""+e.data.feedback+"
","success",null,!0]))}).fail(function(){l.closest(".activity-item").removeClass("loading-pin"),Z(document).trigger("bb_trigger_toast_message",["",""+BP_Nouveau.activity.strings.pinPostError+"
","error",null,!0])})}if(l.hasClass("bb-icon-bell-slash")||l.hasClass("bb-icon-bell")){if(e.preventDefault(),!r)return e;l.closest(".activity-item").addClass("loading-mute");var q="mute";l.hasClass("bb-icon-bell")&&(q="unmute"),d.ajax({action:"toggle_activity_notification_status",id:r,notification_toggle_action:q},"activity").done(function(e){l.closest(".activity-item").removeClass("loading-mute"),void 0!==(e="object"!=typeof e?JSON.parse(e):e).data&&void 0!==e.data.feedback&&(e.success&&("mute"===q?(l.closest("li.activity-item").addClass("bb-muted"),l.removeClass("bb-icon-bell-slash"),l.addClass("bb-icon-bell"),l.attr("title",BP_Nouveau.activity.strings.unmuteNotification),l.find("span").html(BP_Nouveau.activity.strings.unmuteNotification)):"unmute"===q&&(l.closest("li.activity-item").removeClass("bb-muted"),l.removeClass("bb-icon-bell"),l.addClass("bb-icon-bell-slash"),l.attr("title",BP_Nouveau.activity.strings.muteNotification),l.find("span").html(BP_Nouveau.activity.strings.muteNotification)),void 0!==bp.Nouveau.Activity.activityHasUpdates&&(bp.Nouveau.Activity.activityHasUpdates=!0)),Z(document).trigger("bb_trigger_toast_message",["",""+e.data.feedback+"
","success",null,!0])),v&&(bp.Nouveau.Activity.activityPinHasUpdates=!0),bp.Nouveau.Activity.activityHasUpdates=!0,bp.Nouveau.Activity.currentActivityId=r}).fail(function(){l.closest(".activity-item").removeClass("loading-pin"),Z(document).trigger("bb_trigger_toast_message",["",""+BP_Nouveau.activity.strings.pinPostError+"
","error",null,!0])})}if(l.hasClass("close-activity-comment")||l.hasClass("unclose-activity-comment")){if(e.preventDefault(),!r)return e;l.closest(".activity-item").addClass("loading-pin");var W="close_comments";l.hasClass("unclose-activity-comment")&&(W="unclose_comments"),d.ajax({action:"activity_update_close_comments",id:r,close_comments_action:W},"activity").done(function(e){var t;l.closest(".activity-item").removeClass("loading-pin"),void 0!==(e="object"!=typeof e?JSON.parse(e):e).data&&void 0!==e.data.feedback&&(e.success&&(t=Z("#activity-stream > .activity-list").find("[data-bp-activity-id="+r+"]"),l.closest(".activity-item").find(".bb-activity-closed-comments-notice").remove(),"close_comments"===W?(l.closest("li.activity-item").addClass("bb-closed-comments"),0