From 6813cf178ff5d6bd743563b7b534e2574adf4a91 Mon Sep 17 00:00:00 2001
From: Jitendra Banjara li.bb-edit-privacy a",bp.Nouveau,this.activityPrivacyRedirect.bind(this)),q('#buddypress [data-bp-list="activity"], #activity-modal').on("click",".activity-privacy>li:not(.bb-edit-privacy)",bp.Nouveau,this.activityPrivacyChange.bind(this)),q('#buddypress [data-bp-list="activity"], #bb-media-model-container .activity-list, #activity-modal').on("click","span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),q("#bb-media-model-container .activity-list").on("click",".activity-item",bp.Nouveau,this.activityActions.bind(this)),q(".bb-activity-model-wrapper").on("click",".ac-form-placeholder",bp.Nouveau,this.activityRootComment.bind(this)),q(document).keydown(this.commentFormAction),q(document).click(this.togglePopupDropdown),q('#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)),q('#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)),q('#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)),q('#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)),q(document).on("click",".activity-state-popup_overlay",bp.Nouveau,this.closeActivityState.bind(this)),q(document).on("click",".activity-state-popup .activity-state-popup_tab_panel a",this.ReactionStatePopupTab),_.isUndefined(BP_Nouveau.activity.params.autoload)||q(window).scroll(this.loadMoreActivities),q(document).on("click",".bb-subnav-filters-container .subnav-filters-opener",this.openActivityFilter.bind(this)),q(document).on("click",this.closeActivityFilter.bind(this)),q(document).on("click",".bb-subnav-filters-container .subnav-filters-modal a:not(.layout-view)",this.filterActivity.bind(this)),q(".bb-activity-model-wrapper, .bb-media-model-wrapper").on("click",".acomments-view-more",this.viewMoreComments.bind(this)),q(document).on("click","#activity-stream .activity-comments .view-more-comments, #activity-stream .activity-state-comments > .comments-count",function(e){e.preventDefault(),q(this).parents("li.activity-item").find(".activity-comments > ul > li.acomments-view-more, .activity-comments > .activity-actions > ul > li.acomments-view-more").trigger("click")}),q("#activity-modal > .bb-modal-activity-body").on("scroll",this.autoloadMoreComments.bind(this)),q("#activity-modal > .bb-modal-activity-body").on("scroll",this.discardGifEmojiPicker.bind(this)),q(".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?q("#buddypress").on("bp_ajax_request",'[data-bp-list="activity"]',function(){setTimeout(function(){q(".ac-form.not-initialized").each(function(){var e=q(this),t=e.find(".ac-textarea");bp.Nouveau.Activity.toggleMultiMediaOptions(e,t)})},1e3)}):setTimeout(function(){q(".ac-form.not-initialized").each(function(){var e=q(this),t=e.find(".ac-textarea");bp.Nouveau.Activity.toggleMultiMediaOptions(e,t)})},1e3),bp.Nouveau.wrapNavigation(".activity-topic-selector ul",120,!0)},heartbeatSend:function(e,t){q(bp.Nouveau.objectNavParent+" [data-bp-orderby=date_updated].selected").length?void 0!==(a=q("#buddypress [data-bp-list] [data-bp-activity-id]:not(.bb-pinned)").first()).data("bb-updated-timestamp")?this.heartbeat_data.first_recorded=a.data("bb-updated-timestamp"):a.length&&void 0!==a.data("bp-activity").date_updated&&""!==a.data("bp-activity").date_updated?(o=a.data("bp-activity").date_updated,o=new Date(o.replace(" ","T")+"Z").getTime()/1e3,this.heartbeat_data.first_recorded=o):this.heartbeat_data.first_recorded=a.data("bp-timestamp")||0:this.heartbeat_data.first_recorded=q("#buddypress [data-bp-list] [data-bp-activity-id]:not(.bb-pinned)").first().data("bp-timestamp")||0;var a,i,o=q("#buddypress [data-bp-list] [data-bp-activity-id]").first().data("bp-timestamp")||0;o>this.heartbeat_data.first_recorded&&(this.heartbeat_data.first_recorded=o),(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,q("#buddypress .activity-head-bar .activity-search input[type=search]").length&&(t.bp_activity_last_recorded_search_terms=q("#buddypress .activity-head-bar .activity-search input[type=search]").val()),q.extend(t,{bp_heartbeat:(a={scope:"all"},q("body.my-activity:not(.activity-singular)").length?a=bp.Nouveau.getStorage("bp-user-activity")||{scope:"just-me"}:(a=bp.Nouveau.getStorage("bp-activity")||{scope:"all"},q("body.activity.buddypress.groups.single-item").length&&(a.scope="all")),q(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").length&&(i=q(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").data("bp-scope"),void 0!==a.scope&&a.scope===i||(a.scope=i,"undefined"!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request&&(q("body.my-activity:not(.activity-singular)").length?bp.Nouveau.setStorage("bp-user-activity","scope",i):bp.Nouveau.setStorage("bp-activity","scope",i)))),q(bp.Nouveau.objectNavParent+" [data-bp-order].selected").length&&(i=q(bp.Nouveau.objectNavParent+" [data-bp-order].selected").data("bp-orderby"),a.order_by=i),(i=bp.Nouveau.getStorage("bp-activity","topic_id"))&&(t.bp_heartbeat=t.bp_heartbeat||{},t.bp_heartbeat.topic_id=i),a)})},heartbeatTick:function(e,t){var a,i,o=bp.Nouveau.objects,d=bp.Nouveau.getStorage("bp-activity","scope"),s=this,n=bp.Nouveau.getStorage("bp-activity","topic_id");void 0!==t&&t.bp_activity_newest_activities&&(this.heartbeat_data.newest=q.trim(t.bp_activity_newest_activities.activities)+this.heartbeat_data.newest,this.heartbeat_data.last_recorded=Number(t.bp_activity_newest_activities.last_recorded),t=q(this.heartbeat_data.newest).filter(".activity-item"),n&&(a=(t=t.filter(function(){var e=this.dataset.bpActivity?JSON.parse(this.dataset.bpActivity):null,e=e&&void 0!==e.topic_id?e.topic_id:null;return e&&parseInt(e)===parseInt(n)})).length),a=Number(t.length),o.push("mentions"),"all"===d?(q.each(t,function(e,a){a=q(a),q.each(o,function(e,t){-1!==q.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===q.inArray(a.data("bp-activity-id"),s.heartbeat_data.highlights[t])&&s.heartbeat_data.highlights[t].push(a.data("bp-activity-id")))})}),i=new RegExp("bp-my-("+o.join("|")+")","g"),this.heartbeat_data.newest=this.heartbeat_data.newest.replace(i,""),q(bp.Nouveau.objectNavParent+' [data-bp-scope="all"]').find("a span").html(a)):(this.heartbeat_data.highlights[d]=[],q.each(t,function(e,t){s.heartbeat_data.highlights[d].push(q(t).data("bp-activity-id"))})),q.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),q(bp.Nouveau.objectNavParent+' [data-bp-scope="'+t+'"]').find("a span").html(Number(s.heartbeat_data.highlights[t].length)+a))}),o.pop(),q(document).prop("title","("+a+") "+this.heartbeat_data.document_title),q('#buddypress [data-bp-list="activity"]').first().hasClass("load-newest")?(i=q('#buddypress [data-bp-list="activity"] .load-newest a').html(),q('#buddypress [data-bp-list="activity"] .load-newest a').html(i.replace(/([0-9]+)/,a))):q('#buddypress [data-bp-list="activity"] ul.activity-list').prepend('
"):t.append("
")),t.children("ul").append(q(d).hide().fadeIn(200))),q(r).find(".ac-input").first().html(""),t.parent().addClass("has-comments"),t.parent().addClass("comments-loaded"),u.addClass("has-comments")),r.removeClass("acomment-edit"),r.find(".ac-reply-content"));if(0
"+e.data.message+"
ul > li.acomments-view-more:not(.loading), .bb-modal-activity-body .activity-comments .activity-actions > ul > li.acomments-view-more:not(.loading)"),t=q(".bb-activity-model-wrapper .bb-modal-activity-body"),o=q(".bb-activity-model-wrapper .bb-modal-activity-body").find(".activity-comments:not(.active)"),0a&&q(e).trigger("click").addClass("loading"),setTimeout(function(){jQuery(window).scroll()},200))},activitySyncOnModalClose:function(e,t){e.preventDefault();var e=(q(e.currentTarget).is(document)?q(".bb-activity-model-wrapper"):q(e.currentTarget).parents(".bb-activity-model-wrapper")).find("ul.activity-list > li").data("bp-activity-id"),t=void 0!==t?t:e,a=q("#activity-stream li.activity-item[data-bp-activity-id="+t+"]");void 0!==bp.Nouveau.Activity.activityPinHasUpdates&&bp.Nouveau.Activity.activityPinHasUpdates?(0 .bb-modal-activity-body .activity-item").data("bp-activity-id");0 /gi,"\n").replace(/<\/div>/gi,""));t=t.replace(/ /g," "),""!==e.text()||0<=t.indexOf("emojioneemoji")?e.closest("form").addClass("has-content"):e.closest("form").removeClass("has-content")},picker_show:function(){q(this.button[0]).closest(".post-emoji").addClass("active"),q(".emojionearea-theatre").removeClass("hide").addClass("show")},picker_hide:function(){q(this.button[0]).closest(".post-emoji").removeClass("active"),q(".emojionearea-theatre").removeClass("show").addClass("hide")}}})},openActivityFilter:function(e){e.preventDefault(),q(".bb-subnav-filters-container:not(.bb-subnav-filters-search)").removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false");e=q(e.currentTarget).parent(".bb-subnav-filters-container");e.addClass("active").find(".subnav-filters-opener").attr("aria-expanded","true"),e.find('input[type="search"]').length&&e.find('input[type="search"]').focus()},closeActivityFilter:function(e){q(e.target).closest(".bb-subnav-filters-container").length||q.each(q(".bb-subnav-filters-container"),function(){(!q(this).hasClass("bb-subnav-filters-search")||""===q(this).find('input[name="activity_search"]').val())&&q(this).removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false")})},filterActivity:function(e){e.preventDefault();var e=q(e.currentTarget),t=e.closest(".bb-subnav-filters-container"),a=(e.parent().addClass("selected").siblings().removeClass("selected"),t.removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false"),e.parent().data("filter-label")),t=(t.find(".subnav-filters-opener .selected").text(a||e.text()),bp.Nouveau.Activity.current_page=1,bp.Nouveau.objectNavParent),a="activity",i=q("#buddypress").find('[data-bp-filter="'+a+'"]').first().val(),o="",d="",s="",n="",c=!1,r=!1,t=(q(t+" [data-bp-object].selected").length&&(o=q(t+" [data-bp-object].selected").data("bp-scope"),e.closest("#bb-subnav-filter-show").length)&&(c=!0,q("body").hasClass("my-activity"))&&(r=!(c=!1)),q('#buddypress [data-bp-search="'+a+'"] input[type=search]').length&&(d=q('#buddypress [data-bp-search="'+a+'"] input[type=search]').val()),q(t+" [data-bp-order]").length&&(s=q(t+' [data-bp-order="'+a+'"].selected').data("bp-orderby")),bp.Nouveau.getStorage("bp-"+a)),a=(void 0!==t.extras&&(n=t.extras),bp.Nouveau.Activity.heartbeat_data.last_recorded=0,{object:a,scope:o,filter:i,search_terms:d,extras:n,order_by:s,save_scope:c,event_element:e});r&&(a.user_timeline=!0),t.topic_id&&(a.topic_id=t.topic_id),bp.Nouveau.objectRequest(a)}},bp.Nouveau.Activity.start())})((bp,jQuery)); \ No newline at end of file +window.bp=window.bp||{},(q=>{"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},bp.Models=bp.Models||{},bp.Models.ACReply=Backbone.Model.extend({defaults:{gif_data:{}}}),bp.Nouveau.Activity={start:function(){this.setupGlobals(),this.addListeners()},invokeMediaFn:function(e){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media[e]&&bp.Nouveau.Media[e]()},setupGlobals:function(){this.just_posted=[],this.current_page=1,this.mentions_count=Number(q(bp.Nouveau.objectNavParent+' [data-bp-scope="mentions"]').find("a span").html())||0,this.heartbeat_data={newest:"",highlights:{},last_recorded:0,first_recorded:0,document_title:q(document).prop("title")},void 0!==window.Dropzone&&void 0!==BP_Nouveau.media&&(window.Dropzone.autoDiscover=!1,this.dropzone_options={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,dictDefaultMessage:BP_Nouveau.media.dropzone_media_message,acceptedFiles:"image/*",autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.media.maxFiles?BP_Nouveau.media.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2,dictMaxFilesExceeded:BP_Nouveau.media.media_dict_file_exceeded,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation,maxThumbnailFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2},void 0!==BP_Nouveau.media.dropzone_options)&&Object.assign(this.dropzone_options,BP_Nouveau.media.dropzone_options),this.dropzone_obj=null,this.dropzone_media=[],this.dropzone_document_obj=null,this.dropzone_document=[],this.dropzone_video_obj=null,this.dropzone_video=[],this.models=[],this.InitiatedCommentForms=[],this.activityHasUpdates=!1,this.currentActivityId=null,this.activityPinHasUpdates=!1},addListeners:function(){q("body").hasClass("activity-singular")||q("#buddypress").on("bp_heartbeat_send",this.heartbeatSend.bind(this)),q("#buddypress").on("bp_heartbeat_tick",this.heartbeatTick.bind(this)),q(".actvity-head-bar").length&&(q(".actvity-head-bar").addClass("activity-head-bar").removeClass("actvity-head-bar"),q(".activity-head-bar > nav.activity-type-navs").length)&&q(".activity-head-bar .bb-subnav-filters-filtering").length&&q(".activity-head-bar > nav.activity-type-navs").remove(),q('#buddypress [data-bp-list="activity"]:not( #bb-schedule-posts_modal [data-bp-list="activity"] )').on("click","li.load-newest, li.load-more",this.injectActivities.bind(this)),void 0!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request?q("#buddypress").on("bp_ajax_request",'[data-bp-list="activity"]',this.scopeLoaded.bind(this)):q(window).on("load",function(){setTimeout(function(){bp.Nouveau.Activity.openEditActivityPopup()}.bind(this),0)}),q("#activity-stream").on("click",".acomments-view-more",this.showActivity),q("body").on("click",".bb-close-action-popup",this.closeActivity),q(document).on("activityModalOpened",function(e,t){var a=t.activityId;q(document).on("click",".bb-activity-model-wrapper.activity-theatre",function(e){!(0li.bb-edit-privacy a",bp.Nouveau,this.activityPrivacyRedirect.bind(this)),q('#buddypress [data-bp-list="activity"], #activity-modal').on("click",".activity-privacy>li:not(.bb-edit-privacy)",bp.Nouveau,this.activityPrivacyChange.bind(this)),q('#buddypress [data-bp-list="activity"], #bb-media-model-container .activity-list, #activity-modal').on("click","span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),q("#bb-media-model-container .activity-list").on("click",".activity-item",bp.Nouveau,this.activityActions.bind(this)),q(".bb-activity-model-wrapper").on("click",".ac-form-placeholder",bp.Nouveau,this.activityRootComment.bind(this)),q(document).keydown(this.commentFormAction),q(document).click(this.togglePopupDropdown),q('#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)),q('#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)),q('#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)),q('#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)),q(document).on("click",".activity-state-popup_overlay",bp.Nouveau,this.closeActivityState.bind(this)),q(document).on("click",".activity-state-popup .activity-state-popup_tab_panel a",this.ReactionStatePopupTab),_.isUndefined(BP_Nouveau.activity.params.autoload)||q(window).scroll(this.loadMoreActivities),q(document).on("click",".bb-subnav-filters-container .subnav-filters-opener",this.openActivityFilter.bind(this)),q(document).on("click",this.closeActivityFilter.bind(this)),q(document).on("click",".bb-subnav-filters-container .subnav-filters-modal a:not(.layout-view)",this.filterActivity.bind(this)),q(".bb-activity-model-wrapper, .bb-media-model-wrapper").on("click",".acomments-view-more",this.viewMoreComments.bind(this)),q(document).on("click","#activity-stream .activity-comments .view-more-comments, #activity-stream .activity-state-comments > .comments-count",function(e){e.preventDefault(),q(this).parents("li.activity-item").find(".activity-comments > ul > li.acomments-view-more, .activity-comments > .activity-actions > ul > li.acomments-view-more").trigger("click")}),q("#activity-modal > .bb-modal-activity-body").on("scroll",this.autoloadMoreComments.bind(this)),q("#activity-modal > .bb-modal-activity-body").on("scroll",this.discardGifEmojiPicker.bind(this)),q(".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?q("#buddypress").on("bp_ajax_request",'[data-bp-list="activity"]',function(){setTimeout(function(){q(".ac-form.not-initialized").each(function(){var e=q(this),t=e.find(".ac-textarea");bp.Nouveau.Activity.toggleMultiMediaOptions(e,t)})},1e3)}):setTimeout(function(){q(".ac-form.not-initialized").each(function(){var e=q(this),t=e.find(".ac-textarea");bp.Nouveau.Activity.toggleMultiMediaOptions(e,t)})},1e3),bp.Nouveau.wrapNavigation(".activity-topic-selector ul",120,!0)},heartbeatSend:function(e,t){q(bp.Nouveau.objectNavParent+" [data-bp-orderby=date_updated].selected").length?void 0!==(a=q("#buddypress [data-bp-list] [data-bp-activity-id]:not(.bb-pinned)").first()).data("bb-updated-timestamp")?this.heartbeat_data.first_recorded=a.data("bb-updated-timestamp"):a.length&&void 0!==a.data("bp-activity").date_updated&&""!==a.data("bp-activity").date_updated?(o=a.data("bp-activity").date_updated,o=new Date(o.replace(" ","T")+"Z").getTime()/1e3,this.heartbeat_data.first_recorded=o):this.heartbeat_data.first_recorded=a.data("bp-timestamp")||0:this.heartbeat_data.first_recorded=q("#buddypress [data-bp-list] [data-bp-activity-id]:not(.bb-pinned)").first().data("bp-timestamp")||0;var a,i,o=q("#buddypress [data-bp-list] [data-bp-activity-id]").first().data("bp-timestamp")||0;o>this.heartbeat_data.first_recorded&&(this.heartbeat_data.first_recorded=o),(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,q("#buddypress .activity-head-bar .activity-search input[type=search]").length&&(t.bp_activity_last_recorded_search_terms=q("#buddypress .activity-head-bar .activity-search input[type=search]").val()),q.extend(t,{bp_heartbeat:(a={scope:"all"},q("body.my-activity:not(.activity-singular)").length?a=bp.Nouveau.getStorage("bp-user-activity")||{scope:"just-me"}:(a=bp.Nouveau.getStorage("bp-activity")||{scope:"all"},q("body.activity.buddypress.groups.single-item").length&&(a.scope="all")),q(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").length&&(i=q(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").data("bp-scope"),void 0!==a.scope&&a.scope===i||(a.scope=i,"undefined"!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request&&(q("body.my-activity:not(.activity-singular)").length?bp.Nouveau.setStorage("bp-user-activity","scope",i):bp.Nouveau.setStorage("bp-activity","scope",i)))),q(bp.Nouveau.objectNavParent+" [data-bp-order].selected").length&&(i=q(bp.Nouveau.objectNavParent+" [data-bp-order].selected").data("bp-orderby"),a.order_by=i),(i=bp.Nouveau.getStorage("bp-activity","topic_id"))&&(t.bp_heartbeat=t.bp_heartbeat||{},t.bp_heartbeat.topic_id=i),a)})},heartbeatTick:function(e,t){var a,i,o=bp.Nouveau.objects,d=bp.Nouveau.getStorage("bp-activity","scope"),s=this,n=bp.Nouveau.getStorage("bp-activity","topic_id");void 0!==t&&t.bp_activity_newest_activities&&(this.heartbeat_data.newest=q.trim(t.bp_activity_newest_activities.activities)+this.heartbeat_data.newest,this.heartbeat_data.last_recorded=Number(t.bp_activity_newest_activities.last_recorded),t=q(this.heartbeat_data.newest).filter(".activity-item"),n&&(a=(t=t.filter(function(){var e=this.dataset.bpActivity?JSON.parse(this.dataset.bpActivity):null,e=e&&void 0!==e.topic_id?e.topic_id:null;return e&&parseInt(e)===parseInt(n)})).length),a=Number(t.length),o.push("mentions"),"all"===d?(q.each(t,function(e,a){a=q(a),q.each(o,function(e,t){-1!==q.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===q.inArray(a.data("bp-activity-id"),s.heartbeat_data.highlights[t])&&s.heartbeat_data.highlights[t].push(a.data("bp-activity-id")))})}),i=new RegExp("bp-my-("+o.join("|")+")","g"),this.heartbeat_data.newest=this.heartbeat_data.newest.replace(i,""),q(bp.Nouveau.objectNavParent+' [data-bp-scope="all"]').find("a span").html(a)):(this.heartbeat_data.highlights[d]=[],q.each(t,function(e,t){s.heartbeat_data.highlights[d].push(q(t).data("bp-activity-id"))})),q.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),q(bp.Nouveau.objectNavParent+' [data-bp-scope="'+t+'"]').find("a span").html(Number(s.heartbeat_data.highlights[t].length)+a))}),o.pop(),q(document).prop("title","("+a+") "+this.heartbeat_data.document_title),q('#buddypress [data-bp-list="activity"]').first().hasClass("load-newest")?(i=q('#buddypress [data-bp-list="activity"] .load-newest a').html(),q('#buddypress [data-bp-list="activity"] .load-newest a').html(i.replace(/([0-9]+)/,a))):q('#buddypress [data-bp-list="activity"] ul.activity-list').prepend(''+BP_Nouveau.newest+" ("+a+") "),q('#buddypress [data-bp-list="activity"] li.load-newest').trigger("click"),q('#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=q("body.my-activity:not(.activity-singular)").length?bp.Nouveau.getStorage("bp-user-activity"):bp.Nouveau.getStorage("bp-activity"),s=d.scope||null,d=d.filter||null;q(e.currentTarget).hasClass("load-newest")?(e.preventDefault(),q(e.currentTarget).remove(),i=q.parseHTML(this.heartbeat_data.newest),q.each(i,function(e,t){"LI"===t.nodeName&&q(t).hasClass("just-posted")&&q("#"+q(t).prop("id")).length&&q("#"+q(t).prop("id")).remove()}),(0<(i=q(e.delegateTarget).find(".activity-list .activity-item").first()).length&&i.hasClass("bb-pinned")?q(i).after(this.heartbeat_data.newest):q(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&&q(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),q(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(){q(e.delegateTarget).find("[data-bp-activity-id]").removeClass("newest_"+s+"_activity")},3e3),q(document).prop("title",this.heartbeat_data.document_title),jQuery(window).scroll()):q(e.currentTarget).hasClass("load-more")&&(t=+Number(this.current_page)+1,a=this,i="",e.preventDefault(),(o=q(e.currentTarget)).find("a").first().addClass("loading"),this.just_posted=[],q(e.delegateTarget).children(".just-posted").each(function(){a.just_posted.push(q(this).data("bp-activity-id"))}),q("#buddypress .dir-search input[type=search]").length?i=q("#buddypress .dir-search input[type=search]").val():q("#buddypress .activity-search.bp-search input[type=search]").length&&(i=q("#buddypress .activity-search.bp-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())})),q(".activity-item.bb-closed-comments").find(".edit-activity, .acomment-edit").parents(".generic-button").hide()},hideComments:function(e){var a,i,o,e=q(e.target).find(".activity-comments");e.length&&e.each(function(e,t){o=q(t).children("ul").not(".conflict-activity-ul-li-comment"),!(i=q(o).find("li").not(q(".document-action-class, .media-action-class, .video-action-class"))).length||q("body").hasClass("activity-singular")&&""!==window.location.hash&&q(window.location.hash).length&&0!==q(window.location.hash).closest(".activity-comments").length||(a=q(t).closest(".activity-item"),q("#acomment-comment-"+a.data("bp-activity-id")+" span.comment-count").html(),i.each(function(e,t){if(e"),window.location.hash&&"#"+q(t).attr("id")===window.location.hash)return q(t).parents("li.comment-item").show(),!1;q(t).addClass("bp-hidden").hide()}}),q(o).children(".bp-hidden").length===q(o).children("li").length-1&&q(o).find("li.show-all").length&&q(o).children("li:not(.show-all)").removeClass("bp-hidden").toggle())})},showActivity:function(e){e.preventDefault();var t=q(e.currentTarget).parent(),a=t.data("parent_comment_id"),t=q(t).data("activity_id");q(document).trigger("activityModalOpened",{activityId:t}),q(e.currentTarget).parents(".activity-comments").find(".ac-form").each(function(){var e=q(this),t=q(this).closest(".activity-comments"),a=q(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 e=q(e.target).closest(".bb-activity-model-wrapper"),t=e.find(".bb-modal-activity-footer"),a=e.find(".activity-item").data("bp-activity-id"),i=e.find("#ac-form-"+a);bp.Nouveau.Activity.reinitializeActivityCommentForm(i),_.isUndefined(BP_Nouveau.media)||_.isUndefined(BP_Nouveau.media.emoji)||bp.Nouveau.Activity.initializeEmojioneArea(!1,"",a),e.find("#activity-modal").removeClass("bb-closed-comments"),e.closest("body").removeClass("acomments-modal-open"),e.hide(),e.find("ul.activity-list").empty(),t.removeClass("active"),t.find("form.ac-form").remove()},scopeLoaded:function(e,a){this.current_page=1,"mentions"===a.scope&&void 0!==a.response.new_mentions?(q.each(a.response.new_mentions,function(e,t){q("#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&&q.each(this.heartbeat_data.highlights[a.scope],function(e,t){q("#buddypress #activity-stream").find('[data-bp-activity-id="'+t+'"]').length&&q("#buddypress #activity-stream").find('[data-bp-activity-id="'+t+'"]').addClass("newest_"+a.scope+"_activity")}),this.heartbeat_data.newest="",q.each(q(bp.Nouveau.objectNavParent+" [data-bp-scope]").find("a span"),function(e,t){0===parseInt(q(t).html(),10)&&q(t).html("")}),void 0!==this.heartbeat_data.highlights[a.scope]&&(this.heartbeat_data.highlights[a.scope]=[]),q(document).prop("title",this.heartbeat_data.document_title),setTimeout(function(){q("#buddypress #activity-stream .activity-item").removeClass("newest_"+a.scope+"_activity")},3e3),setTimeout(function(){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media.autoPlayGifVideos&&bp.Nouveau.Media.autoPlayGifVideos()},200),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 .acomment-display > .acomment_inner").find(".activity-state-reactions").parent().addClass("bb-has-reaction_update"):"activity"===d&&q(".activity[data-bp-activity-id="+f+"] > .activity-content").find(".activity-state-reactions").parent().addClass("bb-has-reaction_update"),"fav"===i?void 0===e.data.directory_tab||""===e.data.directory_tab||q(s.objectNavParent+' [data-bp-scope="favorites"]').length||q(s.objectNavParent+' [data-bp-scope="all"]').after(e.data.directory_tab):"unfav"===i&&((t=q('[data-bp-user-scope="favorites"]').hasClass("selected")||q(s.objectNavParent+' [data-bp-scope="favorites"]').hasClass("selected"))&&m.remove(),void 0!==e.data.no_favorite)&&(q(s.objectNavParent+' [data-bp-scope="all"]').length&&q(s.objectNavParent+' [data-bp-scope="all"]').hasClass("selected")?q(s.objectNavParent+' [data-bp-scope="favorites"]').remove():t&&L.append(e.data.no_favorite)))}).fail(function(){l.removeClass("loading")})}if(l.hasClass("delete-activity")||l.hasClass("acomment-delete")||l.hasClass("spam-activity")||l.hasClass("spam-activity-comment")){var h,g,C,N,w,P=l.closest("[data-bp-activity-comment-id]"),z=P.data("bp-activity-comment-id"),j=0;if((w=l.closest(".activity-comments")).addClass("active"),e.preventDefault(),void 0!==BP_Nouveau.confirm&&!1===window.confirm(BP_Nouveau.confirm))return!1;l.addClass("loading");var B={action:"delete_activity",id:p,_wpnonce:s.getLinkParams(l.prop("href"),"_wpnonce"),is_single:l.closest("[data-bp-single]").length};(l.hasClass("spam-activity")||l.hasClass("spam-activity-comment"))&&(B.action="bp_spam_activity"),h=m,z&&(delete B.is_single,B.id=z,B.is_comment=!0,h=P),s.ajax(B,"activity").done(function(e){if(l.removeClass("loading"),!1===e.success)h.append(e.data.feedback),h.find(".bp-feedback").hide().fadeIn(300);else{var t,a,i,o=h.closest(".has-child-comments"),d=(h.hasClass("has-child-comments")&&(t=h.closest("ul").closest("li")),o.find("> ul"));if(e.data.redirect)return window.location.href=e.data.redirect;e.data.parent_activity_id&&e.data.activity&&q("body:not(.activity-singular) #buddypress #activity-stream ul.activity-list li#activity-"+e.data.parent_activity_id).replaceWith(e.data.activity),z&&(j=1,i=P.find(".acomments-view-more").data("child-count"),m.append(P.find("form")),q.each(P.find("li.comment-item"),function(){j+=1}),j+=void 0!==i?parseFloat(i):0,g=v.find("span.comments-count"),C=g.text().length?g.text().match(/\d+/)[0]:0,C=Number(C-j),u.length?(i=1 ul").html().trim()&&t.removeClass("has-child-comments")}),z||m.data("bp-timestamp")!==s.Activity.heartbeat_data.last_recorded||(s.Activity.heartbeat_data.newest="",s.Activity.heartbeat_data.last_recorded=0),q(document).trigger("bp_activity_ajax_delete_request",q.extend(B,{response:e})),q(document).trigger("bp_activity_ajax_delete_request_video",q.extend(B,{response:e})),bp.Nouveau.Activity.activityHasUpdates=!0,bp.Nouveau.Activity.currentActivityId=p}w.removeClass("active")})}if(l.closest("span").hasClass("activity-read-more")){var x=l.closest("div"),H=l.closest("span");if(f=null,q(x).hasClass("activity-inner")?f=p:q(x).hasClass("acomment-content")&&(f=l.closest("li").data("bp-activity-comment-id")),!f)return e;e.preventDefault(),q(H).addClass("loading"),s.ajax({action:"get_single_activity_content",id:f},"activity").done(function(e){"object"!=typeof e&&0 ul li.comment-item").length+1&&(A=k.parent().closest("li.comment-item")).length?A:k:c.find('[data-bp-activity-comment-id="'+f+'"]'),y&&q(".bb-modal-activity-footer").removeClass("active"),A.append(r)),r.removeClass("not-initialized"),r.find(".post-elements-buttons-item.post-emoji").prevAll().not(":hidden").length+1),c=(r.find(".post-elements-buttons-item.post-emoji").attr("data-nth-child",k),r.find(".post-elements-buttons-item.post-gif").prevAll().not(":hidden").length+1),A=(r.find(".post-elements-buttons-item.post-gif").attr("data-nth-child",c),r.find(".ac-input[contenteditable]")),k=(bp.Nouveau.Activity.listenCommentInput(A),l.attr("aria-expanded","true"),l.closest(".activity-comments").find(".acomment-display").removeClass("display-focus"),l.closest(".activity-comments").find(".comment-item").removeClass("comment-item-focus"),l.closest(".acomment-display").addClass("display-focus"),l.closest(".comment-item").addClass("comment-item-focus"),_.isNull(t)||(T=t.nickname),_.isNull(t)||(M=t.user_id),'@'+T+" ");_.isUndefined(BP_Nouveau.activity.params.user_id)||(O=BP_Nouveau.activity.params.user_id);var T,c={offset:-(q(window).height()/2-75),easing:"swing"},S=A.get(0);jQuery("body").hasClass("bb-is-mobile")?setTimeout(function(){var e=300 /gi,"\n").replace(/<\/div>/gi,""),M={action:"new_activity_comment",_wpnonce_new_activity_comment:q("#_wpnonce_new_activity_comment").val(),comment_id:f,form_id:p,content:O},Q=(q("#_bp_as_nonce_"+p).val()&&(M["_bp_as_nonce_"+p]=q("#_bp_as_nonce_"+p).val()),this.dropzone_media.length&&(M.media=this.dropzone_media),this.dropzone_document.length&&(M.document=this.dropzone_document),this.dropzone_video.length&&(M.video=this.dropzone_video,_.isEmpty(M.content))&&(M.content=""),_.isUndefined(this.models[p])||(I=this.models[p],M.gif_data=this.models[p].get("gif_data")),M.content=M.content.replace(/ /g," "),r.hasClass("acomment-edit")&&(M.edit_comment=!0),0 '),r.closest("#activity-modal").find(".bb-modal-activity-body .activity-comments, .bb-modal-activity-body .activity-comments .activity-actions").children("ul").append(q(d))):(0===t.children("ul").length&&(t.hasClass("activity-comments")?t.prepend(" "):t.append("
")),t.children("ul").append(q(d).hide().fadeIn(200))),q(r).find(".ac-input").first().html(""),t.parent().addClass("has-comments"),t.parent().addClass("comments-loaded"),v.addClass("has-comments")),r.removeClass("acomment-edit"),r.find(".ac-reply-content"));if(0
'+BP_Nouveau.activity.strings.commentPostError+""):(e=e.responseJSON&&e.responseJSON.message?e.responseJSON.message:e.statusText,r.find(".ac-reply-content").after(' '+e+""))})}if(l.hasClass("edit")&&l.hasClass("edit-activity")&&(e.preventDefault(),k=m.data("bp-activity"),t=""!==m.data("link-url")?m.data("link-url"):null,void 0!==k)&&(bp.Nouveau.Activity.postForm.displayEditActivityForm(k,t),l.closest("li").hasClass("groups")?q("#bp-nouveau-activity-form").addClass("group-activity"):q("#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)&&(q(document).find(".bb-close-media-theatre").trigger("click"),q(document).find(".bb-close-document-theatre").trigger("click")),y&&(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(),!p)return e;l.closest(".activity-item").addClass("loading-pin");var E="pin";l.hasClass("unpin-activity")&&(E="unpin"),s.ajax({action:"activity_update_pinned_post",id:p,pin_action:E},"activity").done(function(e){var t,a,i,o,d,s,n,c,r;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"),a=l.closest(".buddypress-wrap:not(.bb-internal-model)").find("#activity-stream"),i=0"+e.data.feedback+"",e.success?"success":"error",null,!0]),y)&&(void 0!==bp.Nouveau.Activity.activityHasUpdates&&(bp.Nouveau.Activity.activityHasUpdates=!0),void 0!==bp.Nouveau.Activity.activityPinHasUpdates)&&(bp.Nouveau.Activity.activityPinHasUpdates=!0)}).fail(function(){l.closest(".activity-item").removeClass("loading-pin"),q(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(),!p)return e;l.closest(".activity-item").addClass("loading-mute");var D="mute";l.hasClass("bb-icon-bell")&&(D="unmute"),s.ajax({action:"toggle_activity_notification_status",id:p,notification_toggle_action:D},"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"===D?(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"===D&&(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),q(document).trigger("bb_trigger_toast_message",["",""+e.data.feedback+"","success",null,!0])),y&&(bp.Nouveau.Activity.activityPinHasUpdates=!0),bp.Nouveau.Activity.activityHasUpdates=!0,bp.Nouveau.Activity.currentActivityId=p}).fail(function(){l.closest(".activity-item").removeClass("loading-pin"),q(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(),!p)return e;l.closest(".activity-item").addClass("loading-pin");var V="close_comments";l.hasClass("unclose-activity-comment")&&(V="unclose_comments"),s.ajax({action:"activity_update_close_comments",id:p,close_comments_action:V},"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=q("#activity-stream > .activity-list").find("[data-bp-activity-id="+p+"]"),l.closest(".activity-item").find(".bb-activity-closed-comments-notice").remove(),"close_comments"===V?(l.closest("li.activity-item").addClass("bb-closed-comments"),0'+e.data.feedback+""),0 '+e.data.feedback+""))):"unclose_comments"===V&&(l.closest("li.activity-item.bb-closed-comments").find(".edit-activity, .acomment-edit").parents(".generic-button").show(),l.closest("li.activity-item").removeClass("bb-closed-comments"),0 "+e.data.feedback+"",e.success?"success":"error",null,!0]))}).fail(function(){l.closest(".activity-item").removeClass("loading-pin"),q(document).trigger("bb_trigger_toast_message",[""," "+BP_Nouveau.activity.strings.closeCommentsError+"","error",null,!0])})}},commentFormAction:function(e){var t,a;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),!0!==e.altKey&&!0!==e.metaKey&&"TEXTAREA"===t.tagName&&q(t).hasClass("ac-input")?void(27===(a=e.keyCode||e.which)&&!1===e.ctrlKey?"TEXTAREA"===t.tagName&&q(t).closest("form").slideUp(200):e.ctrlKey&&13===a&&q(t).val()&&q(t).closest("form").find("[type=submit]").first().trigger("click")):e},togglePopupDropdown:function(e){var t;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),!0===e.altKey||!0===e.metaKey||q(t).hasClass("privacy-wrap")||q(t).parent().hasClass("privacy-wrap")?e:void q("ul.activity-privacy").removeClass("bb-open")},loadMoreActivities:function(){var e,t=q(".load-more:visible").last(),a=q(window);t.closest(".activity-list").length&&t.get(0)&&!t.data("bp-autoloaded")&&(e=t.offset().top-50,a.scrollTop()+a.height()>e)&&(t.data("bp-autoloaded",1),t.find("a").text(BP_Nouveau.activity.strings.loadingMore),t.find("a").trigger("click"))},destroyCommentMediaUploader:function(e){_.isNull(this.dropzone_obj)||(this.dropzone_obj.destroy(),q("#ac-reply-post-media-uploader-"+e).html(""),q("#ac-reply-post-media-uploader-1-"+e).html("")),this.dropzone_media=[],q("#ac-reply-post-media-uploader-"+e).removeClass("open").addClass("closed"),q("#ac-reply-media-button-"+e).removeClass("active")},destroyCommentDocumentUploader:function(e){_.isNull(this.dropzone_document_obj)||(this.dropzone_document_obj.destroy(),q("#ac-reply-post-document-uploader-"+e).html("")),this.dropzone_document=[],q("#ac-reply-post-document-uploader-"+e).removeClass("open").addClass("closed"),q("#ac-reply-document-button-"+e).removeClass("active")},destroyCommentVideoUploader:function(e){_.isNull(this.dropzone_video_obj)||(this.dropzone_video_obj.destroy(),q("#ac-reply-post-video-uploader-"+e).html("")),this.dropzone_video=[],q("#ac-reply-post-video-uploader-"+e).removeClass("open").addClass("closed"),q("#ac-reply-video-button-"+e).removeClass("active")},resetGifPicker:function(e){q("#ac-reply-gif-button-"+e).closest(".post-gif").find(".gif-media-search-dropdown").removeClass("open").empty(),q("#ac-reply-gif-button-"+e).removeClass("active"),q(".gif-media-search-dropdown-standalone").removeClass("open").empty(),_.isUndefined(this.models[e])||(this.models[e].set("gif_data",{}),q("#ac-reply-post-gif-"+e).find(".activity-attached-gif-container").removeAttr("style"))},openCommentsMediaUploader:function(e){var t,c=this,o=q(e.currentTarget),a=o.data("ac-id"),a=o.closest(".bp-ac-form-container").find("#ac-reply-post-media-uploader-"+a),i=0'+t+""),this.removeFile(e),a.removeClass("media-uploading"))}),c.dropzone_obj.on("removedfile",function(e){if(c.dropzone_media.length)for(var t in c.dropzone_media)if(e.upload.uuid==c.dropzone_media[t].uuid){void 0===c.dropzone_media[t].saved||c.dropzone_media[t].saved||bp.Nouveau.Media.removeAttachment(c.dropzone_media[t].id),c.dropzone_media.splice(t,1);break}var a,i;_.isNull(c.dropzone_obj)||_.isNull(c.dropzone_obj.files)||0!==c.dropzone_obj.files.length?o.closest(".ac-form").addClass("has-content"):(a=o.parents(".ac-reply-toolbar"),(i=o.closest(".ac-form")).removeClass("has-media"),a.find(".ac-reply-document-button")&&a.find(".ac-reply-document-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-video-button")&&a.find(".ac-reply-video-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-gif-button")&&a.find(".ac-reply-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-media-button")&&a.find(".ac-reply-media-button").parents(".post-elements-buttons-item").removeClass("no-click").find(".toolbar-button").removeClass("active"),q(c.dropzone_obj.element).removeClass("files-uploaded dz-progress-view").find(".dz-global-progress").remove(),c.validateCommentContent(i.find(".ac-textarea").children(".ac-input")))}),c.dropzone_obj.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 '+t+""),this.removeFile(e),a.removeClass("media-uploading"))}),c.dropzone_document_obj.on("removedfile",function(e){if(c.dropzone_document.length)for(var t in c.dropzone_document)if(e.upload.uuid==c.dropzone_document[t].uuid){void 0===c.dropzone_document[t].saved||c.dropzone_document[t].saved||bp.Nouveau.Media.removeAttachment(c.dropzone_document[t].id),c.dropzone_document.splice(t,1);break}var a,i;_.isNull(c.dropzone_document_obj)||_.isNull(c.dropzone_document_obj.files)||0!==c.dropzone_document_obj.files.length?o.closest(".ac-form").addClass("has-content"):(a=o.parents(".ac-reply-toolbar"),(i=o.closest(".ac-form")).removeClass("has-media"),a.find(".ac-reply-media-button")&&a.find(".ac-reply-media-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-video-button")&&a.find(".ac-reply-video-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-gif-button")&&a.find(".ac-reply-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-document-button")&&a.find(".ac-reply-document-button").parents(".post-elements-buttons-item").removeClass("no-click").find(".toolbar-button").removeClass("active"),q(c.dropzone_document_obj.element).removeClass("files-uploaded dz-progress-view").find(".dz-global-progress").remove(),c.validateCommentContent(i.find(".ac-textarea").children(".ac-input")))}),c.dropzone_document_obj.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 '),q(e.previewElement).closest(".dz-preview").addClass("dz-has-thumbnail")):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),c.dropzone_video_obj.on("uploadprogress",function(){o.closest(".ac-form").addClass("media-uploading"),bp.Nouveau.dropZoneGlobalProgress&&bp.Nouveau.dropZoneGlobalProgress(this)}),c.dropzone_video_obj.on("success",function(e,t){if(100===e.upload.progress&&(q(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,q(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),q(e.previewElement).closest(".dz-preview").addClass("dz-complete")),t.data.id)return e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=q(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.album_id=void 0!==BP_Nouveau.video&&void 0!==BP_Nouveau.video.album_id&&BP_Nouveau.video.album_id,t.data.group_id=void 0!==BP_Nouveau.video&&void 0!==BP_Nouveau.video.group_id&&BP_Nouveau.video.group_id,t.data.saved=!1,t.data.js_preview=q(e.previewElement).find(".dz-video-thumbnail img").attr("src"),c.dropzone_video.push(t.data),e.previewElement.classList.add("dz-success");var a,i,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],i=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;i '+t+""),this.removeFile(e),a.removeClass("media-uploading"))}),c.dropzone_video_obj.on("removedfile",function(e){if(c.dropzone_video.length)for(var t in c.dropzone_video)if(e.upload.uuid==c.dropzone_video[t].uuid){void 0===c.dropzone_video[t].saved||c.dropzone_video[t].saved||bp.Nouveau.Media.removeAttachment(c.dropzone_video[t].id),c.dropzone_video.splice(t,1);break}var a,i;_.isNull(c.dropzone_video_obj)||_.isNull(c.dropzone_video_obj.files)||0!==c.dropzone_video_obj.files.length?o.closest(".ac-form").addClass("has-content"):(a=o.parents(".ac-reply-toolbar"),(i=o.closest(".ac-form")).removeClass("has-media"),a.find(".ac-reply-media-button")&&a.find(".ac-reply-media-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-document-button")&&a.find(".ac-reply-document-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-gif-button")&&a.find(".ac-reply-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-video-button")&&a.find(".ac-reply-video-button").parents(".post-elements-buttons-item").removeClass("no-click").find(".toolbar-button").removeClass("active"),q(c.dropzone_video_obj.element).removeClass("files-uploaded dz-progress-view").find(".dz-global-progress").remove(),c.validateCommentContent(i.find(".ac-textarea").children(".ac-input")))}),c.dropzone_video_obj.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 /gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," ");""!==e.text().trim()||0<=t.indexOf("emojioneemoji")||e.closest("form").hasClass("acomment-edit")?e.closest("form").addClass("has-content"):e.closest("form").removeClass("has-content")},ReactionStatePopupTab:function(e){e.preventDefault(),q(this).closest(".activity-state-popup").find(".activity-state-popup_tab_panel li a").removeClass("active"),q(this).addClass("active"),q(this).closest(".activity-state-popup").find(".activity-state-popup_tab_content .activity-state-popup_tab_item").removeClass("active"),q(this).closest(".activity-state-popup").find("."+q(this).data("tab")).addClass("active")},closeActivityState:function(){q(".activity-state-popup").hide().removeClass("active")},listenCommentInput:function(e){var t,a;0 /gi,"\n").replace(/<\/div>/gi,""));t=t.replace(/ /g," "),""!==jQuery(e.currentTarget).text().trim()||0<=t.indexOf("emojioneemoji")?jQuery(e.currentTarget).closest("form").addClass("has-content"):jQuery(e.currentTarget).closest("form").removeClass("has-content")}),q(e).closest("form").addClass("events-initiated"),this.InitiatedCommentForms.push(t)))},activityRootComment:function(e){var e=q(e.currentTarget).closest("#activity-modal"),t=e.find(".activity-item").data("bp-activity-id"),a=e.find("#ac-form-"+t);bp.Nouveau.Activity.resetActivityCommentForm(a,"hardReset"),e.find(".acomment-display").removeClass("display-focus"),e.find(".comment-item").removeClass("comment-item-focus"),e.find(".bb-modal-activity-footer").addClass("active").append(a),a.addClass("root"),a.find("#ac-input-"+t).focus(),bp.Nouveau.Activity.clearFeedbackNotice(a)},clearFeedbackNotice:function(e){e.find(".bp-ac-form-container").find(".bp-feedback").length&&e.find(".bp-ac-form-container").find(".bp-feedback").remove()},launchActivityPopup:function(e,t){var a=q("#activity-"+e),i=q(".bb-activity-model-wrapper"),o=a[0].outerHTML,t='[data-parent_comment_id="'+t+'"]',d=a.data("activity-popup-title");bp.Nouveau.Activity.activityHasUpdates=!1,bp.Nouveau.Activity.currentActivityId=null,bp.Nouveau.Activity.activityPinHasUpdates=!1,i.closest("body").addClass("acomments-modal-open"),i.show(),i.find("ul.activity-list").html(o),i.find(".bb-modal-activity-header h2").text(d);i.find(".bb-activity-video-elem").each(function(e,t){var o=q(t);o.find("video").each(function(e,t){var t=q(t),a=t.attr("id")+Math.floor(1e4*Math.random()),i=(t.attr("id",a),o.find(".video-action-wrap"));0 '),{action:"activity_loadmore_comments",activity_id:o,parent_comment_id:n,offset:q(e.currentTarget).parents(".activity-comments").find('ul[data-parent_comment_id ="'+n+'"] > li.comment-item:not(.bb-recent-comment)').length,activity_type_is_blog:1"+e.data.message+"").removeClass("acomments-view-more--hide"),d.removeClass("active"),s.removeClass("active")):void 0!==e.data&&void 0!==e.data.comments&&(t=q(".bb-internal-model .activity-comments").find("[data-activity_id='"+o+"'][data-parent_comment_id='"+n+"']"),e=q(q.parseHTML(e.data.comments)),0"+e.statusText+"").removeClass("acomments-view-more--hide"),d.removeClass("active"),s.removeClass("active")})},autoloadMoreComments:function(){var e,t,a,i,o;0 ul > li.acomments-view-more:not(.loading), .bb-modal-activity-body .activity-comments .activity-actions > ul > li.acomments-view-more:not(.loading)"),t=q(".bb-activity-model-wrapper .bb-modal-activity-body"),o=q(".bb-activity-model-wrapper .bb-modal-activity-body").find(".activity-comments:not(.active)"),0a&&q(e).trigger("click").addClass("loading"),setTimeout(function(){jQuery(window).scroll()},200))},activitySyncOnModalClose:function(e,t){e.preventDefault();var e=(q(e.currentTarget).is(document)?q(".bb-activity-model-wrapper"):q(e.currentTarget).parents(".bb-activity-model-wrapper")).find("ul.activity-list > li").data("bp-activity-id"),t=void 0!==t?t:e,a=q("#activity-stream li.activity-item[data-bp-activity-id="+t+"]");void 0!==bp.Nouveau.Activity.activityPinHasUpdates&&bp.Nouveau.Activity.activityPinHasUpdates?(0 .bb-modal-activity-body .activity-item").data("bp-activity-id");0 /gi,"\n").replace(/<\/div>/gi,""));t=t.replace(/ /g," "),""!==e.text()||0<=t.indexOf("emojioneemoji")?e.closest("form").addClass("has-content"):e.closest("form").removeClass("has-content")},picker_show:function(){q(this.button[0]).closest(".post-emoji").addClass("active"),q(".emojionearea-theatre").removeClass("hide").addClass("show")},picker_hide:function(){q(this.button[0]).closest(".post-emoji").removeClass("active"),q(".emojionearea-theatre").removeClass("show").addClass("hide")}}})},openActivityFilter:function(e){e.preventDefault(),q(".bb-subnav-filters-container:not(.bb-subnav-filters-search)").removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false");e=q(e.currentTarget).parent(".bb-subnav-filters-container");e.addClass("active").find(".subnav-filters-opener").attr("aria-expanded","true"),e.find('input[type="search"]').length&&e.find('input[type="search"]').focus()},closeActivityFilter:function(e){q(e.target).closest(".bb-subnav-filters-container").length||q.each(q(".bb-subnav-filters-container"),function(){(!q(this).hasClass("bb-subnav-filters-search")||""===q(this).find('input[name="activity_search"]').val())&&q(this).removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false")})},filterActivity:function(e){e.preventDefault();var e=q(e.currentTarget),t=e.closest(".bb-subnav-filters-container"),a=(e.parent().addClass("selected").siblings().removeClass("selected"),t.removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false"),e.parent().data("filter-label")),t=(t.find(".subnav-filters-opener .selected").text(a||e.text()),bp.Nouveau.Activity.current_page=1,bp.Nouveau.objectNavParent),a="activity",i=q("#buddypress").find('[data-bp-filter="'+a+'"]').first().val(),o="",d="",s="",n="",c=!1,r=!1,t=(q(t+" [data-bp-object].selected").length&&(o=q(t+" [data-bp-object].selected").data("bp-scope"),e.closest("#bb-subnav-filter-show").length)&&(c=!0,q("body").hasClass("my-activity"))&&(r=!(c=!1)),q('#buddypress [data-bp-search="'+a+'"] input[type=search]').length&&(d=q('#buddypress [data-bp-search="'+a+'"] input[type=search]').val()),q(t+" [data-bp-order]").length&&(s=q(t+' [data-bp-order="'+a+'"].selected').data("bp-orderby")),bp.Nouveau.getStorage("bp-"+a)),a=(void 0!==t.extras&&(n=t.extras),bp.Nouveau.Activity.heartbeat_data.last_recorded=0,{object:a,scope:o,filter:i,search_terms:d,extras:n,order_by:s,save_scope:c,event_element:e});r&&(a.user_timeline=!0),t.topic_id&&(a.topic_id=t.topic_id),bp.Nouveau.objectRequest(a)}},bp.Nouveau.Activity.start())})((bp,jQuery)); \ No newline at end of file diff --git a/src/bp-templates/bp-nouveau/js/buddypress-media.js b/src/bp-templates/bp-nouveau/js/buddypress-media.js index 2a0a20631e0..cf2423c09fd 100644 --- a/src/bp-templates/bp-nouveau/js/buddypress-media.js +++ b/src/bp-templates/bp-nouveau/js/buddypress-media.js @@ -1413,6 +1413,16 @@ window.bp = window.bp || {}; $( 'body #buddypress .activity-list li#activity-' + activityId ).remove(); $( 'body .bb-activity-media-elem.media-activity.' + id ).remove(); $( 'body .activity-comments li#acomment-' + activityId ).remove(); + + // The "view more comments" modal holds its own copy of the + // activity, and its wrapper duplicates id="buddypress", so + // the ID selector above only ever reaches the page copy. + // When the whole activity is gone, close the modal through + // its real close button so the close handler runs. + var $activityModal = $( '#activity-modal:visible' ); + if ( $activityModal.length && $activityModal.find( 'li[data-bp-activity-id="' + activityId + '"]' ).length ) { + $activityModal.find( '.bb-modal-activity-header .bb-close-action-popup' ).trigger( 'click' ); + } } else { $( 'body #buddypress .activity-list li#activity-' + activityId ).replaceWith( response.data.activity_content ); } diff --git a/src/bp-templates/bp-nouveau/js/buddypress-media.min.js b/src/bp-templates/bp-nouveau/js/buddypress-media.min.js index 2dc71e10497..622b7bb3a4d 100644 --- a/src/bp-templates/bp-nouveau/js/buddypress-media.min.js +++ b/src/bp-templates/bp-nouveau/js/buddypress-media.min.js @@ -1 +1 @@ -window.bp=window.bp||{},(m=>{"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},bp.Nouveau.Media={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){var e=m("body"),e=(this.current_page=1,this.current_page_existing_media=1,this.current_page_albums=1,this.current_tab=!e.hasClass("single-topic")&&!e.hasClass("single-forum")&&"bp-dropzone-content",this.sort_by="",this.order_by="",this.currentTargetParent=BP_Nouveau.media.current_folder,this.moveToIdPopup=BP_Nouveau.media.move_to_id_popup,this.moveToTypePopup=BP_Nouveau.media.current_type,this.privacySelectorSelect="",this.privacySelectorSpan="",this.currentAlbum=BP_Nouveau.media.current_album,void 0!==window.Dropzone&&(window.Dropzone.autoDiscover=!1),document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:""),e=(this.documentOptions={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,acceptedFiles:BP_Nouveau.media.document_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.media.dropzone_document_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.document.maxFiles?BP_Nouveau.document.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.document.max_upload_size?BP_Nouveau.document.max_upload_size:2,dictInvalidFileType:BP_Nouveau.document.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation},document.getElementsByClassName("forum-post-video-template").length?document.getElementsByClassName("forum-post-video-template")[0].innerHTML:"");this.videoOptions={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.video.dictFileTooBig,acceptedFiles:BP_Nouveau.video.video_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.video.dropzone_video_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.video.maxFiles?BP_Nouveau.video.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.video.max_upload_size?BP_Nouveau.video.max_upload_size:2,dictInvalidFileType:BP_Nouveau.video.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.video.video_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.video.dictCancelUploadConfirmation},m("#bp-media-uploader").hasClass("bp-media-document-uploader")?(e=document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:"",this.options={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,acceptedFiles:BP_Nouveau.media.document_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.media.dropzone_document_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.document.maxFiles?BP_Nouveau.document.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.document.max_upload_size?BP_Nouveau.document.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation}):(e=document.getElementsByClassName("forum-post-media-template").length?document.getElementsByClassName("forum-post-media-template")[0].innerHTML:"",this.options={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,dictDefaultMessage:BP_Nouveau.media.dropzone_media_message,acceptedFiles:"image/*",autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.media.maxFiles?BP_Nouveau.media.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.media_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation,maxThumbnailFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2}),void 0!==BP_Nouveau.media.dropzone_options&&Object.assign(this.options,BP_Nouveau.media.dropzone_options),this.dropzone_obj=[],this.dropzone_media=[],this.album_id=void 0!==BP_Nouveau.media.album_id&&BP_Nouveau.media.album_id,this.current_folder=void 0!==BP_Nouveau.media.current_folder&&BP_Nouveau.media.current_folder,this.current_group_id=void 0!==BP_Nouveau.media.current_group_id&&BP_Nouveau.media.current_group_id,this.group_id=void 0!==BP_Nouveau.media.group_id&&BP_Nouveau.media.group_id,this.bbp_is_reply_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_reply_edit&&window.BP_Forums_Nouveau.media.bbp_is_reply_edit,this.bbp_is_topic_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_topic_edit&&window.BP_Forums_Nouveau.media.bbp_is_topic_edit,this.bbp_is_forum_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_forum_edit&&window.BP_Forums_Nouveau.media.bbp_is_forum_edit,this.bbp_reply_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_media?window.BP_Forums_Nouveau.media.reply_edit_media:[],this.bbp_reply_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_document?window.BP_Forums_Nouveau.media.reply_edit_document:[],this.bbp_reply_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_video?window.BP_Forums_Nouveau.media.reply_edit_video:[],this.bbp_topic_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_media?window.BP_Forums_Nouveau.media.topic_edit_media:[],this.bbp_topic_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_video?window.BP_Forums_Nouveau.media.topic_edit_video:[],this.bbp_topic_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_document?window.BP_Forums_Nouveau.media.topic_edit_document:[],this.bbp_forum_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_media?window.BP_Forums_Nouveau.media.forum_edit_media:[],this.bbp_forum_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_document?window.BP_Forums_Nouveau.media.forum_edit_document:[],this.bbp_forum_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_video?window.BP_Forums_Nouveau.media.forum_edit_video:[],this.bbp_reply_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_gif_data?window.BP_Forums_Nouveau.media.reply_edit_gif_data:[],this.bbp_topic_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_gif_data?window.BP_Forums_Nouveau.media.topic_edit_gif_data:[],this.bbp_forum_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_gif_data?window.BP_Forums_Nouveau.media.forum_edit_gif_data:[],this.giphy=null,this.gif_offset=0,this.gif_q=null,this.gif_limit=20,this.gif_requests=[],this.gif_data=[],this.gif_container_key=!1,this.reply_topic_allow_delete_media=!1,this.reply_topic_display_post="edit",bp.Nouveau.Media.documentCodeMirror(),m(window).on("scroll resize",function(){bp.Nouveau.Media.documentCodeMirror()})},addListeners:function(){var e=m(".bp-nouveau"),t=m(".bp-existing-media-wrap"),t=(e.on("click","#bp-add-media",this.openUploader.bind(this)),e.on("click","#bp-add-document",this.openDocumentUploader.bind(this)),e.on("click","#bp-media-submit",this.submitMedia.bind(this)),e.on("click","#bp-media-document-submit",this.submitDocumentMedia.bind(this)),e.on("click","#bp-media-uploader-close",this.closeUploader.bind(this)),e.on("click","#bb-delete-media",this.deleteMedia.bind(this)),e.on("click","#bb-select-deselect-all-media",this.toggleSelectAllMedia.bind(this)),void 0!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request?m('#buddypress [data-bp-list="media"]').on("bp_ajax_request",this.bp_ajax_media_request):this.bp_media_after_load(),e.on("click","#bb-create-album",this.openCreateAlbumModal.bind(this)),m(document).on("click","#bb-create-folder",this.openCreateFolderModal.bind(this)),m(document).on("click","#bb-create-folder-child",this.openCreateFolderChildModal.bind(this)),m(document).on("click","#bp-edit-folder-open",this.openEditFolderChildModal.bind(this)),m(document).on("click","#bp-media-create-album-submit",this.saveAlbum.bind(this)),m(document).on("click","#bp-media-create-folder-submit",this.saveFolder.bind(this)),m(document).on("click","#bp-media-create-child-folder-submit",this.saveChildFolder.bind(this)),e.on("click","#bp-media-create-album-close",this.closeCreateAlbumModal.bind(this)),m(document).on("click","#bp-media-create-folder-close",this.closeCreateFolderModal.bind(this)),m(document).on("click","#bp-media-edit-folder-close",this.closeEditFolderModal.bind(this)),m(document).on("click",".open-popup .errorPopup",this.closeErrorPopup.bind(this)),e.on("click","#bp-media-add-more",this.triggerDropzoneSelectFileDialog.bind(this)),m("#bp-media-uploader").on("click",".bp-media-upload-tab",this.changeUploadModalTab.bind(this)),m('.bp-nouveau [data-bp-list="media"]').on("click","li.load-more",this.injectMedias.bind(this)),m(".bp-nouveau #albums-dir-list").on("click","li.load-more",this.appendAlbums.bind(this)),t.on("click","li.load-more",this.appendMedia.bind(this)),e.on("change",'.bb-media-check-wrap [name="bb-media-select"]',this.addSelectedClassToWrapper.bind(this)),t.on("change",'.bb-media-check-wrap [name="bb-media-select"]',this.toggleSubmitMediaButton.bind(this)),e.on("click","#bp-edit-album-title",this.editAlbumTitle.bind(this)),m(document).on("click","#bp-edit-folder-title",this.editFolderTitle.bind(this)),e.on("click","#bp-cancel-edit-album-title",this.cancelEditAlbumTitle.bind(this)),e.on("click","#bp-save-album-title",this.saveAlbum.bind(this)),m(document).on("click","#bp-save-folder-title",this.saveFolder.bind(this)),e.on("change","#bp-media-single-album select#bb-album-privacy",this.saveAlbum.bind(this)),e.on("change","#media-stream select#bb-folder-privacy",this.savePrivacy.bind(this)),e.on("click","#bb-delete-album",this.deleteAlbum.bind(this)),m(document).on("click","#bb-delete-folder",this.deleteFolder.bind(this)),m(document).on("click","ul.document-nav li",this.resetPageDocumentDirectory.bind(this)),m(document).on("click","ul.document-nav li a",this.resetPageDocumentDirectory.bind(this)),m(document).on("click","#forums-media-button",this.openForumsUploader.bind(this)),m(document).on("click","#forums-document-button",this.openForumsDocumentUploader.bind(this)),m(document).on("click","#forums-video-button",this.openForumsVideoUploader.bind(this)),m(document).on("click","#forums-gif-button",this.toggleGifSelector.bind(this)),m(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("keydown",".search-query-input",this.searchGif.bind(this)),m(document).on("click",".bbpress-forums-activity #whats-new-toolbar .found-media-item",this.selectGif.bind(this)),m(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("click",".found-media-item",this.selectGif.bind(this)),m(document).find("form #whats-new-toolbar .gif-search-results, .forum form #whats-new-toolbar .gif-search-results").scroll(this.loadMoreGif.bind(this)),m(".buddypress.groups.messages").length||m(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("click",".found-media-item",this.selectGif.bind(this)),m(document).find("form #whats-new-attachments .forums-attached-gif-container .gif-search-results, .forum form #whats-new-attachments .forums-attached-gif-container .gif-search-results").scroll(this.loadMoreGif.bind(this)),m(document).find("form #whats-new-attachments .forums-attached-gif-container, .forum form #whats-new-attachments .forums-attached-gif-container").on("click",".gif-image-remove",this.removeSelectedGif.bind(this)),m(document).on("click",".gif-image-container",this.playVideo.bind(this)),m(document).on("click",".directory.document .media-folder_action__anchor, .directory.document .media-folder_action__anchor li a, .bb-media-container .media-folder_action__anchor, .bb-media-container .media-folder_action__list li a",this.fileActionButton.bind(this)),m(document).on("click",".bb-activity-media-elem .copy_download_file_url a, .media-folder_action__list .copy_download_file_url a, .media .bb-photo-thumb .copy_download_file_url a",this.copyDownloadLink.bind(this)),m(document).on("click",".bb-activity-media-elem.media-activity .media-action-wrap .media-action_more, #media-stream.media .bb-photo-thumb .media-action-wrap .media-action_more, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_more, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_list li a",this.fileActivityActionButton.bind(this)),m(document).click(this.toggleFileActivityActionButton),m(document).on("click",".bb-activity-media-elem.document-activity .document-expand .document-expand-anchor, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_collapse",this.toggleCodePreview.bind(this)),m(document).on("click",".activity .bp-document-move-activity, #media-stream .bp-document-move-activity",this.moveDocumentIntoFolder.bind(this)),m(document).on("click",'.bp-nouveau [data-bp-list="document"] .pager .dt-more-container.load-more',this.injectDocuments.bind(this)),m(document).on("click",'.bp-nouveau [data-bp-list="document"] .data-head',this.sortDocuments.bind(this)),m(document).on("click",".modal-container .bb-field-steps-actions",this.documentPopupNavigate.bind(this)),m(document).on("click",".bp-media-document-uploader .modal-container .bb-field-uploader-actions",this.uploadDocumentNavigate.bind(this)),m(document).on("click",".bp-media-photo-uploader .modal-container .bb-field-uploader-actions",this.uploadMediaNavigate.bind(this)),m(document).on("click",".modal-container #bp-media-edit-child-folder-submit",this.renameChildFolder.bind(this)),m(document).on("click",".activity .bp-media-move-activity, #media-stream .bp-media-move-activity",this.moveMediaIntoAlbum.bind(this)),m("#bb-media-model-container .activity-list, #media-stream")),e="#buddypress .activity-list",i='#buddypress [data-bp-list="activity"]',a="#bb-media-model-container .activity-list",o="#media-stream",e=(m(document).on("click",e+" .ac-document-move, "+i+" .ac-document-move, "+e+" .ac-folder-move, "+i+" .ac-folder-move, "+a+" .ac-document-move, "+a+" .ac-folder-move, "+o+" .ac-document-move, "+o+" .ac-folder-move",this.openDocumentMove.bind(this)),m(document).on("click",e+" .ac-media-move, "+i+" .ac-media-move, "+a+" .ac-media-move, "+o+" .ac-media-move, .group-media "+o+" .ac-media-move",this.openMediaMove.bind(this)),m(document).on("click",e+" .ac-document-close-button, "+i+" .ac-document-close-button, "+e+" .ac-folder-close-button, "+i+" .ac-folder-close-button, "+a+" .ac-document-close-button, "+a+" .ac-folder-close-button, "+o+" .ac-document-close-button, "+o+" .ac-folder-close-button",this.closeDocumentMove.bind(this)),m(document).on("click",e+" .ac-media-close-button, "+i+" .ac-media-close-button, "+a+" .ac-media-close-button, "+o+" .ac-media-close-button",this.closeMediaMove.bind(this)),t.on("click",".ac-document-rename",this.renameDocument.bind(this)),t.on("click",".ac-document-privacy",this.editPrivacyDocument.bind(this)),t.on("keyup",".media-folder_name_edit",this.renameDocumentSubmit.bind(this)),t.on("click",".name_edit_cancel, .name_edit_save",this.renameDocumentSubmit.bind(this)),m(document).on("click",".document-file-delete",this.deleteDocument.bind(this)),m(document).on("click",".media-file-delete",this.deleteMedia.bind(this)),m(document).on("click",".bp-folder-move",this.folderMove.bind(this)),m(document).on("click",".bp-document-open-create-popup-folder",this.createFolderInPopup.bind(this)),m(document).on("click",".bp-media-open-create-popup-folder",this.createAlbumInPopup.bind(this)),m(document).on("click",".close-create-popup-folder",this.closeCreateFolderInPopup.bind(this)),m(document).on("click",".close-create-popup-album",this.closeCreateAlbumInPopup.bind(this)),m(document).on("click",".bp-document-create-popup-folder-submit",this.submitCreateFolderInPopup.bind(this)),m(document).on("click",".bp-media-create-popup-album-submit",this.submitCreateAlbumInPopup.bind(this)),m(".buddypress.groups.messages")),i=m(".buddypress.groups.messages form#send_group_message_form #whats-new-toolbar"),a=m(".buddypress.groups.messages form#send_group_message_form #whats-new-attachments .bp-group-messages-attached-gif-container .gif-search-results"),o=m(".buddypress.groups.messages form#send_group_message_form #whats-new-attachments .bp-group-messages-attached-gif-container");e.on("click","#bp-group-messages-media-button",this.openGroupMessagesUploader.bind(this)),e.on("click","#bp-group-messages-document-button",this.openGroupMessagesDocumentUploader.bind(this)),e.on("click","#bp-group-messages-video-button",this.openGroupMessagesVideoUploader.bind(this)),e.on("click","#bp-group-messages-gif-button",this.toggleGroupMessagesGifSelector.bind(this)),i.on("keyup",".search-query-input",this.searchGroupMessagesGif.bind(this)),i.on("click",".found-media-item",this.selectGroupMessagesGif.bind(this)),a.scroll(this.loadMoreGroupMessagesGif.bind(this)),m(".groups.messages form#send_group_message_form #whats-new-toolbar .bp-group-messages-attached-gif-container .gif-search-results").scroll(this.loadMoreGroupMessagesGif.bind(this)),o.on("click",".gif-image-remove",this.removeGroupMessagesSelectedGif.bind(this)),m(".bp-existing-media-wrap").on("scroll",this.loadExistingMedia.bind(this)),document.addEventListener("keyup",this.closePopup.bind(this)),document.addEventListener("keyup",this.submitPopup.bind(this)),m(window).bind("beforeunload",this.beforeunloadWindow.bind(this)),_.isUndefined(BP_Nouveau.media.gif_api_key)||(window.addEventListener("scroll",this.throttledAutoPlayGifVideos.bind(this),!1),window.addEventListener("resize",this.throttledAutoPlayGifVideos.bind(this),!1),(t=m("#bp-message-thread-list")).length&&t.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),(e=m(".bb-modal-activity-body")).length&&e.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),(i=m(".bb-media-model-container .activity-list .activity-item")).length&&i.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),m(document).on("scroll","#bp-message-thread-list",this.throttledAutoPlayGifVideos.bind(this)),m(document).on("scroll",".bb-modal-activity-body",this.throttledAutoPlayGifVideos.bind(this)),m(document).on("scroll",".bb-media-model-container .activity-list .activity-item",this.throttledAutoPlayGifVideos.bind(this)),setTimeout(function(){var e=document.getElementById("bp-message-thread-list"),e=(e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1),document.querySelector(".bb-modal-activity-body")),e=(e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1),document.querySelector(".bb-media-model-container .activity-list .activity-item"));e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1)},1e3),m(window).on("load",function(){setTimeout(function(){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media.autoPlayGifVideos&&bp.Nouveau.Media.autoPlayGifVideos()},300)}),document.addEventListener("keydown",_.bind(this.closePickersOnEsc,this)),m(document).on("click",_.bind(this.closePickersOnClick,this))),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_media.length||this.bbp_topic_edit_media.length||this.bbp_forum_edit_media.length)&&m("#forums-media-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_document.length||this.bbp_topic_edit_document.length||this.bbp_forum_edit_document.length)&&m("#forums-document-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_video.length||this.bbp_topic_edit_video.length||this.bbp_forum_edit_video.length)&&m("#forums-video-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(Object.keys(this.bbp_reply_edit_gif_data).length||Object.keys(this.bbp_topic_edit_gif_data).length||Object.keys(this.bbp_forum_edit_gif_data).length)&&(this.editGifPreview(),(a=jQuery("#forums-gif-button").addClass("active").closest("form")).find("#forums-document-button")&&a.find("#forums-document-button").parents(".post-elements-buttons-item").addClass("disable"),a.find("#forums-media-button")&&a.find("#forums-media-button").parents(".post-elements-buttons-item").addClass("disable"),a.find("#forums-video-button"))&&a.find("#forums-video-button").parents(".post-elements-buttons-item").addClass("disable"),"#openEditFolder"==window.location.hash&&m("#bp-media-edit-child-folder").length&&(history.pushState(null,null,window.location.href.split("#")[0]),m("#bp-media-edit-child-folder").show()),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(bp.Nouveau.Media.reply_topic_allow_delete_media=!0)},updateAlbumCounts:function(e){var t,i,a,o;m("#buddypress #bp-media-single-album").length&&(o=parseInt(e.album_media_count)||0,e=parseInt(e.album_video_count)||0,t=function(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},0<(a=m("#buddypress .bb-album-photo-count")).length&&(i=1===o?BP_Nouveau.media.i18n_strings.photo:BP_Nouveau.media.i18n_strings.photos,a.text(t(o)+" "+i)),0<(a=m("#buddypress .bb-album-video-count")).length)&&(o=1===e?BP_Nouveau.media.i18n_strings.video:BP_Nouveau.media.i18n_strings.videos,a.text(t(e)+" "+o))},loadExistingMedia:function(){m(window).scroll()},resetPageDocumentDirectory:function(e){e.preventDefault(),this.current_page=1},submitCreateFolderInPopup:function(e){e.preventDefault();var i=m(e.currentTarget).closest(".open-popup"),a=m(i).find(".bp-document-create-popup-folder-submit"),t=i.find(".bb-folder-selected-id").val(),o=m.trim(m(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder-title").val()),d=m(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder-title"),s=/[\\/?%*:|"<>]+/g.exec(d.val()),s=Boolean(s);if(""===m.trim(d.val())||s)return d.addClass("error"),!1;d.removeClass("error"),this.currentTargetParent=t=""===t?0:t;var n=this.currentTargetParent,r=0,l="",c="",u=0;if("group"===this.moveToTypePopup?(l="grouponly",r=this.moveToIdPopup):(l=m(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder #bb-folder-privacy").val(),c=m(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder #bb-folder-privacy")),""===o)return alert(BP_Nouveau.media.create_folder_error_title),!1;a.addClass("loading"),setTimeout(function(){var e={action:"document_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:o,privacy:l,parent:n,group_id:r};m.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,async:!1,success:function(e){var t;e.success&&(m(".document-data-table-head").length&&parseInt(n)===parseInt(BP_Nouveau.media.current_folder)&&(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()),i.find(".location-folder-list-wrap .location-folder-list").remove(),i.find(".location-folder-list-wrap").append(e.data.tree_view),t="#"+m(i).attr("id")+".open-popup",bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,e.data.folder_id),u=e.data.folder_id,(""===e.data.tree_view?(i.find(".location-folder-list-wrap").hide(),i.find(".location-folder-list-wrap-main span.no-folder-exists")):(i.find(".location-folder-list-wrap-main span.no-folder-exists").hide(),i.find(".location-folder-list-wrap"))).show(),i.find("ul.location-folder-list span#"+u).trigger("click"),i.find(".bb-model-footer").show(),i.find(".bb-model-footer, #bp-media-document-prev").show(),i.find(".bb-field-wrap-search").show(),i.find(".bp-document-open-create-popup-folder").show(),i.find(".location-folder-list-wrap-main").show(),i.find(".create-popup-folder-wrap").hide(),i.find(".bb-folder-selected-id").val(),i.find(".bb-folder-selected-id").val(u),i.find(".bb-model-header").children().show(),i.find(".bb-model-header p").hide(),d.val(""),""!==c&&c.val("public"),m(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0m(i).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(m(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(m(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),m(i).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||m('...').insertAfter(m(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),a.removeClass("loading"),setTimeout(function(){var e=i.find("ul.location-folder-list span#"+u),t=(e.trigger("click"),m(i).find("#bb-document-privacy"));0!==Number(e.data("id"))?(t.find("option").removeAttr("selected"),t.val(e.parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1))},200))}}),this.currentTargetParent=u,i.find(".location-folder-list li.is_active").show().children("span, i").show().siblings("ul").hide(),i.find(".location-folder-list li.is_active").siblings("li").show().children("span, i").show().siblings("ul").hide(),i.find(".location-folder-list li span.selected").removeClass("selected"),i.find(".location-folder-list li.is_active").children("span").addClass("selected")},0)},submitCreateAlbumInPopup:function(e){e.preventDefault();var t=this,i=m(e.currentTarget).closest(".open-popup"),a=m(i).find(".bp-media-create-popup-album-submit"),o=i.find(".bb-album-selected-id").val(),d=(this.currentTargetParent=o=""===o?0:o,this.currentTargetParent),s=0,n=m.trim(m(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album-title").val()),r=m(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album-title"),l="",c="",u=0;if("group"===this.moveToTypePopup?(l="grouponly",s=this.moveToIdPopup):(l=m(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album #bb-album-privacy").val(),c=m(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album #bb-album-privacy")),""===n)return alert(BP_Nouveau.media.create_album_error_title),!1;a.addClass("loading"),setTimeout(function(){var e={action:"media_album_save",_wpnonce:BP_Nouveau.nonces.media,title:n,privacy:l,parent:d,group_id:s};m.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,async:!1,success:function(e){e.success&&(i.find(".location-album-list-wrap .location-album-list").remove(),i.find(".location-album-list-wrap").append(e.data.tree_view),bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(i,e.data.album_id),u=e.data.album_id,(""===e.data.tree_view?(i.find(".location-album-list-wrap").hide(),i.find(".location-album-list-wrap-main span.no-album-exists")):(i.find(".location-album-list-wrap-main span.no-album-exists").hide(),i.find(".location-album-list-wrap"))).show(),i.find("ul.location-album-list span#"+u).trigger("click"),i.find(".bb-model-footer").show(),i.find(".bb-field-wrap-search").show(),i.find(".bp-media-open-create-popup-album").show(),i.find(".location-album-list-wrap-main").show(),i.find(".create-popup-album-wrap").hide(),i.find(".bb-field-steps-2 #bp-media-prev").show(),i.find(".bb-album-selected-id").val(),i.find(".bb-album-selected-id").val(u),i.find(".bb-model-header").children().show(),i.find(".bb-model-header p").hide(),r.val(""),""!==c&&c.val("public"),m(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 m(i).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(m(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(m(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),m(i).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||m('...').insertAfter(m(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),t.updateAlbumNavCount(e.data.album_count)),a.removeClass("loading")}}),this.currentTargetParent=u,i.find(".location-album-list li.is_active").show().children("span, i").show().siblings("ul").hide(),i.find(".location-album-list li.is_active").siblings("li").show().children("span, i").show().siblings("ul").hide(),i.find(".location-album-list li span.selected").removeClass("selected"),i.find(".location-album-list li.is_active").children("span").addClass("selected")},0)},closeCreateFolderInPopup:function(e){e.preventDefault(),m(".modal-container .bb-model-footer").show(),m(".bb-field-wrap-search").show(),m(".bp-document-open-create-popup-folder").show(),m(".location-folder-list-wrap-main").show(),m("#bp-media-document-prev").show(),m(".create-popup-folder-wrap").hide(),m(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header").children().show(),m(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header p").hide()},closeCreateAlbumInPopup:function(e){e.preventDefault(),m(".modal-container .bb-model-footer").show(),m(".bb-field-wrap-search").show(),m(".bp-document-open-create-popup-folder").show(),m(".modal-container:visible .bp-video-open-create-popup-album").show(),m(".location-album-list-wrap-main").show(),m(".bb-field-steps-2 #bp-media-prev").show(),m(".bb-field-steps-2 #bp-video-next").show(),m(".create-popup-album-wrap").hide(),m(".bp-media-create-popup-album-submit.loading").removeClass("loading"),m(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header").children().show(),m(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header p").hide()},createFolderInPopup:function(e){e.preventDefault();var t=parseInt(m(document).find(".open-popup .bb-folder-selected-id").val()),i=m(document).find(".open-popup .bb-folder-create-from").val();0 "+BP_Nouveau.media.create_folder+""),m(".modal-container #bb-folder-privacy").addClass("new-folder-create-privacy"),m(document).find(".open-popup .error").hide()},createAlbumInPopup:function(e){e.preventDefault();var t=parseInt(m(document).find(".open-popup .bb-album-selected-id").val()),i=m(document).find(".open-popup .bb-album-create-from").val();0 "+BP_Nouveau.media.create_album_title+""),m(".modal-container #bb-folder-privacy").addClass("new-folder-create-privacy"),m(document).find(".open-popup .error").hide()},savePrivacy:function(e){var t,i,a,o=m(e.currentTarget);if(e.preventDefault(),o.hasClass("new-folder-create-privacy"))return!1;t=parseInt(o.data("item-id")),i=o.data("item-type"),a=o.val(),e=m(e.currentTarget).find("option:selected").text(),this.privacySelectorSelect.addClass("hide"),this.privacySelectorSpan.text(""),this.privacySelectorSpan.text(e),this.privacySelectorSpan.show(),0 '+e.data.media_personal_count+" "+i)):m("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count)),void 0!==e.data&&void 0!==e.data.media_group_count&&0 '+e.data.media_group_count+" "+i)):m("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(m(".bb-photos-actions").hide(),m("#media-stream")):n.find(".media-list:not(.existing-media-list)")).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(m(".bb-photos-actions").hide(),m("#media-stream")):n.find(".media-list:not(.existing-media-list)")).html(e.data.group_media_html_content):m.each(s,function(e,t){m('#media-stream ul.media-list li[data-id="'+t+'"]').length&&m('#media-stream ul.media-list li[data-id="'+t+'"]').remove()}),void 0!==e.data.album_total_count&&d.updateAlbumCounts(e.data))):(setTimeout(function(){o.prop("disabled",!1)},500),e.success?(void 0!==e.data&&void 0!==e.data.media_personal_count&&0 '+e.data.media_personal_count+" "+i)):m("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count)),void 0!==e.data&&void 0!==e.data.media_group_count&&0 '+e.data.media_group_count+" "+i)):m("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),(t=n.find(".media-list:not(.existing-media-list)")).find('.bb-media-check-wrap [name="bb-media-select"]:checked').each(function(){m(this).closest("li").remove()}),t.parent().parent().hasClass("album-single-view")&&t.find('.bb-video-check-wrap [name="bb-video-select"]:checked').each(function(){m(this).closest("li").remove()}),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(m(".bb-photos-actions").hide(),m("#media-stream")):t).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(m(".bb-photos-actions").hide(),m("#media-stream")):t).html(e.data.group_media_html_content):m.each(s,function(e,t){m('#media-stream ul.media-list li[data-id="'+t+'"]').length&&m('#media-stream ul.media-list li[data-id="'+t+'"]').remove()}),void 0!==e.data.album_total_count&&d.updateAlbumCounts(e.data)):m("#buddypress #media-stream.media").prepend(e.data.feedback));var t,i=m(".bp-nouveau #bb-select-deselect-all-media");i.hasClass("selected")&&i.removeClass("selected"),jQuery(window).scroll()}})},toggleSelectAllMedia:function(e){e.preventDefault(),m(e.currentTarget).hasClass("selected")?(m(e.currentTarget).data("bp-tooltip",BP_Nouveau.media.i18n_strings.selectall),this.deselectAllMedia(e)):(m(e.currentTarget).data("bp-tooltip",BP_Nouveau.media.i18n_strings.unselectall),this.selectAllMedia(e)),m(e.currentTarget).toggleClass("selected")},selectAllMedia:function(e){e.preventDefault();e=m("#buddypress").find(".media-list:not(.existing-media-list)");e.find('.bb-media-check-wrap [name="bb-media-select"]').each(function(){m(this).prop("checked",!0),m(this).closest(".bb-item-thumb").addClass("selected"),m(this).closest(".bb-media-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.unselect)}),e.parent().parent().hasClass("album-single-view")&&e.find('.bb-video-check-wrap [name="bb-video-select"]').each(function(){m(this).prop("checked",!0),m(this).closest(".bb-item-thumb").addClass("selected"),m(this).closest(".bb-video-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.unselect)})},deselectAllMedia:function(e){e.preventDefault();e=m("#buddypress").find(".media-list:not(.existing-media-list)");e.find('.bb-media-check-wrap [name="bb-media-select"]').each(function(){m(this).prop("checked",!1),m(this).closest(".bb-item-thumb").removeClass("selected"),m(this).closest(".bb-media-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.select)}),e.parent().parent().hasClass("album-single-view")&&e.find('.bb-video-check-wrap [name="bb-video-select"]').each(function(){m(this).prop("checked",!1),m(this).closest(".bb-item-thumb").removeClass("selected"),m(this).closest(".bb-video-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.select)})},editAlbumTitle:function(e){e.preventDefault(),m("#bb-album-title").show(),m("#bp-save-album-title").show(),m("#bp-cancel-edit-album-title").show(),m("#bp-edit-album-title").hide(),m("#bp-media-single-album #bp-single-album-title").hide()},editFolderTitle:function(e){e.preventDefault(),m("#bb-album-title").show(),m("#bp-save-folder-title").show(),m("#bp-cancel-edit-album-title").show(),m("#bp-edit-folder-title").hide(),m("#bp-media-single-album #bp-single-album-title").hide()},cancelEditAlbumTitle:function(e){e.preventDefault(),m("#bb-album-title").removeClass("error").hide(),m("#bp-save-album-title,#bp-save-folder-title").hide(),m("#bp-cancel-edit-album-title").hide(),m("#bp-edit-album-title,#bp-edit-folder-title").show(),m("#bp-media-single-album #bp-single-album-title").show()},triggerDropzoneSelectFileDialog:function(){this.dropzone_obj.hiddenFileInput.click()},closeUploader:function(e){e.preventDefault(),m("#bp-media-uploader").hide(),m("#bp-media-add-more").hide(),m("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),m("#bp-media-uploader-modal-status-text").text(""),m("#bp-media-post-content").val(""),m("#bp-dropzone-content .bp-feedback").remove(),this.dropzone_obj.element&&this.dropzone_obj.destroy(),this.dropzone_media=[];var t=m(e.currentTarget).closest("#bp-media-uploader");m(".close-create-popup-album").trigger("click"),m(".close-create-popup-folder").trigger("click"),t.find('.breadcrumbs-append-ul-li .item span[data-id="0"]').trigger("click"),t.find(".bb-field-steps").length&&(t.find(".bb-field-steps-1").show().siblings(".bb-field-steps-2").hide(),t.find(".bb-field-steps-1 #bp-media-photo-next, .bb-field-steps-1 #bp-media-document-next ").hide(),t.find(".bb-field-steps-1").removeClass("controls-added"),t.find("#bp-media-document-prev, #bp-media-prev, #bp-media-document-submit, #bp-media-submit, .bp-media-open-create-popup-folder, .bp-document-open-create-popup-folder, .create-popup-folder-wrap, .create-popup-album-wrap, .bp-video-open-create-popup-album").hide()),this.clearFolderLocationUI(e)},closeChildFolderUploader:function(e){e.preventDefault(),m(document).find(".open-popup #bb-album-child-title").val(""),m(document).find(".open-popup #bp-media-create-child-folder-submit").removeClass("loading"),m(document).find("#bp-media-create-child-folder").removeClass("open-popup"),m(document).find("#bp-media-create-child-folder").hide(),m(document).find(".open-popup #bb-album-title").text(""),m(document).find(".open-popup #bp-media-create-folder").hide(),m(document).find("#bp-media-create-folder").removeClass("open-popup")},closeFolderUploader:function(e){e.preventDefault(),m(document).find(".open-popup #bb-album-title").val(""),m(document).find(".open-popup #bp-media-create-folder-submit").removeClass("loading"),m(document).find(".open-popup #bp-media-document-submit").hide(),m(document).find("#bp-media-create-folder").removeClass("open-popup"),m(document).find("#bp-media-create-folder").hide()},loadMoreGif:function(e){var t=e.target,i=this,e=m(e.target).closest("form").find(".forums-attached-gif-container"),a=e.data("key");i.gif_container_key=a,t.scrollTop+t.offsetHeight>=t.scrollHeight&&!e.hasClass("loading")&&0 =t.scrollHeight&&!m(e.target).closest(".bp-group-messages-attached-gif-container").hasClass("loading")&&0 \n\t\n\t\t \n\t\n',e.data[t].saved=!1,this.gif_data.push(e.data[t])}m(".bp-group-messages-attached-gif-container").find(".gif-search-results-list").append(i)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(this.gif_total_count=e.pagination.total_count)},loadMoreGifResponse:function(e){var t=this,i=0;if(m('div.forums-attached-gif-container[data-key="'+t.gif_container_key+'"]').removeClass("loading"),void 0!==e.data&&e.data.length){for(var a="",i=0;i
\n\t\n\t\t \n\t\n',e.data[i].saved=!1,t.gif_data[t.gif_container_key].data.push(e.data[i])}m('div.forums-attached-gif-container[data-key="'+t.gif_container_key+'"]').closest("form").find(".gif-search-results-list").append(a)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(t.gif_data[t.gif_container_key].total_count=e.pagination.total_count)},editGifPreview:function(){var e=this,t={};if(e.bbp_is_reply_edit&&Object.keys(e.bbp_reply_edit_gif_data).length?t=e.bbp_reply_edit_gif_data.gif_raw_data:e.bbp_is_topic_edit&&Object.keys(e.bbp_topic_edit_gif_data).length?t=e.bbp_topic_edit_gif_data.gif_raw_data:e.bbp_is_forum_edit&&Object.keys(e.bbp_forum_edit_gif_data).length&&(t=e.bbp_forum_edit_gif_data.gif_raw_data),void 0===t.images)return!1;e=m("#whats-new-attachments .forums-attached-gif-container");e[0].style.backgroundImage="url("+t.images.fixed_width.url+")",e[0].style.backgroundSize="contain",e[0].style.height=t.images.original.height+"px",e[0].style.width=t.images.original.width+"px",e.find(".gif-image-container img").attr("src",t.images.original.url),e.removeClass("closed"),m("#bbp_media_gif").length&&m("#bbp_media_gif").val(JSON.stringify(t))},selectGif:function(e){var t=this,i=0,a=m(e.currentTarget),o=a.closest("form").find(".forums-attached-gif-container"),d=(e.preventDefault(),o.closest("form").find(".gif-media-search-dropdown").removeClass("open"),o.data("key"));if(void 0!==t.gif_data[d]&&void 0!==t.gif_data[d].data&&t.gif_data[d].data.length){for(i=0;i
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,s.gif_data.push(e.data[n])}m(d.target).closest(".bp-group-messages-attached-gif-container").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(s.gif_total_count=e.pagination.total_count),m(d.target).closest(".bp-group-messages-attached-gif-container").removeClass("loading")},function(){m(d.target).find(".gif-no-connection").addClass("show")}));s.gif_requests.push(e),s.gif_offset=s.gif_offset+s.gif_limit},searchGifRequest:function(d){var s=this,n=0,r=m(d.target).closest("form").find(".forums-attached-gif-container"),l=(r.addClass("loading"),r.data("key")),e=(m(d.target).closest("form").find(".gif-no-results").removeClass("show"),m(d.target).closest("form").find(".gif-no-connection").removeClass("show"),s.clearGifRequests(l),s.gif_data[l].q=d.target.value,s.gif_data[l].offset=0,s.giphy.search({q:s.gif_data[l].q,offset:s.gif_data[l].offset,fmt:"json",limit:s.gif_data[l].limit},function(e){if(void 0!==e.data.length&&0===e.data.length&&m(d.target).closest("form").find(".gif-no-results").addClass("show"),void 0!==e.meta.status&&200!==e.meta.status&&m(d.target).closest("form").find(".gif-no-connection").addClass("show"),void 0!==e.data&&e.data.length){var t="";for(n=0;n
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,s.gif_data[l].data.push(e.data[n])}m(d.target).closest(".gif-search-content").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(s.gif_data[l].total_count=e.pagination.total_count),r.removeClass("loading")},function(){m(d.target).closest("form").find(".gif-no-connection").addClass("show")}));s.gif_data[l].requests.push(e),s.gif_data[l].offset=s.gif_data[l].offset+s.gif_data[l].limit},clearGifRequests:function(e){var t=this;if(void 0!==t.gif_data[e]&&void 0!==t.gif_data[e].requests){for(var i=0;i
\n\t\n\t\t \n\t\n',e.data[l].saved=!1,n.gif_data[s].data.push(e.data[l])}r.closest("form").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(n.gif_data[s].total_count=e.pagination.total_count),d.removeClass("loading")}),n.gif_data[s].requests.push(e),n.gif_data[s].offset=n.gif_data[s].offset+n.gif_data[s].limit),t.toggleClass("open"),r.parents("form").find("#whats-new-attachments .forums-attached-gif-container img")),t=(0
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,d.gif_data.push(e.data[n])}s.closest("form").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(d.gif_total_count=e.pagination.total_count),m(".gif-search-query").closest(".bp-group-messages-attached-gif-container").removeClass("loading")}),d.gif_requests.push(e),d.gif_offset=d.gif_offset+d.gif_limit),s.parents("form").find("#whats-new-attachments .bp-group-messages-attached-gif-container img"));0
"),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),a.dropzone_obj[n].on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=m(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.album_id=a.album_id,t.data.group_id=a.group_id,t.data.saved=!1,a.dropzone_media[n].push(t.data),a.addMediaIdsToForumsForm(d)):(jQuery(".forum-media-error-popup").length||m("body").append('"),this.removeFile(e))}),a.dropzone_obj[n].on("removedfile",function(e){if(!0===bp.Nouveau.Media.reply_topic_allow_delete_media){if(a.dropzone_media[n].length)for(var t in a.dropzone_media[n])if(e.upload.uuid==a.dropzone_media[n][t].uuid){this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit||void 0===a.dropzone_media[n][t].saved||a.dropzone_media[n][t].saved||"edit"!==bp.Nouveau.Media.reply_topic_display_post||a.removeAttachment(a.dropzone_media[n][t].id),a.dropzone_media[n].splice(t,1),a.addMediaIdsToForumsForm(d);break}var i;_.isNull(a.dropzone_obj[n].files)||0!==a.dropzone_obj[n].files.length||((i=o.closest("form")).find("#forums-document-button")&&i.find("#forums-document-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-video-button")&&i.find("#forums-video-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-gif-button")&&i.find("#forums-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-media-button")&&i.find("#forums-media-button").parents(".post-elements-buttons-item").removeClass("no-click"))}_.isNull(a.dropzone_obj[n].files)||0!==a.dropzone_obj[n].files.length||o.closest("form").removeClass("has-media")}),a.dropzone_obj[n].on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 "),this.removeFile(e))}),a.dropzone_obj.on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=m(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.album_id=a.album_id,t.data.group_id=a.group_id,t.data.saved=!1,a.dropzone_media.push(t.data),a.addMediaIdsToGroupMessagesForm()):(jQuery(".group-message-error-popup").length||m("body").append('"),this.removeFile(e))}),a.dropzone_obj.on("removedfile",function(e){if(a.dropzone_media.length)for(var t in a.dropzone_media)if(e.upload.uuid==a.dropzone_media[t].uuid){void 0===a.dropzone_media[t].saved||a.dropzone_media[t].saved||a.removeAttachment(a.dropzone_media[t].id),a.dropzone_media.splice(t,1),a.addMediaIdsToGroupMessagesForm();break}var i;_.isNull(a.dropzone_obj.files)||0!==a.dropzone_obj.files.length||((i=m("#send_group_message_form")).find("#bp-group-messages-document-button")&&i.find("#bp-group-messages-document-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-video-button")&&i.find("#bp-group-messages-video-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-gif-button")&&i.find("#bp-group-messages-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-media-button")&&i.find("#bp-group-messages-media-button").parents(".post-elements-buttons-item").removeClass("no-click"))}),t.removeClass("closed").addClass("open"),a.resetGroupMessagesGifComponent(),a.resetGroupMessagesDocumentComponent(),a.resetGroupMessagesVideoComponent()):a.resetGroupMessagesMediaComponent())},openGroupMessagesDocumentUploader:function(e){var l=this,t=m("div#bp-group-messages-post-document-uploader"),i=m(e.currentTarget);e.preventDefault(),i.toggleClass("active"),void 0!==window.Dropzone&&t.length&&(t.hasClass("closed")?(l.document_dropzone_obj=new Dropzone("div#bp-group-messages-post-document-uploader",l.documentOptions),l.document_dropzone_obj.on("addedfile",function(){}),l.document_dropzone_obj.on("sending",function(e,t,i){i.append("action","document_document_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media);i=m("#send_group_message_form");i.find("#bp-group-messages-media-button")&&i.find("#bp-group-messages-media-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-video-button")&&i.find("#bp-group-messages-video-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-gif-button")&&i.find("#bp-group-messages-gif-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-document-button")&&i.find("#bp-group-messages-document-button").parents(".post-elements-buttons-item").addClass("no-click")}),l.document_dropzone_obj.on("uploadprogress",function(e){var t=m(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),l.document_dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?m(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&m(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".group-document-error-popup").length||m("body").append('"),this.removeFile(e))}),l.document_dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.document_dropzone_obj.on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e))}),r.video_dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.video.empty_video_type):t()}),r.video_dropzone_obj.on("addedfile",function(e){e.dataURL||bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),r.video_dropzone_obj.on("uploadprogress",function(e){var t=m(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);e.upload.progress<=99?(m(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,m(e.previewElement).find(".dz-progress-count").text("99% "+BP_Nouveau.video.i18n_strings.video_uploaded_text))}),r.video_dropzone_obj.on("success",function(e,t){if(100===e.upload.progress&&(m(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,m(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),m(e.previewElement).closest(".dz-preview").addClass("dz-complete")),!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),l.dropzone_obj[u].on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.dropzone_obj[u].on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),l.dropzone_obj[u].on("accept",function(e,t){0==e.size?t(BP_Nouveau.video.empty_video_type):t()}),l.dropzone_obj[u].on("addedfile",function(e){e.dataURL&&e.dataThumb&&e.dataThumb.length?m(e.previewElement).find(".dz-video-thumbnail").prepend(' '):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),l.dropzone_obj[u].on("uploadprogress",function(e){o.closest("form").addClass("media-uploading");var t=m(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);e.upload.progress<=99?(m(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,m(e.previewElement).find(".dz-progress-count").text("99% "+BP_Nouveau.video.i18n_strings.video_uploaded_text))}),l.dropzone_obj[u].on("success",function(e,t){if(100===e.upload.progress&&(m(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,m(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),m(e.previewElement).closest(".dz-preview").addClass("dz-complete")),!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a
'+m(this).text()+""),m(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a==m(e.currentTarget).data("id")?m(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):m(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),m(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||(m(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val(m(e.currentTarget).data("id")),t=m(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),0!==Number(m(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(m(e.currentTarget).parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),m(document).on("click",t+" .breadcrumb .item > span",function(e){var t,i;m(this).hasClass("is-disabled")||(m(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val(0),m(e.currentTarget).closest(".bb-field-wrap").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),m(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&m(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),a==m(e.currentTarget).data("id")?m(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):m(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),t=m(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),i=m(e.currentTarget).closest("#bp-media-uploader").find(".location-album-list li.is_active").data("privacy"),0!==Number(m(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),e=document.getElementsByClassName("uploader-post-media-template").length?document.getElementsByClassName("uploader-post-media-template")[0].innerHTML:"",i.options.previewTemplate=e,i.dropzone_obj=new Dropzone("div#media-uploader",i.options),i.dropzone_obj.on("sending",function(e,t,i){i.append("action","media_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media)}),i.dropzone_obj.on("uploadprogress",function(e){var t=m(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),i.dropzone_obj.on("addedfile",function(){setTimeout(function(){i.dropzone_obj.getAcceptedFiles().length&&m("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),i.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?m(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&m(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".media-error-popup").length||m("body").append('"),this.removeFile(e))}),i.dropzone_obj.on("queuecomplete",function(){m("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),m(".bb-field-steps-1 #bp-media-photo-next, #bp-media-submit, #bp-media-create-album-submit").show()}),i.dropzone_obj.on("processing",function(){m("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),m(".bb-field-steps-1 #bp-media-photo-next, #bp-media-submit, #bp-media-create-album-submit").hide()}),i.dropzone_obj.on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=i.dropzone_media.length,t.data.album_id=i.album_id,t.data.group_id=i.group_id,t.data.saved=!1,i.dropzone_media.push(t.data)):(jQuery(".media-error-popup").length||m("body").append('"),this.removeFile(e)),m(".modal-container").addClass("modal-container--alert"),m(".bb-field-steps-1").addClass("controls-added"),m("#bp-media-add-more").show(),m("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),m("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()}),i.dropzone_obj.on("removedfile",function(e){if(i.dropzone_media.length)for(var t in i.dropzone_media)if(e.upload.uuid==i.dropzone_media[t].uuid){void 0===i.dropzone_media[t].saved||i.dropzone_media[t].saved||i.removeAttachment(i.dropzone_media[t].id),i.dropzone_media.splice(t,1);break}i.dropzone_obj.getAcceptedFiles().length?m("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show():(m("#bp-media-uploader-modal-status-text").text(""),m("#bp-media-add-more, #bp-media-photo-next").hide(),m(".bb-field-steps-1").removeClass("controls-added"),m("#bp-media-submit").hide(),m(".modal-container").removeClass("modal-container--alert"))}))},openDocumentUploader:function(e){var a,t,l=this;e.preventDefault(),void 0!==window.Dropzone&&m("div#media-uploader").length&&(m("#bp-media-uploader").hasClass("bp-media-document-uploader")&&!this.currentTargetParent&&(this.currentTargetParent=0),m(e.currentTarget).closest("#bp-media-single-folder").length&&m("#bb-document-privacy").hide(),m(document).removeClass("open-popup"),m("#bp-media-uploader").show(),m("#bp-media-uploader").addClass("open-popup"),m("#bp-media-uploader.bp-media-document-uploader").find(".bb-field-steps.bb-field-steps-2").length&&(t="#bp-media-uploader.bp-media-document-uploader",0!==Number(m(t).find(".bb-folder-selected-id").data("value"))?(a=m(t).find(".bb-folder-selected-id").data("value"),m(t).find("#bb-document-privacy").prop("disabled",!0)):a=0,""!==this.moveToIdPopup)&&m.ajax({url:BP_Nouveau.ajaxurl,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:BP_Nouveau.nonces.media},success:function(e){m(document).find(".bp-media-document-uploader .location-folder-list-wrap h4 span.where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(m(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap").hide(),m(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap-main span.no-folder-exists")):(m(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap-main span.no-folder-exists").hide(),m(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap"))).show(),m(document).find(".bp-media-document-uploader .popup-on-fly-create-album .privacy-field-wrap-hide-show").show(),m(document).find(".bp-media-document-uploader .open-popup .bb-folder-create-from").val("profile"),m(t).find(".location-folder-list-wrap .location-folder-list").remove(),m(t).find(".location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,a),m(t).find("ul.location-folder-list span#"+a).trigger("click"),m(t).find(".bb-folder-selected-id").val(a)}}),m(document).on("click",t+" .location-folder-list li span",function(e){var t;e.preventDefault(),m(this).parent().hasClass("is_active")||(0!=m(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&m(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),m(this).closest(".location-folder-list-wrap").find(".breadcrumb .item").append(''+m(this).text()+""),m(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a==m(e.currentTarget).data("id")?m(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):m(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),m(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||(m(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val(m(e.currentTarget).data("id")),t=m(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),0!==Number(m(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(m(e.currentTarget).parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),m(document).on("click",t+" .breadcrumb .item > span",function(e){var t,i;m(this).hasClass("is-disabled")||(m(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val(m(e.currentTarget).data("id")),m(e.currentTarget).closest(".bb-field-wrap").find(".location-folder-list li span").removeClass("selected").parent().removeClass("is_active"),m(e.currentTarget).closest(".bb-field-wrap").find('.location-folder-list li[data-id="'+m(e.currentTarget).data("id")+'"]').addClass("is_active"),m(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&m(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),a==m(e.currentTarget).data("id")?m(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):m(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),t=m(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),i=m(e.currentTarget).closest("#bp-media-uploader").find(".location-folder-list li.is_active").data("privacy"),0!==Number(m(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),e=document.getElementsByClassName("uploader-post-document-template").length?document.getElementsByClassName("uploader-post-document-template")[0].innerHTML:"",l.options.previewTemplate=e,l.dropzone_obj=new Dropzone("div#media-uploader",l.options),l.dropzone_obj.on("sending",function(e,t,i){i.append("action","document_document_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media)}),l.dropzone_obj.on("uploadprogress",function(e){var t=m(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),l.dropzone_obj.on("addedfile",function(){setTimeout(function(){l.dropzone_obj.getAcceptedFiles().length&&m("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,l.dropzone_media.length,l.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),l.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?m(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&m(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".document-error-popup").length||m("body").append('"),this.removeFile(e))}),l.dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.dropzone_obj.on("queuecomplete",function(){m("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),m(".bb-field-steps-1 #bp-media-document-next, #bp-media-document-submit").show()}),l.dropzone_obj.on("processing",function(){m("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),m(".bb-field-steps-1 #bp-media-document-next, #bp-media-document-submit").hide()}),l.dropzone_obj.on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a .activity-content .bp-media-move-file",m(o).find(".bp-document-move").attr("id",m(e.currentTarget).closest(".document-activity").attr("data-id")),0 ');var i,t,a,o,d=t,s=this.moveToTypePopup;""!==this.moveToIdPopup&&m.ajax({url:BP_Nouveau.ajaxurl,type:"post",data:{action:"media_get_album_view",id:this.moveToIdPopup,type:this.moveToTypePopup},success:function(e){m(document).find(".location-album-list-wrap h4 span.where-to-move-profile-or-group-media").html(e.data.first_span_text),(""===e.data.html?(m(document).find(".open-popup .location-album-list-wrap").hide(),m(document).find(".open-popup .location-album-list-wrap-main span.no-album-exists")):(m(document).find(".open-popup .location-album-list-wrap-main span.no-album-exists").hide(),m(document).find(".open-popup .location-album-list-wrap"))).show(),"group"===s?(m(document).find(".popup-on-fly-create-album .privacy-field-wrap-hide-show").hide(),m(document).find(".open-popup .bb-album-create-from").val("group")):(m(document).find(".popup-on-fly-create-album .privacy-field-wrap-hide-show").show(),m(document).find(".open-popup .bb-album-create-from").val("profile")),!1===e.data.create_album?(m(o+".open-popup").find(".bp-media-open-create-popup-folder").removeClass("create-album"),m(o+".open-popup").find(".bp-media-open-create-popup-folder").hide()):(m(o+".open-popup").find(".bp-media-open-create-popup-folder").addClass("create-album"),m(o+".open-popup").find(".bp-media-open-create-popup-folder").show()),m(o).find(".location-album-list-wrap .location-album-list").remove(),m(o).find(".location-album-list-wrap").append(e.data.html),m(o).find("ul.location-album-list span#"+d).trigger("click")}}),m(document).on("click",o+" .location-album-list li span",function(e){var t;e.preventDefault(),m(this).parent().hasClass("is_active")||(0!=m(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&m(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),m(this).closest(".location-album-list-wrap").find(".breadcrumb .item").append(''+m(this).text()+""),m(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),t=m(document).find('a.bb-open-media-theatre[data-id="'+i.find(".bp-media-move").attr("id")+'"]').data("album-id"),Number(t)==Number(m(e.currentTarget).data("id"))?m(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):m(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),m(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||m(e.currentTarget).closest(".bp-media-move-file").find(".bb-album-selected-id").val(m(e.currentTarget).data("id"))}),m(document).on("click",o+" .breadcrumb .item > span",function(e){m(this).hasClass("is-disabled")||(m(e.currentTarget).closest(".bp-media-move-file").find(".bb-album-selected-id").val(0),m(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),m(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&m(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),d==m(e.currentTarget).data("id")?m(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):m(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"))})},openDocumentMove:function(e){e.preventDefault();var t,i,a,e=m(e.currentTarget),o=(e.closest(".bb-activity-media-elem").find(".document-title").text(),this.moveToIdPopup=e.attr("id"),this.moveToTypePopup=e.attr("data-type"),e.attr("data-action")),d=(m(".bp-media-move-file.open-popup, .bp-media-move-folder.open-popup").hide().removeClass("open-popup"),e.closest("#activity-modal")),s=(0===d.length&&(d=m("body")),e.closest(".conflict-activity-ul-li-comment").closest("li.comment-item").length?(i=e.closest("li.comment-item"),i=d.find("#"+i.attr("id")+".comment-item .bp-media-move-file").first()):0<(a=e.closest("li.activity-item")).length&&(i=d.find("#"+a.attr("id")+" > .activity-content .bp-media-move-file").first()),i&&0!==i.length||(e.closest(".conflict-activity-ul-li-comment").closest("li.comment-item").length?(a=e.closest("li.comment-item").attr("id"),i=d.find("#"+a+".comment-item .bp-media-move-file").first()):(a=e.closest("li.activity-item").attr("id"))&&(i=d.find("#"+a+" > .activity-content .bp-media-move-file").first())),i&&0 '),"document"===o?m(t).find(".bb-model-header h4 .target_name").text(BP_Nouveau.media.move_to_file):m(t).find(".bb-model-header h4 .target_name").text(BP_Nouveau.media.move_to_folder),m(t).show(),m(t).addClass("open-popup"),"group"===this.moveToTypePopup?(m(document).find(".location-folder-list-wrap h4").show(),m(t).addClass("move-folder-popup-group")):(m(document).find(".location-folder-list-wrap h4").hide(),m(".move-folder-popup-group").removeClass("move-folder-popup-group")),this.currentTargetParent),n=this.moveToTypePopup;""!==this.moveToIdPopup&&m.ajax({url:BP_Nouveau.ajaxurl,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:BP_Nouveau.nonces.media},success:function(e){m(document).find(".location-folder-list-wrap h4 span.where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(m(document).find(".open-popup .location-folder-list-wrap").hide(),m(document).find(".open-popup .location-folder-list-wrap-main span.no-folder-exists")):(m(document).find(".open-popup .location-folder-list-wrap-main span.no-folder-exists").hide(),m(document).find(".open-popup .location-folder-list-wrap"))).show(),"group"===n?(m(document).find(".popup-on-fly-create-folder .privacy-field-wrap-hide-show").hide(),m(document).find(".open-popup .bb-folder-create-from").val("group")):(m(document).find(".popup-on-fly-create-folder .privacy-field-wrap-hide-show").show(),m(document).find(".open-popup .bb-folder-create-from").val("profile")),m(t).find(".location-folder-list-wrap .location-folder-list").remove(),m(t).find(".location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&(bp.Nouveau.Media.folderLocationUI(t,s),m(t).find("ul.location-folder-list span#"+s).trigger("click"))}})},closeMediaMove:function(e){e.preventDefault(),0!=m(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list-wrap .breadcrumb .item span:last-child").data("id")&&m(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list-wrap .breadcrumb .item span:last-child").remove(),m(e.currentTarget).closest(".bp-media-move-file").hide()},closeDocumentMove:function(e){e.preventDefault();var t=m(e.currentTarget),i=jQuery(e.currentTarget).closest(".has-folderlocationUI");(t.hasClass("ac-document-close-button")?(t.closest(".bp-media-move-file"),m(".bp-media-move-file.open-popup").hide().removeClass("open-popup").find(".bp-document-move")):(t.closest(".bp-media-move-folder"),m(".bp-media-move-folder.open-popup").hide().removeClass("open-popup").find(".bp-folder-move"))).attr("id",""),i.find(".bp-document-move.loading").removeClass("loading"),this.clearFolderLocationUI(e)},renameDocument:function(e){var t=m(e.currentTarget).closest(".media-folder_items").find(".media-folder_name"),i=t.children("span").text();t.hide().siblings(".media-folder_name_edit_wrap").show().children(".media-folder_name_edit").val(i).focus().select(),e.preventDefault()},editPrivacyDocument:function(e){e.preventDefault(),m(e.currentTarget).closest("#media-folder-document-data-table").find(".media-folder_visibility .media-folder_details__bottom span").show().siblings("select").addClass("hide");var t=m(e.currentTarget).closest(".media-folder_items").find(".media-folder_visibility");t.find(".media-folder_details__bottom span").hide().siblings("select").removeClass("hide"),t.find(".media-folder_details__bottom span").hide().siblings("select").val(m(e.currentTarget).attr("data-privacy")),t.find(".media-folder_details__bottom #bb-folder-privacy").attr("data-privacy",m(e.currentTarget).attr("data-privacy")),this.privacySelectorSelect=t.find(".media-folder_details__bottom span").hide().siblings("select"),this.privacySelectorSpan=t.find(".media-folder_details__bottom span")},editPrivacyDocumentSubmit:function(e){e=m(e.currentTarget);"true"==e.attr("data-mouseup")?(e.attr("data-mouseup","false"),e.addClass("hide").siblings("span").show().text(e.find("option:selected").text())):e.attr("data-mouseup","true")},renameDocumentSubmit:function(t){var i=m(t.currentTarget).closest(".media-folder_items").find(".media-folder_name_edit"),a=m(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > span"),o=m(t.currentTarget).closest(".media-folder_items").find(".media-folder_name"),e=m(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-id").attr("data-item-id"),d=m(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-attachment-id").attr("data-item-id"),s=m(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-type").attr("data-item-id"),n=i.val().trim(),r="",r=(m(t.currentTarget).closest(".ac-document-list").length?r=/[?\[\]=<>:;,'"&$#*()|~`!{}%+ \/]+/g:m(t.currentTarget).closest(".ac-folder-list").length&&(r=/[\\/?%*:|"<>]+/g),r.exec(n)),r=Boolean(r);if(r?i.addClass("error"):i.removeClass("error"),m(t.currentTarget).closest(".ac-document-list").length&&(-1!=n.indexOf("\\\\")||r?i.addClass("error"):i.removeClass("error")),!m(t.currentTarget).hasClass("name_edit_cancel")&&27!=t.keyCode||(i.removeClass("error"),i.parent().hide().siblings(".media-folder_name").show()),m(t.currentTarget).hasClass("name_edit_save")||13==t.keyCode){if(r)return;i.parent().addClass("submitting").append(''),m.ajax({url:BP_Nouveau.ajaxurl,type:"post",data:{action:"document_update_file_name",document_id:e,attachment_document_id:d,document_type:s,name:n,_wpnonce:BP_Nouveau.nonces.media},success:function(e){e.success?void 0!==e.data.document&&0 ');e.parents("li").each(function(e,t){t=m(t).children("span").clone();i.prepend("",t)}),m(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")),m(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||m(a).find(".breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),m(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 m(a).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(m(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(m(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),m(a).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||m('...').insertAfter(m(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),m(this).hasClass("selected")&&!m(this).hasClass("disabled")?(m(this).closest(".location-folder-list-wrap-main").find(".bb-folder-destination").val(""),m(this).closest(".location-folder-list-wrap-main").find(".bb-folder-selected-id").val("0"),m(a).find(".location-folder-list li.is_active").length?m(a).find(".bb-folder-selected-id").val(m(a).find(".location-folder-list li.is_active").attr("data-id")):m(a).find(".bb-folder-selected-id").val("0")):(m(this).closest(".location-folder-list-wrap-main").find(".location-folder-list li span").removeClass("selected"),m(this).addClass("selected"),m(this).closest(".location-folder-list-wrap-main").find(".bb-folder-destination").val(m(this).text()),m(this).closest(".location-folder-list-wrap-main").find(".bb-folder-selected-id").val(m(this).parent().attr("data-id"))),m(this).closest(".location-folder-list-wrap").find(".location-folder-title").text(m(this).siblings("span").text()).siblings(".location-folder-back").css("display","inline-block"),m(this).siblings("ul").show().siblings("span, i").hide().parent().siblings().hide(),m(this).siblings("ul").children("li").show().children("span,i").show(),m(this).closest(".is_active").removeClass("is_active"),m(a).find("li.is_active").removeClass("is_active"),m(this).parent().addClass("is_active"),m(a).find(".bb-folder-selected-id").val(m(a).find(".location-folder-list li.is_active").attr("data-id")),m(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").each(function(){m(this).show()}),o===m(a).find(".breadcrumbs-append-ul-li .item > span[data-id]").last().attr("data-id")&&(m(a).hasClass("bp-media-move-file")||m(a).hasClass("bp-media-move-folder"))?(m(a).find(".bp-document-move").addClass("is-disabled"),m(a).find(".bp-folder-move").addClass("is-disabled")):(m(a).find(".bp-document-move").removeClass("is-disabled"),m(a).find(".bp-folder-move").removeClass("is-disabled")),setTimeout(function(){m(a).closest(".bb-activity-media-wrap").find(".bb-activity-media-elem.document-activity").attr("data-parent-id")===(m(a).find(".breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?m(a).find(".breadcrumbs-append-ul-li .item > span:last-child").prev():m(a).find(".breadcrumbs-append-ul-li .item > span:last-child")).attr("id")&&(m(a).hasClass("bp-media-move-file")||m(a).hasClass("bp-media-move-folder"))?(m(a).find(".bp-document-move").addClass("is-disabled"),m(a).find(".bp-folder-move").addClass("is-disabled")):(m(a).find(".bp-document-move").removeClass("is-disabled"),m(a).find(".bp-folder-move").removeClass("is-disabled"))},100)}),m(document).on("click",a+" .breadcrumbs-append-ul-li .item span",function(e){var t,i;m(this).parent().hasClass("is-disabled")||m(this).hasClass("more_options")||(t=m(e.currentTarget).attr("data-id"),m(a).find(".location-folder-list-wrap").find(".location-folder-title").text(m(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),m(a).find(".bb-folder-selected-id").val(t),m(a).find(".location-folder-list li").hide(),m(a).find(".location-folder-list li.is_active").removeClass("is_active"),m(a).find(".location-folder-list li > span.selected").removeClass("selected"),m(a).find('.location-folder-list li[data-id="'+t+'"]').addClass("is_active").children("span").addClass("selected"),m(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),m(a).find(".location-folder-list li.is_active").children("ul").length&&!m(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){m(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):m(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?m(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){m(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),"0"===t&&(m(a).find(".location-folder-list").children("li").show().children("span,i").show(),m(a).find(".location-folder-list-wrap").find(".location-folder-title").text(BP_Nouveau.media.target_text),m(a).find(".location-folder-back").hide()),m(e.currentTarget).nextAll().remove(),o===m(a).find(".breadcrumbs-append-ul-li .item > span[data-id]").last().attr("data-id")&&(m(a).hasClass("bp-media-move-file")||m(a).hasClass("bp-media-move-folder"))?(m(a).find(".bp-document-move").addClass("is-disabled"),m(a).find(".bp-folder-move").addClass("is-disabled")):(m(a).find(".bp-document-move").removeClass("is-disabled"),m(a).find(".bp-folder-move").removeClass("is-disabled")),e=m(a).find(".location-folder-list .is_active > span"),i=m(''),e.parents("li").each(function(e,t){t=m(t).children("span").clone();i.prepend("",t)}),m(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")),0===m(a).find('.breadcrumbs-append-ul-li .breadcrumb .item > span[data-id="'+t+'"]').length&&m(a).find(".breadcrumbs-append-ul-li .breadcrumb .item").append(m(a).find('.location-folder-list li[data-id="'+t+'"]').children("span").clone()),m(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||m(a).find(".breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),m(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 m(a).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(m(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(m(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),m(a).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||m('...').insertAfter(m(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),m(a).find(".bb-folder-selected-id").val(t))})),m(a).find(".location-folder-list li").each(function(){m(this).children("ul").parent().addClass("has-ul").append('')}),m(a).hasClass("bp-media-move-folder")&&(m(a).find(".location-folder-list li>span").removeClass("is-disabled"),m(a).find('.location-folder-list li>span[id="'+m(a).find(".bp-folder-move").attr("id")+'"]').parent().addClass("is-disabled")),e=m(a).find(".bp-folder-move").attr("id"),0==m(a).find('.location-folder-list li[data-id="'+e+'"]').siblings().length&&m(a).find('.location-folder-list li[data-id="'+e+'"]').parent("ul").addClass("no-folder-list a"),o&&(m(a).find(".location-folder-list li").hide(),m(a).find(".location-folder-list li.is_active").removeClass("is_active"),m(a).find('.location-folder-list li[data-id="'+o+'"]').addClass("is_active"),m(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),m(a).find(".location-folder-list li.is_active").children("ul").length&&!m(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){m(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):m(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?m(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){m(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),m(a).find(".location-folder-list-wrap").find(".location-folder-title").text(m(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),m(a).find(".bb-folder-selected-id").val(m(a).find(".location-folder-list li.is_active").attr("data-id")),m(a).find('.location-folder-list li[data-id="'+e+'"]').children().hide()),"0"===o&&(m(a).find(".location-folder-list").children("li").show(),m(a).find(".location-folder-list-wrap").find(".location-folder-title").text(BP_Nouveau.media.target_text),m(a).find(".location-folder-back").hide()),setTimeout(function(){var e=0,e=(m(a).find(".breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?m(a).find(".breadcrumbs-append-ul-li .item > span:last-child").prev():m(a).find(".breadcrumbs-append-ul-li .item > span:last-child")).attr("id");o===parseInt(e)&&(m(a).hasClass("bp-media-move-file")||m(a).hasClass("bp-media-move-folder"))?(m(a).find(".bp-document-move").addClass("is-disabled"),m(a).find(".bp-folder-move").addClass("is-disabled")):(m(a).find(".bp-document-move").removeClass("is-disabled"),m(a).find(".bp-folder-move").removeClass("is-disabled"))},100),e=m(a).find(".location-folder-list .is_active > span"),i=m(''),e.parents("li").each(function(e,t){t=m(t).children("span").clone();i.prepend("",t)}),m(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")))},clearFolderLocationUI:function(e){e=jQuery(e.currentTarget).closest(".has-folderlocationUI");0 ul > li.selected").data("bp-scope")||bp.Nouveau.inject("#media-stream ul.media-list",e.data.media,"prepend"),m("#buddypress #bp-media-single-album").length||(e.data.media_personal_count&&(0 '+e.data.media_personal_count+" "+t)):m("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").length?m("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count):"1"===BP_Nouveau.bb_enable_content_counts&&((a=document.createElement("span")).setAttribute("class","count"),o=document.createTextNode(e.data.media_personal_count),a.appendChild(o),m("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a").append(a))),e.data.media_group_count&&(0 '+e.data.media_group_count+" "+t)):m("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").length?m("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count):"1"===BP_Nouveau.bb_enable_content_counts&&((o=document.createElement("span")).setAttribute("class","count"),a=document.createTextNode(e.data.media_group_count),o.appendChild(a),m("#buddypress").find(".bp-wrap .users-nav ul li#photos-groups-li a").append(o))),"yes"===BP_Nouveau.media.is_media_directory&&(0 ul > li.selected").data("bp-scope"))?a=e.data.media_all_count:"personal"===o?a=e.data.media_personal_count:"groups"===o&&(a=e.data.media_group_count),t=BP_Nouveau.dir_labels.hasOwnProperty("media")?1===a?BP_Nouveau.dir_labels.media.singular:BP_Nouveau.dir_labels.media.plural:"",m("#buddypress .bb-item-count").html(''+a+" "+t)):(m("#buddypress").find(".media-type-navs ul.media-nav li#media-all a span.count").text(e.data.media_all_count),m("#buddypress").find(".media-type-navs ul.media-nav li#media-personal a span.count").text(e.data.media_personal_count),m("#buddypress").find(".media-type-navs ul.media-nav li#media-groups a span.count").text(e.data.media_group_count)))),void 0!==e.data.album_total_count&&s.updateAlbumCounts(e.data);for(var i=0;i ").addClass("media-list item-list bp-list bb-photo-list grid")),0 ").addClass("display")),m("#media-stream div").attr("id","media-folder-document-data-table"),m(".bb-photos-actions").show()),m(".document-data-table-head").length?"yes"===BP_Nouveau.media.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(m(document).find("li#document-personal a").trigger("click"),m(document).find("li#document-personal").trigger("click")):r&&bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"):location.reload(!0),m("#bp-media-post-content").val("");for(var t=0;t ]+/g.exec(e.val())),d=Boolean(d);if(""===m.trim(e.val())||d)return e.addClass("error"),!1;if(e.removeClass("error"),!a.group_id&&""===m.trim(o.val()))return o.addClass("error"),!1;o.removeClass("error"),i.prop("disabled",!0).addClass("loading");d={action:"document_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:e.val().trim(),privacy:o.val(),album_id:a.current_folder,group_id:a.current_group_id};m(".bb-single-album-header .bp-feedback").remove(),m("#boss-media-create-album-popup .bp-feedback").remove(),m.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:d,success:function(e){setTimeout(function(){i.prop("disabled",!1)},500),e.success?(a.closeFolderUploader(t),m(".document-data-table-head").length?"yes"===BP_Nouveau.media.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(m(document).find("li#document-personal a").trigger("click"),m(document).find("li#document-personal").trigger("click")):(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()):location.reload(!0)):alert(e.data.feedback.replace("'","'"))}})},saveChildFolder:function(t){var e=m(t.currentTarget),i=this,a=m("#bp-media-create-child-folder #bb-album-child-title"),o=(t.preventDefault(),/[\\/?%*:|"<>]+/g.exec(a.val())),o=Boolean(o);if(""===m.trim(a.val())||o)return a.addClass("error"),!1;a.removeClass("error"),e.prop("disabled",!0).addClass("loading");o={action:"document_child_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:a.val(),folder_id:i.current_folder,group_id:i.current_group_id};m(".bb-single-album-header .bp-feedback").remove(),m("#boss-media-create-album-popup .bp-feedback").remove(),m.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:o,success:function(e){e.success?(i.closeChildFolderUploader(t),location.reload(!0)):alert(e.data.feedback.replace("'","'"))}})},renameChildFolder:function(e){e.preventDefault();var t=m(e.currentTarget),i=this,e=m("#bp-media-edit-child-folder #bb-album-child-title"),a=m("#bp-media-edit-child-folder #bb-folder-privacy"),o=this.currentTargetParent,d=/[\\/?%*:|"<>]+/g.exec(e.val()),d=Boolean(d);if(""===m.trim(e.val())||d)return e.addClass("error"),!1;e.removeClass("error"),t.prop("disabled",!0).addClass("loading");d={action:"document_edit_folder",_wpnonce:BP_Nouveau.nonces.media,title:e.val(),privacy:a.val(),id:o,group_id:i.current_group_id};m(".bb-single-album-header .bp-feedback").remove(),m("#boss-media-create-album-popup .bp-feedback").remove(),m.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:d,success:function(e){setTimeout(function(){t.prop("disabled",!1)},500),e.success?window.location.reload(!0):i.current_folder?m("#bp-media-single-album").prepend(e.data.feedback):m("#boss-media-create-album-popup .bb-model-header").after(e.data.feedback)}})},deleteAlbum:function(t){if(t.preventDefault(),!this.album_id)return!1;if(!confirm(BP_Nouveau.media.i18n_strings.album_delete_confirm))return!1;m(t.currentTarget).prop("disabled",!0);var e={action:"media_album_delete",_wpnonce:BP_Nouveau.nonces.media,album_id:this.album_id,group_id:this.group_id};m.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){e.success?window.location.href=e.data.redirect_url:(alert(BP_Nouveau.media.i18n_strings.album_delete_error),m(t.currentTarget).prop("disabled",!1))}})},deleteFolder:function(t){if(t.preventDefault(),!BP_Nouveau.media.current_folder)return!1;if(!confirm(BP_Nouveau.media.i18n_strings.folder_delete_confirm))return!1;m(t.currentTarget).prop("disabled",!0);var e={action:"document_folder_delete",_wpnonce:BP_Nouveau.nonces.media,folder_id:BP_Nouveau.media.current_folder,group_id:BP_Nouveau.media.current_group_id};m.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){e.success?window.location.href=e.data.redirect_url:(alert(BP_Nouveau.media.i18n_strings.folder_delete_error),m(t.currentTarget).prop("disabled",!1))}})},addMediaIdsToGroupMessagesForm:function(){m("#bp_group_messages_media").length&&m("#bp_group_messages_media").val(JSON.stringify(this.dropzone_media))},addDocumentIdsToGroupMessagesForm:function(){m("#bp_group_messages_document").length&&m("#bp_group_messages_document").val(JSON.stringify(this.dropzone_media))},addVideoIdsToGroupMessagesForm:function(){m("#bp_group_messages_video").length&&m("#bp_group_messages_video").val(JSON.stringify(this.dropzone_media))},injectMedias:function(t){var i,a,e,o=bp.Nouveau.getStorage("bp-media"),d=o.scope||null,o=o.filter||null;m(t.currentTarget).hasClass("load-more")&&(i=+Number(this.current_page)+1,a=this,e="",t.preventDefault(),m(t.currentTarget).find("a").first().addClass("loading"),m("#buddypress .dir-search input[type=search]").length&&(e=m("#buddypress .dir-search input[type=search]").val()),bp.Nouveau.objectRequest({object:"media",scope:d,filter:o,search_terms:e,page:i,method:"append",target:"#buddypress [data-bp-list] ul.bp-list"}).done(function(e){!0===e.success&&(m(t.currentTarget).remove(),a.current_page=i,jQuery(window).scroll())}))},injectDocuments:function(e){var t,i,a,o=bp.Nouveau.getStorage("bp-document"),d="",s="",n=o.scope||null,r=o.filter||null,l=m(e.currentTarget);l.hasClass("load-more")&&(t=+Number(this.current_page)+1,i=this,a="",e.preventDefault(),l.find("a").first().addClass("loading"),m("#buddypress .dir-search input[type=search]").length&&(a=m("#buddypress .dir-search input[type=search]").val()),s=this.order_by&&this.sort_by?(d=this.sort_by,this.order_by):void 0!==o.extras?(d=o.extras.sort,o.extras.orderby):(d="ASC","title"),bp.Nouveau.objectRequest({object:"document",scope:n,filter:r,search_terms:a,page:t,method:"append",target:"#buddypress [data-bp-list] div#media-folder-document-data-table",order_by:s,sort:d}).done(function(e){!0===e.success&&(l.parent(".pager").remove(),i.current_page=t,jQuery(window).scroll())}))},sortDocuments:function(e){var t=m(e.currentTarget),i=t.data("target"),a="",o="date_created";t.attr("class");switch(i){case"name":o="title";break;case"modified":o="date_modified";break;case"visibility":o="privacy";break;case"group":o="group_id"}t.hasClass("asce")?t.removeClass("asce"):t.addClass("asce");var i=t.hasClass("asce")?"DESC":"ASC",t=(bp.Nouveau.getStorage("bp-document"),{}),t=(t.orderby=o,t.sort=i,"group"!==o&&bp.Nouveau.setStorage("bp-document","extras",t),bp.Nouveau.getStorage("bp-document")),d=t.scope||null,t=t.filter||null;m(e.currentTarget);m("#buddypress .bp-dir-search-form input[type=search]").length&&(a=m("#buddypress .bp-dir-search-form input[type=search]").val()),this.sort_by=i,this.order_by=o,this.current_page=1,bp.Nouveau.objectRequest({object:"document",scope:d,filter:t,search_terms:a,page:1,order_by:o,sort:i,method:"reset",target:"#buddypress [data-bp-list]"}).done()},documentPopupNavigate:function(e){e.preventDefault();var e=m(e.currentTarget),t=e.closest(".bb-field-steps"),i=0==e.closest(".bp-document-listing").length?"#bb-album-child-title":"#bb-album-title";e.closest(".document-options").length&&(i="#bb-album-title"),e.hasClass("bb-field-steps-next")&&""==t.find(i).val().trim()?t.find(i).addClass("error"):(t.find(i).removeClass("error"),t.slideUp(200).siblings(".bb-field-steps").slideDown(200))},uploadDocumentNavigate:function(e){e.preventDefault();var e=m(e.currentTarget),t=m(e).closest("#bp-media-uploader");m(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-document-submit, #bp-media-document-prev, .bp-document-open-create-popup-folder, #bb-document-privacy").show(),0!==Number(m(t).find(".bb-folder-selected-id"))&&m(t).find(".location-folder-list li.is_active").length&&m(t).find(".location-folder-list").scrollTop(m(t).find(".location-folder-list li.is_active").offset().top-m(t).find(".location-folder-list").offset().top),m(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 m(t).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(m(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(m(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),m(t).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||m('...').insertAfter(m(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))})):(m(e).hide(),t.find("#bp-media-document-prev, .bp-document-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-folder").length&&m("#bb-document-privacy").hide())},uploadMediaNavigate:function(e){e.preventDefault();var e=m(e.currentTarget),t=m(e).closest(".bp-media-photo-uploader");m(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-submit, #bp-media-prev, .bp-media-open-create-popup-folder.create-album").show(),t.find("#bb-media-privacy").show(),0!==Number(m(t).find(".bb-album-selected-id"))&&m(t).find(".location-album-list li.is_active").length&&m(t).find(".location-album-list").scrollTop(m(t).find(".location-album-list li.is_active").offset().top-m(t).find(".location-album-list").offset().top)):(m(e).hide(),t.find("#bp-media-prev, .bp-media-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-album").length&&m("#bb-media-privacy").hide())},appendMedia:function(t){var i,a,e,o=bp.Nouveau.getStorage("bp-media"),d=o.scope||null,o=o.filter||null;m(t.currentTarget).hasClass("load-more")&&(i=+Number(this.current_page_existing_media)+1,a=this,e="",t.preventDefault(),m(t.currentTarget).find("a").first().addClass("loading"),m("#buddypress .dir-search input[type=search]").length&&(e=m("#buddypress .dir-search input[type=search]").val()),bp.Nouveau.objectRequest({object:"media",scope:d,filter:o,search_terms:e,page:i,method:"append",caller:"bp-existing-media",target:".bp-existing-media-wrap ul.bp-list"}).done(function(e){!0===e.success&&(m(t.currentTarget).remove(),a.current_page_existing_media=i,jQuery(window).scroll())}))},appendAlbums:function(t){var i=+Number(this.current_page_albums)+1,a=this,e=(t.preventDefault(),m(t.currentTarget).find("a").first().addClass("loading"),{action:"media_albums_loader",_wpnonce:BP_Nouveau.nonces.media,page:i});m.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){!0===e.success&&(m(t.currentTarget).remove(),m("#albums-dir-list ul.bb-albums-list").fadeOut(100,function(){m("#albums-dir-list ul.bb-albums-list").append(e.data.albums),m(this).fadeIn(100)}),a.current_page_albums=i)}})},toggleSubmitMediaButton:function(){var e=m("#bp-media-submit"),t=m("#bp-media-add-more");"bp-dropzone-content"===this.current_tab?this.dropzone_obj.getAcceptedFiles().length?(e.show(),t.show()):(e.hide(),t.hide()):"bp-existing-media-content"===this.current_tab&&(m('.bp-existing-media-wrap .bb-media-check-wrap [name="bb-media-select"]:checked').length?e.show():e.hide(),t.hide())},playVideo:function(e){e.preventDefault();var t=m(e.currentTarget).find("video").get(0),e=m(e.currentTarget).find(".gif-play-button");1==t.paused?(t.play().catch(function(e){console.debug("GIF play failed:",e)}),e.hide()):(t.pause(),e.show())},isElementInScrollableContainer:function(e){var t=m(e),e=e.getBoundingClientRect(),i=t.closest("#bp-message-thread-list");return(i=(i=i.length?i:t.closest(".bb-modal-activity-body")).length?i:t.closest(".bb-media-model-container .activity-list .activity-item")).length?(i=i[0].getBoundingClientRect(),e.bottom>i.top&&e.top i.left&&e.left '),m(t).text());return m(t).text(BP_Nouveau.media.copy_to_clip_board_text),m("#"+e).val(m(t).attr("href")),m("#"+e).select(),document.execCommand("copy"),setTimeout(function(){m(t).text(i)},2e3),!1},fileActivityActionButton:function(e){e.preventDefault(),m(e.currentTarget).parent().hasClass("copy_download_file_url")||(m(e.currentTarget).closest(".bb-activity-media-elem").toggleClass("is-visible").siblings().removeClass("is-visible").closest(".activity-item").siblings().find(".bb-activity-media-elem").removeClass("is-visible"),m(e.currentTarget).closest(".bb-activity-media-elem").find(".bb_more_dropdown").toggleClass("open").closest(".bb-activity-media-elem").siblings().find(".bb_more_dropdown").removeClass("open").closest(".activity-item").siblings().find(".bb-activity-media-elem .bb_more_dropdown").removeClass("open"),m("body").addClass("document_more_option_open"),m(e.currentTarget).closest(".bb-activity-media-elem").length<1&&(m(e.currentTarget).closest(".bb-photo-thumb").toggleClass("is-visible").parent().siblings().find(".bb-photo-thumb").removeClass("is-visible").removeClass("is-visible"),m(e.currentTarget).closest(".bb-photo-thumb").find(".bb_more_dropdown").toggleClass("open").closest(".bb-photo-thumb").parent().siblings().find(".bb-photo-thumb .bb_more_dropdown").removeClass("open")),"a"!=e.currentTarget.tagName.toLowerCase())||m(e.currentTarget).hasClass("document-action_more")||m(e.currentTarget).hasClass("media-action_more")||(m(e.currentTarget).closest(".bb-activity-media-elem").removeClass("is-visible").find(".bb_more_dropdown").removeClass("open"),m(e.currentTarget).closest(".bb-photo-thumb").removeClass("is-visible").find(".bb_more_dropdown").removeClass("open"))},toggleFileActivityActionButton:function(e){var t;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),!0===e.altKey||!0===e.metaKey||m(t).hasClass("document-action_more")||m(t).parent().hasClass("document-action_more")||m(t).hasClass("media-folder_action__anchor")||m(t).parent().hasClass("media-folder_action__anchor")||m(t).hasClass("media-action_more")||m(t).parent().hasClass("media-action_more")||m(t).hasClass("video-action_more")||m(t).parent().hasClass("video-action_more")?e:(m(".bb-activity-media-elem.is-visible").removeClass("is-visible"),m(".media-folder_items.is-visible").removeClass("is-visible"),m(".bb-photo-thumb.is-visible").removeClass("is-visible"),m(".bb-item-thumb.is-visible").removeClass("is-visible"),m(".bb-activity-video-elem.is-visible").removeClass("is-visible"),m(".video-action-wrap.item-action-wrap.is-visible").removeClass("is-visible"),m(".video-action-wrap .bb_more_dropdown").removeClass("open"),m(".bb-activity-media-elem .bb_more_dropdown").removeClass("open"),m(".bb-photo-thumb .bb_more_dropdown").removeClass("open"),m(".media-folder_items .bb_more_dropdown").removeClass("open"),void m("body").removeClass("document_more_option_open video_more_option_open item_more_option_open"))},toggleCodePreview:function(e){e.preventDefault(),m(e.currentTarget).closest(".document-activity").toggleClass("code-full-view")},documentCodeMirror:function(){m(".document-text:not(.loaded)").each(function(){var e=m(this),t=e.attr("data-extension"),i=e.attr("data-extension");"html"!=t&&"htm"!=t||(i="text/html"),"js"==t?CodeMirror(e[0],{value:e.find(".document-text-file-data-hidden").val(),lineNumbers:!0,theme:"default",readOnly:!0,lineWrapping:!0}):CodeMirror(e[0],{value:e.find(".document-text-file-data-hidden").val(),mode:i,lineNumbers:!0,theme:"default",readOnly:!0,lineWrapping:!0}),e.addClass("loaded"),150 '+e+" "+t)):(t=m(".single-screen-navs.groups-nav").find("ul li#albums-groups-li"),0 '+e+"")))}},bp.Nouveau.Media.Theatre={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){this.bodySelector=m("body"),this.medias=[],this.documents=[],this.current_media=!1,this.current_document=!1,this.current_index=0,this.current_document_index=0,this.is_open_media=!1,this.is_open_document=!1,this.nextLink=m(".bb-next-media"),this.nextDocumentLink=m(".bb-next-document"),this.previousDocumentLink=m(".bb-prev-document"),this.previousLink=m(".bb-prev-media"),this.activity_ajax=!1,this.group_id=void 0!==BP_Nouveau.media.group_id&&BP_Nouveau.media.group_id,this.manage_media=void 0!==BP_Nouveau.media.can_manage_media&&BP_Nouveau.media.can_manage_media,this.manage_document=void 0!==BP_Nouveau.media.can_manage_document&&BP_Nouveau.media.can_manage_document},addListeners:function(){m(document).on("click",".bb-open-media-theatre",this.openTheatre.bind(this)),m(document).on("click",".bb-open-document-theatre",this.openDocumentTheatre.bind(this)),m(document).on("click",".document-detail-wrap-description-popup",this.openDocumentTheatre.bind(this)),m(document).on("click",".bb-close-media-theatre",this.closeTheatre.bind(this)),m(document).on("click",".bb-close-document-theatre",this.closeDocumentTheatre.bind(this)),m(document).on("click",".bb-prev-media",this.previous.bind(this)),m(document).on("click",".bb-next-media",this.next.bind(this)),m(document).on("click",".bb-prev-document",this.previousDocument.bind(this)),m(document).on("click",".bb-next-document",this.nextDocument.bind(this)),m(document).on("bp_activity_ajax_delete_request",this.activityDeleted.bind(this)),m(document).on("click","#bb-media-model-container .media-privacy>li",this.mediaPrivacyChange.bind(this)),m(document).on("click","#bb-media-model-container .document-privacy>li",this.documentPrivacyChange.bind(this)),m(document).on("click","#bb-media-model-container .bb-media-section span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),m(document).on("click","#bb-media-model-container .bb-document-section span.privacy",bp.Nouveau,this.toggleDocumentPrivacyDropdown.bind(this)),m(document).on("click",".bp-add-media-activity-description",this.openMediaActivityDescription.bind(this)),m(document).on("click","#bp-activity-description-new-reset",this.closeMediaActivityDescription.bind(this)),m(document).on("keyup",".bp-edit-media-activity-description #add-activity-description",this.MediaActivityDescriptionUpdate.bind(this)),m(document).on("click","#bp-activity-description-new-submit",this.submitMediaActivityDescription.bind(this)),m(document).click(this.togglePopupDropdown),document.addEventListener("keyup",this.checkPressedKeyDocuments.bind(this)),document.addEventListener("keyup",this.checkPressedKey.bind(this))},checkPressedKey:function(e){var t=this;if(e=e||window.event,!t.is_open_media)return!1;var i=m(e.target).hasClass("ac-input")||"add-activity-description"===m(e.target).attr("id");switch(e.keyCode){case 27:t.closeTheatre(e);break;case 37:if(void 0===t.medias[t.current_index-1]||i)return!1;t.previous(e);break;case 39:if(void 0===t.medias[t.current_index+1]||i)return!1;t.next(e)}},checkPressedKeyDocuments:function(e){e=e||window.event;var t=this;if(!t.is_open_document)return!1;var i=m(e.target).hasClass("ac-input")||"add-activity-description"===m(e.target).attr("id");switch(e.keyCode){case 27:t.closeDocumentTheatre(e);break;case 37:if(void 0===t.documents[t.current_document_index-1]||i)return!1;t.previousDocument(e);break;case 39:if(void 0===t.documents[t.current_document_index+1]||i)return!1;t.nextDocument(e)}},openTheatre:function(e){e.preventDefault();var e=m(e.currentTarget),t=this;if(e.closest("#bp-existing-media-content").length)return!1;t.setupGlobals(),t.setMedias(e),i=e.data("id"),e.data("activity-id"),t.setCurrentMedia(i),t.showMedia(),t.navigationCommands(),t.getParentActivityHtml(e),t.getMediasDescription(),m(".bb-media-model-wrapper.document").hide();var i=document.getElementById(m(".bb-media-model-wrapper.video video").attr("id"));i&&i.pause(),m(".bb-media-model-wrapper.video").hide(),m(".bb-media-model-wrapper.media").show(),bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay"),t.is_open_media=!0,t.bodySelector.addClass("media-modal-open"),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)},getParentActivityHtml:function(e){var t=m("#hidden_parent_id").val(),e=e.closest(".bb-media-model-wrapper").find("#bb-media-model-container .activity-list li.activity-item").data("bp-activity-id");parseInt(t)===parseInt(e)&&(e=m('#bb-media-model-container [data-bp-activity-id="'+t+'"]'),m('[data-bp-activity-id="'+t+'"] > .activity-state').html(m(e).find(".activity-state").html()),m('[data-bp-activity-id="'+t+'"] > .activity-meta').html(m(e).find(".activity-meta").html()),m('[data-bp-activity-id="'+t+'"] > .activity-comments').html(m(e).find(".activity-comments").html())),m("#hidden_parent_id").length&&m("#hidden_parent_id").remove()},getMediasDescription:function(){var e=this,t=(m(".bb-media-info-section .activity-list").addClass("loading").html(''),0!=e.activity_ajax&&e.activity_ajax.abort(),m('[data-bp-activity-id="'+e.current_media.activity_id+'"] .activity-comments'));t.length&&(t=t.find("#ac-form-"+e.current_media.activity_id),e.current_media.parent_activity_comments=!0,t.remove()),!0===e.current_media.parent_activity_comments&&m(".bb-media-model-wrapper:last").after(''),e.activity_ajax=m.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"media_get_media_description",id:e.current_media.id,attachment_id:e.current_media.attachment_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success?(m(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.description),m(".bb-media-info-section:visible").show(),bp.Nouveau.Media.Theatre.syncPinPostIconToTheatre(),m(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10)):m(".bb-media-info-section.media").hide()}})},openDocumentTheatre:function(e){e.preventDefault();var t=m(e.currentTarget),i=this;if(t.closest("#bp-existing-document-content").length)return!1;t.closest(".document.document-theatre").length&&i.closeDocumentTheatre(e),a=t.data("id"),i.setupGlobals(),i.setDocuments(t),i.setCurrentDocument(a),i.showDocument(),i.navigationDocumentCommands(),i.getParentActivityHtml(t),i.getDocumentsDescription(),-1!==m.inArray(i.current_document.extension,BP_Nouveau.document.mp3_preview_extension.split(","))&&m(e.currentTarget).closest(".bb-activity-media-elem.document-activity").length&&m(e.currentTarget).closest(".bb-activity-media-elem.document-activity").find(".document-audio-wrap").length&&m(e.currentTarget).closest(".bb-activity-media-elem.document-activity").find(".document-audio-wrap audio")[0].pause(),m(".bb-media-model-wrapper.media").hide(),m(".bb-media-model-wrapper.document").show();var a=document.getElementById(m(".bb-media-model-wrapper.video video").attr("id"));a&&(a.pause(),a.src=""),m(".bb-media-model-wrapper.video").hide(),i.is_open_document=!0,i.bodySelector.addClass("document-modal-open"),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay")},500)},resetRemoveActivityCommentsData:function(){var e,t=this,i=!1,a=!1,o=!1,d=!1,s=!1,n=!1;t.current_media.parent_activity_comments&&((i=(d=m('.bb-media-model-wrapper.media [data-bp-activity-id="'+t.current_media.activity_id+'"]')).find(".activity-comments")).length&&(e=i.find("#ac-form-"+t.current_media.activity_id),this.purgeEditActivityForm(e),e.find("#ac-input-"+t.current_media.activity_id).html(""),e.removeClass("has-content has-gif has-media").addClass("root"),i.append(e),e.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(t.current_media.activity_id),i.find(".acomment-display").removeClass("display-focus"),i.find(".comment-item").removeClass("comment-item-focus"),s=i.html(),n=i.attr("class"),i.remove(),(i=m('[data-bp-activity-id="'+t.current_media.activity_id+'"] .activity-comments')).length)&&(i.attr("class",n),0===i.find("#ac-form-"+t.current_media.activity_id).length)&&(i.append(e),i.children("form").removeClass("events-initiated").addClass("not-initialized")),(o=d.find(".activity-state")).length&&(s=o.html(),n=o.attr("class"),o.remove(),(o=m('[data-bp-activity-id="'+t.current_media.activity_id+'"] .activity-state')).length)&&(o.html(s),o.attr("class",n)),(a=d.find(".activity-meta")).length&&(s=a.html(),n=a.attr("class"),a.remove(),(a=m('[data-bp-activity-id="'+t.current_media.activity_id+'"] > .activity-meta')).length)&&(a.html(s),a.attr("class",n)),d.remove()),t.current_document.parent_activity_comments&&((i=(d=m('.bb-media-model-wrapper.document [data-bp-activity-id="'+t.current_document.activity_id+'"]')).find(".activity-comments")).length&&(e=i.find("#ac-form-"+t.current_document.activity_id),this.purgeEditActivityForm(e),e.find("#ac-input-"+t.current_document.activity_id).html(""),e.removeClass("has-content has-gif has-media").addClass("root"),i.append(e),e.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(t.current_document.activity_id),i.find(".acomment-display").removeClass("display-focus"),i.find(".comment-item").removeClass("comment-item-focus"),s=i.html(),n=i.attr("class"),i.remove(),(i=m('[data-bp-activity-id="'+t.current_document.activity_id+'"] .activity-comments')).length)&&(i.attr("class",n),0===i.find("#ac-form-"+t.current_document.activity_id).length&&(i.append(e),i.children("form").removeClass("events-initiated").addClass("not-initialized")),i.find(".document-text.loaded").removeClass("loaded").find(".CodeMirror").remove(),jQuery(window).scroll()),(o=d.find(".activity-state")).length&&(s=o.html(),n=o.attr("class"),o.remove(),(o=m('[data-bp-activity-id="'+t.current_document.activity_id+'"] .activity-state')).length)&&(o.html(s),o.attr("class",n)),(a=d.find(".activity-meta")).length&&(s=a.html(),n=a.attr("class"),a.remove(),(a=m('[data-bp-activity-id="'+t.current_document.activity_id+'"] > .activity-meta')).length)&&(a.html(s),a.attr("class",n)),d.remove()),bp.Nouveau.reportPopUp(),bp.Nouveau.reportActions()},closeTheatre:function(e){e.preventDefault();var t=this,e=m(e.currentTarget);if(m(e).closest(".bb-media-model-wrapper").hasClass("video-theatre"))return!1;m(".bb-media-model-wrapper.media .bb-media-section").find("img").attr("src",""),m(".bb-media-model-wrapper.video .bb-media-section").find("video").length&&videojs(m(".bb-media-model-wrapper.video .bb-media-section").find("video").attr("id")).reset(),m(".bb-media-model-wrapper").hide(),t.is_open_media=!1,t.syncPinPostActivityOnCloseTheatre(e),t.resetRemoveActivityCommentsData(),t.current_media=!1,t.getParentActivityHtml(e),t.bodySelector.removeClass("media-modal-open")},closeDocumentTheatre:function(e){e.preventDefault();var t=this,i=m(document).find(".document-theatre");i.find(".bb-media-section").removeClass("bb-media-no-preview").find(".document-preview").html(""),m(".bb-media-info-section.document").show(),i.hide(),t.is_open_document=!1,t.resetRemoveActivityCommentsData(),t.current_document=!1,t.getParentActivityHtml(m(e.currentTarget)),t.bodySelector.removeClass("document-modal-open")},setMedias:function(e){var t=m(".bb-open-media-theatre"),i=0;if(void 0!==(t=m("body").hasClass("activity")?m(e).closest(".bb-activity-media-wrap").find(".bb-open-media-theatre"):t))for(this.medias=[],i=0;i '),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html(" "+i+'
'),o.find(".bb-document-section .document-preview .document-text").attr("data-extension",d),t=o.find(".bb-document-section .document-preview .document-text textarea"),"html"===d||"htm"===d?t.val(s):t.html(s),setTimeout(function(){bp.Nouveau.Media.documentCodeMirror()},1e3)):-1!==m.inArray(e.current_document.extension,BP_Nouveau.document.mp3_preview_extension.split(","))?(o.find(".bb-document-section .document-preview").html(''),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html('')):-1!==m.inArray("."+e.current_document.extension,BP_Nouveau.video.video_type.split(","))?(o.find(".bb-document-section").addClass("bb-video-preview"),o.find(".bb-document-section .document-preview").html(''),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),"mov"===e.current_document.extension||"m4v"===e.current_document.extension?o.find(".bb-document-section .document-preview").html(''):o.find(".bb-document-section .document-preview").html(''),m(window).scroll()):e.current_document.full_preview?(o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html("'+i+'
"+i+'
')):(o.find(".bb-document-section").addClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html('")),m(".bb-document-section .bb-document-privacy-wrap"));d.length&&(d.show(),d.parent().show(),d.find("ul.document-privacy li").removeClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",""),(t=d.find("ul.document-privacy").find("li[data-value="+e.current_document.privacy+"]")).addClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",t.text()),d.find(".privacy").removeClass("public").removeClass("loggedin").removeClass("onlyme").removeClass("friends").addClass(e.current_document.privacy),void 0!==BP_Nouveau.activity&&void 0!==e.current_document.activity_id&&0!=e.current_document.activity_id||e.group_id||e.current_document.is_forum||e.current_document.group_id||e.current_document.album_id||!e.can_manage_document||!e.current_document.can_edit||e.current_document.is_message)&&d.parent().hide(),e.navigationDocumentCommands()},next:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.medias[e.current_index+1]?(e.current_index=e.current_index+1,e.current_media.activity_id,e.current_media=e.medias[e.current_index],e.showMedia(),e.getMediasDescription(),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):e.nextLink.hide()},previous:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.medias[e.current_index-1]?(e.current_index=e.current_index-1,e.current_media.activity_id,e.current_media=e.medias[e.current_index],e.showMedia(),e.getMediasDescription(),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):e.previousLink.hide()},nextDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.documents[e.current_document_index+1]?(e.current_document_index=e.current_document_index+1,e.current_document.activity_id,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.nextDocumentLink.hide()},previousDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.documents[e.current_document_index-1]?(e.current_document_index=e.current_document_index-1,e.current_document.activity_id,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.previousDocumentLink.hide()},navigationCommands:function(){var e=this;0==e.current_index&&e.current_index!=e.medias.length-1?(e.previousLink.hide(),e.nextLink.show()):0==e.current_index&&e.current_index==e.medias.length-1?(e.previousLink.hide(),e.nextLink.hide()):e.current_index==e.medias.length-1?(e.previousLink.show(),e.nextLink.hide()):(e.previousLink.show(),e.nextLink.show())},navigationDocumentCommands:function(){var e=this;0==e.current_document_index&&e.current_document_index!=e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.show()):0==e.current_document_index&&e.current_document_index==e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.hide()):e.current_document_index==e.documents.length-1?(e.previousDocumentLink.show(),e.nextDocumentLink.hide()):(e.previousDocumentLink.show(),e.nextDocumentLink.show())},getActivity:function(){var e=this;m(".bb-media-info-section .activity-list").addClass("loading").html(''),void 0!==BP_Nouveau.activity&&e.current_media&&void 0!==e.current_media.activity_id&&0!=e.current_media.activity_id&&!e.current_media.is_forum?(0!=e.activity_ajax&&e.activity_ajax.abort(),m('[data-bp-activity-id="'+e.current_media.activity_id+'"] .activity-comments').length&&(e.current_media.parent_activity_comments=!0),!0===e.current_media.parent_activity_comments&&m(".bb-media-model-wrapper:last").after(''),e.activity_ajax=m.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"media_get_activity",id:e.current_media.activity_id,group_id:_.isUndefined(e.current_media.group_id)?0:e.current_media.group_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success&&(m(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.activity),m(".bb-media-info-section:visible").show(),jQuery(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10))}})):m(".bb-media-info-section.media").hide()},getDocumentsActivity:function(){var e=this;m(".bb-media-info-section .activity-list").addClass("loading").html(''),void 0!==BP_Nouveau.activity&&e.current_document&&void 0!==e.current_document.activity_id&&0!=e.current_document.activity_id&&!e.current_document.is_forum?(0!=e.activity_ajax&&e.activity_ajax.abort(),m('[data-bp-activity-id="'+e.current_document.activity_id+'"] .activity-comments').length&&(e.current_document.parent_activity_comments=!0),!0===e.current_document.parent_activity_comments&&m(".bb-media-model-wrapper:last").after(''),e.activity_ajax=m.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"document_get_activity",id:e.current_document.activity_id,group_id:_.isUndefined(e.current_document.group_id)?0:e.current_document.group_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success&&(m(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.activity),m(".bb-media-info-section:visible").show(),jQuery(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10))}})):m(".bb-media-info-section.document").hide()},getDocumentsDescription:function(){var e=this,t=(m(".bb-media-info-section .activity-list").addClass("loading").html(''),0!=e.activity_ajax&&e.activity_ajax.abort(),m('[data-bp-activity-id="'+e.current_document.activity_id+'"] .activity-comments'));t.length&&(t=t.find("#ac-form-"+e.current_document.activity_id),e.current_document.parent_activity_comments=!0,t.remove()),!0===e.current_document.parent_activity_comments&&m(".bb-media-model-wrapper:last").after(''),e.activity_ajax=m.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"document_get_document_description",id:e.current_document.id,attachment_id:e.current_document.attachment_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success?(m(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.description),m(".bb-media-info-section:visible").show(),bp.Nouveau.Media.Theatre.syncPinPostIconToTheatre(),m(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10)):m(".bb-media-info-section.document").hide()}})},activityDeleted:function(e,t){var i=this,a=0;if(i.is_open_media&&void 0!==t&&"delete_activity"===t.action&&i.current_media.activity_id==t.id){var o=m(document).find('[data-bp-list="media"] .bb-open-media-theatre[data-id="'+i.current_media.id+'"]'),d=o.parents("ul");for(o.closest("li").remove(),0===d.find("li:not(.load-more)").length&&(0'+i+"
.activity-list").children("#activity-"+i)).length&&e.hasClass("bb-pinned")&&0 {"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},bp.Nouveau.Media={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){var e=p("body"),e=(this.current_page=1,this.current_page_existing_media=1,this.current_page_albums=1,this.current_tab=!e.hasClass("single-topic")&&!e.hasClass("single-forum")&&"bp-dropzone-content",this.sort_by="",this.order_by="",this.currentTargetParent=BP_Nouveau.media.current_folder,this.moveToIdPopup=BP_Nouveau.media.move_to_id_popup,this.moveToTypePopup=BP_Nouveau.media.current_type,this.privacySelectorSelect="",this.privacySelectorSpan="",this.currentAlbum=BP_Nouveau.media.current_album,void 0!==window.Dropzone&&(window.Dropzone.autoDiscover=!1),document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:""),e=(this.documentOptions={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,acceptedFiles:BP_Nouveau.media.document_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.media.dropzone_document_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.document.maxFiles?BP_Nouveau.document.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.document.max_upload_size?BP_Nouveau.document.max_upload_size:2,dictInvalidFileType:BP_Nouveau.document.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation},document.getElementsByClassName("forum-post-video-template").length?document.getElementsByClassName("forum-post-video-template")[0].innerHTML:"");this.videoOptions={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.video.dictFileTooBig,acceptedFiles:BP_Nouveau.video.video_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.video.dropzone_video_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.video.maxFiles?BP_Nouveau.video.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.video.max_upload_size?BP_Nouveau.video.max_upload_size:2,dictInvalidFileType:BP_Nouveau.video.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.video.video_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.video.dictCancelUploadConfirmation},p("#bp-media-uploader").hasClass("bp-media-document-uploader")?(e=document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:"",this.options={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,acceptedFiles:BP_Nouveau.media.document_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.media.dropzone_document_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.document.maxFiles?BP_Nouveau.document.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.document.max_upload_size?BP_Nouveau.document.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation}):(e=document.getElementsByClassName("forum-post-media-template").length?document.getElementsByClassName("forum-post-media-template")[0].innerHTML:"",this.options={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,dictDefaultMessage:BP_Nouveau.media.dropzone_media_message,acceptedFiles:"image/*",autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.media.maxFiles?BP_Nouveau.media.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.media_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation,maxThumbnailFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2}),void 0!==BP_Nouveau.media.dropzone_options&&Object.assign(this.options,BP_Nouveau.media.dropzone_options),this.dropzone_obj=[],this.dropzone_media=[],this.album_id=void 0!==BP_Nouveau.media.album_id&&BP_Nouveau.media.album_id,this.current_folder=void 0!==BP_Nouveau.media.current_folder&&BP_Nouveau.media.current_folder,this.current_group_id=void 0!==BP_Nouveau.media.current_group_id&&BP_Nouveau.media.current_group_id,this.group_id=void 0!==BP_Nouveau.media.group_id&&BP_Nouveau.media.group_id,this.bbp_is_reply_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_reply_edit&&window.BP_Forums_Nouveau.media.bbp_is_reply_edit,this.bbp_is_topic_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_topic_edit&&window.BP_Forums_Nouveau.media.bbp_is_topic_edit,this.bbp_is_forum_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_forum_edit&&window.BP_Forums_Nouveau.media.bbp_is_forum_edit,this.bbp_reply_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_media?window.BP_Forums_Nouveau.media.reply_edit_media:[],this.bbp_reply_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_document?window.BP_Forums_Nouveau.media.reply_edit_document:[],this.bbp_reply_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_video?window.BP_Forums_Nouveau.media.reply_edit_video:[],this.bbp_topic_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_media?window.BP_Forums_Nouveau.media.topic_edit_media:[],this.bbp_topic_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_video?window.BP_Forums_Nouveau.media.topic_edit_video:[],this.bbp_topic_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_document?window.BP_Forums_Nouveau.media.topic_edit_document:[],this.bbp_forum_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_media?window.BP_Forums_Nouveau.media.forum_edit_media:[],this.bbp_forum_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_document?window.BP_Forums_Nouveau.media.forum_edit_document:[],this.bbp_forum_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_video?window.BP_Forums_Nouveau.media.forum_edit_video:[],this.bbp_reply_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_gif_data?window.BP_Forums_Nouveau.media.reply_edit_gif_data:[],this.bbp_topic_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_gif_data?window.BP_Forums_Nouveau.media.topic_edit_gif_data:[],this.bbp_forum_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_gif_data?window.BP_Forums_Nouveau.media.forum_edit_gif_data:[],this.giphy=null,this.gif_offset=0,this.gif_q=null,this.gif_limit=20,this.gif_requests=[],this.gif_data=[],this.gif_container_key=!1,this.reply_topic_allow_delete_media=!1,this.reply_topic_display_post="edit",bp.Nouveau.Media.documentCodeMirror(),p(window).on("scroll resize",function(){bp.Nouveau.Media.documentCodeMirror()})},addListeners:function(){var e=p(".bp-nouveau"),t=p(".bp-existing-media-wrap"),t=(e.on("click","#bp-add-media",this.openUploader.bind(this)),e.on("click","#bp-add-document",this.openDocumentUploader.bind(this)),e.on("click","#bp-media-submit",this.submitMedia.bind(this)),e.on("click","#bp-media-document-submit",this.submitDocumentMedia.bind(this)),e.on("click","#bp-media-uploader-close",this.closeUploader.bind(this)),e.on("click","#bb-delete-media",this.deleteMedia.bind(this)),e.on("click","#bb-select-deselect-all-media",this.toggleSelectAllMedia.bind(this)),void 0!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request?p('#buddypress [data-bp-list="media"]').on("bp_ajax_request",this.bp_ajax_media_request):this.bp_media_after_load(),e.on("click","#bb-create-album",this.openCreateAlbumModal.bind(this)),p(document).on("click","#bb-create-folder",this.openCreateFolderModal.bind(this)),p(document).on("click","#bb-create-folder-child",this.openCreateFolderChildModal.bind(this)),p(document).on("click","#bp-edit-folder-open",this.openEditFolderChildModal.bind(this)),p(document).on("click","#bp-media-create-album-submit",this.saveAlbum.bind(this)),p(document).on("click","#bp-media-create-folder-submit",this.saveFolder.bind(this)),p(document).on("click","#bp-media-create-child-folder-submit",this.saveChildFolder.bind(this)),e.on("click","#bp-media-create-album-close",this.closeCreateAlbumModal.bind(this)),p(document).on("click","#bp-media-create-folder-close",this.closeCreateFolderModal.bind(this)),p(document).on("click","#bp-media-edit-folder-close",this.closeEditFolderModal.bind(this)),p(document).on("click",".open-popup .errorPopup",this.closeErrorPopup.bind(this)),e.on("click","#bp-media-add-more",this.triggerDropzoneSelectFileDialog.bind(this)),p("#bp-media-uploader").on("click",".bp-media-upload-tab",this.changeUploadModalTab.bind(this)),p('.bp-nouveau [data-bp-list="media"]').on("click","li.load-more",this.injectMedias.bind(this)),p(".bp-nouveau #albums-dir-list").on("click","li.load-more",this.appendAlbums.bind(this)),t.on("click","li.load-more",this.appendMedia.bind(this)),e.on("change",'.bb-media-check-wrap [name="bb-media-select"]',this.addSelectedClassToWrapper.bind(this)),t.on("change",'.bb-media-check-wrap [name="bb-media-select"]',this.toggleSubmitMediaButton.bind(this)),e.on("click","#bp-edit-album-title",this.editAlbumTitle.bind(this)),p(document).on("click","#bp-edit-folder-title",this.editFolderTitle.bind(this)),e.on("click","#bp-cancel-edit-album-title",this.cancelEditAlbumTitle.bind(this)),e.on("click","#bp-save-album-title",this.saveAlbum.bind(this)),p(document).on("click","#bp-save-folder-title",this.saveFolder.bind(this)),e.on("change","#bp-media-single-album select#bb-album-privacy",this.saveAlbum.bind(this)),e.on("change","#media-stream select#bb-folder-privacy",this.savePrivacy.bind(this)),e.on("click","#bb-delete-album",this.deleteAlbum.bind(this)),p(document).on("click","#bb-delete-folder",this.deleteFolder.bind(this)),p(document).on("click","ul.document-nav li",this.resetPageDocumentDirectory.bind(this)),p(document).on("click","ul.document-nav li a",this.resetPageDocumentDirectory.bind(this)),p(document).on("click","#forums-media-button",this.openForumsUploader.bind(this)),p(document).on("click","#forums-document-button",this.openForumsDocumentUploader.bind(this)),p(document).on("click","#forums-video-button",this.openForumsVideoUploader.bind(this)),p(document).on("click","#forums-gif-button",this.toggleGifSelector.bind(this)),p(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("keydown",".search-query-input",this.searchGif.bind(this)),p(document).on("click",".bbpress-forums-activity #whats-new-toolbar .found-media-item",this.selectGif.bind(this)),p(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("click",".found-media-item",this.selectGif.bind(this)),p(document).find("form #whats-new-toolbar .gif-search-results, .forum form #whats-new-toolbar .gif-search-results").scroll(this.loadMoreGif.bind(this)),p(".buddypress.groups.messages").length||p(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("click",".found-media-item",this.selectGif.bind(this)),p(document).find("form #whats-new-attachments .forums-attached-gif-container .gif-search-results, .forum form #whats-new-attachments .forums-attached-gif-container .gif-search-results").scroll(this.loadMoreGif.bind(this)),p(document).find("form #whats-new-attachments .forums-attached-gif-container, .forum form #whats-new-attachments .forums-attached-gif-container").on("click",".gif-image-remove",this.removeSelectedGif.bind(this)),p(document).on("click",".gif-image-container",this.playVideo.bind(this)),p(document).on("click",".directory.document .media-folder_action__anchor, .directory.document .media-folder_action__anchor li a, .bb-media-container .media-folder_action__anchor, .bb-media-container .media-folder_action__list li a",this.fileActionButton.bind(this)),p(document).on("click",".bb-activity-media-elem .copy_download_file_url a, .media-folder_action__list .copy_download_file_url a, .media .bb-photo-thumb .copy_download_file_url a",this.copyDownloadLink.bind(this)),p(document).on("click",".bb-activity-media-elem.media-activity .media-action-wrap .media-action_more, #media-stream.media .bb-photo-thumb .media-action-wrap .media-action_more, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_more, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_list li a",this.fileActivityActionButton.bind(this)),p(document).click(this.toggleFileActivityActionButton),p(document).on("click",".bb-activity-media-elem.document-activity .document-expand .document-expand-anchor, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_collapse",this.toggleCodePreview.bind(this)),p(document).on("click",".activity .bp-document-move-activity, #media-stream .bp-document-move-activity",this.moveDocumentIntoFolder.bind(this)),p(document).on("click",'.bp-nouveau [data-bp-list="document"] .pager .dt-more-container.load-more',this.injectDocuments.bind(this)),p(document).on("click",'.bp-nouveau [data-bp-list="document"] .data-head',this.sortDocuments.bind(this)),p(document).on("click",".modal-container .bb-field-steps-actions",this.documentPopupNavigate.bind(this)),p(document).on("click",".bp-media-document-uploader .modal-container .bb-field-uploader-actions",this.uploadDocumentNavigate.bind(this)),p(document).on("click",".bp-media-photo-uploader .modal-container .bb-field-uploader-actions",this.uploadMediaNavigate.bind(this)),p(document).on("click",".modal-container #bp-media-edit-child-folder-submit",this.renameChildFolder.bind(this)),p(document).on("click",".activity .bp-media-move-activity, #media-stream .bp-media-move-activity",this.moveMediaIntoAlbum.bind(this)),p("#bb-media-model-container .activity-list, #media-stream")),e="#buddypress .activity-list",i='#buddypress [data-bp-list="activity"]',a="#bb-media-model-container .activity-list",o="#media-stream",e=(p(document).on("click",e+" .ac-document-move, "+i+" .ac-document-move, "+e+" .ac-folder-move, "+i+" .ac-folder-move, "+a+" .ac-document-move, "+a+" .ac-folder-move, "+o+" .ac-document-move, "+o+" .ac-folder-move",this.openDocumentMove.bind(this)),p(document).on("click",e+" .ac-media-move, "+i+" .ac-media-move, "+a+" .ac-media-move, "+o+" .ac-media-move, .group-media "+o+" .ac-media-move",this.openMediaMove.bind(this)),p(document).on("click",e+" .ac-document-close-button, "+i+" .ac-document-close-button, "+e+" .ac-folder-close-button, "+i+" .ac-folder-close-button, "+a+" .ac-document-close-button, "+a+" .ac-folder-close-button, "+o+" .ac-document-close-button, "+o+" .ac-folder-close-button",this.closeDocumentMove.bind(this)),p(document).on("click",e+" .ac-media-close-button, "+i+" .ac-media-close-button, "+a+" .ac-media-close-button, "+o+" .ac-media-close-button",this.closeMediaMove.bind(this)),t.on("click",".ac-document-rename",this.renameDocument.bind(this)),t.on("click",".ac-document-privacy",this.editPrivacyDocument.bind(this)),t.on("keyup",".media-folder_name_edit",this.renameDocumentSubmit.bind(this)),t.on("click",".name_edit_cancel, .name_edit_save",this.renameDocumentSubmit.bind(this)),p(document).on("click",".document-file-delete",this.deleteDocument.bind(this)),p(document).on("click",".media-file-delete",this.deleteMedia.bind(this)),p(document).on("click",".bp-folder-move",this.folderMove.bind(this)),p(document).on("click",".bp-document-open-create-popup-folder",this.createFolderInPopup.bind(this)),p(document).on("click",".bp-media-open-create-popup-folder",this.createAlbumInPopup.bind(this)),p(document).on("click",".close-create-popup-folder",this.closeCreateFolderInPopup.bind(this)),p(document).on("click",".close-create-popup-album",this.closeCreateAlbumInPopup.bind(this)),p(document).on("click",".bp-document-create-popup-folder-submit",this.submitCreateFolderInPopup.bind(this)),p(document).on("click",".bp-media-create-popup-album-submit",this.submitCreateAlbumInPopup.bind(this)),p(".buddypress.groups.messages")),i=p(".buddypress.groups.messages form#send_group_message_form #whats-new-toolbar"),a=p(".buddypress.groups.messages form#send_group_message_form #whats-new-attachments .bp-group-messages-attached-gif-container .gif-search-results"),o=p(".buddypress.groups.messages form#send_group_message_form #whats-new-attachments .bp-group-messages-attached-gif-container");e.on("click","#bp-group-messages-media-button",this.openGroupMessagesUploader.bind(this)),e.on("click","#bp-group-messages-document-button",this.openGroupMessagesDocumentUploader.bind(this)),e.on("click","#bp-group-messages-video-button",this.openGroupMessagesVideoUploader.bind(this)),e.on("click","#bp-group-messages-gif-button",this.toggleGroupMessagesGifSelector.bind(this)),i.on("keyup",".search-query-input",this.searchGroupMessagesGif.bind(this)),i.on("click",".found-media-item",this.selectGroupMessagesGif.bind(this)),a.scroll(this.loadMoreGroupMessagesGif.bind(this)),p(".groups.messages form#send_group_message_form #whats-new-toolbar .bp-group-messages-attached-gif-container .gif-search-results").scroll(this.loadMoreGroupMessagesGif.bind(this)),o.on("click",".gif-image-remove",this.removeGroupMessagesSelectedGif.bind(this)),p(".bp-existing-media-wrap").on("scroll",this.loadExistingMedia.bind(this)),document.addEventListener("keyup",this.closePopup.bind(this)),document.addEventListener("keyup",this.submitPopup.bind(this)),p(window).bind("beforeunload",this.beforeunloadWindow.bind(this)),_.isUndefined(BP_Nouveau.media.gif_api_key)||(window.addEventListener("scroll",this.throttledAutoPlayGifVideos.bind(this),!1),window.addEventListener("resize",this.throttledAutoPlayGifVideos.bind(this),!1),(t=p("#bp-message-thread-list")).length&&t.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),(e=p(".bb-modal-activity-body")).length&&e.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),(i=p(".bb-media-model-container .activity-list .activity-item")).length&&i.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),p(document).on("scroll","#bp-message-thread-list",this.throttledAutoPlayGifVideos.bind(this)),p(document).on("scroll",".bb-modal-activity-body",this.throttledAutoPlayGifVideos.bind(this)),p(document).on("scroll",".bb-media-model-container .activity-list .activity-item",this.throttledAutoPlayGifVideos.bind(this)),setTimeout(function(){var e=document.getElementById("bp-message-thread-list"),e=(e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1),document.querySelector(".bb-modal-activity-body")),e=(e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1),document.querySelector(".bb-media-model-container .activity-list .activity-item"));e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1)},1e3),p(window).on("load",function(){setTimeout(function(){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media.autoPlayGifVideos&&bp.Nouveau.Media.autoPlayGifVideos()},300)}),document.addEventListener("keydown",_.bind(this.closePickersOnEsc,this)),p(document).on("click",_.bind(this.closePickersOnClick,this))),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_media.length||this.bbp_topic_edit_media.length||this.bbp_forum_edit_media.length)&&p("#forums-media-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_document.length||this.bbp_topic_edit_document.length||this.bbp_forum_edit_document.length)&&p("#forums-document-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_video.length||this.bbp_topic_edit_video.length||this.bbp_forum_edit_video.length)&&p("#forums-video-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(Object.keys(this.bbp_reply_edit_gif_data).length||Object.keys(this.bbp_topic_edit_gif_data).length||Object.keys(this.bbp_forum_edit_gif_data).length)&&(this.editGifPreview(),(a=jQuery("#forums-gif-button").addClass("active").closest("form")).find("#forums-document-button")&&a.find("#forums-document-button").parents(".post-elements-buttons-item").addClass("disable"),a.find("#forums-media-button")&&a.find("#forums-media-button").parents(".post-elements-buttons-item").addClass("disable"),a.find("#forums-video-button"))&&a.find("#forums-video-button").parents(".post-elements-buttons-item").addClass("disable"),"#openEditFolder"==window.location.hash&&p("#bp-media-edit-child-folder").length&&(history.pushState(null,null,window.location.href.split("#")[0]),p("#bp-media-edit-child-folder").show()),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(bp.Nouveau.Media.reply_topic_allow_delete_media=!0)},updateAlbumCounts:function(e){var t,i,a,o;p("#buddypress #bp-media-single-album").length&&(o=parseInt(e.album_media_count)||0,e=parseInt(e.album_video_count)||0,t=function(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},0<(a=p("#buddypress .bb-album-photo-count")).length&&(i=1===o?BP_Nouveau.media.i18n_strings.photo:BP_Nouveau.media.i18n_strings.photos,a.text(t(o)+" "+i)),0<(a=p("#buddypress .bb-album-video-count")).length)&&(o=1===e?BP_Nouveau.media.i18n_strings.video:BP_Nouveau.media.i18n_strings.videos,a.text(t(e)+" "+o))},loadExistingMedia:function(){p(window).scroll()},resetPageDocumentDirectory:function(e){e.preventDefault(),this.current_page=1},submitCreateFolderInPopup:function(e){e.preventDefault();var i=p(e.currentTarget).closest(".open-popup"),a=p(i).find(".bp-document-create-popup-folder-submit"),t=i.find(".bb-folder-selected-id").val(),o=p.trim(p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder-title").val()),d=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder-title"),s=/[\\/?%*:|"<>]+/g.exec(d.val()),s=Boolean(s);if(""===p.trim(d.val())||s)return d.addClass("error"),!1;d.removeClass("error"),this.currentTargetParent=t=""===t?0:t;var n=this.currentTargetParent,r=0,l="",c="",u=0;if("group"===this.moveToTypePopup?(l="grouponly",r=this.moveToIdPopup):(l=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder #bb-folder-privacy").val(),c=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder #bb-folder-privacy")),""===o)return alert(BP_Nouveau.media.create_folder_error_title),!1;a.addClass("loading"),setTimeout(function(){var e={action:"document_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:o,privacy:l,parent:n,group_id:r};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,async:!1,success:function(e){var t;e.success&&(p(".document-data-table-head").length&&parseInt(n)===parseInt(BP_Nouveau.media.current_folder)&&(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()),i.find(".location-folder-list-wrap .location-folder-list").remove(),i.find(".location-folder-list-wrap").append(e.data.tree_view),t="#"+p(i).attr("id")+".open-popup",bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,e.data.folder_id),u=e.data.folder_id,(""===e.data.tree_view?(i.find(".location-folder-list-wrap").hide(),i.find(".location-folder-list-wrap-main span.no-folder-exists")):(i.find(".location-folder-list-wrap-main span.no-folder-exists").hide(),i.find(".location-folder-list-wrap"))).show(),i.find("ul.location-folder-list span#"+u).trigger("click"),i.find(".bb-model-footer").show(),i.find(".bb-model-footer, #bp-media-document-prev").show(),i.find(".bb-field-wrap-search").show(),i.find(".bp-document-open-create-popup-folder").show(),i.find(".location-folder-list-wrap-main").show(),i.find(".create-popup-folder-wrap").hide(),i.find(".bb-folder-selected-id").val(),i.find(".bb-folder-selected-id").val(u),i.find(".bb-model-header").children().show(),i.find(".bb-model-header p").hide(),d.val(""),""!==c&&c.val("public"),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(i).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),a.removeClass("loading"),setTimeout(function(){var e=i.find("ul.location-folder-list span#"+u),t=(e.trigger("click"),p(i).find("#bb-document-privacy"));0!==Number(e.data("id"))?(t.find("option").removeAttr("selected"),t.val(e.parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1))},200))}}),this.currentTargetParent=u,i.find(".location-folder-list li.is_active").show().children("span, i").show().siblings("ul").hide(),i.find(".location-folder-list li.is_active").siblings("li").show().children("span, i").show().siblings("ul").hide(),i.find(".location-folder-list li span.selected").removeClass("selected"),i.find(".location-folder-list li.is_active").children("span").addClass("selected")},0)},submitCreateAlbumInPopup:function(e){e.preventDefault();var t=this,i=p(e.currentTarget).closest(".open-popup"),a=p(i).find(".bp-media-create-popup-album-submit"),o=i.find(".bb-album-selected-id").val(),d=(this.currentTargetParent=o=""===o?0:o,this.currentTargetParent),s=0,n=p.trim(p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album-title").val()),r=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album-title"),l="",c="",u=0;if("group"===this.moveToTypePopup?(l="grouponly",s=this.moveToIdPopup):(l=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album #bb-album-privacy").val(),c=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album #bb-album-privacy")),""===n)return alert(BP_Nouveau.media.create_album_error_title),!1;a.addClass("loading"),setTimeout(function(){var e={action:"media_album_save",_wpnonce:BP_Nouveau.nonces.media,title:n,privacy:l,parent:d,group_id:s};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,async:!1,success:function(e){e.success&&(i.find(".location-album-list-wrap .location-album-list").remove(),i.find(".location-album-list-wrap").append(e.data.tree_view),bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(i,e.data.album_id),u=e.data.album_id,(""===e.data.tree_view?(i.find(".location-album-list-wrap").hide(),i.find(".location-album-list-wrap-main span.no-album-exists")):(i.find(".location-album-list-wrap-main span.no-album-exists").hide(),i.find(".location-album-list-wrap"))).show(),i.find("ul.location-album-list span#"+u).trigger("click"),i.find(".bb-model-footer").show(),i.find(".bb-field-wrap-search").show(),i.find(".bp-media-open-create-popup-album").show(),i.find(".location-album-list-wrap-main").show(),i.find(".create-popup-album-wrap").hide(),i.find(".bb-field-steps-2 #bp-media-prev").show(),i.find(".bb-album-selected-id").val(),i.find(".bb-album-selected-id").val(u),i.find(".bb-model-header").children().show(),i.find(".bb-model-header p").hide(),r.val(""),""!==c&&c.val("public"),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(i).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),t.updateAlbumNavCount(e.data.album_count)),a.removeClass("loading")}}),this.currentTargetParent=u,i.find(".location-album-list li.is_active").show().children("span, i").show().siblings("ul").hide(),i.find(".location-album-list li.is_active").siblings("li").show().children("span, i").show().siblings("ul").hide(),i.find(".location-album-list li span.selected").removeClass("selected"),i.find(".location-album-list li.is_active").children("span").addClass("selected")},0)},closeCreateFolderInPopup:function(e){e.preventDefault(),p(".modal-container .bb-model-footer").show(),p(".bb-field-wrap-search").show(),p(".bp-document-open-create-popup-folder").show(),p(".location-folder-list-wrap-main").show(),p("#bp-media-document-prev").show(),p(".create-popup-folder-wrap").hide(),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header").children().show(),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header p").hide()},closeCreateAlbumInPopup:function(e){e.preventDefault(),p(".modal-container .bb-model-footer").show(),p(".bb-field-wrap-search").show(),p(".bp-document-open-create-popup-folder").show(),p(".modal-container:visible .bp-video-open-create-popup-album").show(),p(".location-album-list-wrap-main").show(),p(".bb-field-steps-2 #bp-media-prev").show(),p(".bb-field-steps-2 #bp-video-next").show(),p(".create-popup-album-wrap").hide(),p(".bp-media-create-popup-album-submit.loading").removeClass("loading"),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header").children().show(),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header p").hide()},createFolderInPopup:function(e){e.preventDefault();var t=parseInt(p(document).find(".open-popup .bb-folder-selected-id").val()),i=p(document).find(".open-popup .bb-folder-create-from").val();0 "+BP_Nouveau.media.create_folder+""),p(".modal-container #bb-folder-privacy").addClass("new-folder-create-privacy"),p(document).find(".open-popup .error").hide()},createAlbumInPopup:function(e){e.preventDefault();var t=parseInt(p(document).find(".open-popup .bb-album-selected-id").val()),i=p(document).find(".open-popup .bb-album-create-from").val();0 "+BP_Nouveau.media.create_album_title+""),p(".modal-container #bb-folder-privacy").addClass("new-folder-create-privacy"),p(document).find(".open-popup .error").hide()},savePrivacy:function(e){var t,i,a,o=p(e.currentTarget);if(e.preventDefault(),o.hasClass("new-folder-create-privacy"))return!1;t=parseInt(o.data("item-id")),i=o.data("item-type"),a=o.val(),e=p(e.currentTarget).find("option:selected").text(),this.privacySelectorSelect.addClass("hide"),this.privacySelectorSpan.text(""),this.privacySelectorSpan.text(e),this.privacySelectorSpan.show(),0 '+e.data.media_personal_count+" "+i)):p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count)),void 0!==e.data&&void 0!==e.data.media_group_count&&0 '+e.data.media_group_count+" "+i)):p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):n.find(".media-list:not(.existing-media-list)")).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):n.find(".media-list:not(.existing-media-list)")).html(e.data.group_media_html_content):p.each(s,function(e,t){p('#media-stream ul.media-list li[data-id="'+t+'"]').length&&p('#media-stream ul.media-list li[data-id="'+t+'"]').remove()}),void 0!==e.data.album_total_count&&d.updateAlbumCounts(e.data))):(setTimeout(function(){o.prop("disabled",!1)},500),e.success?(void 0!==e.data&&void 0!==e.data.media_personal_count&&0
'+e.data.media_personal_count+" "+i)):p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count)),void 0!==e.data&&void 0!==e.data.media_group_count&&0
'+e.data.media_group_count+" "+i)):p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),(t=n.find(".media-list:not(.existing-media-list)")).find('.bb-media-check-wrap [name="bb-media-select"]:checked').each(function(){p(this).closest("li").remove()}),t.parent().parent().hasClass("album-single-view")&&t.find('.bb-video-check-wrap [name="bb-video-select"]:checked').each(function(){p(this).closest("li").remove()}),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):t).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):t).html(e.data.group_media_html_content):p.each(s,function(e,t){p('#media-stream ul.media-list li[data-id="'+t+'"]').length&&p('#media-stream ul.media-list li[data-id="'+t+'"]').remove()}),void 0!==e.data.album_total_count&&d.updateAlbumCounts(e.data)):p("#buddypress #media-stream.media").prepend(e.data.feedback));var t,i=p(".bp-nouveau #bb-select-deselect-all-media");i.hasClass("selected")&&i.removeClass("selected"),jQuery(window).scroll()}})},toggleSelectAllMedia:function(e){e.preventDefault(),p(e.currentTarget).hasClass("selected")?(p(e.currentTarget).data("bp-tooltip",BP_Nouveau.media.i18n_strings.selectall),this.deselectAllMedia(e)):(p(e.currentTarget).data("bp-tooltip",BP_Nouveau.media.i18n_strings.unselectall),this.selectAllMedia(e)),p(e.currentTarget).toggleClass("selected")},selectAllMedia:function(e){e.preventDefault();e=p("#buddypress").find(".media-list:not(.existing-media-list)");e.find('.bb-media-check-wrap [name="bb-media-select"]').each(function(){p(this).prop("checked",!0),p(this).closest(".bb-item-thumb").addClass("selected"),p(this).closest(".bb-media-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.unselect)}),e.parent().parent().hasClass("album-single-view")&&e.find('.bb-video-check-wrap [name="bb-video-select"]').each(function(){p(this).prop("checked",!0),p(this).closest(".bb-item-thumb").addClass("selected"),p(this).closest(".bb-video-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.unselect)})},deselectAllMedia:function(e){e.preventDefault();e=p("#buddypress").find(".media-list:not(.existing-media-list)");e.find('.bb-media-check-wrap [name="bb-media-select"]').each(function(){p(this).prop("checked",!1),p(this).closest(".bb-item-thumb").removeClass("selected"),p(this).closest(".bb-media-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.select)}),e.parent().parent().hasClass("album-single-view")&&e.find('.bb-video-check-wrap [name="bb-video-select"]').each(function(){p(this).prop("checked",!1),p(this).closest(".bb-item-thumb").removeClass("selected"),p(this).closest(".bb-video-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.select)})},editAlbumTitle:function(e){e.preventDefault(),p("#bb-album-title").show(),p("#bp-save-album-title").show(),p("#bp-cancel-edit-album-title").show(),p("#bp-edit-album-title").hide(),p("#bp-media-single-album #bp-single-album-title").hide()},editFolderTitle:function(e){e.preventDefault(),p("#bb-album-title").show(),p("#bp-save-folder-title").show(),p("#bp-cancel-edit-album-title").show(),p("#bp-edit-folder-title").hide(),p("#bp-media-single-album #bp-single-album-title").hide()},cancelEditAlbumTitle:function(e){e.preventDefault(),p("#bb-album-title").removeClass("error").hide(),p("#bp-save-album-title,#bp-save-folder-title").hide(),p("#bp-cancel-edit-album-title").hide(),p("#bp-edit-album-title,#bp-edit-folder-title").show(),p("#bp-media-single-album #bp-single-album-title").show()},triggerDropzoneSelectFileDialog:function(){this.dropzone_obj.hiddenFileInput.click()},closeUploader:function(e){e.preventDefault(),p("#bp-media-uploader").hide(),p("#bp-media-add-more").hide(),p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),p("#bp-media-uploader-modal-status-text").text(""),p("#bp-media-post-content").val(""),p("#bp-dropzone-content .bp-feedback").remove(),this.dropzone_obj.element&&this.dropzone_obj.destroy(),this.dropzone_media=[];var t=p(e.currentTarget).closest("#bp-media-uploader");p(".close-create-popup-album").trigger("click"),p(".close-create-popup-folder").trigger("click"),t.find('.breadcrumbs-append-ul-li .item span[data-id="0"]').trigger("click"),t.find(".bb-field-steps").length&&(t.find(".bb-field-steps-1").show().siblings(".bb-field-steps-2").hide(),t.find(".bb-field-steps-1 #bp-media-photo-next, .bb-field-steps-1 #bp-media-document-next ").hide(),t.find(".bb-field-steps-1").removeClass("controls-added"),t.find("#bp-media-document-prev, #bp-media-prev, #bp-media-document-submit, #bp-media-submit, .bp-media-open-create-popup-folder, .bp-document-open-create-popup-folder, .create-popup-folder-wrap, .create-popup-album-wrap, .bp-video-open-create-popup-album").hide()),this.clearFolderLocationUI(e)},closeChildFolderUploader:function(e){e.preventDefault(),p(document).find(".open-popup #bb-album-child-title").val(""),p(document).find(".open-popup #bp-media-create-child-folder-submit").removeClass("loading"),p(document).find("#bp-media-create-child-folder").removeClass("open-popup"),p(document).find("#bp-media-create-child-folder").hide(),p(document).find(".open-popup #bb-album-title").text(""),p(document).find(".open-popup #bp-media-create-folder").hide(),p(document).find("#bp-media-create-folder").removeClass("open-popup")},closeFolderUploader:function(e){e.preventDefault(),p(document).find(".open-popup #bb-album-title").val(""),p(document).find(".open-popup #bp-media-create-folder-submit").removeClass("loading"),p(document).find(".open-popup #bp-media-document-submit").hide(),p(document).find("#bp-media-create-folder").removeClass("open-popup"),p(document).find("#bp-media-create-folder").hide()},loadMoreGif:function(e){var t=e.target,i=this,e=p(e.target).closest("form").find(".forums-attached-gif-container"),a=e.data("key");i.gif_container_key=a,t.scrollTop+t.offsetHeight>=t.scrollHeight&&!e.hasClass("loading")&&0
").removeClass("acomments-view-more--hide"),d.removeClass("active"),s.removeClass("active")):void 0!==e.data&&void 0!==e.data.comments&&(t=q(".bb-internal-model .activity-comments").find("[data-activity_id='"+o+"'][data-parent_comment_id='"+n+"']"),e=q(q.parseHTML(e.data.comments)),0=t.scrollHeight&&!p(e.target).closest(".bp-group-messages-attached-gif-container").hasClass("loading")&&0 \n\t\n\t\t \n\t\n',e.data[t].saved=!1,this.gif_data.push(e.data[t])}p(".bp-group-messages-attached-gif-container").find(".gif-search-results-list").append(i)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(this.gif_total_count=e.pagination.total_count)},loadMoreGifResponse:function(e){var t=this,i=0;if(p('div.forums-attached-gif-container[data-key="'+t.gif_container_key+'"]').removeClass("loading"),void 0!==e.data&&e.data.length){for(var a="",i=0;i
\n\t\n\t\t \n\t\n',e.data[i].saved=!1,t.gif_data[t.gif_container_key].data.push(e.data[i])}p('div.forums-attached-gif-container[data-key="'+t.gif_container_key+'"]').closest("form").find(".gif-search-results-list").append(a)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(t.gif_data[t.gif_container_key].total_count=e.pagination.total_count)},editGifPreview:function(){var e=this,t={};if(e.bbp_is_reply_edit&&Object.keys(e.bbp_reply_edit_gif_data).length?t=e.bbp_reply_edit_gif_data.gif_raw_data:e.bbp_is_topic_edit&&Object.keys(e.bbp_topic_edit_gif_data).length?t=e.bbp_topic_edit_gif_data.gif_raw_data:e.bbp_is_forum_edit&&Object.keys(e.bbp_forum_edit_gif_data).length&&(t=e.bbp_forum_edit_gif_data.gif_raw_data),void 0===t.images)return!1;e=p("#whats-new-attachments .forums-attached-gif-container");e[0].style.backgroundImage="url("+t.images.fixed_width.url+")",e[0].style.backgroundSize="contain",e[0].style.height=t.images.original.height+"px",e[0].style.width=t.images.original.width+"px",e.find(".gif-image-container img").attr("src",t.images.original.url),e.removeClass("closed"),p("#bbp_media_gif").length&&p("#bbp_media_gif").val(JSON.stringify(t))},selectGif:function(e){var t=this,i=0,a=p(e.currentTarget),o=a.closest("form").find(".forums-attached-gif-container"),d=(e.preventDefault(),o.closest("form").find(".gif-media-search-dropdown").removeClass("open"),o.data("key"));if(void 0!==t.gif_data[d]&&void 0!==t.gif_data[d].data&&t.gif_data[d].data.length){for(i=0;i
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,s.gif_data.push(e.data[n])}p(d.target).closest(".bp-group-messages-attached-gif-container").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(s.gif_total_count=e.pagination.total_count),p(d.target).closest(".bp-group-messages-attached-gif-container").removeClass("loading")},function(){p(d.target).find(".gif-no-connection").addClass("show")}));s.gif_requests.push(e),s.gif_offset=s.gif_offset+s.gif_limit},searchGifRequest:function(d){var s=this,n=0,r=p(d.target).closest("form").find(".forums-attached-gif-container"),l=(r.addClass("loading"),r.data("key")),e=(p(d.target).closest("form").find(".gif-no-results").removeClass("show"),p(d.target).closest("form").find(".gif-no-connection").removeClass("show"),s.clearGifRequests(l),s.gif_data[l].q=d.target.value,s.gif_data[l].offset=0,s.giphy.search({q:s.gif_data[l].q,offset:s.gif_data[l].offset,fmt:"json",limit:s.gif_data[l].limit},function(e){if(void 0!==e.data.length&&0===e.data.length&&p(d.target).closest("form").find(".gif-no-results").addClass("show"),void 0!==e.meta.status&&200!==e.meta.status&&p(d.target).closest("form").find(".gif-no-connection").addClass("show"),void 0!==e.data&&e.data.length){var t="";for(n=0;n
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,s.gif_data[l].data.push(e.data[n])}p(d.target).closest(".gif-search-content").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(s.gif_data[l].total_count=e.pagination.total_count),r.removeClass("loading")},function(){p(d.target).closest("form").find(".gif-no-connection").addClass("show")}));s.gif_data[l].requests.push(e),s.gif_data[l].offset=s.gif_data[l].offset+s.gif_data[l].limit},clearGifRequests:function(e){var t=this;if(void 0!==t.gif_data[e]&&void 0!==t.gif_data[e].requests){for(var i=0;i
\n\t\n\t\t \n\t\n',e.data[l].saved=!1,n.gif_data[s].data.push(e.data[l])}r.closest("form").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(n.gif_data[s].total_count=e.pagination.total_count),d.removeClass("loading")}),n.gif_data[s].requests.push(e),n.gif_data[s].offset=n.gif_data[s].offset+n.gif_data[s].limit),t.toggleClass("open"),r.parents("form").find("#whats-new-attachments .forums-attached-gif-container img")),t=(0
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,d.gif_data.push(e.data[n])}s.closest("form").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(d.gif_total_count=e.pagination.total_count),p(".gif-search-query").closest(".bp-group-messages-attached-gif-container").removeClass("loading")}),d.gif_requests.push(e),d.gif_offset=d.gif_offset+d.gif_limit),s.parents("form").find("#whats-new-attachments .bp-group-messages-attached-gif-container img"));0
"),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),a.dropzone_obj[n].on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=p(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.album_id=a.album_id,t.data.group_id=a.group_id,t.data.saved=!1,a.dropzone_media[n].push(t.data),a.addMediaIdsToForumsForm(d)):(jQuery(".forum-media-error-popup").length||p("body").append('"),this.removeFile(e))}),a.dropzone_obj[n].on("removedfile",function(e){if(!0===bp.Nouveau.Media.reply_topic_allow_delete_media){if(a.dropzone_media[n].length)for(var t in a.dropzone_media[n])if(e.upload.uuid==a.dropzone_media[n][t].uuid){this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit||void 0===a.dropzone_media[n][t].saved||a.dropzone_media[n][t].saved||"edit"!==bp.Nouveau.Media.reply_topic_display_post||a.removeAttachment(a.dropzone_media[n][t].id),a.dropzone_media[n].splice(t,1),a.addMediaIdsToForumsForm(d);break}var i;_.isNull(a.dropzone_obj[n].files)||0!==a.dropzone_obj[n].files.length||((i=o.closest("form")).find("#forums-document-button")&&i.find("#forums-document-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-video-button")&&i.find("#forums-video-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-gif-button")&&i.find("#forums-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-media-button")&&i.find("#forums-media-button").parents(".post-elements-buttons-item").removeClass("no-click"))}_.isNull(a.dropzone_obj[n].files)||0!==a.dropzone_obj[n].files.length||o.closest("form").removeClass("has-media")}),a.dropzone_obj[n].on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 "),this.removeFile(e))}),a.dropzone_obj.on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=p(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.album_id=a.album_id,t.data.group_id=a.group_id,t.data.saved=!1,a.dropzone_media.push(t.data),a.addMediaIdsToGroupMessagesForm()):(jQuery(".group-message-error-popup").length||p("body").append('"),this.removeFile(e))}),a.dropzone_obj.on("removedfile",function(e){if(a.dropzone_media.length)for(var t in a.dropzone_media)if(e.upload.uuid==a.dropzone_media[t].uuid){void 0===a.dropzone_media[t].saved||a.dropzone_media[t].saved||a.removeAttachment(a.dropzone_media[t].id),a.dropzone_media.splice(t,1),a.addMediaIdsToGroupMessagesForm();break}var i;_.isNull(a.dropzone_obj.files)||0!==a.dropzone_obj.files.length||((i=p("#send_group_message_form")).find("#bp-group-messages-document-button")&&i.find("#bp-group-messages-document-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-video-button")&&i.find("#bp-group-messages-video-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-gif-button")&&i.find("#bp-group-messages-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-media-button")&&i.find("#bp-group-messages-media-button").parents(".post-elements-buttons-item").removeClass("no-click"))}),t.removeClass("closed").addClass("open"),a.resetGroupMessagesGifComponent(),a.resetGroupMessagesDocumentComponent(),a.resetGroupMessagesVideoComponent()):a.resetGroupMessagesMediaComponent())},openGroupMessagesDocumentUploader:function(e){var l=this,t=p("div#bp-group-messages-post-document-uploader"),i=p(e.currentTarget);e.preventDefault(),i.toggleClass("active"),void 0!==window.Dropzone&&t.length&&(t.hasClass("closed")?(l.document_dropzone_obj=new Dropzone("div#bp-group-messages-post-document-uploader",l.documentOptions),l.document_dropzone_obj.on("addedfile",function(){}),l.document_dropzone_obj.on("sending",function(e,t,i){i.append("action","document_document_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media);i=p("#send_group_message_form");i.find("#bp-group-messages-media-button")&&i.find("#bp-group-messages-media-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-video-button")&&i.find("#bp-group-messages-video-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-gif-button")&&i.find("#bp-group-messages-gif-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-document-button")&&i.find("#bp-group-messages-document-button").parents(".post-elements-buttons-item").addClass("no-click")}),l.document_dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),l.document_dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?p(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&p(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".group-document-error-popup").length||p("body").append('"),this.removeFile(e))}),l.document_dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.document_dropzone_obj.on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e))}),r.video_dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.video.empty_video_type):t()}),r.video_dropzone_obj.on("addedfile",function(e){e.dataURL||bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),r.video_dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);e.upload.progress<=99?(p(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,p(e.previewElement).find(".dz-progress-count").text("99% "+BP_Nouveau.video.i18n_strings.video_uploaded_text))}),r.video_dropzone_obj.on("success",function(e,t){if(100===e.upload.progress&&(p(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,p(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),p(e.previewElement).closest(".dz-preview").addClass("dz-complete")),!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),l.dropzone_obj[u].on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.dropzone_obj[u].on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),l.dropzone_obj[u].on("accept",function(e,t){0==e.size?t(BP_Nouveau.video.empty_video_type):t()}),l.dropzone_obj[u].on("addedfile",function(e){e.dataURL&&e.dataThumb&&e.dataThumb.length?p(e.previewElement).find(".dz-video-thumbnail").prepend(' '):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),l.dropzone_obj[u].on("uploadprogress",function(e){o.closest("form").addClass("media-uploading");var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);e.upload.progress<=99?(p(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,p(e.previewElement).find(".dz-progress-count").text("99% "+BP_Nouveau.video.i18n_strings.video_uploaded_text))}),l.dropzone_obj[u].on("success",function(e,t){if(100===e.upload.progress&&(p(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,p(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),p(e.previewElement).closest(".dz-preview").addClass("dz-complete")),!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a
'+p(this).text()+""),p(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val(p(e.currentTarget).data("id")),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),0!==Number(p(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(p(e.currentTarget).parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),p(document).on("click",t+" .breadcrumb .item > span",function(e){var t,i;p(this).hasClass("is-disabled")||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val(0),p(e.currentTarget).closest(".bb-field-wrap").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),i=p(e.currentTarget).closest("#bp-media-uploader").find(".location-album-list li.is_active").data("privacy"),0!==Number(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),e=document.getElementsByClassName("uploader-post-media-template").length?document.getElementsByClassName("uploader-post-media-template")[0].innerHTML:"",i.options.previewTemplate=e,i.dropzone_obj=new Dropzone("div#media-uploader",i.options),i.dropzone_obj.on("sending",function(e,t,i){i.append("action","media_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media)}),i.dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),i.dropzone_obj.on("addedfile",function(){setTimeout(function(){i.dropzone_obj.getAcceptedFiles().length&&p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),i.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?p(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&p(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".media-error-popup").length||p("body").append('"),this.removeFile(e))}),i.dropzone_obj.on("queuecomplete",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),p(".bb-field-steps-1 #bp-media-photo-next, #bp-media-submit, #bp-media-create-album-submit").show()}),i.dropzone_obj.on("processing",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),p(".bb-field-steps-1 #bp-media-photo-next, #bp-media-submit, #bp-media-create-album-submit").hide()}),i.dropzone_obj.on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=i.dropzone_media.length,t.data.album_id=i.album_id,t.data.group_id=i.group_id,t.data.saved=!1,i.dropzone_media.push(t.data)):(jQuery(".media-error-popup").length||p("body").append('"),this.removeFile(e)),p(".modal-container").addClass("modal-container--alert"),p(".bb-field-steps-1").addClass("controls-added"),p("#bp-media-add-more").show(),p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()}),i.dropzone_obj.on("removedfile",function(e){if(i.dropzone_media.length)for(var t in i.dropzone_media)if(e.upload.uuid==i.dropzone_media[t].uuid){void 0===i.dropzone_media[t].saved||i.dropzone_media[t].saved||i.removeAttachment(i.dropzone_media[t].id),i.dropzone_media.splice(t,1);break}i.dropzone_obj.getAcceptedFiles().length?p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show():(p("#bp-media-uploader-modal-status-text").text(""),p("#bp-media-add-more, #bp-media-photo-next").hide(),p(".bb-field-steps-1").removeClass("controls-added"),p("#bp-media-submit").hide(),p(".modal-container").removeClass("modal-container--alert"))}))},openDocumentUploader:function(e){var a,t,l=this;e.preventDefault(),void 0!==window.Dropzone&&p("div#media-uploader").length&&(p("#bp-media-uploader").hasClass("bp-media-document-uploader")&&!this.currentTargetParent&&(this.currentTargetParent=0),p(e.currentTarget).closest("#bp-media-single-folder").length&&p("#bb-document-privacy").hide(),p(document).removeClass("open-popup"),p("#bp-media-uploader").show(),p("#bp-media-uploader").addClass("open-popup"),p("#bp-media-uploader.bp-media-document-uploader").find(".bb-field-steps.bb-field-steps-2").length&&(t="#bp-media-uploader.bp-media-document-uploader",0!==Number(p(t).find(".bb-folder-selected-id").data("value"))?(a=p(t).find(".bb-folder-selected-id").data("value"),p(t).find("#bb-document-privacy").prop("disabled",!0)):a=0,""!==this.moveToIdPopup)&&p.ajax({url:BP_Nouveau.ajaxurl,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:BP_Nouveau.nonces.media},success:function(e){p(document).find(".bp-media-document-uploader .location-folder-list-wrap h4 span.where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap").hide(),p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap-main span.no-folder-exists")):(p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap-main span.no-folder-exists").hide(),p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap"))).show(),p(document).find(".bp-media-document-uploader .popup-on-fly-create-album .privacy-field-wrap-hide-show").show(),p(document).find(".bp-media-document-uploader .open-popup .bb-folder-create-from").val("profile"),p(t).find(".location-folder-list-wrap .location-folder-list").remove(),p(t).find(".location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,a),p(t).find("ul.location-folder-list span#"+a).trigger("click"),p(t).find(".bb-folder-selected-id").val(a)}}),p(document).on("click",t+" .location-folder-list li span",function(e){var t;e.preventDefault(),p(this).parent().hasClass("is_active")||(0!=p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item").append(''+p(this).text()+""),p(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val(p(e.currentTarget).data("id")),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),0!==Number(p(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(p(e.currentTarget).parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),p(document).on("click",t+" .breadcrumb .item > span",function(e){var t,i;p(this).hasClass("is-disabled")||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val(p(e.currentTarget).data("id")),p(e.currentTarget).closest(".bb-field-wrap").find(".location-folder-list li span").removeClass("selected").parent().removeClass("is_active"),p(e.currentTarget).closest(".bb-field-wrap").find('.location-folder-list li[data-id="'+p(e.currentTarget).data("id")+'"]').addClass("is_active"),p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),i=p(e.currentTarget).closest("#bp-media-uploader").find(".location-folder-list li.is_active").data("privacy"),0!==Number(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),e=document.getElementsByClassName("uploader-post-document-template").length?document.getElementsByClassName("uploader-post-document-template")[0].innerHTML:"",l.options.previewTemplate=e,l.dropzone_obj=new Dropzone("div#media-uploader",l.options),l.dropzone_obj.on("sending",function(e,t,i){i.append("action","document_document_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media)}),l.dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),l.dropzone_obj.on("addedfile",function(){setTimeout(function(){l.dropzone_obj.getAcceptedFiles().length&&p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,l.dropzone_media.length,l.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),l.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?p(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&p(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".document-error-popup").length||p("body").append('"),this.removeFile(e))}),l.dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.dropzone_obj.on("queuecomplete",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),p(".bb-field-steps-1 #bp-media-document-next, #bp-media-document-submit").show()}),l.dropzone_obj.on("processing",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),p(".bb-field-steps-1 #bp-media-document-next, #bp-media-document-submit").hide()}),l.dropzone_obj.on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a .activity-content .bp-media-move-file",p(o).find(".bp-document-move").attr("id",p(e.currentTarget).closest(".document-activity").attr("data-id")),0 ');var i,t,a,o,d=t,s=this.moveToTypePopup;""!==this.moveToIdPopup&&p.ajax({url:BP_Nouveau.ajaxurl,type:"post",data:{action:"media_get_album_view",id:this.moveToIdPopup,type:this.moveToTypePopup},success:function(e){p(document).find(".location-album-list-wrap h4 span.where-to-move-profile-or-group-media").html(e.data.first_span_text),(""===e.data.html?(p(document).find(".open-popup .location-album-list-wrap").hide(),p(document).find(".open-popup .location-album-list-wrap-main span.no-album-exists")):(p(document).find(".open-popup .location-album-list-wrap-main span.no-album-exists").hide(),p(document).find(".open-popup .location-album-list-wrap"))).show(),"group"===s?(p(document).find(".popup-on-fly-create-album .privacy-field-wrap-hide-show").hide(),p(document).find(".open-popup .bb-album-create-from").val("group")):(p(document).find(".popup-on-fly-create-album .privacy-field-wrap-hide-show").show(),p(document).find(".open-popup .bb-album-create-from").val("profile")),!1===e.data.create_album?(p(o+".open-popup").find(".bp-media-open-create-popup-folder").removeClass("create-album"),p(o+".open-popup").find(".bp-media-open-create-popup-folder").hide()):(p(o+".open-popup").find(".bp-media-open-create-popup-folder").addClass("create-album"),p(o+".open-popup").find(".bp-media-open-create-popup-folder").show()),p(o).find(".location-album-list-wrap .location-album-list").remove(),p(o).find(".location-album-list-wrap").append(e.data.html),p(o).find("ul.location-album-list span#"+d).trigger("click")}}),p(document).on("click",o+" .location-album-list li span",function(e){var t;e.preventDefault(),p(this).parent().hasClass("is_active")||(0!=p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),p(this).closest(".location-album-list-wrap").find(".breadcrumb .item").append(''+p(this).text()+""),p(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),t=p(document).find('a.bb-open-media-theatre[data-id="'+i.find(".bp-media-move").attr("id")+'"]').data("album-id"),Number(t)==Number(p(e.currentTarget).data("id"))?p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||p(e.currentTarget).closest(".bp-media-move-file").find(".bb-album-selected-id").val(p(e.currentTarget).data("id"))}),p(document).on("click",o+" .breadcrumb .item > span",function(e){p(this).hasClass("is-disabled")||(p(e.currentTarget).closest(".bp-media-move-file").find(".bb-album-selected-id").val(0),p(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),d==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"))})},openDocumentMove:function(e){e.preventDefault();var t,i,a,e=p(e.currentTarget),o=(e.closest(".bb-activity-media-elem").find(".document-title").text(),this.moveToIdPopup=e.attr("id"),this.moveToTypePopup=e.attr("data-type"),e.attr("data-action")),d=(p(".bp-media-move-file.open-popup, .bp-media-move-folder.open-popup").hide().removeClass("open-popup"),e.closest("#activity-modal")),s=(0===d.length&&(d=p("body")),e.closest(".conflict-activity-ul-li-comment").closest("li.comment-item").length?(i=e.closest("li.comment-item"),i=d.find("#"+i.attr("id")+".comment-item .bp-media-move-file").first()):0<(a=e.closest("li.activity-item")).length&&(i=d.find("#"+a.attr("id")+" > .activity-content .bp-media-move-file").first()),i&&0!==i.length||(e.closest(".conflict-activity-ul-li-comment").closest("li.comment-item").length?(a=e.closest("li.comment-item").attr("id"),i=d.find("#"+a+".comment-item .bp-media-move-file").first()):(a=e.closest("li.activity-item").attr("id"))&&(i=d.find("#"+a+" > .activity-content .bp-media-move-file").first())),i&&0 '),"document"===o?p(t).find(".bb-model-header h4 .target_name").text(BP_Nouveau.media.move_to_file):p(t).find(".bb-model-header h4 .target_name").text(BP_Nouveau.media.move_to_folder),p(t).show(),p(t).addClass("open-popup"),"group"===this.moveToTypePopup?(p(document).find(".location-folder-list-wrap h4").show(),p(t).addClass("move-folder-popup-group")):(p(document).find(".location-folder-list-wrap h4").hide(),p(".move-folder-popup-group").removeClass("move-folder-popup-group")),this.currentTargetParent),n=this.moveToTypePopup;""!==this.moveToIdPopup&&p.ajax({url:BP_Nouveau.ajaxurl,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:BP_Nouveau.nonces.media},success:function(e){p(document).find(".location-folder-list-wrap h4 span.where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(p(document).find(".open-popup .location-folder-list-wrap").hide(),p(document).find(".open-popup .location-folder-list-wrap-main span.no-folder-exists")):(p(document).find(".open-popup .location-folder-list-wrap-main span.no-folder-exists").hide(),p(document).find(".open-popup .location-folder-list-wrap"))).show(),"group"===n?(p(document).find(".popup-on-fly-create-folder .privacy-field-wrap-hide-show").hide(),p(document).find(".open-popup .bb-folder-create-from").val("group")):(p(document).find(".popup-on-fly-create-folder .privacy-field-wrap-hide-show").show(),p(document).find(".open-popup .bb-folder-create-from").val("profile")),p(t).find(".location-folder-list-wrap .location-folder-list").remove(),p(t).find(".location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&(bp.Nouveau.Media.folderLocationUI(t,s),p(t).find("ul.location-folder-list span#"+s).trigger("click"))}})},closeMediaMove:function(e){e.preventDefault(),0!=p(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list-wrap .breadcrumb .item span:last-child").data("id")&&p(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list-wrap .breadcrumb .item span:last-child").remove(),p(e.currentTarget).closest(".bp-media-move-file").hide()},closeDocumentMove:function(e){e.preventDefault();var t=p(e.currentTarget),i=jQuery(e.currentTarget).closest(".has-folderlocationUI");(t.hasClass("ac-document-close-button")?(t.closest(".bp-media-move-file"),p(".bp-media-move-file.open-popup").hide().removeClass("open-popup").find(".bp-document-move")):(t.closest(".bp-media-move-folder"),p(".bp-media-move-folder.open-popup").hide().removeClass("open-popup").find(".bp-folder-move"))).attr("id",""),i.find(".bp-document-move.loading").removeClass("loading"),this.clearFolderLocationUI(e)},renameDocument:function(e){var t=p(e.currentTarget).closest(".media-folder_items").find(".media-folder_name"),i=t.children("span").text();t.hide().siblings(".media-folder_name_edit_wrap").show().children(".media-folder_name_edit").val(i).focus().select(),e.preventDefault()},editPrivacyDocument:function(e){e.preventDefault(),p(e.currentTarget).closest("#media-folder-document-data-table").find(".media-folder_visibility .media-folder_details__bottom span").show().siblings("select").addClass("hide");var t=p(e.currentTarget).closest(".media-folder_items").find(".media-folder_visibility");t.find(".media-folder_details__bottom span").hide().siblings("select").removeClass("hide"),t.find(".media-folder_details__bottom span").hide().siblings("select").val(p(e.currentTarget).attr("data-privacy")),t.find(".media-folder_details__bottom #bb-folder-privacy").attr("data-privacy",p(e.currentTarget).attr("data-privacy")),this.privacySelectorSelect=t.find(".media-folder_details__bottom span").hide().siblings("select"),this.privacySelectorSpan=t.find(".media-folder_details__bottom span")},editPrivacyDocumentSubmit:function(e){e=p(e.currentTarget);"true"==e.attr("data-mouseup")?(e.attr("data-mouseup","false"),e.addClass("hide").siblings("span").show().text(e.find("option:selected").text())):e.attr("data-mouseup","true")},renameDocumentSubmit:function(t){var i=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name_edit"),a=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > span"),o=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name"),e=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-id").attr("data-item-id"),d=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-attachment-id").attr("data-item-id"),s=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-type").attr("data-item-id"),n=i.val().trim(),r="",r=(p(t.currentTarget).closest(".ac-document-list").length?r=/[?\[\]=<>:;,'"&$#*()|~`!{}%+ \/]+/g:p(t.currentTarget).closest(".ac-folder-list").length&&(r=/[\\/?%*:|"<>]+/g),r.exec(n)),r=Boolean(r);if(r?i.addClass("error"):i.removeClass("error"),p(t.currentTarget).closest(".ac-document-list").length&&(-1!=n.indexOf("\\\\")||r?i.addClass("error"):i.removeClass("error")),!p(t.currentTarget).hasClass("name_edit_cancel")&&27!=t.keyCode||(i.removeClass("error"),i.parent().hide().siblings(".media-folder_name").show()),p(t.currentTarget).hasClass("name_edit_save")||13==t.keyCode){if(r)return;i.parent().addClass("submitting").append(''),p.ajax({url:BP_Nouveau.ajaxurl,type:"post",data:{action:"document_update_file_name",document_id:e,attachment_document_id:d,document_type:s,name:n,_wpnonce:BP_Nouveau.nonces.media},success:function(e){e.success?void 0!==e.data.document&&0 ');e.parents("li").each(function(e,t){t=p(t).children("span").clone();i.prepend("",t)}),p(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||p(a).find(".breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0
"),h(".bb-rl-modal-container #bb-rl-folder-privacy").addClass("new-folder-create-privacy"),a.find(".open-popup .error").hide(),bp.Readylaunch&&bp.Readylaunch.initSelect2Scoped&&setTimeout(function(){var e=o.find(".bb-rl-create-popup-"+i+"-wrap");e.length&&e.is(":visible")&&bp.Readylaunch.initSelect2Scoped(e)},150)},closeCreateFolderAlbumInPopup:function(e,t){h(".bb-rl-modal-container .bb-rl-model-footer, .modal-container .bb-model-footer").show(),h(".bb-field-wrap-search").show(),h(".bb-rl-document-open-create-popup-folder").show(),"album"===t&&h(".bb-rl-modal-container:visible .bb-rl-video-open-create-popup-album").show(),h(".bb-rl-location-"+t+"-list-wrap-main").show(),"folder"===t?h("#bp-media-document-prev").show():"album"===t&&((i=h(".bb-field-steps-2")).find("#bp-media-prev").show(),i.find("#bp-video-next").show()),h(".bb-rl-create-popup-"+t+"-wrap").hide(),"album"===t&&h(".bb-rl-media-create-popup-album-submit.loading").removeClass("loading");var i=h(e.currentTarget).closest(".bb-rl-has-folderlocationUI");i.find(".bb-rl-modal-header").children().show(),i.find(".bb-rl-modal-header p").hide()},submitCreateFolderAlbumInPopup:function(e,a,o){e.preventDefault();var d=this,e=h(e.currentTarget),r=e.closest(".open-popup"),n=h(r).find(".bb-rl-"+a+"-create-popup-"+o+"-submit"),t=r.find(".bb-rl-"+o+"-selected-id").val(),s=e.closest(".modal-container, .bb-rl-modal-container").find(".bb-rl-popup-on-fly-create-"+o+"-title"),i=h.trim(s.val());if("document"===a){var l=/[\\/?%*:|"<>]+/g.exec(i),l=Boolean(l);if(""===i||l)return s.addClass("error"),!1;s.removeClass("error")}this.currentTargetParent=t=""===t?0:t;var c=this.currentTargetParent,p=0,b="",m="",u=0;if("group"===this.moveToTypePopup?(b="grouponly",p=this.moveToIdPopup):(m=e.closest(".modal-container, .bb-rl-modal-container").find(".bb-rl-popup-on-fly-create-"+o+' select[id*="-'+o+'-privacy"]'),b=m.val()),""===i)return l="document"===a?g.create_folder_error_title:g.create_album_error_title,alert(l),!1;n.addClass("loading");var f=("video"===a?"media":a)+"_"+o+"_save",v=".location-"+o+"-list";setTimeout(function(){var e={action:f,_wpnonce:w.media,title:i,privacy:b,parent:c,group_id:p};h.ajax({type:"POST",url:y,data:e,async:!1,success:function(e){var t,i;e.success?("document"===a&&h(".document-data-table-head").length&&parseInt(c)===parseInt(g.current_folder)&&(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()),r.find(".bb-rl-location-"+o+"-list-wrap "+v).remove(),r.find(".bb-rl-location-"+o+"-list-wrap").append(e.data.tree_view),t="document"===a?"#"+h(r).attr("id")+".open-popup":r,i="document"===a?e.data.folder_id:e.data.album_id,bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,i),u=i,(""===e.data.tree_view?(r.find(".bb-rl-location-"+o+"-list-wrap").hide(),r.find(".bb-rl-location-"+o+"-list-wrap-main span.bb-rl-no-"+o+"-exists")):(r.find(".bb-rl-location-"+o+"-list-wrap-main span.bb-rl-no-"+o+"-exists").hide(),r.find(".bb-rl-location-"+o+"-list-wrap"))).show(),r.find("ul"+v+" span#"+u).trigger("click"),r.find(".bb-rl-model-footer, .bb-model-footer").show(),"document"===a&&r.find(".bb-rl-model-footer, .bb-model-footer, #bp-media-"+a+"-prev").show(),r.find(".bb-field-wrap-search").show(),r.find(".bb-rl-"+a+"-open-create-popup-"+o).show(),r.find(".bb-rl-location-"+o+"-list-wrap-main").show(),r.find(".bb-rl-create-popup-"+o+"-wrap").hide(),"media"===a&&r.find(".bb-field-steps-2 #bp-media-prev").show(),r.find(".bb-rl-"+o+"-selected-id").val(),r.find(".bb-rl"+o+"-selected-id").val(u),r.find(".bb-rl-modal-header").children().show(),r.find(".bb-rl-modal-header p").hide(),s.val(""),""!==m&&m.val("public"),h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0p(a).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),p(this).hasClass("selected")&&!p(this).hasClass("disabled")?(p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-destination").val(""),p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-selected-id").val("0"),p(a).find(".location-folder-list li.is_active").length?p(a).find(".bb-folder-selected-id").val(p(a).find(".location-folder-list li.is_active").attr("data-id")):p(a).find(".bb-folder-selected-id").val("0")):(p(this).closest(".location-folder-list-wrap-main").find(".location-folder-list li span").removeClass("selected"),p(this).addClass("selected"),p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-destination").val(p(this).text()),p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-selected-id").val(p(this).parent().attr("data-id"))),p(this).closest(".location-folder-list-wrap").find(".location-folder-title").text(p(this).siblings("span").text()).siblings(".location-folder-back").css("display","inline-block"),p(this).siblings("ul").show().siblings("span, i").hide().parent().siblings().hide(),p(this).siblings("ul").children("li").show().children("span,i").show(),p(this).closest(".is_active").removeClass("is_active"),p(a).find("li.is_active").removeClass("is_active"),p(this).parent().addClass("is_active"),p(a).find(".bb-folder-selected-id").val(p(a).find(".location-folder-list li.is_active").attr("data-id")),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").each(function(){p(this).show()}),o===p(a).find(".breadcrumbs-append-ul-li .item > span[data-id]").last().attr("data-id")&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled")),setTimeout(function(){p(a).closest(".bb-activity-media-wrap").find(".bb-activity-media-elem.document-activity").attr("data-parent-id")===(p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").prev():p(a).find(".breadcrumbs-append-ul-li .item > span:last-child")).attr("id")&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled"))},100)}),p(document).on("click",a+" .breadcrumbs-append-ul-li .item span",function(e){var t,i;p(this).parent().hasClass("is-disabled")||p(this).hasClass("more_options")||(t=p(e.currentTarget).attr("data-id"),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(p(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),p(a).find(".bb-folder-selected-id").val(t),p(a).find(".location-folder-list li").hide(),p(a).find(".location-folder-list li.is_active").removeClass("is_active"),p(a).find(".location-folder-list li > span.selected").removeClass("selected"),p(a).find('.location-folder-list li[data-id="'+t+'"]').addClass("is_active").children("span").addClass("selected"),p(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),p(a).find(".location-folder-list li.is_active").children("ul").length&&!p(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):p(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?p(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),"0"===t&&(p(a).find(".location-folder-list").children("li").show().children("span,i").show(),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(BP_Nouveau.media.target_text),p(a).find(".location-folder-back").hide()),p(e.currentTarget).nextAll().remove(),o===p(a).find(".breadcrumbs-append-ul-li .item > span[data-id]").last().attr("data-id")&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled")),e=p(a).find(".location-folder-list .is_active > span"),i=p(''),e.parents("li").each(function(e,t){t=p(t).children("span").clone();i.prepend("",t)}),p(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")),0===p(a).find('.breadcrumbs-append-ul-li .breadcrumb .item > span[data-id="'+t+'"]').length&&p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item").append(p(a).find('.location-folder-list li[data-id="'+t+'"]').children("span").clone()),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||p(a).find(".breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(a).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),p(a).find(".bb-folder-selected-id").val(t))})),p(a).find(".location-folder-list li").each(function(){p(this).children("ul").parent().addClass("has-ul").append('')}),p(a).hasClass("bp-media-move-folder")&&(p(a).find(".location-folder-list li>span").removeClass("is-disabled"),p(a).find('.location-folder-list li>span[id="'+p(a).find(".bp-folder-move").attr("id")+'"]').parent().addClass("is-disabled")),e=p(a).find(".bp-folder-move").attr("id"),0==p(a).find('.location-folder-list li[data-id="'+e+'"]').siblings().length&&p(a).find('.location-folder-list li[data-id="'+e+'"]').parent("ul").addClass("no-folder-list a"),o&&(p(a).find(".location-folder-list li").hide(),p(a).find(".location-folder-list li.is_active").removeClass("is_active"),p(a).find('.location-folder-list li[data-id="'+o+'"]').addClass("is_active"),p(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),p(a).find(".location-folder-list li.is_active").children("ul").length&&!p(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):p(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?p(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(p(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),p(a).find(".bb-folder-selected-id").val(p(a).find(".location-folder-list li.is_active").attr("data-id")),p(a).find('.location-folder-list li[data-id="'+e+'"]').children().hide()),"0"===o&&(p(a).find(".location-folder-list").children("li").show(),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(BP_Nouveau.media.target_text),p(a).find(".location-folder-back").hide()),setTimeout(function(){var e=0,e=(p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").prev():p(a).find(".breadcrumbs-append-ul-li .item > span:last-child")).attr("id");o===parseInt(e)&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled"))},100),e=p(a).find(".location-folder-list .is_active > span"),i=p(''),e.parents("li").each(function(e,t){t=p(t).children("span").clone();i.prepend("",t)}),p(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")))},clearFolderLocationUI:function(e){e=jQuery(e.currentTarget).closest(".has-folderlocationUI");0 ul > li.selected").data("bp-scope")||bp.Nouveau.inject("#media-stream ul.media-list",e.data.media,"prepend"),p("#buddypress #bp-media-single-album").length||(e.data.media_personal_count&&(0 '+e.data.media_personal_count+" "+t)):p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").length?p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count):"1"===BP_Nouveau.bb_enable_content_counts&&((a=document.createElement("span")).setAttribute("class","count"),o=document.createTextNode(e.data.media_personal_count),a.appendChild(o),p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a").append(a))),e.data.media_group_count&&(0
'+e.data.media_group_count+" "+t)):p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").length?p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count):"1"===BP_Nouveau.bb_enable_content_counts&&((o=document.createElement("span")).setAttribute("class","count"),a=document.createTextNode(e.data.media_group_count),o.appendChild(a),p("#buddypress").find(".bp-wrap .users-nav ul li#photos-groups-li a").append(o))),"yes"===BP_Nouveau.media.is_media_directory&&(0
ul > li.selected").data("bp-scope"))?a=e.data.media_all_count:"personal"===o?a=e.data.media_personal_count:"groups"===o&&(a=e.data.media_group_count),t=BP_Nouveau.dir_labels.hasOwnProperty("media")?1===a?BP_Nouveau.dir_labels.media.singular:BP_Nouveau.dir_labels.media.plural:"",p("#buddypress .bb-item-count").html(''+a+" "+t)):(p("#buddypress").find(".media-type-navs ul.media-nav li#media-all a span.count").text(e.data.media_all_count),p("#buddypress").find(".media-type-navs ul.media-nav li#media-personal a span.count").text(e.data.media_personal_count),p("#buddypress").find(".media-type-navs ul.media-nav li#media-groups a span.count").text(e.data.media_group_count)))),void 0!==e.data.album_total_count&&s.updateAlbumCounts(e.data);for(var i=0;i
"),h(".bb-rl-modal-container #bb-rl-folder-privacy").addClass("new-folder-create-privacy"),a.find(".open-popup .error").hide(),bp.Readylaunch&&bp.Readylaunch.initSelect2Scoped&&setTimeout(function(){var e=o.find(".bb-rl-create-popup-"+i+"-wrap");e.length&&e.is(":visible")&&bp.Readylaunch.initSelect2Scoped(e)},150)},closeCreateFolderAlbumInPopup:function(e,t){h(".bb-rl-modal-container .bb-rl-model-footer, .modal-container .bb-model-footer").show(),h(".bb-field-wrap-search").show(),h(".bb-rl-document-open-create-popup-folder").show(),"album"===t&&h(".bb-rl-modal-container:visible .bb-rl-video-open-create-popup-album").show(),h(".bb-rl-location-"+t+"-list-wrap-main").show(),"folder"===t?h("#bp-media-document-prev").show():"album"===t&&((i=h(".bb-field-steps-2")).find("#bp-media-prev").show(),i.find("#bp-video-next").show()),h(".bb-rl-create-popup-"+t+"-wrap").hide(),"album"===t&&h(".bb-rl-media-create-popup-album-submit.loading").removeClass("loading");var i=h(e.currentTarget).closest(".bb-rl-has-folderlocationUI");i.find(".bb-rl-modal-header").children().show(),i.find(".bb-rl-modal-header p").hide()},submitCreateFolderAlbumInPopup:function(e,a,o){e.preventDefault();var d=this,e=h(e.currentTarget),n=e.closest(".open-popup"),r=h(n).find(".bb-rl-"+a+"-create-popup-"+o+"-submit"),t=n.find(".bb-rl-"+o+"-selected-id").val(),s=e.closest(".modal-container, .bb-rl-modal-container").find(".bb-rl-popup-on-fly-create-"+o+"-title"),i=h.trim(s.val());if("document"===a){var l=/[\\/?%*:|"<>]+/g.exec(i),l=Boolean(l);if(""===i||l)return s.addClass("error"),!1;s.removeClass("error")}this.currentTargetParent=t=""===t?0:t;var c=this.currentTargetParent,p=0,b="",m="",u=0;if("group"===this.moveToTypePopup?(b="grouponly",p=this.moveToIdPopup):(m=e.closest(".modal-container, .bb-rl-modal-container").find(".bb-rl-popup-on-fly-create-"+o+' select[id*="-'+o+'-privacy"]'),b=m.val()),""===i)return l="document"===a?g.create_folder_error_title:g.create_album_error_title,alert(l),!1;r.addClass("loading");var f=("video"===a?"media":a)+"_"+o+"_save",v=".location-"+o+"-list";setTimeout(function(){var e={action:f,_wpnonce:w.media,title:i,privacy:b,parent:c,group_id:p};h.ajax({type:"POST",url:y,data:e,async:!1,success:function(e){var t,i;e.success?("document"===a&&h(".document-data-table-head").length&&parseInt(c)===parseInt(g.current_folder)&&(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()),n.find(".bb-rl-location-"+o+"-list-wrap "+v).remove(),n.find(".bb-rl-location-"+o+"-list-wrap").append(e.data.tree_view),t="document"===a?"#"+h(n).attr("id")+".open-popup":n,i="document"===a?e.data.folder_id:e.data.album_id,bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,i),u=i,(""===e.data.tree_view?(n.find(".bb-rl-location-"+o+"-list-wrap").hide(),n.find(".bb-rl-location-"+o+"-list-wrap-main span.bb-rl-no-"+o+"-exists")):(n.find(".bb-rl-location-"+o+"-list-wrap-main span.bb-rl-no-"+o+"-exists").hide(),n.find(".bb-rl-location-"+o+"-list-wrap"))).show(),n.find("ul"+v+" span#"+u).trigger("click"),n.find(".bb-rl-model-footer, .bb-model-footer").show(),"document"===a&&n.find(".bb-rl-model-footer, .bb-model-footer, #bp-media-"+a+"-prev").show(),n.find(".bb-field-wrap-search").show(),n.find(".bb-rl-"+a+"-open-create-popup-"+o).show(),n.find(".bb-rl-location-"+o+"-list-wrap-main").show(),n.find(".bb-rl-create-popup-"+o+"-wrap").hide(),"media"===a&&n.find(".bb-field-steps-2 #bp-media-prev").show(),n.find(".bb-rl-"+o+"-selected-id").val(),n.find(".bb-rl"+o+"-selected-id").val(u),n.find(".bb-rl-modal-header").children().show(),n.find(".bb-rl-modal-header p").hide(),s.val(""),""!==m&&m.val("public"),h(n).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0").addClass("media-list item-list bp-list bb-photo-list grid")),0 ").addClass("display")),p("#media-stream div").attr("id","media-folder-document-data-table"),p(".bb-photos-actions").show()),p(".document-data-table-head").length?"yes"===BP_Nouveau.media.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(p(document).find("li#document-personal a").trigger("click"),p(document).find("li#document-personal").trigger("click")):r&&bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"):location.reload(!0),p("#bp-media-post-content").val("");for(var t=0;t
").removeClass("acomments-view-more--hide"),o.isModal||(o.commentsList.removeClass("active"),o.commentsActivityItem.removeClass("active"))})}},bp.Nouveau.Activity.start())})((bp,jQuery)); \ No newline at end of file diff --git a/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-media.js b/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-media.js index c17a6b5ef61..3df7da8b29a 100644 --- a/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-media.js +++ b/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-media.js @@ -954,6 +954,16 @@ window.bp = window.bp || {}; $( 'body #buddypress .bb-rl-activity-list li#bb-rl-activity-' + activityId ).remove(); $( 'body .bb-rl-activity-media-elem.bb-rl-media-activity.' + id ).remove(); $( 'body .bb-rl-activity-comments li#bb-rl-acomment-' + activityId ).remove(); + + // The "view more comments" modal holds its own copy of the + // activity, and its wrapper duplicates id="buddypress", so + // the ID selector above only ever reaches the page copy. + // When the whole activity is gone, close the modal through + // its real close button so the close handler runs. + var $activityModal = $( '#bb-rl-activity-modal:visible' ); + if ( $activityModal.length && $activityModal.find( 'li[data-bp-activity-id="' + activityId + '"]' ).length ) { + $activityModal.find( '.bb-rl-modal-activity-header .bb-rl-close-action-popup' ).trigger( 'click' ); + } } else { $( 'body #buddypress .bb-rl-activity-list li#bb-rl-activity-' + activityId ).replaceWith( response.data.activity_content ); } diff --git a/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-media.min.js b/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-media.min.js index 32c972a6f07..56e23389248 100644 --- a/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-media.min.js +++ b/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-media.min.js @@ -1 +1 @@ -window.bp=window.bp||{},(h=>{var e,g,r,y,v,s,w,l,t;"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},g=(e=BP_Nouveau).media,r=e.document,y=e.ajaxurl,v=e.video,s=e.is_send_ajax_request,w=e.nonces,l=e.activity,t=void 0!==window.BP_Forums_Nouveau&&(window.BP_Forums_Nouveau.media,1)?window.BP_Forums_Nouveau.media:{},bp.Nouveau.Media={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){var e=h("body"),e=(this.current_page=1,this.current_page_existing_media=1,this.current_page_albums=1,this.current_tab=!e.hasClass("single-topic")&&!e.hasClass("single-forum")&&"bp-dropzone-content",this.sort_by="",this.order_by="",this.currentTargetParent=g.current_folder,this.moveToIdPopup=g.move_to_id_popup,this.moveToTypePopup=g.current_type,this.privacySelectorSelect="",this.privacySelectorSpan="",void 0!==window.Dropzone&&(window.Dropzone.autoDiscover=!1),document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:""),e=(this.documentOptions=bp.Readylaunch.Utilities.createDropzoneOptions({dictFileTooBig:g.dictFileTooBig,acceptedFiles:g.document_type,createImageThumbnails:!1,dictDefaultMessage:g.dropzone_document_message,maxFiles:void 0!==r.maxFiles?r.maxFiles:10,maxFilesize:void 0!==r.max_upload_size?r.max_upload_size:2,dictInvalidFileType:r.dictInvalidFileType,dictMaxFilesExceeded:g.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:g.dictCancelUploadConfirmation}),document.getElementsByClassName("forum-post-video-template").length?document.getElementsByClassName("forum-post-video-template")[0].innerHTML:"");this.videoOptions=bp.Readylaunch.Utilities.createDropzoneOptions({dictFileTooBig:v.dictFileTooBig,acceptedFiles:v.video_type,createImageThumbnails:!1,dictDefaultMessage:v.dropzone_video_message,maxFiles:void 0!==v.maxFiles?v.maxFiles:10,maxFilesize:void 0!==v.max_upload_size?v.max_upload_size:2,dictInvalidFileType:v.dictInvalidFileType,dictMaxFilesExceeded:v.video_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:v.dictCancelUploadConfirmation}),h("#bp-media-uploader").hasClass("bp-media-document-uploader")?(e=document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:"",this.options=bp.Readylaunch.Utilities.createDropzoneOptions({dictFileTooBig:g.dictFileTooBig,acceptedFiles:g.document_type,createImageThumbnails:!1,dictDefaultMessage:g.dropzone_document_message,maxFiles:void 0!==r.maxFiles?r.maxFiles:10,maxFilesize:void 0!==r.max_upload_size?r.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:g.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:g.dictCancelUploadConfirmation})):(e=document.getElementsByClassName("forum-post-media-template").length?document.getElementsByClassName("forum-post-media-template")[0].innerHTML:"",this.options=bp.Readylaunch.Utilities.createDropzoneOptions({dictFileTooBig:g.dictFileTooBig,dictDefaultMessage:g.dropzone_media_message,acceptedFiles:"image/*",maxFiles:void 0!==g.maxFiles?g.maxFiles:10,maxFilesize:void 0!==g.max_upload_size?g.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:g.media_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:g.dictCancelUploadConfirmation,maxThumbnailFilesize:void 0!==g.max_upload_size?g.max_upload_size:2})),void 0!==g.dropzone_options&&Object.assign(this.options,g.dropzone_options),this.dropzone_obj=[],this.dropzone_media=[],this.album_id=void 0!==g.album_id&&g.album_id,this.current_folder=void 0!==g.current_folder&&g.current_folder,this.current_group_id=void 0!==g.current_group_id&&g.current_group_id,this.group_id=void 0!==g.group_id&&g.group_id,this.bbp_is_reply_edit=void 0!==t.bbp_is_reply_edit&&t.bbp_is_reply_edit,this.bbp_is_topic_edit=void 0!==t.bbp_is_topic_edit&&t.bbp_is_topic_edit,this.bbp_is_forum_edit=void 0!==t.bbp_is_forum_edit&&t.bbp_is_forum_edit,this.bbp_reply_edit_media=void 0!==t.reply_edit_media?t.reply_edit_media:[],this.bbp_reply_edit_document=void 0!==t.reply_edit_document?t.reply_edit_document:[],this.bbp_reply_edit_video=void 0!==t.reply_edit_video?t.reply_edit_video:[],this.bbp_topic_edit_media=void 0!==t.topic_edit_media?t.topic_edit_media:[],this.bbp_topic_edit_video=void 0!==t.topic_edit_video?t.topic_edit_video:[],this.bbp_topic_edit_document=void 0!==t.topic_edit_document?t.topic_edit_document:[],this.bbp_forum_edit_media=void 0!==t.forum_edit_media?t.forum_edit_media:[],this.bbp_forum_edit_document=void 0!==t.forum_edit_document?t.forum_edit_document:[],this.bbp_forum_edit_video=void 0!==t.forum_edit_video?t.forum_edit_video:[],this.bbp_reply_edit_gif_data=void 0!==t.reply_edit_gif_data?t.reply_edit_gif_data:[],this.bbp_topic_edit_gif_data=void 0!==t.topic_edit_gif_data?t.topic_edit_gif_data:[],this.bbp_forum_edit_gif_data=void 0!==t.forum_edit_gif_data?t.forum_edit_gif_data:[],this.giphy=null,this.gif_offset=0,this.gif_q=null,this.gif_limit=20,this.gif_requests=[],this.gif_data=[],this.gif_container_key=!1,this.reply_topic_allow_delete_media=!1,this.reply_topic_display_post="edit",bp.Nouveau.Media.documentCodeMirror(),h(window).on("scroll resize",function(){bp.Nouveau.Media.documentCodeMirror()})},refreshDirectoryFilter:function(e,t){e=h(document).find("#bb-rl-"+e+"-scope-options");e.length&&(t=e.find('option[data-bp-scope="'+t+'"]')).length&&(t=t.text().trim(),e.val(t).trigger("change"))},updateAlbumCounts:function(e){var t,i,a,o;h("#buddypress #bp-media-single-album").length&&(o=parseInt(e.album_media_count)||0,e=parseInt(e.album_video_count)||0,t=function(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},0<(a=h("#buddypress .bb-album-photo-count")).length&&(0]+/g.exec(e.val())),d=Boolean(d);if(""===p.trim(e.val())||d)return e.addClass("error"),!1;if(e.removeClass("error"),!a.group_id&&""===p.trim(o.val()))return o.addClass("error"),!1;o.removeClass("error"),i.prop("disabled",!0).addClass("loading");d={action:"document_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:e.val().trim(),privacy:o.val(),album_id:a.current_folder,group_id:a.current_group_id};p(".bb-single-album-header .bp-feedback").remove(),p("#boss-media-create-album-popup .bp-feedback").remove(),p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:d,success:function(e){setTimeout(function(){i.prop("disabled",!1)},500),e.success?(a.closeFolderUploader(t),p(".document-data-table-head").length?"yes"===BP_Nouveau.media.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(p(document).find("li#document-personal a").trigger("click"),p(document).find("li#document-personal").trigger("click")):(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()):location.reload(!0)):alert(e.data.feedback.replace("'","'"))}})},saveChildFolder:function(t){var e=p(t.currentTarget),i=this,a=p("#bp-media-create-child-folder #bb-album-child-title"),o=(t.preventDefault(),/[\\/?%*:|"<>]+/g.exec(a.val())),o=Boolean(o);if(""===p.trim(a.val())||o)return a.addClass("error"),!1;a.removeClass("error"),e.prop("disabled",!0).addClass("loading");o={action:"document_child_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:a.val(),folder_id:i.current_folder,group_id:i.current_group_id};p(".bb-single-album-header .bp-feedback").remove(),p("#boss-media-create-album-popup .bp-feedback").remove(),p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:o,success:function(e){e.success?(i.closeChildFolderUploader(t),location.reload(!0)):alert(e.data.feedback.replace("'","'"))}})},renameChildFolder:function(e){e.preventDefault();var t=p(e.currentTarget),i=this,e=p("#bp-media-edit-child-folder #bb-album-child-title"),a=p("#bp-media-edit-child-folder #bb-folder-privacy"),o=this.currentTargetParent,d=/[\\/?%*:|"<>]+/g.exec(e.val()),d=Boolean(d);if(""===p.trim(e.val())||d)return e.addClass("error"),!1;e.removeClass("error"),t.prop("disabled",!0).addClass("loading");d={action:"document_edit_folder",_wpnonce:BP_Nouveau.nonces.media,title:e.val(),privacy:a.val(),id:o,group_id:i.current_group_id};p(".bb-single-album-header .bp-feedback").remove(),p("#boss-media-create-album-popup .bp-feedback").remove(),p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:d,success:function(e){setTimeout(function(){t.prop("disabled",!1)},500),e.success?window.location.reload(!0):i.current_folder?p("#bp-media-single-album").prepend(e.data.feedback):p("#boss-media-create-album-popup .bb-model-header").after(e.data.feedback)}})},deleteAlbum:function(t){if(t.preventDefault(),!this.album_id)return!1;if(!confirm(BP_Nouveau.media.i18n_strings.album_delete_confirm))return!1;p(t.currentTarget).prop("disabled",!0);var e={action:"media_album_delete",_wpnonce:BP_Nouveau.nonces.media,album_id:this.album_id,group_id:this.group_id};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){e.success?window.location.href=e.data.redirect_url:(alert(BP_Nouveau.media.i18n_strings.album_delete_error),p(t.currentTarget).prop("disabled",!1))}})},deleteFolder:function(t){if(t.preventDefault(),!BP_Nouveau.media.current_folder)return!1;if(!confirm(BP_Nouveau.media.i18n_strings.folder_delete_confirm))return!1;p(t.currentTarget).prop("disabled",!0);var e={action:"document_folder_delete",_wpnonce:BP_Nouveau.nonces.media,folder_id:BP_Nouveau.media.current_folder,group_id:BP_Nouveau.media.current_group_id};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){e.success?window.location.href=e.data.redirect_url:(alert(BP_Nouveau.media.i18n_strings.folder_delete_error),p(t.currentTarget).prop("disabled",!1))}})},addMediaIdsToGroupMessagesForm:function(){p("#bp_group_messages_media").length&&p("#bp_group_messages_media").val(JSON.stringify(this.dropzone_media))},addDocumentIdsToGroupMessagesForm:function(){p("#bp_group_messages_document").length&&p("#bp_group_messages_document").val(JSON.stringify(this.dropzone_media))},addVideoIdsToGroupMessagesForm:function(){p("#bp_group_messages_video").length&&p("#bp_group_messages_video").val(JSON.stringify(this.dropzone_media))},injectMedias:function(t){var i,a,e,o=bp.Nouveau.getStorage("bp-media"),d=o.scope||null,o=o.filter||null;p(t.currentTarget).hasClass("load-more")&&(i=+Number(this.current_page)+1,a=this,e="",t.preventDefault(),p(t.currentTarget).find("a").first().addClass("loading"),p("#buddypress .dir-search input[type=search]").length&&(e=p("#buddypress .dir-search input[type=search]").val()),bp.Nouveau.objectRequest({object:"media",scope:d,filter:o,search_terms:e,page:i,method:"append",target:"#buddypress [data-bp-list] ul.bp-list"}).done(function(e){!0===e.success&&(p(t.currentTarget).remove(),a.current_page=i,jQuery(window).scroll())}))},injectDocuments:function(e){var t,i,a,o=bp.Nouveau.getStorage("bp-document"),d="",s="",n=o.scope||null,r=o.filter||null,l=p(e.currentTarget);l.hasClass("load-more")&&(t=+Number(this.current_page)+1,i=this,a="",e.preventDefault(),l.find("a").first().addClass("loading"),p("#buddypress .dir-search input[type=search]").length&&(a=p("#buddypress .dir-search input[type=search]").val()),s=this.order_by&&this.sort_by?(d=this.sort_by,this.order_by):void 0!==o.extras?(d=o.extras.sort,o.extras.orderby):(d="ASC","title"),bp.Nouveau.objectRequest({object:"document",scope:n,filter:r,search_terms:a,page:t,method:"append",target:"#buddypress [data-bp-list] div#media-folder-document-data-table",order_by:s,sort:d}).done(function(e){!0===e.success&&(l.parent(".pager").remove(),i.current_page=t,jQuery(window).scroll())}))},sortDocuments:function(e){var t=p(e.currentTarget),i=t.data("target"),a="",o="date_created";t.attr("class");switch(i){case"name":o="title";break;case"modified":o="date_modified";break;case"visibility":o="privacy";break;case"group":o="group_id"}t.hasClass("asce")?t.removeClass("asce"):t.addClass("asce");var i=t.hasClass("asce")?"DESC":"ASC",t=(bp.Nouveau.getStorage("bp-document"),{}),t=(t.orderby=o,t.sort=i,"group"!==o&&bp.Nouveau.setStorage("bp-document","extras",t),bp.Nouveau.getStorage("bp-document")),d=t.scope||null,t=t.filter||null;p(e.currentTarget);p("#buddypress .bp-dir-search-form input[type=search]").length&&(a=p("#buddypress .bp-dir-search-form input[type=search]").val()),this.sort_by=i,this.order_by=o,this.current_page=1,bp.Nouveau.objectRequest({object:"document",scope:d,filter:t,search_terms:a,page:1,order_by:o,sort:i,method:"reset",target:"#buddypress [data-bp-list]"}).done()},documentPopupNavigate:function(e){e.preventDefault();var e=p(e.currentTarget),t=e.closest(".bb-field-steps"),i=0==e.closest(".bp-document-listing").length?"#bb-album-child-title":"#bb-album-title";e.closest(".document-options").length&&(i="#bb-album-title"),e.hasClass("bb-field-steps-next")&&""==t.find(i).val().trim()?t.find(i).addClass("error"):(t.find(i).removeClass("error"),t.slideUp(200).siblings(".bb-field-steps").slideDown(200))},uploadDocumentNavigate:function(e){e.preventDefault();var e=p(e.currentTarget),t=p(e).closest("#bp-media-uploader");p(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-document-submit, #bp-media-document-prev, .bp-document-open-create-popup-folder, #bb-document-privacy").show(),0!==Number(p(t).find(".bb-folder-selected-id"))&&p(t).find(".location-folder-list li.is_active").length&&p(t).find(".location-folder-list").scrollTop(p(t).find(".location-folder-list li.is_active").offset().top-p(t).find(".location-folder-list").offset().top),p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(t).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))})):(p(e).hide(),t.find("#bp-media-document-prev, .bp-document-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-folder").length&&p("#bb-document-privacy").hide())},uploadMediaNavigate:function(e){e.preventDefault();var e=p(e.currentTarget),t=p(e).closest(".bp-media-photo-uploader");p(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-submit, #bp-media-prev, .bp-media-open-create-popup-folder.create-album").show(),t.find("#bb-media-privacy").show(),0!==Number(p(t).find(".bb-album-selected-id"))&&p(t).find(".location-album-list li.is_active").length&&p(t).find(".location-album-list").scrollTop(p(t).find(".location-album-list li.is_active").offset().top-p(t).find(".location-album-list").offset().top)):(p(e).hide(),t.find("#bp-media-prev, .bp-media-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-album").length&&p("#bb-media-privacy").hide())},appendMedia:function(t){var i,a,e,o=bp.Nouveau.getStorage("bp-media"),d=o.scope||null,o=o.filter||null;p(t.currentTarget).hasClass("load-more")&&(i=+Number(this.current_page_existing_media)+1,a=this,e="",t.preventDefault(),p(t.currentTarget).find("a").first().addClass("loading"),p("#buddypress .dir-search input[type=search]").length&&(e=p("#buddypress .dir-search input[type=search]").val()),bp.Nouveau.objectRequest({object:"media",scope:d,filter:o,search_terms:e,page:i,method:"append",caller:"bp-existing-media",target:".bp-existing-media-wrap ul.bp-list"}).done(function(e){!0===e.success&&(p(t.currentTarget).remove(),a.current_page_existing_media=i,jQuery(window).scroll())}))},appendAlbums:function(t){var i=+Number(this.current_page_albums)+1,a=this,e=(t.preventDefault(),p(t.currentTarget).find("a").first().addClass("loading"),{action:"media_albums_loader",_wpnonce:BP_Nouveau.nonces.media,page:i});p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){!0===e.success&&(p(t.currentTarget).remove(),p("#albums-dir-list ul.bb-albums-list").fadeOut(100,function(){p("#albums-dir-list ul.bb-albums-list").append(e.data.albums),p(this).fadeIn(100)}),a.current_page_albums=i)}})},toggleSubmitMediaButton:function(){var e=p("#bp-media-submit"),t=p("#bp-media-add-more");"bp-dropzone-content"===this.current_tab?this.dropzone_obj.getAcceptedFiles().length?(e.show(),t.show()):(e.hide(),t.hide()):"bp-existing-media-content"===this.current_tab&&(p('.bp-existing-media-wrap .bb-media-check-wrap [name="bb-media-select"]:checked').length?e.show():e.hide(),t.hide())},playVideo:function(e){e.preventDefault();var t=p(e.currentTarget).find("video").get(0),e=p(e.currentTarget).find(".gif-play-button");1==t.paused?(t.play().catch(function(e){console.debug("GIF play failed:",e)}),e.hide()):(t.pause(),e.show())},isElementInScrollableContainer:function(e){var t=p(e),e=e.getBoundingClientRect(),i=t.closest("#bp-message-thread-list");return(i=(i=i.length?i:t.closest(".bb-modal-activity-body")).length?i:t.closest(".bb-media-model-container .activity-list .activity-item")).length?(i=i[0].getBoundingClientRect(),e.bottom>i.top&&e.top i.left&&e.left '),p(t).text());return p(t).text(BP_Nouveau.media.copy_to_clip_board_text),p("#"+e).val(p(t).attr("href")),p("#"+e).select(),document.execCommand("copy"),setTimeout(function(){p(t).text(i)},2e3),!1},fileActivityActionButton:function(e){e.preventDefault(),p(e.currentTarget).parent().hasClass("copy_download_file_url")||(p(e.currentTarget).closest(".bb-activity-media-elem").toggleClass("is-visible").siblings().removeClass("is-visible").closest(".activity-item").siblings().find(".bb-activity-media-elem").removeClass("is-visible"),p(e.currentTarget).closest(".bb-activity-media-elem").find(".bb_more_dropdown").toggleClass("open").closest(".bb-activity-media-elem").siblings().find(".bb_more_dropdown").removeClass("open").closest(".activity-item").siblings().find(".bb-activity-media-elem .bb_more_dropdown").removeClass("open"),p("body").addClass("document_more_option_open"),p(e.currentTarget).closest(".bb-activity-media-elem").length<1&&(p(e.currentTarget).closest(".bb-photo-thumb").toggleClass("is-visible").parent().siblings().find(".bb-photo-thumb").removeClass("is-visible").removeClass("is-visible"),p(e.currentTarget).closest(".bb-photo-thumb").find(".bb_more_dropdown").toggleClass("open").closest(".bb-photo-thumb").parent().siblings().find(".bb-photo-thumb .bb_more_dropdown").removeClass("open")),"a"!=e.currentTarget.tagName.toLowerCase())||p(e.currentTarget).hasClass("document-action_more")||p(e.currentTarget).hasClass("media-action_more")||(p(e.currentTarget).closest(".bb-activity-media-elem").removeClass("is-visible").find(".bb_more_dropdown").removeClass("open"),p(e.currentTarget).closest(".bb-photo-thumb").removeClass("is-visible").find(".bb_more_dropdown").removeClass("open"))},toggleFileActivityActionButton:function(e){var t;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),!0===e.altKey||!0===e.metaKey||p(t).hasClass("document-action_more")||p(t).parent().hasClass("document-action_more")||p(t).hasClass("media-folder_action__anchor")||p(t).parent().hasClass("media-folder_action__anchor")||p(t).hasClass("media-action_more")||p(t).parent().hasClass("media-action_more")||p(t).hasClass("video-action_more")||p(t).parent().hasClass("video-action_more")?e:(p(".bb-activity-media-elem.is-visible").removeClass("is-visible"),p(".media-folder_items.is-visible").removeClass("is-visible"),p(".bb-photo-thumb.is-visible").removeClass("is-visible"),p(".bb-item-thumb.is-visible").removeClass("is-visible"),p(".bb-activity-video-elem.is-visible").removeClass("is-visible"),p(".video-action-wrap.item-action-wrap.is-visible").removeClass("is-visible"),p(".video-action-wrap .bb_more_dropdown").removeClass("open"),p(".bb-activity-media-elem .bb_more_dropdown").removeClass("open"),p(".bb-photo-thumb .bb_more_dropdown").removeClass("open"),p(".media-folder_items .bb_more_dropdown").removeClass("open"),void p("body").removeClass("document_more_option_open video_more_option_open item_more_option_open"))},toggleCodePreview:function(e){e.preventDefault(),p(e.currentTarget).closest(".document-activity").toggleClass("code-full-view")},documentCodeMirror:function(){p(".document-text:not(.loaded)").each(function(){var e=p(this),t=e.attr("data-extension"),i=e.attr("data-extension");"html"!=t&&"htm"!=t||(i="text/html"),"js"==t?CodeMirror(e[0],{value:e.find(".document-text-file-data-hidden").val(),lineNumbers:!0,theme:"default",readOnly:!0,lineWrapping:!0}):CodeMirror(e[0],{value:e.find(".document-text-file-data-hidden").val(),mode:i,lineNumbers:!0,theme:"default",readOnly:!0,lineWrapping:!0}),e.addClass("loaded"),150 '+e+" "+t)):(t=p(".single-screen-navs.groups-nav").find("ul li#albums-groups-li"),0 '+e+"")))}},bp.Nouveau.Media.Theatre={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){this.bodySelector=p("body"),this.medias=[],this.documents=[],this.current_media=!1,this.current_document=!1,this.current_index=0,this.current_document_index=0,this.is_open_media=!1,this.is_open_document=!1,this.nextLink=p(".bb-next-media"),this.nextDocumentLink=p(".bb-next-document"),this.previousDocumentLink=p(".bb-prev-document"),this.previousLink=p(".bb-prev-media"),this.activity_ajax=!1,this.group_id=void 0!==BP_Nouveau.media.group_id&&BP_Nouveau.media.group_id,this.manage_media=void 0!==BP_Nouveau.media.can_manage_media&&BP_Nouveau.media.can_manage_media,this.manage_document=void 0!==BP_Nouveau.media.can_manage_document&&BP_Nouveau.media.can_manage_document},addListeners:function(){p(document).on("click",".bb-open-media-theatre",this.openTheatre.bind(this)),p(document).on("click",".bb-open-document-theatre",this.openDocumentTheatre.bind(this)),p(document).on("click",".document-detail-wrap-description-popup",this.openDocumentTheatre.bind(this)),p(document).on("click",".bb-close-media-theatre",this.closeTheatre.bind(this)),p(document).on("click",".bb-close-document-theatre",this.closeDocumentTheatre.bind(this)),p(document).on("click",".bb-prev-media",this.previous.bind(this)),p(document).on("click",".bb-next-media",this.next.bind(this)),p(document).on("click",".bb-prev-document",this.previousDocument.bind(this)),p(document).on("click",".bb-next-document",this.nextDocument.bind(this)),p(document).on("bp_activity_ajax_delete_request",this.activityDeleted.bind(this)),p(document).on("click","#bb-media-model-container .media-privacy>li",this.mediaPrivacyChange.bind(this)),p(document).on("click","#bb-media-model-container .document-privacy>li",this.documentPrivacyChange.bind(this)),p(document).on("click","#bb-media-model-container .bb-media-section span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),p(document).on("click","#bb-media-model-container .bb-document-section span.privacy",bp.Nouveau,this.toggleDocumentPrivacyDropdown.bind(this)),p(document).on("click",".bp-add-media-activity-description",this.openMediaActivityDescription.bind(this)),p(document).on("click","#bp-activity-description-new-reset",this.closeMediaActivityDescription.bind(this)),p(document).on("keyup",".bp-edit-media-activity-description #add-activity-description",this.MediaActivityDescriptionUpdate.bind(this)),p(document).on("click","#bp-activity-description-new-submit",this.submitMediaActivityDescription.bind(this)),p(document).click(this.togglePopupDropdown),document.addEventListener("keyup",this.checkPressedKeyDocuments.bind(this)),document.addEventListener("keyup",this.checkPressedKey.bind(this))},checkPressedKey:function(e){var t=this;if(e=e||window.event,!t.is_open_media)return!1;var i=p(e.target).hasClass("ac-input")||"add-activity-description"===p(e.target).attr("id");switch(e.keyCode){case 27:t.closeTheatre(e);break;case 37:if(void 0===t.medias[t.current_index-1]||i)return!1;t.previous(e);break;case 39:if(void 0===t.medias[t.current_index+1]||i)return!1;t.next(e)}},checkPressedKeyDocuments:function(e){e=e||window.event;var t=this;if(!t.is_open_document)return!1;var i=p(e.target).hasClass("ac-input")||"add-activity-description"===p(e.target).attr("id");switch(e.keyCode){case 27:t.closeDocumentTheatre(e);break;case 37:if(void 0===t.documents[t.current_document_index-1]||i)return!1;t.previousDocument(e);break;case 39:if(void 0===t.documents[t.current_document_index+1]||i)return!1;t.nextDocument(e)}},openTheatre:function(e){e.preventDefault();var e=p(e.currentTarget),t=this;if(e.closest("#bp-existing-media-content").length)return!1;t.setupGlobals(),t.setMedias(e),i=e.data("id"),e.data("activity-id"),t.setCurrentMedia(i),t.showMedia(),t.navigationCommands(),t.getParentActivityHtml(e),t.getMediasDescription(),p(".bb-media-model-wrapper.document").hide();var i=document.getElementById(p(".bb-media-model-wrapper.video video").attr("id"));i&&i.pause(),p(".bb-media-model-wrapper.video").hide(),p(".bb-media-model-wrapper.media").show(),bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay"),t.is_open_media=!0,t.bodySelector.addClass("media-modal-open"),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)},getParentActivityHtml:function(e){var t=p("#hidden_parent_id").val(),e=e.closest(".bb-media-model-wrapper").find("#bb-media-model-container .activity-list li.activity-item").data("bp-activity-id");parseInt(t)===parseInt(e)&&(e=p('#bb-media-model-container [data-bp-activity-id="'+t+'"]'),p('[data-bp-activity-id="'+t+'"] > .activity-state').html(p(e).find(".activity-state").html()),p('[data-bp-activity-id="'+t+'"] > .activity-meta').html(p(e).find(".activity-meta").html()),p('[data-bp-activity-id="'+t+'"] > .activity-comments').html(p(e).find(".activity-comments").html())),p("#hidden_parent_id").length&&p("#hidden_parent_id").remove()},getMediasDescription:function(){var e=this,t=(p(".bb-media-info-section .activity-list").addClass("loading").html(''),0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_media.activity_id+'"] .activity-comments'));t.length&&(t=t.find("#ac-form-"+e.current_media.activity_id),e.current_media.parent_activity_comments=!0,t.remove()),!0===e.current_media.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"media_get_media_description",id:e.current_media.id,attachment_id:e.current_media.attachment_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success?(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.description),p(".bb-media-info-section:visible").show(),bp.Nouveau.Media.Theatre.syncPinPostIconToTheatre(),p(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10)):p(".bb-media-info-section.media").hide()}})},openDocumentTheatre:function(e){e.preventDefault();var t=p(e.currentTarget),i=this;if(t.closest("#bp-existing-document-content").length)return!1;t.closest(".document.document-theatre").length&&i.closeDocumentTheatre(e),a=t.data("id"),i.setupGlobals(),i.setDocuments(t),i.setCurrentDocument(a),i.showDocument(),i.navigationDocumentCommands(),i.getParentActivityHtml(t),i.getDocumentsDescription(),-1!==p.inArray(i.current_document.extension,BP_Nouveau.document.mp3_preview_extension.split(","))&&p(e.currentTarget).closest(".bb-activity-media-elem.document-activity").length&&p(e.currentTarget).closest(".bb-activity-media-elem.document-activity").find(".document-audio-wrap").length&&p(e.currentTarget).closest(".bb-activity-media-elem.document-activity").find(".document-audio-wrap audio")[0].pause(),p(".bb-media-model-wrapper.media").hide(),p(".bb-media-model-wrapper.document").show();var a=document.getElementById(p(".bb-media-model-wrapper.video video").attr("id"));a&&(a.pause(),a.src=""),p(".bb-media-model-wrapper.video").hide(),i.is_open_document=!0,i.bodySelector.addClass("document-modal-open"),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay")},500)},resetRemoveActivityCommentsData:function(){var e,t=this,i=!1,a=!1,o=!1,d=!1,s=!1,n=!1;t.current_media.parent_activity_comments&&((i=(d=p('.bb-media-model-wrapper.media [data-bp-activity-id="'+t.current_media.activity_id+'"]')).find(".activity-comments")).length&&(e=i.find("#ac-form-"+t.current_media.activity_id),this.purgeEditActivityForm(e),e.find("#ac-input-"+t.current_media.activity_id).html(""),e.removeClass("has-content has-gif has-media").addClass("root"),i.append(e),e.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(t.current_media.activity_id),i.find(".acomment-display").removeClass("display-focus"),i.find(".comment-item").removeClass("comment-item-focus"),s=i.html(),n=i.attr("class"),i.remove(),(i=p('[data-bp-activity-id="'+t.current_media.activity_id+'"] .activity-comments')).length)&&(i.attr("class",n),0===i.find("#ac-form-"+t.current_media.activity_id).length)&&(i.append(e),i.children("form").removeClass("events-initiated").addClass("not-initialized")),(o=d.find(".activity-state")).length&&(s=o.html(),n=o.attr("class"),o.remove(),(o=p('[data-bp-activity-id="'+t.current_media.activity_id+'"] .activity-state')).length)&&(o.html(s),o.attr("class",n)),(a=d.find(".activity-meta")).length&&(s=a.html(),n=a.attr("class"),a.remove(),(a=p('[data-bp-activity-id="'+t.current_media.activity_id+'"] > .activity-meta')).length)&&(a.html(s),a.attr("class",n)),d.remove()),t.current_document.parent_activity_comments&&((i=(d=p('.bb-media-model-wrapper.document [data-bp-activity-id="'+t.current_document.activity_id+'"]')).find(".activity-comments")).length&&(e=i.find("#ac-form-"+t.current_document.activity_id),this.purgeEditActivityForm(e),e.find("#ac-input-"+t.current_document.activity_id).html(""),e.removeClass("has-content has-gif has-media").addClass("root"),i.append(e),e.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(t.current_document.activity_id),i.find(".acomment-display").removeClass("display-focus"),i.find(".comment-item").removeClass("comment-item-focus"),s=i.html(),n=i.attr("class"),i.remove(),(i=p('[data-bp-activity-id="'+t.current_document.activity_id+'"] .activity-comments')).length)&&(i.attr("class",n),0===i.find("#ac-form-"+t.current_document.activity_id).length&&(i.append(e),i.children("form").removeClass("events-initiated").addClass("not-initialized")),i.find(".document-text.loaded").removeClass("loaded").find(".CodeMirror").remove(),jQuery(window).scroll()),(o=d.find(".activity-state")).length&&(s=o.html(),n=o.attr("class"),o.remove(),(o=p('[data-bp-activity-id="'+t.current_document.activity_id+'"] .activity-state')).length)&&(o.html(s),o.attr("class",n)),(a=d.find(".activity-meta")).length&&(s=a.html(),n=a.attr("class"),a.remove(),(a=p('[data-bp-activity-id="'+t.current_document.activity_id+'"] > .activity-meta')).length)&&(a.html(s),a.attr("class",n)),d.remove()),bp.Nouveau.reportPopUp(),bp.Nouveau.reportActions()},closeTheatre:function(e){e.preventDefault();var t=this,e=p(e.currentTarget);if(p(e).closest(".bb-media-model-wrapper").hasClass("video-theatre"))return!1;p(".bb-media-model-wrapper.media .bb-media-section").find("img").attr("src",""),p(".bb-media-model-wrapper.video .bb-media-section").find("video").length&&videojs(p(".bb-media-model-wrapper.video .bb-media-section").find("video").attr("id")).reset(),p(".bb-media-model-wrapper").hide(),t.is_open_media=!1,t.syncPinPostActivityOnCloseTheatre(e),t.resetRemoveActivityCommentsData(),t.current_media=!1,t.getParentActivityHtml(e),t.bodySelector.removeClass("media-modal-open")},closeDocumentTheatre:function(e){e.preventDefault();var t=this,i=p(document).find(".document-theatre");i.find(".bb-media-section").removeClass("bb-media-no-preview").find(".document-preview").html(""),p(".bb-media-info-section.document").show(),i.hide(),t.is_open_document=!1,t.resetRemoveActivityCommentsData(),t.current_document=!1,t.getParentActivityHtml(p(e.currentTarget)),t.bodySelector.removeClass("document-modal-open")},setMedias:function(e){var t=p(".bb-open-media-theatre"),i=0;if(void 0!==(t=p("body").hasClass("activity")?p(e).closest(".bb-activity-media-wrap").find(".bb-open-media-theatre"):t))for(this.medias=[],i=0;i
").removeClass("acomments-view-more--hide"),o.isModal||(o.commentsList.removeClass("active"),o.commentsActivityItem.removeClass("active"))):void 0!==t.data&&void 0!==t.data.comments&&((i=n.closest(".activity-item")).hasClass("has-comments")||i.addClass("has-comments"),i=k(".bb-rl-internal-model .bb-rl-activity-comments"),e=o.isModal?i:i.find("[data-activity_id='"+o.activityId+"'][data-parent_comment_id='"+o.parentCommentId+"']"),i=k(k.parseHTML(t.data.comments)),0'),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html(" "+i+'
'),o.find(".bb-document-section .document-preview .document-text").attr("data-extension",d),t=o.find(".bb-document-section .document-preview .document-text textarea"),"html"===d||"htm"===d?t.val(s):t.html(s),setTimeout(function(){bp.Nouveau.Media.documentCodeMirror()},1e3)):-1!==p.inArray(e.current_document.extension,BP_Nouveau.document.mp3_preview_extension.split(","))?(o.find(".bb-document-section .document-preview").html(''),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html('')):-1!==p.inArray("."+e.current_document.extension,BP_Nouveau.video.video_type.split(","))?(o.find(".bb-document-section").addClass("bb-video-preview"),o.find(".bb-document-section .document-preview").html(''),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),"mov"===e.current_document.extension||"m4v"===e.current_document.extension?o.find(".bb-document-section .document-preview").html(''):o.find(".bb-document-section .document-preview").html(''),p(window).scroll()):e.current_document.full_preview?(o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html("'+i+'
"+i+'
')):(o.find(".bb-document-section").addClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html('")),p(".bb-document-section .bb-document-privacy-wrap"));d.length&&(d.show(),d.parent().show(),d.find("ul.document-privacy li").removeClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",""),(t=d.find("ul.document-privacy").find("li[data-value="+e.current_document.privacy+"]")).addClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",t.text()),d.find(".privacy").removeClass("public").removeClass("loggedin").removeClass("onlyme").removeClass("friends").addClass(e.current_document.privacy),void 0!==BP_Nouveau.activity&&void 0!==e.current_document.activity_id&&0!=e.current_document.activity_id||e.group_id||e.current_document.is_forum||e.current_document.group_id||e.current_document.album_id||!e.can_manage_document||!e.current_document.can_edit||e.current_document.is_message)&&d.parent().hide(),e.navigationDocumentCommands()},next:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.medias[e.current_index+1]?(e.current_index=e.current_index+1,e.current_media.activity_id,e.current_media=e.medias[e.current_index],e.showMedia(),e.getMediasDescription(),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):e.nextLink.hide()},previous:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.medias[e.current_index-1]?(e.current_index=e.current_index-1,e.current_media.activity_id,e.current_media=e.medias[e.current_index],e.showMedia(),e.getMediasDescription(),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):e.previousLink.hide()},nextDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.documents[e.current_document_index+1]?(e.current_document_index=e.current_document_index+1,e.current_document.activity_id,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.nextDocumentLink.hide()},previousDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.documents[e.current_document_index-1]?(e.current_document_index=e.current_document_index-1,e.current_document.activity_id,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.previousDocumentLink.hide()},navigationCommands:function(){var e=this;0==e.current_index&&e.current_index!=e.medias.length-1?(e.previousLink.hide(),e.nextLink.show()):0==e.current_index&&e.current_index==e.medias.length-1?(e.previousLink.hide(),e.nextLink.hide()):e.current_index==e.medias.length-1?(e.previousLink.show(),e.nextLink.hide()):(e.previousLink.show(),e.nextLink.show())},navigationDocumentCommands:function(){var e=this;0==e.current_document_index&&e.current_document_index!=e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.show()):0==e.current_document_index&&e.current_document_index==e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.hide()):e.current_document_index==e.documents.length-1?(e.previousDocumentLink.show(),e.nextDocumentLink.hide()):(e.previousDocumentLink.show(),e.nextDocumentLink.show())},getActivity:function(){var e=this;p(".bb-media-info-section .activity-list").addClass("loading").html(''),void 0!==BP_Nouveau.activity&&e.current_media&&void 0!==e.current_media.activity_id&&0!=e.current_media.activity_id&&!e.current_media.is_forum?(0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_media.activity_id+'"] .activity-comments').length&&(e.current_media.parent_activity_comments=!0),!0===e.current_media.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"media_get_activity",id:e.current_media.activity_id,group_id:_.isUndefined(e.current_media.group_id)?0:e.current_media.group_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success&&(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.activity),p(".bb-media-info-section:visible").show(),jQuery(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10))}})):p(".bb-media-info-section.media").hide()},getDocumentsActivity:function(){var e=this;p(".bb-media-info-section .activity-list").addClass("loading").html(''),void 0!==BP_Nouveau.activity&&e.current_document&&void 0!==e.current_document.activity_id&&0!=e.current_document.activity_id&&!e.current_document.is_forum?(0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_document.activity_id+'"] .activity-comments').length&&(e.current_document.parent_activity_comments=!0),!0===e.current_document.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"document_get_activity",id:e.current_document.activity_id,group_id:_.isUndefined(e.current_document.group_id)?0:e.current_document.group_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success&&(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.activity),p(".bb-media-info-section:visible").show(),jQuery(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10))}})):p(".bb-media-info-section.document").hide()},getDocumentsDescription:function(){var e=this,t=(p(".bb-media-info-section .activity-list").addClass("loading").html(''),0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_document.activity_id+'"] .activity-comments'));t.length&&(t=t.find("#ac-form-"+e.current_document.activity_id),e.current_document.parent_activity_comments=!0,t.remove()),!0===e.current_document.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"document_get_document_description",id:e.current_document.id,attachment_id:e.current_document.attachment_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success?(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.description),p(".bb-media-info-section:visible").show(),bp.Nouveau.Media.Theatre.syncPinPostIconToTheatre(),p(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10)):p(".bb-media-info-section.document").hide()}})},activityDeleted:function(e,t){var i=this,a=0;if(i.is_open_media&&void 0!==t&&"delete_activity"===t.action&&i.current_media.activity_id==t.id){var o=p(document).find('[data-bp-list="media"] .bb-open-media-theatre[data-id="'+i.current_media.id+'"]'),d=o.parents("ul");for(o.closest("li").remove(),0===d.find("li:not(.load-more)").length&&(0'+i+"
.activity-list").children("#activity-"+i)).length&&e.hasClass("bb-pinned")&&0
").removeClass("acomments-view-more--hide"),o.isModal||(o.commentsList.removeClass("active"),o.commentsActivityItem.removeClass("active"))})}},bp.Nouveau.Activity.start())})((bp,jQuery)); \ No newline at end of file +window.bp=window.bp||{},(k=>{var t,e,u,d,P,r,M,a;"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},bp.Models=bp.Models||{},bp.Models.ACReply=Backbone.Model.extend({defaults:{gif_data:{}}}),t=BP_Nouveau,e=t.ajaxurl,u=t.media,d=t.is_send_ajax_request,P=t.activity,r=t.newest,M=t.show_x_comments,a=t.confirm,bp.Nouveau.Activity={start:function(){bp.Nouveau.Activity.LocalizeActivityVars=t,this.setupGlobals(),this.addListeners()},invokeMediaFn:function(t){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media[t]&&bp.Nouveau.Media[t]()},setupGlobals:function(){this.just_posted=[],this.current_page=1,this.mentions_count=Number(k(bp.Nouveau.objectNavParent+' [data-bp-scope="mentions"]').find("a span").html())||0,this.heartbeat_data={newest:"",highlights:{},last_recorded:0,first_recorded:0,document_title:k(document).prop("title")},void 0!==window.Dropzone&&void 0!==u&&(window.Dropzone.autoDiscover=!1,this.dropzone_options={url:e,timeout:108e5,dictFileTooBig:u.dictFileTooBig,dictDefaultMessage:u.dropzone_media_message,acceptedFiles:"image/*",autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==u.maxFiles?u.maxFiles:10,maxFilesize:void 0!==u.max_upload_size?u.max_upload_size:2,dictMaxFilesExceeded:u.media_dict_file_exceeded,dictCancelUploadConfirmation:u.dictCancelUploadConfirmation,maxThumbnailFilesize:void 0!==u.max_upload_size?u.max_upload_size:2},void 0!==u.dropzone_options)&&Object.assign(this.dropzone_options,u.dropzone_options),this.dropzone_obj=null,this.dropzone_media=[],this.dropzone_document_obj=null,this.dropzone_document=[],this.dropzone_video_obj=null,this.dropzone_video=[],this.models=[],this.InitiatedCommentForms=[],this.activityHasUpdates=!1,this.activityPinHasUpdates=!1,k(".activity-topic-selector").length&&k(".activity-head-bar").length&&!k(".activity-topic-selector").parent().hasClass("bb-rl-activity-filters-container")&&(k(".activity-topic-selector, .activity-topic-selector + .subnav-filters, .activity-topic-selector + .subnav-filters + .activity-head-bar").wrapAll(''),k('').insertAfter(".activity-topic-selector"))},addListeners:function(){function t(){k(".ac-form.not-initialized").each(function(){var t=k(this),e=t.find(".ac-textarea");bp.Nouveau.Activity.toggleMultiMediaOptions(t,e),s&&(t.removeClass("not-initialized"),e=t.find(".ac-input[contenteditable]"),bp.Nouveau.Activity.listenCommentInput(e))})}var e=k("body"),a=k("#buddypress"),i=k(document),o=k("#bb-rl-activity-modal > .bb-rl-modal-activity-body"),n=(e.hasClass("activity-singular")||a.on("bp_heartbeat_send",this.heartbeatSend.bind(this)),a.on("bp_heartbeat_tick",this.heartbeatTick.bind(this)),a.find('[data-bp-list="activity"]:not( #bb-schedule-posts_modal [data-bp-list="activity"] )').on("click","li.load-newest, li.bb-rl-load-more",this.injectActivities.bind(this)),a.on("bp_ajax_request",'[data-bp-list="activity"]',this.scopeLoaded.bind(this)),k("#bb-rl-activity-stream").on("click",".acomments-view-more",this.showActivity),e.on("click",".bb-rl-close-action-popup",this.closeActivity),i.on("activityModalOpened",function(t,e){var a=e.activityId;i.on("click",function(t){!(0Date: Mon, 17 Aug 2026 17:57:48 +0530 Subject: [PATCH 2/4] PROD-9616 - Close the ReadyLaunch activity modal and anchor the feed when the shown activity is deleted --- .../readylaunch/js/buddypress-activity.js | 22 +++++++++++++++++++ .../readylaunch/js/buddypress-activity.min.js | 2 +- .../readylaunch/js/buddypress-media.js | 10 +++++++++ .../readylaunch/js/buddypress-media.min.js | 2 +- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-activity.js b/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-activity.js index 2b468946a4b..b143585c71a 100644 --- a/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-activity.js +++ b/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-activity.js @@ -3080,6 +3080,28 @@ window.bp = window.bp || {}; } } + // Deleting the activity from inside the "view more comments" + // modal removes only the modal's copy of the entry below - + // the feed's copy stays stale and the modal is left open as + // an empty shell. Drop the feed copy, close the modal through + // its real close button, and anchor the feed on the deleted + // post's neighbor so the user lands at the right position. + if ( ! ajaxData.is_comment && li_parent.closest( '#bb-rl-activity-modal' ).length ) { + var $feedCopy = $( '#bb-rl-activity-stream li.activity-item[data-bp-activity-id="' + ajaxData.id + '"]' ); + var $feedAnchor = $feedCopy.prev( 'li.activity-item' ); + if ( ! $feedAnchor.length ) { + $feedAnchor = $feedCopy.next( 'li.activity-item' ); + } + + $feedCopy.remove(); + $( '#bb-rl-activity-modal .bb-rl-modal-activity-header .bb-rl-close-action-popup' ).trigger( 'click' ); + + if ( $feedAnchor.length ) { + var adminBar = $( '#wpadminbar' ).length !== 0 ? $( '#wpadminbar' ).innerHeight() : 0; + $( 'html, body' ).animate( { scrollTop: parseInt( $feedAnchor.offset().top ) - ( 80 + adminBar ) }, 300 ); + } + } + // Remove the entry. li_parent.slideUp( 300, diff --git a/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-activity.min.js b/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-activity.min.js index 20b54c803dd..2d3b6668c2d 100644 --- a/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-activity.min.js +++ b/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-activity.min.js @@ -1 +1 @@ -window.bp=window.bp||{},(k=>{var t,e,u,d,P,r,M,a;"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},bp.Models=bp.Models||{},bp.Models.ACReply=Backbone.Model.extend({defaults:{gif_data:{}}}),t=BP_Nouveau,e=t.ajaxurl,u=t.media,d=t.is_send_ajax_request,P=t.activity,r=t.newest,M=t.show_x_comments,a=t.confirm,bp.Nouveau.Activity={start:function(){bp.Nouveau.Activity.LocalizeActivityVars=t,this.setupGlobals(),this.addListeners()},invokeMediaFn:function(t){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media[t]&&bp.Nouveau.Media[t]()},setupGlobals:function(){this.just_posted=[],this.current_page=1,this.mentions_count=Number(k(bp.Nouveau.objectNavParent+' [data-bp-scope="mentions"]').find("a span").html())||0,this.heartbeat_data={newest:"",highlights:{},last_recorded:0,first_recorded:0,document_title:k(document).prop("title")},void 0!==window.Dropzone&&void 0!==u&&(window.Dropzone.autoDiscover=!1,this.dropzone_options={url:e,timeout:108e5,dictFileTooBig:u.dictFileTooBig,dictDefaultMessage:u.dropzone_media_message,acceptedFiles:"image/*",autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==u.maxFiles?u.maxFiles:10,maxFilesize:void 0!==u.max_upload_size?u.max_upload_size:2,dictMaxFilesExceeded:u.media_dict_file_exceeded,dictCancelUploadConfirmation:u.dictCancelUploadConfirmation,maxThumbnailFilesize:void 0!==u.max_upload_size?u.max_upload_size:2},void 0!==u.dropzone_options)&&Object.assign(this.dropzone_options,u.dropzone_options),this.dropzone_obj=null,this.dropzone_media=[],this.dropzone_document_obj=null,this.dropzone_document=[],this.dropzone_video_obj=null,this.dropzone_video=[],this.models=[],this.InitiatedCommentForms=[],this.activityHasUpdates=!1,this.activityPinHasUpdates=!1,k(".activity-topic-selector").length&&k(".activity-head-bar").length&&!k(".activity-topic-selector").parent().hasClass("bb-rl-activity-filters-container")&&(k(".activity-topic-selector, .activity-topic-selector + .subnav-filters, .activity-topic-selector + .subnav-filters + .activity-head-bar").wrapAll(''),k('').insertAfter(".activity-topic-selector"))},addListeners:function(){function t(){k(".ac-form.not-initialized").each(function(){var t=k(this),e=t.find(".ac-textarea");bp.Nouveau.Activity.toggleMultiMediaOptions(t,e),n&&(t.removeClass("not-initialized"),e=t.find(".ac-input[contenteditable]"),bp.Nouveau.Activity.listenCommentInput(e))})}var e=k("body"),a=k("#buddypress"),i=k(document),o=k("#bb-rl-activity-modal > .bb-rl-modal-activity-body"),s=(e.hasClass("activity-singular")||a.on("bp_heartbeat_send",this.heartbeatSend.bind(this)),a.on("bp_heartbeat_tick",this.heartbeatTick.bind(this)),a.find('[data-bp-list="activity"]:not( #bb-schedule-posts_modal [data-bp-list="activity"] )').on("click","li.load-newest, li.bb-rl-load-more",this.injectActivities.bind(this)),a.on("bp_ajax_request",'[data-bp-list="activity"]',this.scopeLoaded.bind(this)),k("#bb-rl-activity-stream").on("click",".acomments-view-more",this.showActivity),e.on("click",".bb-rl-close-action-popup",this.closeActivity),i.on("activityModalOpened",function(t,e){var a=e.activityId;i.on("click",function(t){!(0 li.bb-edit-privacy a",bp.Nouveau,this.activityPrivacyRedirect.bind(this)),a.find(s).on("click",".activity-privacy>li:not(.bb-edit-privacy)",bp.Nouveau,this.activityPrivacyChange.bind(this)),a.find(s).on("click","span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),k("#bb-rl-media-model-container .bb-rl-activity-list").on("click",".activity-item",bp.Nouveau,this.activityActions.bind(this)),k(".bb-rl-activity-model-wrapper").on("click",".bb-rl-ac-form-placeholder",bp.Nouveau,this.activityRootComment.bind(this)),i.keydown(this.commentFormAction),i.click(this.togglePopupDropdown),k('#buddypress [data-bp-list="activity"], #bb-rl-media-model-container .bb-rl-activity-list, #activity-modal .bb-rl-activity-list, .bb-rl-modal-activity-footer').on("click",".ac-reply-media-button",this.openCommentsMediaUploader.bind(this)),a.find('[data-bp-list="activity"], #bb-rl-media-model-container .bb-rl-activity-list, #bb-rl-activity-modal .bb-rl-activity-list, .bb-rl-modal-activity-footer').on("click",".bb-rl-ac-reply-media-button, .bb-rl-ac-reply-document-button, .bb-rl-ac-reply-video-button, .bb-rl-ac-reply-gif-button",function(t){var e=k(t.currentTarget);e.hasClass("bb-rl-ac-reply-media-button")?this.openCommentsMediaUploader(t):e.hasClass("bb-rl-ac-reply-document-button")?this.openCommentsDocumentUploader(t):e.hasClass("bb-rl-ac-reply-video-button")?this.openCommentsVideoUploader(t):e.hasClass("bb-rl-ac-reply-gif-button")&&this.openGifPicker(t)}.bind(this)),i.on("click",".activity-state-popup_overlay",bp.Nouveau,this.closeActivityState.bind(this)),i.on("click",".activity-state-popup .activity-state-popup_tab_panel a",this.ReactionStatePopupTab),_.isUndefined(P.params.autoload)||k(window).scroll(this.loadMoreActivities),k(document).on("click",".bb-subnav-filters-container .subnav-filters-opener",this.openActivityFilter.bind(this)),k(document).on("click",this.closeActivityFilter.bind(this)),k(document).on("click",".bb-subnav-filters-container .subnav-filters-modal a",this.filterActivity.bind(this)),k(".bb-rl-activity-model-wrapper, .bb-rl-media-model-wrapper").on("click",".acomments-view-more",this.viewMoreComments.bind(this)),i.on("click","#bb-rl-activity-stream .bb-rl-activity-comments .view-more-comments",function(t){t.preventDefault(),k(this).parents("li.activity-item").find(".bb-rl-activity-comments > ul > li.acomments-view-more, .bb-rl-activity-comments > .activity-actions > ul > li.acomments-view-more").trigger("click")}),i.on("click","#bb-rl-activity-stream .activity-state-comments > .comments-count, #bb-rl-activity-stream .groups-meta > .generic-button .acomment-reply, #bb-rl-activity-stream .activity-meta > .generic-button .acomment-reply",function(t){t.preventDefault();var t=k(this).closest(".activity-item"),e=t.data("bp-activity-id");""===t.find(".bb-rl-activity-comments > ul").html()&&bp.Nouveau.Activity.launchActivityPopup(e,"")}),o.on("scroll",this.autoloadMoreComments.bind(this)),o.on("scroll",this.discardGifEmojiPicker.bind(this)),k(".bb-rl-activity-model-wrapper .bb-rl-model-close-button").on("click",this.activitySyncOnModalClose.bind(this)),e.hasClass("activity-permalink"));"1"===d?a.on("bp_ajax_request",'[data-bp-list="activity"]',function(){setTimeout(t,1e3)}):setTimeout(t,1e3),bp.Nouveau.wrapNavigation(".activity-topic-selector ul",120,!0)},openActivityFilter:function(t){t.preventDefault(),k(".bb-subnav-filters-container:not(.bb-subnav-filters-search)").removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false");t=k(t.currentTarget).parent(".bb-subnav-filters-container");t.addClass("active").find(".subnav-filters-opener").attr("aria-expanded","true"),t.find('input[type="search"]').length&&t.find('input[type="search"]').focus()},closeActivityFilter:function(t){k(t.target).closest(".bb-subnav-filters-container").length||k.each(k(".bb-subnav-filters-container"),function(){(!k(this).hasClass("bb-subnav-filters-search")||""===k(this).find('input[name="activity_search"]').val())&&k(this).removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false")})},filterActivity:function(t){t.preventDefault();var t=k(t.currentTarget),e=t.closest(".bb-subnav-filters-container"),a=(t.parent().addClass("selected").siblings().removeClass("selected"),e.removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false"),t.parent().data("filter-label")),e=(e.find(".subnav-filters-opener .selected").text(a||t.text()),bp.Nouveau.Activity.current_page=1,bp.Nouveau.objectNavParent),a="activity",i=k("#buddypress").find('[data-bp-filter="'+a+'"]').first().val(),o="",s="",n="",d="",l=!1,r=!1,c=(k(e+" [data-bp-object].selected").length&&(o=k(e+" [data-bp-object].selected").data("bp-scope"),t.closest("#bb-subnav-filter-show").length)&&(l=!0,k("body").hasClass("my-activity"))&&(r=!(l=!1)),k('#buddypress [data-bp-search="'+a+'"] input[type=search]')),c=(c.length&&(s=c.val()),k(e+" [data-bp-order]").length&&(n=k(e+' [data-bp-order="'+a+'"].selected').data("bp-orderby")),bp.Nouveau.getStorage("bp-"+a)),e=(void 0!==c.extras&&(d=c.extras),bp.Nouveau.Activity.heartbeat_data.last_recorded=0,{object:a,scope:o,filter:i,search_terms:s,extras:d,order_by:n,save_scope:l,event_element:t});r&&(e.user_timeline=!0),bp.Nouveau.objectRequest(e)},heartbeatSend:function(t,e){var a,i=k("#buddypress [data-bp-list] [data-bp-activity-id]"),o=i.not(".bb-pinned").first(),s=(this.heartbeat_data.first_recorded=o.data("bp-timestamp")||0,k(bp.Nouveau.objectNavParent+" [data-bp-orderby=date_updated].selected").length?void 0!==(o=k("#buddypress [data-bp-list] [data-bp-activity-id]:not(.bb-pinned)").first()).data("bb-updated-timestamp")?this.heartbeat_data.first_recorded=o.data("bb-updated-timestamp"):o.length&&void 0!==o.data("bp-activity").date_updated&&""!==o.data("bp-activity").date_updated?(s=o.data("bp-activity").date_updated,s=new Date(s.replace(" ","T")+"Z"),this.heartbeat_data.first_recorded=s.getTime()/1e3):this.heartbeat_data.first_recorded=o.data("bp-timestamp")||0:this.heartbeat_data.first_recorded=k("#buddypress [data-bp-list] [data-bp-activity-id]:not(.bb-pinned)").first().data("bp-timestamp")||0,i.first().data("bp-timestamp")||0),o=(s>this.heartbeat_data.first_recorded&&(this.heartbeat_data.first_recorded=s),(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),e.bp_activity_last_recorded=this.heartbeat_data.last_recorded,k("#buddypress .activity-head-bar .activity-search input[type=search]"));o.length&&(e.bp_activity_last_recorded_search_terms=o.val()),k.extend(e,{bp_heartbeat:((i=k("body.my-activity:not(.activity-singular)")).length?a=bp.Nouveau.getStorage("bp-user-activity")||{scope:"just-me"}:(a=bp.Nouveau.getStorage("bp-activity")||{scope:"all"},k("body.activity.buddypress.groups.single-item").length&&(a.scope="all")),k(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").length&&(s=k(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").data("bp-scope"),void 0!==a.scope&&a.scope===s||(a.scope=s,"undefined"!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request&&(i.length?bp.Nouveau.setStorage("bp-user-activity","scope",s):bp.Nouveau.setStorage("bp-activity","scope",s)))),k(bp.Nouveau.objectNavParent+" [data-bp-order].selected").length&&(a.order_by=k(bp.Nouveau.objectNavParent+" [data-bp-order].selected").data("bp-orderby")),(i=bp.Nouveau.getStorage("bp-activity","topic_id"))&&(e.bp_heartbeat=e.bp_heartbeat||{},e.bp_heartbeat.topic_id=i),a)})},heartbeatTick:function(t,e){var a,i,o,s=bp.Nouveau.objects,n=bp.Nouveau.getStorage("bp-activity","scope"),d=this,l=bp.Nouveau.getStorage("bp-activity","topic_id");void 0!==e&&e.bp_activity_newest_activities&&(e=e.bp_activity_newest_activities,this.heartbeat_data.newest=k.trim(e.activities)+this.heartbeat_data.newest,this.heartbeat_data.last_recorded=Number(e.last_recorded),e=k(this.heartbeat_data.newest).filter(".activity-item"),l&&(a=(e=e.filter(function(){var t=this.dataset.bpActivity?JSON.parse(this.dataset.bpActivity):null,t=t&&void 0!==t.topic_id?t.topic_id:null;return t&&parseInt(t)===parseInt(l)})).length),a=Number(e.length),s.push("mentions"),"all"===n?(k.each(e,function(t,a){a=k(a),k.each(s,function(t,e){-1!==k.inArray("bp-my-"+e,a.get(0).classList)&&(void 0===d.heartbeat_data.highlights[e]?d.heartbeat_data.highlights[e]=[a.data("bp-activity-id")]:-1===k.inArray(a.data("bp-activity-id"),d.heartbeat_data.highlights[e])&&d.heartbeat_data.highlights[e].push(a.data("bp-activity-id")))})}),i=new RegExp("bp-my-("+s.join("|")+")","g"),this.heartbeat_data.newest=this.heartbeat_data.newest.replace(i,""),k(bp.Nouveau.objectNavParent+' [data-bp-scope="all"]').find("a span").html(a)):(this.heartbeat_data.highlights[n]=[],k.each(e,function(t,e){d.heartbeat_data.highlights[n].push(k(e).data("bp-activity-id"))})),k.each(s,function(t,e){var a;void 0!==d.heartbeat_data.highlights[e]&&d.heartbeat_data.highlights[e].length&&(a=0,"mentions"===e&&(a=d.mentions_count),k(bp.Nouveau.objectNavParent+' [data-bp-scope="'+e+'"]').find("a span").html(Number(d.heartbeat_data.highlights[e].length)+a))}),s.pop(),k(document).prop("title","("+a+") "+this.heartbeat_data.document_title),e=(i=k('#buddypress [data-bp-list="activity"]')).find(".load-newest a"),i.first().hasClass("load-newest")?(o=e.html(),e.html(o.replace(/([0-9]+)/,a))):i.find("ul.bb-rl-activity-list").prepend(' '+r+" ("+a+") "),i.find("li.load-newest").trigger("click"),i.trigger("bp_heartbeat_pending",this.heartbeat_data),void 0!==bp.Nouveau)&&bp.Nouveau.reportPopUp()},injectActivities:function(t){var e,a,i,o,s,n=k("body.my-activity:not(.activity-singular)").length?bp.Nouveau.getStorage("bp-user-activity"):bp.Nouveau.getStorage("bp-activity"),d=n.scope||null,n=n.filter||null;k(t.currentTarget).hasClass("load-newest")?(t.preventDefault(),k(t.currentTarget).remove(),s=k.parseHTML(this.heartbeat_data.newest),k.each(s,function(t,e){"LI"===e.nodeName&&k(e).hasClass("just-posted")&&(e=k("#"+k(e).prop("id"))).length&&e.remove()}),(0<(i=(s=k(t.delegateTarget).find(".bb-rl-activity-list")).find(".activity-item").first()).length&&i.hasClass("bb-pinned")?k(i).after(this.heartbeat_data.newest):s.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"===d&&k(bp.Nouveau.objectNavParent+' [data-bp-scope="all"]').find("a span").html(""),"mentions"===d&&(bp.Nouveau.ajax({action:"activity_clear_new_mentions"},"activity"),this.mentions_count=0),k(bp.Nouveau.objectNavParent+' [data-bp-scope="'+d+'"]').find("a span").html(""),void 0!==this.heartbeat_data.highlights[d]&&(this.heartbeat_data.highlights[d]=[]),setTimeout(function(){k(t.delegateTarget).find("[data-bp-activity-id]").removeClass("newest_"+d+"_activity")},3e3),k(document).prop("title",this.heartbeat_data.document_title),jQuery(window).scroll()):k(t.currentTarget).hasClass("bb-rl-load-more")&&(e=Number(this.current_page)+1,a=this,i="",t.preventDefault(),(o=k(t.currentTarget)).find("a").first().addClass("loading"),this.just_posted=[],k(t.delegateTarget).children(".just-posted").each(function(){a.just_posted.push(k(this).data("bp-activity-id"))}),(s=k("#buddypress .activity-search.bp-search input[type=search]")).length&&(i=s.val()),bp.Nouveau.objectRequest({object:"activity",scope:d,filter:n,search_terms:i,page:e,method:"append",exclude_just_posted:this.just_posted.join(","),target:'#buddypress [data-bp-list]:not( #bb-schedule-posts_modal [data-bp-list="activity"] ) ul.bb-rl-list'}).done(function(t){!0===t.success&&(o.remove(),a.current_page=e,jQuery(window).scroll())})),k(".activity-item.bb-closed-comments").find(".edit-activity, .acomment-edit").parents(".generic-button").hide()},hideComments:function(t){var a,i,o,t=k(t.target).find(".bb-rl-activity-comments");t.length&&t.each(function(t,e){o=k(e).children("ul").not(".bb-rl-conflict-activity-ul-li-comment"),!(i=k(o).find("li").not(k(".bb-rl-document-action-class, .bb-rl-media-action-class, .bb-rl-video-action-class"))).length||k("body").hasClass("activity-singular")&&""!==window.location.hash&&k(window.location.hash).length&&0!==k(window.location.hash).closest(".bb-rl-activity-comments").length||(a=k(e).closest(".activity-item"),k("#acomment-comment-"+a.data("bp-activity-id")+" span.comment-count").html(),i.each(function(t,e){if(t"),window.location.hash&&"#"+k(e).attr("id")===window.location.hash)return k(e).parents("li.comment-item").show(),!1;k(e).addClass("bp-hidden").hide()}}),k(o).children(".bp-hidden").length===k(o).children("li").length-1&&k(o).find("li.show-all").length&&k(o).children("li:not(.show-all)").removeClass("bp-hidden").toggle())})},showActivity:function(t){t.preventDefault();var e=k(t.currentTarget).parent(),a=e.data("parent_comment_id"),e=k(e).data("activity_id");k(document).trigger("activityModalOpened",{activityId:e}),k(t.currentTarget).parents(".bb-rl-activity-comments").find(".ac-form").each(function(){var t=k(this),e=k(this).closest(".bb-rl-activity-comments"),a=k(this).closest(".comment-item");t.find(".bb-rl-post-elements-buttons-item.bb-rl-post-emoji").removeClass("active").empty(""),bp.Nouveau.Activity.resetActivityCommentForm(t,"hardReset"),e.append(t),a.find(".bb-rl-acomment-display").removeClass("bb-rl-display-focus"),a.removeClass("bb-rl-comment-item-focus")}),bp.Nouveau.Activity.launchActivityPopup(e,a)},closeActivity:function(t){t.preventDefault();var t=k(t.target).closest(".bb-rl-activity-model-wrapper"),e=t.find(".bb-rl-modal-activity-footer"),a=t.find(".activity-item").data("bp-activity-id"),i=t.find("#ac-form-"+a),i=(i.length&&bp.Nouveau.Activity.reinitializeActivityCommentForm(i),_.isUndefined(u)||_.isUndefined(u.emoji)||bp.Nouveau.Activity.initializeEmojioneArea(!1,"",a),a&&bp.Nouveau.Activity.cleanupEmojiEventHandlers(a),k(".bb-rl-emojionearea-theatre"));i.length&&(i.find(".emojionearea-picker").remove(),i.removeClass("show hide").addClass("hide")),t.find("#bb-rl-activity-modal").removeClass("bb-closed-comments"),t.closest("body").removeClass("acomments-modal-open"),t.hide(),t.find("ul.bb-rl-activity-list").empty(),e.removeClass("active"),e.find("form.ac-form").remove(),k("li#bb-rl-activity-"+a).removeClass("has-comments")},scopeLoaded:function(t,a){this.current_page=1;var i=k("#buddypress #bb-rl-activity-stream");"mentions"===a.scope&&void 0!==a.response.new_mentions?(k.each(a.response.new_mentions,function(t,e){i.find('[data-bp-activity-id="'+e+'"]').addClass("newest_mentions_activity")}),this.mentions_count=0):void 0!==this.heartbeat_data.highlights[a.scope]&&this.heartbeat_data.highlights[a.scope].length&&k.each(this.heartbeat_data.highlights[a.scope],function(t,e){i.find('[data-bp-activity-id="'+e+'"]').length&&i.find('[data-bp-activity-id="'+e+'"]').addClass("newest_"+a.scope+"_activity")}),this.heartbeat_data.newest="",k.each(k(bp.Nouveau.objectNavParent+" [data-bp-scope]").find("a span"),function(t,e){"0"===k(e).html()&&k(e).html("")}),void 0!==this.heartbeat_data.highlights[a.scope]&&(this.heartbeat_data.highlights[a.scope]=[]),k(document).prop("title",this.heartbeat_data.document_title),setTimeout(function(){k("#buddypress #bb-rl-activity-stream .activity-item").removeClass("newest_"+a.scope+"_activity")},3e3),setTimeout(function(){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media.autoPlayGifVideos&&bp.Nouveau.Media.autoPlayGifVideos()},200),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 t,e;!_.isUndefined(P.params.is_activity_edit)&&0 ul").html())||a.hasClass("acomment-reply")||a.parent().hasClass("acomment-reply")||a.hasClass("acomment-edit"))&&r.displayingTheCommentForm({event:t,target:a,activityId:o,isInsideModal:m,isInsideMediaTheatre:b,self:r}),a.hasClass("activity-state-no-comments")&&t.preventDefault(),a.hasClass("ac-reply-cancel")&&((c=k(a).closest(".ac-form")).addClass("not-initialized"),k(".acomment-reply").attr("aria-expanded","false"),["media","document"].forEach(function(t){r.destroyUploader(t,o)}),c.closest("li.comment-item").length?r.activityRootComment(t):r.resetActivityCommentForm(c,"hardReset"),t.preventDefault()),"ac_form_submit"===a.prop("name")){if(a.prop("disabled"))return void t.preventDefault();r.submitActivityComment({event:t,parent:e,target:a,activityId:o,isInsideModal:m,activityState:n,commentsText:d,activityItem:i,self:r})}a.hasClass("edit")&&a.hasClass("edit-activity")&&(t.preventDefault(),s=i.data("bp-activity"),l=""!==i.data("link-url")?i.data("link-url"):null,void 0!==s)&&(bp.Nouveau.Activity.postForm.displayEditActivityForm(s,l),k("#bb-rl-activity-form").toggleClass("group-activity",a.closest("li").hasClass("groups")),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)&&k(".bb-rl-close-media-theatre, .bb-close-document-theatre").trigger("click"),m&&(a.hasClass("bb-rl-open-media-theatre")||a.hasClass("bb-open-video-theatre")||a.hasClass("bb-rl-open-document-theatre")||a.hasClass("bb-rl-document-detail-wrap-description-popup")||a.hasClass("bb-rl-document-description-wrap"))&&(t.preventDefault(),a.closest("#bb-rl-activity-modal").find(".bb-rl-modal-activity-header .bb-rl-close-action-popup").trigger("click")),(a.hasClass("pin-activity")||a.hasClass("unpin-activity"))&&r.pinUnpinActivity({event:t,activityId:o,parent:e,target:a,isInsideModal:m}),(a.hasClass("bb-icon-bell-slash")||a.hasClass("bb-icon-bell"))&&r.muteUnmuteNotifications({event:t,activityId:o,parent:e,target:a,isInsideModal:m}),(a.hasClass("close-activity-comment")||a.hasClass("unclose-activity-comment"))&&r.onOffComment({event:t,activityId:o,parent:e,target:a,isInsideModal:m})},commentFormAction:function(t){var e,a;return 3===(e=(t=t||window.event).target||t.srcElement).nodeType&&(e=e.parentNode),!0!==t.altKey&&!0!==t.metaKey&&"TEXTAREA"===e.tagName&&k(e).hasClass("ac-input")?void(27===(a=t.keyCode||t.which)&&!1===t.ctrlKey?k(e).closest("form").slideUp(200):t.ctrlKey&&13===a&&k(e).val()&&k(e).closest("form").find("[type=submit]").first().trigger("click")):t},togglePopupDropdown:function(t){var e;return 3===(e=(t=t||window.event).target||t.srcElement).nodeType&&(e=e.parentNode),!0===t.altKey||!0===t.metaKey||k(e).closest(".privacy-wrap").length?t:void k("ul.activity-privacy").removeClass("bb-open")},loadMoreActivities:function(){var t,e=k(".bb-rl-load-more:visible").last(),a=k(window);0!==e.length&&e.closest(".bb-rl-activity-list").length&&!0!==e.data("bp-autoloaded")&&(t=e.offset().top-50,a.scrollTop()+a.height()>t)&&(e.data("bp-autoloaded",1),e.find("a").text(P.strings.loadingMore),e.find("a").trigger("click"))},openCommentsMediaUploader:function(t){var e,a,i=this,o=k(t.currentTarget),s=o.data("ac-id"),s=o.closest(".bb-rl-ac-form-container").find("#bb-rl-ac-reply-post-media-uploader-"+s),n=0 /gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," "),a=t.text().trim(),t=t.closest("form");""!==a||0<=e.indexOf("emojioneemoji")||t.hasClass("acomment-edit")?t.addClass("has-content"):t.removeClass("has-content")},ReactionStatePopupTab:function(t){t.preventDefault();t=k(this).closest(".activity-state-popup");t.find(".activity-state-popup_tab_panel li a").removeClass("active"),k(this).addClass("active"),t.find(".activity-state-popup_tab_content .activity-state-popup_tab_item").removeClass("active"),t.find("."+k(this).data("tab")).addClass("active")},closeActivityState:function(){k(".activity-state-popup").hide().removeClass("active")},listenCommentInput:function(t){var e,a;0 /gi,"\n").replace(/<\/div>/gi,""));e=e.replace(/ /g," "),""!==k(t.currentTarget).text().trim()||0<=e.indexOf("emojioneemoji")?k(t.currentTarget).closest("form").addClass("has-content"):k(t.currentTarget).closest("form").removeClass("has-content")}),k(t).closest("form").addClass("events-initiated"),this.InitiatedCommentForms.push(e)))},activityRootComment:function(t){var t=k(t.currentTarget).closest("#bb-rl-activity-modal"),e=t.find(".activity-item").data("bp-activity-id"),a=t.find("#ac-form-"+e);bp.Nouveau.Activity.resetActivityCommentForm(a,"hardReset"),t.find(".bb-rl-acomment-display").removeClass("bb-rl-display-focus"),t.find(".comment-item").removeClass("bb-rl-comment-item-focus"),t.find(".bb-rl-modal-activity-footer").addClass("active").append(a),a.addClass("root"),a.find("#ac-input-"+e).focus(),a.find(".bb-rl-ac-reply-content .ac-input").attr("data-placeholder",P.strings.commentPlaceholder),a.find('input[name="ac_form_submit"]').val(P.strings.commentButtonText),bp.Nouveau.Activity.clearFeedbackNotice(a)},clearFeedbackNotice:function(t){t=t.find(".bb-rl-ac-form-container .bp-feedback");t.length&&t.remove()},launchActivityPopup:function(t,e){var a=k("#bb-rl-activity-"+t),i=k(".bb-rl-activity-model-wrapper"),o=a[0].outerHTML,e='[data-parent_comment_id="'+e+'"]',s=a.data("activity-popup-title");bp.Nouveau.Activity.activityHasUpdates=!1,bp.Nouveau.Activity.currentActivityId=null,bp.Nouveau.Activity.activityPinHasUpdates=!1,i.closest("body").addClass("acomments-modal-open"),i.show(),i.find("ul.bb-rl-activity-list").html(o),i.find(".bb-rl-modal-activity-header h2").text(s),0 =t.prop("scrollHeight")?i.addClass("bb-rl-modal-activity-body-scrolled-to-bottom"):i.removeClass("bb-rl-modal-activity-body-scrolled-to-bottom")}),i.find(".bb-rl-modal-activity-body").addClass("bb-rl-modal-activity-body-scroll-event-initiated"))},initialLoadComment:function(t){this.loadMoreComments({target:t.modal.find(".bb-rl-activity-comments"),activityId:t.activityID,parentCommentId:t.parentID||0,isModal:!0})},viewMoreComments:function(t){t.preventDefault();var t=k(t.currentTarget),e=t.parent();this.loadMoreComments({target:t,currentTargetList:t.parent(),activityId:k(e).data("activity_id"),commentsList:t.closest(".bb-rl-activity-comments"),commentsActivityItem:t.closest(".activity-item"),parentCommentId:k(e).data("parent_comment_id"),lastCommentTimestamp:t.prev("li.activity-comment").data("bp-timestamp"),addAfterListItemId:"",lastCommentId:t.prev("li.activity-comment").data("bp-activity-comment-id"),isModal:!1})},autoloadMoreComments:function(){var t,e,a,i,o=k(".bb-rl-activity-model-wrapper");0 ul > li.acomments-view-more:not(.loading), .bb-rl-modal-activity-body .bb-rl-activity-comments .activity-actions > ul > li.acomments-view-more:not(.loading)"),i=(o=o.find(".bb-rl-modal-activity-body")).find(".bb-rl-activity-comments:not(.active)"),0 e&&k(t).trigger("click").addClass("loading"),setTimeout(function(){jQuery(window).scroll()},200))},activitySyncOnModalClose:function(t,e){t.preventDefault();var t=k(t.currentTarget),t=t.is(document)?k(".bb-rl-activity-model-wrapper"):t.parents(".bb-rl-activity-model-wrapper"),t=t.find("ul.bb-rl-activity-list > li").data("bp-activity-id"),e=void 0!==e?e:t,a=k("#bb-rl-activity-stream li.activity-item[data-bp-activity-id="+e+"]");0 /gi,"\n").replace(/<\/div>/gi,""));e=e.replace(/ /g," "),""!==t.text()||0<=e.indexOf("emojioneemoji")?t.closest("form").addClass("has-content"):t.closest("form").removeClass("has-content")},picker_show:function(){k(this.button[0]).closest(".bb-rl-post-emoji").addClass("active"),k(".bb-rl-emojionearea-theatre").removeClass("hide").addClass("show")},picker_hide:function(){k(this.button[0]).closest(".bb-rl-post-emoji").removeClass("active"),k(".bb-rl-emojionearea-theatre").removeClass("show").addClass("hide")}}}),t&&((e=(e=k(s).closest(".modal, .bb-modal, .bb-rl-modal, .activity-modal, .activity-theatre, .bb-rl-screen-content")).length?e:k(s)).on("click"+(t=".bb-rl-emoji-"+n),"#bb-rl-ac-reply-emoji-button-"+n,function(e){var t,a,i,o;k(e.target).closest(".emojionearea-button").length||(t=k(s+"#ac-input-"+n).data("emojioneArea"))&&(i=(a=k(".bb-rl-emojionearea-theatre")).find(".emojionearea-picker"),a.hasClass("show")&&!i.hasClass("hidden")?(t.hidePicker(),a.removeClass("show").addClass("hide"),i.addClass("hidden")):(1<(i=a.find(".emojionearea-picker")).length&&i.remove(),t.showPicker(),a.removeClass("hide").addClass("show"),(o=a.find(".emojionearea-picker")).addClass("hidden"),setTimeout(function(){var t=e.clientX;o.length&&(o.css("transform","translate("+(t+30)+"px, "+(e.clientY-20)+"px) translate(-100%, -100%)"),o.removeClass("hidden"))},50)))}),e.data("emoji-event-namespace-"+n,t)))},cleanupEmojiEventHandlers:function(a){k(".modal, .bb-modal, .bb-rl-modal, .activity-modal, .activity-theatre, .bb-rl-screen-content").each(function(){var t=k(this),e=t.data("emoji-event-namespace-"+a);e&&(t.off(e),t.removeData("emoji-event-namespace-"+a))})},destroyUploader:function(t,e){var a,i=this,i={media:{obj:i.dropzone_obj,dropzone:i.dropzone_media,uploaderId:"#bb-rl-ac-reply-post-media-uploader-",buttonId:"#bb-rl-ac-reply-media-button-",additionalIds:["#bb-rl-ac-reply-post-media-uploader-1-"]},document:{obj:i.dropzone_document_obj,dropzone:i.dropzone_document,uploaderId:"#bb-rl-ac-reply-post-document-uploader-",buttonId:"#bb-rl-ac-reply-document-button-"},video:{obj:i.dropzone_video_obj,dropzone:i.dropzone_video,uploaderId:"#bb-rl-ac-reply-post-video-uploader-",buttonId:"#bb-rl-ac-reply-video-button-"},gif:{buttonId:"#bb-rl-ac-reply-gif-button-",dropdownClass:".bb-rl-gif-media-search-dropdown",standaloneClass:".bb-rl-gif-media-search-dropdown-standalone",modelProperty:"gif_data",containerId:"#bb-rl-ac-reply-post-gif-"}}[t];i&&("gif"!==t&&(a=i.obj,_.isNull(a)||(a.destroy(),k(i.uploaderId+e).html(""),i.additionalIds&&i.additionalIds.forEach(function(t){k(t+e).html("")})),i.dropzone=[],k(i.uploaderId+e).removeClass("open").addClass("closed")),k(i.buttonId+e).removeClass("active"),"gif"===t)&&(k(i.buttonId+e).closest(".bb-rl-post-gif").find(i.dropdownClass).removeClass("open").empty(),k(i.standaloneClass).removeClass("open").empty(),_.isUndefined(this.models[e])||(this.models[e].set(i.modelProperty,{}),k(i.containerId+e).find(".bb-rl-activity-attached-gif-container").removeAttr("style")))},handleFavoriteUnfavorite:function(t){var e,i,o,s,a=t.event,n=(a.preventDefault(),t.parent),d=t.target,l=t.reactionId,r=t.activityState,c=t.bodyElem,m=t.stream,b=t.activityItem;c.hasClass("bb-is-mobile")&&c.hasClass("bb-reactions-mode")&&0===d.closest(".ac-emotion_btn").length&&!0!==a.customTriggered||(d=k(d).is("a")?d:k(d).closest("a")).hasClass("loading")||(d.addClass("loading"),e=d.hasClass("fav")?"fav":"unfav",i=!0,t="activity",c=d.parents(".bb-rl-acomment-display").first(),a=d.attr("data-reacted-id"),0 .bb-rl-activity-content":".activity-comment[data-bp-activity-comment-id="+s+"] > .bb-rl-acomment-display > .bb-rl-acomment_inner").find(".activity-state-reactions").parent().addClass("bb-has-reaction_update"),"fav"===e?void 0===a.data.directory_tab||""===a.data.directory_tab||k(n.objectNavParent+' [data-bp-scope="favorites"]').length||k(n.objectNavParent+' [data-bp-scope="all"]').after(a.data.directory_tab):"unfav"===e&&((t=k('[data-bp-user-scope="favorites"]').hasClass("selected")||k(n.objectNavParent+' [data-bp-scope="favorites"]').hasClass("selected"))&&b.remove(),void 0!==a.data.no_favorite)&&(k(n.objectNavParent+' [data-bp-scope="all"]').length&&k(n.objectNavParent+' [data-bp-scope="all"]').hasClass("selected")?k(n.objectNavParent+' [data-bp-scope="favorites"]').remove():t&&m.append(a.data.no_favorite)))}).fail(function(){d.removeClass("loading")})))},deleteActivity:function(t){t.event.preventDefault();var b,p,v,u=t.parent,y=t.target,h=t.activityState,f=t.activityItem,g=t.commentsText,_=t.activityId,C=y.closest("[data-bp-activity-comment-id]"),w=C.data("bp-activity-comment-id"),N=0,j=y.closest(".bb-rl-activity-comments");if(j.addClass("active"),void 0!==a&&!1===window.confirm(a))return!1;y.addClass("loading");var A={action:"delete_activity",id:_,_wpnonce:u.getLinkParams(y.prop("href"),"_wpnonce"),is_single:y.closest("[data-bp-single]").length};(y.hasClass("spam-activity")||y.hasClass("spam-activity-comment"))&&(A.action="bp_spam_activity"),b=f,w&&(delete A.is_single,A.id=w,A.is_comment=!0,b=C),u.ajax(A,"activity").done(function(t){if(y.removeClass("loading"),!1===t.success)b.append(t.data.feedback),b.find(".bp-feedback").hide().fadeIn(300);else{var e,a=b.closest(".has-child-comments"),i=(b.hasClass("has-child-comments")&&(e=b.closest("ul").closest("li")),a.find("> ul"));if(t.data.redirect)return window.location.href=t.data.redirect;if(t.data.parent_activity_id&&t.data.activity&&k("body:not(.activity-singular) #buddypress #bb-rl-activity-stream ul.bb-rl-activity-list li#bb-rl-activity-"+t.data.parent_activity_id).replaceWith(t.data.activity),w){N=1;for(var o=C.find(".acomments-view-more").data("child-count"),o=(f.append(C.find("form")),C.find("li.comment-item").each(function(){N+=1}),N+=void 0!==o?parseFloat(o):0,v=h.find("span.comments-count"),p=v.text().length?v.text().match(/\d+/)[0]:0,p=Number(p-N),g.length?(o=1 ul")).length&&(t=t.html())&&""===t.trim()&&e.removeClass("has-child-comments")}),w||f.data("bp-timestamp")!==u.Activity.heartbeat_data.last_recorded||(u.Activity.heartbeat_data.newest="",u.Activity.heartbeat_data.last_recorded=0),k(document).trigger("bp_activity_ajax_delete_request",k.extend(A,{response:t})),k(document).trigger("bp_activity_ajax_delete_request_video",k.extend(A,{response:t})),bp.Nouveau.Activity.activityHasUpdates=!0,bp.Nouveau.Activity.currentActivityId=_}j.removeClass("active")})},readMoreActivity:function(t){var e=t.event,a=(e.preventDefault(),t.target),i=null,o=t.activityId,s=a.closest("div");if(k(s).hasClass("bb-rl-activity-inner")?i=o:k(s).hasClass("bb-rl-acomment-content")&&(i=a.closest("li").data("bp-activity-comment-id")),!i)return e;var o=t.parent,n=t.activityItem,d=a.closest("span");k(d).addClass("loading"),o.ajax({action:"get_single_activity_content",id:i},"activity").done(function(t){"object"!=typeof t&&0
").removeClass("acomments-view-more--hide"),o.isModal||(o.commentsList.removeClass("active"),o.commentsActivityItem.removeClass("active"))):void 0!==t.data&&void 0!==t.data.comments&&((i=s.closest(".activity-item")).hasClass("has-comments")||i.addClass("has-comments"),i=k(".bb-rl-internal-model .bb-rl-activity-comments"),e=o.isModal?i:i.find("[data-activity_id='"+o.activityId+"'][data-parent_comment_id='"+o.parentCommentId+"']"),i=k(k.parseHTML(t.data.comments)),0ul li.comment-item").length+1&&(c=d.parent().closest("li.comment-item")).length?c:d:p.find('[data-bp-activity-comment-id="'+m+'"]'),a&&b.removeClass("active"),r.append(e))),t=e.find('input[name="ac_form_submit"]'),c=!1,(0 @'+c+" "),p=_.isUndefined(P.params.user_id)?"":P.params.user_id,b={offset:-(k(window).height()/2-75),easing:"swing"},l=m.get(0),jQuery("body").hasClass("bb-is-mobile")?setTimeout(function(){var t,e,a=300 /gi,"\n").replace(/<\/div>/gi,"")),I={action:"new_activity_comment",_wpnonce_new_activity_comment:k("#_wpnonce_new_activity_comment").val(),comment_id:A,form_id:y,content:e},t=k("#_bp_as_nonce_"+y).val(),T=(t&&(I["_bp_as_nonce_"+y]=t),this.dropzone_media.length&&(I.media=this.dropzone_media),this.dropzone_document.length&&(I.document=this.dropzone_document),this.dropzone_video.length&&(I.video=this.dropzone_video,_.isEmpty(I.content))&&(I.content=""),_.isUndefined(this.models[y])||(p=this.models[y],I.gif_data=this.models[y].get("gif_data")),I.content=I.content.replace(/ /g," "),j.hasClass("acomment-edit")&&(I.edit_comment=!0),0 "),(T?j.closest("#bb-rl-activity-modal").find(".bb-rl-modal-activity-body .bb-rl-activity-comments, .bb-rl-modal-activity-body .bb-rl-activity-comments .activity-actions"):e).children("ul").append(k(s).hide().fadeIn(200)),k(j).find(".ac-input").first().html(""),e.parent().addClass("has-comments comments-loaded"),f.addClass("has-comments")),j.removeClass("acomment-edit"),j.find(".bb-rl-ac-reply-content"));if([".bb-rl-ac-reply-media-button",".bb-rl-ac-reply-document-button",".bb-rl-ac-reply-video-button",".bb-rl-ac-reply-gif-button"].forEach(function(t){var e=n.find(".bb-rl-ac-reply-toolbar "+t);0 '+P.strings.replyLabel.replace("%d",1)+""),d.addClass("has-child-comments"),d=d.parent().closest(".activity-comment")}i.parent(":not( .has-comments )").addClass("has-comments");s=k(C).find(".show-all a");s&&s.html(M.replace("%d",t))}[w.dropzone_media,w.dropzone_document,w.dropzone_video].forEach(function(t){t&&0 '+t+"")})},pinUnpinActivity:function(t){var e=t.event,a=t.activityId;if(e.preventDefault(),!a)return e;var e=t.parent,l=t.target,r=t.isInsideModal,c=l.closest(".activity-item"),m=(c.addClass("loading-pin"),l.hasClass("unpin-activity")?"unpin":"pin");e.ajax({action:"activity_update_pinned_post",id:a,pin_action:m},"activity").done(function(t){var e,a,i,o,s,n,d;c.removeClass("loading-pin"),void 0!==(t="object"!=typeof t?JSON.parse(t):t).data&&void 0!==t.data.feedback&&(e=l.closest("ul.bb-rl-activity-list"),d=r?l.closest(".bb-rl-wrap").find("#bb-rl-activity-stream"):l.closest("#bb-rl-activity-stream"),t.success&&((""===(n=bp.Nouveau.getStorage("bp-activity","scope"))||!1===n||"undefined"!==BP_Nouveau.is_send_ajax_request&&""===BP_Nouveau.is_send_ajax_request)&&k(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").length&&(n=k(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").data("bp-scope")),a=!1,o="",(i=c.hasClass("groups"))&&(o=(s=c.attr("class").match(/group-\d+/))?s[0].replace("group-",""):""),d.hasClass("single-user")?a=!1:(d.hasClass("activity")&&"all"===n&&!i||d.hasClass("single-group"))&&(a=!0),"pin"==m?(a&&e.find("li.activity-item").removeClass("bb-pinned"),s=i&&!d.hasClass("single-group")?"li.activity-item.group-"+o:"li.activity-item",e.find(s).each(function(){var t=k(this).find(".unpin-activity"),e=(t.removeClass("unpin-activity").addClass("pin-activity"),i?P.strings.pinGroupPost:P.strings.pinPost);t.find("span").html(e)}),a&&c.addClass("bb-pinned"),l.addClass("unpin-activity").removeClass("pin-activity"),n=i?P.strings.unpinGroupPost:P.strings.unpinPost,l.find("span").html(n)):"unpin"==m&&(c.removeClass("bb-pinned"),l.addClass("pin-activity").removeClass("unpin-activity"),d=i?P.strings.pinGroupPost:P.strings.pinPost,l.find("span").html(d)),a)&&(bp.Nouveau.Activity.heartbeat_data.last_recorded=0,bp.Nouveau.refreshActivities()),k(document).trigger("bb_trigger_toast_message",[""," "+t.data.feedback+"","success",null,!0]),r)&&(void 0!==bp.Nouveau.Activity.activityHasUpdates&&(bp.Nouveau.Activity.activityHasUpdates=!0),void 0!==bp.Nouveau.Activity.activityPinHasUpdates)&&(bp.Nouveau.Activity.activityPinHasUpdates=!0)}).fail(function(){l.closest(".activity-item").removeClass("loading-pin"),k(document).trigger("bb_trigger_toast_message",["",""+P.strings.pinPostError+"","error",null,!0])})},muteUnmuteNotifications:function(t){var e=t.event,a=t.parent,i=t.target,o=t.activityId,s=t.isInsideModal;if(i.hasClass("bb-icon-bell-slash")||i.hasClass("bb-icon-bell")){if(e.preventDefault(),!o)return e;var n=i.closest(".activity-item"),d=(n.addClass("loading-mute"),i.hasClass("bb-icon-bell")?"unmute":"mute");a.ajax({action:"toggle_activity_notification_status",id:o,notification_toggle_action:d},"activity").done(function(t){var e;n.removeClass("loading-mute"),void 0!==(t="object"!=typeof t?JSON.parse(t):t).data&&void 0!==t.data.feedback&&(t.success&&("mute"==d?(e=P.strings.unmuteNotification,n.addClass("bb-muted"),i.removeClass("bb-icon-bell-slash"),i.addClass("bb-icon-bell"),i.attr("title",e),i.find("span").html(e)):"unmute"==d&&(e=P.strings.muteNotification,n.removeClass("bb-muted"),i.removeClass("bb-icon-bell"),i.addClass("bb-icon-bell-slash"),i.attr("title",e),i.find("span").html(e)),void 0!==bp.Nouveau.Activity.activityHasUpdates)&&(bp.Nouveau.Activity.activityHasUpdates=!0),k(document).trigger("bb_trigger_toast_message",["",""+t.data.feedback+"","success",null,!0])),s&&(bp.Nouveau.Activity.activityPinHasUpdates=!0),bp.Nouveau.Activity.activityHasUpdates=!0,bp.Nouveau.Activity.currentActivityId=o}).fail(function(){i.closest(".activity-item").removeClass("loading-pin"),k(document).trigger("bb_trigger_toast_message",["",""+P.strings.pinPostError+"","error",null,!0])})}},onOffComment:function(t){var e=t.event,a=t.target,i=t.parent,o=t.activityId;if(e.preventDefault(),!o)return e;var s=a.closest(".activity-item"),n=(s.addClass("loading-pin"),a.hasClass("unclose-activity-comment")?"unclose_comments":"close_comments");i.ajax({action:"activity_update_close_comments",id:o,close_comments_action:n},"activity").done(function(t){var e;s.removeClass("loading-pin"),void 0!==(t="object"!=typeof t?JSON.parse(t):t).data&&void 0!==t.data.feedback&&(t.success&&(e=k("#bb-rl-activity-stream > .bb-rl-activity-list").find("[data-bp-activity-id="+o+"]"),s.find(".bb-rl-activity-closed-comments-notice").remove(),"close_comments"==n?(s.addClass("bb-closed-comments"),0'+t.data.feedback+""),0 '+t.data.feedback+""))):"unclose_comments"==n&&(s.find(".edit-activity, .acomment-edit").parents(".generic-button").show(),s.removeClass("bb-closed-comments"),0 "+t.data.feedback+"",t.success?"success":"error",null,!0]))}).fail(function(){a.closest(".activity-item").removeClass("loading-pin"),k(document).trigger("bb_trigger_toast_message",[""," "+P.strings.closeCommentsError+"","error",null,!0])})},setupDropzoneEventHandlers:function(t){var o=t.self,c=t.dropzoneObj,s=t.target,m=t.type,b=t.dropzoneDataObj;c.on("addedfile",function(t){var e;t[m+"_edit_data"]&&(b.push(t[m+"_edit_data"]),"document"===m&&(e=(e=t.upload.filename).substr(e.lastIndexOf(".")+1),k(t.previewElement).find(".dz-details .dz-icon .bb-icon-file").removeClass("bb-icon-file").addClass("bb-icon-file-"+e)),(e=s.parents(".bb-rl-ac-reply-toolbar")).find(".bb-rl-ac-reply-"+m+"-button"))&&e.find(".bb-rl-ac-reply-"+m+"-button").parents(".bb-rl-post-elements-buttons-item").addClass("no-click").find(".toolbar-button").addClass("active"),"video"===m&&(t.dataURL&&t.video_edit_data.thumb.length?(k(t.previewElement).find(".dz-image").prepend(''),k(t.previewElement).closest(".dz-preview").addClass("dz-has-thumbnail")):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(t,".dz-image"))}),c.on("sending",function(t,e,a){a.append("action","document"===m?m+"_"+m+"_upload":m+"_upload");var i="document"===m?"media":m,o=(a.append("_wpnonce",BP_Nouveau.nonces[i]),s.parents(".bb-rl-ac-reply-toolbar"));s.closest(".ac-form").addClass("has-media"),["media","document","video","gif"].forEach(function(t){var e;o.find(".bb-rl-ac-reply-"+t+"-button")&&(e=o.find(".bb-rl-ac-reply-"+t+"-button").parents(".bb-rl-post-elements-buttons-item"),m===t?e.addClass("no-click").find(".toolbar-button").addClass("active"):e.addClass("disable"))}),this.element.classList.remove("files-uploaded")}),c.on("uploadprogress",function(t){s.closest(".ac-form").addClass("media-uploading");var e=k(t.previewElement).find(".dz-progress-ring circle")[0],a=2*e.r.baseVal.value*Math.PI;e.style.strokeDasharray=a+" "+a,e.style.strokeDashoffset=a-t.upload.progress.toFixed(0)/100*a,k(t.previewElement).find(".dz-progress [data-dz-progress]").text(t.upload.progress.toFixed(0)+"%")}),c.on("success",function(t,e){var a,i;if("document"===m&&(a=(a=t.upload.filename).substr(a.lastIndexOf(".")+1),i=_.isUndefined(e.data.svg_icon)?"":e.data.svg_icon,a=_.isEmpty(i)?"bb-icon-file-"+a:i,k(t.previewElement).find(".dz-details .dz-icon .bb-icons-rl-file").length)&&k(t.previewElement).find(".dz-details .dz-icon .bb-icons-rl-file").removeClass("bb-icons-rl-file").addClass(a),e.data.id)return t.id=e.id,e.data.uuid=t.upload.uuid,e.data.menu_order=k(t.previewElement).closest(".dropzone").find(t.previewElement).index()-1,i="document"===m?"media":m,e.data.album_id=void 0!==BP_Nouveau[i]&&void 0!==BP_Nouveau[i].album_id&&BP_Nouveau[i].album_id,e.data.group_id=void 0!==BP_Nouveau[i]&&void 0!==BP_Nouveau[i].group_id&&BP_Nouveau[i].group_id,e.data.saved=!1,b.push(e.data),t.previewElement.classList.add("dz-success");var o,s,n,d,l,r=e.data.feedback;for(t.previewElement.classList.add("dz-error"),l=[],s=0,n=(d=t.previewElement.querySelectorAll("[data-dz-errormessage]")).length;s
'+e+""),this.removeFile(t),a.removeClass("media-uploading"))}),c.on("removedfile",function(t){if(b.length)for(var e in b)if(t.upload.uuid===b[e].uuid){void 0===b[e].saved||b[e].saved||bp.Nouveau.Media.removeAttachment(b[e].id),b.splice(e,1);break}var a,i;_.isNull(c)||_.isNull(c.files)||0!==c.files.length?s.closest(".ac-form").addClass("has-content"):(a=s.parents(".bb-rl-ac-reply-toolbar"),(i=s.closest(".ac-form")).removeClass("has-media"),["media","document","video","gif"].forEach(function(t){var e;a.find(".bb-rl-ac-reply-"+t+"-button")&&(e=a.find(".bb-rl-ac-reply-"+t+"-button").parents(".bb-rl-post-elements-buttons-item"),m===t?e.removeClass("no-click").find(".toolbar-button").removeClass("active"):e.removeClass("disable"))}),k(c.element).removeClass("files-uploaded dz-progress-view").find(".dz-global-progress").remove(),o.validateCommentContent(i.find(".ac-textarea").children(".ac-input")))}),c.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 '),{action:o.isModal?"bb_rl_activity_loadmore_comments":"activity_loadmore_comments",activity_id:o.activityId,parent_comment_id:o.parentCommentId,offset:o.isModal?0:s.parents(".bb-rl-activity-comments").find('ul[data-parent_comment_id ="'+o.parentCommentId+'"] > li.comment-item:not(.bb-recent-comment)').length,activity_type_is_blog:1"+t.data.message+" "+t.statusText+" li.bb-edit-privacy a",bp.Nouveau,this.activityPrivacyRedirect.bind(this)),a.find(n).on("click",".activity-privacy>li:not(.bb-edit-privacy)",bp.Nouveau,this.activityPrivacyChange.bind(this)),a.find(n).on("click","span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),k("#bb-rl-media-model-container .bb-rl-activity-list").on("click",".activity-item",bp.Nouveau,this.activityActions.bind(this)),k(".bb-rl-activity-model-wrapper").on("click",".bb-rl-ac-form-placeholder",bp.Nouveau,this.activityRootComment.bind(this)),i.keydown(this.commentFormAction),i.click(this.togglePopupDropdown),k('#buddypress [data-bp-list="activity"], #bb-rl-media-model-container .bb-rl-activity-list, #activity-modal .bb-rl-activity-list, .bb-rl-modal-activity-footer').on("click",".ac-reply-media-button",this.openCommentsMediaUploader.bind(this)),a.find('[data-bp-list="activity"], #bb-rl-media-model-container .bb-rl-activity-list, #bb-rl-activity-modal .bb-rl-activity-list, .bb-rl-modal-activity-footer').on("click",".bb-rl-ac-reply-media-button, .bb-rl-ac-reply-document-button, .bb-rl-ac-reply-video-button, .bb-rl-ac-reply-gif-button",function(t){var e=k(t.currentTarget);e.hasClass("bb-rl-ac-reply-media-button")?this.openCommentsMediaUploader(t):e.hasClass("bb-rl-ac-reply-document-button")?this.openCommentsDocumentUploader(t):e.hasClass("bb-rl-ac-reply-video-button")?this.openCommentsVideoUploader(t):e.hasClass("bb-rl-ac-reply-gif-button")&&this.openGifPicker(t)}.bind(this)),i.on("click",".activity-state-popup_overlay",bp.Nouveau,this.closeActivityState.bind(this)),i.on("click",".activity-state-popup .activity-state-popup_tab_panel a",this.ReactionStatePopupTab),_.isUndefined(P.params.autoload)||k(window).scroll(this.loadMoreActivities),k(document).on("click",".bb-subnav-filters-container .subnav-filters-opener",this.openActivityFilter.bind(this)),k(document).on("click",this.closeActivityFilter.bind(this)),k(document).on("click",".bb-subnav-filters-container .subnav-filters-modal a",this.filterActivity.bind(this)),k(".bb-rl-activity-model-wrapper, .bb-rl-media-model-wrapper").on("click",".acomments-view-more",this.viewMoreComments.bind(this)),i.on("click","#bb-rl-activity-stream .bb-rl-activity-comments .view-more-comments",function(t){t.preventDefault(),k(this).parents("li.activity-item").find(".bb-rl-activity-comments > ul > li.acomments-view-more, .bb-rl-activity-comments > .activity-actions > ul > li.acomments-view-more").trigger("click")}),i.on("click","#bb-rl-activity-stream .activity-state-comments > .comments-count, #bb-rl-activity-stream .groups-meta > .generic-button .acomment-reply, #bb-rl-activity-stream .activity-meta > .generic-button .acomment-reply",function(t){t.preventDefault();var t=k(this).closest(".activity-item"),e=t.data("bp-activity-id");""===t.find(".bb-rl-activity-comments > ul").html()&&bp.Nouveau.Activity.launchActivityPopup(e,"")}),o.on("scroll",this.autoloadMoreComments.bind(this)),o.on("scroll",this.discardGifEmojiPicker.bind(this)),k(".bb-rl-activity-model-wrapper .bb-rl-model-close-button").on("click",this.activitySyncOnModalClose.bind(this)),e.hasClass("activity-permalink"));"1"===d?a.on("bp_ajax_request",'[data-bp-list="activity"]',function(){setTimeout(t,1e3)}):setTimeout(t,1e3),bp.Nouveau.wrapNavigation(".activity-topic-selector ul",120,!0)},openActivityFilter:function(t){t.preventDefault(),k(".bb-subnav-filters-container:not(.bb-subnav-filters-search)").removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false");t=k(t.currentTarget).parent(".bb-subnav-filters-container");t.addClass("active").find(".subnav-filters-opener").attr("aria-expanded","true"),t.find('input[type="search"]').length&&t.find('input[type="search"]').focus()},closeActivityFilter:function(t){k(t.target).closest(".bb-subnav-filters-container").length||k.each(k(".bb-subnav-filters-container"),function(){(!k(this).hasClass("bb-subnav-filters-search")||""===k(this).find('input[name="activity_search"]').val())&&k(this).removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false")})},filterActivity:function(t){t.preventDefault();var t=k(t.currentTarget),e=t.closest(".bb-subnav-filters-container"),a=(t.parent().addClass("selected").siblings().removeClass("selected"),e.removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false"),t.parent().data("filter-label")),e=(e.find(".subnav-filters-opener .selected").text(a||t.text()),bp.Nouveau.Activity.current_page=1,bp.Nouveau.objectNavParent),a="activity",i=k("#buddypress").find('[data-bp-filter="'+a+'"]').first().val(),o="",n="",s="",d="",l=!1,r=!1,c=(k(e+" [data-bp-object].selected").length&&(o=k(e+" [data-bp-object].selected").data("bp-scope"),t.closest("#bb-subnav-filter-show").length)&&(l=!0,k("body").hasClass("my-activity"))&&(r=!(l=!1)),k('#buddypress [data-bp-search="'+a+'"] input[type=search]')),c=(c.length&&(n=c.val()),k(e+" [data-bp-order]").length&&(s=k(e+' [data-bp-order="'+a+'"].selected').data("bp-orderby")),bp.Nouveau.getStorage("bp-"+a)),e=(void 0!==c.extras&&(d=c.extras),bp.Nouveau.Activity.heartbeat_data.last_recorded=0,{object:a,scope:o,filter:i,search_terms:n,extras:d,order_by:s,save_scope:l,event_element:t});r&&(e.user_timeline=!0),bp.Nouveau.objectRequest(e)},heartbeatSend:function(t,e){var a,i=k("#buddypress [data-bp-list] [data-bp-activity-id]"),o=i.not(".bb-pinned").first(),n=(this.heartbeat_data.first_recorded=o.data("bp-timestamp")||0,k(bp.Nouveau.objectNavParent+" [data-bp-orderby=date_updated].selected").length?void 0!==(o=k("#buddypress [data-bp-list] [data-bp-activity-id]:not(.bb-pinned)").first()).data("bb-updated-timestamp")?this.heartbeat_data.first_recorded=o.data("bb-updated-timestamp"):o.length&&void 0!==o.data("bp-activity").date_updated&&""!==o.data("bp-activity").date_updated?(n=o.data("bp-activity").date_updated,n=new Date(n.replace(" ","T")+"Z"),this.heartbeat_data.first_recorded=n.getTime()/1e3):this.heartbeat_data.first_recorded=o.data("bp-timestamp")||0:this.heartbeat_data.first_recorded=k("#buddypress [data-bp-list] [data-bp-activity-id]:not(.bb-pinned)").first().data("bp-timestamp")||0,i.first().data("bp-timestamp")||0),o=(n>this.heartbeat_data.first_recorded&&(this.heartbeat_data.first_recorded=n),(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),e.bp_activity_last_recorded=this.heartbeat_data.last_recorded,k("#buddypress .activity-head-bar .activity-search input[type=search]"));o.length&&(e.bp_activity_last_recorded_search_terms=o.val()),k.extend(e,{bp_heartbeat:((i=k("body.my-activity:not(.activity-singular)")).length?a=bp.Nouveau.getStorage("bp-user-activity")||{scope:"just-me"}:(a=bp.Nouveau.getStorage("bp-activity")||{scope:"all"},k("body.activity.buddypress.groups.single-item").length&&(a.scope="all")),k(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").length&&(n=k(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").data("bp-scope"),void 0!==a.scope&&a.scope===n||(a.scope=n,"undefined"!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request&&(i.length?bp.Nouveau.setStorage("bp-user-activity","scope",n):bp.Nouveau.setStorage("bp-activity","scope",n)))),k(bp.Nouveau.objectNavParent+" [data-bp-order].selected").length&&(a.order_by=k(bp.Nouveau.objectNavParent+" [data-bp-order].selected").data("bp-orderby")),(i=bp.Nouveau.getStorage("bp-activity","topic_id"))&&(e.bp_heartbeat=e.bp_heartbeat||{},e.bp_heartbeat.topic_id=i),a)})},heartbeatTick:function(t,e){var a,i,o,n=bp.Nouveau.objects,s=bp.Nouveau.getStorage("bp-activity","scope"),d=this,l=bp.Nouveau.getStorage("bp-activity","topic_id");void 0!==e&&e.bp_activity_newest_activities&&(e=e.bp_activity_newest_activities,this.heartbeat_data.newest=k.trim(e.activities)+this.heartbeat_data.newest,this.heartbeat_data.last_recorded=Number(e.last_recorded),e=k(this.heartbeat_data.newest).filter(".activity-item"),l&&(a=(e=e.filter(function(){var t=this.dataset.bpActivity?JSON.parse(this.dataset.bpActivity):null,t=t&&void 0!==t.topic_id?t.topic_id:null;return t&&parseInt(t)===parseInt(l)})).length),a=Number(e.length),n.push("mentions"),"all"===s?(k.each(e,function(t,a){a=k(a),k.each(n,function(t,e){-1!==k.inArray("bp-my-"+e,a.get(0).classList)&&(void 0===d.heartbeat_data.highlights[e]?d.heartbeat_data.highlights[e]=[a.data("bp-activity-id")]:-1===k.inArray(a.data("bp-activity-id"),d.heartbeat_data.highlights[e])&&d.heartbeat_data.highlights[e].push(a.data("bp-activity-id")))})}),i=new RegExp("bp-my-("+n.join("|")+")","g"),this.heartbeat_data.newest=this.heartbeat_data.newest.replace(i,""),k(bp.Nouveau.objectNavParent+' [data-bp-scope="all"]').find("a span").html(a)):(this.heartbeat_data.highlights[s]=[],k.each(e,function(t,e){d.heartbeat_data.highlights[s].push(k(e).data("bp-activity-id"))})),k.each(n,function(t,e){var a;void 0!==d.heartbeat_data.highlights[e]&&d.heartbeat_data.highlights[e].length&&(a=0,"mentions"===e&&(a=d.mentions_count),k(bp.Nouveau.objectNavParent+' [data-bp-scope="'+e+'"]').find("a span").html(Number(d.heartbeat_data.highlights[e].length)+a))}),n.pop(),k(document).prop("title","("+a+") "+this.heartbeat_data.document_title),e=(i=k('#buddypress [data-bp-list="activity"]')).find(".load-newest a"),i.first().hasClass("load-newest")?(o=e.html(),e.html(o.replace(/([0-9]+)/,a))):i.find("ul.bb-rl-activity-list").prepend(' '+r+" ("+a+") "),i.find("li.load-newest").trigger("click"),i.trigger("bp_heartbeat_pending",this.heartbeat_data),void 0!==bp.Nouveau)&&bp.Nouveau.reportPopUp()},injectActivities:function(t){var e,a,i,o,n,s=k("body.my-activity:not(.activity-singular)").length?bp.Nouveau.getStorage("bp-user-activity"):bp.Nouveau.getStorage("bp-activity"),d=s.scope||null,s=s.filter||null;k(t.currentTarget).hasClass("load-newest")?(t.preventDefault(),k(t.currentTarget).remove(),n=k.parseHTML(this.heartbeat_data.newest),k.each(n,function(t,e){"LI"===e.nodeName&&k(e).hasClass("just-posted")&&(e=k("#"+k(e).prop("id"))).length&&e.remove()}),(0<(i=(n=k(t.delegateTarget).find(".bb-rl-activity-list")).find(".activity-item").first()).length&&i.hasClass("bb-pinned")?k(i).after(this.heartbeat_data.newest):n.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"===d&&k(bp.Nouveau.objectNavParent+' [data-bp-scope="all"]').find("a span").html(""),"mentions"===d&&(bp.Nouveau.ajax({action:"activity_clear_new_mentions"},"activity"),this.mentions_count=0),k(bp.Nouveau.objectNavParent+' [data-bp-scope="'+d+'"]').find("a span").html(""),void 0!==this.heartbeat_data.highlights[d]&&(this.heartbeat_data.highlights[d]=[]),setTimeout(function(){k(t.delegateTarget).find("[data-bp-activity-id]").removeClass("newest_"+d+"_activity")},3e3),k(document).prop("title",this.heartbeat_data.document_title),jQuery(window).scroll()):k(t.currentTarget).hasClass("bb-rl-load-more")&&(e=Number(this.current_page)+1,a=this,i="",t.preventDefault(),(o=k(t.currentTarget)).find("a").first().addClass("loading"),this.just_posted=[],k(t.delegateTarget).children(".just-posted").each(function(){a.just_posted.push(k(this).data("bp-activity-id"))}),(n=k("#buddypress .activity-search.bp-search input[type=search]")).length&&(i=n.val()),bp.Nouveau.objectRequest({object:"activity",scope:d,filter:s,search_terms:i,page:e,method:"append",exclude_just_posted:this.just_posted.join(","),target:'#buddypress [data-bp-list]:not( #bb-schedule-posts_modal [data-bp-list="activity"] ) ul.bb-rl-list'}).done(function(t){!0===t.success&&(o.remove(),a.current_page=e,jQuery(window).scroll())})),k(".activity-item.bb-closed-comments").find(".edit-activity, .acomment-edit").parents(".generic-button").hide()},hideComments:function(t){var a,i,o,t=k(t.target).find(".bb-rl-activity-comments");t.length&&t.each(function(t,e){o=k(e).children("ul").not(".bb-rl-conflict-activity-ul-li-comment"),!(i=k(o).find("li").not(k(".bb-rl-document-action-class, .bb-rl-media-action-class, .bb-rl-video-action-class"))).length||k("body").hasClass("activity-singular")&&""!==window.location.hash&&k(window.location.hash).length&&0!==k(window.location.hash).closest(".bb-rl-activity-comments").length||(a=k(e).closest(".activity-item"),k("#acomment-comment-"+a.data("bp-activity-id")+" span.comment-count").html(),i.each(function(t,e){if(t"),window.location.hash&&"#"+k(e).attr("id")===window.location.hash)return k(e).parents("li.comment-item").show(),!1;k(e).addClass("bp-hidden").hide()}}),k(o).children(".bp-hidden").length===k(o).children("li").length-1&&k(o).find("li.show-all").length&&k(o).children("li:not(.show-all)").removeClass("bp-hidden").toggle())})},showActivity:function(t){t.preventDefault();var e=k(t.currentTarget).parent(),a=e.data("parent_comment_id"),e=k(e).data("activity_id");k(document).trigger("activityModalOpened",{activityId:e}),k(t.currentTarget).parents(".bb-rl-activity-comments").find(".ac-form").each(function(){var t=k(this),e=k(this).closest(".bb-rl-activity-comments"),a=k(this).closest(".comment-item");t.find(".bb-rl-post-elements-buttons-item.bb-rl-post-emoji").removeClass("active").empty(""),bp.Nouveau.Activity.resetActivityCommentForm(t,"hardReset"),e.append(t),a.find(".bb-rl-acomment-display").removeClass("bb-rl-display-focus"),a.removeClass("bb-rl-comment-item-focus")}),bp.Nouveau.Activity.launchActivityPopup(e,a)},closeActivity:function(t){t.preventDefault();var t=k(t.target).closest(".bb-rl-activity-model-wrapper"),e=t.find(".bb-rl-modal-activity-footer"),a=t.find(".activity-item").data("bp-activity-id"),i=t.find("#ac-form-"+a),i=(i.length&&bp.Nouveau.Activity.reinitializeActivityCommentForm(i),_.isUndefined(u)||_.isUndefined(u.emoji)||bp.Nouveau.Activity.initializeEmojioneArea(!1,"",a),a&&bp.Nouveau.Activity.cleanupEmojiEventHandlers(a),k(".bb-rl-emojionearea-theatre"));i.length&&(i.find(".emojionearea-picker").remove(),i.removeClass("show hide").addClass("hide")),t.find("#bb-rl-activity-modal").removeClass("bb-closed-comments"),t.closest("body").removeClass("acomments-modal-open"),t.hide(),t.find("ul.bb-rl-activity-list").empty(),e.removeClass("active"),e.find("form.ac-form").remove(),k("li#bb-rl-activity-"+a).removeClass("has-comments")},scopeLoaded:function(t,a){this.current_page=1;var i=k("#buddypress #bb-rl-activity-stream");"mentions"===a.scope&&void 0!==a.response.new_mentions?(k.each(a.response.new_mentions,function(t,e){i.find('[data-bp-activity-id="'+e+'"]').addClass("newest_mentions_activity")}),this.mentions_count=0):void 0!==this.heartbeat_data.highlights[a.scope]&&this.heartbeat_data.highlights[a.scope].length&&k.each(this.heartbeat_data.highlights[a.scope],function(t,e){i.find('[data-bp-activity-id="'+e+'"]').length&&i.find('[data-bp-activity-id="'+e+'"]').addClass("newest_"+a.scope+"_activity")}),this.heartbeat_data.newest="",k.each(k(bp.Nouveau.objectNavParent+" [data-bp-scope]").find("a span"),function(t,e){"0"===k(e).html()&&k(e).html("")}),void 0!==this.heartbeat_data.highlights[a.scope]&&(this.heartbeat_data.highlights[a.scope]=[]),k(document).prop("title",this.heartbeat_data.document_title),setTimeout(function(){k("#buddypress #bb-rl-activity-stream .activity-item").removeClass("newest_"+a.scope+"_activity")},3e3),setTimeout(function(){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media.autoPlayGifVideos&&bp.Nouveau.Media.autoPlayGifVideos()},200),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 t,e;!_.isUndefined(P.params.is_activity_edit)&&0 ul").html())||a.hasClass("acomment-reply")||a.parent().hasClass("acomment-reply")||a.hasClass("acomment-edit"))&&r.displayingTheCommentForm({event:t,target:a,activityId:o,isInsideModal:m,isInsideMediaTheatre:b,self:r}),a.hasClass("activity-state-no-comments")&&t.preventDefault(),a.hasClass("ac-reply-cancel")&&((c=k(a).closest(".ac-form")).addClass("not-initialized"),k(".acomment-reply").attr("aria-expanded","false"),["media","document"].forEach(function(t){r.destroyUploader(t,o)}),c.closest("li.comment-item").length?r.activityRootComment(t):r.resetActivityCommentForm(c,"hardReset"),t.preventDefault()),"ac_form_submit"===a.prop("name")){if(a.prop("disabled"))return void t.preventDefault();r.submitActivityComment({event:t,parent:e,target:a,activityId:o,isInsideModal:m,activityState:s,commentsText:d,activityItem:i,self:r})}a.hasClass("edit")&&a.hasClass("edit-activity")&&(t.preventDefault(),n=i.data("bp-activity"),l=""!==i.data("link-url")?i.data("link-url"):null,void 0!==n)&&(bp.Nouveau.Activity.postForm.displayEditActivityForm(n,l),k("#bb-rl-activity-form").toggleClass("group-activity",a.closest("li").hasClass("groups")),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)&&k(".bb-rl-close-media-theatre, .bb-close-document-theatre").trigger("click"),m&&(a.hasClass("bb-rl-open-media-theatre")||a.hasClass("bb-open-video-theatre")||a.hasClass("bb-rl-open-document-theatre")||a.hasClass("bb-rl-document-detail-wrap-description-popup")||a.hasClass("bb-rl-document-description-wrap"))&&(t.preventDefault(),a.closest("#bb-rl-activity-modal").find(".bb-rl-modal-activity-header .bb-rl-close-action-popup").trigger("click")),(a.hasClass("pin-activity")||a.hasClass("unpin-activity"))&&r.pinUnpinActivity({event:t,activityId:o,parent:e,target:a,isInsideModal:m}),(a.hasClass("bb-icon-bell-slash")||a.hasClass("bb-icon-bell"))&&r.muteUnmuteNotifications({event:t,activityId:o,parent:e,target:a,isInsideModal:m}),(a.hasClass("close-activity-comment")||a.hasClass("unclose-activity-comment"))&&r.onOffComment({event:t,activityId:o,parent:e,target:a,isInsideModal:m})},commentFormAction:function(t){var e,a;return 3===(e=(t=t||window.event).target||t.srcElement).nodeType&&(e=e.parentNode),!0!==t.altKey&&!0!==t.metaKey&&"TEXTAREA"===e.tagName&&k(e).hasClass("ac-input")?void(27===(a=t.keyCode||t.which)&&!1===t.ctrlKey?k(e).closest("form").slideUp(200):t.ctrlKey&&13===a&&k(e).val()&&k(e).closest("form").find("[type=submit]").first().trigger("click")):t},togglePopupDropdown:function(t){var e;return 3===(e=(t=t||window.event).target||t.srcElement).nodeType&&(e=e.parentNode),!0===t.altKey||!0===t.metaKey||k(e).closest(".privacy-wrap").length?t:void k("ul.activity-privacy").removeClass("bb-open")},loadMoreActivities:function(){var t,e=k(".bb-rl-load-more:visible").last(),a=k(window);0!==e.length&&e.closest(".bb-rl-activity-list").length&&!0!==e.data("bp-autoloaded")&&(t=e.offset().top-50,a.scrollTop()+a.height()>t)&&(e.data("bp-autoloaded",1),e.find("a").text(P.strings.loadingMore),e.find("a").trigger("click"))},openCommentsMediaUploader:function(t){var e,a,i=this,o=k(t.currentTarget),n=o.data("ac-id"),n=o.closest(".bb-rl-ac-form-container").find("#bb-rl-ac-reply-post-media-uploader-"+n),s=0 /gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," "),a=t.text().trim(),t=t.closest("form");""!==a||0<=e.indexOf("emojioneemoji")||t.hasClass("acomment-edit")?t.addClass("has-content"):t.removeClass("has-content")},ReactionStatePopupTab:function(t){t.preventDefault();t=k(this).closest(".activity-state-popup");t.find(".activity-state-popup_tab_panel li a").removeClass("active"),k(this).addClass("active"),t.find(".activity-state-popup_tab_content .activity-state-popup_tab_item").removeClass("active"),t.find("."+k(this).data("tab")).addClass("active")},closeActivityState:function(){k(".activity-state-popup").hide().removeClass("active")},listenCommentInput:function(t){var e,a;0 /gi,"\n").replace(/<\/div>/gi,""));e=e.replace(/ /g," "),""!==k(t.currentTarget).text().trim()||0<=e.indexOf("emojioneemoji")?k(t.currentTarget).closest("form").addClass("has-content"):k(t.currentTarget).closest("form").removeClass("has-content")}),k(t).closest("form").addClass("events-initiated"),this.InitiatedCommentForms.push(e)))},activityRootComment:function(t){var t=k(t.currentTarget).closest("#bb-rl-activity-modal"),e=t.find(".activity-item").data("bp-activity-id"),a=t.find("#ac-form-"+e);bp.Nouveau.Activity.resetActivityCommentForm(a,"hardReset"),t.find(".bb-rl-acomment-display").removeClass("bb-rl-display-focus"),t.find(".comment-item").removeClass("bb-rl-comment-item-focus"),t.find(".bb-rl-modal-activity-footer").addClass("active").append(a),a.addClass("root"),a.find("#ac-input-"+e).focus(),a.find(".bb-rl-ac-reply-content .ac-input").attr("data-placeholder",P.strings.commentPlaceholder),a.find('input[name="ac_form_submit"]').val(P.strings.commentButtonText),bp.Nouveau.Activity.clearFeedbackNotice(a)},clearFeedbackNotice:function(t){t=t.find(".bb-rl-ac-form-container .bp-feedback");t.length&&t.remove()},launchActivityPopup:function(t,e){var a=k("#bb-rl-activity-"+t),i=k(".bb-rl-activity-model-wrapper"),o=a[0].outerHTML,e='[data-parent_comment_id="'+e+'"]',n=a.data("activity-popup-title");bp.Nouveau.Activity.activityHasUpdates=!1,bp.Nouveau.Activity.currentActivityId=null,bp.Nouveau.Activity.activityPinHasUpdates=!1,i.closest("body").addClass("acomments-modal-open"),i.show(),i.find("ul.bb-rl-activity-list").html(o),i.find(".bb-rl-modal-activity-header h2").text(n),0 =t.prop("scrollHeight")?i.addClass("bb-rl-modal-activity-body-scrolled-to-bottom"):i.removeClass("bb-rl-modal-activity-body-scrolled-to-bottom")}),i.find(".bb-rl-modal-activity-body").addClass("bb-rl-modal-activity-body-scroll-event-initiated"))},initialLoadComment:function(t){this.loadMoreComments({target:t.modal.find(".bb-rl-activity-comments"),activityId:t.activityID,parentCommentId:t.parentID||0,isModal:!0})},viewMoreComments:function(t){t.preventDefault();var t=k(t.currentTarget),e=t.parent();this.loadMoreComments({target:t,currentTargetList:t.parent(),activityId:k(e).data("activity_id"),commentsList:t.closest(".bb-rl-activity-comments"),commentsActivityItem:t.closest(".activity-item"),parentCommentId:k(e).data("parent_comment_id"),lastCommentTimestamp:t.prev("li.activity-comment").data("bp-timestamp"),addAfterListItemId:"",lastCommentId:t.prev("li.activity-comment").data("bp-activity-comment-id"),isModal:!1})},autoloadMoreComments:function(){var t,e,a,i,o=k(".bb-rl-activity-model-wrapper");0 ul > li.acomments-view-more:not(.loading), .bb-rl-modal-activity-body .bb-rl-activity-comments .activity-actions > ul > li.acomments-view-more:not(.loading)"),i=(o=o.find(".bb-rl-modal-activity-body")).find(".bb-rl-activity-comments:not(.active)"),0 e&&k(t).trigger("click").addClass("loading"),setTimeout(function(){jQuery(window).scroll()},200))},activitySyncOnModalClose:function(t,e){t.preventDefault();var t=k(t.currentTarget),t=t.is(document)?k(".bb-rl-activity-model-wrapper"):t.parents(".bb-rl-activity-model-wrapper"),t=t.find("ul.bb-rl-activity-list > li").data("bp-activity-id"),e=void 0!==e?e:t,a=k("#bb-rl-activity-stream li.activity-item[data-bp-activity-id="+e+"]");0 /gi,"\n").replace(/<\/div>/gi,""));e=e.replace(/ /g," "),""!==t.text()||0<=e.indexOf("emojioneemoji")?t.closest("form").addClass("has-content"):t.closest("form").removeClass("has-content")},picker_show:function(){k(this.button[0]).closest(".bb-rl-post-emoji").addClass("active"),k(".bb-rl-emojionearea-theatre").removeClass("hide").addClass("show")},picker_hide:function(){k(this.button[0]).closest(".bb-rl-post-emoji").removeClass("active"),k(".bb-rl-emojionearea-theatre").removeClass("show").addClass("hide")}}}),t&&((e=(e=k(n).closest(".modal, .bb-modal, .bb-rl-modal, .activity-modal, .activity-theatre, .bb-rl-screen-content")).length?e:k(n)).on("click"+(t=".bb-rl-emoji-"+s),"#bb-rl-ac-reply-emoji-button-"+s,function(e){var t,a,i,o;k(e.target).closest(".emojionearea-button").length||(t=k(n+"#ac-input-"+s).data("emojioneArea"))&&(i=(a=k(".bb-rl-emojionearea-theatre")).find(".emojionearea-picker"),a.hasClass("show")&&!i.hasClass("hidden")?(t.hidePicker(),a.removeClass("show").addClass("hide"),i.addClass("hidden")):(1<(i=a.find(".emojionearea-picker")).length&&i.remove(),t.showPicker(),a.removeClass("hide").addClass("show"),(o=a.find(".emojionearea-picker")).addClass("hidden"),setTimeout(function(){var t=e.clientX;o.length&&(o.css("transform","translate("+(t+30)+"px, "+(e.clientY-20)+"px) translate(-100%, -100%)"),o.removeClass("hidden"))},50)))}),e.data("emoji-event-namespace-"+s,t)))},cleanupEmojiEventHandlers:function(a){k(".modal, .bb-modal, .bb-rl-modal, .activity-modal, .activity-theatre, .bb-rl-screen-content").each(function(){var t=k(this),e=t.data("emoji-event-namespace-"+a);e&&(t.off(e),t.removeData("emoji-event-namespace-"+a))})},destroyUploader:function(t,e){var a,i=this,i={media:{obj:i.dropzone_obj,dropzone:i.dropzone_media,uploaderId:"#bb-rl-ac-reply-post-media-uploader-",buttonId:"#bb-rl-ac-reply-media-button-",additionalIds:["#bb-rl-ac-reply-post-media-uploader-1-"]},document:{obj:i.dropzone_document_obj,dropzone:i.dropzone_document,uploaderId:"#bb-rl-ac-reply-post-document-uploader-",buttonId:"#bb-rl-ac-reply-document-button-"},video:{obj:i.dropzone_video_obj,dropzone:i.dropzone_video,uploaderId:"#bb-rl-ac-reply-post-video-uploader-",buttonId:"#bb-rl-ac-reply-video-button-"},gif:{buttonId:"#bb-rl-ac-reply-gif-button-",dropdownClass:".bb-rl-gif-media-search-dropdown",standaloneClass:".bb-rl-gif-media-search-dropdown-standalone",modelProperty:"gif_data",containerId:"#bb-rl-ac-reply-post-gif-"}}[t];i&&("gif"!==t&&(a=i.obj,_.isNull(a)||(a.destroy(),k(i.uploaderId+e).html(""),i.additionalIds&&i.additionalIds.forEach(function(t){k(t+e).html("")})),i.dropzone=[],k(i.uploaderId+e).removeClass("open").addClass("closed")),k(i.buttonId+e).removeClass("active"),"gif"===t)&&(k(i.buttonId+e).closest(".bb-rl-post-gif").find(i.dropdownClass).removeClass("open").empty(),k(i.standaloneClass).removeClass("open").empty(),_.isUndefined(this.models[e])||(this.models[e].set(i.modelProperty,{}),k(i.containerId+e).find(".bb-rl-activity-attached-gif-container").removeAttr("style")))},handleFavoriteUnfavorite:function(t){var e,i,o,n,a=t.event,s=(a.preventDefault(),t.parent),d=t.target,l=t.reactionId,r=t.activityState,c=t.bodyElem,m=t.stream,b=t.activityItem;c.hasClass("bb-is-mobile")&&c.hasClass("bb-reactions-mode")&&0===d.closest(".ac-emotion_btn").length&&!0!==a.customTriggered||(d=k(d).is("a")?d:k(d).closest("a")).hasClass("loading")||(d.addClass("loading"),e=d.hasClass("fav")?"fav":"unfav",i=!0,t="activity",c=d.parents(".bb-rl-acomment-display").first(),a=d.attr("data-reacted-id"),0 .bb-rl-activity-content":".activity-comment[data-bp-activity-comment-id="+n+"] > .bb-rl-acomment-display > .bb-rl-acomment_inner").find(".activity-state-reactions").parent().addClass("bb-has-reaction_update"),"fav"===e?void 0===a.data.directory_tab||""===a.data.directory_tab||k(s.objectNavParent+' [data-bp-scope="favorites"]').length||k(s.objectNavParent+' [data-bp-scope="all"]').after(a.data.directory_tab):"unfav"===e&&((t=k('[data-bp-user-scope="favorites"]').hasClass("selected")||k(s.objectNavParent+' [data-bp-scope="favorites"]').hasClass("selected"))&&b.remove(),void 0!==a.data.no_favorite)&&(k(s.objectNavParent+' [data-bp-scope="all"]').length&&k(s.objectNavParent+' [data-bp-scope="all"]').hasClass("selected")?k(s.objectNavParent+' [data-bp-scope="favorites"]').remove():t&&m.append(a.data.no_favorite)))}).fail(function(){d.removeClass("loading")})))},deleteActivity:function(t){t.event.preventDefault();var p,v,u,y=t.parent,h=t.target,f=t.activityState,g=t.activityItem,_=t.commentsText,C=t.activityId,w=h.closest("[data-bp-activity-comment-id]"),N=w.data("bp-activity-comment-id"),j=0,A=h.closest(".bb-rl-activity-comments");if(A.addClass("active"),void 0!==a&&!1===window.confirm(a))return!1;h.addClass("loading");var x={action:"delete_activity",id:C,_wpnonce:y.getLinkParams(h.prop("href"),"_wpnonce"),is_single:h.closest("[data-bp-single]").length};(h.hasClass("spam-activity")||h.hasClass("spam-activity-comment"))&&(x.action="bp_spam_activity"),p=g,N&&(delete x.is_single,x.id=N,x.is_comment=!0,p=w),y.ajax(x,"activity").done(function(t){if(h.removeClass("loading"),!1===t.success)p.append(t.data.feedback),p.find(".bp-feedback").hide().fadeIn(300);else{var e,a,i=p.closest(".has-child-comments"),o=(p.hasClass("has-child-comments")&&(e=p.closest("ul").closest("li")),i.find("> ul"));if(t.data.redirect)return window.location.href=t.data.redirect;if(t.data.parent_activity_id&&t.data.activity&&k("body:not(.activity-singular) #buddypress #bb-rl-activity-stream ul.bb-rl-activity-list li#bb-rl-activity-"+t.data.parent_activity_id).replaceWith(t.data.activity),N){j=1;for(var n=w.find(".acomments-view-more").data("child-count"),n=(g.append(w.find("form")),w.find("li.comment-item").each(function(){j+=1}),j+=void 0!==n?parseFloat(n):0,u=f.find("span.comments-count"),v=u.text().length?u.text().match(/\d+/)[0]:0,v=Number(v-j),_.length?(n=1 ul")).length&&(t=t.html())&&""===t.trim()&&e.removeClass("has-child-comments")}),N||g.data("bp-timestamp")!==y.Activity.heartbeat_data.last_recorded||(y.Activity.heartbeat_data.newest="",y.Activity.heartbeat_data.last_recorded=0),k(document).trigger("bp_activity_ajax_delete_request",k.extend(x,{response:t})),k(document).trigger("bp_activity_ajax_delete_request_video",k.extend(x,{response:t})),bp.Nouveau.Activity.activityHasUpdates=!0,bp.Nouveau.Activity.currentActivityId=C}A.removeClass("active")})},readMoreActivity:function(t){var e=t.event,a=(e.preventDefault(),t.target),i=null,o=t.activityId,n=a.closest("div");if(k(n).hasClass("bb-rl-activity-inner")?i=o:k(n).hasClass("bb-rl-acomment-content")&&(i=a.closest("li").data("bp-activity-comment-id")),!i)return e;var o=t.parent,s=t.activityItem,d=a.closest("span");k(d).addClass("loading"),o.ajax({action:"get_single_activity_content",id:i},"activity").done(function(t){"object"!=typeof t&&0 ul li.comment-item").length+1&&(c=d.parent().closest("li.comment-item")).length?c:d:p.find('[data-bp-activity-comment-id="'+m+'"]'),a&&b.removeClass("active"),r.append(e))),t=e.find('input[name="ac_form_submit"]'),c=!1,(0 @'+c+" "),p=_.isUndefined(P.params.user_id)?"":P.params.user_id,b={offset:-(k(window).height()/2-75),easing:"swing"},l=m.get(0),jQuery("body").hasClass("bb-is-mobile")?setTimeout(function(){var t,e,a=300 /gi,"\n").replace(/<\/div>/gi,"")),I={action:"new_activity_comment",_wpnonce_new_activity_comment:k("#_wpnonce_new_activity_comment").val(),comment_id:A,form_id:y,content:e},t=k("#_bp_as_nonce_"+y).val(),T=(t&&(I["_bp_as_nonce_"+y]=t),this.dropzone_media.length&&(I.media=this.dropzone_media),this.dropzone_document.length&&(I.document=this.dropzone_document),this.dropzone_video.length&&(I.video=this.dropzone_video,_.isEmpty(I.content))&&(I.content=""),_.isUndefined(this.models[y])||(p=this.models[y],I.gif_data=this.models[y].get("gif_data")),I.content=I.content.replace(/ /g," "),j.hasClass("acomment-edit")&&(I.edit_comment=!0),0 "),(T?j.closest("#bb-rl-activity-modal").find(".bb-rl-modal-activity-body .bb-rl-activity-comments, .bb-rl-modal-activity-body .bb-rl-activity-comments .activity-actions"):e).children("ul").append(k(n).hide().fadeIn(200)),k(j).find(".ac-input").first().html(""),e.parent().addClass("has-comments comments-loaded"),f.addClass("has-comments")),j.removeClass("acomment-edit"),j.find(".bb-rl-ac-reply-content"));if([".bb-rl-ac-reply-media-button",".bb-rl-ac-reply-document-button",".bb-rl-ac-reply-video-button",".bb-rl-ac-reply-gif-button"].forEach(function(t){var e=s.find(".bb-rl-ac-reply-toolbar "+t);0 '+P.strings.replyLabel.replace("%d",1)+""),d.addClass("has-child-comments"),d=d.parent().closest(".activity-comment")}i.parent(":not( .has-comments )").addClass("has-comments");n=k(C).find(".show-all a");n&&n.html(M.replace("%d",t))}[w.dropzone_media,w.dropzone_document,w.dropzone_video].forEach(function(t){t&&0 '+t+"")})},pinUnpinActivity:function(t){var e=t.event,a=t.activityId;if(e.preventDefault(),!a)return e;var e=t.parent,l=t.target,r=t.isInsideModal,c=l.closest(".activity-item"),m=(c.addClass("loading-pin"),l.hasClass("unpin-activity")?"unpin":"pin");e.ajax({action:"activity_update_pinned_post",id:a,pin_action:m},"activity").done(function(t){var e,a,i,o,n,s,d;c.removeClass("loading-pin"),void 0!==(t="object"!=typeof t?JSON.parse(t):t).data&&void 0!==t.data.feedback&&(e=l.closest("ul.bb-rl-activity-list"),d=r?l.closest(".bb-rl-wrap").find("#bb-rl-activity-stream"):l.closest("#bb-rl-activity-stream"),t.success&&((""===(s=bp.Nouveau.getStorage("bp-activity","scope"))||!1===s||"undefined"!==BP_Nouveau.is_send_ajax_request&&""===BP_Nouveau.is_send_ajax_request)&&k(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").length&&(s=k(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").data("bp-scope")),a=!1,o="",(i=c.hasClass("groups"))&&(o=(n=c.attr("class").match(/group-\d+/))?n[0].replace("group-",""):""),d.hasClass("single-user")?a=!1:(d.hasClass("activity")&&"all"===s&&!i||d.hasClass("single-group"))&&(a=!0),"pin"==m?(a&&e.find("li.activity-item").removeClass("bb-pinned"),n=i&&!d.hasClass("single-group")?"li.activity-item.group-"+o:"li.activity-item",e.find(n).each(function(){var t=k(this).find(".unpin-activity"),e=(t.removeClass("unpin-activity").addClass("pin-activity"),i?P.strings.pinGroupPost:P.strings.pinPost);t.find("span").html(e)}),a&&c.addClass("bb-pinned"),l.addClass("unpin-activity").removeClass("pin-activity"),s=i?P.strings.unpinGroupPost:P.strings.unpinPost,l.find("span").html(s)):"unpin"==m&&(c.removeClass("bb-pinned"),l.addClass("pin-activity").removeClass("unpin-activity"),d=i?P.strings.pinGroupPost:P.strings.pinPost,l.find("span").html(d)),a)&&(bp.Nouveau.Activity.heartbeat_data.last_recorded=0,bp.Nouveau.refreshActivities()),k(document).trigger("bb_trigger_toast_message",[""," "+t.data.feedback+"","success",null,!0]),r)&&(void 0!==bp.Nouveau.Activity.activityHasUpdates&&(bp.Nouveau.Activity.activityHasUpdates=!0),void 0!==bp.Nouveau.Activity.activityPinHasUpdates)&&(bp.Nouveau.Activity.activityPinHasUpdates=!0)}).fail(function(){l.closest(".activity-item").removeClass("loading-pin"),k(document).trigger("bb_trigger_toast_message",["",""+P.strings.pinPostError+"","error",null,!0])})},muteUnmuteNotifications:function(t){var e=t.event,a=t.parent,i=t.target,o=t.activityId,n=t.isInsideModal;if(i.hasClass("bb-icon-bell-slash")||i.hasClass("bb-icon-bell")){if(e.preventDefault(),!o)return e;var s=i.closest(".activity-item"),d=(s.addClass("loading-mute"),i.hasClass("bb-icon-bell")?"unmute":"mute");a.ajax({action:"toggle_activity_notification_status",id:o,notification_toggle_action:d},"activity").done(function(t){var e;s.removeClass("loading-mute"),void 0!==(t="object"!=typeof t?JSON.parse(t):t).data&&void 0!==t.data.feedback&&(t.success&&("mute"==d?(e=P.strings.unmuteNotification,s.addClass("bb-muted"),i.removeClass("bb-icon-bell-slash"),i.addClass("bb-icon-bell"),i.attr("title",e),i.find("span").html(e)):"unmute"==d&&(e=P.strings.muteNotification,s.removeClass("bb-muted"),i.removeClass("bb-icon-bell"),i.addClass("bb-icon-bell-slash"),i.attr("title",e),i.find("span").html(e)),void 0!==bp.Nouveau.Activity.activityHasUpdates)&&(bp.Nouveau.Activity.activityHasUpdates=!0),k(document).trigger("bb_trigger_toast_message",["",""+t.data.feedback+"","success",null,!0])),n&&(bp.Nouveau.Activity.activityPinHasUpdates=!0),bp.Nouveau.Activity.activityHasUpdates=!0,bp.Nouveau.Activity.currentActivityId=o}).fail(function(){i.closest(".activity-item").removeClass("loading-pin"),k(document).trigger("bb_trigger_toast_message",["",""+P.strings.pinPostError+"","error",null,!0])})}},onOffComment:function(t){var e=t.event,a=t.target,i=t.parent,o=t.activityId;if(e.preventDefault(),!o)return e;var n=a.closest(".activity-item"),s=(n.addClass("loading-pin"),a.hasClass("unclose-activity-comment")?"unclose_comments":"close_comments");i.ajax({action:"activity_update_close_comments",id:o,close_comments_action:s},"activity").done(function(t){var e;n.removeClass("loading-pin"),void 0!==(t="object"!=typeof t?JSON.parse(t):t).data&&void 0!==t.data.feedback&&(t.success&&(e=k("#bb-rl-activity-stream > .bb-rl-activity-list").find("[data-bp-activity-id="+o+"]"),n.find(".bb-rl-activity-closed-comments-notice").remove(),"close_comments"==s?(n.addClass("bb-closed-comments"),0'+t.data.feedback+""),0 '+t.data.feedback+""))):"unclose_comments"==s&&(n.find(".edit-activity, .acomment-edit").parents(".generic-button").show(),n.removeClass("bb-closed-comments"),0 "+t.data.feedback+"",t.success?"success":"error",null,!0]))}).fail(function(){a.closest(".activity-item").removeClass("loading-pin"),k(document).trigger("bb_trigger_toast_message",[""," "+P.strings.closeCommentsError+"","error",null,!0])})},setupDropzoneEventHandlers:function(t){var o=t.self,c=t.dropzoneObj,n=t.target,m=t.type,b=t.dropzoneDataObj;c.on("addedfile",function(t){var e;t[m+"_edit_data"]&&(b.push(t[m+"_edit_data"]),"document"===m&&(e=(e=t.upload.filename).substr(e.lastIndexOf(".")+1),k(t.previewElement).find(".dz-details .dz-icon .bb-icon-file").removeClass("bb-icon-file").addClass("bb-icon-file-"+e)),(e=n.parents(".bb-rl-ac-reply-toolbar")).find(".bb-rl-ac-reply-"+m+"-button"))&&e.find(".bb-rl-ac-reply-"+m+"-button").parents(".bb-rl-post-elements-buttons-item").addClass("no-click").find(".toolbar-button").addClass("active"),"video"===m&&(t.dataURL&&t.video_edit_data.thumb.length?(k(t.previewElement).find(".dz-image").prepend(''),k(t.previewElement).closest(".dz-preview").addClass("dz-has-thumbnail")):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(t,".dz-image"))}),c.on("sending",function(t,e,a){a.append("action","document"===m?m+"_"+m+"_upload":m+"_upload");var i="document"===m?"media":m,o=(a.append("_wpnonce",BP_Nouveau.nonces[i]),n.parents(".bb-rl-ac-reply-toolbar"));n.closest(".ac-form").addClass("has-media"),["media","document","video","gif"].forEach(function(t){var e;o.find(".bb-rl-ac-reply-"+t+"-button")&&(e=o.find(".bb-rl-ac-reply-"+t+"-button").parents(".bb-rl-post-elements-buttons-item"),m===t?e.addClass("no-click").find(".toolbar-button").addClass("active"):e.addClass("disable"))}),this.element.classList.remove("files-uploaded")}),c.on("uploadprogress",function(t){n.closest(".ac-form").addClass("media-uploading");var e=k(t.previewElement).find(".dz-progress-ring circle")[0],a=2*e.r.baseVal.value*Math.PI;e.style.strokeDasharray=a+" "+a,e.style.strokeDashoffset=a-t.upload.progress.toFixed(0)/100*a,k(t.previewElement).find(".dz-progress [data-dz-progress]").text(t.upload.progress.toFixed(0)+"%")}),c.on("success",function(t,e){var a,i;if("document"===m&&(a=(a=t.upload.filename).substr(a.lastIndexOf(".")+1),i=_.isUndefined(e.data.svg_icon)?"":e.data.svg_icon,a=_.isEmpty(i)?"bb-icon-file-"+a:i,k(t.previewElement).find(".dz-details .dz-icon .bb-icons-rl-file").length)&&k(t.previewElement).find(".dz-details .dz-icon .bb-icons-rl-file").removeClass("bb-icons-rl-file").addClass(a),e.data.id)return t.id=e.id,e.data.uuid=t.upload.uuid,e.data.menu_order=k(t.previewElement).closest(".dropzone").find(t.previewElement).index()-1,i="document"===m?"media":m,e.data.album_id=void 0!==BP_Nouveau[i]&&void 0!==BP_Nouveau[i].album_id&&BP_Nouveau[i].album_id,e.data.group_id=void 0!==BP_Nouveau[i]&&void 0!==BP_Nouveau[i].group_id&&BP_Nouveau[i].group_id,e.data.saved=!1,b.push(e.data),t.previewElement.classList.add("dz-success");var o,n,s,d,l,r=e.data.feedback;for(t.previewElement.classList.add("dz-error"),l=[],n=0,s=(d=t.previewElement.querySelectorAll("[data-dz-errormessage]")).length;n
'+e+""),this.removeFile(t),a.removeClass("media-uploading"))}),c.on("removedfile",function(t){if(b.length)for(var e in b)if(t.upload.uuid===b[e].uuid){void 0===b[e].saved||b[e].saved||bp.Nouveau.Media.removeAttachment(b[e].id),b.splice(e,1);break}var a,i;_.isNull(c)||_.isNull(c.files)||0!==c.files.length?n.closest(".ac-form").addClass("has-content"):(a=n.parents(".bb-rl-ac-reply-toolbar"),(i=n.closest(".ac-form")).removeClass("has-media"),["media","document","video","gif"].forEach(function(t){var e;a.find(".bb-rl-ac-reply-"+t+"-button")&&(e=a.find(".bb-rl-ac-reply-"+t+"-button").parents(".bb-rl-post-elements-buttons-item"),m===t?e.removeClass("no-click").find(".toolbar-button").removeClass("active"):e.removeClass("disable"))}),k(c.element).removeClass("files-uploaded dz-progress-view").find(".dz-global-progress").remove(),o.validateCommentContent(i.find(".ac-textarea").children(".ac-input")))}),c.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 '),{action:o.isModal?"bb_rl_activity_loadmore_comments":"activity_loadmore_comments",activity_id:o.activityId,parent_comment_id:o.parentCommentId,offset:o.isModal?0:n.parents(".bb-rl-activity-comments").find('ul[data-parent_comment_id ="'+o.parentCommentId+'"] > li.comment-item:not(.bb-recent-comment)').length,activity_type_is_blog:1"+t.data.message+" "+t.statusText+" '+e.data.media_group_count+" "+i)):h("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(h(".bb-photos-actions").hide(),h("#media-stream")):r.find(".media-list:not(.existing-media-list)")).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(h(".bb-photos-actions").hide(),h("#media-stream")):r.find(".media-list:not(.existing-media-list)")).html(e.data.group_media_html_content):h.each(n,function(e,t){t=h('#media-stream ul.media-list li[data-id="'+t+'"]');t.length&&t.remove()}),void 0!==e.data.album_total_count&&o.updateAlbumCounts(e.data))):(setTimeout(function(){a.prop("disabled",!1)},500),e.success?(void 0!==e.data&&void 0!==e.data.media_personal_count&&(0 '+e.data.media_personal_count+" "+i)):h("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count)),void 0!==e.data&&void 0!==e.data.media_group_count&&0 '+e.data.media_group_count+" "+i)):h("#buddypress").find(".groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),(t=r.find(".media-list:not(.existing-media-list)")).find('.bb-media-check-wrap [name="bb-media-select"]:checked').each(function(){h(this).closest("li").remove()}),t.parent().parent().hasClass("album-single-view")&&t.find('.bb-video-check-wrap [name="bb-video-select"]:checked').each(function(){h(this).closest("li").remove()}),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(h(".bb-photos-actions").hide(),h("#media-stream")):t).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(h(".bb-photos-actions").hide(),h("#media-stream")):t).html(e.data.group_media_html_content):h.each(n,function(e,t){t=h('#media-stream ul.media-list li[data-id="'+t+'"]');t.length&&t.remove()})):h("#buddypress #media-stream.media").prepend(e.data.feedback));var t=h(".bp-nouveau #bb-select-deselect-all-media");t.hasClass("selected")&&t.removeClass("selected"),jQuery(window).scroll()}})},toggleSelectAllMedia:function(e){e.preventDefault();var e=h(e.currentTarget),t=!e.hasClass("selected");this.setMediaSelectionState(t),h("#bb-delete-media").length&&(t?h("#bb-delete-media").removeAttr("disabled"):h("#bb-delete-media").attr("disabled","disabled")),e.toggleClass("selected",t).data("bp-tooltip",t?BP_Nouveau.media.i18n_strings.unselectall:BP_Nouveau.media.i18n_strings.selectall)},editFolderTitle:function(e){e.preventDefault(),this.editAlbumFolderTitle(e,"document")},cancelEditAlbumTitle:function(e){e.preventDefault(),h("#bb-album-title").removeClass("error"),h("#bp-save-folder-title").hide(),h("#bp-cancel-edit-album-title").hide(),h("#bp-edit-album-title,#bp-edit-folder-title").show(),h("#bp-media-single-album #bp-single-album-title").show()},triggerDropzoneSelectFileDialog:function(){this.dropzone_obj.hiddenFileInput.click()},closeUploader:function(e){e.preventDefault(),h("#bp-media-uploader").hide(),h("#bp-media-add-more").hide(),h("#bp-media-uploader-modal-title").text(g.i18n_strings.upload),h("#bp-media-uploader-modal-status-text").text(""),h("#bp-media-post-content").val(""),h("#bp-dropzone-content .bp-feedback").remove(),this.dropzone_obj.element&&this.dropzone_obj.destroy(),this.dropzone_media=[];var t=h(e.currentTarget).closest("#bp-media-uploader");h(".bb-rl-close-create-popup-album").trigger("click"),h(".bb-rl-close-create-popup-folder").trigger("click"),t.find('.bb-rl-breadcrumbs-append-ul-li .item span[data-id="0"]').trigger("click"),t.find(".bb-field-steps").length&&(t.find(".bb-field-steps-1").show().siblings(".bb-field-steps-2").hide(),t.find(".bb-field-steps-1 #bp-media-photo-next, .bb-field-steps-1 #bp-media-document-next ").hide(),t.find(".bb-field-steps-1").removeClass("controls-added"),t.find("#bp-media-document-prev, #bp-media-prev, #bp-media-document-submit, #bp-media-submit, .bb-rl-media-open-create-popup-folder, .bb-rl-document-open-create-popup-folder, .bb-rl-create-popup-folder-wrap, .bb-rl-create-popup-album-wrap, .bb-rl-video-open-create-popup-album").hide()),this.clearFolderLocationUI(e)},closeChildFolderUploader:function(e){e.preventDefault();e=h(document);e.find(".open-popup #bb-album-child-title").val(""),e.find(".open-popup #bp-media-create-child-folder-submit").removeClass("loading"),e.find("#bp-media-create-child-folder").removeClass("open-popup"),e.find("#bp-media-create-child-folder").hide(),e.find(".open-popup #bb-album-title").text(""),e.find(".open-popup #bp-media-create-folder").hide(),e.find("#bp-media-create-folder").removeClass("open-popup")},closeFolderUploader:function(e){e.preventDefault();e=h(document);e.find(".open-popup #bb-album-title").val(""),e.find(".open-popup #bp-media-create-folder-submit").removeClass("loading"),e.find(".open-popup #bp-media-document-submit").hide(),e.find("#bp-media-create-folder").removeClass("open-popup"),e.find("#bp-media-create-folder").hide()},loadMoreGif:function(e){var t=e.target,i=this,a=h(e.target).closest(".bb-rl-gif-media-search-dropdown-standalone"),a=0 =t.scrollHeight&&!a.hasClass("loading")&&0 =t.scrollHeight&&!h(e.target).closest(".bp-group-messages-attached-gif-container").hasClass("loading")&&0 \n\t\n\t\t \n\t\n',e.data[t].saved=!1,this.gif_data.push(e.data[t])}i.find(".gif-search-results-list").append(a)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(this.gif_total_count=e.pagination.total_count)},loadMoreGifResponse:function(e){var t=this,i=0,a=h('div.forums-attached-gif-container[data-key="'+t.gif_container_key+'"]'),o=h(".bb-rl-gif-media-search-dropdown-standalone.open"),o=(0
\n\t\n\t\t \n\t\n',e.data[i].saved=!1,t.gif_data[t.gif_container_key].data.push(e.data[i])}o.append(d)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(t.gif_data[t.gif_container_key].total_count=e.pagination.total_count)},editGifPreview:function(){var e=this,t={};if(e.bbp_is_reply_edit&&Object.keys(e.bbp_reply_edit_gif_data).length?t=e.bbp_reply_edit_gif_data.gif_raw_data:e.bbp_is_topic_edit&&Object.keys(e.bbp_topic_edit_gif_data).length?t=e.bbp_topic_edit_gif_data.gif_raw_data:e.bbp_is_forum_edit&&Object.keys(e.bbp_forum_edit_gif_data).length&&(t=e.bbp_forum_edit_gif_data.gif_raw_data),void 0===t.images)return!1;e=h("#whats-new-attachments .forums-attached-gif-container"),e[0].style.backgroundImage="url("+t.images.fixed_width.url+")",e[0].style.backgroundSize="contain",e[0].style.height=t.images.original.height+"px",e[0].style.width=t.images.original.width+"px",e.find(".gif-image-container img").attr("src",t.images.original.url),e.removeClass("closed"),e=h("#bbp_media_gif");e.length&&e.val(JSON.stringify(t))},selectGif:function(e){var t,i=this,a=0,o=h(e.currentTarget),d=o.closest(".bb-rl-gif-media-search-dropdown-standalone"),n=0
\n\t\n\t\t \n\t\n',e.data[s].saved=!1,r.gif_data.push(e.data[s])}h(n.target).closest(".bp-group-messages-attached-gif-container").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(r.gif_total_count=e.pagination.total_count),h(n.target).closest(".bp-group-messages-attached-gif-container").removeClass("loading")},function(){h(n.target).find(".gif-no-connection").addClass("show")}));r.gif_requests.push(e),r.gif_offset=r.gif_offset+r.gif_limit},searchGifRequest:function(n){var r=this,s=0,e=h(n.target).closest(".bb-rl-gif-media-search-dropdown-standalone"),t=0
\n\t\n\t\t \n\t\n',e.data[s].saved=!1,r.gif_data[p].data.push(e.data[s])}h(n.target).closest(".gif-search-content").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(r.gif_data[p].total_count=e.pagination.total_count),l.removeClass("loading")},function(){c.find(".gif-no-connection").addClass("show")}));r.gif_data[p].requests.push(i),r.gif_data[p].offset=r.gif_data[p].offset+r.gif_data[p].limit},clearGifRequests:function(e){var t=this;if(void 0!==t.gif_data[e]&&void 0!==t.gif_data[e].requests){for(var i=t.gif_data[e].requests.length,a=0;a
",l.html(e),l.find(".gif-search-results").on("scroll",s.loadMoreGif.bind(s))),void 0!==window.Giphy&&void 0!==g.gif_api_key&&(s.giphy=new window.Giphy(g.gif_api_key),(n=i.closest("form").find(".forums-attached-gif-container")).addClass("loading"),r=n.data("key"),s.clearGifRequests(r),s.gif_data[r]={q:null,offset:0,limit:20,requests:[],total_count:0,data:[]},e=s.giphy.trending({offset:s.gif_data[r].offset,fmt:"json",limit:s.gif_data[r].limit},function(e){if(void 0!==e.data&&e.data.length){var t="",i=e.data.length;for(c=0;c\n\t\n\t\t'+(g.gif_no_results||"No results found")+'
'+(g.gif_no_connection||"Could not connect to GIPHY")+"
\n\t\n',e.data[c].saved=!1,s.gif_data[r].data.push(e.data[c])}l.find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(s.gif_data[r].total_count=e.pagination.total_count),n.removeClass("loading")}),s.gif_data[r].requests.push(e),s.gif_data[r].offset=s.gif_data[r].offset+s.gif_data[r].limit),l.toggleClass("open"),a&&l.hasClass("open")&&(e=h(window).scrollTop(),a=i.offset(),d=Math.round(a.top),a=Math.round(a.left),t=h("body").hasClass("rtl"),o=l.outerWidth(),t=t?"translate(-"+(h(window).width()-a-i.outerWidth()+o-70)+"px, "+(d-e-5)+"px) translate(0, -100%)":"translate("+(a+o-70)+"px, "+(d-e-5)+"px) translate(-100%, -100%)",l.css("transform",t),l.data("target-form",i.closest("form"))),i.parents("form").find("#whats-new-attachments .forums-attached-gif-container img")),o=(0
\n\t\n\t\t \n\t\n',e.data[s].saved=!1,n.gif_data.push(e.data[s])}r.closest("form").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(n.gif_total_count=e.pagination.total_count),h(".gif-search-query").closest(".bp-group-messages-attached-gif-container").removeClass("loading")}),n.gif_requests.push(e),n.gif_offset=n.gif_offset+n.gif_limit),r.parents("form").find("#whats-new-attachments .bp-group-messages-attached-gif-container img"));0
'+h(this).text()+""),h(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").removeClass("is-disabled"),h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").hasClass("is-disabled"))||((h(e.currentTarget).closest(".bb-field-wrap").length?h(e.currentTarget).closest(".bb-rl-field-wrap"):h(e.currentTarget).closest(".bb-field-wrap")).find(".bb-rl-album-selected-id").val(h(e.currentTarget).data("id")),t=h(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),0!==Number(h(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(h(e.currentTarget).parent().data("privacy")).trigger("change"),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public").trigger("change"),t.prop("disabled",!1)))}),o.on("click",t+" .breadcrumb .item > span",function(e){var t,i;h(this).hasClass("is-disabled")||(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-album-selected-id").val(0),h(e.currentTarget).closest(".bb-rl-field-wrap").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),a===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").removeClass("is-disabled"),t=h(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),i=h(e.currentTarget).closest("#bp-media-uploader").find(".location-album-list li.is_active").data("privacy"),0!==Number(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-album-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i).trigger("change"),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public").trigger("change"),t.prop("disabled",!1)))}),i.options.previewTemplate=document.getElementsByClassName("uploader-post-media-template").length?document.getElementsByClassName("uploader-post-media-template")[0].innerHTML:"",i.dropzone_obj=new Dropzone("div#media-uploader",i.options),i.dropzone_obj.on("sending",function(e,t,i){i.append("action","media_upload"),i.append("_wpnonce",w.media)}),i.dropzone_obj.on("uploadprogress",function(e){var t=h(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI;t.style.strokeDasharray=i+" "+i,t.style.strokeDashoffset=i,t.style.strokeDashoffset=i-e.upload.progress.toFixed(0)/100*i}),i.dropzone_obj.on("addedfile",function(){setTimeout(function(){i.dropzone_obj.getAcceptedFiles().length&&h("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(g.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),i.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?h(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"===e.status&&e.xhr&&0===e.xhr.status&&h(e.previewElement).find(".dz-error-message span").text(g.connection_lost_error):(jQuery(".media-error-popup").length||h("body").append('"),this.removeFile(e))}),i.dropzone_obj.on("queuecomplete",function(){h("#bp-media-uploader-modal-title").text(g.i18n_strings.upload)}),i.dropzone_obj.on("processing",function(){h("#bp-media-uploader-modal-title").text(g.i18n_strings.uploading+"...")}),i.dropzone_obj.on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=i.dropzone_media.length,t.data.album_id=i.album_id,t.data.group_id=i.group_id,t.data.saved=!1,i.dropzone_media.push(t.data)):(jQuery(".media-error-popup").length||h("body").append('"),this.removeFile(e)),h(".bb-field-steps-1 #bp-media-photo-next, #bp-media-submit").show(),h(".modal-container").addClass("modal-container--alert"),h(".bb-field-steps-1").addClass("controls-added"),h("#bp-media-add-more").show(),h("#bp-media-uploader-modal-title").text(g.i18n_strings.uploading+"..."),h("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(g.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()}),i.dropzone_obj.on("removedfile",function(e){if(i.dropzone_media.length)for(var t in i.dropzone_media)if(e.upload.uuid===i.dropzone_media[t].uuid){void 0===i.dropzone_media[t].saved||i.dropzone_media[t].saved||i.removeAttachment(i.dropzone_media[t].id),i.dropzone_media.splice(t,1);break}i.dropzone_obj.getAcceptedFiles().length?h("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(g.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show():(h("#bp-media-uploader-modal-status-text").text(""),h("#bp-media-add-more, #bp-media-photo-next").hide(),h(".bb-field-steps-1").removeClass("controls-added"),h("#bp-media-submit").hide(),h(".modal-container").removeClass("modal-container--alert"))}))},openDocumentUploader:function(e){var a,t,l=this,i=(e.preventDefault(),h(document)),o=h("#bp-media-uploader");void 0!==window.Dropzone&&h("div#media-uploader").length&&(o.hasClass("bp-media-document-uploader")&&!this.currentTargetParent&&(this.currentTargetParent=0),h(e.currentTarget).closest("#bp-media-single-folder").length&&h("#bb-document-privacy").hide(),i.removeClass("open-popup"),o.show(),o.addClass("open-popup"),bp.Readylaunch&&bp.Readylaunch.initSelect2Scoped&&bp.Readylaunch.initSelect2Scoped(o),h("#bp-media-uploader.bp-media-document-uploader").find(".bb-field-steps.bb-field-steps-2").length&&(t="#bp-media-uploader.bp-media-document-uploader",0!==Number(h(t).find(".bb-rl-folder-selected-id").data("value"))?(a=h(t).find(".bb-rl-folder-selected-id").data("value"),h(t).find("#bb-document-privacy").prop("disabled",!0)):a=0,""!==this.moveToIdPopup)&&h.ajax({url:y,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:w.media},success:function(e){i.find(".bp-media-document-uploader .bb-rl-location-folder-list-wrap h4 span.bb-rl-where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(i.find(".bp-media-document-uploader.open-popup .bb-rl-location-folder-list-wrap").hide(),i.find(".bp-media-document-uploader.open-popup .bb-rl-location-folder-list-wrap-main span.bb-rl-no-folder-exists")):(i.find(".bp-media-document-uploader.open-popup .bb-rl-location-folder-list-wrap-main span.bb-rl-no-folder-exists").hide(),i.find(".bp-media-document-uploader.open-popup .bb-rl-location-folder-list-wrap"))).show(),i.find(".bp-media-document-uploader .bb-rl-popup-on-fly-create-album .bb-rl-privacy-field-wrap-hide-show").show(),i.find(".bp-media-document-uploader .open-popup .bb-rl-folder-create-from").val("profile"),h(t).find(".bb-rl-location-folder-list-wrap .location-folder-list").remove(),h(t).find(".bb-rl-location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,a),h(t).find("ul.location-folder-list span#"+a).trigger("click"),h(t).find(".bb-rl-folder-selected-id").val(a)}}),i.on("click",t+" .location-folder-list li span",function(e){var t;e.preventDefault(),h(this).parent().hasClass("is_active")||(0!==h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item").append(''+h(this).text()+""),h(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").removeClass("is-disabled"),h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").hasClass("is-disabled"))||(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-folder-selected-id").val(h(e.currentTarget).data("id")),t=h(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),0!==Number(h(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(h(e.currentTarget).parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),i.on("click",t+" .breadcrumb .item > span",function(e){var t,i;h(this).hasClass("is-disabled")||(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-folder-selected-id").val(h(e.currentTarget).data("id")),h(e.currentTarget).closest(".bb-rl-field-wrap").find(".location-folder-list li span").removeClass("selected").parent().removeClass("is_active"),h(e.currentTarget).closest(".bb-rl-field-wrap").find('.location-folder-list li[data-id="'+h(e.currentTarget).data("id")+'"]').addClass("is_active"),h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),a===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").removeClass("is-disabled"),t=h(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),i=h(e.currentTarget).closest("#bp-media-uploader").find(".location-folder-list li.is_active").data("privacy"),0!==Number(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-folder-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),l.options.previewTemplate=document.getElementsByClassName("uploader-post-document-template").length?document.getElementsByClassName("uploader-post-document-template")[0].innerHTML:"",l.dropzone_obj=new Dropzone("div#media-uploader",l.options),l.dropzone_obj.on("sending",function(e,t,i){i.append("action","document_document_upload"),i.append("_wpnonce",w.media)}),l.dropzone_obj.on("uploadprogress",function(e){var t=h(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI;t.style.strokeDasharray=i+" "+i,t.style.strokeDashoffset=i,t.style.strokeDashoffset=i-e.upload.progress.toFixed(0)/100*i}),l.dropzone_obj.on("addedfile",function(){setTimeout(function(){l.dropzone_obj.getAcceptedFiles().length&&h("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(g.i18n_strings.upload_status,l.dropzone_media.length,l.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),l.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?h(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"===e.status&&e.xhr&&0===e.xhr.status&&h(e.previewElement).find(".dz-error-message span").text(g.connection_lost_error):(jQuery(".document-error-popup").length||h("body").append('"),this.removeFile(e))}),l.dropzone_obj.on("accept",function(e,t){0===e.size?t(g.empty_document_type):t()}),l.dropzone_obj.on("queuecomplete",function(){h("#bp-media-uploader-modal-title").text(g.i18n_strings.upload)}),l.dropzone_obj.on("processing",function(){h("#bp-media-uploader-modal-title").text(g.i18n_strings.uploading+"...")}),l.dropzone_obj.on("success",function(e,t){if(!t.data.id){var i,a,o,d,n,r=t.data.feedback;for(e.previewElement.classList.add("dz-error"),n=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a .bb-rl-activity-content .bb-rl-media-move-file",h(a).find(".bb-rl-document-move").attr("id",e.closest(".bb-rl-document-activity").attr("data-id")),0 '),d),r=this.moveToTypePopup;""!==this.moveToIdPopup&&h.ajax({url:y,type:"post",data:{action:"media_get_album_view",id:this.moveToIdPopup,type:this.moveToTypePopup},success:function(e){o.find(".bb-rl-location-album-list-wrap h4 span.bb-rl-where-to-move-profile-or-group-media").html(e.data.first_span_text),(""===e.data.html?(o.find(".open-popup .bb-rl-location-album-list-wrap").hide(),o.find(".open-popup .bb-rl-location-album-list-wrap-main span.bb-rl-no-album-exists")):(o.find(".open-popup .bb-rl-location-album-list-wrap-main span.bb-rl-no-album-exists").hide(),o.find(".open-popup .bb-rl-location-album-list-wrap"))).show(),"group"===r?(o.find(".bb-rl-popup-on-fly-create-album .bb-rl-privacy-field-wrap-hide-show").hide(),o.find(".open-popup .bb-rl-album-create-from").val("group")):(o.find(".bb-rl-popup-on-fly-create-album .bb-rl-privacy-field-wrap-hide-show").show(),o.find(".open-popup .bb-rl-album-create-from").val("profile")),!1===e.data.create_album?(h(a+".open-popup").find(".bb-rl-media-open-create-popup-folder").removeClass("create-album"),h(a+".open-popup").find(".bb-rl-media-open-create-popup-folder").hide()):(h(a+".open-popup").find(".bb-rl-media-open-create-popup-folder").addClass("create-album"),h(a+".open-popup").find(".bb-rl-media-open-create-popup-folder").show()),h(a).find(".bb-rl-location-album-list-wrap .location-album-list").remove(),h(a).find(".bb-rl-location-album-list-wrap").append(e.data.html),h(a).find(".bb-rl-model-footer .bb-rl-media-move").removeClass("loading"),h(a).find("ul.location-album-list span#"+n).trigger("click")}}),o.on("click",a+" .location-album-list li span",function(e){var t;e.preventDefault(),h(this).parent().hasClass("is_active")||(0!==h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item").append(''+h(this).text()+""),h(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),t=h(document).find('a.bb-rl-open-media-theatre[data-id="'+i.find(".bb-rl-media-move").attr("id")+'"]').data("album-id"),Number(t)===Number(h(e.currentTarget).data("id"))?h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").removeClass("is-disabled"),h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").hasClass("is-disabled"))||h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-album-selected-id").val(h(e.currentTarget).data("id"))}),o.on("click",a+" .breadcrumb .item > span",function(e){h(this).hasClass("is-disabled")||(h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-album-selected-id").val(0),h(e.currentTarget).closest(".bb-rl-media-move-file").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),n===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").removeClass("is-disabled"))})},openDocumentMove:function(e){e.preventDefault();var t,i=h(document),a=h(),e=h(e.currentTarget),o=(this.moveToIdPopup=e.attr("id"),this.moveToTypePopup=e.attr("data-type"),e.attr("data-action")),d=(h(".bb-rl-media-move-file.open-popup, .bb-rl-media-move-folder.open-popup").hide().removeClass("open-popup"),e.closest("#bb-rl-activity-modal")),n=(0===d.length&&(d=h("body")),e.closest(".bb-rl-conflict-activity-ul-li-comment").closest("li.comment-item").length?(t=e.closest("li.comment-item"),a=d.find("#"+t.attr("id")+".comment-item .bb-rl-media-move-file").first()):0<(t=e.closest("li.activity-item")).length&&(a=d.find("#"+t.attr("id")+" > .bb-rl-activity-content .bb-rl-media-move-file").first()),a&&0!==a.length||(e.closest(".bb-rl-conflict-activity-ul-li-comment").closest("li.comment-item").length?(t=e.closest("li.comment-item").attr("id"),a=d.find("#"+t+".comment-item .bb-rl-media-move-file").first()):(t=e.closest("li.activity-item").attr("id"))&&(a=d.find("#"+t+" > .bb-rl-activity-content .bb-rl-media-move-file").first())),a.find(".bb-rl-document-move").attr("id",e.closest(".bb-rl-document-activity").attr("data-id")),this.currentTargetParent=e.closest(".bb-rl-activity-media-elem").attr("data-parent-id"),0 '),"document"===o?a.find(".bb-rl-modal-header h4 .target_name").text(g.move_to_file):a.find(".bb-rl-modal-header h4 .target_name").text(g.move_to_folder),a.show(),a.addClass("open-popup"),"group"===this.moveToTypePopup?(i.find(".bb-rl-location-folder-list-wrap h4").show(),a.addClass("move-folder-popup-group")):(i.find(".bb-rl-location-folder-list-wrap h4").hide(),h(".move-folder-popup-group").removeClass("move-folder-popup-group")),this.currentTargetParent),r=this.moveToTypePopup;""!==this.moveToIdPopup&&h.ajax({url:y,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:w.media},success:function(e){var t;i.find(".bb-rl-location-folder-list-wrap h4 span.bb-rl-where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(a.find(".bb-rl-location-folder-list-wrap").hide(),a.find(".bb-rl-location-folder-list-wrap-main span.bb-rl-no-folder-exists")):(a.find(".bb-rl-location-folder-list-wrap-main span.bb-rl-no-folder-exists").hide(),a.find(".bb-rl-location-folder-list-wrap"))).show(),"group"===r?(a.find(".bb-rl-popup-on-fly-create-folder .bb-rl-privacy-field-wrap-hide-show").hide(),a.find(".bb-rl-folder-create-from").val("group")):(a.find(".bb-rl-popup-on-fly-create-folder .bb-rl-privacy-field-wrap-hide-show").show(),a.find(".bb-rl-folder-create-from").val("profile")),a.find(".bb-rl-location-folder-list-wrap .location-folder-list").remove(),a.find(".bb-rl-location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&(e=(e=a.attr("id"))?"#"+e:(t=a.attr("class"))?"."+t.split(" ")[0]:".bb-rl-media-move-file",bp.Nouveau.Media.folderLocationUI(e,n),a.find("ul.location-folder-list span#"+n).trigger("click"))}})},closeMediaMove:function(e){e.preventDefault();e=h(e.currentTarget);0!==e.closest(".bb-rl-media-move-file").find(".bb-rl-location-album-list-wrap .breadcrumb .item span:last-child").data("id")&&e.closest(".bb-rl-media-move-file").find(".bb-rl-location-album-list-wrap .breadcrumb .item span:last-child").remove(),e.closest(".bb-rl-media-move-file").hide().removeClass("open-popup")},closeDocumentMove:function(e){e.preventDefault();var t=h(e.currentTarget),i=jQuery(e.currentTarget).closest(".bb-rl-has-folderlocationUI");(t.hasClass("bb-rl-ac-document-close-button")?(t.closest(".bb-rl-media-move-file"),h(".bb-rl-media-move-file.open-popup").hide().removeClass("open-popup").find(".bb-rl-document-move")):(t.closest(".bb-rl-media-move-folder"),h(".bb-rl-media-move-folder.open-popup").hide().removeClass("open-popup").find(".bb-rl-folder-move"))).attr("id",""),h(".bb-rl-media-move-file.open-popup").removeClass("open-popup").hide(),h(".bb-rl-media-move-folder.open-popup").removeClass("open-popup").hide(),i.find(".bb-rl-document-move.loading").removeClass("loading"),this.clearFolderLocationUI(e)},renameDocument:function(e){var t=h(e.currentTarget).closest(".media-folder_items").find(".media-folder_name"),i=t.children("span").text();t.hide().siblings(".media-folder_name_edit_wrap").show().children(".media-folder_name_edit").val(i).focus().select(),e.preventDefault()},editDocument:function(e){e.preventDefault();var t=h(document),i=h("#bb-rl-media-edit-file"),a=h(e.currentTarget).closest(".media-folder_items"),o=a.find(".media-folder_name").children("span").text(),d=a.data("id"),n=a.find(".media-folder_name").data("attachment-id"),a=a.find(".media-folder_name").data("privacy");h(e.currentTarget).attr("data-privacy")&&0 span"),o=t.closest(".media-folder_items").find(".media-folder_name"),d=t.closest(".media-folder_items").find(".media-folder_name > i.media-document-id").attr("data-item-id"),n=t.closest(".media-folder_items").find(".media-folder_name > i.media-document-attachment-id").attr("data-item-id"),r=t.closest(".media-folder_items").find(".media-folder_name > i.media-document-type").attr("data-item-id"),s=i.val().trim(),l="",l=(t.closest(".ac-document-list").length?l=/[?\[\]=<>:;,'"&$#*()|~`!{}%+ \/]+/g:t.closest(".ac-folder-list").length&&(l=/[\\/?%*:|"<>]+/g),l.exec(s)),l=Boolean(l);if(l?i.addClass("error"):i.removeClass("error"),t.closest(".ac-document-list").length&&(-1!==s.indexOf("\\\\")||l?i.addClass("error"):i.removeClass("error")),!t.hasClass("name_edit_cancel")&&27!==e.keyCode||(i.removeClass("error"),i.parent().hide().siblings(".media-folder_name").show()),t.hasClass("name_edit_save")||13===e.keyCode){if(l)return;i.parent().addClass("submitting").append(''),h.ajax({url:y,type:"post",data:{action:"document_update_file_name",document_id:d,attachment_document_id:n,document_type:r,name:s,_wpnonce:w.media},success:function(e){e.success?void 0!==e.data.document&&0 span"),n=o.find(".media-folder_name"),r=o.find(".media-folder_name > i.media-document-id").attr("data-item-id"),s=o.find(".media-folder_name > i.media-document-attachment-id").attr("data-item-id"),l=o.find(".media-folder_name > i.media-document-type").attr("data-item-id"),c=t.val().trim(),p=0 :;,'"&$#*()|~`!{}%+ \/]+/g:/[\\/?%*:|"<>]+/g).exec(c),m=Boolean(b),b=a.find(".error-box");m?(t.addClass("error"),("folder"===l?b.text(b.data("folder-error")||b.text()):b.text(b.data("document-error")||b.text())).show()):(t.removeClass("error"),b.hide()),"folder"!==l&&o.length&&(-1!==c.indexOf("\\\\")||m?(t.addClass("error"),b.text(b.data("document-error")||b.text()).show()):(t.removeClass("error"),b.hide())),m||(u||f?(i.addClass("saving"),h.ajax({url:y,type:"post",data:{action:"bb_rl_document_rename_and_privacy_update",document_id:r,attachment_document_id:s,document_type:l,name:c,privacy:p,update_name:u,update_privacy:f,_wpnonce:w.media},success:function(e){var t;e.success?(u&&void 0!==e.data.response.document&&0 ');e.parents("li").each(function(e,t){t=h(t).children("span").clone().show();i.prepend("",t)}),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+g.target_text+"")),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").width()&&(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||h('...').insertAfter(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),h(this).hasClass("selected")&&!h(this).hasClass("disabled")?(h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".bb-rl-folder-destination").val(""),h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".bb-rl-folder-selected-id").val("0"),h(a).find(".location-folder-list li.is_active").length?h(a).find(".bb-rl-folder-selected-id").val(h(a).find(".location-folder-list li.is_active").attr("data-id")):h(a).find(".bb-rl-folder-selected-id").val("0")):(h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".location-folder-list li span").removeClass("selected"),h(this).addClass("selected"),h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".bb-rl-folder-destination").val(h(this).text()),h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".bb-rl-folder-selected-id").val(h(this).parent().attr("data-id"))),h(this).closest(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(h(this).siblings("span").text()).siblings(".location-folder-back").css("display","inline-block"),h(this).siblings("ul").show().siblings("span, i").hide().parent().siblings().hide(),h(this).siblings("ul").children("li").show().children("span,i").show(),h(this).closest(".is_active").removeClass("is_active"),h(a).find("li.is_active").removeClass("is_active"),h(this).parent().addClass("is_active"),h(a).find(".bb-rl-folder-selected-id").val(h(a).find(".location-folder-list li.is_active").attr("data-id")),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").each(function(){h(this).show()}),o===h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").attr("data-id")&&(h(a).hasClass("bb-rl-media-move-file")||h(a).hasClass("bb-rl-media-move-folder"))?(h(a).find(".bb-rl-document-move").addClass("is-disabled"),h(a).find(".bb-rl-folder-move").addClass("is-disabled")):(h(a).find(".bb-rl-document-move").removeClass("is-disabled"),h(a).find(".bb-rl-folder-move").removeClass("is-disabled")),setTimeout(function(){h(a).closest(".bb-activity-media-wrap").find(".bb-rl-activity-media-elem.bb-rl-document-activity").attr("data-parent-id")===(h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").prev():h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child")).attr("id")&&(h(a).hasClass("bb-rl-media-move-file")||h(a).hasClass("bb-rl-media-move-folder"))?(h(a).find(".bb-rl-document-move").addClass("is-disabled"),h(a).find(".bb-rl-folder-move").addClass("is-disabled")):(h(a).find(".bb-rl-document-move").removeClass("is-disabled"),h(a).find(".bb-rl-folder-move").removeClass("is-disabled"))},100)}),e.on("click",a+" .bb-rl-breadcrumbs-append-ul-li .item span",function(e){var t,i;h(this).parent().hasClass("is-disabled")||h(this).hasClass("more_options")||(t=h(e.currentTarget).attr("data-id"),h(a).find(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(h(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),h(a).find(".bb-rl-folder-selected-id").val(t),h(a).find(".location-folder-list li").hide(),h(a).find(".location-folder-list li.is_active").removeClass("is_active"),h(a).find(".location-folder-list li > span.selected").removeClass("selected"),h(a).find('.location-folder-list li[data-id="'+t+'"]').addClass("is_active").children("span").addClass("selected"),h(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),h(a).find(".location-folder-list li.is_active").children("ul").length&&!h(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){h(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):h(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?h(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){h(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),"0"===t&&(h(a).find(".location-folder-list").children("li").show().children("span,i").show(),h(a).find(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(g.target_text),h(a).find(".location-folder-back").hide()),h(e.currentTarget).nextAll().remove(),o===h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").attr("data-id")&&(h(a).hasClass("bb-rl-media-move-file")||h(a).hasClass("bb-rl-media-move-folder"))?(h(a).find(".bb-rl-document-move").addClass("is-disabled"),h(a).find(".bb-rl-folder-move").addClass("is-disabled")):(h(a).find(".bb-rl-document-move").removeClass("is-disabled"),h(a).find(".bb-rl-folder-move").removeClass("is-disabled")),e=h(a).find(".location-folder-list .is_active > span"),i=h(''),e.parents("li").each(function(e,t){t=h(t).children("span").clone().show();i.prepend("",t)}),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+g.target_text+"")),0===h(a).find('.bb-rl-breadcrumbs-append-ul-li .breadcrumb .item > span[data-id="'+t+'"]').length&&h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item").append(h(a).find('.location-folder-list li[data-id="'+t+'"]').children("span").clone().show()),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").width()&&(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||h('...').insertAfter(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),h(a).find(".bb-rl-folder-selected-id").val(t))})),h(a).find(".location-folder-list li").each(function(){h(this).children("ul").parent().addClass("has-ul").append('')}),h(a).hasClass("bb-rl-media-move-folder")&&(h(a).find(".location-folder-list li>span").removeClass("is-disabled"),h(a).find('.location-folder-list li>span[id="'+h(a).find(".bb-rl-folder-move").attr("id")+'"]').parent().addClass("is-disabled")),e=h(a).find(".bb-rl-folder-move").attr("id"),0===h(a).find('.location-folder-list li[data-id="'+e+'"]').siblings().length&&h(a).find('.location-folder-list li[data-id="'+e+'"]').parent("ul").addClass("no-folder-list a"),o&&(h(a).find(".location-folder-list li").hide(),h(a).find(".location-folder-list li.is_active").removeClass("is_active"),h(a).find('.location-folder-list li[data-id="'+o+'"]').addClass("is_active"),h(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),h(a).find(".location-folder-list li.is_active").children("ul").length&&!h(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){h(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):h(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?h(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){h(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),h(a).find(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(h(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),h(a).find(".bb-rl-folder-selected-id").val(h(a).find(".location-folder-list li.is_active").attr("data-id")),h(a).find('.location-folder-list li[data-id="'+e+'"]').children().hide()),"0"===o&&(h(a).find(".location-folder-list").children("li").show(),h(a).find(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(g.target_text),h(a).find(".location-folder-back").hide()),setTimeout(function(){var e=h(a).closest(".bb-activity-media-wrap").find(".bb-rl-activity-media-elem.bb-rl-document-activity").attr("data-parent-id"),t=(h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").prev():h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child")).attr("id");e===t&&(h(a).hasClass("bb-rl-media-move-file")||h(a).hasClass("bb-rl-media-move-folder"))?(h(a).find(".bb-rl-document-move").addClass("is-disabled"),h(a).find(".bb-rl-folder-move").addClass("is-disabled")):(h(a).find(".bb-rl-document-move").removeClass("is-disabled"),h(a).find(".bb-rl-folder-move").removeClass("is-disabled"))},100),e=h(a).find(".location-folder-list .is_active > span"),i=h(''),e.parents("li").each(function(e,t){t=h(t).children("span").clone().show();i.prepend("",t)}),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+g.target_text+"")))},clearFolderLocationUI:function(e){e=jQuery(e.currentTarget).closest(".bb-rl-has-folderlocationUI");0 '+e.data.media_group_count+" "+r)):i.find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").length?i.find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count):((d=document.createElement("span")).setAttribute("class","count"),t=document.createTextNode(e.data.media_group_count),d.appendChild(t),i.find(".bp-wrap .users-nav ul li#photos-groups-li a").append(d))),"yes"===g.is_media_directory&&(i.find(".media-type-navs ul.media-nav li#media-all a span.count").text(e.data.media_all_count),i.find(".media-type-navs ul.media-nav li#media-personal a span.count").text(e.data.media_personal_count),i.find(".media-type-navs ul.media-nav li#media-groups a span.count").text(e.data.media_group_count)),void 0!==e.data.album_total_count&&s.updateAlbumCounts(e.data),s.dropzone_media.length),o=0;o").addClass("media-list item-list bp-list bb-photo-list grid")),0<(t=h(".bb-photos-actions")).length&&t.show(),bp.Nouveau.inject("#media-stream ul.media-list",e.data.media,"prepend"),h('.bp-existing-media-wrap .bb-media-check-wrap [name="bb-media-select"]:checked').each(function(){parseInt(h(this).closest("li").data("id"))===parseInt(h(this).val())&&h(this).closest("li").remove()}),void 0===e.data.source_album_id&&void 0===e.data.dest_album_id||(t=h("#buddypress #bp-media-single-album")).length&&(i={},(t=parseInt(t.attr("data-id")||t.attr("data-album-id"))||0)===e.data.source_album_id?(i.album_media_count=e.data.source_album_media_count,i.album_video_count=e.data.source_album_video_count):t===e.data.dest_album_id&&(i.album_media_count=e.data.dest_album_media_count,i.album_video_count=e.data.dest_album_video_count),s.updateAlbumCounts(i)),jQuery(window).scroll(),s.closeUploader(n)):h("#bp-existing-media-content").prepend(e.data.feedback),l.removeClass("saving")}})):s.current_tab||(s.closeUploader(n),l.removeClass("saving"))},submitDocumentMedia:function(a){var o=this,d=h(a.currentTarget),n=h(a.currentTarget).closest("#bp-media-uploader");if(a.preventDefault(),d.hasClass("saving"))return!1;var r=h(document);if(d.addClass("saving"),"bp-dropzone-content"===o.current_tab){var e=h("#bp-media-post-content").val(),t=h("#bb-document-privacy").val(),i=h(a.currentTarget).closest(".open-popup"),s=i.find(".bb-rl-folder-selected-id").val(),i=i.find(".bb-rl-folder-selected-id").data("value"),l=!0;if(s.length&&0 ").addClass("display")),h("#media-stream div").attr("id","media-folder-document-data-table"),h(".bb-photos-actions").show()),h(".document-data-table-head").length?"yes"===g.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(r.find("li#document-personal a").trigger("click"),r.find("li#document-personal").trigger("click")):l&&bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"):location.reload(!0),h("#bp-media-post-content").val("");for(var t=o.dropzone_media.length,i=0;i ]+/g.exec(e.val()),d=Boolean(d);if(""===h.trim(e.val())||d)return e.addClass("error"),!1;e.removeClass("error"),t.prop("disabled",!0).addClass("loading");d={action:"document_edit_folder",_wpnonce:w.media,title:e.val(),privacy:a.val(),id:o,group_id:i.current_group_id};h(".bb-single-album-header .bp-feedback").remove(),h("#bb-rl-media-create-album-popup .bp-feedback").remove(),h.ajax({type:"POST",url:y,data:d,success:function(e){setTimeout(function(){t.prop("disabled",!1)},500),e.success?window.location.reload(!0):i.current_folder?h("#bp-media-single-album").prepend(e.data.feedback):h("#bb-rl-media-create-album-popup .bb-model-header").after(e.data.feedback)}})},deleteAlbum:function(e){e.preventDefault(),this.deleteAttachment(e,"media","album")},deleteFolder:function(e){e.preventDefault(),this.deleteAttachment(e,"document","folder")},injectMedias:function(e){this.injectAttachments(e,"media")},injectDocuments:function(e){this.injectAttachments(e,"document")},sortDocuments:function(e){var e=h(e.currentTarget),t="",i="date_created";switch(e.data("target")){case"name":i="title";break;case"modified":i="date_modified";break;case"visibility":i="privacy";break;case"group":i="group_id"}e.hasClass("asce")?e.removeClass("asce"):e.addClass("asce");var e=e.hasClass("asce")?"DESC":"ASC",a={},a=(a.orderby=i,a.sort=e,"group"!==i&&bp.Nouveau.setStorage("bp-document","extras",a),bp.Nouveau.getStorage("bp-document")),o=a.scope||null,a=a.filter||null,d=h("#buddypress .bp-dir-search-form input[type=search]");d.length&&(t=d.val()),this.sort_by=e,this.order_by=i,this.current_page=1,bp.Nouveau.objectRequest({object:"document",scope:o,filter:a,search_terms:t,page:1,order_by:i,sort:e,method:"reset",target:"#buddypress [data-bp-list]"}).done()},documentPopupNavigate:function(e){e.preventDefault();var e=h(e.currentTarget),t=e.closest(".bb-field-steps"),i=0===e.closest(".bp-document-listing").length?"#bb-album-child-title":"#bb-album-title";e.closest(".document-options").length&&(i="#bb-album-title"),e.hasClass("bb-field-steps-next")&&""===t.find(i).val().trim()?t.find(i).addClass("error"):(t.find(i).removeClass("error"),t.slideUp(200).siblings(".bb-field-steps").slideDown(200))},uploadDocumentNavigate:function(e){e.preventDefault();var e=h(e.currentTarget),t=h(e).closest("#bp-media-uploader");h(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-document-submit, #bp-media-document-prev, .bb-rl-document-open-create-popup-folder, #bb-document-privacy").show(),0!==Number(h(t).find(".bb-rl-folder-selected-id"))&&h(t).find(".location-folder-list li.is_active").length&&h(t).find(".location-folder-list").scrollTop(h(t).find(".location-folder-list li.is_active").offset().top-h(t).find(".location-folder-list").offset().top),h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").width()&&(h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||h('...').insertAfter(h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))})):(h(e).hide(),t.find("#bp-media-document-prev, .bb-rl-document-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-folder").length&&h("#bb-document-privacy").hide())},uploadMediaNavigate:function(e){e.preventDefault();var e=h(e.currentTarget),t=h(e).closest(".bp-media-photo-uploader");h(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-submit, #bp-media-prev, .bb-rl-media-open-create-popup-folder.create-album").show(),t.find("#bb-media-privacy").show(),0!==Number(h(t).find(".bb-rl-album-selected-id"))&&h(t).find(".location-album-list li.is_active").length&&h(t).find(".location-album-list").scrollTop(h(t).find(".location-album-list li.is_active").offset().top-h(t).find(".location-album-list").offset().top)):(h(e).hide(),t.find("#bp-media-prev, .bb-rl-media-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-album").length&&h("#bb-media-privacy").hide())},appendMedia:function(e){var t,i,a,o=bp.Nouveau.getStorage("bp-media"),d=o.scope||null,o=o.filter||null,n=h(e.currentTarget);n.hasClass("load-more")&&(t=Number(this.current_page_existing_media)+1,i=this,a="",e.preventDefault(),n.find("a").first().addClass("loading"),(e=h("#buddypress .dir-search input[type=search]")).length&&(a=e.val()),bp.Nouveau.objectRequest({object:"media",scope:d,filter:o,search_terms:a,page:t,method:"append",caller:"bp-existing-media",target:".bp-existing-media-wrap ul.bp-list"}).done(function(e){!0===e.success&&(n.remove(),i.current_page_existing_media=t,jQuery(window).scroll())}))},appendAlbums:function(t){var i=Number(this.current_page_albums)+1,a=this,e=(t.preventDefault(),h(t.currentTarget).find("a").first().addClass("loading"),{action:"media_albums_loader",_wpnonce:w.media,page:i});h.ajax({type:"POST",url:y,data:e,success:function(e){!0===e.success&&(h(t.currentTarget).remove(),h("#albums-dir-list ul.bb-albums-list").fadeOut(100,function(){h("#albums-dir-list ul.bb-albums-list").append(e.data.albums),h(this).fadeIn(100)}),a.current_page_albums=i)}})},toggleSubmitMediaButton:function(){var e=h("#bp-media-submit"),t=h("#bp-media-add-more");"bp-dropzone-content"===this.current_tab?this.dropzone_obj.getAcceptedFiles().length?(e.show(),t.show()):(e.hide(),t.hide()):"bp-existing-media-content"===this.current_tab&&(h('.bp-existing-media-wrap .bb-media-check-wrap [name="bb-media-select"]:checked').length?e.show():e.hide(),t.hide())},playVideo:function(e){e.preventDefault();var e=h(e.currentTarget),t=e.find("video").get(0),e=e.find(".gif-play-button");!0===t.paused?(t.play().catch(function(e){console.debug("GIF play failed:",e)}),e.hide()):(t.pause(),e.show())},throttledAutoPlayGifVideos:function(){this.throttleTimer||(this.throttleTimer=setTimeout(function(){bp.Nouveau.Media.throttleTimer=null,bp.Nouveau.Media.autoPlayGifVideos()},100))},invokeMediaFn:function(e){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media[e]&&bp.Nouveau.Media[e]()},isElementInScrollableContainer:function(e){var t=h(e),i=t.closest("#bp-message-thread-list");return(i=(i=i.length?i:t.closest(".bb-rl-modal-activity-body")).length?i:t.closest(".bb-rl-media-model-container .bb-media-info-section")).length?(e=e.getBoundingClientRect(),i=i[0].getBoundingClientRect(),e.bottom>i.top&&e.top i.left&&e.left '),h(t).text()),e=(h(t).text(g.copy_to_clip_board_text),h("#"+e));return e.val(h(t).attr("href")),e.select(),document.execCommand("copy"),setTimeout(function(){h(t).text(i)},2e3),!1},fileActivityActionButton:function(e){e.preventDefault();var t=h(e.currentTarget);t.parent().hasClass("bb_rl_copy_download_file_url")||(t.closest(".bb-rl-activity-media-elem").toggleClass("is-visible").siblings().removeClass("is-visible").closest(".activity-item").siblings().find(".bb-rl-activity-media-elem").removeClass("is-visible"),t.closest(".bb-rl-activity-media-elem").find(".bb_rl_more_dropdown").toggleClass("open").closest(".bb-rl-activity-media-elem").siblings().find(".bb_rl_more_dropdown").removeClass("open").closest(".activity-item").siblings().find(".bb-rl-activity-media-elem .bb_rl_more_dropdown").removeClass("open"),h("body").addClass("document_more_option_open"),t.closest(".bb-rl-activity-media-elem").length<1&&(t.closest(".bb-photo-thumb").toggleClass("is-visible").parent().siblings().find(".bb-photo-thumb").removeClass("is-visible").removeClass("is-visible"),t.closest(".bb-photo-thumb").find(".bb_rl_more_dropdown").toggleClass("open").closest(".bb-photo-thumb").parent().siblings().find(".bb-photo-thumb .bb_rl_more_dropdown").removeClass("open")),"a"!==e.currentTarget.tagName.toLowerCase())||t.hasClass("bb-rl-document-action_more")||t.hasClass("bb_rl_more_dropdown__action")||(t.closest(".bb-rl-activity-media-elem").removeClass("is-visible").find(".bb_rl_more_dropdown").removeClass("open"),t.closest(".bb-photo-thumb").removeClass("is-visible").find(".bb_rl_more_dropdown").removeClass("open"))},toggleFileActivityActionButton:function(e){var t;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),!0===e.altKey||!0===e.metaKey||h(t).hasClass("bb-rl-document-action_more")||h(t).parent().hasClass("bb-rl-document-action_more")||h(t).hasClass("media-folder_action__anchor")||h(t).parent().hasClass("media-folder_action__anchor")||h(t).hasClass("bb_rl_more_dropdown__action")||h(t).parent().hasClass("bb_rl_more_dropdown__action")?e:(h(".bb-rl-activity-media-elem.is-visible").removeClass("is-visible"),h(".media-folder_items.is-visible").removeClass("is-visible"),h(".bb-photo-thumb.is-visible").removeClass("is-visible"),h(".bb-item-thumb.is-visible").removeClass("is-visible"),h(".bb-rl-activity-video-elem.is-visible").removeClass("is-visible"),h(".bb-rl-more_dropdown-wrap.is-visible").removeClass("is-visible"),h(".bb-rl-more_dropdown-wrap .bb_rl_more_dropdown").removeClass("open"),h(".bb-rl-activity-media-elem .bb_rl_more_dropdown").removeClass("open"),h(".bb-photo-thumb .bb_rl_more_dropdown").removeClass("open"),h(".media-folder_items .bb_rl_more_dropdown").removeClass("open"),void h("body").removeClass("document_more_option_open video_more_option_open item_more_option_open"))},toggleCodePreview:function(e){e.preventDefault(),h(e.currentTarget).closest(".bb-rl-document-activity").toggleClass("code-full-view")},documentCodeMirror:function(){h(".bb-rl-document-text:not(.loaded), .document-text:not(.loaded)").each(function(){var e=h(this),t=e.attr("data-extension"),i=e.attr("data-extension");"html"!==t&&"htm"!==t||(i="text/html"),"js"===t?CodeMirror(e[0],{value:(0 '+e+""))},setupForumDropzoneEvents:function(e){var c=e.self,a=e.dropzoneObj,d=e.target,p=e.type,b=e.dropzoneDataObj,m=e.dropzoneContainer;"video"===p&&a.on("addedfile",function(e){e.dataURL&&e.dataThumb&&e.dataThumb.length?h(e.previewElement).find(".dz-video-thumbnail").prepend(' '):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-image")}),a.on("sending",function(e,t,i){i.append("action","document"===p?p+"_"+p+"_upload":p+"_upload");var a="document"===p?"media":p,o=(i.append("_wpnonce",w[a]),d.closest("form"));o.addClass("has-media"),["media","document","video","gif"].forEach(function(e){var t=o.find("#bb-rl-forums-"+e+"-button");t&&(t=t.parents(".bb-rl-post-elements-buttons-item"),p===e?t.addClass("no-click"):t.addClass("disable"))})}),a.on("uploadprogress",function(e){d.closest("form").addClass("media-uploading");var t=h(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=a,"video"===p&&(e.upload.progress<=99?(h(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+v.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,h(e.previewElement).find(".dz-progress-count").text("99% "+v.i18n_strings.video_uploaded_text)))}),a.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?h(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"===e.status&&e.xhr&&0===e.xhr.status&&h(e.previewElement).find(".dz-error-message span").text(g.connection_lost_error):(jQuery(".forum-"+("media"===p?"document":p)+"-error-popup").length||("media"===p?h("body").append('"):"document"===p?h("body").append('"):"video"===p&&h("body").append('")),this.removeFile(e),d.closest("form").removeClass("media-uploading"))}),"media"!==p&&a.on("accept",function(e,t){0===e.size?t(g["empty_"+p+"_type"]):t()}),a.on("success",function(e,t){var i,a;if("video"===p&&100===e.upload.progress&&(h(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,h(e.previewElement).find(".dz-progress-count").text("100% "+v.i18n_strings.video_uploaded_text),h(e.previewElement).closest(".dz-preview").addClass("dz-complete")),t.data.id)e.id=t.data.id,t.data.uuid=e.upload.uuid,t.data.menu_order=h(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.group_id=c.group_id,t.data.saved=!1,"media"===p?t.data.album_id=c.album_id:"document"===p?t.data.folder_id=c.current_folder:"video"===p&&(t.data.album_id=c.album_id,t.data.js_preview=h(e.previewElement).find(".dz-image img").attr("src")),b.push(t.data),m.closest("#whats-new-attachments").find("#bbp_"+p).length&&m.closest("#whats-new-attachments").find("#bbp_"+p).val(JSON.stringify(b)),"document"===p&&(a=(a=e.upload.filename).substr(a.lastIndexOf(".")+1),i=_.isUndefined(t.data.svg_icon)?"":t.data.svg_icon,a=_.isEmpty(i)?"bb-icon-file-"+a:i,h(e.previewElement).find(".dz-details .dz-icon .bb-icons-rl-file").length)&&h(e.previewElement).find(".dz-details .dz-icon .bb-icons-rl-file").removeClass("bb-icon-file").addClass(a);else if("media"===p)jQuery(".forum-"+p+"-error-popup").length||h("body").append('"),this.removeFile(e);else if("document"===p||"video"===p){var o,d,n,r,s,l=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],d=0,n=(r=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;d
'):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-image")}),a.on("sending",function(e,t,i){i.append("action","document"===p?p+"_"+p+"_upload":p+"_upload");var a="document"===p?"media":p,o=(i.append("_wpnonce",w[a]),d.closest("#send_group_message_form"));["media","document","video","gif"].forEach(function(e){var t=o.find("#bp-group-messages-"+e+"-button");t&&(t=t.parents(".post-elements-buttons-item"),p===e?t.addClass("no-click"):t.addClass("disable"))})}),a.on("uploadprogress",function(e){var t=h(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=a,"video"===p&&(e.upload.progress<=99?(h(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+v.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,h(e.previewElement).find(".dz-progress-count").text("99% "+v.i18n_strings.video_uploaded_text)))}),a.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?h(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"===e.status&&e.xhr&&0===e.xhr.status&&h(e.previewElement).find(".dz-error-message span").text(g.connection_lost_error):("media"===p||"document"===p?jQuery(".group-"+("media"===p?"document":p)+"-error-popup").length||("document"===p?h("body").append('"):h("body").append('")):h("body").append('"),this.removeFile(e))}),"media"!==p&&a.on("accept",function(e,t){0===e.size?t(g["empty_"+p+"_type"]):t()}),a.on("success",function(e,t){if("video"===p&&100===e.upload.progress&&(h(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,h(e.previewElement).find(".dz-progress-count").text("100% "+v.i18n_strings.video_uploaded_text),h(e.previewElement).closest(".dz-preview").addClass("dz-complete")),t.data.id){e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=h(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.group_id=c.group_id,t.data.saved=!1,"media"===p?t.data.album_id=c.album_id:"document"===p?t.data.folder_id=c.current_folder:"video"===p&&(t.data.album_id=c.album_id,t.data.js_preview=h(e.previewElement).find(".dz-video-thumbnail img").attr("src")),b.push(t.data);var i,a=h("#bp_group_messages_"+p);a.length&&a.val(JSON.stringify(b)),"document"===p&&(a=(a=e.upload.filename).substr(a.lastIndexOf(".")+1),i=_.isUndefined(t.data.svg_icon)?"":t.data.svg_icon,a=_.isEmpty(i)?"bb-icons-rl-"+a:i,h(e.previewElement).find(".dz-details .dz-icon .bb-icons-rl").length)&&h(e.previewElement).find(".dz-details .dz-icon .bb-icons-rl").removeClass("bb-icon-file").addClass(a)}else if("media"===p)jQuery(".group-message-error-popup").length||h("body").append('"),this.removeFile(e);else if("document"===p||"video"===p){var o,d,n,r,s,l=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],d=0,n=(r=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;d "+t+" h(n).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").width()&&(h(n).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(h(n).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),h(n).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||h('...').insertAfter(h(n).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),"media"===a&&d.updateAlbumNavCount(e.data.album_count),r.removeClass("loading"),"document"===a&&setTimeout(function(){var e=n.find("ul"+v+" span#"+u),t=(e.trigger("click"),h(n).find("#bb-document-privacy"));0!==Number(e.data("id"))?(t.find("option").removeAttr("selected"),t.val(e.parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1))},200)):r.removeClass("loading")}}),this.currentTargetParent=u,n.find(v+" li.is_active").show().children("span, i").show().siblings("ul").hide(),n.find(v+" li.is_active").siblings("li").show().children("span, i").show().siblings("ul").hide(),n.find(v+" li span.selected").removeClass("selected"),n.find(v+" li.is_active").children("span").addClass("selected")},0)},setMediaSelectionState:function(e){var i=h("#buddypress").find(".media-list:not(.existing-media-list)"),a=!0===e,e=["media"];0 ]+/g.test(p.val());if(""===h.trim(p.val())||m)return p.addClass("error"),!1;if(p.removeClass("error"),n||r){if(!c.group_id&&""===h.trim(o.val()))return o.addClass("error"),!1;o.removeClass("error")}d.prop("disabled",!0).toggleClass(n?"saving":"loading");m={action:t+"_"+e+"_save",_wpnonce:b,title:p.val()};n?("media"===t?m.medias=c.dropzone_media:"video"===t&&(m.videos=a),m.privacy=o.val(),c.album_id&&(m.album_id=c.album_id),c.group_id&&(m.group_id=c.group_id)):r?(m.privacy=o.val(),m.album_id=c.current_folder,m.group_id=c.current_group_id):s&&(m.folder_id=c.current_folder,m.group_id=c.current_group_id),h(".bb-single-album-header .bp-feedback, #bb-rl-media-create-album-popup .bp-feedback").remove(),h.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:m,success:function(e){var t;(n||r)&&setTimeout(function(){n&&d.removeClass("saving"),d.prop("disabled",!1)},500),e.success?n?c.album_id?(h("#bp-single-album-title .title-wrap").text(p.val()),h("#bb-album-privacy").val(o.val()),c.cancelEditAlbumTitle(i),l.find("#bp-media-edit-album-close").trigger("click")):(h("#buddypress .bb-albums-list").prepend(e.data.album),window.location.href=e.data.redirect_url):r?(c.closeFolderUploader(i),h(".document-data-table-head").length?"yes"===BP_Nouveau.media.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(h(document).find("li#document-personal a").trigger("click"),h(document).find("li#document-personal").trigger("click")):(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()):location.reload(!0)):s&&(c.closeChildFolderUploader(i),location.reload(!0)):n?(t=c.album_id?"#bp-media-single-album":"#bb-rl-media-create-album-popup .bb-model-header",h(t).prepend(e.data.feedback)):alert(e.data.feedback.replace("'","'"))}})}},disableButtonsInToolBox:function(t,e){e.forEach(function(e){e=t.find(e);e.length&&e.parents(".bb-rl-post-elements-buttons-item").addClass("disable")})}},bp.Nouveau.Media.Theatre={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){this.medias=[],this.documents=[],this.current_media=!1,this.current_document=!1,this.current_index=0,this.current_document_index=0,this.is_open_media=!1,this.is_open_document=!1,this.nextLink=h(".bb-rl-next-media"),this.nextDocumentLink=h(".bb-rl-next-document"),this.previousDocumentLink=h(".bb-rl-prev-document"),this.previousLink=h(".bb-rl-prev-media"),this.activity_ajax=!1,this.group_id=void 0!==g.group_id&&g.group_id},addListeners:function(){var e=h(document);e.on("click",".bb-rl-open-media-theatre",this.openTheatre.bind(this)),e.on("click",".bb-rl-open-document-theatre",this.openDocumentTheatre.bind(this)),e.on("click",".bb-rl-document-detail-wrap-description-popup",this.openDocumentTheatre.bind(this)),e.on("click",".bb-rl-close-media-theatre",this.closeTheatre.bind(this)),e.on("click",".bb-close-document-theatre",this.closeDocumentTheatre.bind(this)),e.on("click",".bb-icons-rl-sidebar-simple",this.ToggleTheatreSidebar.bind(this)),e.on("click",".bb-rl-prev-media",this.previous.bind(this)),e.on("click",".bb-rl-next-media",this.next.bind(this)),e.on("click",".bb-rl-prev-document",this.previousDocument.bind(this)),e.on("click",".bb-rl-next-document",this.nextDocument.bind(this)),e.on("bp_activity_ajax_delete_request",this.activityDeleted.bind(this)),e.on("click","#bb-rl-media-model-container .media-privacy>li",this.mediaPrivacyChange.bind(this)),e.on("click","#bb-rl-media-model-container .document-privacy>li",this.documentPrivacyChange.bind(this)),e.on("click","#bb-rl-media-model-container .bb-rl-media-section span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),e.on("click","#bb-rl-media-model-container .bb-rl-document-section span.privacy",bp.Nouveau,this.toggleDocumentPrivacyDropdown.bind(this)),e.on("click",".bp-add-media-activity-description",this.openMediaActivityDescription.bind(this)),e.on("click","#bp-activity-description-new-reset",this.closeMediaActivityDescription.bind(this)),e.on("keyup",".bp-edit-media-activity-description #add-activity-description",this.MediaActivityDescriptionUpdate.bind(this)),e.on("click","#bp-activity-description-new-submit",this.submitMediaActivityDescription.bind(this)),e.on("click",".bb-rl-media-thumb",this.handleThumbnailClick.bind(this)),e.click(this.togglePopupDropdown),document.addEventListener("keyup",this.checkPressedKeyDocuments.bind(this)),document.addEventListener("keyup",this.checkPressedKey.bind(this))},checkPressedKey:function(e){var t=this;if(e=e||window.event,!t.is_open_media)return!1;var i=h(e.target).hasClass("ac-input")||"add-activity-description"===h(e.target).attr("id");switch(e.keyCode){case 27:t.closeTheatre(e);break;case 37:if(void 0===t.medias[t.current_index-1]||i)return!1;t.previous(e);break;case 39:if(void 0===t.medias[t.current_index+1]||i)return!1;t.next(e)}},checkPressedKeyDocuments:function(e){e=e||window.event;var t=this;if(!t.is_open_document)return!1;var i=h(e.target).hasClass("ac-input")||"add-activity-description"===h(e.target).attr("id");switch(e.keyCode){case 27:t.closeDocumentTheatre(e);break;case 37:if(void 0===t.documents[t.current_document_index-1]||i)return!1;t.previousDocument(e);break;case 39:if(void 0===t.documents[t.current_document_index+1]||i)return!1;t.nextDocument(e)}},handleOpenTheatre:function(e){var t=e.target,i=e.self||this,a=e.modalWrapper,o=e.mediaType,e=e.action,d=(i.setupGlobals(),i.setMedias({target:t,modalWrapper:a,mediaType:o,action:e}),t.data("id")),d=(i.setCurrentMedia(d),i.showMedia({modalWrapper:a,mediaType:o,action:e}),i.navigationCommands(),i.current_activity_data&&i.generateAndDisplayMediaThumbnails({target:t,modalWrapper:a,mediaType:o,action:e}),i.getParentActivityHtml({target:t,modalWrapper:a,mediaType:o,action:e}),i.getMediasDescription({modalWrapper:a,mediaType:o,action:e}),t.closest(".activity-item").data("activity-popup-title")),o=(h(a+" .bb-rl-media-model-header h2").text(d),h(a+".document").hide(),document.getElementById(h(a+".video video").attr("id")));o&&o.pause(),h(a+".video").length&&h(a+".video").hide(),h(a+"."+e).length&&h(a+"."+e).show(),i.is_open_media=!0,bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay")},openTheatre:function(e){e.preventDefault();var t=h(e.currentTarget);if(this.current_activity_data=t.closest(".activity-item").data("bp-activity"),t.closest("#bp-existing-media-content").length)return!1;this.handleOpenTheatre({self:this,target:t,event:e,modalWrapper:".bb-rl-media-model-wrapper",action:"media"})},getParentActivityHtml:function(e){var t=e.target,e=e.action;if("comment"===t.data("privacy"))return!1;var i=h("#hidden_parent_id"),a=i.val(),t=t.closest(".bb-rl-"+e+"-model-wrapper").find("#bb-rl-"+e+"-model-container .bb-rl-activity-list li.activity-item").data("bp-activity-id");parseInt(a)===parseInt(t)&&(t=h("#bb-rl-"+e+'-model-container [data-bp-activity-id="'+a+'"]'),h('[data-bp-activity-id="'+a+'"] > .activity-state').html(h(t).find(".activity-state").html()),h('[data-bp-activity-id="'+a+'"] > .activity-meta').html(h(t).find(".activity-meta").html()),h('[data-bp-activity-id="'+a+'"] > .bb-rl-activity-comments').html(h(t).find(".bb-rl-activity-comments").html())),i.length&&i.remove()},getMediasDescription:function(e){var t=e.action;this.fetchMediaDescription(this.current_media,h(".bb-rl-"+t+"-model-wrapper"),e)},openDocumentTheatre:function(e){e.preventDefault();var t=h(e.currentTarget),i=this;if(t.closest("#bp-existing-document-content").length)return!1;t.closest(".document.bb-rl-document-theatre").length&&i.closeDocumentTheatre(e),a=t.data("id"),i.setupGlobals(),i.setDocuments(t),i.setCurrentDocument(a),i.showDocument(),i.navigationDocumentCommands(),i.getParentActivityHtml({target:t,action:"media"}),i.getDocumentsDescription();var a=t.closest(".activity-item").data("activity-popup-title"),t=(h(".bb-rl-media-model-wrapper .bb-rl-media-model-header h2").text(a),-1!==h.inArray(i.current_document.extension,r.mp3_preview_extension.split(","))&&h(e.currentTarget).closest(".bb-rl-activity-media-elem.bb-rl-document-activity").length&&h(e.currentTarget).closest(".bb-rl-activity-media-elem.bb-rl-document-activity").find(".bb-rl-document-audio-wrap").length&&h(e.currentTarget).closest(".bb-rl-activity-media-elem.bb-rl-document-activity").find(".bb-rl-document-audio-wrap audio")[0].pause(),h(".bb-rl-media-model-wrapper.media").hide(),h(".bb-rl-media-model-wrapper.document").show(),document.getElementById(h(".bb-rl-media-model-wrapper.video video").attr("id")));t&&(t.pause(),t.src=""),h(".bb-rl-media-model-wrapper.video").hide(),i.is_open_document=!0,setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay")},500)},resetRemoveActivityCommentsData:function(e){var t,i=this,a=!1,o=!1,d=!1,n=!1,r=!1,s=!1;i.current_media.parent_activity_comments&&((a=(n=h(".bb-rl-"+e+'-model-wrapper.media [data-bp-activity-id="'+i.current_media.activity_id+'"]')).find(".bb-rl-activity-comments")).length&&(t=a.find("#ac-form-"+i.current_media.activity_id),this.purgeEditActivityForm(t),t.find("#ac-input-"+i.current_media.activity_id).html(""),t.removeClass("has-content has-gif has-media").addClass("root"),a.append(t),t.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(i.current_media.activity_id),a.find(".acomment-display").removeClass("display-focus"),a.find(".comment-item").removeClass("comment-item-focus"),r=a.html(),s=a.attr("class"),a.remove(),(a=h('[data-bp-activity-id="'+i.current_media.activity_id+'"] .bb-rl-activity-comments')).length)&&(a.attr("class",s),0===a.find("#ac-form-"+i.current_media.activity_id).length)&&(a.append(t),a.children("form").removeClass("events-initiated").addClass("not-initialized")),(d=n.find(".activity-state")).length&&(r=d.html(),s=d.attr("class"),d.remove(),(d=h('[data-bp-activity-id="'+i.current_media.activity_id+'"] .activity-state')).length)&&(d.html(r),d.attr("class",s)),(o=n.find(".activity-meta")).length&&(r=o.html(),s=o.attr("class"),o.remove(),(o=h('[data-bp-activity-id="'+i.current_media.activity_id+'"] > .activity-meta')).length)&&(o.html(r),o.attr("class",s)),n.remove()),i.current_document.parent_activity_comments&&((a=(n=h(".bb-rl-"+e+'-model-wrapper.document [data-bp-activity-id="'+i.current_document.activity_id+'"]')).find(".bb-rl-activity-comments")).length&&(t=a.find("#ac-form-"+i.current_document.activity_id),this.purgeEditActivityForm(t),t.find("#ac-input-"+i.current_document.activity_id).html(""),t.removeClass("has-content has-gif has-media").addClass("root"),a.append(t),t.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(i.current_document.activity_id),a.find(".acomment-display").removeClass("display-focus"),a.find(".comment-item").removeClass("comment-item-focus"),r=a.html(),s=a.attr("class"),a.remove(),(a=h('[data-bp-activity-id="'+i.current_document.activity_id+'"] .bb-rl-activity-comments')).length)&&(a.attr("class",s),0===a.find("#ac-form-"+i.current_document.activity_id).length&&(a.append(t),a.children("form").removeClass("events-initiated").addClass("not-initialized")),a.find(".bb-rl-document-text.loaded").removeClass("loaded").find(".CodeMirror").remove(),jQuery(window).scroll()),(d=n.find(".activity-state")).length&&(r=d.html(),s=d.attr("class"),d.remove(),(d=h('[data-bp-activity-id="'+i.current_document.activity_id+'"] .activity-state')).length)&&(d.html(r),d.attr("class",s)),(o=n.find(".activity-meta")).length&&(r=o.html(),s=o.attr("class"),o.remove(),(o=h('[data-bp-activity-id="'+i.current_document.activity_id+'"] > .activity-meta')).length)&&(o.html(r),o.attr("class",s)),n.remove()),bp.Nouveau.reportPopUp(),bp.Nouveau.reportActions()},closeTheatre:function(e){e.preventDefault();var e=h(e.currentTarget),t="";if(e.closest(".bb-rl-internal-model").hasClass("media-video")?t="media-video":e.closest(".bb-rl-internal-model").hasClass("media")?t="media":e.closest(".bb-rl-internal-model").hasClass("video")&&(t="video"),h(e).closest(".bb-rl-"+t+"-model-wrapper").hasClass("bb-rl-video-theatre"))return!1;var i=h(".bb-rl-"+t+"-model-wrapper.media .bb-rl-media-section"),i=(i.find("img").attr("src",""),i.find("video"));i.length&&videojs(i.attr("id")).reset(),h(".bb-rl-"+t+"-model-wrapper").hide(),this.is_open_media=!1,this.resetRemoveActivityCommentsData(t),this.current_media=!1,this.getParentActivityHtml({target:e,action:t})},closeDocumentTheatre:function(e){e.preventDefault();var t=h(document).find(".bb-rl-document-theatre");t.find(".bb-rl-media-section").removeClass("bb-media-no-preview").find(".document-preview").html(""),h(".bb-media-info-section.document").show(),t.hide(),this.is_open_document=!1,this.resetRemoveActivityCommentsData("media"),this.current_document=!1,this.getParentActivityHtml({target:h(e.currentTarget),action:"media"})},ToggleTheatreSidebar:function(e){e.preventDefault(),h(e.currentTarget).closest(".bb-rl-media-model-container").toggleClass("bb-rl-media-toggle-sidebar")},setMedias:function(e){var t=e.target,e=e.action,i=h(t),a=0;if("media-video"===e&&(i=h(".bb-rl-open-"+e+"-theatre")),void 0!==(i=h("body").hasClass("activity")?h(t).closest(".bb-activity-media-wrap").find(".bb-rl-open-"+e+"-theatre"):i)){this.medias=[];for(var o=i.length,a=0;a '):h(i+" .bb-rl-media-section").children("img").length?e.find("img").attr("src",t.current_media.attachment):e.html(' ')):h(i+" .bb-rl-media-section").find("img").attr("src",t.current_media.attachment);a=h(".bb-rl-media-section .bb-media-privacy-wrap");a.length&&(a.show(),a.find("ul.media-privacy li").removeClass("selected"),a.find(".bp-tooltip").attr("data-bp-tooltip",""),(e=a.find("ul.media-privacy").find("li[data-value="+t.current_media.privacy+"]")).addClass("selected"),a.find(".bp-tooltip").attr("data-bp-tooltip",e.text()),a.find(".privacy").removeClass("public").removeClass("loggedin").removeClass("onlyme").removeClass("friends").addClass(t.current_media.privacy),!(void 0!==l&&void 0!==t.current_media.activity_id&&0!==t.current_media.activity_id||t.group_id||t.current_media.is_forum||t.current_media.group_id||t.current_media.album_id||t.current_media.is_message)&&t.can_manage_media&&t.current_media.can_edit||a.hide()),t.navigationCommands()},showDocument:function(){var e=this;if(void 0===e.current_document)return!1;var t,i=e.current_document.target_text,a=e.current_document.target_icon_class,o=h(document).find(".bb-rl-document-theatre"),d=e.current_document.extension,n=e.current_document.mirror_text,d=(o.find(".bb-rl-document-section").removeClass("bb-video-preview"),-1!==h.inArray(e.current_document.extension,["css","txt","js","html","htm","csv"])?(o.find(".bb-rl-document-section .document-preview").html(''),o.find(".bb-rl-document-section").removeClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),o.find(".bb-rl-document-section .document-preview").html("
"+i+'
'),o.find(".bb-rl-document-section .document-preview .bb-rl-document-text").attr("data-extension",d),t=o.find(".bb-rl-document-section .document-preview .bb-rl-document-text textarea"),"html"===d||"htm"===d?t.val(n):t.html(n),setTimeout(function(){bp.Nouveau.Media.documentCodeMirror()},1e3)):-1!==h.inArray(e.current_document.extension,r.mp3_preview_extension.split(","))?(o.find(".bb-rl-document-section .document-preview").html(''),o.find(".bb-rl-document-section").removeClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),o.find(".bb-rl-document-section .document-preview").html('')):-1!==h.inArray("."+e.current_document.extension,v.video_type.split(","))?(o.find(".bb-rl-document-section").addClass("bb-video-preview"),o.find(".bb-rl-document-section .document-preview").html(''),o.find(".bb-rl-document-section").removeClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),"mov"===e.current_document.extension||"m4v"===e.current_document.extension?o.find(".bb-rl-document-section .document-preview").html(''):o.find(".bb-rl-document-section .document-preview").html(''),h(window).scroll()):e.current_document.full_preview?(o.find(".bb-rl-document-section").removeClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),o.find(".bb-rl-document-section .document-preview").html("'+i+'
"+i+'
')):(o.find(".bb-rl-document-section").addClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),o.find(".bb-rl-document-section .document-preview").html('")),h(".bb-rl-document-section .bb-document-privacy-wrap"));d.length&&(d.show(),d.parent().show(),d.find("ul.document-privacy li").removeClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",""),(t=d.find("ul.document-privacy").find("li[data-value="+e.current_document.privacy+"]")).addClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",t.text()),d.find(".privacy").removeClass("public").removeClass("loggedin").removeClass("onlyme").removeClass("friends").addClass(e.current_document.privacy),void 0!==l&&void 0!==e.current_document.activity_id&&0!==e.current_document.activity_id||e.group_id||e.current_document.is_forum||e.current_document.group_id||e.current_document.album_id||!e.can_manage_document||!e.current_document.can_edit||e.current_document.is_message)&&d.parent().hide(),e.navigationDocumentCommands()},generateAndDisplayMediaThumbnails:function(e){var t,i=e.target,e=e.action,a=this;a.current_activity_data=i.closest(".activity-item").data("bp-activity"),!a.current_activity_data||!a.current_activity_data.media||a.current_activity_data.media.length<=1||(i=a.current_activity_data.media.map(function(e){return''+i+"
'}).join(""),(t=(e=h("."+e+".bb-rl-"+e+"-theatre .bb-rl-media-section")).find(".bb-rl-media-thumbnails")).length?t.html(i):e.append(''+i+""))},handleThumbnailClick:function(e){var t,i,a,e=h(e.currentTarget);!e.hasClass("active")&&((i=h(".bb-rl-media-model-wrapper.media .bb-rl-media-section").find("figure")).find("img").hide(),i.addClass("loading").append(''),t=e.data("id"),i=this.medias.find(function(e){return e.id===t}))&&(a="",e.closest(".bb-rl-internal-model").hasClass("media-video")?a="media-video":e.closest(".bb-rl-internal-model").hasClass("media")?a="media":e.closest(".bb-rl-internal-model").hasClass("video")&&(a="video"),this.updateMedia(i,e,{modalWrapper:".bb-rl-"+a+"-model-wrapper",action:a}))},next:function(e){e.preventDefault();var e=h(e.currentTarget),t="";e.closest(".bb-rl-internal-model").hasClass("media-video")?t="media-video":e.closest(".bb-rl-internal-model").hasClass("media")?t="media":e.closest(".bb-rl-internal-model").hasClass("video")&&(t="video");var e={modalWrapper:".bb-rl-"+t+"-model-wrapper",action:t},i=this;i.current_activity_data&&i.medias[i.current_index+1]?i.updateMedia(i.medias[i.current_index+1],h("."+t+".bb-rl-"+t+"-theatre .bb-rl-media-thumb").eq(i.current_index+1),e):(i.resetRemoveActivityCommentsData(t),void 0!==i.medias[i.current_index+1]?(i.current_index=i.current_index+1,i.current_media=i.medias[i.current_index],e.mediaType=i.medias[i.current_index].type||"",i.showMedia(e),i.getMediasDescription(e),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):i.nextLink.hide())},previous:function(e){e.preventDefault();var e=h(e.currentTarget),t="";e.closest(".bb-rl-internal-model").hasClass("media-video")?t="media-video":e.closest(".bb-rl-internal-model").hasClass("media")?t="media":e.closest(".bb-rl-internal-model").hasClass("video")&&(t="video");var e={modalWrapper:".bb-rl-"+t+"-model-wrapper",action:t},i=this;i.current_activity_data&&i.medias[i.current_index-1]?i.updateMedia(i.medias[i.current_index-1],h("."+t+".bb-rl-"+t+"-theatre .bb-rl-media-thumb").eq(i.current_index-1),e):(i.resetRemoveActivityCommentsData(t),void 0!==i.medias[i.current_index-1]?(i.current_index=i.current_index-1,i.current_media=i.medias[i.current_index],e.mediaType=i.medias[i.current_index].type||"",i.showMedia(e),i.getMediasDescription(e),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):i.previousLink.hide())},updateMedia:function(t,e,i){var a=i.action,o=this,a=h("."+a+".bb-rl-"+a+"-theatre"),d=a.find(".bb-rl-media-section figure"),n=d.find("img");n.one("load",function(){d.removeClass("loading").find(".bb-rl-loader").remove(),n.show()}).one("error",function(){d.removeClass("loading").find(".bb-rl-loader").remove()}).attr("src",t.attachment),a.find(".bb-rl-media-thumb").removeClass("active"),e.addClass("active"),o.current_index=o.medias.findIndex(function(e){return e.id===t.id}),o.current_media=t,o.nextLink.toggle(Boolean(o.medias[o.current_index+1])),o.previousLink.toggle(Boolean(o.medias[o.current_index-1])),o.activity_ajax&&o.activity_ajax.abort(),o.fetchMediaDescription(t,a,i)},fetchMediaDescription:function(o,d,e){var n=e.mediaType,r=e.action,s=this,e=(!1!==s.activity_ajax&&s.activity_ajax.abort(),h('[data-bp-activity-id="'+o.activity_id+'"] .bb-rl-activity-comments')),e=(e.length&&(e=e.find("#ac-form-"+o.activity_id),o.parent_activity_comments=!0,e.remove()),!0===o.parent_activity_comments&&h(".bb-rl-"+r+"-model-wrapper:last").after(''),{id:o.id,attachment_id:o.attachment_id,activity_id:o.activity_id});"media-video"===r&&"video"===n?(e.action="video_get_video_description",e.nonce=w.video):(e.action="media_get_media_description",e.nonce=w.media),s.activity_ajax=h.ajax({type:"POST",url:y,data:e,beforeSend:function(){d.find(".bb-media-info-section .bb-rl-activity-list").addClass("loading").html('')},success:function(e){var t,i,a;e.success?(t=d.find(".bb-media-info-section:visible"),i=h(".bb-rl-"+r+"-model-wrapper"),"media-video"===r&&"video"===n&&((a=i.find(".bb-rl-media-section figure")).html(e.data.video_data),a.find("video").attr("autoplay",!0)),t.find(".bb-rl-activity-list").removeClass("loading").html(e.data.description),void 0!==e.data.comment_form&&void 0!==bp.Nouveau.Activity&&(t.find(".bb-rl-activity-list .bb-rl-activity-comments ul:first").after(e.data.comment_form),t.find("#ac-form-"+o.activity_id).removeClass("not-initialized").addClass("root events-initiated").find("#ac-input-"+o.activity_id).focus(),a=t.find("#ac-form-"+o.activity_id),bp.Nouveau.Activity.clearFeedbackNotice(a),a.removeClass("events-initiated"),e=t.find(".ac-form .ac-input[contenteditable]"),bp.Nouveau.Activity.listenCommentInput(e),_.isUndefined(g)||_.isUndefined(g.emoji)||bp.Nouveau.Activity.initializeEmojioneArea(!0,"#bb-rl-activity-modal ",o.activity_id)),t.show(),t.find(".bb-activity-more-options-action").attr("data-balloon-pos","left"),s.updateTheaterHeaderTitle({wrapper:i,action:r}),requestAnimationFrame(function(){h(window).scroll(),bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()})):d.find(".bb-media-info-section.media").hide()}})},nextDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData("media"),void 0!==e.documents[e.current_document_index+1]?(e.current_document_index=e.current_document_index+1,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.nextDocumentLink.hide()},previousDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData("media"),void 0!==e.documents[e.current_document_index-1]?(e.current_document_index=e.current_document_index-1,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.previousDocumentLink.hide()},navigationCommands:function(){var e=this;0===e.current_index&&e.current_index!==e.medias.length-1?(e.previousLink.hide(),e.nextLink.show()):0===e.current_index&&e.current_index===e.medias.length-1?(e.previousLink.hide(),e.nextLink.hide()):e.current_index===e.medias.length-1?(e.previousLink.show(),e.nextLink.hide()):(e.previousLink.show(),e.nextLink.show())},navigationDocumentCommands:function(){var e=this;0===e.current_document_index&&e.current_document_index!==e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.show()):0===e.current_document_index&&e.current_document_index===e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.hide()):e.current_document_index===e.documents.length-1?(e.previousDocumentLink.show(),e.nextDocumentLink.hide()):(e.previousDocumentLink.show(),e.nextDocumentLink.show())},getDocumentsDescription:function(){var t=this,e=(h(".bb-media-info-section .bb-rl-activity-list").addClass("loading").html(''),!1!==t.activity_ajax&&t.activity_ajax.abort(),h('[data-bp-activity-id="'+t.current_document.activity_id+'"] .bb-rl-activity-comments'));e.length&&(e=e.find("#ac-form-"+t.current_document.activity_id),t.current_document.parent_activity_comments=!0,e.remove()),!0===t.current_document.parent_activity_comments&&h(".bb-rl-media-model-wrapper:last").after(''),t.activity_ajax=h.ajax({type:"POST",url:y,data:{action:"document_get_document_description",id:t.current_document.id,attachment_id:t.current_document.attachment_id,nonce:w.media},success:function(e){e.success?(h(".bb-media-info-section:visible .bb-rl-activity-list").removeClass("loading").html(e.data.description),void 0!==e.data.comment_form&&void 0!==bp.Nouveau.Activity&&(h(".bb-media-info-section:visible .bb-rl-activity-list .bb-rl-activity-comments ul:first").after(e.data.comment_form),h(".bb-media-info-section:visible").find("#ac-form-"+t.current_document.activity_id).removeClass("not-initialized").addClass("root events-initiated").find("#ac-input-"+t.current_document.activity_id).focus(),e=h(".bb-media-info-section:visible").find("#ac-form-"+t.current_document.activity_id),bp.Nouveau.Activity.clearFeedbackNotice(e),e.removeClass("events-initiated"),e=h(".bb-media-info-section:visible").find(".ac-form .ac-input[contenteditable]"),bp.Nouveau.Activity.listenCommentInput(e),_.isUndefined(g)||_.isUndefined(g.emoji)||bp.Nouveau.Activity.initializeEmojioneArea(!0,"#bb-rl-activity-modal ",t.current_document.activity_id)),h(".bb-media-info-section:visible").show(),t.updateTheaterHeaderTitle({wrapper:h(".bb-rl-media-model-wrapper"),action:"media"}),h(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10),h(".bb-media-info-section:visible").find(".bb-activity-more-options-action").attr("data-balloon-pos","left")):h(".bb-media-info-section.document").hide()}})},activityDeleted:function(e,t){var i=this,a=0;if(i.is_open_media&&void 0!==t&&"delete_activity"===t.action&&i.current_media.activity_id===t.id){for(var o=h(document).find('[data-bp-list="media"] .bb-rl-open-media-theatre[data-id="'+i.current_media.id+'"]'),d=o.parents("ul"),n=(o.closest("li").remove(),0===d.find("li:not(.load-more)").length&&(0<(o=h(".bb-photos-actions")).length&&o.hide(),1===d.find("li.load-more").length)&&location.reload(),h(document).find('[data-bp-list="activity"] .bb-rl-open-media-theatre[data-id="'+i.current_media.id+'"]').closest(".bb-rl-activity-media-elem").remove(),i.medias.length),a=0;a{var e,g,n,y,v,s,w,l,t;"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},g=(e=BP_Nouveau).media,n=e.document,y=e.ajaxurl,v=e.video,s=e.is_send_ajax_request,w=e.nonces,l=e.activity,t=void 0!==window.BP_Forums_Nouveau&&(window.BP_Forums_Nouveau.media,1)?window.BP_Forums_Nouveau.media:{},bp.Nouveau.Media={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){var e=h("body"),e=(this.current_page=1,this.current_page_existing_media=1,this.current_page_albums=1,this.current_tab=!e.hasClass("single-topic")&&!e.hasClass("single-forum")&&"bp-dropzone-content",this.sort_by="",this.order_by="",this.currentTargetParent=g.current_folder,this.moveToIdPopup=g.move_to_id_popup,this.moveToTypePopup=g.current_type,this.privacySelectorSelect="",this.privacySelectorSpan="",void 0!==window.Dropzone&&(window.Dropzone.autoDiscover=!1),document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:""),e=(this.documentOptions=bp.Readylaunch.Utilities.createDropzoneOptions({dictFileTooBig:g.dictFileTooBig,acceptedFiles:g.document_type,createImageThumbnails:!1,dictDefaultMessage:g.dropzone_document_message,maxFiles:void 0!==n.maxFiles?n.maxFiles:10,maxFilesize:void 0!==n.max_upload_size?n.max_upload_size:2,dictInvalidFileType:n.dictInvalidFileType,dictMaxFilesExceeded:g.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:g.dictCancelUploadConfirmation}),document.getElementsByClassName("forum-post-video-template").length?document.getElementsByClassName("forum-post-video-template")[0].innerHTML:"");this.videoOptions=bp.Readylaunch.Utilities.createDropzoneOptions({dictFileTooBig:v.dictFileTooBig,acceptedFiles:v.video_type,createImageThumbnails:!1,dictDefaultMessage:v.dropzone_video_message,maxFiles:void 0!==v.maxFiles?v.maxFiles:10,maxFilesize:void 0!==v.max_upload_size?v.max_upload_size:2,dictInvalidFileType:v.dictInvalidFileType,dictMaxFilesExceeded:v.video_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:v.dictCancelUploadConfirmation}),h("#bp-media-uploader").hasClass("bp-media-document-uploader")?(e=document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:"",this.options=bp.Readylaunch.Utilities.createDropzoneOptions({dictFileTooBig:g.dictFileTooBig,acceptedFiles:g.document_type,createImageThumbnails:!1,dictDefaultMessage:g.dropzone_document_message,maxFiles:void 0!==n.maxFiles?n.maxFiles:10,maxFilesize:void 0!==n.max_upload_size?n.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:g.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:g.dictCancelUploadConfirmation})):(e=document.getElementsByClassName("forum-post-media-template").length?document.getElementsByClassName("forum-post-media-template")[0].innerHTML:"",this.options=bp.Readylaunch.Utilities.createDropzoneOptions({dictFileTooBig:g.dictFileTooBig,dictDefaultMessage:g.dropzone_media_message,acceptedFiles:"image/*",maxFiles:void 0!==g.maxFiles?g.maxFiles:10,maxFilesize:void 0!==g.max_upload_size?g.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:g.media_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:g.dictCancelUploadConfirmation,maxThumbnailFilesize:void 0!==g.max_upload_size?g.max_upload_size:2})),void 0!==g.dropzone_options&&Object.assign(this.options,g.dropzone_options),this.dropzone_obj=[],this.dropzone_media=[],this.album_id=void 0!==g.album_id&&g.album_id,this.current_folder=void 0!==g.current_folder&&g.current_folder,this.current_group_id=void 0!==g.current_group_id&&g.current_group_id,this.group_id=void 0!==g.group_id&&g.group_id,this.bbp_is_reply_edit=void 0!==t.bbp_is_reply_edit&&t.bbp_is_reply_edit,this.bbp_is_topic_edit=void 0!==t.bbp_is_topic_edit&&t.bbp_is_topic_edit,this.bbp_is_forum_edit=void 0!==t.bbp_is_forum_edit&&t.bbp_is_forum_edit,this.bbp_reply_edit_media=void 0!==t.reply_edit_media?t.reply_edit_media:[],this.bbp_reply_edit_document=void 0!==t.reply_edit_document?t.reply_edit_document:[],this.bbp_reply_edit_video=void 0!==t.reply_edit_video?t.reply_edit_video:[],this.bbp_topic_edit_media=void 0!==t.topic_edit_media?t.topic_edit_media:[],this.bbp_topic_edit_video=void 0!==t.topic_edit_video?t.topic_edit_video:[],this.bbp_topic_edit_document=void 0!==t.topic_edit_document?t.topic_edit_document:[],this.bbp_forum_edit_media=void 0!==t.forum_edit_media?t.forum_edit_media:[],this.bbp_forum_edit_document=void 0!==t.forum_edit_document?t.forum_edit_document:[],this.bbp_forum_edit_video=void 0!==t.forum_edit_video?t.forum_edit_video:[],this.bbp_reply_edit_gif_data=void 0!==t.reply_edit_gif_data?t.reply_edit_gif_data:[],this.bbp_topic_edit_gif_data=void 0!==t.topic_edit_gif_data?t.topic_edit_gif_data:[],this.bbp_forum_edit_gif_data=void 0!==t.forum_edit_gif_data?t.forum_edit_gif_data:[],this.giphy=null,this.gif_offset=0,this.gif_q=null,this.gif_limit=20,this.gif_requests=[],this.gif_data=[],this.gif_container_key=!1,this.reply_topic_allow_delete_media=!1,this.reply_topic_display_post="edit",bp.Nouveau.Media.documentCodeMirror(),h(window).on("scroll resize",function(){bp.Nouveau.Media.documentCodeMirror()})},refreshDirectoryFilter:function(e,t){e=h(document).find("#bb-rl-"+e+"-scope-options");e.length&&(t=e.find('option[data-bp-scope="'+t+'"]')).length&&(t=t.text().trim(),e.val(t).trigger("change"))},updateAlbumCounts:function(e){var t,i,a,o;h("#buddypress #bp-media-single-album").length&&(o=parseInt(e.album_media_count)||0,e=parseInt(e.album_video_count)||0,t=function(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},0<(a=h("#buddypress .bb-album-photo-count")).length&&(0 '+e.data.media_group_count+" "+i)):h("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(h(".bb-photos-actions").hide(),h("#media-stream")):n.find(".media-list:not(.existing-media-list)")).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(h(".bb-photos-actions").hide(),h("#media-stream")):n.find(".media-list:not(.existing-media-list)")).html(e.data.group_media_html_content):h.each(r,function(e,t){t=h('#media-stream ul.media-list li[data-id="'+t+'"]');t.length&&t.remove()}),void 0!==e.data.album_total_count&&o.updateAlbumCounts(e.data))):(setTimeout(function(){a.prop("disabled",!1)},500),e.success?(void 0!==e.data&&void 0!==e.data.media_personal_count&&(0 '+e.data.media_personal_count+" "+i)):h("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count)),void 0!==e.data&&void 0!==e.data.media_group_count&&0 '+e.data.media_group_count+" "+i)):h("#buddypress").find(".groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),(t=n.find(".media-list:not(.existing-media-list)")).find('.bb-media-check-wrap [name="bb-media-select"]:checked').each(function(){h(this).closest("li").remove()}),t.parent().parent().hasClass("album-single-view")&&t.find('.bb-video-check-wrap [name="bb-video-select"]:checked').each(function(){h(this).closest("li").remove()}),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(h(".bb-photos-actions").hide(),h("#media-stream")):t).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(h(".bb-photos-actions").hide(),h("#media-stream")):t).html(e.data.group_media_html_content):h.each(r,function(e,t){t=h('#media-stream ul.media-list li[data-id="'+t+'"]');t.length&&t.remove()})):h("#buddypress #media-stream.media").prepend(e.data.feedback));var t=h(".bp-nouveau #bb-select-deselect-all-media");t.hasClass("selected")&&t.removeClass("selected"),jQuery(window).scroll()}})},toggleSelectAllMedia:function(e){e.preventDefault();var e=h(e.currentTarget),t=!e.hasClass("selected");this.setMediaSelectionState(t),h("#bb-delete-media").length&&(t?h("#bb-delete-media").removeAttr("disabled"):h("#bb-delete-media").attr("disabled","disabled")),e.toggleClass("selected",t).data("bp-tooltip",t?BP_Nouveau.media.i18n_strings.unselectall:BP_Nouveau.media.i18n_strings.selectall)},editFolderTitle:function(e){e.preventDefault(),this.editAlbumFolderTitle(e,"document")},cancelEditAlbumTitle:function(e){e.preventDefault(),h("#bb-album-title").removeClass("error"),h("#bp-save-folder-title").hide(),h("#bp-cancel-edit-album-title").hide(),h("#bp-edit-album-title,#bp-edit-folder-title").show(),h("#bp-media-single-album #bp-single-album-title").show()},triggerDropzoneSelectFileDialog:function(){this.dropzone_obj.hiddenFileInput.click()},closeUploader:function(e){e.preventDefault(),h("#bp-media-uploader").hide(),h("#bp-media-add-more").hide(),h("#bp-media-uploader-modal-title").text(g.i18n_strings.upload),h("#bp-media-uploader-modal-status-text").text(""),h("#bp-media-post-content").val(""),h("#bp-dropzone-content .bp-feedback").remove(),this.dropzone_obj.element&&this.dropzone_obj.destroy(),this.dropzone_media=[];var t=h(e.currentTarget).closest("#bp-media-uploader");h(".bb-rl-close-create-popup-album").trigger("click"),h(".bb-rl-close-create-popup-folder").trigger("click"),t.find('.bb-rl-breadcrumbs-append-ul-li .item span[data-id="0"]').trigger("click"),t.find(".bb-field-steps").length&&(t.find(".bb-field-steps-1").show().siblings(".bb-field-steps-2").hide(),t.find(".bb-field-steps-1 #bp-media-photo-next, .bb-field-steps-1 #bp-media-document-next ").hide(),t.find(".bb-field-steps-1").removeClass("controls-added"),t.find("#bp-media-document-prev, #bp-media-prev, #bp-media-document-submit, #bp-media-submit, .bb-rl-media-open-create-popup-folder, .bb-rl-document-open-create-popup-folder, .bb-rl-create-popup-folder-wrap, .bb-rl-create-popup-album-wrap, .bb-rl-video-open-create-popup-album").hide()),this.clearFolderLocationUI(e)},closeChildFolderUploader:function(e){e.preventDefault();e=h(document);e.find(".open-popup #bb-album-child-title").val(""),e.find(".open-popup #bp-media-create-child-folder-submit").removeClass("loading"),e.find("#bp-media-create-child-folder").removeClass("open-popup"),e.find("#bp-media-create-child-folder").hide(),e.find(".open-popup #bb-album-title").text(""),e.find(".open-popup #bp-media-create-folder").hide(),e.find("#bp-media-create-folder").removeClass("open-popup")},closeFolderUploader:function(e){e.preventDefault();e=h(document);e.find(".open-popup #bb-album-title").val(""),e.find(".open-popup #bp-media-create-folder-submit").removeClass("loading"),e.find(".open-popup #bp-media-document-submit").hide(),e.find("#bp-media-create-folder").removeClass("open-popup"),e.find("#bp-media-create-folder").hide()},loadMoreGif:function(e){var t=e.target,i=this,a=h(e.target).closest(".bb-rl-gif-media-search-dropdown-standalone"),a=0 =t.scrollHeight&&!a.hasClass("loading")&&0 =t.scrollHeight&&!h(e.target).closest(".bp-group-messages-attached-gif-container").hasClass("loading")&&0 \n\t\n\t\t \n\t\n',e.data[t].saved=!1,this.gif_data.push(e.data[t])}i.find(".gif-search-results-list").append(a)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(this.gif_total_count=e.pagination.total_count)},loadMoreGifResponse:function(e){var t=this,i=0,a=h('div.forums-attached-gif-container[data-key="'+t.gif_container_key+'"]'),o=h(".bb-rl-gif-media-search-dropdown-standalone.open"),o=(0
\n\t\n\t\t \n\t\n',e.data[i].saved=!1,t.gif_data[t.gif_container_key].data.push(e.data[i])}o.append(d)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(t.gif_data[t.gif_container_key].total_count=e.pagination.total_count)},editGifPreview:function(){var e=this,t={};if(e.bbp_is_reply_edit&&Object.keys(e.bbp_reply_edit_gif_data).length?t=e.bbp_reply_edit_gif_data.gif_raw_data:e.bbp_is_topic_edit&&Object.keys(e.bbp_topic_edit_gif_data).length?t=e.bbp_topic_edit_gif_data.gif_raw_data:e.bbp_is_forum_edit&&Object.keys(e.bbp_forum_edit_gif_data).length&&(t=e.bbp_forum_edit_gif_data.gif_raw_data),void 0===t.images)return!1;e=h("#whats-new-attachments .forums-attached-gif-container"),e[0].style.backgroundImage="url("+t.images.fixed_width.url+")",e[0].style.backgroundSize="contain",e[0].style.height=t.images.original.height+"px",e[0].style.width=t.images.original.width+"px",e.find(".gif-image-container img").attr("src",t.images.original.url),e.removeClass("closed"),e=h("#bbp_media_gif");e.length&&e.val(JSON.stringify(t))},selectGif:function(e){var t,i=this,a=0,o=h(e.currentTarget),d=o.closest(".bb-rl-gif-media-search-dropdown-standalone"),r=0
\n\t\n\t\t \n\t\n',e.data[s].saved=!1,n.gif_data.push(e.data[s])}h(r.target).closest(".bp-group-messages-attached-gif-container").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(n.gif_total_count=e.pagination.total_count),h(r.target).closest(".bp-group-messages-attached-gif-container").removeClass("loading")},function(){h(r.target).find(".gif-no-connection").addClass("show")}));n.gif_requests.push(e),n.gif_offset=n.gif_offset+n.gif_limit},searchGifRequest:function(r){var n=this,s=0,e=h(r.target).closest(".bb-rl-gif-media-search-dropdown-standalone"),t=0
\n\t\n\t\t \n\t\n',e.data[s].saved=!1,n.gif_data[p].data.push(e.data[s])}h(r.target).closest(".gif-search-content").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(n.gif_data[p].total_count=e.pagination.total_count),l.removeClass("loading")},function(){c.find(".gif-no-connection").addClass("show")}));n.gif_data[p].requests.push(i),n.gif_data[p].offset=n.gif_data[p].offset+n.gif_data[p].limit},clearGifRequests:function(e){var t=this;if(void 0!==t.gif_data[e]&&void 0!==t.gif_data[e].requests){for(var i=t.gif_data[e].requests.length,a=0;a
",l.html(e),l.find(".gif-search-results").on("scroll",s.loadMoreGif.bind(s))),void 0!==window.Giphy&&void 0!==g.gif_api_key&&(s.giphy=new window.Giphy(g.gif_api_key),(r=i.closest("form").find(".forums-attached-gif-container")).addClass("loading"),n=r.data("key"),s.clearGifRequests(n),s.gif_data[n]={q:null,offset:0,limit:20,requests:[],total_count:0,data:[]},e=s.giphy.trending({offset:s.gif_data[n].offset,fmt:"json",limit:s.gif_data[n].limit},function(e){if(void 0!==e.data&&e.data.length){var t="",i=e.data.length;for(c=0;c\n\t\n\t\t'+(g.gif_no_results||"No results found")+'
'+(g.gif_no_connection||"Could not connect to GIPHY")+"
\n\t\n',e.data[c].saved=!1,s.gif_data[n].data.push(e.data[c])}l.find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(s.gif_data[n].total_count=e.pagination.total_count),r.removeClass("loading")}),s.gif_data[n].requests.push(e),s.gif_data[n].offset=s.gif_data[n].offset+s.gif_data[n].limit),l.toggleClass("open"),a&&l.hasClass("open")&&(e=h(window).scrollTop(),a=i.offset(),d=Math.round(a.top),a=Math.round(a.left),t=h("body").hasClass("rtl"),o=l.outerWidth(),t=t?"translate(-"+(h(window).width()-a-i.outerWidth()+o-70)+"px, "+(d-e-5)+"px) translate(0, -100%)":"translate("+(a+o-70)+"px, "+(d-e-5)+"px) translate(-100%, -100%)",l.css("transform",t),l.data("target-form",i.closest("form"))),i.parents("form").find("#whats-new-attachments .forums-attached-gif-container img")),o=(0
\n\t\n\t\t \n\t\n',e.data[s].saved=!1,r.gif_data.push(e.data[s])}n.closest("form").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(r.gif_total_count=e.pagination.total_count),h(".gif-search-query").closest(".bp-group-messages-attached-gif-container").removeClass("loading")}),r.gif_requests.push(e),r.gif_offset=r.gif_offset+r.gif_limit),n.parents("form").find("#whats-new-attachments .bp-group-messages-attached-gif-container img"));0
'+h(this).text()+""),h(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").removeClass("is-disabled"),h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").hasClass("is-disabled"))||((h(e.currentTarget).closest(".bb-field-wrap").length?h(e.currentTarget).closest(".bb-rl-field-wrap"):h(e.currentTarget).closest(".bb-field-wrap")).find(".bb-rl-album-selected-id").val(h(e.currentTarget).data("id")),t=h(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),0!==Number(h(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(h(e.currentTarget).parent().data("privacy")).trigger("change"),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public").trigger("change"),t.prop("disabled",!1)))}),o.on("click",t+" .breadcrumb .item > span",function(e){var t,i;h(this).hasClass("is-disabled")||(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-album-selected-id").val(0),h(e.currentTarget).closest(".bb-rl-field-wrap").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),a===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").removeClass("is-disabled"),t=h(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),i=h(e.currentTarget).closest("#bp-media-uploader").find(".location-album-list li.is_active").data("privacy"),0!==Number(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-album-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i).trigger("change"),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public").trigger("change"),t.prop("disabled",!1)))}),i.options.previewTemplate=document.getElementsByClassName("uploader-post-media-template").length?document.getElementsByClassName("uploader-post-media-template")[0].innerHTML:"",i.dropzone_obj=new Dropzone("div#media-uploader",i.options),i.dropzone_obj.on("sending",function(e,t,i){i.append("action","media_upload"),i.append("_wpnonce",w.media)}),i.dropzone_obj.on("uploadprogress",function(e){var t=h(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI;t.style.strokeDasharray=i+" "+i,t.style.strokeDashoffset=i,t.style.strokeDashoffset=i-e.upload.progress.toFixed(0)/100*i}),i.dropzone_obj.on("addedfile",function(){setTimeout(function(){i.dropzone_obj.getAcceptedFiles().length&&h("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(g.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),i.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?h(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"===e.status&&e.xhr&&0===e.xhr.status&&h(e.previewElement).find(".dz-error-message span").text(g.connection_lost_error):(jQuery(".media-error-popup").length||h("body").append('"),this.removeFile(e))}),i.dropzone_obj.on("queuecomplete",function(){h("#bp-media-uploader-modal-title").text(g.i18n_strings.upload)}),i.dropzone_obj.on("processing",function(){h("#bp-media-uploader-modal-title").text(g.i18n_strings.uploading+"...")}),i.dropzone_obj.on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=i.dropzone_media.length,t.data.album_id=i.album_id,t.data.group_id=i.group_id,t.data.saved=!1,i.dropzone_media.push(t.data)):(jQuery(".media-error-popup").length||h("body").append('"),this.removeFile(e)),h(".bb-field-steps-1 #bp-media-photo-next, #bp-media-submit").show(),h(".modal-container").addClass("modal-container--alert"),h(".bb-field-steps-1").addClass("controls-added"),h("#bp-media-add-more").show(),h("#bp-media-uploader-modal-title").text(g.i18n_strings.uploading+"..."),h("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(g.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()}),i.dropzone_obj.on("removedfile",function(e){if(i.dropzone_media.length)for(var t in i.dropzone_media)if(e.upload.uuid===i.dropzone_media[t].uuid){void 0===i.dropzone_media[t].saved||i.dropzone_media[t].saved||i.removeAttachment(i.dropzone_media[t].id),i.dropzone_media.splice(t,1);break}i.dropzone_obj.getAcceptedFiles().length?h("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(g.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show():(h("#bp-media-uploader-modal-status-text").text(""),h("#bp-media-add-more, #bp-media-photo-next").hide(),h(".bb-field-steps-1").removeClass("controls-added"),h("#bp-media-submit").hide(),h(".modal-container").removeClass("modal-container--alert"))}))},openDocumentUploader:function(e){var a,t,l=this,i=(e.preventDefault(),h(document)),o=h("#bp-media-uploader");void 0!==window.Dropzone&&h("div#media-uploader").length&&(o.hasClass("bp-media-document-uploader")&&!this.currentTargetParent&&(this.currentTargetParent=0),h(e.currentTarget).closest("#bp-media-single-folder").length&&h("#bb-document-privacy").hide(),i.removeClass("open-popup"),o.show(),o.addClass("open-popup"),bp.Readylaunch&&bp.Readylaunch.initSelect2Scoped&&bp.Readylaunch.initSelect2Scoped(o),h("#bp-media-uploader.bp-media-document-uploader").find(".bb-field-steps.bb-field-steps-2").length&&(t="#bp-media-uploader.bp-media-document-uploader",0!==Number(h(t).find(".bb-rl-folder-selected-id").data("value"))?(a=h(t).find(".bb-rl-folder-selected-id").data("value"),h(t).find("#bb-document-privacy").prop("disabled",!0)):a=0,""!==this.moveToIdPopup)&&h.ajax({url:y,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:w.media},success:function(e){i.find(".bp-media-document-uploader .bb-rl-location-folder-list-wrap h4 span.bb-rl-where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(i.find(".bp-media-document-uploader.open-popup .bb-rl-location-folder-list-wrap").hide(),i.find(".bp-media-document-uploader.open-popup .bb-rl-location-folder-list-wrap-main span.bb-rl-no-folder-exists")):(i.find(".bp-media-document-uploader.open-popup .bb-rl-location-folder-list-wrap-main span.bb-rl-no-folder-exists").hide(),i.find(".bp-media-document-uploader.open-popup .bb-rl-location-folder-list-wrap"))).show(),i.find(".bp-media-document-uploader .bb-rl-popup-on-fly-create-album .bb-rl-privacy-field-wrap-hide-show").show(),i.find(".bp-media-document-uploader .open-popup .bb-rl-folder-create-from").val("profile"),h(t).find(".bb-rl-location-folder-list-wrap .location-folder-list").remove(),h(t).find(".bb-rl-location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,a),h(t).find("ul.location-folder-list span#"+a).trigger("click"),h(t).find(".bb-rl-folder-selected-id").val(a)}}),i.on("click",t+" .location-folder-list li span",function(e){var t;e.preventDefault(),h(this).parent().hasClass("is_active")||(0!==h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item").append(''+h(this).text()+""),h(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").removeClass("is-disabled"),h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").hasClass("is-disabled"))||(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-folder-selected-id").val(h(e.currentTarget).data("id")),t=h(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),0!==Number(h(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(h(e.currentTarget).parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),i.on("click",t+" .breadcrumb .item > span",function(e){var t,i;h(this).hasClass("is-disabled")||(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-folder-selected-id").val(h(e.currentTarget).data("id")),h(e.currentTarget).closest(".bb-rl-field-wrap").find(".location-folder-list li span").removeClass("selected").parent().removeClass("is_active"),h(e.currentTarget).closest(".bb-rl-field-wrap").find('.location-folder-list li[data-id="'+h(e.currentTarget).data("id")+'"]').addClass("is_active"),h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),a===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").removeClass("is-disabled"),t=h(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),i=h(e.currentTarget).closest("#bp-media-uploader").find(".location-folder-list li.is_active").data("privacy"),0!==Number(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-folder-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),l.options.previewTemplate=document.getElementsByClassName("uploader-post-document-template").length?document.getElementsByClassName("uploader-post-document-template")[0].innerHTML:"",l.dropzone_obj=new Dropzone("div#media-uploader",l.options),l.dropzone_obj.on("sending",function(e,t,i){i.append("action","document_document_upload"),i.append("_wpnonce",w.media)}),l.dropzone_obj.on("uploadprogress",function(e){var t=h(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI;t.style.strokeDasharray=i+" "+i,t.style.strokeDashoffset=i,t.style.strokeDashoffset=i-e.upload.progress.toFixed(0)/100*i}),l.dropzone_obj.on("addedfile",function(){setTimeout(function(){l.dropzone_obj.getAcceptedFiles().length&&h("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(g.i18n_strings.upload_status,l.dropzone_media.length,l.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),l.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?h(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"===e.status&&e.xhr&&0===e.xhr.status&&h(e.previewElement).find(".dz-error-message span").text(g.connection_lost_error):(jQuery(".document-error-popup").length||h("body").append('"),this.removeFile(e))}),l.dropzone_obj.on("accept",function(e,t){0===e.size?t(g.empty_document_type):t()}),l.dropzone_obj.on("queuecomplete",function(){h("#bp-media-uploader-modal-title").text(g.i18n_strings.upload)}),l.dropzone_obj.on("processing",function(){h("#bp-media-uploader-modal-title").text(g.i18n_strings.uploading+"...")}),l.dropzone_obj.on("success",function(e,t){if(!t.data.id){var i,a,o,d,r,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),r=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a .bb-rl-activity-content .bb-rl-media-move-file",h(a).find(".bb-rl-document-move").attr("id",e.closest(".bb-rl-document-activity").attr("data-id")),0 '),d),n=this.moveToTypePopup;""!==this.moveToIdPopup&&h.ajax({url:y,type:"post",data:{action:"media_get_album_view",id:this.moveToIdPopup,type:this.moveToTypePopup},success:function(e){o.find(".bb-rl-location-album-list-wrap h4 span.bb-rl-where-to-move-profile-or-group-media").html(e.data.first_span_text),(""===e.data.html?(o.find(".open-popup .bb-rl-location-album-list-wrap").hide(),o.find(".open-popup .bb-rl-location-album-list-wrap-main span.bb-rl-no-album-exists")):(o.find(".open-popup .bb-rl-location-album-list-wrap-main span.bb-rl-no-album-exists").hide(),o.find(".open-popup .bb-rl-location-album-list-wrap"))).show(),"group"===n?(o.find(".bb-rl-popup-on-fly-create-album .bb-rl-privacy-field-wrap-hide-show").hide(),o.find(".open-popup .bb-rl-album-create-from").val("group")):(o.find(".bb-rl-popup-on-fly-create-album .bb-rl-privacy-field-wrap-hide-show").show(),o.find(".open-popup .bb-rl-album-create-from").val("profile")),!1===e.data.create_album?(h(a+".open-popup").find(".bb-rl-media-open-create-popup-folder").removeClass("create-album"),h(a+".open-popup").find(".bb-rl-media-open-create-popup-folder").hide()):(h(a+".open-popup").find(".bb-rl-media-open-create-popup-folder").addClass("create-album"),h(a+".open-popup").find(".bb-rl-media-open-create-popup-folder").show()),h(a).find(".bb-rl-location-album-list-wrap .location-album-list").remove(),h(a).find(".bb-rl-location-album-list-wrap").append(e.data.html),h(a).find(".bb-rl-model-footer .bb-rl-media-move").removeClass("loading"),h(a).find("ul.location-album-list span#"+r).trigger("click")}}),o.on("click",a+" .location-album-list li span",function(e){var t;e.preventDefault(),h(this).parent().hasClass("is_active")||(0!==h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item").append(''+h(this).text()+""),h(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),t=h(document).find('a.bb-rl-open-media-theatre[data-id="'+i.find(".bb-rl-media-move").attr("id")+'"]').data("album-id"),Number(t)===Number(h(e.currentTarget).data("id"))?h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").removeClass("is-disabled"),h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").hasClass("is-disabled"))||h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-album-selected-id").val(h(e.currentTarget).data("id"))}),o.on("click",a+" .breadcrumb .item > span",function(e){h(this).hasClass("is-disabled")||(h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-album-selected-id").val(0),h(e.currentTarget).closest(".bb-rl-media-move-file").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),r===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").removeClass("is-disabled"))})},openDocumentMove:function(e){e.preventDefault();var t,i=h(document),a=h(),e=h(e.currentTarget),o=(this.moveToIdPopup=e.attr("id"),this.moveToTypePopup=e.attr("data-type"),e.attr("data-action")),d=(h(".bb-rl-media-move-file.open-popup, .bb-rl-media-move-folder.open-popup").hide().removeClass("open-popup"),e.closest("#bb-rl-activity-modal")),r=(0===d.length&&(d=h("body")),e.closest(".bb-rl-conflict-activity-ul-li-comment").closest("li.comment-item").length?(t=e.closest("li.comment-item"),a=d.find("#"+t.attr("id")+".comment-item .bb-rl-media-move-file").first()):0<(t=e.closest("li.activity-item")).length&&(a=d.find("#"+t.attr("id")+" > .bb-rl-activity-content .bb-rl-media-move-file").first()),a&&0!==a.length||(e.closest(".bb-rl-conflict-activity-ul-li-comment").closest("li.comment-item").length?(t=e.closest("li.comment-item").attr("id"),a=d.find("#"+t+".comment-item .bb-rl-media-move-file").first()):(t=e.closest("li.activity-item").attr("id"))&&(a=d.find("#"+t+" > .bb-rl-activity-content .bb-rl-media-move-file").first())),a.find(".bb-rl-document-move").attr("id",e.closest(".bb-rl-document-activity").attr("data-id")),this.currentTargetParent=e.closest(".bb-rl-activity-media-elem").attr("data-parent-id"),0 '),"document"===o?a.find(".bb-rl-modal-header h4 .target_name").text(g.move_to_file):a.find(".bb-rl-modal-header h4 .target_name").text(g.move_to_folder),a.show(),a.addClass("open-popup"),"group"===this.moveToTypePopup?(i.find(".bb-rl-location-folder-list-wrap h4").show(),a.addClass("move-folder-popup-group")):(i.find(".bb-rl-location-folder-list-wrap h4").hide(),h(".move-folder-popup-group").removeClass("move-folder-popup-group")),this.currentTargetParent),n=this.moveToTypePopup;""!==this.moveToIdPopup&&h.ajax({url:y,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:w.media},success:function(e){var t;i.find(".bb-rl-location-folder-list-wrap h4 span.bb-rl-where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(a.find(".bb-rl-location-folder-list-wrap").hide(),a.find(".bb-rl-location-folder-list-wrap-main span.bb-rl-no-folder-exists")):(a.find(".bb-rl-location-folder-list-wrap-main span.bb-rl-no-folder-exists").hide(),a.find(".bb-rl-location-folder-list-wrap"))).show(),"group"===n?(a.find(".bb-rl-popup-on-fly-create-folder .bb-rl-privacy-field-wrap-hide-show").hide(),a.find(".bb-rl-folder-create-from").val("group")):(a.find(".bb-rl-popup-on-fly-create-folder .bb-rl-privacy-field-wrap-hide-show").show(),a.find(".bb-rl-folder-create-from").val("profile")),a.find(".bb-rl-location-folder-list-wrap .location-folder-list").remove(),a.find(".bb-rl-location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&(e=(e=a.attr("id"))?"#"+e:(t=a.attr("class"))?"."+t.split(" ")[0]:".bb-rl-media-move-file",bp.Nouveau.Media.folderLocationUI(e,r),a.find("ul.location-folder-list span#"+r).trigger("click"))}})},closeMediaMove:function(e){e.preventDefault();e=h(e.currentTarget);0!==e.closest(".bb-rl-media-move-file").find(".bb-rl-location-album-list-wrap .breadcrumb .item span:last-child").data("id")&&e.closest(".bb-rl-media-move-file").find(".bb-rl-location-album-list-wrap .breadcrumb .item span:last-child").remove(),e.closest(".bb-rl-media-move-file").hide().removeClass("open-popup")},closeDocumentMove:function(e){e.preventDefault();var t=h(e.currentTarget),i=jQuery(e.currentTarget).closest(".bb-rl-has-folderlocationUI");(t.hasClass("bb-rl-ac-document-close-button")?(t.closest(".bb-rl-media-move-file"),h(".bb-rl-media-move-file.open-popup").hide().removeClass("open-popup").find(".bb-rl-document-move")):(t.closest(".bb-rl-media-move-folder"),h(".bb-rl-media-move-folder.open-popup").hide().removeClass("open-popup").find(".bb-rl-folder-move"))).attr("id",""),h(".bb-rl-media-move-file.open-popup").removeClass("open-popup").hide(),h(".bb-rl-media-move-folder.open-popup").removeClass("open-popup").hide(),i.find(".bb-rl-document-move.loading").removeClass("loading"),this.clearFolderLocationUI(e)},renameDocument:function(e){var t=h(e.currentTarget).closest(".media-folder_items").find(".media-folder_name"),i=t.children("span").text();t.hide().siblings(".media-folder_name_edit_wrap").show().children(".media-folder_name_edit").val(i).focus().select(),e.preventDefault()},editDocument:function(e){e.preventDefault();var t=h(document),i=h("#bb-rl-media-edit-file"),a=h(e.currentTarget).closest(".media-folder_items"),o=a.find(".media-folder_name").children("span").text(),d=a.data("id"),r=a.find(".media-folder_name").data("attachment-id"),a=a.find(".media-folder_name").data("privacy");h(e.currentTarget).attr("data-privacy")&&0 span"),o=t.closest(".media-folder_items").find(".media-folder_name"),d=t.closest(".media-folder_items").find(".media-folder_name > i.media-document-id").attr("data-item-id"),r=t.closest(".media-folder_items").find(".media-folder_name > i.media-document-attachment-id").attr("data-item-id"),n=t.closest(".media-folder_items").find(".media-folder_name > i.media-document-type").attr("data-item-id"),s=i.val().trim(),l="",l=(t.closest(".ac-document-list").length?l=/[?\[\]=<>:;,'"&$#*()|~`!{}%+ \/]+/g:t.closest(".ac-folder-list").length&&(l=/[\\/?%*:|"<>]+/g),l.exec(s)),l=Boolean(l);if(l?i.addClass("error"):i.removeClass("error"),t.closest(".ac-document-list").length&&(-1!==s.indexOf("\\\\")||l?i.addClass("error"):i.removeClass("error")),!t.hasClass("name_edit_cancel")&&27!==e.keyCode||(i.removeClass("error"),i.parent().hide().siblings(".media-folder_name").show()),t.hasClass("name_edit_save")||13===e.keyCode){if(l)return;i.parent().addClass("submitting").append(''),h.ajax({url:y,type:"post",data:{action:"document_update_file_name",document_id:d,attachment_document_id:r,document_type:n,name:s,_wpnonce:w.media},success:function(e){e.success?void 0!==e.data.document&&0 span"),r=o.find(".media-folder_name"),n=o.find(".media-folder_name > i.media-document-id").attr("data-item-id"),s=o.find(".media-folder_name > i.media-document-attachment-id").attr("data-item-id"),l=o.find(".media-folder_name > i.media-document-type").attr("data-item-id"),c=t.val().trim(),p=0 :;,'"&$#*()|~`!{}%+ \/]+/g:/[\\/?%*:|"<>]+/g).exec(c),m=Boolean(b),b=a.find(".error-box");m?(t.addClass("error"),("folder"===l?b.text(b.data("folder-error")||b.text()):b.text(b.data("document-error")||b.text())).show()):(t.removeClass("error"),b.hide()),"folder"!==l&&o.length&&(-1!==c.indexOf("\\\\")||m?(t.addClass("error"),b.text(b.data("document-error")||b.text()).show()):(t.removeClass("error"),b.hide())),m||(u||f?(i.addClass("saving"),h.ajax({url:y,type:"post",data:{action:"bb_rl_document_rename_and_privacy_update",document_id:n,attachment_document_id:s,document_type:l,name:c,privacy:p,update_name:u,update_privacy:f,_wpnonce:w.media},success:function(e){var t;e.success?(u&&void 0!==e.data.response.document&&0 ');e.parents("li").each(function(e,t){t=h(t).children("span").clone().show();i.prepend("",t)}),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+g.target_text+"")),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").width()&&(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||h('...').insertAfter(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),h(this).hasClass("selected")&&!h(this).hasClass("disabled")?(h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".bb-rl-folder-destination").val(""),h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".bb-rl-folder-selected-id").val("0"),h(a).find(".location-folder-list li.is_active").length?h(a).find(".bb-rl-folder-selected-id").val(h(a).find(".location-folder-list li.is_active").attr("data-id")):h(a).find(".bb-rl-folder-selected-id").val("0")):(h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".location-folder-list li span").removeClass("selected"),h(this).addClass("selected"),h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".bb-rl-folder-destination").val(h(this).text()),h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".bb-rl-folder-selected-id").val(h(this).parent().attr("data-id"))),h(this).closest(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(h(this).siblings("span").text()).siblings(".location-folder-back").css("display","inline-block"),h(this).siblings("ul").show().siblings("span, i").hide().parent().siblings().hide(),h(this).siblings("ul").children("li").show().children("span,i").show(),h(this).closest(".is_active").removeClass("is_active"),h(a).find("li.is_active").removeClass("is_active"),h(this).parent().addClass("is_active"),h(a).find(".bb-rl-folder-selected-id").val(h(a).find(".location-folder-list li.is_active").attr("data-id")),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").each(function(){h(this).show()}),o===h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").attr("data-id")&&(h(a).hasClass("bb-rl-media-move-file")||h(a).hasClass("bb-rl-media-move-folder"))?(h(a).find(".bb-rl-document-move").addClass("is-disabled"),h(a).find(".bb-rl-folder-move").addClass("is-disabled")):(h(a).find(".bb-rl-document-move").removeClass("is-disabled"),h(a).find(".bb-rl-folder-move").removeClass("is-disabled")),setTimeout(function(){h(a).closest(".bb-activity-media-wrap").find(".bb-rl-activity-media-elem.bb-rl-document-activity").attr("data-parent-id")===(h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").prev():h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child")).attr("id")&&(h(a).hasClass("bb-rl-media-move-file")||h(a).hasClass("bb-rl-media-move-folder"))?(h(a).find(".bb-rl-document-move").addClass("is-disabled"),h(a).find(".bb-rl-folder-move").addClass("is-disabled")):(h(a).find(".bb-rl-document-move").removeClass("is-disabled"),h(a).find(".bb-rl-folder-move").removeClass("is-disabled"))},100)}),e.on("click",a+" .bb-rl-breadcrumbs-append-ul-li .item span",function(e){var t,i;h(this).parent().hasClass("is-disabled")||h(this).hasClass("more_options")||(t=h(e.currentTarget).attr("data-id"),h(a).find(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(h(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),h(a).find(".bb-rl-folder-selected-id").val(t),h(a).find(".location-folder-list li").hide(),h(a).find(".location-folder-list li.is_active").removeClass("is_active"),h(a).find(".location-folder-list li > span.selected").removeClass("selected"),h(a).find('.location-folder-list li[data-id="'+t+'"]').addClass("is_active").children("span").addClass("selected"),h(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),h(a).find(".location-folder-list li.is_active").children("ul").length&&!h(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){h(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):h(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?h(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){h(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),"0"===t&&(h(a).find(".location-folder-list").children("li").show().children("span,i").show(),h(a).find(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(g.target_text),h(a).find(".location-folder-back").hide()),h(e.currentTarget).nextAll().remove(),o===h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").attr("data-id")&&(h(a).hasClass("bb-rl-media-move-file")||h(a).hasClass("bb-rl-media-move-folder"))?(h(a).find(".bb-rl-document-move").addClass("is-disabled"),h(a).find(".bb-rl-folder-move").addClass("is-disabled")):(h(a).find(".bb-rl-document-move").removeClass("is-disabled"),h(a).find(".bb-rl-folder-move").removeClass("is-disabled")),e=h(a).find(".location-folder-list .is_active > span"),i=h(''),e.parents("li").each(function(e,t){t=h(t).children("span").clone().show();i.prepend("",t)}),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+g.target_text+"")),0===h(a).find('.bb-rl-breadcrumbs-append-ul-li .breadcrumb .item > span[data-id="'+t+'"]').length&&h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item").append(h(a).find('.location-folder-list li[data-id="'+t+'"]').children("span").clone().show()),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").width()&&(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||h('...').insertAfter(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),h(a).find(".bb-rl-folder-selected-id").val(t))})),h(a).find(".location-folder-list li").each(function(){h(this).children("ul").parent().addClass("has-ul").append('')}),h(a).hasClass("bb-rl-media-move-folder")&&(h(a).find(".location-folder-list li>span").removeClass("is-disabled"),h(a).find('.location-folder-list li>span[id="'+h(a).find(".bb-rl-folder-move").attr("id")+'"]').parent().addClass("is-disabled")),e=h(a).find(".bb-rl-folder-move").attr("id"),0===h(a).find('.location-folder-list li[data-id="'+e+'"]').siblings().length&&h(a).find('.location-folder-list li[data-id="'+e+'"]').parent("ul").addClass("no-folder-list a"),o&&(h(a).find(".location-folder-list li").hide(),h(a).find(".location-folder-list li.is_active").removeClass("is_active"),h(a).find('.location-folder-list li[data-id="'+o+'"]').addClass("is_active"),h(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),h(a).find(".location-folder-list li.is_active").children("ul").length&&!h(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){h(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):h(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?h(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){h(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),h(a).find(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(h(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),h(a).find(".bb-rl-folder-selected-id").val(h(a).find(".location-folder-list li.is_active").attr("data-id")),h(a).find('.location-folder-list li[data-id="'+e+'"]').children().hide()),"0"===o&&(h(a).find(".location-folder-list").children("li").show(),h(a).find(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(g.target_text),h(a).find(".location-folder-back").hide()),setTimeout(function(){var e=h(a).closest(".bb-activity-media-wrap").find(".bb-rl-activity-media-elem.bb-rl-document-activity").attr("data-parent-id"),t=(h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").prev():h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child")).attr("id");e===t&&(h(a).hasClass("bb-rl-media-move-file")||h(a).hasClass("bb-rl-media-move-folder"))?(h(a).find(".bb-rl-document-move").addClass("is-disabled"),h(a).find(".bb-rl-folder-move").addClass("is-disabled")):(h(a).find(".bb-rl-document-move").removeClass("is-disabled"),h(a).find(".bb-rl-folder-move").removeClass("is-disabled"))},100),e=h(a).find(".location-folder-list .is_active > span"),i=h(''),e.parents("li").each(function(e,t){t=h(t).children("span").clone().show();i.prepend("",t)}),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+g.target_text+"")))},clearFolderLocationUI:function(e){e=jQuery(e.currentTarget).closest(".bb-rl-has-folderlocationUI");0 '+e.data.media_group_count+" "+n)):i.find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").length?i.find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count):((d=document.createElement("span")).setAttribute("class","count"),t=document.createTextNode(e.data.media_group_count),d.appendChild(t),i.find(".bp-wrap .users-nav ul li#photos-groups-li a").append(d))),"yes"===g.is_media_directory&&(i.find(".media-type-navs ul.media-nav li#media-all a span.count").text(e.data.media_all_count),i.find(".media-type-navs ul.media-nav li#media-personal a span.count").text(e.data.media_personal_count),i.find(".media-type-navs ul.media-nav li#media-groups a span.count").text(e.data.media_group_count)),void 0!==e.data.album_total_count&&s.updateAlbumCounts(e.data),s.dropzone_media.length),o=0;o").addClass("media-list item-list bp-list bb-photo-list grid")),0<(t=h(".bb-photos-actions")).length&&t.show(),bp.Nouveau.inject("#media-stream ul.media-list",e.data.media,"prepend"),h('.bp-existing-media-wrap .bb-media-check-wrap [name="bb-media-select"]:checked').each(function(){parseInt(h(this).closest("li").data("id"))===parseInt(h(this).val())&&h(this).closest("li").remove()}),void 0===e.data.source_album_id&&void 0===e.data.dest_album_id||(t=h("#buddypress #bp-media-single-album")).length&&(i={},(t=parseInt(t.attr("data-id")||t.attr("data-album-id"))||0)===e.data.source_album_id?(i.album_media_count=e.data.source_album_media_count,i.album_video_count=e.data.source_album_video_count):t===e.data.dest_album_id&&(i.album_media_count=e.data.dest_album_media_count,i.album_video_count=e.data.dest_album_video_count),s.updateAlbumCounts(i)),jQuery(window).scroll(),s.closeUploader(r)):h("#bp-existing-media-content").prepend(e.data.feedback),l.removeClass("saving")}})):s.current_tab||(s.closeUploader(r),l.removeClass("saving"))},submitDocumentMedia:function(a){var o=this,d=h(a.currentTarget),r=h(a.currentTarget).closest("#bp-media-uploader");if(a.preventDefault(),d.hasClass("saving"))return!1;var n=h(document);if(d.addClass("saving"),"bp-dropzone-content"===o.current_tab){var e=h("#bp-media-post-content").val(),t=h("#bb-document-privacy").val(),i=h(a.currentTarget).closest(".open-popup"),s=i.find(".bb-rl-folder-selected-id").val(),i=i.find(".bb-rl-folder-selected-id").data("value"),l=!0;if(s.length&&0 ").addClass("display")),h("#media-stream div").attr("id","media-folder-document-data-table"),h(".bb-photos-actions").show()),h(".document-data-table-head").length?"yes"===g.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(n.find("li#document-personal a").trigger("click"),n.find("li#document-personal").trigger("click")):l&&bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"):location.reload(!0),h("#bp-media-post-content").val("");for(var t=o.dropzone_media.length,i=0;i ]+/g.exec(e.val()),d=Boolean(d);if(""===h.trim(e.val())||d)return e.addClass("error"),!1;e.removeClass("error"),t.prop("disabled",!0).addClass("loading");d={action:"document_edit_folder",_wpnonce:w.media,title:e.val(),privacy:a.val(),id:o,group_id:i.current_group_id};h(".bb-single-album-header .bp-feedback").remove(),h("#bb-rl-media-create-album-popup .bp-feedback").remove(),h.ajax({type:"POST",url:y,data:d,success:function(e){setTimeout(function(){t.prop("disabled",!1)},500),e.success?window.location.reload(!0):i.current_folder?h("#bp-media-single-album").prepend(e.data.feedback):h("#bb-rl-media-create-album-popup .bb-model-header").after(e.data.feedback)}})},deleteAlbum:function(e){e.preventDefault(),this.deleteAttachment(e,"media","album")},deleteFolder:function(e){e.preventDefault(),this.deleteAttachment(e,"document","folder")},injectMedias:function(e){this.injectAttachments(e,"media")},injectDocuments:function(e){this.injectAttachments(e,"document")},sortDocuments:function(e){var e=h(e.currentTarget),t="",i="date_created";switch(e.data("target")){case"name":i="title";break;case"modified":i="date_modified";break;case"visibility":i="privacy";break;case"group":i="group_id"}e.hasClass("asce")?e.removeClass("asce"):e.addClass("asce");var e=e.hasClass("asce")?"DESC":"ASC",a={},a=(a.orderby=i,a.sort=e,"group"!==i&&bp.Nouveau.setStorage("bp-document","extras",a),bp.Nouveau.getStorage("bp-document")),o=a.scope||null,a=a.filter||null,d=h("#buddypress .bp-dir-search-form input[type=search]");d.length&&(t=d.val()),this.sort_by=e,this.order_by=i,this.current_page=1,bp.Nouveau.objectRequest({object:"document",scope:o,filter:a,search_terms:t,page:1,order_by:i,sort:e,method:"reset",target:"#buddypress [data-bp-list]"}).done()},documentPopupNavigate:function(e){e.preventDefault();var e=h(e.currentTarget),t=e.closest(".bb-field-steps"),i=0===e.closest(".bp-document-listing").length?"#bb-album-child-title":"#bb-album-title";e.closest(".document-options").length&&(i="#bb-album-title"),e.hasClass("bb-field-steps-next")&&""===t.find(i).val().trim()?t.find(i).addClass("error"):(t.find(i).removeClass("error"),t.slideUp(200).siblings(".bb-field-steps").slideDown(200))},uploadDocumentNavigate:function(e){e.preventDefault();var e=h(e.currentTarget),t=h(e).closest("#bp-media-uploader");h(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-document-submit, #bp-media-document-prev, .bb-rl-document-open-create-popup-folder, #bb-document-privacy").show(),0!==Number(h(t).find(".bb-rl-folder-selected-id"))&&h(t).find(".location-folder-list li.is_active").length&&h(t).find(".location-folder-list").scrollTop(h(t).find(".location-folder-list li.is_active").offset().top-h(t).find(".location-folder-list").offset().top),h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").width()&&(h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||h('...').insertAfter(h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))})):(h(e).hide(),t.find("#bp-media-document-prev, .bb-rl-document-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-folder").length&&h("#bb-document-privacy").hide())},uploadMediaNavigate:function(e){e.preventDefault();var e=h(e.currentTarget),t=h(e).closest(".bp-media-photo-uploader");h(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-submit, #bp-media-prev, .bb-rl-media-open-create-popup-folder.create-album").show(),t.find("#bb-media-privacy").show(),0!==Number(h(t).find(".bb-rl-album-selected-id"))&&h(t).find(".location-album-list li.is_active").length&&h(t).find(".location-album-list").scrollTop(h(t).find(".location-album-list li.is_active").offset().top-h(t).find(".location-album-list").offset().top)):(h(e).hide(),t.find("#bp-media-prev, .bb-rl-media-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-album").length&&h("#bb-media-privacy").hide())},appendMedia:function(e){var t,i,a,o=bp.Nouveau.getStorage("bp-media"),d=o.scope||null,o=o.filter||null,r=h(e.currentTarget);r.hasClass("load-more")&&(t=Number(this.current_page_existing_media)+1,i=this,a="",e.preventDefault(),r.find("a").first().addClass("loading"),(e=h("#buddypress .dir-search input[type=search]")).length&&(a=e.val()),bp.Nouveau.objectRequest({object:"media",scope:d,filter:o,search_terms:a,page:t,method:"append",caller:"bp-existing-media",target:".bp-existing-media-wrap ul.bp-list"}).done(function(e){!0===e.success&&(r.remove(),i.current_page_existing_media=t,jQuery(window).scroll())}))},appendAlbums:function(t){var i=Number(this.current_page_albums)+1,a=this,e=(t.preventDefault(),h(t.currentTarget).find("a").first().addClass("loading"),{action:"media_albums_loader",_wpnonce:w.media,page:i});h.ajax({type:"POST",url:y,data:e,success:function(e){!0===e.success&&(h(t.currentTarget).remove(),h("#albums-dir-list ul.bb-albums-list").fadeOut(100,function(){h("#albums-dir-list ul.bb-albums-list").append(e.data.albums),h(this).fadeIn(100)}),a.current_page_albums=i)}})},toggleSubmitMediaButton:function(){var e=h("#bp-media-submit"),t=h("#bp-media-add-more");"bp-dropzone-content"===this.current_tab?this.dropzone_obj.getAcceptedFiles().length?(e.show(),t.show()):(e.hide(),t.hide()):"bp-existing-media-content"===this.current_tab&&(h('.bp-existing-media-wrap .bb-media-check-wrap [name="bb-media-select"]:checked').length?e.show():e.hide(),t.hide())},playVideo:function(e){e.preventDefault();var e=h(e.currentTarget),t=e.find("video").get(0),e=e.find(".gif-play-button");!0===t.paused?(t.play().catch(function(e){console.debug("GIF play failed:",e)}),e.hide()):(t.pause(),e.show())},throttledAutoPlayGifVideos:function(){this.throttleTimer||(this.throttleTimer=setTimeout(function(){bp.Nouveau.Media.throttleTimer=null,bp.Nouveau.Media.autoPlayGifVideos()},100))},invokeMediaFn:function(e){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media[e]&&bp.Nouveau.Media[e]()},isElementInScrollableContainer:function(e){var t=h(e),i=t.closest("#bp-message-thread-list");return(i=(i=i.length?i:t.closest(".bb-rl-modal-activity-body")).length?i:t.closest(".bb-rl-media-model-container .bb-media-info-section")).length?(e=e.getBoundingClientRect(),i=i[0].getBoundingClientRect(),e.bottom>i.top&&e.top i.left&&e.left '),h(t).text()),e=(h(t).text(g.copy_to_clip_board_text),h("#"+e));return e.val(h(t).attr("href")),e.select(),document.execCommand("copy"),setTimeout(function(){h(t).text(i)},2e3),!1},fileActivityActionButton:function(e){e.preventDefault();var t=h(e.currentTarget);t.parent().hasClass("bb_rl_copy_download_file_url")||(t.closest(".bb-rl-activity-media-elem").toggleClass("is-visible").siblings().removeClass("is-visible").closest(".activity-item").siblings().find(".bb-rl-activity-media-elem").removeClass("is-visible"),t.closest(".bb-rl-activity-media-elem").find(".bb_rl_more_dropdown").toggleClass("open").closest(".bb-rl-activity-media-elem").siblings().find(".bb_rl_more_dropdown").removeClass("open").closest(".activity-item").siblings().find(".bb-rl-activity-media-elem .bb_rl_more_dropdown").removeClass("open"),h("body").addClass("document_more_option_open"),t.closest(".bb-rl-activity-media-elem").length<1&&(t.closest(".bb-photo-thumb").toggleClass("is-visible").parent().siblings().find(".bb-photo-thumb").removeClass("is-visible").removeClass("is-visible"),t.closest(".bb-photo-thumb").find(".bb_rl_more_dropdown").toggleClass("open").closest(".bb-photo-thumb").parent().siblings().find(".bb-photo-thumb .bb_rl_more_dropdown").removeClass("open")),"a"!==e.currentTarget.tagName.toLowerCase())||t.hasClass("bb-rl-document-action_more")||t.hasClass("bb_rl_more_dropdown__action")||(t.closest(".bb-rl-activity-media-elem").removeClass("is-visible").find(".bb_rl_more_dropdown").removeClass("open"),t.closest(".bb-photo-thumb").removeClass("is-visible").find(".bb_rl_more_dropdown").removeClass("open"))},toggleFileActivityActionButton:function(e){var t;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),!0===e.altKey||!0===e.metaKey||h(t).hasClass("bb-rl-document-action_more")||h(t).parent().hasClass("bb-rl-document-action_more")||h(t).hasClass("media-folder_action__anchor")||h(t).parent().hasClass("media-folder_action__anchor")||h(t).hasClass("bb_rl_more_dropdown__action")||h(t).parent().hasClass("bb_rl_more_dropdown__action")?e:(h(".bb-rl-activity-media-elem.is-visible").removeClass("is-visible"),h(".media-folder_items.is-visible").removeClass("is-visible"),h(".bb-photo-thumb.is-visible").removeClass("is-visible"),h(".bb-item-thumb.is-visible").removeClass("is-visible"),h(".bb-rl-activity-video-elem.is-visible").removeClass("is-visible"),h(".bb-rl-more_dropdown-wrap.is-visible").removeClass("is-visible"),h(".bb-rl-more_dropdown-wrap .bb_rl_more_dropdown").removeClass("open"),h(".bb-rl-activity-media-elem .bb_rl_more_dropdown").removeClass("open"),h(".bb-photo-thumb .bb_rl_more_dropdown").removeClass("open"),h(".media-folder_items .bb_rl_more_dropdown").removeClass("open"),void h("body").removeClass("document_more_option_open video_more_option_open item_more_option_open"))},toggleCodePreview:function(e){e.preventDefault(),h(e.currentTarget).closest(".bb-rl-document-activity").toggleClass("code-full-view")},documentCodeMirror:function(){h(".bb-rl-document-text:not(.loaded), .document-text:not(.loaded)").each(function(){var e=h(this),t=e.attr("data-extension"),i=e.attr("data-extension");"html"!==t&&"htm"!==t||(i="text/html"),"js"===t?CodeMirror(e[0],{value:(0 '+e+""))},setupForumDropzoneEvents:function(e){var c=e.self,a=e.dropzoneObj,d=e.target,p=e.type,b=e.dropzoneDataObj,m=e.dropzoneContainer;"video"===p&&a.on("addedfile",function(e){e.dataURL&&e.dataThumb&&e.dataThumb.length?h(e.previewElement).find(".dz-video-thumbnail").prepend(' '):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-image")}),a.on("sending",function(e,t,i){i.append("action","document"===p?p+"_"+p+"_upload":p+"_upload");var a="document"===p?"media":p,o=(i.append("_wpnonce",w[a]),d.closest("form"));o.addClass("has-media"),["media","document","video","gif"].forEach(function(e){var t=o.find("#bb-rl-forums-"+e+"-button");t&&(t=t.parents(".bb-rl-post-elements-buttons-item"),p===e?t.addClass("no-click"):t.addClass("disable"))})}),a.on("uploadprogress",function(e){d.closest("form").addClass("media-uploading");var t=h(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=a,"video"===p&&(e.upload.progress<=99?(h(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+v.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,h(e.previewElement).find(".dz-progress-count").text("99% "+v.i18n_strings.video_uploaded_text)))}),a.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?h(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"===e.status&&e.xhr&&0===e.xhr.status&&h(e.previewElement).find(".dz-error-message span").text(g.connection_lost_error):(jQuery(".forum-"+("media"===p?"document":p)+"-error-popup").length||("media"===p?h("body").append('"):"document"===p?h("body").append('"):"video"===p&&h("body").append('")),this.removeFile(e),d.closest("form").removeClass("media-uploading"))}),"media"!==p&&a.on("accept",function(e,t){0===e.size?t(g["empty_"+p+"_type"]):t()}),a.on("success",function(e,t){var i,a;if("video"===p&&100===e.upload.progress&&(h(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,h(e.previewElement).find(".dz-progress-count").text("100% "+v.i18n_strings.video_uploaded_text),h(e.previewElement).closest(".dz-preview").addClass("dz-complete")),t.data.id)e.id=t.data.id,t.data.uuid=e.upload.uuid,t.data.menu_order=h(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.group_id=c.group_id,t.data.saved=!1,"media"===p?t.data.album_id=c.album_id:"document"===p?t.data.folder_id=c.current_folder:"video"===p&&(t.data.album_id=c.album_id,t.data.js_preview=h(e.previewElement).find(".dz-image img").attr("src")),b.push(t.data),m.closest("#whats-new-attachments").find("#bbp_"+p).length&&m.closest("#whats-new-attachments").find("#bbp_"+p).val(JSON.stringify(b)),"document"===p&&(a=(a=e.upload.filename).substr(a.lastIndexOf(".")+1),i=_.isUndefined(t.data.svg_icon)?"":t.data.svg_icon,a=_.isEmpty(i)?"bb-icon-file-"+a:i,h(e.previewElement).find(".dz-details .dz-icon .bb-icons-rl-file").length)&&h(e.previewElement).find(".dz-details .dz-icon .bb-icons-rl-file").removeClass("bb-icon-file").addClass(a);else if("media"===p)jQuery(".forum-"+p+"-error-popup").length||h("body").append('"),this.removeFile(e);else if("document"===p||"video"===p){var o,d,r,n,s,l=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],d=0,r=(n=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;d
'):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-image")}),a.on("sending",function(e,t,i){i.append("action","document"===p?p+"_"+p+"_upload":p+"_upload");var a="document"===p?"media":p,o=(i.append("_wpnonce",w[a]),d.closest("#send_group_message_form"));["media","document","video","gif"].forEach(function(e){var t=o.find("#bp-group-messages-"+e+"-button");t&&(t=t.parents(".post-elements-buttons-item"),p===e?t.addClass("no-click"):t.addClass("disable"))})}),a.on("uploadprogress",function(e){var t=h(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=a,"video"===p&&(e.upload.progress<=99?(h(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+v.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,h(e.previewElement).find(".dz-progress-count").text("99% "+v.i18n_strings.video_uploaded_text)))}),a.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?h(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"===e.status&&e.xhr&&0===e.xhr.status&&h(e.previewElement).find(".dz-error-message span").text(g.connection_lost_error):("media"===p||"document"===p?jQuery(".group-"+("media"===p?"document":p)+"-error-popup").length||("document"===p?h("body").append('"):h("body").append('")):h("body").append('"),this.removeFile(e))}),"media"!==p&&a.on("accept",function(e,t){0===e.size?t(g["empty_"+p+"_type"]):t()}),a.on("success",function(e,t){if("video"===p&&100===e.upload.progress&&(h(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,h(e.previewElement).find(".dz-progress-count").text("100% "+v.i18n_strings.video_uploaded_text),h(e.previewElement).closest(".dz-preview").addClass("dz-complete")),t.data.id){e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=h(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.group_id=c.group_id,t.data.saved=!1,"media"===p?t.data.album_id=c.album_id:"document"===p?t.data.folder_id=c.current_folder:"video"===p&&(t.data.album_id=c.album_id,t.data.js_preview=h(e.previewElement).find(".dz-video-thumbnail img").attr("src")),b.push(t.data);var i,a=h("#bp_group_messages_"+p);a.length&&a.val(JSON.stringify(b)),"document"===p&&(a=(a=e.upload.filename).substr(a.lastIndexOf(".")+1),i=_.isUndefined(t.data.svg_icon)?"":t.data.svg_icon,a=_.isEmpty(i)?"bb-icons-rl-"+a:i,h(e.previewElement).find(".dz-details .dz-icon .bb-icons-rl").length)&&h(e.previewElement).find(".dz-details .dz-icon .bb-icons-rl").removeClass("bb-icon-file").addClass(a)}else if("media"===p)jQuery(".group-message-error-popup").length||h("body").append('"),this.removeFile(e);else if("document"===p||"video"===p){var o,d,r,n,s,l=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],d=0,r=(n=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;d "+t+" h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").width()&&(h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||h('...').insertAfter(h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),"media"===a&&d.updateAlbumNavCount(e.data.album_count),n.removeClass("loading"),"document"===a&&setTimeout(function(){var e=r.find("ul"+v+" span#"+u),t=(e.trigger("click"),h(r).find("#bb-document-privacy"));0!==Number(e.data("id"))?(t.find("option").removeAttr("selected"),t.val(e.parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1))},200)):n.removeClass("loading")}}),this.currentTargetParent=u,r.find(v+" li.is_active").show().children("span, i").show().siblings("ul").hide(),r.find(v+" li.is_active").siblings("li").show().children("span, i").show().siblings("ul").hide(),r.find(v+" li span.selected").removeClass("selected"),r.find(v+" li.is_active").children("span").addClass("selected")},0)},setMediaSelectionState:function(e){var i=h("#buddypress").find(".media-list:not(.existing-media-list)"),a=!0===e,e=["media"];0 ]+/g.test(p.val());if(""===h.trim(p.val())||m)return p.addClass("error"),!1;if(p.removeClass("error"),r||n){if(!c.group_id&&""===h.trim(o.val()))return o.addClass("error"),!1;o.removeClass("error")}d.prop("disabled",!0).toggleClass(r?"saving":"loading");m={action:t+"_"+e+"_save",_wpnonce:b,title:p.val()};r?("media"===t?m.medias=c.dropzone_media:"video"===t&&(m.videos=a),m.privacy=o.val(),c.album_id&&(m.album_id=c.album_id),c.group_id&&(m.group_id=c.group_id)):n?(m.privacy=o.val(),m.album_id=c.current_folder,m.group_id=c.current_group_id):s&&(m.folder_id=c.current_folder,m.group_id=c.current_group_id),h(".bb-single-album-header .bp-feedback, #bb-rl-media-create-album-popup .bp-feedback").remove(),h.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:m,success:function(e){var t;(r||n)&&setTimeout(function(){r&&d.removeClass("saving"),d.prop("disabled",!1)},500),e.success?r?c.album_id?(h("#bp-single-album-title .title-wrap").text(p.val()),h("#bb-album-privacy").val(o.val()),c.cancelEditAlbumTitle(i),l.find("#bp-media-edit-album-close").trigger("click")):(h("#buddypress .bb-albums-list").prepend(e.data.album),window.location.href=e.data.redirect_url):n?(c.closeFolderUploader(i),h(".document-data-table-head").length?"yes"===BP_Nouveau.media.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(h(document).find("li#document-personal a").trigger("click"),h(document).find("li#document-personal").trigger("click")):(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()):location.reload(!0)):s&&(c.closeChildFolderUploader(i),location.reload(!0)):r?(t=c.album_id?"#bp-media-single-album":"#bb-rl-media-create-album-popup .bb-model-header",h(t).prepend(e.data.feedback)):alert(e.data.feedback.replace("'","'"))}})}},disableButtonsInToolBox:function(t,e){e.forEach(function(e){e=t.find(e);e.length&&e.parents(".bb-rl-post-elements-buttons-item").addClass("disable")})}},bp.Nouveau.Media.Theatre={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){this.medias=[],this.documents=[],this.current_media=!1,this.current_document=!1,this.current_index=0,this.current_document_index=0,this.is_open_media=!1,this.is_open_document=!1,this.nextLink=h(".bb-rl-next-media"),this.nextDocumentLink=h(".bb-rl-next-document"),this.previousDocumentLink=h(".bb-rl-prev-document"),this.previousLink=h(".bb-rl-prev-media"),this.activity_ajax=!1,this.group_id=void 0!==g.group_id&&g.group_id},addListeners:function(){var e=h(document);e.on("click",".bb-rl-open-media-theatre",this.openTheatre.bind(this)),e.on("click",".bb-rl-open-document-theatre",this.openDocumentTheatre.bind(this)),e.on("click",".bb-rl-document-detail-wrap-description-popup",this.openDocumentTheatre.bind(this)),e.on("click",".bb-rl-close-media-theatre",this.closeTheatre.bind(this)),e.on("click",".bb-close-document-theatre",this.closeDocumentTheatre.bind(this)),e.on("click",".bb-icons-rl-sidebar-simple",this.ToggleTheatreSidebar.bind(this)),e.on("click",".bb-rl-prev-media",this.previous.bind(this)),e.on("click",".bb-rl-next-media",this.next.bind(this)),e.on("click",".bb-rl-prev-document",this.previousDocument.bind(this)),e.on("click",".bb-rl-next-document",this.nextDocument.bind(this)),e.on("bp_activity_ajax_delete_request",this.activityDeleted.bind(this)),e.on("click","#bb-rl-media-model-container .media-privacy>li",this.mediaPrivacyChange.bind(this)),e.on("click","#bb-rl-media-model-container .document-privacy>li",this.documentPrivacyChange.bind(this)),e.on("click","#bb-rl-media-model-container .bb-rl-media-section span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),e.on("click","#bb-rl-media-model-container .bb-rl-document-section span.privacy",bp.Nouveau,this.toggleDocumentPrivacyDropdown.bind(this)),e.on("click",".bp-add-media-activity-description",this.openMediaActivityDescription.bind(this)),e.on("click","#bp-activity-description-new-reset",this.closeMediaActivityDescription.bind(this)),e.on("keyup",".bp-edit-media-activity-description #add-activity-description",this.MediaActivityDescriptionUpdate.bind(this)),e.on("click","#bp-activity-description-new-submit",this.submitMediaActivityDescription.bind(this)),e.on("click",".bb-rl-media-thumb",this.handleThumbnailClick.bind(this)),e.click(this.togglePopupDropdown),document.addEventListener("keyup",this.checkPressedKeyDocuments.bind(this)),document.addEventListener("keyup",this.checkPressedKey.bind(this))},checkPressedKey:function(e){var t=this;if(e=e||window.event,!t.is_open_media)return!1;var i=h(e.target).hasClass("ac-input")||"add-activity-description"===h(e.target).attr("id");switch(e.keyCode){case 27:t.closeTheatre(e);break;case 37:if(void 0===t.medias[t.current_index-1]||i)return!1;t.previous(e);break;case 39:if(void 0===t.medias[t.current_index+1]||i)return!1;t.next(e)}},checkPressedKeyDocuments:function(e){e=e||window.event;var t=this;if(!t.is_open_document)return!1;var i=h(e.target).hasClass("ac-input")||"add-activity-description"===h(e.target).attr("id");switch(e.keyCode){case 27:t.closeDocumentTheatre(e);break;case 37:if(void 0===t.documents[t.current_document_index-1]||i)return!1;t.previousDocument(e);break;case 39:if(void 0===t.documents[t.current_document_index+1]||i)return!1;t.nextDocument(e)}},handleOpenTheatre:function(e){var t=e.target,i=e.self||this,a=e.modalWrapper,o=e.mediaType,e=e.action,d=(i.setupGlobals(),i.setMedias({target:t,modalWrapper:a,mediaType:o,action:e}),t.data("id")),d=(i.setCurrentMedia(d),i.showMedia({modalWrapper:a,mediaType:o,action:e}),i.navigationCommands(),i.current_activity_data&&i.generateAndDisplayMediaThumbnails({target:t,modalWrapper:a,mediaType:o,action:e}),i.getParentActivityHtml({target:t,modalWrapper:a,mediaType:o,action:e}),i.getMediasDescription({modalWrapper:a,mediaType:o,action:e}),t.closest(".activity-item").data("activity-popup-title")),o=(h(a+" .bb-rl-media-model-header h2").text(d),h(a+".document").hide(),document.getElementById(h(a+".video video").attr("id")));o&&o.pause(),h(a+".video").length&&h(a+".video").hide(),h(a+"."+e).length&&h(a+"."+e).show(),i.is_open_media=!0,bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay")},openTheatre:function(e){e.preventDefault();var t=h(e.currentTarget);if(this.current_activity_data=t.closest(".activity-item").data("bp-activity"),t.closest("#bp-existing-media-content").length)return!1;this.handleOpenTheatre({self:this,target:t,event:e,modalWrapper:".bb-rl-media-model-wrapper",action:"media"})},getParentActivityHtml:function(e){var t=e.target,e=e.action;if("comment"===t.data("privacy"))return!1;var i=h("#hidden_parent_id"),a=i.val(),t=t.closest(".bb-rl-"+e+"-model-wrapper").find("#bb-rl-"+e+"-model-container .bb-rl-activity-list li.activity-item").data("bp-activity-id");parseInt(a)===parseInt(t)&&(t=h("#bb-rl-"+e+'-model-container [data-bp-activity-id="'+a+'"]'),h('[data-bp-activity-id="'+a+'"] > .activity-state').html(h(t).find(".activity-state").html()),h('[data-bp-activity-id="'+a+'"] > .activity-meta').html(h(t).find(".activity-meta").html()),h('[data-bp-activity-id="'+a+'"] > .bb-rl-activity-comments').html(h(t).find(".bb-rl-activity-comments").html())),i.length&&i.remove()},getMediasDescription:function(e){var t=e.action;this.fetchMediaDescription(this.current_media,h(".bb-rl-"+t+"-model-wrapper"),e)},openDocumentTheatre:function(e){e.preventDefault();var t=h(e.currentTarget),i=this;if(t.closest("#bp-existing-document-content").length)return!1;t.closest(".document.bb-rl-document-theatre").length&&i.closeDocumentTheatre(e),a=t.data("id"),i.setupGlobals(),i.setDocuments(t),i.setCurrentDocument(a),i.showDocument(),i.navigationDocumentCommands(),i.getParentActivityHtml({target:t,action:"media"}),i.getDocumentsDescription();var a=t.closest(".activity-item").data("activity-popup-title"),t=(h(".bb-rl-media-model-wrapper .bb-rl-media-model-header h2").text(a),-1!==h.inArray(i.current_document.extension,n.mp3_preview_extension.split(","))&&h(e.currentTarget).closest(".bb-rl-activity-media-elem.bb-rl-document-activity").length&&h(e.currentTarget).closest(".bb-rl-activity-media-elem.bb-rl-document-activity").find(".bb-rl-document-audio-wrap").length&&h(e.currentTarget).closest(".bb-rl-activity-media-elem.bb-rl-document-activity").find(".bb-rl-document-audio-wrap audio")[0].pause(),h(".bb-rl-media-model-wrapper.media").hide(),h(".bb-rl-media-model-wrapper.document").show(),document.getElementById(h(".bb-rl-media-model-wrapper.video video").attr("id")));t&&(t.pause(),t.src=""),h(".bb-rl-media-model-wrapper.video").hide(),i.is_open_document=!0,setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay")},500)},resetRemoveActivityCommentsData:function(e){var t,i=this,a=!1,o=!1,d=!1,r=!1,n=!1,s=!1;i.current_media.parent_activity_comments&&((a=(r=h(".bb-rl-"+e+'-model-wrapper.media [data-bp-activity-id="'+i.current_media.activity_id+'"]')).find(".bb-rl-activity-comments")).length&&(t=a.find("#ac-form-"+i.current_media.activity_id),this.purgeEditActivityForm(t),t.find("#ac-input-"+i.current_media.activity_id).html(""),t.removeClass("has-content has-gif has-media").addClass("root"),a.append(t),t.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(i.current_media.activity_id),a.find(".acomment-display").removeClass("display-focus"),a.find(".comment-item").removeClass("comment-item-focus"),n=a.html(),s=a.attr("class"),a.remove(),(a=h('[data-bp-activity-id="'+i.current_media.activity_id+'"] .bb-rl-activity-comments')).length)&&(a.attr("class",s),0===a.find("#ac-form-"+i.current_media.activity_id).length)&&(a.append(t),a.children("form").removeClass("events-initiated").addClass("not-initialized")),(d=r.find(".activity-state")).length&&(n=d.html(),s=d.attr("class"),d.remove(),(d=h('[data-bp-activity-id="'+i.current_media.activity_id+'"] .activity-state')).length)&&(d.html(n),d.attr("class",s)),(o=r.find(".activity-meta")).length&&(n=o.html(),s=o.attr("class"),o.remove(),(o=h('[data-bp-activity-id="'+i.current_media.activity_id+'"] > .activity-meta')).length)&&(o.html(n),o.attr("class",s)),r.remove()),i.current_document.parent_activity_comments&&((a=(r=h(".bb-rl-"+e+'-model-wrapper.document [data-bp-activity-id="'+i.current_document.activity_id+'"]')).find(".bb-rl-activity-comments")).length&&(t=a.find("#ac-form-"+i.current_document.activity_id),this.purgeEditActivityForm(t),t.find("#ac-input-"+i.current_document.activity_id).html(""),t.removeClass("has-content has-gif has-media").addClass("root"),a.append(t),t.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(i.current_document.activity_id),a.find(".acomment-display").removeClass("display-focus"),a.find(".comment-item").removeClass("comment-item-focus"),n=a.html(),s=a.attr("class"),a.remove(),(a=h('[data-bp-activity-id="'+i.current_document.activity_id+'"] .bb-rl-activity-comments')).length)&&(a.attr("class",s),0===a.find("#ac-form-"+i.current_document.activity_id).length&&(a.append(t),a.children("form").removeClass("events-initiated").addClass("not-initialized")),a.find(".bb-rl-document-text.loaded").removeClass("loaded").find(".CodeMirror").remove(),jQuery(window).scroll()),(d=r.find(".activity-state")).length&&(n=d.html(),s=d.attr("class"),d.remove(),(d=h('[data-bp-activity-id="'+i.current_document.activity_id+'"] .activity-state')).length)&&(d.html(n),d.attr("class",s)),(o=r.find(".activity-meta")).length&&(n=o.html(),s=o.attr("class"),o.remove(),(o=h('[data-bp-activity-id="'+i.current_document.activity_id+'"] > .activity-meta')).length)&&(o.html(n),o.attr("class",s)),r.remove()),bp.Nouveau.reportPopUp(),bp.Nouveau.reportActions()},closeTheatre:function(e){e.preventDefault();var e=h(e.currentTarget),t="";if(e.closest(".bb-rl-internal-model").hasClass("media-video")?t="media-video":e.closest(".bb-rl-internal-model").hasClass("media")?t="media":e.closest(".bb-rl-internal-model").hasClass("video")&&(t="video"),h(e).closest(".bb-rl-"+t+"-model-wrapper").hasClass("bb-rl-video-theatre"))return!1;var i=h(".bb-rl-"+t+"-model-wrapper.media .bb-rl-media-section"),i=(i.find("img").attr("src",""),i.find("video"));i.length&&videojs(i.attr("id")).reset(),h(".bb-rl-"+t+"-model-wrapper").hide(),this.is_open_media=!1,this.resetRemoveActivityCommentsData(t),this.current_media=!1,this.getParentActivityHtml({target:e,action:t})},closeDocumentTheatre:function(e){e.preventDefault();var t=h(document).find(".bb-rl-document-theatre");t.find(".bb-rl-media-section").removeClass("bb-media-no-preview").find(".document-preview").html(""),h(".bb-media-info-section.document").show(),t.hide(),this.is_open_document=!1,this.resetRemoveActivityCommentsData("media"),this.current_document=!1,this.getParentActivityHtml({target:h(e.currentTarget),action:"media"})},ToggleTheatreSidebar:function(e){e.preventDefault(),h(e.currentTarget).closest(".bb-rl-media-model-container").toggleClass("bb-rl-media-toggle-sidebar")},setMedias:function(e){var t=e.target,e=e.action,i=h(t),a=0;if("media-video"===e&&(i=h(".bb-rl-open-"+e+"-theatre")),void 0!==(i=h("body").hasClass("activity")?h(t).closest(".bb-activity-media-wrap").find(".bb-rl-open-"+e+"-theatre"):i)){this.medias=[];for(var o=i.length,a=0;a '):h(i+" .bb-rl-media-section").children("img").length?e.find("img").attr("src",t.current_media.attachment):e.html(' ')):h(i+" .bb-rl-media-section").find("img").attr("src",t.current_media.attachment);a=h(".bb-rl-media-section .bb-media-privacy-wrap");a.length&&(a.show(),a.find("ul.media-privacy li").removeClass("selected"),a.find(".bp-tooltip").attr("data-bp-tooltip",""),(e=a.find("ul.media-privacy").find("li[data-value="+t.current_media.privacy+"]")).addClass("selected"),a.find(".bp-tooltip").attr("data-bp-tooltip",e.text()),a.find(".privacy").removeClass("public").removeClass("loggedin").removeClass("onlyme").removeClass("friends").addClass(t.current_media.privacy),!(void 0!==l&&void 0!==t.current_media.activity_id&&0!==t.current_media.activity_id||t.group_id||t.current_media.is_forum||t.current_media.group_id||t.current_media.album_id||t.current_media.is_message)&&t.can_manage_media&&t.current_media.can_edit||a.hide()),t.navigationCommands()},showDocument:function(){var e=this;if(void 0===e.current_document)return!1;var t,i=e.current_document.target_text,a=e.current_document.target_icon_class,o=h(document).find(".bb-rl-document-theatre"),d=e.current_document.extension,r=e.current_document.mirror_text,d=(o.find(".bb-rl-document-section").removeClass("bb-video-preview"),-1!==h.inArray(e.current_document.extension,["css","txt","js","html","htm","csv"])?(o.find(".bb-rl-document-section .document-preview").html(''),o.find(".bb-rl-document-section").removeClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),o.find(".bb-rl-document-section .document-preview").html("
"+i+'
'),o.find(".bb-rl-document-section .document-preview .bb-rl-document-text").attr("data-extension",d),t=o.find(".bb-rl-document-section .document-preview .bb-rl-document-text textarea"),"html"===d||"htm"===d?t.val(r):t.html(r),setTimeout(function(){bp.Nouveau.Media.documentCodeMirror()},1e3)):-1!==h.inArray(e.current_document.extension,n.mp3_preview_extension.split(","))?(o.find(".bb-rl-document-section .document-preview").html(''),o.find(".bb-rl-document-section").removeClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),o.find(".bb-rl-document-section .document-preview").html('')):-1!==h.inArray("."+e.current_document.extension,v.video_type.split(","))?(o.find(".bb-rl-document-section").addClass("bb-video-preview"),o.find(".bb-rl-document-section .document-preview").html(''),o.find(".bb-rl-document-section").removeClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),"mov"===e.current_document.extension||"m4v"===e.current_document.extension?o.find(".bb-rl-document-section .document-preview").html(''):o.find(".bb-rl-document-section .document-preview").html(''),h(window).scroll()):e.current_document.full_preview?(o.find(".bb-rl-document-section").removeClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),o.find(".bb-rl-document-section .document-preview").html("'+i+'
"+i+'
')):(o.find(".bb-rl-document-section").addClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),o.find(".bb-rl-document-section .document-preview").html('")),h(".bb-rl-document-section .bb-document-privacy-wrap"));d.length&&(d.show(),d.parent().show(),d.find("ul.document-privacy li").removeClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",""),(t=d.find("ul.document-privacy").find("li[data-value="+e.current_document.privacy+"]")).addClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",t.text()),d.find(".privacy").removeClass("public").removeClass("loggedin").removeClass("onlyme").removeClass("friends").addClass(e.current_document.privacy),void 0!==l&&void 0!==e.current_document.activity_id&&0!==e.current_document.activity_id||e.group_id||e.current_document.is_forum||e.current_document.group_id||e.current_document.album_id||!e.can_manage_document||!e.current_document.can_edit||e.current_document.is_message)&&d.parent().hide(),e.navigationDocumentCommands()},generateAndDisplayMediaThumbnails:function(e){var t,i=e.target,e=e.action,a=this;a.current_activity_data=i.closest(".activity-item").data("bp-activity"),!a.current_activity_data||!a.current_activity_data.media||a.current_activity_data.media.length<=1||(i=a.current_activity_data.media.map(function(e){return''+i+"
'}).join(""),(t=(e=h("."+e+".bb-rl-"+e+"-theatre .bb-rl-media-section")).find(".bb-rl-media-thumbnails")).length?t.html(i):e.append(''+i+""))},handleThumbnailClick:function(e){var t,i,a,e=h(e.currentTarget);!e.hasClass("active")&&((i=h(".bb-rl-media-model-wrapper.media .bb-rl-media-section").find("figure")).find("img").hide(),i.addClass("loading").append(''),t=e.data("id"),i=this.medias.find(function(e){return e.id===t}))&&(a="",e.closest(".bb-rl-internal-model").hasClass("media-video")?a="media-video":e.closest(".bb-rl-internal-model").hasClass("media")?a="media":e.closest(".bb-rl-internal-model").hasClass("video")&&(a="video"),this.updateMedia(i,e,{modalWrapper:".bb-rl-"+a+"-model-wrapper",action:a}))},next:function(e){e.preventDefault();var e=h(e.currentTarget),t="";e.closest(".bb-rl-internal-model").hasClass("media-video")?t="media-video":e.closest(".bb-rl-internal-model").hasClass("media")?t="media":e.closest(".bb-rl-internal-model").hasClass("video")&&(t="video");var e={modalWrapper:".bb-rl-"+t+"-model-wrapper",action:t},i=this;i.current_activity_data&&i.medias[i.current_index+1]?i.updateMedia(i.medias[i.current_index+1],h("."+t+".bb-rl-"+t+"-theatre .bb-rl-media-thumb").eq(i.current_index+1),e):(i.resetRemoveActivityCommentsData(t),void 0!==i.medias[i.current_index+1]?(i.current_index=i.current_index+1,i.current_media=i.medias[i.current_index],e.mediaType=i.medias[i.current_index].type||"",i.showMedia(e),i.getMediasDescription(e),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):i.nextLink.hide())},previous:function(e){e.preventDefault();var e=h(e.currentTarget),t="";e.closest(".bb-rl-internal-model").hasClass("media-video")?t="media-video":e.closest(".bb-rl-internal-model").hasClass("media")?t="media":e.closest(".bb-rl-internal-model").hasClass("video")&&(t="video");var e={modalWrapper:".bb-rl-"+t+"-model-wrapper",action:t},i=this;i.current_activity_data&&i.medias[i.current_index-1]?i.updateMedia(i.medias[i.current_index-1],h("."+t+".bb-rl-"+t+"-theatre .bb-rl-media-thumb").eq(i.current_index-1),e):(i.resetRemoveActivityCommentsData(t),void 0!==i.medias[i.current_index-1]?(i.current_index=i.current_index-1,i.current_media=i.medias[i.current_index],e.mediaType=i.medias[i.current_index].type||"",i.showMedia(e),i.getMediasDescription(e),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):i.previousLink.hide())},updateMedia:function(t,e,i){var a=i.action,o=this,a=h("."+a+".bb-rl-"+a+"-theatre"),d=a.find(".bb-rl-media-section figure"),r=d.find("img");r.one("load",function(){d.removeClass("loading").find(".bb-rl-loader").remove(),r.show()}).one("error",function(){d.removeClass("loading").find(".bb-rl-loader").remove()}).attr("src",t.attachment),a.find(".bb-rl-media-thumb").removeClass("active"),e.addClass("active"),o.current_index=o.medias.findIndex(function(e){return e.id===t.id}),o.current_media=t,o.nextLink.toggle(Boolean(o.medias[o.current_index+1])),o.previousLink.toggle(Boolean(o.medias[o.current_index-1])),o.activity_ajax&&o.activity_ajax.abort(),o.fetchMediaDescription(t,a,i)},fetchMediaDescription:function(o,d,e){var r=e.mediaType,n=e.action,s=this,e=(!1!==s.activity_ajax&&s.activity_ajax.abort(),h('[data-bp-activity-id="'+o.activity_id+'"] .bb-rl-activity-comments')),e=(e.length&&(e=e.find("#ac-form-"+o.activity_id),o.parent_activity_comments=!0,e.remove()),!0===o.parent_activity_comments&&h(".bb-rl-"+n+"-model-wrapper:last").after(''),{id:o.id,attachment_id:o.attachment_id,activity_id:o.activity_id});"media-video"===n&&"video"===r?(e.action="video_get_video_description",e.nonce=w.video):(e.action="media_get_media_description",e.nonce=w.media),s.activity_ajax=h.ajax({type:"POST",url:y,data:e,beforeSend:function(){d.find(".bb-media-info-section .bb-rl-activity-list").addClass("loading").html('')},success:function(e){var t,i,a;e.success?(t=d.find(".bb-media-info-section:visible"),i=h(".bb-rl-"+n+"-model-wrapper"),"media-video"===n&&"video"===r&&((a=i.find(".bb-rl-media-section figure")).html(e.data.video_data),a.find("video").attr("autoplay",!0)),t.find(".bb-rl-activity-list").removeClass("loading").html(e.data.description),void 0!==e.data.comment_form&&void 0!==bp.Nouveau.Activity&&(t.find(".bb-rl-activity-list .bb-rl-activity-comments ul:first").after(e.data.comment_form),t.find("#ac-form-"+o.activity_id).removeClass("not-initialized").addClass("root events-initiated").find("#ac-input-"+o.activity_id).focus(),a=t.find("#ac-form-"+o.activity_id),bp.Nouveau.Activity.clearFeedbackNotice(a),a.removeClass("events-initiated"),e=t.find(".ac-form .ac-input[contenteditable]"),bp.Nouveau.Activity.listenCommentInput(e),_.isUndefined(g)||_.isUndefined(g.emoji)||bp.Nouveau.Activity.initializeEmojioneArea(!0,"#bb-rl-activity-modal ",o.activity_id)),t.show(),t.find(".bb-activity-more-options-action").attr("data-balloon-pos","left"),s.updateTheaterHeaderTitle({wrapper:i,action:n}),requestAnimationFrame(function(){h(window).scroll(),bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()})):d.find(".bb-media-info-section.media").hide()}})},nextDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData("media"),void 0!==e.documents[e.current_document_index+1]?(e.current_document_index=e.current_document_index+1,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.nextDocumentLink.hide()},previousDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData("media"),void 0!==e.documents[e.current_document_index-1]?(e.current_document_index=e.current_document_index-1,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.previousDocumentLink.hide()},navigationCommands:function(){var e=this;0===e.current_index&&e.current_index!==e.medias.length-1?(e.previousLink.hide(),e.nextLink.show()):0===e.current_index&&e.current_index===e.medias.length-1?(e.previousLink.hide(),e.nextLink.hide()):e.current_index===e.medias.length-1?(e.previousLink.show(),e.nextLink.hide()):(e.previousLink.show(),e.nextLink.show())},navigationDocumentCommands:function(){var e=this;0===e.current_document_index&&e.current_document_index!==e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.show()):0===e.current_document_index&&e.current_document_index===e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.hide()):e.current_document_index===e.documents.length-1?(e.previousDocumentLink.show(),e.nextDocumentLink.hide()):(e.previousDocumentLink.show(),e.nextDocumentLink.show())},getDocumentsDescription:function(){var t=this,e=(h(".bb-media-info-section .bb-rl-activity-list").addClass("loading").html(''),!1!==t.activity_ajax&&t.activity_ajax.abort(),h('[data-bp-activity-id="'+t.current_document.activity_id+'"] .bb-rl-activity-comments'));e.length&&(e=e.find("#ac-form-"+t.current_document.activity_id),t.current_document.parent_activity_comments=!0,e.remove()),!0===t.current_document.parent_activity_comments&&h(".bb-rl-media-model-wrapper:last").after(''),t.activity_ajax=h.ajax({type:"POST",url:y,data:{action:"document_get_document_description",id:t.current_document.id,attachment_id:t.current_document.attachment_id,nonce:w.media},success:function(e){e.success?(h(".bb-media-info-section:visible .bb-rl-activity-list").removeClass("loading").html(e.data.description),void 0!==e.data.comment_form&&void 0!==bp.Nouveau.Activity&&(h(".bb-media-info-section:visible .bb-rl-activity-list .bb-rl-activity-comments ul:first").after(e.data.comment_form),h(".bb-media-info-section:visible").find("#ac-form-"+t.current_document.activity_id).removeClass("not-initialized").addClass("root events-initiated").find("#ac-input-"+t.current_document.activity_id).focus(),e=h(".bb-media-info-section:visible").find("#ac-form-"+t.current_document.activity_id),bp.Nouveau.Activity.clearFeedbackNotice(e),e.removeClass("events-initiated"),e=h(".bb-media-info-section:visible").find(".ac-form .ac-input[contenteditable]"),bp.Nouveau.Activity.listenCommentInput(e),_.isUndefined(g)||_.isUndefined(g.emoji)||bp.Nouveau.Activity.initializeEmojioneArea(!0,"#bb-rl-activity-modal ",t.current_document.activity_id)),h(".bb-media-info-section:visible").show(),t.updateTheaterHeaderTitle({wrapper:h(".bb-rl-media-model-wrapper"),action:"media"}),h(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10),h(".bb-media-info-section:visible").find(".bb-activity-more-options-action").attr("data-balloon-pos","left")):h(".bb-media-info-section.document").hide()}})},activityDeleted:function(e,t){var i=this,a=0;if(i.is_open_media&&void 0!==t&&"delete_activity"===t.action&&i.current_media.activity_id===t.id){for(var o=h(document).find('[data-bp-list="media"] .bb-rl-open-media-theatre[data-id="'+i.current_media.id+'"]'),d=o.parents("ul"),r=(o.closest("li").remove(),0===d.find("li:not(.load-more)").length&&(0<(o=h(".bb-photos-actions")).length&&o.hide(),1===d.find("li.load-more").length)&&location.reload(),h(document).find('[data-bp-list="activity"] .bb-rl-open-media-theatre[data-id="'+i.current_media.id+'"]').closest(".bb-rl-activity-media-elem").remove(),i.medias.length),a=0;aDate: Mon, 17 Aug 2026 18:40:57 +0530 Subject: [PATCH 3/4] PROD-9616 - Harden the modal-delete flow per review Follow-up hardening on the "view more comments" modal delete fix, from the two-reviewer pass: - Clear activityPinHasUpdates before triggering the modal close (legacy). Pinning the post from inside the modal and then deleting it made the close-button's sync handler call refreshActivities() unconditionally, reloading the whole feed from page 1 over the anchor scroll and losing the member's scroll position. - Make the feed anchor lookup robust. prev()/next() only filter the immediate sibling, so a load-more row silently skipped the anchoring, and the trailing placeholder li (which carries the activity-item class) could become the scroll target. Use prevAll()/nextAll().first() and exclude the placeholder per theme (.activity-popup on legacy, .bb-rl-activity-popup on ReadyLaunch). - Fix the media-path close gate, which was dead code. The pre-existing cleanup selector goes through querySelectorAll, which matches duplicate ids, so it already removes the modal's copy of the activity li - the old gate then looked for that same li and could never pass. Gate on "modal visible and its activity list now empty" instead, which fires exactly when the displayed activity is gone and keeps a modal showing a different activity open. Comments reworded to state the real mechanism. - Fall back to hiding the model wrapper when a theme override renames the close control, instead of silently leaving the emptied modal open. - Document the post-close slideUp as an intentional detached-node no-op for the modal path (an early return there would skip the bp_activity_ajax_delete_request triggers the theatre listeners use). --- .../bp-nouveau/js/buddypress-activity.js | 21 ++++++++++++++++--- .../bp-nouveau/js/buddypress-activity.min.js | 2 +- .../bp-nouveau/js/buddypress-media.js | 20 +++++++++++------- .../bp-nouveau/js/buddypress-media.min.js | 2 +- .../readylaunch/js/buddypress-activity.js | 16 +++++++++++--- .../readylaunch/js/buddypress-activity.min.js | 2 +- .../readylaunch/js/buddypress-media.js | 20 +++++++++++------- .../readylaunch/js/buddypress-media.min.js | 2 +- 8 files changed, 61 insertions(+), 24 deletions(-) diff --git a/src/bp-templates/bp-nouveau/js/buddypress-activity.js b/src/bp-templates/bp-nouveau/js/buddypress-activity.js index a0a00a450d5..4668602960a 100644 --- a/src/bp-templates/bp-nouveau/js/buddypress-activity.js +++ b/src/bp-templates/bp-nouveau/js/buddypress-activity.js @@ -1282,15 +1282,30 @@ window.bp = window.bp || {}; // an empty shell. Drop the feed copy, close the modal through // its real close button, and anchor the feed on the deleted // post's neighbor so the user lands at the right position. + // The close empties the modal list, so the slideUp below runs + // on a detached node for this path - intentional no-op. if ( ! ajaxData.is_comment && li_parent.closest( '#activity-modal' ).length ) { var $feedCopy = $( '#activity-stream li.activity-item[data-bp-activity-id="' + ajaxData.id + '"]' ); - var $feedAnchor = $feedCopy.prev( 'li.activity-item' ); + var $feedAnchor = $feedCopy.prevAll( 'li.activity-item:not(.activity-popup)' ).first(); if ( ! $feedAnchor.length ) { - $feedAnchor = $feedCopy.next( 'li.activity-item' ); + $feedAnchor = $feedCopy.nextAll( 'li.activity-item:not(.activity-popup)' ).first(); } + // A pin toggled from inside the modal is moot once the post + // is deleted - left set, the close-button's sync handler + // reloads the whole feed over the anchor scroll below. + bp.Nouveau.Activity.activityPinHasUpdates = false; + $feedCopy.remove(); - $( '#activity-modal .bb-modal-activity-header .bb-close-action-popup' ).trigger( 'click' ); + + var $modalCloseButton = $( '#activity-modal .bb-modal-activity-header .bb-close-action-popup' ); + if ( $modalCloseButton.length ) { + $modalCloseButton.trigger( 'click' ); + } else { + // A theme override may rename the close control - never + // leave the emptied modal open. + $( '#activity-modal' ).closest( '.bb-activity-model-wrapper' ).hide(); + } if ( $feedAnchor.length ) { var adminBar = $( '#wpadminbar' ).length !== 0 ? $( '#wpadminbar' ).innerHeight() : 0; diff --git a/src/bp-templates/bp-nouveau/js/buddypress-activity.min.js b/src/bp-templates/bp-nouveau/js/buddypress-activity.min.js index 14349dcb37a..ee6a82f7c97 100644 --- a/src/bp-templates/bp-nouveau/js/buddypress-activity.min.js +++ b/src/bp-templates/bp-nouveau/js/buddypress-activity.min.js @@ -1 +1 @@ -window.bp=window.bp||{},(q=>{"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},bp.Models=bp.Models||{},bp.Models.ACReply=Backbone.Model.extend({defaults:{gif_data:{}}}),bp.Nouveau.Activity={start:function(){this.setupGlobals(),this.addListeners()},invokeMediaFn:function(e){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media[e]&&bp.Nouveau.Media[e]()},setupGlobals:function(){this.just_posted=[],this.current_page=1,this.mentions_count=Number(q(bp.Nouveau.objectNavParent+' [data-bp-scope="mentions"]').find("a span").html())||0,this.heartbeat_data={newest:"",highlights:{},last_recorded:0,first_recorded:0,document_title:q(document).prop("title")},void 0!==window.Dropzone&&void 0!==BP_Nouveau.media&&(window.Dropzone.autoDiscover=!1,this.dropzone_options={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,dictDefaultMessage:BP_Nouveau.media.dropzone_media_message,acceptedFiles:"image/*",autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.media.maxFiles?BP_Nouveau.media.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2,dictMaxFilesExceeded:BP_Nouveau.media.media_dict_file_exceeded,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation,maxThumbnailFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2},void 0!==BP_Nouveau.media.dropzone_options)&&Object.assign(this.dropzone_options,BP_Nouveau.media.dropzone_options),this.dropzone_obj=null,this.dropzone_media=[],this.dropzone_document_obj=null,this.dropzone_document=[],this.dropzone_video_obj=null,this.dropzone_video=[],this.models=[],this.InitiatedCommentForms=[],this.activityHasUpdates=!1,this.currentActivityId=null,this.activityPinHasUpdates=!1},addListeners:function(){q("body").hasClass("activity-singular")||q("#buddypress").on("bp_heartbeat_send",this.heartbeatSend.bind(this)),q("#buddypress").on("bp_heartbeat_tick",this.heartbeatTick.bind(this)),q(".actvity-head-bar").length&&(q(".actvity-head-bar").addClass("activity-head-bar").removeClass("actvity-head-bar"),q(".activity-head-bar > nav.activity-type-navs").length)&&q(".activity-head-bar .bb-subnav-filters-filtering").length&&q(".activity-head-bar > nav.activity-type-navs").remove(),q('#buddypress [data-bp-list="activity"]:not( #bb-schedule-posts_modal [data-bp-list="activity"] )').on("click","li.load-newest, li.load-more",this.injectActivities.bind(this)),void 0!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request?q("#buddypress").on("bp_ajax_request",'[data-bp-list="activity"]',this.scopeLoaded.bind(this)):q(window).on("load",function(){setTimeout(function(){bp.Nouveau.Activity.openEditActivityPopup()}.bind(this),0)}),q("#activity-stream").on("click",".acomments-view-more",this.showActivity),q("body").on("click",".bb-close-action-popup",this.closeActivity),q(document).on("activityModalOpened",function(e,t){var a=t.activityId;q(document).on("click",".bb-activity-model-wrapper.activity-theatre",function(e){!(0 li.bb-edit-privacy a",bp.Nouveau,this.activityPrivacyRedirect.bind(this)),q('#buddypress [data-bp-list="activity"], #activity-modal').on("click",".activity-privacy>li:not(.bb-edit-privacy)",bp.Nouveau,this.activityPrivacyChange.bind(this)),q('#buddypress [data-bp-list="activity"], #bb-media-model-container .activity-list, #activity-modal').on("click","span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),q("#bb-media-model-container .activity-list").on("click",".activity-item",bp.Nouveau,this.activityActions.bind(this)),q(".bb-activity-model-wrapper").on("click",".ac-form-placeholder",bp.Nouveau,this.activityRootComment.bind(this)),q(document).keydown(this.commentFormAction),q(document).click(this.togglePopupDropdown),q('#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)),q('#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)),q('#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)),q('#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)),q(document).on("click",".activity-state-popup_overlay",bp.Nouveau,this.closeActivityState.bind(this)),q(document).on("click",".activity-state-popup .activity-state-popup_tab_panel a",this.ReactionStatePopupTab),_.isUndefined(BP_Nouveau.activity.params.autoload)||q(window).scroll(this.loadMoreActivities),q(document).on("click",".bb-subnav-filters-container .subnav-filters-opener",this.openActivityFilter.bind(this)),q(document).on("click",this.closeActivityFilter.bind(this)),q(document).on("click",".bb-subnav-filters-container .subnav-filters-modal a:not(.layout-view)",this.filterActivity.bind(this)),q(".bb-activity-model-wrapper, .bb-media-model-wrapper").on("click",".acomments-view-more",this.viewMoreComments.bind(this)),q(document).on("click","#activity-stream .activity-comments .view-more-comments, #activity-stream .activity-state-comments > .comments-count",function(e){e.preventDefault(),q(this).parents("li.activity-item").find(".activity-comments > ul > li.acomments-view-more, .activity-comments > .activity-actions > ul > li.acomments-view-more").trigger("click")}),q("#activity-modal > .bb-modal-activity-body").on("scroll",this.autoloadMoreComments.bind(this)),q("#activity-modal > .bb-modal-activity-body").on("scroll",this.discardGifEmojiPicker.bind(this)),q(".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?q("#buddypress").on("bp_ajax_request",'[data-bp-list="activity"]',function(){setTimeout(function(){q(".ac-form.not-initialized").each(function(){var e=q(this),t=e.find(".ac-textarea");bp.Nouveau.Activity.toggleMultiMediaOptions(e,t)})},1e3)}):setTimeout(function(){q(".ac-form.not-initialized").each(function(){var e=q(this),t=e.find(".ac-textarea");bp.Nouveau.Activity.toggleMultiMediaOptions(e,t)})},1e3),bp.Nouveau.wrapNavigation(".activity-topic-selector ul",120,!0)},heartbeatSend:function(e,t){q(bp.Nouveau.objectNavParent+" [data-bp-orderby=date_updated].selected").length?void 0!==(a=q("#buddypress [data-bp-list] [data-bp-activity-id]:not(.bb-pinned)").first()).data("bb-updated-timestamp")?this.heartbeat_data.first_recorded=a.data("bb-updated-timestamp"):a.length&&void 0!==a.data("bp-activity").date_updated&&""!==a.data("bp-activity").date_updated?(o=a.data("bp-activity").date_updated,o=new Date(o.replace(" ","T")+"Z").getTime()/1e3,this.heartbeat_data.first_recorded=o):this.heartbeat_data.first_recorded=a.data("bp-timestamp")||0:this.heartbeat_data.first_recorded=q("#buddypress [data-bp-list] [data-bp-activity-id]:not(.bb-pinned)").first().data("bp-timestamp")||0;var a,i,o=q("#buddypress [data-bp-list] [data-bp-activity-id]").first().data("bp-timestamp")||0;o>this.heartbeat_data.first_recorded&&(this.heartbeat_data.first_recorded=o),(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,q("#buddypress .activity-head-bar .activity-search input[type=search]").length&&(t.bp_activity_last_recorded_search_terms=q("#buddypress .activity-head-bar .activity-search input[type=search]").val()),q.extend(t,{bp_heartbeat:(a={scope:"all"},q("body.my-activity:not(.activity-singular)").length?a=bp.Nouveau.getStorage("bp-user-activity")||{scope:"just-me"}:(a=bp.Nouveau.getStorage("bp-activity")||{scope:"all"},q("body.activity.buddypress.groups.single-item").length&&(a.scope="all")),q(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").length&&(i=q(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").data("bp-scope"),void 0!==a.scope&&a.scope===i||(a.scope=i,"undefined"!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request&&(q("body.my-activity:not(.activity-singular)").length?bp.Nouveau.setStorage("bp-user-activity","scope",i):bp.Nouveau.setStorage("bp-activity","scope",i)))),q(bp.Nouveau.objectNavParent+" [data-bp-order].selected").length&&(i=q(bp.Nouveau.objectNavParent+" [data-bp-order].selected").data("bp-orderby"),a.order_by=i),(i=bp.Nouveau.getStorage("bp-activity","topic_id"))&&(t.bp_heartbeat=t.bp_heartbeat||{},t.bp_heartbeat.topic_id=i),a)})},heartbeatTick:function(e,t){var a,i,o=bp.Nouveau.objects,d=bp.Nouveau.getStorage("bp-activity","scope"),s=this,n=bp.Nouveau.getStorage("bp-activity","topic_id");void 0!==t&&t.bp_activity_newest_activities&&(this.heartbeat_data.newest=q.trim(t.bp_activity_newest_activities.activities)+this.heartbeat_data.newest,this.heartbeat_data.last_recorded=Number(t.bp_activity_newest_activities.last_recorded),t=q(this.heartbeat_data.newest).filter(".activity-item"),n&&(a=(t=t.filter(function(){var e=this.dataset.bpActivity?JSON.parse(this.dataset.bpActivity):null,e=e&&void 0!==e.topic_id?e.topic_id:null;return e&&parseInt(e)===parseInt(n)})).length),a=Number(t.length),o.push("mentions"),"all"===d?(q.each(t,function(e,a){a=q(a),q.each(o,function(e,t){-1!==q.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===q.inArray(a.data("bp-activity-id"),s.heartbeat_data.highlights[t])&&s.heartbeat_data.highlights[t].push(a.data("bp-activity-id")))})}),i=new RegExp("bp-my-("+o.join("|")+")","g"),this.heartbeat_data.newest=this.heartbeat_data.newest.replace(i,""),q(bp.Nouveau.objectNavParent+' [data-bp-scope="all"]').find("a span").html(a)):(this.heartbeat_data.highlights[d]=[],q.each(t,function(e,t){s.heartbeat_data.highlights[d].push(q(t).data("bp-activity-id"))})),q.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),q(bp.Nouveau.objectNavParent+' [data-bp-scope="'+t+'"]').find("a span").html(Number(s.heartbeat_data.highlights[t].length)+a))}),o.pop(),q(document).prop("title","("+a+") "+this.heartbeat_data.document_title),q('#buddypress [data-bp-list="activity"]').first().hasClass("load-newest")?(i=q('#buddypress [data-bp-list="activity"] .load-newest a').html(),q('#buddypress [data-bp-list="activity"] .load-newest a').html(i.replace(/([0-9]+)/,a))):q('#buddypress [data-bp-list="activity"] ul.activity-list').prepend(''+BP_Nouveau.newest+" ("+a+") "),q('#buddypress [data-bp-list="activity"] li.load-newest').trigger("click"),q('#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=q("body.my-activity:not(.activity-singular)").length?bp.Nouveau.getStorage("bp-user-activity"):bp.Nouveau.getStorage("bp-activity"),s=d.scope||null,d=d.filter||null;q(e.currentTarget).hasClass("load-newest")?(e.preventDefault(),q(e.currentTarget).remove(),i=q.parseHTML(this.heartbeat_data.newest),q.each(i,function(e,t){"LI"===t.nodeName&&q(t).hasClass("just-posted")&&q("#"+q(t).prop("id")).length&&q("#"+q(t).prop("id")).remove()}),(0<(i=q(e.delegateTarget).find(".activity-list .activity-item").first()).length&&i.hasClass("bb-pinned")?q(i).after(this.heartbeat_data.newest):q(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&&q(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),q(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(){q(e.delegateTarget).find("[data-bp-activity-id]").removeClass("newest_"+s+"_activity")},3e3),q(document).prop("title",this.heartbeat_data.document_title),jQuery(window).scroll()):q(e.currentTarget).hasClass("load-more")&&(t=+Number(this.current_page)+1,a=this,i="",e.preventDefault(),(o=q(e.currentTarget)).find("a").first().addClass("loading"),this.just_posted=[],q(e.delegateTarget).children(".just-posted").each(function(){a.just_posted.push(q(this).data("bp-activity-id"))}),q("#buddypress .dir-search input[type=search]").length?i=q("#buddypress .dir-search input[type=search]").val():q("#buddypress .activity-search.bp-search input[type=search]").length&&(i=q("#buddypress .activity-search.bp-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())})),q(".activity-item.bb-closed-comments").find(".edit-activity, .acomment-edit").parents(".generic-button").hide()},hideComments:function(e){var a,i,o,e=q(e.target).find(".activity-comments");e.length&&e.each(function(e,t){o=q(t).children("ul").not(".conflict-activity-ul-li-comment"),!(i=q(o).find("li").not(q(".document-action-class, .media-action-class, .video-action-class"))).length||q("body").hasClass("activity-singular")&&""!==window.location.hash&&q(window.location.hash).length&&0!==q(window.location.hash).closest(".activity-comments").length||(a=q(t).closest(".activity-item"),q("#acomment-comment-"+a.data("bp-activity-id")+" span.comment-count").html(),i.each(function(e,t){if(e"),window.location.hash&&"#"+q(t).attr("id")===window.location.hash)return q(t).parents("li.comment-item").show(),!1;q(t).addClass("bp-hidden").hide()}}),q(o).children(".bp-hidden").length===q(o).children("li").length-1&&q(o).find("li.show-all").length&&q(o).children("li:not(.show-all)").removeClass("bp-hidden").toggle())})},showActivity:function(e){e.preventDefault();var t=q(e.currentTarget).parent(),a=t.data("parent_comment_id"),t=q(t).data("activity_id");q(document).trigger("activityModalOpened",{activityId:t}),q(e.currentTarget).parents(".activity-comments").find(".ac-form").each(function(){var e=q(this),t=q(this).closest(".activity-comments"),a=q(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 e=q(e.target).closest(".bb-activity-model-wrapper"),t=e.find(".bb-modal-activity-footer"),a=e.find(".activity-item").data("bp-activity-id"),i=e.find("#ac-form-"+a);bp.Nouveau.Activity.reinitializeActivityCommentForm(i),_.isUndefined(BP_Nouveau.media)||_.isUndefined(BP_Nouveau.media.emoji)||bp.Nouveau.Activity.initializeEmojioneArea(!1,"",a),e.find("#activity-modal").removeClass("bb-closed-comments"),e.closest("body").removeClass("acomments-modal-open"),e.hide(),e.find("ul.activity-list").empty(),t.removeClass("active"),t.find("form.ac-form").remove()},scopeLoaded:function(e,a){this.current_page=1,"mentions"===a.scope&&void 0!==a.response.new_mentions?(q.each(a.response.new_mentions,function(e,t){q("#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&&q.each(this.heartbeat_data.highlights[a.scope],function(e,t){q("#buddypress #activity-stream").find('[data-bp-activity-id="'+t+'"]').length&&q("#buddypress #activity-stream").find('[data-bp-activity-id="'+t+'"]').addClass("newest_"+a.scope+"_activity")}),this.heartbeat_data.newest="",q.each(q(bp.Nouveau.objectNavParent+" [data-bp-scope]").find("a span"),function(e,t){0===parseInt(q(t).html(),10)&&q(t).html("")}),void 0!==this.heartbeat_data.highlights[a.scope]&&(this.heartbeat_data.highlights[a.scope]=[]),q(document).prop("title",this.heartbeat_data.document_title),setTimeout(function(){q("#buddypress #activity-stream .activity-item").removeClass("newest_"+a.scope+"_activity")},3e3),setTimeout(function(){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media.autoPlayGifVideos&&bp.Nouveau.Media.autoPlayGifVideos()},200),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 .acomment-display > .acomment_inner").find(".activity-state-reactions").parent().addClass("bb-has-reaction_update"):"activity"===d&&q(".activity[data-bp-activity-id="+f+"] > .activity-content").find(".activity-state-reactions").parent().addClass("bb-has-reaction_update"),"fav"===i?void 0===e.data.directory_tab||""===e.data.directory_tab||q(s.objectNavParent+' [data-bp-scope="favorites"]').length||q(s.objectNavParent+' [data-bp-scope="all"]').after(e.data.directory_tab):"unfav"===i&&((t=q('[data-bp-user-scope="favorites"]').hasClass("selected")||q(s.objectNavParent+' [data-bp-scope="favorites"]').hasClass("selected"))&&m.remove(),void 0!==e.data.no_favorite)&&(q(s.objectNavParent+' [data-bp-scope="all"]').length&&q(s.objectNavParent+' [data-bp-scope="all"]').hasClass("selected")?q(s.objectNavParent+' [data-bp-scope="favorites"]').remove():t&&L.append(e.data.no_favorite)))}).fail(function(){l.removeClass("loading")})}if(l.hasClass("delete-activity")||l.hasClass("acomment-delete")||l.hasClass("spam-activity")||l.hasClass("spam-activity-comment")){var h,g,C,N,w,P=l.closest("[data-bp-activity-comment-id]"),z=P.data("bp-activity-comment-id"),j=0;if((w=l.closest(".activity-comments")).addClass("active"),e.preventDefault(),void 0!==BP_Nouveau.confirm&&!1===window.confirm(BP_Nouveau.confirm))return!1;l.addClass("loading");var B={action:"delete_activity",id:p,_wpnonce:s.getLinkParams(l.prop("href"),"_wpnonce"),is_single:l.closest("[data-bp-single]").length};(l.hasClass("spam-activity")||l.hasClass("spam-activity-comment"))&&(B.action="bp_spam_activity"),h=m,z&&(delete B.is_single,B.id=z,B.is_comment=!0,h=P),s.ajax(B,"activity").done(function(e){if(l.removeClass("loading"),!1===e.success)h.append(e.data.feedback),h.find(".bp-feedback").hide().fadeIn(300);else{var t,a,i,o=h.closest(".has-child-comments"),d=(h.hasClass("has-child-comments")&&(t=h.closest("ul").closest("li")),o.find("> ul"));if(e.data.redirect)return window.location.href=e.data.redirect;e.data.parent_activity_id&&e.data.activity&&q("body:not(.activity-singular) #buddypress #activity-stream ul.activity-list li#activity-"+e.data.parent_activity_id).replaceWith(e.data.activity),z&&(j=1,i=P.find(".acomments-view-more").data("child-count"),m.append(P.find("form")),q.each(P.find("li.comment-item"),function(){j+=1}),j+=void 0!==i?parseFloat(i):0,g=v.find("span.comments-count"),C=g.text().length?g.text().match(/\d+/)[0]:0,C=Number(C-j),u.length?(i=1 ul").html().trim()&&t.removeClass("has-child-comments")}),z||m.data("bp-timestamp")!==s.Activity.heartbeat_data.last_recorded||(s.Activity.heartbeat_data.newest="",s.Activity.heartbeat_data.last_recorded=0),q(document).trigger("bp_activity_ajax_delete_request",q.extend(B,{response:e})),q(document).trigger("bp_activity_ajax_delete_request_video",q.extend(B,{response:e})),bp.Nouveau.Activity.activityHasUpdates=!0,bp.Nouveau.Activity.currentActivityId=p}w.removeClass("active")})}if(l.closest("span").hasClass("activity-read-more")){var x=l.closest("div"),H=l.closest("span");if(f=null,q(x).hasClass("activity-inner")?f=p:q(x).hasClass("acomment-content")&&(f=l.closest("li").data("bp-activity-comment-id")),!f)return e;e.preventDefault(),q(H).addClass("loading"),s.ajax({action:"get_single_activity_content",id:f},"activity").done(function(e){"object"!=typeof e&&0 ul li.comment-item").length+1&&(A=k.parent().closest("li.comment-item")).length?A:k:c.find('[data-bp-activity-comment-id="'+f+'"]'),y&&q(".bb-modal-activity-footer").removeClass("active"),A.append(r)),r.removeClass("not-initialized"),r.find(".post-elements-buttons-item.post-emoji").prevAll().not(":hidden").length+1),c=(r.find(".post-elements-buttons-item.post-emoji").attr("data-nth-child",k),r.find(".post-elements-buttons-item.post-gif").prevAll().not(":hidden").length+1),A=(r.find(".post-elements-buttons-item.post-gif").attr("data-nth-child",c),r.find(".ac-input[contenteditable]")),k=(bp.Nouveau.Activity.listenCommentInput(A),l.attr("aria-expanded","true"),l.closest(".activity-comments").find(".acomment-display").removeClass("display-focus"),l.closest(".activity-comments").find(".comment-item").removeClass("comment-item-focus"),l.closest(".acomment-display").addClass("display-focus"),l.closest(".comment-item").addClass("comment-item-focus"),_.isNull(t)||(T=t.nickname),_.isNull(t)||(M=t.user_id),'@'+T+" ");_.isUndefined(BP_Nouveau.activity.params.user_id)||(O=BP_Nouveau.activity.params.user_id);var T,c={offset:-(q(window).height()/2-75),easing:"swing"},S=A.get(0);jQuery("body").hasClass("bb-is-mobile")?setTimeout(function(){var e=300 /gi,"\n").replace(/<\/div>/gi,""),M={action:"new_activity_comment",_wpnonce_new_activity_comment:q("#_wpnonce_new_activity_comment").val(),comment_id:f,form_id:p,content:O},Q=(q("#_bp_as_nonce_"+p).val()&&(M["_bp_as_nonce_"+p]=q("#_bp_as_nonce_"+p).val()),this.dropzone_media.length&&(M.media=this.dropzone_media),this.dropzone_document.length&&(M.document=this.dropzone_document),this.dropzone_video.length&&(M.video=this.dropzone_video,_.isEmpty(M.content))&&(M.content=""),_.isUndefined(this.models[p])||(I=this.models[p],M.gif_data=this.models[p].get("gif_data")),M.content=M.content.replace(/ /g," "),r.hasClass("acomment-edit")&&(M.edit_comment=!0),0 '),r.closest("#activity-modal").find(".bb-modal-activity-body .activity-comments, .bb-modal-activity-body .activity-comments .activity-actions").children("ul").append(q(d))):(0===t.children("ul").length&&(t.hasClass("activity-comments")?t.prepend(" "):t.append("
")),t.children("ul").append(q(d).hide().fadeIn(200))),q(r).find(".ac-input").first().html(""),t.parent().addClass("has-comments"),t.parent().addClass("comments-loaded"),v.addClass("has-comments")),r.removeClass("acomment-edit"),r.find(".ac-reply-content"));if(0
'+BP_Nouveau.activity.strings.commentPostError+""):(e=e.responseJSON&&e.responseJSON.message?e.responseJSON.message:e.statusText,r.find(".ac-reply-content").after(' '+e+""))})}if(l.hasClass("edit")&&l.hasClass("edit-activity")&&(e.preventDefault(),k=m.data("bp-activity"),t=""!==m.data("link-url")?m.data("link-url"):null,void 0!==k)&&(bp.Nouveau.Activity.postForm.displayEditActivityForm(k,t),l.closest("li").hasClass("groups")?q("#bp-nouveau-activity-form").addClass("group-activity"):q("#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)&&(q(document).find(".bb-close-media-theatre").trigger("click"),q(document).find(".bb-close-document-theatre").trigger("click")),y&&(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(),!p)return e;l.closest(".activity-item").addClass("loading-pin");var E="pin";l.hasClass("unpin-activity")&&(E="unpin"),s.ajax({action:"activity_update_pinned_post",id:p,pin_action:E},"activity").done(function(e){var t,a,i,o,d,s,n,c,r;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"),a=l.closest(".buddypress-wrap:not(.bb-internal-model)").find("#activity-stream"),i=0"+e.data.feedback+"",e.success?"success":"error",null,!0]),y)&&(void 0!==bp.Nouveau.Activity.activityHasUpdates&&(bp.Nouveau.Activity.activityHasUpdates=!0),void 0!==bp.Nouveau.Activity.activityPinHasUpdates)&&(bp.Nouveau.Activity.activityPinHasUpdates=!0)}).fail(function(){l.closest(".activity-item").removeClass("loading-pin"),q(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(),!p)return e;l.closest(".activity-item").addClass("loading-mute");var D="mute";l.hasClass("bb-icon-bell")&&(D="unmute"),s.ajax({action:"toggle_activity_notification_status",id:p,notification_toggle_action:D},"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"===D?(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"===D&&(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),q(document).trigger("bb_trigger_toast_message",["",""+e.data.feedback+"","success",null,!0])),y&&(bp.Nouveau.Activity.activityPinHasUpdates=!0),bp.Nouveau.Activity.activityHasUpdates=!0,bp.Nouveau.Activity.currentActivityId=p}).fail(function(){l.closest(".activity-item").removeClass("loading-pin"),q(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(),!p)return e;l.closest(".activity-item").addClass("loading-pin");var V="close_comments";l.hasClass("unclose-activity-comment")&&(V="unclose_comments"),s.ajax({action:"activity_update_close_comments",id:p,close_comments_action:V},"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=q("#activity-stream > .activity-list").find("[data-bp-activity-id="+p+"]"),l.closest(".activity-item").find(".bb-activity-closed-comments-notice").remove(),"close_comments"===V?(l.closest("li.activity-item").addClass("bb-closed-comments"),0'+e.data.feedback+""),0 '+e.data.feedback+""))):"unclose_comments"===V&&(l.closest("li.activity-item.bb-closed-comments").find(".edit-activity, .acomment-edit").parents(".generic-button").show(),l.closest("li.activity-item").removeClass("bb-closed-comments"),0 "+e.data.feedback+"",e.success?"success":"error",null,!0]))}).fail(function(){l.closest(".activity-item").removeClass("loading-pin"),q(document).trigger("bb_trigger_toast_message",[""," "+BP_Nouveau.activity.strings.closeCommentsError+"","error",null,!0])})}},commentFormAction:function(e){var t,a;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),!0!==e.altKey&&!0!==e.metaKey&&"TEXTAREA"===t.tagName&&q(t).hasClass("ac-input")?void(27===(a=e.keyCode||e.which)&&!1===e.ctrlKey?"TEXTAREA"===t.tagName&&q(t).closest("form").slideUp(200):e.ctrlKey&&13===a&&q(t).val()&&q(t).closest("form").find("[type=submit]").first().trigger("click")):e},togglePopupDropdown:function(e){var t;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),!0===e.altKey||!0===e.metaKey||q(t).hasClass("privacy-wrap")||q(t).parent().hasClass("privacy-wrap")?e:void q("ul.activity-privacy").removeClass("bb-open")},loadMoreActivities:function(){var e,t=q(".load-more:visible").last(),a=q(window);t.closest(".activity-list").length&&t.get(0)&&!t.data("bp-autoloaded")&&(e=t.offset().top-50,a.scrollTop()+a.height()>e)&&(t.data("bp-autoloaded",1),t.find("a").text(BP_Nouveau.activity.strings.loadingMore),t.find("a").trigger("click"))},destroyCommentMediaUploader:function(e){_.isNull(this.dropzone_obj)||(this.dropzone_obj.destroy(),q("#ac-reply-post-media-uploader-"+e).html(""),q("#ac-reply-post-media-uploader-1-"+e).html("")),this.dropzone_media=[],q("#ac-reply-post-media-uploader-"+e).removeClass("open").addClass("closed"),q("#ac-reply-media-button-"+e).removeClass("active")},destroyCommentDocumentUploader:function(e){_.isNull(this.dropzone_document_obj)||(this.dropzone_document_obj.destroy(),q("#ac-reply-post-document-uploader-"+e).html("")),this.dropzone_document=[],q("#ac-reply-post-document-uploader-"+e).removeClass("open").addClass("closed"),q("#ac-reply-document-button-"+e).removeClass("active")},destroyCommentVideoUploader:function(e){_.isNull(this.dropzone_video_obj)||(this.dropzone_video_obj.destroy(),q("#ac-reply-post-video-uploader-"+e).html("")),this.dropzone_video=[],q("#ac-reply-post-video-uploader-"+e).removeClass("open").addClass("closed"),q("#ac-reply-video-button-"+e).removeClass("active")},resetGifPicker:function(e){q("#ac-reply-gif-button-"+e).closest(".post-gif").find(".gif-media-search-dropdown").removeClass("open").empty(),q("#ac-reply-gif-button-"+e).removeClass("active"),q(".gif-media-search-dropdown-standalone").removeClass("open").empty(),_.isUndefined(this.models[e])||(this.models[e].set("gif_data",{}),q("#ac-reply-post-gif-"+e).find(".activity-attached-gif-container").removeAttr("style"))},openCommentsMediaUploader:function(e){var t,c=this,o=q(e.currentTarget),a=o.data("ac-id"),a=o.closest(".bp-ac-form-container").find("#ac-reply-post-media-uploader-"+a),i=0'+t+""),this.removeFile(e),a.removeClass("media-uploading"))}),c.dropzone_obj.on("removedfile",function(e){if(c.dropzone_media.length)for(var t in c.dropzone_media)if(e.upload.uuid==c.dropzone_media[t].uuid){void 0===c.dropzone_media[t].saved||c.dropzone_media[t].saved||bp.Nouveau.Media.removeAttachment(c.dropzone_media[t].id),c.dropzone_media.splice(t,1);break}var a,i;_.isNull(c.dropzone_obj)||_.isNull(c.dropzone_obj.files)||0!==c.dropzone_obj.files.length?o.closest(".ac-form").addClass("has-content"):(a=o.parents(".ac-reply-toolbar"),(i=o.closest(".ac-form")).removeClass("has-media"),a.find(".ac-reply-document-button")&&a.find(".ac-reply-document-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-video-button")&&a.find(".ac-reply-video-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-gif-button")&&a.find(".ac-reply-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-media-button")&&a.find(".ac-reply-media-button").parents(".post-elements-buttons-item").removeClass("no-click").find(".toolbar-button").removeClass("active"),q(c.dropzone_obj.element).removeClass("files-uploaded dz-progress-view").find(".dz-global-progress").remove(),c.validateCommentContent(i.find(".ac-textarea").children(".ac-input")))}),c.dropzone_obj.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 '+t+""),this.removeFile(e),a.removeClass("media-uploading"))}),c.dropzone_document_obj.on("removedfile",function(e){if(c.dropzone_document.length)for(var t in c.dropzone_document)if(e.upload.uuid==c.dropzone_document[t].uuid){void 0===c.dropzone_document[t].saved||c.dropzone_document[t].saved||bp.Nouveau.Media.removeAttachment(c.dropzone_document[t].id),c.dropzone_document.splice(t,1);break}var a,i;_.isNull(c.dropzone_document_obj)||_.isNull(c.dropzone_document_obj.files)||0!==c.dropzone_document_obj.files.length?o.closest(".ac-form").addClass("has-content"):(a=o.parents(".ac-reply-toolbar"),(i=o.closest(".ac-form")).removeClass("has-media"),a.find(".ac-reply-media-button")&&a.find(".ac-reply-media-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-video-button")&&a.find(".ac-reply-video-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-gif-button")&&a.find(".ac-reply-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-document-button")&&a.find(".ac-reply-document-button").parents(".post-elements-buttons-item").removeClass("no-click").find(".toolbar-button").removeClass("active"),q(c.dropzone_document_obj.element).removeClass("files-uploaded dz-progress-view").find(".dz-global-progress").remove(),c.validateCommentContent(i.find(".ac-textarea").children(".ac-input")))}),c.dropzone_document_obj.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 '),q(e.previewElement).closest(".dz-preview").addClass("dz-has-thumbnail")):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),c.dropzone_video_obj.on("uploadprogress",function(){o.closest(".ac-form").addClass("media-uploading"),bp.Nouveau.dropZoneGlobalProgress&&bp.Nouveau.dropZoneGlobalProgress(this)}),c.dropzone_video_obj.on("success",function(e,t){if(100===e.upload.progress&&(q(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,q(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),q(e.previewElement).closest(".dz-preview").addClass("dz-complete")),t.data.id)return e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=q(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.album_id=void 0!==BP_Nouveau.video&&void 0!==BP_Nouveau.video.album_id&&BP_Nouveau.video.album_id,t.data.group_id=void 0!==BP_Nouveau.video&&void 0!==BP_Nouveau.video.group_id&&BP_Nouveau.video.group_id,t.data.saved=!1,t.data.js_preview=q(e.previewElement).find(".dz-video-thumbnail img").attr("src"),c.dropzone_video.push(t.data),e.previewElement.classList.add("dz-success");var a,i,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],i=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;i '+t+""),this.removeFile(e),a.removeClass("media-uploading"))}),c.dropzone_video_obj.on("removedfile",function(e){if(c.dropzone_video.length)for(var t in c.dropzone_video)if(e.upload.uuid==c.dropzone_video[t].uuid){void 0===c.dropzone_video[t].saved||c.dropzone_video[t].saved||bp.Nouveau.Media.removeAttachment(c.dropzone_video[t].id),c.dropzone_video.splice(t,1);break}var a,i;_.isNull(c.dropzone_video_obj)||_.isNull(c.dropzone_video_obj.files)||0!==c.dropzone_video_obj.files.length?o.closest(".ac-form").addClass("has-content"):(a=o.parents(".ac-reply-toolbar"),(i=o.closest(".ac-form")).removeClass("has-media"),a.find(".ac-reply-media-button")&&a.find(".ac-reply-media-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-document-button")&&a.find(".ac-reply-document-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-gif-button")&&a.find(".ac-reply-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-video-button")&&a.find(".ac-reply-video-button").parents(".post-elements-buttons-item").removeClass("no-click").find(".toolbar-button").removeClass("active"),q(c.dropzone_video_obj.element).removeClass("files-uploaded dz-progress-view").find(".dz-global-progress").remove(),c.validateCommentContent(i.find(".ac-textarea").children(".ac-input")))}),c.dropzone_video_obj.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 /gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," ");""!==e.text().trim()||0<=t.indexOf("emojioneemoji")||e.closest("form").hasClass("acomment-edit")?e.closest("form").addClass("has-content"):e.closest("form").removeClass("has-content")},ReactionStatePopupTab:function(e){e.preventDefault(),q(this).closest(".activity-state-popup").find(".activity-state-popup_tab_panel li a").removeClass("active"),q(this).addClass("active"),q(this).closest(".activity-state-popup").find(".activity-state-popup_tab_content .activity-state-popup_tab_item").removeClass("active"),q(this).closest(".activity-state-popup").find("."+q(this).data("tab")).addClass("active")},closeActivityState:function(){q(".activity-state-popup").hide().removeClass("active")},listenCommentInput:function(e){var t,a;0 /gi,"\n").replace(/<\/div>/gi,""));t=t.replace(/ /g," "),""!==jQuery(e.currentTarget).text().trim()||0<=t.indexOf("emojioneemoji")?jQuery(e.currentTarget).closest("form").addClass("has-content"):jQuery(e.currentTarget).closest("form").removeClass("has-content")}),q(e).closest("form").addClass("events-initiated"),this.InitiatedCommentForms.push(t)))},activityRootComment:function(e){var e=q(e.currentTarget).closest("#activity-modal"),t=e.find(".activity-item").data("bp-activity-id"),a=e.find("#ac-form-"+t);bp.Nouveau.Activity.resetActivityCommentForm(a,"hardReset"),e.find(".acomment-display").removeClass("display-focus"),e.find(".comment-item").removeClass("comment-item-focus"),e.find(".bb-modal-activity-footer").addClass("active").append(a),a.addClass("root"),a.find("#ac-input-"+t).focus(),bp.Nouveau.Activity.clearFeedbackNotice(a)},clearFeedbackNotice:function(e){e.find(".bp-ac-form-container").find(".bp-feedback").length&&e.find(".bp-ac-form-container").find(".bp-feedback").remove()},launchActivityPopup:function(e,t){var a=q("#activity-"+e),i=q(".bb-activity-model-wrapper"),o=a[0].outerHTML,t='[data-parent_comment_id="'+t+'"]',d=a.data("activity-popup-title");bp.Nouveau.Activity.activityHasUpdates=!1,bp.Nouveau.Activity.currentActivityId=null,bp.Nouveau.Activity.activityPinHasUpdates=!1,i.closest("body").addClass("acomments-modal-open"),i.show(),i.find("ul.activity-list").html(o),i.find(".bb-modal-activity-header h2").text(d);i.find(".bb-activity-video-elem").each(function(e,t){var o=q(t);o.find("video").each(function(e,t){var t=q(t),a=t.attr("id")+Math.floor(1e4*Math.random()),i=(t.attr("id",a),o.find(".video-action-wrap"));0 '),{action:"activity_loadmore_comments",activity_id:o,parent_comment_id:n,offset:q(e.currentTarget).parents(".activity-comments").find('ul[data-parent_comment_id ="'+n+'"] > li.comment-item:not(.bb-recent-comment)').length,activity_type_is_blog:1"+e.data.message+""+e.statusText+"").removeClass("acomments-view-more--hide"),d.removeClass("active"),s.removeClass("active")})},autoloadMoreComments:function(){var e,t,a,i,o;0 ul > li.acomments-view-more:not(.loading), .bb-modal-activity-body .activity-comments .activity-actions > ul > li.acomments-view-more:not(.loading)"),t=q(".bb-activity-model-wrapper .bb-modal-activity-body"),o=q(".bb-activity-model-wrapper .bb-modal-activity-body").find(".activity-comments:not(.active)"),0a&&q(e).trigger("click").addClass("loading"),setTimeout(function(){jQuery(window).scroll()},200))},activitySyncOnModalClose:function(e,t){e.preventDefault();var e=(q(e.currentTarget).is(document)?q(".bb-activity-model-wrapper"):q(e.currentTarget).parents(".bb-activity-model-wrapper")).find("ul.activity-list > li").data("bp-activity-id"),t=void 0!==t?t:e,a=q("#activity-stream li.activity-item[data-bp-activity-id="+t+"]");void 0!==bp.Nouveau.Activity.activityPinHasUpdates&&bp.Nouveau.Activity.activityPinHasUpdates?(0 .bb-modal-activity-body .activity-item").data("bp-activity-id");0 /gi,"\n").replace(/<\/div>/gi,""));t=t.replace(/ /g," "),""!==e.text()||0<=t.indexOf("emojioneemoji")?e.closest("form").addClass("has-content"):e.closest("form").removeClass("has-content")},picker_show:function(){q(this.button[0]).closest(".post-emoji").addClass("active"),q(".emojionearea-theatre").removeClass("hide").addClass("show")},picker_hide:function(){q(this.button[0]).closest(".post-emoji").removeClass("active"),q(".emojionearea-theatre").removeClass("show").addClass("hide")}}})},openActivityFilter:function(e){e.preventDefault(),q(".bb-subnav-filters-container:not(.bb-subnav-filters-search)").removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false");e=q(e.currentTarget).parent(".bb-subnav-filters-container");e.addClass("active").find(".subnav-filters-opener").attr("aria-expanded","true"),e.find('input[type="search"]').length&&e.find('input[type="search"]').focus()},closeActivityFilter:function(e){q(e.target).closest(".bb-subnav-filters-container").length||q.each(q(".bb-subnav-filters-container"),function(){(!q(this).hasClass("bb-subnav-filters-search")||""===q(this).find('input[name="activity_search"]').val())&&q(this).removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false")})},filterActivity:function(e){e.preventDefault();var e=q(e.currentTarget),t=e.closest(".bb-subnav-filters-container"),a=(e.parent().addClass("selected").siblings().removeClass("selected"),t.removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false"),e.parent().data("filter-label")),t=(t.find(".subnav-filters-opener .selected").text(a||e.text()),bp.Nouveau.Activity.current_page=1,bp.Nouveau.objectNavParent),a="activity",i=q("#buddypress").find('[data-bp-filter="'+a+'"]').first().val(),o="",d="",s="",n="",c=!1,r=!1,t=(q(t+" [data-bp-object].selected").length&&(o=q(t+" [data-bp-object].selected").data("bp-scope"),e.closest("#bb-subnav-filter-show").length)&&(c=!0,q("body").hasClass("my-activity"))&&(r=!(c=!1)),q('#buddypress [data-bp-search="'+a+'"] input[type=search]').length&&(d=q('#buddypress [data-bp-search="'+a+'"] input[type=search]').val()),q(t+" [data-bp-order]").length&&(s=q(t+' [data-bp-order="'+a+'"].selected').data("bp-orderby")),bp.Nouveau.getStorage("bp-"+a)),a=(void 0!==t.extras&&(n=t.extras),bp.Nouveau.Activity.heartbeat_data.last_recorded=0,{object:a,scope:o,filter:i,search_terms:d,extras:n,order_by:s,save_scope:c,event_element:e});r&&(a.user_timeline=!0),t.topic_id&&(a.topic_id=t.topic_id),bp.Nouveau.objectRequest(a)}},bp.Nouveau.Activity.start())})((bp,jQuery)); \ No newline at end of file +window.bp=window.bp||{},(q=>{"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},bp.Models=bp.Models||{},bp.Models.ACReply=Backbone.Model.extend({defaults:{gif_data:{}}}),bp.Nouveau.Activity={start:function(){this.setupGlobals(),this.addListeners()},invokeMediaFn:function(e){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media[e]&&bp.Nouveau.Media[e]()},setupGlobals:function(){this.just_posted=[],this.current_page=1,this.mentions_count=Number(q(bp.Nouveau.objectNavParent+' [data-bp-scope="mentions"]').find("a span").html())||0,this.heartbeat_data={newest:"",highlights:{},last_recorded:0,first_recorded:0,document_title:q(document).prop("title")},void 0!==window.Dropzone&&void 0!==BP_Nouveau.media&&(window.Dropzone.autoDiscover=!1,this.dropzone_options={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,dictDefaultMessage:BP_Nouveau.media.dropzone_media_message,acceptedFiles:"image/*",autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.media.maxFiles?BP_Nouveau.media.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2,dictMaxFilesExceeded:BP_Nouveau.media.media_dict_file_exceeded,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation,maxThumbnailFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2},void 0!==BP_Nouveau.media.dropzone_options)&&Object.assign(this.dropzone_options,BP_Nouveau.media.dropzone_options),this.dropzone_obj=null,this.dropzone_media=[],this.dropzone_document_obj=null,this.dropzone_document=[],this.dropzone_video_obj=null,this.dropzone_video=[],this.models=[],this.InitiatedCommentForms=[],this.activityHasUpdates=!1,this.currentActivityId=null,this.activityPinHasUpdates=!1},addListeners:function(){q("body").hasClass("activity-singular")||q("#buddypress").on("bp_heartbeat_send",this.heartbeatSend.bind(this)),q("#buddypress").on("bp_heartbeat_tick",this.heartbeatTick.bind(this)),q(".actvity-head-bar").length&&(q(".actvity-head-bar").addClass("activity-head-bar").removeClass("actvity-head-bar"),q(".activity-head-bar > nav.activity-type-navs").length)&&q(".activity-head-bar .bb-subnav-filters-filtering").length&&q(".activity-head-bar > nav.activity-type-navs").remove(),q('#buddypress [data-bp-list="activity"]:not( #bb-schedule-posts_modal [data-bp-list="activity"] )').on("click","li.load-newest, li.load-more",this.injectActivities.bind(this)),void 0!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request?q("#buddypress").on("bp_ajax_request",'[data-bp-list="activity"]',this.scopeLoaded.bind(this)):q(window).on("load",function(){setTimeout(function(){bp.Nouveau.Activity.openEditActivityPopup()}.bind(this),0)}),q("#activity-stream").on("click",".acomments-view-more",this.showActivity),q("body").on("click",".bb-close-action-popup",this.closeActivity),q(document).on("activityModalOpened",function(e,t){var a=t.activityId;q(document).on("click",".bb-activity-model-wrapper.activity-theatre",function(e){!(0li.bb-edit-privacy a",bp.Nouveau,this.activityPrivacyRedirect.bind(this)),q('#buddypress [data-bp-list="activity"], #activity-modal').on("click",".activity-privacy>li:not(.bb-edit-privacy)",bp.Nouveau,this.activityPrivacyChange.bind(this)),q('#buddypress [data-bp-list="activity"], #bb-media-model-container .activity-list, #activity-modal').on("click","span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),q("#bb-media-model-container .activity-list").on("click",".activity-item",bp.Nouveau,this.activityActions.bind(this)),q(".bb-activity-model-wrapper").on("click",".ac-form-placeholder",bp.Nouveau,this.activityRootComment.bind(this)),q(document).keydown(this.commentFormAction),q(document).click(this.togglePopupDropdown),q('#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)),q('#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)),q('#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)),q('#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)),q(document).on("click",".activity-state-popup_overlay",bp.Nouveau,this.closeActivityState.bind(this)),q(document).on("click",".activity-state-popup .activity-state-popup_tab_panel a",this.ReactionStatePopupTab),_.isUndefined(BP_Nouveau.activity.params.autoload)||q(window).scroll(this.loadMoreActivities),q(document).on("click",".bb-subnav-filters-container .subnav-filters-opener",this.openActivityFilter.bind(this)),q(document).on("click",this.closeActivityFilter.bind(this)),q(document).on("click",".bb-subnav-filters-container .subnav-filters-modal a:not(.layout-view)",this.filterActivity.bind(this)),q(".bb-activity-model-wrapper, .bb-media-model-wrapper").on("click",".acomments-view-more",this.viewMoreComments.bind(this)),q(document).on("click","#activity-stream .activity-comments .view-more-comments, #activity-stream .activity-state-comments > .comments-count",function(e){e.preventDefault(),q(this).parents("li.activity-item").find(".activity-comments > ul > li.acomments-view-more, .activity-comments > .activity-actions > ul > li.acomments-view-more").trigger("click")}),q("#activity-modal > .bb-modal-activity-body").on("scroll",this.autoloadMoreComments.bind(this)),q("#activity-modal > .bb-modal-activity-body").on("scroll",this.discardGifEmojiPicker.bind(this)),q(".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?q("#buddypress").on("bp_ajax_request",'[data-bp-list="activity"]',function(){setTimeout(function(){q(".ac-form.not-initialized").each(function(){var e=q(this),t=e.find(".ac-textarea");bp.Nouveau.Activity.toggleMultiMediaOptions(e,t)})},1e3)}):setTimeout(function(){q(".ac-form.not-initialized").each(function(){var e=q(this),t=e.find(".ac-textarea");bp.Nouveau.Activity.toggleMultiMediaOptions(e,t)})},1e3),bp.Nouveau.wrapNavigation(".activity-topic-selector ul",120,!0)},heartbeatSend:function(e,t){q(bp.Nouveau.objectNavParent+" [data-bp-orderby=date_updated].selected").length?void 0!==(a=q("#buddypress [data-bp-list] [data-bp-activity-id]:not(.bb-pinned)").first()).data("bb-updated-timestamp")?this.heartbeat_data.first_recorded=a.data("bb-updated-timestamp"):a.length&&void 0!==a.data("bp-activity").date_updated&&""!==a.data("bp-activity").date_updated?(o=a.data("bp-activity").date_updated,o=new Date(o.replace(" ","T")+"Z").getTime()/1e3,this.heartbeat_data.first_recorded=o):this.heartbeat_data.first_recorded=a.data("bp-timestamp")||0:this.heartbeat_data.first_recorded=q("#buddypress [data-bp-list] [data-bp-activity-id]:not(.bb-pinned)").first().data("bp-timestamp")||0;var a,i,o=q("#buddypress [data-bp-list] [data-bp-activity-id]").first().data("bp-timestamp")||0;o>this.heartbeat_data.first_recorded&&(this.heartbeat_data.first_recorded=o),(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,q("#buddypress .activity-head-bar .activity-search input[type=search]").length&&(t.bp_activity_last_recorded_search_terms=q("#buddypress .activity-head-bar .activity-search input[type=search]").val()),q.extend(t,{bp_heartbeat:(a={scope:"all"},q("body.my-activity:not(.activity-singular)").length?a=bp.Nouveau.getStorage("bp-user-activity")||{scope:"just-me"}:(a=bp.Nouveau.getStorage("bp-activity")||{scope:"all"},q("body.activity.buddypress.groups.single-item").length&&(a.scope="all")),q(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").length&&(i=q(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").data("bp-scope"),void 0!==a.scope&&a.scope===i||(a.scope=i,"undefined"!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request&&(q("body.my-activity:not(.activity-singular)").length?bp.Nouveau.setStorage("bp-user-activity","scope",i):bp.Nouveau.setStorage("bp-activity","scope",i)))),q(bp.Nouveau.objectNavParent+" [data-bp-order].selected").length&&(i=q(bp.Nouveau.objectNavParent+" [data-bp-order].selected").data("bp-orderby"),a.order_by=i),(i=bp.Nouveau.getStorage("bp-activity","topic_id"))&&(t.bp_heartbeat=t.bp_heartbeat||{},t.bp_heartbeat.topic_id=i),a)})},heartbeatTick:function(e,t){var a,i,o=bp.Nouveau.objects,d=bp.Nouveau.getStorage("bp-activity","scope"),s=this,n=bp.Nouveau.getStorage("bp-activity","topic_id");void 0!==t&&t.bp_activity_newest_activities&&(this.heartbeat_data.newest=q.trim(t.bp_activity_newest_activities.activities)+this.heartbeat_data.newest,this.heartbeat_data.last_recorded=Number(t.bp_activity_newest_activities.last_recorded),t=q(this.heartbeat_data.newest).filter(".activity-item"),n&&(a=(t=t.filter(function(){var e=this.dataset.bpActivity?JSON.parse(this.dataset.bpActivity):null,e=e&&void 0!==e.topic_id?e.topic_id:null;return e&&parseInt(e)===parseInt(n)})).length),a=Number(t.length),o.push("mentions"),"all"===d?(q.each(t,function(e,a){a=q(a),q.each(o,function(e,t){-1!==q.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===q.inArray(a.data("bp-activity-id"),s.heartbeat_data.highlights[t])&&s.heartbeat_data.highlights[t].push(a.data("bp-activity-id")))})}),i=new RegExp("bp-my-("+o.join("|")+")","g"),this.heartbeat_data.newest=this.heartbeat_data.newest.replace(i,""),q(bp.Nouveau.objectNavParent+' [data-bp-scope="all"]').find("a span").html(a)):(this.heartbeat_data.highlights[d]=[],q.each(t,function(e,t){s.heartbeat_data.highlights[d].push(q(t).data("bp-activity-id"))})),q.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),q(bp.Nouveau.objectNavParent+' [data-bp-scope="'+t+'"]').find("a span").html(Number(s.heartbeat_data.highlights[t].length)+a))}),o.pop(),q(document).prop("title","("+a+") "+this.heartbeat_data.document_title),q('#buddypress [data-bp-list="activity"]').first().hasClass("load-newest")?(i=q('#buddypress [data-bp-list="activity"] .load-newest a').html(),q('#buddypress [data-bp-list="activity"] .load-newest a').html(i.replace(/([0-9]+)/,a))):q('#buddypress [data-bp-list="activity"] ul.activity-list').prepend(''+BP_Nouveau.newest+" ("+a+") "),q('#buddypress [data-bp-list="activity"] li.load-newest').trigger("click"),q('#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=q("body.my-activity:not(.activity-singular)").length?bp.Nouveau.getStorage("bp-user-activity"):bp.Nouveau.getStorage("bp-activity"),s=d.scope||null,d=d.filter||null;q(e.currentTarget).hasClass("load-newest")?(e.preventDefault(),q(e.currentTarget).remove(),i=q.parseHTML(this.heartbeat_data.newest),q.each(i,function(e,t){"LI"===t.nodeName&&q(t).hasClass("just-posted")&&q("#"+q(t).prop("id")).length&&q("#"+q(t).prop("id")).remove()}),(0<(i=q(e.delegateTarget).find(".activity-list .activity-item").first()).length&&i.hasClass("bb-pinned")?q(i).after(this.heartbeat_data.newest):q(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&&q(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),q(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(){q(e.delegateTarget).find("[data-bp-activity-id]").removeClass("newest_"+s+"_activity")},3e3),q(document).prop("title",this.heartbeat_data.document_title),jQuery(window).scroll()):q(e.currentTarget).hasClass("load-more")&&(t=+Number(this.current_page)+1,a=this,i="",e.preventDefault(),(o=q(e.currentTarget)).find("a").first().addClass("loading"),this.just_posted=[],q(e.delegateTarget).children(".just-posted").each(function(){a.just_posted.push(q(this).data("bp-activity-id"))}),q("#buddypress .dir-search input[type=search]").length?i=q("#buddypress .dir-search input[type=search]").val():q("#buddypress .activity-search.bp-search input[type=search]").length&&(i=q("#buddypress .activity-search.bp-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())})),q(".activity-item.bb-closed-comments").find(".edit-activity, .acomment-edit").parents(".generic-button").hide()},hideComments:function(e){var a,i,o,e=q(e.target).find(".activity-comments");e.length&&e.each(function(e,t){o=q(t).children("ul").not(".conflict-activity-ul-li-comment"),!(i=q(o).find("li").not(q(".document-action-class, .media-action-class, .video-action-class"))).length||q("body").hasClass("activity-singular")&&""!==window.location.hash&&q(window.location.hash).length&&0!==q(window.location.hash).closest(".activity-comments").length||(a=q(t).closest(".activity-item"),q("#acomment-comment-"+a.data("bp-activity-id")+" span.comment-count").html(),i.each(function(e,t){if(e"),window.location.hash&&"#"+q(t).attr("id")===window.location.hash)return q(t).parents("li.comment-item").show(),!1;q(t).addClass("bp-hidden").hide()}}),q(o).children(".bp-hidden").length===q(o).children("li").length-1&&q(o).find("li.show-all").length&&q(o).children("li:not(.show-all)").removeClass("bp-hidden").toggle())})},showActivity:function(e){e.preventDefault();var t=q(e.currentTarget).parent(),a=t.data("parent_comment_id"),t=q(t).data("activity_id");q(document).trigger("activityModalOpened",{activityId:t}),q(e.currentTarget).parents(".activity-comments").find(".ac-form").each(function(){var e=q(this),t=q(this).closest(".activity-comments"),a=q(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 e=q(e.target).closest(".bb-activity-model-wrapper"),t=e.find(".bb-modal-activity-footer"),a=e.find(".activity-item").data("bp-activity-id"),i=e.find("#ac-form-"+a);bp.Nouveau.Activity.reinitializeActivityCommentForm(i),_.isUndefined(BP_Nouveau.media)||_.isUndefined(BP_Nouveau.media.emoji)||bp.Nouveau.Activity.initializeEmojioneArea(!1,"",a),e.find("#activity-modal").removeClass("bb-closed-comments"),e.closest("body").removeClass("acomments-modal-open"),e.hide(),e.find("ul.activity-list").empty(),t.removeClass("active"),t.find("form.ac-form").remove()},scopeLoaded:function(e,a){this.current_page=1,"mentions"===a.scope&&void 0!==a.response.new_mentions?(q.each(a.response.new_mentions,function(e,t){q("#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&&q.each(this.heartbeat_data.highlights[a.scope],function(e,t){q("#buddypress #activity-stream").find('[data-bp-activity-id="'+t+'"]').length&&q("#buddypress #activity-stream").find('[data-bp-activity-id="'+t+'"]').addClass("newest_"+a.scope+"_activity")}),this.heartbeat_data.newest="",q.each(q(bp.Nouveau.objectNavParent+" [data-bp-scope]").find("a span"),function(e,t){0===parseInt(q(t).html(),10)&&q(t).html("")}),void 0!==this.heartbeat_data.highlights[a.scope]&&(this.heartbeat_data.highlights[a.scope]=[]),q(document).prop("title",this.heartbeat_data.document_title),setTimeout(function(){q("#buddypress #activity-stream .activity-item").removeClass("newest_"+a.scope+"_activity")},3e3),setTimeout(function(){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media.autoPlayGifVideos&&bp.Nouveau.Media.autoPlayGifVideos()},200),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 .acomment-display > .acomment_inner").find(".activity-state-reactions").parent().addClass("bb-has-reaction_update"):"activity"===d&&q(".activity[data-bp-activity-id="+f+"] > .activity-content").find(".activity-state-reactions").parent().addClass("bb-has-reaction_update"),"fav"===i?void 0===e.data.directory_tab||""===e.data.directory_tab||q(s.objectNavParent+' [data-bp-scope="favorites"]').length||q(s.objectNavParent+' [data-bp-scope="all"]').after(e.data.directory_tab):"unfav"===i&&((t=q('[data-bp-user-scope="favorites"]').hasClass("selected")||q(s.objectNavParent+' [data-bp-scope="favorites"]').hasClass("selected"))&&m.remove(),void 0!==e.data.no_favorite)&&(q(s.objectNavParent+' [data-bp-scope="all"]').length&&q(s.objectNavParent+' [data-bp-scope="all"]').hasClass("selected")?q(s.objectNavParent+' [data-bp-scope="favorites"]').remove():t&&L.append(e.data.no_favorite)))}).fail(function(){l.removeClass("loading")})}if(l.hasClass("delete-activity")||l.hasClass("acomment-delete")||l.hasClass("spam-activity")||l.hasClass("spam-activity-comment")){var h,g,C,N,w,P=l.closest("[data-bp-activity-comment-id]"),z=P.data("bp-activity-comment-id"),j=0;if((w=l.closest(".activity-comments")).addClass("active"),e.preventDefault(),void 0!==BP_Nouveau.confirm&&!1===window.confirm(BP_Nouveau.confirm))return!1;l.addClass("loading");var B={action:"delete_activity",id:p,_wpnonce:s.getLinkParams(l.prop("href"),"_wpnonce"),is_single:l.closest("[data-bp-single]").length};(l.hasClass("spam-activity")||l.hasClass("spam-activity-comment"))&&(B.action="bp_spam_activity"),h=m,z&&(delete B.is_single,B.id=z,B.is_comment=!0,h=P),s.ajax(B,"activity").done(function(e){if(l.removeClass("loading"),!1===e.success)h.append(e.data.feedback),h.find(".bp-feedback").hide().fadeIn(300);else{var t,a,i,o=h.closest(".has-child-comments"),d=(h.hasClass("has-child-comments")&&(t=h.closest("ul").closest("li")),o.find("> ul"));if(e.data.redirect)return window.location.href=e.data.redirect;e.data.parent_activity_id&&e.data.activity&&q("body:not(.activity-singular) #buddypress #activity-stream ul.activity-list li#activity-"+e.data.parent_activity_id).replaceWith(e.data.activity),z&&(j=1,i=P.find(".acomments-view-more").data("child-count"),m.append(P.find("form")),q.each(P.find("li.comment-item"),function(){j+=1}),j+=void 0!==i?parseFloat(i):0,g=v.find("span.comments-count"),C=g.text().length?g.text().match(/\d+/)[0]:0,C=Number(C-j),u.length?(i=1 ul").html().trim()&&t.removeClass("has-child-comments")}),z||m.data("bp-timestamp")!==s.Activity.heartbeat_data.last_recorded||(s.Activity.heartbeat_data.newest="",s.Activity.heartbeat_data.last_recorded=0),q(document).trigger("bp_activity_ajax_delete_request",q.extend(B,{response:e})),q(document).trigger("bp_activity_ajax_delete_request_video",q.extend(B,{response:e})),bp.Nouveau.Activity.activityHasUpdates=!0,bp.Nouveau.Activity.currentActivityId=p}w.removeClass("active")})}if(l.closest("span").hasClass("activity-read-more")){var x=l.closest("div"),H=l.closest("span");if(f=null,q(x).hasClass("activity-inner")?f=p:q(x).hasClass("acomment-content")&&(f=l.closest("li").data("bp-activity-comment-id")),!f)return e;e.preventDefault(),q(H).addClass("loading"),s.ajax({action:"get_single_activity_content",id:f},"activity").done(function(e){"object"!=typeof e&&0 ul li.comment-item").length+1&&(k=A.parent().closest("li.comment-item")).length?k:A:c.find('[data-bp-activity-comment-id="'+f+'"]'),y&&q(".bb-modal-activity-footer").removeClass("active"),k.append(r)),r.removeClass("not-initialized"),r.find(".post-elements-buttons-item.post-emoji").prevAll().not(":hidden").length+1),c=(r.find(".post-elements-buttons-item.post-emoji").attr("data-nth-child",A),r.find(".post-elements-buttons-item.post-gif").prevAll().not(":hidden").length+1),k=(r.find(".post-elements-buttons-item.post-gif").attr("data-nth-child",c),r.find(".ac-input[contenteditable]")),A=(bp.Nouveau.Activity.listenCommentInput(k),l.attr("aria-expanded","true"),l.closest(".activity-comments").find(".acomment-display").removeClass("display-focus"),l.closest(".activity-comments").find(".comment-item").removeClass("comment-item-focus"),l.closest(".acomment-display").addClass("display-focus"),l.closest(".comment-item").addClass("comment-item-focus"),_.isNull(t)||(T=t.nickname),_.isNull(t)||(M=t.user_id),'@'+T+" ");_.isUndefined(BP_Nouveau.activity.params.user_id)||(O=BP_Nouveau.activity.params.user_id);var T,c={offset:-(q(window).height()/2-75),easing:"swing"},S=k.get(0);jQuery("body").hasClass("bb-is-mobile")?setTimeout(function(){var e=300 /gi,"\n").replace(/<\/div>/gi,""),M={action:"new_activity_comment",_wpnonce_new_activity_comment:q("#_wpnonce_new_activity_comment").val(),comment_id:f,form_id:p,content:O},Q=(q("#_bp_as_nonce_"+p).val()&&(M["_bp_as_nonce_"+p]=q("#_bp_as_nonce_"+p).val()),this.dropzone_media.length&&(M.media=this.dropzone_media),this.dropzone_document.length&&(M.document=this.dropzone_document),this.dropzone_video.length&&(M.video=this.dropzone_video,_.isEmpty(M.content))&&(M.content=""),_.isUndefined(this.models[p])||(I=this.models[p],M.gif_data=this.models[p].get("gif_data")),M.content=M.content.replace(/ /g," "),r.hasClass("acomment-edit")&&(M.edit_comment=!0),0 '),r.closest("#activity-modal").find(".bb-modal-activity-body .activity-comments, .bb-modal-activity-body .activity-comments .activity-actions").children("ul").append(q(d))):(0===t.children("ul").length&&(t.hasClass("activity-comments")?t.prepend(" "):t.append("
")),t.children("ul").append(q(d).hide().fadeIn(200))),q(r).find(".ac-input").first().html(""),t.parent().addClass("has-comments"),t.parent().addClass("comments-loaded"),v.addClass("has-comments")),r.removeClass("acomment-edit"),r.find(".ac-reply-content"));if(0
'+BP_Nouveau.activity.strings.commentPostError+""):(e=e.responseJSON&&e.responseJSON.message?e.responseJSON.message:e.statusText,r.find(".ac-reply-content").after(' '+e+""))})}if(l.hasClass("edit")&&l.hasClass("edit-activity")&&(e.preventDefault(),A=m.data("bp-activity"),t=""!==m.data("link-url")?m.data("link-url"):null,void 0!==A)&&(bp.Nouveau.Activity.postForm.displayEditActivityForm(A,t),l.closest("li").hasClass("groups")?q("#bp-nouveau-activity-form").addClass("group-activity"):q("#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)&&(q(document).find(".bb-close-media-theatre").trigger("click"),q(document).find(".bb-close-document-theatre").trigger("click")),y&&(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(),!p)return e;l.closest(".activity-item").addClass("loading-pin");var E="pin";l.hasClass("unpin-activity")&&(E="unpin"),s.ajax({action:"activity_update_pinned_post",id:p,pin_action:E},"activity").done(function(e){var t,a,i,o,d,s,n,c,r;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"),a=l.closest(".buddypress-wrap:not(.bb-internal-model)").find("#activity-stream"),i=0"+e.data.feedback+"",e.success?"success":"error",null,!0]),y)&&(void 0!==bp.Nouveau.Activity.activityHasUpdates&&(bp.Nouveau.Activity.activityHasUpdates=!0),void 0!==bp.Nouveau.Activity.activityPinHasUpdates)&&(bp.Nouveau.Activity.activityPinHasUpdates=!0)}).fail(function(){l.closest(".activity-item").removeClass("loading-pin"),q(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(),!p)return e;l.closest(".activity-item").addClass("loading-mute");var D="mute";l.hasClass("bb-icon-bell")&&(D="unmute"),s.ajax({action:"toggle_activity_notification_status",id:p,notification_toggle_action:D},"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"===D?(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"===D&&(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),q(document).trigger("bb_trigger_toast_message",["",""+e.data.feedback+"","success",null,!0])),y&&(bp.Nouveau.Activity.activityPinHasUpdates=!0),bp.Nouveau.Activity.activityHasUpdates=!0,bp.Nouveau.Activity.currentActivityId=p}).fail(function(){l.closest(".activity-item").removeClass("loading-pin"),q(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(),!p)return e;l.closest(".activity-item").addClass("loading-pin");var V="close_comments";l.hasClass("unclose-activity-comment")&&(V="unclose_comments"),s.ajax({action:"activity_update_close_comments",id:p,close_comments_action:V},"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=q("#activity-stream > .activity-list").find("[data-bp-activity-id="+p+"]"),l.closest(".activity-item").find(".bb-activity-closed-comments-notice").remove(),"close_comments"===V?(l.closest("li.activity-item").addClass("bb-closed-comments"),0'+e.data.feedback+""),0 '+e.data.feedback+""))):"unclose_comments"===V&&(l.closest("li.activity-item.bb-closed-comments").find(".edit-activity, .acomment-edit").parents(".generic-button").show(),l.closest("li.activity-item").removeClass("bb-closed-comments"),0 "+e.data.feedback+"",e.success?"success":"error",null,!0]))}).fail(function(){l.closest(".activity-item").removeClass("loading-pin"),q(document).trigger("bb_trigger_toast_message",[""," "+BP_Nouveau.activity.strings.closeCommentsError+"","error",null,!0])})}},commentFormAction:function(e){var t,a;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),!0!==e.altKey&&!0!==e.metaKey&&"TEXTAREA"===t.tagName&&q(t).hasClass("ac-input")?void(27===(a=e.keyCode||e.which)&&!1===e.ctrlKey?"TEXTAREA"===t.tagName&&q(t).closest("form").slideUp(200):e.ctrlKey&&13===a&&q(t).val()&&q(t).closest("form").find("[type=submit]").first().trigger("click")):e},togglePopupDropdown:function(e){var t;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),!0===e.altKey||!0===e.metaKey||q(t).hasClass("privacy-wrap")||q(t).parent().hasClass("privacy-wrap")?e:void q("ul.activity-privacy").removeClass("bb-open")},loadMoreActivities:function(){var e,t=q(".load-more:visible").last(),a=q(window);t.closest(".activity-list").length&&t.get(0)&&!t.data("bp-autoloaded")&&(e=t.offset().top-50,a.scrollTop()+a.height()>e)&&(t.data("bp-autoloaded",1),t.find("a").text(BP_Nouveau.activity.strings.loadingMore),t.find("a").trigger("click"))},destroyCommentMediaUploader:function(e){_.isNull(this.dropzone_obj)||(this.dropzone_obj.destroy(),q("#ac-reply-post-media-uploader-"+e).html(""),q("#ac-reply-post-media-uploader-1-"+e).html("")),this.dropzone_media=[],q("#ac-reply-post-media-uploader-"+e).removeClass("open").addClass("closed"),q("#ac-reply-media-button-"+e).removeClass("active")},destroyCommentDocumentUploader:function(e){_.isNull(this.dropzone_document_obj)||(this.dropzone_document_obj.destroy(),q("#ac-reply-post-document-uploader-"+e).html("")),this.dropzone_document=[],q("#ac-reply-post-document-uploader-"+e).removeClass("open").addClass("closed"),q("#ac-reply-document-button-"+e).removeClass("active")},destroyCommentVideoUploader:function(e){_.isNull(this.dropzone_video_obj)||(this.dropzone_video_obj.destroy(),q("#ac-reply-post-video-uploader-"+e).html("")),this.dropzone_video=[],q("#ac-reply-post-video-uploader-"+e).removeClass("open").addClass("closed"),q("#ac-reply-video-button-"+e).removeClass("active")},resetGifPicker:function(e){q("#ac-reply-gif-button-"+e).closest(".post-gif").find(".gif-media-search-dropdown").removeClass("open").empty(),q("#ac-reply-gif-button-"+e).removeClass("active"),q(".gif-media-search-dropdown-standalone").removeClass("open").empty(),_.isUndefined(this.models[e])||(this.models[e].set("gif_data",{}),q("#ac-reply-post-gif-"+e).find(".activity-attached-gif-container").removeAttr("style"))},openCommentsMediaUploader:function(e){var t,c=this,o=q(e.currentTarget),a=o.data("ac-id"),a=o.closest(".bp-ac-form-container").find("#ac-reply-post-media-uploader-"+a),i=0'+t+""),this.removeFile(e),a.removeClass("media-uploading"))}),c.dropzone_obj.on("removedfile",function(e){if(c.dropzone_media.length)for(var t in c.dropzone_media)if(e.upload.uuid==c.dropzone_media[t].uuid){void 0===c.dropzone_media[t].saved||c.dropzone_media[t].saved||bp.Nouveau.Media.removeAttachment(c.dropzone_media[t].id),c.dropzone_media.splice(t,1);break}var a,i;_.isNull(c.dropzone_obj)||_.isNull(c.dropzone_obj.files)||0!==c.dropzone_obj.files.length?o.closest(".ac-form").addClass("has-content"):(a=o.parents(".ac-reply-toolbar"),(i=o.closest(".ac-form")).removeClass("has-media"),a.find(".ac-reply-document-button")&&a.find(".ac-reply-document-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-video-button")&&a.find(".ac-reply-video-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-gif-button")&&a.find(".ac-reply-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-media-button")&&a.find(".ac-reply-media-button").parents(".post-elements-buttons-item").removeClass("no-click").find(".toolbar-button").removeClass("active"),q(c.dropzone_obj.element).removeClass("files-uploaded dz-progress-view").find(".dz-global-progress").remove(),c.validateCommentContent(i.find(".ac-textarea").children(".ac-input")))}),c.dropzone_obj.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 '+t+""),this.removeFile(e),a.removeClass("media-uploading"))}),c.dropzone_document_obj.on("removedfile",function(e){if(c.dropzone_document.length)for(var t in c.dropzone_document)if(e.upload.uuid==c.dropzone_document[t].uuid){void 0===c.dropzone_document[t].saved||c.dropzone_document[t].saved||bp.Nouveau.Media.removeAttachment(c.dropzone_document[t].id),c.dropzone_document.splice(t,1);break}var a,i;_.isNull(c.dropzone_document_obj)||_.isNull(c.dropzone_document_obj.files)||0!==c.dropzone_document_obj.files.length?o.closest(".ac-form").addClass("has-content"):(a=o.parents(".ac-reply-toolbar"),(i=o.closest(".ac-form")).removeClass("has-media"),a.find(".ac-reply-media-button")&&a.find(".ac-reply-media-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-video-button")&&a.find(".ac-reply-video-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-gif-button")&&a.find(".ac-reply-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-document-button")&&a.find(".ac-reply-document-button").parents(".post-elements-buttons-item").removeClass("no-click").find(".toolbar-button").removeClass("active"),q(c.dropzone_document_obj.element).removeClass("files-uploaded dz-progress-view").find(".dz-global-progress").remove(),c.validateCommentContent(i.find(".ac-textarea").children(".ac-input")))}),c.dropzone_document_obj.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 '),q(e.previewElement).closest(".dz-preview").addClass("dz-has-thumbnail")):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),c.dropzone_video_obj.on("uploadprogress",function(){o.closest(".ac-form").addClass("media-uploading"),bp.Nouveau.dropZoneGlobalProgress&&bp.Nouveau.dropZoneGlobalProgress(this)}),c.dropzone_video_obj.on("success",function(e,t){if(100===e.upload.progress&&(q(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,q(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),q(e.previewElement).closest(".dz-preview").addClass("dz-complete")),t.data.id)return e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=q(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.album_id=void 0!==BP_Nouveau.video&&void 0!==BP_Nouveau.video.album_id&&BP_Nouveau.video.album_id,t.data.group_id=void 0!==BP_Nouveau.video&&void 0!==BP_Nouveau.video.group_id&&BP_Nouveau.video.group_id,t.data.saved=!1,t.data.js_preview=q(e.previewElement).find(".dz-video-thumbnail img").attr("src"),c.dropzone_video.push(t.data),e.previewElement.classList.add("dz-success");var a,i,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],i=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;i '+t+""),this.removeFile(e),a.removeClass("media-uploading"))}),c.dropzone_video_obj.on("removedfile",function(e){if(c.dropzone_video.length)for(var t in c.dropzone_video)if(e.upload.uuid==c.dropzone_video[t].uuid){void 0===c.dropzone_video[t].saved||c.dropzone_video[t].saved||bp.Nouveau.Media.removeAttachment(c.dropzone_video[t].id),c.dropzone_video.splice(t,1);break}var a,i;_.isNull(c.dropzone_video_obj)||_.isNull(c.dropzone_video_obj.files)||0!==c.dropzone_video_obj.files.length?o.closest(".ac-form").addClass("has-content"):(a=o.parents(".ac-reply-toolbar"),(i=o.closest(".ac-form")).removeClass("has-media"),a.find(".ac-reply-media-button")&&a.find(".ac-reply-media-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-document-button")&&a.find(".ac-reply-document-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-gif-button")&&a.find(".ac-reply-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),a.find(".ac-reply-video-button")&&a.find(".ac-reply-video-button").parents(".post-elements-buttons-item").removeClass("no-click").find(".toolbar-button").removeClass("active"),q(c.dropzone_video_obj.element).removeClass("files-uploaded dz-progress-view").find(".dz-global-progress").remove(),c.validateCommentContent(i.find(".ac-textarea").children(".ac-input")))}),c.dropzone_video_obj.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 /gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," ");""!==e.text().trim()||0<=t.indexOf("emojioneemoji")||e.closest("form").hasClass("acomment-edit")?e.closest("form").addClass("has-content"):e.closest("form").removeClass("has-content")},ReactionStatePopupTab:function(e){e.preventDefault(),q(this).closest(".activity-state-popup").find(".activity-state-popup_tab_panel li a").removeClass("active"),q(this).addClass("active"),q(this).closest(".activity-state-popup").find(".activity-state-popup_tab_content .activity-state-popup_tab_item").removeClass("active"),q(this).closest(".activity-state-popup").find("."+q(this).data("tab")).addClass("active")},closeActivityState:function(){q(".activity-state-popup").hide().removeClass("active")},listenCommentInput:function(e){var t,a;0 /gi,"\n").replace(/<\/div>/gi,""));t=t.replace(/ /g," "),""!==jQuery(e.currentTarget).text().trim()||0<=t.indexOf("emojioneemoji")?jQuery(e.currentTarget).closest("form").addClass("has-content"):jQuery(e.currentTarget).closest("form").removeClass("has-content")}),q(e).closest("form").addClass("events-initiated"),this.InitiatedCommentForms.push(t)))},activityRootComment:function(e){var e=q(e.currentTarget).closest("#activity-modal"),t=e.find(".activity-item").data("bp-activity-id"),a=e.find("#ac-form-"+t);bp.Nouveau.Activity.resetActivityCommentForm(a,"hardReset"),e.find(".acomment-display").removeClass("display-focus"),e.find(".comment-item").removeClass("comment-item-focus"),e.find(".bb-modal-activity-footer").addClass("active").append(a),a.addClass("root"),a.find("#ac-input-"+t).focus(),bp.Nouveau.Activity.clearFeedbackNotice(a)},clearFeedbackNotice:function(e){e.find(".bp-ac-form-container").find(".bp-feedback").length&&e.find(".bp-ac-form-container").find(".bp-feedback").remove()},launchActivityPopup:function(e,t){var a=q("#activity-"+e),i=q(".bb-activity-model-wrapper"),o=a[0].outerHTML,t='[data-parent_comment_id="'+t+'"]',d=a.data("activity-popup-title");bp.Nouveau.Activity.activityHasUpdates=!1,bp.Nouveau.Activity.currentActivityId=null,bp.Nouveau.Activity.activityPinHasUpdates=!1,i.closest("body").addClass("acomments-modal-open"),i.show(),i.find("ul.activity-list").html(o),i.find(".bb-modal-activity-header h2").text(d);i.find(".bb-activity-video-elem").each(function(e,t){var o=q(t);o.find("video").each(function(e,t){var t=q(t),a=t.attr("id")+Math.floor(1e4*Math.random()),i=(t.attr("id",a),o.find(".video-action-wrap"));0 '),{action:"activity_loadmore_comments",activity_id:o,parent_comment_id:n,offset:q(e.currentTarget).parents(".activity-comments").find('ul[data-parent_comment_id ="'+n+'"] > li.comment-item:not(.bb-recent-comment)').length,activity_type_is_blog:1"+e.data.message+"").removeClass("acomments-view-more--hide"),d.removeClass("active"),s.removeClass("active")):void 0!==e.data&&void 0!==e.data.comments&&(t=q(".bb-internal-model .activity-comments").find("[data-activity_id='"+o+"'][data-parent_comment_id='"+n+"']"),e=q(q.parseHTML(e.data.comments)),0"+e.statusText+"").removeClass("acomments-view-more--hide"),d.removeClass("active"),s.removeClass("active")})},autoloadMoreComments:function(){var e,t,a,i,o;0 ul > li.acomments-view-more:not(.loading), .bb-modal-activity-body .activity-comments .activity-actions > ul > li.acomments-view-more:not(.loading)"),t=q(".bb-activity-model-wrapper .bb-modal-activity-body"),o=q(".bb-activity-model-wrapper .bb-modal-activity-body").find(".activity-comments:not(.active)"),0a&&q(e).trigger("click").addClass("loading"),setTimeout(function(){jQuery(window).scroll()},200))},activitySyncOnModalClose:function(e,t){e.preventDefault();var e=(q(e.currentTarget).is(document)?q(".bb-activity-model-wrapper"):q(e.currentTarget).parents(".bb-activity-model-wrapper")).find("ul.activity-list > li").data("bp-activity-id"),t=void 0!==t?t:e,a=q("#activity-stream li.activity-item[data-bp-activity-id="+t+"]");void 0!==bp.Nouveau.Activity.activityPinHasUpdates&&bp.Nouveau.Activity.activityPinHasUpdates?(0 .bb-modal-activity-body .activity-item").data("bp-activity-id");0 /gi,"\n").replace(/<\/div>/gi,""));t=t.replace(/ /g," "),""!==e.text()||0<=t.indexOf("emojioneemoji")?e.closest("form").addClass("has-content"):e.closest("form").removeClass("has-content")},picker_show:function(){q(this.button[0]).closest(".post-emoji").addClass("active"),q(".emojionearea-theatre").removeClass("hide").addClass("show")},picker_hide:function(){q(this.button[0]).closest(".post-emoji").removeClass("active"),q(".emojionearea-theatre").removeClass("show").addClass("hide")}}})},openActivityFilter:function(e){e.preventDefault(),q(".bb-subnav-filters-container:not(.bb-subnav-filters-search)").removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false");e=q(e.currentTarget).parent(".bb-subnav-filters-container");e.addClass("active").find(".subnav-filters-opener").attr("aria-expanded","true"),e.find('input[type="search"]').length&&e.find('input[type="search"]').focus()},closeActivityFilter:function(e){q(e.target).closest(".bb-subnav-filters-container").length||q.each(q(".bb-subnav-filters-container"),function(){(!q(this).hasClass("bb-subnav-filters-search")||""===q(this).find('input[name="activity_search"]').val())&&q(this).removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false")})},filterActivity:function(e){e.preventDefault();var e=q(e.currentTarget),t=e.closest(".bb-subnav-filters-container"),a=(e.parent().addClass("selected").siblings().removeClass("selected"),t.removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false"),e.parent().data("filter-label")),t=(t.find(".subnav-filters-opener .selected").text(a||e.text()),bp.Nouveau.Activity.current_page=1,bp.Nouveau.objectNavParent),a="activity",i=q("#buddypress").find('[data-bp-filter="'+a+'"]').first().val(),o="",d="",s="",n="",c=!1,r=!1,t=(q(t+" [data-bp-object].selected").length&&(o=q(t+" [data-bp-object].selected").data("bp-scope"),e.closest("#bb-subnav-filter-show").length)&&(c=!0,q("body").hasClass("my-activity"))&&(r=!(c=!1)),q('#buddypress [data-bp-search="'+a+'"] input[type=search]').length&&(d=q('#buddypress [data-bp-search="'+a+'"] input[type=search]').val()),q(t+" [data-bp-order]").length&&(s=q(t+' [data-bp-order="'+a+'"].selected').data("bp-orderby")),bp.Nouveau.getStorage("bp-"+a)),a=(void 0!==t.extras&&(n=t.extras),bp.Nouveau.Activity.heartbeat_data.last_recorded=0,{object:a,scope:o,filter:i,search_terms:d,extras:n,order_by:s,save_scope:c,event_element:e});r&&(a.user_timeline=!0),t.topic_id&&(a.topic_id=t.topic_id),bp.Nouveau.objectRequest(a)}},bp.Nouveau.Activity.start())})((bp,jQuery)); \ No newline at end of file diff --git a/src/bp-templates/bp-nouveau/js/buddypress-media.js b/src/bp-templates/bp-nouveau/js/buddypress-media.js index cf2423c09fd..7d26a8388da 100644 --- a/src/bp-templates/bp-nouveau/js/buddypress-media.js +++ b/src/bp-templates/bp-nouveau/js/buddypress-media.js @@ -1414,14 +1414,20 @@ window.bp = window.bp || {}; $( 'body .bb-activity-media-elem.media-activity.' + id ).remove(); $( 'body .activity-comments li#acomment-' + activityId ).remove(); - // The "view more comments" modal holds its own copy of the - // activity, and its wrapper duplicates id="buddypress", so - // the ID selector above only ever reaches the page copy. - // When the whole activity is gone, close the modal through - // its real close button so the close handler runs. + // The selectors above also clear the "view more comments" + // modal's copy of the activity, which leaves the modal open + // as an empty shell. When the modal's list has been emptied, + // close it through its real close button so the close + // handler runs; hide the wrapper directly if a theme + // override renamed the button. var $activityModal = $( '#activity-modal:visible' ); - if ( $activityModal.length && $activityModal.find( 'li[data-bp-activity-id="' + activityId + '"]' ).length ) { - $activityModal.find( '.bb-modal-activity-header .bb-close-action-popup' ).trigger( 'click' ); + if ( $activityModal.length && 0 === $activityModal.find( '.bb-modal-activity-body .activity-list li' ).length ) { + var $modalCloseButton = $activityModal.find( '.bb-modal-activity-header .bb-close-action-popup' ); + if ( $modalCloseButton.length ) { + $modalCloseButton.trigger( 'click' ); + } else { + $activityModal.closest( '.bb-activity-model-wrapper' ).hide(); + } } } else { $( 'body #buddypress .activity-list li#activity-' + activityId ).replaceWith( response.data.activity_content ); diff --git a/src/bp-templates/bp-nouveau/js/buddypress-media.min.js b/src/bp-templates/bp-nouveau/js/buddypress-media.min.js index 622b7bb3a4d..dfb50bb9776 100644 --- a/src/bp-templates/bp-nouveau/js/buddypress-media.min.js +++ b/src/bp-templates/bp-nouveau/js/buddypress-media.min.js @@ -1 +1 @@ -window.bp=window.bp||{},(p=>{"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},bp.Nouveau.Media={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){var e=p("body"),e=(this.current_page=1,this.current_page_existing_media=1,this.current_page_albums=1,this.current_tab=!e.hasClass("single-topic")&&!e.hasClass("single-forum")&&"bp-dropzone-content",this.sort_by="",this.order_by="",this.currentTargetParent=BP_Nouveau.media.current_folder,this.moveToIdPopup=BP_Nouveau.media.move_to_id_popup,this.moveToTypePopup=BP_Nouveau.media.current_type,this.privacySelectorSelect="",this.privacySelectorSpan="",this.currentAlbum=BP_Nouveau.media.current_album,void 0!==window.Dropzone&&(window.Dropzone.autoDiscover=!1),document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:""),e=(this.documentOptions={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,acceptedFiles:BP_Nouveau.media.document_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.media.dropzone_document_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.document.maxFiles?BP_Nouveau.document.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.document.max_upload_size?BP_Nouveau.document.max_upload_size:2,dictInvalidFileType:BP_Nouveau.document.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation},document.getElementsByClassName("forum-post-video-template").length?document.getElementsByClassName("forum-post-video-template")[0].innerHTML:"");this.videoOptions={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.video.dictFileTooBig,acceptedFiles:BP_Nouveau.video.video_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.video.dropzone_video_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.video.maxFiles?BP_Nouveau.video.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.video.max_upload_size?BP_Nouveau.video.max_upload_size:2,dictInvalidFileType:BP_Nouveau.video.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.video.video_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.video.dictCancelUploadConfirmation},p("#bp-media-uploader").hasClass("bp-media-document-uploader")?(e=document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:"",this.options={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,acceptedFiles:BP_Nouveau.media.document_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.media.dropzone_document_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.document.maxFiles?BP_Nouveau.document.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.document.max_upload_size?BP_Nouveau.document.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation}):(e=document.getElementsByClassName("forum-post-media-template").length?document.getElementsByClassName("forum-post-media-template")[0].innerHTML:"",this.options={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,dictDefaultMessage:BP_Nouveau.media.dropzone_media_message,acceptedFiles:"image/*",autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.media.maxFiles?BP_Nouveau.media.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.media_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation,maxThumbnailFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2}),void 0!==BP_Nouveau.media.dropzone_options&&Object.assign(this.options,BP_Nouveau.media.dropzone_options),this.dropzone_obj=[],this.dropzone_media=[],this.album_id=void 0!==BP_Nouveau.media.album_id&&BP_Nouveau.media.album_id,this.current_folder=void 0!==BP_Nouveau.media.current_folder&&BP_Nouveau.media.current_folder,this.current_group_id=void 0!==BP_Nouveau.media.current_group_id&&BP_Nouveau.media.current_group_id,this.group_id=void 0!==BP_Nouveau.media.group_id&&BP_Nouveau.media.group_id,this.bbp_is_reply_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_reply_edit&&window.BP_Forums_Nouveau.media.bbp_is_reply_edit,this.bbp_is_topic_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_topic_edit&&window.BP_Forums_Nouveau.media.bbp_is_topic_edit,this.bbp_is_forum_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_forum_edit&&window.BP_Forums_Nouveau.media.bbp_is_forum_edit,this.bbp_reply_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_media?window.BP_Forums_Nouveau.media.reply_edit_media:[],this.bbp_reply_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_document?window.BP_Forums_Nouveau.media.reply_edit_document:[],this.bbp_reply_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_video?window.BP_Forums_Nouveau.media.reply_edit_video:[],this.bbp_topic_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_media?window.BP_Forums_Nouveau.media.topic_edit_media:[],this.bbp_topic_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_video?window.BP_Forums_Nouveau.media.topic_edit_video:[],this.bbp_topic_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_document?window.BP_Forums_Nouveau.media.topic_edit_document:[],this.bbp_forum_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_media?window.BP_Forums_Nouveau.media.forum_edit_media:[],this.bbp_forum_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_document?window.BP_Forums_Nouveau.media.forum_edit_document:[],this.bbp_forum_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_video?window.BP_Forums_Nouveau.media.forum_edit_video:[],this.bbp_reply_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_gif_data?window.BP_Forums_Nouveau.media.reply_edit_gif_data:[],this.bbp_topic_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_gif_data?window.BP_Forums_Nouveau.media.topic_edit_gif_data:[],this.bbp_forum_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_gif_data?window.BP_Forums_Nouveau.media.forum_edit_gif_data:[],this.giphy=null,this.gif_offset=0,this.gif_q=null,this.gif_limit=20,this.gif_requests=[],this.gif_data=[],this.gif_container_key=!1,this.reply_topic_allow_delete_media=!1,this.reply_topic_display_post="edit",bp.Nouveau.Media.documentCodeMirror(),p(window).on("scroll resize",function(){bp.Nouveau.Media.documentCodeMirror()})},addListeners:function(){var e=p(".bp-nouveau"),t=p(".bp-existing-media-wrap"),t=(e.on("click","#bp-add-media",this.openUploader.bind(this)),e.on("click","#bp-add-document",this.openDocumentUploader.bind(this)),e.on("click","#bp-media-submit",this.submitMedia.bind(this)),e.on("click","#bp-media-document-submit",this.submitDocumentMedia.bind(this)),e.on("click","#bp-media-uploader-close",this.closeUploader.bind(this)),e.on("click","#bb-delete-media",this.deleteMedia.bind(this)),e.on("click","#bb-select-deselect-all-media",this.toggleSelectAllMedia.bind(this)),void 0!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request?p('#buddypress [data-bp-list="media"]').on("bp_ajax_request",this.bp_ajax_media_request):this.bp_media_after_load(),e.on("click","#bb-create-album",this.openCreateAlbumModal.bind(this)),p(document).on("click","#bb-create-folder",this.openCreateFolderModal.bind(this)),p(document).on("click","#bb-create-folder-child",this.openCreateFolderChildModal.bind(this)),p(document).on("click","#bp-edit-folder-open",this.openEditFolderChildModal.bind(this)),p(document).on("click","#bp-media-create-album-submit",this.saveAlbum.bind(this)),p(document).on("click","#bp-media-create-folder-submit",this.saveFolder.bind(this)),p(document).on("click","#bp-media-create-child-folder-submit",this.saveChildFolder.bind(this)),e.on("click","#bp-media-create-album-close",this.closeCreateAlbumModal.bind(this)),p(document).on("click","#bp-media-create-folder-close",this.closeCreateFolderModal.bind(this)),p(document).on("click","#bp-media-edit-folder-close",this.closeEditFolderModal.bind(this)),p(document).on("click",".open-popup .errorPopup",this.closeErrorPopup.bind(this)),e.on("click","#bp-media-add-more",this.triggerDropzoneSelectFileDialog.bind(this)),p("#bp-media-uploader").on("click",".bp-media-upload-tab",this.changeUploadModalTab.bind(this)),p('.bp-nouveau [data-bp-list="media"]').on("click","li.load-more",this.injectMedias.bind(this)),p(".bp-nouveau #albums-dir-list").on("click","li.load-more",this.appendAlbums.bind(this)),t.on("click","li.load-more",this.appendMedia.bind(this)),e.on("change",'.bb-media-check-wrap [name="bb-media-select"]',this.addSelectedClassToWrapper.bind(this)),t.on("change",'.bb-media-check-wrap [name="bb-media-select"]',this.toggleSubmitMediaButton.bind(this)),e.on("click","#bp-edit-album-title",this.editAlbumTitle.bind(this)),p(document).on("click","#bp-edit-folder-title",this.editFolderTitle.bind(this)),e.on("click","#bp-cancel-edit-album-title",this.cancelEditAlbumTitle.bind(this)),e.on("click","#bp-save-album-title",this.saveAlbum.bind(this)),p(document).on("click","#bp-save-folder-title",this.saveFolder.bind(this)),e.on("change","#bp-media-single-album select#bb-album-privacy",this.saveAlbum.bind(this)),e.on("change","#media-stream select#bb-folder-privacy",this.savePrivacy.bind(this)),e.on("click","#bb-delete-album",this.deleteAlbum.bind(this)),p(document).on("click","#bb-delete-folder",this.deleteFolder.bind(this)),p(document).on("click","ul.document-nav li",this.resetPageDocumentDirectory.bind(this)),p(document).on("click","ul.document-nav li a",this.resetPageDocumentDirectory.bind(this)),p(document).on("click","#forums-media-button",this.openForumsUploader.bind(this)),p(document).on("click","#forums-document-button",this.openForumsDocumentUploader.bind(this)),p(document).on("click","#forums-video-button",this.openForumsVideoUploader.bind(this)),p(document).on("click","#forums-gif-button",this.toggleGifSelector.bind(this)),p(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("keydown",".search-query-input",this.searchGif.bind(this)),p(document).on("click",".bbpress-forums-activity #whats-new-toolbar .found-media-item",this.selectGif.bind(this)),p(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("click",".found-media-item",this.selectGif.bind(this)),p(document).find("form #whats-new-toolbar .gif-search-results, .forum form #whats-new-toolbar .gif-search-results").scroll(this.loadMoreGif.bind(this)),p(".buddypress.groups.messages").length||p(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("click",".found-media-item",this.selectGif.bind(this)),p(document).find("form #whats-new-attachments .forums-attached-gif-container .gif-search-results, .forum form #whats-new-attachments .forums-attached-gif-container .gif-search-results").scroll(this.loadMoreGif.bind(this)),p(document).find("form #whats-new-attachments .forums-attached-gif-container, .forum form #whats-new-attachments .forums-attached-gif-container").on("click",".gif-image-remove",this.removeSelectedGif.bind(this)),p(document).on("click",".gif-image-container",this.playVideo.bind(this)),p(document).on("click",".directory.document .media-folder_action__anchor, .directory.document .media-folder_action__anchor li a, .bb-media-container .media-folder_action__anchor, .bb-media-container .media-folder_action__list li a",this.fileActionButton.bind(this)),p(document).on("click",".bb-activity-media-elem .copy_download_file_url a, .media-folder_action__list .copy_download_file_url a, .media .bb-photo-thumb .copy_download_file_url a",this.copyDownloadLink.bind(this)),p(document).on("click",".bb-activity-media-elem.media-activity .media-action-wrap .media-action_more, #media-stream.media .bb-photo-thumb .media-action-wrap .media-action_more, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_more, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_list li a",this.fileActivityActionButton.bind(this)),p(document).click(this.toggleFileActivityActionButton),p(document).on("click",".bb-activity-media-elem.document-activity .document-expand .document-expand-anchor, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_collapse",this.toggleCodePreview.bind(this)),p(document).on("click",".activity .bp-document-move-activity, #media-stream .bp-document-move-activity",this.moveDocumentIntoFolder.bind(this)),p(document).on("click",'.bp-nouveau [data-bp-list="document"] .pager .dt-more-container.load-more',this.injectDocuments.bind(this)),p(document).on("click",'.bp-nouveau [data-bp-list="document"] .data-head',this.sortDocuments.bind(this)),p(document).on("click",".modal-container .bb-field-steps-actions",this.documentPopupNavigate.bind(this)),p(document).on("click",".bp-media-document-uploader .modal-container .bb-field-uploader-actions",this.uploadDocumentNavigate.bind(this)),p(document).on("click",".bp-media-photo-uploader .modal-container .bb-field-uploader-actions",this.uploadMediaNavigate.bind(this)),p(document).on("click",".modal-container #bp-media-edit-child-folder-submit",this.renameChildFolder.bind(this)),p(document).on("click",".activity .bp-media-move-activity, #media-stream .bp-media-move-activity",this.moveMediaIntoAlbum.bind(this)),p("#bb-media-model-container .activity-list, #media-stream")),e="#buddypress .activity-list",i='#buddypress [data-bp-list="activity"]',a="#bb-media-model-container .activity-list",o="#media-stream",e=(p(document).on("click",e+" .ac-document-move, "+i+" .ac-document-move, "+e+" .ac-folder-move, "+i+" .ac-folder-move, "+a+" .ac-document-move, "+a+" .ac-folder-move, "+o+" .ac-document-move, "+o+" .ac-folder-move",this.openDocumentMove.bind(this)),p(document).on("click",e+" .ac-media-move, "+i+" .ac-media-move, "+a+" .ac-media-move, "+o+" .ac-media-move, .group-media "+o+" .ac-media-move",this.openMediaMove.bind(this)),p(document).on("click",e+" .ac-document-close-button, "+i+" .ac-document-close-button, "+e+" .ac-folder-close-button, "+i+" .ac-folder-close-button, "+a+" .ac-document-close-button, "+a+" .ac-folder-close-button, "+o+" .ac-document-close-button, "+o+" .ac-folder-close-button",this.closeDocumentMove.bind(this)),p(document).on("click",e+" .ac-media-close-button, "+i+" .ac-media-close-button, "+a+" .ac-media-close-button, "+o+" .ac-media-close-button",this.closeMediaMove.bind(this)),t.on("click",".ac-document-rename",this.renameDocument.bind(this)),t.on("click",".ac-document-privacy",this.editPrivacyDocument.bind(this)),t.on("keyup",".media-folder_name_edit",this.renameDocumentSubmit.bind(this)),t.on("click",".name_edit_cancel, .name_edit_save",this.renameDocumentSubmit.bind(this)),p(document).on("click",".document-file-delete",this.deleteDocument.bind(this)),p(document).on("click",".media-file-delete",this.deleteMedia.bind(this)),p(document).on("click",".bp-folder-move",this.folderMove.bind(this)),p(document).on("click",".bp-document-open-create-popup-folder",this.createFolderInPopup.bind(this)),p(document).on("click",".bp-media-open-create-popup-folder",this.createAlbumInPopup.bind(this)),p(document).on("click",".close-create-popup-folder",this.closeCreateFolderInPopup.bind(this)),p(document).on("click",".close-create-popup-album",this.closeCreateAlbumInPopup.bind(this)),p(document).on("click",".bp-document-create-popup-folder-submit",this.submitCreateFolderInPopup.bind(this)),p(document).on("click",".bp-media-create-popup-album-submit",this.submitCreateAlbumInPopup.bind(this)),p(".buddypress.groups.messages")),i=p(".buddypress.groups.messages form#send_group_message_form #whats-new-toolbar"),a=p(".buddypress.groups.messages form#send_group_message_form #whats-new-attachments .bp-group-messages-attached-gif-container .gif-search-results"),o=p(".buddypress.groups.messages form#send_group_message_form #whats-new-attachments .bp-group-messages-attached-gif-container");e.on("click","#bp-group-messages-media-button",this.openGroupMessagesUploader.bind(this)),e.on("click","#bp-group-messages-document-button",this.openGroupMessagesDocumentUploader.bind(this)),e.on("click","#bp-group-messages-video-button",this.openGroupMessagesVideoUploader.bind(this)),e.on("click","#bp-group-messages-gif-button",this.toggleGroupMessagesGifSelector.bind(this)),i.on("keyup",".search-query-input",this.searchGroupMessagesGif.bind(this)),i.on("click",".found-media-item",this.selectGroupMessagesGif.bind(this)),a.scroll(this.loadMoreGroupMessagesGif.bind(this)),p(".groups.messages form#send_group_message_form #whats-new-toolbar .bp-group-messages-attached-gif-container .gif-search-results").scroll(this.loadMoreGroupMessagesGif.bind(this)),o.on("click",".gif-image-remove",this.removeGroupMessagesSelectedGif.bind(this)),p(".bp-existing-media-wrap").on("scroll",this.loadExistingMedia.bind(this)),document.addEventListener("keyup",this.closePopup.bind(this)),document.addEventListener("keyup",this.submitPopup.bind(this)),p(window).bind("beforeunload",this.beforeunloadWindow.bind(this)),_.isUndefined(BP_Nouveau.media.gif_api_key)||(window.addEventListener("scroll",this.throttledAutoPlayGifVideos.bind(this),!1),window.addEventListener("resize",this.throttledAutoPlayGifVideos.bind(this),!1),(t=p("#bp-message-thread-list")).length&&t.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),(e=p(".bb-modal-activity-body")).length&&e.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),(i=p(".bb-media-model-container .activity-list .activity-item")).length&&i.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),p(document).on("scroll","#bp-message-thread-list",this.throttledAutoPlayGifVideos.bind(this)),p(document).on("scroll",".bb-modal-activity-body",this.throttledAutoPlayGifVideos.bind(this)),p(document).on("scroll",".bb-media-model-container .activity-list .activity-item",this.throttledAutoPlayGifVideos.bind(this)),setTimeout(function(){var e=document.getElementById("bp-message-thread-list"),e=(e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1),document.querySelector(".bb-modal-activity-body")),e=(e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1),document.querySelector(".bb-media-model-container .activity-list .activity-item"));e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1)},1e3),p(window).on("load",function(){setTimeout(function(){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media.autoPlayGifVideos&&bp.Nouveau.Media.autoPlayGifVideos()},300)}),document.addEventListener("keydown",_.bind(this.closePickersOnEsc,this)),p(document).on("click",_.bind(this.closePickersOnClick,this))),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_media.length||this.bbp_topic_edit_media.length||this.bbp_forum_edit_media.length)&&p("#forums-media-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_document.length||this.bbp_topic_edit_document.length||this.bbp_forum_edit_document.length)&&p("#forums-document-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_video.length||this.bbp_topic_edit_video.length||this.bbp_forum_edit_video.length)&&p("#forums-video-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(Object.keys(this.bbp_reply_edit_gif_data).length||Object.keys(this.bbp_topic_edit_gif_data).length||Object.keys(this.bbp_forum_edit_gif_data).length)&&(this.editGifPreview(),(a=jQuery("#forums-gif-button").addClass("active").closest("form")).find("#forums-document-button")&&a.find("#forums-document-button").parents(".post-elements-buttons-item").addClass("disable"),a.find("#forums-media-button")&&a.find("#forums-media-button").parents(".post-elements-buttons-item").addClass("disable"),a.find("#forums-video-button"))&&a.find("#forums-video-button").parents(".post-elements-buttons-item").addClass("disable"),"#openEditFolder"==window.location.hash&&p("#bp-media-edit-child-folder").length&&(history.pushState(null,null,window.location.href.split("#")[0]),p("#bp-media-edit-child-folder").show()),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(bp.Nouveau.Media.reply_topic_allow_delete_media=!0)},updateAlbumCounts:function(e){var t,i,a,o;p("#buddypress #bp-media-single-album").length&&(o=parseInt(e.album_media_count)||0,e=parseInt(e.album_video_count)||0,t=function(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},0<(a=p("#buddypress .bb-album-photo-count")).length&&(i=1===o?BP_Nouveau.media.i18n_strings.photo:BP_Nouveau.media.i18n_strings.photos,a.text(t(o)+" "+i)),0<(a=p("#buddypress .bb-album-video-count")).length)&&(o=1===e?BP_Nouveau.media.i18n_strings.video:BP_Nouveau.media.i18n_strings.videos,a.text(t(e)+" "+o))},loadExistingMedia:function(){p(window).scroll()},resetPageDocumentDirectory:function(e){e.preventDefault(),this.current_page=1},submitCreateFolderInPopup:function(e){e.preventDefault();var i=p(e.currentTarget).closest(".open-popup"),a=p(i).find(".bp-document-create-popup-folder-submit"),t=i.find(".bb-folder-selected-id").val(),o=p.trim(p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder-title").val()),d=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder-title"),s=/[\\/?%*:|"<>]+/g.exec(d.val()),s=Boolean(s);if(""===p.trim(d.val())||s)return d.addClass("error"),!1;d.removeClass("error"),this.currentTargetParent=t=""===t?0:t;var n=this.currentTargetParent,r=0,l="",c="",u=0;if("group"===this.moveToTypePopup?(l="grouponly",r=this.moveToIdPopup):(l=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder #bb-folder-privacy").val(),c=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder #bb-folder-privacy")),""===o)return alert(BP_Nouveau.media.create_folder_error_title),!1;a.addClass("loading"),setTimeout(function(){var e={action:"document_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:o,privacy:l,parent:n,group_id:r};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,async:!1,success:function(e){var t;e.success&&(p(".document-data-table-head").length&&parseInt(n)===parseInt(BP_Nouveau.media.current_folder)&&(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()),i.find(".location-folder-list-wrap .location-folder-list").remove(),i.find(".location-folder-list-wrap").append(e.data.tree_view),t="#"+p(i).attr("id")+".open-popup",bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,e.data.folder_id),u=e.data.folder_id,(""===e.data.tree_view?(i.find(".location-folder-list-wrap").hide(),i.find(".location-folder-list-wrap-main span.no-folder-exists")):(i.find(".location-folder-list-wrap-main span.no-folder-exists").hide(),i.find(".location-folder-list-wrap"))).show(),i.find("ul.location-folder-list span#"+u).trigger("click"),i.find(".bb-model-footer").show(),i.find(".bb-model-footer, #bp-media-document-prev").show(),i.find(".bb-field-wrap-search").show(),i.find(".bp-document-open-create-popup-folder").show(),i.find(".location-folder-list-wrap-main").show(),i.find(".create-popup-folder-wrap").hide(),i.find(".bb-folder-selected-id").val(),i.find(".bb-folder-selected-id").val(u),i.find(".bb-model-header").children().show(),i.find(".bb-model-header p").hide(),d.val(""),""!==c&&c.val("public"),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0p(i).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),a.removeClass("loading"),setTimeout(function(){var e=i.find("ul.location-folder-list span#"+u),t=(e.trigger("click"),p(i).find("#bb-document-privacy"));0!==Number(e.data("id"))?(t.find("option").removeAttr("selected"),t.val(e.parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1))},200))}}),this.currentTargetParent=u,i.find(".location-folder-list li.is_active").show().children("span, i").show().siblings("ul").hide(),i.find(".location-folder-list li.is_active").siblings("li").show().children("span, i").show().siblings("ul").hide(),i.find(".location-folder-list li span.selected").removeClass("selected"),i.find(".location-folder-list li.is_active").children("span").addClass("selected")},0)},submitCreateAlbumInPopup:function(e){e.preventDefault();var t=this,i=p(e.currentTarget).closest(".open-popup"),a=p(i).find(".bp-media-create-popup-album-submit"),o=i.find(".bb-album-selected-id").val(),d=(this.currentTargetParent=o=""===o?0:o,this.currentTargetParent),s=0,n=p.trim(p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album-title").val()),r=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album-title"),l="",c="",u=0;if("group"===this.moveToTypePopup?(l="grouponly",s=this.moveToIdPopup):(l=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album #bb-album-privacy").val(),c=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album #bb-album-privacy")),""===n)return alert(BP_Nouveau.media.create_album_error_title),!1;a.addClass("loading"),setTimeout(function(){var e={action:"media_album_save",_wpnonce:BP_Nouveau.nonces.media,title:n,privacy:l,parent:d,group_id:s};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,async:!1,success:function(e){e.success&&(i.find(".location-album-list-wrap .location-album-list").remove(),i.find(".location-album-list-wrap").append(e.data.tree_view),bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(i,e.data.album_id),u=e.data.album_id,(""===e.data.tree_view?(i.find(".location-album-list-wrap").hide(),i.find(".location-album-list-wrap-main span.no-album-exists")):(i.find(".location-album-list-wrap-main span.no-album-exists").hide(),i.find(".location-album-list-wrap"))).show(),i.find("ul.location-album-list span#"+u).trigger("click"),i.find(".bb-model-footer").show(),i.find(".bb-field-wrap-search").show(),i.find(".bp-media-open-create-popup-album").show(),i.find(".location-album-list-wrap-main").show(),i.find(".create-popup-album-wrap").hide(),i.find(".bb-field-steps-2 #bp-media-prev").show(),i.find(".bb-album-selected-id").val(),i.find(".bb-album-selected-id").val(u),i.find(".bb-model-header").children().show(),i.find(".bb-model-header p").hide(),r.val(""),""!==c&&c.val("public"),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(i).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),t.updateAlbumNavCount(e.data.album_count)),a.removeClass("loading")}}),this.currentTargetParent=u,i.find(".location-album-list li.is_active").show().children("span, i").show().siblings("ul").hide(),i.find(".location-album-list li.is_active").siblings("li").show().children("span, i").show().siblings("ul").hide(),i.find(".location-album-list li span.selected").removeClass("selected"),i.find(".location-album-list li.is_active").children("span").addClass("selected")},0)},closeCreateFolderInPopup:function(e){e.preventDefault(),p(".modal-container .bb-model-footer").show(),p(".bb-field-wrap-search").show(),p(".bp-document-open-create-popup-folder").show(),p(".location-folder-list-wrap-main").show(),p("#bp-media-document-prev").show(),p(".create-popup-folder-wrap").hide(),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header").children().show(),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header p").hide()},closeCreateAlbumInPopup:function(e){e.preventDefault(),p(".modal-container .bb-model-footer").show(),p(".bb-field-wrap-search").show(),p(".bp-document-open-create-popup-folder").show(),p(".modal-container:visible .bp-video-open-create-popup-album").show(),p(".location-album-list-wrap-main").show(),p(".bb-field-steps-2 #bp-media-prev").show(),p(".bb-field-steps-2 #bp-video-next").show(),p(".create-popup-album-wrap").hide(),p(".bp-media-create-popup-album-submit.loading").removeClass("loading"),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header").children().show(),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header p").hide()},createFolderInPopup:function(e){e.preventDefault();var t=parseInt(p(document).find(".open-popup .bb-folder-selected-id").val()),i=p(document).find(".open-popup .bb-folder-create-from").val();0 "+BP_Nouveau.media.create_folder+""),p(".modal-container #bb-folder-privacy").addClass("new-folder-create-privacy"),p(document).find(".open-popup .error").hide()},createAlbumInPopup:function(e){e.preventDefault();var t=parseInt(p(document).find(".open-popup .bb-album-selected-id").val()),i=p(document).find(".open-popup .bb-album-create-from").val();0 "+BP_Nouveau.media.create_album_title+""),p(".modal-container #bb-folder-privacy").addClass("new-folder-create-privacy"),p(document).find(".open-popup .error").hide()},savePrivacy:function(e){var t,i,a,o=p(e.currentTarget);if(e.preventDefault(),o.hasClass("new-folder-create-privacy"))return!1;t=parseInt(o.data("item-id")),i=o.data("item-type"),a=o.val(),e=p(e.currentTarget).find("option:selected").text(),this.privacySelectorSelect.addClass("hide"),this.privacySelectorSpan.text(""),this.privacySelectorSpan.text(e),this.privacySelectorSpan.show(),0 '+e.data.media_personal_count+" "+i)):p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count)),void 0!==e.data&&void 0!==e.data.media_group_count&&0 '+e.data.media_group_count+" "+i)):p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):n.find(".media-list:not(.existing-media-list)")).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):n.find(".media-list:not(.existing-media-list)")).html(e.data.group_media_html_content):p.each(s,function(e,t){p('#media-stream ul.media-list li[data-id="'+t+'"]').length&&p('#media-stream ul.media-list li[data-id="'+t+'"]').remove()}),void 0!==e.data.album_total_count&&d.updateAlbumCounts(e.data))):(setTimeout(function(){o.prop("disabled",!1)},500),e.success?(void 0!==e.data&&void 0!==e.data.media_personal_count&&0
'+e.data.media_personal_count+" "+i)):p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count)),void 0!==e.data&&void 0!==e.data.media_group_count&&0
'+e.data.media_group_count+" "+i)):p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),(t=n.find(".media-list:not(.existing-media-list)")).find('.bb-media-check-wrap [name="bb-media-select"]:checked').each(function(){p(this).closest("li").remove()}),t.parent().parent().hasClass("album-single-view")&&t.find('.bb-video-check-wrap [name="bb-video-select"]:checked').each(function(){p(this).closest("li").remove()}),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):t).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):t).html(e.data.group_media_html_content):p.each(s,function(e,t){p('#media-stream ul.media-list li[data-id="'+t+'"]').length&&p('#media-stream ul.media-list li[data-id="'+t+'"]').remove()}),void 0!==e.data.album_total_count&&d.updateAlbumCounts(e.data)):p("#buddypress #media-stream.media").prepend(e.data.feedback));var t,i=p(".bp-nouveau #bb-select-deselect-all-media");i.hasClass("selected")&&i.removeClass("selected"),jQuery(window).scroll()}})},toggleSelectAllMedia:function(e){e.preventDefault(),p(e.currentTarget).hasClass("selected")?(p(e.currentTarget).data("bp-tooltip",BP_Nouveau.media.i18n_strings.selectall),this.deselectAllMedia(e)):(p(e.currentTarget).data("bp-tooltip",BP_Nouveau.media.i18n_strings.unselectall),this.selectAllMedia(e)),p(e.currentTarget).toggleClass("selected")},selectAllMedia:function(e){e.preventDefault();e=p("#buddypress").find(".media-list:not(.existing-media-list)");e.find('.bb-media-check-wrap [name="bb-media-select"]').each(function(){p(this).prop("checked",!0),p(this).closest(".bb-item-thumb").addClass("selected"),p(this).closest(".bb-media-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.unselect)}),e.parent().parent().hasClass("album-single-view")&&e.find('.bb-video-check-wrap [name="bb-video-select"]').each(function(){p(this).prop("checked",!0),p(this).closest(".bb-item-thumb").addClass("selected"),p(this).closest(".bb-video-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.unselect)})},deselectAllMedia:function(e){e.preventDefault();e=p("#buddypress").find(".media-list:not(.existing-media-list)");e.find('.bb-media-check-wrap [name="bb-media-select"]').each(function(){p(this).prop("checked",!1),p(this).closest(".bb-item-thumb").removeClass("selected"),p(this).closest(".bb-media-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.select)}),e.parent().parent().hasClass("album-single-view")&&e.find('.bb-video-check-wrap [name="bb-video-select"]').each(function(){p(this).prop("checked",!1),p(this).closest(".bb-item-thumb").removeClass("selected"),p(this).closest(".bb-video-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.select)})},editAlbumTitle:function(e){e.preventDefault(),p("#bb-album-title").show(),p("#bp-save-album-title").show(),p("#bp-cancel-edit-album-title").show(),p("#bp-edit-album-title").hide(),p("#bp-media-single-album #bp-single-album-title").hide()},editFolderTitle:function(e){e.preventDefault(),p("#bb-album-title").show(),p("#bp-save-folder-title").show(),p("#bp-cancel-edit-album-title").show(),p("#bp-edit-folder-title").hide(),p("#bp-media-single-album #bp-single-album-title").hide()},cancelEditAlbumTitle:function(e){e.preventDefault(),p("#bb-album-title").removeClass("error").hide(),p("#bp-save-album-title,#bp-save-folder-title").hide(),p("#bp-cancel-edit-album-title").hide(),p("#bp-edit-album-title,#bp-edit-folder-title").show(),p("#bp-media-single-album #bp-single-album-title").show()},triggerDropzoneSelectFileDialog:function(){this.dropzone_obj.hiddenFileInput.click()},closeUploader:function(e){e.preventDefault(),p("#bp-media-uploader").hide(),p("#bp-media-add-more").hide(),p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),p("#bp-media-uploader-modal-status-text").text(""),p("#bp-media-post-content").val(""),p("#bp-dropzone-content .bp-feedback").remove(),this.dropzone_obj.element&&this.dropzone_obj.destroy(),this.dropzone_media=[];var t=p(e.currentTarget).closest("#bp-media-uploader");p(".close-create-popup-album").trigger("click"),p(".close-create-popup-folder").trigger("click"),t.find('.breadcrumbs-append-ul-li .item span[data-id="0"]').trigger("click"),t.find(".bb-field-steps").length&&(t.find(".bb-field-steps-1").show().siblings(".bb-field-steps-2").hide(),t.find(".bb-field-steps-1 #bp-media-photo-next, .bb-field-steps-1 #bp-media-document-next ").hide(),t.find(".bb-field-steps-1").removeClass("controls-added"),t.find("#bp-media-document-prev, #bp-media-prev, #bp-media-document-submit, #bp-media-submit, .bp-media-open-create-popup-folder, .bp-document-open-create-popup-folder, .create-popup-folder-wrap, .create-popup-album-wrap, .bp-video-open-create-popup-album").hide()),this.clearFolderLocationUI(e)},closeChildFolderUploader:function(e){e.preventDefault(),p(document).find(".open-popup #bb-album-child-title").val(""),p(document).find(".open-popup #bp-media-create-child-folder-submit").removeClass("loading"),p(document).find("#bp-media-create-child-folder").removeClass("open-popup"),p(document).find("#bp-media-create-child-folder").hide(),p(document).find(".open-popup #bb-album-title").text(""),p(document).find(".open-popup #bp-media-create-folder").hide(),p(document).find("#bp-media-create-folder").removeClass("open-popup")},closeFolderUploader:function(e){e.preventDefault(),p(document).find(".open-popup #bb-album-title").val(""),p(document).find(".open-popup #bp-media-create-folder-submit").removeClass("loading"),p(document).find(".open-popup #bp-media-document-submit").hide(),p(document).find("#bp-media-create-folder").removeClass("open-popup"),p(document).find("#bp-media-create-folder").hide()},loadMoreGif:function(e){var t=e.target,i=this,e=p(e.target).closest("form").find(".forums-attached-gif-container"),a=e.data("key");i.gif_container_key=a,t.scrollTop+t.offsetHeight>=t.scrollHeight&&!e.hasClass("loading")&&0
=t.scrollHeight&&!p(e.target).closest(".bp-group-messages-attached-gif-container").hasClass("loading")&&0 \n\t\n\t\t \n\t\n',e.data[t].saved=!1,this.gif_data.push(e.data[t])}p(".bp-group-messages-attached-gif-container").find(".gif-search-results-list").append(i)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(this.gif_total_count=e.pagination.total_count)},loadMoreGifResponse:function(e){var t=this,i=0;if(p('div.forums-attached-gif-container[data-key="'+t.gif_container_key+'"]').removeClass("loading"),void 0!==e.data&&e.data.length){for(var a="",i=0;i
\n\t\n\t\t \n\t\n',e.data[i].saved=!1,t.gif_data[t.gif_container_key].data.push(e.data[i])}p('div.forums-attached-gif-container[data-key="'+t.gif_container_key+'"]').closest("form").find(".gif-search-results-list").append(a)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(t.gif_data[t.gif_container_key].total_count=e.pagination.total_count)},editGifPreview:function(){var e=this,t={};if(e.bbp_is_reply_edit&&Object.keys(e.bbp_reply_edit_gif_data).length?t=e.bbp_reply_edit_gif_data.gif_raw_data:e.bbp_is_topic_edit&&Object.keys(e.bbp_topic_edit_gif_data).length?t=e.bbp_topic_edit_gif_data.gif_raw_data:e.bbp_is_forum_edit&&Object.keys(e.bbp_forum_edit_gif_data).length&&(t=e.bbp_forum_edit_gif_data.gif_raw_data),void 0===t.images)return!1;e=p("#whats-new-attachments .forums-attached-gif-container");e[0].style.backgroundImage="url("+t.images.fixed_width.url+")",e[0].style.backgroundSize="contain",e[0].style.height=t.images.original.height+"px",e[0].style.width=t.images.original.width+"px",e.find(".gif-image-container img").attr("src",t.images.original.url),e.removeClass("closed"),p("#bbp_media_gif").length&&p("#bbp_media_gif").val(JSON.stringify(t))},selectGif:function(e){var t=this,i=0,a=p(e.currentTarget),o=a.closest("form").find(".forums-attached-gif-container"),d=(e.preventDefault(),o.closest("form").find(".gif-media-search-dropdown").removeClass("open"),o.data("key"));if(void 0!==t.gif_data[d]&&void 0!==t.gif_data[d].data&&t.gif_data[d].data.length){for(i=0;i
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,s.gif_data.push(e.data[n])}p(d.target).closest(".bp-group-messages-attached-gif-container").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(s.gif_total_count=e.pagination.total_count),p(d.target).closest(".bp-group-messages-attached-gif-container").removeClass("loading")},function(){p(d.target).find(".gif-no-connection").addClass("show")}));s.gif_requests.push(e),s.gif_offset=s.gif_offset+s.gif_limit},searchGifRequest:function(d){var s=this,n=0,r=p(d.target).closest("form").find(".forums-attached-gif-container"),l=(r.addClass("loading"),r.data("key")),e=(p(d.target).closest("form").find(".gif-no-results").removeClass("show"),p(d.target).closest("form").find(".gif-no-connection").removeClass("show"),s.clearGifRequests(l),s.gif_data[l].q=d.target.value,s.gif_data[l].offset=0,s.giphy.search({q:s.gif_data[l].q,offset:s.gif_data[l].offset,fmt:"json",limit:s.gif_data[l].limit},function(e){if(void 0!==e.data.length&&0===e.data.length&&p(d.target).closest("form").find(".gif-no-results").addClass("show"),void 0!==e.meta.status&&200!==e.meta.status&&p(d.target).closest("form").find(".gif-no-connection").addClass("show"),void 0!==e.data&&e.data.length){var t="";for(n=0;n
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,s.gif_data[l].data.push(e.data[n])}p(d.target).closest(".gif-search-content").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(s.gif_data[l].total_count=e.pagination.total_count),r.removeClass("loading")},function(){p(d.target).closest("form").find(".gif-no-connection").addClass("show")}));s.gif_data[l].requests.push(e),s.gif_data[l].offset=s.gif_data[l].offset+s.gif_data[l].limit},clearGifRequests:function(e){var t=this;if(void 0!==t.gif_data[e]&&void 0!==t.gif_data[e].requests){for(var i=0;i
\n\t\n\t\t \n\t\n',e.data[l].saved=!1,n.gif_data[s].data.push(e.data[l])}r.closest("form").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(n.gif_data[s].total_count=e.pagination.total_count),d.removeClass("loading")}),n.gif_data[s].requests.push(e),n.gif_data[s].offset=n.gif_data[s].offset+n.gif_data[s].limit),t.toggleClass("open"),r.parents("form").find("#whats-new-attachments .forums-attached-gif-container img")),t=(0
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,d.gif_data.push(e.data[n])}s.closest("form").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(d.gif_total_count=e.pagination.total_count),p(".gif-search-query").closest(".bp-group-messages-attached-gif-container").removeClass("loading")}),d.gif_requests.push(e),d.gif_offset=d.gif_offset+d.gif_limit),s.parents("form").find("#whats-new-attachments .bp-group-messages-attached-gif-container img"));0
"),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),a.dropzone_obj[n].on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=p(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.album_id=a.album_id,t.data.group_id=a.group_id,t.data.saved=!1,a.dropzone_media[n].push(t.data),a.addMediaIdsToForumsForm(d)):(jQuery(".forum-media-error-popup").length||p("body").append('"),this.removeFile(e))}),a.dropzone_obj[n].on("removedfile",function(e){if(!0===bp.Nouveau.Media.reply_topic_allow_delete_media){if(a.dropzone_media[n].length)for(var t in a.dropzone_media[n])if(e.upload.uuid==a.dropzone_media[n][t].uuid){this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit||void 0===a.dropzone_media[n][t].saved||a.dropzone_media[n][t].saved||"edit"!==bp.Nouveau.Media.reply_topic_display_post||a.removeAttachment(a.dropzone_media[n][t].id),a.dropzone_media[n].splice(t,1),a.addMediaIdsToForumsForm(d);break}var i;_.isNull(a.dropzone_obj[n].files)||0!==a.dropzone_obj[n].files.length||((i=o.closest("form")).find("#forums-document-button")&&i.find("#forums-document-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-video-button")&&i.find("#forums-video-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-gif-button")&&i.find("#forums-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-media-button")&&i.find("#forums-media-button").parents(".post-elements-buttons-item").removeClass("no-click"))}_.isNull(a.dropzone_obj[n].files)||0!==a.dropzone_obj[n].files.length||o.closest("form").removeClass("has-media")}),a.dropzone_obj[n].on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 "),this.removeFile(e))}),a.dropzone_obj.on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=p(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.album_id=a.album_id,t.data.group_id=a.group_id,t.data.saved=!1,a.dropzone_media.push(t.data),a.addMediaIdsToGroupMessagesForm()):(jQuery(".group-message-error-popup").length||p("body").append('"),this.removeFile(e))}),a.dropzone_obj.on("removedfile",function(e){if(a.dropzone_media.length)for(var t in a.dropzone_media)if(e.upload.uuid==a.dropzone_media[t].uuid){void 0===a.dropzone_media[t].saved||a.dropzone_media[t].saved||a.removeAttachment(a.dropzone_media[t].id),a.dropzone_media.splice(t,1),a.addMediaIdsToGroupMessagesForm();break}var i;_.isNull(a.dropzone_obj.files)||0!==a.dropzone_obj.files.length||((i=p("#send_group_message_form")).find("#bp-group-messages-document-button")&&i.find("#bp-group-messages-document-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-video-button")&&i.find("#bp-group-messages-video-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-gif-button")&&i.find("#bp-group-messages-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-media-button")&&i.find("#bp-group-messages-media-button").parents(".post-elements-buttons-item").removeClass("no-click"))}),t.removeClass("closed").addClass("open"),a.resetGroupMessagesGifComponent(),a.resetGroupMessagesDocumentComponent(),a.resetGroupMessagesVideoComponent()):a.resetGroupMessagesMediaComponent())},openGroupMessagesDocumentUploader:function(e){var l=this,t=p("div#bp-group-messages-post-document-uploader"),i=p(e.currentTarget);e.preventDefault(),i.toggleClass("active"),void 0!==window.Dropzone&&t.length&&(t.hasClass("closed")?(l.document_dropzone_obj=new Dropzone("div#bp-group-messages-post-document-uploader",l.documentOptions),l.document_dropzone_obj.on("addedfile",function(){}),l.document_dropzone_obj.on("sending",function(e,t,i){i.append("action","document_document_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media);i=p("#send_group_message_form");i.find("#bp-group-messages-media-button")&&i.find("#bp-group-messages-media-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-video-button")&&i.find("#bp-group-messages-video-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-gif-button")&&i.find("#bp-group-messages-gif-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-document-button")&&i.find("#bp-group-messages-document-button").parents(".post-elements-buttons-item").addClass("no-click")}),l.document_dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),l.document_dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?p(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&p(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".group-document-error-popup").length||p("body").append('"),this.removeFile(e))}),l.document_dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.document_dropzone_obj.on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e))}),r.video_dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.video.empty_video_type):t()}),r.video_dropzone_obj.on("addedfile",function(e){e.dataURL||bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),r.video_dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);e.upload.progress<=99?(p(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,p(e.previewElement).find(".dz-progress-count").text("99% "+BP_Nouveau.video.i18n_strings.video_uploaded_text))}),r.video_dropzone_obj.on("success",function(e,t){if(100===e.upload.progress&&(p(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,p(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),p(e.previewElement).closest(".dz-preview").addClass("dz-complete")),!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),l.dropzone_obj[u].on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.dropzone_obj[u].on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),l.dropzone_obj[u].on("accept",function(e,t){0==e.size?t(BP_Nouveau.video.empty_video_type):t()}),l.dropzone_obj[u].on("addedfile",function(e){e.dataURL&&e.dataThumb&&e.dataThumb.length?p(e.previewElement).find(".dz-video-thumbnail").prepend(' '):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),l.dropzone_obj[u].on("uploadprogress",function(e){o.closest("form").addClass("media-uploading");var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);e.upload.progress<=99?(p(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,p(e.previewElement).find(".dz-progress-count").text("99% "+BP_Nouveau.video.i18n_strings.video_uploaded_text))}),l.dropzone_obj[u].on("success",function(e,t){if(100===e.upload.progress&&(p(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,p(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),p(e.previewElement).closest(".dz-preview").addClass("dz-complete")),!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a
'+p(this).text()+""),p(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val(p(e.currentTarget).data("id")),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),0!==Number(p(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(p(e.currentTarget).parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),p(document).on("click",t+" .breadcrumb .item > span",function(e){var t,i;p(this).hasClass("is-disabled")||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val(0),p(e.currentTarget).closest(".bb-field-wrap").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),i=p(e.currentTarget).closest("#bp-media-uploader").find(".location-album-list li.is_active").data("privacy"),0!==Number(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),e=document.getElementsByClassName("uploader-post-media-template").length?document.getElementsByClassName("uploader-post-media-template")[0].innerHTML:"",i.options.previewTemplate=e,i.dropzone_obj=new Dropzone("div#media-uploader",i.options),i.dropzone_obj.on("sending",function(e,t,i){i.append("action","media_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media)}),i.dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),i.dropzone_obj.on("addedfile",function(){setTimeout(function(){i.dropzone_obj.getAcceptedFiles().length&&p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),i.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?p(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&p(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".media-error-popup").length||p("body").append('"),this.removeFile(e))}),i.dropzone_obj.on("queuecomplete",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),p(".bb-field-steps-1 #bp-media-photo-next, #bp-media-submit, #bp-media-create-album-submit").show()}),i.dropzone_obj.on("processing",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),p(".bb-field-steps-1 #bp-media-photo-next, #bp-media-submit, #bp-media-create-album-submit").hide()}),i.dropzone_obj.on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=i.dropzone_media.length,t.data.album_id=i.album_id,t.data.group_id=i.group_id,t.data.saved=!1,i.dropzone_media.push(t.data)):(jQuery(".media-error-popup").length||p("body").append('"),this.removeFile(e)),p(".modal-container").addClass("modal-container--alert"),p(".bb-field-steps-1").addClass("controls-added"),p("#bp-media-add-more").show(),p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()}),i.dropzone_obj.on("removedfile",function(e){if(i.dropzone_media.length)for(var t in i.dropzone_media)if(e.upload.uuid==i.dropzone_media[t].uuid){void 0===i.dropzone_media[t].saved||i.dropzone_media[t].saved||i.removeAttachment(i.dropzone_media[t].id),i.dropzone_media.splice(t,1);break}i.dropzone_obj.getAcceptedFiles().length?p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show():(p("#bp-media-uploader-modal-status-text").text(""),p("#bp-media-add-more, #bp-media-photo-next").hide(),p(".bb-field-steps-1").removeClass("controls-added"),p("#bp-media-submit").hide(),p(".modal-container").removeClass("modal-container--alert"))}))},openDocumentUploader:function(e){var a,t,l=this;e.preventDefault(),void 0!==window.Dropzone&&p("div#media-uploader").length&&(p("#bp-media-uploader").hasClass("bp-media-document-uploader")&&!this.currentTargetParent&&(this.currentTargetParent=0),p(e.currentTarget).closest("#bp-media-single-folder").length&&p("#bb-document-privacy").hide(),p(document).removeClass("open-popup"),p("#bp-media-uploader").show(),p("#bp-media-uploader").addClass("open-popup"),p("#bp-media-uploader.bp-media-document-uploader").find(".bb-field-steps.bb-field-steps-2").length&&(t="#bp-media-uploader.bp-media-document-uploader",0!==Number(p(t).find(".bb-folder-selected-id").data("value"))?(a=p(t).find(".bb-folder-selected-id").data("value"),p(t).find("#bb-document-privacy").prop("disabled",!0)):a=0,""!==this.moveToIdPopup)&&p.ajax({url:BP_Nouveau.ajaxurl,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:BP_Nouveau.nonces.media},success:function(e){p(document).find(".bp-media-document-uploader .location-folder-list-wrap h4 span.where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap").hide(),p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap-main span.no-folder-exists")):(p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap-main span.no-folder-exists").hide(),p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap"))).show(),p(document).find(".bp-media-document-uploader .popup-on-fly-create-album .privacy-field-wrap-hide-show").show(),p(document).find(".bp-media-document-uploader .open-popup .bb-folder-create-from").val("profile"),p(t).find(".location-folder-list-wrap .location-folder-list").remove(),p(t).find(".location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,a),p(t).find("ul.location-folder-list span#"+a).trigger("click"),p(t).find(".bb-folder-selected-id").val(a)}}),p(document).on("click",t+" .location-folder-list li span",function(e){var t;e.preventDefault(),p(this).parent().hasClass("is_active")||(0!=p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item").append(''+p(this).text()+""),p(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val(p(e.currentTarget).data("id")),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),0!==Number(p(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(p(e.currentTarget).parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),p(document).on("click",t+" .breadcrumb .item > span",function(e){var t,i;p(this).hasClass("is-disabled")||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val(p(e.currentTarget).data("id")),p(e.currentTarget).closest(".bb-field-wrap").find(".location-folder-list li span").removeClass("selected").parent().removeClass("is_active"),p(e.currentTarget).closest(".bb-field-wrap").find('.location-folder-list li[data-id="'+p(e.currentTarget).data("id")+'"]').addClass("is_active"),p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),i=p(e.currentTarget).closest("#bp-media-uploader").find(".location-folder-list li.is_active").data("privacy"),0!==Number(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),e=document.getElementsByClassName("uploader-post-document-template").length?document.getElementsByClassName("uploader-post-document-template")[0].innerHTML:"",l.options.previewTemplate=e,l.dropzone_obj=new Dropzone("div#media-uploader",l.options),l.dropzone_obj.on("sending",function(e,t,i){i.append("action","document_document_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media)}),l.dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),l.dropzone_obj.on("addedfile",function(){setTimeout(function(){l.dropzone_obj.getAcceptedFiles().length&&p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,l.dropzone_media.length,l.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),l.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?p(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&p(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".document-error-popup").length||p("body").append('"),this.removeFile(e))}),l.dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.dropzone_obj.on("queuecomplete",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),p(".bb-field-steps-1 #bp-media-document-next, #bp-media-document-submit").show()}),l.dropzone_obj.on("processing",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),p(".bb-field-steps-1 #bp-media-document-next, #bp-media-document-submit").hide()}),l.dropzone_obj.on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a .activity-content .bp-media-move-file",p(o).find(".bp-document-move").attr("id",p(e.currentTarget).closest(".document-activity").attr("data-id")),0 ');var i,t,a,o,d=t,s=this.moveToTypePopup;""!==this.moveToIdPopup&&p.ajax({url:BP_Nouveau.ajaxurl,type:"post",data:{action:"media_get_album_view",id:this.moveToIdPopup,type:this.moveToTypePopup},success:function(e){p(document).find(".location-album-list-wrap h4 span.where-to-move-profile-or-group-media").html(e.data.first_span_text),(""===e.data.html?(p(document).find(".open-popup .location-album-list-wrap").hide(),p(document).find(".open-popup .location-album-list-wrap-main span.no-album-exists")):(p(document).find(".open-popup .location-album-list-wrap-main span.no-album-exists").hide(),p(document).find(".open-popup .location-album-list-wrap"))).show(),"group"===s?(p(document).find(".popup-on-fly-create-album .privacy-field-wrap-hide-show").hide(),p(document).find(".open-popup .bb-album-create-from").val("group")):(p(document).find(".popup-on-fly-create-album .privacy-field-wrap-hide-show").show(),p(document).find(".open-popup .bb-album-create-from").val("profile")),!1===e.data.create_album?(p(o+".open-popup").find(".bp-media-open-create-popup-folder").removeClass("create-album"),p(o+".open-popup").find(".bp-media-open-create-popup-folder").hide()):(p(o+".open-popup").find(".bp-media-open-create-popup-folder").addClass("create-album"),p(o+".open-popup").find(".bp-media-open-create-popup-folder").show()),p(o).find(".location-album-list-wrap .location-album-list").remove(),p(o).find(".location-album-list-wrap").append(e.data.html),p(o).find("ul.location-album-list span#"+d).trigger("click")}}),p(document).on("click",o+" .location-album-list li span",function(e){var t;e.preventDefault(),p(this).parent().hasClass("is_active")||(0!=p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),p(this).closest(".location-album-list-wrap").find(".breadcrumb .item").append(''+p(this).text()+""),p(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),t=p(document).find('a.bb-open-media-theatre[data-id="'+i.find(".bp-media-move").attr("id")+'"]').data("album-id"),Number(t)==Number(p(e.currentTarget).data("id"))?p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||p(e.currentTarget).closest(".bp-media-move-file").find(".bb-album-selected-id").val(p(e.currentTarget).data("id"))}),p(document).on("click",o+" .breadcrumb .item > span",function(e){p(this).hasClass("is-disabled")||(p(e.currentTarget).closest(".bp-media-move-file").find(".bb-album-selected-id").val(0),p(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),d==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"))})},openDocumentMove:function(e){e.preventDefault();var t,i,a,e=p(e.currentTarget),o=(e.closest(".bb-activity-media-elem").find(".document-title").text(),this.moveToIdPopup=e.attr("id"),this.moveToTypePopup=e.attr("data-type"),e.attr("data-action")),d=(p(".bp-media-move-file.open-popup, .bp-media-move-folder.open-popup").hide().removeClass("open-popup"),e.closest("#activity-modal")),s=(0===d.length&&(d=p("body")),e.closest(".conflict-activity-ul-li-comment").closest("li.comment-item").length?(i=e.closest("li.comment-item"),i=d.find("#"+i.attr("id")+".comment-item .bp-media-move-file").first()):0<(a=e.closest("li.activity-item")).length&&(i=d.find("#"+a.attr("id")+" > .activity-content .bp-media-move-file").first()),i&&0!==i.length||(e.closest(".conflict-activity-ul-li-comment").closest("li.comment-item").length?(a=e.closest("li.comment-item").attr("id"),i=d.find("#"+a+".comment-item .bp-media-move-file").first()):(a=e.closest("li.activity-item").attr("id"))&&(i=d.find("#"+a+" > .activity-content .bp-media-move-file").first())),i&&0 '),"document"===o?p(t).find(".bb-model-header h4 .target_name").text(BP_Nouveau.media.move_to_file):p(t).find(".bb-model-header h4 .target_name").text(BP_Nouveau.media.move_to_folder),p(t).show(),p(t).addClass("open-popup"),"group"===this.moveToTypePopup?(p(document).find(".location-folder-list-wrap h4").show(),p(t).addClass("move-folder-popup-group")):(p(document).find(".location-folder-list-wrap h4").hide(),p(".move-folder-popup-group").removeClass("move-folder-popup-group")),this.currentTargetParent),n=this.moveToTypePopup;""!==this.moveToIdPopup&&p.ajax({url:BP_Nouveau.ajaxurl,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:BP_Nouveau.nonces.media},success:function(e){p(document).find(".location-folder-list-wrap h4 span.where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(p(document).find(".open-popup .location-folder-list-wrap").hide(),p(document).find(".open-popup .location-folder-list-wrap-main span.no-folder-exists")):(p(document).find(".open-popup .location-folder-list-wrap-main span.no-folder-exists").hide(),p(document).find(".open-popup .location-folder-list-wrap"))).show(),"group"===n?(p(document).find(".popup-on-fly-create-folder .privacy-field-wrap-hide-show").hide(),p(document).find(".open-popup .bb-folder-create-from").val("group")):(p(document).find(".popup-on-fly-create-folder .privacy-field-wrap-hide-show").show(),p(document).find(".open-popup .bb-folder-create-from").val("profile")),p(t).find(".location-folder-list-wrap .location-folder-list").remove(),p(t).find(".location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&(bp.Nouveau.Media.folderLocationUI(t,s),p(t).find("ul.location-folder-list span#"+s).trigger("click"))}})},closeMediaMove:function(e){e.preventDefault(),0!=p(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list-wrap .breadcrumb .item span:last-child").data("id")&&p(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list-wrap .breadcrumb .item span:last-child").remove(),p(e.currentTarget).closest(".bp-media-move-file").hide()},closeDocumentMove:function(e){e.preventDefault();var t=p(e.currentTarget),i=jQuery(e.currentTarget).closest(".has-folderlocationUI");(t.hasClass("ac-document-close-button")?(t.closest(".bp-media-move-file"),p(".bp-media-move-file.open-popup").hide().removeClass("open-popup").find(".bp-document-move")):(t.closest(".bp-media-move-folder"),p(".bp-media-move-folder.open-popup").hide().removeClass("open-popup").find(".bp-folder-move"))).attr("id",""),i.find(".bp-document-move.loading").removeClass("loading"),this.clearFolderLocationUI(e)},renameDocument:function(e){var t=p(e.currentTarget).closest(".media-folder_items").find(".media-folder_name"),i=t.children("span").text();t.hide().siblings(".media-folder_name_edit_wrap").show().children(".media-folder_name_edit").val(i).focus().select(),e.preventDefault()},editPrivacyDocument:function(e){e.preventDefault(),p(e.currentTarget).closest("#media-folder-document-data-table").find(".media-folder_visibility .media-folder_details__bottom span").show().siblings("select").addClass("hide");var t=p(e.currentTarget).closest(".media-folder_items").find(".media-folder_visibility");t.find(".media-folder_details__bottom span").hide().siblings("select").removeClass("hide"),t.find(".media-folder_details__bottom span").hide().siblings("select").val(p(e.currentTarget).attr("data-privacy")),t.find(".media-folder_details__bottom #bb-folder-privacy").attr("data-privacy",p(e.currentTarget).attr("data-privacy")),this.privacySelectorSelect=t.find(".media-folder_details__bottom span").hide().siblings("select"),this.privacySelectorSpan=t.find(".media-folder_details__bottom span")},editPrivacyDocumentSubmit:function(e){e=p(e.currentTarget);"true"==e.attr("data-mouseup")?(e.attr("data-mouseup","false"),e.addClass("hide").siblings("span").show().text(e.find("option:selected").text())):e.attr("data-mouseup","true")},renameDocumentSubmit:function(t){var i=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name_edit"),a=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > span"),o=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name"),e=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-id").attr("data-item-id"),d=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-attachment-id").attr("data-item-id"),s=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-type").attr("data-item-id"),n=i.val().trim(),r="",r=(p(t.currentTarget).closest(".ac-document-list").length?r=/[?\[\]=<>:;,'"&$#*()|~`!{}%+ \/]+/g:p(t.currentTarget).closest(".ac-folder-list").length&&(r=/[\\/?%*:|"<>]+/g),r.exec(n)),r=Boolean(r);if(r?i.addClass("error"):i.removeClass("error"),p(t.currentTarget).closest(".ac-document-list").length&&(-1!=n.indexOf("\\\\")||r?i.addClass("error"):i.removeClass("error")),!p(t.currentTarget).hasClass("name_edit_cancel")&&27!=t.keyCode||(i.removeClass("error"),i.parent().hide().siblings(".media-folder_name").show()),p(t.currentTarget).hasClass("name_edit_save")||13==t.keyCode){if(r)return;i.parent().addClass("submitting").append(''),p.ajax({url:BP_Nouveau.ajaxurl,type:"post",data:{action:"document_update_file_name",document_id:e,attachment_document_id:d,document_type:s,name:n,_wpnonce:BP_Nouveau.nonces.media},success:function(e){e.success?void 0!==e.data.document&&0 ');e.parents("li").each(function(e,t){t=p(t).children("span").clone();i.prepend("",t)}),p(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||p(a).find(".breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0
p(a).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),p(this).hasClass("selected")&&!p(this).hasClass("disabled")?(p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-destination").val(""),p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-selected-id").val("0"),p(a).find(".location-folder-list li.is_active").length?p(a).find(".bb-folder-selected-id").val(p(a).find(".location-folder-list li.is_active").attr("data-id")):p(a).find(".bb-folder-selected-id").val("0")):(p(this).closest(".location-folder-list-wrap-main").find(".location-folder-list li span").removeClass("selected"),p(this).addClass("selected"),p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-destination").val(p(this).text()),p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-selected-id").val(p(this).parent().attr("data-id"))),p(this).closest(".location-folder-list-wrap").find(".location-folder-title").text(p(this).siblings("span").text()).siblings(".location-folder-back").css("display","inline-block"),p(this).siblings("ul").show().siblings("span, i").hide().parent().siblings().hide(),p(this).siblings("ul").children("li").show().children("span,i").show(),p(this).closest(".is_active").removeClass("is_active"),p(a).find("li.is_active").removeClass("is_active"),p(this).parent().addClass("is_active"),p(a).find(".bb-folder-selected-id").val(p(a).find(".location-folder-list li.is_active").attr("data-id")),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").each(function(){p(this).show()}),o===p(a).find(".breadcrumbs-append-ul-li .item > span[data-id]").last().attr("data-id")&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled")),setTimeout(function(){p(a).closest(".bb-activity-media-wrap").find(".bb-activity-media-elem.document-activity").attr("data-parent-id")===(p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").prev():p(a).find(".breadcrumbs-append-ul-li .item > span:last-child")).attr("id")&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled"))},100)}),p(document).on("click",a+" .breadcrumbs-append-ul-li .item span",function(e){var t,i;p(this).parent().hasClass("is-disabled")||p(this).hasClass("more_options")||(t=p(e.currentTarget).attr("data-id"),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(p(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),p(a).find(".bb-folder-selected-id").val(t),p(a).find(".location-folder-list li").hide(),p(a).find(".location-folder-list li.is_active").removeClass("is_active"),p(a).find(".location-folder-list li > span.selected").removeClass("selected"),p(a).find('.location-folder-list li[data-id="'+t+'"]').addClass("is_active").children("span").addClass("selected"),p(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),p(a).find(".location-folder-list li.is_active").children("ul").length&&!p(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):p(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?p(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),"0"===t&&(p(a).find(".location-folder-list").children("li").show().children("span,i").show(),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(BP_Nouveau.media.target_text),p(a).find(".location-folder-back").hide()),p(e.currentTarget).nextAll().remove(),o===p(a).find(".breadcrumbs-append-ul-li .item > span[data-id]").last().attr("data-id")&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled")),e=p(a).find(".location-folder-list .is_active > span"),i=p(''),e.parents("li").each(function(e,t){t=p(t).children("span").clone();i.prepend("",t)}),p(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")),0===p(a).find('.breadcrumbs-append-ul-li .breadcrumb .item > span[data-id="'+t+'"]').length&&p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item").append(p(a).find('.location-folder-list li[data-id="'+t+'"]').children("span").clone()),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||p(a).find(".breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(a).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),p(a).find(".bb-folder-selected-id").val(t))})),p(a).find(".location-folder-list li").each(function(){p(this).children("ul").parent().addClass("has-ul").append('')}),p(a).hasClass("bp-media-move-folder")&&(p(a).find(".location-folder-list li>span").removeClass("is-disabled"),p(a).find('.location-folder-list li>span[id="'+p(a).find(".bp-folder-move").attr("id")+'"]').parent().addClass("is-disabled")),e=p(a).find(".bp-folder-move").attr("id"),0==p(a).find('.location-folder-list li[data-id="'+e+'"]').siblings().length&&p(a).find('.location-folder-list li[data-id="'+e+'"]').parent("ul").addClass("no-folder-list a"),o&&(p(a).find(".location-folder-list li").hide(),p(a).find(".location-folder-list li.is_active").removeClass("is_active"),p(a).find('.location-folder-list li[data-id="'+o+'"]').addClass("is_active"),p(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),p(a).find(".location-folder-list li.is_active").children("ul").length&&!p(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):p(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?p(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(p(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),p(a).find(".bb-folder-selected-id").val(p(a).find(".location-folder-list li.is_active").attr("data-id")),p(a).find('.location-folder-list li[data-id="'+e+'"]').children().hide()),"0"===o&&(p(a).find(".location-folder-list").children("li").show(),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(BP_Nouveau.media.target_text),p(a).find(".location-folder-back").hide()),setTimeout(function(){var e=0,e=(p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").prev():p(a).find(".breadcrumbs-append-ul-li .item > span:last-child")).attr("id");o===parseInt(e)&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled"))},100),e=p(a).find(".location-folder-list .is_active > span"),i=p(''),e.parents("li").each(function(e,t){t=p(t).children("span").clone();i.prepend("",t)}),p(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")))},clearFolderLocationUI:function(e){e=jQuery(e.currentTarget).closest(".has-folderlocationUI");0 ul > li.selected").data("bp-scope")||bp.Nouveau.inject("#media-stream ul.media-list",e.data.media,"prepend"),p("#buddypress #bp-media-single-album").length||(e.data.media_personal_count&&(0 '+e.data.media_personal_count+" "+t)):p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").length?p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count):"1"===BP_Nouveau.bb_enable_content_counts&&((a=document.createElement("span")).setAttribute("class","count"),o=document.createTextNode(e.data.media_personal_count),a.appendChild(o),p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a").append(a))),e.data.media_group_count&&(0
'+e.data.media_group_count+" "+t)):p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").length?p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count):"1"===BP_Nouveau.bb_enable_content_counts&&((o=document.createElement("span")).setAttribute("class","count"),a=document.createTextNode(e.data.media_group_count),o.appendChild(a),p("#buddypress").find(".bp-wrap .users-nav ul li#photos-groups-li a").append(o))),"yes"===BP_Nouveau.media.is_media_directory&&(0
ul > li.selected").data("bp-scope"))?a=e.data.media_all_count:"personal"===o?a=e.data.media_personal_count:"groups"===o&&(a=e.data.media_group_count),t=BP_Nouveau.dir_labels.hasOwnProperty("media")?1===a?BP_Nouveau.dir_labels.media.singular:BP_Nouveau.dir_labels.media.plural:"",p("#buddypress .bb-item-count").html(''+a+" "+t)):(p("#buddypress").find(".media-type-navs ul.media-nav li#media-all a span.count").text(e.data.media_all_count),p("#buddypress").find(".media-type-navs ul.media-nav li#media-personal a span.count").text(e.data.media_personal_count),p("#buddypress").find(".media-type-navs ul.media-nav li#media-groups a span.count").text(e.data.media_group_count)))),void 0!==e.data.album_total_count&&s.updateAlbumCounts(e.data);for(var i=0;i
"),p(".modal-container #bb-folder-privacy").addClass("new-folder-create-privacy"),p(document).find(".open-popup .error").hide()},savePrivacy:function(e){var t,i,a,o=p(e.currentTarget);if(e.preventDefault(),o.hasClass("new-folder-create-privacy"))return!1;t=parseInt(o.data("item-id")),i=o.data("item-type"),a=o.val(),e=p(e.currentTarget).find("option:selected").text(),this.privacySelectorSelect.addClass("hide"),this.privacySelectorSpan.text(""),this.privacySelectorSpan.text(e),this.privacySelectorSpan.show(),0").addClass("media-list item-list bp-list bb-photo-list grid")),0 ").addClass("display")),p("#media-stream div").attr("id","media-folder-document-data-table"),p(".bb-photos-actions").show()),p(".document-data-table-head").length?"yes"===BP_Nouveau.media.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(p(document).find("li#document-personal a").trigger("click"),p(document).find("li#document-personal").trigger("click")):r&&bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"):location.reload(!0),p("#bp-media-post-content").val("");for(var t=0;t
"),p(".modal-container #bb-folder-privacy").addClass("new-folder-create-privacy"),p(document).find(".open-popup .error").hide()},createAlbumInPopup:function(e){e.preventDefault();var t=parseInt(p(document).find(".open-popup .bb-album-selected-id").val()),i=p(document).find(".open-popup .bb-album-create-from").val();0]+/g.exec(e.val())),d=Boolean(d);if(""===p.trim(e.val())||d)return e.addClass("error"),!1;if(e.removeClass("error"),!a.group_id&&""===p.trim(o.val()))return o.addClass("error"),!1;o.removeClass("error"),i.prop("disabled",!0).addClass("loading");d={action:"document_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:e.val().trim(),privacy:o.val(),album_id:a.current_folder,group_id:a.current_group_id};p(".bb-single-album-header .bp-feedback").remove(),p("#boss-media-create-album-popup .bp-feedback").remove(),p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:d,success:function(e){setTimeout(function(){i.prop("disabled",!1)},500),e.success?(a.closeFolderUploader(t),p(".document-data-table-head").length?"yes"===BP_Nouveau.media.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(p(document).find("li#document-personal a").trigger("click"),p(document).find("li#document-personal").trigger("click")):(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()):location.reload(!0)):alert(e.data.feedback.replace("'","'"))}})},saveChildFolder:function(t){var e=p(t.currentTarget),i=this,a=p("#bp-media-create-child-folder #bb-album-child-title"),o=(t.preventDefault(),/[\\/?%*:|"<>]+/g.exec(a.val())),o=Boolean(o);if(""===p.trim(a.val())||o)return a.addClass("error"),!1;a.removeClass("error"),e.prop("disabled",!0).addClass("loading");o={action:"document_child_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:a.val(),folder_id:i.current_folder,group_id:i.current_group_id};p(".bb-single-album-header .bp-feedback").remove(),p("#boss-media-create-album-popup .bp-feedback").remove(),p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:o,success:function(e){e.success?(i.closeChildFolderUploader(t),location.reload(!0)):alert(e.data.feedback.replace("'","'"))}})},renameChildFolder:function(e){e.preventDefault();var t=p(e.currentTarget),i=this,e=p("#bp-media-edit-child-folder #bb-album-child-title"),a=p("#bp-media-edit-child-folder #bb-folder-privacy"),o=this.currentTargetParent,d=/[\\/?%*:|"<>]+/g.exec(e.val()),d=Boolean(d);if(""===p.trim(e.val())||d)return e.addClass("error"),!1;e.removeClass("error"),t.prop("disabled",!0).addClass("loading");d={action:"document_edit_folder",_wpnonce:BP_Nouveau.nonces.media,title:e.val(),privacy:a.val(),id:o,group_id:i.current_group_id};p(".bb-single-album-header .bp-feedback").remove(),p("#boss-media-create-album-popup .bp-feedback").remove(),p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:d,success:function(e){setTimeout(function(){t.prop("disabled",!1)},500),e.success?window.location.reload(!0):i.current_folder?p("#bp-media-single-album").prepend(e.data.feedback):p("#boss-media-create-album-popup .bb-model-header").after(e.data.feedback)}})},deleteAlbum:function(t){if(t.preventDefault(),!this.album_id)return!1;if(!confirm(BP_Nouveau.media.i18n_strings.album_delete_confirm))return!1;p(t.currentTarget).prop("disabled",!0);var e={action:"media_album_delete",_wpnonce:BP_Nouveau.nonces.media,album_id:this.album_id,group_id:this.group_id};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){e.success?window.location.href=e.data.redirect_url:(alert(BP_Nouveau.media.i18n_strings.album_delete_error),p(t.currentTarget).prop("disabled",!1))}})},deleteFolder:function(t){if(t.preventDefault(),!BP_Nouveau.media.current_folder)return!1;if(!confirm(BP_Nouveau.media.i18n_strings.folder_delete_confirm))return!1;p(t.currentTarget).prop("disabled",!0);var e={action:"document_folder_delete",_wpnonce:BP_Nouveau.nonces.media,folder_id:BP_Nouveau.media.current_folder,group_id:BP_Nouveau.media.current_group_id};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){e.success?window.location.href=e.data.redirect_url:(alert(BP_Nouveau.media.i18n_strings.folder_delete_error),p(t.currentTarget).prop("disabled",!1))}})},addMediaIdsToGroupMessagesForm:function(){p("#bp_group_messages_media").length&&p("#bp_group_messages_media").val(JSON.stringify(this.dropzone_media))},addDocumentIdsToGroupMessagesForm:function(){p("#bp_group_messages_document").length&&p("#bp_group_messages_document").val(JSON.stringify(this.dropzone_media))},addVideoIdsToGroupMessagesForm:function(){p("#bp_group_messages_video").length&&p("#bp_group_messages_video").val(JSON.stringify(this.dropzone_media))},injectMedias:function(t){var i,a,e,o=bp.Nouveau.getStorage("bp-media"),d=o.scope||null,o=o.filter||null;p(t.currentTarget).hasClass("load-more")&&(i=+Number(this.current_page)+1,a=this,e="",t.preventDefault(),p(t.currentTarget).find("a").first().addClass("loading"),p("#buddypress .dir-search input[type=search]").length&&(e=p("#buddypress .dir-search input[type=search]").val()),bp.Nouveau.objectRequest({object:"media",scope:d,filter:o,search_terms:e,page:i,method:"append",target:"#buddypress [data-bp-list] ul.bp-list"}).done(function(e){!0===e.success&&(p(t.currentTarget).remove(),a.current_page=i,jQuery(window).scroll())}))},injectDocuments:function(e){var t,i,a,o=bp.Nouveau.getStorage("bp-document"),d="",s="",n=o.scope||null,r=o.filter||null,l=p(e.currentTarget);l.hasClass("load-more")&&(t=+Number(this.current_page)+1,i=this,a="",e.preventDefault(),l.find("a").first().addClass("loading"),p("#buddypress .dir-search input[type=search]").length&&(a=p("#buddypress .dir-search input[type=search]").val()),s=this.order_by&&this.sort_by?(d=this.sort_by,this.order_by):void 0!==o.extras?(d=o.extras.sort,o.extras.orderby):(d="ASC","title"),bp.Nouveau.objectRequest({object:"document",scope:n,filter:r,search_terms:a,page:t,method:"append",target:"#buddypress [data-bp-list] div#media-folder-document-data-table",order_by:s,sort:d}).done(function(e){!0===e.success&&(l.parent(".pager").remove(),i.current_page=t,jQuery(window).scroll())}))},sortDocuments:function(e){var t=p(e.currentTarget),i=t.data("target"),a="",o="date_created";t.attr("class");switch(i){case"name":o="title";break;case"modified":o="date_modified";break;case"visibility":o="privacy";break;case"group":o="group_id"}t.hasClass("asce")?t.removeClass("asce"):t.addClass("asce");var i=t.hasClass("asce")?"DESC":"ASC",t=(bp.Nouveau.getStorage("bp-document"),{}),t=(t.orderby=o,t.sort=i,"group"!==o&&bp.Nouveau.setStorage("bp-document","extras",t),bp.Nouveau.getStorage("bp-document")),d=t.scope||null,t=t.filter||null;p(e.currentTarget);p("#buddypress .bp-dir-search-form input[type=search]").length&&(a=p("#buddypress .bp-dir-search-form input[type=search]").val()),this.sort_by=i,this.order_by=o,this.current_page=1,bp.Nouveau.objectRequest({object:"document",scope:d,filter:t,search_terms:a,page:1,order_by:o,sort:i,method:"reset",target:"#buddypress [data-bp-list]"}).done()},documentPopupNavigate:function(e){e.preventDefault();var e=p(e.currentTarget),t=e.closest(".bb-field-steps"),i=0==e.closest(".bp-document-listing").length?"#bb-album-child-title":"#bb-album-title";e.closest(".document-options").length&&(i="#bb-album-title"),e.hasClass("bb-field-steps-next")&&""==t.find(i).val().trim()?t.find(i).addClass("error"):(t.find(i).removeClass("error"),t.slideUp(200).siblings(".bb-field-steps").slideDown(200))},uploadDocumentNavigate:function(e){e.preventDefault();var e=p(e.currentTarget),t=p(e).closest("#bp-media-uploader");p(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-document-submit, #bp-media-document-prev, .bp-document-open-create-popup-folder, #bb-document-privacy").show(),0!==Number(p(t).find(".bb-folder-selected-id"))&&p(t).find(".location-folder-list li.is_active").length&&p(t).find(".location-folder-list").scrollTop(p(t).find(".location-folder-list li.is_active").offset().top-p(t).find(".location-folder-list").offset().top),p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(t).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))})):(p(e).hide(),t.find("#bp-media-document-prev, .bp-document-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-folder").length&&p("#bb-document-privacy").hide())},uploadMediaNavigate:function(e){e.preventDefault();var e=p(e.currentTarget),t=p(e).closest(".bp-media-photo-uploader");p(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-submit, #bp-media-prev, .bp-media-open-create-popup-folder.create-album").show(),t.find("#bb-media-privacy").show(),0!==Number(p(t).find(".bb-album-selected-id"))&&p(t).find(".location-album-list li.is_active").length&&p(t).find(".location-album-list").scrollTop(p(t).find(".location-album-list li.is_active").offset().top-p(t).find(".location-album-list").offset().top)):(p(e).hide(),t.find("#bp-media-prev, .bp-media-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-album").length&&p("#bb-media-privacy").hide())},appendMedia:function(t){var i,a,e,o=bp.Nouveau.getStorage("bp-media"),d=o.scope||null,o=o.filter||null;p(t.currentTarget).hasClass("load-more")&&(i=+Number(this.current_page_existing_media)+1,a=this,e="",t.preventDefault(),p(t.currentTarget).find("a").first().addClass("loading"),p("#buddypress .dir-search input[type=search]").length&&(e=p("#buddypress .dir-search input[type=search]").val()),bp.Nouveau.objectRequest({object:"media",scope:d,filter:o,search_terms:e,page:i,method:"append",caller:"bp-existing-media",target:".bp-existing-media-wrap ul.bp-list"}).done(function(e){!0===e.success&&(p(t.currentTarget).remove(),a.current_page_existing_media=i,jQuery(window).scroll())}))},appendAlbums:function(t){var i=+Number(this.current_page_albums)+1,a=this,e=(t.preventDefault(),p(t.currentTarget).find("a").first().addClass("loading"),{action:"media_albums_loader",_wpnonce:BP_Nouveau.nonces.media,page:i});p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){!0===e.success&&(p(t.currentTarget).remove(),p("#albums-dir-list ul.bb-albums-list").fadeOut(100,function(){p("#albums-dir-list ul.bb-albums-list").append(e.data.albums),p(this).fadeIn(100)}),a.current_page_albums=i)}})},toggleSubmitMediaButton:function(){var e=p("#bp-media-submit"),t=p("#bp-media-add-more");"bp-dropzone-content"===this.current_tab?this.dropzone_obj.getAcceptedFiles().length?(e.show(),t.show()):(e.hide(),t.hide()):"bp-existing-media-content"===this.current_tab&&(p('.bp-existing-media-wrap .bb-media-check-wrap [name="bb-media-select"]:checked').length?e.show():e.hide(),t.hide())},playVideo:function(e){e.preventDefault();var t=p(e.currentTarget).find("video").get(0),e=p(e.currentTarget).find(".gif-play-button");1==t.paused?(t.play().catch(function(e){console.debug("GIF play failed:",e)}),e.hide()):(t.pause(),e.show())},isElementInScrollableContainer:function(e){var t=p(e),e=e.getBoundingClientRect(),i=t.closest("#bp-message-thread-list");return(i=(i=i.length?i:t.closest(".bb-modal-activity-body")).length?i:t.closest(".bb-media-model-container .activity-list .activity-item")).length?(i=i[0].getBoundingClientRect(),e.bottom>i.top&&e.top i.left&&e.left '),p(t).text());return p(t).text(BP_Nouveau.media.copy_to_clip_board_text),p("#"+e).val(p(t).attr("href")),p("#"+e).select(),document.execCommand("copy"),setTimeout(function(){p(t).text(i)},2e3),!1},fileActivityActionButton:function(e){e.preventDefault(),p(e.currentTarget).parent().hasClass("copy_download_file_url")||(p(e.currentTarget).closest(".bb-activity-media-elem").toggleClass("is-visible").siblings().removeClass("is-visible").closest(".activity-item").siblings().find(".bb-activity-media-elem").removeClass("is-visible"),p(e.currentTarget).closest(".bb-activity-media-elem").find(".bb_more_dropdown").toggleClass("open").closest(".bb-activity-media-elem").siblings().find(".bb_more_dropdown").removeClass("open").closest(".activity-item").siblings().find(".bb-activity-media-elem .bb_more_dropdown").removeClass("open"),p("body").addClass("document_more_option_open"),p(e.currentTarget).closest(".bb-activity-media-elem").length<1&&(p(e.currentTarget).closest(".bb-photo-thumb").toggleClass("is-visible").parent().siblings().find(".bb-photo-thumb").removeClass("is-visible").removeClass("is-visible"),p(e.currentTarget).closest(".bb-photo-thumb").find(".bb_more_dropdown").toggleClass("open").closest(".bb-photo-thumb").parent().siblings().find(".bb-photo-thumb .bb_more_dropdown").removeClass("open")),"a"!=e.currentTarget.tagName.toLowerCase())||p(e.currentTarget).hasClass("document-action_more")||p(e.currentTarget).hasClass("media-action_more")||(p(e.currentTarget).closest(".bb-activity-media-elem").removeClass("is-visible").find(".bb_more_dropdown").removeClass("open"),p(e.currentTarget).closest(".bb-photo-thumb").removeClass("is-visible").find(".bb_more_dropdown").removeClass("open"))},toggleFileActivityActionButton:function(e){var t;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),!0===e.altKey||!0===e.metaKey||p(t).hasClass("document-action_more")||p(t).parent().hasClass("document-action_more")||p(t).hasClass("media-folder_action__anchor")||p(t).parent().hasClass("media-folder_action__anchor")||p(t).hasClass("media-action_more")||p(t).parent().hasClass("media-action_more")||p(t).hasClass("video-action_more")||p(t).parent().hasClass("video-action_more")?e:(p(".bb-activity-media-elem.is-visible").removeClass("is-visible"),p(".media-folder_items.is-visible").removeClass("is-visible"),p(".bb-photo-thumb.is-visible").removeClass("is-visible"),p(".bb-item-thumb.is-visible").removeClass("is-visible"),p(".bb-activity-video-elem.is-visible").removeClass("is-visible"),p(".video-action-wrap.item-action-wrap.is-visible").removeClass("is-visible"),p(".video-action-wrap .bb_more_dropdown").removeClass("open"),p(".bb-activity-media-elem .bb_more_dropdown").removeClass("open"),p(".bb-photo-thumb .bb_more_dropdown").removeClass("open"),p(".media-folder_items .bb_more_dropdown").removeClass("open"),void p("body").removeClass("document_more_option_open video_more_option_open item_more_option_open"))},toggleCodePreview:function(e){e.preventDefault(),p(e.currentTarget).closest(".document-activity").toggleClass("code-full-view")},documentCodeMirror:function(){p(".document-text:not(.loaded)").each(function(){var e=p(this),t=e.attr("data-extension"),i=e.attr("data-extension");"html"!=t&&"htm"!=t||(i="text/html"),"js"==t?CodeMirror(e[0],{value:e.find(".document-text-file-data-hidden").val(),lineNumbers:!0,theme:"default",readOnly:!0,lineWrapping:!0}):CodeMirror(e[0],{value:e.find(".document-text-file-data-hidden").val(),mode:i,lineNumbers:!0,theme:"default",readOnly:!0,lineWrapping:!0}),e.addClass("loaded"),150 '+e+" "+t)):(t=p(".single-screen-navs.groups-nav").find("ul li#albums-groups-li"),0 '+e+"")))}},bp.Nouveau.Media.Theatre={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){this.bodySelector=p("body"),this.medias=[],this.documents=[],this.current_media=!1,this.current_document=!1,this.current_index=0,this.current_document_index=0,this.is_open_media=!1,this.is_open_document=!1,this.nextLink=p(".bb-next-media"),this.nextDocumentLink=p(".bb-next-document"),this.previousDocumentLink=p(".bb-prev-document"),this.previousLink=p(".bb-prev-media"),this.activity_ajax=!1,this.group_id=void 0!==BP_Nouveau.media.group_id&&BP_Nouveau.media.group_id,this.manage_media=void 0!==BP_Nouveau.media.can_manage_media&&BP_Nouveau.media.can_manage_media,this.manage_document=void 0!==BP_Nouveau.media.can_manage_document&&BP_Nouveau.media.can_manage_document},addListeners:function(){p(document).on("click",".bb-open-media-theatre",this.openTheatre.bind(this)),p(document).on("click",".bb-open-document-theatre",this.openDocumentTheatre.bind(this)),p(document).on("click",".document-detail-wrap-description-popup",this.openDocumentTheatre.bind(this)),p(document).on("click",".bb-close-media-theatre",this.closeTheatre.bind(this)),p(document).on("click",".bb-close-document-theatre",this.closeDocumentTheatre.bind(this)),p(document).on("click",".bb-prev-media",this.previous.bind(this)),p(document).on("click",".bb-next-media",this.next.bind(this)),p(document).on("click",".bb-prev-document",this.previousDocument.bind(this)),p(document).on("click",".bb-next-document",this.nextDocument.bind(this)),p(document).on("bp_activity_ajax_delete_request",this.activityDeleted.bind(this)),p(document).on("click","#bb-media-model-container .media-privacy>li",this.mediaPrivacyChange.bind(this)),p(document).on("click","#bb-media-model-container .document-privacy>li",this.documentPrivacyChange.bind(this)),p(document).on("click","#bb-media-model-container .bb-media-section span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),p(document).on("click","#bb-media-model-container .bb-document-section span.privacy",bp.Nouveau,this.toggleDocumentPrivacyDropdown.bind(this)),p(document).on("click",".bp-add-media-activity-description",this.openMediaActivityDescription.bind(this)),p(document).on("click","#bp-activity-description-new-reset",this.closeMediaActivityDescription.bind(this)),p(document).on("keyup",".bp-edit-media-activity-description #add-activity-description",this.MediaActivityDescriptionUpdate.bind(this)),p(document).on("click","#bp-activity-description-new-submit",this.submitMediaActivityDescription.bind(this)),p(document).click(this.togglePopupDropdown),document.addEventListener("keyup",this.checkPressedKeyDocuments.bind(this)),document.addEventListener("keyup",this.checkPressedKey.bind(this))},checkPressedKey:function(e){var t=this;if(e=e||window.event,!t.is_open_media)return!1;var i=p(e.target).hasClass("ac-input")||"add-activity-description"===p(e.target).attr("id");switch(e.keyCode){case 27:t.closeTheatre(e);break;case 37:if(void 0===t.medias[t.current_index-1]||i)return!1;t.previous(e);break;case 39:if(void 0===t.medias[t.current_index+1]||i)return!1;t.next(e)}},checkPressedKeyDocuments:function(e){e=e||window.event;var t=this;if(!t.is_open_document)return!1;var i=p(e.target).hasClass("ac-input")||"add-activity-description"===p(e.target).attr("id");switch(e.keyCode){case 27:t.closeDocumentTheatre(e);break;case 37:if(void 0===t.documents[t.current_document_index-1]||i)return!1;t.previousDocument(e);break;case 39:if(void 0===t.documents[t.current_document_index+1]||i)return!1;t.nextDocument(e)}},openTheatre:function(e){e.preventDefault();var e=p(e.currentTarget),t=this;if(e.closest("#bp-existing-media-content").length)return!1;t.setupGlobals(),t.setMedias(e),i=e.data("id"),e.data("activity-id"),t.setCurrentMedia(i),t.showMedia(),t.navigationCommands(),t.getParentActivityHtml(e),t.getMediasDescription(),p(".bb-media-model-wrapper.document").hide();var i=document.getElementById(p(".bb-media-model-wrapper.video video").attr("id"));i&&i.pause(),p(".bb-media-model-wrapper.video").hide(),p(".bb-media-model-wrapper.media").show(),bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay"),t.is_open_media=!0,t.bodySelector.addClass("media-modal-open"),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)},getParentActivityHtml:function(e){var t=p("#hidden_parent_id").val(),e=e.closest(".bb-media-model-wrapper").find("#bb-media-model-container .activity-list li.activity-item").data("bp-activity-id");parseInt(t)===parseInt(e)&&(e=p('#bb-media-model-container [data-bp-activity-id="'+t+'"]'),p('[data-bp-activity-id="'+t+'"] > .activity-state').html(p(e).find(".activity-state").html()),p('[data-bp-activity-id="'+t+'"] > .activity-meta').html(p(e).find(".activity-meta").html()),p('[data-bp-activity-id="'+t+'"] > .activity-comments').html(p(e).find(".activity-comments").html())),p("#hidden_parent_id").length&&p("#hidden_parent_id").remove()},getMediasDescription:function(){var e=this,t=(p(".bb-media-info-section .activity-list").addClass("loading").html(''),0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_media.activity_id+'"] .activity-comments'));t.length&&(t=t.find("#ac-form-"+e.current_media.activity_id),e.current_media.parent_activity_comments=!0,t.remove()),!0===e.current_media.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"media_get_media_description",id:e.current_media.id,attachment_id:e.current_media.attachment_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success?(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.description),p(".bb-media-info-section:visible").show(),bp.Nouveau.Media.Theatre.syncPinPostIconToTheatre(),p(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10)):p(".bb-media-info-section.media").hide()}})},openDocumentTheatre:function(e){e.preventDefault();var t=p(e.currentTarget),i=this;if(t.closest("#bp-existing-document-content").length)return!1;t.closest(".document.document-theatre").length&&i.closeDocumentTheatre(e),a=t.data("id"),i.setupGlobals(),i.setDocuments(t),i.setCurrentDocument(a),i.showDocument(),i.navigationDocumentCommands(),i.getParentActivityHtml(t),i.getDocumentsDescription(),-1!==p.inArray(i.current_document.extension,BP_Nouveau.document.mp3_preview_extension.split(","))&&p(e.currentTarget).closest(".bb-activity-media-elem.document-activity").length&&p(e.currentTarget).closest(".bb-activity-media-elem.document-activity").find(".document-audio-wrap").length&&p(e.currentTarget).closest(".bb-activity-media-elem.document-activity").find(".document-audio-wrap audio")[0].pause(),p(".bb-media-model-wrapper.media").hide(),p(".bb-media-model-wrapper.document").show();var a=document.getElementById(p(".bb-media-model-wrapper.video video").attr("id"));a&&(a.pause(),a.src=""),p(".bb-media-model-wrapper.video").hide(),i.is_open_document=!0,i.bodySelector.addClass("document-modal-open"),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay")},500)},resetRemoveActivityCommentsData:function(){var e,t=this,i=!1,a=!1,o=!1,d=!1,s=!1,n=!1;t.current_media.parent_activity_comments&&((i=(d=p('.bb-media-model-wrapper.media [data-bp-activity-id="'+t.current_media.activity_id+'"]')).find(".activity-comments")).length&&(e=i.find("#ac-form-"+t.current_media.activity_id),this.purgeEditActivityForm(e),e.find("#ac-input-"+t.current_media.activity_id).html(""),e.removeClass("has-content has-gif has-media").addClass("root"),i.append(e),e.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(t.current_media.activity_id),i.find(".acomment-display").removeClass("display-focus"),i.find(".comment-item").removeClass("comment-item-focus"),s=i.html(),n=i.attr("class"),i.remove(),(i=p('[data-bp-activity-id="'+t.current_media.activity_id+'"] .activity-comments')).length)&&(i.attr("class",n),0===i.find("#ac-form-"+t.current_media.activity_id).length)&&(i.append(e),i.children("form").removeClass("events-initiated").addClass("not-initialized")),(o=d.find(".activity-state")).length&&(s=o.html(),n=o.attr("class"),o.remove(),(o=p('[data-bp-activity-id="'+t.current_media.activity_id+'"] .activity-state')).length)&&(o.html(s),o.attr("class",n)),(a=d.find(".activity-meta")).length&&(s=a.html(),n=a.attr("class"),a.remove(),(a=p('[data-bp-activity-id="'+t.current_media.activity_id+'"] > .activity-meta')).length)&&(a.html(s),a.attr("class",n)),d.remove()),t.current_document.parent_activity_comments&&((i=(d=p('.bb-media-model-wrapper.document [data-bp-activity-id="'+t.current_document.activity_id+'"]')).find(".activity-comments")).length&&(e=i.find("#ac-form-"+t.current_document.activity_id),this.purgeEditActivityForm(e),e.find("#ac-input-"+t.current_document.activity_id).html(""),e.removeClass("has-content has-gif has-media").addClass("root"),i.append(e),e.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(t.current_document.activity_id),i.find(".acomment-display").removeClass("display-focus"),i.find(".comment-item").removeClass("comment-item-focus"),s=i.html(),n=i.attr("class"),i.remove(),(i=p('[data-bp-activity-id="'+t.current_document.activity_id+'"] .activity-comments')).length)&&(i.attr("class",n),0===i.find("#ac-form-"+t.current_document.activity_id).length&&(i.append(e),i.children("form").removeClass("events-initiated").addClass("not-initialized")),i.find(".document-text.loaded").removeClass("loaded").find(".CodeMirror").remove(),jQuery(window).scroll()),(o=d.find(".activity-state")).length&&(s=o.html(),n=o.attr("class"),o.remove(),(o=p('[data-bp-activity-id="'+t.current_document.activity_id+'"] .activity-state')).length)&&(o.html(s),o.attr("class",n)),(a=d.find(".activity-meta")).length&&(s=a.html(),n=a.attr("class"),a.remove(),(a=p('[data-bp-activity-id="'+t.current_document.activity_id+'"] > .activity-meta')).length)&&(a.html(s),a.attr("class",n)),d.remove()),bp.Nouveau.reportPopUp(),bp.Nouveau.reportActions()},closeTheatre:function(e){e.preventDefault();var t=this,e=p(e.currentTarget);if(p(e).closest(".bb-media-model-wrapper").hasClass("video-theatre"))return!1;p(".bb-media-model-wrapper.media .bb-media-section").find("img").attr("src",""),p(".bb-media-model-wrapper.video .bb-media-section").find("video").length&&videojs(p(".bb-media-model-wrapper.video .bb-media-section").find("video").attr("id")).reset(),p(".bb-media-model-wrapper").hide(),t.is_open_media=!1,t.syncPinPostActivityOnCloseTheatre(e),t.resetRemoveActivityCommentsData(),t.current_media=!1,t.getParentActivityHtml(e),t.bodySelector.removeClass("media-modal-open")},closeDocumentTheatre:function(e){e.preventDefault();var t=this,i=p(document).find(".document-theatre");i.find(".bb-media-section").removeClass("bb-media-no-preview").find(".document-preview").html(""),p(".bb-media-info-section.document").show(),i.hide(),t.is_open_document=!1,t.resetRemoveActivityCommentsData(),t.current_document=!1,t.getParentActivityHtml(p(e.currentTarget)),t.bodySelector.removeClass("document-modal-open")},setMedias:function(e){var t=p(".bb-open-media-theatre"),i=0;if(void 0!==(t=p("body").hasClass("activity")?p(e).closest(".bb-activity-media-wrap").find(".bb-open-media-theatre"):t))for(this.medias=[],i=0;i
"),p(".modal-container #bb-folder-privacy").addClass("new-folder-create-privacy"),p(document).find(".open-popup .error").hide()},savePrivacy:function(e){var t,i,a,o=p(e.currentTarget);if(e.preventDefault(),o.hasClass("new-folder-create-privacy"))return!1;t=parseInt(o.data("item-id")),i=o.data("item-type"),a=o.val(),e=p(e.currentTarget).find("option:selected").text(),this.privacySelectorSelect.addClass("hide"),this.privacySelectorSpan.text(""),this.privacySelectorSpan.text(e),this.privacySelectorSpan.show(),0'),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html(" "+i+'
'),o.find(".bb-document-section .document-preview .document-text").attr("data-extension",d),t=o.find(".bb-document-section .document-preview .document-text textarea"),"html"===d||"htm"===d?t.val(s):t.html(s),setTimeout(function(){bp.Nouveau.Media.documentCodeMirror()},1e3)):-1!==p.inArray(e.current_document.extension,BP_Nouveau.document.mp3_preview_extension.split(","))?(o.find(".bb-document-section .document-preview").html(''),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html('')):-1!==p.inArray("."+e.current_document.extension,BP_Nouveau.video.video_type.split(","))?(o.find(".bb-document-section").addClass("bb-video-preview"),o.find(".bb-document-section .document-preview").html(''),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),"mov"===e.current_document.extension||"m4v"===e.current_document.extension?o.find(".bb-document-section .document-preview").html(''):o.find(".bb-document-section .document-preview").html(''),p(window).scroll()):e.current_document.full_preview?(o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html("'+i+'
"+i+'
')):(o.find(".bb-document-section").addClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html('")),p(".bb-document-section .bb-document-privacy-wrap"));d.length&&(d.show(),d.parent().show(),d.find("ul.document-privacy li").removeClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",""),(t=d.find("ul.document-privacy").find("li[data-value="+e.current_document.privacy+"]")).addClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",t.text()),d.find(".privacy").removeClass("public").removeClass("loggedin").removeClass("onlyme").removeClass("friends").addClass(e.current_document.privacy),void 0!==BP_Nouveau.activity&&void 0!==e.current_document.activity_id&&0!=e.current_document.activity_id||e.group_id||e.current_document.is_forum||e.current_document.group_id||e.current_document.album_id||!e.can_manage_document||!e.current_document.can_edit||e.current_document.is_message)&&d.parent().hide(),e.navigationDocumentCommands()},next:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.medias[e.current_index+1]?(e.current_index=e.current_index+1,e.current_media.activity_id,e.current_media=e.medias[e.current_index],e.showMedia(),e.getMediasDescription(),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):e.nextLink.hide()},previous:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.medias[e.current_index-1]?(e.current_index=e.current_index-1,e.current_media.activity_id,e.current_media=e.medias[e.current_index],e.showMedia(),e.getMediasDescription(),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):e.previousLink.hide()},nextDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.documents[e.current_document_index+1]?(e.current_document_index=e.current_document_index+1,e.current_document.activity_id,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.nextDocumentLink.hide()},previousDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.documents[e.current_document_index-1]?(e.current_document_index=e.current_document_index-1,e.current_document.activity_id,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.previousDocumentLink.hide()},navigationCommands:function(){var e=this;0==e.current_index&&e.current_index!=e.medias.length-1?(e.previousLink.hide(),e.nextLink.show()):0==e.current_index&&e.current_index==e.medias.length-1?(e.previousLink.hide(),e.nextLink.hide()):e.current_index==e.medias.length-1?(e.previousLink.show(),e.nextLink.hide()):(e.previousLink.show(),e.nextLink.show())},navigationDocumentCommands:function(){var e=this;0==e.current_document_index&&e.current_document_index!=e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.show()):0==e.current_document_index&&e.current_document_index==e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.hide()):e.current_document_index==e.documents.length-1?(e.previousDocumentLink.show(),e.nextDocumentLink.hide()):(e.previousDocumentLink.show(),e.nextDocumentLink.show())},getActivity:function(){var e=this;p(".bb-media-info-section .activity-list").addClass("loading").html(''),void 0!==BP_Nouveau.activity&&e.current_media&&void 0!==e.current_media.activity_id&&0!=e.current_media.activity_id&&!e.current_media.is_forum?(0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_media.activity_id+'"] .activity-comments').length&&(e.current_media.parent_activity_comments=!0),!0===e.current_media.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"media_get_activity",id:e.current_media.activity_id,group_id:_.isUndefined(e.current_media.group_id)?0:e.current_media.group_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success&&(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.activity),p(".bb-media-info-section:visible").show(),jQuery(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10))}})):p(".bb-media-info-section.media").hide()},getDocumentsActivity:function(){var e=this;p(".bb-media-info-section .activity-list").addClass("loading").html(''),void 0!==BP_Nouveau.activity&&e.current_document&&void 0!==e.current_document.activity_id&&0!=e.current_document.activity_id&&!e.current_document.is_forum?(0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_document.activity_id+'"] .activity-comments').length&&(e.current_document.parent_activity_comments=!0),!0===e.current_document.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"document_get_activity",id:e.current_document.activity_id,group_id:_.isUndefined(e.current_document.group_id)?0:e.current_document.group_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success&&(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.activity),p(".bb-media-info-section:visible").show(),jQuery(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10))}})):p(".bb-media-info-section.document").hide()},getDocumentsDescription:function(){var e=this,t=(p(".bb-media-info-section .activity-list").addClass("loading").html(''),0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_document.activity_id+'"] .activity-comments'));t.length&&(t=t.find("#ac-form-"+e.current_document.activity_id),e.current_document.parent_activity_comments=!0,t.remove()),!0===e.current_document.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"document_get_document_description",id:e.current_document.id,attachment_id:e.current_document.attachment_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success?(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.description),p(".bb-media-info-section:visible").show(),bp.Nouveau.Media.Theatre.syncPinPostIconToTheatre(),p(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10)):p(".bb-media-info-section.document").hide()}})},activityDeleted:function(e,t){var i=this,a=0;if(i.is_open_media&&void 0!==t&&"delete_activity"===t.action&&i.current_media.activity_id==t.id){var o=p(document).find('[data-bp-list="media"] .bb-open-media-theatre[data-id="'+i.current_media.id+'"]'),d=o.parents("ul");for(o.closest("li").remove(),0===d.find("li:not(.load-more)").length&&(0'+i+"
.activity-list").children("#activity-"+i)).length&&e.hasClass("bb-pinned")&&0
"),p(".modal-container #bb-folder-privacy").addClass("new-folder-create-privacy"),p(document).find(".open-popup .error").hide()},createAlbumInPopup:function(e){e.preventDefault();var t=parseInt(p(document).find(".open-popup .bb-album-selected-id").val()),i=p(document).find(".open-popup .bb-album-create-from").val();0{"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},bp.Nouveau.Media={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){var e=p("body"),e=(this.current_page=1,this.current_page_existing_media=1,this.current_page_albums=1,this.current_tab=!e.hasClass("single-topic")&&!e.hasClass("single-forum")&&"bp-dropzone-content",this.sort_by="",this.order_by="",this.currentTargetParent=BP_Nouveau.media.current_folder,this.moveToIdPopup=BP_Nouveau.media.move_to_id_popup,this.moveToTypePopup=BP_Nouveau.media.current_type,this.privacySelectorSelect="",this.privacySelectorSpan="",this.currentAlbum=BP_Nouveau.media.current_album,void 0!==window.Dropzone&&(window.Dropzone.autoDiscover=!1),document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:""),e=(this.documentOptions={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,acceptedFiles:BP_Nouveau.media.document_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.media.dropzone_document_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.document.maxFiles?BP_Nouveau.document.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.document.max_upload_size?BP_Nouveau.document.max_upload_size:2,dictInvalidFileType:BP_Nouveau.document.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation},document.getElementsByClassName("forum-post-video-template").length?document.getElementsByClassName("forum-post-video-template")[0].innerHTML:"");this.videoOptions={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.video.dictFileTooBig,acceptedFiles:BP_Nouveau.video.video_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.video.dropzone_video_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.video.maxFiles?BP_Nouveau.video.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.video.max_upload_size?BP_Nouveau.video.max_upload_size:2,dictInvalidFileType:BP_Nouveau.video.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.video.video_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.video.dictCancelUploadConfirmation},p("#bp-media-uploader").hasClass("bp-media-document-uploader")?(e=document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:"",this.options={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,acceptedFiles:BP_Nouveau.media.document_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.media.dropzone_document_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.document.maxFiles?BP_Nouveau.document.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.document.max_upload_size?BP_Nouveau.document.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation}):(e=document.getElementsByClassName("forum-post-media-template").length?document.getElementsByClassName("forum-post-media-template")[0].innerHTML:"",this.options={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,dictDefaultMessage:BP_Nouveau.media.dropzone_media_message,acceptedFiles:"image/*",autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.media.maxFiles?BP_Nouveau.media.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.media_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation,maxThumbnailFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2}),void 0!==BP_Nouveau.media.dropzone_options&&Object.assign(this.options,BP_Nouveau.media.dropzone_options),this.dropzone_obj=[],this.dropzone_media=[],this.album_id=void 0!==BP_Nouveau.media.album_id&&BP_Nouveau.media.album_id,this.current_folder=void 0!==BP_Nouveau.media.current_folder&&BP_Nouveau.media.current_folder,this.current_group_id=void 0!==BP_Nouveau.media.current_group_id&&BP_Nouveau.media.current_group_id,this.group_id=void 0!==BP_Nouveau.media.group_id&&BP_Nouveau.media.group_id,this.bbp_is_reply_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_reply_edit&&window.BP_Forums_Nouveau.media.bbp_is_reply_edit,this.bbp_is_topic_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_topic_edit&&window.BP_Forums_Nouveau.media.bbp_is_topic_edit,this.bbp_is_forum_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_forum_edit&&window.BP_Forums_Nouveau.media.bbp_is_forum_edit,this.bbp_reply_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_media?window.BP_Forums_Nouveau.media.reply_edit_media:[],this.bbp_reply_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_document?window.BP_Forums_Nouveau.media.reply_edit_document:[],this.bbp_reply_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_video?window.BP_Forums_Nouveau.media.reply_edit_video:[],this.bbp_topic_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_media?window.BP_Forums_Nouveau.media.topic_edit_media:[],this.bbp_topic_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_video?window.BP_Forums_Nouveau.media.topic_edit_video:[],this.bbp_topic_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_document?window.BP_Forums_Nouveau.media.topic_edit_document:[],this.bbp_forum_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_media?window.BP_Forums_Nouveau.media.forum_edit_media:[],this.bbp_forum_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_document?window.BP_Forums_Nouveau.media.forum_edit_document:[],this.bbp_forum_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_video?window.BP_Forums_Nouveau.media.forum_edit_video:[],this.bbp_reply_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_gif_data?window.BP_Forums_Nouveau.media.reply_edit_gif_data:[],this.bbp_topic_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_gif_data?window.BP_Forums_Nouveau.media.topic_edit_gif_data:[],this.bbp_forum_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_gif_data?window.BP_Forums_Nouveau.media.forum_edit_gif_data:[],this.giphy=null,this.gif_offset=0,this.gif_q=null,this.gif_limit=20,this.gif_requests=[],this.gif_data=[],this.gif_container_key=!1,this.reply_topic_allow_delete_media=!1,this.reply_topic_display_post="edit",bp.Nouveau.Media.documentCodeMirror(),p(window).on("scroll resize",function(){bp.Nouveau.Media.documentCodeMirror()})},addListeners:function(){var e=p(".bp-nouveau"),t=p(".bp-existing-media-wrap"),t=(e.on("click","#bp-add-media",this.openUploader.bind(this)),e.on("click","#bp-add-document",this.openDocumentUploader.bind(this)),e.on("click","#bp-media-submit",this.submitMedia.bind(this)),e.on("click","#bp-media-document-submit",this.submitDocumentMedia.bind(this)),e.on("click","#bp-media-uploader-close",this.closeUploader.bind(this)),e.on("click","#bb-delete-media",this.deleteMedia.bind(this)),e.on("click","#bb-select-deselect-all-media",this.toggleSelectAllMedia.bind(this)),void 0!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request?p('#buddypress [data-bp-list="media"]').on("bp_ajax_request",this.bp_ajax_media_request):this.bp_media_after_load(),e.on("click","#bb-create-album",this.openCreateAlbumModal.bind(this)),p(document).on("click","#bb-create-folder",this.openCreateFolderModal.bind(this)),p(document).on("click","#bb-create-folder-child",this.openCreateFolderChildModal.bind(this)),p(document).on("click","#bp-edit-folder-open",this.openEditFolderChildModal.bind(this)),p(document).on("click","#bp-media-create-album-submit",this.saveAlbum.bind(this)),p(document).on("click","#bp-media-create-folder-submit",this.saveFolder.bind(this)),p(document).on("click","#bp-media-create-child-folder-submit",this.saveChildFolder.bind(this)),e.on("click","#bp-media-create-album-close",this.closeCreateAlbumModal.bind(this)),p(document).on("click","#bp-media-create-folder-close",this.closeCreateFolderModal.bind(this)),p(document).on("click","#bp-media-edit-folder-close",this.closeEditFolderModal.bind(this)),p(document).on("click",".open-popup .errorPopup",this.closeErrorPopup.bind(this)),e.on("click","#bp-media-add-more",this.triggerDropzoneSelectFileDialog.bind(this)),p("#bp-media-uploader").on("click",".bp-media-upload-tab",this.changeUploadModalTab.bind(this)),p('.bp-nouveau [data-bp-list="media"]').on("click","li.load-more",this.injectMedias.bind(this)),p(".bp-nouveau #albums-dir-list").on("click","li.load-more",this.appendAlbums.bind(this)),t.on("click","li.load-more",this.appendMedia.bind(this)),e.on("change",'.bb-media-check-wrap [name="bb-media-select"]',this.addSelectedClassToWrapper.bind(this)),t.on("change",'.bb-media-check-wrap [name="bb-media-select"]',this.toggleSubmitMediaButton.bind(this)),e.on("click","#bp-edit-album-title",this.editAlbumTitle.bind(this)),p(document).on("click","#bp-edit-folder-title",this.editFolderTitle.bind(this)),e.on("click","#bp-cancel-edit-album-title",this.cancelEditAlbumTitle.bind(this)),e.on("click","#bp-save-album-title",this.saveAlbum.bind(this)),p(document).on("click","#bp-save-folder-title",this.saveFolder.bind(this)),e.on("change","#bp-media-single-album select#bb-album-privacy",this.saveAlbum.bind(this)),e.on("change","#media-stream select#bb-folder-privacy",this.savePrivacy.bind(this)),e.on("click","#bb-delete-album",this.deleteAlbum.bind(this)),p(document).on("click","#bb-delete-folder",this.deleteFolder.bind(this)),p(document).on("click","ul.document-nav li",this.resetPageDocumentDirectory.bind(this)),p(document).on("click","ul.document-nav li a",this.resetPageDocumentDirectory.bind(this)),p(document).on("click","#forums-media-button",this.openForumsUploader.bind(this)),p(document).on("click","#forums-document-button",this.openForumsDocumentUploader.bind(this)),p(document).on("click","#forums-video-button",this.openForumsVideoUploader.bind(this)),p(document).on("click","#forums-gif-button",this.toggleGifSelector.bind(this)),p(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("keydown",".search-query-input",this.searchGif.bind(this)),p(document).on("click",".bbpress-forums-activity #whats-new-toolbar .found-media-item",this.selectGif.bind(this)),p(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("click",".found-media-item",this.selectGif.bind(this)),p(document).find("form #whats-new-toolbar .gif-search-results, .forum form #whats-new-toolbar .gif-search-results").scroll(this.loadMoreGif.bind(this)),p(".buddypress.groups.messages").length||p(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("click",".found-media-item",this.selectGif.bind(this)),p(document).find("form #whats-new-attachments .forums-attached-gif-container .gif-search-results, .forum form #whats-new-attachments .forums-attached-gif-container .gif-search-results").scroll(this.loadMoreGif.bind(this)),p(document).find("form #whats-new-attachments .forums-attached-gif-container, .forum form #whats-new-attachments .forums-attached-gif-container").on("click",".gif-image-remove",this.removeSelectedGif.bind(this)),p(document).on("click",".gif-image-container",this.playVideo.bind(this)),p(document).on("click",".directory.document .media-folder_action__anchor, .directory.document .media-folder_action__anchor li a, .bb-media-container .media-folder_action__anchor, .bb-media-container .media-folder_action__list li a",this.fileActionButton.bind(this)),p(document).on("click",".bb-activity-media-elem .copy_download_file_url a, .media-folder_action__list .copy_download_file_url a, .media .bb-photo-thumb .copy_download_file_url a",this.copyDownloadLink.bind(this)),p(document).on("click",".bb-activity-media-elem.media-activity .media-action-wrap .media-action_more, #media-stream.media .bb-photo-thumb .media-action-wrap .media-action_more, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_more, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_list li a",this.fileActivityActionButton.bind(this)),p(document).click(this.toggleFileActivityActionButton),p(document).on("click",".bb-activity-media-elem.document-activity .document-expand .document-expand-anchor, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_collapse",this.toggleCodePreview.bind(this)),p(document).on("click",".activity .bp-document-move-activity, #media-stream .bp-document-move-activity",this.moveDocumentIntoFolder.bind(this)),p(document).on("click",'.bp-nouveau [data-bp-list="document"] .pager .dt-more-container.load-more',this.injectDocuments.bind(this)),p(document).on("click",'.bp-nouveau [data-bp-list="document"] .data-head',this.sortDocuments.bind(this)),p(document).on("click",".modal-container .bb-field-steps-actions",this.documentPopupNavigate.bind(this)),p(document).on("click",".bp-media-document-uploader .modal-container .bb-field-uploader-actions",this.uploadDocumentNavigate.bind(this)),p(document).on("click",".bp-media-photo-uploader .modal-container .bb-field-uploader-actions",this.uploadMediaNavigate.bind(this)),p(document).on("click",".modal-container #bp-media-edit-child-folder-submit",this.renameChildFolder.bind(this)),p(document).on("click",".activity .bp-media-move-activity, #media-stream .bp-media-move-activity",this.moveMediaIntoAlbum.bind(this)),p("#bb-media-model-container .activity-list, #media-stream")),e="#buddypress .activity-list",i='#buddypress [data-bp-list="activity"]',a="#bb-media-model-container .activity-list",o="#media-stream",e=(p(document).on("click",e+" .ac-document-move, "+i+" .ac-document-move, "+e+" .ac-folder-move, "+i+" .ac-folder-move, "+a+" .ac-document-move, "+a+" .ac-folder-move, "+o+" .ac-document-move, "+o+" .ac-folder-move",this.openDocumentMove.bind(this)),p(document).on("click",e+" .ac-media-move, "+i+" .ac-media-move, "+a+" .ac-media-move, "+o+" .ac-media-move, .group-media "+o+" .ac-media-move",this.openMediaMove.bind(this)),p(document).on("click",e+" .ac-document-close-button, "+i+" .ac-document-close-button, "+e+" .ac-folder-close-button, "+i+" .ac-folder-close-button, "+a+" .ac-document-close-button, "+a+" .ac-folder-close-button, "+o+" .ac-document-close-button, "+o+" .ac-folder-close-button",this.closeDocumentMove.bind(this)),p(document).on("click",e+" .ac-media-close-button, "+i+" .ac-media-close-button, "+a+" .ac-media-close-button, "+o+" .ac-media-close-button",this.closeMediaMove.bind(this)),t.on("click",".ac-document-rename",this.renameDocument.bind(this)),t.on("click",".ac-document-privacy",this.editPrivacyDocument.bind(this)),t.on("keyup",".media-folder_name_edit",this.renameDocumentSubmit.bind(this)),t.on("click",".name_edit_cancel, .name_edit_save",this.renameDocumentSubmit.bind(this)),p(document).on("click",".document-file-delete",this.deleteDocument.bind(this)),p(document).on("click",".media-file-delete",this.deleteMedia.bind(this)),p(document).on("click",".bp-folder-move",this.folderMove.bind(this)),p(document).on("click",".bp-document-open-create-popup-folder",this.createFolderInPopup.bind(this)),p(document).on("click",".bp-media-open-create-popup-folder",this.createAlbumInPopup.bind(this)),p(document).on("click",".close-create-popup-folder",this.closeCreateFolderInPopup.bind(this)),p(document).on("click",".close-create-popup-album",this.closeCreateAlbumInPopup.bind(this)),p(document).on("click",".bp-document-create-popup-folder-submit",this.submitCreateFolderInPopup.bind(this)),p(document).on("click",".bp-media-create-popup-album-submit",this.submitCreateAlbumInPopup.bind(this)),p(".buddypress.groups.messages")),i=p(".buddypress.groups.messages form#send_group_message_form #whats-new-toolbar"),a=p(".buddypress.groups.messages form#send_group_message_form #whats-new-attachments .bp-group-messages-attached-gif-container .gif-search-results"),o=p(".buddypress.groups.messages form#send_group_message_form #whats-new-attachments .bp-group-messages-attached-gif-container");e.on("click","#bp-group-messages-media-button",this.openGroupMessagesUploader.bind(this)),e.on("click","#bp-group-messages-document-button",this.openGroupMessagesDocumentUploader.bind(this)),e.on("click","#bp-group-messages-video-button",this.openGroupMessagesVideoUploader.bind(this)),e.on("click","#bp-group-messages-gif-button",this.toggleGroupMessagesGifSelector.bind(this)),i.on("keyup",".search-query-input",this.searchGroupMessagesGif.bind(this)),i.on("click",".found-media-item",this.selectGroupMessagesGif.bind(this)),a.scroll(this.loadMoreGroupMessagesGif.bind(this)),p(".groups.messages form#send_group_message_form #whats-new-toolbar .bp-group-messages-attached-gif-container .gif-search-results").scroll(this.loadMoreGroupMessagesGif.bind(this)),o.on("click",".gif-image-remove",this.removeGroupMessagesSelectedGif.bind(this)),p(".bp-existing-media-wrap").on("scroll",this.loadExistingMedia.bind(this)),document.addEventListener("keyup",this.closePopup.bind(this)),document.addEventListener("keyup",this.submitPopup.bind(this)),p(window).bind("beforeunload",this.beforeunloadWindow.bind(this)),_.isUndefined(BP_Nouveau.media.gif_api_key)||(window.addEventListener("scroll",this.throttledAutoPlayGifVideos.bind(this),!1),window.addEventListener("resize",this.throttledAutoPlayGifVideos.bind(this),!1),(t=p("#bp-message-thread-list")).length&&t.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),(e=p(".bb-modal-activity-body")).length&&e.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),(i=p(".bb-media-model-container .activity-list .activity-item")).length&&i.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),p(document).on("scroll","#bp-message-thread-list",this.throttledAutoPlayGifVideos.bind(this)),p(document).on("scroll",".bb-modal-activity-body",this.throttledAutoPlayGifVideos.bind(this)),p(document).on("scroll",".bb-media-model-container .activity-list .activity-item",this.throttledAutoPlayGifVideos.bind(this)),setTimeout(function(){var e=document.getElementById("bp-message-thread-list"),e=(e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1),document.querySelector(".bb-modal-activity-body")),e=(e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1),document.querySelector(".bb-media-model-container .activity-list .activity-item"));e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1)},1e3),p(window).on("load",function(){setTimeout(function(){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media.autoPlayGifVideos&&bp.Nouveau.Media.autoPlayGifVideos()},300)}),document.addEventListener("keydown",_.bind(this.closePickersOnEsc,this)),p(document).on("click",_.bind(this.closePickersOnClick,this))),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_media.length||this.bbp_topic_edit_media.length||this.bbp_forum_edit_media.length)&&p("#forums-media-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_document.length||this.bbp_topic_edit_document.length||this.bbp_forum_edit_document.length)&&p("#forums-document-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_video.length||this.bbp_topic_edit_video.length||this.bbp_forum_edit_video.length)&&p("#forums-video-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(Object.keys(this.bbp_reply_edit_gif_data).length||Object.keys(this.bbp_topic_edit_gif_data).length||Object.keys(this.bbp_forum_edit_gif_data).length)&&(this.editGifPreview(),(a=jQuery("#forums-gif-button").addClass("active").closest("form")).find("#forums-document-button")&&a.find("#forums-document-button").parents(".post-elements-buttons-item").addClass("disable"),a.find("#forums-media-button")&&a.find("#forums-media-button").parents(".post-elements-buttons-item").addClass("disable"),a.find("#forums-video-button"))&&a.find("#forums-video-button").parents(".post-elements-buttons-item").addClass("disable"),"#openEditFolder"==window.location.hash&&p("#bp-media-edit-child-folder").length&&(history.pushState(null,null,window.location.href.split("#")[0]),p("#bp-media-edit-child-folder").show()),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(bp.Nouveau.Media.reply_topic_allow_delete_media=!0)},updateAlbumCounts:function(e){var t,i,a,o;p("#buddypress #bp-media-single-album").length&&(o=parseInt(e.album_media_count)||0,e=parseInt(e.album_video_count)||0,t=function(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},0<(a=p("#buddypress .bb-album-photo-count")).length&&(i=1===o?BP_Nouveau.media.i18n_strings.photo:BP_Nouveau.media.i18n_strings.photos,a.text(t(o)+" "+i)),0<(a=p("#buddypress .bb-album-video-count")).length)&&(o=1===e?BP_Nouveau.media.i18n_strings.video:BP_Nouveau.media.i18n_strings.videos,a.text(t(e)+" "+o))},loadExistingMedia:function(){p(window).scroll()},resetPageDocumentDirectory:function(e){e.preventDefault(),this.current_page=1},submitCreateFolderInPopup:function(e){e.preventDefault();var i=p(e.currentTarget).closest(".open-popup"),a=p(i).find(".bp-document-create-popup-folder-submit"),t=i.find(".bb-folder-selected-id").val(),o=p.trim(p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder-title").val()),d=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder-title"),s=/[\\/?%*:|"<>]+/g.exec(d.val()),s=Boolean(s);if(""===p.trim(d.val())||s)return d.addClass("error"),!1;d.removeClass("error"),this.currentTargetParent=t=""===t?0:t;var n=this.currentTargetParent,r=0,l="",c="",u=0;if("group"===this.moveToTypePopup?(l="grouponly",r=this.moveToIdPopup):(l=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder #bb-folder-privacy").val(),c=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder #bb-folder-privacy")),""===o)return alert(BP_Nouveau.media.create_folder_error_title),!1;a.addClass("loading"),setTimeout(function(){var e={action:"document_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:o,privacy:l,parent:n,group_id:r};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,async:!1,success:function(e){var t;e.success&&(p(".document-data-table-head").length&&parseInt(n)===parseInt(BP_Nouveau.media.current_folder)&&(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()),i.find(".location-folder-list-wrap .location-folder-list").remove(),i.find(".location-folder-list-wrap").append(e.data.tree_view),t="#"+p(i).attr("id")+".open-popup",bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,e.data.folder_id),u=e.data.folder_id,(""===e.data.tree_view?(i.find(".location-folder-list-wrap").hide(),i.find(".location-folder-list-wrap-main span.no-folder-exists")):(i.find(".location-folder-list-wrap-main span.no-folder-exists").hide(),i.find(".location-folder-list-wrap"))).show(),i.find("ul.location-folder-list span#"+u).trigger("click"),i.find(".bb-model-footer").show(),i.find(".bb-model-footer, #bp-media-document-prev").show(),i.find(".bb-field-wrap-search").show(),i.find(".bp-document-open-create-popup-folder").show(),i.find(".location-folder-list-wrap-main").show(),i.find(".create-popup-folder-wrap").hide(),i.find(".bb-folder-selected-id").val(),i.find(".bb-folder-selected-id").val(u),i.find(".bb-model-header").children().show(),i.find(".bb-model-header p").hide(),d.val(""),""!==c&&c.val("public"),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(i).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),a.removeClass("loading"),setTimeout(function(){var e=i.find("ul.location-folder-list span#"+u),t=(e.trigger("click"),p(i).find("#bb-document-privacy"));0!==Number(e.data("id"))?(t.find("option").removeAttr("selected"),t.val(e.parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1))},200))}}),this.currentTargetParent=u,i.find(".location-folder-list li.is_active").show().children("span, i").show().siblings("ul").hide(),i.find(".location-folder-list li.is_active").siblings("li").show().children("span, i").show().siblings("ul").hide(),i.find(".location-folder-list li span.selected").removeClass("selected"),i.find(".location-folder-list li.is_active").children("span").addClass("selected")},0)},submitCreateAlbumInPopup:function(e){e.preventDefault();var t=this,i=p(e.currentTarget).closest(".open-popup"),a=p(i).find(".bp-media-create-popup-album-submit"),o=i.find(".bb-album-selected-id").val(),d=(this.currentTargetParent=o=""===o?0:o,this.currentTargetParent),s=0,n=p.trim(p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album-title").val()),r=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album-title"),l="",c="",u=0;if("group"===this.moveToTypePopup?(l="grouponly",s=this.moveToIdPopup):(l=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album #bb-album-privacy").val(),c=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album #bb-album-privacy")),""===n)return alert(BP_Nouveau.media.create_album_error_title),!1;a.addClass("loading"),setTimeout(function(){var e={action:"media_album_save",_wpnonce:BP_Nouveau.nonces.media,title:n,privacy:l,parent:d,group_id:s};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,async:!1,success:function(e){e.success&&(i.find(".location-album-list-wrap .location-album-list").remove(),i.find(".location-album-list-wrap").append(e.data.tree_view),bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(i,e.data.album_id),u=e.data.album_id,(""===e.data.tree_view?(i.find(".location-album-list-wrap").hide(),i.find(".location-album-list-wrap-main span.no-album-exists")):(i.find(".location-album-list-wrap-main span.no-album-exists").hide(),i.find(".location-album-list-wrap"))).show(),i.find("ul.location-album-list span#"+u).trigger("click"),i.find(".bb-model-footer").show(),i.find(".bb-field-wrap-search").show(),i.find(".bp-media-open-create-popup-album").show(),i.find(".location-album-list-wrap-main").show(),i.find(".create-popup-album-wrap").hide(),i.find(".bb-field-steps-2 #bp-media-prev").show(),i.find(".bb-album-selected-id").val(),i.find(".bb-album-selected-id").val(u),i.find(".bb-model-header").children().show(),i.find(".bb-model-header p").hide(),r.val(""),""!==c&&c.val("public"),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(i).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),t.updateAlbumNavCount(e.data.album_count)),a.removeClass("loading")}}),this.currentTargetParent=u,i.find(".location-album-list li.is_active").show().children("span, i").show().siblings("ul").hide(),i.find(".location-album-list li.is_active").siblings("li").show().children("span, i").show().siblings("ul").hide(),i.find(".location-album-list li span.selected").removeClass("selected"),i.find(".location-album-list li.is_active").children("span").addClass("selected")},0)},closeCreateFolderInPopup:function(e){e.preventDefault(),p(".modal-container .bb-model-footer").show(),p(".bb-field-wrap-search").show(),p(".bp-document-open-create-popup-folder").show(),p(".location-folder-list-wrap-main").show(),p("#bp-media-document-prev").show(),p(".create-popup-folder-wrap").hide(),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header").children().show(),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header p").hide()},closeCreateAlbumInPopup:function(e){e.preventDefault(),p(".modal-container .bb-model-footer").show(),p(".bb-field-wrap-search").show(),p(".bp-document-open-create-popup-folder").show(),p(".modal-container:visible .bp-video-open-create-popup-album").show(),p(".location-album-list-wrap-main").show(),p(".bb-field-steps-2 #bp-media-prev").show(),p(".bb-field-steps-2 #bp-video-next").show(),p(".create-popup-album-wrap").hide(),p(".bp-media-create-popup-album-submit.loading").removeClass("loading"),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header").children().show(),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header p").hide()},createFolderInPopup:function(e){e.preventDefault();var t=parseInt(p(document).find(".open-popup .bb-folder-selected-id").val()),i=p(document).find(".open-popup .bb-folder-create-from").val();0 "+BP_Nouveau.media.create_folder+" "+BP_Nouveau.media.create_album_title+" '+e.data.media_personal_count+" "+t)):p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count)),void 0!==e.data&&void 0!==e.data.media_group_count&&0 '+e.data.media_group_count+" "+t)):p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):r.find(".media-list:not(.existing-media-list)")).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):r.find(".media-list:not(.existing-media-list)")).html(e.data.group_media_html_content):p.each(n,function(e,t){p('#media-stream ul.media-list li[data-id="'+t+'"]').length&&p('#media-stream ul.media-list li[data-id="'+t+'"]').remove()}),void 0!==e.data.album_total_count&&s.updateAlbumCounts(e.data))):(setTimeout(function(){d.prop("disabled",!1)},500),e.success?(void 0!==e.data&&void 0!==e.data.media_personal_count&&0
'+e.data.media_personal_count+" "+t)):p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count)),void 0!==e.data&&void 0!==e.data.media_group_count&&0
'+e.data.media_group_count+" "+t)):p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),(i=r.find(".media-list:not(.existing-media-list)")).find('.bb-media-check-wrap [name="bb-media-select"]:checked').each(function(){p(this).closest("li").remove()}),i.parent().parent().hasClass("album-single-view")&&i.find('.bb-video-check-wrap [name="bb-video-select"]:checked').each(function(){p(this).closest("li").remove()}),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):i).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):i).html(e.data.group_media_html_content):p.each(n,function(e,t){p('#media-stream ul.media-list li[data-id="'+t+'"]').length&&p('#media-stream ul.media-list li[data-id="'+t+'"]').remove()}),void 0!==e.data.album_total_count&&s.updateAlbumCounts(e.data)):p("#buddypress #media-stream.media").prepend(e.data.feedback));var t,i,a=p(".bp-nouveau #bb-select-deselect-all-media");a.hasClass("selected")&&a.removeClass("selected"),jQuery(window).scroll()}})},toggleSelectAllMedia:function(e){e.preventDefault(),p(e.currentTarget).hasClass("selected")?(p(e.currentTarget).data("bp-tooltip",BP_Nouveau.media.i18n_strings.selectall),this.deselectAllMedia(e)):(p(e.currentTarget).data("bp-tooltip",BP_Nouveau.media.i18n_strings.unselectall),this.selectAllMedia(e)),p(e.currentTarget).toggleClass("selected")},selectAllMedia:function(e){e.preventDefault();e=p("#buddypress").find(".media-list:not(.existing-media-list)");e.find('.bb-media-check-wrap [name="bb-media-select"]').each(function(){p(this).prop("checked",!0),p(this).closest(".bb-item-thumb").addClass("selected"),p(this).closest(".bb-media-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.unselect)}),e.parent().parent().hasClass("album-single-view")&&e.find('.bb-video-check-wrap [name="bb-video-select"]').each(function(){p(this).prop("checked",!0),p(this).closest(".bb-item-thumb").addClass("selected"),p(this).closest(".bb-video-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.unselect)})},deselectAllMedia:function(e){e.preventDefault();e=p("#buddypress").find(".media-list:not(.existing-media-list)");e.find('.bb-media-check-wrap [name="bb-media-select"]').each(function(){p(this).prop("checked",!1),p(this).closest(".bb-item-thumb").removeClass("selected"),p(this).closest(".bb-media-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.select)}),e.parent().parent().hasClass("album-single-view")&&e.find('.bb-video-check-wrap [name="bb-video-select"]').each(function(){p(this).prop("checked",!1),p(this).closest(".bb-item-thumb").removeClass("selected"),p(this).closest(".bb-video-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.select)})},editAlbumTitle:function(e){e.preventDefault(),p("#bb-album-title").show(),p("#bp-save-album-title").show(),p("#bp-cancel-edit-album-title").show(),p("#bp-edit-album-title").hide(),p("#bp-media-single-album #bp-single-album-title").hide()},editFolderTitle:function(e){e.preventDefault(),p("#bb-album-title").show(),p("#bp-save-folder-title").show(),p("#bp-cancel-edit-album-title").show(),p("#bp-edit-folder-title").hide(),p("#bp-media-single-album #bp-single-album-title").hide()},cancelEditAlbumTitle:function(e){e.preventDefault(),p("#bb-album-title").removeClass("error").hide(),p("#bp-save-album-title,#bp-save-folder-title").hide(),p("#bp-cancel-edit-album-title").hide(),p("#bp-edit-album-title,#bp-edit-folder-title").show(),p("#bp-media-single-album #bp-single-album-title").show()},triggerDropzoneSelectFileDialog:function(){this.dropzone_obj.hiddenFileInput.click()},closeUploader:function(e){e.preventDefault(),p("#bp-media-uploader").hide(),p("#bp-media-add-more").hide(),p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),p("#bp-media-uploader-modal-status-text").text(""),p("#bp-media-post-content").val(""),p("#bp-dropzone-content .bp-feedback").remove(),this.dropzone_obj.element&&this.dropzone_obj.destroy(),this.dropzone_media=[];var t=p(e.currentTarget).closest("#bp-media-uploader");p(".close-create-popup-album").trigger("click"),p(".close-create-popup-folder").trigger("click"),t.find('.breadcrumbs-append-ul-li .item span[data-id="0"]').trigger("click"),t.find(".bb-field-steps").length&&(t.find(".bb-field-steps-1").show().siblings(".bb-field-steps-2").hide(),t.find(".bb-field-steps-1 #bp-media-photo-next, .bb-field-steps-1 #bp-media-document-next ").hide(),t.find(".bb-field-steps-1").removeClass("controls-added"),t.find("#bp-media-document-prev, #bp-media-prev, #bp-media-document-submit, #bp-media-submit, .bp-media-open-create-popup-folder, .bp-document-open-create-popup-folder, .create-popup-folder-wrap, .create-popup-album-wrap, .bp-video-open-create-popup-album").hide()),this.clearFolderLocationUI(e)},closeChildFolderUploader:function(e){e.preventDefault(),p(document).find(".open-popup #bb-album-child-title").val(""),p(document).find(".open-popup #bp-media-create-child-folder-submit").removeClass("loading"),p(document).find("#bp-media-create-child-folder").removeClass("open-popup"),p(document).find("#bp-media-create-child-folder").hide(),p(document).find(".open-popup #bb-album-title").text(""),p(document).find(".open-popup #bp-media-create-folder").hide(),p(document).find("#bp-media-create-folder").removeClass("open-popup")},closeFolderUploader:function(e){e.preventDefault(),p(document).find(".open-popup #bb-album-title").val(""),p(document).find(".open-popup #bp-media-create-folder-submit").removeClass("loading"),p(document).find(".open-popup #bp-media-document-submit").hide(),p(document).find("#bp-media-create-folder").removeClass("open-popup"),p(document).find("#bp-media-create-folder").hide()},loadMoreGif:function(e){var t=e.target,i=this,e=p(e.target).closest("form").find(".forums-attached-gif-container"),a=e.data("key");i.gif_container_key=a,t.scrollTop+t.offsetHeight>=t.scrollHeight&&!e.hasClass("loading")&&0
"),h(".bb-rl-modal-container #bb-rl-folder-privacy").addClass("new-folder-create-privacy"),a.find(".open-popup .error").hide(),bp.Readylaunch&&bp.Readylaunch.initSelect2Scoped&&setTimeout(function(){var e=o.find(".bb-rl-create-popup-"+i+"-wrap");e.length&&e.is(":visible")&&bp.Readylaunch.initSelect2Scoped(e)},150)},closeCreateFolderAlbumInPopup:function(e,t){h(".bb-rl-modal-container .bb-rl-model-footer, .modal-container .bb-model-footer").show(),h(".bb-field-wrap-search").show(),h(".bb-rl-document-open-create-popup-folder").show(),"album"===t&&h(".bb-rl-modal-container:visible .bb-rl-video-open-create-popup-album").show(),h(".bb-rl-location-"+t+"-list-wrap-main").show(),"folder"===t?h("#bp-media-document-prev").show():"album"===t&&((i=h(".bb-field-steps-2")).find("#bp-media-prev").show(),i.find("#bp-video-next").show()),h(".bb-rl-create-popup-"+t+"-wrap").hide(),"album"===t&&h(".bb-rl-media-create-popup-album-submit.loading").removeClass("loading");var i=h(e.currentTarget).closest(".bb-rl-has-folderlocationUI");i.find(".bb-rl-modal-header").children().show(),i.find(".bb-rl-modal-header p").hide()},submitCreateFolderAlbumInPopup:function(e,a,o){e.preventDefault();var d=this,e=h(e.currentTarget),r=e.closest(".open-popup"),n=h(r).find(".bb-rl-"+a+"-create-popup-"+o+"-submit"),t=r.find(".bb-rl-"+o+"-selected-id").val(),s=e.closest(".modal-container, .bb-rl-modal-container").find(".bb-rl-popup-on-fly-create-"+o+"-title"),i=h.trim(s.val());if("document"===a){var l=/[\\/?%*:|"<>]+/g.exec(i),l=Boolean(l);if(""===i||l)return s.addClass("error"),!1;s.removeClass("error")}this.currentTargetParent=t=""===t?0:t;var c=this.currentTargetParent,p=0,b="",m="",u=0;if("group"===this.moveToTypePopup?(b="grouponly",p=this.moveToIdPopup):(m=e.closest(".modal-container, .bb-rl-modal-container").find(".bb-rl-popup-on-fly-create-"+o+' select[id*="-'+o+'-privacy"]'),b=m.val()),""===i)return l="document"===a?g.create_folder_error_title:g.create_album_error_title,alert(l),!1;n.addClass("loading");var f=("video"===a?"media":a)+"_"+o+"_save",v=".location-"+o+"-list";setTimeout(function(){var e={action:f,_wpnonce:w.media,title:i,privacy:b,parent:c,group_id:p};h.ajax({type:"POST",url:y,data:e,async:!1,success:function(e){var t,i;e.success?("document"===a&&h(".document-data-table-head").length&&parseInt(c)===parseInt(g.current_folder)&&(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()),r.find(".bb-rl-location-"+o+"-list-wrap "+v).remove(),r.find(".bb-rl-location-"+o+"-list-wrap").append(e.data.tree_view),t="document"===a?"#"+h(r).attr("id")+".open-popup":r,i="document"===a?e.data.folder_id:e.data.album_id,bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,i),u=i,(""===e.data.tree_view?(r.find(".bb-rl-location-"+o+"-list-wrap").hide(),r.find(".bb-rl-location-"+o+"-list-wrap-main span.bb-rl-no-"+o+"-exists")):(r.find(".bb-rl-location-"+o+"-list-wrap-main span.bb-rl-no-"+o+"-exists").hide(),r.find(".bb-rl-location-"+o+"-list-wrap"))).show(),r.find("ul"+v+" span#"+u).trigger("click"),r.find(".bb-rl-model-footer, .bb-model-footer").show(),"document"===a&&r.find(".bb-rl-model-footer, .bb-model-footer, #bp-media-"+a+"-prev").show(),r.find(".bb-field-wrap-search").show(),r.find(".bb-rl-"+a+"-open-create-popup-"+o).show(),r.find(".bb-rl-location-"+o+"-list-wrap-main").show(),r.find(".bb-rl-create-popup-"+o+"-wrap").hide(),"media"===a&&r.find(".bb-field-steps-2 #bp-media-prev").show(),r.find(".bb-rl-"+o+"-selected-id").val(),r.find(".bb-rl"+o+"-selected-id").val(u),r.find(".bb-rl-modal-header").children().show(),r.find(".bb-rl-modal-header p").hide(),s.val(""),""!==m&&m.val("public"),h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0=t.scrollHeight&&!p(e.target).closest(".bp-group-messages-attached-gif-container").hasClass("loading")&&0 \n\t\n\t\t \n\t\n',e.data[t].saved=!1,this.gif_data.push(e.data[t])}p(".bp-group-messages-attached-gif-container").find(".gif-search-results-list").append(i)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(this.gif_total_count=e.pagination.total_count)},loadMoreGifResponse:function(e){var t=this,i=0;if(p('div.forums-attached-gif-container[data-key="'+t.gif_container_key+'"]').removeClass("loading"),void 0!==e.data&&e.data.length){for(var a="",i=0;i
\n\t\n\t\t \n\t\n',e.data[i].saved=!1,t.gif_data[t.gif_container_key].data.push(e.data[i])}p('div.forums-attached-gif-container[data-key="'+t.gif_container_key+'"]').closest("form").find(".gif-search-results-list").append(a)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(t.gif_data[t.gif_container_key].total_count=e.pagination.total_count)},editGifPreview:function(){var e=this,t={};if(e.bbp_is_reply_edit&&Object.keys(e.bbp_reply_edit_gif_data).length?t=e.bbp_reply_edit_gif_data.gif_raw_data:e.bbp_is_topic_edit&&Object.keys(e.bbp_topic_edit_gif_data).length?t=e.bbp_topic_edit_gif_data.gif_raw_data:e.bbp_is_forum_edit&&Object.keys(e.bbp_forum_edit_gif_data).length&&(t=e.bbp_forum_edit_gif_data.gif_raw_data),void 0===t.images)return!1;e=p("#whats-new-attachments .forums-attached-gif-container");e[0].style.backgroundImage="url("+t.images.fixed_width.url+")",e[0].style.backgroundSize="contain",e[0].style.height=t.images.original.height+"px",e[0].style.width=t.images.original.width+"px",e.find(".gif-image-container img").attr("src",t.images.original.url),e.removeClass("closed"),p("#bbp_media_gif").length&&p("#bbp_media_gif").val(JSON.stringify(t))},selectGif:function(e){var t=this,i=0,a=p(e.currentTarget),o=a.closest("form").find(".forums-attached-gif-container"),d=(e.preventDefault(),o.closest("form").find(".gif-media-search-dropdown").removeClass("open"),o.data("key"));if(void 0!==t.gif_data[d]&&void 0!==t.gif_data[d].data&&t.gif_data[d].data.length){for(i=0;i
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,s.gif_data.push(e.data[n])}p(d.target).closest(".bp-group-messages-attached-gif-container").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(s.gif_total_count=e.pagination.total_count),p(d.target).closest(".bp-group-messages-attached-gif-container").removeClass("loading")},function(){p(d.target).find(".gif-no-connection").addClass("show")}));s.gif_requests.push(e),s.gif_offset=s.gif_offset+s.gif_limit},searchGifRequest:function(d){var s=this,n=0,r=p(d.target).closest("form").find(".forums-attached-gif-container"),l=(r.addClass("loading"),r.data("key")),e=(p(d.target).closest("form").find(".gif-no-results").removeClass("show"),p(d.target).closest("form").find(".gif-no-connection").removeClass("show"),s.clearGifRequests(l),s.gif_data[l].q=d.target.value,s.gif_data[l].offset=0,s.giphy.search({q:s.gif_data[l].q,offset:s.gif_data[l].offset,fmt:"json",limit:s.gif_data[l].limit},function(e){if(void 0!==e.data.length&&0===e.data.length&&p(d.target).closest("form").find(".gif-no-results").addClass("show"),void 0!==e.meta.status&&200!==e.meta.status&&p(d.target).closest("form").find(".gif-no-connection").addClass("show"),void 0!==e.data&&e.data.length){var t="";for(n=0;n
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,s.gif_data[l].data.push(e.data[n])}p(d.target).closest(".gif-search-content").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(s.gif_data[l].total_count=e.pagination.total_count),r.removeClass("loading")},function(){p(d.target).closest("form").find(".gif-no-connection").addClass("show")}));s.gif_data[l].requests.push(e),s.gif_data[l].offset=s.gif_data[l].offset+s.gif_data[l].limit},clearGifRequests:function(e){var t=this;if(void 0!==t.gif_data[e]&&void 0!==t.gif_data[e].requests){for(var i=0;i
\n\t\n\t\t \n\t\n',e.data[l].saved=!1,n.gif_data[s].data.push(e.data[l])}r.closest("form").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(n.gif_data[s].total_count=e.pagination.total_count),d.removeClass("loading")}),n.gif_data[s].requests.push(e),n.gif_data[s].offset=n.gif_data[s].offset+n.gif_data[s].limit),t.toggleClass("open"),r.parents("form").find("#whats-new-attachments .forums-attached-gif-container img")),t=(0
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,d.gif_data.push(e.data[n])}s.closest("form").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(d.gif_total_count=e.pagination.total_count),p(".gif-search-query").closest(".bp-group-messages-attached-gif-container").removeClass("loading")}),d.gif_requests.push(e),d.gif_offset=d.gif_offset+d.gif_limit),s.parents("form").find("#whats-new-attachments .bp-group-messages-attached-gif-container img"));0
"),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),a.dropzone_obj[n].on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=p(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.album_id=a.album_id,t.data.group_id=a.group_id,t.data.saved=!1,a.dropzone_media[n].push(t.data),a.addMediaIdsToForumsForm(d)):(jQuery(".forum-media-error-popup").length||p("body").append('"),this.removeFile(e))}),a.dropzone_obj[n].on("removedfile",function(e){if(!0===bp.Nouveau.Media.reply_topic_allow_delete_media){if(a.dropzone_media[n].length)for(var t in a.dropzone_media[n])if(e.upload.uuid==a.dropzone_media[n][t].uuid){this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit||void 0===a.dropzone_media[n][t].saved||a.dropzone_media[n][t].saved||"edit"!==bp.Nouveau.Media.reply_topic_display_post||a.removeAttachment(a.dropzone_media[n][t].id),a.dropzone_media[n].splice(t,1),a.addMediaIdsToForumsForm(d);break}var i;_.isNull(a.dropzone_obj[n].files)||0!==a.dropzone_obj[n].files.length||((i=o.closest("form")).find("#forums-document-button")&&i.find("#forums-document-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-video-button")&&i.find("#forums-video-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-gif-button")&&i.find("#forums-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-media-button")&&i.find("#forums-media-button").parents(".post-elements-buttons-item").removeClass("no-click"))}_.isNull(a.dropzone_obj[n].files)||0!==a.dropzone_obj[n].files.length||o.closest("form").removeClass("has-media")}),a.dropzone_obj[n].on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 "),this.removeFile(e))}),a.dropzone_obj.on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=p(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.album_id=a.album_id,t.data.group_id=a.group_id,t.data.saved=!1,a.dropzone_media.push(t.data),a.addMediaIdsToGroupMessagesForm()):(jQuery(".group-message-error-popup").length||p("body").append('"),this.removeFile(e))}),a.dropzone_obj.on("removedfile",function(e){if(a.dropzone_media.length)for(var t in a.dropzone_media)if(e.upload.uuid==a.dropzone_media[t].uuid){void 0===a.dropzone_media[t].saved||a.dropzone_media[t].saved||a.removeAttachment(a.dropzone_media[t].id),a.dropzone_media.splice(t,1),a.addMediaIdsToGroupMessagesForm();break}var i;_.isNull(a.dropzone_obj.files)||0!==a.dropzone_obj.files.length||((i=p("#send_group_message_form")).find("#bp-group-messages-document-button")&&i.find("#bp-group-messages-document-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-video-button")&&i.find("#bp-group-messages-video-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-gif-button")&&i.find("#bp-group-messages-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-media-button")&&i.find("#bp-group-messages-media-button").parents(".post-elements-buttons-item").removeClass("no-click"))}),t.removeClass("closed").addClass("open"),a.resetGroupMessagesGifComponent(),a.resetGroupMessagesDocumentComponent(),a.resetGroupMessagesVideoComponent()):a.resetGroupMessagesMediaComponent())},openGroupMessagesDocumentUploader:function(e){var l=this,t=p("div#bp-group-messages-post-document-uploader"),i=p(e.currentTarget);e.preventDefault(),i.toggleClass("active"),void 0!==window.Dropzone&&t.length&&(t.hasClass("closed")?(l.document_dropzone_obj=new Dropzone("div#bp-group-messages-post-document-uploader",l.documentOptions),l.document_dropzone_obj.on("addedfile",function(){}),l.document_dropzone_obj.on("sending",function(e,t,i){i.append("action","document_document_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media);i=p("#send_group_message_form");i.find("#bp-group-messages-media-button")&&i.find("#bp-group-messages-media-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-video-button")&&i.find("#bp-group-messages-video-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-gif-button")&&i.find("#bp-group-messages-gif-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-document-button")&&i.find("#bp-group-messages-document-button").parents(".post-elements-buttons-item").addClass("no-click")}),l.document_dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),l.document_dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?p(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&p(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".group-document-error-popup").length||p("body").append('"),this.removeFile(e))}),l.document_dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.document_dropzone_obj.on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e))}),r.video_dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.video.empty_video_type):t()}),r.video_dropzone_obj.on("addedfile",function(e){e.dataURL||bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),r.video_dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);e.upload.progress<=99?(p(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,p(e.previewElement).find(".dz-progress-count").text("99% "+BP_Nouveau.video.i18n_strings.video_uploaded_text))}),r.video_dropzone_obj.on("success",function(e,t){if(100===e.upload.progress&&(p(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,p(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),p(e.previewElement).closest(".dz-preview").addClass("dz-complete")),!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),l.dropzone_obj[u].on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.dropzone_obj[u].on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),l.dropzone_obj[u].on("accept",function(e,t){0==e.size?t(BP_Nouveau.video.empty_video_type):t()}),l.dropzone_obj[u].on("addedfile",function(e){e.dataURL&&e.dataThumb&&e.dataThumb.length?p(e.previewElement).find(".dz-video-thumbnail").prepend(' '):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),l.dropzone_obj[u].on("uploadprogress",function(e){o.closest("form").addClass("media-uploading");var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);e.upload.progress<=99?(p(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,p(e.previewElement).find(".dz-progress-count").text("99% "+BP_Nouveau.video.i18n_strings.video_uploaded_text))}),l.dropzone_obj[u].on("success",function(e,t){if(100===e.upload.progress&&(p(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,p(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),p(e.previewElement).closest(".dz-preview").addClass("dz-complete")),!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a
'+p(this).text()+""),p(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val(p(e.currentTarget).data("id")),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),0!==Number(p(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(p(e.currentTarget).parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),p(document).on("click",t+" .breadcrumb .item > span",function(e){var t,i;p(this).hasClass("is-disabled")||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val(0),p(e.currentTarget).closest(".bb-field-wrap").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),i=p(e.currentTarget).closest("#bp-media-uploader").find(".location-album-list li.is_active").data("privacy"),0!==Number(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),e=document.getElementsByClassName("uploader-post-media-template").length?document.getElementsByClassName("uploader-post-media-template")[0].innerHTML:"",i.options.previewTemplate=e,i.dropzone_obj=new Dropzone("div#media-uploader",i.options),i.dropzone_obj.on("sending",function(e,t,i){i.append("action","media_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media)}),i.dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),i.dropzone_obj.on("addedfile",function(){setTimeout(function(){i.dropzone_obj.getAcceptedFiles().length&&p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),i.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?p(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&p(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".media-error-popup").length||p("body").append('"),this.removeFile(e))}),i.dropzone_obj.on("queuecomplete",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),p(".bb-field-steps-1 #bp-media-photo-next, #bp-media-submit, #bp-media-create-album-submit").show()}),i.dropzone_obj.on("processing",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),p(".bb-field-steps-1 #bp-media-photo-next, #bp-media-submit, #bp-media-create-album-submit").hide()}),i.dropzone_obj.on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=i.dropzone_media.length,t.data.album_id=i.album_id,t.data.group_id=i.group_id,t.data.saved=!1,i.dropzone_media.push(t.data)):(jQuery(".media-error-popup").length||p("body").append('"),this.removeFile(e)),p(".modal-container").addClass("modal-container--alert"),p(".bb-field-steps-1").addClass("controls-added"),p("#bp-media-add-more").show(),p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()}),i.dropzone_obj.on("removedfile",function(e){if(i.dropzone_media.length)for(var t in i.dropzone_media)if(e.upload.uuid==i.dropzone_media[t].uuid){void 0===i.dropzone_media[t].saved||i.dropzone_media[t].saved||i.removeAttachment(i.dropzone_media[t].id),i.dropzone_media.splice(t,1);break}i.dropzone_obj.getAcceptedFiles().length?p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show():(p("#bp-media-uploader-modal-status-text").text(""),p("#bp-media-add-more, #bp-media-photo-next").hide(),p(".bb-field-steps-1").removeClass("controls-added"),p("#bp-media-submit").hide(),p(".modal-container").removeClass("modal-container--alert"))}))},openDocumentUploader:function(e){var a,t,l=this;e.preventDefault(),void 0!==window.Dropzone&&p("div#media-uploader").length&&(p("#bp-media-uploader").hasClass("bp-media-document-uploader")&&!this.currentTargetParent&&(this.currentTargetParent=0),p(e.currentTarget).closest("#bp-media-single-folder").length&&p("#bb-document-privacy").hide(),p(document).removeClass("open-popup"),p("#bp-media-uploader").show(),p("#bp-media-uploader").addClass("open-popup"),p("#bp-media-uploader.bp-media-document-uploader").find(".bb-field-steps.bb-field-steps-2").length&&(t="#bp-media-uploader.bp-media-document-uploader",0!==Number(p(t).find(".bb-folder-selected-id").data("value"))?(a=p(t).find(".bb-folder-selected-id").data("value"),p(t).find("#bb-document-privacy").prop("disabled",!0)):a=0,""!==this.moveToIdPopup)&&p.ajax({url:BP_Nouveau.ajaxurl,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:BP_Nouveau.nonces.media},success:function(e){p(document).find(".bp-media-document-uploader .location-folder-list-wrap h4 span.where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap").hide(),p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap-main span.no-folder-exists")):(p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap-main span.no-folder-exists").hide(),p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap"))).show(),p(document).find(".bp-media-document-uploader .popup-on-fly-create-album .privacy-field-wrap-hide-show").show(),p(document).find(".bp-media-document-uploader .open-popup .bb-folder-create-from").val("profile"),p(t).find(".location-folder-list-wrap .location-folder-list").remove(),p(t).find(".location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,a),p(t).find("ul.location-folder-list span#"+a).trigger("click"),p(t).find(".bb-folder-selected-id").val(a)}}),p(document).on("click",t+" .location-folder-list li span",function(e){var t;e.preventDefault(),p(this).parent().hasClass("is_active")||(0!=p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item").append(''+p(this).text()+""),p(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val(p(e.currentTarget).data("id")),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),0!==Number(p(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(p(e.currentTarget).parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),p(document).on("click",t+" .breadcrumb .item > span",function(e){var t,i;p(this).hasClass("is-disabled")||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val(p(e.currentTarget).data("id")),p(e.currentTarget).closest(".bb-field-wrap").find(".location-folder-list li span").removeClass("selected").parent().removeClass("is_active"),p(e.currentTarget).closest(".bb-field-wrap").find('.location-folder-list li[data-id="'+p(e.currentTarget).data("id")+'"]').addClass("is_active"),p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),i=p(e.currentTarget).closest("#bp-media-uploader").find(".location-folder-list li.is_active").data("privacy"),0!==Number(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),e=document.getElementsByClassName("uploader-post-document-template").length?document.getElementsByClassName("uploader-post-document-template")[0].innerHTML:"",l.options.previewTemplate=e,l.dropzone_obj=new Dropzone("div#media-uploader",l.options),l.dropzone_obj.on("sending",function(e,t,i){i.append("action","document_document_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media)}),l.dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),l.dropzone_obj.on("addedfile",function(){setTimeout(function(){l.dropzone_obj.getAcceptedFiles().length&&p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,l.dropzone_media.length,l.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),l.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?p(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&p(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".document-error-popup").length||p("body").append('"),this.removeFile(e))}),l.dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.dropzone_obj.on("queuecomplete",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),p(".bb-field-steps-1 #bp-media-document-next, #bp-media-document-submit").show()}),l.dropzone_obj.on("processing",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),p(".bb-field-steps-1 #bp-media-document-next, #bp-media-document-submit").hide()}),l.dropzone_obj.on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a .activity-content .bp-media-move-file",p(o).find(".bp-document-move").attr("id",p(e.currentTarget).closest(".document-activity").attr("data-id")),0 ');var i,t,a,o,d=t,s=this.moveToTypePopup;""!==this.moveToIdPopup&&p.ajax({url:BP_Nouveau.ajaxurl,type:"post",data:{action:"media_get_album_view",id:this.moveToIdPopup,type:this.moveToTypePopup},success:function(e){p(document).find(".location-album-list-wrap h4 span.where-to-move-profile-or-group-media").html(e.data.first_span_text),(""===e.data.html?(p(document).find(".open-popup .location-album-list-wrap").hide(),p(document).find(".open-popup .location-album-list-wrap-main span.no-album-exists")):(p(document).find(".open-popup .location-album-list-wrap-main span.no-album-exists").hide(),p(document).find(".open-popup .location-album-list-wrap"))).show(),"group"===s?(p(document).find(".popup-on-fly-create-album .privacy-field-wrap-hide-show").hide(),p(document).find(".open-popup .bb-album-create-from").val("group")):(p(document).find(".popup-on-fly-create-album .privacy-field-wrap-hide-show").show(),p(document).find(".open-popup .bb-album-create-from").val("profile")),!1===e.data.create_album?(p(o+".open-popup").find(".bp-media-open-create-popup-folder").removeClass("create-album"),p(o+".open-popup").find(".bp-media-open-create-popup-folder").hide()):(p(o+".open-popup").find(".bp-media-open-create-popup-folder").addClass("create-album"),p(o+".open-popup").find(".bp-media-open-create-popup-folder").show()),p(o).find(".location-album-list-wrap .location-album-list").remove(),p(o).find(".location-album-list-wrap").append(e.data.html),p(o).find("ul.location-album-list span#"+d).trigger("click")}}),p(document).on("click",o+" .location-album-list li span",function(e){var t;e.preventDefault(),p(this).parent().hasClass("is_active")||(0!=p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),p(this).closest(".location-album-list-wrap").find(".breadcrumb .item").append(''+p(this).text()+""),p(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),t=p(document).find('a.bb-open-media-theatre[data-id="'+i.find(".bp-media-move").attr("id")+'"]').data("album-id"),Number(t)==Number(p(e.currentTarget).data("id"))?p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||p(e.currentTarget).closest(".bp-media-move-file").find(".bb-album-selected-id").val(p(e.currentTarget).data("id"))}),p(document).on("click",o+" .breadcrumb .item > span",function(e){p(this).hasClass("is-disabled")||(p(e.currentTarget).closest(".bp-media-move-file").find(".bb-album-selected-id").val(0),p(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),d==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"))})},openDocumentMove:function(e){e.preventDefault();var t,i,a,e=p(e.currentTarget),o=(e.closest(".bb-activity-media-elem").find(".document-title").text(),this.moveToIdPopup=e.attr("id"),this.moveToTypePopup=e.attr("data-type"),e.attr("data-action")),d=(p(".bp-media-move-file.open-popup, .bp-media-move-folder.open-popup").hide().removeClass("open-popup"),e.closest("#activity-modal")),s=(0===d.length&&(d=p("body")),e.closest(".conflict-activity-ul-li-comment").closest("li.comment-item").length?(i=e.closest("li.comment-item"),i=d.find("#"+i.attr("id")+".comment-item .bp-media-move-file").first()):0<(a=e.closest("li.activity-item")).length&&(i=d.find("#"+a.attr("id")+" > .activity-content .bp-media-move-file").first()),i&&0!==i.length||(e.closest(".conflict-activity-ul-li-comment").closest("li.comment-item").length?(a=e.closest("li.comment-item").attr("id"),i=d.find("#"+a+".comment-item .bp-media-move-file").first()):(a=e.closest("li.activity-item").attr("id"))&&(i=d.find("#"+a+" > .activity-content .bp-media-move-file").first())),i&&0 '),"document"===o?p(t).find(".bb-model-header h4 .target_name").text(BP_Nouveau.media.move_to_file):p(t).find(".bb-model-header h4 .target_name").text(BP_Nouveau.media.move_to_folder),p(t).show(),p(t).addClass("open-popup"),"group"===this.moveToTypePopup?(p(document).find(".location-folder-list-wrap h4").show(),p(t).addClass("move-folder-popup-group")):(p(document).find(".location-folder-list-wrap h4").hide(),p(".move-folder-popup-group").removeClass("move-folder-popup-group")),this.currentTargetParent),n=this.moveToTypePopup;""!==this.moveToIdPopup&&p.ajax({url:BP_Nouveau.ajaxurl,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:BP_Nouveau.nonces.media},success:function(e){p(document).find(".location-folder-list-wrap h4 span.where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(p(document).find(".open-popup .location-folder-list-wrap").hide(),p(document).find(".open-popup .location-folder-list-wrap-main span.no-folder-exists")):(p(document).find(".open-popup .location-folder-list-wrap-main span.no-folder-exists").hide(),p(document).find(".open-popup .location-folder-list-wrap"))).show(),"group"===n?(p(document).find(".popup-on-fly-create-folder .privacy-field-wrap-hide-show").hide(),p(document).find(".open-popup .bb-folder-create-from").val("group")):(p(document).find(".popup-on-fly-create-folder .privacy-field-wrap-hide-show").show(),p(document).find(".open-popup .bb-folder-create-from").val("profile")),p(t).find(".location-folder-list-wrap .location-folder-list").remove(),p(t).find(".location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&(bp.Nouveau.Media.folderLocationUI(t,s),p(t).find("ul.location-folder-list span#"+s).trigger("click"))}})},closeMediaMove:function(e){e.preventDefault(),0!=p(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list-wrap .breadcrumb .item span:last-child").data("id")&&p(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list-wrap .breadcrumb .item span:last-child").remove(),p(e.currentTarget).closest(".bp-media-move-file").hide()},closeDocumentMove:function(e){e.preventDefault();var t=p(e.currentTarget),i=jQuery(e.currentTarget).closest(".has-folderlocationUI");(t.hasClass("ac-document-close-button")?(t.closest(".bp-media-move-file"),p(".bp-media-move-file.open-popup").hide().removeClass("open-popup").find(".bp-document-move")):(t.closest(".bp-media-move-folder"),p(".bp-media-move-folder.open-popup").hide().removeClass("open-popup").find(".bp-folder-move"))).attr("id",""),i.find(".bp-document-move.loading").removeClass("loading"),this.clearFolderLocationUI(e)},renameDocument:function(e){var t=p(e.currentTarget).closest(".media-folder_items").find(".media-folder_name"),i=t.children("span").text();t.hide().siblings(".media-folder_name_edit_wrap").show().children(".media-folder_name_edit").val(i).focus().select(),e.preventDefault()},editPrivacyDocument:function(e){e.preventDefault(),p(e.currentTarget).closest("#media-folder-document-data-table").find(".media-folder_visibility .media-folder_details__bottom span").show().siblings("select").addClass("hide");var t=p(e.currentTarget).closest(".media-folder_items").find(".media-folder_visibility");t.find(".media-folder_details__bottom span").hide().siblings("select").removeClass("hide"),t.find(".media-folder_details__bottom span").hide().siblings("select").val(p(e.currentTarget).attr("data-privacy")),t.find(".media-folder_details__bottom #bb-folder-privacy").attr("data-privacy",p(e.currentTarget).attr("data-privacy")),this.privacySelectorSelect=t.find(".media-folder_details__bottom span").hide().siblings("select"),this.privacySelectorSpan=t.find(".media-folder_details__bottom span")},editPrivacyDocumentSubmit:function(e){e=p(e.currentTarget);"true"==e.attr("data-mouseup")?(e.attr("data-mouseup","false"),e.addClass("hide").siblings("span").show().text(e.find("option:selected").text())):e.attr("data-mouseup","true")},renameDocumentSubmit:function(t){var i=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name_edit"),a=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > span"),o=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name"),e=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-id").attr("data-item-id"),d=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-attachment-id").attr("data-item-id"),s=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-type").attr("data-item-id"),n=i.val().trim(),r="",r=(p(t.currentTarget).closest(".ac-document-list").length?r=/[?\[\]=<>:;,'"&$#*()|~`!{}%+ \/]+/g:p(t.currentTarget).closest(".ac-folder-list").length&&(r=/[\\/?%*:|"<>]+/g),r.exec(n)),r=Boolean(r);if(r?i.addClass("error"):i.removeClass("error"),p(t.currentTarget).closest(".ac-document-list").length&&(-1!=n.indexOf("\\\\")||r?i.addClass("error"):i.removeClass("error")),!p(t.currentTarget).hasClass("name_edit_cancel")&&27!=t.keyCode||(i.removeClass("error"),i.parent().hide().siblings(".media-folder_name").show()),p(t.currentTarget).hasClass("name_edit_save")||13==t.keyCode){if(r)return;i.parent().addClass("submitting").append(''),p.ajax({url:BP_Nouveau.ajaxurl,type:"post",data:{action:"document_update_file_name",document_id:e,attachment_document_id:d,document_type:s,name:n,_wpnonce:BP_Nouveau.nonces.media},success:function(e){e.success?void 0!==e.data.document&&0 ');e.parents("li").each(function(e,t){t=p(t).children("span").clone();i.prepend("",t)}),p(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||p(a).find(".breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0
"),h(".bb-rl-modal-container #bb-rl-folder-privacy").addClass("new-folder-create-privacy"),a.find(".open-popup .error").hide(),bp.Readylaunch&&bp.Readylaunch.initSelect2Scoped&&setTimeout(function(){var e=o.find(".bb-rl-create-popup-"+i+"-wrap");e.length&&e.is(":visible")&&bp.Readylaunch.initSelect2Scoped(e)},150)},closeCreateFolderAlbumInPopup:function(e,t){h(".bb-rl-modal-container .bb-rl-model-footer, .modal-container .bb-model-footer").show(),h(".bb-field-wrap-search").show(),h(".bb-rl-document-open-create-popup-folder").show(),"album"===t&&h(".bb-rl-modal-container:visible .bb-rl-video-open-create-popup-album").show(),h(".bb-rl-location-"+t+"-list-wrap-main").show(),"folder"===t?h("#bp-media-document-prev").show():"album"===t&&((i=h(".bb-field-steps-2")).find("#bp-media-prev").show(),i.find("#bp-video-next").show()),h(".bb-rl-create-popup-"+t+"-wrap").hide(),"album"===t&&h(".bb-rl-media-create-popup-album-submit.loading").removeClass("loading");var i=h(e.currentTarget).closest(".bb-rl-has-folderlocationUI");i.find(".bb-rl-modal-header").children().show(),i.find(".bb-rl-modal-header p").hide()},submitCreateFolderAlbumInPopup:function(e,a,o){e.preventDefault();var d=this,e=h(e.currentTarget),r=e.closest(".open-popup"),n=h(r).find(".bb-rl-"+a+"-create-popup-"+o+"-submit"),t=r.find(".bb-rl-"+o+"-selected-id").val(),s=e.closest(".modal-container, .bb-rl-modal-container").find(".bb-rl-popup-on-fly-create-"+o+"-title"),i=h.trim(s.val());if("document"===a){var l=/[\\/?%*:|"<>]+/g.exec(i),l=Boolean(l);if(""===i||l)return s.addClass("error"),!1;s.removeClass("error")}this.currentTargetParent=t=""===t?0:t;var c=this.currentTargetParent,p=0,b="",m="",u=0;if("group"===this.moveToTypePopup?(b="grouponly",p=this.moveToIdPopup):(m=e.closest(".modal-container, .bb-rl-modal-container").find(".bb-rl-popup-on-fly-create-"+o+' select[id*="-'+o+'-privacy"]'),b=m.val()),""===i)return l="document"===a?g.create_folder_error_title:g.create_album_error_title,alert(l),!1;n.addClass("loading");var f=("video"===a?"media":a)+"_"+o+"_save",v=".location-"+o+"-list";setTimeout(function(){var e={action:f,_wpnonce:w.media,title:i,privacy:b,parent:c,group_id:p};h.ajax({type:"POST",url:y,data:e,async:!1,success:function(e){var t,i;e.success?("document"===a&&h(".document-data-table-head").length&&parseInt(c)===parseInt(g.current_folder)&&(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()),r.find(".bb-rl-location-"+o+"-list-wrap "+v).remove(),r.find(".bb-rl-location-"+o+"-list-wrap").append(e.data.tree_view),t="document"===a?"#"+h(r).attr("id")+".open-popup":r,i="document"===a?e.data.folder_id:e.data.album_id,bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,i),u=i,(""===e.data.tree_view?(r.find(".bb-rl-location-"+o+"-list-wrap").hide(),r.find(".bb-rl-location-"+o+"-list-wrap-main span.bb-rl-no-"+o+"-exists")):(r.find(".bb-rl-location-"+o+"-list-wrap-main span.bb-rl-no-"+o+"-exists").hide(),r.find(".bb-rl-location-"+o+"-list-wrap"))).show(),r.find("ul"+v+" span#"+u).trigger("click"),r.find(".bb-rl-model-footer, .bb-model-footer").show(),"document"===a&&r.find(".bb-rl-model-footer, .bb-model-footer, #bp-media-"+a+"-prev").show(),r.find(".bb-field-wrap-search").show(),r.find(".bb-rl-"+a+"-open-create-popup-"+o).show(),r.find(".bb-rl-location-"+o+"-list-wrap-main").show(),r.find(".bb-rl-create-popup-"+o+"-wrap").hide(),"media"===a&&r.find(".bb-field-steps-2 #bp-media-prev").show(),r.find(".bb-rl-"+o+"-selected-id").val(),r.find(".bb-rl"+o+"-selected-id").val(u),r.find(".bb-rl-modal-header").children().show(),r.find(".bb-rl-modal-header p").hide(),s.val(""),""!==m&&m.val("public"),h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0p(a).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),p(this).hasClass("selected")&&!p(this).hasClass("disabled")?(p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-destination").val(""),p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-selected-id").val("0"),p(a).find(".location-folder-list li.is_active").length?p(a).find(".bb-folder-selected-id").val(p(a).find(".location-folder-list li.is_active").attr("data-id")):p(a).find(".bb-folder-selected-id").val("0")):(p(this).closest(".location-folder-list-wrap-main").find(".location-folder-list li span").removeClass("selected"),p(this).addClass("selected"),p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-destination").val(p(this).text()),p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-selected-id").val(p(this).parent().attr("data-id"))),p(this).closest(".location-folder-list-wrap").find(".location-folder-title").text(p(this).siblings("span").text()).siblings(".location-folder-back").css("display","inline-block"),p(this).siblings("ul").show().siblings("span, i").hide().parent().siblings().hide(),p(this).siblings("ul").children("li").show().children("span,i").show(),p(this).closest(".is_active").removeClass("is_active"),p(a).find("li.is_active").removeClass("is_active"),p(this).parent().addClass("is_active"),p(a).find(".bb-folder-selected-id").val(p(a).find(".location-folder-list li.is_active").attr("data-id")),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").each(function(){p(this).show()}),o===p(a).find(".breadcrumbs-append-ul-li .item > span[data-id]").last().attr("data-id")&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled")),setTimeout(function(){p(a).closest(".bb-activity-media-wrap").find(".bb-activity-media-elem.document-activity").attr("data-parent-id")===(p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").prev():p(a).find(".breadcrumbs-append-ul-li .item > span:last-child")).attr("id")&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled"))},100)}),p(document).on("click",a+" .breadcrumbs-append-ul-li .item span",function(e){var t,i;p(this).parent().hasClass("is-disabled")||p(this).hasClass("more_options")||(t=p(e.currentTarget).attr("data-id"),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(p(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),p(a).find(".bb-folder-selected-id").val(t),p(a).find(".location-folder-list li").hide(),p(a).find(".location-folder-list li.is_active").removeClass("is_active"),p(a).find(".location-folder-list li > span.selected").removeClass("selected"),p(a).find('.location-folder-list li[data-id="'+t+'"]').addClass("is_active").children("span").addClass("selected"),p(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),p(a).find(".location-folder-list li.is_active").children("ul").length&&!p(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):p(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?p(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),"0"===t&&(p(a).find(".location-folder-list").children("li").show().children("span,i").show(),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(BP_Nouveau.media.target_text),p(a).find(".location-folder-back").hide()),p(e.currentTarget).nextAll().remove(),o===p(a).find(".breadcrumbs-append-ul-li .item > span[data-id]").last().attr("data-id")&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled")),e=p(a).find(".location-folder-list .is_active > span"),i=p(''),e.parents("li").each(function(e,t){t=p(t).children("span").clone();i.prepend("",t)}),p(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")),0===p(a).find('.breadcrumbs-append-ul-li .breadcrumb .item > span[data-id="'+t+'"]').length&&p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item").append(p(a).find('.location-folder-list li[data-id="'+t+'"]').children("span").clone()),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||p(a).find(".breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(a).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),p(a).find(".bb-folder-selected-id").val(t))})),p(a).find(".location-folder-list li").each(function(){p(this).children("ul").parent().addClass("has-ul").append('')}),p(a).hasClass("bp-media-move-folder")&&(p(a).find(".location-folder-list li>span").removeClass("is-disabled"),p(a).find('.location-folder-list li>span[id="'+p(a).find(".bp-folder-move").attr("id")+'"]').parent().addClass("is-disabled")),e=p(a).find(".bp-folder-move").attr("id"),0==p(a).find('.location-folder-list li[data-id="'+e+'"]').siblings().length&&p(a).find('.location-folder-list li[data-id="'+e+'"]').parent("ul").addClass("no-folder-list a"),o&&(p(a).find(".location-folder-list li").hide(),p(a).find(".location-folder-list li.is_active").removeClass("is_active"),p(a).find('.location-folder-list li[data-id="'+o+'"]').addClass("is_active"),p(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),p(a).find(".location-folder-list li.is_active").children("ul").length&&!p(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):p(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?p(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(p(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),p(a).find(".bb-folder-selected-id").val(p(a).find(".location-folder-list li.is_active").attr("data-id")),p(a).find('.location-folder-list li[data-id="'+e+'"]').children().hide()),"0"===o&&(p(a).find(".location-folder-list").children("li").show(),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(BP_Nouveau.media.target_text),p(a).find(".location-folder-back").hide()),setTimeout(function(){var e=0,e=(p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").prev():p(a).find(".breadcrumbs-append-ul-li .item > span:last-child")).attr("id");o===parseInt(e)&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled"))},100),e=p(a).find(".location-folder-list .is_active > span"),i=p(''),e.parents("li").each(function(e,t){t=p(t).children("span").clone();i.prepend("",t)}),p(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")))},clearFolderLocationUI:function(e){e=jQuery(e.currentTarget).closest(".has-folderlocationUI");0 ul > li.selected").data("bp-scope")||bp.Nouveau.inject("#media-stream ul.media-list",e.data.media,"prepend"),p("#buddypress #bp-media-single-album").length||(e.data.media_personal_count&&(0 '+e.data.media_personal_count+" "+t)):p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").length?p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count):"1"===BP_Nouveau.bb_enable_content_counts&&((a=document.createElement("span")).setAttribute("class","count"),o=document.createTextNode(e.data.media_personal_count),a.appendChild(o),p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a").append(a))),e.data.media_group_count&&(0
'+e.data.media_group_count+" "+t)):p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").length?p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count):"1"===BP_Nouveau.bb_enable_content_counts&&((o=document.createElement("span")).setAttribute("class","count"),a=document.createTextNode(e.data.media_group_count),o.appendChild(a),p("#buddypress").find(".bp-wrap .users-nav ul li#photos-groups-li a").append(o))),"yes"===BP_Nouveau.media.is_media_directory&&(0
ul > li.selected").data("bp-scope"))?a=e.data.media_all_count:"personal"===o?a=e.data.media_personal_count:"groups"===o&&(a=e.data.media_group_count),t=BP_Nouveau.dir_labels.hasOwnProperty("media")?1===a?BP_Nouveau.dir_labels.media.singular:BP_Nouveau.dir_labels.media.plural:"",p("#buddypress .bb-item-count").html(''+a+" "+t)):(p("#buddypress").find(".media-type-navs ul.media-nav li#media-all a span.count").text(e.data.media_all_count),p("#buddypress").find(".media-type-navs ul.media-nav li#media-personal a span.count").text(e.data.media_personal_count),p("#buddypress").find(".media-type-navs ul.media-nav li#media-groups a span.count").text(e.data.media_group_count)))),void 0!==e.data.album_total_count&&s.updateAlbumCounts(e.data);for(var i=0;i
").removeClass("acomments-view-more--hide"),o.isModal||(o.commentsList.removeClass("active"),o.commentsActivityItem.removeClass("active"))})}},bp.Nouveau.Activity.start())})((bp,jQuery)); \ No newline at end of file diff --git a/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-media.js b/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-media.js index 3df7da8b29a..4eb84fd5ef6 100644 --- a/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-media.js +++ b/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-media.js @@ -955,14 +955,20 @@ window.bp = window.bp || {}; $( 'body .bb-rl-activity-media-elem.bb-rl-media-activity.' + id ).remove(); $( 'body .bb-rl-activity-comments li#bb-rl-acomment-' + activityId ).remove(); - // The "view more comments" modal holds its own copy of the - // activity, and its wrapper duplicates id="buddypress", so - // the ID selector above only ever reaches the page copy. - // When the whole activity is gone, close the modal through - // its real close button so the close handler runs. + // The selectors above also clear the "view more comments" + // modal's copy of the activity, which leaves the modal open + // as an empty shell. When the modal's list has been emptied, + // close it through its real close button so the close + // handler runs; hide the wrapper directly if a theme + // override renamed the button. var $activityModal = $( '#bb-rl-activity-modal:visible' ); - if ( $activityModal.length && $activityModal.find( 'li[data-bp-activity-id="' + activityId + '"]' ).length ) { - $activityModal.find( '.bb-rl-modal-activity-header .bb-rl-close-action-popup' ).trigger( 'click' ); + if ( $activityModal.length && 0 === $activityModal.find( '.bb-rl-modal-activity-body .bb-rl-activity-list li' ).length ) { + var $modalCloseButton = $activityModal.find( '.bb-rl-modal-activity-header .bb-rl-close-action-popup' ); + if ( $modalCloseButton.length ) { + $modalCloseButton.trigger( 'click' ); + } else { + $activityModal.closest( '.bb-rl-activity-model-wrapper' ).hide(); + } } } else { $( 'body #buddypress .bb-rl-activity-list li#bb-rl-activity-' + activityId ).replaceWith( response.data.activity_content ); diff --git a/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-media.min.js b/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-media.min.js index 56e23389248..b059df4bda1 100644 --- a/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-media.min.js +++ b/src/bp-templates/bp-nouveau/readylaunch/js/buddypress-media.min.js @@ -1 +1 @@ -window.bp=window.bp||{},(h=>{var e,g,n,y,v,s,w,l,t;"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},g=(e=BP_Nouveau).media,n=e.document,y=e.ajaxurl,v=e.video,s=e.is_send_ajax_request,w=e.nonces,l=e.activity,t=void 0!==window.BP_Forums_Nouveau&&(window.BP_Forums_Nouveau.media,1)?window.BP_Forums_Nouveau.media:{},bp.Nouveau.Media={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){var e=h("body"),e=(this.current_page=1,this.current_page_existing_media=1,this.current_page_albums=1,this.current_tab=!e.hasClass("single-topic")&&!e.hasClass("single-forum")&&"bp-dropzone-content",this.sort_by="",this.order_by="",this.currentTargetParent=g.current_folder,this.moveToIdPopup=g.move_to_id_popup,this.moveToTypePopup=g.current_type,this.privacySelectorSelect="",this.privacySelectorSpan="",void 0!==window.Dropzone&&(window.Dropzone.autoDiscover=!1),document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:""),e=(this.documentOptions=bp.Readylaunch.Utilities.createDropzoneOptions({dictFileTooBig:g.dictFileTooBig,acceptedFiles:g.document_type,createImageThumbnails:!1,dictDefaultMessage:g.dropzone_document_message,maxFiles:void 0!==n.maxFiles?n.maxFiles:10,maxFilesize:void 0!==n.max_upload_size?n.max_upload_size:2,dictInvalidFileType:n.dictInvalidFileType,dictMaxFilesExceeded:g.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:g.dictCancelUploadConfirmation}),document.getElementsByClassName("forum-post-video-template").length?document.getElementsByClassName("forum-post-video-template")[0].innerHTML:"");this.videoOptions=bp.Readylaunch.Utilities.createDropzoneOptions({dictFileTooBig:v.dictFileTooBig,acceptedFiles:v.video_type,createImageThumbnails:!1,dictDefaultMessage:v.dropzone_video_message,maxFiles:void 0!==v.maxFiles?v.maxFiles:10,maxFilesize:void 0!==v.max_upload_size?v.max_upload_size:2,dictInvalidFileType:v.dictInvalidFileType,dictMaxFilesExceeded:v.video_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:v.dictCancelUploadConfirmation}),h("#bp-media-uploader").hasClass("bp-media-document-uploader")?(e=document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:"",this.options=bp.Readylaunch.Utilities.createDropzoneOptions({dictFileTooBig:g.dictFileTooBig,acceptedFiles:g.document_type,createImageThumbnails:!1,dictDefaultMessage:g.dropzone_document_message,maxFiles:void 0!==n.maxFiles?n.maxFiles:10,maxFilesize:void 0!==n.max_upload_size?n.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:g.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:g.dictCancelUploadConfirmation})):(e=document.getElementsByClassName("forum-post-media-template").length?document.getElementsByClassName("forum-post-media-template")[0].innerHTML:"",this.options=bp.Readylaunch.Utilities.createDropzoneOptions({dictFileTooBig:g.dictFileTooBig,dictDefaultMessage:g.dropzone_media_message,acceptedFiles:"image/*",maxFiles:void 0!==g.maxFiles?g.maxFiles:10,maxFilesize:void 0!==g.max_upload_size?g.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:g.media_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:g.dictCancelUploadConfirmation,maxThumbnailFilesize:void 0!==g.max_upload_size?g.max_upload_size:2})),void 0!==g.dropzone_options&&Object.assign(this.options,g.dropzone_options),this.dropzone_obj=[],this.dropzone_media=[],this.album_id=void 0!==g.album_id&&g.album_id,this.current_folder=void 0!==g.current_folder&&g.current_folder,this.current_group_id=void 0!==g.current_group_id&&g.current_group_id,this.group_id=void 0!==g.group_id&&g.group_id,this.bbp_is_reply_edit=void 0!==t.bbp_is_reply_edit&&t.bbp_is_reply_edit,this.bbp_is_topic_edit=void 0!==t.bbp_is_topic_edit&&t.bbp_is_topic_edit,this.bbp_is_forum_edit=void 0!==t.bbp_is_forum_edit&&t.bbp_is_forum_edit,this.bbp_reply_edit_media=void 0!==t.reply_edit_media?t.reply_edit_media:[],this.bbp_reply_edit_document=void 0!==t.reply_edit_document?t.reply_edit_document:[],this.bbp_reply_edit_video=void 0!==t.reply_edit_video?t.reply_edit_video:[],this.bbp_topic_edit_media=void 0!==t.topic_edit_media?t.topic_edit_media:[],this.bbp_topic_edit_video=void 0!==t.topic_edit_video?t.topic_edit_video:[],this.bbp_topic_edit_document=void 0!==t.topic_edit_document?t.topic_edit_document:[],this.bbp_forum_edit_media=void 0!==t.forum_edit_media?t.forum_edit_media:[],this.bbp_forum_edit_document=void 0!==t.forum_edit_document?t.forum_edit_document:[],this.bbp_forum_edit_video=void 0!==t.forum_edit_video?t.forum_edit_video:[],this.bbp_reply_edit_gif_data=void 0!==t.reply_edit_gif_data?t.reply_edit_gif_data:[],this.bbp_topic_edit_gif_data=void 0!==t.topic_edit_gif_data?t.topic_edit_gif_data:[],this.bbp_forum_edit_gif_data=void 0!==t.forum_edit_gif_data?t.forum_edit_gif_data:[],this.giphy=null,this.gif_offset=0,this.gif_q=null,this.gif_limit=20,this.gif_requests=[],this.gif_data=[],this.gif_container_key=!1,this.reply_topic_allow_delete_media=!1,this.reply_topic_display_post="edit",bp.Nouveau.Media.documentCodeMirror(),h(window).on("scroll resize",function(){bp.Nouveau.Media.documentCodeMirror()})},refreshDirectoryFilter:function(e,t){e=h(document).find("#bb-rl-"+e+"-scope-options");e.length&&(t=e.find('option[data-bp-scope="'+t+'"]')).length&&(t=t.text().trim(),e.val(t).trigger("change"))},updateAlbumCounts:function(e){var t,i,a,o;h("#buddypress #bp-media-single-album").length&&(o=parseInt(e.album_media_count)||0,e=parseInt(e.album_video_count)||0,t=function(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},0<(a=h("#buddypress .bb-album-photo-count")).length&&(0").addClass("media-list item-list bp-list bb-photo-list grid")),0 ").addClass("display")),p("#media-stream div").attr("id","media-folder-document-data-table"),p(".bb-photos-actions").show()),p(".document-data-table-head").length?"yes"===BP_Nouveau.media.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(p(document).find("li#document-personal a").trigger("click"),p(document).find("li#document-personal").trigger("click")):r&&bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"):location.reload(!0),p("#bp-media-post-content").val("");for(var t=0;t
").removeClass("acomments-view-more--hide"),o.isModal||(o.commentsList.removeClass("active"),o.commentsActivityItem.removeClass("active"))):void 0!==t.data&&void 0!==t.data.comments&&((i=n.closest(".activity-item")).hasClass("has-comments")||i.addClass("has-comments"),i=k(".bb-rl-internal-model .bb-rl-activity-comments"),e=o.isModal?i:i.find("[data-activity_id='"+o.activityId+"'][data-parent_comment_id='"+o.parentCommentId+"']"),i=k(k.parseHTML(t.data.comments)),0]+/g.exec(e.val())),d=Boolean(d);if(""===p.trim(e.val())||d)return e.addClass("error"),!1;if(e.removeClass("error"),!a.group_id&&""===p.trim(o.val()))return o.addClass("error"),!1;o.removeClass("error"),i.prop("disabled",!0).addClass("loading");d={action:"document_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:e.val().trim(),privacy:o.val(),album_id:a.current_folder,group_id:a.current_group_id};p(".bb-single-album-header .bp-feedback").remove(),p("#boss-media-create-album-popup .bp-feedback").remove(),p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:d,success:function(e){setTimeout(function(){i.prop("disabled",!1)},500),e.success?(a.closeFolderUploader(t),p(".document-data-table-head").length?"yes"===BP_Nouveau.media.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(p(document).find("li#document-personal a").trigger("click"),p(document).find("li#document-personal").trigger("click")):(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()):location.reload(!0)):alert(e.data.feedback.replace("'","'"))}})},saveChildFolder:function(t){var e=p(t.currentTarget),i=this,a=p("#bp-media-create-child-folder #bb-album-child-title"),o=(t.preventDefault(),/[\\/?%*:|"<>]+/g.exec(a.val())),o=Boolean(o);if(""===p.trim(a.val())||o)return a.addClass("error"),!1;a.removeClass("error"),e.prop("disabled",!0).addClass("loading");o={action:"document_child_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:a.val(),folder_id:i.current_folder,group_id:i.current_group_id};p(".bb-single-album-header .bp-feedback").remove(),p("#boss-media-create-album-popup .bp-feedback").remove(),p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:o,success:function(e){e.success?(i.closeChildFolderUploader(t),location.reload(!0)):alert(e.data.feedback.replace("'","'"))}})},renameChildFolder:function(e){e.preventDefault();var t=p(e.currentTarget),i=this,e=p("#bp-media-edit-child-folder #bb-album-child-title"),a=p("#bp-media-edit-child-folder #bb-folder-privacy"),o=this.currentTargetParent,d=/[\\/?%*:|"<>]+/g.exec(e.val()),d=Boolean(d);if(""===p.trim(e.val())||d)return e.addClass("error"),!1;e.removeClass("error"),t.prop("disabled",!0).addClass("loading");d={action:"document_edit_folder",_wpnonce:BP_Nouveau.nonces.media,title:e.val(),privacy:a.val(),id:o,group_id:i.current_group_id};p(".bb-single-album-header .bp-feedback").remove(),p("#boss-media-create-album-popup .bp-feedback").remove(),p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:d,success:function(e){setTimeout(function(){t.prop("disabled",!1)},500),e.success?window.location.reload(!0):i.current_folder?p("#bp-media-single-album").prepend(e.data.feedback):p("#boss-media-create-album-popup .bb-model-header").after(e.data.feedback)}})},deleteAlbum:function(t){if(t.preventDefault(),!this.album_id)return!1;if(!confirm(BP_Nouveau.media.i18n_strings.album_delete_confirm))return!1;p(t.currentTarget).prop("disabled",!0);var e={action:"media_album_delete",_wpnonce:BP_Nouveau.nonces.media,album_id:this.album_id,group_id:this.group_id};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){e.success?window.location.href=e.data.redirect_url:(alert(BP_Nouveau.media.i18n_strings.album_delete_error),p(t.currentTarget).prop("disabled",!1))}})},deleteFolder:function(t){if(t.preventDefault(),!BP_Nouveau.media.current_folder)return!1;if(!confirm(BP_Nouveau.media.i18n_strings.folder_delete_confirm))return!1;p(t.currentTarget).prop("disabled",!0);var e={action:"document_folder_delete",_wpnonce:BP_Nouveau.nonces.media,folder_id:BP_Nouveau.media.current_folder,group_id:BP_Nouveau.media.current_group_id};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){e.success?window.location.href=e.data.redirect_url:(alert(BP_Nouveau.media.i18n_strings.folder_delete_error),p(t.currentTarget).prop("disabled",!1))}})},addMediaIdsToGroupMessagesForm:function(){p("#bp_group_messages_media").length&&p("#bp_group_messages_media").val(JSON.stringify(this.dropzone_media))},addDocumentIdsToGroupMessagesForm:function(){p("#bp_group_messages_document").length&&p("#bp_group_messages_document").val(JSON.stringify(this.dropzone_media))},addVideoIdsToGroupMessagesForm:function(){p("#bp_group_messages_video").length&&p("#bp_group_messages_video").val(JSON.stringify(this.dropzone_media))},injectMedias:function(t){var i,a,e,o=bp.Nouveau.getStorage("bp-media"),d=o.scope||null,o=o.filter||null;p(t.currentTarget).hasClass("load-more")&&(i=+Number(this.current_page)+1,a=this,e="",t.preventDefault(),p(t.currentTarget).find("a").first().addClass("loading"),p("#buddypress .dir-search input[type=search]").length&&(e=p("#buddypress .dir-search input[type=search]").val()),bp.Nouveau.objectRequest({object:"media",scope:d,filter:o,search_terms:e,page:i,method:"append",target:"#buddypress [data-bp-list] ul.bp-list"}).done(function(e){!0===e.success&&(p(t.currentTarget).remove(),a.current_page=i,jQuery(window).scroll())}))},injectDocuments:function(e){var t,i,a,o=bp.Nouveau.getStorage("bp-document"),d="",s="",n=o.scope||null,r=o.filter||null,l=p(e.currentTarget);l.hasClass("load-more")&&(t=+Number(this.current_page)+1,i=this,a="",e.preventDefault(),l.find("a").first().addClass("loading"),p("#buddypress .dir-search input[type=search]").length&&(a=p("#buddypress .dir-search input[type=search]").val()),s=this.order_by&&this.sort_by?(d=this.sort_by,this.order_by):void 0!==o.extras?(d=o.extras.sort,o.extras.orderby):(d="ASC","title"),bp.Nouveau.objectRequest({object:"document",scope:n,filter:r,search_terms:a,page:t,method:"append",target:"#buddypress [data-bp-list] div#media-folder-document-data-table",order_by:s,sort:d}).done(function(e){!0===e.success&&(l.parent(".pager").remove(),i.current_page=t,jQuery(window).scroll())}))},sortDocuments:function(e){var t=p(e.currentTarget),i=t.data("target"),a="",o="date_created";t.attr("class");switch(i){case"name":o="title";break;case"modified":o="date_modified";break;case"visibility":o="privacy";break;case"group":o="group_id"}t.hasClass("asce")?t.removeClass("asce"):t.addClass("asce");var i=t.hasClass("asce")?"DESC":"ASC",t=(bp.Nouveau.getStorage("bp-document"),{}),t=(t.orderby=o,t.sort=i,"group"!==o&&bp.Nouveau.setStorage("bp-document","extras",t),bp.Nouveau.getStorage("bp-document")),d=t.scope||null,t=t.filter||null;p(e.currentTarget);p("#buddypress .bp-dir-search-form input[type=search]").length&&(a=p("#buddypress .bp-dir-search-form input[type=search]").val()),this.sort_by=i,this.order_by=o,this.current_page=1,bp.Nouveau.objectRequest({object:"document",scope:d,filter:t,search_terms:a,page:1,order_by:o,sort:i,method:"reset",target:"#buddypress [data-bp-list]"}).done()},documentPopupNavigate:function(e){e.preventDefault();var e=p(e.currentTarget),t=e.closest(".bb-field-steps"),i=0==e.closest(".bp-document-listing").length?"#bb-album-child-title":"#bb-album-title";e.closest(".document-options").length&&(i="#bb-album-title"),e.hasClass("bb-field-steps-next")&&""==t.find(i).val().trim()?t.find(i).addClass("error"):(t.find(i).removeClass("error"),t.slideUp(200).siblings(".bb-field-steps").slideDown(200))},uploadDocumentNavigate:function(e){e.preventDefault();var e=p(e.currentTarget),t=p(e).closest("#bp-media-uploader");p(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-document-submit, #bp-media-document-prev, .bp-document-open-create-popup-folder, #bb-document-privacy").show(),0!==Number(p(t).find(".bb-folder-selected-id"))&&p(t).find(".location-folder-list li.is_active").length&&p(t).find(".location-folder-list").scrollTop(p(t).find(".location-folder-list li.is_active").offset().top-p(t).find(".location-folder-list").offset().top),p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(t).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))})):(p(e).hide(),t.find("#bp-media-document-prev, .bp-document-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-folder").length&&p("#bb-document-privacy").hide())},uploadMediaNavigate:function(e){e.preventDefault();var e=p(e.currentTarget),t=p(e).closest(".bp-media-photo-uploader");p(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-submit, #bp-media-prev, .bp-media-open-create-popup-folder.create-album").show(),t.find("#bb-media-privacy").show(),0!==Number(p(t).find(".bb-album-selected-id"))&&p(t).find(".location-album-list li.is_active").length&&p(t).find(".location-album-list").scrollTop(p(t).find(".location-album-list li.is_active").offset().top-p(t).find(".location-album-list").offset().top)):(p(e).hide(),t.find("#bp-media-prev, .bp-media-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-album").length&&p("#bb-media-privacy").hide())},appendMedia:function(t){var i,a,e,o=bp.Nouveau.getStorage("bp-media"),d=o.scope||null,o=o.filter||null;p(t.currentTarget).hasClass("load-more")&&(i=+Number(this.current_page_existing_media)+1,a=this,e="",t.preventDefault(),p(t.currentTarget).find("a").first().addClass("loading"),p("#buddypress .dir-search input[type=search]").length&&(e=p("#buddypress .dir-search input[type=search]").val()),bp.Nouveau.objectRequest({object:"media",scope:d,filter:o,search_terms:e,page:i,method:"append",caller:"bp-existing-media",target:".bp-existing-media-wrap ul.bp-list"}).done(function(e){!0===e.success&&(p(t.currentTarget).remove(),a.current_page_existing_media=i,jQuery(window).scroll())}))},appendAlbums:function(t){var i=+Number(this.current_page_albums)+1,a=this,e=(t.preventDefault(),p(t.currentTarget).find("a").first().addClass("loading"),{action:"media_albums_loader",_wpnonce:BP_Nouveau.nonces.media,page:i});p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){!0===e.success&&(p(t.currentTarget).remove(),p("#albums-dir-list ul.bb-albums-list").fadeOut(100,function(){p("#albums-dir-list ul.bb-albums-list").append(e.data.albums),p(this).fadeIn(100)}),a.current_page_albums=i)}})},toggleSubmitMediaButton:function(){var e=p("#bp-media-submit"),t=p("#bp-media-add-more");"bp-dropzone-content"===this.current_tab?this.dropzone_obj.getAcceptedFiles().length?(e.show(),t.show()):(e.hide(),t.hide()):"bp-existing-media-content"===this.current_tab&&(p('.bp-existing-media-wrap .bb-media-check-wrap [name="bb-media-select"]:checked').length?e.show():e.hide(),t.hide())},playVideo:function(e){e.preventDefault();var t=p(e.currentTarget).find("video").get(0),e=p(e.currentTarget).find(".gif-play-button");1==t.paused?(t.play().catch(function(e){console.debug("GIF play failed:",e)}),e.hide()):(t.pause(),e.show())},isElementInScrollableContainer:function(e){var t=p(e),e=e.getBoundingClientRect(),i=t.closest("#bp-message-thread-list");return(i=(i=i.length?i:t.closest(".bb-modal-activity-body")).length?i:t.closest(".bb-media-model-container .activity-list .activity-item")).length?(i=i[0].getBoundingClientRect(),e.bottom>i.top&&e.top i.left&&e.left '),p(t).text());return p(t).text(BP_Nouveau.media.copy_to_clip_board_text),p("#"+e).val(p(t).attr("href")),p("#"+e).select(),document.execCommand("copy"),setTimeout(function(){p(t).text(i)},2e3),!1},fileActivityActionButton:function(e){e.preventDefault(),p(e.currentTarget).parent().hasClass("copy_download_file_url")||(p(e.currentTarget).closest(".bb-activity-media-elem").toggleClass("is-visible").siblings().removeClass("is-visible").closest(".activity-item").siblings().find(".bb-activity-media-elem").removeClass("is-visible"),p(e.currentTarget).closest(".bb-activity-media-elem").find(".bb_more_dropdown").toggleClass("open").closest(".bb-activity-media-elem").siblings().find(".bb_more_dropdown").removeClass("open").closest(".activity-item").siblings().find(".bb-activity-media-elem .bb_more_dropdown").removeClass("open"),p("body").addClass("document_more_option_open"),p(e.currentTarget).closest(".bb-activity-media-elem").length<1&&(p(e.currentTarget).closest(".bb-photo-thumb").toggleClass("is-visible").parent().siblings().find(".bb-photo-thumb").removeClass("is-visible").removeClass("is-visible"),p(e.currentTarget).closest(".bb-photo-thumb").find(".bb_more_dropdown").toggleClass("open").closest(".bb-photo-thumb").parent().siblings().find(".bb-photo-thumb .bb_more_dropdown").removeClass("open")),"a"!=e.currentTarget.tagName.toLowerCase())||p(e.currentTarget).hasClass("document-action_more")||p(e.currentTarget).hasClass("media-action_more")||(p(e.currentTarget).closest(".bb-activity-media-elem").removeClass("is-visible").find(".bb_more_dropdown").removeClass("open"),p(e.currentTarget).closest(".bb-photo-thumb").removeClass("is-visible").find(".bb_more_dropdown").removeClass("open"))},toggleFileActivityActionButton:function(e){var t;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),!0===e.altKey||!0===e.metaKey||p(t).hasClass("document-action_more")||p(t).parent().hasClass("document-action_more")||p(t).hasClass("media-folder_action__anchor")||p(t).parent().hasClass("media-folder_action__anchor")||p(t).hasClass("media-action_more")||p(t).parent().hasClass("media-action_more")||p(t).hasClass("video-action_more")||p(t).parent().hasClass("video-action_more")?e:(p(".bb-activity-media-elem.is-visible").removeClass("is-visible"),p(".media-folder_items.is-visible").removeClass("is-visible"),p(".bb-photo-thumb.is-visible").removeClass("is-visible"),p(".bb-item-thumb.is-visible").removeClass("is-visible"),p(".bb-activity-video-elem.is-visible").removeClass("is-visible"),p(".video-action-wrap.item-action-wrap.is-visible").removeClass("is-visible"),p(".video-action-wrap .bb_more_dropdown").removeClass("open"),p(".bb-activity-media-elem .bb_more_dropdown").removeClass("open"),p(".bb-photo-thumb .bb_more_dropdown").removeClass("open"),p(".media-folder_items .bb_more_dropdown").removeClass("open"),void p("body").removeClass("document_more_option_open video_more_option_open item_more_option_open"))},toggleCodePreview:function(e){e.preventDefault(),p(e.currentTarget).closest(".document-activity").toggleClass("code-full-view")},documentCodeMirror:function(){p(".document-text:not(.loaded)").each(function(){var e=p(this),t=e.attr("data-extension"),i=e.attr("data-extension");"html"!=t&&"htm"!=t||(i="text/html"),"js"==t?CodeMirror(e[0],{value:e.find(".document-text-file-data-hidden").val(),lineNumbers:!0,theme:"default",readOnly:!0,lineWrapping:!0}):CodeMirror(e[0],{value:e.find(".document-text-file-data-hidden").val(),mode:i,lineNumbers:!0,theme:"default",readOnly:!0,lineWrapping:!0}),e.addClass("loaded"),150 '+e+" "+t)):(t=p(".single-screen-navs.groups-nav").find("ul li#albums-groups-li"),0 '+e+"")))}},bp.Nouveau.Media.Theatre={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){this.bodySelector=p("body"),this.medias=[],this.documents=[],this.current_media=!1,this.current_document=!1,this.current_index=0,this.current_document_index=0,this.is_open_media=!1,this.is_open_document=!1,this.nextLink=p(".bb-next-media"),this.nextDocumentLink=p(".bb-next-document"),this.previousDocumentLink=p(".bb-prev-document"),this.previousLink=p(".bb-prev-media"),this.activity_ajax=!1,this.group_id=void 0!==BP_Nouveau.media.group_id&&BP_Nouveau.media.group_id,this.manage_media=void 0!==BP_Nouveau.media.can_manage_media&&BP_Nouveau.media.can_manage_media,this.manage_document=void 0!==BP_Nouveau.media.can_manage_document&&BP_Nouveau.media.can_manage_document},addListeners:function(){p(document).on("click",".bb-open-media-theatre",this.openTheatre.bind(this)),p(document).on("click",".bb-open-document-theatre",this.openDocumentTheatre.bind(this)),p(document).on("click",".document-detail-wrap-description-popup",this.openDocumentTheatre.bind(this)),p(document).on("click",".bb-close-media-theatre",this.closeTheatre.bind(this)),p(document).on("click",".bb-close-document-theatre",this.closeDocumentTheatre.bind(this)),p(document).on("click",".bb-prev-media",this.previous.bind(this)),p(document).on("click",".bb-next-media",this.next.bind(this)),p(document).on("click",".bb-prev-document",this.previousDocument.bind(this)),p(document).on("click",".bb-next-document",this.nextDocument.bind(this)),p(document).on("bp_activity_ajax_delete_request",this.activityDeleted.bind(this)),p(document).on("click","#bb-media-model-container .media-privacy>li",this.mediaPrivacyChange.bind(this)),p(document).on("click","#bb-media-model-container .document-privacy>li",this.documentPrivacyChange.bind(this)),p(document).on("click","#bb-media-model-container .bb-media-section span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),p(document).on("click","#bb-media-model-container .bb-document-section span.privacy",bp.Nouveau,this.toggleDocumentPrivacyDropdown.bind(this)),p(document).on("click",".bp-add-media-activity-description",this.openMediaActivityDescription.bind(this)),p(document).on("click","#bp-activity-description-new-reset",this.closeMediaActivityDescription.bind(this)),p(document).on("keyup",".bp-edit-media-activity-description #add-activity-description",this.MediaActivityDescriptionUpdate.bind(this)),p(document).on("click","#bp-activity-description-new-submit",this.submitMediaActivityDescription.bind(this)),p(document).click(this.togglePopupDropdown),document.addEventListener("keyup",this.checkPressedKeyDocuments.bind(this)),document.addEventListener("keyup",this.checkPressedKey.bind(this))},checkPressedKey:function(e){var t=this;if(e=e||window.event,!t.is_open_media)return!1;var i=p(e.target).hasClass("ac-input")||"add-activity-description"===p(e.target).attr("id");switch(e.keyCode){case 27:t.closeTheatre(e);break;case 37:if(void 0===t.medias[t.current_index-1]||i)return!1;t.previous(e);break;case 39:if(void 0===t.medias[t.current_index+1]||i)return!1;t.next(e)}},checkPressedKeyDocuments:function(e){e=e||window.event;var t=this;if(!t.is_open_document)return!1;var i=p(e.target).hasClass("ac-input")||"add-activity-description"===p(e.target).attr("id");switch(e.keyCode){case 27:t.closeDocumentTheatre(e);break;case 37:if(void 0===t.documents[t.current_document_index-1]||i)return!1;t.previousDocument(e);break;case 39:if(void 0===t.documents[t.current_document_index+1]||i)return!1;t.nextDocument(e)}},openTheatre:function(e){e.preventDefault();var e=p(e.currentTarget),t=this;if(e.closest("#bp-existing-media-content").length)return!1;t.setupGlobals(),t.setMedias(e),i=e.data("id"),e.data("activity-id"),t.setCurrentMedia(i),t.showMedia(),t.navigationCommands(),t.getParentActivityHtml(e),t.getMediasDescription(),p(".bb-media-model-wrapper.document").hide();var i=document.getElementById(p(".bb-media-model-wrapper.video video").attr("id"));i&&i.pause(),p(".bb-media-model-wrapper.video").hide(),p(".bb-media-model-wrapper.media").show(),bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay"),t.is_open_media=!0,t.bodySelector.addClass("media-modal-open"),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)},getParentActivityHtml:function(e){var t=p("#hidden_parent_id").val(),e=e.closest(".bb-media-model-wrapper").find("#bb-media-model-container .activity-list li.activity-item").data("bp-activity-id");parseInt(t)===parseInt(e)&&(e=p('#bb-media-model-container [data-bp-activity-id="'+t+'"]'),p('[data-bp-activity-id="'+t+'"] > .activity-state').html(p(e).find(".activity-state").html()),p('[data-bp-activity-id="'+t+'"] > .activity-meta').html(p(e).find(".activity-meta").html()),p('[data-bp-activity-id="'+t+'"] > .activity-comments').html(p(e).find(".activity-comments").html())),p("#hidden_parent_id").length&&p("#hidden_parent_id").remove()},getMediasDescription:function(){var e=this,t=(p(".bb-media-info-section .activity-list").addClass("loading").html(''),0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_media.activity_id+'"] .activity-comments'));t.length&&(t=t.find("#ac-form-"+e.current_media.activity_id),e.current_media.parent_activity_comments=!0,t.remove()),!0===e.current_media.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"media_get_media_description",id:e.current_media.id,attachment_id:e.current_media.attachment_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success?(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.description),p(".bb-media-info-section:visible").show(),bp.Nouveau.Media.Theatre.syncPinPostIconToTheatre(),p(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10)):p(".bb-media-info-section.media").hide()}})},openDocumentTheatre:function(e){e.preventDefault();var t=p(e.currentTarget),i=this;if(t.closest("#bp-existing-document-content").length)return!1;t.closest(".document.document-theatre").length&&i.closeDocumentTheatre(e),a=t.data("id"),i.setupGlobals(),i.setDocuments(t),i.setCurrentDocument(a),i.showDocument(),i.navigationDocumentCommands(),i.getParentActivityHtml(t),i.getDocumentsDescription(),-1!==p.inArray(i.current_document.extension,BP_Nouveau.document.mp3_preview_extension.split(","))&&p(e.currentTarget).closest(".bb-activity-media-elem.document-activity").length&&p(e.currentTarget).closest(".bb-activity-media-elem.document-activity").find(".document-audio-wrap").length&&p(e.currentTarget).closest(".bb-activity-media-elem.document-activity").find(".document-audio-wrap audio")[0].pause(),p(".bb-media-model-wrapper.media").hide(),p(".bb-media-model-wrapper.document").show();var a=document.getElementById(p(".bb-media-model-wrapper.video video").attr("id"));a&&(a.pause(),a.src=""),p(".bb-media-model-wrapper.video").hide(),i.is_open_document=!0,i.bodySelector.addClass("document-modal-open"),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay")},500)},resetRemoveActivityCommentsData:function(){var e,t=this,i=!1,a=!1,o=!1,d=!1,s=!1,n=!1;t.current_media.parent_activity_comments&&((i=(d=p('.bb-media-model-wrapper.media [data-bp-activity-id="'+t.current_media.activity_id+'"]')).find(".activity-comments")).length&&(e=i.find("#ac-form-"+t.current_media.activity_id),this.purgeEditActivityForm(e),e.find("#ac-input-"+t.current_media.activity_id).html(""),e.removeClass("has-content has-gif has-media").addClass("root"),i.append(e),e.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(t.current_media.activity_id),i.find(".acomment-display").removeClass("display-focus"),i.find(".comment-item").removeClass("comment-item-focus"),s=i.html(),n=i.attr("class"),i.remove(),(i=p('[data-bp-activity-id="'+t.current_media.activity_id+'"] .activity-comments')).length)&&(i.attr("class",n),0===i.find("#ac-form-"+t.current_media.activity_id).length)&&(i.append(e),i.children("form").removeClass("events-initiated").addClass("not-initialized")),(o=d.find(".activity-state")).length&&(s=o.html(),n=o.attr("class"),o.remove(),(o=p('[data-bp-activity-id="'+t.current_media.activity_id+'"] .activity-state')).length)&&(o.html(s),o.attr("class",n)),(a=d.find(".activity-meta")).length&&(s=a.html(),n=a.attr("class"),a.remove(),(a=p('[data-bp-activity-id="'+t.current_media.activity_id+'"] > .activity-meta')).length)&&(a.html(s),a.attr("class",n)),d.remove()),t.current_document.parent_activity_comments&&((i=(d=p('.bb-media-model-wrapper.document [data-bp-activity-id="'+t.current_document.activity_id+'"]')).find(".activity-comments")).length&&(e=i.find("#ac-form-"+t.current_document.activity_id),this.purgeEditActivityForm(e),e.find("#ac-input-"+t.current_document.activity_id).html(""),e.removeClass("has-content has-gif has-media").addClass("root"),i.append(e),e.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(t.current_document.activity_id),i.find(".acomment-display").removeClass("display-focus"),i.find(".comment-item").removeClass("comment-item-focus"),s=i.html(),n=i.attr("class"),i.remove(),(i=p('[data-bp-activity-id="'+t.current_document.activity_id+'"] .activity-comments')).length)&&(i.attr("class",n),0===i.find("#ac-form-"+t.current_document.activity_id).length&&(i.append(e),i.children("form").removeClass("events-initiated").addClass("not-initialized")),i.find(".document-text.loaded").removeClass("loaded").find(".CodeMirror").remove(),jQuery(window).scroll()),(o=d.find(".activity-state")).length&&(s=o.html(),n=o.attr("class"),o.remove(),(o=p('[data-bp-activity-id="'+t.current_document.activity_id+'"] .activity-state')).length)&&(o.html(s),o.attr("class",n)),(a=d.find(".activity-meta")).length&&(s=a.html(),n=a.attr("class"),a.remove(),(a=p('[data-bp-activity-id="'+t.current_document.activity_id+'"] > .activity-meta')).length)&&(a.html(s),a.attr("class",n)),d.remove()),bp.Nouveau.reportPopUp(),bp.Nouveau.reportActions()},closeTheatre:function(e){e.preventDefault();var t=this,e=p(e.currentTarget);if(p(e).closest(".bb-media-model-wrapper").hasClass("video-theatre"))return!1;p(".bb-media-model-wrapper.media .bb-media-section").find("img").attr("src",""),p(".bb-media-model-wrapper.video .bb-media-section").find("video").length&&videojs(p(".bb-media-model-wrapper.video .bb-media-section").find("video").attr("id")).reset(),p(".bb-media-model-wrapper").hide(),t.is_open_media=!1,t.syncPinPostActivityOnCloseTheatre(e),t.resetRemoveActivityCommentsData(),t.current_media=!1,t.getParentActivityHtml(e),t.bodySelector.removeClass("media-modal-open")},closeDocumentTheatre:function(e){e.preventDefault();var t=this,i=p(document).find(".document-theatre");i.find(".bb-media-section").removeClass("bb-media-no-preview").find(".document-preview").html(""),p(".bb-media-info-section.document").show(),i.hide(),t.is_open_document=!1,t.resetRemoveActivityCommentsData(),t.current_document=!1,t.getParentActivityHtml(p(e.currentTarget)),t.bodySelector.removeClass("document-modal-open")},setMedias:function(e){var t=p(".bb-open-media-theatre"),i=0;if(void 0!==(t=p("body").hasClass("activity")?p(e).closest(".bb-activity-media-wrap").find(".bb-open-media-theatre"):t))for(this.medias=[],i=0;i
").removeClass("acomments-view-more--hide"),o.isModal||(o.commentsList.removeClass("active"),o.commentsActivityItem.removeClass("active"))})}},bp.Nouveau.Activity.start())})((bp,jQuery)); \ No newline at end of file +window.bp=window.bp||{},(k=>{var t,e,u,d,P,r,M,a;"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},bp.Models=bp.Models||{},bp.Models.ACReply=Backbone.Model.extend({defaults:{gif_data:{}}}),t=BP_Nouveau,e=t.ajaxurl,u=t.media,d=t.is_send_ajax_request,P=t.activity,r=t.newest,M=t.show_x_comments,a=t.confirm,bp.Nouveau.Activity={start:function(){bp.Nouveau.Activity.LocalizeActivityVars=t,this.setupGlobals(),this.addListeners()},invokeMediaFn:function(t){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media[t]&&bp.Nouveau.Media[t]()},setupGlobals:function(){this.just_posted=[],this.current_page=1,this.mentions_count=Number(k(bp.Nouveau.objectNavParent+' [data-bp-scope="mentions"]').find("a span").html())||0,this.heartbeat_data={newest:"",highlights:{},last_recorded:0,first_recorded:0,document_title:k(document).prop("title")},void 0!==window.Dropzone&&void 0!==u&&(window.Dropzone.autoDiscover=!1,this.dropzone_options={url:e,timeout:108e5,dictFileTooBig:u.dictFileTooBig,dictDefaultMessage:u.dropzone_media_message,acceptedFiles:"image/*",autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==u.maxFiles?u.maxFiles:10,maxFilesize:void 0!==u.max_upload_size?u.max_upload_size:2,dictMaxFilesExceeded:u.media_dict_file_exceeded,dictCancelUploadConfirmation:u.dictCancelUploadConfirmation,maxThumbnailFilesize:void 0!==u.max_upload_size?u.max_upload_size:2},void 0!==u.dropzone_options)&&Object.assign(this.dropzone_options,u.dropzone_options),this.dropzone_obj=null,this.dropzone_media=[],this.dropzone_document_obj=null,this.dropzone_document=[],this.dropzone_video_obj=null,this.dropzone_video=[],this.models=[],this.InitiatedCommentForms=[],this.activityHasUpdates=!1,this.activityPinHasUpdates=!1,k(".activity-topic-selector").length&&k(".activity-head-bar").length&&!k(".activity-topic-selector").parent().hasClass("bb-rl-activity-filters-container")&&(k(".activity-topic-selector, .activity-topic-selector + .subnav-filters, .activity-topic-selector + .subnav-filters + .activity-head-bar").wrapAll(''),k('').insertAfter(".activity-topic-selector"))},addListeners:function(){function t(){k(".ac-form.not-initialized").each(function(){var t=k(this),e=t.find(".ac-textarea");bp.Nouveau.Activity.toggleMultiMediaOptions(t,e),s&&(t.removeClass("not-initialized"),e=t.find(".ac-input[contenteditable]"),bp.Nouveau.Activity.listenCommentInput(e))})}var e=k("body"),a=k("#buddypress"),i=k(document),o=k("#bb-rl-activity-modal > .bb-rl-modal-activity-body"),n=(e.hasClass("activity-singular")||a.on("bp_heartbeat_send",this.heartbeatSend.bind(this)),a.on("bp_heartbeat_tick",this.heartbeatTick.bind(this)),a.find('[data-bp-list="activity"]:not( #bb-schedule-posts_modal [data-bp-list="activity"] )').on("click","li.load-newest, li.bb-rl-load-more",this.injectActivities.bind(this)),a.on("bp_ajax_request",'[data-bp-list="activity"]',this.scopeLoaded.bind(this)),k("#bb-rl-activity-stream").on("click",".acomments-view-more",this.showActivity),e.on("click",".bb-rl-close-action-popup",this.closeActivity),i.on("activityModalOpened",function(t,e){var a=e.activityId;i.on("click",function(t){!(0'),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html(" "+i+'
'),o.find(".bb-document-section .document-preview .document-text").attr("data-extension",d),t=o.find(".bb-document-section .document-preview .document-text textarea"),"html"===d||"htm"===d?t.val(s):t.html(s),setTimeout(function(){bp.Nouveau.Media.documentCodeMirror()},1e3)):-1!==p.inArray(e.current_document.extension,BP_Nouveau.document.mp3_preview_extension.split(","))?(o.find(".bb-document-section .document-preview").html(''),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html('')):-1!==p.inArray("."+e.current_document.extension,BP_Nouveau.video.video_type.split(","))?(o.find(".bb-document-section").addClass("bb-video-preview"),o.find(".bb-document-section .document-preview").html(''),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),"mov"===e.current_document.extension||"m4v"===e.current_document.extension?o.find(".bb-document-section .document-preview").html(''):o.find(".bb-document-section .document-preview").html(''),p(window).scroll()):e.current_document.full_preview?(o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html("'+i+'
"+i+'
')):(o.find(".bb-document-section").addClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html('")),p(".bb-document-section .bb-document-privacy-wrap"));d.length&&(d.show(),d.parent().show(),d.find("ul.document-privacy li").removeClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",""),(t=d.find("ul.document-privacy").find("li[data-value="+e.current_document.privacy+"]")).addClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",t.text()),d.find(".privacy").removeClass("public").removeClass("loggedin").removeClass("onlyme").removeClass("friends").addClass(e.current_document.privacy),void 0!==BP_Nouveau.activity&&void 0!==e.current_document.activity_id&&0!=e.current_document.activity_id||e.group_id||e.current_document.is_forum||e.current_document.group_id||e.current_document.album_id||!e.can_manage_document||!e.current_document.can_edit||e.current_document.is_message)&&d.parent().hide(),e.navigationDocumentCommands()},next:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.medias[e.current_index+1]?(e.current_index=e.current_index+1,e.current_media.activity_id,e.current_media=e.medias[e.current_index],e.showMedia(),e.getMediasDescription(),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):e.nextLink.hide()},previous:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.medias[e.current_index-1]?(e.current_index=e.current_index-1,e.current_media.activity_id,e.current_media=e.medias[e.current_index],e.showMedia(),e.getMediasDescription(),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):e.previousLink.hide()},nextDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.documents[e.current_document_index+1]?(e.current_document_index=e.current_document_index+1,e.current_document.activity_id,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.nextDocumentLink.hide()},previousDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.documents[e.current_document_index-1]?(e.current_document_index=e.current_document_index-1,e.current_document.activity_id,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.previousDocumentLink.hide()},navigationCommands:function(){var e=this;0==e.current_index&&e.current_index!=e.medias.length-1?(e.previousLink.hide(),e.nextLink.show()):0==e.current_index&&e.current_index==e.medias.length-1?(e.previousLink.hide(),e.nextLink.hide()):e.current_index==e.medias.length-1?(e.previousLink.show(),e.nextLink.hide()):(e.previousLink.show(),e.nextLink.show())},navigationDocumentCommands:function(){var e=this;0==e.current_document_index&&e.current_document_index!=e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.show()):0==e.current_document_index&&e.current_document_index==e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.hide()):e.current_document_index==e.documents.length-1?(e.previousDocumentLink.show(),e.nextDocumentLink.hide()):(e.previousDocumentLink.show(),e.nextDocumentLink.show())},getActivity:function(){var e=this;p(".bb-media-info-section .activity-list").addClass("loading").html(''),void 0!==BP_Nouveau.activity&&e.current_media&&void 0!==e.current_media.activity_id&&0!=e.current_media.activity_id&&!e.current_media.is_forum?(0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_media.activity_id+'"] .activity-comments').length&&(e.current_media.parent_activity_comments=!0),!0===e.current_media.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"media_get_activity",id:e.current_media.activity_id,group_id:_.isUndefined(e.current_media.group_id)?0:e.current_media.group_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success&&(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.activity),p(".bb-media-info-section:visible").show(),jQuery(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10))}})):p(".bb-media-info-section.media").hide()},getDocumentsActivity:function(){var e=this;p(".bb-media-info-section .activity-list").addClass("loading").html(''),void 0!==BP_Nouveau.activity&&e.current_document&&void 0!==e.current_document.activity_id&&0!=e.current_document.activity_id&&!e.current_document.is_forum?(0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_document.activity_id+'"] .activity-comments').length&&(e.current_document.parent_activity_comments=!0),!0===e.current_document.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"document_get_activity",id:e.current_document.activity_id,group_id:_.isUndefined(e.current_document.group_id)?0:e.current_document.group_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success&&(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.activity),p(".bb-media-info-section:visible").show(),jQuery(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10))}})):p(".bb-media-info-section.document").hide()},getDocumentsDescription:function(){var e=this,t=(p(".bb-media-info-section .activity-list").addClass("loading").html(''),0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_document.activity_id+'"] .activity-comments'));t.length&&(t=t.find("#ac-form-"+e.current_document.activity_id),e.current_document.parent_activity_comments=!0,t.remove()),!0===e.current_document.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"document_get_document_description",id:e.current_document.id,attachment_id:e.current_document.attachment_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success?(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.description),p(".bb-media-info-section:visible").show(),bp.Nouveau.Media.Theatre.syncPinPostIconToTheatre(),p(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10)):p(".bb-media-info-section.document").hide()}})},activityDeleted:function(e,t){var i=this,a=0;if(i.is_open_media&&void 0!==t&&"delete_activity"===t.action&&i.current_media.activity_id==t.id){var o=p(document).find('[data-bp-list="media"] .bb-open-media-theatre[data-id="'+i.current_media.id+'"]'),d=o.parents("ul");for(o.closest("li").remove(),0===d.find("li:not(.load-more)").length&&(0'+i+"
.activity-list").children("#activity-"+i)).length&&e.hasClass("bb-pinned")&&0
").removeClass("acomments-view-more--hide"),o.isModal||(o.commentsList.removeClass("active"),o.commentsActivityItem.removeClass("active"))):void 0!==t.data&&void 0!==t.data.comments&&((i=n.closest(".activity-item")).hasClass("has-comments")||i.addClass("has-comments"),i=k(".bb-rl-internal-model .bb-rl-activity-comments"),e=o.isModal?i:i.find("[data-activity_id='"+o.activityId+"'][data-parent_comment_id='"+o.parentCommentId+"']"),i=k(k.parseHTML(t.data.comments)),0{var t,e,u,d,P,r,M,a;"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},bp.Models=bp.Models||{},bp.Models.ACReply=Backbone.Model.extend({defaults:{gif_data:{}}}),t=BP_Nouveau,e=t.ajaxurl,u=t.media,d=t.is_send_ajax_request,P=t.activity,r=t.newest,M=t.show_x_comments,a=t.confirm,bp.Nouveau.Activity={start:function(){bp.Nouveau.Activity.LocalizeActivityVars=t,this.setupGlobals(),this.addListeners()},invokeMediaFn:function(t){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media[t]&&bp.Nouveau.Media[t]()},setupGlobals:function(){this.just_posted=[],this.current_page=1,this.mentions_count=Number(k(bp.Nouveau.objectNavParent+' [data-bp-scope="mentions"]').find("a span").html())||0,this.heartbeat_data={newest:"",highlights:{},last_recorded:0,first_recorded:0,document_title:k(document).prop("title")},void 0!==window.Dropzone&&void 0!==u&&(window.Dropzone.autoDiscover=!1,this.dropzone_options={url:e,timeout:108e5,dictFileTooBig:u.dictFileTooBig,dictDefaultMessage:u.dropzone_media_message,acceptedFiles:"image/*",autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==u.maxFiles?u.maxFiles:10,maxFilesize:void 0!==u.max_upload_size?u.max_upload_size:2,dictMaxFilesExceeded:u.media_dict_file_exceeded,dictCancelUploadConfirmation:u.dictCancelUploadConfirmation,maxThumbnailFilesize:void 0!==u.max_upload_size?u.max_upload_size:2},void 0!==u.dropzone_options)&&Object.assign(this.dropzone_options,u.dropzone_options),this.dropzone_obj=null,this.dropzone_media=[],this.dropzone_document_obj=null,this.dropzone_document=[],this.dropzone_video_obj=null,this.dropzone_video=[],this.models=[],this.InitiatedCommentForms=[],this.activityHasUpdates=!1,this.activityPinHasUpdates=!1,k(".activity-topic-selector").length&&k(".activity-head-bar").length&&!k(".activity-topic-selector").parent().hasClass("bb-rl-activity-filters-container")&&(k(".activity-topic-selector, .activity-topic-selector + .subnav-filters, .activity-topic-selector + .subnav-filters + .activity-head-bar").wrapAll(''),k('').insertAfter(".activity-topic-selector"))},addListeners:function(){function t(){k(".ac-form.not-initialized").each(function(){var t=k(this),e=t.find(".ac-textarea");bp.Nouveau.Activity.toggleMultiMediaOptions(t,e),s&&(t.removeClass("not-initialized"),e=t.find(".ac-input[contenteditable]"),bp.Nouveau.Activity.listenCommentInput(e))})}var e=k("body"),a=k("#buddypress"),i=k(document),o=k("#bb-rl-activity-modal > .bb-rl-modal-activity-body"),n=(e.hasClass("activity-singular")||a.on("bp_heartbeat_send",this.heartbeatSend.bind(this)),a.on("bp_heartbeat_tick",this.heartbeatTick.bind(this)),a.find('[data-bp-list="activity"]:not( #bb-schedule-posts_modal [data-bp-list="activity"] )').on("click","li.load-newest, li.bb-rl-load-more",this.injectActivities.bind(this)),a.on("bp_ajax_request",'[data-bp-list="activity"]',this.scopeLoaded.bind(this)),k("#bb-rl-activity-stream").on("click",".acomments-view-more",this.showActivity),e.on("click",".bb-rl-close-action-popup",this.closeActivity),i.on("activityModalOpened",function(t,e){var a=e.activityId;i.on("click",function(t){!(0 li.bb-edit-privacy a",bp.Nouveau,this.activityPrivacyRedirect.bind(this)),a.find(n).on("click",".activity-privacy>li:not(.bb-edit-privacy)",bp.Nouveau,this.activityPrivacyChange.bind(this)),a.find(n).on("click","span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),k("#bb-rl-media-model-container .bb-rl-activity-list").on("click",".activity-item",bp.Nouveau,this.activityActions.bind(this)),k(".bb-rl-activity-model-wrapper").on("click",".bb-rl-ac-form-placeholder",bp.Nouveau,this.activityRootComment.bind(this)),i.keydown(this.commentFormAction),i.click(this.togglePopupDropdown),k('#buddypress [data-bp-list="activity"], #bb-rl-media-model-container .bb-rl-activity-list, #activity-modal .bb-rl-activity-list, .bb-rl-modal-activity-footer').on("click",".ac-reply-media-button",this.openCommentsMediaUploader.bind(this)),a.find('[data-bp-list="activity"], #bb-rl-media-model-container .bb-rl-activity-list, #bb-rl-activity-modal .bb-rl-activity-list, .bb-rl-modal-activity-footer').on("click",".bb-rl-ac-reply-media-button, .bb-rl-ac-reply-document-button, .bb-rl-ac-reply-video-button, .bb-rl-ac-reply-gif-button",function(t){var e=k(t.currentTarget);e.hasClass("bb-rl-ac-reply-media-button")?this.openCommentsMediaUploader(t):e.hasClass("bb-rl-ac-reply-document-button")?this.openCommentsDocumentUploader(t):e.hasClass("bb-rl-ac-reply-video-button")?this.openCommentsVideoUploader(t):e.hasClass("bb-rl-ac-reply-gif-button")&&this.openGifPicker(t)}.bind(this)),i.on("click",".activity-state-popup_overlay",bp.Nouveau,this.closeActivityState.bind(this)),i.on("click",".activity-state-popup .activity-state-popup_tab_panel a",this.ReactionStatePopupTab),_.isUndefined(P.params.autoload)||k(window).scroll(this.loadMoreActivities),k(document).on("click",".bb-subnav-filters-container .subnav-filters-opener",this.openActivityFilter.bind(this)),k(document).on("click",this.closeActivityFilter.bind(this)),k(document).on("click",".bb-subnav-filters-container .subnav-filters-modal a",this.filterActivity.bind(this)),k(".bb-rl-activity-model-wrapper, .bb-rl-media-model-wrapper").on("click",".acomments-view-more",this.viewMoreComments.bind(this)),i.on("click","#bb-rl-activity-stream .bb-rl-activity-comments .view-more-comments",function(t){t.preventDefault(),k(this).parents("li.activity-item").find(".bb-rl-activity-comments > ul > li.acomments-view-more, .bb-rl-activity-comments > .activity-actions > ul > li.acomments-view-more").trigger("click")}),i.on("click","#bb-rl-activity-stream .activity-state-comments > .comments-count, #bb-rl-activity-stream .groups-meta > .generic-button .acomment-reply, #bb-rl-activity-stream .activity-meta > .generic-button .acomment-reply",function(t){t.preventDefault();var t=k(this).closest(".activity-item"),e=t.data("bp-activity-id");""===t.find(".bb-rl-activity-comments > ul").html()&&bp.Nouveau.Activity.launchActivityPopup(e,"")}),o.on("scroll",this.autoloadMoreComments.bind(this)),o.on("scroll",this.discardGifEmojiPicker.bind(this)),k(".bb-rl-activity-model-wrapper .bb-rl-model-close-button").on("click",this.activitySyncOnModalClose.bind(this)),e.hasClass("activity-permalink"));"1"===d?a.on("bp_ajax_request",'[data-bp-list="activity"]',function(){setTimeout(t,1e3)}):setTimeout(t,1e3),bp.Nouveau.wrapNavigation(".activity-topic-selector ul",120,!0)},openActivityFilter:function(t){t.preventDefault(),k(".bb-subnav-filters-container:not(.bb-subnav-filters-search)").removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false");t=k(t.currentTarget).parent(".bb-subnav-filters-container");t.addClass("active").find(".subnav-filters-opener").attr("aria-expanded","true"),t.find('input[type="search"]').length&&t.find('input[type="search"]').focus()},closeActivityFilter:function(t){k(t.target).closest(".bb-subnav-filters-container").length||k.each(k(".bb-subnav-filters-container"),function(){(!k(this).hasClass("bb-subnav-filters-search")||""===k(this).find('input[name="activity_search"]').val())&&k(this).removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false")})},filterActivity:function(t){t.preventDefault();var t=k(t.currentTarget),e=t.closest(".bb-subnav-filters-container"),a=(t.parent().addClass("selected").siblings().removeClass("selected"),e.removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false"),t.parent().data("filter-label")),e=(e.find(".subnav-filters-opener .selected").text(a||t.text()),bp.Nouveau.Activity.current_page=1,bp.Nouveau.objectNavParent),a="activity",i=k("#buddypress").find('[data-bp-filter="'+a+'"]').first().val(),o="",n="",s="",d="",l=!1,r=!1,c=(k(e+" [data-bp-object].selected").length&&(o=k(e+" [data-bp-object].selected").data("bp-scope"),t.closest("#bb-subnav-filter-show").length)&&(l=!0,k("body").hasClass("my-activity"))&&(r=!(l=!1)),k('#buddypress [data-bp-search="'+a+'"] input[type=search]')),c=(c.length&&(n=c.val()),k(e+" [data-bp-order]").length&&(s=k(e+' [data-bp-order="'+a+'"].selected').data("bp-orderby")),bp.Nouveau.getStorage("bp-"+a)),e=(void 0!==c.extras&&(d=c.extras),bp.Nouveau.Activity.heartbeat_data.last_recorded=0,{object:a,scope:o,filter:i,search_terms:n,extras:d,order_by:s,save_scope:l,event_element:t});r&&(e.user_timeline=!0),bp.Nouveau.objectRequest(e)},heartbeatSend:function(t,e){var a,i=k("#buddypress [data-bp-list] [data-bp-activity-id]"),o=i.not(".bb-pinned").first(),n=(this.heartbeat_data.first_recorded=o.data("bp-timestamp")||0,k(bp.Nouveau.objectNavParent+" [data-bp-orderby=date_updated].selected").length?void 0!==(o=k("#buddypress [data-bp-list] [data-bp-activity-id]:not(.bb-pinned)").first()).data("bb-updated-timestamp")?this.heartbeat_data.first_recorded=o.data("bb-updated-timestamp"):o.length&&void 0!==o.data("bp-activity").date_updated&&""!==o.data("bp-activity").date_updated?(n=o.data("bp-activity").date_updated,n=new Date(n.replace(" ","T")+"Z"),this.heartbeat_data.first_recorded=n.getTime()/1e3):this.heartbeat_data.first_recorded=o.data("bp-timestamp")||0:this.heartbeat_data.first_recorded=k("#buddypress [data-bp-list] [data-bp-activity-id]:not(.bb-pinned)").first().data("bp-timestamp")||0,i.first().data("bp-timestamp")||0),o=(n>this.heartbeat_data.first_recorded&&(this.heartbeat_data.first_recorded=n),(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),e.bp_activity_last_recorded=this.heartbeat_data.last_recorded,k("#buddypress .activity-head-bar .activity-search input[type=search]"));o.length&&(e.bp_activity_last_recorded_search_terms=o.val()),k.extend(e,{bp_heartbeat:((i=k("body.my-activity:not(.activity-singular)")).length?a=bp.Nouveau.getStorage("bp-user-activity")||{scope:"just-me"}:(a=bp.Nouveau.getStorage("bp-activity")||{scope:"all"},k("body.activity.buddypress.groups.single-item").length&&(a.scope="all")),k(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").length&&(n=k(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").data("bp-scope"),void 0!==a.scope&&a.scope===n||(a.scope=n,"undefined"!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request&&(i.length?bp.Nouveau.setStorage("bp-user-activity","scope",n):bp.Nouveau.setStorage("bp-activity","scope",n)))),k(bp.Nouveau.objectNavParent+" [data-bp-order].selected").length&&(a.order_by=k(bp.Nouveau.objectNavParent+" [data-bp-order].selected").data("bp-orderby")),(i=bp.Nouveau.getStorage("bp-activity","topic_id"))&&(e.bp_heartbeat=e.bp_heartbeat||{},e.bp_heartbeat.topic_id=i),a)})},heartbeatTick:function(t,e){var a,i,o,n=bp.Nouveau.objects,s=bp.Nouveau.getStorage("bp-activity","scope"),d=this,l=bp.Nouveau.getStorage("bp-activity","topic_id");void 0!==e&&e.bp_activity_newest_activities&&(e=e.bp_activity_newest_activities,this.heartbeat_data.newest=k.trim(e.activities)+this.heartbeat_data.newest,this.heartbeat_data.last_recorded=Number(e.last_recorded),e=k(this.heartbeat_data.newest).filter(".activity-item"),l&&(a=(e=e.filter(function(){var t=this.dataset.bpActivity?JSON.parse(this.dataset.bpActivity):null,t=t&&void 0!==t.topic_id?t.topic_id:null;return t&&parseInt(t)===parseInt(l)})).length),a=Number(e.length),n.push("mentions"),"all"===s?(k.each(e,function(t,a){a=k(a),k.each(n,function(t,e){-1!==k.inArray("bp-my-"+e,a.get(0).classList)&&(void 0===d.heartbeat_data.highlights[e]?d.heartbeat_data.highlights[e]=[a.data("bp-activity-id")]:-1===k.inArray(a.data("bp-activity-id"),d.heartbeat_data.highlights[e])&&d.heartbeat_data.highlights[e].push(a.data("bp-activity-id")))})}),i=new RegExp("bp-my-("+n.join("|")+")","g"),this.heartbeat_data.newest=this.heartbeat_data.newest.replace(i,""),k(bp.Nouveau.objectNavParent+' [data-bp-scope="all"]').find("a span").html(a)):(this.heartbeat_data.highlights[s]=[],k.each(e,function(t,e){d.heartbeat_data.highlights[s].push(k(e).data("bp-activity-id"))})),k.each(n,function(t,e){var a;void 0!==d.heartbeat_data.highlights[e]&&d.heartbeat_data.highlights[e].length&&(a=0,"mentions"===e&&(a=d.mentions_count),k(bp.Nouveau.objectNavParent+' [data-bp-scope="'+e+'"]').find("a span").html(Number(d.heartbeat_data.highlights[e].length)+a))}),n.pop(),k(document).prop("title","("+a+") "+this.heartbeat_data.document_title),e=(i=k('#buddypress [data-bp-list="activity"]')).find(".load-newest a"),i.first().hasClass("load-newest")?(o=e.html(),e.html(o.replace(/([0-9]+)/,a))):i.find("ul.bb-rl-activity-list").prepend(' '+r+" ("+a+") "),i.find("li.load-newest").trigger("click"),i.trigger("bp_heartbeat_pending",this.heartbeat_data),void 0!==bp.Nouveau)&&bp.Nouveau.reportPopUp()},injectActivities:function(t){var e,a,i,o,n,s=k("body.my-activity:not(.activity-singular)").length?bp.Nouveau.getStorage("bp-user-activity"):bp.Nouveau.getStorage("bp-activity"),d=s.scope||null,s=s.filter||null;k(t.currentTarget).hasClass("load-newest")?(t.preventDefault(),k(t.currentTarget).remove(),n=k.parseHTML(this.heartbeat_data.newest),k.each(n,function(t,e){"LI"===e.nodeName&&k(e).hasClass("just-posted")&&(e=k("#"+k(e).prop("id"))).length&&e.remove()}),(0<(i=(n=k(t.delegateTarget).find(".bb-rl-activity-list")).find(".activity-item").first()).length&&i.hasClass("bb-pinned")?k(i).after(this.heartbeat_data.newest):n.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"===d&&k(bp.Nouveau.objectNavParent+' [data-bp-scope="all"]').find("a span").html(""),"mentions"===d&&(bp.Nouveau.ajax({action:"activity_clear_new_mentions"},"activity"),this.mentions_count=0),k(bp.Nouveau.objectNavParent+' [data-bp-scope="'+d+'"]').find("a span").html(""),void 0!==this.heartbeat_data.highlights[d]&&(this.heartbeat_data.highlights[d]=[]),setTimeout(function(){k(t.delegateTarget).find("[data-bp-activity-id]").removeClass("newest_"+d+"_activity")},3e3),k(document).prop("title",this.heartbeat_data.document_title),jQuery(window).scroll()):k(t.currentTarget).hasClass("bb-rl-load-more")&&(e=Number(this.current_page)+1,a=this,i="",t.preventDefault(),(o=k(t.currentTarget)).find("a").first().addClass("loading"),this.just_posted=[],k(t.delegateTarget).children(".just-posted").each(function(){a.just_posted.push(k(this).data("bp-activity-id"))}),(n=k("#buddypress .activity-search.bp-search input[type=search]")).length&&(i=n.val()),bp.Nouveau.objectRequest({object:"activity",scope:d,filter:s,search_terms:i,page:e,method:"append",exclude_just_posted:this.just_posted.join(","),target:'#buddypress [data-bp-list]:not( #bb-schedule-posts_modal [data-bp-list="activity"] ) ul.bb-rl-list'}).done(function(t){!0===t.success&&(o.remove(),a.current_page=e,jQuery(window).scroll())})),k(".activity-item.bb-closed-comments").find(".edit-activity, .acomment-edit").parents(".generic-button").hide()},hideComments:function(t){var a,i,o,t=k(t.target).find(".bb-rl-activity-comments");t.length&&t.each(function(t,e){o=k(e).children("ul").not(".bb-rl-conflict-activity-ul-li-comment"),!(i=k(o).find("li").not(k(".bb-rl-document-action-class, .bb-rl-media-action-class, .bb-rl-video-action-class"))).length||k("body").hasClass("activity-singular")&&""!==window.location.hash&&k(window.location.hash).length&&0!==k(window.location.hash).closest(".bb-rl-activity-comments").length||(a=k(e).closest(".activity-item"),k("#acomment-comment-"+a.data("bp-activity-id")+" span.comment-count").html(),i.each(function(t,e){if(t"),window.location.hash&&"#"+k(e).attr("id")===window.location.hash)return k(e).parents("li.comment-item").show(),!1;k(e).addClass("bp-hidden").hide()}}),k(o).children(".bp-hidden").length===k(o).children("li").length-1&&k(o).find("li.show-all").length&&k(o).children("li:not(.show-all)").removeClass("bp-hidden").toggle())})},showActivity:function(t){t.preventDefault();var e=k(t.currentTarget).parent(),a=e.data("parent_comment_id"),e=k(e).data("activity_id");k(document).trigger("activityModalOpened",{activityId:e}),k(t.currentTarget).parents(".bb-rl-activity-comments").find(".ac-form").each(function(){var t=k(this),e=k(this).closest(".bb-rl-activity-comments"),a=k(this).closest(".comment-item");t.find(".bb-rl-post-elements-buttons-item.bb-rl-post-emoji").removeClass("active").empty(""),bp.Nouveau.Activity.resetActivityCommentForm(t,"hardReset"),e.append(t),a.find(".bb-rl-acomment-display").removeClass("bb-rl-display-focus"),a.removeClass("bb-rl-comment-item-focus")}),bp.Nouveau.Activity.launchActivityPopup(e,a)},closeActivity:function(t){t.preventDefault();var t=k(t.target).closest(".bb-rl-activity-model-wrapper"),e=t.find(".bb-rl-modal-activity-footer"),a=t.find(".activity-item").data("bp-activity-id"),i=t.find("#ac-form-"+a),i=(i.length&&bp.Nouveau.Activity.reinitializeActivityCommentForm(i),_.isUndefined(u)||_.isUndefined(u.emoji)||bp.Nouveau.Activity.initializeEmojioneArea(!1,"",a),a&&bp.Nouveau.Activity.cleanupEmojiEventHandlers(a),k(".bb-rl-emojionearea-theatre"));i.length&&(i.find(".emojionearea-picker").remove(),i.removeClass("show hide").addClass("hide")),t.find("#bb-rl-activity-modal").removeClass("bb-closed-comments"),t.closest("body").removeClass("acomments-modal-open"),t.hide(),t.find("ul.bb-rl-activity-list").empty(),e.removeClass("active"),e.find("form.ac-form").remove(),k("li#bb-rl-activity-"+a).removeClass("has-comments")},scopeLoaded:function(t,a){this.current_page=1;var i=k("#buddypress #bb-rl-activity-stream");"mentions"===a.scope&&void 0!==a.response.new_mentions?(k.each(a.response.new_mentions,function(t,e){i.find('[data-bp-activity-id="'+e+'"]').addClass("newest_mentions_activity")}),this.mentions_count=0):void 0!==this.heartbeat_data.highlights[a.scope]&&this.heartbeat_data.highlights[a.scope].length&&k.each(this.heartbeat_data.highlights[a.scope],function(t,e){i.find('[data-bp-activity-id="'+e+'"]').length&&i.find('[data-bp-activity-id="'+e+'"]').addClass("newest_"+a.scope+"_activity")}),this.heartbeat_data.newest="",k.each(k(bp.Nouveau.objectNavParent+" [data-bp-scope]").find("a span"),function(t,e){"0"===k(e).html()&&k(e).html("")}),void 0!==this.heartbeat_data.highlights[a.scope]&&(this.heartbeat_data.highlights[a.scope]=[]),k(document).prop("title",this.heartbeat_data.document_title),setTimeout(function(){k("#buddypress #bb-rl-activity-stream .activity-item").removeClass("newest_"+a.scope+"_activity")},3e3),setTimeout(function(){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media.autoPlayGifVideos&&bp.Nouveau.Media.autoPlayGifVideos()},200),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 t,e;!_.isUndefined(P.params.is_activity_edit)&&0 ul").html())||a.hasClass("acomment-reply")||a.parent().hasClass("acomment-reply")||a.hasClass("acomment-edit"))&&r.displayingTheCommentForm({event:t,target:a,activityId:o,isInsideModal:m,isInsideMediaTheatre:b,self:r}),a.hasClass("activity-state-no-comments")&&t.preventDefault(),a.hasClass("ac-reply-cancel")&&((c=k(a).closest(".ac-form")).addClass("not-initialized"),k(".acomment-reply").attr("aria-expanded","false"),["media","document"].forEach(function(t){r.destroyUploader(t,o)}),c.closest("li.comment-item").length?r.activityRootComment(t):r.resetActivityCommentForm(c,"hardReset"),t.preventDefault()),"ac_form_submit"===a.prop("name")){if(a.prop("disabled"))return void t.preventDefault();r.submitActivityComment({event:t,parent:e,target:a,activityId:o,isInsideModal:m,activityState:s,commentsText:d,activityItem:i,self:r})}a.hasClass("edit")&&a.hasClass("edit-activity")&&(t.preventDefault(),n=i.data("bp-activity"),l=""!==i.data("link-url")?i.data("link-url"):null,void 0!==n)&&(bp.Nouveau.Activity.postForm.displayEditActivityForm(n,l),k("#bb-rl-activity-form").toggleClass("group-activity",a.closest("li").hasClass("groups")),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)&&k(".bb-rl-close-media-theatre, .bb-close-document-theatre").trigger("click"),m&&(a.hasClass("bb-rl-open-media-theatre")||a.hasClass("bb-open-video-theatre")||a.hasClass("bb-rl-open-document-theatre")||a.hasClass("bb-rl-document-detail-wrap-description-popup")||a.hasClass("bb-rl-document-description-wrap"))&&(t.preventDefault(),a.closest("#bb-rl-activity-modal").find(".bb-rl-modal-activity-header .bb-rl-close-action-popup").trigger("click")),(a.hasClass("pin-activity")||a.hasClass("unpin-activity"))&&r.pinUnpinActivity({event:t,activityId:o,parent:e,target:a,isInsideModal:m}),(a.hasClass("bb-icon-bell-slash")||a.hasClass("bb-icon-bell"))&&r.muteUnmuteNotifications({event:t,activityId:o,parent:e,target:a,isInsideModal:m}),(a.hasClass("close-activity-comment")||a.hasClass("unclose-activity-comment"))&&r.onOffComment({event:t,activityId:o,parent:e,target:a,isInsideModal:m})},commentFormAction:function(t){var e,a;return 3===(e=(t=t||window.event).target||t.srcElement).nodeType&&(e=e.parentNode),!0!==t.altKey&&!0!==t.metaKey&&"TEXTAREA"===e.tagName&&k(e).hasClass("ac-input")?void(27===(a=t.keyCode||t.which)&&!1===t.ctrlKey?k(e).closest("form").slideUp(200):t.ctrlKey&&13===a&&k(e).val()&&k(e).closest("form").find("[type=submit]").first().trigger("click")):t},togglePopupDropdown:function(t){var e;return 3===(e=(t=t||window.event).target||t.srcElement).nodeType&&(e=e.parentNode),!0===t.altKey||!0===t.metaKey||k(e).closest(".privacy-wrap").length?t:void k("ul.activity-privacy").removeClass("bb-open")},loadMoreActivities:function(){var t,e=k(".bb-rl-load-more:visible").last(),a=k(window);0!==e.length&&e.closest(".bb-rl-activity-list").length&&!0!==e.data("bp-autoloaded")&&(t=e.offset().top-50,a.scrollTop()+a.height()>t)&&(e.data("bp-autoloaded",1),e.find("a").text(P.strings.loadingMore),e.find("a").trigger("click"))},openCommentsMediaUploader:function(t){var e,a,i=this,o=k(t.currentTarget),n=o.data("ac-id"),n=o.closest(".bb-rl-ac-form-container").find("#bb-rl-ac-reply-post-media-uploader-"+n),s=0 /gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," "),a=t.text().trim(),t=t.closest("form");""!==a||0<=e.indexOf("emojioneemoji")||t.hasClass("acomment-edit")?t.addClass("has-content"):t.removeClass("has-content")},ReactionStatePopupTab:function(t){t.preventDefault();t=k(this).closest(".activity-state-popup");t.find(".activity-state-popup_tab_panel li a").removeClass("active"),k(this).addClass("active"),t.find(".activity-state-popup_tab_content .activity-state-popup_tab_item").removeClass("active"),t.find("."+k(this).data("tab")).addClass("active")},closeActivityState:function(){k(".activity-state-popup").hide().removeClass("active")},listenCommentInput:function(t){var e,a;0 /gi,"\n").replace(/<\/div>/gi,""));e=e.replace(/ /g," "),""!==k(t.currentTarget).text().trim()||0<=e.indexOf("emojioneemoji")?k(t.currentTarget).closest("form").addClass("has-content"):k(t.currentTarget).closest("form").removeClass("has-content")}),k(t).closest("form").addClass("events-initiated"),this.InitiatedCommentForms.push(e)))},activityRootComment:function(t){var t=k(t.currentTarget).closest("#bb-rl-activity-modal"),e=t.find(".activity-item").data("bp-activity-id"),a=t.find("#ac-form-"+e);bp.Nouveau.Activity.resetActivityCommentForm(a,"hardReset"),t.find(".bb-rl-acomment-display").removeClass("bb-rl-display-focus"),t.find(".comment-item").removeClass("bb-rl-comment-item-focus"),t.find(".bb-rl-modal-activity-footer").addClass("active").append(a),a.addClass("root"),a.find("#ac-input-"+e).focus(),a.find(".bb-rl-ac-reply-content .ac-input").attr("data-placeholder",P.strings.commentPlaceholder),a.find('input[name="ac_form_submit"]').val(P.strings.commentButtonText),bp.Nouveau.Activity.clearFeedbackNotice(a)},clearFeedbackNotice:function(t){t=t.find(".bb-rl-ac-form-container .bp-feedback");t.length&&t.remove()},launchActivityPopup:function(t,e){var a=k("#bb-rl-activity-"+t),i=k(".bb-rl-activity-model-wrapper"),o=a[0].outerHTML,e='[data-parent_comment_id="'+e+'"]',n=a.data("activity-popup-title");bp.Nouveau.Activity.activityHasUpdates=!1,bp.Nouveau.Activity.currentActivityId=null,bp.Nouveau.Activity.activityPinHasUpdates=!1,i.closest("body").addClass("acomments-modal-open"),i.show(),i.find("ul.bb-rl-activity-list").html(o),i.find(".bb-rl-modal-activity-header h2").text(n),0 =t.prop("scrollHeight")?i.addClass("bb-rl-modal-activity-body-scrolled-to-bottom"):i.removeClass("bb-rl-modal-activity-body-scrolled-to-bottom")}),i.find(".bb-rl-modal-activity-body").addClass("bb-rl-modal-activity-body-scroll-event-initiated"))},initialLoadComment:function(t){this.loadMoreComments({target:t.modal.find(".bb-rl-activity-comments"),activityId:t.activityID,parentCommentId:t.parentID||0,isModal:!0})},viewMoreComments:function(t){t.preventDefault();var t=k(t.currentTarget),e=t.parent();this.loadMoreComments({target:t,currentTargetList:t.parent(),activityId:k(e).data("activity_id"),commentsList:t.closest(".bb-rl-activity-comments"),commentsActivityItem:t.closest(".activity-item"),parentCommentId:k(e).data("parent_comment_id"),lastCommentTimestamp:t.prev("li.activity-comment").data("bp-timestamp"),addAfterListItemId:"",lastCommentId:t.prev("li.activity-comment").data("bp-activity-comment-id"),isModal:!1})},autoloadMoreComments:function(){var t,e,a,i,o=k(".bb-rl-activity-model-wrapper");0 ul > li.acomments-view-more:not(.loading), .bb-rl-modal-activity-body .bb-rl-activity-comments .activity-actions > ul > li.acomments-view-more:not(.loading)"),i=(o=o.find(".bb-rl-modal-activity-body")).find(".bb-rl-activity-comments:not(.active)"),0 e&&k(t).trigger("click").addClass("loading"),setTimeout(function(){jQuery(window).scroll()},200))},activitySyncOnModalClose:function(t,e){t.preventDefault();var t=k(t.currentTarget),t=t.is(document)?k(".bb-rl-activity-model-wrapper"):t.parents(".bb-rl-activity-model-wrapper"),t=t.find("ul.bb-rl-activity-list > li").data("bp-activity-id"),e=void 0!==e?e:t,a=k("#bb-rl-activity-stream li.activity-item[data-bp-activity-id="+e+"]");0 /gi,"\n").replace(/<\/div>/gi,""));e=e.replace(/ /g," "),""!==t.text()||0<=e.indexOf("emojioneemoji")?t.closest("form").addClass("has-content"):t.closest("form").removeClass("has-content")},picker_show:function(){k(this.button[0]).closest(".bb-rl-post-emoji").addClass("active"),k(".bb-rl-emojionearea-theatre").removeClass("hide").addClass("show")},picker_hide:function(){k(this.button[0]).closest(".bb-rl-post-emoji").removeClass("active"),k(".bb-rl-emojionearea-theatre").removeClass("show").addClass("hide")}}}),t&&((e=(e=k(n).closest(".modal, .bb-modal, .bb-rl-modal, .activity-modal, .activity-theatre, .bb-rl-screen-content")).length?e:k(n)).on("click"+(t=".bb-rl-emoji-"+s),"#bb-rl-ac-reply-emoji-button-"+s,function(e){var t,a,i,o;k(e.target).closest(".emojionearea-button").length||(t=k(n+"#ac-input-"+s).data("emojioneArea"))&&(i=(a=k(".bb-rl-emojionearea-theatre")).find(".emojionearea-picker"),a.hasClass("show")&&!i.hasClass("hidden")?(t.hidePicker(),a.removeClass("show").addClass("hide"),i.addClass("hidden")):(1<(i=a.find(".emojionearea-picker")).length&&i.remove(),t.showPicker(),a.removeClass("hide").addClass("show"),(o=a.find(".emojionearea-picker")).addClass("hidden"),setTimeout(function(){var t=e.clientX;o.length&&(o.css("transform","translate("+(t+30)+"px, "+(e.clientY-20)+"px) translate(-100%, -100%)"),o.removeClass("hidden"))},50)))}),e.data("emoji-event-namespace-"+s,t)))},cleanupEmojiEventHandlers:function(a){k(".modal, .bb-modal, .bb-rl-modal, .activity-modal, .activity-theatre, .bb-rl-screen-content").each(function(){var t=k(this),e=t.data("emoji-event-namespace-"+a);e&&(t.off(e),t.removeData("emoji-event-namespace-"+a))})},destroyUploader:function(t,e){var a,i=this,i={media:{obj:i.dropzone_obj,dropzone:i.dropzone_media,uploaderId:"#bb-rl-ac-reply-post-media-uploader-",buttonId:"#bb-rl-ac-reply-media-button-",additionalIds:["#bb-rl-ac-reply-post-media-uploader-1-"]},document:{obj:i.dropzone_document_obj,dropzone:i.dropzone_document,uploaderId:"#bb-rl-ac-reply-post-document-uploader-",buttonId:"#bb-rl-ac-reply-document-button-"},video:{obj:i.dropzone_video_obj,dropzone:i.dropzone_video,uploaderId:"#bb-rl-ac-reply-post-video-uploader-",buttonId:"#bb-rl-ac-reply-video-button-"},gif:{buttonId:"#bb-rl-ac-reply-gif-button-",dropdownClass:".bb-rl-gif-media-search-dropdown",standaloneClass:".bb-rl-gif-media-search-dropdown-standalone",modelProperty:"gif_data",containerId:"#bb-rl-ac-reply-post-gif-"}}[t];i&&("gif"!==t&&(a=i.obj,_.isNull(a)||(a.destroy(),k(i.uploaderId+e).html(""),i.additionalIds&&i.additionalIds.forEach(function(t){k(t+e).html("")})),i.dropzone=[],k(i.uploaderId+e).removeClass("open").addClass("closed")),k(i.buttonId+e).removeClass("active"),"gif"===t)&&(k(i.buttonId+e).closest(".bb-rl-post-gif").find(i.dropdownClass).removeClass("open").empty(),k(i.standaloneClass).removeClass("open").empty(),_.isUndefined(this.models[e])||(this.models[e].set(i.modelProperty,{}),k(i.containerId+e).find(".bb-rl-activity-attached-gif-container").removeAttr("style")))},handleFavoriteUnfavorite:function(t){var e,i,o,n,a=t.event,s=(a.preventDefault(),t.parent),d=t.target,l=t.reactionId,r=t.activityState,c=t.bodyElem,m=t.stream,b=t.activityItem;c.hasClass("bb-is-mobile")&&c.hasClass("bb-reactions-mode")&&0===d.closest(".ac-emotion_btn").length&&!0!==a.customTriggered||(d=k(d).is("a")?d:k(d).closest("a")).hasClass("loading")||(d.addClass("loading"),e=d.hasClass("fav")?"fav":"unfav",i=!0,t="activity",c=d.parents(".bb-rl-acomment-display").first(),a=d.attr("data-reacted-id"),0 .bb-rl-activity-content":".activity-comment[data-bp-activity-comment-id="+n+"] > .bb-rl-acomment-display > .bb-rl-acomment_inner").find(".activity-state-reactions").parent().addClass("bb-has-reaction_update"),"fav"===e?void 0===a.data.directory_tab||""===a.data.directory_tab||k(s.objectNavParent+' [data-bp-scope="favorites"]').length||k(s.objectNavParent+' [data-bp-scope="all"]').after(a.data.directory_tab):"unfav"===e&&((t=k('[data-bp-user-scope="favorites"]').hasClass("selected")||k(s.objectNavParent+' [data-bp-scope="favorites"]').hasClass("selected"))&&b.remove(),void 0!==a.data.no_favorite)&&(k(s.objectNavParent+' [data-bp-scope="all"]').length&&k(s.objectNavParent+' [data-bp-scope="all"]').hasClass("selected")?k(s.objectNavParent+' [data-bp-scope="favorites"]').remove():t&&m.append(a.data.no_favorite)))}).fail(function(){d.removeClass("loading")})))},deleteActivity:function(t){t.event.preventDefault();var p,v,u,y=t.parent,h=t.target,f=t.activityState,g=t.activityItem,_=t.commentsText,C=t.activityId,w=h.closest("[data-bp-activity-comment-id]"),N=w.data("bp-activity-comment-id"),j=0,A=h.closest(".bb-rl-activity-comments");if(A.addClass("active"),void 0!==a&&!1===window.confirm(a))return!1;h.addClass("loading");var x={action:"delete_activity",id:C,_wpnonce:y.getLinkParams(h.prop("href"),"_wpnonce"),is_single:h.closest("[data-bp-single]").length};(h.hasClass("spam-activity")||h.hasClass("spam-activity-comment"))&&(x.action="bp_spam_activity"),p=g,N&&(delete x.is_single,x.id=N,x.is_comment=!0,p=w),y.ajax(x,"activity").done(function(t){if(h.removeClass("loading"),!1===t.success)p.append(t.data.feedback),p.find(".bp-feedback").hide().fadeIn(300);else{var e,a,i=p.closest(".has-child-comments"),o=(p.hasClass("has-child-comments")&&(e=p.closest("ul").closest("li")),i.find("> ul"));if(t.data.redirect)return window.location.href=t.data.redirect;if(t.data.parent_activity_id&&t.data.activity&&k("body:not(.activity-singular) #buddypress #bb-rl-activity-stream ul.bb-rl-activity-list li#bb-rl-activity-"+t.data.parent_activity_id).replaceWith(t.data.activity),N){j=1;for(var n=w.find(".acomments-view-more").data("child-count"),n=(g.append(w.find("form")),w.find("li.comment-item").each(function(){j+=1}),j+=void 0!==n?parseFloat(n):0,u=f.find("span.comments-count"),v=u.text().length?u.text().match(/\d+/)[0]:0,v=Number(v-j),_.length?(n=1 ul")).length&&(t=t.html())&&""===t.trim()&&e.removeClass("has-child-comments")}),N||g.data("bp-timestamp")!==y.Activity.heartbeat_data.last_recorded||(y.Activity.heartbeat_data.newest="",y.Activity.heartbeat_data.last_recorded=0),k(document).trigger("bp_activity_ajax_delete_request",k.extend(x,{response:t})),k(document).trigger("bp_activity_ajax_delete_request_video",k.extend(x,{response:t})),bp.Nouveau.Activity.activityHasUpdates=!0,bp.Nouveau.Activity.currentActivityId=C}A.removeClass("active")})},readMoreActivity:function(t){var e=t.event,a=(e.preventDefault(),t.target),i=null,o=t.activityId,n=a.closest("div");if(k(n).hasClass("bb-rl-activity-inner")?i=o:k(n).hasClass("bb-rl-acomment-content")&&(i=a.closest("li").data("bp-activity-comment-id")),!i)return e;var o=t.parent,s=t.activityItem,d=a.closest("span");k(d).addClass("loading"),o.ajax({action:"get_single_activity_content",id:i},"activity").done(function(t){"object"!=typeof t&&0 ul li.comment-item").length+1&&(c=d.parent().closest("li.comment-item")).length?c:d:p.find('[data-bp-activity-comment-id="'+m+'"]'),a&&b.removeClass("active"),r.append(e))),t=e.find('input[name="ac_form_submit"]'),c=!1,(0 @'+c+" "),p=_.isUndefined(P.params.user_id)?"":P.params.user_id,b={offset:-(k(window).height()/2-75),easing:"swing"},l=m.get(0),jQuery("body").hasClass("bb-is-mobile")?setTimeout(function(){var t,e,a=300 /gi,"\n").replace(/<\/div>/gi,"")),I={action:"new_activity_comment",_wpnonce_new_activity_comment:k("#_wpnonce_new_activity_comment").val(),comment_id:A,form_id:y,content:e},t=k("#_bp_as_nonce_"+y).val(),T=(t&&(I["_bp_as_nonce_"+y]=t),this.dropzone_media.length&&(I.media=this.dropzone_media),this.dropzone_document.length&&(I.document=this.dropzone_document),this.dropzone_video.length&&(I.video=this.dropzone_video,_.isEmpty(I.content))&&(I.content=""),_.isUndefined(this.models[y])||(p=this.models[y],I.gif_data=this.models[y].get("gif_data")),I.content=I.content.replace(/ /g," "),j.hasClass("acomment-edit")&&(I.edit_comment=!0),0 "),(T?j.closest("#bb-rl-activity-modal").find(".bb-rl-modal-activity-body .bb-rl-activity-comments, .bb-rl-modal-activity-body .bb-rl-activity-comments .activity-actions"):e).children("ul").append(k(n).hide().fadeIn(200)),k(j).find(".ac-input").first().html(""),e.parent().addClass("has-comments comments-loaded"),f.addClass("has-comments")),j.removeClass("acomment-edit"),j.find(".bb-rl-ac-reply-content"));if([".bb-rl-ac-reply-media-button",".bb-rl-ac-reply-document-button",".bb-rl-ac-reply-video-button",".bb-rl-ac-reply-gif-button"].forEach(function(t){var e=s.find(".bb-rl-ac-reply-toolbar "+t);0 '+P.strings.replyLabel.replace("%d",1)+""),d.addClass("has-child-comments"),d=d.parent().closest(".activity-comment")}i.parent(":not( .has-comments )").addClass("has-comments");n=k(C).find(".show-all a");n&&n.html(M.replace("%d",t))}[w.dropzone_media,w.dropzone_document,w.dropzone_video].forEach(function(t){t&&0 '+t+"")})},pinUnpinActivity:function(t){var e=t.event,a=t.activityId;if(e.preventDefault(),!a)return e;var e=t.parent,l=t.target,r=t.isInsideModal,c=l.closest(".activity-item"),m=(c.addClass("loading-pin"),l.hasClass("unpin-activity")?"unpin":"pin");e.ajax({action:"activity_update_pinned_post",id:a,pin_action:m},"activity").done(function(t){var e,a,i,o,n,s,d;c.removeClass("loading-pin"),void 0!==(t="object"!=typeof t?JSON.parse(t):t).data&&void 0!==t.data.feedback&&(e=l.closest("ul.bb-rl-activity-list"),d=r?l.closest(".bb-rl-wrap").find("#bb-rl-activity-stream"):l.closest("#bb-rl-activity-stream"),t.success&&((""===(s=bp.Nouveau.getStorage("bp-activity","scope"))||!1===s||"undefined"!==BP_Nouveau.is_send_ajax_request&&""===BP_Nouveau.is_send_ajax_request)&&k(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").length&&(s=k(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").data("bp-scope")),a=!1,o="",(i=c.hasClass("groups"))&&(o=(n=c.attr("class").match(/group-\d+/))?n[0].replace("group-",""):""),d.hasClass("single-user")?a=!1:(d.hasClass("activity")&&"all"===s&&!i||d.hasClass("single-group"))&&(a=!0),"pin"==m?(a&&e.find("li.activity-item").removeClass("bb-pinned"),n=i&&!d.hasClass("single-group")?"li.activity-item.group-"+o:"li.activity-item",e.find(n).each(function(){var t=k(this).find(".unpin-activity"),e=(t.removeClass("unpin-activity").addClass("pin-activity"),i?P.strings.pinGroupPost:P.strings.pinPost);t.find("span").html(e)}),a&&c.addClass("bb-pinned"),l.addClass("unpin-activity").removeClass("pin-activity"),s=i?P.strings.unpinGroupPost:P.strings.unpinPost,l.find("span").html(s)):"unpin"==m&&(c.removeClass("bb-pinned"),l.addClass("pin-activity").removeClass("unpin-activity"),d=i?P.strings.pinGroupPost:P.strings.pinPost,l.find("span").html(d)),a)&&(bp.Nouveau.Activity.heartbeat_data.last_recorded=0,bp.Nouveau.refreshActivities()),k(document).trigger("bb_trigger_toast_message",[""," "+t.data.feedback+"","success",null,!0]),r)&&(void 0!==bp.Nouveau.Activity.activityHasUpdates&&(bp.Nouveau.Activity.activityHasUpdates=!0),void 0!==bp.Nouveau.Activity.activityPinHasUpdates)&&(bp.Nouveau.Activity.activityPinHasUpdates=!0)}).fail(function(){l.closest(".activity-item").removeClass("loading-pin"),k(document).trigger("bb_trigger_toast_message",["",""+P.strings.pinPostError+"","error",null,!0])})},muteUnmuteNotifications:function(t){var e=t.event,a=t.parent,i=t.target,o=t.activityId,n=t.isInsideModal;if(i.hasClass("bb-icon-bell-slash")||i.hasClass("bb-icon-bell")){if(e.preventDefault(),!o)return e;var s=i.closest(".activity-item"),d=(s.addClass("loading-mute"),i.hasClass("bb-icon-bell")?"unmute":"mute");a.ajax({action:"toggle_activity_notification_status",id:o,notification_toggle_action:d},"activity").done(function(t){var e;s.removeClass("loading-mute"),void 0!==(t="object"!=typeof t?JSON.parse(t):t).data&&void 0!==t.data.feedback&&(t.success&&("mute"==d?(e=P.strings.unmuteNotification,s.addClass("bb-muted"),i.removeClass("bb-icon-bell-slash"),i.addClass("bb-icon-bell"),i.attr("title",e),i.find("span").html(e)):"unmute"==d&&(e=P.strings.muteNotification,s.removeClass("bb-muted"),i.removeClass("bb-icon-bell"),i.addClass("bb-icon-bell-slash"),i.attr("title",e),i.find("span").html(e)),void 0!==bp.Nouveau.Activity.activityHasUpdates)&&(bp.Nouveau.Activity.activityHasUpdates=!0),k(document).trigger("bb_trigger_toast_message",["",""+t.data.feedback+"","success",null,!0])),n&&(bp.Nouveau.Activity.activityPinHasUpdates=!0),bp.Nouveau.Activity.activityHasUpdates=!0,bp.Nouveau.Activity.currentActivityId=o}).fail(function(){i.closest(".activity-item").removeClass("loading-pin"),k(document).trigger("bb_trigger_toast_message",["",""+P.strings.pinPostError+"","error",null,!0])})}},onOffComment:function(t){var e=t.event,a=t.target,i=t.parent,o=t.activityId;if(e.preventDefault(),!o)return e;var n=a.closest(".activity-item"),s=(n.addClass("loading-pin"),a.hasClass("unclose-activity-comment")?"unclose_comments":"close_comments");i.ajax({action:"activity_update_close_comments",id:o,close_comments_action:s},"activity").done(function(t){var e;n.removeClass("loading-pin"),void 0!==(t="object"!=typeof t?JSON.parse(t):t).data&&void 0!==t.data.feedback&&(t.success&&(e=k("#bb-rl-activity-stream > .bb-rl-activity-list").find("[data-bp-activity-id="+o+"]"),n.find(".bb-rl-activity-closed-comments-notice").remove(),"close_comments"==s?(n.addClass("bb-closed-comments"),0'+t.data.feedback+""),0 '+t.data.feedback+""))):"unclose_comments"==s&&(n.find(".edit-activity, .acomment-edit").parents(".generic-button").show(),n.removeClass("bb-closed-comments"),0 "+t.data.feedback+"",t.success?"success":"error",null,!0]))}).fail(function(){a.closest(".activity-item").removeClass("loading-pin"),k(document).trigger("bb_trigger_toast_message",[""," "+P.strings.closeCommentsError+"","error",null,!0])})},setupDropzoneEventHandlers:function(t){var o=t.self,c=t.dropzoneObj,n=t.target,m=t.type,b=t.dropzoneDataObj;c.on("addedfile",function(t){var e;t[m+"_edit_data"]&&(b.push(t[m+"_edit_data"]),"document"===m&&(e=(e=t.upload.filename).substr(e.lastIndexOf(".")+1),k(t.previewElement).find(".dz-details .dz-icon .bb-icon-file").removeClass("bb-icon-file").addClass("bb-icon-file-"+e)),(e=n.parents(".bb-rl-ac-reply-toolbar")).find(".bb-rl-ac-reply-"+m+"-button"))&&e.find(".bb-rl-ac-reply-"+m+"-button").parents(".bb-rl-post-elements-buttons-item").addClass("no-click").find(".toolbar-button").addClass("active"),"video"===m&&(t.dataURL&&t.video_edit_data.thumb.length?(k(t.previewElement).find(".dz-image").prepend(''),k(t.previewElement).closest(".dz-preview").addClass("dz-has-thumbnail")):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(t,".dz-image"))}),c.on("sending",function(t,e,a){a.append("action","document"===m?m+"_"+m+"_upload":m+"_upload");var i="document"===m?"media":m,o=(a.append("_wpnonce",BP_Nouveau.nonces[i]),n.parents(".bb-rl-ac-reply-toolbar"));n.closest(".ac-form").addClass("has-media"),["media","document","video","gif"].forEach(function(t){var e;o.find(".bb-rl-ac-reply-"+t+"-button")&&(e=o.find(".bb-rl-ac-reply-"+t+"-button").parents(".bb-rl-post-elements-buttons-item"),m===t?e.addClass("no-click").find(".toolbar-button").addClass("active"):e.addClass("disable"))}),this.element.classList.remove("files-uploaded")}),c.on("uploadprogress",function(t){n.closest(".ac-form").addClass("media-uploading");var e=k(t.previewElement).find(".dz-progress-ring circle")[0],a=2*e.r.baseVal.value*Math.PI;e.style.strokeDasharray=a+" "+a,e.style.strokeDashoffset=a-t.upload.progress.toFixed(0)/100*a,k(t.previewElement).find(".dz-progress [data-dz-progress]").text(t.upload.progress.toFixed(0)+"%")}),c.on("success",function(t,e){var a,i;if("document"===m&&(a=(a=t.upload.filename).substr(a.lastIndexOf(".")+1),i=_.isUndefined(e.data.svg_icon)?"":e.data.svg_icon,a=_.isEmpty(i)?"bb-icon-file-"+a:i,k(t.previewElement).find(".dz-details .dz-icon .bb-icons-rl-file").length)&&k(t.previewElement).find(".dz-details .dz-icon .bb-icons-rl-file").removeClass("bb-icons-rl-file").addClass(a),e.data.id)return t.id=e.id,e.data.uuid=t.upload.uuid,e.data.menu_order=k(t.previewElement).closest(".dropzone").find(t.previewElement).index()-1,i="document"===m?"media":m,e.data.album_id=void 0!==BP_Nouveau[i]&&void 0!==BP_Nouveau[i].album_id&&BP_Nouveau[i].album_id,e.data.group_id=void 0!==BP_Nouveau[i]&&void 0!==BP_Nouveau[i].group_id&&BP_Nouveau[i].group_id,e.data.saved=!1,b.push(e.data),t.previewElement.classList.add("dz-success");var o,n,s,d,l,r=e.data.feedback;for(t.previewElement.classList.add("dz-error"),l=[],n=0,s=(d=t.previewElement.querySelectorAll("[data-dz-errormessage]")).length;n
'+e+""),this.removeFile(t),a.removeClass("media-uploading"))}),c.on("removedfile",function(t){if(b.length)for(var e in b)if(t.upload.uuid===b[e].uuid){void 0===b[e].saved||b[e].saved||bp.Nouveau.Media.removeAttachment(b[e].id),b.splice(e,1);break}var a,i;_.isNull(c)||_.isNull(c.files)||0!==c.files.length?n.closest(".ac-form").addClass("has-content"):(a=n.parents(".bb-rl-ac-reply-toolbar"),(i=n.closest(".ac-form")).removeClass("has-media"),["media","document","video","gif"].forEach(function(t){var e;a.find(".bb-rl-ac-reply-"+t+"-button")&&(e=a.find(".bb-rl-ac-reply-"+t+"-button").parents(".bb-rl-post-elements-buttons-item"),m===t?e.removeClass("no-click").find(".toolbar-button").removeClass("active"):e.removeClass("disable"))}),k(c.element).removeClass("files-uploaded dz-progress-view").find(".dz-global-progress").remove(),o.validateCommentContent(i.find(".ac-textarea").children(".ac-input")))}),c.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 '),{action:o.isModal?"bb_rl_activity_loadmore_comments":"activity_loadmore_comments",activity_id:o.activityId,parent_comment_id:o.parentCommentId,offset:o.isModal?0:n.parents(".bb-rl-activity-comments").find('ul[data-parent_comment_id ="'+o.parentCommentId+'"] > li.comment-item:not(.bb-recent-comment)').length,activity_type_is_blog:1"+t.data.message+" "+t.statusText+" li.bb-edit-privacy a",bp.Nouveau,this.activityPrivacyRedirect.bind(this)),a.find(n).on("click",".activity-privacy>li:not(.bb-edit-privacy)",bp.Nouveau,this.activityPrivacyChange.bind(this)),a.find(n).on("click","span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),k("#bb-rl-media-model-container .bb-rl-activity-list").on("click",".activity-item",bp.Nouveau,this.activityActions.bind(this)),k(".bb-rl-activity-model-wrapper").on("click",".bb-rl-ac-form-placeholder",bp.Nouveau,this.activityRootComment.bind(this)),i.keydown(this.commentFormAction),i.click(this.togglePopupDropdown),k('#buddypress [data-bp-list="activity"], #bb-rl-media-model-container .bb-rl-activity-list, #activity-modal .bb-rl-activity-list, .bb-rl-modal-activity-footer').on("click",".ac-reply-media-button",this.openCommentsMediaUploader.bind(this)),a.find('[data-bp-list="activity"], #bb-rl-media-model-container .bb-rl-activity-list, #bb-rl-activity-modal .bb-rl-activity-list, .bb-rl-modal-activity-footer').on("click",".bb-rl-ac-reply-media-button, .bb-rl-ac-reply-document-button, .bb-rl-ac-reply-video-button, .bb-rl-ac-reply-gif-button",function(t){var e=k(t.currentTarget);e.hasClass("bb-rl-ac-reply-media-button")?this.openCommentsMediaUploader(t):e.hasClass("bb-rl-ac-reply-document-button")?this.openCommentsDocumentUploader(t):e.hasClass("bb-rl-ac-reply-video-button")?this.openCommentsVideoUploader(t):e.hasClass("bb-rl-ac-reply-gif-button")&&this.openGifPicker(t)}.bind(this)),i.on("click",".activity-state-popup_overlay",bp.Nouveau,this.closeActivityState.bind(this)),i.on("click",".activity-state-popup .activity-state-popup_tab_panel a",this.ReactionStatePopupTab),_.isUndefined(P.params.autoload)||k(window).scroll(this.loadMoreActivities),k(document).on("click",".bb-subnav-filters-container .subnav-filters-opener",this.openActivityFilter.bind(this)),k(document).on("click",this.closeActivityFilter.bind(this)),k(document).on("click",".bb-subnav-filters-container .subnav-filters-modal a",this.filterActivity.bind(this)),k(".bb-rl-activity-model-wrapper, .bb-rl-media-model-wrapper").on("click",".acomments-view-more",this.viewMoreComments.bind(this)),i.on("click","#bb-rl-activity-stream .bb-rl-activity-comments .view-more-comments",function(t){t.preventDefault(),k(this).parents("li.activity-item").find(".bb-rl-activity-comments > ul > li.acomments-view-more, .bb-rl-activity-comments > .activity-actions > ul > li.acomments-view-more").trigger("click")}),i.on("click","#bb-rl-activity-stream .activity-state-comments > .comments-count, #bb-rl-activity-stream .groups-meta > .generic-button .acomment-reply, #bb-rl-activity-stream .activity-meta > .generic-button .acomment-reply",function(t){t.preventDefault();var t=k(this).closest(".activity-item"),e=t.data("bp-activity-id");""===t.find(".bb-rl-activity-comments > ul").html()&&bp.Nouveau.Activity.launchActivityPopup(e,"")}),o.on("scroll",this.autoloadMoreComments.bind(this)),o.on("scroll",this.discardGifEmojiPicker.bind(this)),k(".bb-rl-activity-model-wrapper .bb-rl-model-close-button").on("click",this.activitySyncOnModalClose.bind(this)),e.hasClass("activity-permalink"));"1"===d?a.on("bp_ajax_request",'[data-bp-list="activity"]',function(){setTimeout(t,1e3)}):setTimeout(t,1e3),bp.Nouveau.wrapNavigation(".activity-topic-selector ul",120,!0)},openActivityFilter:function(t){t.preventDefault(),k(".bb-subnav-filters-container:not(.bb-subnav-filters-search)").removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false");t=k(t.currentTarget).parent(".bb-subnav-filters-container");t.addClass("active").find(".subnav-filters-opener").attr("aria-expanded","true"),t.find('input[type="search"]').length&&t.find('input[type="search"]').focus()},closeActivityFilter:function(t){k(t.target).closest(".bb-subnav-filters-container").length||k.each(k(".bb-subnav-filters-container"),function(){(!k(this).hasClass("bb-subnav-filters-search")||""===k(this).find('input[name="activity_search"]').val())&&k(this).removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false")})},filterActivity:function(t){t.preventDefault();var t=k(t.currentTarget),e=t.closest(".bb-subnav-filters-container"),a=(t.parent().addClass("selected").siblings().removeClass("selected"),e.removeClass("active").find(".subnav-filters-opener").attr("aria-expanded","false"),t.parent().data("filter-label")),e=(e.find(".subnav-filters-opener .selected").text(a||t.text()),bp.Nouveau.Activity.current_page=1,bp.Nouveau.objectNavParent),a="activity",i=k("#buddypress").find('[data-bp-filter="'+a+'"]').first().val(),o="",n="",s="",d="",l=!1,r=!1,c=(k(e+" [data-bp-object].selected").length&&(o=k(e+" [data-bp-object].selected").data("bp-scope"),t.closest("#bb-subnav-filter-show").length)&&(l=!0,k("body").hasClass("my-activity"))&&(r=!(l=!1)),k('#buddypress [data-bp-search="'+a+'"] input[type=search]')),c=(c.length&&(n=c.val()),k(e+" [data-bp-order]").length&&(s=k(e+' [data-bp-order="'+a+'"].selected').data("bp-orderby")),bp.Nouveau.getStorage("bp-"+a)),e=(void 0!==c.extras&&(d=c.extras),bp.Nouveau.Activity.heartbeat_data.last_recorded=0,{object:a,scope:o,filter:i,search_terms:n,extras:d,order_by:s,save_scope:l,event_element:t});r&&(e.user_timeline=!0),bp.Nouveau.objectRequest(e)},heartbeatSend:function(t,e){var a,i=k("#buddypress [data-bp-list] [data-bp-activity-id]"),o=i.not(".bb-pinned").first(),n=(this.heartbeat_data.first_recorded=o.data("bp-timestamp")||0,k(bp.Nouveau.objectNavParent+" [data-bp-orderby=date_updated].selected").length?void 0!==(o=k("#buddypress [data-bp-list] [data-bp-activity-id]:not(.bb-pinned)").first()).data("bb-updated-timestamp")?this.heartbeat_data.first_recorded=o.data("bb-updated-timestamp"):o.length&&void 0!==o.data("bp-activity").date_updated&&""!==o.data("bp-activity").date_updated?(n=o.data("bp-activity").date_updated,n=new Date(n.replace(" ","T")+"Z"),this.heartbeat_data.first_recorded=n.getTime()/1e3):this.heartbeat_data.first_recorded=o.data("bp-timestamp")||0:this.heartbeat_data.first_recorded=k("#buddypress [data-bp-list] [data-bp-activity-id]:not(.bb-pinned)").first().data("bp-timestamp")||0,i.first().data("bp-timestamp")||0),o=(n>this.heartbeat_data.first_recorded&&(this.heartbeat_data.first_recorded=n),(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),e.bp_activity_last_recorded=this.heartbeat_data.last_recorded,k("#buddypress .activity-head-bar .activity-search input[type=search]"));o.length&&(e.bp_activity_last_recorded_search_terms=o.val()),k.extend(e,{bp_heartbeat:((i=k("body.my-activity:not(.activity-singular)")).length?a=bp.Nouveau.getStorage("bp-user-activity")||{scope:"just-me"}:(a=bp.Nouveau.getStorage("bp-activity")||{scope:"all"},k("body.activity.buddypress.groups.single-item").length&&(a.scope="all")),k(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").length&&(n=k(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").data("bp-scope"),void 0!==a.scope&&a.scope===n||(a.scope=n,"undefined"!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request&&(i.length?bp.Nouveau.setStorage("bp-user-activity","scope",n):bp.Nouveau.setStorage("bp-activity","scope",n)))),k(bp.Nouveau.objectNavParent+" [data-bp-order].selected").length&&(a.order_by=k(bp.Nouveau.objectNavParent+" [data-bp-order].selected").data("bp-orderby")),(i=bp.Nouveau.getStorage("bp-activity","topic_id"))&&(e.bp_heartbeat=e.bp_heartbeat||{},e.bp_heartbeat.topic_id=i),a)})},heartbeatTick:function(t,e){var a,i,o,n=bp.Nouveau.objects,s=bp.Nouveau.getStorage("bp-activity","scope"),d=this,l=bp.Nouveau.getStorage("bp-activity","topic_id");void 0!==e&&e.bp_activity_newest_activities&&(e=e.bp_activity_newest_activities,this.heartbeat_data.newest=k.trim(e.activities)+this.heartbeat_data.newest,this.heartbeat_data.last_recorded=Number(e.last_recorded),e=k(this.heartbeat_data.newest).filter(".activity-item"),l&&(a=(e=e.filter(function(){var t=this.dataset.bpActivity?JSON.parse(this.dataset.bpActivity):null,t=t&&void 0!==t.topic_id?t.topic_id:null;return t&&parseInt(t)===parseInt(l)})).length),a=Number(e.length),n.push("mentions"),"all"===s?(k.each(e,function(t,a){a=k(a),k.each(n,function(t,e){-1!==k.inArray("bp-my-"+e,a.get(0).classList)&&(void 0===d.heartbeat_data.highlights[e]?d.heartbeat_data.highlights[e]=[a.data("bp-activity-id")]:-1===k.inArray(a.data("bp-activity-id"),d.heartbeat_data.highlights[e])&&d.heartbeat_data.highlights[e].push(a.data("bp-activity-id")))})}),i=new RegExp("bp-my-("+n.join("|")+")","g"),this.heartbeat_data.newest=this.heartbeat_data.newest.replace(i,""),k(bp.Nouveau.objectNavParent+' [data-bp-scope="all"]').find("a span").html(a)):(this.heartbeat_data.highlights[s]=[],k.each(e,function(t,e){d.heartbeat_data.highlights[s].push(k(e).data("bp-activity-id"))})),k.each(n,function(t,e){var a;void 0!==d.heartbeat_data.highlights[e]&&d.heartbeat_data.highlights[e].length&&(a=0,"mentions"===e&&(a=d.mentions_count),k(bp.Nouveau.objectNavParent+' [data-bp-scope="'+e+'"]').find("a span").html(Number(d.heartbeat_data.highlights[e].length)+a))}),n.pop(),k(document).prop("title","("+a+") "+this.heartbeat_data.document_title),e=(i=k('#buddypress [data-bp-list="activity"]')).find(".load-newest a"),i.first().hasClass("load-newest")?(o=e.html(),e.html(o.replace(/([0-9]+)/,a))):i.find("ul.bb-rl-activity-list").prepend(' '+r+" ("+a+") "),i.find("li.load-newest").trigger("click"),i.trigger("bp_heartbeat_pending",this.heartbeat_data),void 0!==bp.Nouveau)&&bp.Nouveau.reportPopUp()},injectActivities:function(t){var e,a,i,o,n,s=k("body.my-activity:not(.activity-singular)").length?bp.Nouveau.getStorage("bp-user-activity"):bp.Nouveau.getStorage("bp-activity"),d=s.scope||null,s=s.filter||null;k(t.currentTarget).hasClass("load-newest")?(t.preventDefault(),k(t.currentTarget).remove(),n=k.parseHTML(this.heartbeat_data.newest),k.each(n,function(t,e){"LI"===e.nodeName&&k(e).hasClass("just-posted")&&(e=k("#"+k(e).prop("id"))).length&&e.remove()}),(0<(i=(n=k(t.delegateTarget).find(".bb-rl-activity-list")).find(".activity-item").first()).length&&i.hasClass("bb-pinned")?k(i).after(this.heartbeat_data.newest):n.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"===d&&k(bp.Nouveau.objectNavParent+' [data-bp-scope="all"]').find("a span").html(""),"mentions"===d&&(bp.Nouveau.ajax({action:"activity_clear_new_mentions"},"activity"),this.mentions_count=0),k(bp.Nouveau.objectNavParent+' [data-bp-scope="'+d+'"]').find("a span").html(""),void 0!==this.heartbeat_data.highlights[d]&&(this.heartbeat_data.highlights[d]=[]),setTimeout(function(){k(t.delegateTarget).find("[data-bp-activity-id]").removeClass("newest_"+d+"_activity")},3e3),k(document).prop("title",this.heartbeat_data.document_title),jQuery(window).scroll()):k(t.currentTarget).hasClass("bb-rl-load-more")&&(e=Number(this.current_page)+1,a=this,i="",t.preventDefault(),(o=k(t.currentTarget)).find("a").first().addClass("loading"),this.just_posted=[],k(t.delegateTarget).children(".just-posted").each(function(){a.just_posted.push(k(this).data("bp-activity-id"))}),(n=k("#buddypress .activity-search.bp-search input[type=search]")).length&&(i=n.val()),bp.Nouveau.objectRequest({object:"activity",scope:d,filter:s,search_terms:i,page:e,method:"append",exclude_just_posted:this.just_posted.join(","),target:'#buddypress [data-bp-list]:not( #bb-schedule-posts_modal [data-bp-list="activity"] ) ul.bb-rl-list'}).done(function(t){!0===t.success&&(o.remove(),a.current_page=e,jQuery(window).scroll())})),k(".activity-item.bb-closed-comments").find(".edit-activity, .acomment-edit").parents(".generic-button").hide()},hideComments:function(t){var a,i,o,t=k(t.target).find(".bb-rl-activity-comments");t.length&&t.each(function(t,e){o=k(e).children("ul").not(".bb-rl-conflict-activity-ul-li-comment"),!(i=k(o).find("li").not(k(".bb-rl-document-action-class, .bb-rl-media-action-class, .bb-rl-video-action-class"))).length||k("body").hasClass("activity-singular")&&""!==window.location.hash&&k(window.location.hash).length&&0!==k(window.location.hash).closest(".bb-rl-activity-comments").length||(a=k(e).closest(".activity-item"),k("#acomment-comment-"+a.data("bp-activity-id")+" span.comment-count").html(),i.each(function(t,e){if(t"),window.location.hash&&"#"+k(e).attr("id")===window.location.hash)return k(e).parents("li.comment-item").show(),!1;k(e).addClass("bp-hidden").hide()}}),k(o).children(".bp-hidden").length===k(o).children("li").length-1&&k(o).find("li.show-all").length&&k(o).children("li:not(.show-all)").removeClass("bp-hidden").toggle())})},showActivity:function(t){t.preventDefault();var e=k(t.currentTarget).parent(),a=e.data("parent_comment_id"),e=k(e).data("activity_id");k(document).trigger("activityModalOpened",{activityId:e}),k(t.currentTarget).parents(".bb-rl-activity-comments").find(".ac-form").each(function(){var t=k(this),e=k(this).closest(".bb-rl-activity-comments"),a=k(this).closest(".comment-item");t.find(".bb-rl-post-elements-buttons-item.bb-rl-post-emoji").removeClass("active").empty(""),bp.Nouveau.Activity.resetActivityCommentForm(t,"hardReset"),e.append(t),a.find(".bb-rl-acomment-display").removeClass("bb-rl-display-focus"),a.removeClass("bb-rl-comment-item-focus")}),bp.Nouveau.Activity.launchActivityPopup(e,a)},closeActivity:function(t){t.preventDefault();var t=k(t.target).closest(".bb-rl-activity-model-wrapper"),e=t.find(".bb-rl-modal-activity-footer"),a=t.find(".activity-item").data("bp-activity-id"),i=t.find("#ac-form-"+a),i=(i.length&&bp.Nouveau.Activity.reinitializeActivityCommentForm(i),_.isUndefined(u)||_.isUndefined(u.emoji)||bp.Nouveau.Activity.initializeEmojioneArea(!1,"",a),a&&bp.Nouveau.Activity.cleanupEmojiEventHandlers(a),k(".bb-rl-emojionearea-theatre"));i.length&&(i.find(".emojionearea-picker").remove(),i.removeClass("show hide").addClass("hide")),t.find("#bb-rl-activity-modal").removeClass("bb-closed-comments"),t.closest("body").removeClass("acomments-modal-open"),t.hide(),t.find("ul.bb-rl-activity-list").empty(),e.removeClass("active"),e.find("form.ac-form").remove(),k("li#bb-rl-activity-"+a).removeClass("has-comments")},scopeLoaded:function(t,a){this.current_page=1;var i=k("#buddypress #bb-rl-activity-stream");"mentions"===a.scope&&void 0!==a.response.new_mentions?(k.each(a.response.new_mentions,function(t,e){i.find('[data-bp-activity-id="'+e+'"]').addClass("newest_mentions_activity")}),this.mentions_count=0):void 0!==this.heartbeat_data.highlights[a.scope]&&this.heartbeat_data.highlights[a.scope].length&&k.each(this.heartbeat_data.highlights[a.scope],function(t,e){i.find('[data-bp-activity-id="'+e+'"]').length&&i.find('[data-bp-activity-id="'+e+'"]').addClass("newest_"+a.scope+"_activity")}),this.heartbeat_data.newest="",k.each(k(bp.Nouveau.objectNavParent+" [data-bp-scope]").find("a span"),function(t,e){"0"===k(e).html()&&k(e).html("")}),void 0!==this.heartbeat_data.highlights[a.scope]&&(this.heartbeat_data.highlights[a.scope]=[]),k(document).prop("title",this.heartbeat_data.document_title),setTimeout(function(){k("#buddypress #bb-rl-activity-stream .activity-item").removeClass("newest_"+a.scope+"_activity")},3e3),setTimeout(function(){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media.autoPlayGifVideos&&bp.Nouveau.Media.autoPlayGifVideos()},200),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 t,e;!_.isUndefined(P.params.is_activity_edit)&&0 ul").html())||a.hasClass("acomment-reply")||a.parent().hasClass("acomment-reply")||a.hasClass("acomment-edit"))&&r.displayingTheCommentForm({event:t,target:a,activityId:o,isInsideModal:m,isInsideMediaTheatre:b,self:r}),a.hasClass("activity-state-no-comments")&&t.preventDefault(),a.hasClass("ac-reply-cancel")&&((c=k(a).closest(".ac-form")).addClass("not-initialized"),k(".acomment-reply").attr("aria-expanded","false"),["media","document"].forEach(function(t){r.destroyUploader(t,o)}),c.closest("li.comment-item").length?r.activityRootComment(t):r.resetActivityCommentForm(c,"hardReset"),t.preventDefault()),"ac_form_submit"===a.prop("name")){if(a.prop("disabled"))return void t.preventDefault();r.submitActivityComment({event:t,parent:e,target:a,activityId:o,isInsideModal:m,activityState:s,commentsText:d,activityItem:i,self:r})}a.hasClass("edit")&&a.hasClass("edit-activity")&&(t.preventDefault(),n=i.data("bp-activity"),l=""!==i.data("link-url")?i.data("link-url"):null,void 0!==n)&&(bp.Nouveau.Activity.postForm.displayEditActivityForm(n,l),k("#bb-rl-activity-form").toggleClass("group-activity",a.closest("li").hasClass("groups")),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)&&k(".bb-rl-close-media-theatre, .bb-close-document-theatre").trigger("click"),m&&(a.hasClass("bb-rl-open-media-theatre")||a.hasClass("bb-open-video-theatre")||a.hasClass("bb-rl-open-document-theatre")||a.hasClass("bb-rl-document-detail-wrap-description-popup")||a.hasClass("bb-rl-document-description-wrap"))&&(t.preventDefault(),a.closest("#bb-rl-activity-modal").find(".bb-rl-modal-activity-header .bb-rl-close-action-popup").trigger("click")),(a.hasClass("pin-activity")||a.hasClass("unpin-activity"))&&r.pinUnpinActivity({event:t,activityId:o,parent:e,target:a,isInsideModal:m}),(a.hasClass("bb-icon-bell-slash")||a.hasClass("bb-icon-bell"))&&r.muteUnmuteNotifications({event:t,activityId:o,parent:e,target:a,isInsideModal:m}),(a.hasClass("close-activity-comment")||a.hasClass("unclose-activity-comment"))&&r.onOffComment({event:t,activityId:o,parent:e,target:a,isInsideModal:m})},commentFormAction:function(t){var e,a;return 3===(e=(t=t||window.event).target||t.srcElement).nodeType&&(e=e.parentNode),!0!==t.altKey&&!0!==t.metaKey&&"TEXTAREA"===e.tagName&&k(e).hasClass("ac-input")?void(27===(a=t.keyCode||t.which)&&!1===t.ctrlKey?k(e).closest("form").slideUp(200):t.ctrlKey&&13===a&&k(e).val()&&k(e).closest("form").find("[type=submit]").first().trigger("click")):t},togglePopupDropdown:function(t){var e;return 3===(e=(t=t||window.event).target||t.srcElement).nodeType&&(e=e.parentNode),!0===t.altKey||!0===t.metaKey||k(e).closest(".privacy-wrap").length?t:void k("ul.activity-privacy").removeClass("bb-open")},loadMoreActivities:function(){var t,e=k(".bb-rl-load-more:visible").last(),a=k(window);0!==e.length&&e.closest(".bb-rl-activity-list").length&&!0!==e.data("bp-autoloaded")&&(t=e.offset().top-50,a.scrollTop()+a.height()>t)&&(e.data("bp-autoloaded",1),e.find("a").text(P.strings.loadingMore),e.find("a").trigger("click"))},openCommentsMediaUploader:function(t){var e,a,i=this,o=k(t.currentTarget),n=o.data("ac-id"),n=o.closest(".bb-rl-ac-form-container").find("#bb-rl-ac-reply-post-media-uploader-"+n),s=0 /gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," "),a=t.text().trim(),t=t.closest("form");""!==a||0<=e.indexOf("emojioneemoji")||t.hasClass("acomment-edit")?t.addClass("has-content"):t.removeClass("has-content")},ReactionStatePopupTab:function(t){t.preventDefault();t=k(this).closest(".activity-state-popup");t.find(".activity-state-popup_tab_panel li a").removeClass("active"),k(this).addClass("active"),t.find(".activity-state-popup_tab_content .activity-state-popup_tab_item").removeClass("active"),t.find("."+k(this).data("tab")).addClass("active")},closeActivityState:function(){k(".activity-state-popup").hide().removeClass("active")},listenCommentInput:function(t){var e,a;0 /gi,"\n").replace(/<\/div>/gi,""));e=e.replace(/ /g," "),""!==k(t.currentTarget).text().trim()||0<=e.indexOf("emojioneemoji")?k(t.currentTarget).closest("form").addClass("has-content"):k(t.currentTarget).closest("form").removeClass("has-content")}),k(t).closest("form").addClass("events-initiated"),this.InitiatedCommentForms.push(e)))},activityRootComment:function(t){var t=k(t.currentTarget).closest("#bb-rl-activity-modal"),e=t.find(".activity-item").data("bp-activity-id"),a=t.find("#ac-form-"+e);bp.Nouveau.Activity.resetActivityCommentForm(a,"hardReset"),t.find(".bb-rl-acomment-display").removeClass("bb-rl-display-focus"),t.find(".comment-item").removeClass("bb-rl-comment-item-focus"),t.find(".bb-rl-modal-activity-footer").addClass("active").append(a),a.addClass("root"),a.find("#ac-input-"+e).focus(),a.find(".bb-rl-ac-reply-content .ac-input").attr("data-placeholder",P.strings.commentPlaceholder),a.find('input[name="ac_form_submit"]').val(P.strings.commentButtonText),bp.Nouveau.Activity.clearFeedbackNotice(a)},clearFeedbackNotice:function(t){t=t.find(".bb-rl-ac-form-container .bp-feedback");t.length&&t.remove()},launchActivityPopup:function(t,e){var a=k("#bb-rl-activity-"+t),i=k(".bb-rl-activity-model-wrapper"),o=a[0].outerHTML,e='[data-parent_comment_id="'+e+'"]',n=a.data("activity-popup-title");bp.Nouveau.Activity.activityHasUpdates=!1,bp.Nouveau.Activity.currentActivityId=null,bp.Nouveau.Activity.activityPinHasUpdates=!1,i.closest("body").addClass("acomments-modal-open"),i.show(),i.find("ul.bb-rl-activity-list").html(o),i.find(".bb-rl-modal-activity-header h2").text(n),0 =t.prop("scrollHeight")?i.addClass("bb-rl-modal-activity-body-scrolled-to-bottom"):i.removeClass("bb-rl-modal-activity-body-scrolled-to-bottom")}),i.find(".bb-rl-modal-activity-body").addClass("bb-rl-modal-activity-body-scroll-event-initiated"))},initialLoadComment:function(t){this.loadMoreComments({target:t.modal.find(".bb-rl-activity-comments"),activityId:t.activityID,parentCommentId:t.parentID||0,isModal:!0})},viewMoreComments:function(t){t.preventDefault();var t=k(t.currentTarget),e=t.parent();this.loadMoreComments({target:t,currentTargetList:t.parent(),activityId:k(e).data("activity_id"),commentsList:t.closest(".bb-rl-activity-comments"),commentsActivityItem:t.closest(".activity-item"),parentCommentId:k(e).data("parent_comment_id"),lastCommentTimestamp:t.prev("li.activity-comment").data("bp-timestamp"),addAfterListItemId:"",lastCommentId:t.prev("li.activity-comment").data("bp-activity-comment-id"),isModal:!1})},autoloadMoreComments:function(){var t,e,a,i,o=k(".bb-rl-activity-model-wrapper");0 ul > li.acomments-view-more:not(.loading), .bb-rl-modal-activity-body .bb-rl-activity-comments .activity-actions > ul > li.acomments-view-more:not(.loading)"),i=(o=o.find(".bb-rl-modal-activity-body")).find(".bb-rl-activity-comments:not(.active)"),0 e&&k(t).trigger("click").addClass("loading"),setTimeout(function(){jQuery(window).scroll()},200))},activitySyncOnModalClose:function(t,e){t.preventDefault();var t=k(t.currentTarget),t=t.is(document)?k(".bb-rl-activity-model-wrapper"):t.parents(".bb-rl-activity-model-wrapper"),t=t.find("ul.bb-rl-activity-list > li").data("bp-activity-id"),e=void 0!==e?e:t,a=k("#bb-rl-activity-stream li.activity-item[data-bp-activity-id="+e+"]");0 /gi,"\n").replace(/<\/div>/gi,""));e=e.replace(/ /g," "),""!==t.text()||0<=e.indexOf("emojioneemoji")?t.closest("form").addClass("has-content"):t.closest("form").removeClass("has-content")},picker_show:function(){k(this.button[0]).closest(".bb-rl-post-emoji").addClass("active"),k(".bb-rl-emojionearea-theatre").removeClass("hide").addClass("show")},picker_hide:function(){k(this.button[0]).closest(".bb-rl-post-emoji").removeClass("active"),k(".bb-rl-emojionearea-theatre").removeClass("show").addClass("hide")}}}),t&&((e=(e=k(n).closest(".modal, .bb-modal, .bb-rl-modal, .activity-modal, .activity-theatre, .bb-rl-screen-content")).length?e:k(n)).on("click"+(t=".bb-rl-emoji-"+s),"#bb-rl-ac-reply-emoji-button-"+s,function(e){var t,a,i,o;k(e.target).closest(".emojionearea-button").length||(t=k(n+"#ac-input-"+s).data("emojioneArea"))&&(i=(a=k(".bb-rl-emojionearea-theatre")).find(".emojionearea-picker"),a.hasClass("show")&&!i.hasClass("hidden")?(t.hidePicker(),a.removeClass("show").addClass("hide"),i.addClass("hidden")):(1<(i=a.find(".emojionearea-picker")).length&&i.remove(),t.showPicker(),a.removeClass("hide").addClass("show"),(o=a.find(".emojionearea-picker")).addClass("hidden"),setTimeout(function(){var t=e.clientX;o.length&&(o.css("transform","translate("+(t+30)+"px, "+(e.clientY-20)+"px) translate(-100%, -100%)"),o.removeClass("hidden"))},50)))}),e.data("emoji-event-namespace-"+s,t)))},cleanupEmojiEventHandlers:function(a){k(".modal, .bb-modal, .bb-rl-modal, .activity-modal, .activity-theatre, .bb-rl-screen-content").each(function(){var t=k(this),e=t.data("emoji-event-namespace-"+a);e&&(t.off(e),t.removeData("emoji-event-namespace-"+a))})},destroyUploader:function(t,e){var a,i=this,i={media:{obj:i.dropzone_obj,dropzone:i.dropzone_media,uploaderId:"#bb-rl-ac-reply-post-media-uploader-",buttonId:"#bb-rl-ac-reply-media-button-",additionalIds:["#bb-rl-ac-reply-post-media-uploader-1-"]},document:{obj:i.dropzone_document_obj,dropzone:i.dropzone_document,uploaderId:"#bb-rl-ac-reply-post-document-uploader-",buttonId:"#bb-rl-ac-reply-document-button-"},video:{obj:i.dropzone_video_obj,dropzone:i.dropzone_video,uploaderId:"#bb-rl-ac-reply-post-video-uploader-",buttonId:"#bb-rl-ac-reply-video-button-"},gif:{buttonId:"#bb-rl-ac-reply-gif-button-",dropdownClass:".bb-rl-gif-media-search-dropdown",standaloneClass:".bb-rl-gif-media-search-dropdown-standalone",modelProperty:"gif_data",containerId:"#bb-rl-ac-reply-post-gif-"}}[t];i&&("gif"!==t&&(a=i.obj,_.isNull(a)||(a.destroy(),k(i.uploaderId+e).html(""),i.additionalIds&&i.additionalIds.forEach(function(t){k(t+e).html("")})),i.dropzone=[],k(i.uploaderId+e).removeClass("open").addClass("closed")),k(i.buttonId+e).removeClass("active"),"gif"===t)&&(k(i.buttonId+e).closest(".bb-rl-post-gif").find(i.dropdownClass).removeClass("open").empty(),k(i.standaloneClass).removeClass("open").empty(),_.isUndefined(this.models[e])||(this.models[e].set(i.modelProperty,{}),k(i.containerId+e).find(".bb-rl-activity-attached-gif-container").removeAttr("style")))},handleFavoriteUnfavorite:function(t){var e,i,o,n,a=t.event,s=(a.preventDefault(),t.parent),d=t.target,l=t.reactionId,r=t.activityState,c=t.bodyElem,m=t.stream,b=t.activityItem;c.hasClass("bb-is-mobile")&&c.hasClass("bb-reactions-mode")&&0===d.closest(".ac-emotion_btn").length&&!0!==a.customTriggered||(d=k(d).is("a")?d:k(d).closest("a")).hasClass("loading")||(d.addClass("loading"),e=d.hasClass("fav")?"fav":"unfav",i=!0,t="activity",c=d.parents(".bb-rl-acomment-display").first(),a=d.attr("data-reacted-id"),0 .bb-rl-activity-content":".activity-comment[data-bp-activity-comment-id="+n+"] > .bb-rl-acomment-display > .bb-rl-acomment_inner").find(".activity-state-reactions").parent().addClass("bb-has-reaction_update"),"fav"===e?void 0===a.data.directory_tab||""===a.data.directory_tab||k(s.objectNavParent+' [data-bp-scope="favorites"]').length||k(s.objectNavParent+' [data-bp-scope="all"]').after(a.data.directory_tab):"unfav"===e&&((t=k('[data-bp-user-scope="favorites"]').hasClass("selected")||k(s.objectNavParent+' [data-bp-scope="favorites"]').hasClass("selected"))&&b.remove(),void 0!==a.data.no_favorite)&&(k(s.objectNavParent+' [data-bp-scope="all"]').length&&k(s.objectNavParent+' [data-bp-scope="all"]').hasClass("selected")?k(s.objectNavParent+' [data-bp-scope="favorites"]').remove():t&&m.append(a.data.no_favorite)))}).fail(function(){d.removeClass("loading")})))},deleteActivity:function(t){t.event.preventDefault();var p,v,u,y=t.parent,h=t.target,f=t.activityState,g=t.activityItem,_=t.commentsText,C=t.activityId,w=h.closest("[data-bp-activity-comment-id]"),N=w.data("bp-activity-comment-id"),j=0,A=h.closest(".bb-rl-activity-comments");if(A.addClass("active"),void 0!==a&&!1===window.confirm(a))return!1;h.addClass("loading");var x={action:"delete_activity",id:C,_wpnonce:y.getLinkParams(h.prop("href"),"_wpnonce"),is_single:h.closest("[data-bp-single]").length};(h.hasClass("spam-activity")||h.hasClass("spam-activity-comment"))&&(x.action="bp_spam_activity"),p=g,N&&(delete x.is_single,x.id=N,x.is_comment=!0,p=w),y.ajax(x,"activity").done(function(t){if(h.removeClass("loading"),!1===t.success)p.append(t.data.feedback),p.find(".bp-feedback").hide().fadeIn(300);else{var e,a,i=p.closest(".has-child-comments"),o=(p.hasClass("has-child-comments")&&(e=p.closest("ul").closest("li")),i.find("> ul"));if(t.data.redirect)return window.location.href=t.data.redirect;if(t.data.parent_activity_id&&t.data.activity&&k("body:not(.activity-singular) #buddypress #bb-rl-activity-stream ul.bb-rl-activity-list li#bb-rl-activity-"+t.data.parent_activity_id).replaceWith(t.data.activity),N){j=1;for(var n=w.find(".acomments-view-more").data("child-count"),n=(g.append(w.find("form")),w.find("li.comment-item").each(function(){j+=1}),j+=void 0!==n?parseFloat(n):0,u=f.find("span.comments-count"),v=u.text().length?u.text().match(/\d+/)[0]:0,v=Number(v-j),_.length?(n=1 ul")).length&&(t=t.html())&&""===t.trim()&&e.removeClass("has-child-comments")}),N||g.data("bp-timestamp")!==y.Activity.heartbeat_data.last_recorded||(y.Activity.heartbeat_data.newest="",y.Activity.heartbeat_data.last_recorded=0),k(document).trigger("bp_activity_ajax_delete_request",k.extend(x,{response:t})),k(document).trigger("bp_activity_ajax_delete_request_video",k.extend(x,{response:t})),bp.Nouveau.Activity.activityHasUpdates=!0,bp.Nouveau.Activity.currentActivityId=C}A.removeClass("active")})},readMoreActivity:function(t){var e=t.event,a=(e.preventDefault(),t.target),i=null,o=t.activityId,n=a.closest("div");if(k(n).hasClass("bb-rl-activity-inner")?i=o:k(n).hasClass("bb-rl-acomment-content")&&(i=a.closest("li").data("bp-activity-comment-id")),!i)return e;var o=t.parent,s=t.activityItem,d=a.closest("span");k(d).addClass("loading"),o.ajax({action:"get_single_activity_content",id:i},"activity").done(function(t){"object"!=typeof t&&0 ul li.comment-item").length+1&&(c=d.parent().closest("li.comment-item")).length?c:d:p.find('[data-bp-activity-comment-id="'+m+'"]'),a&&b.removeClass("active"),r.append(e))),t=e.find('input[name="ac_form_submit"]'),c=!1,(0 @'+c+" "),p=_.isUndefined(P.params.user_id)?"":P.params.user_id,b={offset:-(k(window).height()/2-75),easing:"swing"},l=m.get(0),jQuery("body").hasClass("bb-is-mobile")?setTimeout(function(){var t,e,a=300 /gi,"\n").replace(/<\/div>/gi,"")),I={action:"new_activity_comment",_wpnonce_new_activity_comment:k("#_wpnonce_new_activity_comment").val(),comment_id:A,form_id:y,content:e},t=k("#_bp_as_nonce_"+y).val(),T=(t&&(I["_bp_as_nonce_"+y]=t),this.dropzone_media.length&&(I.media=this.dropzone_media),this.dropzone_document.length&&(I.document=this.dropzone_document),this.dropzone_video.length&&(I.video=this.dropzone_video,_.isEmpty(I.content))&&(I.content=""),_.isUndefined(this.models[y])||(p=this.models[y],I.gif_data=this.models[y].get("gif_data")),I.content=I.content.replace(/ /g," "),j.hasClass("acomment-edit")&&(I.edit_comment=!0),0 "),(T?j.closest("#bb-rl-activity-modal").find(".bb-rl-modal-activity-body .bb-rl-activity-comments, .bb-rl-modal-activity-body .bb-rl-activity-comments .activity-actions"):e).children("ul").append(k(n).hide().fadeIn(200)),k(j).find(".ac-input").first().html(""),e.parent().addClass("has-comments comments-loaded"),f.addClass("has-comments")),j.removeClass("acomment-edit"),j.find(".bb-rl-ac-reply-content"));if([".bb-rl-ac-reply-media-button",".bb-rl-ac-reply-document-button",".bb-rl-ac-reply-video-button",".bb-rl-ac-reply-gif-button"].forEach(function(t){var e=s.find(".bb-rl-ac-reply-toolbar "+t);0 '+P.strings.replyLabel.replace("%d",1)+""),d.addClass("has-child-comments"),d=d.parent().closest(".activity-comment")}i.parent(":not( .has-comments )").addClass("has-comments");n=k(C).find(".show-all a");n&&n.html(M.replace("%d",t))}[w.dropzone_media,w.dropzone_document,w.dropzone_video].forEach(function(t){t&&0 '+t+"")})},pinUnpinActivity:function(t){var e=t.event,a=t.activityId;if(e.preventDefault(),!a)return e;var e=t.parent,l=t.target,r=t.isInsideModal,c=l.closest(".activity-item"),m=(c.addClass("loading-pin"),l.hasClass("unpin-activity")?"unpin":"pin");e.ajax({action:"activity_update_pinned_post",id:a,pin_action:m},"activity").done(function(t){var e,a,i,o,n,s,d;c.removeClass("loading-pin"),void 0!==(t="object"!=typeof t?JSON.parse(t):t).data&&void 0!==t.data.feedback&&(e=l.closest("ul.bb-rl-activity-list"),d=r?l.closest(".bb-rl-wrap").find("#bb-rl-activity-stream"):l.closest("#bb-rl-activity-stream"),t.success&&((""===(s=bp.Nouveau.getStorage("bp-activity","scope"))||!1===s||"undefined"!==BP_Nouveau.is_send_ajax_request&&""===BP_Nouveau.is_send_ajax_request)&&k(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").length&&(s=k(bp.Nouveau.objectNavParent+" #bb-subnav-filter-show [data-bp-scope].selected").data("bp-scope")),a=!1,o="",(i=c.hasClass("groups"))&&(o=(n=c.attr("class").match(/group-\d+/))?n[0].replace("group-",""):""),d.hasClass("single-user")?a=!1:(d.hasClass("activity")&&"all"===s&&!i||d.hasClass("single-group"))&&(a=!0),"pin"==m?(a&&e.find("li.activity-item").removeClass("bb-pinned"),n=i&&!d.hasClass("single-group")?"li.activity-item.group-"+o:"li.activity-item",e.find(n).each(function(){var t=k(this).find(".unpin-activity"),e=(t.removeClass("unpin-activity").addClass("pin-activity"),i?P.strings.pinGroupPost:P.strings.pinPost);t.find("span").html(e)}),a&&c.addClass("bb-pinned"),l.addClass("unpin-activity").removeClass("pin-activity"),s=i?P.strings.unpinGroupPost:P.strings.unpinPost,l.find("span").html(s)):"unpin"==m&&(c.removeClass("bb-pinned"),l.addClass("pin-activity").removeClass("unpin-activity"),d=i?P.strings.pinGroupPost:P.strings.pinPost,l.find("span").html(d)),a)&&(bp.Nouveau.Activity.heartbeat_data.last_recorded=0,bp.Nouveau.refreshActivities()),k(document).trigger("bb_trigger_toast_message",[""," "+t.data.feedback+"","success",null,!0]),r)&&(void 0!==bp.Nouveau.Activity.activityHasUpdates&&(bp.Nouveau.Activity.activityHasUpdates=!0),void 0!==bp.Nouveau.Activity.activityPinHasUpdates)&&(bp.Nouveau.Activity.activityPinHasUpdates=!0)}).fail(function(){l.closest(".activity-item").removeClass("loading-pin"),k(document).trigger("bb_trigger_toast_message",["",""+P.strings.pinPostError+"","error",null,!0])})},muteUnmuteNotifications:function(t){var e=t.event,a=t.parent,i=t.target,o=t.activityId,n=t.isInsideModal;if(i.hasClass("bb-icon-bell-slash")||i.hasClass("bb-icon-bell")){if(e.preventDefault(),!o)return e;var s=i.closest(".activity-item"),d=(s.addClass("loading-mute"),i.hasClass("bb-icon-bell")?"unmute":"mute");a.ajax({action:"toggle_activity_notification_status",id:o,notification_toggle_action:d},"activity").done(function(t){var e;s.removeClass("loading-mute"),void 0!==(t="object"!=typeof t?JSON.parse(t):t).data&&void 0!==t.data.feedback&&(t.success&&("mute"==d?(e=P.strings.unmuteNotification,s.addClass("bb-muted"),i.removeClass("bb-icon-bell-slash"),i.addClass("bb-icon-bell"),i.attr("title",e),i.find("span").html(e)):"unmute"==d&&(e=P.strings.muteNotification,s.removeClass("bb-muted"),i.removeClass("bb-icon-bell"),i.addClass("bb-icon-bell-slash"),i.attr("title",e),i.find("span").html(e)),void 0!==bp.Nouveau.Activity.activityHasUpdates)&&(bp.Nouveau.Activity.activityHasUpdates=!0),k(document).trigger("bb_trigger_toast_message",["",""+t.data.feedback+"","success",null,!0])),n&&(bp.Nouveau.Activity.activityPinHasUpdates=!0),bp.Nouveau.Activity.activityHasUpdates=!0,bp.Nouveau.Activity.currentActivityId=o}).fail(function(){i.closest(".activity-item").removeClass("loading-pin"),k(document).trigger("bb_trigger_toast_message",["",""+P.strings.pinPostError+"","error",null,!0])})}},onOffComment:function(t){var e=t.event,a=t.target,i=t.parent,o=t.activityId;if(e.preventDefault(),!o)return e;var n=a.closest(".activity-item"),s=(n.addClass("loading-pin"),a.hasClass("unclose-activity-comment")?"unclose_comments":"close_comments");i.ajax({action:"activity_update_close_comments",id:o,close_comments_action:s},"activity").done(function(t){var e;n.removeClass("loading-pin"),void 0!==(t="object"!=typeof t?JSON.parse(t):t).data&&void 0!==t.data.feedback&&(t.success&&(e=k("#bb-rl-activity-stream > .bb-rl-activity-list").find("[data-bp-activity-id="+o+"]"),n.find(".bb-rl-activity-closed-comments-notice").remove(),"close_comments"==s?(n.addClass("bb-closed-comments"),0'+t.data.feedback+""),0 '+t.data.feedback+""))):"unclose_comments"==s&&(n.find(".edit-activity, .acomment-edit").parents(".generic-button").show(),n.removeClass("bb-closed-comments"),0 "+t.data.feedback+"",t.success?"success":"error",null,!0]))}).fail(function(){a.closest(".activity-item").removeClass("loading-pin"),k(document).trigger("bb_trigger_toast_message",[""," "+P.strings.closeCommentsError+"","error",null,!0])})},setupDropzoneEventHandlers:function(t){var o=t.self,c=t.dropzoneObj,n=t.target,m=t.type,b=t.dropzoneDataObj;c.on("addedfile",function(t){var e;t[m+"_edit_data"]&&(b.push(t[m+"_edit_data"]),"document"===m&&(e=(e=t.upload.filename).substr(e.lastIndexOf(".")+1),k(t.previewElement).find(".dz-details .dz-icon .bb-icon-file").removeClass("bb-icon-file").addClass("bb-icon-file-"+e)),(e=n.parents(".bb-rl-ac-reply-toolbar")).find(".bb-rl-ac-reply-"+m+"-button"))&&e.find(".bb-rl-ac-reply-"+m+"-button").parents(".bb-rl-post-elements-buttons-item").addClass("no-click").find(".toolbar-button").addClass("active"),"video"===m&&(t.dataURL&&t.video_edit_data.thumb.length?(k(t.previewElement).find(".dz-image").prepend(''),k(t.previewElement).closest(".dz-preview").addClass("dz-has-thumbnail")):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(t,".dz-image"))}),c.on("sending",function(t,e,a){a.append("action","document"===m?m+"_"+m+"_upload":m+"_upload");var i="document"===m?"media":m,o=(a.append("_wpnonce",BP_Nouveau.nonces[i]),n.parents(".bb-rl-ac-reply-toolbar"));n.closest(".ac-form").addClass("has-media"),["media","document","video","gif"].forEach(function(t){var e;o.find(".bb-rl-ac-reply-"+t+"-button")&&(e=o.find(".bb-rl-ac-reply-"+t+"-button").parents(".bb-rl-post-elements-buttons-item"),m===t?e.addClass("no-click").find(".toolbar-button").addClass("active"):e.addClass("disable"))}),this.element.classList.remove("files-uploaded")}),c.on("uploadprogress",function(t){n.closest(".ac-form").addClass("media-uploading");var e=k(t.previewElement).find(".dz-progress-ring circle")[0],a=2*e.r.baseVal.value*Math.PI;e.style.strokeDasharray=a+" "+a,e.style.strokeDashoffset=a-t.upload.progress.toFixed(0)/100*a,k(t.previewElement).find(".dz-progress [data-dz-progress]").text(t.upload.progress.toFixed(0)+"%")}),c.on("success",function(t,e){var a,i;if("document"===m&&(a=(a=t.upload.filename).substr(a.lastIndexOf(".")+1),i=_.isUndefined(e.data.svg_icon)?"":e.data.svg_icon,a=_.isEmpty(i)?"bb-icon-file-"+a:i,k(t.previewElement).find(".dz-details .dz-icon .bb-icons-rl-file").length)&&k(t.previewElement).find(".dz-details .dz-icon .bb-icons-rl-file").removeClass("bb-icons-rl-file").addClass(a),e.data.id)return t.id=e.id,e.data.uuid=t.upload.uuid,e.data.menu_order=k(t.previewElement).closest(".dropzone").find(t.previewElement).index()-1,i="document"===m?"media":m,e.data.album_id=void 0!==BP_Nouveau[i]&&void 0!==BP_Nouveau[i].album_id&&BP_Nouveau[i].album_id,e.data.group_id=void 0!==BP_Nouveau[i]&&void 0!==BP_Nouveau[i].group_id&&BP_Nouveau[i].group_id,e.data.saved=!1,b.push(e.data),t.previewElement.classList.add("dz-success");var o,n,s,d,l,r=e.data.feedback;for(t.previewElement.classList.add("dz-error"),l=[],n=0,s=(d=t.previewElement.querySelectorAll("[data-dz-errormessage]")).length;n
'+e+""),this.removeFile(t),a.removeClass("media-uploading"))}),c.on("removedfile",function(t){if(b.length)for(var e in b)if(t.upload.uuid===b[e].uuid){void 0===b[e].saved||b[e].saved||bp.Nouveau.Media.removeAttachment(b[e].id),b.splice(e,1);break}var a,i;_.isNull(c)||_.isNull(c.files)||0!==c.files.length?n.closest(".ac-form").addClass("has-content"):(a=n.parents(".bb-rl-ac-reply-toolbar"),(i=n.closest(".ac-form")).removeClass("has-media"),["media","document","video","gif"].forEach(function(t){var e;a.find(".bb-rl-ac-reply-"+t+"-button")&&(e=a.find(".bb-rl-ac-reply-"+t+"-button").parents(".bb-rl-post-elements-buttons-item"),m===t?e.removeClass("no-click").find(".toolbar-button").removeClass("active"):e.removeClass("disable"))}),k(c.element).removeClass("files-uploaded dz-progress-view").find(".dz-global-progress").remove(),o.validateCommentContent(i.find(".ac-textarea").children(".ac-input")))}),c.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 '),{action:o.isModal?"bb_rl_activity_loadmore_comments":"activity_loadmore_comments",activity_id:o.activityId,parent_comment_id:o.parentCommentId,offset:o.isModal?0:n.parents(".bb-rl-activity-comments").find('ul[data-parent_comment_id ="'+o.parentCommentId+'"] > li.comment-item:not(.bb-recent-comment)').length,activity_type_is_blog:1"+t.data.message+" "+t.statusText+" '+e.data.media_group_count+" "+i)):h("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(h(".bb-photos-actions").hide(),h("#media-stream")):n.find(".media-list:not(.existing-media-list)")).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(h(".bb-photos-actions").hide(),h("#media-stream")):n.find(".media-list:not(.existing-media-list)")).html(e.data.group_media_html_content):h.each(r,function(e,t){t=h('#media-stream ul.media-list li[data-id="'+t+'"]');t.length&&t.remove()}),void 0!==e.data.album_total_count&&o.updateAlbumCounts(e.data))):(setTimeout(function(){a.prop("disabled",!1)},500),e.success?(void 0!==e.data&&void 0!==e.data.media_personal_count&&(0 '+e.data.media_personal_count+" "+i)):h("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count)),void 0!==e.data&&void 0!==e.data.media_group_count&&0 '+e.data.media_group_count+" "+i)):h("#buddypress").find(".groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),(t=n.find(".media-list:not(.existing-media-list)")).find('.bb-media-check-wrap [name="bb-media-select"]:checked').each(function(){h(this).closest("li").remove()}),t.parent().parent().hasClass("album-single-view")&&t.find('.bb-video-check-wrap [name="bb-video-select"]:checked').each(function(){h(this).closest("li").remove()}),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(h(".bb-photos-actions").hide(),h("#media-stream")):t).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(h(".bb-photos-actions").hide(),h("#media-stream")):t).html(e.data.group_media_html_content):h.each(r,function(e,t){t=h('#media-stream ul.media-list li[data-id="'+t+'"]');t.length&&t.remove()})):h("#buddypress #media-stream.media").prepend(e.data.feedback));var t=h(".bp-nouveau #bb-select-deselect-all-media");t.hasClass("selected")&&t.removeClass("selected"),jQuery(window).scroll()}})},toggleSelectAllMedia:function(e){e.preventDefault();var e=h(e.currentTarget),t=!e.hasClass("selected");this.setMediaSelectionState(t),h("#bb-delete-media").length&&(t?h("#bb-delete-media").removeAttr("disabled"):h("#bb-delete-media").attr("disabled","disabled")),e.toggleClass("selected",t).data("bp-tooltip",t?BP_Nouveau.media.i18n_strings.unselectall:BP_Nouveau.media.i18n_strings.selectall)},editFolderTitle:function(e){e.preventDefault(),this.editAlbumFolderTitle(e,"document")},cancelEditAlbumTitle:function(e){e.preventDefault(),h("#bb-album-title").removeClass("error"),h("#bp-save-folder-title").hide(),h("#bp-cancel-edit-album-title").hide(),h("#bp-edit-album-title,#bp-edit-folder-title").show(),h("#bp-media-single-album #bp-single-album-title").show()},triggerDropzoneSelectFileDialog:function(){this.dropzone_obj.hiddenFileInput.click()},closeUploader:function(e){e.preventDefault(),h("#bp-media-uploader").hide(),h("#bp-media-add-more").hide(),h("#bp-media-uploader-modal-title").text(g.i18n_strings.upload),h("#bp-media-uploader-modal-status-text").text(""),h("#bp-media-post-content").val(""),h("#bp-dropzone-content .bp-feedback").remove(),this.dropzone_obj.element&&this.dropzone_obj.destroy(),this.dropzone_media=[];var t=h(e.currentTarget).closest("#bp-media-uploader");h(".bb-rl-close-create-popup-album").trigger("click"),h(".bb-rl-close-create-popup-folder").trigger("click"),t.find('.bb-rl-breadcrumbs-append-ul-li .item span[data-id="0"]').trigger("click"),t.find(".bb-field-steps").length&&(t.find(".bb-field-steps-1").show().siblings(".bb-field-steps-2").hide(),t.find(".bb-field-steps-1 #bp-media-photo-next, .bb-field-steps-1 #bp-media-document-next ").hide(),t.find(".bb-field-steps-1").removeClass("controls-added"),t.find("#bp-media-document-prev, #bp-media-prev, #bp-media-document-submit, #bp-media-submit, .bb-rl-media-open-create-popup-folder, .bb-rl-document-open-create-popup-folder, .bb-rl-create-popup-folder-wrap, .bb-rl-create-popup-album-wrap, .bb-rl-video-open-create-popup-album").hide()),this.clearFolderLocationUI(e)},closeChildFolderUploader:function(e){e.preventDefault();e=h(document);e.find(".open-popup #bb-album-child-title").val(""),e.find(".open-popup #bp-media-create-child-folder-submit").removeClass("loading"),e.find("#bp-media-create-child-folder").removeClass("open-popup"),e.find("#bp-media-create-child-folder").hide(),e.find(".open-popup #bb-album-title").text(""),e.find(".open-popup #bp-media-create-folder").hide(),e.find("#bp-media-create-folder").removeClass("open-popup")},closeFolderUploader:function(e){e.preventDefault();e=h(document);e.find(".open-popup #bb-album-title").val(""),e.find(".open-popup #bp-media-create-folder-submit").removeClass("loading"),e.find(".open-popup #bp-media-document-submit").hide(),e.find("#bp-media-create-folder").removeClass("open-popup"),e.find("#bp-media-create-folder").hide()},loadMoreGif:function(e){var t=e.target,i=this,a=h(e.target).closest(".bb-rl-gif-media-search-dropdown-standalone"),a=0 =t.scrollHeight&&!a.hasClass("loading")&&0 =t.scrollHeight&&!h(e.target).closest(".bp-group-messages-attached-gif-container").hasClass("loading")&&0 \n\t\n\t\t \n\t\n',e.data[t].saved=!1,this.gif_data.push(e.data[t])}i.find(".gif-search-results-list").append(a)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(this.gif_total_count=e.pagination.total_count)},loadMoreGifResponse:function(e){var t=this,i=0,a=h('div.forums-attached-gif-container[data-key="'+t.gif_container_key+'"]'),o=h(".bb-rl-gif-media-search-dropdown-standalone.open"),o=(0
\n\t\n\t\t \n\t\n',e.data[i].saved=!1,t.gif_data[t.gif_container_key].data.push(e.data[i])}o.append(d)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(t.gif_data[t.gif_container_key].total_count=e.pagination.total_count)},editGifPreview:function(){var e=this,t={};if(e.bbp_is_reply_edit&&Object.keys(e.bbp_reply_edit_gif_data).length?t=e.bbp_reply_edit_gif_data.gif_raw_data:e.bbp_is_topic_edit&&Object.keys(e.bbp_topic_edit_gif_data).length?t=e.bbp_topic_edit_gif_data.gif_raw_data:e.bbp_is_forum_edit&&Object.keys(e.bbp_forum_edit_gif_data).length&&(t=e.bbp_forum_edit_gif_data.gif_raw_data),void 0===t.images)return!1;e=h("#whats-new-attachments .forums-attached-gif-container"),e[0].style.backgroundImage="url("+t.images.fixed_width.url+")",e[0].style.backgroundSize="contain",e[0].style.height=t.images.original.height+"px",e[0].style.width=t.images.original.width+"px",e.find(".gif-image-container img").attr("src",t.images.original.url),e.removeClass("closed"),e=h("#bbp_media_gif");e.length&&e.val(JSON.stringify(t))},selectGif:function(e){var t,i=this,a=0,o=h(e.currentTarget),d=o.closest(".bb-rl-gif-media-search-dropdown-standalone"),r=0
\n\t\n\t\t \n\t\n',e.data[s].saved=!1,n.gif_data.push(e.data[s])}h(r.target).closest(".bp-group-messages-attached-gif-container").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(n.gif_total_count=e.pagination.total_count),h(r.target).closest(".bp-group-messages-attached-gif-container").removeClass("loading")},function(){h(r.target).find(".gif-no-connection").addClass("show")}));n.gif_requests.push(e),n.gif_offset=n.gif_offset+n.gif_limit},searchGifRequest:function(r){var n=this,s=0,e=h(r.target).closest(".bb-rl-gif-media-search-dropdown-standalone"),t=0
\n\t\n\t\t \n\t\n',e.data[s].saved=!1,n.gif_data[p].data.push(e.data[s])}h(r.target).closest(".gif-search-content").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(n.gif_data[p].total_count=e.pagination.total_count),l.removeClass("loading")},function(){c.find(".gif-no-connection").addClass("show")}));n.gif_data[p].requests.push(i),n.gif_data[p].offset=n.gif_data[p].offset+n.gif_data[p].limit},clearGifRequests:function(e){var t=this;if(void 0!==t.gif_data[e]&&void 0!==t.gif_data[e].requests){for(var i=t.gif_data[e].requests.length,a=0;a
",l.html(e),l.find(".gif-search-results").on("scroll",s.loadMoreGif.bind(s))),void 0!==window.Giphy&&void 0!==g.gif_api_key&&(s.giphy=new window.Giphy(g.gif_api_key),(r=i.closest("form").find(".forums-attached-gif-container")).addClass("loading"),n=r.data("key"),s.clearGifRequests(n),s.gif_data[n]={q:null,offset:0,limit:20,requests:[],total_count:0,data:[]},e=s.giphy.trending({offset:s.gif_data[n].offset,fmt:"json",limit:s.gif_data[n].limit},function(e){if(void 0!==e.data&&e.data.length){var t="",i=e.data.length;for(c=0;c\n\t\n\t\t'+(g.gif_no_results||"No results found")+'
'+(g.gif_no_connection||"Could not connect to GIPHY")+"
\n\t\n',e.data[c].saved=!1,s.gif_data[n].data.push(e.data[c])}l.find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(s.gif_data[n].total_count=e.pagination.total_count),r.removeClass("loading")}),s.gif_data[n].requests.push(e),s.gif_data[n].offset=s.gif_data[n].offset+s.gif_data[n].limit),l.toggleClass("open"),a&&l.hasClass("open")&&(e=h(window).scrollTop(),a=i.offset(),d=Math.round(a.top),a=Math.round(a.left),t=h("body").hasClass("rtl"),o=l.outerWidth(),t=t?"translate(-"+(h(window).width()-a-i.outerWidth()+o-70)+"px, "+(d-e-5)+"px) translate(0, -100%)":"translate("+(a+o-70)+"px, "+(d-e-5)+"px) translate(-100%, -100%)",l.css("transform",t),l.data("target-form",i.closest("form"))),i.parents("form").find("#whats-new-attachments .forums-attached-gif-container img")),o=(0
\n\t\n\t\t \n\t\n',e.data[s].saved=!1,r.gif_data.push(e.data[s])}n.closest("form").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(r.gif_total_count=e.pagination.total_count),h(".gif-search-query").closest(".bp-group-messages-attached-gif-container").removeClass("loading")}),r.gif_requests.push(e),r.gif_offset=r.gif_offset+r.gif_limit),n.parents("form").find("#whats-new-attachments .bp-group-messages-attached-gif-container img"));0
'+h(this).text()+""),h(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").removeClass("is-disabled"),h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").hasClass("is-disabled"))||((h(e.currentTarget).closest(".bb-field-wrap").length?h(e.currentTarget).closest(".bb-rl-field-wrap"):h(e.currentTarget).closest(".bb-field-wrap")).find(".bb-rl-album-selected-id").val(h(e.currentTarget).data("id")),t=h(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),0!==Number(h(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(h(e.currentTarget).parent().data("privacy")).trigger("change"),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public").trigger("change"),t.prop("disabled",!1)))}),o.on("click",t+" .breadcrumb .item > span",function(e){var t,i;h(this).hasClass("is-disabled")||(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-album-selected-id").val(0),h(e.currentTarget).closest(".bb-rl-field-wrap").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),a===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").removeClass("is-disabled"),t=h(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),i=h(e.currentTarget).closest("#bp-media-uploader").find(".location-album-list li.is_active").data("privacy"),0!==Number(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-album-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i).trigger("change"),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public").trigger("change"),t.prop("disabled",!1)))}),i.options.previewTemplate=document.getElementsByClassName("uploader-post-media-template").length?document.getElementsByClassName("uploader-post-media-template")[0].innerHTML:"",i.dropzone_obj=new Dropzone("div#media-uploader",i.options),i.dropzone_obj.on("sending",function(e,t,i){i.append("action","media_upload"),i.append("_wpnonce",w.media)}),i.dropzone_obj.on("uploadprogress",function(e){var t=h(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI;t.style.strokeDasharray=i+" "+i,t.style.strokeDashoffset=i,t.style.strokeDashoffset=i-e.upload.progress.toFixed(0)/100*i}),i.dropzone_obj.on("addedfile",function(){setTimeout(function(){i.dropzone_obj.getAcceptedFiles().length&&h("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(g.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),i.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?h(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"===e.status&&e.xhr&&0===e.xhr.status&&h(e.previewElement).find(".dz-error-message span").text(g.connection_lost_error):(jQuery(".media-error-popup").length||h("body").append('"),this.removeFile(e))}),i.dropzone_obj.on("queuecomplete",function(){h("#bp-media-uploader-modal-title").text(g.i18n_strings.upload)}),i.dropzone_obj.on("processing",function(){h("#bp-media-uploader-modal-title").text(g.i18n_strings.uploading+"...")}),i.dropzone_obj.on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=i.dropzone_media.length,t.data.album_id=i.album_id,t.data.group_id=i.group_id,t.data.saved=!1,i.dropzone_media.push(t.data)):(jQuery(".media-error-popup").length||h("body").append('"),this.removeFile(e)),h(".bb-field-steps-1 #bp-media-photo-next, #bp-media-submit").show(),h(".modal-container").addClass("modal-container--alert"),h(".bb-field-steps-1").addClass("controls-added"),h("#bp-media-add-more").show(),h("#bp-media-uploader-modal-title").text(g.i18n_strings.uploading+"..."),h("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(g.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()}),i.dropzone_obj.on("removedfile",function(e){if(i.dropzone_media.length)for(var t in i.dropzone_media)if(e.upload.uuid===i.dropzone_media[t].uuid){void 0===i.dropzone_media[t].saved||i.dropzone_media[t].saved||i.removeAttachment(i.dropzone_media[t].id),i.dropzone_media.splice(t,1);break}i.dropzone_obj.getAcceptedFiles().length?h("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(g.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show():(h("#bp-media-uploader-modal-status-text").text(""),h("#bp-media-add-more, #bp-media-photo-next").hide(),h(".bb-field-steps-1").removeClass("controls-added"),h("#bp-media-submit").hide(),h(".modal-container").removeClass("modal-container--alert"))}))},openDocumentUploader:function(e){var a,t,l=this,i=(e.preventDefault(),h(document)),o=h("#bp-media-uploader");void 0!==window.Dropzone&&h("div#media-uploader").length&&(o.hasClass("bp-media-document-uploader")&&!this.currentTargetParent&&(this.currentTargetParent=0),h(e.currentTarget).closest("#bp-media-single-folder").length&&h("#bb-document-privacy").hide(),i.removeClass("open-popup"),o.show(),o.addClass("open-popup"),bp.Readylaunch&&bp.Readylaunch.initSelect2Scoped&&bp.Readylaunch.initSelect2Scoped(o),h("#bp-media-uploader.bp-media-document-uploader").find(".bb-field-steps.bb-field-steps-2").length&&(t="#bp-media-uploader.bp-media-document-uploader",0!==Number(h(t).find(".bb-rl-folder-selected-id").data("value"))?(a=h(t).find(".bb-rl-folder-selected-id").data("value"),h(t).find("#bb-document-privacy").prop("disabled",!0)):a=0,""!==this.moveToIdPopup)&&h.ajax({url:y,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:w.media},success:function(e){i.find(".bp-media-document-uploader .bb-rl-location-folder-list-wrap h4 span.bb-rl-where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(i.find(".bp-media-document-uploader.open-popup .bb-rl-location-folder-list-wrap").hide(),i.find(".bp-media-document-uploader.open-popup .bb-rl-location-folder-list-wrap-main span.bb-rl-no-folder-exists")):(i.find(".bp-media-document-uploader.open-popup .bb-rl-location-folder-list-wrap-main span.bb-rl-no-folder-exists").hide(),i.find(".bp-media-document-uploader.open-popup .bb-rl-location-folder-list-wrap"))).show(),i.find(".bp-media-document-uploader .bb-rl-popup-on-fly-create-album .bb-rl-privacy-field-wrap-hide-show").show(),i.find(".bp-media-document-uploader .open-popup .bb-rl-folder-create-from").val("profile"),h(t).find(".bb-rl-location-folder-list-wrap .location-folder-list").remove(),h(t).find(".bb-rl-location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,a),h(t).find("ul.location-folder-list span#"+a).trigger("click"),h(t).find(".bb-rl-folder-selected-id").val(a)}}),i.on("click",t+" .location-folder-list li span",function(e){var t;e.preventDefault(),h(this).parent().hasClass("is_active")||(0!==h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item").append(''+h(this).text()+""),h(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").removeClass("is-disabled"),h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").hasClass("is-disabled"))||(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-folder-selected-id").val(h(e.currentTarget).data("id")),t=h(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),0!==Number(h(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(h(e.currentTarget).parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),i.on("click",t+" .breadcrumb .item > span",function(e){var t,i;h(this).hasClass("is-disabled")||(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-folder-selected-id").val(h(e.currentTarget).data("id")),h(e.currentTarget).closest(".bb-rl-field-wrap").find(".location-folder-list li span").removeClass("selected").parent().removeClass("is_active"),h(e.currentTarget).closest(".bb-rl-field-wrap").find('.location-folder-list li[data-id="'+h(e.currentTarget).data("id")+'"]').addClass("is_active"),h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),a===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").removeClass("is-disabled"),t=h(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),i=h(e.currentTarget).closest("#bp-media-uploader").find(".location-folder-list li.is_active").data("privacy"),0!==Number(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-folder-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),l.options.previewTemplate=document.getElementsByClassName("uploader-post-document-template").length?document.getElementsByClassName("uploader-post-document-template")[0].innerHTML:"",l.dropzone_obj=new Dropzone("div#media-uploader",l.options),l.dropzone_obj.on("sending",function(e,t,i){i.append("action","document_document_upload"),i.append("_wpnonce",w.media)}),l.dropzone_obj.on("uploadprogress",function(e){var t=h(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI;t.style.strokeDasharray=i+" "+i,t.style.strokeDashoffset=i,t.style.strokeDashoffset=i-e.upload.progress.toFixed(0)/100*i}),l.dropzone_obj.on("addedfile",function(){setTimeout(function(){l.dropzone_obj.getAcceptedFiles().length&&h("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(g.i18n_strings.upload_status,l.dropzone_media.length,l.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),l.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?h(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"===e.status&&e.xhr&&0===e.xhr.status&&h(e.previewElement).find(".dz-error-message span").text(g.connection_lost_error):(jQuery(".document-error-popup").length||h("body").append('"),this.removeFile(e))}),l.dropzone_obj.on("accept",function(e,t){0===e.size?t(g.empty_document_type):t()}),l.dropzone_obj.on("queuecomplete",function(){h("#bp-media-uploader-modal-title").text(g.i18n_strings.upload)}),l.dropzone_obj.on("processing",function(){h("#bp-media-uploader-modal-title").text(g.i18n_strings.uploading+"...")}),l.dropzone_obj.on("success",function(e,t){if(!t.data.id){var i,a,o,d,r,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),r=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a .bb-rl-activity-content .bb-rl-media-move-file",h(a).find(".bb-rl-document-move").attr("id",e.closest(".bb-rl-document-activity").attr("data-id")),0 '),d),n=this.moveToTypePopup;""!==this.moveToIdPopup&&h.ajax({url:y,type:"post",data:{action:"media_get_album_view",id:this.moveToIdPopup,type:this.moveToTypePopup},success:function(e){o.find(".bb-rl-location-album-list-wrap h4 span.bb-rl-where-to-move-profile-or-group-media").html(e.data.first_span_text),(""===e.data.html?(o.find(".open-popup .bb-rl-location-album-list-wrap").hide(),o.find(".open-popup .bb-rl-location-album-list-wrap-main span.bb-rl-no-album-exists")):(o.find(".open-popup .bb-rl-location-album-list-wrap-main span.bb-rl-no-album-exists").hide(),o.find(".open-popup .bb-rl-location-album-list-wrap"))).show(),"group"===n?(o.find(".bb-rl-popup-on-fly-create-album .bb-rl-privacy-field-wrap-hide-show").hide(),o.find(".open-popup .bb-rl-album-create-from").val("group")):(o.find(".bb-rl-popup-on-fly-create-album .bb-rl-privacy-field-wrap-hide-show").show(),o.find(".open-popup .bb-rl-album-create-from").val("profile")),!1===e.data.create_album?(h(a+".open-popup").find(".bb-rl-media-open-create-popup-folder").removeClass("create-album"),h(a+".open-popup").find(".bb-rl-media-open-create-popup-folder").hide()):(h(a+".open-popup").find(".bb-rl-media-open-create-popup-folder").addClass("create-album"),h(a+".open-popup").find(".bb-rl-media-open-create-popup-folder").show()),h(a).find(".bb-rl-location-album-list-wrap .location-album-list").remove(),h(a).find(".bb-rl-location-album-list-wrap").append(e.data.html),h(a).find(".bb-rl-model-footer .bb-rl-media-move").removeClass("loading"),h(a).find("ul.location-album-list span#"+r).trigger("click")}}),o.on("click",a+" .location-album-list li span",function(e){var t;e.preventDefault(),h(this).parent().hasClass("is_active")||(0!==h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item").append(''+h(this).text()+""),h(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),t=h(document).find('a.bb-rl-open-media-theatre[data-id="'+i.find(".bb-rl-media-move").attr("id")+'"]').data("album-id"),Number(t)===Number(h(e.currentTarget).data("id"))?h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").removeClass("is-disabled"),h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").hasClass("is-disabled"))||h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-album-selected-id").val(h(e.currentTarget).data("id"))}),o.on("click",a+" .breadcrumb .item > span",function(e){h(this).hasClass("is-disabled")||(h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-album-selected-id").val(0),h(e.currentTarget).closest(".bb-rl-media-move-file").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),r===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").removeClass("is-disabled"))})},openDocumentMove:function(e){e.preventDefault();var t,i=h(document),a=h(),e=h(e.currentTarget),o=(this.moveToIdPopup=e.attr("id"),this.moveToTypePopup=e.attr("data-type"),e.attr("data-action")),d=(h(".bb-rl-media-move-file.open-popup, .bb-rl-media-move-folder.open-popup").hide().removeClass("open-popup"),e.closest("#bb-rl-activity-modal")),r=(0===d.length&&(d=h("body")),e.closest(".bb-rl-conflict-activity-ul-li-comment").closest("li.comment-item").length?(t=e.closest("li.comment-item"),a=d.find("#"+t.attr("id")+".comment-item .bb-rl-media-move-file").first()):0<(t=e.closest("li.activity-item")).length&&(a=d.find("#"+t.attr("id")+" > .bb-rl-activity-content .bb-rl-media-move-file").first()),a&&0!==a.length||(e.closest(".bb-rl-conflict-activity-ul-li-comment").closest("li.comment-item").length?(t=e.closest("li.comment-item").attr("id"),a=d.find("#"+t+".comment-item .bb-rl-media-move-file").first()):(t=e.closest("li.activity-item").attr("id"))&&(a=d.find("#"+t+" > .bb-rl-activity-content .bb-rl-media-move-file").first())),a.find(".bb-rl-document-move").attr("id",e.closest(".bb-rl-document-activity").attr("data-id")),this.currentTargetParent=e.closest(".bb-rl-activity-media-elem").attr("data-parent-id"),0 '),"document"===o?a.find(".bb-rl-modal-header h4 .target_name").text(g.move_to_file):a.find(".bb-rl-modal-header h4 .target_name").text(g.move_to_folder),a.show(),a.addClass("open-popup"),"group"===this.moveToTypePopup?(i.find(".bb-rl-location-folder-list-wrap h4").show(),a.addClass("move-folder-popup-group")):(i.find(".bb-rl-location-folder-list-wrap h4").hide(),h(".move-folder-popup-group").removeClass("move-folder-popup-group")),this.currentTargetParent),n=this.moveToTypePopup;""!==this.moveToIdPopup&&h.ajax({url:y,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:w.media},success:function(e){var t;i.find(".bb-rl-location-folder-list-wrap h4 span.bb-rl-where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(a.find(".bb-rl-location-folder-list-wrap").hide(),a.find(".bb-rl-location-folder-list-wrap-main span.bb-rl-no-folder-exists")):(a.find(".bb-rl-location-folder-list-wrap-main span.bb-rl-no-folder-exists").hide(),a.find(".bb-rl-location-folder-list-wrap"))).show(),"group"===n?(a.find(".bb-rl-popup-on-fly-create-folder .bb-rl-privacy-field-wrap-hide-show").hide(),a.find(".bb-rl-folder-create-from").val("group")):(a.find(".bb-rl-popup-on-fly-create-folder .bb-rl-privacy-field-wrap-hide-show").show(),a.find(".bb-rl-folder-create-from").val("profile")),a.find(".bb-rl-location-folder-list-wrap .location-folder-list").remove(),a.find(".bb-rl-location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&(e=(e=a.attr("id"))?"#"+e:(t=a.attr("class"))?"."+t.split(" ")[0]:".bb-rl-media-move-file",bp.Nouveau.Media.folderLocationUI(e,r),a.find("ul.location-folder-list span#"+r).trigger("click"))}})},closeMediaMove:function(e){e.preventDefault();e=h(e.currentTarget);0!==e.closest(".bb-rl-media-move-file").find(".bb-rl-location-album-list-wrap .breadcrumb .item span:last-child").data("id")&&e.closest(".bb-rl-media-move-file").find(".bb-rl-location-album-list-wrap .breadcrumb .item span:last-child").remove(),e.closest(".bb-rl-media-move-file").hide().removeClass("open-popup")},closeDocumentMove:function(e){e.preventDefault();var t=h(e.currentTarget),i=jQuery(e.currentTarget).closest(".bb-rl-has-folderlocationUI");(t.hasClass("bb-rl-ac-document-close-button")?(t.closest(".bb-rl-media-move-file"),h(".bb-rl-media-move-file.open-popup").hide().removeClass("open-popup").find(".bb-rl-document-move")):(t.closest(".bb-rl-media-move-folder"),h(".bb-rl-media-move-folder.open-popup").hide().removeClass("open-popup").find(".bb-rl-folder-move"))).attr("id",""),h(".bb-rl-media-move-file.open-popup").removeClass("open-popup").hide(),h(".bb-rl-media-move-folder.open-popup").removeClass("open-popup").hide(),i.find(".bb-rl-document-move.loading").removeClass("loading"),this.clearFolderLocationUI(e)},renameDocument:function(e){var t=h(e.currentTarget).closest(".media-folder_items").find(".media-folder_name"),i=t.children("span").text();t.hide().siblings(".media-folder_name_edit_wrap").show().children(".media-folder_name_edit").val(i).focus().select(),e.preventDefault()},editDocument:function(e){e.preventDefault();var t=h(document),i=h("#bb-rl-media-edit-file"),a=h(e.currentTarget).closest(".media-folder_items"),o=a.find(".media-folder_name").children("span").text(),d=a.data("id"),r=a.find(".media-folder_name").data("attachment-id"),a=a.find(".media-folder_name").data("privacy");h(e.currentTarget).attr("data-privacy")&&0 span"),o=t.closest(".media-folder_items").find(".media-folder_name"),d=t.closest(".media-folder_items").find(".media-folder_name > i.media-document-id").attr("data-item-id"),r=t.closest(".media-folder_items").find(".media-folder_name > i.media-document-attachment-id").attr("data-item-id"),n=t.closest(".media-folder_items").find(".media-folder_name > i.media-document-type").attr("data-item-id"),s=i.val().trim(),l="",l=(t.closest(".ac-document-list").length?l=/[?\[\]=<>:;,'"&$#*()|~`!{}%+ \/]+/g:t.closest(".ac-folder-list").length&&(l=/[\\/?%*:|"<>]+/g),l.exec(s)),l=Boolean(l);if(l?i.addClass("error"):i.removeClass("error"),t.closest(".ac-document-list").length&&(-1!==s.indexOf("\\\\")||l?i.addClass("error"):i.removeClass("error")),!t.hasClass("name_edit_cancel")&&27!==e.keyCode||(i.removeClass("error"),i.parent().hide().siblings(".media-folder_name").show()),t.hasClass("name_edit_save")||13===e.keyCode){if(l)return;i.parent().addClass("submitting").append(''),h.ajax({url:y,type:"post",data:{action:"document_update_file_name",document_id:d,attachment_document_id:r,document_type:n,name:s,_wpnonce:w.media},success:function(e){e.success?void 0!==e.data.document&&0 span"),r=o.find(".media-folder_name"),n=o.find(".media-folder_name > i.media-document-id").attr("data-item-id"),s=o.find(".media-folder_name > i.media-document-attachment-id").attr("data-item-id"),l=o.find(".media-folder_name > i.media-document-type").attr("data-item-id"),c=t.val().trim(),p=0 :;,'"&$#*()|~`!{}%+ \/]+/g:/[\\/?%*:|"<>]+/g).exec(c),m=Boolean(b),b=a.find(".error-box");m?(t.addClass("error"),("folder"===l?b.text(b.data("folder-error")||b.text()):b.text(b.data("document-error")||b.text())).show()):(t.removeClass("error"),b.hide()),"folder"!==l&&o.length&&(-1!==c.indexOf("\\\\")||m?(t.addClass("error"),b.text(b.data("document-error")||b.text()).show()):(t.removeClass("error"),b.hide())),m||(u||f?(i.addClass("saving"),h.ajax({url:y,type:"post",data:{action:"bb_rl_document_rename_and_privacy_update",document_id:n,attachment_document_id:s,document_type:l,name:c,privacy:p,update_name:u,update_privacy:f,_wpnonce:w.media},success:function(e){var t;e.success?(u&&void 0!==e.data.response.document&&0 ');e.parents("li").each(function(e,t){t=h(t).children("span").clone().show();i.prepend("",t)}),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+g.target_text+"")),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").width()&&(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||h('...').insertAfter(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),h(this).hasClass("selected")&&!h(this).hasClass("disabled")?(h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".bb-rl-folder-destination").val(""),h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".bb-rl-folder-selected-id").val("0"),h(a).find(".location-folder-list li.is_active").length?h(a).find(".bb-rl-folder-selected-id").val(h(a).find(".location-folder-list li.is_active").attr("data-id")):h(a).find(".bb-rl-folder-selected-id").val("0")):(h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".location-folder-list li span").removeClass("selected"),h(this).addClass("selected"),h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".bb-rl-folder-destination").val(h(this).text()),h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".bb-rl-folder-selected-id").val(h(this).parent().attr("data-id"))),h(this).closest(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(h(this).siblings("span").text()).siblings(".location-folder-back").css("display","inline-block"),h(this).siblings("ul").show().siblings("span, i").hide().parent().siblings().hide(),h(this).siblings("ul").children("li").show().children("span,i").show(),h(this).closest(".is_active").removeClass("is_active"),h(a).find("li.is_active").removeClass("is_active"),h(this).parent().addClass("is_active"),h(a).find(".bb-rl-folder-selected-id").val(h(a).find(".location-folder-list li.is_active").attr("data-id")),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").each(function(){h(this).show()}),o===h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").attr("data-id")&&(h(a).hasClass("bb-rl-media-move-file")||h(a).hasClass("bb-rl-media-move-folder"))?(h(a).find(".bb-rl-document-move").addClass("is-disabled"),h(a).find(".bb-rl-folder-move").addClass("is-disabled")):(h(a).find(".bb-rl-document-move").removeClass("is-disabled"),h(a).find(".bb-rl-folder-move").removeClass("is-disabled")),setTimeout(function(){h(a).closest(".bb-activity-media-wrap").find(".bb-rl-activity-media-elem.bb-rl-document-activity").attr("data-parent-id")===(h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").prev():h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child")).attr("id")&&(h(a).hasClass("bb-rl-media-move-file")||h(a).hasClass("bb-rl-media-move-folder"))?(h(a).find(".bb-rl-document-move").addClass("is-disabled"),h(a).find(".bb-rl-folder-move").addClass("is-disabled")):(h(a).find(".bb-rl-document-move").removeClass("is-disabled"),h(a).find(".bb-rl-folder-move").removeClass("is-disabled"))},100)}),e.on("click",a+" .bb-rl-breadcrumbs-append-ul-li .item span",function(e){var t,i;h(this).parent().hasClass("is-disabled")||h(this).hasClass("more_options")||(t=h(e.currentTarget).attr("data-id"),h(a).find(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(h(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),h(a).find(".bb-rl-folder-selected-id").val(t),h(a).find(".location-folder-list li").hide(),h(a).find(".location-folder-list li.is_active").removeClass("is_active"),h(a).find(".location-folder-list li > span.selected").removeClass("selected"),h(a).find('.location-folder-list li[data-id="'+t+'"]').addClass("is_active").children("span").addClass("selected"),h(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),h(a).find(".location-folder-list li.is_active").children("ul").length&&!h(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){h(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):h(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?h(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){h(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),"0"===t&&(h(a).find(".location-folder-list").children("li").show().children("span,i").show(),h(a).find(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(g.target_text),h(a).find(".location-folder-back").hide()),h(e.currentTarget).nextAll().remove(),o===h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").attr("data-id")&&(h(a).hasClass("bb-rl-media-move-file")||h(a).hasClass("bb-rl-media-move-folder"))?(h(a).find(".bb-rl-document-move").addClass("is-disabled"),h(a).find(".bb-rl-folder-move").addClass("is-disabled")):(h(a).find(".bb-rl-document-move").removeClass("is-disabled"),h(a).find(".bb-rl-folder-move").removeClass("is-disabled")),e=h(a).find(".location-folder-list .is_active > span"),i=h(''),e.parents("li").each(function(e,t){t=h(t).children("span").clone().show();i.prepend("",t)}),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+g.target_text+"")),0===h(a).find('.bb-rl-breadcrumbs-append-ul-li .breadcrumb .item > span[data-id="'+t+'"]').length&&h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item").append(h(a).find('.location-folder-list li[data-id="'+t+'"]').children("span").clone().show()),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").width()&&(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||h('...').insertAfter(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),h(a).find(".bb-rl-folder-selected-id").val(t))})),h(a).find(".location-folder-list li").each(function(){h(this).children("ul").parent().addClass("has-ul").append('')}),h(a).hasClass("bb-rl-media-move-folder")&&(h(a).find(".location-folder-list li>span").removeClass("is-disabled"),h(a).find('.location-folder-list li>span[id="'+h(a).find(".bb-rl-folder-move").attr("id")+'"]').parent().addClass("is-disabled")),e=h(a).find(".bb-rl-folder-move").attr("id"),0===h(a).find('.location-folder-list li[data-id="'+e+'"]').siblings().length&&h(a).find('.location-folder-list li[data-id="'+e+'"]').parent("ul").addClass("no-folder-list a"),o&&(h(a).find(".location-folder-list li").hide(),h(a).find(".location-folder-list li.is_active").removeClass("is_active"),h(a).find('.location-folder-list li[data-id="'+o+'"]').addClass("is_active"),h(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),h(a).find(".location-folder-list li.is_active").children("ul").length&&!h(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){h(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):h(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?h(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){h(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),h(a).find(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(h(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),h(a).find(".bb-rl-folder-selected-id").val(h(a).find(".location-folder-list li.is_active").attr("data-id")),h(a).find('.location-folder-list li[data-id="'+e+'"]').children().hide()),"0"===o&&(h(a).find(".location-folder-list").children("li").show(),h(a).find(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(g.target_text),h(a).find(".location-folder-back").hide()),setTimeout(function(){var e=h(a).closest(".bb-activity-media-wrap").find(".bb-rl-activity-media-elem.bb-rl-document-activity").attr("data-parent-id"),t=(h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").prev():h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child")).attr("id");e===t&&(h(a).hasClass("bb-rl-media-move-file")||h(a).hasClass("bb-rl-media-move-folder"))?(h(a).find(".bb-rl-document-move").addClass("is-disabled"),h(a).find(".bb-rl-folder-move").addClass("is-disabled")):(h(a).find(".bb-rl-document-move").removeClass("is-disabled"),h(a).find(".bb-rl-folder-move").removeClass("is-disabled"))},100),e=h(a).find(".location-folder-list .is_active > span"),i=h(''),e.parents("li").each(function(e,t){t=h(t).children("span").clone().show();i.prepend("",t)}),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+g.target_text+"")))},clearFolderLocationUI:function(e){e=jQuery(e.currentTarget).closest(".bb-rl-has-folderlocationUI");0 '+e.data.media_group_count+" "+n)):i.find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").length?i.find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count):((d=document.createElement("span")).setAttribute("class","count"),t=document.createTextNode(e.data.media_group_count),d.appendChild(t),i.find(".bp-wrap .users-nav ul li#photos-groups-li a").append(d))),"yes"===g.is_media_directory&&(i.find(".media-type-navs ul.media-nav li#media-all a span.count").text(e.data.media_all_count),i.find(".media-type-navs ul.media-nav li#media-personal a span.count").text(e.data.media_personal_count),i.find(".media-type-navs ul.media-nav li#media-groups a span.count").text(e.data.media_group_count)),void 0!==e.data.album_total_count&&s.updateAlbumCounts(e.data),s.dropzone_media.length),o=0;o").addClass("media-list item-list bp-list bb-photo-list grid")),0<(t=h(".bb-photos-actions")).length&&t.show(),bp.Nouveau.inject("#media-stream ul.media-list",e.data.media,"prepend"),h('.bp-existing-media-wrap .bb-media-check-wrap [name="bb-media-select"]:checked').each(function(){parseInt(h(this).closest("li").data("id"))===parseInt(h(this).val())&&h(this).closest("li").remove()}),void 0===e.data.source_album_id&&void 0===e.data.dest_album_id||(t=h("#buddypress #bp-media-single-album")).length&&(i={},(t=parseInt(t.attr("data-id")||t.attr("data-album-id"))||0)===e.data.source_album_id?(i.album_media_count=e.data.source_album_media_count,i.album_video_count=e.data.source_album_video_count):t===e.data.dest_album_id&&(i.album_media_count=e.data.dest_album_media_count,i.album_video_count=e.data.dest_album_video_count),s.updateAlbumCounts(i)),jQuery(window).scroll(),s.closeUploader(r)):h("#bp-existing-media-content").prepend(e.data.feedback),l.removeClass("saving")}})):s.current_tab||(s.closeUploader(r),l.removeClass("saving"))},submitDocumentMedia:function(a){var o=this,d=h(a.currentTarget),r=h(a.currentTarget).closest("#bp-media-uploader");if(a.preventDefault(),d.hasClass("saving"))return!1;var n=h(document);if(d.addClass("saving"),"bp-dropzone-content"===o.current_tab){var e=h("#bp-media-post-content").val(),t=h("#bb-document-privacy").val(),i=h(a.currentTarget).closest(".open-popup"),s=i.find(".bb-rl-folder-selected-id").val(),i=i.find(".bb-rl-folder-selected-id").data("value"),l=!0;if(s.length&&0 ").addClass("display")),h("#media-stream div").attr("id","media-folder-document-data-table"),h(".bb-photos-actions").show()),h(".document-data-table-head").length?"yes"===g.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(n.find("li#document-personal a").trigger("click"),n.find("li#document-personal").trigger("click")):l&&bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"):location.reload(!0),h("#bp-media-post-content").val("");for(var t=o.dropzone_media.length,i=0;i ]+/g.exec(e.val()),d=Boolean(d);if(""===h.trim(e.val())||d)return e.addClass("error"),!1;e.removeClass("error"),t.prop("disabled",!0).addClass("loading");d={action:"document_edit_folder",_wpnonce:w.media,title:e.val(),privacy:a.val(),id:o,group_id:i.current_group_id};h(".bb-single-album-header .bp-feedback").remove(),h("#bb-rl-media-create-album-popup .bp-feedback").remove(),h.ajax({type:"POST",url:y,data:d,success:function(e){setTimeout(function(){t.prop("disabled",!1)},500),e.success?window.location.reload(!0):i.current_folder?h("#bp-media-single-album").prepend(e.data.feedback):h("#bb-rl-media-create-album-popup .bb-model-header").after(e.data.feedback)}})},deleteAlbum:function(e){e.preventDefault(),this.deleteAttachment(e,"media","album")},deleteFolder:function(e){e.preventDefault(),this.deleteAttachment(e,"document","folder")},injectMedias:function(e){this.injectAttachments(e,"media")},injectDocuments:function(e){this.injectAttachments(e,"document")},sortDocuments:function(e){var e=h(e.currentTarget),t="",i="date_created";switch(e.data("target")){case"name":i="title";break;case"modified":i="date_modified";break;case"visibility":i="privacy";break;case"group":i="group_id"}e.hasClass("asce")?e.removeClass("asce"):e.addClass("asce");var e=e.hasClass("asce")?"DESC":"ASC",a={},a=(a.orderby=i,a.sort=e,"group"!==i&&bp.Nouveau.setStorage("bp-document","extras",a),bp.Nouveau.getStorage("bp-document")),o=a.scope||null,a=a.filter||null,d=h("#buddypress .bp-dir-search-form input[type=search]");d.length&&(t=d.val()),this.sort_by=e,this.order_by=i,this.current_page=1,bp.Nouveau.objectRequest({object:"document",scope:o,filter:a,search_terms:t,page:1,order_by:i,sort:e,method:"reset",target:"#buddypress [data-bp-list]"}).done()},documentPopupNavigate:function(e){e.preventDefault();var e=h(e.currentTarget),t=e.closest(".bb-field-steps"),i=0===e.closest(".bp-document-listing").length?"#bb-album-child-title":"#bb-album-title";e.closest(".document-options").length&&(i="#bb-album-title"),e.hasClass("bb-field-steps-next")&&""===t.find(i).val().trim()?t.find(i).addClass("error"):(t.find(i).removeClass("error"),t.slideUp(200).siblings(".bb-field-steps").slideDown(200))},uploadDocumentNavigate:function(e){e.preventDefault();var e=h(e.currentTarget),t=h(e).closest("#bp-media-uploader");h(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-document-submit, #bp-media-document-prev, .bb-rl-document-open-create-popup-folder, #bb-document-privacy").show(),0!==Number(h(t).find(".bb-rl-folder-selected-id"))&&h(t).find(".location-folder-list li.is_active").length&&h(t).find(".location-folder-list").scrollTop(h(t).find(".location-folder-list li.is_active").offset().top-h(t).find(".location-folder-list").offset().top),h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").width()&&(h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||h('...').insertAfter(h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))})):(h(e).hide(),t.find("#bp-media-document-prev, .bb-rl-document-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-folder").length&&h("#bb-document-privacy").hide())},uploadMediaNavigate:function(e){e.preventDefault();var e=h(e.currentTarget),t=h(e).closest(".bp-media-photo-uploader");h(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-submit, #bp-media-prev, .bb-rl-media-open-create-popup-folder.create-album").show(),t.find("#bb-media-privacy").show(),0!==Number(h(t).find(".bb-rl-album-selected-id"))&&h(t).find(".location-album-list li.is_active").length&&h(t).find(".location-album-list").scrollTop(h(t).find(".location-album-list li.is_active").offset().top-h(t).find(".location-album-list").offset().top)):(h(e).hide(),t.find("#bp-media-prev, .bb-rl-media-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-album").length&&h("#bb-media-privacy").hide())},appendMedia:function(e){var t,i,a,o=bp.Nouveau.getStorage("bp-media"),d=o.scope||null,o=o.filter||null,r=h(e.currentTarget);r.hasClass("load-more")&&(t=Number(this.current_page_existing_media)+1,i=this,a="",e.preventDefault(),r.find("a").first().addClass("loading"),(e=h("#buddypress .dir-search input[type=search]")).length&&(a=e.val()),bp.Nouveau.objectRequest({object:"media",scope:d,filter:o,search_terms:a,page:t,method:"append",caller:"bp-existing-media",target:".bp-existing-media-wrap ul.bp-list"}).done(function(e){!0===e.success&&(r.remove(),i.current_page_existing_media=t,jQuery(window).scroll())}))},appendAlbums:function(t){var i=Number(this.current_page_albums)+1,a=this,e=(t.preventDefault(),h(t.currentTarget).find("a").first().addClass("loading"),{action:"media_albums_loader",_wpnonce:w.media,page:i});h.ajax({type:"POST",url:y,data:e,success:function(e){!0===e.success&&(h(t.currentTarget).remove(),h("#albums-dir-list ul.bb-albums-list").fadeOut(100,function(){h("#albums-dir-list ul.bb-albums-list").append(e.data.albums),h(this).fadeIn(100)}),a.current_page_albums=i)}})},toggleSubmitMediaButton:function(){var e=h("#bp-media-submit"),t=h("#bp-media-add-more");"bp-dropzone-content"===this.current_tab?this.dropzone_obj.getAcceptedFiles().length?(e.show(),t.show()):(e.hide(),t.hide()):"bp-existing-media-content"===this.current_tab&&(h('.bp-existing-media-wrap .bb-media-check-wrap [name="bb-media-select"]:checked').length?e.show():e.hide(),t.hide())},playVideo:function(e){e.preventDefault();var e=h(e.currentTarget),t=e.find("video").get(0),e=e.find(".gif-play-button");!0===t.paused?(t.play().catch(function(e){console.debug("GIF play failed:",e)}),e.hide()):(t.pause(),e.show())},throttledAutoPlayGifVideos:function(){this.throttleTimer||(this.throttleTimer=setTimeout(function(){bp.Nouveau.Media.throttleTimer=null,bp.Nouveau.Media.autoPlayGifVideos()},100))},invokeMediaFn:function(e){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media[e]&&bp.Nouveau.Media[e]()},isElementInScrollableContainer:function(e){var t=h(e),i=t.closest("#bp-message-thread-list");return(i=(i=i.length?i:t.closest(".bb-rl-modal-activity-body")).length?i:t.closest(".bb-rl-media-model-container .bb-media-info-section")).length?(e=e.getBoundingClientRect(),i=i[0].getBoundingClientRect(),e.bottom>i.top&&e.top i.left&&e.left '),h(t).text()),e=(h(t).text(g.copy_to_clip_board_text),h("#"+e));return e.val(h(t).attr("href")),e.select(),document.execCommand("copy"),setTimeout(function(){h(t).text(i)},2e3),!1},fileActivityActionButton:function(e){e.preventDefault();var t=h(e.currentTarget);t.parent().hasClass("bb_rl_copy_download_file_url")||(t.closest(".bb-rl-activity-media-elem").toggleClass("is-visible").siblings().removeClass("is-visible").closest(".activity-item").siblings().find(".bb-rl-activity-media-elem").removeClass("is-visible"),t.closest(".bb-rl-activity-media-elem").find(".bb_rl_more_dropdown").toggleClass("open").closest(".bb-rl-activity-media-elem").siblings().find(".bb_rl_more_dropdown").removeClass("open").closest(".activity-item").siblings().find(".bb-rl-activity-media-elem .bb_rl_more_dropdown").removeClass("open"),h("body").addClass("document_more_option_open"),t.closest(".bb-rl-activity-media-elem").length<1&&(t.closest(".bb-photo-thumb").toggleClass("is-visible").parent().siblings().find(".bb-photo-thumb").removeClass("is-visible").removeClass("is-visible"),t.closest(".bb-photo-thumb").find(".bb_rl_more_dropdown").toggleClass("open").closest(".bb-photo-thumb").parent().siblings().find(".bb-photo-thumb .bb_rl_more_dropdown").removeClass("open")),"a"!==e.currentTarget.tagName.toLowerCase())||t.hasClass("bb-rl-document-action_more")||t.hasClass("bb_rl_more_dropdown__action")||(t.closest(".bb-rl-activity-media-elem").removeClass("is-visible").find(".bb_rl_more_dropdown").removeClass("open"),t.closest(".bb-photo-thumb").removeClass("is-visible").find(".bb_rl_more_dropdown").removeClass("open"))},toggleFileActivityActionButton:function(e){var t;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),!0===e.altKey||!0===e.metaKey||h(t).hasClass("bb-rl-document-action_more")||h(t).parent().hasClass("bb-rl-document-action_more")||h(t).hasClass("media-folder_action__anchor")||h(t).parent().hasClass("media-folder_action__anchor")||h(t).hasClass("bb_rl_more_dropdown__action")||h(t).parent().hasClass("bb_rl_more_dropdown__action")?e:(h(".bb-rl-activity-media-elem.is-visible").removeClass("is-visible"),h(".media-folder_items.is-visible").removeClass("is-visible"),h(".bb-photo-thumb.is-visible").removeClass("is-visible"),h(".bb-item-thumb.is-visible").removeClass("is-visible"),h(".bb-rl-activity-video-elem.is-visible").removeClass("is-visible"),h(".bb-rl-more_dropdown-wrap.is-visible").removeClass("is-visible"),h(".bb-rl-more_dropdown-wrap .bb_rl_more_dropdown").removeClass("open"),h(".bb-rl-activity-media-elem .bb_rl_more_dropdown").removeClass("open"),h(".bb-photo-thumb .bb_rl_more_dropdown").removeClass("open"),h(".media-folder_items .bb_rl_more_dropdown").removeClass("open"),void h("body").removeClass("document_more_option_open video_more_option_open item_more_option_open"))},toggleCodePreview:function(e){e.preventDefault(),h(e.currentTarget).closest(".bb-rl-document-activity").toggleClass("code-full-view")},documentCodeMirror:function(){h(".bb-rl-document-text:not(.loaded), .document-text:not(.loaded)").each(function(){var e=h(this),t=e.attr("data-extension"),i=e.attr("data-extension");"html"!==t&&"htm"!==t||(i="text/html"),"js"===t?CodeMirror(e[0],{value:(0 '+e+""))},setupForumDropzoneEvents:function(e){var c=e.self,a=e.dropzoneObj,d=e.target,p=e.type,b=e.dropzoneDataObj,m=e.dropzoneContainer;"video"===p&&a.on("addedfile",function(e){e.dataURL&&e.dataThumb&&e.dataThumb.length?h(e.previewElement).find(".dz-video-thumbnail").prepend(' '):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-image")}),a.on("sending",function(e,t,i){i.append("action","document"===p?p+"_"+p+"_upload":p+"_upload");var a="document"===p?"media":p,o=(i.append("_wpnonce",w[a]),d.closest("form"));o.addClass("has-media"),["media","document","video","gif"].forEach(function(e){var t=o.find("#bb-rl-forums-"+e+"-button");t&&(t=t.parents(".bb-rl-post-elements-buttons-item"),p===e?t.addClass("no-click"):t.addClass("disable"))})}),a.on("uploadprogress",function(e){d.closest("form").addClass("media-uploading");var t=h(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=a,"video"===p&&(e.upload.progress<=99?(h(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+v.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,h(e.previewElement).find(".dz-progress-count").text("99% "+v.i18n_strings.video_uploaded_text)))}),a.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?h(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"===e.status&&e.xhr&&0===e.xhr.status&&h(e.previewElement).find(".dz-error-message span").text(g.connection_lost_error):(jQuery(".forum-"+("media"===p?"document":p)+"-error-popup").length||("media"===p?h("body").append('"):"document"===p?h("body").append('"):"video"===p&&h("body").append('")),this.removeFile(e),d.closest("form").removeClass("media-uploading"))}),"media"!==p&&a.on("accept",function(e,t){0===e.size?t(g["empty_"+p+"_type"]):t()}),a.on("success",function(e,t){var i,a;if("video"===p&&100===e.upload.progress&&(h(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,h(e.previewElement).find(".dz-progress-count").text("100% "+v.i18n_strings.video_uploaded_text),h(e.previewElement).closest(".dz-preview").addClass("dz-complete")),t.data.id)e.id=t.data.id,t.data.uuid=e.upload.uuid,t.data.menu_order=h(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.group_id=c.group_id,t.data.saved=!1,"media"===p?t.data.album_id=c.album_id:"document"===p?t.data.folder_id=c.current_folder:"video"===p&&(t.data.album_id=c.album_id,t.data.js_preview=h(e.previewElement).find(".dz-image img").attr("src")),b.push(t.data),m.closest("#whats-new-attachments").find("#bbp_"+p).length&&m.closest("#whats-new-attachments").find("#bbp_"+p).val(JSON.stringify(b)),"document"===p&&(a=(a=e.upload.filename).substr(a.lastIndexOf(".")+1),i=_.isUndefined(t.data.svg_icon)?"":t.data.svg_icon,a=_.isEmpty(i)?"bb-icon-file-"+a:i,h(e.previewElement).find(".dz-details .dz-icon .bb-icons-rl-file").length)&&h(e.previewElement).find(".dz-details .dz-icon .bb-icons-rl-file").removeClass("bb-icon-file").addClass(a);else if("media"===p)jQuery(".forum-"+p+"-error-popup").length||h("body").append('"),this.removeFile(e);else if("document"===p||"video"===p){var o,d,r,n,s,l=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],d=0,r=(n=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;d
'):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-image")}),a.on("sending",function(e,t,i){i.append("action","document"===p?p+"_"+p+"_upload":p+"_upload");var a="document"===p?"media":p,o=(i.append("_wpnonce",w[a]),d.closest("#send_group_message_form"));["media","document","video","gif"].forEach(function(e){var t=o.find("#bp-group-messages-"+e+"-button");t&&(t=t.parents(".post-elements-buttons-item"),p===e?t.addClass("no-click"):t.addClass("disable"))})}),a.on("uploadprogress",function(e){var t=h(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=a,"video"===p&&(e.upload.progress<=99?(h(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+v.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,h(e.previewElement).find(".dz-progress-count").text("99% "+v.i18n_strings.video_uploaded_text)))}),a.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?h(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"===e.status&&e.xhr&&0===e.xhr.status&&h(e.previewElement).find(".dz-error-message span").text(g.connection_lost_error):("media"===p||"document"===p?jQuery(".group-"+("media"===p?"document":p)+"-error-popup").length||("document"===p?h("body").append('"):h("body").append('")):h("body").append('"),this.removeFile(e))}),"media"!==p&&a.on("accept",function(e,t){0===e.size?t(g["empty_"+p+"_type"]):t()}),a.on("success",function(e,t){if("video"===p&&100===e.upload.progress&&(h(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,h(e.previewElement).find(".dz-progress-count").text("100% "+v.i18n_strings.video_uploaded_text),h(e.previewElement).closest(".dz-preview").addClass("dz-complete")),t.data.id){e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=h(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.group_id=c.group_id,t.data.saved=!1,"media"===p?t.data.album_id=c.album_id:"document"===p?t.data.folder_id=c.current_folder:"video"===p&&(t.data.album_id=c.album_id,t.data.js_preview=h(e.previewElement).find(".dz-video-thumbnail img").attr("src")),b.push(t.data);var i,a=h("#bp_group_messages_"+p);a.length&&a.val(JSON.stringify(b)),"document"===p&&(a=(a=e.upload.filename).substr(a.lastIndexOf(".")+1),i=_.isUndefined(t.data.svg_icon)?"":t.data.svg_icon,a=_.isEmpty(i)?"bb-icons-rl-"+a:i,h(e.previewElement).find(".dz-details .dz-icon .bb-icons-rl").length)&&h(e.previewElement).find(".dz-details .dz-icon .bb-icons-rl").removeClass("bb-icon-file").addClass(a)}else if("media"===p)jQuery(".group-message-error-popup").length||h("body").append('"),this.removeFile(e);else if("document"===p||"video"===p){var o,d,r,n,s,l=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],d=0,r=(n=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;d "+t+" h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").width()&&(h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||h('...').insertAfter(h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),"media"===a&&d.updateAlbumNavCount(e.data.album_count),n.removeClass("loading"),"document"===a&&setTimeout(function(){var e=r.find("ul"+v+" span#"+u),t=(e.trigger("click"),h(r).find("#bb-document-privacy"));0!==Number(e.data("id"))?(t.find("option").removeAttr("selected"),t.val(e.parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1))},200)):n.removeClass("loading")}}),this.currentTargetParent=u,r.find(v+" li.is_active").show().children("span, i").show().siblings("ul").hide(),r.find(v+" li.is_active").siblings("li").show().children("span, i").show().siblings("ul").hide(),r.find(v+" li span.selected").removeClass("selected"),r.find(v+" li.is_active").children("span").addClass("selected")},0)},setMediaSelectionState:function(e){var i=h("#buddypress").find(".media-list:not(.existing-media-list)"),a=!0===e,e=["media"];0 ]+/g.test(p.val());if(""===h.trim(p.val())||m)return p.addClass("error"),!1;if(p.removeClass("error"),r||n){if(!c.group_id&&""===h.trim(o.val()))return o.addClass("error"),!1;o.removeClass("error")}d.prop("disabled",!0).toggleClass(r?"saving":"loading");m={action:t+"_"+e+"_save",_wpnonce:b,title:p.val()};r?("media"===t?m.medias=c.dropzone_media:"video"===t&&(m.videos=a),m.privacy=o.val(),c.album_id&&(m.album_id=c.album_id),c.group_id&&(m.group_id=c.group_id)):n?(m.privacy=o.val(),m.album_id=c.current_folder,m.group_id=c.current_group_id):s&&(m.folder_id=c.current_folder,m.group_id=c.current_group_id),h(".bb-single-album-header .bp-feedback, #bb-rl-media-create-album-popup .bp-feedback").remove(),h.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:m,success:function(e){var t;(r||n)&&setTimeout(function(){r&&d.removeClass("saving"),d.prop("disabled",!1)},500),e.success?r?c.album_id?(h("#bp-single-album-title .title-wrap").text(p.val()),h("#bb-album-privacy").val(o.val()),c.cancelEditAlbumTitle(i),l.find("#bp-media-edit-album-close").trigger("click")):(h("#buddypress .bb-albums-list").prepend(e.data.album),window.location.href=e.data.redirect_url):n?(c.closeFolderUploader(i),h(".document-data-table-head").length?"yes"===BP_Nouveau.media.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(h(document).find("li#document-personal a").trigger("click"),h(document).find("li#document-personal").trigger("click")):(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()):location.reload(!0)):s&&(c.closeChildFolderUploader(i),location.reload(!0)):r?(t=c.album_id?"#bp-media-single-album":"#bb-rl-media-create-album-popup .bb-model-header",h(t).prepend(e.data.feedback)):alert(e.data.feedback.replace("'","'"))}})}},disableButtonsInToolBox:function(t,e){e.forEach(function(e){e=t.find(e);e.length&&e.parents(".bb-rl-post-elements-buttons-item").addClass("disable")})}},bp.Nouveau.Media.Theatre={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){this.medias=[],this.documents=[],this.current_media=!1,this.current_document=!1,this.current_index=0,this.current_document_index=0,this.is_open_media=!1,this.is_open_document=!1,this.nextLink=h(".bb-rl-next-media"),this.nextDocumentLink=h(".bb-rl-next-document"),this.previousDocumentLink=h(".bb-rl-prev-document"),this.previousLink=h(".bb-rl-prev-media"),this.activity_ajax=!1,this.group_id=void 0!==g.group_id&&g.group_id},addListeners:function(){var e=h(document);e.on("click",".bb-rl-open-media-theatre",this.openTheatre.bind(this)),e.on("click",".bb-rl-open-document-theatre",this.openDocumentTheatre.bind(this)),e.on("click",".bb-rl-document-detail-wrap-description-popup",this.openDocumentTheatre.bind(this)),e.on("click",".bb-rl-close-media-theatre",this.closeTheatre.bind(this)),e.on("click",".bb-close-document-theatre",this.closeDocumentTheatre.bind(this)),e.on("click",".bb-icons-rl-sidebar-simple",this.ToggleTheatreSidebar.bind(this)),e.on("click",".bb-rl-prev-media",this.previous.bind(this)),e.on("click",".bb-rl-next-media",this.next.bind(this)),e.on("click",".bb-rl-prev-document",this.previousDocument.bind(this)),e.on("click",".bb-rl-next-document",this.nextDocument.bind(this)),e.on("bp_activity_ajax_delete_request",this.activityDeleted.bind(this)),e.on("click","#bb-rl-media-model-container .media-privacy>li",this.mediaPrivacyChange.bind(this)),e.on("click","#bb-rl-media-model-container .document-privacy>li",this.documentPrivacyChange.bind(this)),e.on("click","#bb-rl-media-model-container .bb-rl-media-section span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),e.on("click","#bb-rl-media-model-container .bb-rl-document-section span.privacy",bp.Nouveau,this.toggleDocumentPrivacyDropdown.bind(this)),e.on("click",".bp-add-media-activity-description",this.openMediaActivityDescription.bind(this)),e.on("click","#bp-activity-description-new-reset",this.closeMediaActivityDescription.bind(this)),e.on("keyup",".bp-edit-media-activity-description #add-activity-description",this.MediaActivityDescriptionUpdate.bind(this)),e.on("click","#bp-activity-description-new-submit",this.submitMediaActivityDescription.bind(this)),e.on("click",".bb-rl-media-thumb",this.handleThumbnailClick.bind(this)),e.click(this.togglePopupDropdown),document.addEventListener("keyup",this.checkPressedKeyDocuments.bind(this)),document.addEventListener("keyup",this.checkPressedKey.bind(this))},checkPressedKey:function(e){var t=this;if(e=e||window.event,!t.is_open_media)return!1;var i=h(e.target).hasClass("ac-input")||"add-activity-description"===h(e.target).attr("id");switch(e.keyCode){case 27:t.closeTheatre(e);break;case 37:if(void 0===t.medias[t.current_index-1]||i)return!1;t.previous(e);break;case 39:if(void 0===t.medias[t.current_index+1]||i)return!1;t.next(e)}},checkPressedKeyDocuments:function(e){e=e||window.event;var t=this;if(!t.is_open_document)return!1;var i=h(e.target).hasClass("ac-input")||"add-activity-description"===h(e.target).attr("id");switch(e.keyCode){case 27:t.closeDocumentTheatre(e);break;case 37:if(void 0===t.documents[t.current_document_index-1]||i)return!1;t.previousDocument(e);break;case 39:if(void 0===t.documents[t.current_document_index+1]||i)return!1;t.nextDocument(e)}},handleOpenTheatre:function(e){var t=e.target,i=e.self||this,a=e.modalWrapper,o=e.mediaType,e=e.action,d=(i.setupGlobals(),i.setMedias({target:t,modalWrapper:a,mediaType:o,action:e}),t.data("id")),d=(i.setCurrentMedia(d),i.showMedia({modalWrapper:a,mediaType:o,action:e}),i.navigationCommands(),i.current_activity_data&&i.generateAndDisplayMediaThumbnails({target:t,modalWrapper:a,mediaType:o,action:e}),i.getParentActivityHtml({target:t,modalWrapper:a,mediaType:o,action:e}),i.getMediasDescription({modalWrapper:a,mediaType:o,action:e}),t.closest(".activity-item").data("activity-popup-title")),o=(h(a+" .bb-rl-media-model-header h2").text(d),h(a+".document").hide(),document.getElementById(h(a+".video video").attr("id")));o&&o.pause(),h(a+".video").length&&h(a+".video").hide(),h(a+"."+e).length&&h(a+"."+e).show(),i.is_open_media=!0,bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay")},openTheatre:function(e){e.preventDefault();var t=h(e.currentTarget);if(this.current_activity_data=t.closest(".activity-item").data("bp-activity"),t.closest("#bp-existing-media-content").length)return!1;this.handleOpenTheatre({self:this,target:t,event:e,modalWrapper:".bb-rl-media-model-wrapper",action:"media"})},getParentActivityHtml:function(e){var t=e.target,e=e.action;if("comment"===t.data("privacy"))return!1;var i=h("#hidden_parent_id"),a=i.val(),t=t.closest(".bb-rl-"+e+"-model-wrapper").find("#bb-rl-"+e+"-model-container .bb-rl-activity-list li.activity-item").data("bp-activity-id");parseInt(a)===parseInt(t)&&(t=h("#bb-rl-"+e+'-model-container [data-bp-activity-id="'+a+'"]'),h('[data-bp-activity-id="'+a+'"] > .activity-state').html(h(t).find(".activity-state").html()),h('[data-bp-activity-id="'+a+'"] > .activity-meta').html(h(t).find(".activity-meta").html()),h('[data-bp-activity-id="'+a+'"] > .bb-rl-activity-comments').html(h(t).find(".bb-rl-activity-comments").html())),i.length&&i.remove()},getMediasDescription:function(e){var t=e.action;this.fetchMediaDescription(this.current_media,h(".bb-rl-"+t+"-model-wrapper"),e)},openDocumentTheatre:function(e){e.preventDefault();var t=h(e.currentTarget),i=this;if(t.closest("#bp-existing-document-content").length)return!1;t.closest(".document.bb-rl-document-theatre").length&&i.closeDocumentTheatre(e),a=t.data("id"),i.setupGlobals(),i.setDocuments(t),i.setCurrentDocument(a),i.showDocument(),i.navigationDocumentCommands(),i.getParentActivityHtml({target:t,action:"media"}),i.getDocumentsDescription();var a=t.closest(".activity-item").data("activity-popup-title"),t=(h(".bb-rl-media-model-wrapper .bb-rl-media-model-header h2").text(a),-1!==h.inArray(i.current_document.extension,n.mp3_preview_extension.split(","))&&h(e.currentTarget).closest(".bb-rl-activity-media-elem.bb-rl-document-activity").length&&h(e.currentTarget).closest(".bb-rl-activity-media-elem.bb-rl-document-activity").find(".bb-rl-document-audio-wrap").length&&h(e.currentTarget).closest(".bb-rl-activity-media-elem.bb-rl-document-activity").find(".bb-rl-document-audio-wrap audio")[0].pause(),h(".bb-rl-media-model-wrapper.media").hide(),h(".bb-rl-media-model-wrapper.document").show(),document.getElementById(h(".bb-rl-media-model-wrapper.video video").attr("id")));t&&(t.pause(),t.src=""),h(".bb-rl-media-model-wrapper.video").hide(),i.is_open_document=!0,setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay")},500)},resetRemoveActivityCommentsData:function(e){var t,i=this,a=!1,o=!1,d=!1,r=!1,n=!1,s=!1;i.current_media.parent_activity_comments&&((a=(r=h(".bb-rl-"+e+'-model-wrapper.media [data-bp-activity-id="'+i.current_media.activity_id+'"]')).find(".bb-rl-activity-comments")).length&&(t=a.find("#ac-form-"+i.current_media.activity_id),this.purgeEditActivityForm(t),t.find("#ac-input-"+i.current_media.activity_id).html(""),t.removeClass("has-content has-gif has-media").addClass("root"),a.append(t),t.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(i.current_media.activity_id),a.find(".acomment-display").removeClass("display-focus"),a.find(".comment-item").removeClass("comment-item-focus"),n=a.html(),s=a.attr("class"),a.remove(),(a=h('[data-bp-activity-id="'+i.current_media.activity_id+'"] .bb-rl-activity-comments')).length)&&(a.attr("class",s),0===a.find("#ac-form-"+i.current_media.activity_id).length)&&(a.append(t),a.children("form").removeClass("events-initiated").addClass("not-initialized")),(d=r.find(".activity-state")).length&&(n=d.html(),s=d.attr("class"),d.remove(),(d=h('[data-bp-activity-id="'+i.current_media.activity_id+'"] .activity-state')).length)&&(d.html(n),d.attr("class",s)),(o=r.find(".activity-meta")).length&&(n=o.html(),s=o.attr("class"),o.remove(),(o=h('[data-bp-activity-id="'+i.current_media.activity_id+'"] > .activity-meta')).length)&&(o.html(n),o.attr("class",s)),r.remove()),i.current_document.parent_activity_comments&&((a=(r=h(".bb-rl-"+e+'-model-wrapper.document [data-bp-activity-id="'+i.current_document.activity_id+'"]')).find(".bb-rl-activity-comments")).length&&(t=a.find("#ac-form-"+i.current_document.activity_id),this.purgeEditActivityForm(t),t.find("#ac-input-"+i.current_document.activity_id).html(""),t.removeClass("has-content has-gif has-media").addClass("root"),a.append(t),t.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(i.current_document.activity_id),a.find(".acomment-display").removeClass("display-focus"),a.find(".comment-item").removeClass("comment-item-focus"),n=a.html(),s=a.attr("class"),a.remove(),(a=h('[data-bp-activity-id="'+i.current_document.activity_id+'"] .bb-rl-activity-comments')).length)&&(a.attr("class",s),0===a.find("#ac-form-"+i.current_document.activity_id).length&&(a.append(t),a.children("form").removeClass("events-initiated").addClass("not-initialized")),a.find(".bb-rl-document-text.loaded").removeClass("loaded").find(".CodeMirror").remove(),jQuery(window).scroll()),(d=r.find(".activity-state")).length&&(n=d.html(),s=d.attr("class"),d.remove(),(d=h('[data-bp-activity-id="'+i.current_document.activity_id+'"] .activity-state')).length)&&(d.html(n),d.attr("class",s)),(o=r.find(".activity-meta")).length&&(n=o.html(),s=o.attr("class"),o.remove(),(o=h('[data-bp-activity-id="'+i.current_document.activity_id+'"] > .activity-meta')).length)&&(o.html(n),o.attr("class",s)),r.remove()),bp.Nouveau.reportPopUp(),bp.Nouveau.reportActions()},closeTheatre:function(e){e.preventDefault();var e=h(e.currentTarget),t="";if(e.closest(".bb-rl-internal-model").hasClass("media-video")?t="media-video":e.closest(".bb-rl-internal-model").hasClass("media")?t="media":e.closest(".bb-rl-internal-model").hasClass("video")&&(t="video"),h(e).closest(".bb-rl-"+t+"-model-wrapper").hasClass("bb-rl-video-theatre"))return!1;var i=h(".bb-rl-"+t+"-model-wrapper.media .bb-rl-media-section"),i=(i.find("img").attr("src",""),i.find("video"));i.length&&videojs(i.attr("id")).reset(),h(".bb-rl-"+t+"-model-wrapper").hide(),this.is_open_media=!1,this.resetRemoveActivityCommentsData(t),this.current_media=!1,this.getParentActivityHtml({target:e,action:t})},closeDocumentTheatre:function(e){e.preventDefault();var t=h(document).find(".bb-rl-document-theatre");t.find(".bb-rl-media-section").removeClass("bb-media-no-preview").find(".document-preview").html(""),h(".bb-media-info-section.document").show(),t.hide(),this.is_open_document=!1,this.resetRemoveActivityCommentsData("media"),this.current_document=!1,this.getParentActivityHtml({target:h(e.currentTarget),action:"media"})},ToggleTheatreSidebar:function(e){e.preventDefault(),h(e.currentTarget).closest(".bb-rl-media-model-container").toggleClass("bb-rl-media-toggle-sidebar")},setMedias:function(e){var t=e.target,e=e.action,i=h(t),a=0;if("media-video"===e&&(i=h(".bb-rl-open-"+e+"-theatre")),void 0!==(i=h("body").hasClass("activity")?h(t).closest(".bb-activity-media-wrap").find(".bb-rl-open-"+e+"-theatre"):i)){this.medias=[];for(var o=i.length,a=0;a '):h(i+" .bb-rl-media-section").children("img").length?e.find("img").attr("src",t.current_media.attachment):e.html(' ')):h(i+" .bb-rl-media-section").find("img").attr("src",t.current_media.attachment);a=h(".bb-rl-media-section .bb-media-privacy-wrap");a.length&&(a.show(),a.find("ul.media-privacy li").removeClass("selected"),a.find(".bp-tooltip").attr("data-bp-tooltip",""),(e=a.find("ul.media-privacy").find("li[data-value="+t.current_media.privacy+"]")).addClass("selected"),a.find(".bp-tooltip").attr("data-bp-tooltip",e.text()),a.find(".privacy").removeClass("public").removeClass("loggedin").removeClass("onlyme").removeClass("friends").addClass(t.current_media.privacy),!(void 0!==l&&void 0!==t.current_media.activity_id&&0!==t.current_media.activity_id||t.group_id||t.current_media.is_forum||t.current_media.group_id||t.current_media.album_id||t.current_media.is_message)&&t.can_manage_media&&t.current_media.can_edit||a.hide()),t.navigationCommands()},showDocument:function(){var e=this;if(void 0===e.current_document)return!1;var t,i=e.current_document.target_text,a=e.current_document.target_icon_class,o=h(document).find(".bb-rl-document-theatre"),d=e.current_document.extension,r=e.current_document.mirror_text,d=(o.find(".bb-rl-document-section").removeClass("bb-video-preview"),-1!==h.inArray(e.current_document.extension,["css","txt","js","html","htm","csv"])?(o.find(".bb-rl-document-section .document-preview").html(''),o.find(".bb-rl-document-section").removeClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),o.find(".bb-rl-document-section .document-preview").html("
"+i+'
'),o.find(".bb-rl-document-section .document-preview .bb-rl-document-text").attr("data-extension",d),t=o.find(".bb-rl-document-section .document-preview .bb-rl-document-text textarea"),"html"===d||"htm"===d?t.val(r):t.html(r),setTimeout(function(){bp.Nouveau.Media.documentCodeMirror()},1e3)):-1!==h.inArray(e.current_document.extension,n.mp3_preview_extension.split(","))?(o.find(".bb-rl-document-section .document-preview").html(''),o.find(".bb-rl-document-section").removeClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),o.find(".bb-rl-document-section .document-preview").html('')):-1!==h.inArray("."+e.current_document.extension,v.video_type.split(","))?(o.find(".bb-rl-document-section").addClass("bb-video-preview"),o.find(".bb-rl-document-section .document-preview").html(''),o.find(".bb-rl-document-section").removeClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),"mov"===e.current_document.extension||"m4v"===e.current_document.extension?o.find(".bb-rl-document-section .document-preview").html(''):o.find(".bb-rl-document-section .document-preview").html(''),h(window).scroll()):e.current_document.full_preview?(o.find(".bb-rl-document-section").removeClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),o.find(".bb-rl-document-section .document-preview").html("'+i+'
"+i+'
')):(o.find(".bb-rl-document-section").addClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),o.find(".bb-rl-document-section .document-preview").html('")),h(".bb-rl-document-section .bb-document-privacy-wrap"));d.length&&(d.show(),d.parent().show(),d.find("ul.document-privacy li").removeClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",""),(t=d.find("ul.document-privacy").find("li[data-value="+e.current_document.privacy+"]")).addClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",t.text()),d.find(".privacy").removeClass("public").removeClass("loggedin").removeClass("onlyme").removeClass("friends").addClass(e.current_document.privacy),void 0!==l&&void 0!==e.current_document.activity_id&&0!==e.current_document.activity_id||e.group_id||e.current_document.is_forum||e.current_document.group_id||e.current_document.album_id||!e.can_manage_document||!e.current_document.can_edit||e.current_document.is_message)&&d.parent().hide(),e.navigationDocumentCommands()},generateAndDisplayMediaThumbnails:function(e){var t,i=e.target,e=e.action,a=this;a.current_activity_data=i.closest(".activity-item").data("bp-activity"),!a.current_activity_data||!a.current_activity_data.media||a.current_activity_data.media.length<=1||(i=a.current_activity_data.media.map(function(e){return''+i+"
'}).join(""),(t=(e=h("."+e+".bb-rl-"+e+"-theatre .bb-rl-media-section")).find(".bb-rl-media-thumbnails")).length?t.html(i):e.append(''+i+""))},handleThumbnailClick:function(e){var t,i,a,e=h(e.currentTarget);!e.hasClass("active")&&((i=h(".bb-rl-media-model-wrapper.media .bb-rl-media-section").find("figure")).find("img").hide(),i.addClass("loading").append(''),t=e.data("id"),i=this.medias.find(function(e){return e.id===t}))&&(a="",e.closest(".bb-rl-internal-model").hasClass("media-video")?a="media-video":e.closest(".bb-rl-internal-model").hasClass("media")?a="media":e.closest(".bb-rl-internal-model").hasClass("video")&&(a="video"),this.updateMedia(i,e,{modalWrapper:".bb-rl-"+a+"-model-wrapper",action:a}))},next:function(e){e.preventDefault();var e=h(e.currentTarget),t="";e.closest(".bb-rl-internal-model").hasClass("media-video")?t="media-video":e.closest(".bb-rl-internal-model").hasClass("media")?t="media":e.closest(".bb-rl-internal-model").hasClass("video")&&(t="video");var e={modalWrapper:".bb-rl-"+t+"-model-wrapper",action:t},i=this;i.current_activity_data&&i.medias[i.current_index+1]?i.updateMedia(i.medias[i.current_index+1],h("."+t+".bb-rl-"+t+"-theatre .bb-rl-media-thumb").eq(i.current_index+1),e):(i.resetRemoveActivityCommentsData(t),void 0!==i.medias[i.current_index+1]?(i.current_index=i.current_index+1,i.current_media=i.medias[i.current_index],e.mediaType=i.medias[i.current_index].type||"",i.showMedia(e),i.getMediasDescription(e),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):i.nextLink.hide())},previous:function(e){e.preventDefault();var e=h(e.currentTarget),t="";e.closest(".bb-rl-internal-model").hasClass("media-video")?t="media-video":e.closest(".bb-rl-internal-model").hasClass("media")?t="media":e.closest(".bb-rl-internal-model").hasClass("video")&&(t="video");var e={modalWrapper:".bb-rl-"+t+"-model-wrapper",action:t},i=this;i.current_activity_data&&i.medias[i.current_index-1]?i.updateMedia(i.medias[i.current_index-1],h("."+t+".bb-rl-"+t+"-theatre .bb-rl-media-thumb").eq(i.current_index-1),e):(i.resetRemoveActivityCommentsData(t),void 0!==i.medias[i.current_index-1]?(i.current_index=i.current_index-1,i.current_media=i.medias[i.current_index],e.mediaType=i.medias[i.current_index].type||"",i.showMedia(e),i.getMediasDescription(e),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):i.previousLink.hide())},updateMedia:function(t,e,i){var a=i.action,o=this,a=h("."+a+".bb-rl-"+a+"-theatre"),d=a.find(".bb-rl-media-section figure"),r=d.find("img");r.one("load",function(){d.removeClass("loading").find(".bb-rl-loader").remove(),r.show()}).one("error",function(){d.removeClass("loading").find(".bb-rl-loader").remove()}).attr("src",t.attachment),a.find(".bb-rl-media-thumb").removeClass("active"),e.addClass("active"),o.current_index=o.medias.findIndex(function(e){return e.id===t.id}),o.current_media=t,o.nextLink.toggle(Boolean(o.medias[o.current_index+1])),o.previousLink.toggle(Boolean(o.medias[o.current_index-1])),o.activity_ajax&&o.activity_ajax.abort(),o.fetchMediaDescription(t,a,i)},fetchMediaDescription:function(o,d,e){var r=e.mediaType,n=e.action,s=this,e=(!1!==s.activity_ajax&&s.activity_ajax.abort(),h('[data-bp-activity-id="'+o.activity_id+'"] .bb-rl-activity-comments')),e=(e.length&&(e=e.find("#ac-form-"+o.activity_id),o.parent_activity_comments=!0,e.remove()),!0===o.parent_activity_comments&&h(".bb-rl-"+n+"-model-wrapper:last").after(''),{id:o.id,attachment_id:o.attachment_id,activity_id:o.activity_id});"media-video"===n&&"video"===r?(e.action="video_get_video_description",e.nonce=w.video):(e.action="media_get_media_description",e.nonce=w.media),s.activity_ajax=h.ajax({type:"POST",url:y,data:e,beforeSend:function(){d.find(".bb-media-info-section .bb-rl-activity-list").addClass("loading").html('')},success:function(e){var t,i,a;e.success?(t=d.find(".bb-media-info-section:visible"),i=h(".bb-rl-"+n+"-model-wrapper"),"media-video"===n&&"video"===r&&((a=i.find(".bb-rl-media-section figure")).html(e.data.video_data),a.find("video").attr("autoplay",!0)),t.find(".bb-rl-activity-list").removeClass("loading").html(e.data.description),void 0!==e.data.comment_form&&void 0!==bp.Nouveau.Activity&&(t.find(".bb-rl-activity-list .bb-rl-activity-comments ul:first").after(e.data.comment_form),t.find("#ac-form-"+o.activity_id).removeClass("not-initialized").addClass("root events-initiated").find("#ac-input-"+o.activity_id).focus(),a=t.find("#ac-form-"+o.activity_id),bp.Nouveau.Activity.clearFeedbackNotice(a),a.removeClass("events-initiated"),e=t.find(".ac-form .ac-input[contenteditable]"),bp.Nouveau.Activity.listenCommentInput(e),_.isUndefined(g)||_.isUndefined(g.emoji)||bp.Nouveau.Activity.initializeEmojioneArea(!0,"#bb-rl-activity-modal ",o.activity_id)),t.show(),t.find(".bb-activity-more-options-action").attr("data-balloon-pos","left"),s.updateTheaterHeaderTitle({wrapper:i,action:n}),requestAnimationFrame(function(){h(window).scroll(),bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()})):d.find(".bb-media-info-section.media").hide()}})},nextDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData("media"),void 0!==e.documents[e.current_document_index+1]?(e.current_document_index=e.current_document_index+1,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.nextDocumentLink.hide()},previousDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData("media"),void 0!==e.documents[e.current_document_index-1]?(e.current_document_index=e.current_document_index-1,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.previousDocumentLink.hide()},navigationCommands:function(){var e=this;0===e.current_index&&e.current_index!==e.medias.length-1?(e.previousLink.hide(),e.nextLink.show()):0===e.current_index&&e.current_index===e.medias.length-1?(e.previousLink.hide(),e.nextLink.hide()):e.current_index===e.medias.length-1?(e.previousLink.show(),e.nextLink.hide()):(e.previousLink.show(),e.nextLink.show())},navigationDocumentCommands:function(){var e=this;0===e.current_document_index&&e.current_document_index!==e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.show()):0===e.current_document_index&&e.current_document_index===e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.hide()):e.current_document_index===e.documents.length-1?(e.previousDocumentLink.show(),e.nextDocumentLink.hide()):(e.previousDocumentLink.show(),e.nextDocumentLink.show())},getDocumentsDescription:function(){var t=this,e=(h(".bb-media-info-section .bb-rl-activity-list").addClass("loading").html(''),!1!==t.activity_ajax&&t.activity_ajax.abort(),h('[data-bp-activity-id="'+t.current_document.activity_id+'"] .bb-rl-activity-comments'));e.length&&(e=e.find("#ac-form-"+t.current_document.activity_id),t.current_document.parent_activity_comments=!0,e.remove()),!0===t.current_document.parent_activity_comments&&h(".bb-rl-media-model-wrapper:last").after(''),t.activity_ajax=h.ajax({type:"POST",url:y,data:{action:"document_get_document_description",id:t.current_document.id,attachment_id:t.current_document.attachment_id,nonce:w.media},success:function(e){e.success?(h(".bb-media-info-section:visible .bb-rl-activity-list").removeClass("loading").html(e.data.description),void 0!==e.data.comment_form&&void 0!==bp.Nouveau.Activity&&(h(".bb-media-info-section:visible .bb-rl-activity-list .bb-rl-activity-comments ul:first").after(e.data.comment_form),h(".bb-media-info-section:visible").find("#ac-form-"+t.current_document.activity_id).removeClass("not-initialized").addClass("root events-initiated").find("#ac-input-"+t.current_document.activity_id).focus(),e=h(".bb-media-info-section:visible").find("#ac-form-"+t.current_document.activity_id),bp.Nouveau.Activity.clearFeedbackNotice(e),e.removeClass("events-initiated"),e=h(".bb-media-info-section:visible").find(".ac-form .ac-input[contenteditable]"),bp.Nouveau.Activity.listenCommentInput(e),_.isUndefined(g)||_.isUndefined(g.emoji)||bp.Nouveau.Activity.initializeEmojioneArea(!0,"#bb-rl-activity-modal ",t.current_document.activity_id)),h(".bb-media-info-section:visible").show(),t.updateTheaterHeaderTitle({wrapper:h(".bb-rl-media-model-wrapper"),action:"media"}),h(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10),h(".bb-media-info-section:visible").find(".bb-activity-more-options-action").attr("data-balloon-pos","left")):h(".bb-media-info-section.document").hide()}})},activityDeleted:function(e,t){var i=this,a=0;if(i.is_open_media&&void 0!==t&&"delete_activity"===t.action&&i.current_media.activity_id===t.id){for(var o=h(document).find('[data-bp-list="media"] .bb-rl-open-media-theatre[data-id="'+i.current_media.id+'"]'),d=o.parents("ul"),r=(o.closest("li").remove(),0===d.find("li:not(.load-more)").length&&(0<(o=h(".bb-photos-actions")).length&&o.hide(),1===d.find("li.load-more").length)&&location.reload(),h(document).find('[data-bp-list="activity"] .bb-rl-open-media-theatre[data-id="'+i.current_media.id+'"]').closest(".bb-rl-activity-media-elem").remove(),i.medias.length),a=0;a{var e,g,n,y,v,s,w,l,t;"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},g=(e=BP_Nouveau).media,n=e.document,y=e.ajaxurl,v=e.video,s=e.is_send_ajax_request,w=e.nonces,l=e.activity,t=void 0!==window.BP_Forums_Nouveau&&(window.BP_Forums_Nouveau.media,1)?window.BP_Forums_Nouveau.media:{},bp.Nouveau.Media={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){var e=h("body"),e=(this.current_page=1,this.current_page_existing_media=1,this.current_page_albums=1,this.current_tab=!e.hasClass("single-topic")&&!e.hasClass("single-forum")&&"bp-dropzone-content",this.sort_by="",this.order_by="",this.currentTargetParent=g.current_folder,this.moveToIdPopup=g.move_to_id_popup,this.moveToTypePopup=g.current_type,this.privacySelectorSelect="",this.privacySelectorSpan="",void 0!==window.Dropzone&&(window.Dropzone.autoDiscover=!1),document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:""),e=(this.documentOptions=bp.Readylaunch.Utilities.createDropzoneOptions({dictFileTooBig:g.dictFileTooBig,acceptedFiles:g.document_type,createImageThumbnails:!1,dictDefaultMessage:g.dropzone_document_message,maxFiles:void 0!==n.maxFiles?n.maxFiles:10,maxFilesize:void 0!==n.max_upload_size?n.max_upload_size:2,dictInvalidFileType:n.dictInvalidFileType,dictMaxFilesExceeded:g.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:g.dictCancelUploadConfirmation}),document.getElementsByClassName("forum-post-video-template").length?document.getElementsByClassName("forum-post-video-template")[0].innerHTML:"");this.videoOptions=bp.Readylaunch.Utilities.createDropzoneOptions({dictFileTooBig:v.dictFileTooBig,acceptedFiles:v.video_type,createImageThumbnails:!1,dictDefaultMessage:v.dropzone_video_message,maxFiles:void 0!==v.maxFiles?v.maxFiles:10,maxFilesize:void 0!==v.max_upload_size?v.max_upload_size:2,dictInvalidFileType:v.dictInvalidFileType,dictMaxFilesExceeded:v.video_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:v.dictCancelUploadConfirmation}),h("#bp-media-uploader").hasClass("bp-media-document-uploader")?(e=document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:"",this.options=bp.Readylaunch.Utilities.createDropzoneOptions({dictFileTooBig:g.dictFileTooBig,acceptedFiles:g.document_type,createImageThumbnails:!1,dictDefaultMessage:g.dropzone_document_message,maxFiles:void 0!==n.maxFiles?n.maxFiles:10,maxFilesize:void 0!==n.max_upload_size?n.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:g.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:g.dictCancelUploadConfirmation})):(e=document.getElementsByClassName("forum-post-media-template").length?document.getElementsByClassName("forum-post-media-template")[0].innerHTML:"",this.options=bp.Readylaunch.Utilities.createDropzoneOptions({dictFileTooBig:g.dictFileTooBig,dictDefaultMessage:g.dropzone_media_message,acceptedFiles:"image/*",maxFiles:void 0!==g.maxFiles?g.maxFiles:10,maxFilesize:void 0!==g.max_upload_size?g.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:g.media_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:g.dictCancelUploadConfirmation,maxThumbnailFilesize:void 0!==g.max_upload_size?g.max_upload_size:2})),void 0!==g.dropzone_options&&Object.assign(this.options,g.dropzone_options),this.dropzone_obj=[],this.dropzone_media=[],this.album_id=void 0!==g.album_id&&g.album_id,this.current_folder=void 0!==g.current_folder&&g.current_folder,this.current_group_id=void 0!==g.current_group_id&&g.current_group_id,this.group_id=void 0!==g.group_id&&g.group_id,this.bbp_is_reply_edit=void 0!==t.bbp_is_reply_edit&&t.bbp_is_reply_edit,this.bbp_is_topic_edit=void 0!==t.bbp_is_topic_edit&&t.bbp_is_topic_edit,this.bbp_is_forum_edit=void 0!==t.bbp_is_forum_edit&&t.bbp_is_forum_edit,this.bbp_reply_edit_media=void 0!==t.reply_edit_media?t.reply_edit_media:[],this.bbp_reply_edit_document=void 0!==t.reply_edit_document?t.reply_edit_document:[],this.bbp_reply_edit_video=void 0!==t.reply_edit_video?t.reply_edit_video:[],this.bbp_topic_edit_media=void 0!==t.topic_edit_media?t.topic_edit_media:[],this.bbp_topic_edit_video=void 0!==t.topic_edit_video?t.topic_edit_video:[],this.bbp_topic_edit_document=void 0!==t.topic_edit_document?t.topic_edit_document:[],this.bbp_forum_edit_media=void 0!==t.forum_edit_media?t.forum_edit_media:[],this.bbp_forum_edit_document=void 0!==t.forum_edit_document?t.forum_edit_document:[],this.bbp_forum_edit_video=void 0!==t.forum_edit_video?t.forum_edit_video:[],this.bbp_reply_edit_gif_data=void 0!==t.reply_edit_gif_data?t.reply_edit_gif_data:[],this.bbp_topic_edit_gif_data=void 0!==t.topic_edit_gif_data?t.topic_edit_gif_data:[],this.bbp_forum_edit_gif_data=void 0!==t.forum_edit_gif_data?t.forum_edit_gif_data:[],this.giphy=null,this.gif_offset=0,this.gif_q=null,this.gif_limit=20,this.gif_requests=[],this.gif_data=[],this.gif_container_key=!1,this.reply_topic_allow_delete_media=!1,this.reply_topic_display_post="edit",bp.Nouveau.Media.documentCodeMirror(),h(window).on("scroll resize",function(){bp.Nouveau.Media.documentCodeMirror()})},refreshDirectoryFilter:function(e,t){e=h(document).find("#bb-rl-"+e+"-scope-options");e.length&&(t=e.find('option[data-bp-scope="'+t+'"]')).length&&(t=t.text().trim(),e.val(t).trigger("change"))},updateAlbumCounts:function(e){var t,i,a,o;h("#buddypress #bp-media-single-album").length&&(o=parseInt(e.album_media_count)||0,e=parseInt(e.album_video_count)||0,t=function(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},0<(a=h("#buddypress .bb-album-photo-count")).length&&(0 '+e.data.media_group_count+" "+a)):h("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(h(".bb-photos-actions").hide(),h("#media-stream")):s.find(".media-list:not(.existing-media-list)")).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(h(".bb-photos-actions").hide(),h("#media-stream")):s.find(".media-list:not(.existing-media-list)")).html(e.data.group_media_html_content):h.each(n,function(e,t){t=h('#media-stream ul.media-list li[data-id="'+t+'"]');t.length&&t.remove()}),void 0!==e.data.album_total_count&&d.updateAlbumCounts(e.data))):(setTimeout(function(){o.prop("disabled",!1)},500),e.success?(void 0!==e.data&&void 0!==e.data.media_personal_count&&(0 '+e.data.media_personal_count+" "+a)):h("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count)),void 0!==e.data&&void 0!==e.data.media_group_count&&0 '+e.data.media_group_count+" "+a)):h("#buddypress").find(".groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),(t=s.find(".media-list:not(.existing-media-list)")).find('.bb-media-check-wrap [name="bb-media-select"]:checked').each(function(){h(this).closest("li").remove()}),t.parent().parent().hasClass("album-single-view")&&t.find('.bb-video-check-wrap [name="bb-video-select"]:checked').each(function(){h(this).closest("li").remove()}),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(h(".bb-photos-actions").hide(),h("#media-stream")):t).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(h(".bb-photos-actions").hide(),h("#media-stream")):t).html(e.data.group_media_html_content):h.each(n,function(e,t){t=h('#media-stream ul.media-list li[data-id="'+t+'"]');t.length&&t.remove()})):h("#buddypress #media-stream.media").prepend(e.data.feedback));var t,i=h(".bp-nouveau #bb-select-deselect-all-media");i.hasClass("selected")&&i.removeClass("selected"),jQuery(window).scroll()}})},toggleSelectAllMedia:function(e){e.preventDefault();var e=h(e.currentTarget),t=!e.hasClass("selected");this.setMediaSelectionState(t),h("#bb-delete-media").length&&(t?h("#bb-delete-media").removeAttr("disabled"):h("#bb-delete-media").attr("disabled","disabled")),e.toggleClass("selected",t).data("bp-tooltip",t?BP_Nouveau.media.i18n_strings.unselectall:BP_Nouveau.media.i18n_strings.selectall)},editFolderTitle:function(e){e.preventDefault(),this.editAlbumFolderTitle(e,"document")},cancelEditAlbumTitle:function(e){e.preventDefault(),h("#bb-album-title").removeClass("error"),h("#bp-save-folder-title").hide(),h("#bp-cancel-edit-album-title").hide(),h("#bp-edit-album-title,#bp-edit-folder-title").show(),h("#bp-media-single-album #bp-single-album-title").show()},triggerDropzoneSelectFileDialog:function(){this.dropzone_obj.hiddenFileInput.click()},closeUploader:function(e){e.preventDefault(),h("#bp-media-uploader").hide(),h("#bp-media-add-more").hide(),h("#bp-media-uploader-modal-title").text(g.i18n_strings.upload),h("#bp-media-uploader-modal-status-text").text(""),h("#bp-media-post-content").val(""),h("#bp-dropzone-content .bp-feedback").remove(),this.dropzone_obj.element&&this.dropzone_obj.destroy(),this.dropzone_media=[];var t=h(e.currentTarget).closest("#bp-media-uploader");h(".bb-rl-close-create-popup-album").trigger("click"),h(".bb-rl-close-create-popup-folder").trigger("click"),t.find('.bb-rl-breadcrumbs-append-ul-li .item span[data-id="0"]').trigger("click"),t.find(".bb-field-steps").length&&(t.find(".bb-field-steps-1").show().siblings(".bb-field-steps-2").hide(),t.find(".bb-field-steps-1 #bp-media-photo-next, .bb-field-steps-1 #bp-media-document-next ").hide(),t.find(".bb-field-steps-1").removeClass("controls-added"),t.find("#bp-media-document-prev, #bp-media-prev, #bp-media-document-submit, #bp-media-submit, .bb-rl-media-open-create-popup-folder, .bb-rl-document-open-create-popup-folder, .bb-rl-create-popup-folder-wrap, .bb-rl-create-popup-album-wrap, .bb-rl-video-open-create-popup-album").hide()),this.clearFolderLocationUI(e)},closeChildFolderUploader:function(e){e.preventDefault();e=h(document);e.find(".open-popup #bb-album-child-title").val(""),e.find(".open-popup #bp-media-create-child-folder-submit").removeClass("loading"),e.find("#bp-media-create-child-folder").removeClass("open-popup"),e.find("#bp-media-create-child-folder").hide(),e.find(".open-popup #bb-album-title").text(""),e.find(".open-popup #bp-media-create-folder").hide(),e.find("#bp-media-create-folder").removeClass("open-popup")},closeFolderUploader:function(e){e.preventDefault();e=h(document);e.find(".open-popup #bb-album-title").val(""),e.find(".open-popup #bp-media-create-folder-submit").removeClass("loading"),e.find(".open-popup #bp-media-document-submit").hide(),e.find("#bp-media-create-folder").removeClass("open-popup"),e.find("#bp-media-create-folder").hide()},loadMoreGif:function(e){var t=e.target,i=this,a=h(e.target).closest(".bb-rl-gif-media-search-dropdown-standalone"),a=0 =t.scrollHeight&&!a.hasClass("loading")&&0 =t.scrollHeight&&!h(e.target).closest(".bp-group-messages-attached-gif-container").hasClass("loading")&&0 \n\t\n\t\t \n\t\n',e.data[t].saved=!1,this.gif_data.push(e.data[t])}i.find(".gif-search-results-list").append(a)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(this.gif_total_count=e.pagination.total_count)},loadMoreGifResponse:function(e){var t=this,i=0,a=h('div.forums-attached-gif-container[data-key="'+t.gif_container_key+'"]'),o=h(".bb-rl-gif-media-search-dropdown-standalone.open"),o=(0
\n\t\n\t\t \n\t\n',e.data[i].saved=!1,t.gif_data[t.gif_container_key].data.push(e.data[i])}o.append(d)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(t.gif_data[t.gif_container_key].total_count=e.pagination.total_count)},editGifPreview:function(){var e=this,t={};if(e.bbp_is_reply_edit&&Object.keys(e.bbp_reply_edit_gif_data).length?t=e.bbp_reply_edit_gif_data.gif_raw_data:e.bbp_is_topic_edit&&Object.keys(e.bbp_topic_edit_gif_data).length?t=e.bbp_topic_edit_gif_data.gif_raw_data:e.bbp_is_forum_edit&&Object.keys(e.bbp_forum_edit_gif_data).length&&(t=e.bbp_forum_edit_gif_data.gif_raw_data),void 0===t.images)return!1;e=h("#whats-new-attachments .forums-attached-gif-container"),e[0].style.backgroundImage="url("+t.images.fixed_width.url+")",e[0].style.backgroundSize="contain",e[0].style.height=t.images.original.height+"px",e[0].style.width=t.images.original.width+"px",e.find(".gif-image-container img").attr("src",t.images.original.url),e.removeClass("closed"),e=h("#bbp_media_gif");e.length&&e.val(JSON.stringify(t))},selectGif:function(e){var t,i=this,a=0,o=h(e.currentTarget),d=o.closest(".bb-rl-gif-media-search-dropdown-standalone"),r=0
\n\t\n\t\t \n\t\n',e.data[s].saved=!1,n.gif_data.push(e.data[s])}h(r.target).closest(".bp-group-messages-attached-gif-container").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(n.gif_total_count=e.pagination.total_count),h(r.target).closest(".bp-group-messages-attached-gif-container").removeClass("loading")},function(){h(r.target).find(".gif-no-connection").addClass("show")}));n.gif_requests.push(e),n.gif_offset=n.gif_offset+n.gif_limit},searchGifRequest:function(r){var n=this,s=0,e=h(r.target).closest(".bb-rl-gif-media-search-dropdown-standalone"),t=0
\n\t\n\t\t \n\t\n',e.data[s].saved=!1,n.gif_data[p].data.push(e.data[s])}h(r.target).closest(".gif-search-content").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(n.gif_data[p].total_count=e.pagination.total_count),l.removeClass("loading")},function(){c.find(".gif-no-connection").addClass("show")}));n.gif_data[p].requests.push(i),n.gif_data[p].offset=n.gif_data[p].offset+n.gif_data[p].limit},clearGifRequests:function(e){var t=this;if(void 0!==t.gif_data[e]&&void 0!==t.gif_data[e].requests){for(var i=t.gif_data[e].requests.length,a=0;a
",l.html(e),l.find(".gif-search-results").on("scroll",s.loadMoreGif.bind(s))),void 0!==window.Giphy&&void 0!==g.gif_api_key&&(s.giphy=new window.Giphy(g.gif_api_key),(r=i.closest("form").find(".forums-attached-gif-container")).addClass("loading"),n=r.data("key"),s.clearGifRequests(n),s.gif_data[n]={q:null,offset:0,limit:20,requests:[],total_count:0,data:[]},e=s.giphy.trending({offset:s.gif_data[n].offset,fmt:"json",limit:s.gif_data[n].limit},function(e){if(void 0!==e.data&&e.data.length){var t="",i=e.data.length;for(c=0;c\n\t\n\t\t'+(g.gif_no_results||"No results found")+'
'+(g.gif_no_connection||"Could not connect to GIPHY")+"
\n\t\n',e.data[c].saved=!1,s.gif_data[n].data.push(e.data[c])}l.find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(s.gif_data[n].total_count=e.pagination.total_count),r.removeClass("loading")}),s.gif_data[n].requests.push(e),s.gif_data[n].offset=s.gif_data[n].offset+s.gif_data[n].limit),l.toggleClass("open"),a&&l.hasClass("open")&&(e=h(window).scrollTop(),a=i.offset(),d=Math.round(a.top),a=Math.round(a.left),t=h("body").hasClass("rtl"),o=l.outerWidth(),t=t?"translate(-"+(h(window).width()-a-i.outerWidth()+o-70)+"px, "+(d-e-5)+"px) translate(0, -100%)":"translate("+(a+o-70)+"px, "+(d-e-5)+"px) translate(-100%, -100%)",l.css("transform",t),l.data("target-form",i.closest("form"))),i.parents("form").find("#whats-new-attachments .forums-attached-gif-container img")),o=(0
\n\t\n\t\t \n\t\n',e.data[s].saved=!1,r.gif_data.push(e.data[s])}n.closest("form").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(r.gif_total_count=e.pagination.total_count),h(".gif-search-query").closest(".bp-group-messages-attached-gif-container").removeClass("loading")}),r.gif_requests.push(e),r.gif_offset=r.gif_offset+r.gif_limit),n.parents("form").find("#whats-new-attachments .bp-group-messages-attached-gif-container img"));0
'+h(this).text()+""),h(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").removeClass("is-disabled"),h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").hasClass("is-disabled"))||((h(e.currentTarget).closest(".bb-field-wrap").length?h(e.currentTarget).closest(".bb-rl-field-wrap"):h(e.currentTarget).closest(".bb-field-wrap")).find(".bb-rl-album-selected-id").val(h(e.currentTarget).data("id")),t=h(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),0!==Number(h(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(h(e.currentTarget).parent().data("privacy")).trigger("change"),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public").trigger("change"),t.prop("disabled",!1)))}),o.on("click",t+" .breadcrumb .item > span",function(e){var t,i;h(this).hasClass("is-disabled")||(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-album-selected-id").val(0),h(e.currentTarget).closest(".bb-rl-field-wrap").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),a===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").removeClass("is-disabled"),t=h(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),i=h(e.currentTarget).closest("#bp-media-uploader").find(".location-album-list li.is_active").data("privacy"),0!==Number(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-album-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i).trigger("change"),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public").trigger("change"),t.prop("disabled",!1)))}),i.options.previewTemplate=document.getElementsByClassName("uploader-post-media-template").length?document.getElementsByClassName("uploader-post-media-template")[0].innerHTML:"",i.dropzone_obj=new Dropzone("div#media-uploader",i.options),i.dropzone_obj.on("sending",function(e,t,i){i.append("action","media_upload"),i.append("_wpnonce",w.media)}),i.dropzone_obj.on("uploadprogress",function(e){var t=h(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI;t.style.strokeDasharray=i+" "+i,t.style.strokeDashoffset=i,t.style.strokeDashoffset=i-e.upload.progress.toFixed(0)/100*i}),i.dropzone_obj.on("addedfile",function(){setTimeout(function(){i.dropzone_obj.getAcceptedFiles().length&&h("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(g.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),i.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?h(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"===e.status&&e.xhr&&0===e.xhr.status&&h(e.previewElement).find(".dz-error-message span").text(g.connection_lost_error):(jQuery(".media-error-popup").length||h("body").append('"),this.removeFile(e))}),i.dropzone_obj.on("queuecomplete",function(){h("#bp-media-uploader-modal-title").text(g.i18n_strings.upload)}),i.dropzone_obj.on("processing",function(){h("#bp-media-uploader-modal-title").text(g.i18n_strings.uploading+"...")}),i.dropzone_obj.on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=i.dropzone_media.length,t.data.album_id=i.album_id,t.data.group_id=i.group_id,t.data.saved=!1,i.dropzone_media.push(t.data)):(jQuery(".media-error-popup").length||h("body").append('"),this.removeFile(e)),h(".bb-field-steps-1 #bp-media-photo-next, #bp-media-submit").show(),h(".modal-container").addClass("modal-container--alert"),h(".bb-field-steps-1").addClass("controls-added"),h("#bp-media-add-more").show(),h("#bp-media-uploader-modal-title").text(g.i18n_strings.uploading+"..."),h("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(g.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()}),i.dropzone_obj.on("removedfile",function(e){if(i.dropzone_media.length)for(var t in i.dropzone_media)if(e.upload.uuid===i.dropzone_media[t].uuid){void 0===i.dropzone_media[t].saved||i.dropzone_media[t].saved||i.removeAttachment(i.dropzone_media[t].id),i.dropzone_media.splice(t,1);break}i.dropzone_obj.getAcceptedFiles().length?h("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(g.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show():(h("#bp-media-uploader-modal-status-text").text(""),h("#bp-media-add-more, #bp-media-photo-next").hide(),h(".bb-field-steps-1").removeClass("controls-added"),h("#bp-media-submit").hide(),h(".modal-container").removeClass("modal-container--alert"))}))},openDocumentUploader:function(e){var a,t,l=this,i=(e.preventDefault(),h(document)),o=h("#bp-media-uploader");void 0!==window.Dropzone&&h("div#media-uploader").length&&(o.hasClass("bp-media-document-uploader")&&!this.currentTargetParent&&(this.currentTargetParent=0),h(e.currentTarget).closest("#bp-media-single-folder").length&&h("#bb-document-privacy").hide(),i.removeClass("open-popup"),o.show(),o.addClass("open-popup"),bp.Readylaunch&&bp.Readylaunch.initSelect2Scoped&&bp.Readylaunch.initSelect2Scoped(o),h("#bp-media-uploader.bp-media-document-uploader").find(".bb-field-steps.bb-field-steps-2").length&&(t="#bp-media-uploader.bp-media-document-uploader",0!==Number(h(t).find(".bb-rl-folder-selected-id").data("value"))?(a=h(t).find(".bb-rl-folder-selected-id").data("value"),h(t).find("#bb-document-privacy").prop("disabled",!0)):a=0,""!==this.moveToIdPopup)&&h.ajax({url:y,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:w.media},success:function(e){i.find(".bp-media-document-uploader .bb-rl-location-folder-list-wrap h4 span.bb-rl-where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(i.find(".bp-media-document-uploader.open-popup .bb-rl-location-folder-list-wrap").hide(),i.find(".bp-media-document-uploader.open-popup .bb-rl-location-folder-list-wrap-main span.bb-rl-no-folder-exists")):(i.find(".bp-media-document-uploader.open-popup .bb-rl-location-folder-list-wrap-main span.bb-rl-no-folder-exists").hide(),i.find(".bp-media-document-uploader.open-popup .bb-rl-location-folder-list-wrap"))).show(),i.find(".bp-media-document-uploader .bb-rl-popup-on-fly-create-album .bb-rl-privacy-field-wrap-hide-show").show(),i.find(".bp-media-document-uploader .open-popup .bb-rl-folder-create-from").val("profile"),h(t).find(".bb-rl-location-folder-list-wrap .location-folder-list").remove(),h(t).find(".bb-rl-location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,a),h(t).find("ul.location-folder-list span#"+a).trigger("click"),h(t).find(".bb-rl-folder-selected-id").val(a)}}),i.on("click",t+" .location-folder-list li span",function(e){var t;e.preventDefault(),h(this).parent().hasClass("is_active")||(0!==h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item").append(''+h(this).text()+""),h(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").removeClass("is-disabled"),h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").hasClass("is-disabled"))||(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-folder-selected-id").val(h(e.currentTarget).data("id")),t=h(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),0!==Number(h(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(h(e.currentTarget).parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),i.on("click",t+" .breadcrumb .item > span",function(e){var t,i;h(this).hasClass("is-disabled")||(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-folder-selected-id").val(h(e.currentTarget).data("id")),h(e.currentTarget).closest(".bb-rl-field-wrap").find(".location-folder-list li span").removeClass("selected").parent().removeClass("is_active"),h(e.currentTarget).closest(".bb-rl-field-wrap").find('.location-folder-list li[data-id="'+h(e.currentTarget).data("id")+'"]').addClass("is_active"),h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&h(this).closest(".bb-rl-location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),a===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-model-footer .bb-rl-media-move").removeClass("is-disabled"),t=h(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),i=h(e.currentTarget).closest("#bp-media-uploader").find(".location-folder-list li.is_active").data("privacy"),0!==Number(h(e.currentTarget).closest(".bb-rl-field-wrap").find(".bb-rl-folder-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),l.options.previewTemplate=document.getElementsByClassName("uploader-post-document-template").length?document.getElementsByClassName("uploader-post-document-template")[0].innerHTML:"",l.dropzone_obj=new Dropzone("div#media-uploader",l.options),l.dropzone_obj.on("sending",function(e,t,i){i.append("action","document_document_upload"),i.append("_wpnonce",w.media)}),l.dropzone_obj.on("uploadprogress",function(e){var t=h(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI;t.style.strokeDasharray=i+" "+i,t.style.strokeDashoffset=i,t.style.strokeDashoffset=i-e.upload.progress.toFixed(0)/100*i}),l.dropzone_obj.on("addedfile",function(){setTimeout(function(){l.dropzone_obj.getAcceptedFiles().length&&h("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(g.i18n_strings.upload_status,l.dropzone_media.length,l.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),l.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?h(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"===e.status&&e.xhr&&0===e.xhr.status&&h(e.previewElement).find(".dz-error-message span").text(g.connection_lost_error):(jQuery(".document-error-popup").length||h("body").append('"),this.removeFile(e))}),l.dropzone_obj.on("accept",function(e,t){0===e.size?t(g.empty_document_type):t()}),l.dropzone_obj.on("queuecomplete",function(){h("#bp-media-uploader-modal-title").text(g.i18n_strings.upload)}),l.dropzone_obj.on("processing",function(){h("#bp-media-uploader-modal-title").text(g.i18n_strings.uploading+"...")}),l.dropzone_obj.on("success",function(e,t){if(!t.data.id){var i,a,o,d,r,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),r=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a .bb-rl-activity-content .bb-rl-media-move-file",h(a).find(".bb-rl-document-move").attr("id",e.closest(".bb-rl-document-activity").attr("data-id")),0 '),d),n=this.moveToTypePopup;""!==this.moveToIdPopup&&h.ajax({url:y,type:"post",data:{action:"media_get_album_view",id:this.moveToIdPopup,type:this.moveToTypePopup},success:function(e){o.find(".bb-rl-location-album-list-wrap h4 span.bb-rl-where-to-move-profile-or-group-media").html(e.data.first_span_text),(""===e.data.html?(o.find(".open-popup .bb-rl-location-album-list-wrap").hide(),o.find(".open-popup .bb-rl-location-album-list-wrap-main span.bb-rl-no-album-exists")):(o.find(".open-popup .bb-rl-location-album-list-wrap-main span.bb-rl-no-album-exists").hide(),o.find(".open-popup .bb-rl-location-album-list-wrap"))).show(),"group"===n?(o.find(".bb-rl-popup-on-fly-create-album .bb-rl-privacy-field-wrap-hide-show").hide(),o.find(".open-popup .bb-rl-album-create-from").val("group")):(o.find(".bb-rl-popup-on-fly-create-album .bb-rl-privacy-field-wrap-hide-show").show(),o.find(".open-popup .bb-rl-album-create-from").val("profile")),!1===e.data.create_album?(h(a+".open-popup").find(".bb-rl-media-open-create-popup-folder").removeClass("create-album"),h(a+".open-popup").find(".bb-rl-media-open-create-popup-folder").hide()):(h(a+".open-popup").find(".bb-rl-media-open-create-popup-folder").addClass("create-album"),h(a+".open-popup").find(".bb-rl-media-open-create-popup-folder").show()),h(a).find(".bb-rl-location-album-list-wrap .location-album-list").remove(),h(a).find(".bb-rl-location-album-list-wrap").append(e.data.html),h(a).find(".bb-rl-model-footer .bb-rl-media-move").removeClass("loading"),h(a).find("ul.location-album-list span#"+r).trigger("click")}}),o.on("click",a+" .location-album-list li span",function(e){var t;e.preventDefault(),h(this).parent().hasClass("is_active")||(0!==h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item").append(''+h(this).text()+""),h(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),t=h(document).find('a.bb-rl-open-media-theatre[data-id="'+i.find(".bb-rl-media-move").attr("id")+'"]').data("album-id"),Number(t)===Number(h(e.currentTarget).data("id"))?h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").removeClass("is-disabled"),h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").hasClass("is-disabled"))||h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-album-selected-id").val(h(e.currentTarget).data("id"))}),o.on("click",a+" .breadcrumb .item > span",function(e){h(this).hasClass("is-disabled")||(h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-album-selected-id").val(0),h(e.currentTarget).closest(".bb-rl-media-move-file").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&h(this).closest(".bb-rl-location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),r===h(e.currentTarget).data("id")?h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").addClass("is-disabled"):h(e.currentTarget).closest(".bb-rl-media-move-file").find(".bb-rl-model-footer .bb-rl-media-move").removeClass("is-disabled"))})},openDocumentMove:function(e){e.preventDefault();var t,i=h(document),a=h(),e=h(e.currentTarget),o=(this.moveToIdPopup=e.attr("id"),this.moveToTypePopup=e.attr("data-type"),e.attr("data-action")),d=(h(".bb-rl-media-move-file.open-popup, .bb-rl-media-move-folder.open-popup").hide().removeClass("open-popup"),e.closest("#bb-rl-activity-modal")),r=(0===d.length&&(d=h("body")),e.closest(".bb-rl-conflict-activity-ul-li-comment").closest("li.comment-item").length?(t=e.closest("li.comment-item"),a=d.find("#"+t.attr("id")+".comment-item .bb-rl-media-move-file").first()):0<(t=e.closest("li.activity-item")).length&&(a=d.find("#"+t.attr("id")+" > .bb-rl-activity-content .bb-rl-media-move-file").first()),a&&0!==a.length||(e.closest(".bb-rl-conflict-activity-ul-li-comment").closest("li.comment-item").length?(t=e.closest("li.comment-item").attr("id"),a=d.find("#"+t+".comment-item .bb-rl-media-move-file").first()):(t=e.closest("li.activity-item").attr("id"))&&(a=d.find("#"+t+" > .bb-rl-activity-content .bb-rl-media-move-file").first())),a.find(".bb-rl-document-move").attr("id",e.closest(".bb-rl-document-activity").attr("data-id")),this.currentTargetParent=e.closest(".bb-rl-activity-media-elem").attr("data-parent-id"),0 '),"document"===o?a.find(".bb-rl-modal-header h4 .target_name").text(g.move_to_file):a.find(".bb-rl-modal-header h4 .target_name").text(g.move_to_folder),a.show(),a.addClass("open-popup"),"group"===this.moveToTypePopup?(i.find(".bb-rl-location-folder-list-wrap h4").show(),a.addClass("move-folder-popup-group")):(i.find(".bb-rl-location-folder-list-wrap h4").hide(),h(".move-folder-popup-group").removeClass("move-folder-popup-group")),this.currentTargetParent),n=this.moveToTypePopup;""!==this.moveToIdPopup&&h.ajax({url:y,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:w.media},success:function(e){var t;i.find(".bb-rl-location-folder-list-wrap h4 span.bb-rl-where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(a.find(".bb-rl-location-folder-list-wrap").hide(),a.find(".bb-rl-location-folder-list-wrap-main span.bb-rl-no-folder-exists")):(a.find(".bb-rl-location-folder-list-wrap-main span.bb-rl-no-folder-exists").hide(),a.find(".bb-rl-location-folder-list-wrap"))).show(),"group"===n?(a.find(".bb-rl-popup-on-fly-create-folder .bb-rl-privacy-field-wrap-hide-show").hide(),a.find(".bb-rl-folder-create-from").val("group")):(a.find(".bb-rl-popup-on-fly-create-folder .bb-rl-privacy-field-wrap-hide-show").show(),a.find(".bb-rl-folder-create-from").val("profile")),a.find(".bb-rl-location-folder-list-wrap .location-folder-list").remove(),a.find(".bb-rl-location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&(e=(e=a.attr("id"))?"#"+e:(t=a.attr("class"))?"."+t.split(" ")[0]:".bb-rl-media-move-file",bp.Nouveau.Media.folderLocationUI(e,r),a.find("ul.location-folder-list span#"+r).trigger("click"))}})},closeMediaMove:function(e){e.preventDefault();e=h(e.currentTarget);0!==e.closest(".bb-rl-media-move-file").find(".bb-rl-location-album-list-wrap .breadcrumb .item span:last-child").data("id")&&e.closest(".bb-rl-media-move-file").find(".bb-rl-location-album-list-wrap .breadcrumb .item span:last-child").remove(),e.closest(".bb-rl-media-move-file").hide().removeClass("open-popup")},closeDocumentMove:function(e){e.preventDefault();var t=h(e.currentTarget),i=jQuery(e.currentTarget).closest(".bb-rl-has-folderlocationUI");(t.hasClass("bb-rl-ac-document-close-button")?(t.closest(".bb-rl-media-move-file"),h(".bb-rl-media-move-file.open-popup").hide().removeClass("open-popup").find(".bb-rl-document-move")):(t.closest(".bb-rl-media-move-folder"),h(".bb-rl-media-move-folder.open-popup").hide().removeClass("open-popup").find(".bb-rl-folder-move"))).attr("id",""),h(".bb-rl-media-move-file.open-popup").removeClass("open-popup").hide(),h(".bb-rl-media-move-folder.open-popup").removeClass("open-popup").hide(),i.find(".bb-rl-document-move.loading").removeClass("loading"),this.clearFolderLocationUI(e)},renameDocument:function(e){var t=h(e.currentTarget).closest(".media-folder_items").find(".media-folder_name"),i=t.children("span").text();t.hide().siblings(".media-folder_name_edit_wrap").show().children(".media-folder_name_edit").val(i).focus().select(),e.preventDefault()},editDocument:function(e){e.preventDefault();var t=h(document),i=h("#bb-rl-media-edit-file"),a=h(e.currentTarget).closest(".media-folder_items"),o=a.find(".media-folder_name").children("span").text(),d=a.data("id"),r=a.find(".media-folder_name").data("attachment-id"),a=a.find(".media-folder_name").data("privacy");h(e.currentTarget).attr("data-privacy")&&0 span"),o=t.closest(".media-folder_items").find(".media-folder_name"),d=t.closest(".media-folder_items").find(".media-folder_name > i.media-document-id").attr("data-item-id"),r=t.closest(".media-folder_items").find(".media-folder_name > i.media-document-attachment-id").attr("data-item-id"),n=t.closest(".media-folder_items").find(".media-folder_name > i.media-document-type").attr("data-item-id"),s=i.val().trim(),l="",l=(t.closest(".ac-document-list").length?l=/[?\[\]=<>:;,'"&$#*()|~`!{}%+ \/]+/g:t.closest(".ac-folder-list").length&&(l=/[\\/?%*:|"<>]+/g),l.exec(s)),l=Boolean(l);if(l?i.addClass("error"):i.removeClass("error"),t.closest(".ac-document-list").length&&(-1!==s.indexOf("\\\\")||l?i.addClass("error"):i.removeClass("error")),!t.hasClass("name_edit_cancel")&&27!==e.keyCode||(i.removeClass("error"),i.parent().hide().siblings(".media-folder_name").show()),t.hasClass("name_edit_save")||13===e.keyCode){if(l)return;i.parent().addClass("submitting").append(''),h.ajax({url:y,type:"post",data:{action:"document_update_file_name",document_id:d,attachment_document_id:r,document_type:n,name:s,_wpnonce:w.media},success:function(e){e.success?void 0!==e.data.document&&0 span"),r=o.find(".media-folder_name"),n=o.find(".media-folder_name > i.media-document-id").attr("data-item-id"),s=o.find(".media-folder_name > i.media-document-attachment-id").attr("data-item-id"),l=o.find(".media-folder_name > i.media-document-type").attr("data-item-id"),c=t.val().trim(),p=0 :;,'"&$#*()|~`!{}%+ \/]+/g:/[\\/?%*:|"<>]+/g).exec(c),m=Boolean(b),b=a.find(".error-box");m?(t.addClass("error"),("folder"===l?b.text(b.data("folder-error")||b.text()):b.text(b.data("document-error")||b.text())).show()):(t.removeClass("error"),b.hide()),"folder"!==l&&o.length&&(-1!==c.indexOf("\\\\")||m?(t.addClass("error"),b.text(b.data("document-error")||b.text()).show()):(t.removeClass("error"),b.hide())),m||(u||f?(i.addClass("saving"),h.ajax({url:y,type:"post",data:{action:"bb_rl_document_rename_and_privacy_update",document_id:n,attachment_document_id:s,document_type:l,name:c,privacy:p,update_name:u,update_privacy:f,_wpnonce:w.media},success:function(e){var t;e.success?(u&&void 0!==e.data.response.document&&0 ');e.parents("li").each(function(e,t){t=h(t).children("span").clone().show();i.prepend("",t)}),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+g.target_text+"")),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").width()&&(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||h('...').insertAfter(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),h(this).hasClass("selected")&&!h(this).hasClass("disabled")?(h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".bb-rl-folder-destination").val(""),h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".bb-rl-folder-selected-id").val("0"),h(a).find(".location-folder-list li.is_active").length?h(a).find(".bb-rl-folder-selected-id").val(h(a).find(".location-folder-list li.is_active").attr("data-id")):h(a).find(".bb-rl-folder-selected-id").val("0")):(h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".location-folder-list li span").removeClass("selected"),h(this).addClass("selected"),h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".bb-rl-folder-destination").val(h(this).text()),h(this).closest(".bb-rl-location-folder-list-wrap-main").find(".bb-rl-folder-selected-id").val(h(this).parent().attr("data-id"))),h(this).closest(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(h(this).siblings("span").text()).siblings(".location-folder-back").css("display","inline-block"),h(this).siblings("ul").show().siblings("span, i").hide().parent().siblings().hide(),h(this).siblings("ul").children("li").show().children("span,i").show(),h(this).closest(".is_active").removeClass("is_active"),h(a).find("li.is_active").removeClass("is_active"),h(this).parent().addClass("is_active"),h(a).find(".bb-rl-folder-selected-id").val(h(a).find(".location-folder-list li.is_active").attr("data-id")),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").each(function(){h(this).show()}),o===h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").attr("data-id")&&(h(a).hasClass("bb-rl-media-move-file")||h(a).hasClass("bb-rl-media-move-folder"))?(h(a).find(".bb-rl-document-move").addClass("is-disabled"),h(a).find(".bb-rl-folder-move").addClass("is-disabled")):(h(a).find(".bb-rl-document-move").removeClass("is-disabled"),h(a).find(".bb-rl-folder-move").removeClass("is-disabled")),setTimeout(function(){h(a).closest(".bb-activity-media-wrap").find(".bb-rl-activity-media-elem.bb-rl-document-activity").attr("data-parent-id")===(h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").prev():h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child")).attr("id")&&(h(a).hasClass("bb-rl-media-move-file")||h(a).hasClass("bb-rl-media-move-folder"))?(h(a).find(".bb-rl-document-move").addClass("is-disabled"),h(a).find(".bb-rl-folder-move").addClass("is-disabled")):(h(a).find(".bb-rl-document-move").removeClass("is-disabled"),h(a).find(".bb-rl-folder-move").removeClass("is-disabled"))},100)}),e.on("click",a+" .bb-rl-breadcrumbs-append-ul-li .item span",function(e){var t,i;h(this).parent().hasClass("is-disabled")||h(this).hasClass("more_options")||(t=h(e.currentTarget).attr("data-id"),h(a).find(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(h(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),h(a).find(".bb-rl-folder-selected-id").val(t),h(a).find(".location-folder-list li").hide(),h(a).find(".location-folder-list li.is_active").removeClass("is_active"),h(a).find(".location-folder-list li > span.selected").removeClass("selected"),h(a).find('.location-folder-list li[data-id="'+t+'"]').addClass("is_active").children("span").addClass("selected"),h(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),h(a).find(".location-folder-list li.is_active").children("ul").length&&!h(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){h(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):h(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?h(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){h(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),"0"===t&&(h(a).find(".location-folder-list").children("li").show().children("span,i").show(),h(a).find(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(g.target_text),h(a).find(".location-folder-back").hide()),h(e.currentTarget).nextAll().remove(),o===h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").attr("data-id")&&(h(a).hasClass("bb-rl-media-move-file")||h(a).hasClass("bb-rl-media-move-folder"))?(h(a).find(".bb-rl-document-move").addClass("is-disabled"),h(a).find(".bb-rl-folder-move").addClass("is-disabled")):(h(a).find(".bb-rl-document-move").removeClass("is-disabled"),h(a).find(".bb-rl-folder-move").removeClass("is-disabled")),e=h(a).find(".location-folder-list .is_active > span"),i=h(''),e.parents("li").each(function(e,t){t=h(t).children("span").clone().show();i.prepend("",t)}),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+g.target_text+"")),0===h(a).find('.bb-rl-breadcrumbs-append-ul-li .breadcrumb .item > span[data-id="'+t+'"]').length&&h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item").append(h(a).find('.location-folder-list li[data-id="'+t+'"]').children("span").clone().show()),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").width()&&(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||h('...').insertAfter(h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),h(a).find(".bb-rl-folder-selected-id").val(t))})),h(a).find(".location-folder-list li").each(function(){h(this).children("ul").parent().addClass("has-ul").append('')}),h(a).hasClass("bb-rl-media-move-folder")&&(h(a).find(".location-folder-list li>span").removeClass("is-disabled"),h(a).find('.location-folder-list li>span[id="'+h(a).find(".bb-rl-folder-move").attr("id")+'"]').parent().addClass("is-disabled")),e=h(a).find(".bb-rl-folder-move").attr("id"),0===h(a).find('.location-folder-list li[data-id="'+e+'"]').siblings().length&&h(a).find('.location-folder-list li[data-id="'+e+'"]').parent("ul").addClass("no-folder-list a"),o&&(h(a).find(".location-folder-list li").hide(),h(a).find(".location-folder-list li.is_active").removeClass("is_active"),h(a).find('.location-folder-list li[data-id="'+o+'"]').addClass("is_active"),h(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),h(a).find(".location-folder-list li.is_active").children("ul").length&&!h(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){h(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):h(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?h(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){h(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),h(a).find(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(h(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),h(a).find(".bb-rl-folder-selected-id").val(h(a).find(".location-folder-list li.is_active").attr("data-id")),h(a).find('.location-folder-list li[data-id="'+e+'"]').children().hide()),"0"===o&&(h(a).find(".location-folder-list").children("li").show(),h(a).find(".bb-rl-location-folder-list-wrap").find(".location-folder-title").text(g.target_text),h(a).find(".location-folder-back").hide()),setTimeout(function(){var e=h(a).closest(".bb-activity-media-wrap").find(".bb-rl-activity-media-elem.bb-rl-document-activity").attr("data-parent-id"),t=(h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child").prev():h(a).find(".bb-rl-breadcrumbs-append-ul-li .item > span:last-child")).attr("id");e===t&&(h(a).hasClass("bb-rl-media-move-file")||h(a).hasClass("bb-rl-media-move-folder"))?(h(a).find(".bb-rl-document-move").addClass("is-disabled"),h(a).find(".bb-rl-folder-move").addClass("is-disabled")):(h(a).find(".bb-rl-document-move").removeClass("is-disabled"),h(a).find(".bb-rl-folder-move").removeClass("is-disabled"))},100),e=h(a).find(".location-folder-list .is_active > span"),i=h(''),e.parents("li").each(function(e,t){t=h(t).children("span").clone().show();i.prepend("",t)}),h(a).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+g.target_text+"")))},clearFolderLocationUI:function(e){e=jQuery(e.currentTarget).closest(".bb-rl-has-folderlocationUI");0 '+e.data.media_group_count+" "+n)):i.find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").length?i.find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count):((d=document.createElement("span")).setAttribute("class","count"),t=document.createTextNode(e.data.media_group_count),d.appendChild(t),i.find(".bp-wrap .users-nav ul li#photos-groups-li a").append(d))),"yes"===g.is_media_directory&&(i.find(".media-type-navs ul.media-nav li#media-all a span.count").text(e.data.media_all_count),i.find(".media-type-navs ul.media-nav li#media-personal a span.count").text(e.data.media_personal_count),i.find(".media-type-navs ul.media-nav li#media-groups a span.count").text(e.data.media_group_count)),void 0!==e.data.album_total_count&&s.updateAlbumCounts(e.data),s.dropzone_media.length),o=0;o").addClass("media-list item-list bp-list bb-photo-list grid")),0<(t=h(".bb-photos-actions")).length&&t.show(),bp.Nouveau.inject("#media-stream ul.media-list",e.data.media,"prepend"),h('.bp-existing-media-wrap .bb-media-check-wrap [name="bb-media-select"]:checked').each(function(){parseInt(h(this).closest("li").data("id"))===parseInt(h(this).val())&&h(this).closest("li").remove()}),void 0===e.data.source_album_id&&void 0===e.data.dest_album_id||(t=h("#buddypress #bp-media-single-album")).length&&(i={},(t=parseInt(t.attr("data-id")||t.attr("data-album-id"))||0)===e.data.source_album_id?(i.album_media_count=e.data.source_album_media_count,i.album_video_count=e.data.source_album_video_count):t===e.data.dest_album_id&&(i.album_media_count=e.data.dest_album_media_count,i.album_video_count=e.data.dest_album_video_count),s.updateAlbumCounts(i)),jQuery(window).scroll(),s.closeUploader(r)):h("#bp-existing-media-content").prepend(e.data.feedback),l.removeClass("saving")}})):s.current_tab||(s.closeUploader(r),l.removeClass("saving"))},submitDocumentMedia:function(a){var o=this,d=h(a.currentTarget),r=h(a.currentTarget).closest("#bp-media-uploader");if(a.preventDefault(),d.hasClass("saving"))return!1;var n=h(document);if(d.addClass("saving"),"bp-dropzone-content"===o.current_tab){var e=h("#bp-media-post-content").val(),t=h("#bb-document-privacy").val(),i=h(a.currentTarget).closest(".open-popup"),s=i.find(".bb-rl-folder-selected-id").val(),i=i.find(".bb-rl-folder-selected-id").data("value"),l=!0;if(s.length&&0 ").addClass("display")),h("#media-stream div").attr("id","media-folder-document-data-table"),h(".bb-photos-actions").show()),h(".document-data-table-head").length?"yes"===g.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(n.find("li#document-personal a").trigger("click"),n.find("li#document-personal").trigger("click")):l&&bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"):location.reload(!0),h("#bp-media-post-content").val("");for(var t=o.dropzone_media.length,i=0;i ]+/g.exec(e.val()),d=Boolean(d);if(""===h.trim(e.val())||d)return e.addClass("error"),!1;e.removeClass("error"),t.prop("disabled",!0).addClass("loading");d={action:"document_edit_folder",_wpnonce:w.media,title:e.val(),privacy:a.val(),id:o,group_id:i.current_group_id};h(".bb-single-album-header .bp-feedback").remove(),h("#bb-rl-media-create-album-popup .bp-feedback").remove(),h.ajax({type:"POST",url:y,data:d,success:function(e){setTimeout(function(){t.prop("disabled",!1)},500),e.success?window.location.reload(!0):i.current_folder?h("#bp-media-single-album").prepend(e.data.feedback):h("#bb-rl-media-create-album-popup .bb-model-header").after(e.data.feedback)}})},deleteAlbum:function(e){e.preventDefault(),this.deleteAttachment(e,"media","album")},deleteFolder:function(e){e.preventDefault(),this.deleteAttachment(e,"document","folder")},injectMedias:function(e){this.injectAttachments(e,"media")},injectDocuments:function(e){this.injectAttachments(e,"document")},sortDocuments:function(e){var e=h(e.currentTarget),t="",i="date_created";switch(e.data("target")){case"name":i="title";break;case"modified":i="date_modified";break;case"visibility":i="privacy";break;case"group":i="group_id"}e.hasClass("asce")?e.removeClass("asce"):e.addClass("asce");var e=e.hasClass("asce")?"DESC":"ASC",a={},a=(a.orderby=i,a.sort=e,"group"!==i&&bp.Nouveau.setStorage("bp-document","extras",a),bp.Nouveau.getStorage("bp-document")),o=a.scope||null,a=a.filter||null,d=h("#buddypress .bp-dir-search-form input[type=search]");d.length&&(t=d.val()),this.sort_by=e,this.order_by=i,this.current_page=1,bp.Nouveau.objectRequest({object:"document",scope:o,filter:a,search_terms:t,page:1,order_by:i,sort:e,method:"reset",target:"#buddypress [data-bp-list]"}).done()},documentPopupNavigate:function(e){e.preventDefault();var e=h(e.currentTarget),t=e.closest(".bb-field-steps"),i=0===e.closest(".bp-document-listing").length?"#bb-album-child-title":"#bb-album-title";e.closest(".document-options").length&&(i="#bb-album-title"),e.hasClass("bb-field-steps-next")&&""===t.find(i).val().trim()?t.find(i).addClass("error"):(t.find(i).removeClass("error"),t.slideUp(200).siblings(".bb-field-steps").slideDown(200))},uploadDocumentNavigate:function(e){e.preventDefault();var e=h(e.currentTarget),t=h(e).closest("#bp-media-uploader");h(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-document-submit, #bp-media-document-prev, .bb-rl-document-open-create-popup-folder, #bb-document-privacy").show(),0!==Number(h(t).find(".bb-rl-folder-selected-id"))&&h(t).find(".location-folder-list li.is_active").length&&h(t).find(".location-folder-list").scrollTop(h(t).find(".location-folder-list li.is_active").offset().top-h(t).find(".location-folder-list").offset().top),h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").width()&&(h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||h('...').insertAfter(h(t).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))})):(h(e).hide(),t.find("#bp-media-document-prev, .bb-rl-document-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-folder").length&&h("#bb-document-privacy").hide())},uploadMediaNavigate:function(e){e.preventDefault();var e=h(e.currentTarget),t=h(e).closest(".bp-media-photo-uploader");h(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-submit, #bp-media-prev, .bb-rl-media-open-create-popup-folder.create-album").show(),t.find("#bb-media-privacy").show(),0!==Number(h(t).find(".bb-rl-album-selected-id"))&&h(t).find(".location-album-list li.is_active").length&&h(t).find(".location-album-list").scrollTop(h(t).find(".location-album-list li.is_active").offset().top-h(t).find(".location-album-list").offset().top)):(h(e).hide(),t.find("#bp-media-prev, .bb-rl-media-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-album").length&&h("#bb-media-privacy").hide())},appendMedia:function(e){var t,i,a,o=bp.Nouveau.getStorage("bp-media"),d=o.scope||null,o=o.filter||null,r=h(e.currentTarget);r.hasClass("load-more")&&(t=Number(this.current_page_existing_media)+1,i=this,a="",e.preventDefault(),r.find("a").first().addClass("loading"),(e=h("#buddypress .dir-search input[type=search]")).length&&(a=e.val()),bp.Nouveau.objectRequest({object:"media",scope:d,filter:o,search_terms:a,page:t,method:"append",caller:"bp-existing-media",target:".bp-existing-media-wrap ul.bp-list"}).done(function(e){!0===e.success&&(r.remove(),i.current_page_existing_media=t,jQuery(window).scroll())}))},appendAlbums:function(t){var i=Number(this.current_page_albums)+1,a=this,e=(t.preventDefault(),h(t.currentTarget).find("a").first().addClass("loading"),{action:"media_albums_loader",_wpnonce:w.media,page:i});h.ajax({type:"POST",url:y,data:e,success:function(e){!0===e.success&&(h(t.currentTarget).remove(),h("#albums-dir-list ul.bb-albums-list").fadeOut(100,function(){h("#albums-dir-list ul.bb-albums-list").append(e.data.albums),h(this).fadeIn(100)}),a.current_page_albums=i)}})},toggleSubmitMediaButton:function(){var e=h("#bp-media-submit"),t=h("#bp-media-add-more");"bp-dropzone-content"===this.current_tab?this.dropzone_obj.getAcceptedFiles().length?(e.show(),t.show()):(e.hide(),t.hide()):"bp-existing-media-content"===this.current_tab&&(h('.bp-existing-media-wrap .bb-media-check-wrap [name="bb-media-select"]:checked').length?e.show():e.hide(),t.hide())},playVideo:function(e){e.preventDefault();var e=h(e.currentTarget),t=e.find("video").get(0),e=e.find(".gif-play-button");!0===t.paused?(t.play().catch(function(e){console.debug("GIF play failed:",e)}),e.hide()):(t.pause(),e.show())},throttledAutoPlayGifVideos:function(){this.throttleTimer||(this.throttleTimer=setTimeout(function(){bp.Nouveau.Media.throttleTimer=null,bp.Nouveau.Media.autoPlayGifVideos()},100))},invokeMediaFn:function(e){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media[e]&&bp.Nouveau.Media[e]()},isElementInScrollableContainer:function(e){var t=h(e),i=t.closest("#bp-message-thread-list");return(i=(i=i.length?i:t.closest(".bb-rl-modal-activity-body")).length?i:t.closest(".bb-rl-media-model-container .bb-media-info-section")).length?(e=e.getBoundingClientRect(),i=i[0].getBoundingClientRect(),e.bottom>i.top&&e.top i.left&&e.left '),h(t).text()),e=(h(t).text(g.copy_to_clip_board_text),h("#"+e));return e.val(h(t).attr("href")),e.select(),document.execCommand("copy"),setTimeout(function(){h(t).text(i)},2e3),!1},fileActivityActionButton:function(e){e.preventDefault();var t=h(e.currentTarget);t.parent().hasClass("bb_rl_copy_download_file_url")||(t.closest(".bb-rl-activity-media-elem").toggleClass("is-visible").siblings().removeClass("is-visible").closest(".activity-item").siblings().find(".bb-rl-activity-media-elem").removeClass("is-visible"),t.closest(".bb-rl-activity-media-elem").find(".bb_rl_more_dropdown").toggleClass("open").closest(".bb-rl-activity-media-elem").siblings().find(".bb_rl_more_dropdown").removeClass("open").closest(".activity-item").siblings().find(".bb-rl-activity-media-elem .bb_rl_more_dropdown").removeClass("open"),h("body").addClass("document_more_option_open"),t.closest(".bb-rl-activity-media-elem").length<1&&(t.closest(".bb-photo-thumb").toggleClass("is-visible").parent().siblings().find(".bb-photo-thumb").removeClass("is-visible").removeClass("is-visible"),t.closest(".bb-photo-thumb").find(".bb_rl_more_dropdown").toggleClass("open").closest(".bb-photo-thumb").parent().siblings().find(".bb-photo-thumb .bb_rl_more_dropdown").removeClass("open")),"a"!==e.currentTarget.tagName.toLowerCase())||t.hasClass("bb-rl-document-action_more")||t.hasClass("bb_rl_more_dropdown__action")||(t.closest(".bb-rl-activity-media-elem").removeClass("is-visible").find(".bb_rl_more_dropdown").removeClass("open"),t.closest(".bb-photo-thumb").removeClass("is-visible").find(".bb_rl_more_dropdown").removeClass("open"))},toggleFileActivityActionButton:function(e){var t;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),!0===e.altKey||!0===e.metaKey||h(t).hasClass("bb-rl-document-action_more")||h(t).parent().hasClass("bb-rl-document-action_more")||h(t).hasClass("media-folder_action__anchor")||h(t).parent().hasClass("media-folder_action__anchor")||h(t).hasClass("bb_rl_more_dropdown__action")||h(t).parent().hasClass("bb_rl_more_dropdown__action")?e:(h(".bb-rl-activity-media-elem.is-visible").removeClass("is-visible"),h(".media-folder_items.is-visible").removeClass("is-visible"),h(".bb-photo-thumb.is-visible").removeClass("is-visible"),h(".bb-item-thumb.is-visible").removeClass("is-visible"),h(".bb-rl-activity-video-elem.is-visible").removeClass("is-visible"),h(".bb-rl-more_dropdown-wrap.is-visible").removeClass("is-visible"),h(".bb-rl-more_dropdown-wrap .bb_rl_more_dropdown").removeClass("open"),h(".bb-rl-activity-media-elem .bb_rl_more_dropdown").removeClass("open"),h(".bb-photo-thumb .bb_rl_more_dropdown").removeClass("open"),h(".media-folder_items .bb_rl_more_dropdown").removeClass("open"),void h("body").removeClass("document_more_option_open video_more_option_open item_more_option_open"))},toggleCodePreview:function(e){e.preventDefault(),h(e.currentTarget).closest(".bb-rl-document-activity").toggleClass("code-full-view")},documentCodeMirror:function(){h(".bb-rl-document-text:not(.loaded), .document-text:not(.loaded)").each(function(){var e=h(this),t=e.attr("data-extension"),i=e.attr("data-extension");"html"!==t&&"htm"!==t||(i="text/html"),"js"===t?CodeMirror(e[0],{value:(0 '+e+""))},setupForumDropzoneEvents:function(e){var c=e.self,a=e.dropzoneObj,d=e.target,p=e.type,b=e.dropzoneDataObj,m=e.dropzoneContainer;"video"===p&&a.on("addedfile",function(e){e.dataURL&&e.dataThumb&&e.dataThumb.length?h(e.previewElement).find(".dz-video-thumbnail").prepend(' '):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-image")}),a.on("sending",function(e,t,i){i.append("action","document"===p?p+"_"+p+"_upload":p+"_upload");var a="document"===p?"media":p,o=(i.append("_wpnonce",w[a]),d.closest("form"));o.addClass("has-media"),["media","document","video","gif"].forEach(function(e){var t=o.find("#bb-rl-forums-"+e+"-button");t&&(t=t.parents(".bb-rl-post-elements-buttons-item"),p===e?t.addClass("no-click"):t.addClass("disable"))})}),a.on("uploadprogress",function(e){d.closest("form").addClass("media-uploading");var t=h(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=a,"video"===p&&(e.upload.progress<=99?(h(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+v.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,h(e.previewElement).find(".dz-progress-count").text("99% "+v.i18n_strings.video_uploaded_text)))}),a.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?h(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"===e.status&&e.xhr&&0===e.xhr.status&&h(e.previewElement).find(".dz-error-message span").text(g.connection_lost_error):(jQuery(".forum-"+("media"===p?"document":p)+"-error-popup").length||("media"===p?h("body").append('"):"document"===p?h("body").append('"):"video"===p&&h("body").append('")),this.removeFile(e),d.closest("form").removeClass("media-uploading"))}),"media"!==p&&a.on("accept",function(e,t){0===e.size?t(g["empty_"+p+"_type"]):t()}),a.on("success",function(e,t){var i,a;if("video"===p&&100===e.upload.progress&&(h(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,h(e.previewElement).find(".dz-progress-count").text("100% "+v.i18n_strings.video_uploaded_text),h(e.previewElement).closest(".dz-preview").addClass("dz-complete")),t.data.id)e.id=t.data.id,t.data.uuid=e.upload.uuid,t.data.menu_order=h(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.group_id=c.group_id,t.data.saved=!1,"media"===p?t.data.album_id=c.album_id:"document"===p?t.data.folder_id=c.current_folder:"video"===p&&(t.data.album_id=c.album_id,t.data.js_preview=h(e.previewElement).find(".dz-image img").attr("src")),b.push(t.data),m.closest("#whats-new-attachments").find("#bbp_"+p).length&&m.closest("#whats-new-attachments").find("#bbp_"+p).val(JSON.stringify(b)),"document"===p&&(a=(a=e.upload.filename).substr(a.lastIndexOf(".")+1),i=_.isUndefined(t.data.svg_icon)?"":t.data.svg_icon,a=_.isEmpty(i)?"bb-icon-file-"+a:i,h(e.previewElement).find(".dz-details .dz-icon .bb-icons-rl-file").length)&&h(e.previewElement).find(".dz-details .dz-icon .bb-icons-rl-file").removeClass("bb-icon-file").addClass(a);else if("media"===p)jQuery(".forum-"+p+"-error-popup").length||h("body").append('"),this.removeFile(e);else if("document"===p||"video"===p){var o,d,r,n,s,l=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],d=0,r=(n=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;d
'):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-image")}),a.on("sending",function(e,t,i){i.append("action","document"===p?p+"_"+p+"_upload":p+"_upload");var a="document"===p?"media":p,o=(i.append("_wpnonce",w[a]),d.closest("#send_group_message_form"));["media","document","video","gif"].forEach(function(e){var t=o.find("#bp-group-messages-"+e+"-button");t&&(t=t.parents(".post-elements-buttons-item"),p===e?t.addClass("no-click"):t.addClass("disable"))})}),a.on("uploadprogress",function(e){var t=h(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=a,"video"===p&&(e.upload.progress<=99?(h(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+v.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,h(e.previewElement).find(".dz-progress-count").text("99% "+v.i18n_strings.video_uploaded_text)))}),a.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?h(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"===e.status&&e.xhr&&0===e.xhr.status&&h(e.previewElement).find(".dz-error-message span").text(g.connection_lost_error):("media"===p||"document"===p?jQuery(".group-"+("media"===p?"document":p)+"-error-popup").length||("document"===p?h("body").append('"):h("body").append('")):h("body").append('"),this.removeFile(e))}),"media"!==p&&a.on("accept",function(e,t){0===e.size?t(g["empty_"+p+"_type"]):t()}),a.on("success",function(e,t){if("video"===p&&100===e.upload.progress&&(h(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,h(e.previewElement).find(".dz-progress-count").text("100% "+v.i18n_strings.video_uploaded_text),h(e.previewElement).closest(".dz-preview").addClass("dz-complete")),t.data.id){e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=h(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.group_id=c.group_id,t.data.saved=!1,"media"===p?t.data.album_id=c.album_id:"document"===p?t.data.folder_id=c.current_folder:"video"===p&&(t.data.album_id=c.album_id,t.data.js_preview=h(e.previewElement).find(".dz-video-thumbnail img").attr("src")),b.push(t.data);var i,a=h("#bp_group_messages_"+p);a.length&&a.val(JSON.stringify(b)),"document"===p&&(a=(a=e.upload.filename).substr(a.lastIndexOf(".")+1),i=_.isUndefined(t.data.svg_icon)?"":t.data.svg_icon,a=_.isEmpty(i)?"bb-icons-rl-"+a:i,h(e.previewElement).find(".dz-details .dz-icon .bb-icons-rl").length)&&h(e.previewElement).find(".dz-details .dz-icon .bb-icons-rl").removeClass("bb-icon-file").addClass(a)}else if("media"===p)jQuery(".group-message-error-popup").length||h("body").append('"),this.removeFile(e);else if("document"===p||"video"===p){var o,d,r,n,s,l=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],d=0,r=(n=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;d "+t+" h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb").width()&&(h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||h('...').insertAfter(h(r).find(".bb-rl-breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),"media"===a&&d.updateAlbumNavCount(e.data.album_count),n.removeClass("loading"),"document"===a&&setTimeout(function(){var e=r.find("ul"+v+" span#"+u),t=(e.trigger("click"),h(r).find("#bb-document-privacy"));0!==Number(e.data("id"))?(t.find("option").removeAttr("selected"),t.val(e.parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1))},200)):n.removeClass("loading")}}),this.currentTargetParent=u,r.find(v+" li.is_active").show().children("span, i").show().siblings("ul").hide(),r.find(v+" li.is_active").siblings("li").show().children("span, i").show().siblings("ul").hide(),r.find(v+" li span.selected").removeClass("selected"),r.find(v+" li.is_active").children("span").addClass("selected")},0)},setMediaSelectionState:function(e){var i=h("#buddypress").find(".media-list:not(.existing-media-list)"),a=!0===e,e=["media"];0 ]+/g.test(p.val());if(""===h.trim(p.val())||m)return p.addClass("error"),!1;if(p.removeClass("error"),r||n){if(!c.group_id&&""===h.trim(o.val()))return o.addClass("error"),!1;o.removeClass("error")}d.prop("disabled",!0).toggleClass(r?"saving":"loading");m={action:t+"_"+e+"_save",_wpnonce:b,title:p.val()};r?("media"===t?m.medias=c.dropzone_media:"video"===t&&(m.videos=a),m.privacy=o.val(),c.album_id&&(m.album_id=c.album_id),c.group_id&&(m.group_id=c.group_id)):n?(m.privacy=o.val(),m.album_id=c.current_folder,m.group_id=c.current_group_id):s&&(m.folder_id=c.current_folder,m.group_id=c.current_group_id),h(".bb-single-album-header .bp-feedback, #bb-rl-media-create-album-popup .bp-feedback").remove(),h.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:m,success:function(e){var t;(r||n)&&setTimeout(function(){r&&d.removeClass("saving"),d.prop("disabled",!1)},500),e.success?r?c.album_id?(h("#bp-single-album-title .title-wrap").text(p.val()),h("#bb-album-privacy").val(o.val()),c.cancelEditAlbumTitle(i),l.find("#bp-media-edit-album-close").trigger("click")):(h("#buddypress .bb-albums-list").prepend(e.data.album),window.location.href=e.data.redirect_url):n?(c.closeFolderUploader(i),h(".document-data-table-head").length?"yes"===BP_Nouveau.media.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(h(document).find("li#document-personal a").trigger("click"),h(document).find("li#document-personal").trigger("click")):(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()):location.reload(!0)):s&&(c.closeChildFolderUploader(i),location.reload(!0)):r?(t=c.album_id?"#bp-media-single-album":"#bb-rl-media-create-album-popup .bb-model-header",h(t).prepend(e.data.feedback)):alert(e.data.feedback.replace("'","'"))}})}},disableButtonsInToolBox:function(t,e){e.forEach(function(e){e=t.find(e);e.length&&e.parents(".bb-rl-post-elements-buttons-item").addClass("disable")})}},bp.Nouveau.Media.Theatre={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){this.medias=[],this.documents=[],this.current_media=!1,this.current_document=!1,this.current_index=0,this.current_document_index=0,this.is_open_media=!1,this.is_open_document=!1,this.nextLink=h(".bb-rl-next-media"),this.nextDocumentLink=h(".bb-rl-next-document"),this.previousDocumentLink=h(".bb-rl-prev-document"),this.previousLink=h(".bb-rl-prev-media"),this.activity_ajax=!1,this.group_id=void 0!==g.group_id&&g.group_id},addListeners:function(){var e=h(document);e.on("click",".bb-rl-open-media-theatre",this.openTheatre.bind(this)),e.on("click",".bb-rl-open-document-theatre",this.openDocumentTheatre.bind(this)),e.on("click",".bb-rl-document-detail-wrap-description-popup",this.openDocumentTheatre.bind(this)),e.on("click",".bb-rl-close-media-theatre",this.closeTheatre.bind(this)),e.on("click",".bb-close-document-theatre",this.closeDocumentTheatre.bind(this)),e.on("click",".bb-icons-rl-sidebar-simple",this.ToggleTheatreSidebar.bind(this)),e.on("click",".bb-rl-prev-media",this.previous.bind(this)),e.on("click",".bb-rl-next-media",this.next.bind(this)),e.on("click",".bb-rl-prev-document",this.previousDocument.bind(this)),e.on("click",".bb-rl-next-document",this.nextDocument.bind(this)),e.on("bp_activity_ajax_delete_request",this.activityDeleted.bind(this)),e.on("click","#bb-rl-media-model-container .media-privacy>li",this.mediaPrivacyChange.bind(this)),e.on("click","#bb-rl-media-model-container .document-privacy>li",this.documentPrivacyChange.bind(this)),e.on("click","#bb-rl-media-model-container .bb-rl-media-section span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),e.on("click","#bb-rl-media-model-container .bb-rl-document-section span.privacy",bp.Nouveau,this.toggleDocumentPrivacyDropdown.bind(this)),e.on("click",".bp-add-media-activity-description",this.openMediaActivityDescription.bind(this)),e.on("click","#bp-activity-description-new-reset",this.closeMediaActivityDescription.bind(this)),e.on("keyup",".bp-edit-media-activity-description #add-activity-description",this.MediaActivityDescriptionUpdate.bind(this)),e.on("click","#bp-activity-description-new-submit",this.submitMediaActivityDescription.bind(this)),e.on("click",".bb-rl-media-thumb",this.handleThumbnailClick.bind(this)),e.click(this.togglePopupDropdown),document.addEventListener("keyup",this.checkPressedKeyDocuments.bind(this)),document.addEventListener("keyup",this.checkPressedKey.bind(this))},checkPressedKey:function(e){var t=this;if(e=e||window.event,!t.is_open_media)return!1;var i=h(e.target).hasClass("ac-input")||"add-activity-description"===h(e.target).attr("id");switch(e.keyCode){case 27:t.closeTheatre(e);break;case 37:if(void 0===t.medias[t.current_index-1]||i)return!1;t.previous(e);break;case 39:if(void 0===t.medias[t.current_index+1]||i)return!1;t.next(e)}},checkPressedKeyDocuments:function(e){e=e||window.event;var t=this;if(!t.is_open_document)return!1;var i=h(e.target).hasClass("ac-input")||"add-activity-description"===h(e.target).attr("id");switch(e.keyCode){case 27:t.closeDocumentTheatre(e);break;case 37:if(void 0===t.documents[t.current_document_index-1]||i)return!1;t.previousDocument(e);break;case 39:if(void 0===t.documents[t.current_document_index+1]||i)return!1;t.nextDocument(e)}},handleOpenTheatre:function(e){var t=e.target,i=e.self||this,a=e.modalWrapper,o=e.mediaType,e=e.action,d=(i.setupGlobals(),i.setMedias({target:t,modalWrapper:a,mediaType:o,action:e}),t.data("id")),d=(i.setCurrentMedia(d),i.showMedia({modalWrapper:a,mediaType:o,action:e}),i.navigationCommands(),i.current_activity_data&&i.generateAndDisplayMediaThumbnails({target:t,modalWrapper:a,mediaType:o,action:e}),i.getParentActivityHtml({target:t,modalWrapper:a,mediaType:o,action:e}),i.getMediasDescription({modalWrapper:a,mediaType:o,action:e}),t.closest(".activity-item").data("activity-popup-title")),o=(h(a+" .bb-rl-media-model-header h2").text(d),h(a+".document").hide(),document.getElementById(h(a+".video video").attr("id")));o&&o.pause(),h(a+".video").length&&h(a+".video").hide(),h(a+"."+e).length&&h(a+"."+e).show(),i.is_open_media=!0,bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay")},openTheatre:function(e){e.preventDefault();var t=h(e.currentTarget);if(this.current_activity_data=t.closest(".activity-item").data("bp-activity"),t.closest("#bp-existing-media-content").length)return!1;this.handleOpenTheatre({self:this,target:t,event:e,modalWrapper:".bb-rl-media-model-wrapper",action:"media"})},getParentActivityHtml:function(e){var t=e.target,e=e.action;if("comment"===t.data("privacy"))return!1;var i=h("#hidden_parent_id"),a=i.val(),t=t.closest(".bb-rl-"+e+"-model-wrapper").find("#bb-rl-"+e+"-model-container .bb-rl-activity-list li.activity-item").data("bp-activity-id");parseInt(a)===parseInt(t)&&(t=h("#bb-rl-"+e+'-model-container [data-bp-activity-id="'+a+'"]'),h('[data-bp-activity-id="'+a+'"] > .activity-state').html(h(t).find(".activity-state").html()),h('[data-bp-activity-id="'+a+'"] > .activity-meta').html(h(t).find(".activity-meta").html()),h('[data-bp-activity-id="'+a+'"] > .bb-rl-activity-comments').html(h(t).find(".bb-rl-activity-comments").html())),i.length&&i.remove()},getMediasDescription:function(e){var t=e.action;this.fetchMediaDescription(this.current_media,h(".bb-rl-"+t+"-model-wrapper"),e)},openDocumentTheatre:function(e){e.preventDefault();var t=h(e.currentTarget),i=this;if(t.closest("#bp-existing-document-content").length)return!1;t.closest(".document.bb-rl-document-theatre").length&&i.closeDocumentTheatre(e),a=t.data("id"),i.setupGlobals(),i.setDocuments(t),i.setCurrentDocument(a),i.showDocument(),i.navigationDocumentCommands(),i.getParentActivityHtml({target:t,action:"media"}),i.getDocumentsDescription();var a=t.closest(".activity-item").data("activity-popup-title"),t=(h(".bb-rl-media-model-wrapper .bb-rl-media-model-header h2").text(a),-1!==h.inArray(i.current_document.extension,n.mp3_preview_extension.split(","))&&h(e.currentTarget).closest(".bb-rl-activity-media-elem.bb-rl-document-activity").length&&h(e.currentTarget).closest(".bb-rl-activity-media-elem.bb-rl-document-activity").find(".bb-rl-document-audio-wrap").length&&h(e.currentTarget).closest(".bb-rl-activity-media-elem.bb-rl-document-activity").find(".bb-rl-document-audio-wrap audio")[0].pause(),h(".bb-rl-media-model-wrapper.media").hide(),h(".bb-rl-media-model-wrapper.document").show(),document.getElementById(h(".bb-rl-media-model-wrapper.video video").attr("id")));t&&(t.pause(),t.src=""),h(".bb-rl-media-model-wrapper.video").hide(),i.is_open_document=!0,setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay")},500)},resetRemoveActivityCommentsData:function(e){var t,i=this,a=!1,o=!1,d=!1,r=!1,n=!1,s=!1;i.current_media.parent_activity_comments&&((a=(r=h(".bb-rl-"+e+'-model-wrapper.media [data-bp-activity-id="'+i.current_media.activity_id+'"]')).find(".bb-rl-activity-comments")).length&&(t=a.find("#ac-form-"+i.current_media.activity_id),this.purgeEditActivityForm(t),t.find("#ac-input-"+i.current_media.activity_id).html(""),t.removeClass("has-content has-gif has-media").addClass("root"),a.append(t),t.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(i.current_media.activity_id),a.find(".acomment-display").removeClass("display-focus"),a.find(".comment-item").removeClass("comment-item-focus"),n=a.html(),s=a.attr("class"),a.remove(),(a=h('[data-bp-activity-id="'+i.current_media.activity_id+'"] .bb-rl-activity-comments')).length)&&(a.attr("class",s),0===a.find("#ac-form-"+i.current_media.activity_id).length)&&(a.append(t),a.children("form").removeClass("events-initiated").addClass("not-initialized")),(d=r.find(".activity-state")).length&&(n=d.html(),s=d.attr("class"),d.remove(),(d=h('[data-bp-activity-id="'+i.current_media.activity_id+'"] .activity-state')).length)&&(d.html(n),d.attr("class",s)),(o=r.find(".activity-meta")).length&&(n=o.html(),s=o.attr("class"),o.remove(),(o=h('[data-bp-activity-id="'+i.current_media.activity_id+'"] > .activity-meta')).length)&&(o.html(n),o.attr("class",s)),r.remove()),i.current_document.parent_activity_comments&&((a=(r=h(".bb-rl-"+e+'-model-wrapper.document [data-bp-activity-id="'+i.current_document.activity_id+'"]')).find(".bb-rl-activity-comments")).length&&(t=a.find("#ac-form-"+i.current_document.activity_id),this.purgeEditActivityForm(t),t.find("#ac-input-"+i.current_document.activity_id).html(""),t.removeClass("has-content has-gif has-media").addClass("root"),a.append(t),t.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(i.current_document.activity_id),a.find(".acomment-display").removeClass("display-focus"),a.find(".comment-item").removeClass("comment-item-focus"),n=a.html(),s=a.attr("class"),a.remove(),(a=h('[data-bp-activity-id="'+i.current_document.activity_id+'"] .bb-rl-activity-comments')).length)&&(a.attr("class",s),0===a.find("#ac-form-"+i.current_document.activity_id).length&&(a.append(t),a.children("form").removeClass("events-initiated").addClass("not-initialized")),a.find(".bb-rl-document-text.loaded").removeClass("loaded").find(".CodeMirror").remove(),jQuery(window).scroll()),(d=r.find(".activity-state")).length&&(n=d.html(),s=d.attr("class"),d.remove(),(d=h('[data-bp-activity-id="'+i.current_document.activity_id+'"] .activity-state')).length)&&(d.html(n),d.attr("class",s)),(o=r.find(".activity-meta")).length&&(n=o.html(),s=o.attr("class"),o.remove(),(o=h('[data-bp-activity-id="'+i.current_document.activity_id+'"] > .activity-meta')).length)&&(o.html(n),o.attr("class",s)),r.remove()),bp.Nouveau.reportPopUp(),bp.Nouveau.reportActions()},closeTheatre:function(e){e.preventDefault();var e=h(e.currentTarget),t="";if(e.closest(".bb-rl-internal-model").hasClass("media-video")?t="media-video":e.closest(".bb-rl-internal-model").hasClass("media")?t="media":e.closest(".bb-rl-internal-model").hasClass("video")&&(t="video"),h(e).closest(".bb-rl-"+t+"-model-wrapper").hasClass("bb-rl-video-theatre"))return!1;var i=h(".bb-rl-"+t+"-model-wrapper.media .bb-rl-media-section"),i=(i.find("img").attr("src",""),i.find("video"));i.length&&videojs(i.attr("id")).reset(),h(".bb-rl-"+t+"-model-wrapper").hide(),this.is_open_media=!1,this.resetRemoveActivityCommentsData(t),this.current_media=!1,this.getParentActivityHtml({target:e,action:t})},closeDocumentTheatre:function(e){e.preventDefault();var t=h(document).find(".bb-rl-document-theatre");t.find(".bb-rl-media-section").removeClass("bb-media-no-preview").find(".document-preview").html(""),h(".bb-media-info-section.document").show(),t.hide(),this.is_open_document=!1,this.resetRemoveActivityCommentsData("media"),this.current_document=!1,this.getParentActivityHtml({target:h(e.currentTarget),action:"media"})},ToggleTheatreSidebar:function(e){e.preventDefault(),h(e.currentTarget).closest(".bb-rl-media-model-container").toggleClass("bb-rl-media-toggle-sidebar")},setMedias:function(e){var t=e.target,e=e.action,i=h(t),a=0;if("media-video"===e&&(i=h(".bb-rl-open-"+e+"-theatre")),void 0!==(i=h("body").hasClass("activity")?h(t).closest(".bb-activity-media-wrap").find(".bb-rl-open-"+e+"-theatre"):i)){this.medias=[];for(var o=i.length,a=0;a '):h(i+" .bb-rl-media-section").children("img").length?e.find("img").attr("src",t.current_media.attachment):e.html(' ')):h(i+" .bb-rl-media-section").find("img").attr("src",t.current_media.attachment);a=h(".bb-rl-media-section .bb-media-privacy-wrap");a.length&&(a.show(),a.find("ul.media-privacy li").removeClass("selected"),a.find(".bp-tooltip").attr("data-bp-tooltip",""),(e=a.find("ul.media-privacy").find("li[data-value="+t.current_media.privacy+"]")).addClass("selected"),a.find(".bp-tooltip").attr("data-bp-tooltip",e.text()),a.find(".privacy").removeClass("public").removeClass("loggedin").removeClass("onlyme").removeClass("friends").addClass(t.current_media.privacy),!(void 0!==l&&void 0!==t.current_media.activity_id&&0!==t.current_media.activity_id||t.group_id||t.current_media.is_forum||t.current_media.group_id||t.current_media.album_id||t.current_media.is_message)&&t.can_manage_media&&t.current_media.can_edit||a.hide()),t.navigationCommands()},showDocument:function(){var e=this;if(void 0===e.current_document)return!1;var t,i=e.current_document.target_text,a=e.current_document.target_icon_class,o=h(document).find(".bb-rl-document-theatre"),d=e.current_document.extension,r=e.current_document.mirror_text,d=(o.find(".bb-rl-document-section").removeClass("bb-video-preview"),-1!==h.inArray(e.current_document.extension,["css","txt","js","html","htm","csv"])?(o.find(".bb-rl-document-section .document-preview").html(''),o.find(".bb-rl-document-section").removeClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),o.find(".bb-rl-document-section .document-preview").html("
"+i+'
'),o.find(".bb-rl-document-section .document-preview .bb-rl-document-text").attr("data-extension",d),t=o.find(".bb-rl-document-section .document-preview .bb-rl-document-text textarea"),"html"===d||"htm"===d?t.val(r):t.html(r),setTimeout(function(){bp.Nouveau.Media.documentCodeMirror()},1e3)):-1!==h.inArray(e.current_document.extension,n.mp3_preview_extension.split(","))?(o.find(".bb-rl-document-section .document-preview").html(''),o.find(".bb-rl-document-section").removeClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),o.find(".bb-rl-document-section .document-preview").html('')):-1!==h.inArray("."+e.current_document.extension,v.video_type.split(","))?(o.find(".bb-rl-document-section").addClass("bb-video-preview"),o.find(".bb-rl-document-section .document-preview").html(''),o.find(".bb-rl-document-section").removeClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),"mov"===e.current_document.extension||"m4v"===e.current_document.extension?o.find(".bb-rl-document-section .document-preview").html(''):o.find(".bb-rl-document-section .document-preview").html(''),h(window).scroll()):e.current_document.full_preview?(o.find(".bb-rl-document-section").removeClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),o.find(".bb-rl-document-section .document-preview").html("'+i+'
"+i+'
')):(o.find(".bb-rl-document-section").addClass("bb-media-no-preview"),o.find(".bb-rl-document-section .document-preview").html(""),o.find(".bb-rl-document-section .document-preview").html('")),h(".bb-rl-document-section .bb-document-privacy-wrap"));d.length&&(d.show(),d.parent().show(),d.find("ul.document-privacy li").removeClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",""),(t=d.find("ul.document-privacy").find("li[data-value="+e.current_document.privacy+"]")).addClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",t.text()),d.find(".privacy").removeClass("public").removeClass("loggedin").removeClass("onlyme").removeClass("friends").addClass(e.current_document.privacy),void 0!==l&&void 0!==e.current_document.activity_id&&0!==e.current_document.activity_id||e.group_id||e.current_document.is_forum||e.current_document.group_id||e.current_document.album_id||!e.can_manage_document||!e.current_document.can_edit||e.current_document.is_message)&&d.parent().hide(),e.navigationDocumentCommands()},generateAndDisplayMediaThumbnails:function(e){var t,i=e.target,e=e.action,a=this;a.current_activity_data=i.closest(".activity-item").data("bp-activity"),!a.current_activity_data||!a.current_activity_data.media||a.current_activity_data.media.length<=1||(i=a.current_activity_data.media.map(function(e){return''+i+"
'}).join(""),(t=(e=h("."+e+".bb-rl-"+e+"-theatre .bb-rl-media-section")).find(".bb-rl-media-thumbnails")).length?t.html(i):e.append(''+i+""))},handleThumbnailClick:function(e){var t,i,a,e=h(e.currentTarget);!e.hasClass("active")&&((i=h(".bb-rl-media-model-wrapper.media .bb-rl-media-section").find("figure")).find("img").hide(),i.addClass("loading").append(''),t=e.data("id"),i=this.medias.find(function(e){return e.id===t}))&&(a="",e.closest(".bb-rl-internal-model").hasClass("media-video")?a="media-video":e.closest(".bb-rl-internal-model").hasClass("media")?a="media":e.closest(".bb-rl-internal-model").hasClass("video")&&(a="video"),this.updateMedia(i,e,{modalWrapper:".bb-rl-"+a+"-model-wrapper",action:a}))},next:function(e){e.preventDefault();var e=h(e.currentTarget),t="";e.closest(".bb-rl-internal-model").hasClass("media-video")?t="media-video":e.closest(".bb-rl-internal-model").hasClass("media")?t="media":e.closest(".bb-rl-internal-model").hasClass("video")&&(t="video");var e={modalWrapper:".bb-rl-"+t+"-model-wrapper",action:t},i=this;i.current_activity_data&&i.medias[i.current_index+1]?i.updateMedia(i.medias[i.current_index+1],h("."+t+".bb-rl-"+t+"-theatre .bb-rl-media-thumb").eq(i.current_index+1),e):(i.resetRemoveActivityCommentsData(t),void 0!==i.medias[i.current_index+1]?(i.current_index=i.current_index+1,i.current_media=i.medias[i.current_index],e.mediaType=i.medias[i.current_index].type||"",i.showMedia(e),i.getMediasDescription(e),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):i.nextLink.hide())},previous:function(e){e.preventDefault();var e=h(e.currentTarget),t="";e.closest(".bb-rl-internal-model").hasClass("media-video")?t="media-video":e.closest(".bb-rl-internal-model").hasClass("media")?t="media":e.closest(".bb-rl-internal-model").hasClass("video")&&(t="video");var e={modalWrapper:".bb-rl-"+t+"-model-wrapper",action:t},i=this;i.current_activity_data&&i.medias[i.current_index-1]?i.updateMedia(i.medias[i.current_index-1],h("."+t+".bb-rl-"+t+"-theatre .bb-rl-media-thumb").eq(i.current_index-1),e):(i.resetRemoveActivityCommentsData(t),void 0!==i.medias[i.current_index-1]?(i.current_index=i.current_index-1,i.current_media=i.medias[i.current_index],e.mediaType=i.medias[i.current_index].type||"",i.showMedia(e),i.getMediasDescription(e),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):i.previousLink.hide())},updateMedia:function(t,e,i){var a=i.action,o=this,a=h("."+a+".bb-rl-"+a+"-theatre"),d=a.find(".bb-rl-media-section figure"),r=d.find("img");r.one("load",function(){d.removeClass("loading").find(".bb-rl-loader").remove(),r.show()}).one("error",function(){d.removeClass("loading").find(".bb-rl-loader").remove()}).attr("src",t.attachment),a.find(".bb-rl-media-thumb").removeClass("active"),e.addClass("active"),o.current_index=o.medias.findIndex(function(e){return e.id===t.id}),o.current_media=t,o.nextLink.toggle(Boolean(o.medias[o.current_index+1])),o.previousLink.toggle(Boolean(o.medias[o.current_index-1])),o.activity_ajax&&o.activity_ajax.abort(),o.fetchMediaDescription(t,a,i)},fetchMediaDescription:function(o,d,e){var r=e.mediaType,n=e.action,s=this,e=(!1!==s.activity_ajax&&s.activity_ajax.abort(),h('[data-bp-activity-id="'+o.activity_id+'"] .bb-rl-activity-comments')),e=(e.length&&(e=e.find("#ac-form-"+o.activity_id),o.parent_activity_comments=!0,e.remove()),!0===o.parent_activity_comments&&h(".bb-rl-"+n+"-model-wrapper:last").after(''),{id:o.id,attachment_id:o.attachment_id,activity_id:o.activity_id});"media-video"===n&&"video"===r?(e.action="video_get_video_description",e.nonce=w.video):(e.action="media_get_media_description",e.nonce=w.media),s.activity_ajax=h.ajax({type:"POST",url:y,data:e,beforeSend:function(){d.find(".bb-media-info-section .bb-rl-activity-list").addClass("loading").html('')},success:function(e){var t,i,a;e.success?(t=d.find(".bb-media-info-section:visible"),i=h(".bb-rl-"+n+"-model-wrapper"),"media-video"===n&&"video"===r&&((a=i.find(".bb-rl-media-section figure")).html(e.data.video_data),a.find("video").attr("autoplay",!0)),t.find(".bb-rl-activity-list").removeClass("loading").html(e.data.description),void 0!==e.data.comment_form&&void 0!==bp.Nouveau.Activity&&(t.find(".bb-rl-activity-list .bb-rl-activity-comments ul:first").after(e.data.comment_form),t.find("#ac-form-"+o.activity_id).removeClass("not-initialized").addClass("root events-initiated").find("#ac-input-"+o.activity_id).focus(),a=t.find("#ac-form-"+o.activity_id),bp.Nouveau.Activity.clearFeedbackNotice(a),a.removeClass("events-initiated"),e=t.find(".ac-form .ac-input[contenteditable]"),bp.Nouveau.Activity.listenCommentInput(e),_.isUndefined(g)||_.isUndefined(g.emoji)||bp.Nouveau.Activity.initializeEmojioneArea(!0,"#bb-rl-activity-modal ",o.activity_id)),t.show(),t.find(".bb-activity-more-options-action").attr("data-balloon-pos","left"),s.updateTheaterHeaderTitle({wrapper:i,action:n}),requestAnimationFrame(function(){h(window).scroll(),bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()})):d.find(".bb-media-info-section.media").hide()}})},nextDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData("media"),void 0!==e.documents[e.current_document_index+1]?(e.current_document_index=e.current_document_index+1,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.nextDocumentLink.hide()},previousDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData("media"),void 0!==e.documents[e.current_document_index-1]?(e.current_document_index=e.current_document_index-1,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.previousDocumentLink.hide()},navigationCommands:function(){var e=this;0===e.current_index&&e.current_index!==e.medias.length-1?(e.previousLink.hide(),e.nextLink.show()):0===e.current_index&&e.current_index===e.medias.length-1?(e.previousLink.hide(),e.nextLink.hide()):e.current_index===e.medias.length-1?(e.previousLink.show(),e.nextLink.hide()):(e.previousLink.show(),e.nextLink.show())},navigationDocumentCommands:function(){var e=this;0===e.current_document_index&&e.current_document_index!==e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.show()):0===e.current_document_index&&e.current_document_index===e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.hide()):e.current_document_index===e.documents.length-1?(e.previousDocumentLink.show(),e.nextDocumentLink.hide()):(e.previousDocumentLink.show(),e.nextDocumentLink.show())},getDocumentsDescription:function(){var t=this,e=(h(".bb-media-info-section .bb-rl-activity-list").addClass("loading").html(''),!1!==t.activity_ajax&&t.activity_ajax.abort(),h('[data-bp-activity-id="'+t.current_document.activity_id+'"] .bb-rl-activity-comments'));e.length&&(e=e.find("#ac-form-"+t.current_document.activity_id),t.current_document.parent_activity_comments=!0,e.remove()),!0===t.current_document.parent_activity_comments&&h(".bb-rl-media-model-wrapper:last").after(''),t.activity_ajax=h.ajax({type:"POST",url:y,data:{action:"document_get_document_description",id:t.current_document.id,attachment_id:t.current_document.attachment_id,nonce:w.media},success:function(e){e.success?(h(".bb-media-info-section:visible .bb-rl-activity-list").removeClass("loading").html(e.data.description),void 0!==e.data.comment_form&&void 0!==bp.Nouveau.Activity&&(h(".bb-media-info-section:visible .bb-rl-activity-list .bb-rl-activity-comments ul:first").after(e.data.comment_form),h(".bb-media-info-section:visible").find("#ac-form-"+t.current_document.activity_id).removeClass("not-initialized").addClass("root events-initiated").find("#ac-input-"+t.current_document.activity_id).focus(),e=h(".bb-media-info-section:visible").find("#ac-form-"+t.current_document.activity_id),bp.Nouveau.Activity.clearFeedbackNotice(e),e.removeClass("events-initiated"),e=h(".bb-media-info-section:visible").find(".ac-form .ac-input[contenteditable]"),bp.Nouveau.Activity.listenCommentInput(e),_.isUndefined(g)||_.isUndefined(g.emoji)||bp.Nouveau.Activity.initializeEmojioneArea(!0,"#bb-rl-activity-modal ",t.current_document.activity_id)),h(".bb-media-info-section:visible").show(),t.updateTheaterHeaderTitle({wrapper:h(".bb-rl-media-model-wrapper"),action:"media"}),h(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10),h(".bb-media-info-section:visible").find(".bb-activity-more-options-action").attr("data-balloon-pos","left")):h(".bb-media-info-section.document").hide()}})},activityDeleted:function(e,t){var i=this,a=0;if(i.is_open_media&&void 0!==t&&"delete_activity"===t.action&&i.current_media.activity_id===t.id){for(var o=h(document).find('[data-bp-list="media"] .bb-rl-open-media-theatre[data-id="'+i.current_media.id+'"]'),d=o.parents("ul"),r=(o.closest("li").remove(),0===d.find("li:not(.load-more)").length&&(0<(o=h(".bb-photos-actions")).length&&o.hide(),1===d.find("li.load-more").length)&&location.reload(),h(document).find('[data-bp-list="activity"] .bb-rl-open-media-theatre[data-id="'+i.current_media.id+'"]').closest(".bb-rl-activity-media-elem").remove(),i.medias.length),a=0;aDate: Mon, 17 Aug 2026 18:51:58 +0530 Subject: [PATCH 4/4] PROD-9616 - Reset the pin flag on the media-path modal close too The media-path close (deleting the last attached photo via its own delete control, which removes the whole activity) triggers the same close button as the direct-delete path, so activitySyncOnModalClose runs its unconditional refreshActivities() branch when a pin was toggled from inside the modal - reloading the feed from page 1 and losing the member's scroll position. Apply the same activityPinHasUpdates reset the direct-delete path got in 99a3a01, typeof-guarded since this runs in buddypress-media.js. ReadyLaunch needs no change - its sync handler has no unconditional pin branch. --- src/bp-templates/bp-nouveau/js/buddypress-media.js | 7 +++++++ src/bp-templates/bp-nouveau/js/buddypress-media.min.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bp-templates/bp-nouveau/js/buddypress-media.js b/src/bp-templates/bp-nouveau/js/buddypress-media.js index 7d26a8388da..372ed61ac10 100644 --- a/src/bp-templates/bp-nouveau/js/buddypress-media.js +++ b/src/bp-templates/bp-nouveau/js/buddypress-media.js @@ -1424,6 +1424,13 @@ window.bp = window.bp || {}; if ( $activityModal.length && 0 === $activityModal.find( '.bb-modal-activity-body .activity-list li' ).length ) { var $modalCloseButton = $activityModal.find( '.bb-modal-activity-header .bb-close-action-popup' ); if ( $modalCloseButton.length ) { + // A pin toggled from inside the modal is moot once the + // post is deleted - left set, the close-button's sync + // handler reloads the whole feed (same reset as the + // direct-delete path in buddypress-activity.js). + if ( 'undefined' !== typeof bp.Nouveau.Activity ) { + bp.Nouveau.Activity.activityPinHasUpdates = false; + } $modalCloseButton.trigger( 'click' ); } else { $activityModal.closest( '.bb-activity-model-wrapper' ).hide(); diff --git a/src/bp-templates/bp-nouveau/js/buddypress-media.min.js b/src/bp-templates/bp-nouveau/js/buddypress-media.min.js index dfb50bb9776..3b007bcdf15 100644 --- a/src/bp-templates/bp-nouveau/js/buddypress-media.min.js +++ b/src/bp-templates/bp-nouveau/js/buddypress-media.min.js @@ -1 +1 @@ -window.bp=window.bp||{},(p=>{"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},bp.Nouveau.Media={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){var e=p("body"),e=(this.current_page=1,this.current_page_existing_media=1,this.current_page_albums=1,this.current_tab=!e.hasClass("single-topic")&&!e.hasClass("single-forum")&&"bp-dropzone-content",this.sort_by="",this.order_by="",this.currentTargetParent=BP_Nouveau.media.current_folder,this.moveToIdPopup=BP_Nouveau.media.move_to_id_popup,this.moveToTypePopup=BP_Nouveau.media.current_type,this.privacySelectorSelect="",this.privacySelectorSpan="",this.currentAlbum=BP_Nouveau.media.current_album,void 0!==window.Dropzone&&(window.Dropzone.autoDiscover=!1),document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:""),e=(this.documentOptions={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,acceptedFiles:BP_Nouveau.media.document_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.media.dropzone_document_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.document.maxFiles?BP_Nouveau.document.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.document.max_upload_size?BP_Nouveau.document.max_upload_size:2,dictInvalidFileType:BP_Nouveau.document.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation},document.getElementsByClassName("forum-post-video-template").length?document.getElementsByClassName("forum-post-video-template")[0].innerHTML:"");this.videoOptions={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.video.dictFileTooBig,acceptedFiles:BP_Nouveau.video.video_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.video.dropzone_video_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.video.maxFiles?BP_Nouveau.video.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.video.max_upload_size?BP_Nouveau.video.max_upload_size:2,dictInvalidFileType:BP_Nouveau.video.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.video.video_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.video.dictCancelUploadConfirmation},p("#bp-media-uploader").hasClass("bp-media-document-uploader")?(e=document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:"",this.options={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,acceptedFiles:BP_Nouveau.media.document_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.media.dropzone_document_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.document.maxFiles?BP_Nouveau.document.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.document.max_upload_size?BP_Nouveau.document.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation}):(e=document.getElementsByClassName("forum-post-media-template").length?document.getElementsByClassName("forum-post-media-template")[0].innerHTML:"",this.options={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,dictDefaultMessage:BP_Nouveau.media.dropzone_media_message,acceptedFiles:"image/*",autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.media.maxFiles?BP_Nouveau.media.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.media_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation,maxThumbnailFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2}),void 0!==BP_Nouveau.media.dropzone_options&&Object.assign(this.options,BP_Nouveau.media.dropzone_options),this.dropzone_obj=[],this.dropzone_media=[],this.album_id=void 0!==BP_Nouveau.media.album_id&&BP_Nouveau.media.album_id,this.current_folder=void 0!==BP_Nouveau.media.current_folder&&BP_Nouveau.media.current_folder,this.current_group_id=void 0!==BP_Nouveau.media.current_group_id&&BP_Nouveau.media.current_group_id,this.group_id=void 0!==BP_Nouveau.media.group_id&&BP_Nouveau.media.group_id,this.bbp_is_reply_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_reply_edit&&window.BP_Forums_Nouveau.media.bbp_is_reply_edit,this.bbp_is_topic_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_topic_edit&&window.BP_Forums_Nouveau.media.bbp_is_topic_edit,this.bbp_is_forum_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_forum_edit&&window.BP_Forums_Nouveau.media.bbp_is_forum_edit,this.bbp_reply_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_media?window.BP_Forums_Nouveau.media.reply_edit_media:[],this.bbp_reply_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_document?window.BP_Forums_Nouveau.media.reply_edit_document:[],this.bbp_reply_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_video?window.BP_Forums_Nouveau.media.reply_edit_video:[],this.bbp_topic_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_media?window.BP_Forums_Nouveau.media.topic_edit_media:[],this.bbp_topic_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_video?window.BP_Forums_Nouveau.media.topic_edit_video:[],this.bbp_topic_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_document?window.BP_Forums_Nouveau.media.topic_edit_document:[],this.bbp_forum_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_media?window.BP_Forums_Nouveau.media.forum_edit_media:[],this.bbp_forum_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_document?window.BP_Forums_Nouveau.media.forum_edit_document:[],this.bbp_forum_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_video?window.BP_Forums_Nouveau.media.forum_edit_video:[],this.bbp_reply_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_gif_data?window.BP_Forums_Nouveau.media.reply_edit_gif_data:[],this.bbp_topic_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_gif_data?window.BP_Forums_Nouveau.media.topic_edit_gif_data:[],this.bbp_forum_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_gif_data?window.BP_Forums_Nouveau.media.forum_edit_gif_data:[],this.giphy=null,this.gif_offset=0,this.gif_q=null,this.gif_limit=20,this.gif_requests=[],this.gif_data=[],this.gif_container_key=!1,this.reply_topic_allow_delete_media=!1,this.reply_topic_display_post="edit",bp.Nouveau.Media.documentCodeMirror(),p(window).on("scroll resize",function(){bp.Nouveau.Media.documentCodeMirror()})},addListeners:function(){var e=p(".bp-nouveau"),t=p(".bp-existing-media-wrap"),t=(e.on("click","#bp-add-media",this.openUploader.bind(this)),e.on("click","#bp-add-document",this.openDocumentUploader.bind(this)),e.on("click","#bp-media-submit",this.submitMedia.bind(this)),e.on("click","#bp-media-document-submit",this.submitDocumentMedia.bind(this)),e.on("click","#bp-media-uploader-close",this.closeUploader.bind(this)),e.on("click","#bb-delete-media",this.deleteMedia.bind(this)),e.on("click","#bb-select-deselect-all-media",this.toggleSelectAllMedia.bind(this)),void 0!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request?p('#buddypress [data-bp-list="media"]').on("bp_ajax_request",this.bp_ajax_media_request):this.bp_media_after_load(),e.on("click","#bb-create-album",this.openCreateAlbumModal.bind(this)),p(document).on("click","#bb-create-folder",this.openCreateFolderModal.bind(this)),p(document).on("click","#bb-create-folder-child",this.openCreateFolderChildModal.bind(this)),p(document).on("click","#bp-edit-folder-open",this.openEditFolderChildModal.bind(this)),p(document).on("click","#bp-media-create-album-submit",this.saveAlbum.bind(this)),p(document).on("click","#bp-media-create-folder-submit",this.saveFolder.bind(this)),p(document).on("click","#bp-media-create-child-folder-submit",this.saveChildFolder.bind(this)),e.on("click","#bp-media-create-album-close",this.closeCreateAlbumModal.bind(this)),p(document).on("click","#bp-media-create-folder-close",this.closeCreateFolderModal.bind(this)),p(document).on("click","#bp-media-edit-folder-close",this.closeEditFolderModal.bind(this)),p(document).on("click",".open-popup .errorPopup",this.closeErrorPopup.bind(this)),e.on("click","#bp-media-add-more",this.triggerDropzoneSelectFileDialog.bind(this)),p("#bp-media-uploader").on("click",".bp-media-upload-tab",this.changeUploadModalTab.bind(this)),p('.bp-nouveau [data-bp-list="media"]').on("click","li.load-more",this.injectMedias.bind(this)),p(".bp-nouveau #albums-dir-list").on("click","li.load-more",this.appendAlbums.bind(this)),t.on("click","li.load-more",this.appendMedia.bind(this)),e.on("change",'.bb-media-check-wrap [name="bb-media-select"]',this.addSelectedClassToWrapper.bind(this)),t.on("change",'.bb-media-check-wrap [name="bb-media-select"]',this.toggleSubmitMediaButton.bind(this)),e.on("click","#bp-edit-album-title",this.editAlbumTitle.bind(this)),p(document).on("click","#bp-edit-folder-title",this.editFolderTitle.bind(this)),e.on("click","#bp-cancel-edit-album-title",this.cancelEditAlbumTitle.bind(this)),e.on("click","#bp-save-album-title",this.saveAlbum.bind(this)),p(document).on("click","#bp-save-folder-title",this.saveFolder.bind(this)),e.on("change","#bp-media-single-album select#bb-album-privacy",this.saveAlbum.bind(this)),e.on("change","#media-stream select#bb-folder-privacy",this.savePrivacy.bind(this)),e.on("click","#bb-delete-album",this.deleteAlbum.bind(this)),p(document).on("click","#bb-delete-folder",this.deleteFolder.bind(this)),p(document).on("click","ul.document-nav li",this.resetPageDocumentDirectory.bind(this)),p(document).on("click","ul.document-nav li a",this.resetPageDocumentDirectory.bind(this)),p(document).on("click","#forums-media-button",this.openForumsUploader.bind(this)),p(document).on("click","#forums-document-button",this.openForumsDocumentUploader.bind(this)),p(document).on("click","#forums-video-button",this.openForumsVideoUploader.bind(this)),p(document).on("click","#forums-gif-button",this.toggleGifSelector.bind(this)),p(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("keydown",".search-query-input",this.searchGif.bind(this)),p(document).on("click",".bbpress-forums-activity #whats-new-toolbar .found-media-item",this.selectGif.bind(this)),p(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("click",".found-media-item",this.selectGif.bind(this)),p(document).find("form #whats-new-toolbar .gif-search-results, .forum form #whats-new-toolbar .gif-search-results").scroll(this.loadMoreGif.bind(this)),p(".buddypress.groups.messages").length||p(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("click",".found-media-item",this.selectGif.bind(this)),p(document).find("form #whats-new-attachments .forums-attached-gif-container .gif-search-results, .forum form #whats-new-attachments .forums-attached-gif-container .gif-search-results").scroll(this.loadMoreGif.bind(this)),p(document).find("form #whats-new-attachments .forums-attached-gif-container, .forum form #whats-new-attachments .forums-attached-gif-container").on("click",".gif-image-remove",this.removeSelectedGif.bind(this)),p(document).on("click",".gif-image-container",this.playVideo.bind(this)),p(document).on("click",".directory.document .media-folder_action__anchor, .directory.document .media-folder_action__anchor li a, .bb-media-container .media-folder_action__anchor, .bb-media-container .media-folder_action__list li a",this.fileActionButton.bind(this)),p(document).on("click",".bb-activity-media-elem .copy_download_file_url a, .media-folder_action__list .copy_download_file_url a, .media .bb-photo-thumb .copy_download_file_url a",this.copyDownloadLink.bind(this)),p(document).on("click",".bb-activity-media-elem.media-activity .media-action-wrap .media-action_more, #media-stream.media .bb-photo-thumb .media-action-wrap .media-action_more, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_more, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_list li a",this.fileActivityActionButton.bind(this)),p(document).click(this.toggleFileActivityActionButton),p(document).on("click",".bb-activity-media-elem.document-activity .document-expand .document-expand-anchor, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_collapse",this.toggleCodePreview.bind(this)),p(document).on("click",".activity .bp-document-move-activity, #media-stream .bp-document-move-activity",this.moveDocumentIntoFolder.bind(this)),p(document).on("click",'.bp-nouveau [data-bp-list="document"] .pager .dt-more-container.load-more',this.injectDocuments.bind(this)),p(document).on("click",'.bp-nouveau [data-bp-list="document"] .data-head',this.sortDocuments.bind(this)),p(document).on("click",".modal-container .bb-field-steps-actions",this.documentPopupNavigate.bind(this)),p(document).on("click",".bp-media-document-uploader .modal-container .bb-field-uploader-actions",this.uploadDocumentNavigate.bind(this)),p(document).on("click",".bp-media-photo-uploader .modal-container .bb-field-uploader-actions",this.uploadMediaNavigate.bind(this)),p(document).on("click",".modal-container #bp-media-edit-child-folder-submit",this.renameChildFolder.bind(this)),p(document).on("click",".activity .bp-media-move-activity, #media-stream .bp-media-move-activity",this.moveMediaIntoAlbum.bind(this)),p("#bb-media-model-container .activity-list, #media-stream")),e="#buddypress .activity-list",i='#buddypress [data-bp-list="activity"]',a="#bb-media-model-container .activity-list",o="#media-stream",e=(p(document).on("click",e+" .ac-document-move, "+i+" .ac-document-move, "+e+" .ac-folder-move, "+i+" .ac-folder-move, "+a+" .ac-document-move, "+a+" .ac-folder-move, "+o+" .ac-document-move, "+o+" .ac-folder-move",this.openDocumentMove.bind(this)),p(document).on("click",e+" .ac-media-move, "+i+" .ac-media-move, "+a+" .ac-media-move, "+o+" .ac-media-move, .group-media "+o+" .ac-media-move",this.openMediaMove.bind(this)),p(document).on("click",e+" .ac-document-close-button, "+i+" .ac-document-close-button, "+e+" .ac-folder-close-button, "+i+" .ac-folder-close-button, "+a+" .ac-document-close-button, "+a+" .ac-folder-close-button, "+o+" .ac-document-close-button, "+o+" .ac-folder-close-button",this.closeDocumentMove.bind(this)),p(document).on("click",e+" .ac-media-close-button, "+i+" .ac-media-close-button, "+a+" .ac-media-close-button, "+o+" .ac-media-close-button",this.closeMediaMove.bind(this)),t.on("click",".ac-document-rename",this.renameDocument.bind(this)),t.on("click",".ac-document-privacy",this.editPrivacyDocument.bind(this)),t.on("keyup",".media-folder_name_edit",this.renameDocumentSubmit.bind(this)),t.on("click",".name_edit_cancel, .name_edit_save",this.renameDocumentSubmit.bind(this)),p(document).on("click",".document-file-delete",this.deleteDocument.bind(this)),p(document).on("click",".media-file-delete",this.deleteMedia.bind(this)),p(document).on("click",".bp-folder-move",this.folderMove.bind(this)),p(document).on("click",".bp-document-open-create-popup-folder",this.createFolderInPopup.bind(this)),p(document).on("click",".bp-media-open-create-popup-folder",this.createAlbumInPopup.bind(this)),p(document).on("click",".close-create-popup-folder",this.closeCreateFolderInPopup.bind(this)),p(document).on("click",".close-create-popup-album",this.closeCreateAlbumInPopup.bind(this)),p(document).on("click",".bp-document-create-popup-folder-submit",this.submitCreateFolderInPopup.bind(this)),p(document).on("click",".bp-media-create-popup-album-submit",this.submitCreateAlbumInPopup.bind(this)),p(".buddypress.groups.messages")),i=p(".buddypress.groups.messages form#send_group_message_form #whats-new-toolbar"),a=p(".buddypress.groups.messages form#send_group_message_form #whats-new-attachments .bp-group-messages-attached-gif-container .gif-search-results"),o=p(".buddypress.groups.messages form#send_group_message_form #whats-new-attachments .bp-group-messages-attached-gif-container");e.on("click","#bp-group-messages-media-button",this.openGroupMessagesUploader.bind(this)),e.on("click","#bp-group-messages-document-button",this.openGroupMessagesDocumentUploader.bind(this)),e.on("click","#bp-group-messages-video-button",this.openGroupMessagesVideoUploader.bind(this)),e.on("click","#bp-group-messages-gif-button",this.toggleGroupMessagesGifSelector.bind(this)),i.on("keyup",".search-query-input",this.searchGroupMessagesGif.bind(this)),i.on("click",".found-media-item",this.selectGroupMessagesGif.bind(this)),a.scroll(this.loadMoreGroupMessagesGif.bind(this)),p(".groups.messages form#send_group_message_form #whats-new-toolbar .bp-group-messages-attached-gif-container .gif-search-results").scroll(this.loadMoreGroupMessagesGif.bind(this)),o.on("click",".gif-image-remove",this.removeGroupMessagesSelectedGif.bind(this)),p(".bp-existing-media-wrap").on("scroll",this.loadExistingMedia.bind(this)),document.addEventListener("keyup",this.closePopup.bind(this)),document.addEventListener("keyup",this.submitPopup.bind(this)),p(window).bind("beforeunload",this.beforeunloadWindow.bind(this)),_.isUndefined(BP_Nouveau.media.gif_api_key)||(window.addEventListener("scroll",this.throttledAutoPlayGifVideos.bind(this),!1),window.addEventListener("resize",this.throttledAutoPlayGifVideos.bind(this),!1),(t=p("#bp-message-thread-list")).length&&t.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),(e=p(".bb-modal-activity-body")).length&&e.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),(i=p(".bb-media-model-container .activity-list .activity-item")).length&&i.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),p(document).on("scroll","#bp-message-thread-list",this.throttledAutoPlayGifVideos.bind(this)),p(document).on("scroll",".bb-modal-activity-body",this.throttledAutoPlayGifVideos.bind(this)),p(document).on("scroll",".bb-media-model-container .activity-list .activity-item",this.throttledAutoPlayGifVideos.bind(this)),setTimeout(function(){var e=document.getElementById("bp-message-thread-list"),e=(e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1),document.querySelector(".bb-modal-activity-body")),e=(e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1),document.querySelector(".bb-media-model-container .activity-list .activity-item"));e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1)},1e3),p(window).on("load",function(){setTimeout(function(){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media.autoPlayGifVideos&&bp.Nouveau.Media.autoPlayGifVideos()},300)}),document.addEventListener("keydown",_.bind(this.closePickersOnEsc,this)),p(document).on("click",_.bind(this.closePickersOnClick,this))),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_media.length||this.bbp_topic_edit_media.length||this.bbp_forum_edit_media.length)&&p("#forums-media-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_document.length||this.bbp_topic_edit_document.length||this.bbp_forum_edit_document.length)&&p("#forums-document-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_video.length||this.bbp_topic_edit_video.length||this.bbp_forum_edit_video.length)&&p("#forums-video-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(Object.keys(this.bbp_reply_edit_gif_data).length||Object.keys(this.bbp_topic_edit_gif_data).length||Object.keys(this.bbp_forum_edit_gif_data).length)&&(this.editGifPreview(),(a=jQuery("#forums-gif-button").addClass("active").closest("form")).find("#forums-document-button")&&a.find("#forums-document-button").parents(".post-elements-buttons-item").addClass("disable"),a.find("#forums-media-button")&&a.find("#forums-media-button").parents(".post-elements-buttons-item").addClass("disable"),a.find("#forums-video-button"))&&a.find("#forums-video-button").parents(".post-elements-buttons-item").addClass("disable"),"#openEditFolder"==window.location.hash&&p("#bp-media-edit-child-folder").length&&(history.pushState(null,null,window.location.href.split("#")[0]),p("#bp-media-edit-child-folder").show()),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(bp.Nouveau.Media.reply_topic_allow_delete_media=!0)},updateAlbumCounts:function(e){var t,i,a,o;p("#buddypress #bp-media-single-album").length&&(o=parseInt(e.album_media_count)||0,e=parseInt(e.album_video_count)||0,t=function(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},0<(a=p("#buddypress .bb-album-photo-count")).length&&(i=1===o?BP_Nouveau.media.i18n_strings.photo:BP_Nouveau.media.i18n_strings.photos,a.text(t(o)+" "+i)),0<(a=p("#buddypress .bb-album-video-count")).length)&&(o=1===e?BP_Nouveau.media.i18n_strings.video:BP_Nouveau.media.i18n_strings.videos,a.text(t(e)+" "+o))},loadExistingMedia:function(){p(window).scroll()},resetPageDocumentDirectory:function(e){e.preventDefault(),this.current_page=1},submitCreateFolderInPopup:function(e){e.preventDefault();var i=p(e.currentTarget).closest(".open-popup"),a=p(i).find(".bp-document-create-popup-folder-submit"),t=i.find(".bb-folder-selected-id").val(),o=p.trim(p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder-title").val()),d=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder-title"),s=/[\\/?%*:|"<>]+/g.exec(d.val()),s=Boolean(s);if(""===p.trim(d.val())||s)return d.addClass("error"),!1;d.removeClass("error"),this.currentTargetParent=t=""===t?0:t;var n=this.currentTargetParent,r=0,l="",c="",u=0;if("group"===this.moveToTypePopup?(l="grouponly",r=this.moveToIdPopup):(l=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder #bb-folder-privacy").val(),c=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder #bb-folder-privacy")),""===o)return alert(BP_Nouveau.media.create_folder_error_title),!1;a.addClass("loading"),setTimeout(function(){var e={action:"document_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:o,privacy:l,parent:n,group_id:r};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,async:!1,success:function(e){var t;e.success&&(p(".document-data-table-head").length&&parseInt(n)===parseInt(BP_Nouveau.media.current_folder)&&(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()),i.find(".location-folder-list-wrap .location-folder-list").remove(),i.find(".location-folder-list-wrap").append(e.data.tree_view),t="#"+p(i).attr("id")+".open-popup",bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,e.data.folder_id),u=e.data.folder_id,(""===e.data.tree_view?(i.find(".location-folder-list-wrap").hide(),i.find(".location-folder-list-wrap-main span.no-folder-exists")):(i.find(".location-folder-list-wrap-main span.no-folder-exists").hide(),i.find(".location-folder-list-wrap"))).show(),i.find("ul.location-folder-list span#"+u).trigger("click"),i.find(".bb-model-footer").show(),i.find(".bb-model-footer, #bp-media-document-prev").show(),i.find(".bb-field-wrap-search").show(),i.find(".bp-document-open-create-popup-folder").show(),i.find(".location-folder-list-wrap-main").show(),i.find(".create-popup-folder-wrap").hide(),i.find(".bb-folder-selected-id").val(),i.find(".bb-folder-selected-id").val(u),i.find(".bb-model-header").children().show(),i.find(".bb-model-header p").hide(),d.val(""),""!==c&&c.val("public"),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(i).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),a.removeClass("loading"),setTimeout(function(){var e=i.find("ul.location-folder-list span#"+u),t=(e.trigger("click"),p(i).find("#bb-document-privacy"));0!==Number(e.data("id"))?(t.find("option").removeAttr("selected"),t.val(e.parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1))},200))}}),this.currentTargetParent=u,i.find(".location-folder-list li.is_active").show().children("span, i").show().siblings("ul").hide(),i.find(".location-folder-list li.is_active").siblings("li").show().children("span, i").show().siblings("ul").hide(),i.find(".location-folder-list li span.selected").removeClass("selected"),i.find(".location-folder-list li.is_active").children("span").addClass("selected")},0)},submitCreateAlbumInPopup:function(e){e.preventDefault();var t=this,i=p(e.currentTarget).closest(".open-popup"),a=p(i).find(".bp-media-create-popup-album-submit"),o=i.find(".bb-album-selected-id").val(),d=(this.currentTargetParent=o=""===o?0:o,this.currentTargetParent),s=0,n=p.trim(p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album-title").val()),r=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album-title"),l="",c="",u=0;if("group"===this.moveToTypePopup?(l="grouponly",s=this.moveToIdPopup):(l=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album #bb-album-privacy").val(),c=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album #bb-album-privacy")),""===n)return alert(BP_Nouveau.media.create_album_error_title),!1;a.addClass("loading"),setTimeout(function(){var e={action:"media_album_save",_wpnonce:BP_Nouveau.nonces.media,title:n,privacy:l,parent:d,group_id:s};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,async:!1,success:function(e){e.success&&(i.find(".location-album-list-wrap .location-album-list").remove(),i.find(".location-album-list-wrap").append(e.data.tree_view),bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(i,e.data.album_id),u=e.data.album_id,(""===e.data.tree_view?(i.find(".location-album-list-wrap").hide(),i.find(".location-album-list-wrap-main span.no-album-exists")):(i.find(".location-album-list-wrap-main span.no-album-exists").hide(),i.find(".location-album-list-wrap"))).show(),i.find("ul.location-album-list span#"+u).trigger("click"),i.find(".bb-model-footer").show(),i.find(".bb-field-wrap-search").show(),i.find(".bp-media-open-create-popup-album").show(),i.find(".location-album-list-wrap-main").show(),i.find(".create-popup-album-wrap").hide(),i.find(".bb-field-steps-2 #bp-media-prev").show(),i.find(".bb-album-selected-id").val(),i.find(".bb-album-selected-id").val(u),i.find(".bb-model-header").children().show(),i.find(".bb-model-header p").hide(),r.val(""),""!==c&&c.val("public"),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(i).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),t.updateAlbumNavCount(e.data.album_count)),a.removeClass("loading")}}),this.currentTargetParent=u,i.find(".location-album-list li.is_active").show().children("span, i").show().siblings("ul").hide(),i.find(".location-album-list li.is_active").siblings("li").show().children("span, i").show().siblings("ul").hide(),i.find(".location-album-list li span.selected").removeClass("selected"),i.find(".location-album-list li.is_active").children("span").addClass("selected")},0)},closeCreateFolderInPopup:function(e){e.preventDefault(),p(".modal-container .bb-model-footer").show(),p(".bb-field-wrap-search").show(),p(".bp-document-open-create-popup-folder").show(),p(".location-folder-list-wrap-main").show(),p("#bp-media-document-prev").show(),p(".create-popup-folder-wrap").hide(),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header").children().show(),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header p").hide()},closeCreateAlbumInPopup:function(e){e.preventDefault(),p(".modal-container .bb-model-footer").show(),p(".bb-field-wrap-search").show(),p(".bp-document-open-create-popup-folder").show(),p(".modal-container:visible .bp-video-open-create-popup-album").show(),p(".location-album-list-wrap-main").show(),p(".bb-field-steps-2 #bp-media-prev").show(),p(".bb-field-steps-2 #bp-video-next").show(),p(".create-popup-album-wrap").hide(),p(".bp-media-create-popup-album-submit.loading").removeClass("loading"),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header").children().show(),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header p").hide()},createFolderInPopup:function(e){e.preventDefault();var t=parseInt(p(document).find(".open-popup .bb-folder-selected-id").val()),i=p(document).find(".open-popup .bb-folder-create-from").val();0 "+BP_Nouveau.media.create_folder+" "+BP_Nouveau.media.create_album_title+" '+e.data.media_personal_count+" "+t)):p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count)),void 0!==e.data&&void 0!==e.data.media_group_count&&0 '+e.data.media_group_count+" "+t)):p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):r.find(".media-list:not(.existing-media-list)")).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):r.find(".media-list:not(.existing-media-list)")).html(e.data.group_media_html_content):p.each(n,function(e,t){p('#media-stream ul.media-list li[data-id="'+t+'"]').length&&p('#media-stream ul.media-list li[data-id="'+t+'"]').remove()}),void 0!==e.data.album_total_count&&s.updateAlbumCounts(e.data))):(setTimeout(function(){d.prop("disabled",!1)},500),e.success?(void 0!==e.data&&void 0!==e.data.media_personal_count&&0
'+e.data.media_personal_count+" "+t)):p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count)),void 0!==e.data&&void 0!==e.data.media_group_count&&0
'+e.data.media_group_count+" "+t)):p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),(i=r.find(".media-list:not(.existing-media-list)")).find('.bb-media-check-wrap [name="bb-media-select"]:checked').each(function(){p(this).closest("li").remove()}),i.parent().parent().hasClass("album-single-view")&&i.find('.bb-video-check-wrap [name="bb-video-select"]:checked').each(function(){p(this).closest("li").remove()}),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):i).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):i).html(e.data.group_media_html_content):p.each(n,function(e,t){p('#media-stream ul.media-list li[data-id="'+t+'"]').length&&p('#media-stream ul.media-list li[data-id="'+t+'"]').remove()}),void 0!==e.data.album_total_count&&s.updateAlbumCounts(e.data)):p("#buddypress #media-stream.media").prepend(e.data.feedback));var t,i,a=p(".bp-nouveau #bb-select-deselect-all-media");a.hasClass("selected")&&a.removeClass("selected"),jQuery(window).scroll()}})},toggleSelectAllMedia:function(e){e.preventDefault(),p(e.currentTarget).hasClass("selected")?(p(e.currentTarget).data("bp-tooltip",BP_Nouveau.media.i18n_strings.selectall),this.deselectAllMedia(e)):(p(e.currentTarget).data("bp-tooltip",BP_Nouveau.media.i18n_strings.unselectall),this.selectAllMedia(e)),p(e.currentTarget).toggleClass("selected")},selectAllMedia:function(e){e.preventDefault();e=p("#buddypress").find(".media-list:not(.existing-media-list)");e.find('.bb-media-check-wrap [name="bb-media-select"]').each(function(){p(this).prop("checked",!0),p(this).closest(".bb-item-thumb").addClass("selected"),p(this).closest(".bb-media-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.unselect)}),e.parent().parent().hasClass("album-single-view")&&e.find('.bb-video-check-wrap [name="bb-video-select"]').each(function(){p(this).prop("checked",!0),p(this).closest(".bb-item-thumb").addClass("selected"),p(this).closest(".bb-video-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.unselect)})},deselectAllMedia:function(e){e.preventDefault();e=p("#buddypress").find(".media-list:not(.existing-media-list)");e.find('.bb-media-check-wrap [name="bb-media-select"]').each(function(){p(this).prop("checked",!1),p(this).closest(".bb-item-thumb").removeClass("selected"),p(this).closest(".bb-media-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.select)}),e.parent().parent().hasClass("album-single-view")&&e.find('.bb-video-check-wrap [name="bb-video-select"]').each(function(){p(this).prop("checked",!1),p(this).closest(".bb-item-thumb").removeClass("selected"),p(this).closest(".bb-video-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.select)})},editAlbumTitle:function(e){e.preventDefault(),p("#bb-album-title").show(),p("#bp-save-album-title").show(),p("#bp-cancel-edit-album-title").show(),p("#bp-edit-album-title").hide(),p("#bp-media-single-album #bp-single-album-title").hide()},editFolderTitle:function(e){e.preventDefault(),p("#bb-album-title").show(),p("#bp-save-folder-title").show(),p("#bp-cancel-edit-album-title").show(),p("#bp-edit-folder-title").hide(),p("#bp-media-single-album #bp-single-album-title").hide()},cancelEditAlbumTitle:function(e){e.preventDefault(),p("#bb-album-title").removeClass("error").hide(),p("#bp-save-album-title,#bp-save-folder-title").hide(),p("#bp-cancel-edit-album-title").hide(),p("#bp-edit-album-title,#bp-edit-folder-title").show(),p("#bp-media-single-album #bp-single-album-title").show()},triggerDropzoneSelectFileDialog:function(){this.dropzone_obj.hiddenFileInput.click()},closeUploader:function(e){e.preventDefault(),p("#bp-media-uploader").hide(),p("#bp-media-add-more").hide(),p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),p("#bp-media-uploader-modal-status-text").text(""),p("#bp-media-post-content").val(""),p("#bp-dropzone-content .bp-feedback").remove(),this.dropzone_obj.element&&this.dropzone_obj.destroy(),this.dropzone_media=[];var t=p(e.currentTarget).closest("#bp-media-uploader");p(".close-create-popup-album").trigger("click"),p(".close-create-popup-folder").trigger("click"),t.find('.breadcrumbs-append-ul-li .item span[data-id="0"]').trigger("click"),t.find(".bb-field-steps").length&&(t.find(".bb-field-steps-1").show().siblings(".bb-field-steps-2").hide(),t.find(".bb-field-steps-1 #bp-media-photo-next, .bb-field-steps-1 #bp-media-document-next ").hide(),t.find(".bb-field-steps-1").removeClass("controls-added"),t.find("#bp-media-document-prev, #bp-media-prev, #bp-media-document-submit, #bp-media-submit, .bp-media-open-create-popup-folder, .bp-document-open-create-popup-folder, .create-popup-folder-wrap, .create-popup-album-wrap, .bp-video-open-create-popup-album").hide()),this.clearFolderLocationUI(e)},closeChildFolderUploader:function(e){e.preventDefault(),p(document).find(".open-popup #bb-album-child-title").val(""),p(document).find(".open-popup #bp-media-create-child-folder-submit").removeClass("loading"),p(document).find("#bp-media-create-child-folder").removeClass("open-popup"),p(document).find("#bp-media-create-child-folder").hide(),p(document).find(".open-popup #bb-album-title").text(""),p(document).find(".open-popup #bp-media-create-folder").hide(),p(document).find("#bp-media-create-folder").removeClass("open-popup")},closeFolderUploader:function(e){e.preventDefault(),p(document).find(".open-popup #bb-album-title").val(""),p(document).find(".open-popup #bp-media-create-folder-submit").removeClass("loading"),p(document).find(".open-popup #bp-media-document-submit").hide(),p(document).find("#bp-media-create-folder").removeClass("open-popup"),p(document).find("#bp-media-create-folder").hide()},loadMoreGif:function(e){var t=e.target,i=this,e=p(e.target).closest("form").find(".forums-attached-gif-container"),a=e.data("key");i.gif_container_key=a,t.scrollTop+t.offsetHeight>=t.scrollHeight&&!e.hasClass("loading")&&0
=t.scrollHeight&&!p(e.target).closest(".bp-group-messages-attached-gif-container").hasClass("loading")&&0 \n\t\n\t\t \n\t\n',e.data[t].saved=!1,this.gif_data.push(e.data[t])}p(".bp-group-messages-attached-gif-container").find(".gif-search-results-list").append(i)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(this.gif_total_count=e.pagination.total_count)},loadMoreGifResponse:function(e){var t=this,i=0;if(p('div.forums-attached-gif-container[data-key="'+t.gif_container_key+'"]').removeClass("loading"),void 0!==e.data&&e.data.length){for(var a="",i=0;i
\n\t\n\t\t \n\t\n',e.data[i].saved=!1,t.gif_data[t.gif_container_key].data.push(e.data[i])}p('div.forums-attached-gif-container[data-key="'+t.gif_container_key+'"]').closest("form").find(".gif-search-results-list").append(a)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(t.gif_data[t.gif_container_key].total_count=e.pagination.total_count)},editGifPreview:function(){var e=this,t={};if(e.bbp_is_reply_edit&&Object.keys(e.bbp_reply_edit_gif_data).length?t=e.bbp_reply_edit_gif_data.gif_raw_data:e.bbp_is_topic_edit&&Object.keys(e.bbp_topic_edit_gif_data).length?t=e.bbp_topic_edit_gif_data.gif_raw_data:e.bbp_is_forum_edit&&Object.keys(e.bbp_forum_edit_gif_data).length&&(t=e.bbp_forum_edit_gif_data.gif_raw_data),void 0===t.images)return!1;e=p("#whats-new-attachments .forums-attached-gif-container");e[0].style.backgroundImage="url("+t.images.fixed_width.url+")",e[0].style.backgroundSize="contain",e[0].style.height=t.images.original.height+"px",e[0].style.width=t.images.original.width+"px",e.find(".gif-image-container img").attr("src",t.images.original.url),e.removeClass("closed"),p("#bbp_media_gif").length&&p("#bbp_media_gif").val(JSON.stringify(t))},selectGif:function(e){var t=this,i=0,a=p(e.currentTarget),o=a.closest("form").find(".forums-attached-gif-container"),d=(e.preventDefault(),o.closest("form").find(".gif-media-search-dropdown").removeClass("open"),o.data("key"));if(void 0!==t.gif_data[d]&&void 0!==t.gif_data[d].data&&t.gif_data[d].data.length){for(i=0;i
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,s.gif_data.push(e.data[n])}p(d.target).closest(".bp-group-messages-attached-gif-container").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(s.gif_total_count=e.pagination.total_count),p(d.target).closest(".bp-group-messages-attached-gif-container").removeClass("loading")},function(){p(d.target).find(".gif-no-connection").addClass("show")}));s.gif_requests.push(e),s.gif_offset=s.gif_offset+s.gif_limit},searchGifRequest:function(d){var s=this,n=0,r=p(d.target).closest("form").find(".forums-attached-gif-container"),l=(r.addClass("loading"),r.data("key")),e=(p(d.target).closest("form").find(".gif-no-results").removeClass("show"),p(d.target).closest("form").find(".gif-no-connection").removeClass("show"),s.clearGifRequests(l),s.gif_data[l].q=d.target.value,s.gif_data[l].offset=0,s.giphy.search({q:s.gif_data[l].q,offset:s.gif_data[l].offset,fmt:"json",limit:s.gif_data[l].limit},function(e){if(void 0!==e.data.length&&0===e.data.length&&p(d.target).closest("form").find(".gif-no-results").addClass("show"),void 0!==e.meta.status&&200!==e.meta.status&&p(d.target).closest("form").find(".gif-no-connection").addClass("show"),void 0!==e.data&&e.data.length){var t="";for(n=0;n
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,s.gif_data[l].data.push(e.data[n])}p(d.target).closest(".gif-search-content").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(s.gif_data[l].total_count=e.pagination.total_count),r.removeClass("loading")},function(){p(d.target).closest("form").find(".gif-no-connection").addClass("show")}));s.gif_data[l].requests.push(e),s.gif_data[l].offset=s.gif_data[l].offset+s.gif_data[l].limit},clearGifRequests:function(e){var t=this;if(void 0!==t.gif_data[e]&&void 0!==t.gif_data[e].requests){for(var i=0;i
\n\t\n\t\t \n\t\n',e.data[l].saved=!1,n.gif_data[s].data.push(e.data[l])}r.closest("form").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(n.gif_data[s].total_count=e.pagination.total_count),d.removeClass("loading")}),n.gif_data[s].requests.push(e),n.gif_data[s].offset=n.gif_data[s].offset+n.gif_data[s].limit),t.toggleClass("open"),r.parents("form").find("#whats-new-attachments .forums-attached-gif-container img")),t=(0
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,d.gif_data.push(e.data[n])}s.closest("form").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(d.gif_total_count=e.pagination.total_count),p(".gif-search-query").closest(".bp-group-messages-attached-gif-container").removeClass("loading")}),d.gif_requests.push(e),d.gif_offset=d.gif_offset+d.gif_limit),s.parents("form").find("#whats-new-attachments .bp-group-messages-attached-gif-container img"));0
"),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),a.dropzone_obj[n].on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=p(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.album_id=a.album_id,t.data.group_id=a.group_id,t.data.saved=!1,a.dropzone_media[n].push(t.data),a.addMediaIdsToForumsForm(d)):(jQuery(".forum-media-error-popup").length||p("body").append('"),this.removeFile(e))}),a.dropzone_obj[n].on("removedfile",function(e){if(!0===bp.Nouveau.Media.reply_topic_allow_delete_media){if(a.dropzone_media[n].length)for(var t in a.dropzone_media[n])if(e.upload.uuid==a.dropzone_media[n][t].uuid){this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit||void 0===a.dropzone_media[n][t].saved||a.dropzone_media[n][t].saved||"edit"!==bp.Nouveau.Media.reply_topic_display_post||a.removeAttachment(a.dropzone_media[n][t].id),a.dropzone_media[n].splice(t,1),a.addMediaIdsToForumsForm(d);break}var i;_.isNull(a.dropzone_obj[n].files)||0!==a.dropzone_obj[n].files.length||((i=o.closest("form")).find("#forums-document-button")&&i.find("#forums-document-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-video-button")&&i.find("#forums-video-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-gif-button")&&i.find("#forums-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-media-button")&&i.find("#forums-media-button").parents(".post-elements-buttons-item").removeClass("no-click"))}_.isNull(a.dropzone_obj[n].files)||0!==a.dropzone_obj[n].files.length||o.closest("form").removeClass("has-media")}),a.dropzone_obj[n].on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 "),this.removeFile(e))}),a.dropzone_obj.on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=p(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.album_id=a.album_id,t.data.group_id=a.group_id,t.data.saved=!1,a.dropzone_media.push(t.data),a.addMediaIdsToGroupMessagesForm()):(jQuery(".group-message-error-popup").length||p("body").append('"),this.removeFile(e))}),a.dropzone_obj.on("removedfile",function(e){if(a.dropzone_media.length)for(var t in a.dropzone_media)if(e.upload.uuid==a.dropzone_media[t].uuid){void 0===a.dropzone_media[t].saved||a.dropzone_media[t].saved||a.removeAttachment(a.dropzone_media[t].id),a.dropzone_media.splice(t,1),a.addMediaIdsToGroupMessagesForm();break}var i;_.isNull(a.dropzone_obj.files)||0!==a.dropzone_obj.files.length||((i=p("#send_group_message_form")).find("#bp-group-messages-document-button")&&i.find("#bp-group-messages-document-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-video-button")&&i.find("#bp-group-messages-video-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-gif-button")&&i.find("#bp-group-messages-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-media-button")&&i.find("#bp-group-messages-media-button").parents(".post-elements-buttons-item").removeClass("no-click"))}),t.removeClass("closed").addClass("open"),a.resetGroupMessagesGifComponent(),a.resetGroupMessagesDocumentComponent(),a.resetGroupMessagesVideoComponent()):a.resetGroupMessagesMediaComponent())},openGroupMessagesDocumentUploader:function(e){var l=this,t=p("div#bp-group-messages-post-document-uploader"),i=p(e.currentTarget);e.preventDefault(),i.toggleClass("active"),void 0!==window.Dropzone&&t.length&&(t.hasClass("closed")?(l.document_dropzone_obj=new Dropzone("div#bp-group-messages-post-document-uploader",l.documentOptions),l.document_dropzone_obj.on("addedfile",function(){}),l.document_dropzone_obj.on("sending",function(e,t,i){i.append("action","document_document_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media);i=p("#send_group_message_form");i.find("#bp-group-messages-media-button")&&i.find("#bp-group-messages-media-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-video-button")&&i.find("#bp-group-messages-video-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-gif-button")&&i.find("#bp-group-messages-gif-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-document-button")&&i.find("#bp-group-messages-document-button").parents(".post-elements-buttons-item").addClass("no-click")}),l.document_dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),l.document_dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?p(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&p(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".group-document-error-popup").length||p("body").append('"),this.removeFile(e))}),l.document_dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.document_dropzone_obj.on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e))}),r.video_dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.video.empty_video_type):t()}),r.video_dropzone_obj.on("addedfile",function(e){e.dataURL||bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),r.video_dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);e.upload.progress<=99?(p(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,p(e.previewElement).find(".dz-progress-count").text("99% "+BP_Nouveau.video.i18n_strings.video_uploaded_text))}),r.video_dropzone_obj.on("success",function(e,t){if(100===e.upload.progress&&(p(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,p(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),p(e.previewElement).closest(".dz-preview").addClass("dz-complete")),!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),l.dropzone_obj[u].on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.dropzone_obj[u].on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),l.dropzone_obj[u].on("accept",function(e,t){0==e.size?t(BP_Nouveau.video.empty_video_type):t()}),l.dropzone_obj[u].on("addedfile",function(e){e.dataURL&&e.dataThumb&&e.dataThumb.length?p(e.previewElement).find(".dz-video-thumbnail").prepend(' '):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),l.dropzone_obj[u].on("uploadprogress",function(e){o.closest("form").addClass("media-uploading");var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);e.upload.progress<=99?(p(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,p(e.previewElement).find(".dz-progress-count").text("99% "+BP_Nouveau.video.i18n_strings.video_uploaded_text))}),l.dropzone_obj[u].on("success",function(e,t){if(100===e.upload.progress&&(p(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,p(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),p(e.previewElement).closest(".dz-preview").addClass("dz-complete")),!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a
'+p(this).text()+""),p(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val(p(e.currentTarget).data("id")),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),0!==Number(p(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(p(e.currentTarget).parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),p(document).on("click",t+" .breadcrumb .item > span",function(e){var t,i;p(this).hasClass("is-disabled")||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val(0),p(e.currentTarget).closest(".bb-field-wrap").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),i=p(e.currentTarget).closest("#bp-media-uploader").find(".location-album-list li.is_active").data("privacy"),0!==Number(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),e=document.getElementsByClassName("uploader-post-media-template").length?document.getElementsByClassName("uploader-post-media-template")[0].innerHTML:"",i.options.previewTemplate=e,i.dropzone_obj=new Dropzone("div#media-uploader",i.options),i.dropzone_obj.on("sending",function(e,t,i){i.append("action","media_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media)}),i.dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),i.dropzone_obj.on("addedfile",function(){setTimeout(function(){i.dropzone_obj.getAcceptedFiles().length&&p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),i.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?p(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&p(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".media-error-popup").length||p("body").append('"),this.removeFile(e))}),i.dropzone_obj.on("queuecomplete",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),p(".bb-field-steps-1 #bp-media-photo-next, #bp-media-submit, #bp-media-create-album-submit").show()}),i.dropzone_obj.on("processing",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),p(".bb-field-steps-1 #bp-media-photo-next, #bp-media-submit, #bp-media-create-album-submit").hide()}),i.dropzone_obj.on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=i.dropzone_media.length,t.data.album_id=i.album_id,t.data.group_id=i.group_id,t.data.saved=!1,i.dropzone_media.push(t.data)):(jQuery(".media-error-popup").length||p("body").append('"),this.removeFile(e)),p(".modal-container").addClass("modal-container--alert"),p(".bb-field-steps-1").addClass("controls-added"),p("#bp-media-add-more").show(),p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()}),i.dropzone_obj.on("removedfile",function(e){if(i.dropzone_media.length)for(var t in i.dropzone_media)if(e.upload.uuid==i.dropzone_media[t].uuid){void 0===i.dropzone_media[t].saved||i.dropzone_media[t].saved||i.removeAttachment(i.dropzone_media[t].id),i.dropzone_media.splice(t,1);break}i.dropzone_obj.getAcceptedFiles().length?p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show():(p("#bp-media-uploader-modal-status-text").text(""),p("#bp-media-add-more, #bp-media-photo-next").hide(),p(".bb-field-steps-1").removeClass("controls-added"),p("#bp-media-submit").hide(),p(".modal-container").removeClass("modal-container--alert"))}))},openDocumentUploader:function(e){var a,t,l=this;e.preventDefault(),void 0!==window.Dropzone&&p("div#media-uploader").length&&(p("#bp-media-uploader").hasClass("bp-media-document-uploader")&&!this.currentTargetParent&&(this.currentTargetParent=0),p(e.currentTarget).closest("#bp-media-single-folder").length&&p("#bb-document-privacy").hide(),p(document).removeClass("open-popup"),p("#bp-media-uploader").show(),p("#bp-media-uploader").addClass("open-popup"),p("#bp-media-uploader.bp-media-document-uploader").find(".bb-field-steps.bb-field-steps-2").length&&(t="#bp-media-uploader.bp-media-document-uploader",0!==Number(p(t).find(".bb-folder-selected-id").data("value"))?(a=p(t).find(".bb-folder-selected-id").data("value"),p(t).find("#bb-document-privacy").prop("disabled",!0)):a=0,""!==this.moveToIdPopup)&&p.ajax({url:BP_Nouveau.ajaxurl,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:BP_Nouveau.nonces.media},success:function(e){p(document).find(".bp-media-document-uploader .location-folder-list-wrap h4 span.where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap").hide(),p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap-main span.no-folder-exists")):(p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap-main span.no-folder-exists").hide(),p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap"))).show(),p(document).find(".bp-media-document-uploader .popup-on-fly-create-album .privacy-field-wrap-hide-show").show(),p(document).find(".bp-media-document-uploader .open-popup .bb-folder-create-from").val("profile"),p(t).find(".location-folder-list-wrap .location-folder-list").remove(),p(t).find(".location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,a),p(t).find("ul.location-folder-list span#"+a).trigger("click"),p(t).find(".bb-folder-selected-id").val(a)}}),p(document).on("click",t+" .location-folder-list li span",function(e){var t;e.preventDefault(),p(this).parent().hasClass("is_active")||(0!=p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item").append(''+p(this).text()+""),p(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val(p(e.currentTarget).data("id")),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),0!==Number(p(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(p(e.currentTarget).parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),p(document).on("click",t+" .breadcrumb .item > span",function(e){var t,i;p(this).hasClass("is-disabled")||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val(p(e.currentTarget).data("id")),p(e.currentTarget).closest(".bb-field-wrap").find(".location-folder-list li span").removeClass("selected").parent().removeClass("is_active"),p(e.currentTarget).closest(".bb-field-wrap").find('.location-folder-list li[data-id="'+p(e.currentTarget).data("id")+'"]').addClass("is_active"),p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),i=p(e.currentTarget).closest("#bp-media-uploader").find(".location-folder-list li.is_active").data("privacy"),0!==Number(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),e=document.getElementsByClassName("uploader-post-document-template").length?document.getElementsByClassName("uploader-post-document-template")[0].innerHTML:"",l.options.previewTemplate=e,l.dropzone_obj=new Dropzone("div#media-uploader",l.options),l.dropzone_obj.on("sending",function(e,t,i){i.append("action","document_document_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media)}),l.dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),l.dropzone_obj.on("addedfile",function(){setTimeout(function(){l.dropzone_obj.getAcceptedFiles().length&&p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,l.dropzone_media.length,l.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),l.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?p(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&p(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".document-error-popup").length||p("body").append('"),this.removeFile(e))}),l.dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.dropzone_obj.on("queuecomplete",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),p(".bb-field-steps-1 #bp-media-document-next, #bp-media-document-submit").show()}),l.dropzone_obj.on("processing",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),p(".bb-field-steps-1 #bp-media-document-next, #bp-media-document-submit").hide()}),l.dropzone_obj.on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a .activity-content .bp-media-move-file",p(o).find(".bp-document-move").attr("id",p(e.currentTarget).closest(".document-activity").attr("data-id")),0 ');var i,t,a,o,d=t,s=this.moveToTypePopup;""!==this.moveToIdPopup&&p.ajax({url:BP_Nouveau.ajaxurl,type:"post",data:{action:"media_get_album_view",id:this.moveToIdPopup,type:this.moveToTypePopup},success:function(e){p(document).find(".location-album-list-wrap h4 span.where-to-move-profile-or-group-media").html(e.data.first_span_text),(""===e.data.html?(p(document).find(".open-popup .location-album-list-wrap").hide(),p(document).find(".open-popup .location-album-list-wrap-main span.no-album-exists")):(p(document).find(".open-popup .location-album-list-wrap-main span.no-album-exists").hide(),p(document).find(".open-popup .location-album-list-wrap"))).show(),"group"===s?(p(document).find(".popup-on-fly-create-album .privacy-field-wrap-hide-show").hide(),p(document).find(".open-popup .bb-album-create-from").val("group")):(p(document).find(".popup-on-fly-create-album .privacy-field-wrap-hide-show").show(),p(document).find(".open-popup .bb-album-create-from").val("profile")),!1===e.data.create_album?(p(o+".open-popup").find(".bp-media-open-create-popup-folder").removeClass("create-album"),p(o+".open-popup").find(".bp-media-open-create-popup-folder").hide()):(p(o+".open-popup").find(".bp-media-open-create-popup-folder").addClass("create-album"),p(o+".open-popup").find(".bp-media-open-create-popup-folder").show()),p(o).find(".location-album-list-wrap .location-album-list").remove(),p(o).find(".location-album-list-wrap").append(e.data.html),p(o).find("ul.location-album-list span#"+d).trigger("click")}}),p(document).on("click",o+" .location-album-list li span",function(e){var t;e.preventDefault(),p(this).parent().hasClass("is_active")||(0!=p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),p(this).closest(".location-album-list-wrap").find(".breadcrumb .item").append(''+p(this).text()+""),p(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),t=p(document).find('a.bb-open-media-theatre[data-id="'+i.find(".bp-media-move").attr("id")+'"]').data("album-id"),Number(t)==Number(p(e.currentTarget).data("id"))?p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||p(e.currentTarget).closest(".bp-media-move-file").find(".bb-album-selected-id").val(p(e.currentTarget).data("id"))}),p(document).on("click",o+" .breadcrumb .item > span",function(e){p(this).hasClass("is-disabled")||(p(e.currentTarget).closest(".bp-media-move-file").find(".bb-album-selected-id").val(0),p(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),d==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"))})},openDocumentMove:function(e){e.preventDefault();var t,i,a,e=p(e.currentTarget),o=(e.closest(".bb-activity-media-elem").find(".document-title").text(),this.moveToIdPopup=e.attr("id"),this.moveToTypePopup=e.attr("data-type"),e.attr("data-action")),d=(p(".bp-media-move-file.open-popup, .bp-media-move-folder.open-popup").hide().removeClass("open-popup"),e.closest("#activity-modal")),s=(0===d.length&&(d=p("body")),e.closest(".conflict-activity-ul-li-comment").closest("li.comment-item").length?(i=e.closest("li.comment-item"),i=d.find("#"+i.attr("id")+".comment-item .bp-media-move-file").first()):0<(a=e.closest("li.activity-item")).length&&(i=d.find("#"+a.attr("id")+" > .activity-content .bp-media-move-file").first()),i&&0!==i.length||(e.closest(".conflict-activity-ul-li-comment").closest("li.comment-item").length?(a=e.closest("li.comment-item").attr("id"),i=d.find("#"+a+".comment-item .bp-media-move-file").first()):(a=e.closest("li.activity-item").attr("id"))&&(i=d.find("#"+a+" > .activity-content .bp-media-move-file").first())),i&&0 '),"document"===o?p(t).find(".bb-model-header h4 .target_name").text(BP_Nouveau.media.move_to_file):p(t).find(".bb-model-header h4 .target_name").text(BP_Nouveau.media.move_to_folder),p(t).show(),p(t).addClass("open-popup"),"group"===this.moveToTypePopup?(p(document).find(".location-folder-list-wrap h4").show(),p(t).addClass("move-folder-popup-group")):(p(document).find(".location-folder-list-wrap h4").hide(),p(".move-folder-popup-group").removeClass("move-folder-popup-group")),this.currentTargetParent),n=this.moveToTypePopup;""!==this.moveToIdPopup&&p.ajax({url:BP_Nouveau.ajaxurl,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:BP_Nouveau.nonces.media},success:function(e){p(document).find(".location-folder-list-wrap h4 span.where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(p(document).find(".open-popup .location-folder-list-wrap").hide(),p(document).find(".open-popup .location-folder-list-wrap-main span.no-folder-exists")):(p(document).find(".open-popup .location-folder-list-wrap-main span.no-folder-exists").hide(),p(document).find(".open-popup .location-folder-list-wrap"))).show(),"group"===n?(p(document).find(".popup-on-fly-create-folder .privacy-field-wrap-hide-show").hide(),p(document).find(".open-popup .bb-folder-create-from").val("group")):(p(document).find(".popup-on-fly-create-folder .privacy-field-wrap-hide-show").show(),p(document).find(".open-popup .bb-folder-create-from").val("profile")),p(t).find(".location-folder-list-wrap .location-folder-list").remove(),p(t).find(".location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&(bp.Nouveau.Media.folderLocationUI(t,s),p(t).find("ul.location-folder-list span#"+s).trigger("click"))}})},closeMediaMove:function(e){e.preventDefault(),0!=p(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list-wrap .breadcrumb .item span:last-child").data("id")&&p(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list-wrap .breadcrumb .item span:last-child").remove(),p(e.currentTarget).closest(".bp-media-move-file").hide()},closeDocumentMove:function(e){e.preventDefault();var t=p(e.currentTarget),i=jQuery(e.currentTarget).closest(".has-folderlocationUI");(t.hasClass("ac-document-close-button")?(t.closest(".bp-media-move-file"),p(".bp-media-move-file.open-popup").hide().removeClass("open-popup").find(".bp-document-move")):(t.closest(".bp-media-move-folder"),p(".bp-media-move-folder.open-popup").hide().removeClass("open-popup").find(".bp-folder-move"))).attr("id",""),i.find(".bp-document-move.loading").removeClass("loading"),this.clearFolderLocationUI(e)},renameDocument:function(e){var t=p(e.currentTarget).closest(".media-folder_items").find(".media-folder_name"),i=t.children("span").text();t.hide().siblings(".media-folder_name_edit_wrap").show().children(".media-folder_name_edit").val(i).focus().select(),e.preventDefault()},editPrivacyDocument:function(e){e.preventDefault(),p(e.currentTarget).closest("#media-folder-document-data-table").find(".media-folder_visibility .media-folder_details__bottom span").show().siblings("select").addClass("hide");var t=p(e.currentTarget).closest(".media-folder_items").find(".media-folder_visibility");t.find(".media-folder_details__bottom span").hide().siblings("select").removeClass("hide"),t.find(".media-folder_details__bottom span").hide().siblings("select").val(p(e.currentTarget).attr("data-privacy")),t.find(".media-folder_details__bottom #bb-folder-privacy").attr("data-privacy",p(e.currentTarget).attr("data-privacy")),this.privacySelectorSelect=t.find(".media-folder_details__bottom span").hide().siblings("select"),this.privacySelectorSpan=t.find(".media-folder_details__bottom span")},editPrivacyDocumentSubmit:function(e){e=p(e.currentTarget);"true"==e.attr("data-mouseup")?(e.attr("data-mouseup","false"),e.addClass("hide").siblings("span").show().text(e.find("option:selected").text())):e.attr("data-mouseup","true")},renameDocumentSubmit:function(t){var i=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name_edit"),a=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > span"),o=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name"),e=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-id").attr("data-item-id"),d=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-attachment-id").attr("data-item-id"),s=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-type").attr("data-item-id"),n=i.val().trim(),r="",r=(p(t.currentTarget).closest(".ac-document-list").length?r=/[?\[\]=<>:;,'"&$#*()|~`!{}%+ \/]+/g:p(t.currentTarget).closest(".ac-folder-list").length&&(r=/[\\/?%*:|"<>]+/g),r.exec(n)),r=Boolean(r);if(r?i.addClass("error"):i.removeClass("error"),p(t.currentTarget).closest(".ac-document-list").length&&(-1!=n.indexOf("\\\\")||r?i.addClass("error"):i.removeClass("error")),!p(t.currentTarget).hasClass("name_edit_cancel")&&27!=t.keyCode||(i.removeClass("error"),i.parent().hide().siblings(".media-folder_name").show()),p(t.currentTarget).hasClass("name_edit_save")||13==t.keyCode){if(r)return;i.parent().addClass("submitting").append(''),p.ajax({url:BP_Nouveau.ajaxurl,type:"post",data:{action:"document_update_file_name",document_id:e,attachment_document_id:d,document_type:s,name:n,_wpnonce:BP_Nouveau.nonces.media},success:function(e){e.success?void 0!==e.data.document&&0 ');e.parents("li").each(function(e,t){t=p(t).children("span").clone();i.prepend("",t)}),p(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||p(a).find(".breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0
p(a).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),p(this).hasClass("selected")&&!p(this).hasClass("disabled")?(p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-destination").val(""),p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-selected-id").val("0"),p(a).find(".location-folder-list li.is_active").length?p(a).find(".bb-folder-selected-id").val(p(a).find(".location-folder-list li.is_active").attr("data-id")):p(a).find(".bb-folder-selected-id").val("0")):(p(this).closest(".location-folder-list-wrap-main").find(".location-folder-list li span").removeClass("selected"),p(this).addClass("selected"),p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-destination").val(p(this).text()),p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-selected-id").val(p(this).parent().attr("data-id"))),p(this).closest(".location-folder-list-wrap").find(".location-folder-title").text(p(this).siblings("span").text()).siblings(".location-folder-back").css("display","inline-block"),p(this).siblings("ul").show().siblings("span, i").hide().parent().siblings().hide(),p(this).siblings("ul").children("li").show().children("span,i").show(),p(this).closest(".is_active").removeClass("is_active"),p(a).find("li.is_active").removeClass("is_active"),p(this).parent().addClass("is_active"),p(a).find(".bb-folder-selected-id").val(p(a).find(".location-folder-list li.is_active").attr("data-id")),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").each(function(){p(this).show()}),o===p(a).find(".breadcrumbs-append-ul-li .item > span[data-id]").last().attr("data-id")&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled")),setTimeout(function(){p(a).closest(".bb-activity-media-wrap").find(".bb-activity-media-elem.document-activity").attr("data-parent-id")===(p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").prev():p(a).find(".breadcrumbs-append-ul-li .item > span:last-child")).attr("id")&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled"))},100)}),p(document).on("click",a+" .breadcrumbs-append-ul-li .item span",function(e){var t,i;p(this).parent().hasClass("is-disabled")||p(this).hasClass("more_options")||(t=p(e.currentTarget).attr("data-id"),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(p(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),p(a).find(".bb-folder-selected-id").val(t),p(a).find(".location-folder-list li").hide(),p(a).find(".location-folder-list li.is_active").removeClass("is_active"),p(a).find(".location-folder-list li > span.selected").removeClass("selected"),p(a).find('.location-folder-list li[data-id="'+t+'"]').addClass("is_active").children("span").addClass("selected"),p(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),p(a).find(".location-folder-list li.is_active").children("ul").length&&!p(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):p(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?p(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),"0"===t&&(p(a).find(".location-folder-list").children("li").show().children("span,i").show(),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(BP_Nouveau.media.target_text),p(a).find(".location-folder-back").hide()),p(e.currentTarget).nextAll().remove(),o===p(a).find(".breadcrumbs-append-ul-li .item > span[data-id]").last().attr("data-id")&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled")),e=p(a).find(".location-folder-list .is_active > span"),i=p(''),e.parents("li").each(function(e,t){t=p(t).children("span").clone();i.prepend("",t)}),p(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")),0===p(a).find('.breadcrumbs-append-ul-li .breadcrumb .item > span[data-id="'+t+'"]').length&&p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item").append(p(a).find('.location-folder-list li[data-id="'+t+'"]').children("span").clone()),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||p(a).find(".breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(a).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),p(a).find(".bb-folder-selected-id").val(t))})),p(a).find(".location-folder-list li").each(function(){p(this).children("ul").parent().addClass("has-ul").append('')}),p(a).hasClass("bp-media-move-folder")&&(p(a).find(".location-folder-list li>span").removeClass("is-disabled"),p(a).find('.location-folder-list li>span[id="'+p(a).find(".bp-folder-move").attr("id")+'"]').parent().addClass("is-disabled")),e=p(a).find(".bp-folder-move").attr("id"),0==p(a).find('.location-folder-list li[data-id="'+e+'"]').siblings().length&&p(a).find('.location-folder-list li[data-id="'+e+'"]').parent("ul").addClass("no-folder-list a"),o&&(p(a).find(".location-folder-list li").hide(),p(a).find(".location-folder-list li.is_active").removeClass("is_active"),p(a).find('.location-folder-list li[data-id="'+o+'"]').addClass("is_active"),p(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),p(a).find(".location-folder-list li.is_active").children("ul").length&&!p(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):p(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?p(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(p(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),p(a).find(".bb-folder-selected-id").val(p(a).find(".location-folder-list li.is_active").attr("data-id")),p(a).find('.location-folder-list li[data-id="'+e+'"]').children().hide()),"0"===o&&(p(a).find(".location-folder-list").children("li").show(),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(BP_Nouveau.media.target_text),p(a).find(".location-folder-back").hide()),setTimeout(function(){var e=0,e=(p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").prev():p(a).find(".breadcrumbs-append-ul-li .item > span:last-child")).attr("id");o===parseInt(e)&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled"))},100),e=p(a).find(".location-folder-list .is_active > span"),i=p(''),e.parents("li").each(function(e,t){t=p(t).children("span").clone();i.prepend("",t)}),p(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")))},clearFolderLocationUI:function(e){e=jQuery(e.currentTarget).closest(".has-folderlocationUI");0 ul > li.selected").data("bp-scope")||bp.Nouveau.inject("#media-stream ul.media-list",e.data.media,"prepend"),p("#buddypress #bp-media-single-album").length||(e.data.media_personal_count&&(0 '+e.data.media_personal_count+" "+t)):p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").length?p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count):"1"===BP_Nouveau.bb_enable_content_counts&&((a=document.createElement("span")).setAttribute("class","count"),o=document.createTextNode(e.data.media_personal_count),a.appendChild(o),p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a").append(a))),e.data.media_group_count&&(0
'+e.data.media_group_count+" "+t)):p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").length?p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count):"1"===BP_Nouveau.bb_enable_content_counts&&((o=document.createElement("span")).setAttribute("class","count"),a=document.createTextNode(e.data.media_group_count),o.appendChild(a),p("#buddypress").find(".bp-wrap .users-nav ul li#photos-groups-li a").append(o))),"yes"===BP_Nouveau.media.is_media_directory&&(0
ul > li.selected").data("bp-scope"))?a=e.data.media_all_count:"personal"===o?a=e.data.media_personal_count:"groups"===o&&(a=e.data.media_group_count),t=BP_Nouveau.dir_labels.hasOwnProperty("media")?1===a?BP_Nouveau.dir_labels.media.singular:BP_Nouveau.dir_labels.media.plural:"",p("#buddypress .bb-item-count").html(''+a+" "+t)):(p("#buddypress").find(".media-type-navs ul.media-nav li#media-all a span.count").text(e.data.media_all_count),p("#buddypress").find(".media-type-navs ul.media-nav li#media-personal a span.count").text(e.data.media_personal_count),p("#buddypress").find(".media-type-navs ul.media-nav li#media-groups a span.count").text(e.data.media_group_count)))),void 0!==e.data.album_total_count&&s.updateAlbumCounts(e.data);for(var i=0;i
").addClass("media-list item-list bp-list bb-photo-list grid")),0 ").addClass("display")),p("#media-stream div").attr("id","media-folder-document-data-table"),p(".bb-photos-actions").show()),p(".document-data-table-head").length?"yes"===BP_Nouveau.media.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(p(document).find("li#document-personal a").trigger("click"),p(document).find("li#document-personal").trigger("click")):r&&bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"):location.reload(!0),p("#bp-media-post-content").val("");for(var t=0;t
]+/g.exec(e.val())),d=Boolean(d);if(""===p.trim(e.val())||d)return e.addClass("error"),!1;if(e.removeClass("error"),!a.group_id&&""===p.trim(o.val()))return o.addClass("error"),!1;o.removeClass("error"),i.prop("disabled",!0).addClass("loading");d={action:"document_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:e.val().trim(),privacy:o.val(),album_id:a.current_folder,group_id:a.current_group_id};p(".bb-single-album-header .bp-feedback").remove(),p("#boss-media-create-album-popup .bp-feedback").remove(),p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:d,success:function(e){setTimeout(function(){i.prop("disabled",!1)},500),e.success?(a.closeFolderUploader(t),p(".document-data-table-head").length?"yes"===BP_Nouveau.media.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(p(document).find("li#document-personal a").trigger("click"),p(document).find("li#document-personal").trigger("click")):(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()):location.reload(!0)):alert(e.data.feedback.replace("'","'"))}})},saveChildFolder:function(t){var e=p(t.currentTarget),i=this,a=p("#bp-media-create-child-folder #bb-album-child-title"),o=(t.preventDefault(),/[\\/?%*:|"<>]+/g.exec(a.val())),o=Boolean(o);if(""===p.trim(a.val())||o)return a.addClass("error"),!1;a.removeClass("error"),e.prop("disabled",!0).addClass("loading");o={action:"document_child_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:a.val(),folder_id:i.current_folder,group_id:i.current_group_id};p(".bb-single-album-header .bp-feedback").remove(),p("#boss-media-create-album-popup .bp-feedback").remove(),p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:o,success:function(e){e.success?(i.closeChildFolderUploader(t),location.reload(!0)):alert(e.data.feedback.replace("'","'"))}})},renameChildFolder:function(e){e.preventDefault();var t=p(e.currentTarget),i=this,e=p("#bp-media-edit-child-folder #bb-album-child-title"),a=p("#bp-media-edit-child-folder #bb-folder-privacy"),o=this.currentTargetParent,d=/[\\/?%*:|"<>]+/g.exec(e.val()),d=Boolean(d);if(""===p.trim(e.val())||d)return e.addClass("error"),!1;e.removeClass("error"),t.prop("disabled",!0).addClass("loading");d={action:"document_edit_folder",_wpnonce:BP_Nouveau.nonces.media,title:e.val(),privacy:a.val(),id:o,group_id:i.current_group_id};p(".bb-single-album-header .bp-feedback").remove(),p("#boss-media-create-album-popup .bp-feedback").remove(),p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:d,success:function(e){setTimeout(function(){t.prop("disabled",!1)},500),e.success?window.location.reload(!0):i.current_folder?p("#bp-media-single-album").prepend(e.data.feedback):p("#boss-media-create-album-popup .bb-model-header").after(e.data.feedback)}})},deleteAlbum:function(t){if(t.preventDefault(),!this.album_id)return!1;if(!confirm(BP_Nouveau.media.i18n_strings.album_delete_confirm))return!1;p(t.currentTarget).prop("disabled",!0);var e={action:"media_album_delete",_wpnonce:BP_Nouveau.nonces.media,album_id:this.album_id,group_id:this.group_id};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){e.success?window.location.href=e.data.redirect_url:(alert(BP_Nouveau.media.i18n_strings.album_delete_error),p(t.currentTarget).prop("disabled",!1))}})},deleteFolder:function(t){if(t.preventDefault(),!BP_Nouveau.media.current_folder)return!1;if(!confirm(BP_Nouveau.media.i18n_strings.folder_delete_confirm))return!1;p(t.currentTarget).prop("disabled",!0);var e={action:"document_folder_delete",_wpnonce:BP_Nouveau.nonces.media,folder_id:BP_Nouveau.media.current_folder,group_id:BP_Nouveau.media.current_group_id};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){e.success?window.location.href=e.data.redirect_url:(alert(BP_Nouveau.media.i18n_strings.folder_delete_error),p(t.currentTarget).prop("disabled",!1))}})},addMediaIdsToGroupMessagesForm:function(){p("#bp_group_messages_media").length&&p("#bp_group_messages_media").val(JSON.stringify(this.dropzone_media))},addDocumentIdsToGroupMessagesForm:function(){p("#bp_group_messages_document").length&&p("#bp_group_messages_document").val(JSON.stringify(this.dropzone_media))},addVideoIdsToGroupMessagesForm:function(){p("#bp_group_messages_video").length&&p("#bp_group_messages_video").val(JSON.stringify(this.dropzone_media))},injectMedias:function(t){var i,a,e,o=bp.Nouveau.getStorage("bp-media"),d=o.scope||null,o=o.filter||null;p(t.currentTarget).hasClass("load-more")&&(i=+Number(this.current_page)+1,a=this,e="",t.preventDefault(),p(t.currentTarget).find("a").first().addClass("loading"),p("#buddypress .dir-search input[type=search]").length&&(e=p("#buddypress .dir-search input[type=search]").val()),bp.Nouveau.objectRequest({object:"media",scope:d,filter:o,search_terms:e,page:i,method:"append",target:"#buddypress [data-bp-list] ul.bp-list"}).done(function(e){!0===e.success&&(p(t.currentTarget).remove(),a.current_page=i,jQuery(window).scroll())}))},injectDocuments:function(e){var t,i,a,o=bp.Nouveau.getStorage("bp-document"),d="",s="",n=o.scope||null,r=o.filter||null,l=p(e.currentTarget);l.hasClass("load-more")&&(t=+Number(this.current_page)+1,i=this,a="",e.preventDefault(),l.find("a").first().addClass("loading"),p("#buddypress .dir-search input[type=search]").length&&(a=p("#buddypress .dir-search input[type=search]").val()),s=this.order_by&&this.sort_by?(d=this.sort_by,this.order_by):void 0!==o.extras?(d=o.extras.sort,o.extras.orderby):(d="ASC","title"),bp.Nouveau.objectRequest({object:"document",scope:n,filter:r,search_terms:a,page:t,method:"append",target:"#buddypress [data-bp-list] div#media-folder-document-data-table",order_by:s,sort:d}).done(function(e){!0===e.success&&(l.parent(".pager").remove(),i.current_page=t,jQuery(window).scroll())}))},sortDocuments:function(e){var t=p(e.currentTarget),i=t.data("target"),a="",o="date_created";t.attr("class");switch(i){case"name":o="title";break;case"modified":o="date_modified";break;case"visibility":o="privacy";break;case"group":o="group_id"}t.hasClass("asce")?t.removeClass("asce"):t.addClass("asce");var i=t.hasClass("asce")?"DESC":"ASC",t=(bp.Nouveau.getStorage("bp-document"),{}),t=(t.orderby=o,t.sort=i,"group"!==o&&bp.Nouveau.setStorage("bp-document","extras",t),bp.Nouveau.getStorage("bp-document")),d=t.scope||null,t=t.filter||null;p(e.currentTarget);p("#buddypress .bp-dir-search-form input[type=search]").length&&(a=p("#buddypress .bp-dir-search-form input[type=search]").val()),this.sort_by=i,this.order_by=o,this.current_page=1,bp.Nouveau.objectRequest({object:"document",scope:d,filter:t,search_terms:a,page:1,order_by:o,sort:i,method:"reset",target:"#buddypress [data-bp-list]"}).done()},documentPopupNavigate:function(e){e.preventDefault();var e=p(e.currentTarget),t=e.closest(".bb-field-steps"),i=0==e.closest(".bp-document-listing").length?"#bb-album-child-title":"#bb-album-title";e.closest(".document-options").length&&(i="#bb-album-title"),e.hasClass("bb-field-steps-next")&&""==t.find(i).val().trim()?t.find(i).addClass("error"):(t.find(i).removeClass("error"),t.slideUp(200).siblings(".bb-field-steps").slideDown(200))},uploadDocumentNavigate:function(e){e.preventDefault();var e=p(e.currentTarget),t=p(e).closest("#bp-media-uploader");p(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-document-submit, #bp-media-document-prev, .bp-document-open-create-popup-folder, #bb-document-privacy").show(),0!==Number(p(t).find(".bb-folder-selected-id"))&&p(t).find(".location-folder-list li.is_active").length&&p(t).find(".location-folder-list").scrollTop(p(t).find(".location-folder-list li.is_active").offset().top-p(t).find(".location-folder-list").offset().top),p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(t).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))})):(p(e).hide(),t.find("#bp-media-document-prev, .bp-document-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-folder").length&&p("#bb-document-privacy").hide())},uploadMediaNavigate:function(e){e.preventDefault();var e=p(e.currentTarget),t=p(e).closest(".bp-media-photo-uploader");p(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-submit, #bp-media-prev, .bp-media-open-create-popup-folder.create-album").show(),t.find("#bb-media-privacy").show(),0!==Number(p(t).find(".bb-album-selected-id"))&&p(t).find(".location-album-list li.is_active").length&&p(t).find(".location-album-list").scrollTop(p(t).find(".location-album-list li.is_active").offset().top-p(t).find(".location-album-list").offset().top)):(p(e).hide(),t.find("#bp-media-prev, .bp-media-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-album").length&&p("#bb-media-privacy").hide())},appendMedia:function(t){var i,a,e,o=bp.Nouveau.getStorage("bp-media"),d=o.scope||null,o=o.filter||null;p(t.currentTarget).hasClass("load-more")&&(i=+Number(this.current_page_existing_media)+1,a=this,e="",t.preventDefault(),p(t.currentTarget).find("a").first().addClass("loading"),p("#buddypress .dir-search input[type=search]").length&&(e=p("#buddypress .dir-search input[type=search]").val()),bp.Nouveau.objectRequest({object:"media",scope:d,filter:o,search_terms:e,page:i,method:"append",caller:"bp-existing-media",target:".bp-existing-media-wrap ul.bp-list"}).done(function(e){!0===e.success&&(p(t.currentTarget).remove(),a.current_page_existing_media=i,jQuery(window).scroll())}))},appendAlbums:function(t){var i=+Number(this.current_page_albums)+1,a=this,e=(t.preventDefault(),p(t.currentTarget).find("a").first().addClass("loading"),{action:"media_albums_loader",_wpnonce:BP_Nouveau.nonces.media,page:i});p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){!0===e.success&&(p(t.currentTarget).remove(),p("#albums-dir-list ul.bb-albums-list").fadeOut(100,function(){p("#albums-dir-list ul.bb-albums-list").append(e.data.albums),p(this).fadeIn(100)}),a.current_page_albums=i)}})},toggleSubmitMediaButton:function(){var e=p("#bp-media-submit"),t=p("#bp-media-add-more");"bp-dropzone-content"===this.current_tab?this.dropzone_obj.getAcceptedFiles().length?(e.show(),t.show()):(e.hide(),t.hide()):"bp-existing-media-content"===this.current_tab&&(p('.bp-existing-media-wrap .bb-media-check-wrap [name="bb-media-select"]:checked').length?e.show():e.hide(),t.hide())},playVideo:function(e){e.preventDefault();var t=p(e.currentTarget).find("video").get(0),e=p(e.currentTarget).find(".gif-play-button");1==t.paused?(t.play().catch(function(e){console.debug("GIF play failed:",e)}),e.hide()):(t.pause(),e.show())},isElementInScrollableContainer:function(e){var t=p(e),e=e.getBoundingClientRect(),i=t.closest("#bp-message-thread-list");return(i=(i=i.length?i:t.closest(".bb-modal-activity-body")).length?i:t.closest(".bb-media-model-container .activity-list .activity-item")).length?(i=i[0].getBoundingClientRect(),e.bottom>i.top&&e.top i.left&&e.left '),p(t).text());return p(t).text(BP_Nouveau.media.copy_to_clip_board_text),p("#"+e).val(p(t).attr("href")),p("#"+e).select(),document.execCommand("copy"),setTimeout(function(){p(t).text(i)},2e3),!1},fileActivityActionButton:function(e){e.preventDefault(),p(e.currentTarget).parent().hasClass("copy_download_file_url")||(p(e.currentTarget).closest(".bb-activity-media-elem").toggleClass("is-visible").siblings().removeClass("is-visible").closest(".activity-item").siblings().find(".bb-activity-media-elem").removeClass("is-visible"),p(e.currentTarget).closest(".bb-activity-media-elem").find(".bb_more_dropdown").toggleClass("open").closest(".bb-activity-media-elem").siblings().find(".bb_more_dropdown").removeClass("open").closest(".activity-item").siblings().find(".bb-activity-media-elem .bb_more_dropdown").removeClass("open"),p("body").addClass("document_more_option_open"),p(e.currentTarget).closest(".bb-activity-media-elem").length<1&&(p(e.currentTarget).closest(".bb-photo-thumb").toggleClass("is-visible").parent().siblings().find(".bb-photo-thumb").removeClass("is-visible").removeClass("is-visible"),p(e.currentTarget).closest(".bb-photo-thumb").find(".bb_more_dropdown").toggleClass("open").closest(".bb-photo-thumb").parent().siblings().find(".bb-photo-thumb .bb_more_dropdown").removeClass("open")),"a"!=e.currentTarget.tagName.toLowerCase())||p(e.currentTarget).hasClass("document-action_more")||p(e.currentTarget).hasClass("media-action_more")||(p(e.currentTarget).closest(".bb-activity-media-elem").removeClass("is-visible").find(".bb_more_dropdown").removeClass("open"),p(e.currentTarget).closest(".bb-photo-thumb").removeClass("is-visible").find(".bb_more_dropdown").removeClass("open"))},toggleFileActivityActionButton:function(e){var t;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),!0===e.altKey||!0===e.metaKey||p(t).hasClass("document-action_more")||p(t).parent().hasClass("document-action_more")||p(t).hasClass("media-folder_action__anchor")||p(t).parent().hasClass("media-folder_action__anchor")||p(t).hasClass("media-action_more")||p(t).parent().hasClass("media-action_more")||p(t).hasClass("video-action_more")||p(t).parent().hasClass("video-action_more")?e:(p(".bb-activity-media-elem.is-visible").removeClass("is-visible"),p(".media-folder_items.is-visible").removeClass("is-visible"),p(".bb-photo-thumb.is-visible").removeClass("is-visible"),p(".bb-item-thumb.is-visible").removeClass("is-visible"),p(".bb-activity-video-elem.is-visible").removeClass("is-visible"),p(".video-action-wrap.item-action-wrap.is-visible").removeClass("is-visible"),p(".video-action-wrap .bb_more_dropdown").removeClass("open"),p(".bb-activity-media-elem .bb_more_dropdown").removeClass("open"),p(".bb-photo-thumb .bb_more_dropdown").removeClass("open"),p(".media-folder_items .bb_more_dropdown").removeClass("open"),void p("body").removeClass("document_more_option_open video_more_option_open item_more_option_open"))},toggleCodePreview:function(e){e.preventDefault(),p(e.currentTarget).closest(".document-activity").toggleClass("code-full-view")},documentCodeMirror:function(){p(".document-text:not(.loaded)").each(function(){var e=p(this),t=e.attr("data-extension"),i=e.attr("data-extension");"html"!=t&&"htm"!=t||(i="text/html"),"js"==t?CodeMirror(e[0],{value:e.find(".document-text-file-data-hidden").val(),lineNumbers:!0,theme:"default",readOnly:!0,lineWrapping:!0}):CodeMirror(e[0],{value:e.find(".document-text-file-data-hidden").val(),mode:i,lineNumbers:!0,theme:"default",readOnly:!0,lineWrapping:!0}),e.addClass("loaded"),150 '+e+" "+t)):(t=p(".single-screen-navs.groups-nav").find("ul li#albums-groups-li"),0 '+e+"")))}},bp.Nouveau.Media.Theatre={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){this.bodySelector=p("body"),this.medias=[],this.documents=[],this.current_media=!1,this.current_document=!1,this.current_index=0,this.current_document_index=0,this.is_open_media=!1,this.is_open_document=!1,this.nextLink=p(".bb-next-media"),this.nextDocumentLink=p(".bb-next-document"),this.previousDocumentLink=p(".bb-prev-document"),this.previousLink=p(".bb-prev-media"),this.activity_ajax=!1,this.group_id=void 0!==BP_Nouveau.media.group_id&&BP_Nouveau.media.group_id,this.manage_media=void 0!==BP_Nouveau.media.can_manage_media&&BP_Nouveau.media.can_manage_media,this.manage_document=void 0!==BP_Nouveau.media.can_manage_document&&BP_Nouveau.media.can_manage_document},addListeners:function(){p(document).on("click",".bb-open-media-theatre",this.openTheatre.bind(this)),p(document).on("click",".bb-open-document-theatre",this.openDocumentTheatre.bind(this)),p(document).on("click",".document-detail-wrap-description-popup",this.openDocumentTheatre.bind(this)),p(document).on("click",".bb-close-media-theatre",this.closeTheatre.bind(this)),p(document).on("click",".bb-close-document-theatre",this.closeDocumentTheatre.bind(this)),p(document).on("click",".bb-prev-media",this.previous.bind(this)),p(document).on("click",".bb-next-media",this.next.bind(this)),p(document).on("click",".bb-prev-document",this.previousDocument.bind(this)),p(document).on("click",".bb-next-document",this.nextDocument.bind(this)),p(document).on("bp_activity_ajax_delete_request",this.activityDeleted.bind(this)),p(document).on("click","#bb-media-model-container .media-privacy>li",this.mediaPrivacyChange.bind(this)),p(document).on("click","#bb-media-model-container .document-privacy>li",this.documentPrivacyChange.bind(this)),p(document).on("click","#bb-media-model-container .bb-media-section span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),p(document).on("click","#bb-media-model-container .bb-document-section span.privacy",bp.Nouveau,this.toggleDocumentPrivacyDropdown.bind(this)),p(document).on("click",".bp-add-media-activity-description",this.openMediaActivityDescription.bind(this)),p(document).on("click","#bp-activity-description-new-reset",this.closeMediaActivityDescription.bind(this)),p(document).on("keyup",".bp-edit-media-activity-description #add-activity-description",this.MediaActivityDescriptionUpdate.bind(this)),p(document).on("click","#bp-activity-description-new-submit",this.submitMediaActivityDescription.bind(this)),p(document).click(this.togglePopupDropdown),document.addEventListener("keyup",this.checkPressedKeyDocuments.bind(this)),document.addEventListener("keyup",this.checkPressedKey.bind(this))},checkPressedKey:function(e){var t=this;if(e=e||window.event,!t.is_open_media)return!1;var i=p(e.target).hasClass("ac-input")||"add-activity-description"===p(e.target).attr("id");switch(e.keyCode){case 27:t.closeTheatre(e);break;case 37:if(void 0===t.medias[t.current_index-1]||i)return!1;t.previous(e);break;case 39:if(void 0===t.medias[t.current_index+1]||i)return!1;t.next(e)}},checkPressedKeyDocuments:function(e){e=e||window.event;var t=this;if(!t.is_open_document)return!1;var i=p(e.target).hasClass("ac-input")||"add-activity-description"===p(e.target).attr("id");switch(e.keyCode){case 27:t.closeDocumentTheatre(e);break;case 37:if(void 0===t.documents[t.current_document_index-1]||i)return!1;t.previousDocument(e);break;case 39:if(void 0===t.documents[t.current_document_index+1]||i)return!1;t.nextDocument(e)}},openTheatre:function(e){e.preventDefault();var e=p(e.currentTarget),t=this;if(e.closest("#bp-existing-media-content").length)return!1;t.setupGlobals(),t.setMedias(e),i=e.data("id"),e.data("activity-id"),t.setCurrentMedia(i),t.showMedia(),t.navigationCommands(),t.getParentActivityHtml(e),t.getMediasDescription(),p(".bb-media-model-wrapper.document").hide();var i=document.getElementById(p(".bb-media-model-wrapper.video video").attr("id"));i&&i.pause(),p(".bb-media-model-wrapper.video").hide(),p(".bb-media-model-wrapper.media").show(),bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay"),t.is_open_media=!0,t.bodySelector.addClass("media-modal-open"),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)},getParentActivityHtml:function(e){var t=p("#hidden_parent_id").val(),e=e.closest(".bb-media-model-wrapper").find("#bb-media-model-container .activity-list li.activity-item").data("bp-activity-id");parseInt(t)===parseInt(e)&&(e=p('#bb-media-model-container [data-bp-activity-id="'+t+'"]'),p('[data-bp-activity-id="'+t+'"] > .activity-state').html(p(e).find(".activity-state").html()),p('[data-bp-activity-id="'+t+'"] > .activity-meta').html(p(e).find(".activity-meta").html()),p('[data-bp-activity-id="'+t+'"] > .activity-comments').html(p(e).find(".activity-comments").html())),p("#hidden_parent_id").length&&p("#hidden_parent_id").remove()},getMediasDescription:function(){var e=this,t=(p(".bb-media-info-section .activity-list").addClass("loading").html(''),0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_media.activity_id+'"] .activity-comments'));t.length&&(t=t.find("#ac-form-"+e.current_media.activity_id),e.current_media.parent_activity_comments=!0,t.remove()),!0===e.current_media.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"media_get_media_description",id:e.current_media.id,attachment_id:e.current_media.attachment_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success?(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.description),p(".bb-media-info-section:visible").show(),bp.Nouveau.Media.Theatre.syncPinPostIconToTheatre(),p(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10)):p(".bb-media-info-section.media").hide()}})},openDocumentTheatre:function(e){e.preventDefault();var t=p(e.currentTarget),i=this;if(t.closest("#bp-existing-document-content").length)return!1;t.closest(".document.document-theatre").length&&i.closeDocumentTheatre(e),a=t.data("id"),i.setupGlobals(),i.setDocuments(t),i.setCurrentDocument(a),i.showDocument(),i.navigationDocumentCommands(),i.getParentActivityHtml(t),i.getDocumentsDescription(),-1!==p.inArray(i.current_document.extension,BP_Nouveau.document.mp3_preview_extension.split(","))&&p(e.currentTarget).closest(".bb-activity-media-elem.document-activity").length&&p(e.currentTarget).closest(".bb-activity-media-elem.document-activity").find(".document-audio-wrap").length&&p(e.currentTarget).closest(".bb-activity-media-elem.document-activity").find(".document-audio-wrap audio")[0].pause(),p(".bb-media-model-wrapper.media").hide(),p(".bb-media-model-wrapper.document").show();var a=document.getElementById(p(".bb-media-model-wrapper.video video").attr("id"));a&&(a.pause(),a.src=""),p(".bb-media-model-wrapper.video").hide(),i.is_open_document=!0,i.bodySelector.addClass("document-modal-open"),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay")},500)},resetRemoveActivityCommentsData:function(){var e,t=this,i=!1,a=!1,o=!1,d=!1,s=!1,n=!1;t.current_media.parent_activity_comments&&((i=(d=p('.bb-media-model-wrapper.media [data-bp-activity-id="'+t.current_media.activity_id+'"]')).find(".activity-comments")).length&&(e=i.find("#ac-form-"+t.current_media.activity_id),this.purgeEditActivityForm(e),e.find("#ac-input-"+t.current_media.activity_id).html(""),e.removeClass("has-content has-gif has-media").addClass("root"),i.append(e),e.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(t.current_media.activity_id),i.find(".acomment-display").removeClass("display-focus"),i.find(".comment-item").removeClass("comment-item-focus"),s=i.html(),n=i.attr("class"),i.remove(),(i=p('[data-bp-activity-id="'+t.current_media.activity_id+'"] .activity-comments')).length)&&(i.attr("class",n),0===i.find("#ac-form-"+t.current_media.activity_id).length)&&(i.append(e),i.children("form").removeClass("events-initiated").addClass("not-initialized")),(o=d.find(".activity-state")).length&&(s=o.html(),n=o.attr("class"),o.remove(),(o=p('[data-bp-activity-id="'+t.current_media.activity_id+'"] .activity-state')).length)&&(o.html(s),o.attr("class",n)),(a=d.find(".activity-meta")).length&&(s=a.html(),n=a.attr("class"),a.remove(),(a=p('[data-bp-activity-id="'+t.current_media.activity_id+'"] > .activity-meta')).length)&&(a.html(s),a.attr("class",n)),d.remove()),t.current_document.parent_activity_comments&&((i=(d=p('.bb-media-model-wrapper.document [data-bp-activity-id="'+t.current_document.activity_id+'"]')).find(".activity-comments")).length&&(e=i.find("#ac-form-"+t.current_document.activity_id),this.purgeEditActivityForm(e),e.find("#ac-input-"+t.current_document.activity_id).html(""),e.removeClass("has-content has-gif has-media").addClass("root"),i.append(e),e.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(t.current_document.activity_id),i.find(".acomment-display").removeClass("display-focus"),i.find(".comment-item").removeClass("comment-item-focus"),s=i.html(),n=i.attr("class"),i.remove(),(i=p('[data-bp-activity-id="'+t.current_document.activity_id+'"] .activity-comments')).length)&&(i.attr("class",n),0===i.find("#ac-form-"+t.current_document.activity_id).length&&(i.append(e),i.children("form").removeClass("events-initiated").addClass("not-initialized")),i.find(".document-text.loaded").removeClass("loaded").find(".CodeMirror").remove(),jQuery(window).scroll()),(o=d.find(".activity-state")).length&&(s=o.html(),n=o.attr("class"),o.remove(),(o=p('[data-bp-activity-id="'+t.current_document.activity_id+'"] .activity-state')).length)&&(o.html(s),o.attr("class",n)),(a=d.find(".activity-meta")).length&&(s=a.html(),n=a.attr("class"),a.remove(),(a=p('[data-bp-activity-id="'+t.current_document.activity_id+'"] > .activity-meta')).length)&&(a.html(s),a.attr("class",n)),d.remove()),bp.Nouveau.reportPopUp(),bp.Nouveau.reportActions()},closeTheatre:function(e){e.preventDefault();var t=this,e=p(e.currentTarget);if(p(e).closest(".bb-media-model-wrapper").hasClass("video-theatre"))return!1;p(".bb-media-model-wrapper.media .bb-media-section").find("img").attr("src",""),p(".bb-media-model-wrapper.video .bb-media-section").find("video").length&&videojs(p(".bb-media-model-wrapper.video .bb-media-section").find("video").attr("id")).reset(),p(".bb-media-model-wrapper").hide(),t.is_open_media=!1,t.syncPinPostActivityOnCloseTheatre(e),t.resetRemoveActivityCommentsData(),t.current_media=!1,t.getParentActivityHtml(e),t.bodySelector.removeClass("media-modal-open")},closeDocumentTheatre:function(e){e.preventDefault();var t=this,i=p(document).find(".document-theatre");i.find(".bb-media-section").removeClass("bb-media-no-preview").find(".document-preview").html(""),p(".bb-media-info-section.document").show(),i.hide(),t.is_open_document=!1,t.resetRemoveActivityCommentsData(),t.current_document=!1,t.getParentActivityHtml(p(e.currentTarget)),t.bodySelector.removeClass("document-modal-open")},setMedias:function(e){var t=p(".bb-open-media-theatre"),i=0;if(void 0!==(t=p("body").hasClass("activity")?p(e).closest(".bb-activity-media-wrap").find(".bb-open-media-theatre"):t))for(this.medias=[],i=0;i
"),p(".modal-container #bb-folder-privacy").addClass("new-folder-create-privacy"),p(document).find(".open-popup .error").hide()},savePrivacy:function(e){var t,i,a,o=p(e.currentTarget);if(e.preventDefault(),o.hasClass("new-folder-create-privacy"))return!1;t=parseInt(o.data("item-id")),i=o.data("item-type"),a=o.val(),e=p(e.currentTarget).find("option:selected").text(),this.privacySelectorSelect.addClass("hide"),this.privacySelectorSpan.text(""),this.privacySelectorSpan.text(e),this.privacySelectorSpan.show(),0'),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html(" "+i+'
'),o.find(".bb-document-section .document-preview .document-text").attr("data-extension",d),t=o.find(".bb-document-section .document-preview .document-text textarea"),"html"===d||"htm"===d?t.val(s):t.html(s),setTimeout(function(){bp.Nouveau.Media.documentCodeMirror()},1e3)):-1!==p.inArray(e.current_document.extension,BP_Nouveau.document.mp3_preview_extension.split(","))?(o.find(".bb-document-section .document-preview").html(''),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html('')):-1!==p.inArray("."+e.current_document.extension,BP_Nouveau.video.video_type.split(","))?(o.find(".bb-document-section").addClass("bb-video-preview"),o.find(".bb-document-section .document-preview").html(''),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),"mov"===e.current_document.extension||"m4v"===e.current_document.extension?o.find(".bb-document-section .document-preview").html(''):o.find(".bb-document-section .document-preview").html(''),p(window).scroll()):e.current_document.full_preview?(o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html("'+i+'
"+i+'
')):(o.find(".bb-document-section").addClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html('")),p(".bb-document-section .bb-document-privacy-wrap"));d.length&&(d.show(),d.parent().show(),d.find("ul.document-privacy li").removeClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",""),(t=d.find("ul.document-privacy").find("li[data-value="+e.current_document.privacy+"]")).addClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",t.text()),d.find(".privacy").removeClass("public").removeClass("loggedin").removeClass("onlyme").removeClass("friends").addClass(e.current_document.privacy),void 0!==BP_Nouveau.activity&&void 0!==e.current_document.activity_id&&0!=e.current_document.activity_id||e.group_id||e.current_document.is_forum||e.current_document.group_id||e.current_document.album_id||!e.can_manage_document||!e.current_document.can_edit||e.current_document.is_message)&&d.parent().hide(),e.navigationDocumentCommands()},next:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.medias[e.current_index+1]?(e.current_index=e.current_index+1,e.current_media.activity_id,e.current_media=e.medias[e.current_index],e.showMedia(),e.getMediasDescription(),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):e.nextLink.hide()},previous:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.medias[e.current_index-1]?(e.current_index=e.current_index-1,e.current_media.activity_id,e.current_media=e.medias[e.current_index],e.showMedia(),e.getMediasDescription(),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):e.previousLink.hide()},nextDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.documents[e.current_document_index+1]?(e.current_document_index=e.current_document_index+1,e.current_document.activity_id,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.nextDocumentLink.hide()},previousDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.documents[e.current_document_index-1]?(e.current_document_index=e.current_document_index-1,e.current_document.activity_id,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.previousDocumentLink.hide()},navigationCommands:function(){var e=this;0==e.current_index&&e.current_index!=e.medias.length-1?(e.previousLink.hide(),e.nextLink.show()):0==e.current_index&&e.current_index==e.medias.length-1?(e.previousLink.hide(),e.nextLink.hide()):e.current_index==e.medias.length-1?(e.previousLink.show(),e.nextLink.hide()):(e.previousLink.show(),e.nextLink.show())},navigationDocumentCommands:function(){var e=this;0==e.current_document_index&&e.current_document_index!=e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.show()):0==e.current_document_index&&e.current_document_index==e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.hide()):e.current_document_index==e.documents.length-1?(e.previousDocumentLink.show(),e.nextDocumentLink.hide()):(e.previousDocumentLink.show(),e.nextDocumentLink.show())},getActivity:function(){var e=this;p(".bb-media-info-section .activity-list").addClass("loading").html(''),void 0!==BP_Nouveau.activity&&e.current_media&&void 0!==e.current_media.activity_id&&0!=e.current_media.activity_id&&!e.current_media.is_forum?(0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_media.activity_id+'"] .activity-comments').length&&(e.current_media.parent_activity_comments=!0),!0===e.current_media.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"media_get_activity",id:e.current_media.activity_id,group_id:_.isUndefined(e.current_media.group_id)?0:e.current_media.group_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success&&(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.activity),p(".bb-media-info-section:visible").show(),jQuery(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10))}})):p(".bb-media-info-section.media").hide()},getDocumentsActivity:function(){var e=this;p(".bb-media-info-section .activity-list").addClass("loading").html(''),void 0!==BP_Nouveau.activity&&e.current_document&&void 0!==e.current_document.activity_id&&0!=e.current_document.activity_id&&!e.current_document.is_forum?(0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_document.activity_id+'"] .activity-comments').length&&(e.current_document.parent_activity_comments=!0),!0===e.current_document.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"document_get_activity",id:e.current_document.activity_id,group_id:_.isUndefined(e.current_document.group_id)?0:e.current_document.group_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success&&(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.activity),p(".bb-media-info-section:visible").show(),jQuery(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10))}})):p(".bb-media-info-section.document").hide()},getDocumentsDescription:function(){var e=this,t=(p(".bb-media-info-section .activity-list").addClass("loading").html(''),0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_document.activity_id+'"] .activity-comments'));t.length&&(t=t.find("#ac-form-"+e.current_document.activity_id),e.current_document.parent_activity_comments=!0,t.remove()),!0===e.current_document.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"document_get_document_description",id:e.current_document.id,attachment_id:e.current_document.attachment_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success?(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.description),p(".bb-media-info-section:visible").show(),bp.Nouveau.Media.Theatre.syncPinPostIconToTheatre(),p(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10)):p(".bb-media-info-section.document").hide()}})},activityDeleted:function(e,t){var i=this,a=0;if(i.is_open_media&&void 0!==t&&"delete_activity"===t.action&&i.current_media.activity_id==t.id){var o=p(document).find('[data-bp-list="media"] .bb-open-media-theatre[data-id="'+i.current_media.id+'"]'),d=o.parents("ul");for(o.closest("li").remove(),0===d.find("li:not(.load-more)").length&&(0'+i+"
.activity-list").children("#activity-"+i)).length&&e.hasClass("bb-pinned")&&0
"),p(".modal-container #bb-folder-privacy").addClass("new-folder-create-privacy"),p(document).find(".open-popup .error").hide()},createAlbumInPopup:function(e){e.preventDefault();var t=parseInt(p(document).find(".open-popup .bb-album-selected-id").val()),i=p(document).find(".open-popup .bb-album-create-from").val();0{"undefined"!=typeof BP_Nouveau&&(bp.Nouveau=bp.Nouveau||{},bp.Nouveau.Media={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){var e=p("body"),e=(this.current_page=1,this.current_page_existing_media=1,this.current_page_albums=1,this.current_tab=!e.hasClass("single-topic")&&!e.hasClass("single-forum")&&"bp-dropzone-content",this.sort_by="",this.order_by="",this.currentTargetParent=BP_Nouveau.media.current_folder,this.moveToIdPopup=BP_Nouveau.media.move_to_id_popup,this.moveToTypePopup=BP_Nouveau.media.current_type,this.privacySelectorSelect="",this.privacySelectorSpan="",this.currentAlbum=BP_Nouveau.media.current_album,void 0!==window.Dropzone&&(window.Dropzone.autoDiscover=!1),document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:""),e=(this.documentOptions={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,acceptedFiles:BP_Nouveau.media.document_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.media.dropzone_document_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.document.maxFiles?BP_Nouveau.document.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.document.max_upload_size?BP_Nouveau.document.max_upload_size:2,dictInvalidFileType:BP_Nouveau.document.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation},document.getElementsByClassName("forum-post-video-template").length?document.getElementsByClassName("forum-post-video-template")[0].innerHTML:"");this.videoOptions={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.video.dictFileTooBig,acceptedFiles:BP_Nouveau.video.video_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.video.dropzone_video_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.video.maxFiles?BP_Nouveau.video.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.video.max_upload_size?BP_Nouveau.video.max_upload_size:2,dictInvalidFileType:BP_Nouveau.video.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.video.video_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.video.dictCancelUploadConfirmation},p("#bp-media-uploader").hasClass("bp-media-document-uploader")?(e=document.getElementsByClassName("forum-post-document-template").length?document.getElementsByClassName("forum-post-document-template")[0].innerHTML:"",this.options={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,acceptedFiles:BP_Nouveau.media.document_type,createImageThumbnails:!1,dictDefaultMessage:BP_Nouveau.media.dropzone_document_message,autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.document.maxFiles?BP_Nouveau.document.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.document.max_upload_size?BP_Nouveau.document.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.document_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation}):(e=document.getElementsByClassName("forum-post-media-template").length?document.getElementsByClassName("forum-post-media-template")[0].innerHTML:"",this.options={url:BP_Nouveau.ajaxurl,timeout:108e5,dictFileTooBig:BP_Nouveau.media.dictFileTooBig,dictDefaultMessage:BP_Nouveau.media.dropzone_media_message,acceptedFiles:"image/*",autoProcessQueue:!0,addRemoveLinks:!0,uploadMultiple:!1,maxFiles:void 0!==BP_Nouveau.media.maxFiles?BP_Nouveau.media.maxFiles:10,maxFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2,dictInvalidFileType:bp_media_dropzone.dictInvalidFileType,dictMaxFilesExceeded:BP_Nouveau.media.media_dict_file_exceeded,previewTemplate:e,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation,maxThumbnailFilesize:void 0!==BP_Nouveau.media.max_upload_size?BP_Nouveau.media.max_upload_size:2}),void 0!==BP_Nouveau.media.dropzone_options&&Object.assign(this.options,BP_Nouveau.media.dropzone_options),this.dropzone_obj=[],this.dropzone_media=[],this.album_id=void 0!==BP_Nouveau.media.album_id&&BP_Nouveau.media.album_id,this.current_folder=void 0!==BP_Nouveau.media.current_folder&&BP_Nouveau.media.current_folder,this.current_group_id=void 0!==BP_Nouveau.media.current_group_id&&BP_Nouveau.media.current_group_id,this.group_id=void 0!==BP_Nouveau.media.group_id&&BP_Nouveau.media.group_id,this.bbp_is_reply_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_reply_edit&&window.BP_Forums_Nouveau.media.bbp_is_reply_edit,this.bbp_is_topic_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_topic_edit&&window.BP_Forums_Nouveau.media.bbp_is_topic_edit,this.bbp_is_forum_edit=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.bbp_is_forum_edit&&window.BP_Forums_Nouveau.media.bbp_is_forum_edit,this.bbp_reply_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_media?window.BP_Forums_Nouveau.media.reply_edit_media:[],this.bbp_reply_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_document?window.BP_Forums_Nouveau.media.reply_edit_document:[],this.bbp_reply_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_video?window.BP_Forums_Nouveau.media.reply_edit_video:[],this.bbp_topic_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_media?window.BP_Forums_Nouveau.media.topic_edit_media:[],this.bbp_topic_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_video?window.BP_Forums_Nouveau.media.topic_edit_video:[],this.bbp_topic_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_document?window.BP_Forums_Nouveau.media.topic_edit_document:[],this.bbp_forum_edit_media=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_media?window.BP_Forums_Nouveau.media.forum_edit_media:[],this.bbp_forum_edit_document=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_document?window.BP_Forums_Nouveau.media.forum_edit_document:[],this.bbp_forum_edit_video=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_video?window.BP_Forums_Nouveau.media.forum_edit_video:[],this.bbp_reply_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.reply_edit_gif_data?window.BP_Forums_Nouveau.media.reply_edit_gif_data:[],this.bbp_topic_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.topic_edit_gif_data?window.BP_Forums_Nouveau.media.topic_edit_gif_data:[],this.bbp_forum_edit_gif_data=void 0!==window.BP_Forums_Nouveau&&void 0!==window.BP_Forums_Nouveau.media.forum_edit_gif_data?window.BP_Forums_Nouveau.media.forum_edit_gif_data:[],this.giphy=null,this.gif_offset=0,this.gif_q=null,this.gif_limit=20,this.gif_requests=[],this.gif_data=[],this.gif_container_key=!1,this.reply_topic_allow_delete_media=!1,this.reply_topic_display_post="edit",bp.Nouveau.Media.documentCodeMirror(),p(window).on("scroll resize",function(){bp.Nouveau.Media.documentCodeMirror()})},addListeners:function(){var e=p(".bp-nouveau"),t=p(".bp-existing-media-wrap"),t=(e.on("click","#bp-add-media",this.openUploader.bind(this)),e.on("click","#bp-add-document",this.openDocumentUploader.bind(this)),e.on("click","#bp-media-submit",this.submitMedia.bind(this)),e.on("click","#bp-media-document-submit",this.submitDocumentMedia.bind(this)),e.on("click","#bp-media-uploader-close",this.closeUploader.bind(this)),e.on("click","#bb-delete-media",this.deleteMedia.bind(this)),e.on("click","#bb-select-deselect-all-media",this.toggleSelectAllMedia.bind(this)),void 0!==BP_Nouveau.is_send_ajax_request&&"1"===BP_Nouveau.is_send_ajax_request?p('#buddypress [data-bp-list="media"]').on("bp_ajax_request",this.bp_ajax_media_request):this.bp_media_after_load(),e.on("click","#bb-create-album",this.openCreateAlbumModal.bind(this)),p(document).on("click","#bb-create-folder",this.openCreateFolderModal.bind(this)),p(document).on("click","#bb-create-folder-child",this.openCreateFolderChildModal.bind(this)),p(document).on("click","#bp-edit-folder-open",this.openEditFolderChildModal.bind(this)),p(document).on("click","#bp-media-create-album-submit",this.saveAlbum.bind(this)),p(document).on("click","#bp-media-create-folder-submit",this.saveFolder.bind(this)),p(document).on("click","#bp-media-create-child-folder-submit",this.saveChildFolder.bind(this)),e.on("click","#bp-media-create-album-close",this.closeCreateAlbumModal.bind(this)),p(document).on("click","#bp-media-create-folder-close",this.closeCreateFolderModal.bind(this)),p(document).on("click","#bp-media-edit-folder-close",this.closeEditFolderModal.bind(this)),p(document).on("click",".open-popup .errorPopup",this.closeErrorPopup.bind(this)),e.on("click","#bp-media-add-more",this.triggerDropzoneSelectFileDialog.bind(this)),p("#bp-media-uploader").on("click",".bp-media-upload-tab",this.changeUploadModalTab.bind(this)),p('.bp-nouveau [data-bp-list="media"]').on("click","li.load-more",this.injectMedias.bind(this)),p(".bp-nouveau #albums-dir-list").on("click","li.load-more",this.appendAlbums.bind(this)),t.on("click","li.load-more",this.appendMedia.bind(this)),e.on("change",'.bb-media-check-wrap [name="bb-media-select"]',this.addSelectedClassToWrapper.bind(this)),t.on("change",'.bb-media-check-wrap [name="bb-media-select"]',this.toggleSubmitMediaButton.bind(this)),e.on("click","#bp-edit-album-title",this.editAlbumTitle.bind(this)),p(document).on("click","#bp-edit-folder-title",this.editFolderTitle.bind(this)),e.on("click","#bp-cancel-edit-album-title",this.cancelEditAlbumTitle.bind(this)),e.on("click","#bp-save-album-title",this.saveAlbum.bind(this)),p(document).on("click","#bp-save-folder-title",this.saveFolder.bind(this)),e.on("change","#bp-media-single-album select#bb-album-privacy",this.saveAlbum.bind(this)),e.on("change","#media-stream select#bb-folder-privacy",this.savePrivacy.bind(this)),e.on("click","#bb-delete-album",this.deleteAlbum.bind(this)),p(document).on("click","#bb-delete-folder",this.deleteFolder.bind(this)),p(document).on("click","ul.document-nav li",this.resetPageDocumentDirectory.bind(this)),p(document).on("click","ul.document-nav li a",this.resetPageDocumentDirectory.bind(this)),p(document).on("click","#forums-media-button",this.openForumsUploader.bind(this)),p(document).on("click","#forums-document-button",this.openForumsDocumentUploader.bind(this)),p(document).on("click","#forums-video-button",this.openForumsVideoUploader.bind(this)),p(document).on("click","#forums-gif-button",this.toggleGifSelector.bind(this)),p(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("keydown",".search-query-input",this.searchGif.bind(this)),p(document).on("click",".bbpress-forums-activity #whats-new-toolbar .found-media-item",this.selectGif.bind(this)),p(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("click",".found-media-item",this.selectGif.bind(this)),p(document).find("form #whats-new-toolbar .gif-search-results, .forum form #whats-new-toolbar .gif-search-results").scroll(this.loadMoreGif.bind(this)),p(".buddypress.groups.messages").length||p(document).find("form #whats-new-toolbar, .forum form #whats-new-toolbar").on("click",".found-media-item",this.selectGif.bind(this)),p(document).find("form #whats-new-attachments .forums-attached-gif-container .gif-search-results, .forum form #whats-new-attachments .forums-attached-gif-container .gif-search-results").scroll(this.loadMoreGif.bind(this)),p(document).find("form #whats-new-attachments .forums-attached-gif-container, .forum form #whats-new-attachments .forums-attached-gif-container").on("click",".gif-image-remove",this.removeSelectedGif.bind(this)),p(document).on("click",".gif-image-container",this.playVideo.bind(this)),p(document).on("click",".directory.document .media-folder_action__anchor, .directory.document .media-folder_action__anchor li a, .bb-media-container .media-folder_action__anchor, .bb-media-container .media-folder_action__list li a",this.fileActionButton.bind(this)),p(document).on("click",".bb-activity-media-elem .copy_download_file_url a, .media-folder_action__list .copy_download_file_url a, .media .bb-photo-thumb .copy_download_file_url a",this.copyDownloadLink.bind(this)),p(document).on("click",".bb-activity-media-elem.media-activity .media-action-wrap .media-action_more, #media-stream.media .bb-photo-thumb .media-action-wrap .media-action_more, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_more, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_list li a",this.fileActivityActionButton.bind(this)),p(document).click(this.toggleFileActivityActionButton),p(document).on("click",".bb-activity-media-elem.document-activity .document-expand .document-expand-anchor, .bb-activity-media-elem.document-activity .document-action-wrap .document-action_collapse",this.toggleCodePreview.bind(this)),p(document).on("click",".activity .bp-document-move-activity, #media-stream .bp-document-move-activity",this.moveDocumentIntoFolder.bind(this)),p(document).on("click",'.bp-nouveau [data-bp-list="document"] .pager .dt-more-container.load-more',this.injectDocuments.bind(this)),p(document).on("click",'.bp-nouveau [data-bp-list="document"] .data-head',this.sortDocuments.bind(this)),p(document).on("click",".modal-container .bb-field-steps-actions",this.documentPopupNavigate.bind(this)),p(document).on("click",".bp-media-document-uploader .modal-container .bb-field-uploader-actions",this.uploadDocumentNavigate.bind(this)),p(document).on("click",".bp-media-photo-uploader .modal-container .bb-field-uploader-actions",this.uploadMediaNavigate.bind(this)),p(document).on("click",".modal-container #bp-media-edit-child-folder-submit",this.renameChildFolder.bind(this)),p(document).on("click",".activity .bp-media-move-activity, #media-stream .bp-media-move-activity",this.moveMediaIntoAlbum.bind(this)),p("#bb-media-model-container .activity-list, #media-stream")),e="#buddypress .activity-list",i='#buddypress [data-bp-list="activity"]',a="#bb-media-model-container .activity-list",o="#media-stream",e=(p(document).on("click",e+" .ac-document-move, "+i+" .ac-document-move, "+e+" .ac-folder-move, "+i+" .ac-folder-move, "+a+" .ac-document-move, "+a+" .ac-folder-move, "+o+" .ac-document-move, "+o+" .ac-folder-move",this.openDocumentMove.bind(this)),p(document).on("click",e+" .ac-media-move, "+i+" .ac-media-move, "+a+" .ac-media-move, "+o+" .ac-media-move, .group-media "+o+" .ac-media-move",this.openMediaMove.bind(this)),p(document).on("click",e+" .ac-document-close-button, "+i+" .ac-document-close-button, "+e+" .ac-folder-close-button, "+i+" .ac-folder-close-button, "+a+" .ac-document-close-button, "+a+" .ac-folder-close-button, "+o+" .ac-document-close-button, "+o+" .ac-folder-close-button",this.closeDocumentMove.bind(this)),p(document).on("click",e+" .ac-media-close-button, "+i+" .ac-media-close-button, "+a+" .ac-media-close-button, "+o+" .ac-media-close-button",this.closeMediaMove.bind(this)),t.on("click",".ac-document-rename",this.renameDocument.bind(this)),t.on("click",".ac-document-privacy",this.editPrivacyDocument.bind(this)),t.on("keyup",".media-folder_name_edit",this.renameDocumentSubmit.bind(this)),t.on("click",".name_edit_cancel, .name_edit_save",this.renameDocumentSubmit.bind(this)),p(document).on("click",".document-file-delete",this.deleteDocument.bind(this)),p(document).on("click",".media-file-delete",this.deleteMedia.bind(this)),p(document).on("click",".bp-folder-move",this.folderMove.bind(this)),p(document).on("click",".bp-document-open-create-popup-folder",this.createFolderInPopup.bind(this)),p(document).on("click",".bp-media-open-create-popup-folder",this.createAlbumInPopup.bind(this)),p(document).on("click",".close-create-popup-folder",this.closeCreateFolderInPopup.bind(this)),p(document).on("click",".close-create-popup-album",this.closeCreateAlbumInPopup.bind(this)),p(document).on("click",".bp-document-create-popup-folder-submit",this.submitCreateFolderInPopup.bind(this)),p(document).on("click",".bp-media-create-popup-album-submit",this.submitCreateAlbumInPopup.bind(this)),p(".buddypress.groups.messages")),i=p(".buddypress.groups.messages form#send_group_message_form #whats-new-toolbar"),a=p(".buddypress.groups.messages form#send_group_message_form #whats-new-attachments .bp-group-messages-attached-gif-container .gif-search-results"),o=p(".buddypress.groups.messages form#send_group_message_form #whats-new-attachments .bp-group-messages-attached-gif-container");e.on("click","#bp-group-messages-media-button",this.openGroupMessagesUploader.bind(this)),e.on("click","#bp-group-messages-document-button",this.openGroupMessagesDocumentUploader.bind(this)),e.on("click","#bp-group-messages-video-button",this.openGroupMessagesVideoUploader.bind(this)),e.on("click","#bp-group-messages-gif-button",this.toggleGroupMessagesGifSelector.bind(this)),i.on("keyup",".search-query-input",this.searchGroupMessagesGif.bind(this)),i.on("click",".found-media-item",this.selectGroupMessagesGif.bind(this)),a.scroll(this.loadMoreGroupMessagesGif.bind(this)),p(".groups.messages form#send_group_message_form #whats-new-toolbar .bp-group-messages-attached-gif-container .gif-search-results").scroll(this.loadMoreGroupMessagesGif.bind(this)),o.on("click",".gif-image-remove",this.removeGroupMessagesSelectedGif.bind(this)),p(".bp-existing-media-wrap").on("scroll",this.loadExistingMedia.bind(this)),document.addEventListener("keyup",this.closePopup.bind(this)),document.addEventListener("keyup",this.submitPopup.bind(this)),p(window).bind("beforeunload",this.beforeunloadWindow.bind(this)),_.isUndefined(BP_Nouveau.media.gif_api_key)||(window.addEventListener("scroll",this.throttledAutoPlayGifVideos.bind(this),!1),window.addEventListener("resize",this.throttledAutoPlayGifVideos.bind(this),!1),(t=p("#bp-message-thread-list")).length&&t.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),(e=p(".bb-modal-activity-body")).length&&e.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),(i=p(".bb-media-model-container .activity-list .activity-item")).length&&i.on("scroll",this.throttledAutoPlayGifVideos.bind(this)),p(document).on("scroll","#bp-message-thread-list",this.throttledAutoPlayGifVideos.bind(this)),p(document).on("scroll",".bb-modal-activity-body",this.throttledAutoPlayGifVideos.bind(this)),p(document).on("scroll",".bb-media-model-container .activity-list .activity-item",this.throttledAutoPlayGifVideos.bind(this)),setTimeout(function(){var e=document.getElementById("bp-message-thread-list"),e=(e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1),document.querySelector(".bb-modal-activity-body")),e=(e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1),document.querySelector(".bb-media-model-container .activity-list .activity-item"));e&&e.addEventListener("scroll",bp.Nouveau.Media.throttledAutoPlayGifVideos.bind(bp.Nouveau.Media),!1)},1e3),p(window).on("load",function(){setTimeout(function(){void 0!==bp.Nouveau.Media&&"function"==typeof bp.Nouveau.Media.autoPlayGifVideos&&bp.Nouveau.Media.autoPlayGifVideos()},300)}),document.addEventListener("keydown",_.bind(this.closePickersOnEsc,this)),p(document).on("click",_.bind(this.closePickersOnClick,this))),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_media.length||this.bbp_topic_edit_media.length||this.bbp_forum_edit_media.length)&&p("#forums-media-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_document.length||this.bbp_topic_edit_document.length||this.bbp_forum_edit_document.length)&&p("#forums-document-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(this.bbp_reply_edit_video.length||this.bbp_topic_edit_video.length||this.bbp_forum_edit_video.length)&&p("#forums-video-button").trigger("click"),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(Object.keys(this.bbp_reply_edit_gif_data).length||Object.keys(this.bbp_topic_edit_gif_data).length||Object.keys(this.bbp_forum_edit_gif_data).length)&&(this.editGifPreview(),(a=jQuery("#forums-gif-button").addClass("active").closest("form")).find("#forums-document-button")&&a.find("#forums-document-button").parents(".post-elements-buttons-item").addClass("disable"),a.find("#forums-media-button")&&a.find("#forums-media-button").parents(".post-elements-buttons-item").addClass("disable"),a.find("#forums-video-button"))&&a.find("#forums-video-button").parents(".post-elements-buttons-item").addClass("disable"),"#openEditFolder"==window.location.hash&&p("#bp-media-edit-child-folder").length&&(history.pushState(null,null,window.location.href.split("#")[0]),p("#bp-media-edit-child-folder").show()),(this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit)&&(bp.Nouveau.Media.reply_topic_allow_delete_media=!0)},updateAlbumCounts:function(e){var t,i,a,o;p("#buddypress #bp-media-single-album").length&&(o=parseInt(e.album_media_count)||0,e=parseInt(e.album_video_count)||0,t=function(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},0<(a=p("#buddypress .bb-album-photo-count")).length&&(i=1===o?BP_Nouveau.media.i18n_strings.photo:BP_Nouveau.media.i18n_strings.photos,a.text(t(o)+" "+i)),0<(a=p("#buddypress .bb-album-video-count")).length)&&(o=1===e?BP_Nouveau.media.i18n_strings.video:BP_Nouveau.media.i18n_strings.videos,a.text(t(e)+" "+o))},loadExistingMedia:function(){p(window).scroll()},resetPageDocumentDirectory:function(e){e.preventDefault(),this.current_page=1},submitCreateFolderInPopup:function(e){e.preventDefault();var i=p(e.currentTarget).closest(".open-popup"),a=p(i).find(".bp-document-create-popup-folder-submit"),t=i.find(".bb-folder-selected-id").val(),o=p.trim(p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder-title").val()),d=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder-title"),s=/[\\/?%*:|"<>]+/g.exec(d.val()),s=Boolean(s);if(""===p.trim(d.val())||s)return d.addClass("error"),!1;d.removeClass("error"),this.currentTargetParent=t=""===t?0:t;var n=this.currentTargetParent,r=0,l="",c="",u=0;if("group"===this.moveToTypePopup?(l="grouponly",r=this.moveToIdPopup):(l=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder #bb-folder-privacy").val(),c=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-folder #bb-folder-privacy")),""===o)return alert(BP_Nouveau.media.create_folder_error_title),!1;a.addClass("loading"),setTimeout(function(){var e={action:"document_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:o,privacy:l,parent:n,group_id:r};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,async:!1,success:function(e){var t;e.success&&(p(".document-data-table-head").length&&parseInt(n)===parseInt(BP_Nouveau.media.current_folder)&&(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()),i.find(".location-folder-list-wrap .location-folder-list").remove(),i.find(".location-folder-list-wrap").append(e.data.tree_view),t="#"+p(i).attr("id")+".open-popup",bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,e.data.folder_id),u=e.data.folder_id,(""===e.data.tree_view?(i.find(".location-folder-list-wrap").hide(),i.find(".location-folder-list-wrap-main span.no-folder-exists")):(i.find(".location-folder-list-wrap-main span.no-folder-exists").hide(),i.find(".location-folder-list-wrap"))).show(),i.find("ul.location-folder-list span#"+u).trigger("click"),i.find(".bb-model-footer").show(),i.find(".bb-model-footer, #bp-media-document-prev").show(),i.find(".bb-field-wrap-search").show(),i.find(".bp-document-open-create-popup-folder").show(),i.find(".location-folder-list-wrap-main").show(),i.find(".create-popup-folder-wrap").hide(),i.find(".bb-folder-selected-id").val(),i.find(".bb-folder-selected-id").val(u),i.find(".bb-model-header").children().show(),i.find(".bb-model-header p").hide(),d.val(""),""!==c&&c.val("public"),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(i).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),a.removeClass("loading"),setTimeout(function(){var e=i.find("ul.location-folder-list span#"+u),t=(e.trigger("click"),p(i).find("#bb-document-privacy"));0!==Number(e.data("id"))?(t.find("option").removeAttr("selected"),t.val(e.parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1))},200))}}),this.currentTargetParent=u,i.find(".location-folder-list li.is_active").show().children("span, i").show().siblings("ul").hide(),i.find(".location-folder-list li.is_active").siblings("li").show().children("span, i").show().siblings("ul").hide(),i.find(".location-folder-list li span.selected").removeClass("selected"),i.find(".location-folder-list li.is_active").children("span").addClass("selected")},0)},submitCreateAlbumInPopup:function(e){e.preventDefault();var t=this,i=p(e.currentTarget).closest(".open-popup"),a=p(i).find(".bp-media-create-popup-album-submit"),o=i.find(".bb-album-selected-id").val(),d=(this.currentTargetParent=o=""===o?0:o,this.currentTargetParent),s=0,n=p.trim(p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album-title").val()),r=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album-title"),l="",c="",u=0;if("group"===this.moveToTypePopup?(l="grouponly",s=this.moveToIdPopup):(l=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album #bb-album-privacy").val(),c=p(e.currentTarget).closest(".modal-container").find(".popup-on-fly-create-album #bb-album-privacy")),""===n)return alert(BP_Nouveau.media.create_album_error_title),!1;a.addClass("loading"),setTimeout(function(){var e={action:"media_album_save",_wpnonce:BP_Nouveau.nonces.media,title:n,privacy:l,parent:d,group_id:s};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,async:!1,success:function(e){e.success&&(i.find(".location-album-list-wrap .location-album-list").remove(),i.find(".location-album-list-wrap").append(e.data.tree_view),bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(i,e.data.album_id),u=e.data.album_id,(""===e.data.tree_view?(i.find(".location-album-list-wrap").hide(),i.find(".location-album-list-wrap-main span.no-album-exists")):(i.find(".location-album-list-wrap-main span.no-album-exists").hide(),i.find(".location-album-list-wrap"))).show(),i.find("ul.location-album-list span#"+u).trigger("click"),i.find(".bb-model-footer").show(),i.find(".bb-field-wrap-search").show(),i.find(".bp-media-open-create-popup-album").show(),i.find(".location-album-list-wrap-main").show(),i.find(".create-popup-album-wrap").hide(),i.find(".bb-field-steps-2 #bp-media-prev").show(),i.find(".bb-album-selected-id").val(),i.find(".bb-album-selected-id").val(u),i.find(".bb-model-header").children().show(),i.find(".bb-model-header p").hide(),r.val(""),""!==c&&c.val("public"),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(i).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(i).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),t.updateAlbumNavCount(e.data.album_count)),a.removeClass("loading")}}),this.currentTargetParent=u,i.find(".location-album-list li.is_active").show().children("span, i").show().siblings("ul").hide(),i.find(".location-album-list li.is_active").siblings("li").show().children("span, i").show().siblings("ul").hide(),i.find(".location-album-list li span.selected").removeClass("selected"),i.find(".location-album-list li.is_active").children("span").addClass("selected")},0)},closeCreateFolderInPopup:function(e){e.preventDefault(),p(".modal-container .bb-model-footer").show(),p(".bb-field-wrap-search").show(),p(".bp-document-open-create-popup-folder").show(),p(".location-folder-list-wrap-main").show(),p("#bp-media-document-prev").show(),p(".create-popup-folder-wrap").hide(),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header").children().show(),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header p").hide()},closeCreateAlbumInPopup:function(e){e.preventDefault(),p(".modal-container .bb-model-footer").show(),p(".bb-field-wrap-search").show(),p(".bp-document-open-create-popup-folder").show(),p(".modal-container:visible .bp-video-open-create-popup-album").show(),p(".location-album-list-wrap-main").show(),p(".bb-field-steps-2 #bp-media-prev").show(),p(".bb-field-steps-2 #bp-video-next").show(),p(".create-popup-album-wrap").hide(),p(".bp-media-create-popup-album-submit.loading").removeClass("loading"),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header").children().show(),p(e.currentTarget).closest(".has-folderlocationUI").find(".bb-model-header p").hide()},createFolderInPopup:function(e){e.preventDefault();var t=parseInt(p(document).find(".open-popup .bb-folder-selected-id").val()),i=p(document).find(".open-popup .bb-folder-create-from").val();0 "+BP_Nouveau.media.create_folder+" "+BP_Nouveau.media.create_album_title+" '+e.data.media_personal_count+" "+t)):p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count)),void 0!==e.data&&void 0!==e.data.media_group_count&&0 '+e.data.media_group_count+" "+t)):p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):r.find(".media-list:not(.existing-media-list)")).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):r.find(".media-list:not(.existing-media-list)")).html(e.data.group_media_html_content):p.each(n,function(e,t){p('#media-stream ul.media-list li[data-id="'+t+'"]').length&&p('#media-stream ul.media-list li[data-id="'+t+'"]').remove()}),void 0!==e.data.album_total_count&&s.updateAlbumCounts(e.data))):(setTimeout(function(){d.prop("disabled",!1)},500),e.success?(void 0!==e.data&&void 0!==e.data.media_personal_count&&0
'+e.data.media_personal_count+" "+t)):p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count)),void 0!==e.data&&void 0!==e.data.media_group_count&&0
'+e.data.media_group_count+" "+t)):p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count)),(i=r.find(".media-list:not(.existing-media-list)")).find('.bb-media-check-wrap [name="bb-media-select"]:checked').each(function(){p(this).closest("li").remove()}),i.parent().parent().hasClass("album-single-view")&&i.find('.bb-video-check-wrap [name="bb-video-select"]:checked').each(function(){p(this).closest("li").remove()}),0!==e.data.media_html_content.length?(0===parseInt(e.data.media_personal_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):i).html(e.data.media_html_content):0!==e.data.group_media_html_content.length?(0===parseInt(e.data.media_group_count)?(p(".bb-photos-actions").hide(),p("#media-stream")):i).html(e.data.group_media_html_content):p.each(n,function(e,t){p('#media-stream ul.media-list li[data-id="'+t+'"]').length&&p('#media-stream ul.media-list li[data-id="'+t+'"]').remove()}),void 0!==e.data.album_total_count&&s.updateAlbumCounts(e.data)):p("#buddypress #media-stream.media").prepend(e.data.feedback));var t,i,a=p(".bp-nouveau #bb-select-deselect-all-media");a.hasClass("selected")&&a.removeClass("selected"),jQuery(window).scroll()}})},toggleSelectAllMedia:function(e){e.preventDefault(),p(e.currentTarget).hasClass("selected")?(p(e.currentTarget).data("bp-tooltip",BP_Nouveau.media.i18n_strings.selectall),this.deselectAllMedia(e)):(p(e.currentTarget).data("bp-tooltip",BP_Nouveau.media.i18n_strings.unselectall),this.selectAllMedia(e)),p(e.currentTarget).toggleClass("selected")},selectAllMedia:function(e){e.preventDefault();e=p("#buddypress").find(".media-list:not(.existing-media-list)");e.find('.bb-media-check-wrap [name="bb-media-select"]').each(function(){p(this).prop("checked",!0),p(this).closest(".bb-item-thumb").addClass("selected"),p(this).closest(".bb-media-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.unselect)}),e.parent().parent().hasClass("album-single-view")&&e.find('.bb-video-check-wrap [name="bb-video-select"]').each(function(){p(this).prop("checked",!0),p(this).closest(".bb-item-thumb").addClass("selected"),p(this).closest(".bb-video-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.unselect)})},deselectAllMedia:function(e){e.preventDefault();e=p("#buddypress").find(".media-list:not(.existing-media-list)");e.find('.bb-media-check-wrap [name="bb-media-select"]').each(function(){p(this).prop("checked",!1),p(this).closest(".bb-item-thumb").removeClass("selected"),p(this).closest(".bb-media-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.select)}),e.parent().parent().hasClass("album-single-view")&&e.find('.bb-video-check-wrap [name="bb-video-select"]').each(function(){p(this).prop("checked",!1),p(this).closest(".bb-item-thumb").removeClass("selected"),p(this).closest(".bb-video-check-wrap").find(".bp-tooltip").attr("data-bp-tooltip",BP_Nouveau.media.i18n_strings.select)})},editAlbumTitle:function(e){e.preventDefault(),p("#bb-album-title").show(),p("#bp-save-album-title").show(),p("#bp-cancel-edit-album-title").show(),p("#bp-edit-album-title").hide(),p("#bp-media-single-album #bp-single-album-title").hide()},editFolderTitle:function(e){e.preventDefault(),p("#bb-album-title").show(),p("#bp-save-folder-title").show(),p("#bp-cancel-edit-album-title").show(),p("#bp-edit-folder-title").hide(),p("#bp-media-single-album #bp-single-album-title").hide()},cancelEditAlbumTitle:function(e){e.preventDefault(),p("#bb-album-title").removeClass("error").hide(),p("#bp-save-album-title,#bp-save-folder-title").hide(),p("#bp-cancel-edit-album-title").hide(),p("#bp-edit-album-title,#bp-edit-folder-title").show(),p("#bp-media-single-album #bp-single-album-title").show()},triggerDropzoneSelectFileDialog:function(){this.dropzone_obj.hiddenFileInput.click()},closeUploader:function(e){e.preventDefault(),p("#bp-media-uploader").hide(),p("#bp-media-add-more").hide(),p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),p("#bp-media-uploader-modal-status-text").text(""),p("#bp-media-post-content").val(""),p("#bp-dropzone-content .bp-feedback").remove(),this.dropzone_obj.element&&this.dropzone_obj.destroy(),this.dropzone_media=[];var t=p(e.currentTarget).closest("#bp-media-uploader");p(".close-create-popup-album").trigger("click"),p(".close-create-popup-folder").trigger("click"),t.find('.breadcrumbs-append-ul-li .item span[data-id="0"]').trigger("click"),t.find(".bb-field-steps").length&&(t.find(".bb-field-steps-1").show().siblings(".bb-field-steps-2").hide(),t.find(".bb-field-steps-1 #bp-media-photo-next, .bb-field-steps-1 #bp-media-document-next ").hide(),t.find(".bb-field-steps-1").removeClass("controls-added"),t.find("#bp-media-document-prev, #bp-media-prev, #bp-media-document-submit, #bp-media-submit, .bp-media-open-create-popup-folder, .bp-document-open-create-popup-folder, .create-popup-folder-wrap, .create-popup-album-wrap, .bp-video-open-create-popup-album").hide()),this.clearFolderLocationUI(e)},closeChildFolderUploader:function(e){e.preventDefault(),p(document).find(".open-popup #bb-album-child-title").val(""),p(document).find(".open-popup #bp-media-create-child-folder-submit").removeClass("loading"),p(document).find("#bp-media-create-child-folder").removeClass("open-popup"),p(document).find("#bp-media-create-child-folder").hide(),p(document).find(".open-popup #bb-album-title").text(""),p(document).find(".open-popup #bp-media-create-folder").hide(),p(document).find("#bp-media-create-folder").removeClass("open-popup")},closeFolderUploader:function(e){e.preventDefault(),p(document).find(".open-popup #bb-album-title").val(""),p(document).find(".open-popup #bp-media-create-folder-submit").removeClass("loading"),p(document).find(".open-popup #bp-media-document-submit").hide(),p(document).find("#bp-media-create-folder").removeClass("open-popup"),p(document).find("#bp-media-create-folder").hide()},loadMoreGif:function(e){var t=e.target,i=this,e=p(e.target).closest("form").find(".forums-attached-gif-container"),a=e.data("key");i.gif_container_key=a,t.scrollTop+t.offsetHeight>=t.scrollHeight&&!e.hasClass("loading")&&0
=t.scrollHeight&&!p(e.target).closest(".bp-group-messages-attached-gif-container").hasClass("loading")&&0 \n\t\n\t\t \n\t\n',e.data[t].saved=!1,this.gif_data.push(e.data[t])}p(".bp-group-messages-attached-gif-container").find(".gif-search-results-list").append(i)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(this.gif_total_count=e.pagination.total_count)},loadMoreGifResponse:function(e){var t=this,i=0;if(p('div.forums-attached-gif-container[data-key="'+t.gif_container_key+'"]').removeClass("loading"),void 0!==e.data&&e.data.length){for(var a="",i=0;i
\n\t\n\t\t \n\t\n',e.data[i].saved=!1,t.gif_data[t.gif_container_key].data.push(e.data[i])}p('div.forums-attached-gif-container[data-key="'+t.gif_container_key+'"]').closest("form").find(".gif-search-results-list").append(a)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(t.gif_data[t.gif_container_key].total_count=e.pagination.total_count)},editGifPreview:function(){var e=this,t={};if(e.bbp_is_reply_edit&&Object.keys(e.bbp_reply_edit_gif_data).length?t=e.bbp_reply_edit_gif_data.gif_raw_data:e.bbp_is_topic_edit&&Object.keys(e.bbp_topic_edit_gif_data).length?t=e.bbp_topic_edit_gif_data.gif_raw_data:e.bbp_is_forum_edit&&Object.keys(e.bbp_forum_edit_gif_data).length&&(t=e.bbp_forum_edit_gif_data.gif_raw_data),void 0===t.images)return!1;e=p("#whats-new-attachments .forums-attached-gif-container");e[0].style.backgroundImage="url("+t.images.fixed_width.url+")",e[0].style.backgroundSize="contain",e[0].style.height=t.images.original.height+"px",e[0].style.width=t.images.original.width+"px",e.find(".gif-image-container img").attr("src",t.images.original.url),e.removeClass("closed"),p("#bbp_media_gif").length&&p("#bbp_media_gif").val(JSON.stringify(t))},selectGif:function(e){var t=this,i=0,a=p(e.currentTarget),o=a.closest("form").find(".forums-attached-gif-container"),d=(e.preventDefault(),o.closest("form").find(".gif-media-search-dropdown").removeClass("open"),o.data("key"));if(void 0!==t.gif_data[d]&&void 0!==t.gif_data[d].data&&t.gif_data[d].data.length){for(i=0;i
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,s.gif_data.push(e.data[n])}p(d.target).closest(".bp-group-messages-attached-gif-container").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(s.gif_total_count=e.pagination.total_count),p(d.target).closest(".bp-group-messages-attached-gif-container").removeClass("loading")},function(){p(d.target).find(".gif-no-connection").addClass("show")}));s.gif_requests.push(e),s.gif_offset=s.gif_offset+s.gif_limit},searchGifRequest:function(d){var s=this,n=0,r=p(d.target).closest("form").find(".forums-attached-gif-container"),l=(r.addClass("loading"),r.data("key")),e=(p(d.target).closest("form").find(".gif-no-results").removeClass("show"),p(d.target).closest("form").find(".gif-no-connection").removeClass("show"),s.clearGifRequests(l),s.gif_data[l].q=d.target.value,s.gif_data[l].offset=0,s.giphy.search({q:s.gif_data[l].q,offset:s.gif_data[l].offset,fmt:"json",limit:s.gif_data[l].limit},function(e){if(void 0!==e.data.length&&0===e.data.length&&p(d.target).closest("form").find(".gif-no-results").addClass("show"),void 0!==e.meta.status&&200!==e.meta.status&&p(d.target).closest("form").find(".gif-no-connection").addClass("show"),void 0!==e.data&&e.data.length){var t="";for(n=0;n
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,s.gif_data[l].data.push(e.data[n])}p(d.target).closest(".gif-search-content").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(s.gif_data[l].total_count=e.pagination.total_count),r.removeClass("loading")},function(){p(d.target).closest("form").find(".gif-no-connection").addClass("show")}));s.gif_data[l].requests.push(e),s.gif_data[l].offset=s.gif_data[l].offset+s.gif_data[l].limit},clearGifRequests:function(e){var t=this;if(void 0!==t.gif_data[e]&&void 0!==t.gif_data[e].requests){for(var i=0;i
\n\t\n\t\t \n\t\n',e.data[l].saved=!1,n.gif_data[s].data.push(e.data[l])}r.closest("form").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(n.gif_data[s].total_count=e.pagination.total_count),d.removeClass("loading")}),n.gif_data[s].requests.push(e),n.gif_data[s].offset=n.gif_data[s].offset+n.gif_data[s].limit),t.toggleClass("open"),r.parents("form").find("#whats-new-attachments .forums-attached-gif-container img")),t=(0
\n\t\n\t\t \n\t\n',e.data[n].saved=!1,d.gif_data.push(e.data[n])}s.closest("form").find(".gif-search-results-list").append(t)}void 0!==e.pagination&&void 0!==e.pagination.total_count&&(d.gif_total_count=e.pagination.total_count),p(".gif-search-query").closest(".bp-group-messages-attached-gif-container").removeClass("loading")}),d.gif_requests.push(e),d.gif_offset=d.gif_offset+d.gif_limit),s.parents("form").find("#whats-new-attachments .bp-group-messages-attached-gif-container img"));0
"),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),a.dropzone_obj[n].on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=p(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.album_id=a.album_id,t.data.group_id=a.group_id,t.data.saved=!1,a.dropzone_media[n].push(t.data),a.addMediaIdsToForumsForm(d)):(jQuery(".forum-media-error-popup").length||p("body").append('"),this.removeFile(e))}),a.dropzone_obj[n].on("removedfile",function(e){if(!0===bp.Nouveau.Media.reply_topic_allow_delete_media){if(a.dropzone_media[n].length)for(var t in a.dropzone_media[n])if(e.upload.uuid==a.dropzone_media[n][t].uuid){this.bbp_is_reply_edit||this.bbp_is_topic_edit||this.bbp_is_forum_edit||void 0===a.dropzone_media[n][t].saved||a.dropzone_media[n][t].saved||"edit"!==bp.Nouveau.Media.reply_topic_display_post||a.removeAttachment(a.dropzone_media[n][t].id),a.dropzone_media[n].splice(t,1),a.addMediaIdsToForumsForm(d);break}var i;_.isNull(a.dropzone_obj[n].files)||0!==a.dropzone_obj[n].files.length||((i=o.closest("form")).find("#forums-document-button")&&i.find("#forums-document-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-video-button")&&i.find("#forums-video-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-gif-button")&&i.find("#forums-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#forums-media-button")&&i.find("#forums-media-button").parents(".post-elements-buttons-item").removeClass("no-click"))}_.isNull(a.dropzone_obj[n].files)||0!==a.dropzone_obj[n].files.length||o.closest("form").removeClass("has-media")}),a.dropzone_obj[n].on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0 "),this.removeFile(e))}),a.dropzone_obj.on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=p(e.previewElement).closest(".dropzone").find(e.previewElement).index()-1,t.data.album_id=a.album_id,t.data.group_id=a.group_id,t.data.saved=!1,a.dropzone_media.push(t.data),a.addMediaIdsToGroupMessagesForm()):(jQuery(".group-message-error-popup").length||p("body").append('"),this.removeFile(e))}),a.dropzone_obj.on("removedfile",function(e){if(a.dropzone_media.length)for(var t in a.dropzone_media)if(e.upload.uuid==a.dropzone_media[t].uuid){void 0===a.dropzone_media[t].saved||a.dropzone_media[t].saved||a.removeAttachment(a.dropzone_media[t].id),a.dropzone_media.splice(t,1),a.addMediaIdsToGroupMessagesForm();break}var i;_.isNull(a.dropzone_obj.files)||0!==a.dropzone_obj.files.length||((i=p("#send_group_message_form")).find("#bp-group-messages-document-button")&&i.find("#bp-group-messages-document-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-video-button")&&i.find("#bp-group-messages-video-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-gif-button")&&i.find("#bp-group-messages-gif-button").parents(".post-elements-buttons-item").removeClass("disable"),i.find("#bp-group-messages-media-button")&&i.find("#bp-group-messages-media-button").parents(".post-elements-buttons-item").removeClass("no-click"))}),t.removeClass("closed").addClass("open"),a.resetGroupMessagesGifComponent(),a.resetGroupMessagesDocumentComponent(),a.resetGroupMessagesVideoComponent()):a.resetGroupMessagesMediaComponent())},openGroupMessagesDocumentUploader:function(e){var l=this,t=p("div#bp-group-messages-post-document-uploader"),i=p(e.currentTarget);e.preventDefault(),i.toggleClass("active"),void 0!==window.Dropzone&&t.length&&(t.hasClass("closed")?(l.document_dropzone_obj=new Dropzone("div#bp-group-messages-post-document-uploader",l.documentOptions),l.document_dropzone_obj.on("addedfile",function(){}),l.document_dropzone_obj.on("sending",function(e,t,i){i.append("action","document_document_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media);i=p("#send_group_message_form");i.find("#bp-group-messages-media-button")&&i.find("#bp-group-messages-media-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-video-button")&&i.find("#bp-group-messages-video-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-gif-button")&&i.find("#bp-group-messages-gif-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#bp-group-messages-document-button")&&i.find("#bp-group-messages-document-button").parents(".post-elements-buttons-item").addClass("no-click")}),l.document_dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),l.document_dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?p(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&p(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".group-document-error-popup").length||p("body").append('"),this.removeFile(e))}),l.document_dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.document_dropzone_obj.on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e))}),r.video_dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.video.empty_video_type):t()}),r.video_dropzone_obj.on("addedfile",function(e){e.dataURL||bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),r.video_dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);e.upload.progress<=99?(p(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,p(e.previewElement).find(".dz-progress-count").text("99% "+BP_Nouveau.video.i18n_strings.video_uploaded_text))}),r.video_dropzone_obj.on("success",function(e,t){if(100===e.upload.progress&&(p(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,p(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),p(e.previewElement).closest(".dz-preview").addClass("dz-complete")),!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),l.dropzone_obj[u].on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.dropzone_obj[u].on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a "),this.removeFile(e),o.closest("form").removeClass("media-uploading"))}),l.dropzone_obj[u].on("accept",function(e,t){0==e.size?t(BP_Nouveau.video.empty_video_type):t()}),l.dropzone_obj[u].on("addedfile",function(e){e.dataURL&&e.dataThumb&&e.dataThumb.length?p(e.previewElement).find(".dz-video-thumbnail").prepend(' '):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),l.dropzone_obj[u].on("uploadprogress",function(e){o.closest("form").addClass("media-uploading");var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,a=(t.style.strokeDasharray=i+" "+i,i-e.upload.progress.toFixed(0)/100*i);e.upload.progress<=99?(p(e.previewElement).find(".dz-progress-count").text(e.upload.progress.toFixed(0)+"% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),t.style.strokeDashoffset=a):100===e.upload.progress&&(t.style.strokeDashoffset=i-.99*i,p(e.previewElement).find(".dz-progress-count").text("99% "+BP_Nouveau.video.i18n_strings.video_uploaded_text))}),l.dropzone_obj[u].on("success",function(e,t){if(100===e.upload.progress&&(p(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,p(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),p(e.previewElement).closest(".dz-preview").addClass("dz-complete")),!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a
'+p(this).text()+""),p(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val(p(e.currentTarget).data("id")),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),0!==Number(p(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(p(e.currentTarget).parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),p(document).on("click",t+" .breadcrumb .item > span",function(e){var t,i;p(this).hasClass("is-disabled")||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val(0),p(e.currentTarget).closest(".bb-field-wrap").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-media-privacy"),i=p(e.currentTarget).closest("#bp-media-uploader").find(".location-album-list li.is_active").data("privacy"),0!==Number(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-album-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),e=document.getElementsByClassName("uploader-post-media-template").length?document.getElementsByClassName("uploader-post-media-template")[0].innerHTML:"",i.options.previewTemplate=e,i.dropzone_obj=new Dropzone("div#media-uploader",i.options),i.dropzone_obj.on("sending",function(e,t,i){i.append("action","media_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media)}),i.dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),i.dropzone_obj.on("addedfile",function(){setTimeout(function(){i.dropzone_obj.getAcceptedFiles().length&&p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),i.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?p(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&p(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".media-error-popup").length||p("body").append('"),this.removeFile(e))}),i.dropzone_obj.on("queuecomplete",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),p(".bb-field-steps-1 #bp-media-photo-next, #bp-media-submit, #bp-media-create-album-submit").show()}),i.dropzone_obj.on("processing",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),p(".bb-field-steps-1 #bp-media-photo-next, #bp-media-submit, #bp-media-create-album-submit").hide()}),i.dropzone_obj.on("success",function(e,t){t.data.id?(e.id=t.id,t.data.uuid=e.upload.uuid,t.data.menu_order=i.dropzone_media.length,t.data.album_id=i.album_id,t.data.group_id=i.group_id,t.data.saved=!1,i.dropzone_media.push(t.data)):(jQuery(".media-error-popup").length||p("body").append('"),this.removeFile(e)),p(".modal-container").addClass("modal-container--alert"),p(".bb-field-steps-1").addClass("controls-added"),p("#bp-media-add-more").show(),p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show()}),i.dropzone_obj.on("removedfile",function(e){if(i.dropzone_media.length)for(var t in i.dropzone_media)if(e.upload.uuid==i.dropzone_media[t].uuid){void 0===i.dropzone_media[t].saved||i.dropzone_media[t].saved||i.removeAttachment(i.dropzone_media[t].id),i.dropzone_media.splice(t,1);break}i.dropzone_obj.getAcceptedFiles().length?p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,i.dropzone_media.length,i.dropzone_obj.getAcceptedFiles().length)).show():(p("#bp-media-uploader-modal-status-text").text(""),p("#bp-media-add-more, #bp-media-photo-next").hide(),p(".bb-field-steps-1").removeClass("controls-added"),p("#bp-media-submit").hide(),p(".modal-container").removeClass("modal-container--alert"))}))},openDocumentUploader:function(e){var a,t,l=this;e.preventDefault(),void 0!==window.Dropzone&&p("div#media-uploader").length&&(p("#bp-media-uploader").hasClass("bp-media-document-uploader")&&!this.currentTargetParent&&(this.currentTargetParent=0),p(e.currentTarget).closest("#bp-media-single-folder").length&&p("#bb-document-privacy").hide(),p(document).removeClass("open-popup"),p("#bp-media-uploader").show(),p("#bp-media-uploader").addClass("open-popup"),p("#bp-media-uploader.bp-media-document-uploader").find(".bb-field-steps.bb-field-steps-2").length&&(t="#bp-media-uploader.bp-media-document-uploader",0!==Number(p(t).find(".bb-folder-selected-id").data("value"))?(a=p(t).find(".bb-folder-selected-id").data("value"),p(t).find("#bb-document-privacy").prop("disabled",!0)):a=0,""!==this.moveToIdPopup)&&p.ajax({url:BP_Nouveau.ajaxurl,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:BP_Nouveau.nonces.media},success:function(e){p(document).find(".bp-media-document-uploader .location-folder-list-wrap h4 span.where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap").hide(),p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap-main span.no-folder-exists")):(p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap-main span.no-folder-exists").hide(),p(document).find(".bp-media-document-uploader.open-popup .location-folder-list-wrap"))).show(),p(document).find(".bp-media-document-uploader .popup-on-fly-create-album .privacy-field-wrap-hide-show").show(),p(document).find(".bp-media-document-uploader .open-popup .bb-folder-create-from").val("profile"),p(t).find(".location-folder-list-wrap .location-folder-list").remove(),p(t).find(".location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&bp.Nouveau.Media.folderLocationUI(t,a),p(t).find("ul.location-folder-list span#"+a).trigger("click"),p(t).find(".bb-folder-selected-id").val(a)}}),p(document).on("click",t+" .location-folder-list li span",function(e){var t;e.preventDefault(),p(this).parent().hasClass("is_active")||(0!=p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item").append(''+p(this).text()+""),p(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val(p(e.currentTarget).data("id")),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),0!==Number(p(e.currentTarget).data("id"))?(t.find("option").removeAttr("selected"),t.val(p(e.currentTarget).parent().data("privacy")),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),p(document).on("click",t+" .breadcrumb .item > span",function(e){var t,i;p(this).hasClass("is-disabled")||(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val(p(e.currentTarget).data("id")),p(e.currentTarget).closest(".bb-field-wrap").find(".location-folder-list li span").removeClass("selected").parent().removeClass("is_active"),p(e.currentTarget).closest(".bb-field-wrap").find('.location-folder-list li[data-id="'+p(e.currentTarget).data("id")+'"]').addClass("is_active"),p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&p(this).closest(".location-folder-list-wrap").find(".breadcrumb .item span:last-child").remove(),a==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bb-field-wrap").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),t=p(e.currentTarget).closest("#bp-media-uploader").find("#bb-document-privacy"),i=p(e.currentTarget).closest("#bp-media-uploader").find(".location-folder-list li.is_active").data("privacy"),0!==Number(p(e.currentTarget).closest(".bb-field-wrap").find(".bb-folder-selected-id").val())?(t.find("option").removeAttr("selected"),t.val(void 0===i?"public":i),t.prop("disabled",!0)):(t.find("option").removeAttr("selected"),t.val("public"),t.prop("disabled",!1)))}),e=document.getElementsByClassName("uploader-post-document-template").length?document.getElementsByClassName("uploader-post-document-template")[0].innerHTML:"",l.options.previewTemplate=e,l.dropzone_obj=new Dropzone("div#media-uploader",l.options),l.dropzone_obj.on("sending",function(e,t,i){i.append("action","document_document_upload"),i.append("_wpnonce",BP_Nouveau.nonces.media)}),l.dropzone_obj.on("uploadprogress",function(e){var t=p(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI,e=(t.style.strokeDasharray=i+" "+i,(t.style.strokeDashoffset=i)-e.upload.progress.toFixed(0)/100*i);t.style.strokeDashoffset=e}),l.dropzone_obj.on("addedfile",function(){setTimeout(function(){l.dropzone_obj.getAcceptedFiles().length&&p("#bp-media-uploader-modal-status-text").text(wp.i18n.sprintf(BP_Nouveau.media.i18n_strings.upload_status,l.dropzone_media.length,l.dropzone_obj.getAcceptedFiles().length)).show()},1e3)}),l.dropzone_obj.on("error",function(e,t){e.accepted?void 0!==t&&void 0!==t.data&&void 0!==t.data.feedback?p(e.previewElement).find(".dz-error-message span").text(t.data.feedback):"error"==e.status&&e.xhr&&0==e.xhr.status&&p(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):(jQuery(".document-error-popup").length||p("body").append('"),this.removeFile(e))}),l.dropzone_obj.on("accept",function(e,t){0==e.size?t(BP_Nouveau.media.empty_document_type):t()}),l.dropzone_obj.on("queuecomplete",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.upload),p(".bb-field-steps-1 #bp-media-document-next, #bp-media-document-submit").show()}),l.dropzone_obj.on("processing",function(){p("#bp-media-uploader-modal-title").text(BP_Nouveau.media.i18n_strings.uploading+"..."),p(".bb-field-steps-1 #bp-media-document-next, #bp-media-document-submit").hide()}),l.dropzone_obj.on("success",function(e,t){if(!t.data.id){var i,a,o,d,s,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),s=[],a=0,o=(d=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a .activity-content .bp-media-move-file",p(o).find(".bp-document-move").attr("id",p(e.currentTarget).closest(".document-activity").attr("data-id")),0 ');var i,t,a,o,d=t,s=this.moveToTypePopup;""!==this.moveToIdPopup&&p.ajax({url:BP_Nouveau.ajaxurl,type:"post",data:{action:"media_get_album_view",id:this.moveToIdPopup,type:this.moveToTypePopup},success:function(e){p(document).find(".location-album-list-wrap h4 span.where-to-move-profile-or-group-media").html(e.data.first_span_text),(""===e.data.html?(p(document).find(".open-popup .location-album-list-wrap").hide(),p(document).find(".open-popup .location-album-list-wrap-main span.no-album-exists")):(p(document).find(".open-popup .location-album-list-wrap-main span.no-album-exists").hide(),p(document).find(".open-popup .location-album-list-wrap"))).show(),"group"===s?(p(document).find(".popup-on-fly-create-album .privacy-field-wrap-hide-show").hide(),p(document).find(".open-popup .bb-album-create-from").val("group")):(p(document).find(".popup-on-fly-create-album .privacy-field-wrap-hide-show").show(),p(document).find(".open-popup .bb-album-create-from").val("profile")),!1===e.data.create_album?(p(o+".open-popup").find(".bp-media-open-create-popup-folder").removeClass("create-album"),p(o+".open-popup").find(".bp-media-open-create-popup-folder").hide()):(p(o+".open-popup").find(".bp-media-open-create-popup-folder").addClass("create-album"),p(o+".open-popup").find(".bp-media-open-create-popup-folder").show()),p(o).find(".location-album-list-wrap .location-album-list").remove(),p(o).find(".location-album-list-wrap").append(e.data.html),p(o).find("ul.location-album-list span#"+d).trigger("click")}}),p(document).on("click",o+" .location-album-list li span",function(e){var t;e.preventDefault(),p(this).parent().hasClass("is_active")||(0!=p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").data("id")&&p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),p(this).closest(".location-album-list-wrap").find(".breadcrumb .item").append(''+p(this).text()+""),p(this).addClass("selected").parent().addClass("is_active").siblings().removeClass("is_active").children("span").removeClass("selected"),t=p(document).find('a.bb-open-media-theatre[data-id="'+i.find(".bp-media-move").attr("id")+'"]').data("album-id"),Number(t)==Number(p(e.currentTarget).data("id"))?p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"),p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").hasClass("is-disabled"))||p(e.currentTarget).closest(".bp-media-move-file").find(".bb-album-selected-id").val(p(e.currentTarget).data("id"))}),p(document).on("click",o+" .breadcrumb .item > span",function(e){p(this).hasClass("is-disabled")||(p(e.currentTarget).closest(".bp-media-move-file").find(".bb-album-selected-id").val(0),p(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list li span").removeClass("selected").parent().removeClass("is_active"),p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").hasClass("is-disabled")&&p(this).closest(".location-album-list-wrap").find(".breadcrumb .item span:last-child").remove(),d==p(e.currentTarget).data("id")?p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").addClass("is-disabled"):p(e.currentTarget).closest(".bp-media-move-file").find(".bb-model-footer .bp-media-move").removeClass("is-disabled"))})},openDocumentMove:function(e){e.preventDefault();var t,i,a,e=p(e.currentTarget),o=(e.closest(".bb-activity-media-elem").find(".document-title").text(),this.moveToIdPopup=e.attr("id"),this.moveToTypePopup=e.attr("data-type"),e.attr("data-action")),d=(p(".bp-media-move-file.open-popup, .bp-media-move-folder.open-popup").hide().removeClass("open-popup"),e.closest("#activity-modal")),s=(0===d.length&&(d=p("body")),e.closest(".conflict-activity-ul-li-comment").closest("li.comment-item").length?(i=e.closest("li.comment-item"),i=d.find("#"+i.attr("id")+".comment-item .bp-media-move-file").first()):0<(a=e.closest("li.activity-item")).length&&(i=d.find("#"+a.attr("id")+" > .activity-content .bp-media-move-file").first()),i&&0!==i.length||(e.closest(".conflict-activity-ul-li-comment").closest("li.comment-item").length?(a=e.closest("li.comment-item").attr("id"),i=d.find("#"+a+".comment-item .bp-media-move-file").first()):(a=e.closest("li.activity-item").attr("id"))&&(i=d.find("#"+a+" > .activity-content .bp-media-move-file").first())),i&&0 '),"document"===o?p(t).find(".bb-model-header h4 .target_name").text(BP_Nouveau.media.move_to_file):p(t).find(".bb-model-header h4 .target_name").text(BP_Nouveau.media.move_to_folder),p(t).show(),p(t).addClass("open-popup"),"group"===this.moveToTypePopup?(p(document).find(".location-folder-list-wrap h4").show(),p(t).addClass("move-folder-popup-group")):(p(document).find(".location-folder-list-wrap h4").hide(),p(".move-folder-popup-group").removeClass("move-folder-popup-group")),this.currentTargetParent),n=this.moveToTypePopup;""!==this.moveToIdPopup&&p.ajax({url:BP_Nouveau.ajaxurl,type:"GET",data:{action:"document_get_folder_view",id:this.moveToIdPopup,type:this.moveToTypePopup,_wpnonce:BP_Nouveau.nonces.media},success:function(e){p(document).find(".location-folder-list-wrap h4 span.where-to-move-profile-or-group-document").html(e.data.first_span_text),(""===e.data.html?(p(document).find(".open-popup .location-folder-list-wrap").hide(),p(document).find(".open-popup .location-folder-list-wrap-main span.no-folder-exists")):(p(document).find(".open-popup .location-folder-list-wrap-main span.no-folder-exists").hide(),p(document).find(".open-popup .location-folder-list-wrap"))).show(),"group"===n?(p(document).find(".popup-on-fly-create-folder .privacy-field-wrap-hide-show").hide(),p(document).find(".open-popup .bb-folder-create-from").val("group")):(p(document).find(".popup-on-fly-create-folder .privacy-field-wrap-hide-show").show(),p(document).find(".open-popup .bb-folder-create-from").val("profile")),p(t).find(".location-folder-list-wrap .location-folder-list").remove(),p(t).find(".location-folder-list-wrap").append(e.data.html),bp.Nouveau.Media.folderLocationUI&&(bp.Nouveau.Media.folderLocationUI(t,s),p(t).find("ul.location-folder-list span#"+s).trigger("click"))}})},closeMediaMove:function(e){e.preventDefault(),0!=p(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list-wrap .breadcrumb .item span:last-child").data("id")&&p(e.currentTarget).closest(".bp-media-move-file").find(".location-album-list-wrap .breadcrumb .item span:last-child").remove(),p(e.currentTarget).closest(".bp-media-move-file").hide()},closeDocumentMove:function(e){e.preventDefault();var t=p(e.currentTarget),i=jQuery(e.currentTarget).closest(".has-folderlocationUI");(t.hasClass("ac-document-close-button")?(t.closest(".bp-media-move-file"),p(".bp-media-move-file.open-popup").hide().removeClass("open-popup").find(".bp-document-move")):(t.closest(".bp-media-move-folder"),p(".bp-media-move-folder.open-popup").hide().removeClass("open-popup").find(".bp-folder-move"))).attr("id",""),i.find(".bp-document-move.loading").removeClass("loading"),this.clearFolderLocationUI(e)},renameDocument:function(e){var t=p(e.currentTarget).closest(".media-folder_items").find(".media-folder_name"),i=t.children("span").text();t.hide().siblings(".media-folder_name_edit_wrap").show().children(".media-folder_name_edit").val(i).focus().select(),e.preventDefault()},editPrivacyDocument:function(e){e.preventDefault(),p(e.currentTarget).closest("#media-folder-document-data-table").find(".media-folder_visibility .media-folder_details__bottom span").show().siblings("select").addClass("hide");var t=p(e.currentTarget).closest(".media-folder_items").find(".media-folder_visibility");t.find(".media-folder_details__bottom span").hide().siblings("select").removeClass("hide"),t.find(".media-folder_details__bottom span").hide().siblings("select").val(p(e.currentTarget).attr("data-privacy")),t.find(".media-folder_details__bottom #bb-folder-privacy").attr("data-privacy",p(e.currentTarget).attr("data-privacy")),this.privacySelectorSelect=t.find(".media-folder_details__bottom span").hide().siblings("select"),this.privacySelectorSpan=t.find(".media-folder_details__bottom span")},editPrivacyDocumentSubmit:function(e){e=p(e.currentTarget);"true"==e.attr("data-mouseup")?(e.attr("data-mouseup","false"),e.addClass("hide").siblings("span").show().text(e.find("option:selected").text())):e.attr("data-mouseup","true")},renameDocumentSubmit:function(t){var i=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name_edit"),a=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > span"),o=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name"),e=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-id").attr("data-item-id"),d=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-attachment-id").attr("data-item-id"),s=p(t.currentTarget).closest(".media-folder_items").find(".media-folder_name > i.media-document-type").attr("data-item-id"),n=i.val().trim(),r="",r=(p(t.currentTarget).closest(".ac-document-list").length?r=/[?\[\]=<>:;,'"&$#*()|~`!{}%+ \/]+/g:p(t.currentTarget).closest(".ac-folder-list").length&&(r=/[\\/?%*:|"<>]+/g),r.exec(n)),r=Boolean(r);if(r?i.addClass("error"):i.removeClass("error"),p(t.currentTarget).closest(".ac-document-list").length&&(-1!=n.indexOf("\\\\")||r?i.addClass("error"):i.removeClass("error")),!p(t.currentTarget).hasClass("name_edit_cancel")&&27!=t.keyCode||(i.removeClass("error"),i.parent().hide().siblings(".media-folder_name").show()),p(t.currentTarget).hasClass("name_edit_save")||13==t.keyCode){if(r)return;i.parent().addClass("submitting").append(''),p.ajax({url:BP_Nouveau.ajaxurl,type:"post",data:{action:"document_update_file_name",document_id:e,attachment_document_id:d,document_type:s,name:n,_wpnonce:BP_Nouveau.nonces.media},success:function(e){e.success?void 0!==e.data.document&&0 ');e.parents("li").each(function(e,t){t=p(t).children("span").clone();i.prepend("",t)}),p(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||p(a).find(".breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0
p(a).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),p(this).hasClass("selected")&&!p(this).hasClass("disabled")?(p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-destination").val(""),p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-selected-id").val("0"),p(a).find(".location-folder-list li.is_active").length?p(a).find(".bb-folder-selected-id").val(p(a).find(".location-folder-list li.is_active").attr("data-id")):p(a).find(".bb-folder-selected-id").val("0")):(p(this).closest(".location-folder-list-wrap-main").find(".location-folder-list li span").removeClass("selected"),p(this).addClass("selected"),p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-destination").val(p(this).text()),p(this).closest(".location-folder-list-wrap-main").find(".bb-folder-selected-id").val(p(this).parent().attr("data-id"))),p(this).closest(".location-folder-list-wrap").find(".location-folder-title").text(p(this).siblings("span").text()).siblings(".location-folder-back").css("display","inline-block"),p(this).siblings("ul").show().siblings("span, i").hide().parent().siblings().hide(),p(this).siblings("ul").children("li").show().children("span,i").show(),p(this).closest(".is_active").removeClass("is_active"),p(a).find("li.is_active").removeClass("is_active"),p(this).parent().addClass("is_active"),p(a).find(".bb-folder-selected-id").val(p(a).find(".location-folder-list li.is_active").attr("data-id")),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").each(function(){p(this).show()}),o===p(a).find(".breadcrumbs-append-ul-li .item > span[data-id]").last().attr("data-id")&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled")),setTimeout(function(){p(a).closest(".bb-activity-media-wrap").find(".bb-activity-media-elem.document-activity").attr("data-parent-id")===(p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").prev():p(a).find(".breadcrumbs-append-ul-li .item > span:last-child")).attr("id")&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled"))},100)}),p(document).on("click",a+" .breadcrumbs-append-ul-li .item span",function(e){var t,i;p(this).parent().hasClass("is-disabled")||p(this).hasClass("more_options")||(t=p(e.currentTarget).attr("data-id"),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(p(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),p(a).find(".bb-folder-selected-id").val(t),p(a).find(".location-folder-list li").hide(),p(a).find(".location-folder-list li.is_active").removeClass("is_active"),p(a).find(".location-folder-list li > span.selected").removeClass("selected"),p(a).find('.location-folder-list li[data-id="'+t+'"]').addClass("is_active").children("span").addClass("selected"),p(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),p(a).find(".location-folder-list li.is_active").children("ul").length&&!p(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):p(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?p(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),"0"===t&&(p(a).find(".location-folder-list").children("li").show().children("span,i").show(),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(BP_Nouveau.media.target_text),p(a).find(".location-folder-back").hide()),p(e.currentTarget).nextAll().remove(),o===p(a).find(".breadcrumbs-append-ul-li .item > span[data-id]").last().attr("data-id")&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled")),e=p(a).find(".location-folder-list .is_active > span"),i=p(''),e.parents("li").each(function(e,t){t=p(t).children("span").clone();i.prepend("",t)}),p(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")),0===p(a).find('.breadcrumbs-append-ul-li .breadcrumb .item > span[data-id="'+t+'"]').length&&p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item").append(p(a).find('.location-folder-list li[data-id="'+t+'"]').children("span").clone()),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").length||p(a).find(".breadcrumbs-append-ul-li .breadcrumb").find(".item").append(''),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(a).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(a).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))}),p(a).find(".bb-folder-selected-id").val(t))})),p(a).find(".location-folder-list li").each(function(){p(this).children("ul").parent().addClass("has-ul").append('')}),p(a).hasClass("bp-media-move-folder")&&(p(a).find(".location-folder-list li>span").removeClass("is-disabled"),p(a).find('.location-folder-list li>span[id="'+p(a).find(".bp-folder-move").attr("id")+'"]').parent().addClass("is-disabled")),e=p(a).find(".bp-folder-move").attr("id"),0==p(a).find('.location-folder-list li[data-id="'+e+'"]').siblings().length&&p(a).find('.location-folder-list li[data-id="'+e+'"]').parent("ul").addClass("no-folder-list a"),o&&(p(a).find(".location-folder-list li").hide(),p(a).find(".location-folder-list li.is_active").removeClass("is_active"),p(a).find('.location-folder-list li[data-id="'+o+'"]').addClass("is_active"),p(a).find(".location-folder-list li.is_active").parents(".has-ul").show().children("ul").show().siblings("span,i").hide(),p(a).find(".location-folder-list li.is_active").children("ul").length&&!p(a).find(".location-folder-list li.is_active").children("ul").hasClass("no-folder-list")?setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("ul").show().children("li").show().children("span,i").show().closest("ul").siblings("span, i").hide()},100):p(a).find(".location-folder-list li.is_active").hasClass("has-ul").length?p(a).find(".location-folder-list li.is_active").children("span,i").hide().parent().children("ul").show().children("li").show():setTimeout(function(){p(a).find(".location-folder-list li.is_active").show().children("span").show().parent().siblings("li").show().children("span,i").show()},10),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(p(a).find(".location-folder-list li.is_active").closest(".has-ul").children("span").text()).siblings(".location-folder-back").css("display","inline-block"),p(a).find(".bb-folder-selected-id").val(p(a).find(".location-folder-list li.is_active").attr("data-id")),p(a).find('.location-folder-list li[data-id="'+e+'"]').children().hide()),"0"===o&&(p(a).find(".location-folder-list").children("li").show(),p(a).find(".location-folder-list-wrap").find(".location-folder-title").text(BP_Nouveau.media.target_text),p(a).find(".location-folder-back").hide()),setTimeout(function(){var e=0,e=(p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").hasClass("hidden")?p(a).find(".breadcrumbs-append-ul-li .item > span:last-child").prev():p(a).find(".breadcrumbs-append-ul-li .item > span:last-child")).attr("id");o===parseInt(e)&&(p(a).hasClass("bp-media-move-file")||p(a).hasClass("bp-media-move-folder"))?(p(a).find(".bp-document-move").addClass("is-disabled"),p(a).find(".bp-folder-move").addClass("is-disabled")):(p(a).find(".bp-document-move").removeClass("is-disabled"),p(a).find(".bp-folder-move").removeClass("is-disabled"))},100),e=p(a).find(".location-folder-list .is_active > span"),i=p(''),e.parents("li").each(function(e,t){t=p(t).children("span").clone();i.prepend("",t)}),p(a).find(".breadcrumbs-append-ul-li .breadcrumb").html(i.prepend(''+BP_Nouveau.media.target_text+"")))},clearFolderLocationUI:function(e){e=jQuery(e.currentTarget).closest(".has-folderlocationUI");0 ul > li.selected").data("bp-scope")||bp.Nouveau.inject("#media-stream ul.media-list",e.data.media,"prepend"),p("#buddypress #bp-media-single-album").length||(e.data.media_personal_count&&(0 '+e.data.media_personal_count+" "+t)):p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").length?p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a span.count").text(e.data.media_personal_count):"1"===BP_Nouveau.bb_enable_content_counts&&((a=document.createElement("span")).setAttribute("class","count"),o=document.createTextNode(e.data.media_personal_count),a.appendChild(o),p("#buddypress").find(".bp-wrap .users-nav ul li#media-personal-li a").append(a))),e.data.media_group_count&&(0
'+e.data.media_group_count+" "+t)):p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").length?p("#buddypress").find(".bp-wrap .groups-nav ul li#photos-groups-li a span.count").text(e.data.media_group_count):"1"===BP_Nouveau.bb_enable_content_counts&&((o=document.createElement("span")).setAttribute("class","count"),a=document.createTextNode(e.data.media_group_count),o.appendChild(a),p("#buddypress").find(".bp-wrap .users-nav ul li#photos-groups-li a").append(o))),"yes"===BP_Nouveau.media.is_media_directory&&(0
ul > li.selected").data("bp-scope"))?a=e.data.media_all_count:"personal"===o?a=e.data.media_personal_count:"groups"===o&&(a=e.data.media_group_count),t=BP_Nouveau.dir_labels.hasOwnProperty("media")?1===a?BP_Nouveau.dir_labels.media.singular:BP_Nouveau.dir_labels.media.plural:"",p("#buddypress .bb-item-count").html(''+a+" "+t)):(p("#buddypress").find(".media-type-navs ul.media-nav li#media-all a span.count").text(e.data.media_all_count),p("#buddypress").find(".media-type-navs ul.media-nav li#media-personal a span.count").text(e.data.media_personal_count),p("#buddypress").find(".media-type-navs ul.media-nav li#media-groups a span.count").text(e.data.media_group_count)))),void 0!==e.data.album_total_count&&s.updateAlbumCounts(e.data);for(var i=0;i
").addClass("media-list item-list bp-list bb-photo-list grid")),0 ").addClass("display")),p("#media-stream div").attr("id","media-folder-document-data-table"),p(".bb-photos-actions").show()),p(".document-data-table-head").length?"yes"===BP_Nouveau.media.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(p(document).find("li#document-personal a").trigger("click"),p(document).find("li#document-personal").trigger("click")):r&&bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"):location.reload(!0),p("#bp-media-post-content").val("");for(var t=0;t
]+/g.exec(e.val())),d=Boolean(d);if(""===p.trim(e.val())||d)return e.addClass("error"),!1;if(e.removeClass("error"),!a.group_id&&""===p.trim(o.val()))return o.addClass("error"),!1;o.removeClass("error"),i.prop("disabled",!0).addClass("loading");d={action:"document_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:e.val().trim(),privacy:o.val(),album_id:a.current_folder,group_id:a.current_group_id};p(".bb-single-album-header .bp-feedback").remove(),p("#boss-media-create-album-popup .bp-feedback").remove(),p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:d,success:function(e){setTimeout(function(){i.prop("disabled",!1)},500),e.success?(a.closeFolderUploader(t),p(".document-data-table-head").length?"yes"===BP_Nouveau.media.is_document_directory&&"groups"===bp.Nouveau.getStorage("bp-document").scope?(p(document).find("li#document-personal a").trigger("click"),p(document).find("li#document-personal").trigger("click")):(bp.Nouveau.inject("#media-stream div#media-folder-document-data-table",e.data.document,"prepend"),jQuery(window).scroll()):location.reload(!0)):alert(e.data.feedback.replace("'","'"))}})},saveChildFolder:function(t){var e=p(t.currentTarget),i=this,a=p("#bp-media-create-child-folder #bb-album-child-title"),o=(t.preventDefault(),/[\\/?%*:|"<>]+/g.exec(a.val())),o=Boolean(o);if(""===p.trim(a.val())||o)return a.addClass("error"),!1;a.removeClass("error"),e.prop("disabled",!0).addClass("loading");o={action:"document_child_folder_save",_wpnonce:BP_Nouveau.nonces.media,title:a.val(),folder_id:i.current_folder,group_id:i.current_group_id};p(".bb-single-album-header .bp-feedback").remove(),p("#boss-media-create-album-popup .bp-feedback").remove(),p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:o,success:function(e){e.success?(i.closeChildFolderUploader(t),location.reload(!0)):alert(e.data.feedback.replace("'","'"))}})},renameChildFolder:function(e){e.preventDefault();var t=p(e.currentTarget),i=this,e=p("#bp-media-edit-child-folder #bb-album-child-title"),a=p("#bp-media-edit-child-folder #bb-folder-privacy"),o=this.currentTargetParent,d=/[\\/?%*:|"<>]+/g.exec(e.val()),d=Boolean(d);if(""===p.trim(e.val())||d)return e.addClass("error"),!1;e.removeClass("error"),t.prop("disabled",!0).addClass("loading");d={action:"document_edit_folder",_wpnonce:BP_Nouveau.nonces.media,title:e.val(),privacy:a.val(),id:o,group_id:i.current_group_id};p(".bb-single-album-header .bp-feedback").remove(),p("#boss-media-create-album-popup .bp-feedback").remove(),p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:d,success:function(e){setTimeout(function(){t.prop("disabled",!1)},500),e.success?window.location.reload(!0):i.current_folder?p("#bp-media-single-album").prepend(e.data.feedback):p("#boss-media-create-album-popup .bb-model-header").after(e.data.feedback)}})},deleteAlbum:function(t){if(t.preventDefault(),!this.album_id)return!1;if(!confirm(BP_Nouveau.media.i18n_strings.album_delete_confirm))return!1;p(t.currentTarget).prop("disabled",!0);var e={action:"media_album_delete",_wpnonce:BP_Nouveau.nonces.media,album_id:this.album_id,group_id:this.group_id};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){e.success?window.location.href=e.data.redirect_url:(alert(BP_Nouveau.media.i18n_strings.album_delete_error),p(t.currentTarget).prop("disabled",!1))}})},deleteFolder:function(t){if(t.preventDefault(),!BP_Nouveau.media.current_folder)return!1;if(!confirm(BP_Nouveau.media.i18n_strings.folder_delete_confirm))return!1;p(t.currentTarget).prop("disabled",!0);var e={action:"document_folder_delete",_wpnonce:BP_Nouveau.nonces.media,folder_id:BP_Nouveau.media.current_folder,group_id:BP_Nouveau.media.current_group_id};p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){e.success?window.location.href=e.data.redirect_url:(alert(BP_Nouveau.media.i18n_strings.folder_delete_error),p(t.currentTarget).prop("disabled",!1))}})},addMediaIdsToGroupMessagesForm:function(){p("#bp_group_messages_media").length&&p("#bp_group_messages_media").val(JSON.stringify(this.dropzone_media))},addDocumentIdsToGroupMessagesForm:function(){p("#bp_group_messages_document").length&&p("#bp_group_messages_document").val(JSON.stringify(this.dropzone_media))},addVideoIdsToGroupMessagesForm:function(){p("#bp_group_messages_video").length&&p("#bp_group_messages_video").val(JSON.stringify(this.dropzone_media))},injectMedias:function(t){var i,a,e,o=bp.Nouveau.getStorage("bp-media"),d=o.scope||null,o=o.filter||null;p(t.currentTarget).hasClass("load-more")&&(i=+Number(this.current_page)+1,a=this,e="",t.preventDefault(),p(t.currentTarget).find("a").first().addClass("loading"),p("#buddypress .dir-search input[type=search]").length&&(e=p("#buddypress .dir-search input[type=search]").val()),bp.Nouveau.objectRequest({object:"media",scope:d,filter:o,search_terms:e,page:i,method:"append",target:"#buddypress [data-bp-list] ul.bp-list"}).done(function(e){!0===e.success&&(p(t.currentTarget).remove(),a.current_page=i,jQuery(window).scroll())}))},injectDocuments:function(e){var t,i,a,o=bp.Nouveau.getStorage("bp-document"),d="",s="",n=o.scope||null,r=o.filter||null,l=p(e.currentTarget);l.hasClass("load-more")&&(t=+Number(this.current_page)+1,i=this,a="",e.preventDefault(),l.find("a").first().addClass("loading"),p("#buddypress .dir-search input[type=search]").length&&(a=p("#buddypress .dir-search input[type=search]").val()),s=this.order_by&&this.sort_by?(d=this.sort_by,this.order_by):void 0!==o.extras?(d=o.extras.sort,o.extras.orderby):(d="ASC","title"),bp.Nouveau.objectRequest({object:"document",scope:n,filter:r,search_terms:a,page:t,method:"append",target:"#buddypress [data-bp-list] div#media-folder-document-data-table",order_by:s,sort:d}).done(function(e){!0===e.success&&(l.parent(".pager").remove(),i.current_page=t,jQuery(window).scroll())}))},sortDocuments:function(e){var t=p(e.currentTarget),i=t.data("target"),a="",o="date_created";t.attr("class");switch(i){case"name":o="title";break;case"modified":o="date_modified";break;case"visibility":o="privacy";break;case"group":o="group_id"}t.hasClass("asce")?t.removeClass("asce"):t.addClass("asce");var i=t.hasClass("asce")?"DESC":"ASC",t=(bp.Nouveau.getStorage("bp-document"),{}),t=(t.orderby=o,t.sort=i,"group"!==o&&bp.Nouveau.setStorage("bp-document","extras",t),bp.Nouveau.getStorage("bp-document")),d=t.scope||null,t=t.filter||null;p(e.currentTarget);p("#buddypress .bp-dir-search-form input[type=search]").length&&(a=p("#buddypress .bp-dir-search-form input[type=search]").val()),this.sort_by=i,this.order_by=o,this.current_page=1,bp.Nouveau.objectRequest({object:"document",scope:d,filter:t,search_terms:a,page:1,order_by:o,sort:i,method:"reset",target:"#buddypress [data-bp-list]"}).done()},documentPopupNavigate:function(e){e.preventDefault();var e=p(e.currentTarget),t=e.closest(".bb-field-steps"),i=0==e.closest(".bp-document-listing").length?"#bb-album-child-title":"#bb-album-title";e.closest(".document-options").length&&(i="#bb-album-title"),e.hasClass("bb-field-steps-next")&&""==t.find(i).val().trim()?t.find(i).addClass("error"):(t.find(i).removeClass("error"),t.slideUp(200).siblings(".bb-field-steps").slideDown(200))},uploadDocumentNavigate:function(e){e.preventDefault();var e=p(e.currentTarget),t=p(e).closest("#bp-media-uploader");p(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-document-submit, #bp-media-document-prev, .bp-document-open-create-popup-folder, #bb-document-privacy").show(),0!==Number(p(t).find(".bb-folder-selected-id"))&&p(t).find(".location-folder-list li.is_active").length&&p(t).find(".location-folder-list").scrollTop(p(t).find(".location-folder-list li.is_active").offset().top-p(t).find(".location-folder-list").offset().top),p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span:not(.hidden)").each(function(e){0 p(t).find(".breadcrumbs-append-ul-li .breadcrumb").width()&&(p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span.hidden").append(p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(2)),p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item .more_options").length||p('...').insertAfter(p(t).find(".breadcrumbs-append-ul-li .breadcrumb .item span").eq(0)))})):(p(e).hide(),t.find("#bp-media-document-prev, .bp-document-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-folder").length&&p("#bb-document-privacy").hide())},uploadMediaNavigate:function(e){e.preventDefault();var e=p(e.currentTarget),t=p(e).closest(".bp-media-photo-uploader");p(e).hasClass("bb-field-uploader-next")?(t.find(".bb-field-steps-1").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.find("#bp-media-submit, #bp-media-prev, .bp-media-open-create-popup-folder.create-album").show(),t.find("#bb-media-privacy").show(),0!==Number(p(t).find(".bb-album-selected-id"))&&p(t).find(".location-album-list li.is_active").length&&p(t).find(".location-album-list").scrollTop(p(t).find(".location-album-list li.is_active").offset().top-p(t).find(".location-album-list").offset().top)):(p(e).hide(),t.find("#bp-media-prev, .bp-media-open-create-popup-folder").hide(),t.find(".bb-field-steps-2").slideUp(200).siblings(".bb-field-steps").slideDown(200),t.closest("#bp-media-single-album").length&&p("#bb-media-privacy").hide())},appendMedia:function(t){var i,a,e,o=bp.Nouveau.getStorage("bp-media"),d=o.scope||null,o=o.filter||null;p(t.currentTarget).hasClass("load-more")&&(i=+Number(this.current_page_existing_media)+1,a=this,e="",t.preventDefault(),p(t.currentTarget).find("a").first().addClass("loading"),p("#buddypress .dir-search input[type=search]").length&&(e=p("#buddypress .dir-search input[type=search]").val()),bp.Nouveau.objectRequest({object:"media",scope:d,filter:o,search_terms:e,page:i,method:"append",caller:"bp-existing-media",target:".bp-existing-media-wrap ul.bp-list"}).done(function(e){!0===e.success&&(p(t.currentTarget).remove(),a.current_page_existing_media=i,jQuery(window).scroll())}))},appendAlbums:function(t){var i=+Number(this.current_page_albums)+1,a=this,e=(t.preventDefault(),p(t.currentTarget).find("a").first().addClass("loading"),{action:"media_albums_loader",_wpnonce:BP_Nouveau.nonces.media,page:i});p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:e,success:function(e){!0===e.success&&(p(t.currentTarget).remove(),p("#albums-dir-list ul.bb-albums-list").fadeOut(100,function(){p("#albums-dir-list ul.bb-albums-list").append(e.data.albums),p(this).fadeIn(100)}),a.current_page_albums=i)}})},toggleSubmitMediaButton:function(){var e=p("#bp-media-submit"),t=p("#bp-media-add-more");"bp-dropzone-content"===this.current_tab?this.dropzone_obj.getAcceptedFiles().length?(e.show(),t.show()):(e.hide(),t.hide()):"bp-existing-media-content"===this.current_tab&&(p('.bp-existing-media-wrap .bb-media-check-wrap [name="bb-media-select"]:checked').length?e.show():e.hide(),t.hide())},playVideo:function(e){e.preventDefault();var t=p(e.currentTarget).find("video").get(0),e=p(e.currentTarget).find(".gif-play-button");1==t.paused?(t.play().catch(function(e){console.debug("GIF play failed:",e)}),e.hide()):(t.pause(),e.show())},isElementInScrollableContainer:function(e){var t=p(e),e=e.getBoundingClientRect(),i=t.closest("#bp-message-thread-list");return(i=(i=i.length?i:t.closest(".bb-modal-activity-body")).length?i:t.closest(".bb-media-model-container .activity-list .activity-item")).length?(i=i[0].getBoundingClientRect(),e.bottom>i.top&&e.top i.left&&e.left '),p(t).text());return p(t).text(BP_Nouveau.media.copy_to_clip_board_text),p("#"+e).val(p(t).attr("href")),p("#"+e).select(),document.execCommand("copy"),setTimeout(function(){p(t).text(i)},2e3),!1},fileActivityActionButton:function(e){e.preventDefault(),p(e.currentTarget).parent().hasClass("copy_download_file_url")||(p(e.currentTarget).closest(".bb-activity-media-elem").toggleClass("is-visible").siblings().removeClass("is-visible").closest(".activity-item").siblings().find(".bb-activity-media-elem").removeClass("is-visible"),p(e.currentTarget).closest(".bb-activity-media-elem").find(".bb_more_dropdown").toggleClass("open").closest(".bb-activity-media-elem").siblings().find(".bb_more_dropdown").removeClass("open").closest(".activity-item").siblings().find(".bb-activity-media-elem .bb_more_dropdown").removeClass("open"),p("body").addClass("document_more_option_open"),p(e.currentTarget).closest(".bb-activity-media-elem").length<1&&(p(e.currentTarget).closest(".bb-photo-thumb").toggleClass("is-visible").parent().siblings().find(".bb-photo-thumb").removeClass("is-visible").removeClass("is-visible"),p(e.currentTarget).closest(".bb-photo-thumb").find(".bb_more_dropdown").toggleClass("open").closest(".bb-photo-thumb").parent().siblings().find(".bb-photo-thumb .bb_more_dropdown").removeClass("open")),"a"!=e.currentTarget.tagName.toLowerCase())||p(e.currentTarget).hasClass("document-action_more")||p(e.currentTarget).hasClass("media-action_more")||(p(e.currentTarget).closest(".bb-activity-media-elem").removeClass("is-visible").find(".bb_more_dropdown").removeClass("open"),p(e.currentTarget).closest(".bb-photo-thumb").removeClass("is-visible").find(".bb_more_dropdown").removeClass("open"))},toggleFileActivityActionButton:function(e){var t;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),!0===e.altKey||!0===e.metaKey||p(t).hasClass("document-action_more")||p(t).parent().hasClass("document-action_more")||p(t).hasClass("media-folder_action__anchor")||p(t).parent().hasClass("media-folder_action__anchor")||p(t).hasClass("media-action_more")||p(t).parent().hasClass("media-action_more")||p(t).hasClass("video-action_more")||p(t).parent().hasClass("video-action_more")?e:(p(".bb-activity-media-elem.is-visible").removeClass("is-visible"),p(".media-folder_items.is-visible").removeClass("is-visible"),p(".bb-photo-thumb.is-visible").removeClass("is-visible"),p(".bb-item-thumb.is-visible").removeClass("is-visible"),p(".bb-activity-video-elem.is-visible").removeClass("is-visible"),p(".video-action-wrap.item-action-wrap.is-visible").removeClass("is-visible"),p(".video-action-wrap .bb_more_dropdown").removeClass("open"),p(".bb-activity-media-elem .bb_more_dropdown").removeClass("open"),p(".bb-photo-thumb .bb_more_dropdown").removeClass("open"),p(".media-folder_items .bb_more_dropdown").removeClass("open"),void p("body").removeClass("document_more_option_open video_more_option_open item_more_option_open"))},toggleCodePreview:function(e){e.preventDefault(),p(e.currentTarget).closest(".document-activity").toggleClass("code-full-view")},documentCodeMirror:function(){p(".document-text:not(.loaded)").each(function(){var e=p(this),t=e.attr("data-extension"),i=e.attr("data-extension");"html"!=t&&"htm"!=t||(i="text/html"),"js"==t?CodeMirror(e[0],{value:e.find(".document-text-file-data-hidden").val(),lineNumbers:!0,theme:"default",readOnly:!0,lineWrapping:!0}):CodeMirror(e[0],{value:e.find(".document-text-file-data-hidden").val(),mode:i,lineNumbers:!0,theme:"default",readOnly:!0,lineWrapping:!0}),e.addClass("loaded"),150 '+e+" "+t)):(t=p(".single-screen-navs.groups-nav").find("ul li#albums-groups-li"),0 '+e+"")))}},bp.Nouveau.Media.Theatre={start:function(){this.setupGlobals(),this.addListeners()},setupGlobals:function(){this.bodySelector=p("body"),this.medias=[],this.documents=[],this.current_media=!1,this.current_document=!1,this.current_index=0,this.current_document_index=0,this.is_open_media=!1,this.is_open_document=!1,this.nextLink=p(".bb-next-media"),this.nextDocumentLink=p(".bb-next-document"),this.previousDocumentLink=p(".bb-prev-document"),this.previousLink=p(".bb-prev-media"),this.activity_ajax=!1,this.group_id=void 0!==BP_Nouveau.media.group_id&&BP_Nouveau.media.group_id,this.manage_media=void 0!==BP_Nouveau.media.can_manage_media&&BP_Nouveau.media.can_manage_media,this.manage_document=void 0!==BP_Nouveau.media.can_manage_document&&BP_Nouveau.media.can_manage_document},addListeners:function(){p(document).on("click",".bb-open-media-theatre",this.openTheatre.bind(this)),p(document).on("click",".bb-open-document-theatre",this.openDocumentTheatre.bind(this)),p(document).on("click",".document-detail-wrap-description-popup",this.openDocumentTheatre.bind(this)),p(document).on("click",".bb-close-media-theatre",this.closeTheatre.bind(this)),p(document).on("click",".bb-close-document-theatre",this.closeDocumentTheatre.bind(this)),p(document).on("click",".bb-prev-media",this.previous.bind(this)),p(document).on("click",".bb-next-media",this.next.bind(this)),p(document).on("click",".bb-prev-document",this.previousDocument.bind(this)),p(document).on("click",".bb-next-document",this.nextDocument.bind(this)),p(document).on("bp_activity_ajax_delete_request",this.activityDeleted.bind(this)),p(document).on("click","#bb-media-model-container .media-privacy>li",this.mediaPrivacyChange.bind(this)),p(document).on("click","#bb-media-model-container .document-privacy>li",this.documentPrivacyChange.bind(this)),p(document).on("click","#bb-media-model-container .bb-media-section span.privacy",bp.Nouveau,this.togglePrivacyDropdown.bind(this)),p(document).on("click","#bb-media-model-container .bb-document-section span.privacy",bp.Nouveau,this.toggleDocumentPrivacyDropdown.bind(this)),p(document).on("click",".bp-add-media-activity-description",this.openMediaActivityDescription.bind(this)),p(document).on("click","#bp-activity-description-new-reset",this.closeMediaActivityDescription.bind(this)),p(document).on("keyup",".bp-edit-media-activity-description #add-activity-description",this.MediaActivityDescriptionUpdate.bind(this)),p(document).on("click","#bp-activity-description-new-submit",this.submitMediaActivityDescription.bind(this)),p(document).click(this.togglePopupDropdown),document.addEventListener("keyup",this.checkPressedKeyDocuments.bind(this)),document.addEventListener("keyup",this.checkPressedKey.bind(this))},checkPressedKey:function(e){var t=this;if(e=e||window.event,!t.is_open_media)return!1;var i=p(e.target).hasClass("ac-input")||"add-activity-description"===p(e.target).attr("id");switch(e.keyCode){case 27:t.closeTheatre(e);break;case 37:if(void 0===t.medias[t.current_index-1]||i)return!1;t.previous(e);break;case 39:if(void 0===t.medias[t.current_index+1]||i)return!1;t.next(e)}},checkPressedKeyDocuments:function(e){e=e||window.event;var t=this;if(!t.is_open_document)return!1;var i=p(e.target).hasClass("ac-input")||"add-activity-description"===p(e.target).attr("id");switch(e.keyCode){case 27:t.closeDocumentTheatre(e);break;case 37:if(void 0===t.documents[t.current_document_index-1]||i)return!1;t.previousDocument(e);break;case 39:if(void 0===t.documents[t.current_document_index+1]||i)return!1;t.nextDocument(e)}},openTheatre:function(e){e.preventDefault();var e=p(e.currentTarget),t=this;if(e.closest("#bp-existing-media-content").length)return!1;t.setupGlobals(),t.setMedias(e),i=e.data("id"),e.data("activity-id"),t.setCurrentMedia(i),t.showMedia(),t.navigationCommands(),t.getParentActivityHtml(e),t.getMediasDescription(),p(".bb-media-model-wrapper.document").hide();var i=document.getElementById(p(".bb-media-model-wrapper.video video").attr("id"));i&&i.pause(),p(".bb-media-model-wrapper.video").hide(),p(".bb-media-model-wrapper.media").show(),bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay"),t.is_open_media=!0,t.bodySelector.addClass("media-modal-open"),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)},getParentActivityHtml:function(e){var t=p("#hidden_parent_id").val(),e=e.closest(".bb-media-model-wrapper").find("#bb-media-model-container .activity-list li.activity-item").data("bp-activity-id");parseInt(t)===parseInt(e)&&(e=p('#bb-media-model-container [data-bp-activity-id="'+t+'"]'),p('[data-bp-activity-id="'+t+'"] > .activity-state').html(p(e).find(".activity-state").html()),p('[data-bp-activity-id="'+t+'"] > .activity-meta').html(p(e).find(".activity-meta").html()),p('[data-bp-activity-id="'+t+'"] > .activity-comments').html(p(e).find(".activity-comments").html())),p("#hidden_parent_id").length&&p("#hidden_parent_id").remove()},getMediasDescription:function(){var e=this,t=(p(".bb-media-info-section .activity-list").addClass("loading").html(''),0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_media.activity_id+'"] .activity-comments'));t.length&&(t=t.find("#ac-form-"+e.current_media.activity_id),e.current_media.parent_activity_comments=!0,t.remove()),!0===e.current_media.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"media_get_media_description",id:e.current_media.id,attachment_id:e.current_media.attachment_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success?(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.description),p(".bb-media-info-section:visible").show(),bp.Nouveau.Media.Theatre.syncPinPostIconToTheatre(),p(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10)):p(".bb-media-info-section.media").hide()}})},openDocumentTheatre:function(e){e.preventDefault();var t=p(e.currentTarget),i=this;if(t.closest("#bp-existing-document-content").length)return!1;t.closest(".document.document-theatre").length&&i.closeDocumentTheatre(e),a=t.data("id"),i.setupGlobals(),i.setDocuments(t),i.setCurrentDocument(a),i.showDocument(),i.navigationDocumentCommands(),i.getParentActivityHtml(t),i.getDocumentsDescription(),-1!==p.inArray(i.current_document.extension,BP_Nouveau.document.mp3_preview_extension.split(","))&&p(e.currentTarget).closest(".bb-activity-media-elem.document-activity").length&&p(e.currentTarget).closest(".bb-activity-media-elem.document-activity").find(".document-audio-wrap").length&&p(e.currentTarget).closest(".bb-activity-media-elem.document-activity").find(".document-audio-wrap audio")[0].pause(),p(".bb-media-model-wrapper.media").hide(),p(".bb-media-model-wrapper.document").show();var a=document.getElementById(p(".bb-media-model-wrapper.video video").attr("id"));a&&(a.pause(),a.src=""),p(".bb-media-model-wrapper.video").hide(),i.is_open_document=!0,i.bodySelector.addClass("document-modal-open"),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("setupMediaModalGifAutoplay")},500)},resetRemoveActivityCommentsData:function(){var e,t=this,i=!1,a=!1,o=!1,d=!1,s=!1,n=!1;t.current_media.parent_activity_comments&&((i=(d=p('.bb-media-model-wrapper.media [data-bp-activity-id="'+t.current_media.activity_id+'"]')).find(".activity-comments")).length&&(e=i.find("#ac-form-"+t.current_media.activity_id),this.purgeEditActivityForm(e),e.find("#ac-input-"+t.current_media.activity_id).html(""),e.removeClass("has-content has-gif has-media").addClass("root"),i.append(e),e.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(t.current_media.activity_id),i.find(".acomment-display").removeClass("display-focus"),i.find(".comment-item").removeClass("comment-item-focus"),s=i.html(),n=i.attr("class"),i.remove(),(i=p('[data-bp-activity-id="'+t.current_media.activity_id+'"] .activity-comments')).length)&&(i.attr("class",n),0===i.find("#ac-form-"+t.current_media.activity_id).length)&&(i.append(e),i.children("form").removeClass("events-initiated").addClass("not-initialized")),(o=d.find(".activity-state")).length&&(s=o.html(),n=o.attr("class"),o.remove(),(o=p('[data-bp-activity-id="'+t.current_media.activity_id+'"] .activity-state')).length)&&(o.html(s),o.attr("class",n)),(a=d.find(".activity-meta")).length&&(s=a.html(),n=a.attr("class"),a.remove(),(a=p('[data-bp-activity-id="'+t.current_media.activity_id+'"] > .activity-meta')).length)&&(a.html(s),a.attr("class",n)),d.remove()),t.current_document.parent_activity_comments&&((i=(d=p('.bb-media-model-wrapper.document [data-bp-activity-id="'+t.current_document.activity_id+'"]')).find(".activity-comments")).length&&(e=i.find("#ac-form-"+t.current_document.activity_id),this.purgeEditActivityForm(e),e.find("#ac-input-"+t.current_document.activity_id).html(""),e.removeClass("has-content has-gif has-media").addClass("root"),i.append(e),e.find(".post-elements-buttons-item.post-emoji").removeClass("active").empty(""),this.resetActivityMedia(t.current_document.activity_id),i.find(".acomment-display").removeClass("display-focus"),i.find(".comment-item").removeClass("comment-item-focus"),s=i.html(),n=i.attr("class"),i.remove(),(i=p('[data-bp-activity-id="'+t.current_document.activity_id+'"] .activity-comments')).length)&&(i.attr("class",n),0===i.find("#ac-form-"+t.current_document.activity_id).length&&(i.append(e),i.children("form").removeClass("events-initiated").addClass("not-initialized")),i.find(".document-text.loaded").removeClass("loaded").find(".CodeMirror").remove(),jQuery(window).scroll()),(o=d.find(".activity-state")).length&&(s=o.html(),n=o.attr("class"),o.remove(),(o=p('[data-bp-activity-id="'+t.current_document.activity_id+'"] .activity-state')).length)&&(o.html(s),o.attr("class",n)),(a=d.find(".activity-meta")).length&&(s=a.html(),n=a.attr("class"),a.remove(),(a=p('[data-bp-activity-id="'+t.current_document.activity_id+'"] > .activity-meta')).length)&&(a.html(s),a.attr("class",n)),d.remove()),bp.Nouveau.reportPopUp(),bp.Nouveau.reportActions()},closeTheatre:function(e){e.preventDefault();var t=this,e=p(e.currentTarget);if(p(e).closest(".bb-media-model-wrapper").hasClass("video-theatre"))return!1;p(".bb-media-model-wrapper.media .bb-media-section").find("img").attr("src",""),p(".bb-media-model-wrapper.video .bb-media-section").find("video").length&&videojs(p(".bb-media-model-wrapper.video .bb-media-section").find("video").attr("id")).reset(),p(".bb-media-model-wrapper").hide(),t.is_open_media=!1,t.syncPinPostActivityOnCloseTheatre(e),t.resetRemoveActivityCommentsData(),t.current_media=!1,t.getParentActivityHtml(e),t.bodySelector.removeClass("media-modal-open")},closeDocumentTheatre:function(e){e.preventDefault();var t=this,i=p(document).find(".document-theatre");i.find(".bb-media-section").removeClass("bb-media-no-preview").find(".document-preview").html(""),p(".bb-media-info-section.document").show(),i.hide(),t.is_open_document=!1,t.resetRemoveActivityCommentsData(),t.current_document=!1,t.getParentActivityHtml(p(e.currentTarget)),t.bodySelector.removeClass("document-modal-open")},setMedias:function(e){var t=p(".bb-open-media-theatre"),i=0;if(void 0!==(t=p("body").hasClass("activity")?p(e).closest(".bb-activity-media-wrap").find(".bb-open-media-theatre"):t))for(this.medias=[],i=0;i
'),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html(" "+i+'
'),o.find(".bb-document-section .document-preview .document-text").attr("data-extension",d),t=o.find(".bb-document-section .document-preview .document-text textarea"),"html"===d||"htm"===d?t.val(s):t.html(s),setTimeout(function(){bp.Nouveau.Media.documentCodeMirror()},1e3)):-1!==p.inArray(e.current_document.extension,BP_Nouveau.document.mp3_preview_extension.split(","))?(o.find(".bb-document-section .document-preview").html(''),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html('')):-1!==p.inArray("."+e.current_document.extension,BP_Nouveau.video.video_type.split(","))?(o.find(".bb-document-section").addClass("bb-video-preview"),o.find(".bb-document-section .document-preview").html(''),o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),"mov"===e.current_document.extension||"m4v"===e.current_document.extension?o.find(".bb-document-section .document-preview").html(''):o.find(".bb-document-section .document-preview").html(''),p(window).scroll()):e.current_document.full_preview?(o.find(".bb-document-section").removeClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html("'+i+'
"+i+'
')):(o.find(".bb-document-section").addClass("bb-media-no-preview"),o.find(".bb-document-section .document-preview").html(""),o.find(".bb-document-section .document-preview").html('")),p(".bb-document-section .bb-document-privacy-wrap"));d.length&&(d.show(),d.parent().show(),d.find("ul.document-privacy li").removeClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",""),(t=d.find("ul.document-privacy").find("li[data-value="+e.current_document.privacy+"]")).addClass("selected"),d.find(".bp-tooltip").attr("data-bp-tooltip",t.text()),d.find(".privacy").removeClass("public").removeClass("loggedin").removeClass("onlyme").removeClass("friends").addClass(e.current_document.privacy),void 0!==BP_Nouveau.activity&&void 0!==e.current_document.activity_id&&0!=e.current_document.activity_id||e.group_id||e.current_document.is_forum||e.current_document.group_id||e.current_document.album_id||!e.can_manage_document||!e.current_document.can_edit||e.current_document.is_message)&&d.parent().hide(),e.navigationDocumentCommands()},next:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.medias[e.current_index+1]?(e.current_index=e.current_index+1,e.current_media.activity_id,e.current_media=e.medias[e.current_index],e.showMedia(),e.getMediasDescription(),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):e.nextLink.hide()},previous:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.medias[e.current_index-1]?(e.current_index=e.current_index-1,e.current_media.activity_id,e.current_media=e.medias[e.current_index],e.showMedia(),e.getMediasDescription(),setTimeout(function(){bp.Nouveau.Media.invokeMediaFn("autoPlayGifVideos")},500)):e.previousLink.hide()},nextDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.documents[e.current_document_index+1]?(e.current_document_index=e.current_document_index+1,e.current_document.activity_id,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.nextDocumentLink.hide()},previousDocument:function(e){e.preventDefault();e=this;e.resetRemoveActivityCommentsData(),void 0!==e.documents[e.current_document_index-1]?(e.current_document_index=e.current_document_index-1,e.current_document.activity_id,e.current_document=e.documents[e.current_document_index],e.showDocument(),e.getDocumentsDescription()):e.previousDocumentLink.hide()},navigationCommands:function(){var e=this;0==e.current_index&&e.current_index!=e.medias.length-1?(e.previousLink.hide(),e.nextLink.show()):0==e.current_index&&e.current_index==e.medias.length-1?(e.previousLink.hide(),e.nextLink.hide()):e.current_index==e.medias.length-1?(e.previousLink.show(),e.nextLink.hide()):(e.previousLink.show(),e.nextLink.show())},navigationDocumentCommands:function(){var e=this;0==e.current_document_index&&e.current_document_index!=e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.show()):0==e.current_document_index&&e.current_document_index==e.documents.length-1?(e.previousDocumentLink.hide(),e.nextDocumentLink.hide()):e.current_document_index==e.documents.length-1?(e.previousDocumentLink.show(),e.nextDocumentLink.hide()):(e.previousDocumentLink.show(),e.nextDocumentLink.show())},getActivity:function(){var e=this;p(".bb-media-info-section .activity-list").addClass("loading").html(''),void 0!==BP_Nouveau.activity&&e.current_media&&void 0!==e.current_media.activity_id&&0!=e.current_media.activity_id&&!e.current_media.is_forum?(0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_media.activity_id+'"] .activity-comments').length&&(e.current_media.parent_activity_comments=!0),!0===e.current_media.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"media_get_activity",id:e.current_media.activity_id,group_id:_.isUndefined(e.current_media.group_id)?0:e.current_media.group_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success&&(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.activity),p(".bb-media-info-section:visible").show(),jQuery(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10))}})):p(".bb-media-info-section.media").hide()},getDocumentsActivity:function(){var e=this;p(".bb-media-info-section .activity-list").addClass("loading").html(''),void 0!==BP_Nouveau.activity&&e.current_document&&void 0!==e.current_document.activity_id&&0!=e.current_document.activity_id&&!e.current_document.is_forum?(0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_document.activity_id+'"] .activity-comments').length&&(e.current_document.parent_activity_comments=!0),!0===e.current_document.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"document_get_activity",id:e.current_document.activity_id,group_id:_.isUndefined(e.current_document.group_id)?0:e.current_document.group_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success&&(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.activity),p(".bb-media-info-section:visible").show(),jQuery(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10))}})):p(".bb-media-info-section.document").hide()},getDocumentsDescription:function(){var e=this,t=(p(".bb-media-info-section .activity-list").addClass("loading").html(''),0!=e.activity_ajax&&e.activity_ajax.abort(),p('[data-bp-activity-id="'+e.current_document.activity_id+'"] .activity-comments'));t.length&&(t=t.find("#ac-form-"+e.current_document.activity_id),e.current_document.parent_activity_comments=!0,t.remove()),!0===e.current_document.parent_activity_comments&&p(".bb-media-model-wrapper:last").after(''),e.activity_ajax=p.ajax({type:"POST",url:BP_Nouveau.ajaxurl,data:{action:"document_get_document_description",id:e.current_document.id,attachment_id:e.current_document.attachment_id,nonce:BP_Nouveau.nonces.media},success:function(e){e.success?(p(".bb-media-info-section:visible .activity-list").removeClass("loading").html(e.data.description),p(".bb-media-info-section:visible").show(),bp.Nouveau.Media.Theatre.syncPinPostIconToTheatre(),p(window).scroll(),setTimeout(function(){bp.Nouveau.reportPopUp(),bp.Nouveau.reportedPopup()},10)):p(".bb-media-info-section.document").hide()}})},activityDeleted:function(e,t){var i=this,a=0;if(i.is_open_media&&void 0!==t&&"delete_activity"===t.action&&i.current_media.activity_id==t.id){var o=p(document).find('[data-bp-list="media"] .bb-open-media-theatre[data-id="'+i.current_media.id+'"]'),d=o.parents("ul");for(o.closest("li").remove(),0===d.find("li:not(.load-more)").length&&(0'+i+"
.activity-list").children("#activity-"+i)).length&&e.hasClass("bb-pinned")&&0